@niscorp/moss 0.9.2 → 0.9.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/CHANGELOG.md +12 -0
- package/DOCS.md +21 -2
- package/dist/{chunk-WMIJU6ZZ.js → chunk-6MZPY4X6.js} +51 -10
- package/dist/chunk-6MZPY4X6.js.map +1 -0
- package/dist/{chunk-KVXP6OTW.cjs → chunk-EXMOO7ZR.cjs} +105 -64
- package/dist/chunk-EXMOO7ZR.cjs.map +1 -0
- package/dist/{chunk-5ZB7FZ2J.js → chunk-MVG333UF.js} +4 -3
- package/dist/chunk-MVG333UF.js.map +1 -0
- package/dist/{chunk-FUJRIO4N.js → chunk-TAAKHW3U.js} +3 -3
- package/dist/{chunk-FUJRIO4N.js.map → chunk-TAAKHW3U.js.map} +1 -1
- package/dist/{chunk-6ZWMC2OV.cjs → chunk-U43CBKKE.cjs} +3 -2
- package/dist/chunk-U43CBKKE.cjs.map +1 -0
- package/dist/{chunk-KMZT6NVL.cjs → chunk-YGZS5B2U.cjs} +5 -5
- package/dist/{chunk-KMZT6NVL.cjs.map → chunk-YGZS5B2U.cjs.map} +1 -1
- package/dist/{document-C3aS9uiW.d.ts → document-BzXQvEc1.d.ts} +2 -1
- package/dist/{document-deAs7Dre.d.cts → document-CuF4JqzJ.d.cts} +2 -1
- package/dist/index.cjs +14 -14
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/node.cjs +7 -7
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -3
- package/dist/unverified.cjs +2 -2
- package/dist/unverified.js +1 -1
- package/dist/vite.cjs +8 -8
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +3 -3
- package/package.json +7 -7
- package/dist/chunk-5ZB7FZ2J.js.map +0 -1
- package/dist/chunk-6ZWMC2OV.cjs.map +0 -1
- package/dist/chunk-KVXP6OTW.cjs.map +0 -1
- package/dist/chunk-WMIJU6ZZ.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @niscorp/moss
|
|
2
2
|
|
|
3
|
+
## 0.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 637d412: **A vex read returns stamped JSON columns upgraded.** A JSON column whose values carry the grammar stamp they were written at in another JSON column of the row can now be named once on the engine, with a strata upgrader beside it: `createQueryEngine({ upgrader: await createUpgrader(grammars, { transform: evaluate }), upgradedColumns: { answers: { plan: { stamp: 'grammar', kind: 'acme.answers/plan' } } } })`. A kind can also be read from the row: `kind: { grammar: 'acme.notes', column: 'kind' }`. Every read that returns the column (a replay, a generated read, a reactive read's every answer, `engine.test`) hands its mapping and its caller the value upgraded, with the stamp set to the stamp the upgrade gives back. A read returns the column only as one of its own fields, with its stamp (and kind) column beside it; vex refuses any other read of it when the read is compiled. A row that does not upgrade refuses the read, or, where the column says `unreadable: 'omit'` or `'null'`, is left out or has that value set to null, with a line in `meta.warnings`. New exports: `UpgradedColumnsSchema`, `UNREADABLE_MODES`, and the types `UpgradedColumn`, `UpgradedColumns`, `ColumnUpgrader`.
|
|
8
|
+
|
|
9
|
+
**Moss takes them on the manifest.** `defineApp({ upgradedColumns })` hands them to the app's engine and to the one that answers intents, with the upgrader moss builds from nova's, Prism's and vex's grammars and the app's `grammars`. Only the app's own tables can be named. The boot is refused where a table named is a feature's, the artifactory's or the generation pointer's (their owners read them as stored), where a kind is in none of those grammars, where a column or its stamp is not a json column of the database, or where a seeded read does not compile: an app that names `upgradedColumns` has every seeded read compiled at boot and on a refresh, so a read of an upgraded column that vex refuses stops the boot rather than its first replay.
|
|
10
|
+
|
|
11
|
+
**The rulebook** says so under "Using Vex" and in rule 19.
|
|
12
|
+
|
|
13
|
+
**What to change:** nothing. An app or engine that names no `upgradedColumns` reads every column as stored, as before. No grammar, table, entry or cache format changes.
|
|
14
|
+
|
|
3
15
|
## 0.9.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/DOCS.md
CHANGED
|
@@ -59,6 +59,7 @@ type NiscApp = {
|
|
|
59
59
|
shell?: ShellManifest; // the server shell, as data — THE APP
|
|
60
60
|
pages?: Record<string, PageManifest>; // what is drawn at a path and kept by nothing
|
|
61
61
|
grammars?: readonly Sequence[]; // the app's own strata grammar sequences
|
|
62
|
+
upgradedColumns?: UpgradedColumns; // JSON columns every vex read returns upgraded
|
|
62
63
|
// the code seams
|
|
63
64
|
scope?: (principal: string | null, identity?: IdentityRecord) => Record<string, unknown>;
|
|
64
65
|
identity?: { as?: string; resolve: (principal, read) => Promise<IdentityRecord> };
|
|
@@ -190,8 +191,26 @@ reaction's `run` — and `features`. Absent `shell`, the app serves data only
|
|
|
190
191
|
app does not hand over: ``shell.canvases.1.reconcile: "keyed" is not a
|
|
191
192
|
reconciler the app hands over in `reconcilers` ``.
|
|
192
193
|
- `grammars` — strata sequences for documents only this app defines the shape
|
|
193
|
-
of (its kit's component props
|
|
194
|
-
grammars" below.
|
|
194
|
+
of (its kit's component props, and the values of its `upgradedColumns`). See
|
|
195
|
+
"Documents are read in this code's grammars" below.
|
|
196
|
+
- `upgradedColumns` — the app's JSON columns whose values are stamped in
|
|
197
|
+
another column of the row, keyed by table and column:
|
|
198
|
+
`{ answers: { plan: { stamp: 'grammar', kind: 'acme.answers/plan' } } }`, or
|
|
199
|
+
with the kind read from the row, `kind: { grammar: 'acme.notes', column: 'kind' }`,
|
|
200
|
+
and what a read does with a row that does not upgrade, `unreadable: 'refuse' | 'omit' | 'null'`.
|
|
201
|
+
Moss hands them to the app's engine, and to the one that answers intents,
|
|
202
|
+
with the upgrader it builds from nova's, Prism's and vex's grammars and the
|
|
203
|
+
app's `grammars`: every read through either returns those columns upgraded,
|
|
204
|
+
before its mapping. What a read must select and what a row that does not
|
|
205
|
+
upgrade does are vex's ([Upgraded columns](../vex/DOCS.md#upgraded-columns)).
|
|
206
|
+
Only the app's own tables can be named: a feature's tables, the
|
|
207
|
+
artifactory's and the generation pointer's are read by their owner's own
|
|
208
|
+
entries, which read them as stored. **The boot is refused** where a table
|
|
209
|
+
named is one of those, where a kind, or the grammar of a kind read from the
|
|
210
|
+
row, is in none of the upgrader's grammars, where a column or its stamp is not a json
|
|
211
|
+
column of the database, and where a seeded read in `entries` does not compile
|
|
212
|
+
(moss compiles each one at boot, and each one a refresh hands over, only for
|
|
213
|
+
an app that names `upgradedColumns`).
|
|
195
214
|
|
|
196
215
|
A `LayoutVariant` is `{ action: string; layout: LayoutNode }` — ring 2: the
|
|
197
216
|
charter's `layouts` section selects who is granted which variant id, and moss
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { entriesOf, receiveManifest, verifiedAtBoot, verifyManifest, withFragments, candidateOf, FRAME_LAYOUT_REF, canvasLayoutRef, functionsIn, charterOverFunctions, refusalOf, functionsWarning, layoutMisfits, freezeDeep, entryMisfits, sessionOn, endlessChains, actionLayoutRef, endShell, GENERATED_ID_PREFIX, layoutNameRefusal, actionOfLayoutRef, withLayoutInPlace, canvasesOf, treeOf, buildShell, SHELL_GONE, draftedIn, attach, holdGranted, layoutsOf, withVariants, variantLayouts } from './chunk-
|
|
1
|
+
import { entriesOf, receiveManifest, verifiedAtBoot, verifyManifest, withFragments, candidateOf, FRAME_LAYOUT_REF, canvasLayoutRef, functionsIn, charterOverFunctions, refusalOf, functionsWarning, layoutMisfits, freezeDeep, entryMisfits, sessionOn, endlessChains, actionLayoutRef, endShell, GENERATED_ID_PREFIX, layoutNameRefusal, actionOfLayoutRef, withLayoutInPlace, canvasesOf, treeOf, buildShell, SHELL_GONE, draftedIn, attach, holdGranted, layoutsOf, withVariants, variantLayouts } from './chunk-MVG333UF.js';
|
|
2
2
|
import { emitterOf, FabricMessageSchema, spanClock } from './chunk-QAHDSRPK.js';
|
|
3
3
|
import { DEFAULT_TOKEN_KEY, sessionNameOf, SNAPSHOT_ELEMENT_ID, CLOSE_SHELL_FAILED, CLOSE_PROTOCOL_MISMATCH, CLOSE_INVALID_TOKEN, CLOSE_AT_CAPACITY, PROTOCOL_MIN, PROTOCOL, offeredSealed, offeredToken, ClientMessageSchema } from './chunk-TKXYPO2Y.js';
|
|
4
4
|
import { z } from 'zod';
|
|
@@ -731,7 +731,12 @@ var createDataLayer = async (deps) => {
|
|
|
731
731
|
const table = deps.cache ?? createPostgresCache({ pool: deps.pool });
|
|
732
732
|
await table.init?.();
|
|
733
733
|
const { cache, askFirst } = createEntryCache(table);
|
|
734
|
-
const engine = createQueryEngine({
|
|
734
|
+
const engine = createQueryEngine({
|
|
735
|
+
adapter,
|
|
736
|
+
cache,
|
|
737
|
+
...deps.vexConfig !== void 0 ? { config: deps.vexConfig } : {},
|
|
738
|
+
...deps.upgradedColumns !== void 0 && deps.upgrader !== void 0 ? { upgradedColumns: deps.upgradedColumns, upgrader: deps.upgrader } : {}
|
|
739
|
+
});
|
|
735
740
|
const schema = await engine.introspect();
|
|
736
741
|
return { engine, adapter, schema, grants: scopeGrants(schema.entities.map((e) => e.name)), askFirst };
|
|
737
742
|
};
|
|
@@ -991,7 +996,8 @@ var createIntentAnswers = (deps) => {
|
|
|
991
996
|
generateDsl: writers.generateDsl,
|
|
992
997
|
mapToShape: writers.mapToShape,
|
|
993
998
|
...deps.behaviors !== void 0 ? { behaviors: deps.behaviors } : {},
|
|
994
|
-
...deps.vexConfig !== void 0 ? { config: deps.vexConfig } : {}
|
|
999
|
+
...deps.vexConfig !== void 0 ? { config: deps.vexConfig } : {},
|
|
1000
|
+
...deps.upgradedColumns !== void 0 && deps.upgrader !== void 0 ? { upgradedColumns: deps.upgradedColumns, upgrader: deps.upgrader } : {}
|
|
995
1001
|
});
|
|
996
1002
|
await engine.introspect();
|
|
997
1003
|
return engine;
|
|
@@ -1018,7 +1024,7 @@ var prepareEngine = async (config) => {
|
|
|
1018
1024
|
);
|
|
1019
1025
|
});
|
|
1020
1026
|
const grammars = await createGrammarUpgrader({ grammars: config.grammars });
|
|
1021
|
-
const layer = await createDataLayer(config);
|
|
1027
|
+
const layer = await createDataLayer({ ...config, upgrader: grammars });
|
|
1022
1028
|
return {
|
|
1023
1029
|
grammars,
|
|
1024
1030
|
engine: layer.engine,
|
|
@@ -1042,7 +1048,8 @@ var lazyIntentAnswers = (prepared, config) => {
|
|
|
1042
1048
|
schema,
|
|
1043
1049
|
cache: engine.cache,
|
|
1044
1050
|
...config.behaviors !== void 0 ? { behaviors: config.behaviors } : {},
|
|
1045
|
-
...config.vexConfig !== void 0 ? { vexConfig: config.vexConfig } : {}
|
|
1051
|
+
...config.vexConfig !== void 0 ? { vexConfig: config.vexConfig } : {},
|
|
1052
|
+
...config.upgradedColumns !== void 0 ? { upgradedColumns: config.upgradedColumns, upgrader: prepared.grammars } : {}
|
|
1046
1053
|
});
|
|
1047
1054
|
return answers;
|
|
1048
1055
|
};
|
|
@@ -1053,6 +1060,20 @@ var tablesByFeature = (config) => (feature) => {
|
|
|
1053
1060
|
if (kept === void 0) throw new Error(`moss: the data module was asked for the tables of a feature it was never told of ("${feature}").`);
|
|
1054
1061
|
return kept.names;
|
|
1055
1062
|
};
|
|
1063
|
+
var refuseUpgradedOwnedTables = (config) => {
|
|
1064
|
+
const owners = new Map([
|
|
1065
|
+
...(config.featureTables ?? []).flatMap((tables) => tables.names.map((name) => [name, `the feature "${tables.feature}"`])),
|
|
1066
|
+
...ARTIFACT_TABLES.map((name) => [name, "the artifactory"]),
|
|
1067
|
+
...POINTER.tables.map((name) => [name, POINTER.owner])
|
|
1068
|
+
]);
|
|
1069
|
+
const owned = Object.keys(config.upgradedColumns ?? {}).flatMap((table) => {
|
|
1070
|
+
const owner = owners.get(table);
|
|
1071
|
+
return owner === void 0 ? [] : [`"${table}" is ${owner}'s`];
|
|
1072
|
+
});
|
|
1073
|
+
if (owned.length > 0) {
|
|
1074
|
+
throw new Error(`moss: the app's \`upgradedColumns\` name tables it does not own (${owned.join("; ")}). Their owner reads them as stored: name only the app's own tables.`);
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1056
1077
|
var createUpgradeStore = (prepared, tablesOf) => async (feature, store) => {
|
|
1057
1078
|
const own = tablesOf(feature);
|
|
1058
1079
|
if (store.schema !== void 0) {
|
|
@@ -1066,6 +1087,7 @@ var createUpgradeStore = (prepared, tablesOf) => async (feature, store) => {
|
|
|
1066
1087
|
await prepared.upgradeStore(store);
|
|
1067
1088
|
};
|
|
1068
1089
|
var createDataWith = (prepared, config) => {
|
|
1090
|
+
refuseUpgradedOwnedTables(config);
|
|
1069
1091
|
const { grammars, engine, grants } = prepared;
|
|
1070
1092
|
const governed = { charter: config.charter, behaviors: { ...config.behaviors, ...config.rowRules } };
|
|
1071
1093
|
const policies = createPolicies({ ...governed, grants });
|
|
@@ -1461,6 +1483,19 @@ var generatedInForce = async (inForce2, heldTo, whose) => {
|
|
|
1461
1483
|
};
|
|
1462
1484
|
return { actions: await passed("action", readAction), fragments: await passed("fragment", readFragment) };
|
|
1463
1485
|
};
|
|
1486
|
+
var refuseUnrunnable = (entries, compile2, heading) => {
|
|
1487
|
+
if (compile2 === void 0) return;
|
|
1488
|
+
const unrunnable = entries.flatMap((entry) => {
|
|
1489
|
+
if (!("dsl" in entry)) return [];
|
|
1490
|
+
try {
|
|
1491
|
+
compile2(entry.dsl);
|
|
1492
|
+
return [];
|
|
1493
|
+
} catch (error) {
|
|
1494
|
+
return [` "${entry.fingerprint}": ${error instanceof Error ? error.message : String(error)}`];
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
if (unrunnable.length > 0) throw new Error([heading, ...unrunnable].join("\n"));
|
|
1498
|
+
};
|
|
1464
1499
|
var compileEntries = async (entries) => {
|
|
1465
1500
|
const compiled = createMemoryCache();
|
|
1466
1501
|
await seedCache(compiled, entries);
|
|
@@ -1471,7 +1506,8 @@ var mergedEntries = (own, sets) => {
|
|
|
1471
1506
|
for (const entry of [...own, ...[...sets.values()].flat()]) byFingerprint.set(entry.fingerprint, entry);
|
|
1472
1507
|
return Object.freeze([...byFingerprint.values()]);
|
|
1473
1508
|
};
|
|
1474
|
-
var createEntriesInForce = (own) => {
|
|
1509
|
+
var createEntriesInForce = (own, compileRead) => {
|
|
1510
|
+
refuseUnrunnable(own, compileRead, "Seeded reads that do not run \u2014 refusing to serve:");
|
|
1475
1511
|
let sets = /* @__PURE__ */ new Map();
|
|
1476
1512
|
let list = mergedEntries(own, sets);
|
|
1477
1513
|
let byFingerprint = new Map(list.map((entry) => [entry.fingerprint, entry]));
|
|
@@ -1484,6 +1520,7 @@ var createEntriesInForce = (own) => {
|
|
|
1484
1520
|
holdsSet: (source) => sets.has(source),
|
|
1485
1521
|
withSet: (source, handed) => mergedEntries(own, new Map([...sets, [source, handed]])),
|
|
1486
1522
|
takeSet: (source, handed, taken) => {
|
|
1523
|
+
refuseUnrunnable(handed, compileRead, "Refresh refused \u2014 seeded reads that do not run:");
|
|
1487
1524
|
sets = new Map([...sets, [source, handed]]);
|
|
1488
1525
|
list = mergedEntries(own, sets);
|
|
1489
1526
|
byFingerprint = new Map(list.map((entry) => [entry.fingerprint, entry]));
|
|
@@ -1989,7 +2026,7 @@ var tell = (listener, ...told) => {
|
|
|
1989
2026
|
};
|
|
1990
2027
|
var createRunningManifest = (config) => {
|
|
1991
2028
|
const { shipped } = config;
|
|
1992
|
-
const entries = createEntriesInForce(entriesOf(shipped));
|
|
2029
|
+
const entries = createEntriesInForce(entriesOf(shipped), config.compileSeeded);
|
|
1993
2030
|
let defaults = NO_DEFAULTS;
|
|
1994
2031
|
const usage = createUsage(config.touchEveryMs ?? TOUCH_EVERY_MS);
|
|
1995
2032
|
let functionIds;
|
|
@@ -3438,6 +3475,7 @@ var buildData = (app, runtime) => createData({
|
|
|
3438
3475
|
featureTables: featureTablesOf(app),
|
|
3439
3476
|
tables: runtime.tables,
|
|
3440
3477
|
grammars: app.grammars,
|
|
3478
|
+
upgradedColumns: app.upgradedColumns,
|
|
3441
3479
|
charter: app.charter,
|
|
3442
3480
|
behaviors: app.behaviors,
|
|
3443
3481
|
rowRules: rowRulesBeside(app.behaviors),
|
|
@@ -3532,7 +3570,10 @@ var buildRunningManifest = async (app, runtime, data, saved) => {
|
|
|
3532
3570
|
// Polled on the clock a socket's credential is re-verified on.
|
|
3533
3571
|
pointer: { read: data.pointer.read, move: data.pointer.move, ...runtime.sessionRevalidateMs !== void 0 ? { everyMs: runtime.sessionRevalidateMs } : {} },
|
|
3534
3572
|
shells: [...app.shell !== void 0 ? [app.shell] : [], ...Object.values(app.pages ?? {})],
|
|
3535
|
-
...saved !== void 0 ? { published: saved.published().inForce, reads: { written: data.vexEntry, compile: data.compileQuery, savedOf: saved.of } } : {}
|
|
3573
|
+
...saved !== void 0 ? { published: saved.published().inForce, reads: { written: data.vexEntry, compile: data.compileQuery, savedOf: saved.of } } : {},
|
|
3574
|
+
// Only where the app names upgradedColumns: vex refuses some reads of those when it compiles a read, and a seeded
|
|
3575
|
+
// read is otherwise first compiled at its first replay. An app that names none boots as before.
|
|
3576
|
+
...app.upgradedColumns !== void 0 ? { compileSeeded: data.compileQuery } : {}
|
|
3536
3577
|
});
|
|
3537
3578
|
data.dropOnChange(running.onChange);
|
|
3538
3579
|
data.entriesHeldBy({ get: running.cacheEntry, entries: running.cacheEntries });
|
|
@@ -3590,5 +3631,5 @@ var subscribeReactions = ({ app, onWrite, deliver }) => {
|
|
|
3590
3631
|
};
|
|
3591
3632
|
|
|
3592
3633
|
export { MOSS_SEQUENCE, createServer, exportDocuments, migrateTables, mintDevToken, mintSession, renderDocument, revokeAllFor, sessionCookies, tableStatus };
|
|
3593
|
-
//# sourceMappingURL=chunk-
|
|
3594
|
-
//# sourceMappingURL=chunk-
|
|
3634
|
+
//# sourceMappingURL=chunk-6MZPY4X6.js.map
|
|
3635
|
+
//# sourceMappingURL=chunk-6MZPY4X6.js.map
|