@inferencebureau/apps-sdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/test.d.ts +2 -2
- package/dist/test.js +14 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,6 +80,7 @@ Entry points:
|
|
|
80
80
|
`shopifySessionToken`, `isPreview`, `previewSession`.
|
|
81
81
|
- `@inferencebureau/apps-sdk/test`: for the app's tests: `loadApp` (or `createTestApp`) runs actions against
|
|
82
82
|
in-memory records with the records engine's rules, mocks the Shopify Admin API, delivers webhooks and installs,
|
|
83
|
-
and runs queued jobs; `fixtures` has Shopify's webhook payloads. Node only
|
|
83
|
+
and runs queued jobs; `fixtures` has Shopify's webhook payloads. Node only, under Vitest with this package inlined:
|
|
84
|
+
`test: { server: { deps: { inline: ["@inferencebureau/apps-sdk"] } } }` in vitest.config.ts (new apps have it).
|
|
84
85
|
|
|
85
86
|
Docs: https://app.inferencebureau.com/docs/apps
|
package/dist/test.d.ts
CHANGED
|
@@ -243,8 +243,8 @@ export interface TestApp {
|
|
|
243
243
|
export declare function createTestApp(o?: TestAppOptions): TestApp;
|
|
244
244
|
/**
|
|
245
245
|
* A TestApp from an app's folder (the working directory unless named): every model's schema.ib.ts, every action
|
|
246
|
-
* file (loaded when first run, as a deployment does) and settings.ib.ts. Runs under
|
|
247
|
-
*
|
|
246
|
+
* file (loaded when first run, as a deployment does) and settings.ib.ts. Runs under Vitest (`ib-apps test`), with
|
|
247
|
+
* this package inlined (`server.deps.inline`, as new apps' vitest.config.ts has it) so it can load TypeScript.
|
|
248
248
|
*/
|
|
249
249
|
export declare function loadApp(dir?: string, o?: Omit<TestAppOptions, "models" | "actions" | "settings">): Promise<TestApp>;
|
|
250
250
|
export {};
|
package/dist/test.js
CHANGED
|
@@ -974,8 +974,8 @@ const GLOBAL_ACTION = /^api\/actions\/([^/]+)\.(ts|tsx|js|mjs)$/;
|
|
|
974
974
|
const nodeImport = (name) => import(/* @vite-ignore */ name);
|
|
975
975
|
/**
|
|
976
976
|
* A TestApp from an app's folder (the working directory unless named): every model's schema.ib.ts, every action
|
|
977
|
-
* file (loaded when first run, as a deployment does) and settings.ib.ts. Runs under
|
|
978
|
-
*
|
|
977
|
+
* file (loaded when first run, as a deployment does) and settings.ib.ts. Runs under Vitest (`ib-apps test`), with
|
|
978
|
+
* this package inlined (`server.deps.inline`, as new apps' vitest.config.ts has it) so it can load TypeScript.
|
|
979
979
|
*/
|
|
980
980
|
export async function loadApp(dir, o = {}) {
|
|
981
981
|
const fs = await nodeImport("node:fs");
|
|
@@ -994,7 +994,18 @@ export async function loadApp(dir, o = {}) {
|
|
|
994
994
|
};
|
|
995
995
|
if (fs.existsSync(path.join(root, "api")))
|
|
996
996
|
walk("api");
|
|
997
|
-
const load = (rel) =>
|
|
997
|
+
const load = async (rel) => {
|
|
998
|
+
try {
|
|
999
|
+
return await import(/* @vite-ignore */ url.pathToFileURL(path.join(root, rel)).href);
|
|
1000
|
+
}
|
|
1001
|
+
catch (e) {
|
|
1002
|
+
// Node itself got the import: Vitest left this package to Node, as it does with node_modules by default.
|
|
1003
|
+
if (e.code === "ERR_UNKNOWN_FILE_EXTENSION") {
|
|
1004
|
+
throw new Error(`loadApp can't load ${rel}: Vitest has to run @inferencebureau/apps-sdk itself. Add to vitest.config.ts: test: { server: { deps: { inline: ["@inferencebureau/apps-sdk"] } } }`);
|
|
1005
|
+
}
|
|
1006
|
+
throw e;
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
998
1009
|
const models = {};
|
|
999
1010
|
const actions = {};
|
|
1000
1011
|
for (const f of files.sort()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inferencebureau/apps-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The SDK an Inference Bureau app's code imports: action helpers, metadata types, the records API client and a test harness for its actions.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"keywords": [
|