Skip to content

Commit

Permalink
Merge branch '21585-codegen' of github.com:howsoai/howso-engine-ts in…
Browse files Browse the repository at this point in the history
…to 21585-codegen
  • Loading branch information
lancegliser committed Oct 2, 2024
2 parents b0706b6 + 402d324 commit 8b1cea5
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
6 changes: 2 additions & 4 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ This major change refactors the client and types for all Howso Engine operations

### Typing Changes

- The `types/models` package has been renamed to `types/schemas`.
- The `types/schemas` types are now autogenerated from the Engine API, and will have a different naming schema across
- Most of all the types are now autogenerated from the Engine API, and will have a different naming schema across
the board. However, most of the type's properties should remain the same.
- `types/shims` have been added as a stop gap for types lost from this migration. These will be transitioned out as
types improve in the Howso Engine API specification.
- The `Trainee` type no longer has a `features` property. Instead use `getFeatureAttributes`
- `Trainee` and `Session` types are exposed from the top level `types` package.
- The `Trainee` type no longer has a `features` property. Instead use `getFeatureAttributes`.

### Client Changes

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ This process can be CPU intensive, you are encouraged to use a web `Worker` if r
#### Through a web Worker

```ts
// @/workers/AmalgamWorker
import { AmalgamWasmService, initRuntime } from "@howso/amalgam-lang";
import wasmDataUri from "@howso/amalgam-lang/lib/amalgam-st.data?url";
import wasmUri from "@howso/amalgam-lang/lib/amalgam-st.wasm?url";
Expand Down Expand Up @@ -86,7 +87,7 @@ const getClient = async (options?: ClientOptions): Promise<HowsoWorkerClient> =>
const fs = new BrowserFileSystem(worker);
const client = new HowsoWorkerClient(worker, fs, {
howsoUrl,
migrationsUrl,
migrationsUrl, // Optional, used for upgrading Trainees saved to disk.
...options,
});
return client.setup();
Expand Down
2 changes: 1 addition & 1 deletion codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Note that by running this utility, files will be added/updated/deleted in the
`src` directory. Once generated, files should then be committed back to the
repository.

Ensure that the Howso Engine caml file located at `src/engine/howso.caml` is
Ensure that the Howso Engine caml file located at `src/assets/howso.caml` is
up to date before generation.

### Generating the code
Expand Down
7 changes: 4 additions & 3 deletions codegen/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface Schema extends BaseSchema {
values?: SchemaType | Schema | Ref;
indices?: Record<string, SchemaType | Schema | Ref>;
dynamic_indices?: Record<string, SchemaType | Schema | Ref>;
additional_indices?: SchemaType | Schema | Ref;
additional_indices?: SchemaType | Schema | Ref | false;
}

export interface LabelDefinition {
Expand All @@ -49,7 +49,7 @@ export interface EngineApi {

export async function getEngineApi(): Promise<EngineApi> {
const handle = "default";
const enginePath = require.resolve("../../src/engine/howso.caml");
const enginePath = require.resolve("../../src/assets/howso.caml");
const dataPath = require.resolve("@howso/amalgam-lang/lib/amalgam-st.data");
const wasmPath = require.resolve("@howso/amalgam-lang/lib/amalgam-st.wasm");

Expand Down Expand Up @@ -101,6 +101,7 @@ export function isSchema(value: SchemaType | Schema | Ref | null | undefined): v
return !isRef(value) && "type" in value && typeof value.type === "string";
}

export function isSchemaOrRef(value: SchemaType | Schema | Ref | null | undefined): value is Schema | Ref {
export function isSchemaOrRef(value: SchemaType | Schema | Ref | boolean | null | undefined): value is Schema | Ref {
if (typeof value === "boolean") return false;
return isRef(value) || isSchema(value);
}
2 changes: 1 addition & 1 deletion codegen/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default {
copy({
targets: [
{
src: ["src/engine/howso.caml"],
src: ["src/assets/howso.caml"],
dest: "./codegen/build",
},
{
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
copy({
targets: [
{
src: ["src/engine/howso.caml", "src/engine/migrations.caml"],
src: ["src/assets/howso.caml", "src/assets/migrations.caml"],
dest: "lib",
},
],
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/client/worker/HowsoWorkerClient.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("Node HowsoWorkerClient", () => {
const fs = new NodeFileSystem(worker);
client = new HowsoWorkerClient(worker, fs, {
trace: false,
howsoUrl: resolve(__dirname, "../../engine/howso.caml"),
howsoUrl: resolve(__dirname, "../../assets/howso.caml"),
});
await client.setup();
const dataPath = resolve(__dirname, "../../tests/assets/iris.json");
Expand Down

0 comments on commit 8b1cea5

Please sign in to comment.