@ldclabs/kip-lang 2.0.2 → 2.2.0
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 +69 -0
- package/README.md +4 -4
- package/dist/ast.d.ts +75 -58
- package/dist/ast.d.ts.map +1 -1
- package/dist/exec-ast.d.ts +51 -50
- package/dist/exec-ast.d.ts.map +1 -1
- package/dist/formatter.d.ts.map +1 -1
- package/dist/formatter.js +62 -121
- package/dist/formatter.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lower.d.ts.map +1 -1
- package/dist/lower.js +112 -97
- package/dist/lower.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +146 -224
- package/dist/parser.js.map +1 -1
- package/dist/semantics.js +66 -35
- package/dist/semantics.js.map +1 -1
- package/dist/token.d.ts +4 -11
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +8 -22
- package/dist/token.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/ast.ts +73 -70
- package/src/exec-ast.ts +53 -42
- package/src/formatter.ts +61 -139
- package/src/index.ts +7 -13
- package/src/lower.ts +134 -106
- package/src/parser.ts +161 -250
- package/src/semantics.ts +63 -37
- package/src/token.ts +8 -22
- package/src/version.ts +1 -1
package/src/exec-ast.ts
CHANGED
|
@@ -172,7 +172,8 @@ export interface KqlQuery {
|
|
|
172
172
|
cursor: Scalar | null
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
/** Cognitive time is a sequence coordinate; ids and instants resolve to one first. */
|
|
176
|
+
export type AsOf = { Seq: Scalar }
|
|
176
177
|
|
|
177
178
|
export interface FindClause {
|
|
178
179
|
expressions: FindExpression[]
|
|
@@ -306,16 +307,27 @@ export type MutationClause =
|
|
|
306
307
|
| { CreateAssertion: RecordCreate }
|
|
307
308
|
| { CreateActivity: RecordCreate }
|
|
308
309
|
| { Update: UpdateStatement }
|
|
309
|
-
| {
|
|
310
|
-
| { SupersedeAssertion: SupersedeAssertion }
|
|
311
|
-
| { CorrectEvidence: CorrectEvidence }
|
|
312
|
-
| { TransitionActivity: TransitionActivity }
|
|
310
|
+
| { Transition: Transition }
|
|
313
311
|
| { SetRetention: SetRetention }
|
|
314
|
-
| { Archive: RemovalStatement }
|
|
315
|
-
| { Tombstone: RemovalStatement }
|
|
316
312
|
| { Purge: PurgeStatement }
|
|
313
|
+
| { PurgePayload: PurgePayloadStatement }
|
|
317
314
|
| { MergeConcept: MergeConcept }
|
|
318
315
|
|
|
316
|
+
/**
|
|
317
|
+
* `EXPECT VERSION n [OF plane]` (Spec §35.1). Without a plane the guard is
|
|
318
|
+
* on the element's `_system.version`; with one, on that plane's own version.
|
|
319
|
+
*/
|
|
320
|
+
export interface ExpectVersion {
|
|
321
|
+
version: Scalar
|
|
322
|
+
plane: VersionPlane | null
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export type VersionPlane =
|
|
326
|
+
| 'Attributes'
|
|
327
|
+
| 'Structural'
|
|
328
|
+
| 'Retention'
|
|
329
|
+
| { Facet: SymbolRef }
|
|
330
|
+
|
|
319
331
|
export interface ConceptCreate {
|
|
320
332
|
handle: string
|
|
321
333
|
type: SymbolRef | null
|
|
@@ -330,7 +342,7 @@ export interface ConceptCreate {
|
|
|
330
342
|
export interface ConceptUpsert {
|
|
331
343
|
handle: string
|
|
332
344
|
match: ObjectMatcher | null
|
|
333
|
-
|
|
345
|
+
expect_versions: ExpectVersion[]
|
|
334
346
|
set_fields: Assignments | null
|
|
335
347
|
set_attributes: Assignments | null
|
|
336
348
|
set_facets: FacetAssignment[]
|
|
@@ -354,7 +366,7 @@ export interface EnsureProposition {
|
|
|
354
366
|
subject: Term
|
|
355
367
|
predicate: PredAtom
|
|
356
368
|
object: Term
|
|
357
|
-
|
|
369
|
+
expect_versions: ExpectVersion[]
|
|
358
370
|
}
|
|
359
371
|
|
|
360
372
|
export interface FacetAssignment {
|
|
@@ -405,14 +417,14 @@ export type UpdateFunction = 'Add' | 'Mul' | 'Clamp' | 'Coalesce'
|
|
|
405
417
|
|
|
406
418
|
export interface UpdateStatement {
|
|
407
419
|
target: ElementRef
|
|
408
|
-
expect_version: Scalar | null
|
|
409
420
|
actions: UpdateAction[]
|
|
410
421
|
/**
|
|
411
422
|
* `null` when the statement names its target directly and omits WHERE —
|
|
412
|
-
* the same shape as the removal family (Spec §58).
|
|
423
|
+
* the same shape as TRANSITION and the removal family (Spec §58).
|
|
413
424
|
*/
|
|
414
425
|
where_clauses: WhereClause[] | null
|
|
415
426
|
limit: Scalar | null
|
|
427
|
+
expect_versions: ExpectVersion[]
|
|
416
428
|
}
|
|
417
429
|
|
|
418
430
|
export type UpdateAction =
|
|
@@ -424,31 +436,21 @@ export type UpdateAction =
|
|
|
424
436
|
| { SetStructural: StructuralEdge[] }
|
|
425
437
|
| { UnsetStructural: StructuralRemoval[] }
|
|
426
438
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
export interface SupersedeAssertion {
|
|
435
|
-
target: ElementRef
|
|
436
|
-
by: ElementRef
|
|
437
|
-
expect_state: Scalar | null
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
export interface CorrectEvidence {
|
|
441
|
-
target: ElementRef
|
|
442
|
-
by: ElementRef
|
|
443
|
-
expect_state: Scalar | null
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
export interface TransitionActivity {
|
|
439
|
+
/**
|
|
440
|
+
* The one lifecycle statement (Spec §52.5): `to` names the move, the engine
|
|
441
|
+
* validates it against the target's kind and current state. `by` carries the
|
|
442
|
+
* replacing element for `superseded` / `corrected`; `set_fields` and
|
|
443
|
+
* `set_structural` finalize a pending Activity in the same transition.
|
|
444
|
+
*/
|
|
445
|
+
export interface Transition {
|
|
447
446
|
target: ElementRef
|
|
448
447
|
to: Scalar
|
|
448
|
+
by: ElementRef | null
|
|
449
449
|
set_fields: Assignments | null
|
|
450
450
|
set_structural: StructuralEdge[] | null
|
|
451
|
-
|
|
451
|
+
where_clauses: WhereClause[] | null
|
|
452
|
+
limit: Scalar | null
|
|
453
|
+
expect_versions: ExpectVersion[]
|
|
452
454
|
}
|
|
453
455
|
|
|
454
456
|
export interface SetRetention {
|
|
@@ -456,21 +458,28 @@ export interface SetRetention {
|
|
|
456
458
|
values: Assignments
|
|
457
459
|
where_clauses: WhereClause[] | null
|
|
458
460
|
limit: Scalar | null
|
|
459
|
-
|
|
461
|
+
expect_versions: ExpectVersion[]
|
|
460
462
|
}
|
|
461
463
|
|
|
462
|
-
export interface
|
|
464
|
+
export interface PurgeStatement {
|
|
463
465
|
target: ElementRef
|
|
464
466
|
where_clauses: WhereClause[] | null
|
|
465
467
|
limit: Scalar | null
|
|
466
|
-
|
|
468
|
+
expect_versions: ExpectVersion[]
|
|
469
|
+
reference_policy: Scalar | null
|
|
470
|
+
/** Always the literal `PURGE`; the grammar freezes the spelling. */
|
|
471
|
+
confirm: string
|
|
467
472
|
}
|
|
468
473
|
|
|
469
|
-
|
|
474
|
+
/**
|
|
475
|
+
* Payload-only purge (Spec §60.6): Evidence bytes are destroyed, the element
|
|
476
|
+
* survives, so no reference policy exists.
|
|
477
|
+
*/
|
|
478
|
+
export interface PurgePayloadStatement {
|
|
470
479
|
target: ElementRef
|
|
471
480
|
where_clauses: WhereClause[] | null
|
|
472
481
|
limit: Scalar | null
|
|
473
|
-
|
|
482
|
+
expect_versions: ExpectVersion[]
|
|
474
483
|
/** Always the literal `PURGE`; the grammar freezes the spelling. */
|
|
475
484
|
confirm: string
|
|
476
485
|
}
|
|
@@ -479,7 +488,7 @@ export interface MergeConcept {
|
|
|
479
488
|
source: ElementRef
|
|
480
489
|
into: ElementRef
|
|
481
490
|
where_clauses: WhereClause[] | null
|
|
482
|
-
|
|
491
|
+
expect_versions: ExpectVersion[]
|
|
483
492
|
}
|
|
484
493
|
|
|
485
494
|
// ---------------------------------------------------------------------------
|
|
@@ -495,13 +504,11 @@ export type MetaCommand =
|
|
|
495
504
|
| { Preview: PreviewCommand }
|
|
496
505
|
| { History: HistoryCommand }
|
|
497
506
|
| { Changes: ChangesCommand }
|
|
498
|
-
| { Snapshot: { as_of: AsOf | null } }
|
|
499
507
|
| { ExportCapsule: ExportCapsuleCommand }
|
|
500
508
|
|
|
501
509
|
export type DescribeTarget =
|
|
502
510
|
| { Primer: { mode: Scalar | null } }
|
|
503
511
|
| 'Protocol'
|
|
504
|
-
| 'ExecutionContext'
|
|
505
512
|
| 'Capabilities'
|
|
506
513
|
| { Space: { value: Scalar | null } }
|
|
507
514
|
| { SchemaEnvironment: { as_of: AsOf | null } }
|
|
@@ -514,10 +521,9 @@ export type DescribeTarget =
|
|
|
514
521
|
| { Error: Scalar }
|
|
515
522
|
| { Transaction: Scalar }
|
|
516
523
|
| { TransactionByIdempotencyKey: Scalar }
|
|
517
|
-
| { Snapshot: { as_of: AsOf | null } }
|
|
524
|
+
| { Snapshot: { as_of: AsOf | null; at_time: Scalar | null } }
|
|
518
525
|
| { Capsule: Scalar }
|
|
519
526
|
| { EpistemicPolicy: { value: Scalar | null } }
|
|
520
|
-
| 'ProjectionCapability'
|
|
521
527
|
| { Trust: { value: Scalar | null } }
|
|
522
528
|
| { Access: { with: Record<string, BoundValue> | null } }
|
|
523
529
|
|
|
@@ -525,6 +531,10 @@ export interface ListCommand {
|
|
|
525
531
|
target: ListTarget
|
|
526
532
|
/** `LIST SCHEMA PACKAGES STATUS ...` only. */
|
|
527
533
|
status: Scalar | null
|
|
534
|
+
/** `LIST DEPENDENTS :id` only — the traversal root. */
|
|
535
|
+
element: Scalar | null
|
|
536
|
+
/** `LIST DEPENDENTS ... DEPTH :n` only. */
|
|
537
|
+
depth: Scalar | null
|
|
528
538
|
limit: Scalar | null
|
|
529
539
|
cursor: Scalar | null
|
|
530
540
|
}
|
|
@@ -537,6 +547,7 @@ export type ListTarget =
|
|
|
537
547
|
| 'Facets'
|
|
538
548
|
| 'StructuralFields'
|
|
539
549
|
| 'EpistemicPolicies'
|
|
550
|
+
| 'Dependents'
|
|
540
551
|
|
|
541
552
|
export interface SearchCommand {
|
|
542
553
|
target: SearchTarget
|
package/src/formatter.ts
CHANGED
|
@@ -34,14 +34,11 @@ import type {
|
|
|
34
34
|
UnsetFacetClause,
|
|
35
35
|
UpdateStatement,
|
|
36
36
|
UpdateAction,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
CorrectEvidenceStatement,
|
|
40
|
-
TransitionActivityStatement,
|
|
37
|
+
ExpectVersionClause,
|
|
38
|
+
TransitionStatement,
|
|
41
39
|
SetRetentionStatement,
|
|
42
|
-
ArchiveStatement,
|
|
43
|
-
TombstoneStatement,
|
|
44
40
|
PurgeStatement,
|
|
41
|
+
PurgePayloadStatement,
|
|
45
42
|
MergeConceptStatement,
|
|
46
43
|
DescribeStatement,
|
|
47
44
|
ListStatement,
|
|
@@ -51,7 +48,6 @@ import type {
|
|
|
51
48
|
PreviewStatement,
|
|
52
49
|
HistoryStatement,
|
|
53
50
|
ChangesStatement,
|
|
54
|
-
SnapshotStatement,
|
|
55
51
|
ExportCapsuleStatement,
|
|
56
52
|
Expression,
|
|
57
53
|
ScalarValue,
|
|
@@ -197,9 +193,6 @@ class Formatter {
|
|
|
197
193
|
case 'ChangesStatement':
|
|
198
194
|
this.formatChanges(stmt)
|
|
199
195
|
break
|
|
200
|
-
case 'SnapshotStatement':
|
|
201
|
-
this.formatSnapshot(stmt)
|
|
202
|
-
break
|
|
203
196
|
case 'ExportCapsuleStatement':
|
|
204
197
|
this.formatExport(stmt)
|
|
205
198
|
break
|
|
@@ -234,30 +227,18 @@ class Formatter {
|
|
|
234
227
|
case 'UpdateStatement':
|
|
235
228
|
this.formatUpdate(stmt)
|
|
236
229
|
break
|
|
237
|
-
case '
|
|
238
|
-
this.formatRetract(stmt)
|
|
239
|
-
break
|
|
240
|
-
case 'SupersedeAssertionStatement':
|
|
241
|
-
this.formatSupersede(stmt)
|
|
242
|
-
break
|
|
243
|
-
case 'CorrectEvidenceStatement':
|
|
244
|
-
this.formatCorrect(stmt)
|
|
245
|
-
break
|
|
246
|
-
case 'TransitionActivityStatement':
|
|
230
|
+
case 'TransitionStatement':
|
|
247
231
|
this.formatTransition(stmt)
|
|
248
232
|
break
|
|
249
233
|
case 'SetRetentionStatement':
|
|
250
234
|
this.formatSetRetention(stmt)
|
|
251
235
|
break
|
|
252
|
-
case 'ArchiveStatement':
|
|
253
|
-
this.formatRemoval('ARCHIVE', stmt)
|
|
254
|
-
break
|
|
255
|
-
case 'TombstoneStatement':
|
|
256
|
-
this.formatRemoval('TOMBSTONE', stmt)
|
|
257
|
-
break
|
|
258
236
|
case 'PurgeStatement':
|
|
259
237
|
this.formatPurge(stmt)
|
|
260
238
|
break
|
|
239
|
+
case 'PurgePayloadStatement':
|
|
240
|
+
this.formatPurgePayload(stmt)
|
|
241
|
+
break
|
|
261
242
|
case 'MergeConceptStatement':
|
|
262
243
|
this.formatMerge(stmt)
|
|
263
244
|
break
|
|
@@ -325,7 +306,28 @@ class Formatter {
|
|
|
325
306
|
}
|
|
326
307
|
|
|
327
308
|
private asOfToString(clause: AsOfClause): string {
|
|
328
|
-
return `AS OF
|
|
309
|
+
return `AS OF SEQ ${this.scalar(clause.value)}`
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private expectVersionToString(clause: ExpectVersionClause): string {
|
|
313
|
+
let text = `EXPECT VERSION ${this.scalar(clause.value)}`
|
|
314
|
+
if (clause.plane) {
|
|
315
|
+
text +=
|
|
316
|
+
clause.plane.kind === 'FACET'
|
|
317
|
+
? ` OF FACET ${this.symbol(clause.plane.facet)}`
|
|
318
|
+
: ` OF ${clause.plane.kind}`
|
|
319
|
+
}
|
|
320
|
+
return text
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Trailing guards, one per line at the statement's own indentation. */
|
|
324
|
+
private formatExpectVersions(clauses: ExpectVersionClause[]): void {
|
|
325
|
+
for (const clause of clauses) {
|
|
326
|
+
this.emitCommentsBefore(clause.range.start.line)
|
|
327
|
+
this.writeIndent()
|
|
328
|
+
this.write(this.expectVersionToString(clause))
|
|
329
|
+
this.newline()
|
|
330
|
+
}
|
|
329
331
|
}
|
|
330
332
|
|
|
331
333
|
// ────────────────────────────────────────────────────────────────────
|
|
@@ -598,17 +600,6 @@ class Formatter {
|
|
|
598
600
|
}
|
|
599
601
|
})
|
|
600
602
|
}
|
|
601
|
-
if (stmt.expectVersion) {
|
|
602
|
-
const node = stmt.expectVersion
|
|
603
|
-
clauses.push({
|
|
604
|
-
node,
|
|
605
|
-
print: () => {
|
|
606
|
-
this.writeIndent()
|
|
607
|
-
this.write(`EXPECT VERSION ${this.scalar(node.value)}`)
|
|
608
|
-
this.newline()
|
|
609
|
-
}
|
|
610
|
-
})
|
|
611
|
-
}
|
|
612
603
|
if (stmt.setFields) {
|
|
613
604
|
const node = stmt.setFields
|
|
614
605
|
clauses.push({
|
|
@@ -651,6 +642,7 @@ class Formatter {
|
|
|
651
642
|
stmt.range.end.line,
|
|
652
643
|
clauses
|
|
653
644
|
)
|
|
645
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
654
646
|
}
|
|
655
647
|
|
|
656
648
|
private formatRecordCreate(
|
|
@@ -698,8 +690,8 @@ class Formatter {
|
|
|
698
690
|
this.write('ENSURE PROPOSITION ')
|
|
699
691
|
if (stmt.handle) this.write(`${stmt.handle.name} `)
|
|
700
692
|
this.write(this.tupleToString(stmt.tuple))
|
|
701
|
-
|
|
702
|
-
this.write(`
|
|
693
|
+
for (const clause of stmt.expectVersions) {
|
|
694
|
+
this.write(` ${this.expectVersionToString(clause)}`)
|
|
703
695
|
}
|
|
704
696
|
this.newline()
|
|
705
697
|
}
|
|
@@ -726,12 +718,6 @@ class Formatter {
|
|
|
726
718
|
this.write(`UPDATE ${this.targetRef(stmt.target)}`)
|
|
727
719
|
this.newline()
|
|
728
720
|
|
|
729
|
-
if (stmt.expectVersion) {
|
|
730
|
-
this.emitCommentsBefore(stmt.expectVersion.range.start.line)
|
|
731
|
-
this.writeIndent()
|
|
732
|
-
this.write(`EXPECT VERSION ${this.scalar(stmt.expectVersion.value)}`)
|
|
733
|
-
this.newline()
|
|
734
|
-
}
|
|
735
721
|
for (const action of stmt.actions) {
|
|
736
722
|
this.emitCommentsBefore(action.range.start.line)
|
|
737
723
|
this.formatUpdateAction(action)
|
|
@@ -744,6 +730,7 @@ class Formatter {
|
|
|
744
730
|
this.emitCommentsBefore(stmt.limit.range.start.line)
|
|
745
731
|
this.formatLimit(stmt.limit)
|
|
746
732
|
}
|
|
733
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
747
734
|
}
|
|
748
735
|
|
|
749
736
|
private formatUpdateAction(action: UpdateAction): void {
|
|
@@ -776,52 +763,13 @@ class Formatter {
|
|
|
776
763
|
}
|
|
777
764
|
}
|
|
778
765
|
|
|
779
|
-
private
|
|
780
|
-
this.writeIndent()
|
|
781
|
-
this.write(`RETRACT ASSERTION ${this.targetRef(stmt.target)}`)
|
|
782
|
-
if (!stmt.where && !stmt.limit && stmt.expectState) {
|
|
783
|
-
this.write(` EXPECT STATE ${this.scalar(stmt.expectState.value)}`)
|
|
784
|
-
this.newline()
|
|
785
|
-
return
|
|
786
|
-
}
|
|
787
|
-
this.newline()
|
|
788
|
-
if (stmt.where) this.formatWhere(stmt.where, 'WHERE')
|
|
789
|
-
if (stmt.limit) this.formatLimit(stmt.limit)
|
|
790
|
-
if (stmt.expectState) {
|
|
791
|
-
this.writeIndent()
|
|
792
|
-
this.write(`EXPECT STATE ${this.scalar(stmt.expectState.value)}`)
|
|
793
|
-
this.newline()
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
private formatSupersede(stmt: SupersedeAssertionStatement): void {
|
|
766
|
+
private formatTransition(stmt: TransitionStatement): void {
|
|
798
767
|
this.writeIndent()
|
|
799
|
-
this.write(
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
if (stmt.expectState) {
|
|
803
|
-
this.write(` EXPECT STATE ${this.scalar(stmt.expectState.value)}`)
|
|
804
|
-
}
|
|
805
|
-
this.newline()
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
private formatCorrect(stmt: CorrectEvidenceStatement): void {
|
|
809
|
-
this.writeIndent()
|
|
810
|
-
this.write(
|
|
811
|
-
`CORRECT EVIDENCE ${this.targetRef(stmt.target)} BY ${this.targetRef(stmt.by)}`
|
|
812
|
-
)
|
|
813
|
-
if (stmt.expectState) {
|
|
814
|
-
this.write(` EXPECT STATE ${this.scalar(stmt.expectState.value)}`)
|
|
815
|
-
}
|
|
816
|
-
this.newline()
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
private formatTransition(stmt: TransitionActivityStatement): void {
|
|
820
|
-
this.writeIndent()
|
|
821
|
-
this.write(
|
|
822
|
-
`TRANSITION ACTIVITY ${this.targetRef(stmt.target)} TO ${this.scalar(stmt.to)}`
|
|
823
|
-
)
|
|
768
|
+
this.write(`TRANSITION ${this.targetRef(stmt.target)} TO ${this.scalar(stmt.to)}`)
|
|
769
|
+
if (stmt.by) this.write(` BY ${this.targetRef(stmt.by)}`)
|
|
770
|
+
const tail = stmt.finalize.length > 0 || stmt.where || stmt.limit || stmt.expectVersions.length > 0
|
|
824
771
|
this.newline()
|
|
772
|
+
if (!tail) return
|
|
825
773
|
if (stmt.finalize.length > 0) {
|
|
826
774
|
this.indentLevel++
|
|
827
775
|
for (const clause of stmt.finalize) {
|
|
@@ -834,14 +782,9 @@ class Formatter {
|
|
|
834
782
|
}
|
|
835
783
|
this.indentLevel--
|
|
836
784
|
}
|
|
837
|
-
if (stmt.
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
this.writeIndent()
|
|
841
|
-
this.write(`EXPECT STATE ${this.scalar(stmt.expectState.value)}`)
|
|
842
|
-
this.newline()
|
|
843
|
-
this.indentLevel--
|
|
844
|
-
}
|
|
785
|
+
if (stmt.where) this.formatWhere(stmt.where, 'WHERE')
|
|
786
|
+
if (stmt.limit) this.formatLimit(stmt.limit)
|
|
787
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
845
788
|
}
|
|
846
789
|
|
|
847
790
|
private formatSetRetention(stmt: SetRetentionStatement): void {
|
|
@@ -851,48 +794,36 @@ class Formatter {
|
|
|
851
794
|
this.newline()
|
|
852
795
|
if (stmt.where) this.formatWhere(stmt.where, 'WHERE')
|
|
853
796
|
if (stmt.limit) this.formatLimit(stmt.limit)
|
|
854
|
-
|
|
855
|
-
this.writeIndent()
|
|
856
|
-
this.write(`EXPECT VERSION ${this.scalar(stmt.expectVersion.value)}`)
|
|
857
|
-
this.newline()
|
|
858
|
-
}
|
|
797
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
859
798
|
}
|
|
860
799
|
|
|
861
|
-
private
|
|
862
|
-
keyword: string,
|
|
863
|
-
stmt: ArchiveStatement | TombstoneStatement
|
|
864
|
-
): void {
|
|
800
|
+
private formatPurge(stmt: PurgeStatement): void {
|
|
865
801
|
this.writeIndent()
|
|
866
|
-
this.write(
|
|
867
|
-
if (!stmt.where && !stmt.limit) {
|
|
868
|
-
if (stmt.expectState) {
|
|
869
|
-
this.write(` EXPECT STATE ${this.scalar(stmt.expectState.value)}`)
|
|
870
|
-
}
|
|
871
|
-
this.newline()
|
|
872
|
-
return
|
|
873
|
-
}
|
|
802
|
+
this.write(`PURGE ${this.targetRef(stmt.target)}`)
|
|
874
803
|
this.newline()
|
|
875
804
|
if (stmt.where) this.formatWhere(stmt.where, 'WHERE')
|
|
876
805
|
if (stmt.limit) this.formatLimit(stmt.limit)
|
|
877
|
-
|
|
806
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
807
|
+
this.indentLevel++
|
|
808
|
+
if (stmt.referencePolicy) {
|
|
878
809
|
this.writeIndent()
|
|
879
|
-
this.write(`
|
|
810
|
+
this.write(`REFERENCE POLICY ${this.scalar(stmt.referencePolicy)}`)
|
|
880
811
|
this.newline()
|
|
881
812
|
}
|
|
813
|
+
this.writeIndent()
|
|
814
|
+
this.write(`CONFIRM ${stmt.confirm.value}`)
|
|
815
|
+
this.newline()
|
|
816
|
+
this.indentLevel--
|
|
882
817
|
}
|
|
883
818
|
|
|
884
|
-
private
|
|
819
|
+
private formatPurgePayload(stmt: PurgePayloadStatement): void {
|
|
885
820
|
this.writeIndent()
|
|
886
|
-
this.write(`PURGE ${this.targetRef(stmt.target)}`)
|
|
821
|
+
this.write(`PURGE PAYLOAD ${this.targetRef(stmt.target)}`)
|
|
887
822
|
this.newline()
|
|
888
823
|
if (stmt.where) this.formatWhere(stmt.where, 'WHERE')
|
|
889
824
|
if (stmt.limit) this.formatLimit(stmt.limit)
|
|
825
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
890
826
|
this.indentLevel++
|
|
891
|
-
if (stmt.referencePolicy) {
|
|
892
|
-
this.writeIndent()
|
|
893
|
-
this.write(`REFERENCE POLICY ${this.scalar(stmt.referencePolicy)}`)
|
|
894
|
-
this.newline()
|
|
895
|
-
}
|
|
896
827
|
this.writeIndent()
|
|
897
828
|
this.write(`CONFIRM ${stmt.confirm.value}`)
|
|
898
829
|
this.newline()
|
|
@@ -906,11 +837,7 @@ class Formatter {
|
|
|
906
837
|
)
|
|
907
838
|
this.newline()
|
|
908
839
|
if (stmt.where) this.formatWhere(stmt.where, 'WHERE')
|
|
909
|
-
|
|
910
|
-
this.writeIndent()
|
|
911
|
-
this.write(`EXPECT VERSION ${this.scalar(stmt.expectVersion.value)}`)
|
|
912
|
-
this.newline()
|
|
913
|
-
}
|
|
840
|
+
this.formatExpectVersions(stmt.expectVersions)
|
|
914
841
|
}
|
|
915
842
|
|
|
916
843
|
// ────────────────────────────────────────────────────────────────────
|
|
@@ -1001,7 +928,6 @@ class Formatter {
|
|
|
1001
928
|
const words: Record<DescribeStatement['target'], string> = {
|
|
1002
929
|
PRIMER: 'PRIMER',
|
|
1003
930
|
PROTOCOL: 'PROTOCOL',
|
|
1004
|
-
EXECUTION_CONTEXT: 'EXECUTION CONTEXT',
|
|
1005
931
|
CAPABILITIES: 'CAPABILITIES',
|
|
1006
932
|
SPACE: 'SPACE',
|
|
1007
933
|
SCHEMA_ENVIRONMENT: 'SCHEMA ENVIRONMENT',
|
|
@@ -1017,7 +943,6 @@ class Formatter {
|
|
|
1017
943
|
SNAPSHOT: 'SNAPSHOT',
|
|
1018
944
|
CAPSULE: 'CAPSULE',
|
|
1019
945
|
EPISTEMIC_POLICY: 'EPISTEMIC POLICY',
|
|
1020
|
-
PROJECTION_CAPABILITY: 'PROJECTION CAPABILITY',
|
|
1021
946
|
TRUST: 'TRUST',
|
|
1022
947
|
ACCESS: 'ACCESS'
|
|
1023
948
|
}
|
|
@@ -1030,6 +955,7 @@ class Formatter {
|
|
|
1030
955
|
}
|
|
1031
956
|
if (stmt.mode) this.write(` MODE ${this.scalar(stmt.mode)}`)
|
|
1032
957
|
if (stmt.asOf) this.write(` ${this.asOfToString(stmt.asOf)}`)
|
|
958
|
+
if (stmt.atTime) this.write(` AT TIME ${this.scalar(stmt.atTime)}`)
|
|
1033
959
|
if (stmt.with) this.write(` WITH ${this.objectLiteralToString(stmt.with)}`)
|
|
1034
960
|
this.newline()
|
|
1035
961
|
}
|
|
@@ -1043,9 +969,12 @@ class Formatter {
|
|
|
1043
969
|
PREDICATES: 'PREDICATES',
|
|
1044
970
|
FACETS: 'FACETS',
|
|
1045
971
|
STRUCTURAL_FIELDS: 'STRUCTURAL FIELDS',
|
|
1046
|
-
EPISTEMIC_POLICIES: 'EPISTEMIC POLICIES'
|
|
972
|
+
EPISTEMIC_POLICIES: 'EPISTEMIC POLICIES',
|
|
973
|
+
DEPENDENTS: 'DEPENDENTS'
|
|
1047
974
|
}
|
|
1048
975
|
this.write(`LIST ${words[stmt.target]}`)
|
|
976
|
+
if (stmt.element) this.write(` ${this.scalar(stmt.element)}`)
|
|
977
|
+
if (stmt.depth) this.write(` DEPTH ${this.scalar(stmt.depth)}`)
|
|
1049
978
|
if (stmt.status) this.write(` STATUS ${this.scalar(stmt.status)}`)
|
|
1050
979
|
if (stmt.limit) this.write(` LIMIT ${this.scalar(stmt.limit.value)}`)
|
|
1051
980
|
if (stmt.cursor) this.write(` CURSOR ${this.scalar(stmt.cursor.value)}`)
|
|
@@ -1127,13 +1056,6 @@ class Formatter {
|
|
|
1127
1056
|
this.newline()
|
|
1128
1057
|
}
|
|
1129
1058
|
|
|
1130
|
-
private formatSnapshot(stmt: SnapshotStatement): void {
|
|
1131
|
-
this.writeIndent()
|
|
1132
|
-
this.write('SNAPSHOT')
|
|
1133
|
-
if (stmt.asOf) this.write(` ${this.asOfToString(stmt.asOf)}`)
|
|
1134
|
-
this.newline()
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
1059
|
private formatExport(stmt: ExportCapsuleStatement): void {
|
|
1138
1060
|
this.writeIndent()
|
|
1139
1061
|
this.write(`EXPORT CAPSULE ${this.targetRef(stmt.target)}`)
|
package/src/index.ts
CHANGED
|
@@ -88,17 +88,13 @@ export type {
|
|
|
88
88
|
UnsetStructuralClause,
|
|
89
89
|
StructuralRemoval,
|
|
90
90
|
ExpectVersionClause,
|
|
91
|
-
|
|
91
|
+
VersionPlane,
|
|
92
92
|
UpdateStatement,
|
|
93
93
|
UpdateAction,
|
|
94
|
-
|
|
95
|
-
SupersedeAssertionStatement,
|
|
96
|
-
CorrectEvidenceStatement,
|
|
97
|
-
TransitionActivityStatement,
|
|
94
|
+
TransitionStatement,
|
|
98
95
|
SetRetentionStatement,
|
|
99
|
-
ArchiveStatement,
|
|
100
|
-
TombstoneStatement,
|
|
101
96
|
PurgeStatement,
|
|
97
|
+
PurgePayloadStatement,
|
|
102
98
|
MergeConceptStatement,
|
|
103
99
|
// META
|
|
104
100
|
DescribeStatement,
|
|
@@ -114,7 +110,6 @@ export type {
|
|
|
114
110
|
PreviewStatement,
|
|
115
111
|
HistoryStatement,
|
|
116
112
|
ChangesStatement,
|
|
117
|
-
SnapshotStatement,
|
|
118
113
|
ExportCapsuleStatement,
|
|
119
114
|
// Expressions
|
|
120
115
|
Expression,
|
|
@@ -199,13 +194,12 @@ export type {
|
|
|
199
194
|
UpdateFunction,
|
|
200
195
|
UpdateStatement as ExecUpdateStatement,
|
|
201
196
|
UpdateAction as ExecUpdateAction,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
TransitionActivity,
|
|
197
|
+
ExpectVersion,
|
|
198
|
+
VersionPlane as ExecVersionPlane,
|
|
199
|
+
Transition,
|
|
206
200
|
SetRetention,
|
|
207
|
-
RemovalStatement,
|
|
208
201
|
PurgeStatement as ExecPurgeStatement,
|
|
202
|
+
PurgePayloadStatement as ExecPurgePayloadStatement,
|
|
209
203
|
MergeConcept,
|
|
210
204
|
// META
|
|
211
205
|
MetaCommand,
|