diff --git a/MIGRATION.md b/MIGRATION.md index 80e9e2b..193af6b 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -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 diff --git a/README.md b/README.md index 4f8cf5c..b76ffd7 100644 --- a/README.md +++ b/README.md @@ -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"; @@ -86,7 +87,7 @@ const getClient = async (options?: ClientOptions): Promise => 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(); diff --git a/codegen/README.md b/codegen/README.md index e8e600a..ea769bf 100644 --- a/codegen/README.md +++ b/codegen/README.md @@ -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 diff --git a/codegen/engine.ts b/codegen/engine.ts index 7a652a6..dea38af 100644 --- a/codegen/engine.ts +++ b/codegen/engine.ts @@ -26,7 +26,7 @@ export interface Schema extends BaseSchema { values?: SchemaType | Schema | Ref; indices?: Record; dynamic_indices?: Record; - additional_indices?: SchemaType | Schema | Ref; + additional_indices?: SchemaType | Schema | Ref | false; } export interface LabelDefinition { @@ -49,7 +49,7 @@ export interface EngineApi { export async function getEngineApi(): Promise { 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"); @@ -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); } diff --git a/codegen/rollup.config.js b/codegen/rollup.config.js index 9134832..297b5b4 100644 --- a/codegen/rollup.config.js +++ b/codegen/rollup.config.js @@ -15,7 +15,7 @@ export default { copy({ targets: [ { - src: ["src/engine/howso.caml"], + src: ["src/assets/howso.caml"], dest: "./codegen/build", }, { diff --git a/rollup.config.js b/rollup.config.js index b10dcfe..d29bfcf 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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", }, ], diff --git a/src/engine/howso.caml b/src/assets/howso.caml similarity index 100% rename from src/engine/howso.caml rename to src/assets/howso.caml diff --git a/src/engine/migrations.caml b/src/assets/migrations.caml similarity index 100% rename from src/engine/migrations.caml rename to src/assets/migrations.caml diff --git a/src/client/worker/HowsoWorkerClient.node.test.ts b/src/client/worker/HowsoWorkerClient.node.test.ts index 5a1ff11..97dea9d 100644 --- a/src/client/worker/HowsoWorkerClient.node.test.ts +++ b/src/client/worker/HowsoWorkerClient.node.test.ts @@ -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");