@inferencebureau/apps-sdk 0.1.0 → 0.2.0

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 CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  What an Inference Bureau app's code imports: types for the metadata files (`schema.ib.ts`, `permissions.ib.ts`,
4
4
  `settings.ib.ts`), the helpers an action's `run` uses (`applyParams`, `save`, `deleteRecord`), the records API client,
5
- and request checks for Shopify session tokens and app proxies. Apps are operator-only for now.
5
+ request checks for Shopify session tokens and app proxies, and a harness for testing actions. Apps are operator-only for
6
+ now.
6
7
 
7
8
  ```sh
8
9
  npm install @inferencebureau/apps-sdk
@@ -34,12 +35,51 @@ export async function GET(request: Request) {
34
35
  }
35
36
  ```
36
37
 
38
+ ```ts
39
+ // Anywhere in the app's server code: the environment's records and actions, no options needed.
40
+ import { ApiError, createClient } from "@inferencebureau/apps-sdk";
41
+
42
+ const api = createClient();
43
+ const page = await api.review.findMany({
44
+ filter: { shop: { equals: "inference-bureau.myshopify.com" }, status: { equals: "pending" } },
45
+ sort: { createdAt: "Ascending" },
46
+ first: 50,
47
+ });
48
+ try {
49
+ await api.review.run("approve", { id: page.records[0].id, shop: "inference-bureau.myshopify.com" });
50
+ } catch (e) {
51
+ if (e instanceof ApiError) console.error(e.status, e.code, e.problems);
52
+ }
53
+ ```
54
+
55
+ ```ts
56
+ // tests/approve.test.ts: the app's actions against in-memory records, run with `ib-apps test` (Vitest)
57
+ import { expect, it } from "vitest";
58
+ import { TEST_SHOP, loadApp } from "@inferencebureau/apps-sdk/test";
59
+
60
+ const app = await loadApp(); // the folder's schemas, actions and settings.ib.ts
61
+
62
+ it("approves a review", async () => {
63
+ app.shopify.on("PublishReviews", { metafieldsSet: { userErrors: [] } }); // the Admin API, mocked
64
+ const review = await app.seed("review", { shop: TEST_SHOP, rating: 5, body: "Fits well, washes well." });
65
+ const run = await app.run("review.approve", { id: review.id, shop: TEST_SHOP });
66
+ expect(run.record).toMatchObject({ status: "approved" });
67
+ });
68
+ ```
69
+
70
+ Inside an app, `createClient()` reads `IB_API_URL`, `IB_ENVIRONMENT_TOKEN`, `IB_APP` and `IB_ENVIRONMENT`, which
71
+ Inference Bureau sets. From a script or another service, pass `{ token: process.env.IB_API_KEY, app, environment }`
72
+ with a key linked to the app.
73
+
37
74
  Entry points:
38
75
 
39
76
  - `@inferencebureau/apps-sdk`: metadata types, action helpers, `createClient`, `createShopifyClient`,
40
- `verifyShopifySession`, `verifyProxyRequest`.
77
+ `verifyShopifySession`, `verifyProxyRequest`, and the errors they throw (`ApiError`, `ShopifyError`).
41
78
  - `@inferencebureau/apps-sdk/runtime`: `handleAction`, the signed `/_ib/actions` route every build adds.
42
79
  - `@inferencebureau/apps-sdk/browser`: for an embedded admin page's client code: `sessionFetch`,
43
- `shopifySessionToken`, `isPreview`.
80
+ `shopifySessionToken`, `isPreview`, `previewSession`.
81
+ - `@inferencebureau/apps-sdk/test`: for the app's tests: `loadApp` (or `createTestApp`) runs actions against
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.
44
84
 
45
85
  Docs: https://app.inferencebureau.com/docs/apps
package/dist/index.d.ts CHANGED
@@ -58,11 +58,39 @@ export interface ModelSchema {
58
58
  storageKey?: string;
59
59
  fields: Record<string, FieldDef>;
60
60
  }
61
+ /**
62
+ * `settings.ib.ts`. Keep it a plain object literal: Inference Bureau reads `webhooks` and `schedules` from the file.
63
+ * Both run global actions (`api/actions/<name>.ts`) as background jobs, retried when they fail.
64
+ */
61
65
  export interface AppSettings {
62
66
  type: "ib/settings/v1";
63
67
  platform: "shopify" | "web";
68
+ /** Shopify webhook topics that queue an action, with Shopify's payload as `params` and the store as `shop`. */
69
+ webhooks?: WebhookSetting[];
70
+ /** Actions queued on a cron schedule, `params.scheduledAt` the time it was due. */
71
+ schedules?: ScheduleSetting[];
64
72
  [key: string]: unknown;
65
73
  }
74
+ export interface WebhookSetting {
75
+ /** A Shopify webhook topic, e.g. orders/create. The app's scopes must allow it. */
76
+ topic: string;
77
+ /** The global action to queue. */
78
+ action: string;
79
+ /** Only deliveries matching this, in Shopify's search syntax (e.g. "total_price:>100"). */
80
+ filter?: string;
81
+ /** Only these fields of the payload. */
82
+ includeFields?: string[];
83
+ }
84
+ export interface ScheduleSetting {
85
+ /** The global action to queue. */
86
+ action: string;
87
+ /** Five fields: minute hour day-of-month month day-of-week, e.g. "0 3 * * *" for 03:00 every day. */
88
+ cron: string;
89
+ /** An IANA timezone, UTC unless named. */
90
+ timezone?: string;
91
+ /** Where it runs: production only unless development is named too. */
92
+ environments?: ("development" | "production")[];
93
+ }
66
94
  export interface AppPermissions {
67
95
  type: "ib/permissions/v1";
68
96
  roles: Record<string, unknown>;
@@ -133,6 +161,8 @@ export interface ModelClient {
133
161
  create(values: Record<string, unknown>): Promise<AppRecord>;
134
162
  update(id: string, values: Record<string, unknown>): Promise<AppRecord>;
135
163
  delete(id: string): Promise<void>;
164
+ /** Whether `password` is the one stored in the record's password field (`password` unless named). Hashes are never returned. */
165
+ checkPassword(id: string, password: string, field?: string): Promise<boolean>;
136
166
  /** Runs one of the model's actions: on a record when `id` is given, else as a new one; `shop` gives it `shopify`. */
137
167
  run(action: string, o?: {
138
168
  id?: string;
@@ -150,7 +180,38 @@ export type Api = {
150
180
  $global(action: string, params?: Record<string, unknown>): Promise<{
151
181
  result?: unknown;
152
182
  }>;
183
+ /**
184
+ * Queues an action as a background job and returns at once: a global action's name, or `<model>.<action>` (with
185
+ * `id` for the record). It gets up to five minutes, and is retried when it fails.
186
+ */
187
+ enqueue(action: string, params?: Record<string, unknown>, options?: EnqueueOptions): Promise<Job>;
153
188
  };
189
+ export interface EnqueueOptions {
190
+ /** The record a model's action works on. */
191
+ id?: string;
192
+ /** Gives the action its `shopify` client for this store. */
193
+ shop?: string;
194
+ /** Milliseconds to wait before running it (at most 30 days); or `runAt`. */
195
+ delay?: number;
196
+ runAt?: string | Date;
197
+ /** Tries after the first, when it fails (6 by default, up to 20), backing off from 15 seconds to an hour. */
198
+ retries?: number;
199
+ /** high runs before default before low. */
200
+ priority?: "low" | "default" | "high";
201
+ /** Jobs with the same key run at most `concurrency` (1 by default) at a time. */
202
+ concurrencyKey?: string;
203
+ concurrency?: number;
204
+ }
205
+ export interface Job {
206
+ id: string;
207
+ action: string;
208
+ state: "queued" | "running" | "succeeded" | "failed" | "canceled";
209
+ run_at: string;
210
+ attempts: number;
211
+ max_attempts: number;
212
+ last_error: string | null;
213
+ [key: string]: unknown;
214
+ }
154
215
  export interface ClientOptions {
155
216
  /** Inference Bureau's API; IB_API_URL in an app's deployment. */
156
217
  url?: string;
@@ -251,7 +312,7 @@ export interface ActionOptions {
251
312
  actionType?: "create" | "update" | "delete" | "custom";
252
313
  /** Whether what `run` returns goes back to the caller (it's dropped otherwise). */
253
314
  returnType?: boolean;
254
- /** How long `run` may take, at most 60 seconds (30 by default). */
315
+ /** How long `run` may take: at most 60 seconds (30 by default), or 5 minutes (the default) as a background job. */
255
316
  timeoutMS?: number;
256
317
  }
257
318
  export interface ActionModule {
@@ -259,3 +320,30 @@ export interface ActionModule {
259
320
  onSuccess?: ActionOnSuccess;
260
321
  options?: ActionOptions;
261
322
  }
323
+ export interface ShopifyPrivacyCustomer {
324
+ id: number;
325
+ email?: string | null;
326
+ phone?: string | null;
327
+ }
328
+ /** `api/actions/shopifyCustomersRedact.ts`: erase what the app holds on this customer (and these orders). */
329
+ export interface ShopifyCustomersRedactParams {
330
+ shop_id: number;
331
+ shop_domain: string;
332
+ customer: ShopifyPrivacyCustomer;
333
+ orders_to_redact: number[];
334
+ }
335
+ /** `api/actions/shopifyCustomersDataRequest.ts`: send the store what the app holds on this customer, within 30 days. */
336
+ export interface ShopifyCustomersDataRequestParams {
337
+ shop_id: number;
338
+ shop_domain: string;
339
+ customer: ShopifyPrivacyCustomer;
340
+ orders_requested: number[];
341
+ data_request: {
342
+ id: number;
343
+ };
344
+ }
345
+ /** `api/actions/shopifyShopRedact.ts`: 48 hours after an uninstall, erase the store's data the app keeps elsewhere. */
346
+ export interface ShopifyShopRedactParams {
347
+ shop_id: number;
348
+ shop_domain: string;
349
+ }
package/dist/index.js CHANGED
@@ -115,15 +115,19 @@ export function createClient(o = {}) {
115
115
  create: (values) => call("POST", `${m}/records`, values),
116
116
  update: (id, values) => call("PATCH", `${m}/records/${encodeURIComponent(id)}`, values),
117
117
  delete: (id) => call("DELETE", `${m}/records/${encodeURIComponent(id)}`),
118
+ checkPassword: async (id, password, field) => (await call("POST", `${m}/records/${encodeURIComponent(id)}/check-password`, { password, ...(field ? { field } : {}) })).valid,
118
119
  run: (action, o = {}) => call("POST", `${m}/actions/${encodeURIComponent(action)}`, { ...(o.id ? { id: o.id } : {}), params: o.params ?? {}, ...(o.shop ? { shop: o.shop } : {}) }),
119
120
  };
120
121
  };
121
122
  const cache = new Map();
122
123
  const $global = (action, params = {}) => call("POST", `/actions/${encodeURIComponent(action)}`, { params });
124
+ const enqueue = (action, params = {}, o = {}) => call("POST", "/jobs", { action, params, ...o, ...(o.runAt instanceof Date ? { runAt: o.runAt.toISOString() } : {}) });
123
125
  return new Proxy({}, {
124
126
  get(_t, prop) {
125
127
  if (prop === "$global")
126
128
  return $global;
129
+ if (prop === "enqueue")
130
+ return enqueue;
127
131
  if (typeof prop !== "string" || prop === "then")
128
132
  return undefined;
129
133
  if (!cache.has(prop))
package/dist/runtime.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * signature, runs the action file, and answers with what `run` asked to happen to the record. Inference Bureau
5
5
  * applies that in one transaction, then calls again for `onSuccess` with the saved record.
6
6
  */
7
- import { type ActionModule, type AppRecord, type LogLine } from "./index.js";
7
+ import { type ActionModule, type Api, type AppRecord, type LogLine, type ShopifyClient } from "./index.js";
8
8
  /** Action modules by key: `<model>/<action>` for model actions, `$global/<action>` for global ones. */
9
9
  export type ActionRegistry = Record<string, () => Promise<ActionModule>>;
10
10
  export interface ActionRequest {
@@ -39,9 +39,16 @@ export type ActionResponse = {
39
39
  };
40
40
  /** The signature Inference Bureau sends: HMAC-SHA256 of `<timestamp>.<body>` with the environment's token, hex. */
41
41
  export declare function sign(token: string, timestamp: string, body: string): Promise<string>;
42
- /** Runs one phase of an action, without checking where the request came from (handleAction does). */
42
+ /**
43
+ * Runs one phase of an action, without checking where the request came from (handleAction does). `api` and
44
+ * `shopify` stand in for the environment's clients (the test app's in-memory ones); `echo: false` keeps the logger's
45
+ * lines off the console.
46
+ */
43
47
  export declare function runAction(req: ActionRequest, registry: ActionRegistry, o?: {
44
48
  token?: string;
49
+ api?: Api;
50
+ shopify?: (shop: string) => ShopifyClient;
51
+ echo?: boolean;
45
52
  }): Promise<ActionResponse>;
46
53
  /** The `/_ib/actions` route: a signed request from Inference Bureau, or 404 for anyone else. */
47
54
  export declare function handleAction(request: Request, registry: ActionRegistry, o?: {
package/dist/runtime.js CHANGED
@@ -22,14 +22,19 @@ function sameText(a, b) {
22
22
  d |= a.charCodeAt(i) ^ b.charCodeAt(i);
23
23
  return d === 0;
24
24
  }
25
- function collector(lines) {
25
+ function collector(lines, echo) {
26
26
  const at = (level) => (message, data) => {
27
27
  lines.push({ level, message: String(message).slice(0, 2000), ...(data === undefined ? {} : { data }), at: new Date().toISOString() });
28
- (level === "error" ? console.error : level === "warn" ? console.warn : console.log)(`[action] ${message}`, ...(data === undefined ? [] : [data]));
28
+ if (echo)
29
+ (level === "error" ? console.error : level === "warn" ? console.warn : console.log)(`[action] ${message}`, ...(data === undefined ? [] : [data]));
29
30
  };
30
31
  return { debug: at("debug"), info: at("info"), warn: at("warn"), error: at("error") };
31
32
  }
32
- /** Runs one phase of an action, without checking where the request came from (handleAction does). */
33
+ /**
34
+ * Runs one phase of an action, without checking where the request came from (handleAction does). `api` and
35
+ * `shopify` stand in for the environment's clients (the test app's in-memory ones); `echo: false` keeps the logger's
36
+ * lines off the console.
37
+ */
33
38
  export async function runAction(req, registry, o = {}) {
34
39
  const logs = [];
35
40
  try {
@@ -40,9 +45,9 @@ export async function runAction(req, registry, o = {}) {
40
45
  const mod = await load();
41
46
  const record = req.record ? trackRecord({ ...req.record }, req.model) : null;
42
47
  const ctx = {
43
- params: req.params ?? {}, record, api: createClient(o.token ? { token: o.token } : {}), logger: collector(logs),
48
+ params: req.params ?? {}, record, api: o.api ?? createClient(o.token ? { token: o.token } : {}), logger: collector(logs, o.echo ?? true),
44
49
  model: req.model, action: req.action, environment: req.environment,
45
- shop: req.shop ?? null, shopify: req.shop ? createShopifyClient(req.shop, o.token ? { token: o.token } : {}) : null,
50
+ shop: req.shop ?? null, shopify: req.shop ? (o.shopify?.(req.shop) ?? createShopifyClient(req.shop, o.token ? { token: o.token } : {})) : null,
46
51
  };
47
52
  if (req.phase === "onSuccess") {
48
53
  await mod.onSuccess?.(ctx);
package/dist/test.d.ts ADDED
@@ -0,0 +1,250 @@
1
+ /**
2
+ * @inferencebureau/apps-sdk/test: an app's actions run in the test process against an in-memory copy of its records,
3
+ * so they can be tested without an environment. `loadApp()` reads the app's folder (its schemas, actions and
4
+ * settings) and gives back a TestApp: `run` an action as Inference Bureau would, read and write records through
5
+ * `api` as the action's own `api` does, deliver Shopify webhooks, install a store, run queued jobs, and answer the
6
+ * action's Shopify Admin calls with mocks.
7
+ *
8
+ * The records follow the records engine's rules (packages/apps/src/records.ts): field types and conversions,
9
+ * defaults, validations, uniqueness, belongsTo, filters, sorting and pages, and the errors the API answers with, as
10
+ * ApiError. An action's run goes through the same runner as a deployment (runtime.ts): its params and record arrive
11
+ * as JSON, its writes are applied when `run` returns, then `onSuccess` runs with the saved record. Not covered:
12
+ * permissions (actions run as the system), `timeoutMS`, webhook `filter`s (Shopify applies them), schedules' timing
13
+ * and computed or relationship fields other than belongsTo.
14
+ */
15
+ import { ApiError, type ActionModule, type Api, type AppRecord, type AppSettings, type Job, type LogLine, type ModelSchema } from "./index.js";
16
+ type Embed = (model: string, input: string[]) => Promise<number[][]>;
17
+ /** The store a test app installs on and runs as, unless a test names another. */
18
+ export declare const TEST_SHOP = "test-shop.myshopify.com";
19
+ export interface ShopifyCall {
20
+ shop: string;
21
+ query: string;
22
+ variables: Record<string, unknown>;
23
+ }
24
+ export type ShopifyAnswer = unknown | ((variables: Record<string, unknown>, call: ShopifyCall) => unknown);
25
+ /** Answers for the Admin API calls an action makes, and the calls it made. */
26
+ export interface ShopifyMock {
27
+ /**
28
+ * Answers queries containing `match` (text, like an operation name, or a RegExp) with `data`, or what a function
29
+ * returns for the call; a function that throws ShopifyError fails the call as Shopify would. The latest match wins.
30
+ */
31
+ on(match: string | RegExp, answer: ShopifyAnswer): ShopifyMock;
32
+ calls: ShopifyCall[];
33
+ }
34
+ /**
35
+ * Shopify's webhook payloads (REST-shaped, as deliveries arrive), filled with believable values. Pass what the test
36
+ * cares about; the rest is made up. Ids are unique within the test run.
37
+ */
38
+ export declare const fixtures: {
39
+ shop(o?: Record<string, unknown>): {
40
+ id: number;
41
+ name: string;
42
+ email: string;
43
+ domain: string;
44
+ myshopify_domain: string;
45
+ currency: string;
46
+ plan_display_name: string;
47
+ country_code: string;
48
+ timezone: string;
49
+ };
50
+ variant(o?: Record<string, unknown>): {
51
+ id: number;
52
+ admin_graphql_api_id: string;
53
+ title: string;
54
+ sku: string;
55
+ price: string;
56
+ compare_at_price: null;
57
+ inventory_quantity: number;
58
+ position: number;
59
+ updated_at: string;
60
+ };
61
+ product(o?: Record<string, unknown>): {
62
+ id: number;
63
+ admin_graphql_api_id: string;
64
+ title: string;
65
+ handle: string;
66
+ status: string;
67
+ vendor: string;
68
+ product_type: string;
69
+ tags: string;
70
+ body_html: string;
71
+ published_at: string;
72
+ created_at: string;
73
+ updated_at: string;
74
+ variants: {
75
+ id: number;
76
+ admin_graphql_api_id: string;
77
+ title: string;
78
+ sku: string;
79
+ price: string;
80
+ compare_at_price: null;
81
+ inventory_quantity: number;
82
+ position: number;
83
+ updated_at: string;
84
+ }[];
85
+ };
86
+ collection(o?: Record<string, unknown>): {
87
+ id: number;
88
+ admin_graphql_api_id: string;
89
+ title: string;
90
+ handle: string;
91
+ body_html: string;
92
+ sort_order: string;
93
+ updated_at: string;
94
+ };
95
+ customer(o?: Record<string, unknown>): {
96
+ id: number;
97
+ admin_graphql_api_id: string;
98
+ email: string;
99
+ first_name: string;
100
+ last_name: string;
101
+ phone: null;
102
+ state: string;
103
+ created_at: string;
104
+ updated_at: string;
105
+ };
106
+ order(o?: Record<string, unknown>): {
107
+ id: number;
108
+ admin_graphql_api_id: string;
109
+ name: string;
110
+ order_number: number;
111
+ email: string;
112
+ currency: string;
113
+ total_price: string;
114
+ subtotal_price: string;
115
+ total_tax: string;
116
+ financial_status: string;
117
+ fulfillment_status: null;
118
+ customer: {
119
+ id: number;
120
+ admin_graphql_api_id: string;
121
+ email: string;
122
+ first_name: string;
123
+ last_name: string;
124
+ phone: null;
125
+ state: string;
126
+ created_at: string;
127
+ updated_at: string;
128
+ };
129
+ line_items: {
130
+ id: number;
131
+ product_id: number;
132
+ variant_id: number;
133
+ title: string;
134
+ quantity: number;
135
+ price: string;
136
+ sku: string;
137
+ }[];
138
+ created_at: string;
139
+ updated_at: string;
140
+ };
141
+ /** customers/redact, customers/data_request and shop/redact, for the shopify* privacy actions. */
142
+ customersRedact(o?: Record<string, unknown>): {
143
+ shop_id: number;
144
+ shop_domain: string;
145
+ customer: {
146
+ id: number;
147
+ email: string;
148
+ phone: null;
149
+ };
150
+ orders_to_redact: never[];
151
+ };
152
+ customersDataRequest(o?: Record<string, unknown>): {
153
+ shop_id: number;
154
+ shop_domain: string;
155
+ customer: {
156
+ id: number;
157
+ email: string;
158
+ phone: null;
159
+ };
160
+ orders_requested: never[];
161
+ data_request: {
162
+ id: number;
163
+ };
164
+ };
165
+ shopRedact(o?: Record<string, unknown>): {
166
+ shop_id: number;
167
+ shop_domain: string;
168
+ };
169
+ };
170
+ export type ActionModules = Record<string, ActionModule | (() => Promise<ActionModule>)>;
171
+ export interface TestAppOptions {
172
+ /** Each model's `schema` (from its schema.ib.ts), by model name. */
173
+ models?: Record<string, ModelSchema>;
174
+ /** Action modules (or loaders) by `<model>/<action>`, and `$global/<action>` for global ones. */
175
+ actions?: ActionModules;
176
+ /** settings.ib.ts's `settings`: which webhooks run which actions. */
177
+ settings?: AppSettings;
178
+ environment?: "development" | "production";
179
+ /** The clock records are stamped with. */
180
+ now?: () => number;
181
+ /** Embeds text for vector fields and text searches; without one, a sourced vector is dropped when its text changes. */
182
+ embed?: Embed;
183
+ /** Prints what actions log to the console as well (it's always in `logs`). */
184
+ echo?: boolean;
185
+ }
186
+ export interface RunOptions {
187
+ id?: string;
188
+ params?: Record<string, unknown>;
189
+ shop?: string;
190
+ }
191
+ export interface TestRun {
192
+ /** `<model>.<action>`, or the global action's name. */
193
+ action: string;
194
+ /** The record after the run: saved, or null when deleted (and in a global action). */
195
+ record: AppRecord | null;
196
+ /** What `run` returned, when the action's options have `returnType: true`. */
197
+ result?: unknown;
198
+ logs: LogLine[];
199
+ /** onSuccess threw: the run's changes stand, as they do in a deployment, and this says why. */
200
+ onSuccessError: string | null;
201
+ }
202
+ /** An action's `run` threw: nothing it asked for was applied. The API answers the same 422. */
203
+ export declare class ActionFailedError extends ApiError {
204
+ readonly logs: LogLine[];
205
+ constructor(message: string, logs: LogLine[], actionStack?: string);
206
+ }
207
+ export interface TestApp {
208
+ /**
209
+ * The app's records and actions, as an action's own `api` sees them: `create`, `update` and `delete` run the
210
+ * model's action of that name when it has one, as through the API.
211
+ */
212
+ api: Api;
213
+ /** Writes a record directly, without its actions (still validated): data for a test to start from. */
214
+ seed(model: string, values: Record<string, unknown>): Promise<AppRecord>;
215
+ /** Runs an action (`<model>.<action>` or a global one's name) as a call through the API would. */
216
+ run(action: string, o?: RunOptions): Promise<TestRun>;
217
+ /** A model's records, oldest first. */
218
+ records(model: string): AppRecord[];
219
+ /** A store installs the app: the shopifyShop model's install (or reinstall) runs, as on a real install. */
220
+ install(shop?: string, o?: {
221
+ scopes?: string;
222
+ }): Promise<AppRecord | null>;
223
+ uninstall(shop?: string): Promise<AppRecord | null>;
224
+ /**
225
+ * A Shopify webhook arrives from `shop` (TEST_SHOP unless named): synced Shopify models are written (and their
226
+ * create, update or delete actions run), and the actions settings.ib.ts names for the topic run with the payload.
227
+ */
228
+ webhook(topic: string, payload: Record<string, unknown>, o?: {
229
+ shop?: string;
230
+ }): Promise<TestRun[]>;
231
+ /** Jobs `api.enqueue` queued, in order. */
232
+ jobs: Job[];
233
+ /** Runs every queued job once (and the ones they queue), whatever its delay. A failed job stays queued while it has tries left. */
234
+ runJobs(): Promise<Job[]>;
235
+ shopify: ShopifyMock;
236
+ /** Everything every action logged, in order. */
237
+ logs: (LogLine & {
238
+ action: string;
239
+ })[];
240
+ /** Empties the records, jobs, logs and Shopify calls (mocks stay), e.g. in beforeEach. */
241
+ reset(): void;
242
+ }
243
+ export declare function createTestApp(o?: TestAppOptions): TestApp;
244
+ /**
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 a test runner that loads
247
+ * TypeScript, like Vitest (`ib-apps test`).
248
+ */
249
+ export declare function loadApp(dir?: string, o?: Omit<TestAppOptions, "models" | "actions" | "settings">): Promise<TestApp>;
250
+ export {};