@serene-pub/sdk 0.6.0-pr-7 → 0.6.0-pr-9
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/annexFields.d.ts +14 -0
- package/dist/annexFields.js +7 -0
- package/dist/announce.d.ts +62 -16
- package/dist/announce.js +90 -4
- package/dist/appletCard.d.ts +17 -0
- package/dist/appletCard.js +60 -0
- package/dist/attributes.d.ts +3 -3
- package/dist/attributes.js +1 -1
- package/dist/builder.d.ts +28 -13
- package/dist/builder.js +57 -5
- package/dist/cadences.d.ts +8 -1
- package/dist/cadences.js +27 -2
- package/dist/characterProfile.d.ts +137 -0
- package/dist/characterProfile.js +24 -0
- package/dist/component.d.ts +1 -1
- package/dist/componentImports.d.ts +1 -1
- package/dist/componentImports.js +2 -0
- package/dist/componentWire.js +28 -0
- package/dist/conditions.d.ts +5 -1
- package/dist/conditions.js +7 -0
- package/dist/declarations.d.ts +63 -1
- package/dist/declarations.js +176 -7
- package/dist/descriptors.d.ts +145 -6
- package/dist/descriptors.js +106 -5
- package/dist/document.d.ts +9 -1
- package/dist/document.js +44 -1
- package/dist/events.d.ts +82 -8
- package/dist/events.js +42 -5
- package/dist/executor.d.ts +27 -0
- package/dist/executor.js +32 -8
- package/dist/exposure.d.ts +35 -1
- package/dist/exposure.js +64 -2
- package/dist/extension.d.ts +30 -2
- package/dist/extension.js +3 -1
- package/dist/fit.d.ts +4 -1
- package/dist/fit.js +43 -1
- package/dist/functions.d.ts +7 -1
- package/dist/functions.js +3 -1
- package/dist/genres.d.ts +67 -2
- package/dist/genres.js +160 -8
- package/dist/hookGrants.js +10 -0
- package/dist/hostElements.d.ts +3 -3
- package/dist/hostElements.js +12 -4
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10 -0
- package/dist/layout.d.ts +18 -0
- package/dist/libraryDraft.d.ts +2 -0
- package/dist/libraryDraft.js +5 -1
- package/dist/lorebookFile.d.ts +8 -0
- package/dist/lorebookFile.js +21 -0
- package/dist/participants.d.ts +83 -8
- package/dist/participants.js +9 -5
- package/dist/pluginPermissions.js +1 -1
- package/dist/promptBlocks.d.ts +5 -1
- package/dist/promptBlocks.js +23 -8
- package/dist/provisos.d.ts +92 -0
- package/dist/provisos.js +273 -0
- package/dist/receiverRules.js +1 -1
- package/dist/registrations.d.ts +154 -14
- package/dist/registrations.js +293 -23
- package/dist/registry.js +6 -3
- package/dist/repertoires.d.ts +13 -1
- package/dist/repertoires.js +5 -1
- package/dist/rulesetDocument.d.ts +11 -0
- package/dist/rulesetDocument.js +17 -0
- package/dist/rulesetSections.d.ts +12 -0
- package/dist/rulesetSections.js +8 -0
- package/dist/rulesets.js +6 -0
- package/dist/sceneSettings.d.ts +7 -1
- package/dist/sceneSettings.js +10 -5
- package/dist/sessionDossier.d.ts +159 -2
- package/dist/sessionLayout.d.ts +296 -85
- package/dist/sessionLayout.js +397 -133
- package/dist/sessionSettings.d.ts +18 -0
- package/dist/settings.d.ts +28 -1
- package/dist/settings.js +50 -2
- package/dist/shapes.d.ts +15 -1
- package/dist/shapes.js +15 -1
- package/dist/sheetLatitude.d.ts +148 -0
- package/dist/sheetLatitude.js +161 -0
- package/dist/speech.d.ts +14 -3
- package/dist/storyTime.d.ts +77 -1
- package/dist/storyTime.js +117 -8
- package/dist/surfaces.d.ts +49 -2
- package/dist/surfaces.js +3 -0
- package/dist/template.d.ts +38 -1
- package/dist/templateCheck.d.ts +24 -0
- package/dist/templateCheck.js +465 -10
- package/dist/templateFit.js +8 -1
- package/dist/templateIds.d.ts +6 -0
- package/dist/templateIds.js +9 -0
- package/dist/turnLock.d.ts +10 -1
- package/dist/turnLock.js +6 -1
- package/dist/turnOrder.d.ts +37 -4
- package/dist/turnOrder.js +49 -11
- package/dist/validate.d.ts +4 -2
- package/dist/validate.js +84 -11
- package/dist/variableLayouts.d.ts +160 -0
- package/dist/variableLayouts.js +202 -0
- package/dist/variables.d.ts +237 -20
- package/dist/variables.js +292 -33
- package/dist/widgetDecls.js +12 -0
- package/dist/widgets.d.ts +449 -47
- package/dist/widgets.js +31 -0
- package/host-elements.d.ts +4 -2
- package/package.json +1 -1
package/dist/registrations.js
CHANGED
|
@@ -29,6 +29,14 @@
|
|
|
29
29
|
* trigger is a different registration. Two alike in one layer warn, never
|
|
30
30
|
* refuse (R34).
|
|
31
31
|
*
|
|
32
|
+
* ## One registration runs
|
|
33
|
+
*
|
|
34
|
+
* An event declared `runsOne` runs exactly one of its registrations: the
|
|
35
|
+
* session's choice, else the one marked `default: true`. Each registration is
|
|
36
|
+
* an option a session's owner picks, named by its `label`. A later layer's
|
|
37
|
+
* `default` replaces the earlier layers' (`effectiveRegistrations`); the door
|
|
38
|
+
* refuses two marks in one layer and warns when none is marked.
|
|
39
|
+
*
|
|
32
40
|
* ## Objects first; strings warn (R30, A18)
|
|
33
41
|
*
|
|
34
42
|
* `register()` takes the declared objects — an event (`coreEvents.…`, a
|
|
@@ -39,18 +47,19 @@
|
|
|
39
47
|
* @ruling R6, R7, R24, R30, R31, R34, A4, A8, A12, LS1, §11
|
|
40
48
|
*/
|
|
41
49
|
import { i18nFindings } from './i18n.js';
|
|
42
|
-
import { EVENT_ID, eventById, eventIdOf, isEventDef, isSessionEventDecl, notADeclaredEvent, } from './events.js';
|
|
50
|
+
import { CORE_EVENTS, EVENT_ID, eventById, eventIdOf, isEventDef, isSessionEventDecl, notADeclaredEvent, } from './events.js';
|
|
43
51
|
import { CADENCE_ID, ON_EVENT, cadenceClock, cadenceOptionFindings, isCadenceRef, } from './cadences.js';
|
|
44
52
|
import { conditionFindings } from './conditions.js';
|
|
53
|
+
import { CLAUSE_MODES } from './clauses.js';
|
|
45
54
|
import { fitOf } from './entities.js';
|
|
46
55
|
import { actionsOf, isActionIdentity } from './actions.js';
|
|
47
|
-
import { getDefinition } from './descriptors.js';
|
|
56
|
+
import { getDefinition, templateExposureOf } from './descriptors.js';
|
|
48
57
|
import { exposureFindings } from './exposure.js';
|
|
49
58
|
/** The families core's host supports today. @experimental */
|
|
50
59
|
export const TRIGGER_FAMILIES = ['event', 'action', 'routine'];
|
|
51
60
|
/** The routine modes. @experimental */
|
|
52
61
|
export const ROUTINE_MODES = ['off', 'review', 'full'];
|
|
53
|
-
const OPTION_KEYS = ['when', 'values', 'order', 'mode', 'allowStacking', 'caps', 'label', 'minAge'];
|
|
62
|
+
const OPTION_KEYS = ['when', 'values', 'order', 'mode', 'allowStacking', 'caps', 'label', 'minAge', 'default'];
|
|
54
63
|
/** 🚧 The routine default (ruled 2026-10-24). @experimental */
|
|
55
64
|
export const DEFAULT_ROUTINE_MIN_AGE = 20;
|
|
56
65
|
/** 🚧 A registration's effective minAge. @experimental */
|
|
@@ -88,6 +97,37 @@ export function actionHandlesOf(s) {
|
|
|
88
97
|
out[a.key] = actionHandle(s.id, a);
|
|
89
98
|
return out;
|
|
90
99
|
}
|
|
100
|
+
// ── Routine groups ──────────────────────────────────────────────────────────
|
|
101
|
+
const ROUTINE_GROUP_KEY = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
102
|
+
const ROUTINE_GROUP_OPTION_KEYS = ['key', 'label', 'when', 'allowStacking', 'caps', 'run'];
|
|
103
|
+
const isRoutineGroupShaped = (v) => !!v &&
|
|
104
|
+
typeof v === 'object' &&
|
|
105
|
+
typeof v.key === 'string' &&
|
|
106
|
+
isCadenceRef(v.cadence);
|
|
107
|
+
/**
|
|
108
|
+
* 🚧 Declare a routine group: routines that fire together on `cadence`, counted and limited as
|
|
109
|
+
* one. `key` is the author's slug (`scenes`, `world-turns`). A routine joins it with
|
|
110
|
+
* `register(group, pipeline)` or a preset's `change: [{ of, group }]`. Judges nothing but the
|
|
111
|
+
* shape; the values are `routineGroupFindings`'s.
|
|
112
|
+
* @experimental
|
|
113
|
+
* @ruling RG1, RG2, RG3, RN1
|
|
114
|
+
*/
|
|
115
|
+
export function routineGroup(cadence, opts) {
|
|
116
|
+
if (!isCadenceRef(cadence))
|
|
117
|
+
throw new Error('routineGroup(): the first argument is a cadence — everyNRounds({ n: 2 }), everyNTurns(…), systemCron(…), …');
|
|
118
|
+
if (!opts || typeof opts !== 'object' || Array.isArray(opts))
|
|
119
|
+
throw new Error('routineGroup(): options are an object — { key, label?, when?, allowStacking?, caps?, run? }');
|
|
120
|
+
for (const k of Object.keys(opts))
|
|
121
|
+
if (!ROUTINE_GROUP_OPTION_KEYS.includes(k))
|
|
122
|
+
throw new Error(`routineGroup(): '${k}' is not a routine group option — one of ${ROUTINE_GROUP_OPTION_KEYS.join(', ')}`);
|
|
123
|
+
if (typeof opts.key !== 'string' || !ROUTINE_GROUP_KEY.test(opts.key))
|
|
124
|
+
throw new Error("routineGroup(): key is a slug of lowercase letters, digits and dashes — name it like 'scenes' or 'world-turns'");
|
|
125
|
+
return Object.freeze({
|
|
126
|
+
key: opts.key,
|
|
127
|
+
cadence,
|
|
128
|
+
...Object.fromEntries(ROUTINE_GROUP_OPTION_KEYS.filter((k) => k !== 'key' && opts[k] !== undefined).map((k) => [k, opts[k]])),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
91
131
|
// ── Keys ────────────────────────────────────────────────────────────────────
|
|
92
132
|
/** The arrow a registration key joins its two halves with. @experimental */
|
|
93
133
|
export const REGISTRATION_KEY_JOIN = '→';
|
|
@@ -161,6 +201,8 @@ export function triggerOf(input) {
|
|
|
161
201
|
throw new Error(`register(): '${input}' is not an event id, an action identity or a cadence id — pass the object: ` +
|
|
162
202
|
`coreEvents.messageRespond, spec.actions.<key>, everyNTurns({ n: 5 })`);
|
|
163
203
|
}
|
|
204
|
+
if (isRoutineGroupShaped(input))
|
|
205
|
+
return { trigger: { family: 'routine', cadence: input.cadence }, group: input.key };
|
|
164
206
|
if (isSessionEventDecl(input) || isEventDef(input))
|
|
165
207
|
return { trigger: { family: 'event', event: eventIdOf(input) } };
|
|
166
208
|
if (isActionHandle(input))
|
|
@@ -195,7 +237,8 @@ export function pipelineOf(input) {
|
|
|
195
237
|
* key is derived (A8); `opts` are the registration's `when`, `values`,
|
|
196
238
|
* `order` and, for a routine, `mode`, `allowStacking` and `caps`. Nothing
|
|
197
239
|
* here refuses what the door judges (fit, cadence options, duplicates): call
|
|
198
|
-
* `registrationFindings`, which a package build and a host both do.
|
|
240
|
+
* `registrationFindings`, which a package build and a host both do. A routine
|
|
241
|
+
* group (`routineGroup(…)`) as the trigger makes the routine a member of it.
|
|
199
242
|
* @experimental
|
|
200
243
|
* @ruling D1, A8, R30
|
|
201
244
|
*/
|
|
@@ -211,6 +254,7 @@ export function register(trigger, pipeline, opts = {}) {
|
|
|
211
254
|
key: registrationKeyOf(t.trigger, p.id),
|
|
212
255
|
trigger: Object.freeze({ ...t.trigger }),
|
|
213
256
|
pipeline: p.id,
|
|
257
|
+
...(t.group !== undefined ? { group: t.group } : {}),
|
|
214
258
|
...Object.fromEntries(OPTION_KEYS.filter((k) => opts?.[k] !== undefined).map((k) => [k, opts[k]])),
|
|
215
259
|
});
|
|
216
260
|
const strings = [t.spelled, p.spelled].filter((s) => !!s);
|
|
@@ -290,6 +334,32 @@ const warn = (law, message, fix) => ({
|
|
|
290
334
|
message,
|
|
291
335
|
fix,
|
|
292
336
|
});
|
|
337
|
+
/** Every path a stored condition's leaves read. */
|
|
338
|
+
function conditionPaths(c) {
|
|
339
|
+
if (!c || typeof c !== 'object')
|
|
340
|
+
return [];
|
|
341
|
+
const o = c;
|
|
342
|
+
if (typeof o.on === 'string')
|
|
343
|
+
return [o.on];
|
|
344
|
+
const kids = Array.isArray(o.all) ? o.all : Array.isArray(o.any) ? o.any : o.not !== undefined ? [o.not] : [];
|
|
345
|
+
return kids.flatMap(conditionPaths);
|
|
346
|
+
}
|
|
347
|
+
/** The definition of the outlet that writes a session's turn order. */
|
|
348
|
+
const SET_TURN_ORDER_DEFINITION = 'core:outlet/set-turn-order';
|
|
349
|
+
/** A run limit's two checks — whole numbers, within the system's — for a registration and a routine group alike. */
|
|
350
|
+
function capsFindings(caps, at, ctx) {
|
|
351
|
+
const out = [];
|
|
352
|
+
for (const k of ['idleTimeoutMinutes', 'maxRunsInRow']) {
|
|
353
|
+
const v = caps?.[k];
|
|
354
|
+
if (v === undefined)
|
|
355
|
+
continue;
|
|
356
|
+
if (typeof v !== 'number' || !Number.isInteger(v) || v < 1)
|
|
357
|
+
out.push(err('registration caps', `${at}: caps.${k} is a whole number, 1 or more`, `set caps.${k} to a whole number`));
|
|
358
|
+
else if (ctx.caps?.[k] !== undefined && v > ctx.caps[k])
|
|
359
|
+
out.push(err('registration caps', `${at}: caps.${k} is ${v}, above the system's ${ctx.caps[k]}`, `set it to ${ctx.caps[k]} or less — each layer is at most the one above (R11)`));
|
|
360
|
+
}
|
|
361
|
+
return out;
|
|
362
|
+
}
|
|
293
363
|
/** The slots a registration's values may set (R38): never a connection. */
|
|
294
364
|
const VALUE_SLOTS = [
|
|
295
365
|
'prompts',
|
|
@@ -313,7 +383,7 @@ const VALUE_SLOTS = [
|
|
|
313
383
|
* story clock, a session that has one;
|
|
314
384
|
* · the pipeline resolves, and **fits** the trigger (R4, R12);
|
|
315
385
|
* · routine-only fields (`mode`, `allowStacking`, `caps`) sit on routines,
|
|
316
|
-
* caps
|
|
386
|
+
* caps within the system's (RG2);
|
|
317
387
|
* · `values` set the slots a registration may (never a connection), on
|
|
318
388
|
* nodes the pipeline has;
|
|
319
389
|
* · the pipeline exposes no model plumbing to the owner (ruled 10-12);
|
|
@@ -393,27 +463,28 @@ export function registrationFindings(decls, ctx = {}) {
|
|
|
393
463
|
out.push(err('routine fields', `${at}: allowStacking is true or false`, 'leave it out for the default (off)'));
|
|
394
464
|
if (d.minAge !== undefined && (typeof d.minAge !== 'number' || !Number.isInteger(d.minAge) || d.minAge < 0))
|
|
395
465
|
out.push(err('summary depth', `${at}: minAge is a whole number of lines, 0 or more`, 'leave it out for the default — 20 on a routine, 0 on an action or an event'));
|
|
396
|
-
if (d.caps !== undefined)
|
|
397
|
-
|
|
398
|
-
out.push(warn('registration caps', `${at}: caps apply to routines on the system clock, and this one is not`, 'drop caps'));
|
|
399
|
-
for (const k of ['idleTimeoutMinutes', 'maxRunsInRow']) {
|
|
400
|
-
const v = d.caps?.[k];
|
|
401
|
-
if (v === undefined)
|
|
402
|
-
continue;
|
|
403
|
-
if (typeof v !== 'number' || !Number.isInteger(v) || v < 1)
|
|
404
|
-
out.push(err('registration caps', `${at}: caps.${k} is a whole number, 1 or more`, `set caps.${k} to a whole number`));
|
|
405
|
-
else if (ctx.caps?.[k] !== undefined && v > ctx.caps[k])
|
|
406
|
-
out.push(err('registration caps', `${at}: caps.${k} is ${v}, above the system's ${ctx.caps[k]}`, `set it to ${ctx.caps[k]} or less — each layer is at most the one above (R11)`));
|
|
407
|
-
}
|
|
408
|
-
}
|
|
466
|
+
if (d.caps !== undefined)
|
|
467
|
+
out.push(...capsFindings(d.caps, at, ctx));
|
|
409
468
|
if (d.order !== undefined &&
|
|
410
469
|
(typeof d.order !== 'number' ||
|
|
411
470
|
!Number.isInteger(d.order) ||
|
|
412
471
|
Math.abs(d.order) > MAX_ORDER))
|
|
413
472
|
out.push(err('registration order', `${at}: order is a whole number`, 'order registrations on one trigger with 0, 10, 20 …'));
|
|
414
|
-
if (d.when !== undefined)
|
|
473
|
+
if (d.when !== undefined) {
|
|
415
474
|
for (const f of conditionFindings(d.when, `${at} when`))
|
|
416
475
|
out.push(err('registration when', f, 'build the condition with the typed builders — isTrue(…), eq(…), and(…)'));
|
|
476
|
+
if (d.trigger.family !== 'event' && conditionPaths(d.when).some((x) => x.startsWith('event.')))
|
|
477
|
+
out.push(warn('registration when', `${at}: an action's or routine's \`when\` has no event to read — 'event.…' is the payload of the event an event registration answers`, "read a published value instead, or register on the event"));
|
|
478
|
+
}
|
|
479
|
+
if (d.default !== undefined) {
|
|
480
|
+
const ev = d.trigger.family === 'event' ? d.trigger.event : undefined;
|
|
481
|
+
if (d.default !== true)
|
|
482
|
+
out.push(err('registration default', `${at}: default is true or left out`, 'leave it out, or mark the one registration that runs when the session chose none with default: true'));
|
|
483
|
+
else if (ev === undefined)
|
|
484
|
+
out.push(err('registration default', `${at}: 'default' belongs to a registration on an event where one registration runs — this one is on ${d.trigger.family === 'action' ? 'an action' : 'a routine'}`, "drop 'default'"));
|
|
485
|
+
else if (eventById(ev) && !eventById(ev)?.runsOne)
|
|
486
|
+
out.push(err('registration default', `${at}: 'default' belongs to a registration on an event where one registration runs — every registration on '${ev}' runs`, "drop 'default'"));
|
|
487
|
+
}
|
|
417
488
|
if (d.label !== undefined)
|
|
418
489
|
for (const f of i18nFindings(d.label, `${at} label`))
|
|
419
490
|
out.push(err('registration label', f, "a string or a locale map with 'en'"));
|
|
@@ -449,6 +520,8 @@ export function registrationFindings(decls, ctx = {}) {
|
|
|
449
520
|
for (const f of exposureFindings(schema, `'${d.pipeline}' ${n.key}.${slotName}`))
|
|
450
521
|
out.push(err('exposed plumbing', `${at}: ${f}`, 'model plumbing is never exposed to a member (ruled 10-12)'));
|
|
451
522
|
}
|
|
523
|
+
for (const m of def ? templateExposureOf(def) : [])
|
|
524
|
+
out.push(warn('exposed template', `${at}: '${d.pipeline}' ${n.key}: ${m}`, 'templates are an administrator\'s (owner ruling G7): drop reach: \'owner\' from it'));
|
|
452
525
|
}
|
|
453
526
|
out.push(...pipelineDefaultsFindings(p).map((m) => warn('pipeline defaults', `${at}: ${m}`, "move the preset's values into a registration's values, or into .defaults()")));
|
|
454
527
|
}
|
|
@@ -456,11 +529,125 @@ export function registrationFindings(decls, ctx = {}) {
|
|
|
456
529
|
for (const [key, n] of counts)
|
|
457
530
|
if (n > 1)
|
|
458
531
|
out.push(warn('registration duplicate', `registration '${key}'${layer} is declared ${n} times — the same trigger and pipeline`, 'keep one: two alike are one registration (R34)'));
|
|
532
|
+
// Two writers of one order: options on Turn order asked, and a registration on another event
|
|
533
|
+
// whose pipeline writes the turn order too.
|
|
534
|
+
if (ctx.pipeline) {
|
|
535
|
+
const asked = eventIdOf(CORE_EVENTS.turnOrderAsked);
|
|
536
|
+
const live = decls.filter((d) => d && typeof d === 'object' && d.trigger?.family === 'event' && typeof d.pipeline === 'string');
|
|
537
|
+
if (live.some((d) => d.trigger.family === 'event' && d.trigger.event === asked))
|
|
538
|
+
for (const d of live) {
|
|
539
|
+
if (d.trigger.family !== 'event' || d.trigger.event === asked || ctx.external?.(d.pipeline))
|
|
540
|
+
continue;
|
|
541
|
+
const p = ctx.pipeline(d.pipeline);
|
|
542
|
+
if (p?.nodes.some((n) => n.definitionId === SET_TURN_ORDER_DEFINITION))
|
|
543
|
+
out.push(warn('registration turn order', `registrations${layer} register turn order options on Turn order asked and '${d.key}' still writes the turn order on '${d.trigger.event}' — two writers of one order`, 'drop the per-event turn-order registration; the options on Turn order asked write it'));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const onOneEvent = new Map();
|
|
547
|
+
for (const d of decls) {
|
|
548
|
+
if (!d || typeof d !== 'object' || !d.trigger || typeof d.pipeline !== 'string')
|
|
549
|
+
continue;
|
|
550
|
+
if (!families.includes(d.trigger.family))
|
|
551
|
+
continue;
|
|
552
|
+
if (d.trigger.family !== 'event' || eventById(d.trigger.event)?.runsOne !== true)
|
|
553
|
+
continue;
|
|
554
|
+
onOneEvent.set(d.trigger.event, [...(onOneEvent.get(d.trigger.event) ?? []), d]);
|
|
555
|
+
}
|
|
556
|
+
for (const [ev, group] of onOneEvent) {
|
|
557
|
+
const marked = group.filter((d) => d.default === true);
|
|
558
|
+
if (marked.length > 1)
|
|
559
|
+
out.push(err('registration default', `${marked.length} registrations${layer} on '${ev}' are marked default (${marked.map((d) => `'${d.key}'`).join(', ')}) — one registration runs on it, so one is the default`, 'keep default: true on one of them'));
|
|
560
|
+
else if (!marked.length)
|
|
561
|
+
out.push(warn('registration default', `registrations${layer} on '${ev}' mark none as default — a session that chose none has no option to run`, 'mark one: register(…, { default: true })'));
|
|
562
|
+
}
|
|
459
563
|
if (ctx.pipeline)
|
|
460
564
|
for (const cycle of emitCycles(decls, ctx.pipeline))
|
|
461
565
|
out.push(err('emits cycle', `registrations${layer} form a cycle through emitted events: ${cycle.join(' → ')}`, "break it — drop one registration, or a pipeline's emits (A12)"));
|
|
462
566
|
return out;
|
|
463
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* 🚧 **The routine group door**: the whole-list check a host calls beside
|
|
570
|
+
* `registrationFindings`, which stays per registration. It judges each routine
|
|
571
|
+
* group (shape, key, cadence, clock, `run`, stacking, run limit, `when`, label,
|
|
572
|
+
* duplicates), each registration's `group` (a routine's, naming a declared
|
|
573
|
+
* routine group, never restating what the routine group owns), and warns about
|
|
574
|
+
* a routine group no routine is in. A host passes the effective routine groups
|
|
575
|
+
* (`effectiveRoutineGroups`) with the effective registrations. `groups` of
|
|
576
|
+
* `null` or `undefined`: a check the context cannot support is skipped.
|
|
577
|
+
* @experimental
|
|
578
|
+
* @ruling RG1, RG2, RG3
|
|
579
|
+
*/
|
|
580
|
+
export function routineGroupFindings(decls, groups, ctx = {}) {
|
|
581
|
+
if (groups === null || groups === undefined)
|
|
582
|
+
return [];
|
|
583
|
+
const out = [];
|
|
584
|
+
const layer = ctx.layer ? ` in ${ctx.layer}` : '';
|
|
585
|
+
const counts = new Map();
|
|
586
|
+
const declared = new Set();
|
|
587
|
+
for (const [i, g] of groups.entries()) {
|
|
588
|
+
const gat = `routine group '${typeof g?.key === 'string' ? g.key : `#${i + 1}`}'${layer}`;
|
|
589
|
+
if (!isRoutineGroupShaped(g)) {
|
|
590
|
+
out.push(err('routine group', `${gat} is not a routine group`, 'make it with routineGroup(cadence, { key })'));
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
counts.set(g.key, (counts.get(g.key) ?? 0) + 1);
|
|
594
|
+
declared.add(g.key);
|
|
595
|
+
if (!ROUTINE_GROUP_KEY.test(g.key))
|
|
596
|
+
out.push(err('routine group', `${gat}: the key is lowercase letters, digits and dashes`, "name it like 'scenes' or 'world-turns'"));
|
|
597
|
+
for (const f of cadenceOptionFindings(g.cadence, `${gat} cadence`))
|
|
598
|
+
out.push(err('cadence options', f, 'state the cadence with its ready-made function — everyNTurns({ n }), systemCron({ every, unit }), …'));
|
|
599
|
+
if (ctx.storyClock === false && cadenceClock(g.cadence) === 'story')
|
|
600
|
+
out.push(err('cadence clock', `${gat}: needs a story clock, and the session has none`, 'attach a lorebook with a calendar, or register on another cadence'));
|
|
601
|
+
if (g.run !== undefined && !CLAUSE_MODES.includes(g.run))
|
|
602
|
+
out.push(err('routine group', `${gat}: run is 'sequential' or 'parallel'`, 'leave it out to run its routines one after another'));
|
|
603
|
+
if (g.allowStacking !== undefined && typeof g.allowStacking !== 'boolean')
|
|
604
|
+
out.push(err('routine group', `${gat}: allowStacking is true or false`, 'leave it out for the default (off)'));
|
|
605
|
+
if (g.caps !== undefined)
|
|
606
|
+
out.push(...capsFindings(g.caps, gat, ctx));
|
|
607
|
+
if (g.when !== undefined) {
|
|
608
|
+
for (const f of conditionFindings(g.when, `${gat} when`))
|
|
609
|
+
out.push(err('registration when', f, 'build the condition with the typed builders — isTrue(…), eq(…), and(…)'));
|
|
610
|
+
if (conditionPaths(g.when).some((x) => x.startsWith('event.')))
|
|
611
|
+
out.push(warn('registration when', `${gat}: a routine group's \`when\` has no event to read — 'event.…' is the payload of the event an event registration answers`, 'read a published value instead'));
|
|
612
|
+
}
|
|
613
|
+
if (g.label !== undefined)
|
|
614
|
+
for (const f of i18nFindings(g.label, `${gat} label`))
|
|
615
|
+
out.push(err('registration label', f, "a string or a locale map with 'en'"));
|
|
616
|
+
}
|
|
617
|
+
for (const [g, n] of counts)
|
|
618
|
+
if (n > 1)
|
|
619
|
+
out.push(err('routine group duplicate', `${n} routine groups${layer} have the key '${g}' — one key names one routine group`, 'rename one: routineGroup(cadence, { key })'));
|
|
620
|
+
const named = new Set();
|
|
621
|
+
for (const [i, d] of decls.entries()) {
|
|
622
|
+
if (!d || typeof d !== 'object' || !d.trigger || typeof d.pipeline !== 'string')
|
|
623
|
+
continue;
|
|
624
|
+
if (d.group === undefined)
|
|
625
|
+
continue;
|
|
626
|
+
const at = `registration '${d.key ?? `#${i + 1}`}'${layer}`;
|
|
627
|
+
const g = d.group;
|
|
628
|
+
if (d.trigger.family !== 'routine') {
|
|
629
|
+
out.push(err('routine group member', `${at}: 'group' is a routine's — this registration is on ${d.trigger.family === 'event' ? 'an event' : 'an action'}`, "drop 'group'"));
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
named.add(g);
|
|
633
|
+
if (!declared.has(g)) {
|
|
634
|
+
out.push(err('routine group unknown', `${at} is in routine group '${g}', which is not declared${layer}`, `declare it — routineGroup(cadence, { key: '${g}' }) — or register the routine on a cadence of its own`));
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
const owned = [
|
|
638
|
+
['when', 'a member runs whenever its routine group fires', 'when'],
|
|
639
|
+
['allowStacking', "the routine group's firing is what waits or stacks", 'allowStacking'],
|
|
640
|
+
['caps', 'one run limit counts the whole routine group', 'caps'],
|
|
641
|
+
];
|
|
642
|
+
for (const [k, why, field] of owned)
|
|
643
|
+
if (d[k] !== undefined)
|
|
644
|
+
out.push(err('routine group member', `${at}: '${k}' belongs to its routine group '${g}' — ${why}`, `state it on the routine group: routineGroup(cadence, { key, ${field} })`));
|
|
645
|
+
}
|
|
646
|
+
for (const g of declared)
|
|
647
|
+
if (!named.has(g))
|
|
648
|
+
out.push(warn('routine group empty', `routine group '${g}'${layer} has no routine — it fires nothing`, 'register a routine on it — register(group, pipeline) — or leave it out'));
|
|
649
|
+
return out;
|
|
650
|
+
}
|
|
464
651
|
/**
|
|
465
652
|
* Author presets a pipeline ships that are not its declared defaults (R38,
|
|
466
653
|
* PLAN-layering D5): only the `default: true` one (`.defaults()`) is read;
|
|
@@ -473,7 +660,7 @@ export function pipelineDefaultsFindings(p) {
|
|
|
473
660
|
.filter((x) => !x.default)
|
|
474
661
|
.map((x) => `'${p.id}' ships the author preset '${x.slug}', which is ignored — a pipeline's values come from its declared defaults and the registrations that change them (R38)`);
|
|
475
662
|
}
|
|
476
|
-
const CHANGE_KEYS = ['values', 'mode', 'when', 'allowStacking', 'caps', 'order', 'label', 'minAge'];
|
|
663
|
+
const CHANGE_KEYS = ['values', 'mode', 'when', 'allowStacking', 'caps', 'order', 'label', 'minAge', 'default', 'group'];
|
|
477
664
|
/** A copy of a registration that keeps what `register()` noted about it (a string reference, a range). */
|
|
478
665
|
function carried(from, to) {
|
|
479
666
|
const s = spelled.get(from);
|
|
@@ -507,12 +694,36 @@ function applyChange(r, change, by) {
|
|
|
507
694
|
next.changedBy = [...(r.changedBy ?? []), by];
|
|
508
695
|
return carried(r, next);
|
|
509
696
|
}
|
|
697
|
+
/** A layer's `default` mark replaces the earlier layers' on the same event: the others lose theirs. */
|
|
698
|
+
function yieldDefaults(byKey, marked, by) {
|
|
699
|
+
const events = new Set();
|
|
700
|
+
for (const key of marked) {
|
|
701
|
+
const r = byKey.get(key);
|
|
702
|
+
if (r?.default && r.trigger.family === 'event')
|
|
703
|
+
events.add(r.trigger.event);
|
|
704
|
+
}
|
|
705
|
+
if (!events.size)
|
|
706
|
+
return;
|
|
707
|
+
for (const [key, r] of [...byKey]) {
|
|
708
|
+
if (!r.default || marked.has(key) || r.trigger.family !== 'event' || !events.has(r.trigger.event))
|
|
709
|
+
continue;
|
|
710
|
+
const { default: _default, ...rest } = r;
|
|
711
|
+
byKey.set(key, carried(r, { ...rest, changedBy: [...(r.changedBy ?? []), by] }));
|
|
712
|
+
}
|
|
713
|
+
}
|
|
510
714
|
/**
|
|
511
715
|
* **Effective registrations** — the genre's defaults ⊕ a preset's changes ⊕
|
|
512
716
|
* a session's rows (PLAN-layering D4). Pure; the host's resolver reuses it.
|
|
513
717
|
* A dropped registration is gone; a routine switched Off stays, with
|
|
514
718
|
* `mode: 'off'` (R8). Sorted by `order`, then key (R24). Within one layer the
|
|
515
|
-
* first of two alike wins — the door warns about the second (R34).
|
|
719
|
+
* first of two alike wins — the door warns about the second (R34). A layer
|
|
720
|
+
* that marks a registration `default` on an event takes the mark from the
|
|
721
|
+
* others on that event: a later layer's default replaces the earlier layers'.
|
|
722
|
+
* A session's change row never carries the mark: the session's choice is its
|
|
723
|
+
* own column, read by the host. A routine in a routine group carries `group`
|
|
724
|
+
* (from its declaration, or a layer's change) and nothing else about it
|
|
725
|
+
* changes; its routine group's cadence, `when`, stacking and run limit are
|
|
726
|
+
* read from `effectiveRoutineGroups`.
|
|
516
727
|
* @experimental
|
|
517
728
|
* @ruling R2, R8, R22, R24, R34
|
|
518
729
|
*/
|
|
@@ -522,12 +733,15 @@ export function effectiveRegistrations(genreDefaults, presetChanges, sessionRows
|
|
|
522
733
|
if (!byKey.has(r.key))
|
|
523
734
|
byKey.set(r.key, carried(r, { ...r, origin: 'genre' }));
|
|
524
735
|
if (presetChanges) {
|
|
736
|
+
const marked = new Set();
|
|
525
737
|
for (const key of presetChanges.drop ?? [])
|
|
526
738
|
byKey.delete(key);
|
|
527
739
|
for (const c of presetChanges.change ?? []) {
|
|
528
740
|
const r = byKey.get(c.key);
|
|
529
741
|
if (r)
|
|
530
742
|
byKey.set(c.key, applyChange(r, c, 'preset'));
|
|
743
|
+
if (r && c.default === true)
|
|
744
|
+
marked.add(c.key);
|
|
531
745
|
}
|
|
532
746
|
const added = new Set();
|
|
533
747
|
for (const r of presetChanges.register ?? []) {
|
|
@@ -535,8 +749,12 @@ export function effectiveRegistrations(genreDefaults, presetChanges, sessionRows
|
|
|
535
749
|
continue;
|
|
536
750
|
added.add(r.key);
|
|
537
751
|
byKey.set(r.key, carried(r, { ...r, origin: 'preset' }));
|
|
752
|
+
if (r.default === true)
|
|
753
|
+
marked.add(r.key);
|
|
538
754
|
}
|
|
755
|
+
yieldDefaults(byKey, marked, 'preset');
|
|
539
756
|
}
|
|
757
|
+
const sessionMarked = new Set();
|
|
540
758
|
for (const row of sessionRows ?? []) {
|
|
541
759
|
if (row.dropped) {
|
|
542
760
|
byKey.delete(row.key);
|
|
@@ -544,14 +762,66 @@ export function effectiveRegistrations(genreDefaults, presetChanges, sessionRows
|
|
|
544
762
|
}
|
|
545
763
|
if (row.registration) {
|
|
546
764
|
byKey.set(row.registration.key, carried(row.registration, { ...row.registration, origin: row.origin ?? 'session' }));
|
|
765
|
+
if (row.registration.default === true)
|
|
766
|
+
sessionMarked.add(row.registration.key);
|
|
547
767
|
continue;
|
|
548
768
|
}
|
|
549
769
|
const r = byKey.get(row.key);
|
|
550
|
-
if (r)
|
|
551
|
-
|
|
770
|
+
if (!r)
|
|
771
|
+
continue;
|
|
772
|
+
// The session's choice lives on the session (`sessions.turn_order_option`), never in a mark.
|
|
773
|
+
const { default: _default, ...change } = row;
|
|
774
|
+
byKey.set(row.key, applyChange(r, change, 'session'));
|
|
552
775
|
}
|
|
776
|
+
yieldDefaults(byKey, sessionMarked, 'session');
|
|
553
777
|
return [...byKey.values()].sort((a, b) => (a.order ?? 0) - (b.order ?? 0) || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
554
778
|
}
|
|
779
|
+
const GROUP_CHANGE_KEYS = ['cadence', 'label', 'when', 'allowStacking', 'caps', 'run'];
|
|
780
|
+
function applyGroupChange(g, change, by) {
|
|
781
|
+
const next = { ...g };
|
|
782
|
+
for (const k of GROUP_CHANGE_KEYS)
|
|
783
|
+
if (change[k] !== undefined)
|
|
784
|
+
next[k] = change[k];
|
|
785
|
+
next.changedBy = [...(g.changedBy ?? []), by];
|
|
786
|
+
return next;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* 🚧 **Effective routine groups** — the genre's routine groups ⊕ a preset's
|
|
790
|
+
* changes ⊕ a session's changes, layered as `effectiveRegistrations` is: the
|
|
791
|
+
* genre's by key (the first of two alike in a layer wins); the preset's
|
|
792
|
+
* `changeGroups` on the ones present (an unknown key is ignored); the preset's
|
|
793
|
+
* `groups` set by key (replacing a genre's of that key, origin `preset`); the
|
|
794
|
+
* session's changes on the ones present. Sorted by key. Pure; refuses nothing
|
|
795
|
+
* (`routineGroupFindings` judges).
|
|
796
|
+
* @experimental
|
|
797
|
+
* @ruling RG1, RG2
|
|
798
|
+
*/
|
|
799
|
+
export function effectiveRoutineGroups(genreGroups, presetChanges, sessionChanges) {
|
|
800
|
+
const byKey = new Map();
|
|
801
|
+
for (const g of genreGroups ?? [])
|
|
802
|
+
if (!byKey.has(g.key))
|
|
803
|
+
byKey.set(g.key, { ...g, origin: 'genre' });
|
|
804
|
+
if (presetChanges) {
|
|
805
|
+
for (const c of presetChanges.changeGroups ?? []) {
|
|
806
|
+
const g = byKey.get(c.key);
|
|
807
|
+
if (g)
|
|
808
|
+
byKey.set(c.key, applyGroupChange(g, c, 'preset'));
|
|
809
|
+
}
|
|
810
|
+
const added = new Set();
|
|
811
|
+
for (const g of presetChanges.groups ?? []) {
|
|
812
|
+
if (added.has(g.key))
|
|
813
|
+
continue;
|
|
814
|
+
added.add(g.key);
|
|
815
|
+
byKey.set(g.key, { ...g, origin: 'preset' });
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
for (const c of sessionChanges ?? []) {
|
|
819
|
+
const g = byKey.get(c.key);
|
|
820
|
+
if (g)
|
|
821
|
+
byKey.set(c.key, applyGroupChange(g, c, 'session'));
|
|
822
|
+
}
|
|
823
|
+
return [...byKey.values()].sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
|
|
824
|
+
}
|
|
555
825
|
/** Do two triggers name the same thing (event, action, or cadence id)? @experimental */
|
|
556
826
|
export function sameTrigger(a, b) {
|
|
557
827
|
if (a.family !== b.family)
|
package/dist/registry.js
CHANGED
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* @ruling 13 §10c, 04 §2, F6
|
|
31
31
|
*/
|
|
32
32
|
import { pluginRuleRef } from './pluginRuleRef.js';
|
|
33
|
+
import { removedNodeDefinitionSentence } from './descriptors.js';
|
|
33
34
|
import { definitionPolicy, scriptPointsOf, } from './descriptors.js';
|
|
34
35
|
import { isScriptKindId } from './scripts.js';
|
|
35
36
|
import { settingsSlotFor } from './settingsSlot.js';
|
|
@@ -171,14 +172,16 @@ export function checkInstall(input) {
|
|
|
171
172
|
// 2. A pin that resolves to nothing.
|
|
172
173
|
if (!entry && !declared.has(pin)) {
|
|
173
174
|
const known = latest.get(n.definitionId);
|
|
175
|
+
const removed = removedNodeDefinitionSentence(n.definitionId);
|
|
174
176
|
findings.push({
|
|
175
177
|
severity: 'error',
|
|
176
178
|
code: 'E_UNKNOWN_TYPE',
|
|
177
179
|
where: `${doc.id} · ${n.key}`,
|
|
178
180
|
message: `pins ${pin}, which this pub does not have`,
|
|
179
|
-
fix:
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
fix: removed ??
|
|
182
|
+
(known
|
|
183
|
+
? `this pub has ${n.definitionId}@${known}. Pins are frozen on purpose, so the plugin has to be rebuilt against this release rather than silently re-pinned here.`
|
|
184
|
+
: `no version of ${n.definitionId} is registered. It comes from another plugin — install that one first, or the pipeline has a dependency its manifest does not declare.`),
|
|
182
185
|
});
|
|
183
186
|
continue;
|
|
184
187
|
}
|
package/dist/repertoires.d.ts
CHANGED
|
@@ -351,6 +351,18 @@ interface RepertoireProps {
|
|
|
351
351
|
renames?: Readonly<Record<string, string>>;
|
|
352
352
|
/** Piece fields retired since an earlier version: no longer declared, still read. */
|
|
353
353
|
retired?: readonly string[];
|
|
354
|
+
/**
|
|
355
|
+
* 🚧 Whether an entry a session creates begins at the session's story date
|
|
356
|
+
* (`'began'`) or has always been true (`'perpetual'`). Absent when
|
|
357
|
+
* unstated: perpetual. The layers are this default ← the writing step's
|
|
358
|
+
* params. @experimental
|
|
359
|
+
*/
|
|
360
|
+
defaultBeginning?: 'perpetual' | 'began';
|
|
361
|
+
/**
|
|
362
|
+
* 🚧 The Decay rate, 0 (a fact) to 1, an entry a session creates starts
|
|
363
|
+
* with. Absent when unstated: 0. @experimental
|
|
364
|
+
*/
|
|
365
|
+
defaultDecayRate?: number;
|
|
354
366
|
}
|
|
355
367
|
/** @experimental */
|
|
356
368
|
export interface RepertoireDecl extends Omit<RepertoireProps, 'piece'> {
|
|
@@ -449,7 +461,7 @@ export declare const _repertoireMechanicFindings: (rep: RepertoireDecl, ctx: Rep
|
|
|
449
461
|
*
|
|
450
462
|
* Reasons: `invalid-id` · `display-text` · `missing-prose` ·
|
|
451
463
|
* `piece-not-object` · `piece-redeclares-universal` · `piece-reserved-field` ·
|
|
452
|
-
* `bad-applies-to` · `bad-earshot` · `bad-gm-only` · `bad-render-depth` ·
|
|
464
|
+
* `bad-applies-to` · `bad-earshot` · `bad-gm-only` · `bad-render-depth` · 🚧 `bad-entry-default` ·
|
|
453
465
|
* `rename-still-declared` · `rename-to-nothing` · `retired-still-declared` ·
|
|
454
466
|
* `unknown-verb` · `unknown-event` · `malformed-mechanic` · `inert-pairing` ·
|
|
455
467
|
* `mechanic-duration` · `bad-predicate` · `unknown-selector` ·
|
package/dist/repertoires.js
CHANGED
|
@@ -288,6 +288,10 @@ function ownFindings(id, props, built) {
|
|
|
288
288
|
if (!Array.isArray(tags) || tags.some((t) => typeof t !== 'string' || !REPERTOIRE_NAME.test(t)) || new Set(tags).size !== tags.length)
|
|
289
289
|
out.push(finding('bad-tags', `${at}.tags is a list of distinct lowercase words joined by '-' — ${REPERTOIRE_TAGS.slice(0, 3).map((t) => `'${t}'`).join(', ')}, or a word of the ruleset's own.`));
|
|
290
290
|
}
|
|
291
|
+
if (props.defaultBeginning !== undefined && props.defaultBeginning !== 'perpetual' && props.defaultBeginning !== 'began')
|
|
292
|
+
out.push(finding('bad-entry-default', `${at} declares defaultBeginning '${String(props.defaultBeginning)}'. Say 'perpetual' or 'began', or leave it out.`));
|
|
293
|
+
if (props.defaultDecayRate !== undefined && !(typeof props.defaultDecayRate === 'number' && Number.isFinite(props.defaultDecayRate) && props.defaultDecayRate >= 0 && props.defaultDecayRate <= 1))
|
|
294
|
+
out.push(finding('bad-entry-default', `${at} declares defaultDecayRate ${String(props.defaultDecayRate)}. A Decay rate is a number from 0 to 1: 0 is a fact, above 0 a living entry.`));
|
|
291
295
|
if (props.renderDepth !== undefined && !RENDER_DEPTHS.includes(props.renderDepth))
|
|
292
296
|
out.push(finding('bad-render-depth', `${at}.renderDepth is '${String(props.renderDepth)}'. Say 'index', 'summary' or 'full'.`));
|
|
293
297
|
const fields = new Set(Object.keys((built ?? wholePiece(props)).fields ?? {}));
|
|
@@ -517,7 +521,7 @@ export const _repertoireMechanicFindings = (rep, ctx, where) => (rep.mechanics ?
|
|
|
517
521
|
*
|
|
518
522
|
* Reasons: `invalid-id` · `display-text` · `missing-prose` ·
|
|
519
523
|
* `piece-not-object` · `piece-redeclares-universal` · `piece-reserved-field` ·
|
|
520
|
-
* `bad-applies-to` · `bad-earshot` · `bad-gm-only` · `bad-render-depth` ·
|
|
524
|
+
* `bad-applies-to` · `bad-earshot` · `bad-gm-only` · `bad-render-depth` · 🚧 `bad-entry-default` ·
|
|
521
525
|
* `rename-still-declared` · `rename-to-nothing` · `retired-still-declared` ·
|
|
522
526
|
* `unknown-verb` · `unknown-event` · `malformed-mechanic` · `inert-pairing` ·
|
|
523
527
|
* `mechanic-duration` · `bad-predicate` · `unknown-selector` ·
|
|
@@ -76,6 +76,17 @@ export declare function rulesetDocumentProps(doc: RulesetDocument): RulesetProps
|
|
|
76
76
|
* @experimental
|
|
77
77
|
*/
|
|
78
78
|
export declare function rulesetDocumentFindings(doc: unknown): string[];
|
|
79
|
+
/**
|
|
80
|
+
* 🚧 The template-like names in a document's `options.fields` — each a warning,
|
|
81
|
+
* never a refusal, for a field named `template`, `templates` or `variables`,
|
|
82
|
+
* whatever its reach. A ruleset's option is a rules choice: core draws each
|
|
83
|
+
* enum option on a session's _Rules options_ whatever its reach, and its
|
|
84
|
+
* value lays conventions, never a template. `[]` for a document that is not
|
|
85
|
+
* an object.
|
|
86
|
+
* @experimental
|
|
87
|
+
* @ruling G7
|
|
88
|
+
*/
|
|
89
|
+
export declare function rulesetDocumentWarnings(doc: unknown): string[];
|
|
79
90
|
/** Numeric order of two versions: negative, zero or positive. @experimental */
|
|
80
91
|
export declare function compareRulesetVersions(a: string, b: string): number;
|
|
81
92
|
/** The next patch version — `1.0.0` → `1.0.1`. @experimental */
|
package/dist/rulesetDocument.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { slotOwner } from './attributes.js';
|
|
21
21
|
import { finding, RULESET_ID_PATTERN } from './repertoires.js';
|
|
22
|
+
import { rulesetOptionWarnings } from './exposure.js';
|
|
22
23
|
import { declaresSections, rulesetAttributeSlots } from './rulesetSections.js';
|
|
23
24
|
import { parseFunctionId } from './functions.js';
|
|
24
25
|
import { defineStoredRuleset, rulesetFindings, rulesetUpgradeFindings, } from './rulesets.js';
|
|
@@ -78,6 +79,22 @@ export function rulesetDocumentFindings(doc) {
|
|
|
78
79
|
out.push(...upgradeChainFindings(d));
|
|
79
80
|
return out;
|
|
80
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* 🚧 The template-like names in a document's `options.fields` — each a warning,
|
|
84
|
+
* never a refusal, for a field named `template`, `templates` or `variables`,
|
|
85
|
+
* whatever its reach. A ruleset's option is a rules choice: core draws each
|
|
86
|
+
* enum option on a session's _Rules options_ whatever its reach, and its
|
|
87
|
+
* value lays conventions, never a template. `[]` for a document that is not
|
|
88
|
+
* an object.
|
|
89
|
+
* @experimental
|
|
90
|
+
* @ruling G7
|
|
91
|
+
*/
|
|
92
|
+
export function rulesetDocumentWarnings(doc) {
|
|
93
|
+
if (!doc || typeof doc !== 'object' || Array.isArray(doc))
|
|
94
|
+
return [];
|
|
95
|
+
const d = doc;
|
|
96
|
+
return rulesetOptionWarnings(d.options?.fields, `${String(d.id)}.options.fields`);
|
|
97
|
+
}
|
|
81
98
|
const UPGRADE_SLOT_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:slot\/[a-z0-9]+(?:-[a-z0-9]+)*@\d+$/;
|
|
82
99
|
/** 🚧 Why a document's `upgrades` chain is refused (`bad-version`): versions, forward, contiguous, ending at `version`, slot ids. */
|
|
83
100
|
function upgradeChainFindings(d) {
|
|
@@ -263,6 +263,18 @@ export interface RulesetEntryTypeDecl {
|
|
|
263
263
|
retired?: readonly string[];
|
|
264
264
|
/** ⏳ `false` for a repertoire that never yielded an entry type. */
|
|
265
265
|
entryable?: false;
|
|
266
|
+
/**
|
|
267
|
+
* 🚧 Whether an entry a session creates begins at the session's story date
|
|
268
|
+
* (`'began'`) or has always been true (`'perpetual'`). Absent when
|
|
269
|
+
* unstated: perpetual. The layers are this default ← the writing step's
|
|
270
|
+
* params. @experimental
|
|
271
|
+
*/
|
|
272
|
+
defaultBeginning?: 'perpetual' | 'began';
|
|
273
|
+
/**
|
|
274
|
+
* 🚧 The Decay rate, 0 (a fact) to 1, an entry a session creates starts
|
|
275
|
+
* with. Absent when unstated: 0. @experimental
|
|
276
|
+
*/
|
|
277
|
+
defaultDecayRate?: number;
|
|
266
278
|
}
|
|
267
279
|
/** 🚧 What a zone type that holds entries of every entry type says it holds. @experimental */
|
|
268
280
|
export declare const ZONE_HOLDS_ANY: '*';
|
package/dist/rulesetSections.js
CHANGED
|
@@ -348,6 +348,10 @@ export function rulesetEntryTypeFindings(e, at, own = new Map()) {
|
|
|
348
348
|
out.push(finding('bad-entry-type', `${at}.${flag} is true or left out.`));
|
|
349
349
|
if (e.entryable !== undefined && e.entryable !== false)
|
|
350
350
|
out.push(finding('bad-entry-type', `${at}.entryable is false or left out — an entry type is entryable.`));
|
|
351
|
+
if (e.defaultBeginning !== undefined && e.defaultBeginning !== 'perpetual' && e.defaultBeginning !== 'began')
|
|
352
|
+
out.push(finding('bad-entry-type', `${at} declares defaultBeginning '${String(e.defaultBeginning)}'. Say 'perpetual' or 'began', or leave it out.`));
|
|
353
|
+
if (e.defaultDecayRate !== undefined && !(typeof e.defaultDecayRate === 'number' && Number.isFinite(e.defaultDecayRate) && e.defaultDecayRate >= 0 && e.defaultDecayRate <= 1))
|
|
354
|
+
out.push(finding('bad-entry-type', `${at} declares defaultDecayRate ${String(e.defaultDecayRate)}. A Decay rate is a number from 0 to 1: 0 is a fact, above 0 a living entry.`));
|
|
351
355
|
if (e.renderDepth !== undefined && !RENDER_DEPTHS.includes(e.renderDepth))
|
|
352
356
|
out.push(finding('bad-render-depth', `${at}.renderDepth is one of ${RENDER_DEPTHS.join(', ')}.`));
|
|
353
357
|
out.push(...ownersFindings(e.holders, `${at}.holders`, 'bad-holders'));
|
|
@@ -689,6 +693,8 @@ function aliasEntryTypes(d) {
|
|
|
689
693
|
...(r.renderDepth !== undefined ? { renderDepth: r.renderDepth } : {}),
|
|
690
694
|
...(r.renames !== undefined ? { renames: r.renames } : {}),
|
|
691
695
|
...(r.retired !== undefined ? { retired: r.retired } : {}),
|
|
696
|
+
...(r.defaultBeginning !== undefined ? { defaultBeginning: r.defaultBeginning } : {}),
|
|
697
|
+
...(r.defaultDecayRate !== undefined ? { defaultDecayRate: r.defaultDecayRate } : {}),
|
|
692
698
|
...(entryable.has(r.id) ? {} : { entryable: false }),
|
|
693
699
|
}));
|
|
694
700
|
}
|
|
@@ -925,6 +931,8 @@ export function _entryTypeAsRepertoire(e) {
|
|
|
925
931
|
...(e.renderDepth !== undefined ? { renderDepth: e.renderDepth } : {}),
|
|
926
932
|
...(e.renames ? { renames: e.renames } : {}),
|
|
927
933
|
...(e.retired ? { retired: e.retired } : {}),
|
|
934
|
+
...(e.defaultBeginning !== undefined ? { defaultBeginning: e.defaultBeginning } : {}),
|
|
935
|
+
...(e.defaultDecayRate !== undefined ? { defaultDecayRate: e.defaultDecayRate } : {}),
|
|
928
936
|
...(e.entryable !== false ? { entryable: true } : {}),
|
|
929
937
|
};
|
|
930
938
|
}
|