@listen-fire/movement-lang 0.13.0 → 0.13.1
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/dist/catalog/types.d.ts +10 -1
- package/dist/expression/filter.d.ts +4 -3
- package/dist/expression/filter.js +51 -7
- package/dist/language_version_value.d.ts +1 -1
- package/dist/language_version_value.js +1 -1
- package/dist/parser/ast.d.ts +19 -4
- package/dist/parser/ast.js +9 -5
- package/dist/wasm/movement.wasm +0 -0
- package/dist/wasm/movement_parser.wasm +0 -0
- package/package.json +1 -1
package/dist/catalog/types.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export interface ConstructionArg {
|
|
|
27
27
|
label?: string;
|
|
28
28
|
}
|
|
29
29
|
export interface AdapterSpec {
|
|
30
|
+
/**
|
|
31
|
+
* The package the module is installed from (`@lf/github`), which a
|
|
32
|
+
* `connect` names it by. Absent for a module known only by its key: a
|
|
33
|
+
* project's local command, file or server, an embedding host's adapter.
|
|
34
|
+
*/
|
|
35
|
+
package?: string;
|
|
30
36
|
/**
|
|
31
37
|
* The adapter's full construction signature — the credential (if any) folded
|
|
32
38
|
* in as a `kind: 'credential'` entry, plus every entry-position arg.
|
|
@@ -773,10 +779,13 @@ export interface PositionSchema {
|
|
|
773
779
|
fieldIds?: Record<string, string>;
|
|
774
780
|
/** The fields whose meaning its module changed in a release, by name: a
|
|
775
781
|
* check for an upgrade from before that release warns where a program
|
|
776
|
-
* reads one (gmail's `Labels`, ids before 0.13 and names since).
|
|
782
|
+
* reads one (gmail's `Labels`, ids before 0.13 and names since).
|
|
783
|
+
* `unchangedValues`: the values whose meaning did not change; a comparison
|
|
784
|
+
* with literals all among them is not warned. */
|
|
777
785
|
changedFields?: Record<string, {
|
|
778
786
|
release: string;
|
|
779
787
|
note: string;
|
|
788
|
+
unchangedValues?: string[];
|
|
780
789
|
}>;
|
|
781
790
|
}
|
|
782
791
|
/**
|
|
@@ -91,9 +91,10 @@ export declare function isNullLiteral(expr: Expression): boolean;
|
|
|
91
91
|
*/
|
|
92
92
|
export declare function compareToNull(op: FilterOperator, value: unknown): boolean;
|
|
93
93
|
/**
|
|
94
|
-
* Scalar comparison semantics
|
|
95
|
-
* (
|
|
96
|
-
*
|
|
94
|
+
* Scalar comparison semantics, exactly as the engine's judge decides them
|
|
95
|
+
* (crates/movement-engine filter.rs `compare_values`, held to
|
|
96
|
+
* engine-contracts/conformance/taken-comparisons.json), so adapters filtering
|
|
97
|
+
* through this unit decide a comparison as the engine does.
|
|
97
98
|
*/
|
|
98
99
|
export declare function compareValues(left: unknown, op: FilterOperator, right: unknown, options?: {
|
|
99
100
|
now?: number;
|
|
@@ -387,9 +387,10 @@ function compareToNull(op, value) {
|
|
|
387
387
|
return false;
|
|
388
388
|
}
|
|
389
389
|
/**
|
|
390
|
-
* Scalar comparison semantics
|
|
391
|
-
* (
|
|
392
|
-
*
|
|
390
|
+
* Scalar comparison semantics, exactly as the engine's judge decides them
|
|
391
|
+
* (crates/movement-engine filter.rs `compare_values`, held to
|
|
392
|
+
* engine-contracts/conformance/taken-comparisons.json), so adapters filtering
|
|
393
|
+
* through this unit decide a comparison as the engine does.
|
|
393
394
|
*/
|
|
394
395
|
function compareValues(left, op, right, options = {}) {
|
|
395
396
|
switch (op) {
|
|
@@ -462,15 +463,58 @@ function durationToMs(spec) {
|
|
|
462
463
|
return null;
|
|
463
464
|
return parseFloat(match[1]) * DURATION_UNIT_MS[match[2].toLowerCase()];
|
|
464
465
|
}
|
|
465
|
-
/**
|
|
466
|
-
|
|
466
|
+
/** Days from 1970-01-01 to a proleptic Gregorian date. */
|
|
467
|
+
function daysFromCivil(year, month, day) {
|
|
468
|
+
const y = month <= 2 ? year - 1 : year;
|
|
469
|
+
const era = Math.floor(y / 400);
|
|
470
|
+
const yoe = y - era * 400;
|
|
471
|
+
const doy = Math.floor((153 * ((month + 9) % 12) + 2) / 5) + day - 1;
|
|
472
|
+
return era * 146_097 + yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy - 719_468;
|
|
473
|
+
}
|
|
474
|
+
const ISO_INSTANT = /^(?:([+-])(\d{6})|(\d{4}))(?:-(\d{2})(?:-(\d{2}))?)?(?:[Tt ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?([Zz]|[+-]\d{2}:?\d{2})?)?$/;
|
|
475
|
+
/** An ISO 8601 / RFC 3339 text as an instant (epoch ms), a text with no
|
|
476
|
+
* offset read as UTC; null for any other text, a day its month lacks, the
|
|
477
|
+
* hour 24 (crates/movement-engine js_date.rs `parse`). `new Date` is not
|
|
478
|
+
* this: it reads a text with no offset in the host's zone, and reads texts
|
|
479
|
+
* like `Mar 5, 2024` the engine orders as text. */
|
|
480
|
+
function isoInstant(text) {
|
|
481
|
+
const m = ISO_INSTANT.exec(text);
|
|
482
|
+
if (m === null)
|
|
483
|
+
return null;
|
|
484
|
+
const [, sign, signed, plain, mm, dd, hh, mi, ss, fraction, offset] = m;
|
|
485
|
+
if (sign === '-' && Number(signed) === 0)
|
|
486
|
+
return null;
|
|
487
|
+
const year = plain !== undefined ? Number(plain) : (sign === '-' ? -1 : 1) * Number(signed);
|
|
488
|
+
const month = mm !== undefined ? Number(mm) : 1;
|
|
489
|
+
const day = dd !== undefined ? Number(dd) : 1;
|
|
490
|
+
const nextMonth = month === 12 ? daysFromCivil(year + 1, 1, 1) : daysFromCivil(year, month + 1, 1);
|
|
491
|
+
if (month < 1 || month > 12 || day < 1 || day > nextMonth - daysFromCivil(year, month, 1))
|
|
492
|
+
return null;
|
|
493
|
+
let ms = daysFromCivil(year, month, day) * 86_400_000;
|
|
494
|
+
if (hh !== undefined) {
|
|
495
|
+
const [hour, minute, second] = [Number(hh), Number(mi), ss !== undefined ? Number(ss) : 0];
|
|
496
|
+
if (hour > 23 || minute > 59 || second > 59)
|
|
497
|
+
return null;
|
|
498
|
+
ms += hour * 3_600_000 + minute * 60_000 + second * 1000 + (fraction !== undefined ? Number(fraction.slice(0, 3).padEnd(3, '0')) : 0);
|
|
499
|
+
if (offset !== undefined && offset.toUpperCase() !== 'Z') {
|
|
500
|
+
const [hours, minutes] = [Number(offset.slice(1, 3)), Number(offset.slice(-2))];
|
|
501
|
+
if (hours > 23 || minutes > 59)
|
|
502
|
+
return null;
|
|
503
|
+
ms += (offset.startsWith('+') ? -1 : 1) * (hours * 60 + minutes) * 60_000;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return Number.isFinite(ms) && Math.abs(ms) <= 8.64e15 ? Math.trunc(ms) + 0 : null;
|
|
507
|
+
}
|
|
508
|
+
/** A value as an instant (epoch ms): a finite number as itself, a boolean as
|
|
509
|
+
* 0 or 1, anything else by its text, as an ISO instant. */
|
|
467
510
|
function toEpochMs(value) {
|
|
468
511
|
if (value === null || value === undefined)
|
|
469
512
|
return null;
|
|
470
513
|
if (typeof value === 'number')
|
|
471
514
|
return Number.isFinite(value) ? value : null;
|
|
472
|
-
|
|
473
|
-
|
|
515
|
+
if (typeof value === 'boolean')
|
|
516
|
+
return value ? 1 : 0;
|
|
517
|
+
return isoInstant(String(value));
|
|
474
518
|
}
|
|
475
519
|
/** A value as a finite number — a number as-is, a numeric string parsed.
|
|
476
520
|
* null/undefined/booleans/objects and non-numeric strings → null. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.13.
|
|
1
|
+
export declare const PACKAGE_VERSION = "0.13.1";
|
|
@@ -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.13.
|
|
8
|
+
exports.PACKAGE_VERSION = '0.13.1';
|
package/dist/parser/ast.d.ts
CHANGED
|
@@ -254,6 +254,10 @@ export interface ConstructionCall {
|
|
|
254
254
|
callee: string;
|
|
255
255
|
args: NamedArg[];
|
|
256
256
|
span: Span;
|
|
257
|
+
/** Written `connect x using c`, whose adapter and credential need no import. */
|
|
258
|
+
connect?: true;
|
|
259
|
+
/** Written `connect #x`: `x` is a module of the project's own (no package), by its key. */
|
|
260
|
+
own?: true;
|
|
257
261
|
}
|
|
258
262
|
/**
|
|
259
263
|
* A value-position `f(a: x)` read as the CALL it is when `f` resolves to a
|
|
@@ -1332,13 +1336,24 @@ export interface ValueTypeKey {
|
|
|
1332
1336
|
optional?: true;
|
|
1333
1337
|
span: Span;
|
|
1334
1338
|
}
|
|
1335
|
-
/**
|
|
1336
|
-
|
|
1339
|
+
/**
|
|
1340
|
+
* `<crm-[:Memo]-> | crm-[:Remark]->>` — a value that is one of several
|
|
1341
|
+
* records: TypeScript's `Memo | Remark`. At least two members, each a record
|
|
1342
|
+
* type written as a parameter's is.
|
|
1343
|
+
*/
|
|
1344
|
+
export interface UnionTypeRef {
|
|
1345
|
+
kind: 'union';
|
|
1346
|
+
members: TypeRef[];
|
|
1347
|
+
span: Span;
|
|
1348
|
+
}
|
|
1349
|
+
/** A parameter's written type: a name, a value type spelled in full, or a
|
|
1350
|
+
* union of record types. */
|
|
1351
|
+
export type ParamTypeRef = TypeRef | ValueTypeRef | UnionTypeRef;
|
|
1337
1352
|
/** Is this parameter type a value type spelled in full (rather than a name)? */
|
|
1338
1353
|
export declare function isValueTypeRef(type: ParamTypeRef): type is ValueTypeRef;
|
|
1339
1354
|
/** The parameter type as a NAME (a position, a node declaration, a scalar, a
|
|
1340
|
-
* refinement) — undefined when none was written or it is a value type
|
|
1341
|
-
* in full, which names
|
|
1355
|
+
* refinement) — undefined when none was written, or it is a value type
|
|
1356
|
+
* spelled in full or a union, neither of which names one graph. */
|
|
1342
1357
|
export declare function typeNameOf(type: ParamTypeRef | undefined): TypeRef | undefined;
|
|
1343
1358
|
/** A parameter's written type in its surface spelling, without the brackets. */
|
|
1344
1359
|
export declare function spellParamType(type: ParamTypeRef): string;
|
package/dist/parser/ast.js
CHANGED
|
@@ -174,17 +174,21 @@ function isPositionalCall(args) {
|
|
|
174
174
|
}
|
|
175
175
|
/** Is this parameter type a value type spelled in full (rather than a name)? */
|
|
176
176
|
function isValueTypeRef(type) {
|
|
177
|
-
return 'kind' in type;
|
|
177
|
+
return 'kind' in type && type.kind !== 'union';
|
|
178
178
|
}
|
|
179
179
|
/** The parameter type as a NAME (a position, a node declaration, a scalar, a
|
|
180
|
-
* refinement) — undefined when none was written or it is a value type
|
|
181
|
-
* in full, which names
|
|
180
|
+
* refinement) — undefined when none was written, or it is a value type
|
|
181
|
+
* spelled in full or a union, neither of which names one graph. */
|
|
182
182
|
function typeNameOf(type) {
|
|
183
|
-
return type === undefined ||
|
|
183
|
+
return type === undefined || 'kind' in type ? undefined : type;
|
|
184
184
|
}
|
|
185
185
|
/** A parameter's written type in its surface spelling, without the brackets. */
|
|
186
186
|
function spellParamType(type) {
|
|
187
|
-
|
|
187
|
+
if (!('kind' in type))
|
|
188
|
+
return `${type.graph}${type.hopsRaw ?? ''}`;
|
|
189
|
+
if (type.kind === 'union')
|
|
190
|
+
return type.members.map((member) => `${member.graph}${member.hopsRaw ?? ''}`).join(' | ');
|
|
191
|
+
return spellValueType(type);
|
|
188
192
|
}
|
|
189
193
|
/** A written value type in its surface spelling, for diagnostics. */
|
|
190
194
|
function spellValueType(type) {
|
package/dist/wasm/movement.wasm
CHANGED
|
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.13.
|
|
4
|
+
"version": "0.13.1",
|
|
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"
|