@colixsystems/widget-sdk 0.95.0 → 0.96.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 +18 -0
- package/dist/contract.cjs +21 -4
- package/dist/contract.js +21 -4
- package/dist/index.d.ts +13 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,6 +66,24 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
|
|
|
66
66
|
|
|
67
67
|
`v0.91.0` — pre-publish. The package surface (types, function names, export paths) is the v1 contract; runtime behaviour for some hooks is stubbed (each hook documents what's wired and what isn't). It is **not yet published to npm**.
|
|
68
68
|
|
|
69
|
+
### What's new in 0.96.0 (contract 1.68.0)
|
|
70
|
+
|
|
71
|
+
**A manifest action can declare `manual`, and every action script gains a `request` global (sc-5366).** The backend Action model grew three ways of *reaching* a script to sit beside the ones that *fire* it: `manual` (nothing starts it — the workspace runs it on demand), `app` (a published app's button `onPress`) and `http_post` (an inbound webhook at `POST /api/v1/action-hooks/:actionId`, authenticated with one of the workspace's integration API keys). The same change retired the separate `appInvokable` boolean, so one column now answers "what starts this action?".
|
|
72
|
+
|
|
73
|
+
Only `manual` joins `CONTRACT.actionTriggerTypes`, and that is deliberate. `app` and `http_post` expose a script to a caller **outside** the Studio, which is the installing workspace's decision about running someone else's code — not the author's. A manifest that declares either is rejected by `validateManifest`, the CLI linter and the backend alike; the operator grants them in the Actions admin page after install, on top of whatever triggers your manifest declared. Nothing about an already-published manifest changes.
|
|
74
|
+
|
|
75
|
+
`CONTRACT.actionScriptGlobals` gains **`request`**: `{ body }` — the JSON an inbound webhook caller sent — on an `http_post` run, and `null` on every other trigger. Request *headers* are never passed through, because they carry the caller's API key. `triggerType` now also reports `"http_post"` alongside `"manual"` and `"app"`, so one script can tell a webhook apart from its nightly schedule:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
if (triggerType === "http_post") {
|
|
79
|
+
const order = request?.body;
|
|
80
|
+
if (!order?.id) return; // never trust the caller's shape
|
|
81
|
+
await datastore.records("Orders").create({ externalId: order.id });
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`CONTRACT.version` → `1.68.0`. Additive for every existing manifest.
|
|
86
|
+
|
|
69
87
|
### What's new in 0.95.0 (contract 1.67.0)
|
|
70
88
|
|
|
71
89
|
**An admin can mail a locked-out member a password-reset link — `useUsers().sendPasswordReset(userId)` (sc-5335).** An app user who forgot their password could only recover it themselves, from the app's own login screen. The admin they actually ask — the one already able to invite, deactivate and remove them — had no way to help, and the workaround in the field was to remove and re-invite the account, which discards its group memberships and history.
|
package/dist/contract.cjs
CHANGED
|
@@ -1459,14 +1459,23 @@ const PLATFORMS = ["web", "native"];
|
|
|
1459
1459
|
|
|
1460
1460
|
// REQ-WIDGET-ACTION — server-side actions a widget may declare in its
|
|
1461
1461
|
// manifest. Each runs in the shared isolated-vm action runner (see backend
|
|
1462
|
-
// action-runner.service.js) on a cron schedule
|
|
1463
|
-
//
|
|
1464
|
-
// export parity.
|
|
1462
|
+
// action-runner.service.js) on a cron schedule, in response to a record CRUD
|
|
1463
|
+
// event, or on demand — NEVER in the rendered app, so they never affect
|
|
1464
|
+
// Player ↔ export parity.
|
|
1465
|
+
//
|
|
1466
|
+
// This is what a MANIFEST may declare. The backend Action model additionally
|
|
1467
|
+
// accepts 'app' and 'http_post' (sc-5366), which expose a script to a
|
|
1468
|
+
// published app's buttons or to a public webhook — those are the installing
|
|
1469
|
+
// workspace's decision about running someone else's code, so an operator
|
|
1470
|
+
// grants them and a manifest may not ask for them. `validateManifest` and the
|
|
1471
|
+
// backend's `_validateWidgetDeclared` both reject them, so the linter and the
|
|
1472
|
+
// server agree about what a manifest declared.
|
|
1465
1473
|
const ACTION_TRIGGER_TYPES = [
|
|
1466
1474
|
"schedule",
|
|
1467
1475
|
"record_created",
|
|
1468
1476
|
"record_updated",
|
|
1469
1477
|
"record_deleted",
|
|
1478
|
+
"manual",
|
|
1470
1479
|
];
|
|
1471
1480
|
// Globals the action script runs against (the runner's surface) — distinct
|
|
1472
1481
|
// from the React/SDK widget surface, so the component import/banned-API
|
|
@@ -1479,6 +1488,9 @@ const ACTION_SCRIPT_GLOBALS = [
|
|
|
1479
1488
|
"notifications",
|
|
1480
1489
|
"console",
|
|
1481
1490
|
"record",
|
|
1491
|
+
// sc-5366 — `{ body }` on a run fired by the inbound `http_post` trigger,
|
|
1492
|
+
// null on every other trigger.
|
|
1493
|
+
"request",
|
|
1482
1494
|
"tenantId",
|
|
1483
1495
|
"triggerType",
|
|
1484
1496
|
"triggerTableId",
|
|
@@ -2939,7 +2951,12 @@ const CONTRACT = deepFreeze({
|
|
|
2939
2951
|
// resolves `{ sent, email_masked }` and never returns the token or the
|
|
2940
2952
|
// link, so it is not an account-takeover primitive; it gates on the same
|
|
2941
2953
|
// `users.write:*` scope as invite / deactivate.
|
|
2942
|
-
|
|
2954
|
+
// 1.68.0: additive (sc-5366) — a manifest action may declare the `manual`
|
|
2955
|
+
// trigger (nothing fires it; the workspace runs it on demand), and every
|
|
2956
|
+
// action script now sees a `request` global — `{ body }` on a run fired
|
|
2957
|
+
// by the workspace-granted `http_post` webhook trigger, null otherwise.
|
|
2958
|
+
// `app` and `http_post` stay operator-granted and are NOT declarable.
|
|
2959
|
+
version: "1.68.0",
|
|
2943
2960
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
2944
2961
|
hooks: HOOKS,
|
|
2945
2962
|
primitives: PRIMITIVES,
|
package/dist/contract.js
CHANGED
|
@@ -1459,14 +1459,23 @@ const PLATFORMS = ["web", "native"];
|
|
|
1459
1459
|
|
|
1460
1460
|
// REQ-WIDGET-ACTION — server-side actions a widget may declare in its
|
|
1461
1461
|
// manifest. Each runs in the shared isolated-vm action runner (see backend
|
|
1462
|
-
// action-runner.service.js) on a cron schedule
|
|
1463
|
-
//
|
|
1464
|
-
// export parity.
|
|
1462
|
+
// action-runner.service.js) on a cron schedule, in response to a record CRUD
|
|
1463
|
+
// event, or on demand — NEVER in the rendered app, so they never affect
|
|
1464
|
+
// Player ↔ export parity.
|
|
1465
|
+
//
|
|
1466
|
+
// This is what a MANIFEST may declare. The backend Action model additionally
|
|
1467
|
+
// accepts 'app' and 'http_post' (sc-5366), which expose a script to a
|
|
1468
|
+
// published app's buttons or to a public webhook — those are the installing
|
|
1469
|
+
// workspace's decision about running someone else's code, so an operator
|
|
1470
|
+
// grants them and a manifest may not ask for them. `validateManifest` and the
|
|
1471
|
+
// backend's `_validateWidgetDeclared` both reject them, so the linter and the
|
|
1472
|
+
// server agree about what a manifest declared.
|
|
1465
1473
|
const ACTION_TRIGGER_TYPES = [
|
|
1466
1474
|
"schedule",
|
|
1467
1475
|
"record_created",
|
|
1468
1476
|
"record_updated",
|
|
1469
1477
|
"record_deleted",
|
|
1478
|
+
"manual",
|
|
1470
1479
|
];
|
|
1471
1480
|
// Globals the action script runs against (the runner's surface) — distinct
|
|
1472
1481
|
// from the React/SDK widget surface, so the component import/banned-API
|
|
@@ -1479,6 +1488,9 @@ const ACTION_SCRIPT_GLOBALS = [
|
|
|
1479
1488
|
"notifications",
|
|
1480
1489
|
"console",
|
|
1481
1490
|
"record",
|
|
1491
|
+
// sc-5366 — `{ body }` on a run fired by the inbound `http_post` trigger,
|
|
1492
|
+
// null on every other trigger.
|
|
1493
|
+
"request",
|
|
1482
1494
|
"tenantId",
|
|
1483
1495
|
"triggerType",
|
|
1484
1496
|
"triggerTableId",
|
|
@@ -2939,7 +2951,12 @@ const CONTRACT = deepFreeze({
|
|
|
2939
2951
|
// resolves `{ sent, email_masked }` and never returns the token or the
|
|
2940
2952
|
// link, so it is not an account-takeover primitive; it gates on the same
|
|
2941
2953
|
// `users.write:*` scope as invite / deactivate.
|
|
2942
|
-
|
|
2954
|
+
// 1.68.0: additive (sc-5366) — a manifest action may declare the `manual`
|
|
2955
|
+
// trigger (nothing fires it; the workspace runs it on demand), and every
|
|
2956
|
+
// action script now sees a `request` global — `{ body }` on a run fired
|
|
2957
|
+
// by the workspace-granted `http_post` webhook trigger, null otherwise.
|
|
2958
|
+
// `app` and `http_post` stay operator-granted and are NOT declarable.
|
|
2959
|
+
version: "1.68.0",
|
|
2943
2960
|
sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
|
|
2944
2961
|
hooks: HOOKS,
|
|
2945
2962
|
primitives: PRIMITIVES,
|
package/dist/index.d.ts
CHANGED
|
@@ -229,17 +229,25 @@ export interface WidgetManifestAction {
|
|
|
229
229
|
* that actually fired.
|
|
230
230
|
*/
|
|
231
231
|
triggerTypes: Array<
|
|
232
|
-
|
|
232
|
+
| "schedule"
|
|
233
|
+
| "record_created"
|
|
234
|
+
| "record_updated"
|
|
235
|
+
| "record_deleted"
|
|
236
|
+
// sc-5366 — nothing fires it; the workspace runs it on demand. The
|
|
237
|
+
// `"app"` and `"http_post"` triggers are operator-granted, not declarable.
|
|
238
|
+
| "manual"
|
|
233
239
|
>;
|
|
234
240
|
/** Required iff `triggerTypes` contains `"schedule"`. node-cron syntax. */
|
|
235
241
|
scheduleCron?: string;
|
|
236
242
|
/** 100–300000. Defaults to 30000 on materialise. */
|
|
237
243
|
timeoutMs?: number;
|
|
238
244
|
/**
|
|
239
|
-
* Runs against `datastore`, `fetch`, `console`, `record`, `
|
|
240
|
-
* `triggerType`, `triggerTableId` — NOT the React/SDK surface.
|
|
241
|
-
* `triggerType` is the trigger that fired THIS run — one of the
|
|
242
|
-
* `triggerTypes`, or `"manual"` / `"app"` for an
|
|
245
|
+
* Runs against `datastore`, `fetch`, `console`, `record`, `request`,
|
|
246
|
+
* `tenantId`, `triggerType`, `triggerTableId` — NOT the React/SDK surface.
|
|
247
|
+
* ≤ 200 KiB. `triggerType` is the trigger that fired THIS run — one of the
|
|
248
|
+
* declared `triggerTypes`, or `"manual"` / `"app"` / `"http_post"` for an
|
|
249
|
+
* operator, button or webhook run. `request` is `{ body }` on a webhook run
|
|
250
|
+
* and `null` otherwise (sc-5366).
|
|
243
251
|
*/
|
|
244
252
|
scriptSource: string;
|
|
245
253
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@colixsystems/widget-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.0",
|
|
4
4
|
"description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|