@listen-fire/movement-lang 0.15.2 → 0.15.3
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 +3 -0
- package/dist/checker/standard_library.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/language_version_value.d.ts +1 -1
- package/dist/language_version_value.js +1 -1
- package/dist/service/description.d.ts +103 -0
- package/dist/service/description.js +142 -0
- package/dist/wasm/loader.d.ts +13 -0
- package/dist/wasm/loader.js +14 -0
- 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
|
@@ -985,6 +985,9 @@ export interface CollectionSchema extends EdgeListening {
|
|
|
985
985
|
cursor?: boolean;
|
|
986
986
|
identity?: string;
|
|
987
987
|
version?: string;
|
|
988
|
+
/** What the module says of what lands here, where the type has no position
|
|
989
|
+
* to say it on (one known only by what is written to it). */
|
|
990
|
+
description?: string;
|
|
988
991
|
}
|
|
989
992
|
/**
|
|
990
993
|
* The schema of a constructed instance — produced per construction because
|
|
@@ -13,8 +13,8 @@ export interface StandardBuiltin {
|
|
|
13
13
|
* table (`surfaceTable`) gives the name an author writes. */
|
|
14
14
|
name: string;
|
|
15
15
|
params: readonly StandardBuiltinParam[];
|
|
16
|
-
/** What a call gives back, as
|
|
17
|
-
*
|
|
16
|
+
/** What a call gives back, as a program writes a type (`text[]`,
|
|
17
|
+
* `text | null`), or `derived`: it follows from the arguments. */
|
|
18
18
|
returns: string;
|
|
19
19
|
/** One line for listings. `RETIRED — …` for a built-in kept only so old
|
|
20
20
|
* automations still read. */
|
package/dist/index.d.ts
CHANGED
|
@@ -19,4 +19,5 @@ export * from './checker/standard_library';
|
|
|
19
19
|
export type { MExpr } from './parser/expression/tree';
|
|
20
20
|
export * from './service/snapshot';
|
|
21
21
|
export * from './service/language_service';
|
|
22
|
+
export * from './service/description';
|
|
22
23
|
export * from './language_version';
|
package/dist/index.js
CHANGED
|
@@ -46,4 +46,5 @@ __exportStar(require("./checker/story_analysis"), exports);
|
|
|
46
46
|
__exportStar(require("./checker/standard_library"), exports);
|
|
47
47
|
__exportStar(require("./service/snapshot"), exports);
|
|
48
48
|
__exportStar(require("./service/language_service"), exports);
|
|
49
|
+
__exportStar(require("./service/description"), exports);
|
|
49
50
|
__exportStar(require("./language_version"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "0.15.
|
|
1
|
+
export declare const PACKAGE_VERSION = "0.15.3";
|
|
@@ -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.
|
|
8
|
+
exports.PACKAGE_VERSION = '0.15.3';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { CatalogSnapshot } from './snapshot';
|
|
2
|
+
/** How much of a place to show. Absent: all of it. */
|
|
3
|
+
export interface Showing {
|
|
4
|
+
/** At most this many fields per list: required first, then identifying. */
|
|
5
|
+
fields?: number;
|
|
6
|
+
/** At most this many options per enum, the rest counted (`"a" | "b" | …+3`). */
|
|
7
|
+
enumOptions?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DescriptionLevels {
|
|
10
|
+
/** How much of the place itself. */
|
|
11
|
+
showing?: Showing;
|
|
12
|
+
/** How much of where each of its edges lands. */
|
|
13
|
+
landings?: Showing;
|
|
14
|
+
}
|
|
15
|
+
export interface DescribedField {
|
|
16
|
+
name: string;
|
|
17
|
+
/** The whole field as the catalog writes it: `` `Message Id`!* text ``,
|
|
18
|
+
* `` `Reply Markup` json (write only) ``. */
|
|
19
|
+
written: string;
|
|
20
|
+
/** Its name and marks alone, as a write's field list writes it: `Text!`. */
|
|
21
|
+
markedName: string;
|
|
22
|
+
/** Its type as a program writes it. */
|
|
23
|
+
type: string;
|
|
24
|
+
required: boolean;
|
|
25
|
+
identifying: boolean;
|
|
26
|
+
readOnly: boolean;
|
|
27
|
+
/** A field only a write gives, on a type that can be read. */
|
|
28
|
+
writeOnly: boolean;
|
|
29
|
+
/** A read's WHERE must set it with `==`. */
|
|
30
|
+
pinned: boolean;
|
|
31
|
+
description?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface DescribedFields {
|
|
34
|
+
shown: DescribedField[];
|
|
35
|
+
/** How many `Showing.fields` left out. */
|
|
36
|
+
cut: number;
|
|
37
|
+
}
|
|
38
|
+
export interface DescribedEdge {
|
|
39
|
+
name: string;
|
|
40
|
+
/** The hop alone, as a walk writes it: ``-[:`Linked Users`]->``. */
|
|
41
|
+
step: string;
|
|
42
|
+
/** The hop, where it lands and what it can do: ``-[:Replies]-> Message [w]``. */
|
|
43
|
+
hop: string;
|
|
44
|
+
/** The type it lands on; null where its members land apart. */
|
|
45
|
+
target: string | null;
|
|
46
|
+
read: boolean;
|
|
47
|
+
write: boolean;
|
|
48
|
+
fires: boolean;
|
|
49
|
+
description?: string;
|
|
50
|
+
/** What a write along it takes, where one can be written. */
|
|
51
|
+
writes?: DescribedFields;
|
|
52
|
+
/** Where it lands, one level deep: its own edges carry no landing. */
|
|
53
|
+
lands?: DescribedPlace;
|
|
54
|
+
}
|
|
55
|
+
export type Known = 'whole' | 'open' | 'undescribed';
|
|
56
|
+
export interface DescribedPlace {
|
|
57
|
+
/** The type's name as its module shows it. */
|
|
58
|
+
name: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
/** `open`: its module has fields no description names; `undescribed`: nothing has looked at it. */
|
|
61
|
+
known: Known;
|
|
62
|
+
/** What it may be, where it is one of several types. */
|
|
63
|
+
members: string[];
|
|
64
|
+
fields: DescribedFields;
|
|
65
|
+
edges: DescribedEdge[];
|
|
66
|
+
}
|
|
67
|
+
export interface DescribedDiagnostic {
|
|
68
|
+
code: string;
|
|
69
|
+
message: string;
|
|
70
|
+
severity: 'error' | 'warning' | 'info';
|
|
71
|
+
}
|
|
72
|
+
/** Every connection a snapshot describes, at its root. */
|
|
73
|
+
export interface CatalogDescription {
|
|
74
|
+
/** The notation's one line, said once at the top of a text in it. */
|
|
75
|
+
legend: string;
|
|
76
|
+
connections: Array<{
|
|
77
|
+
adapter: string;
|
|
78
|
+
key: string;
|
|
79
|
+
place: DescribedPlace;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
/** The one connection or place an address names. */
|
|
83
|
+
export interface AddressDescription {
|
|
84
|
+
legend: string;
|
|
85
|
+
diagnostics: DescribedDiagnostic[];
|
|
86
|
+
/** Null where a diagnostic is an error, or nothing describes where it lands. */
|
|
87
|
+
place: DescribedPlace | null;
|
|
88
|
+
/** An address with no walk: each record type the connection holds, by the
|
|
89
|
+
* name a program's type writes (`<c-[:Message]->>`). */
|
|
90
|
+
records?: Array<{
|
|
91
|
+
name: string;
|
|
92
|
+
place: DescribedPlace;
|
|
93
|
+
}>;
|
|
94
|
+
}
|
|
95
|
+
/** Every connection `snapshot` describes, each at its root with where each of its edges lands. */
|
|
96
|
+
export declare function describeCatalog(snapshot: CatalogSnapshot, levels?: DescriptionLevels): CatalogDescription;
|
|
97
|
+
/**
|
|
98
|
+
* The connection or place `address` names, written as `listen-fire catalog
|
|
99
|
+
* '<address>'` takes one (`'@lf/slack:team_workspace-[:Channels]->'`): read,
|
|
100
|
+
* checked and walked by the checker, so a misspelt edge comes back as its
|
|
101
|
+
* diagnostic.
|
|
102
|
+
*/
|
|
103
|
+
export declare function describeAddress(snapshot: CatalogSnapshot, address: string, levels?: DescriptionLevels): AddressDescription;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// What a catalog holds, as the one description every tool reads
|
|
3
|
+
// (crates/movement-checker/src/description.rs), through the movement
|
|
4
|
+
// artifact's `describe_query` export. Every name, type, hop and mark arrives
|
|
5
|
+
// spelled as `listen-fire catalog` spells it: a caller chooses how much to
|
|
6
|
+
// show (`Showing`) and lays the parts out, and never spells one itself.
|
|
7
|
+
//
|
|
8
|
+
// It loads with the engine artifact, which a browser never downloads.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.describeCatalog = describeCatalog;
|
|
11
|
+
exports.describeAddress = describeAddress;
|
|
12
|
+
const loader_1 = require("../wasm/loader");
|
|
13
|
+
const rust_checker_1 = require("../checker/rust_checker");
|
|
14
|
+
/** Every connection `snapshot` describes, each at its root with where each of its edges lands. */
|
|
15
|
+
function describeCatalog(snapshot, levels = {}) {
|
|
16
|
+
const answer = ask(snapshot, levels);
|
|
17
|
+
if (!isRecord(answer) || !Array.isArray(answer.connections))
|
|
18
|
+
throw malformed('catalog description', answer);
|
|
19
|
+
return {
|
|
20
|
+
legend: stringOf(answer.legend, 'legend'),
|
|
21
|
+
connections: answer.connections.map((connection) => {
|
|
22
|
+
if (!isRecord(connection))
|
|
23
|
+
throw malformed('connection', connection);
|
|
24
|
+
return { adapter: stringOf(connection.adapter, 'adapter'), key: stringOf(connection.key, 'key'), place: placeOf(connection.place) };
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The connection or place `address` names, written as `listen-fire catalog
|
|
30
|
+
* '<address>'` takes one (`'@lf/slack:team_workspace-[:Channels]->'`): read,
|
|
31
|
+
* checked and walked by the checker, so a misspelt edge comes back as its
|
|
32
|
+
* diagnostic.
|
|
33
|
+
*/
|
|
34
|
+
function describeAddress(snapshot, address, levels = {}) {
|
|
35
|
+
const answer = ask(snapshot, { address, ...levels });
|
|
36
|
+
if (!isRecord(answer) || !Array.isArray(answer.diagnostics))
|
|
37
|
+
throw malformed('address description', answer);
|
|
38
|
+
const records = answer.records;
|
|
39
|
+
if (records !== undefined && !Array.isArray(records))
|
|
40
|
+
throw malformed('record types', records);
|
|
41
|
+
return {
|
|
42
|
+
legend: stringOf(answer.legend, 'legend'),
|
|
43
|
+
diagnostics: answer.diagnostics.map(diagnosticOf),
|
|
44
|
+
place: answer.place === null ? null : placeOf(answer.place),
|
|
45
|
+
...(records !== undefined
|
|
46
|
+
? {
|
|
47
|
+
records: records.map((record) => {
|
|
48
|
+
if (!isRecord(record))
|
|
49
|
+
throw malformed('record type', record);
|
|
50
|
+
return { name: stringOf(record.name, 'record type name'), place: placeOf(record.place) };
|
|
51
|
+
}),
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function ask(snapshot, request) {
|
|
57
|
+
const reply = (0, loader_1.callDescribeQuery)(JSON.stringify(snapshot), JSON.stringify(request));
|
|
58
|
+
if (!reply.ok)
|
|
59
|
+
throw rust_checker_1.RustCheckRefused.of(reply.json);
|
|
60
|
+
return reply.json;
|
|
61
|
+
}
|
|
62
|
+
function placeOf(value) {
|
|
63
|
+
if (!isRecord(value) || !Array.isArray(value.members) || !Array.isArray(value.edges))
|
|
64
|
+
throw malformed('place', value);
|
|
65
|
+
return {
|
|
66
|
+
name: stringOf(value.name, 'place name'),
|
|
67
|
+
...optionalString(value.description, 'place description'),
|
|
68
|
+
known: knownOf(value.known),
|
|
69
|
+
members: value.members.map((member) => stringOf(member, 'member')),
|
|
70
|
+
fields: fieldsOf(value.fields),
|
|
71
|
+
edges: value.edges.map(edgeOf),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function knownOf(value) {
|
|
75
|
+
if (value === 'whole' || value === 'open' || value === 'undescribed')
|
|
76
|
+
return value;
|
|
77
|
+
throw malformed('known', value);
|
|
78
|
+
}
|
|
79
|
+
function fieldsOf(value) {
|
|
80
|
+
if (!isRecord(value) || !Array.isArray(value.shown) || typeof value.cut !== 'number')
|
|
81
|
+
throw malformed('field list', value);
|
|
82
|
+
return { shown: value.shown.map(fieldOf), cut: value.cut };
|
|
83
|
+
}
|
|
84
|
+
function fieldOf(value) {
|
|
85
|
+
if (!isRecord(value))
|
|
86
|
+
throw malformed('field', value);
|
|
87
|
+
return {
|
|
88
|
+
name: stringOf(value.name, 'field name'),
|
|
89
|
+
written: stringOf(value.written, 'field'),
|
|
90
|
+
markedName: stringOf(value.markedName, 'field name and marks'),
|
|
91
|
+
type: stringOf(value.type, 'field type'),
|
|
92
|
+
required: booleanOf(value.required, 'required'),
|
|
93
|
+
identifying: booleanOf(value.identifying, 'identifying'),
|
|
94
|
+
readOnly: booleanOf(value.readOnly, 'readOnly'),
|
|
95
|
+
writeOnly: booleanOf(value.writeOnly, 'writeOnly'),
|
|
96
|
+
pinned: booleanOf(value.pinned, 'pinned'),
|
|
97
|
+
...optionalString(value.description, 'field description'),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function edgeOf(value) {
|
|
101
|
+
if (!isRecord(value) || (value.target !== null && typeof value.target !== 'string'))
|
|
102
|
+
throw malformed('edge', value);
|
|
103
|
+
return {
|
|
104
|
+
name: stringOf(value.name, 'edge name'),
|
|
105
|
+
step: stringOf(value.step, 'step'),
|
|
106
|
+
hop: stringOf(value.hop, 'hop'),
|
|
107
|
+
target: value.target,
|
|
108
|
+
read: booleanOf(value.read, 'read'),
|
|
109
|
+
write: booleanOf(value.write, 'write'),
|
|
110
|
+
fires: booleanOf(value.fires, 'fires'),
|
|
111
|
+
...optionalString(value.description, 'edge description'),
|
|
112
|
+
...(value.writes !== undefined ? { writes: fieldsOf(value.writes) } : {}),
|
|
113
|
+
...(value.lands !== undefined ? { lands: placeOf(value.lands) } : {}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function diagnosticOf(value) {
|
|
117
|
+
if (!isRecord(value))
|
|
118
|
+
throw malformed('diagnostic', value);
|
|
119
|
+
const { severity } = value;
|
|
120
|
+
if (severity !== 'error' && severity !== 'warning' && severity !== 'info')
|
|
121
|
+
throw malformed('severity', severity);
|
|
122
|
+
return { code: stringOf(value.code, 'code'), message: stringOf(value.message, 'message'), severity };
|
|
123
|
+
}
|
|
124
|
+
function stringOf(value, what) {
|
|
125
|
+
if (typeof value !== 'string')
|
|
126
|
+
throw malformed(what, value);
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
function booleanOf(value, what) {
|
|
130
|
+
if (typeof value !== 'boolean')
|
|
131
|
+
throw malformed(what, value);
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
function optionalString(value, what) {
|
|
135
|
+
return value === undefined ? {} : { description: stringOf(value, what) };
|
|
136
|
+
}
|
|
137
|
+
function isRecord(value) {
|
|
138
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
139
|
+
}
|
|
140
|
+
function malformed(what, value) {
|
|
141
|
+
return new Error(`the describing query answered a ${what} that is not one: ${JSON.stringify(value)?.slice(0, 200)}`);
|
|
142
|
+
}
|
package/dist/wasm/loader.d.ts
CHANGED
|
@@ -140,6 +140,19 @@ export declare function callLanguageQuery(source: string, snapshotJson: string,
|
|
|
140
140
|
ok: boolean;
|
|
141
141
|
json: unknown;
|
|
142
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* The describing query (crates/movement-language/src/describe.rs
|
|
145
|
+
* `describe_query`): the snapshot and the request as JSON, and the reply —
|
|
146
|
+
* what the snapshot holds, or the one connection or place an address names,
|
|
147
|
+
* as the description value — or `{error}` for a snapshot or a request that
|
|
148
|
+
* does not read.
|
|
149
|
+
*
|
|
150
|
+
* @internal Used by the description's wrapper (service/description.ts).
|
|
151
|
+
*/
|
|
152
|
+
export declare function callDescribeQuery(snapshotJson: string, requestJson: string): {
|
|
153
|
+
ok: boolean;
|
|
154
|
+
json: unknown;
|
|
155
|
+
};
|
|
143
156
|
/**
|
|
144
157
|
* The checker's story analysis (crates/movement-checker/src/story.rs
|
|
145
158
|
* `story_analysis`): `callCheckProgram`'s inputs, and the reply —
|
package/dist/wasm/loader.js
CHANGED
|
@@ -35,6 +35,7 @@ exports.callStandardLibrary = callStandardLibrary;
|
|
|
35
35
|
exports.callLanguageVersion = callLanguageVersion;
|
|
36
36
|
exports.callLanguageStanding = callLanguageStanding;
|
|
37
37
|
exports.callLanguageQuery = callLanguageQuery;
|
|
38
|
+
exports.callDescribeQuery = callDescribeQuery;
|
|
38
39
|
exports.callStoryAnalysis = callStoryAnalysis;
|
|
39
40
|
exports.callJudgeArrival = callJudgeArrival;
|
|
40
41
|
exports.callListenIdentity = callListenIdentity;
|
|
@@ -202,6 +203,18 @@ function callLanguageStanding(pin) {
|
|
|
202
203
|
function callLanguageQuery(source, snapshotJson, queryJson) {
|
|
203
204
|
return callChecker('language_query', [source, snapshotJson, queryJson], []);
|
|
204
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* The describing query (crates/movement-language/src/describe.rs
|
|
208
|
+
* `describe_query`): the snapshot and the request as JSON, and the reply —
|
|
209
|
+
* what the snapshot holds, or the one connection or place an address names,
|
|
210
|
+
* as the description value — or `{error}` for a snapshot or a request that
|
|
211
|
+
* does not read.
|
|
212
|
+
*
|
|
213
|
+
* @internal Used by the description's wrapper (service/description.ts).
|
|
214
|
+
*/
|
|
215
|
+
function callDescribeQuery(snapshotJson, requestJson) {
|
|
216
|
+
return callChecker('describe_query', [snapshotJson, requestJson], []);
|
|
217
|
+
}
|
|
205
218
|
/**
|
|
206
219
|
* The checker's story analysis (crates/movement-checker/src/story.rs
|
|
207
220
|
* `story_analysis`): `callCheckProgram`'s inputs, and the reply —
|
|
@@ -518,6 +531,7 @@ function readExports(raw) {
|
|
|
518
531
|
'language_version',
|
|
519
532
|
'language_standing',
|
|
520
533
|
'language_query',
|
|
534
|
+
'describe_query',
|
|
521
535
|
'story_analysis',
|
|
522
536
|
'judge_arrival',
|
|
523
537
|
'listen_identity',
|
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.15.
|
|
4
|
+
"version": "0.15.3",
|
|
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"
|