@oddington/sdk 0.1.77 → 0.1.79
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 +10 -2
- package/dist/browser.js +13 -7
- package/dist/index.js +4 -4
- package/dist/types/packages/sdk/src/routine-definition-types.d.ts +7 -1
- package/dist/types/shared/inbox-contract.d.ts +1 -0
- package/dist/types/shared/inbox-member-types.d.ts +1 -0
- package/dist/types/shared/inbox-records.d.ts +2 -1
- package/dist/types/shared/record-display.d.ts +2 -1
- package/dist/types/shared/record-link.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -292,6 +292,7 @@ import { defineResponse, respond, resolveAsk } from '@oddington/sdk';
|
|
|
292
292
|
// List this action in the owning defineRoutine({ responses: [setStatus], access, ... }).
|
|
293
293
|
// The routine's single access declaration governs both its run and its actions.
|
|
294
294
|
const setStatus = defineResponse<{ recordRef: string; status: string }>({ id: 'set-status', async run({ input }, os) {
|
|
295
|
+
await os.action.progress({ label: 'Updating the record' });
|
|
295
296
|
const changes = os.data.repository('general').changes();
|
|
296
297
|
changes.update(input.recordRef, { status: input.status });
|
|
297
298
|
await changes.publish();
|
|
@@ -300,6 +301,11 @@ const setStatus = defineResponse<{ recordRef: string; status: string }>({ id: 's
|
|
|
300
301
|
// Attach to a published Question with handler: respond(setStatus, { recordRef, status: 'complete' }).
|
|
301
302
|
```
|
|
302
303
|
|
|
304
|
+
`action.progress` replaces the Inbox's generic invoking copy while this action
|
|
305
|
+
is running. Use concise customer-facing text for meaningful waits. It does not
|
|
306
|
+
create timeline events, counted steps or a completion estimate; the next label
|
|
307
|
+
replaces it and the platform clears it when recording the outcome.
|
|
308
|
+
|
|
303
309
|
The SDK owns browser provider setup, email/passcode actions, persisted restoration,
|
|
304
310
|
refresh and expiry. Create one opaque handle outside rendering and bind the app's
|
|
305
311
|
presentation to its state:
|
|
@@ -897,8 +903,10 @@ if (next) await general.records.query({
|
|
|
897
903
|
```
|
|
898
904
|
|
|
899
905
|
`collections.schema(name)` includes an optional `display.title` list of one or
|
|
900
|
-
two ordered scalar field names when the collection declares a
|
|
901
|
-
title.
|
|
906
|
+
two ordered singular scalar or link field names when the collection declares a
|
|
907
|
+
short Record title. A link contributes its target Record's declared scalar
|
|
908
|
+
title on surfaces that resolve presentation. It is presentation metadata;
|
|
909
|
+
`$ref` remains the Record identity.
|
|
902
910
|
|
|
903
911
|
Binding is inert. Each operation resolves current workspace, endpoint and
|
|
904
912
|
short-lived authority from the trusted app host or managed routine context.
|
package/dist/browser.js
CHANGED
|
@@ -5574,7 +5574,7 @@ var RecordSelectionError = class extends InboxContractError {
|
|
|
5574
5574
|
constructor(problem, source2) {
|
|
5575
5575
|
let collection = `${source2.collection.repository}/${source2.collection.name}`, messages = {
|
|
5576
5576
|
collection_unavailable: `The ${collection} collection is unavailable. Check the collection name and its schema.`,
|
|
5577
|
-
display_fields_invalid: "display" in source2 ? `The label fields for ${collection} must be scalar fields in its schema. Check display.labelFields.` : `The ${collection} schema must declare one or two scalar title fields. Check display.title.`,
|
|
5577
|
+
display_fields_invalid: "display" in source2 ? `The label fields for ${collection} must be scalar fields in its schema. Check display.labelFields.` : `The ${collection} schema must declare one or two singular scalar or link title fields. Check display.title.`,
|
|
5578
5578
|
filter_fields_invalid: `The filters for ${collection} must use scalar schema fields and matching values. Check the Question\u2019s where fields.`,
|
|
5579
5579
|
ref_prefix_invalid: `The record reference prefix does not belong to ${collection}. Check refPrefix against the collection\u2019s record references.`,
|
|
5580
5580
|
suggestion_unavailable: `A suggested record is missing or isn\u2019t eligible for ${collection}. Update the suggestions and try again.`,
|
|
@@ -6531,7 +6531,13 @@ function createCapabilityRuntime(contract, runtime2, current2, owner) {
|
|
|
6531
6531
|
if (!current2()) throw new Error(`${owner} authority ended`);
|
|
6532
6532
|
return value;
|
|
6533
6533
|
} },
|
|
6534
|
-
inbox: { ...runtime2.inbox, publishAsk: (value, options) => runtime2.inbox.publishAsk(validateHandlers(value), options) }
|
|
6534
|
+
inbox: { ...runtime2.inbox, publishAsk: (value, options) => runtime2.inbox.publishAsk(validateHandlers(value), options) },
|
|
6535
|
+
...owner === "Response" ? { action: freezeRoutineMetadata({ async progress(value) {
|
|
6536
|
+
assertRoutineFields(value, ["label"]);
|
|
6537
|
+
let label = value.label;
|
|
6538
|
+
if (!routineTitle(label) || !runtime2.action) return invalid3();
|
|
6539
|
+
await runtime2.action.progress({ label });
|
|
6540
|
+
} }) } : {}
|
|
6535
6541
|
}) }), guarded, async drain() {
|
|
6536
6542
|
for (; aiWork.size; ) await Promise.allSettled([...aiWork]);
|
|
6537
6543
|
} };
|
|
@@ -7398,12 +7404,12 @@ function parseRecordDisplay(value, definitions2, fail8 = invalid7) {
|
|
|
7398
7404
|
if (value === void 0) return;
|
|
7399
7405
|
if (!value || typeof value != "object" || Array.isArray(value)) return fail8("Expected a field mapping");
|
|
7400
7406
|
let row = value;
|
|
7401
|
-
if (Object.keys(row).some((key) => key !== "title") || !Object.hasOwn(row, "title") || !Array.isArray(row.title) || row.title.length < 1 || row.title.length > 2 || row.title.some((name2) => typeof name2 != "string" || !NAME.test(name2)) || new Set(row.title).size !== row.title.length) return fail8("Display title requires one or two distinct scalar fields");
|
|
7407
|
+
if (Object.keys(row).some((key) => key !== "title") || !Object.hasOwn(row, "title") || !Array.isArray(row.title) || row.title.length < 1 || row.title.length > 2 || row.title.some((name2) => typeof name2 != "string" || !NAME.test(name2)) || new Set(row.title).size !== row.title.length) return fail8("Display title requires one or two distinct singular scalar or link fields");
|
|
7402
7408
|
let title = row.title;
|
|
7403
7409
|
return title.some((name2) => {
|
|
7404
7410
|
let field = definitions2.find((candidate) => candidate.name === name2);
|
|
7405
|
-
return !field || field.many || ["
|
|
7406
|
-
}) ? fail8("Display title requires one or two distinct scalar fields") : { title };
|
|
7411
|
+
return !field || field.many || ["object", "map"].includes(field.kind);
|
|
7412
|
+
}) ? fail8("Display title requires one or two distinct singular scalar or link fields") : { title };
|
|
7407
7413
|
}
|
|
7408
7414
|
|
|
7409
7415
|
var RecordValidationError = class extends Error {
|
|
@@ -10428,12 +10434,12 @@ function parseInboxItem(value) {
|
|
|
10428
10434
|
let execution = object8(question2.execution);
|
|
10429
10435
|
if (assert(id2(execution.id) && ["pending", "running", "completed", "failed"].includes(String(execution.state)) && integer(execution.attempt, 0)), "consequence" in execution) {
|
|
10430
10436
|
let consequence = object8(execution.consequence);
|
|
10431
|
-
keys6(consequence, ["phase", "updatedAt", "evidence"]), assert((consequence.phase === null || ["loading", "invoking", "committing"].includes(String(consequence.phase))) && date(consequence.updatedAt)), array2(consequence.evidence).forEach((value3) => {
|
|
10437
|
+
keys6(consequence, ["phase", "progressLabel", "updatedAt", "evidence"], ["phase", "updatedAt", "evidence"]), assert((consequence.phase === null || ["loading", "invoking", "committing"].includes(String(consequence.phase))) && date(consequence.updatedAt)), "progressLabel" in consequence && assert(consequence.progressLabel === null || text4(consequence.progressLabel) && consequence.progressLabel.length <= 256), array2(consequence.evidence).forEach((value3) => {
|
|
10432
10438
|
let receipt = object8(value3);
|
|
10433
10439
|
receipt.provider === "airtable" ? (keys6(receipt, ["provider", "connection", "baseId", "table", "operation", "records"]), assert(text4(receipt.connection) && /^airtable\/[a-z0-9][a-z0-9-]*$/.test(receipt.connection) && text4(receipt.baseId) && text4(receipt.table) && ["create", "update", "delete"].includes(String(receipt.operation))), array2(receipt.records).forEach((value4) => {
|
|
10434
10440
|
let record4 = object8(value4);
|
|
10435
10441
|
keys6(record4, ["id"]), assert(text4(record4.id));
|
|
10436
|
-
})) : (keys6(receipt, ["repository", "commit", "diff"]), assert(text4(receipt.repository) && text4(receipt.commit) && text4(receipt.diff, !0)));
|
|
10442
|
+
})) : (keys6(receipt, ["repository", "commit", "diff", "url"]), assert(text4(receipt.repository) && text4(receipt.commit) && text4(receipt.diff, !0)), "url" in receipt && assert(text4(receipt.url) && /^https:\/\/github\.com\/[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9_.-]+\/commit\/[0-9a-f]{40}$/.test(receipt.url) && receipt.url.endsWith(`/commit/${receipt.commit}`)));
|
|
10437
10443
|
});
|
|
10438
10444
|
}
|
|
10439
10445
|
}
|