@colixsystems/widget-sdk 0.285.0 → 0.286.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
@@ -89,7 +89,11 @@ See the design reference for the full architecture: [`docs/architecture/widget-m
89
89
 
90
90
  ## Status
91
91
 
92
- `v0.285.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**.
92
+ `v0.286.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**.
93
+
94
+ ### What's new in 0.286.0 (contract 1.234.0)
95
+
96
+ **Action scripts only: `previous` and `changedFields`.** `CONTRACT.actionScriptGlobals` lists the two new runner globals a `record_updated` Action script reads: the row before the edit and the columns whose value changed. Nothing changes for widget authors.
93
97
 
94
98
  ### What's new in 0.285.0 (contract 1.233.0)
95
99
 
package/dist/contract.cjs CHANGED
@@ -3945,6 +3945,9 @@ const ACTION_SCRIPT_GLOBALS = [
3945
3945
  "directory",
3946
3946
  "console",
3947
3947
  "record",
3948
+ // sc-15609 — on record_updated, the row before the edit and what changed.
3949
+ "previous",
3950
+ "changedFields",
3948
3951
  // sc-5366 — `{ body }` on a run fired by the inbound `http_post` trigger,
3949
3952
  // null on every other trigger.
3950
3953
  "request",
@@ -6719,7 +6722,9 @@ const CONTRACT = deepFreeze({
6719
6722
  // "Rows per page" property.
6720
6723
  // 1.233.0: additive (sc-8115) — a `datastoreTemplate` table may declare
6721
6724
  // `deleteWhenLastMemberLeaves: true`.
6722
- version: "1.233.0",
6725
+ // 1.234.0: additive (sc-15609) — ACTION_SCRIPT_GLOBALS gains `previous` and
6726
+ // `changedFields`; no widget hook, primitive or manifest field changed.
6727
+ version: "1.234.0",
6723
6728
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6724
6729
  hooks: HOOKS,
6725
6730
  primitives: PRIMITIVES,
package/dist/contract.js CHANGED
@@ -3941,6 +3941,9 @@ const ACTION_SCRIPT_GLOBALS = [
3941
3941
  "directory",
3942
3942
  "console",
3943
3943
  "record",
3944
+ // sc-15609 — on record_updated, the row before the edit and what changed.
3945
+ "previous",
3946
+ "changedFields",
3944
3947
  // sc-5366 — `{ body }` on a run fired by the inbound `http_post` trigger,
3945
3948
  // null on every other trigger.
3946
3949
  "request",
@@ -6715,7 +6718,9 @@ const CONTRACT = deepFreeze({
6715
6718
  // "Rows per page" property.
6716
6719
  // 1.233.0: additive (sc-8115) — a `datastoreTemplate` table may declare
6717
6720
  // `deleteWhenLastMemberLeaves: true`.
6718
- version: "1.233.0",
6721
+ // 1.234.0: additive (sc-15609) — ACTION_SCRIPT_GLOBALS gains `previous` and
6722
+ // `changedFields`; no widget hook, primitive or manifest field changed.
6723
+ version: "1.234.0",
6719
6724
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6720
6725
  hooks: HOOKS,
6721
6726
  primitives: PRIMITIVES,
@@ -3,6 +3,7 @@
3
3
  "use strict";
4
4
 
5
5
  const { CONTRACT, isHexColor, contrastRatio, mixHex, readableTextColor } = require("./contract.cjs");
6
+ const { isPlainObject } = require("./plain-object.cjs");
6
7
 
7
8
  // REQ-NAV-STRUCTURE — the host side of an app's navigation SHAPE and the
8
9
  // tokens its footer strip is painted with.
@@ -27,10 +28,6 @@ const { CONTRACT, isHexColor, contrastRatio, mixHex, readableTextColor } = requi
27
28
  // existed renders and compiles byte-identically.
28
29
  const DEFAULT_MENU_TYPE = "sidebar";
29
30
 
30
- function isPlainObject(value) {
31
- return value !== null && typeof value === "object" && !Array.isArray(value);
32
- }
33
-
34
31
  /**
35
32
  * Resolve a `theme_config.navigation` block to the shape both hosts read.
36
33
  *
@@ -17,15 +17,12 @@
17
17
  // diverge.
18
18
 
19
19
  import { CONTRACT, isHexColor, contrastRatio, mixHex, readableTextColor } from "./contract.js";
20
+ import { isPlainObject } from "./plain-object.js";
20
21
 
21
22
  // Absent or unknown resolves here, so every app authored before menu types
22
23
  // existed renders and compiles byte-identically.
23
24
  const DEFAULT_MENU_TYPE = "sidebar";
24
25
 
25
- function isPlainObject(value) {
26
- return value !== null && typeof value === "object" && !Array.isArray(value);
27
- }
28
-
29
26
  /**
30
27
  * Resolve a `theme_config.navigation` block to the shape both hosts read.
31
28
  *
@@ -0,0 +1,11 @@
1
+ // GENERATED from plain-object.js by scripts/generate-cjs.js — DO NOT EDIT.
2
+ // Change plain-object.js, then run `npm run generate:cjs` in packages/widget-sdk.
3
+ "use strict";
4
+
5
+ /** Any non-null, non-array object — a Date, Map or class instance passes. */
6
+ function isPlainObject(value) {
7
+ return value !== null && typeof value === "object" && !Array.isArray(value);
8
+ }
9
+ module.exports = {
10
+ isPlainObject,
11
+ };
@@ -0,0 +1,4 @@
1
+ /** Any non-null, non-array object — a Date, Map or class instance passes. */
2
+ export function isPlainObject(value) {
3
+ return value !== null && typeof value === "object" && !Array.isArray(value);
4
+ }
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { CORNER_RADIUS_KEYS } from "./corner-radius.js";
5
5
  import { SPACING_KEYS } from "./spacing.js";
6
+ import { isPlainObject } from "./plain-object.js";
6
7
 
7
8
  const VALID_TYPES = new Set([
8
9
  "string", "number", "boolean",
@@ -85,10 +86,6 @@ const VALID_TYPES = new Set([
85
86
  /** The propertySchema field types, for documentation generated from this list. */
86
87
  export const PROPERTY_TYPES = Object.freeze([...VALID_TYPES]);
87
88
 
88
- function isPlainObject(v) {
89
- return v !== null && typeof v === "object" && !Array.isArray(v);
90
- }
91
-
92
89
  function validateDef(def, path, errors) {
93
90
  if (!isPlainObject(def)) {
94
91
  errors.push(`${path}: must be an object`);
@@ -2,6 +2,8 @@
2
2
  // a sign order's state, what a refusal says, and how an overview is indexed.
3
3
  // Kept apart from hooks.js so it runs under plain `node --test`.
4
4
 
5
+ import { isPlainObject } from "./plain-object.js";
6
+
5
7
  /** The server reads at most this many file ids per overview call. */
6
8
  export const OVERVIEW_IDS_PER_CALL = 200;
7
9
 
@@ -83,12 +85,11 @@ export function readRefusalDetail(err) {
83
85
  }
84
86
 
85
87
  const nonEmptyString = (value) => typeof value === "string" && value.trim() !== "";
86
- const isObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
87
88
 
88
89
  /** One prepare entry as the filestore client takes it, or null when it is neither form. */
89
90
  function signerForPrepare(signer) {
90
91
  if (nonEmptyString(signer)) return signer;
91
- if (!isObject(signer)) return null;
92
+ if (!isPlainObject(signer)) return null;
92
93
  const keys = Object.keys(signer).sort().join(",");
93
94
  if (keys === "app_user_id" && nonEmptyString(signer.app_user_id)) return signer.app_user_id;
94
95
  if (keys === "email,name" && nonEmptyString(signer.name) && nonEmptyString(signer.email)) {
@@ -111,7 +112,7 @@ export function signerListForPrepare(signers) {
111
112
 
112
113
  /** The body of a new link: a corrected `email` when one is given, otherwise nothing. */
113
114
  export function resendLinkOptions(options) {
114
- const email = isObject(options) && typeof options.email === "string" ? options.email.trim() : "";
115
+ const email = isPlainObject(options) && typeof options.email === "string" ? options.email.trim() : "";
115
116
  return email ? { email } : {};
116
117
  }
117
118
 
@@ -3,6 +3,7 @@
3
3
  "use strict";
4
4
 
5
5
  const { isHexColor, APPEARANCE_PREFERENCES } = require("./contract.cjs");
6
+ const { isPlainObject } = require("./plain-object.cjs");
6
7
 
7
8
  // APPEARANCE_PREFERENCES: what an app opens on and a user may choose.
8
9
 
@@ -21,10 +22,6 @@ const APPEARANCE_THEME_KEYS = ["dark", "appearance"];
21
22
  /** The two palettes an app can render. */
22
23
  const APPEARANCE_MODES = Object.freeze(["light", "dark"]);
23
24
 
24
- function isPlainObject(value) {
25
- return value !== null && typeof value === "object" && !Array.isArray(value);
26
- }
27
-
28
25
  // A gradient is one colour value: its angle and type travel with its stops.
29
26
  function isGradient(value) {
30
27
  return isPlainObject(value) && isHexColor(value.from) && isHexColor(value.to);
@@ -1,5 +1,6 @@
1
1
  // APPEARANCE_PREFERENCES: what an app opens on and a user may choose.
2
2
  import { isHexColor, APPEARANCE_PREFERENCES } from "./contract.js";
3
+ import { isPlainObject } from "./plain-object.js";
3
4
 
4
5
  export { APPEARANCE_PREFERENCES };
5
6
 
@@ -17,10 +18,6 @@ const APPEARANCE_THEME_KEYS = ["dark", "appearance"];
17
18
  /** The two palettes an app can render. */
18
19
  export const APPEARANCE_MODES = Object.freeze(["light", "dark"]);
19
20
 
20
- function isPlainObject(value) {
21
- return value !== null && typeof value === "object" && !Array.isArray(value);
22
- }
23
-
24
21
  // A gradient is one colour value: its angle and type travel with its stops.
25
22
  function isGradient(value) {
26
23
  return isPlainObject(value) && isHexColor(value.from) && isHexColor(value.to);
@@ -3,6 +3,7 @@
3
3
  "use strict";
4
4
 
5
5
  const { CONTRACT, normaliseComponentGradient } = require("./contract.cjs");
6
+ const { isPlainObject } = require("./plain-object.cjs");
6
7
 
7
8
  // REQ-THEME-15 (sc-1497) — the host side of per-component style tokens.
8
9
  //
@@ -26,10 +27,6 @@ const { CONTRACT, normaliseComponentGradient } = require("./contract.cjs");
26
27
  // must never drop a colour the runner already accepted.
27
28
  const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
28
29
 
29
- function isPlainObject(value) {
30
- return value !== null && typeof value === "object" && !Array.isArray(value);
31
- }
32
-
33
30
  function coerceToken(def, value) {
34
31
  if (def.type === "color") {
35
32
  if (typeof value !== "string") return undefined;
@@ -16,15 +16,12 @@
16
16
  // literal, so what a planner may emit and what a host applies cannot diverge.
17
17
 
18
18
  import { CONTRACT, normaliseComponentGradient } from "./contract.js";
19
+ import { isPlainObject } from "./plain-object.js";
19
20
 
20
21
  // 3-, 6- and 8-digit hex, matching what the build runner persists — the host
21
22
  // must never drop a colour the runner already accepted.
22
23
  const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
23
24
 
24
- function isPlainObject(value) {
25
- return value !== null && typeof value === "object" && !Array.isArray(value);
26
- }
27
-
28
25
  function coerceToken(def, value) {
29
26
  if (def.type === "color") {
30
27
  if (typeof value !== "string") return undefined;
@@ -23,6 +23,7 @@ import {
23
23
  withHexAlpha,
24
24
  THEME_TOKEN_REF_PREFIX,
25
25
  } from "./contract.js";
26
+ import { isPlainObject } from "./plain-object.js";
26
27
 
27
28
  // A value is a binding, not a colour, when it carries this prefix. No CSS
28
29
  // colour can begin with it, so a stored literal can never be misread as one.
@@ -67,10 +68,6 @@ export function resolveThemeTokenRef(value, theme) {
67
68
  return ref.alpha === null ? resolved : withHexAlpha(resolved, ref.alpha);
68
69
  }
69
70
 
70
- function isPlainObject(value) {
71
- return value !== null && typeof value === "object" && !Array.isArray(value);
72
- }
73
-
74
71
  // The same guard the neighbouring style validators apply: these props are
75
72
  // author-stored JSON, and assigning such a key while rebuilding an object would
76
73
  // silently reseat its prototype instead of carrying the value.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colixsystems/widget-sdk",
3
- "version": "0.285.0",
3
+ "version": "0.286.0",
4
4
  "description": "Common widget interface for AppStudio. Implements WidgetManifest, WidgetContext, property schema, and helper hooks.",
5
5
  "homepage": "https://github.com/Colix-AB/AppStudio",
6
6
  "type": "module",
package/src/contract.js CHANGED
@@ -3941,6 +3941,9 @@ const ACTION_SCRIPT_GLOBALS = [
3941
3941
  "directory",
3942
3942
  "console",
3943
3943
  "record",
3944
+ // sc-15609 — on record_updated, the row before the edit and what changed.
3945
+ "previous",
3946
+ "changedFields",
3944
3947
  // sc-5366 — `{ body }` on a run fired by the inbound `http_post` trigger,
3945
3948
  // null on every other trigger.
3946
3949
  "request",
@@ -6715,7 +6718,9 @@ const CONTRACT = deepFreeze({
6715
6718
  // "Rows per page" property.
6716
6719
  // 1.233.0: additive (sc-8115) — a `datastoreTemplate` table may declare
6717
6720
  // `deleteWhenLastMemberLeaves: true`.
6718
- version: "1.233.0",
6721
+ // 1.234.0: additive (sc-15609) — ACTION_SCRIPT_GLOBALS gains `previous` and
6722
+ // `changedFields`; no widget hook, primitive or manifest field changed.
6723
+ version: "1.234.0",
6719
6724
  sharedTranslationKeys: SHARED_TRANSLATION_KEYS,
6720
6725
  hooks: HOOKS,
6721
6726
  primitives: PRIMITIVES,