@agentshouse/mdmodel 0.1.0-c669bdbad8a03 → 0.1.0-c679f403bf3fb
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/API.md +71 -61
- package/dist/condition.d.ts +19 -7
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +189 -85
- package/dist/definition.d.ts +1 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +29 -3
- package/dist/divide.js +9 -9
- package/dist/document.d.ts +4 -4
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +28 -30
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/links.d.ts +1 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +43 -28
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +3 -5
- package/dist/types.d.ts +8 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +25 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +135 -65
- package/fixtures/README.md +5 -4
- package/fixtures/division.json +26 -26
- package/package.json +1 -1
package/dist/condition.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerSegments, } from './definition.js';
|
|
1
|
+
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
2
2
|
import { roomPath, target } from './paths.js';
|
|
3
|
-
import {
|
|
3
|
+
import { plain } from './yaml.js';
|
|
4
|
+
export const CONDITION_OPERATORS = [
|
|
5
|
+
'eq',
|
|
6
|
+
'in',
|
|
7
|
+
'exists',
|
|
8
|
+
'contains',
|
|
9
|
+
'gt',
|
|
10
|
+
'gte',
|
|
11
|
+
'lt',
|
|
12
|
+
'lte',
|
|
13
|
+
'prefix',
|
|
14
|
+
];
|
|
4
15
|
export const WRITE_DOORS = ['browser', 'agent', 'client'];
|
|
5
16
|
const PROSE = { kind: 'prose' };
|
|
6
17
|
const NULL = { kind: 'null' };
|
|
@@ -8,6 +19,7 @@ const UNREADABLE = { kind: 'unreadable' };
|
|
|
8
19
|
const UNREAD = { present: undefined, values: [undefined], items: [undefined] };
|
|
9
20
|
const NO_ITEM = { present: false, values: [], items: [] };
|
|
10
21
|
const DATE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
22
|
+
const HEADER = /^\/headers\/[!#$%&'*+.^_`|~0-9a-z-]+$/u;
|
|
11
23
|
const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/u;
|
|
12
24
|
export function factKind(facts) {
|
|
13
25
|
if (facts.reference !== undefined)
|
|
@@ -71,8 +83,7 @@ function factOf(value, declared, place) {
|
|
|
71
83
|
return UNREADABLE;
|
|
72
84
|
if (kind !== 'reference')
|
|
73
85
|
return { kind, value };
|
|
74
|
-
const reached = target(place.path, value) ??
|
|
75
|
-
(declared.crossRoom === true ? roomPath(value) : null);
|
|
86
|
+
const reached = target(place.path, value) ?? roomPath(value);
|
|
76
87
|
const resolved = reached === null ? undefined : place.resolve(reached);
|
|
77
88
|
if (resolved === undefined)
|
|
78
89
|
return UNREADABLE;
|
|
@@ -182,10 +193,9 @@ function documentRead({ reached, several, missing }, held) {
|
|
|
182
193
|
};
|
|
183
194
|
}
|
|
184
195
|
function readDocument(facts, path) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return facts.type === null ? undefined : single({ kind: 'string', value: facts.type });
|
|
196
|
+
const own = tested(DOCUMENT_TESTS, path);
|
|
197
|
+
if (own !== undefined)
|
|
198
|
+
return own.read(facts, path);
|
|
189
199
|
if (path.startsWith('/sections/'))
|
|
190
200
|
return facts.sections.includes(path.slice('/sections/'.length))
|
|
191
201
|
? single({ kind: 'prose' })
|
|
@@ -196,22 +206,147 @@ function readDocument(facts, path) {
|
|
|
196
206
|
return documentRead(walked(rootOf(facts, '/members'), path.slice('/members'.length)), memberHeld);
|
|
197
207
|
return undefined;
|
|
198
208
|
}
|
|
199
|
-
function readActor(actor, path) {
|
|
200
|
-
const value = path === '/user'
|
|
201
|
-
? actor.user
|
|
202
|
-
: path === '/site'
|
|
203
|
-
? actor.site
|
|
204
|
-
: path === '/door'
|
|
205
|
-
? actor.door
|
|
206
|
-
: undefined;
|
|
207
|
-
return value === undefined ? undefined : single({ kind: 'actor', value });
|
|
208
|
-
}
|
|
209
209
|
export function datePointers(fields) {
|
|
210
210
|
return Object.entries(fields)
|
|
211
211
|
.filter(([, facts]) => facts.type === 'string' && facts.format === 'date')
|
|
212
|
-
.map(([name]) => `/fields/${name}`)
|
|
212
|
+
.map(([name]) => `/fields/${escapePointer(name)}`)
|
|
213
213
|
.sort();
|
|
214
214
|
}
|
|
215
|
+
export function valuedChange(definition, field) {
|
|
216
|
+
if (!field.startsWith('/fields/'))
|
|
217
|
+
return false;
|
|
218
|
+
const reached = pointerFacts(definition, field.slice('/fields'.length));
|
|
219
|
+
return (reached !== undefined &&
|
|
220
|
+
!reached.through &&
|
|
221
|
+
reached.facts.type !== 'array' &&
|
|
222
|
+
!reached.facts.prose &&
|
|
223
|
+
factKind(reached.facts) !== null);
|
|
224
|
+
}
|
|
225
|
+
export function changeFields(definition) {
|
|
226
|
+
return [
|
|
227
|
+
...Object.keys(definition.fields).map((name) => `/fields/${escapePointer(name)}`),
|
|
228
|
+
...Object.keys(definition.sections).map((heading) => `/sections/${heading}`),
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
export function memberPointers(definition, memberType) {
|
|
232
|
+
return Object.entries(definition.fields)
|
|
233
|
+
.filter(([, facts]) => (facts.type === 'array' ? facts.items : facts)?.reference?.includes(memberType) === true)
|
|
234
|
+
.map(([name]) => `/members/${escapePointer(name)}`);
|
|
235
|
+
}
|
|
236
|
+
function kindOperators(kind) {
|
|
237
|
+
switch (kind) {
|
|
238
|
+
case 'string':
|
|
239
|
+
return ['eq', 'in', 'prefix', 'exists'];
|
|
240
|
+
case 'boolean':
|
|
241
|
+
return ['eq', 'exists'];
|
|
242
|
+
case 'number':
|
|
243
|
+
case 'date':
|
|
244
|
+
case 'time':
|
|
245
|
+
return ['eq', 'in', 'gt', 'gte', 'lt', 'lte', 'exists'];
|
|
246
|
+
default:
|
|
247
|
+
return ['eq', 'in', 'exists'];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function pointerOperators({ facts, through }) {
|
|
251
|
+
const scalar = facts.type === 'array' ? facts.items : facts;
|
|
252
|
+
const kind = scalar === undefined || scalar.prose ? null : factKind(scalar);
|
|
253
|
+
if (kind === null)
|
|
254
|
+
return ['exists'];
|
|
255
|
+
if (facts.type === 'array')
|
|
256
|
+
return ['contains', 'exists'];
|
|
257
|
+
const own = kindOperators(kind);
|
|
258
|
+
return through ? [...own.filter((operator) => operator !== 'exists'), 'contains', 'exists'] : own;
|
|
259
|
+
}
|
|
260
|
+
function typeOperators(definition, path, memberType) {
|
|
261
|
+
if (path.startsWith('/sections/'))
|
|
262
|
+
return Object.hasOwn(definition.sections, path.slice('/sections/'.length)) ? ['exists'] : [];
|
|
263
|
+
const pointer = path.startsWith('/fields/')
|
|
264
|
+
? path.slice('/fields'.length)
|
|
265
|
+
: memberType !== null && memberPointers(definition, memberType).includes(path)
|
|
266
|
+
? path.slice('/members'.length)
|
|
267
|
+
: undefined;
|
|
268
|
+
const reached = pointer === undefined ? undefined : pointerFacts(definition, pointer);
|
|
269
|
+
return reached === undefined ? [] : pointerOperators(reached);
|
|
270
|
+
}
|
|
271
|
+
function envelope(path, kind, value) {
|
|
272
|
+
return {
|
|
273
|
+
path,
|
|
274
|
+
names: (named) => named === path,
|
|
275
|
+
kind,
|
|
276
|
+
operators: kindOperators(kind),
|
|
277
|
+
read: (facts) => {
|
|
278
|
+
const held = value(facts);
|
|
279
|
+
return held === null || held === undefined ? undefined : single({ kind, value: held });
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function tested(tests, path) {
|
|
284
|
+
return tests.find(({ names }) => names(path));
|
|
285
|
+
}
|
|
286
|
+
function reader(tests, facts) {
|
|
287
|
+
return (path) => tested(tests, path)?.read(facts, path);
|
|
288
|
+
}
|
|
289
|
+
const DOCUMENT_TESTS = [
|
|
290
|
+
{
|
|
291
|
+
path: '/path',
|
|
292
|
+
names: (named) => named === '/path',
|
|
293
|
+
kind: 'string',
|
|
294
|
+
operators: ['eq', 'in', 'prefix'],
|
|
295
|
+
read: (facts) => single({ kind: 'string', value: facts.path }),
|
|
296
|
+
},
|
|
297
|
+
envelope('/type', 'enum', (facts) => facts.type),
|
|
298
|
+
];
|
|
299
|
+
const ACTOR_TESTS = [
|
|
300
|
+
envelope('/user', 'enum', (actor) => actor.user),
|
|
301
|
+
envelope('/site', 'enum', (actor) => actor.site),
|
|
302
|
+
envelope('/door', 'enum', (actor) => actor.door),
|
|
303
|
+
];
|
|
304
|
+
const ITEM_TESTS = [
|
|
305
|
+
envelope('/delivery', 'enum', (item) => item.delivery),
|
|
306
|
+
envelope('/source', 'enum', (item) => item.source),
|
|
307
|
+
envelope('/has_attachment', 'boolean', (item) => item.has_attachment),
|
|
308
|
+
envelope('/container', 'string', (item) => item.container),
|
|
309
|
+
envelope('/author', 'string', (item) => item.author),
|
|
310
|
+
{
|
|
311
|
+
path: '/headers/<lowercase name>',
|
|
312
|
+
names: (named) => HEADER.test(named),
|
|
313
|
+
kind: 'string',
|
|
314
|
+
operators: kindOperators('string'),
|
|
315
|
+
read: (item, path) => {
|
|
316
|
+
const name = path.slice('/headers/'.length);
|
|
317
|
+
return Object.hasOwn(item.headers, name)
|
|
318
|
+
? single({ kind: 'string', value: item.headers[name] })
|
|
319
|
+
: undefined;
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
path: '/json/<JSON Pointer>',
|
|
324
|
+
names: (named) => named.startsWith('/json/'),
|
|
325
|
+
kind: null,
|
|
326
|
+
operators: CONDITION_OPERATORS,
|
|
327
|
+
read: (item, path) => item.json === null ? UNREAD : jsonRead(pointed(item.json.value, path.slice('/json'.length))),
|
|
328
|
+
},
|
|
329
|
+
];
|
|
330
|
+
export const DOCUMENT_PATHS = DOCUMENT_TESTS.map(({ path }) => path);
|
|
331
|
+
export const ACTOR_PATHS = ACTOR_TESTS.map(({ path }) => path);
|
|
332
|
+
export const ITEM_PATHS = ITEM_TESTS.map(({ path }) => path);
|
|
333
|
+
export function testOperators(definitions, path, memberType) {
|
|
334
|
+
const own = tested(DOCUMENT_TESTS, path);
|
|
335
|
+
if (own !== undefined)
|
|
336
|
+
return own.operators;
|
|
337
|
+
return [
|
|
338
|
+
...new Set(definitions.flatMap((definition) => typeOperators(definition, path, memberType))),
|
|
339
|
+
];
|
|
340
|
+
}
|
|
341
|
+
export function actorOperators(path) {
|
|
342
|
+
return tested(ACTOR_TESTS, path)?.operators ?? [];
|
|
343
|
+
}
|
|
344
|
+
export function itemOperators(path) {
|
|
345
|
+
return tested(ITEM_TESTS, path)?.operators ?? [];
|
|
346
|
+
}
|
|
347
|
+
export function itemKind(path) {
|
|
348
|
+
return tested(ITEM_TESTS, path)?.kind ?? null;
|
|
349
|
+
}
|
|
215
350
|
export function dated(value) {
|
|
216
351
|
return (typeof value === 'string' && DATE.test(value) && instant(`${value}T00:00:00Z`) !== undefined);
|
|
217
352
|
}
|
|
@@ -240,11 +375,8 @@ export function instant(value) {
|
|
|
240
375
|
return (BigInt(at.getTime()) - BigInt(offset) * 60000n) * 1000000n + BigInt(fraction);
|
|
241
376
|
}
|
|
242
377
|
export function pointed(value, pointer) {
|
|
243
|
-
if (pointer === '')
|
|
244
|
-
return value;
|
|
245
378
|
let reached = value;
|
|
246
|
-
for (const
|
|
247
|
-
const token = part.replaceAll('~1', '/').replaceAll('~0', '~');
|
|
379
|
+
for (const token of pointerSegments(pointer)) {
|
|
248
380
|
if (Array.isArray(reached)) {
|
|
249
381
|
if (!ARRAY_INDEX.test(token))
|
|
250
382
|
return undefined;
|
|
@@ -283,44 +415,15 @@ function jsonRead(value) {
|
|
|
283
415
|
return single({ kind: 'prose' });
|
|
284
416
|
return { present: true, values: [], items: value.filter(scalar).map(jsonHeld), loose: true };
|
|
285
417
|
}
|
|
286
|
-
function
|
|
287
|
-
if (path.startsWith('/json/')) {
|
|
288
|
-
if (item.json === null)
|
|
289
|
-
return UNREAD;
|
|
290
|
-
return jsonRead(pointed(item.json.value, path.slice('/json'.length)));
|
|
291
|
-
}
|
|
292
|
-
if (path.startsWith('/headers/')) {
|
|
293
|
-
const name = path.slice('/headers/'.length);
|
|
294
|
-
return Object.hasOwn(item.headers, name)
|
|
295
|
-
? single({ kind: 'string', value: item.headers[name] })
|
|
296
|
-
: undefined;
|
|
297
|
-
}
|
|
298
|
-
if (path === '/has_attachment')
|
|
299
|
-
return single({ kind: 'boolean', value: item.has_attachment });
|
|
300
|
-
const value = path === '/delivery'
|
|
301
|
-
? item.delivery
|
|
302
|
-
: path === '/source'
|
|
303
|
-
? item.source
|
|
304
|
-
: path === '/container'
|
|
305
|
-
? item.container
|
|
306
|
-
: path === '/author'
|
|
307
|
-
? item.author
|
|
308
|
-
: null;
|
|
309
|
-
return value === null ? undefined : single({ kind: 'string', value });
|
|
310
|
-
}
|
|
311
|
-
function wanted(value, owner) {
|
|
312
|
-
return isRecord(value) && value.owner === true ? owner : value;
|
|
313
|
-
}
|
|
314
|
-
function equal(held, value, owner) {
|
|
418
|
+
function equal(held, value) {
|
|
315
419
|
if (!('value' in held))
|
|
316
420
|
return undefined;
|
|
317
|
-
|
|
318
|
-
if (typeof expected !== typeof held.value)
|
|
421
|
+
if (typeof value !== typeof held.value)
|
|
319
422
|
return undefined;
|
|
320
423
|
if (held.kind !== 'time')
|
|
321
|
-
return
|
|
424
|
+
return value === held.value;
|
|
322
425
|
const left = instant(held.value);
|
|
323
|
-
const right = instant(
|
|
426
|
+
const right = instant(value);
|
|
324
427
|
return left === undefined || right === undefined ? undefined : left === right;
|
|
325
428
|
}
|
|
326
429
|
function sign(left, right) {
|
|
@@ -357,11 +460,11 @@ function allOf(truths) {
|
|
|
357
460
|
return false;
|
|
358
461
|
return truths.some((truth) => truth === undefined) ? undefined : true;
|
|
359
462
|
}
|
|
360
|
-
function compared(test, held
|
|
463
|
+
function compared(test, held) {
|
|
361
464
|
if ('eq' in test)
|
|
362
|
-
return equal(held, test.eq
|
|
465
|
+
return equal(held, test.eq);
|
|
363
466
|
if ('in' in test)
|
|
364
|
-
return anyOf(test.in.map((value) => equal(held, value
|
|
467
|
+
return anyOf(test.in.map((value) => equal(held, value)));
|
|
365
468
|
if ('prefix' in test) {
|
|
366
469
|
if (!('value' in held) || typeof held.value !== 'string')
|
|
367
470
|
return undefined;
|
|
@@ -377,7 +480,7 @@ function compared(test, held, owner) {
|
|
|
377
480
|
return ordered(held, test.lt, (sign) => sign < 0);
|
|
378
481
|
return ordered(held, test.lte, (sign) => sign <= 0);
|
|
379
482
|
}
|
|
380
|
-
function leaf(test, read
|
|
483
|
+
function leaf(test, read) {
|
|
381
484
|
if ('exists' in test) {
|
|
382
485
|
const present = read === undefined ? false : read.present;
|
|
383
486
|
return present === undefined ? undefined : present === test.exists;
|
|
@@ -387,23 +490,23 @@ function leaf(test, read, owner) {
|
|
|
387
490
|
if ('contains' in test) {
|
|
388
491
|
if (read.items === null)
|
|
389
492
|
return undefined;
|
|
390
|
-
const truths = read.items.map((item) => item === undefined ? undefined : equal(item, test.contains
|
|
493
|
+
const truths = read.items.map((item) => item === undefined ? undefined : equal(item, test.contains));
|
|
391
494
|
return read.loose === true && !truths.includes(true) ? false : anyOf(truths);
|
|
392
495
|
}
|
|
393
496
|
if (read.values.length === 0)
|
|
394
497
|
return read === NO_ITEM ? false : undefined;
|
|
395
|
-
return anyOf(read.values.map((value) => (value === undefined ? undefined : compared(test, value
|
|
498
|
+
return anyOf(read.values.map((value) => (value === undefined ? undefined : compared(test, value))));
|
|
396
499
|
}
|
|
397
|
-
function evaluated(test, read
|
|
500
|
+
function evaluated(test, read) {
|
|
398
501
|
if ('all' in test)
|
|
399
|
-
return allOf(test.all.map((part) => evaluated(part, read
|
|
502
|
+
return allOf(test.all.map((part) => evaluated(part, read)));
|
|
400
503
|
if ('any' in test)
|
|
401
|
-
return anyOf(test.any.map((part) => evaluated(part, read
|
|
504
|
+
return anyOf(test.any.map((part) => evaluated(part, read)));
|
|
402
505
|
if ('not' in test) {
|
|
403
|
-
const truth = evaluated(test.not, read
|
|
506
|
+
const truth = evaluated(test.not, read);
|
|
404
507
|
return truth === undefined ? undefined : !truth;
|
|
405
508
|
}
|
|
406
|
-
return leaf(test, read(test.path)
|
|
509
|
+
return leaf(test, read(test.path));
|
|
407
510
|
}
|
|
408
511
|
export function members(document, path) {
|
|
409
512
|
if (!path.startsWith('/members/'))
|
|
@@ -416,8 +519,8 @@ export function members(document, path) {
|
|
|
416
519
|
: [])),
|
|
417
520
|
].sort();
|
|
418
521
|
}
|
|
419
|
-
export function holds(test, document
|
|
420
|
-
return evaluated(test, (path) => readDocument(document, path)
|
|
522
|
+
export function holds(test, document) {
|
|
523
|
+
return evaluated(test, (path) => readDocument(document, path));
|
|
421
524
|
}
|
|
422
525
|
function inScope(scope, document) {
|
|
423
526
|
if (document === null)
|
|
@@ -428,10 +531,10 @@ function inScope(scope, document) {
|
|
|
428
531
|
return document.id === scope.document;
|
|
429
532
|
return scope.folder === '/' || document.path.startsWith(`${scope.folder}/`);
|
|
430
533
|
}
|
|
431
|
-
function matched(condition, test, document
|
|
534
|
+
function matched(condition, test, document) {
|
|
432
535
|
if (!inScope(condition.scope, document))
|
|
433
536
|
return false;
|
|
434
|
-
return test === undefined || holds(test, document
|
|
537
|
+
return test === undefined || holds(test, document) === true;
|
|
435
538
|
}
|
|
436
539
|
function reachedAt(document, field) {
|
|
437
540
|
if (document === null)
|
|
@@ -464,10 +567,10 @@ function valueOf(fact) {
|
|
|
464
567
|
function signature(reached) {
|
|
465
568
|
return JSON.stringify(reached.map(({ fact }) => valueOf(fact)));
|
|
466
569
|
}
|
|
467
|
-
function among(values, document, field
|
|
468
|
-
return holds({ path: field, in: values }, document
|
|
570
|
+
function among(values, document, field) {
|
|
571
|
+
return holds({ path: field, in: values }, document) === true;
|
|
469
572
|
}
|
|
470
|
-
function fieldChanged(condition, event
|
|
573
|
+
function fieldChanged(condition, event) {
|
|
471
574
|
const { field, from, to } = condition;
|
|
472
575
|
const before = reachedAt(event.before, field);
|
|
473
576
|
const after = reachedAt(event.after, field);
|
|
@@ -481,32 +584,33 @@ function fieldChanged(condition, event, owner) {
|
|
|
481
584
|
return false;
|
|
482
585
|
if (from === 'new'
|
|
483
586
|
? event.before !== null
|
|
484
|
-
: from !== undefined && (event.before === null || !among(from, event.before, field
|
|
587
|
+
: from !== undefined && (event.before === null || !among(from, event.before, field)))
|
|
485
588
|
return false;
|
|
486
589
|
if (to === 'deleted'
|
|
487
590
|
? event.after !== null
|
|
488
|
-
: to !== undefined && (event.after === null || !among(to, event.after, field
|
|
591
|
+
: to !== undefined && (event.after === null || !among(to, event.after, field)))
|
|
489
592
|
return false;
|
|
490
593
|
return true;
|
|
491
594
|
}
|
|
492
|
-
export function fires(condition, event
|
|
493
|
-
if (condition.
|
|
494
|
-
|
|
595
|
+
export function fires(condition, event) {
|
|
596
|
+
if (condition.moved_between_rooms !== undefined &&
|
|
597
|
+
condition.moved_between_rooms !== event.moved_between_rooms)
|
|
598
|
+
return false;
|
|
599
|
+
if (condition.by !== undefined && evaluated(condition.by, reader(ACTOR_TESTS, event.by)) !== true)
|
|
495
600
|
return false;
|
|
496
601
|
if (condition.mode === 'starts_matching') {
|
|
497
602
|
if (event.before === null && !condition.new_documents)
|
|
498
603
|
return false;
|
|
499
|
-
return (matched(condition, condition.match, event.after
|
|
500
|
-
!matched(condition, condition.match, event.before
|
|
604
|
+
return (matched(condition, condition.match, event.after) &&
|
|
605
|
+
!matched(condition, condition.match, event.before));
|
|
501
606
|
}
|
|
502
607
|
const side = event.after ?? event.before;
|
|
503
|
-
return matched(condition, condition.match, side
|
|
608
|
+
return matched(condition, condition.match, side) && fieldChanged(condition, event);
|
|
504
609
|
}
|
|
505
|
-
export function itemFires(condition, item
|
|
610
|
+
export function itemFires(condition, item) {
|
|
506
611
|
if (condition.source !== undefined && item.source !== condition.source)
|
|
507
612
|
return false;
|
|
508
613
|
if (condition.address !== undefined && item.address !== condition.address)
|
|
509
614
|
return false;
|
|
510
|
-
return (condition.match === undefined ||
|
|
511
|
-
evaluated(condition.match, (path) => readItem(item, path), owner) === true);
|
|
615
|
+
return (condition.match === undefined || evaluated(condition.match, reader(ITEM_TESTS, item)) === true);
|
|
512
616
|
}
|
package/dist/definition.d.ts
CHANGED
|
@@ -77,5 +77,5 @@ export type PointerFacts = {
|
|
|
77
77
|
export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
|
|
78
78
|
export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
|
|
79
79
|
export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
|
|
80
|
-
export declare function readSchema(text: string): VerifiedModel | Failure;
|
|
80
|
+
export declare function readSchema(text: string, provided?: VerifiedModel): VerifiedModel | Failure;
|
|
81
81
|
//# sourceMappingURL=definition.d.ts.map
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjG,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,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;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAKlF;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAK5D;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAItF;AAqBD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAc9F;AAuQD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,aAAwB,GACjC,aAAa,GAAG,OAAO,CAsCzB"}
|
package/dist/definition.js
CHANGED
|
@@ -24,6 +24,8 @@ const ANNOTATIONS = new Set([
|
|
|
24
24
|
'writeOnly',
|
|
25
25
|
]);
|
|
26
26
|
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
27
|
+
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
28
|
+
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
27
29
|
const DEFS_REFERENCE = '#/$defs/';
|
|
28
30
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
29
31
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
@@ -657,6 +659,24 @@ function unruled(schema) {
|
|
|
657
659
|
}
|
|
658
660
|
return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
|
|
659
661
|
}
|
|
662
|
+
function providedType(name, value, provided) {
|
|
663
|
+
const at = `/${escapePointer(name)}`;
|
|
664
|
+
if (!isRecord(value))
|
|
665
|
+
return refuse('schema', at);
|
|
666
|
+
const declared = Object.keys(value).find((key) => !PROVIDED_KEYWORDS.includes(key));
|
|
667
|
+
if (declared !== undefined)
|
|
668
|
+
return refuse('provided-type', `${at}/${escapePointer(declared)}`);
|
|
669
|
+
const { create_roles: createRoles, delete_roles: deleteRoles } = value;
|
|
670
|
+
if (createRoles !== undefined && !roleNames(createRoles))
|
|
671
|
+
return refuse('create_roles', `${at}/create_roles`);
|
|
672
|
+
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
673
|
+
return refuse('delete_roles', `${at}/delete_roles`);
|
|
674
|
+
return {
|
|
675
|
+
...provided,
|
|
676
|
+
...(createRoles === undefined ? {} : { createRoles }),
|
|
677
|
+
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
678
|
+
};
|
|
679
|
+
}
|
|
660
680
|
function readType(name, value, context) {
|
|
661
681
|
const at = `/${escapePointer(name)}`;
|
|
662
682
|
if (!isRecord(value))
|
|
@@ -712,7 +732,7 @@ function readType(name, value, context) {
|
|
|
712
732
|
function lineAt(text, offset) {
|
|
713
733
|
return text.slice(0, offset).split(/\r\n|\r|\n/).length;
|
|
714
734
|
}
|
|
715
|
-
export function readSchema(text) {
|
|
735
|
+
export function readSchema(text, provided = NO_TYPES) {
|
|
716
736
|
let root;
|
|
717
737
|
try {
|
|
718
738
|
root = jsValue(parseYamlMapping(text, 0, text.length));
|
|
@@ -730,7 +750,7 @@ export function readSchema(text) {
|
|
|
730
750
|
if (name === '' || name.startsWith('$') || name === BUILT_IN_TYPE || name === ATTACHMENT)
|
|
731
751
|
return refuse('schema-type-name', `/${escapePointer(name)}`);
|
|
732
752
|
}
|
|
733
|
-
const context = { defs, types: new Set(names) };
|
|
753
|
+
const context = { defs, types: new Set([...names, ...Object.keys(provided.types)]) };
|
|
734
754
|
for (const [name, def] of Object.entries(defs)) {
|
|
735
755
|
const failure = schemaFailure(def, `/$defs/${escapePointer(name)}`, context);
|
|
736
756
|
if (failure !== undefined)
|
|
@@ -739,7 +759,9 @@ export function readSchema(text) {
|
|
|
739
759
|
const types = Object.create(null);
|
|
740
760
|
let marked = false;
|
|
741
761
|
for (const name of names) {
|
|
742
|
-
const definition =
|
|
762
|
+
const definition = Object.hasOwn(provided.types, name)
|
|
763
|
+
? providedType(name, root[name], provided.types[name])
|
|
764
|
+
: readType(name, root[name], context);
|
|
743
765
|
if ('rule' in definition)
|
|
744
766
|
return definition;
|
|
745
767
|
if (definition.memberDocument) {
|
|
@@ -749,5 +771,9 @@ export function readSchema(text) {
|
|
|
749
771
|
}
|
|
750
772
|
types[name] = deepFreeze(definition);
|
|
751
773
|
}
|
|
774
|
+
for (const [name, definition] of Object.entries(provided.types)) {
|
|
775
|
+
if (!Object.hasOwn(types, name))
|
|
776
|
+
types[name] = definition;
|
|
777
|
+
}
|
|
752
778
|
return Object.freeze({ types: Object.freeze(types) });
|
|
753
779
|
}
|
package/dist/divide.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blockRanges, headingLines } from './blocks.js';
|
|
2
2
|
import { firstEditFrom, projectionInput, rangeText, } from './project.js';
|
|
3
3
|
import { refusal } from './refuse.js';
|
|
4
|
-
const
|
|
4
|
+
const SMALLEST_BOUND = 2;
|
|
5
5
|
function node(draft) {
|
|
6
6
|
return {
|
|
7
7
|
start: draft.start,
|
|
@@ -86,8 +86,8 @@ function isTrailingSurrogate(text, index) {
|
|
|
86
86
|
function characterLength(text, index) {
|
|
87
87
|
return isTrailingSurrogate(text, index + 1) ? 2 : 1;
|
|
88
88
|
}
|
|
89
|
-
function boundOf(cutting, from, to,
|
|
90
|
-
const limit = from +
|
|
89
|
+
function boundOf(cutting, from, to, bound) {
|
|
90
|
+
const limit = from + bound;
|
|
91
91
|
if (limit >= to)
|
|
92
92
|
return to;
|
|
93
93
|
for (let index = limit; index > from + 1; index -= 1) {
|
|
@@ -168,12 +168,12 @@ function valueCutting(value) {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
function prefixOf(state, body) {
|
|
171
|
-
if (body.emitted === 0 || body.heading.length >= state.
|
|
171
|
+
if (body.emitted === 0 || body.heading.length >= state.bound)
|
|
172
172
|
return '';
|
|
173
173
|
return body.heading;
|
|
174
174
|
}
|
|
175
175
|
function available(state, body) {
|
|
176
|
-
return state.
|
|
176
|
+
return state.bound - prefixOf(state, body).length;
|
|
177
177
|
}
|
|
178
178
|
function emit(state, body, piece, bare = false) {
|
|
179
179
|
if (piece.text.trim() === '')
|
|
@@ -216,7 +216,7 @@ function divideBound(state, body, cutting, range) {
|
|
|
216
216
|
let start = range.start;
|
|
217
217
|
while (start < range.end) {
|
|
218
218
|
const bare = available(state, body) < characterLength(cutting.text, start);
|
|
219
|
-
const room = bare ? state.
|
|
219
|
+
const room = bare ? state.bound : available(state, body);
|
|
220
220
|
const stop = boundOf(cutting, start, range.end, room);
|
|
221
221
|
const piece = cutting.piece(start, stop);
|
|
222
222
|
if (cutting.masks.length === 0 || piece.text.length <= room) {
|
|
@@ -303,8 +303,8 @@ function divideInput(state, input) {
|
|
|
303
303
|
]);
|
|
304
304
|
}
|
|
305
305
|
export function divide(document, file, context) {
|
|
306
|
-
if (!Number.isInteger(context.
|
|
307
|
-
return { ok: false, refusal: refusal(file, 'division-
|
|
306
|
+
if (!Number.isInteger(context.bound) || context.bound < SMALLEST_BOUND) {
|
|
307
|
+
return { ok: false, refusal: refusal(file, 'division-bound') };
|
|
308
308
|
}
|
|
309
309
|
const result = projectionInput(document, file, context);
|
|
310
310
|
if (!result.ok)
|
|
@@ -312,7 +312,7 @@ export function divide(document, file, context) {
|
|
|
312
312
|
const state = {
|
|
313
313
|
content: document.content,
|
|
314
314
|
edits: result.input.edits,
|
|
315
|
-
|
|
315
|
+
bound: context.bound,
|
|
316
316
|
spans: [],
|
|
317
317
|
};
|
|
318
318
|
divideInput(state, result.input);
|
package/dist/document.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
|
-
import
|
|
2
|
+
import { type LinkInventory } from './links.js';
|
|
3
|
+
import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, ParseResult } from './types.js';
|
|
3
4
|
import { type YamlMap } from './yaml.js';
|
|
5
|
+
export declare function inventoryOf(document: Document): LinkInventory;
|
|
4
6
|
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
5
7
|
export declare function parse(content: string, file?: string): ParseResult;
|
|
6
|
-
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
|
|
8
|
+
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
|
|
7
9
|
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
|
8
10
|
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
9
11
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
10
|
-
export declare function linkOccurrences(document: Document, file: string): readonly LinkOccurrence[];
|
|
11
12
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
12
13
|
export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
|
|
13
14
|
export declare function serialize(document: Document): string;
|
|
14
|
-
export declare function fieldStart(document: Document, pointer: string): number | undefined;
|
|
15
15
|
export declare function frontmatter(document: Document): YamlMap | null;
|
|
16
16
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"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