@listen-fire/movement-lang 0.15.3 → 0.16.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.
@@ -114,6 +114,10 @@ export interface AdapterSpec {
114
114
  /** What a 0.12 settings listen on this module becomes as a traversal: the
115
115
  * upgrade's rewrite of `listen to x { … }`. */
116
116
  listenSettingsBecome?: SettingsBecome;
117
+ /** The release before which a host may have let only registered senders set
118
+ * a listen on this module off (Slack's `0.16.0`): an upgrade from an older
119
+ * key tells each listen whose filter does not limit it. */
120
+ listensLimitedBefore?: string;
117
121
  }
118
122
  /**
119
123
  * A module's mapping from its 0.12 listen settings to the traversal a listen
@@ -266,7 +270,7 @@ export interface PluginSpec {
266
270
  * where it is written, and an argument declared to take structured data
267
271
  * (`json`) is handed a record's fields. Absent for an argument nobody typed.
268
272
  */
269
- argTypes?: Record<string, SchemaFieldType>;
273
+ argTypes?: Record<string, PluginArgType>;
270
274
  /**
271
275
  * Arguments (⊆ `args`) a call MUST supply: a call missing one is
272
276
  * MOV_THROUGH_ARG_MISSING.
@@ -302,6 +306,13 @@ export interface PluginSpec {
302
306
  * what the stage would have handed it.
303
307
  */
304
308
  fedByExtraction?: boolean;
309
+ /**
310
+ * The same arguments give the same answer until the host says otherwise, so
311
+ * a call of it may stand where only a pure expression may. Absent ⇒ not pure.
312
+ */
313
+ pure?: boolean;
314
+ /** How long a host may keep a pure plugin's answer, in seconds. Only a pure plugin declares one. */
315
+ maxAgeSeconds?: number;
305
316
  /**
306
317
  * Arguments the EXTRACTION fills inside a `through [ … ]` stage — the engine
307
318
  * feeds them from the `from [ … ]` source, which is why a stage never writes
@@ -378,6 +389,7 @@ export type PluginOutput = {
378
389
  } | {
379
390
  kind: 'record';
380
391
  fields: Record<string, SchemaFieldType>;
392
+ maybeAbsent?: true;
381
393
  } | {
382
394
  kind: 'records';
383
395
  fields: Record<string, SchemaFieldType>;
@@ -1309,6 +1321,15 @@ export type SchemaFieldType = 'text' | 'number' | 'boolean' | 'date' | 'datetime
1309
1321
  kind: 'maybeAbsent';
1310
1322
  of: SchemaFieldType;
1311
1323
  }
1324
+ /** `text & Brand<"claim:email/address">`: `of`, narrowed by each brand, as
1325
+ * TypeScript's intersection narrows. A brand is a name compared whole,
1326
+ * never parsed. A branded value fits where `of` is asked for; a value
1327
+ * without the brand never fits where it is. */
1328
+ | {
1329
+ kind: 'branded';
1330
+ of: SchemaFieldType;
1331
+ brands: string[];
1332
+ }
1312
1333
  /** A record's fields held as the field's value (`c.Current`): typed as a
1313
1334
  * plain object of that position's fields, never as the record. It has no
1314
1335
  * edges and no identity, so a checker refuses a walk, a write or a record
@@ -1317,6 +1338,13 @@ export type SchemaFieldType = 'text' | 'number' | 'boolean' | 'date' | 'datetime
1317
1338
  kind: 'record';
1318
1339
  position: SchemaPositionRef;
1319
1340
  };
1341
+ /** What a plugin's argument takes: a field type, or one of several (`text &
1342
+ * Brand<"a"> | text & Brand<"b">`). A union is the checker's typing, which a
1343
+ * schema's field never is, so it lives here and not on `SchemaFieldType`. */
1344
+ export type PluginArgType = SchemaFieldType | {
1345
+ kind: 'union';
1346
+ of: PluginArgType[];
1347
+ };
1320
1348
  /** Which record a `record` field holds: one record type of the instance, or
1321
1349
  * one of several (`unions`). */
1322
1350
  export type SchemaPositionRef = {
@@ -17,5 +17,9 @@ export interface Diagnostic {
17
17
  /** The exact rewrite that resolves it, built from the author's own source —
18
18
  * also spelled out in `message`, which is all a text reader sees. */
19
19
  fix?: DiagnosticFix;
20
+ /** The library it came from, as the checked file's import names it
21
+ * (`lib/finance`), when it came from one. The message names it too; a host
22
+ * tells a library's fault by this, never by reading the message. */
23
+ file?: string;
20
24
  }
21
25
  export declare function diagnosticSeverity(diagnostic: Diagnostic): DiagnosticSeverity;
@@ -7,6 +7,11 @@ export interface RustCheckOptions {
7
7
  languageVersion: LanguageVersion;
8
8
  /** Checking for a move up from this release (`CheckOptions.upgradingFrom`). */
9
9
  upgradingFrom?: LanguageVersion;
10
+ /** The catalog key of the pure plugin the host limits a listen's senders
11
+ * with (`@lf-platform/team/isMember`): an upgrade's `MOV_LISTEN_NOW_OPEN`
12
+ * then carries the check that calls it, as an unsafe fix
13
+ * (`CheckOptions.limiting_function`). */
14
+ limitingFunction?: string;
10
15
  }
11
16
  /** A source the Rust checker could not check: it does not parse, or the
12
17
  * snapshot does not load. */
@@ -105,7 +105,10 @@ function compatibleInRust(request) {
105
105
  throw new Error(`the Rust checker answered check.compatible with ${JSON.stringify(json)}`);
106
106
  }
107
107
  function callOptions(options) {
108
- return options.upgradingFrom === undefined ? {} : { upgradingFrom: options.upgradingFrom };
108
+ return {
109
+ ...(options.upgradingFrom !== undefined ? { upgradingFrom: options.upgradingFrom } : {}),
110
+ ...(options.limitingFunction !== undefined ? { limitingFunction: options.limitingFunction } : {}),
111
+ };
109
112
  }
110
113
  /** Every fact a stamp may carry; a stamp carries exactly one, as the
111
114
  * engine's `join_check` holds it to. */
@@ -210,6 +213,7 @@ function diagnosticOf(value) {
210
213
  ...(severity !== undefined ? { severity } : {}),
211
214
  ...(value.upgrade === true ? { upgrade: true } : {}),
212
215
  ...(value.fix !== undefined ? { fix: fixOf(value.fix) } : {}),
216
+ ...(typeof value.file === 'string' ? { file: value.file } : {}),
213
217
  };
214
218
  }
215
219
  function fixOf(value) {
@@ -40,7 +40,7 @@ const PURE_KINDS = new Set([
40
40
  'property',
41
41
  'edge_property',
42
42
  'alias_ref',
43
- // `@current_date` / `@user_email` / `@current_timestamp` — an ambient scalar
43
+ // `@current_date` / `@current_timestamp` — an ambient scalar
44
44
  // the engine resolves with no adapter, no AI, no traversal. A childless leaf,
45
45
  // so `isPurePredicate` admits it with no recursion (childExpressions → []).
46
46
  'meta',
@@ -52,7 +52,7 @@ export interface FormulaCapabilities {
52
52
  resources: boolean;
53
53
  llm: boolean;
54
54
  /**
55
- * KG-bound global identifiers (`@id`, `@user_*`, `@parent.*`,
55
+ * KG-bound global identifiers (`@id`, `@parent.*`,
56
56
  * `@current_date`, `@input_channel_name`). True for the TG field
57
57
  * editor where these resolve against the surrounding action node /
58
58
  * pipeline context. False for adapter-source filter authoring (trigger
@@ -296,6 +296,9 @@ function serialize(expr, resolve, parentPrec = 0, resolveStaticValue, resolveEdg
296
296
  case 'at': {
297
297
  return `AT(${ser(expr.expression)}, ${ser(expr.index)})`;
298
298
  }
299
+ case 'field': {
300
+ return `${ser(expr.expression)}${expr.optional === true ? '?.' : '.'}${quoteName(expr.field)}`;
301
+ }
299
302
  }
300
303
  // Shorthand for recursive calls that threads resolveStaticValue/resolveEdgeInfo through
301
304
  function ser(e, prec = 0) {
@@ -1085,8 +1088,6 @@ const FUNCTION_COMPLETIONS = [
1085
1088
  ];
1086
1089
  const SPECIAL_COMPLETIONS = [
1087
1090
  { label: '@id', insert: '@id', kind: 'special' },
1088
- { label: '@user_name', insert: '@user_name', kind: 'special' },
1089
- { label: '@user_email', insert: '@user_email', kind: 'special' },
1090
1091
  { label: '@current_date', insert: '@current_date', kind: 'special' },
1091
1092
  { label: '@input_channel_name', insert: '@input_channel_name', kind: 'special' },
1092
1093
  { label: '@parent.created', insert: '@parent.created', kind: 'special' },
@@ -1580,7 +1581,7 @@ function getCompletions(input, cursorPos, properties, edges, contextNodeTypeId,
1580
1581
  // Early check: typing @ prefix for special completions. Gated on the
1581
1582
  // `kgGlobals` capability — adapter-source authoring contexts (e.g.
1582
1583
  // trigger filters) have no parent action node or KG identifiers in
1583
- // scope, so offering @parent / @id / @user_* would mislead.
1584
+ // scope, so offering @parent / @id would mislead.
1584
1585
  const specialPrefix = textBefore.match(/@([a-zA-Z0-9_.]*)?$/);
1585
1586
  if (specialPrefix) {
1586
1587
  if (capabilities.kgGlobals === false)
@@ -470,6 +470,11 @@ export type Expression =
470
470
  type: 'at';
471
471
  expression: Expression;
472
472
  index: Expression;
473
+ } | {
474
+ type: 'field';
475
+ expression: Expression;
476
+ field: string;
477
+ optional?: boolean;
473
478
  } | {
474
479
  type: 'aggregate';
475
480
  fn: Aggregation['function'];
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from './parser/ast';
3
3
  export * from './parser/await_words';
4
4
  export * from './parser/scan';
5
5
  export * from './parser/parse';
6
- export { MovementParserNotReady, assertParserReady, callJudgeArrival, callLandingMisfits, callLandingNode, callListenIdentity, EngineStackRanOut, initEngine, initParser, isParserReady, openEngineSegment, type EngineSegment, } from './wasm/loader';
6
+ export { MovementParserNotReady, assertParserReady, callExplainArrival, callJudgeArrival, callLandingMisfits, callLandingNode, callListenIdentity, EngineStackRanOut, initEngine, initParser, isParserReady, openEngineSegment, type EngineSegment, } from './wasm/loader';
7
7
  export * from './expression/bridge';
8
8
  export * from './expression/chunk';
9
9
  export * from './expression/file_value';
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.openEngineSegment = exports.isParserReady = exports.initParser = exports.initEngine = exports.EngineStackRanOut = exports.callListenIdentity = exports.callLandingNode = exports.callLandingMisfits = exports.callJudgeArrival = exports.assertParserReady = exports.MovementParserNotReady = void 0;
17
+ exports.openEngineSegment = exports.isParserReady = exports.initParser = exports.initEngine = exports.EngineStackRanOut = exports.callListenIdentity = exports.callLandingNode = exports.callLandingMisfits = exports.callJudgeArrival = exports.callExplainArrival = exports.assertParserReady = exports.MovementParserNotReady = void 0;
18
18
  __exportStar(require("./never"), exports);
19
19
  __exportStar(require("./parser/ast"), exports);
20
20
  __exportStar(require("./parser/await_words"), exports);
@@ -23,6 +23,7 @@ __exportStar(require("./parser/parse"), exports);
23
23
  var loader_1 = require("./wasm/loader");
24
24
  Object.defineProperty(exports, "MovementParserNotReady", { enumerable: true, get: function () { return loader_1.MovementParserNotReady; } });
25
25
  Object.defineProperty(exports, "assertParserReady", { enumerable: true, get: function () { return loader_1.assertParserReady; } });
26
+ Object.defineProperty(exports, "callExplainArrival", { enumerable: true, get: function () { return loader_1.callExplainArrival; } });
26
27
  Object.defineProperty(exports, "callJudgeArrival", { enumerable: true, get: function () { return loader_1.callJudgeArrival; } });
27
28
  Object.defineProperty(exports, "callLandingMisfits", { enumerable: true, get: function () { return loader_1.callLandingMisfits; } });
28
29
  Object.defineProperty(exports, "callLandingNode", { enumerable: true, get: function () { return loader_1.callLandingNode; } });
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "0.15.3";
1
+ export declare const PACKAGE_VERSION = "0.16.0";
@@ -5,4 +5,4 @@ exports.PACKAGE_VERSION = void 0;
5
5
  // scripts/build-packages.cjs (a source and its build sit at different depths
6
6
  // beside package.json, so neither can require it by one relative path).
7
7
  // __test__/language_version.unit.test.ts holds it equal to package.json.
8
- exports.PACKAGE_VERSION = '0.15.3';
8
+ exports.PACKAGE_VERSION = '0.16.0';
@@ -1306,6 +1306,14 @@ export type ValueTypeRef = {
1306
1306
  keys: ValueTypeKey[];
1307
1307
  span: Span;
1308
1308
  }
1309
+ /** `text & Brand<"claim:email/address">`: `of` narrowed by each brand,
1310
+ * TypeScript's intersection. A brand is a name, compared and never parsed. */
1311
+ | {
1312
+ kind: 'branded';
1313
+ of: ValueTypeMember;
1314
+ brands: string[];
1315
+ span: Span;
1316
+ }
1309
1317
  /**
1310
1318
  * `<(c: <Company>) => <text>>` — a CLOSURE type,
1311
1319
  * TypeScript's function type: what each parameter takes and what calling it
@@ -201,5 +201,7 @@ function spellValueType(type) {
201
201
  return `{ ${type.keys.map(key => `${key.name}${key.optional ? '?' : ''}: ${spellValueType(key.type)}`).join(', ')} }`;
202
202
  case 'closure':
203
203
  return `(${type.params.map(param => `${param.name}: <${param.type !== undefined ? spellParamType(param.type) : '?'}>`).join(', ')}) => <${spellParamType(type.returns)}>`;
204
+ case 'branded':
205
+ return [spellValueType(type.of), ...[...new Set(type.brands)].sort().map((brand) => `Brand<${JSON.stringify(brand)}>`)].join(' & ');
204
206
  }
205
207
  }
@@ -61,6 +61,9 @@ export declare function callCatalog(snapshotJson: string, queryJson: string): {
61
61
  export interface CheckCallOptions {
62
62
  /** The release a move up starts from. */
63
63
  upgradingFrom?: string;
64
+ /** The catalog key of the pure plugin the host limits a listen's senders
65
+ * with: an open listen told so on an upgrade is offered its check. */
66
+ limitingFunction?: string;
64
67
  }
65
68
  /**
66
69
  * The Rust checker over `source` (crates/movement-checker/src/abi.rs
@@ -168,9 +171,10 @@ export declare function callStoryAnalysis(source: string, snapshotJson: string,
168
171
  };
169
172
  /**
170
173
  * Whether an arrival fires a listen (crates/movement-engine/src/abi.rs
171
- * `judge_arrival`): `{plan, arrival, nowMs}` as JSON, and the reply — the
172
- * verdict, `{fires: true}`, `{skips}` or `{undecided}` — or `{error}` for an
173
- * input that does not read.
174
+ * `judge_arrival`): `{plan, arrival, nowMs, answers?}` as JSON, and the reply
175
+ * — the verdict, `{fires: true}`, `{skips}`, `{undecided}`, or `{asks}` for a
176
+ * host function the answers do not answer yet — or `{error}` for an input
177
+ * that does not read.
174
178
  *
175
179
  * @internal Used by the engine's judge (movement-engine triggers/listen_plans.ts).
176
180
  */
@@ -178,6 +182,17 @@ export declare function callJudgeArrival(inputJson: string): {
178
182
  ok: boolean;
179
183
  json: unknown;
180
184
  };
185
+ /**
186
+ * `callJudgeArrival`'s verdict with the term of the filter that skipped the
187
+ * arrival (crates/movement-engine/src/abi.rs `explain_arrival`): the same
188
+ * input, and the reply `{verdict, firstFailed?}`, or `{error}`.
189
+ *
190
+ * @internal Used by the engine's judge (movement-engine triggers/listen_plans.ts).
191
+ */
192
+ export declare function callExplainArrival(inputJson: string): {
193
+ ok: boolean;
194
+ json: unknown;
195
+ };
181
196
  /**
182
197
  * What makes a listen one listen (crates/movement-engine/src/abi.rs
183
198
  * `listen_identity`, `ListenPlan::identity`): the plan as JSON, and the reply
@@ -38,6 +38,7 @@ exports.callLanguageQuery = callLanguageQuery;
38
38
  exports.callDescribeQuery = callDescribeQuery;
39
39
  exports.callStoryAnalysis = callStoryAnalysis;
40
40
  exports.callJudgeArrival = callJudgeArrival;
41
+ exports.callExplainArrival = callExplainArrival;
41
42
  exports.callListenIdentity = callListenIdentity;
42
43
  exports.callLandingNode = callLandingNode;
43
44
  exports.callLandingMisfits = callLandingMisfits;
@@ -130,7 +131,7 @@ function callCatalog(snapshotJson, queryJson) {
130
131
  return call('catalog_query', [snapshotJson, queryJson], []);
131
132
  }
132
133
  function optionsJson(options) {
133
- return JSON.stringify({ upgradingFrom: options.upgradingFrom ?? null });
134
+ return JSON.stringify({ upgradingFrom: options.upgradingFrom ?? null, limitingFunction: options.limitingFunction ?? null });
134
135
  }
135
136
  /**
136
137
  * The Rust checker over `source` (crates/movement-checker/src/abi.rs
@@ -229,15 +230,26 @@ function callStoryAnalysis(source, snapshotJson, options) {
229
230
  }
230
231
  /**
231
232
  * Whether an arrival fires a listen (crates/movement-engine/src/abi.rs
232
- * `judge_arrival`): `{plan, arrival, nowMs}` as JSON, and the reply — the
233
- * verdict, `{fires: true}`, `{skips}` or `{undecided}` — or `{error}` for an
234
- * input that does not read.
233
+ * `judge_arrival`): `{plan, arrival, nowMs, answers?}` as JSON, and the reply
234
+ * — the verdict, `{fires: true}`, `{skips}`, `{undecided}`, or `{asks}` for a
235
+ * host function the answers do not answer yet — or `{error}` for an input
236
+ * that does not read.
235
237
  *
236
238
  * @internal Used by the engine's judge (movement-engine triggers/listen_plans.ts).
237
239
  */
238
240
  function callJudgeArrival(inputJson) {
239
241
  return callChecker('judge_arrival', [inputJson], []);
240
242
  }
243
+ /**
244
+ * `callJudgeArrival`'s verdict with the term of the filter that skipped the
245
+ * arrival (crates/movement-engine/src/abi.rs `explain_arrival`): the same
246
+ * input, and the reply `{verdict, firstFailed?}`, or `{error}`.
247
+ *
248
+ * @internal Used by the engine's judge (movement-engine triggers/listen_plans.ts).
249
+ */
250
+ function callExplainArrival(inputJson) {
251
+ return callChecker('explain_arrival', [inputJson], []);
252
+ }
241
253
  /**
242
254
  * What makes a listen one listen (crates/movement-engine/src/abi.rs
243
255
  * `listen_identity`, `ListenPlan::identity`): the plan as JSON, and the reply
@@ -534,6 +546,7 @@ function readExports(raw) {
534
546
  'describe_query',
535
547
  'story_analysis',
536
548
  'judge_arrival',
549
+ 'explain_arrival',
537
550
  'listen_identity',
538
551
  'landing_node',
539
552
  'landing_misfits',
Binary file
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@listen-fire/movement-lang",
3
3
  "license": "Apache-2.0",
4
- "version": "0.15.3",
4
+ "version": "0.16.0",
5
5
  "description": "The data-movement language: the wasm parser, checker and engine with their loader and bindings, the version rule, the expression AST and the types the contracts name",
6
6
  "engines": {
7
7
  "node": ">=22.23.4 <23"