@elaraai/e3 1.0.98 → 1.0.100

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.
Files changed (146) hide show
  1. package/README.md +4 -5
  2. package/dist/src/browser.d.ts +2 -0
  3. package/dist/src/browser.d.ts.map +1 -1
  4. package/dist/src/browser.js +6 -0
  5. package/dist/src/browser.js.map +1 -1
  6. package/dist/src/environment-capture.d.ts +21 -0
  7. package/dist/src/environment-capture.d.ts.map +1 -1
  8. package/dist/src/environment-capture.js +48 -0
  9. package/dist/src/environment-capture.js.map +1 -1
  10. package/dist/src/export.d.ts +10 -5
  11. package/dist/src/export.d.ts.map +1 -1
  12. package/dist/src/export.js +31 -47
  13. package/dist/src/export.js.map +1 -1
  14. package/dist/src/export.spec.js +27 -16
  15. package/dist/src/export.spec.js.map +1 -1
  16. package/dist/src/function.d.ts.map +1 -1
  17. package/dist/src/function.js.map +1 -1
  18. package/dist/src/functions-cache.d.ts +60 -0
  19. package/dist/src/functions-cache.d.ts.map +1 -0
  20. package/dist/src/functions-cache.js +165 -0
  21. package/dist/src/functions-cache.js.map +1 -0
  22. package/dist/src/functions-link.spec.js +191 -12
  23. package/dist/src/functions-link.spec.js.map +1 -1
  24. package/dist/src/functions-resolve.d.ts +52 -23
  25. package/dist/src/functions-resolve.d.ts.map +1 -1
  26. package/dist/src/functions-resolve.js +244 -96
  27. package/dist/src/functions-resolve.js.map +1 -1
  28. package/dist/src/index.d.ts +8 -61
  29. package/dist/src/index.d.ts.map +1 -1
  30. package/dist/src/index.js +3 -8
  31. package/dist/src/index.js.map +1 -1
  32. package/dist/src/internal.d.ts +53 -0
  33. package/dist/src/internal.d.ts.map +1 -0
  34. package/dist/src/internal.js +29 -0
  35. package/dist/src/internal.js.map +1 -0
  36. package/dist/src/lazy-build.d.ts +25 -0
  37. package/dist/src/lazy-build.d.ts.map +1 -0
  38. package/dist/src/lazy-build.js +56 -0
  39. package/dist/src/lazy-build.js.map +1 -0
  40. package/dist/src/lazy-build.spec.d.ts +6 -0
  41. package/dist/src/lazy-build.spec.d.ts.map +1 -0
  42. package/dist/src/lazy-build.spec.js +153 -0
  43. package/dist/src/lazy-build.spec.js.map +1 -0
  44. package/dist/src/migration.d.ts +20 -163
  45. package/dist/src/migration.d.ts.map +1 -1
  46. package/dist/src/migration.js +37 -34
  47. package/dist/src/migration.js.map +1 -1
  48. package/dist/src/migration.spec.js +83 -78
  49. package/dist/src/migration.spec.js.map +1 -1
  50. package/dist/src/mutation-programs.spec.js +211 -118
  51. package/dist/src/mutation-programs.spec.js.map +1 -1
  52. package/dist/src/mutation.d.ts +37 -141
  53. package/dist/src/mutation.d.ts.map +1 -1
  54. package/dist/src/mutation.js +66 -28
  55. package/dist/src/mutation.js.map +1 -1
  56. package/dist/src/open-beast-link.spec.js +1 -1
  57. package/dist/src/open-beast-link.spec.js.map +1 -1
  58. package/dist/src/output.js.map +1 -1
  59. package/dist/src/package.d.ts +2 -38
  60. package/dist/src/package.d.ts.map +1 -1
  61. package/dist/src/package.js +42 -175
  62. package/dist/src/package.js.map +1 -1
  63. package/dist/src/record-area.d.ts +49 -37
  64. package/dist/src/record-area.d.ts.map +1 -1
  65. package/dist/src/record-area.js +211 -131
  66. package/dist/src/record-area.js.map +1 -1
  67. package/dist/src/record-area.spec.js +79 -62
  68. package/dist/src/record-area.spec.js.map +1 -1
  69. package/dist/src/record-arguments.d.ts +55 -0
  70. package/dist/src/record-arguments.d.ts.map +1 -0
  71. package/dist/src/record-arguments.js +72 -0
  72. package/dist/src/record-arguments.js.map +1 -0
  73. package/dist/src/record-builders.d.ts +547 -0
  74. package/dist/src/record-builders.d.ts.map +1 -0
  75. package/dist/src/record-builders.js +112 -0
  76. package/dist/src/record-builders.js.map +1 -0
  77. package/dist/src/record-declared.spec.d.ts +6 -0
  78. package/dist/src/record-declared.spec.d.ts.map +1 -0
  79. package/dist/src/record-declared.spec.js +251 -0
  80. package/dist/src/record-declared.spec.js.map +1 -0
  81. package/dist/src/record-guards.d.ts +114 -1
  82. package/dist/src/record-guards.d.ts.map +1 -1
  83. package/dist/src/record-guards.js +153 -2
  84. package/dist/src/record-guards.js.map +1 -1
  85. package/dist/src/record-index.d.ts +128 -350
  86. package/dist/src/record-index.d.ts.map +1 -1
  87. package/dist/src/record-index.js +44 -481
  88. package/dist/src/record-index.js.map +1 -1
  89. package/dist/src/record-index.spec.js +124 -90
  90. package/dist/src/record-index.spec.js.map +1 -1
  91. package/dist/src/record-interval.d.ts +57 -36
  92. package/dist/src/record-interval.d.ts.map +1 -1
  93. package/dist/src/record-interval.js +136 -94
  94. package/dist/src/record-interval.js.map +1 -1
  95. package/dist/src/record-interval.spec.js +48 -27
  96. package/dist/src/record-interval.spec.js.map +1 -1
  97. package/dist/src/record-keys.d.ts +146 -0
  98. package/dist/src/record-keys.d.ts.map +1 -0
  99. package/dist/src/record-keys.js +178 -0
  100. package/dist/src/record-keys.js.map +1 -0
  101. package/dist/src/record-nested-programs.d.ts +1457 -0
  102. package/dist/src/record-nested-programs.d.ts.map +1 -0
  103. package/dist/src/record-nested-programs.js +1974 -0
  104. package/dist/src/record-nested-programs.js.map +1 -0
  105. package/dist/src/record-nested.d.ts +284 -0
  106. package/dist/src/record-nested.d.ts.map +1 -0
  107. package/dist/src/record-nested.js +304 -0
  108. package/dist/src/record-nested.js.map +1 -0
  109. package/dist/src/record-nested.spec.d.ts +6 -0
  110. package/dist/src/record-nested.spec.d.ts.map +1 -0
  111. package/dist/src/record-nested.spec.js +1032 -0
  112. package/dist/src/record-nested.spec.js.map +1 -0
  113. package/dist/src/record-patches.d.ts +25 -0
  114. package/dist/src/record-patches.d.ts.map +1 -0
  115. package/dist/src/record-patches.js +27 -0
  116. package/dist/src/record-patches.js.map +1 -0
  117. package/dist/src/record-programs.d.ts +192 -26
  118. package/dist/src/record-programs.d.ts.map +1 -1
  119. package/dist/src/record-programs.js +858 -350
  120. package/dist/src/record-programs.js.map +1 -1
  121. package/dist/src/record-programs.spec.d.ts +6 -0
  122. package/dist/src/record-programs.spec.d.ts.map +1 -0
  123. package/dist/src/record-programs.spec.js +242 -0
  124. package/dist/src/record-programs.spec.js.map +1 -0
  125. package/dist/src/record-series.d.ts +101 -97
  126. package/dist/src/record-series.d.ts.map +1 -1
  127. package/dist/src/record-series.js +198 -149
  128. package/dist/src/record-series.js.map +1 -1
  129. package/dist/src/record-series.spec.js +241 -120
  130. package/dist/src/record-series.spec.js.map +1 -1
  131. package/dist/src/record-tiles.d.ts +328 -37
  132. package/dist/src/record-tiles.d.ts.map +1 -1
  133. package/dist/src/record-tiles.js +289 -100
  134. package/dist/src/record-tiles.js.map +1 -1
  135. package/dist/src/record.d.ts +66 -12
  136. package/dist/src/record.d.ts.map +1 -1
  137. package/dist/src/record.js +103 -34
  138. package/dist/src/record.js.map +1 -1
  139. package/dist/src/record.spec.js +48 -63
  140. package/dist/src/record.spec.js.map +1 -1
  141. package/dist/src/task.d.ts.map +1 -1
  142. package/dist/src/task.js +4 -1
  143. package/dist/src/task.js.map +1 -1
  144. package/dist/src/types.d.ts +103 -37
  145. package/dist/src/types.d.ts.map +1 -1
  146. package/package.json +7 -3
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { plainDefinition } from './record-index.js';
6
+ import { intervalDefinition } from './record-interval.js';
7
+ import { areaDefinition } from './record-area.js';
8
+ import { seriesDefinition, summaryDefinition } from './record-series.js';
9
+ import { nestedDefinition } from './record-nested-programs.js';
10
+ import { items, recursive, rows, values } from './record-nested.js';
11
+ import { editDefinition, patchDefinition, reduceDefinition } from './mutation.js';
12
+ import { stepDefinition } from './migration.js';
13
+ /** The key of a part a builder makes: what `e3.record` builds the part by. */
14
+ export const RECORD_PART = Symbol('e3.recordPart');
15
+ /** The `index` builder: each method a draft `e3.record` builds under its key. */
16
+ export const INDEX_BUILDER = {
17
+ on: plainForm('on'),
18
+ key: plainForm('key'),
19
+ keys: plainForm('keys'),
20
+ interval: (spec, options) => indexDraft('index.interval', options, (where, record, name) => intervalDefinition(where, name, record, spec, runnerOf(options))),
21
+ area: (spec, options) => indexDraft('index.area', options, (where, record, name) => areaDefinition(where, name, record, spec, runnerOf(options))),
22
+ series: (spec, options) => indexDraft('index.series', options, (where, record, name) => {
23
+ if (typeof spec === 'object' && spec !== null && 'collections' in spec) {
24
+ throw new Error(`${where} '${name}' takes key, from, to and tile — collections are a nested series index's: index.nested({ collections, tile, summary? })`);
25
+ }
26
+ return seriesDefinition(where, name, record, spec, runnerOf(options));
27
+ }),
28
+ nested: Object.assign((spec, options) => indexDraft('index.nested', options, (where, record, name) => nestedDefinition(where, name, record, spec, runnerOf(options))), { items, values, rows, recursive }),
29
+ summary: (spec, options) => indexDraft('index.summary', options, (where, record, name) => summaryDefinition(where, name, record, spec, runnerOf(options))),
30
+ };
31
+ /** The `mutation` builder: each method a draft `e3.record` builds under its key. */
32
+ export const MUTATION_BUILDER = {
33
+ reduce: (fn, options) => mutationDraft('mutation.reduce', options, (where, record, name) => reduceDefinition(where, name, record, fn, runnerOf(options))),
34
+ edit: (fn, options) => mutationDraft('mutation.edit', options, (where, record, name) => editDefinition(where, name, record, fn, runnerOf(options))),
35
+ patch: (options) => mutationDraft('mutation.patch', options, (where, record, name) => patchDefinition(where, name, record, runnerOf(options))),
36
+ };
37
+ /** The `migration` builder: each method a step `e3.record` builds in its place. */
38
+ export const MIGRATION_BUILDER = {
39
+ value: stepForm('value'),
40
+ rows: stepForm('rows'),
41
+ rekey: stepForm('rekey'),
42
+ };
43
+ /** A refusal's subject: the builder, on its record. */
44
+ function wordsOf(record, builder) {
45
+ return `e3.record '${record.name}': ${builder}`;
46
+ }
47
+ /** Refuses options a builder does not take, naming those it does. */
48
+ function checkOptions(where, name, options, allowed) {
49
+ if (options === undefined)
50
+ return;
51
+ if (typeof options !== 'object' || options === null || Array.isArray(options)) {
52
+ throw new Error(`${where} '${name}' takes its options as an object, { ${allowed.join(', ')} }`);
53
+ }
54
+ const extra = Object.keys(options).filter((option) => !allowed.includes(option));
55
+ if (extra.length > 0)
56
+ throw new Error(`${where} '${name}' takes ${allowed.join(' and ')}, not ${extra.join(', ')}`);
57
+ }
58
+ /** A part's runner selection, from the options its builder was given. */
59
+ function runnerOf(options) {
60
+ const runner = options?.runner;
61
+ return runner === undefined ? undefined : { runner };
62
+ }
63
+ /** An index draft, its options checked as it is built. */
64
+ function indexDraft(builder, options, build) {
65
+ return {
66
+ [RECORD_PART]: {
67
+ part: 'index',
68
+ build: (record, name) => {
69
+ const where = wordsOf(record, builder);
70
+ checkOptions(where, name, options, builder === 'index.on' || builder === 'index.key' || builder === 'index.keys' ? ['value', 'runner'] : ['runner']);
71
+ return build(where, record, name);
72
+ },
73
+ },
74
+ };
75
+ }
76
+ /** A plain index's builder: by row fields, a key function, or a keys function. */
77
+ function plainForm(form) {
78
+ return (by, options) => indexDraft(`index.${form}`, options, (where, record, name) => {
79
+ if (form === 'on' && !Array.isArray(by)) {
80
+ throw new Error(`${where} '${name}' takes the row fields leading it as a list, as index.on(['site'])`);
81
+ }
82
+ const value = options?.value;
83
+ return plainDefinition(where, name, record, { [form]: by, ...(value !== undefined && { value }) }, runnerOf(options));
84
+ });
85
+ }
86
+ /** A mutation draft, its options checked as it is built. */
87
+ function mutationDraft(builder, options, build) {
88
+ return {
89
+ [RECORD_PART]: {
90
+ part: 'mutation',
91
+ build: (record, name) => {
92
+ const where = wordsOf(record, builder);
93
+ checkOptions(where, name, options, ['runner']);
94
+ return build(where, record, name);
95
+ },
96
+ },
97
+ };
98
+ }
99
+ /** A migration step's builder in a form: the step named, its place in the list its chain. */
100
+ function stepForm(form) {
101
+ return (name, fn, options) => ({
102
+ [RECORD_PART]: {
103
+ part: 'migration',
104
+ build: (record, previous) => {
105
+ const where = wordsOf(record, `migration.${form}`);
106
+ checkOptions(where, name, options, ['runner']);
107
+ return stepDefinition(where, form, name, record, fn, runnerOf(options), previous);
108
+ },
109
+ },
110
+ });
111
+ }
112
+ //# sourceMappingURL=record-builders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-builders.js","sourceRoot":"","sources":["../../src/record-builders.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAiB,MAAM,oBAAoB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAWhD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAienD,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,SAAS,CAAC,IAAI,CAAC;IACnB,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC;IACrB,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAa,EAAE,OAAiB,EAAE,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAC5G,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAgD,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/G,IAAI,EAAE,CAAC,IAAa,EAAE,OAAiB,EAAE,EAAE,CA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AC,CAAC;gBAC/C,OAAO,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,SAAS,QAAQ,CAAC,IAAgC;IAChD,OAAO,CAAC,IAAY,EAAE,EAAiB,EAAE,OAAiB,EAAkB,EAAE,CAAC,CAAC;QAC9E,CAAC,WAAW,CAAC,EAAE;YACb,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;gBAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,aAAa,IAAI,EAAE,CAAC,CAAC;gBACnD,YAAY,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC/C,OAAO,cAAc,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;YACpF,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=record-declared.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-declared.spec.d.ts","sourceRoot":"","sources":["../../src/record-declared.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * A record declared whole: `e3.record(name, type, { initial, indexes,
7
+ * mutations, migrations })` builds each part through the builder it hands the
8
+ * declaration, under its key or in its place in the list, over the record
9
+ * itself, and freezes them. What TypeScript reads off the one call — each
10
+ * part's name and types, and a field a part names held to the row — is checked
11
+ * here as it compiles; each refusal names the record and the part.
12
+ */
13
+ import { describe, it } from 'node:test';
14
+ import assert from 'node:assert/strict';
15
+ import { DateTimeType, DictType, East, FloatType, NullType, SetType, StringType, StructType, isTypeEqual, } from '@elaraai/east';
16
+ import { record } from './record.js';
17
+ import { mutation } from './mutation.js';
18
+ import { package_ } from './package.js';
19
+ import { builtIndex } from './record-programs.js';
20
+ const Job = StructType({ product: StringType, start: DateTimeType, end: DateTimeType });
21
+ /** A machine: where it stands, when it is planned, and what it nests. */
22
+ const Machine = StructType({
23
+ name: StringType, site: StringType, status: StringType, planned_start: DateTimeType, planned_end: DateTimeType,
24
+ jobs: DictType(StringType, Job), load: DictType(DateTimeType, FloatType),
25
+ });
26
+ const Machines = DictType(StringType, Machine);
27
+ const MachinesV1 = DictType(StringType, StructType({ name: StringType }));
28
+ const startOf = East.function([StringType, Machine], DateTimeType, (_$, _key, row) => row.planned_start);
29
+ const statusesOf = East.function([StringType, Machine], SetType(StringType), ($, _key, row) => {
30
+ const statuses = $.let(new Set(), SetType(StringType));
31
+ $(statuses.insert(row.status));
32
+ return statuses;
33
+ });
34
+ const nameOf = East.function([StringType, Machine], StringType, (_$, _key, row) => row.name);
35
+ const setStatus = East.function([Machines, StringType, StringType], Machines, (_$, state, _id, _status) => state);
36
+ const retire = East.function([Machines, StringType, mutation.editType(Machines)], NullType, ($, _state, id, edit) => {
37
+ $(edit.delete(id));
38
+ });
39
+ const named = East.function([MachinesV1], MachinesV1, (_$, old) => old);
40
+ const filled = East.function([StringType, StructType({ name: StringType })], Machine, (_$, _id, old) => ({
41
+ name: old.name, site: '', status: 'idle', planned_start: new Date(0), planned_end: new Date(0), jobs: new Map(), load: new Map(),
42
+ }));
43
+ /** The machines, declared whole: every index kind, every write form, and a chain of two steps. */
44
+ function machines() {
45
+ return record('machines', Machines, {
46
+ initial: new Map(),
47
+ indexes: (index) => ({
48
+ by_site: index.on(['site']),
49
+ by_site_status: index.on(['site', 'status'], { value: nameOf }),
50
+ by_start: index.key(startOf),
51
+ by_statuses: index.keys(statusesOf),
52
+ in_window: index.interval({ from: 'planned_start', to: 'planned_end' }),
53
+ planned: index.series({ key: 'site', from: 'planned_start', to: 'planned_end', tile: 'week' }),
54
+ in_time: index.nested({
55
+ collections: { jobs: index.nested.items({ from: 'start', to: 'end' }), load: index.nested.values() },
56
+ tile: 'week',
57
+ summary: 'month',
58
+ }),
59
+ busy: index.summary({ key: 'site', from: 'planned_start', to: 'planned_end', tile: 'day' }),
60
+ }),
61
+ mutations: (mutation) => ({
62
+ set_status: mutation.reduce(setStatus),
63
+ retire: mutation.edit(retire),
64
+ patch: mutation.patch(),
65
+ }),
66
+ migrations: (migration) => [
67
+ migration.value('name_machines', named),
68
+ migration.rows('fill_machines', filled),
69
+ ],
70
+ });
71
+ }
72
+ describe('e3.record declared whole', () => {
73
+ it('builds each index under its key, over the record, in the order declared, the nested series index\'s span after them', () => {
74
+ const rec = machines();
75
+ assert.deepEqual(Object.keys(rec.indexes), ['by_site', 'by_site_status', 'by_start', 'by_statuses', 'in_window', 'planned', 'in_time', 'busy', 'in_time_span']);
76
+ for (const [key, index] of Object.entries(rec.indexes)) {
77
+ assert.equal(index.name, key, `${key} is named by its key`);
78
+ assert.equal(index.record, rec, `${key} is the record's`);
79
+ }
80
+ assert.ok(isTypeEqual(rec.indexes.by_site.keyType, StringType), "by_site's key is the site");
81
+ assert.ok(isTypeEqual(rec.indexes.by_site_status.valueType, StringType), 'by_site_status carries the name it projects');
82
+ assert.ok(isTypeEqual(rec.indexes.by_start.keyType, DateTimeType), "by_start's key is what its function returns");
83
+ assert.ok(isTypeEqual(rec.indexes.by_statuses.keyType, StringType), "by_statuses' key is an element of the Set its function returns");
84
+ assert.equal(rec.indexes.by_statuses.multi, true);
85
+ assert.equal(rec.indexes.in_window.interval.from, 'planned_start');
86
+ assert.equal(rec.indexes.planned.series.tile, 'week');
87
+ assert.equal(rec.indexes.in_time.nested.summary, 'month');
88
+ assert.equal(rec.indexes.busy.summary.tile, 'day');
89
+ });
90
+ it('builds each mutation under its key, its arguments read off its function', () => {
91
+ const rec = machines();
92
+ assert.deepEqual(Object.keys(rec.mutations), ['set_status', 'retire', 'patch']);
93
+ assert.deepEqual(Object.values(rec.mutations).map((m) => [m.name, m.form, m.record === rec]), [
94
+ ['set_status', 'reduce', true], ['retire', 'edit', true], ['patch', 'patch', true],
95
+ ]);
96
+ assert.equal(rec.mutations.set_status.argTypes.length, 2);
97
+ assert.ok(rec.mutations.set_status.argTypes.every((t) => isTypeEqual(t, StringType)), 'set_status takes the id and the status');
98
+ assert.ok(isTypeEqual(rec.mutations.retire.argTypes[0], StringType), 'retire takes the id, the edit capability apart');
99
+ });
100
+ it('builds its migrations in the order listed, each taking the record as the one before leaves it, the last leaving it as its type', () => {
101
+ const rec = machines();
102
+ assert.deepEqual(rec.migrations.map((step) => step.name), ['name_machines', 'fill_machines']);
103
+ assert.ok(isTypeEqual(rec.migrations[1].from, rec.migrations[0].to));
104
+ assert.ok(isTypeEqual(rec.migrations.at(-1).to, Machines));
105
+ });
106
+ it('holds its initial state, and none when it is committed from outside', () => {
107
+ assert.equal(machines().default instanceof Map, true);
108
+ assert.equal(record('later', Machines, { indexes: (index) => ({ by_site: index.on(['site']) }) }).default, undefined);
109
+ });
110
+ it('makes its initial state with the function given for it once, when it is first read — as its package is exported — never as it is declared', () => {
111
+ let made = 0;
112
+ const rec = record('made', Machines, { initial: () => { made++; return new Map(); } });
113
+ assert.equal(made, 0, 'declared, nothing made');
114
+ assert.equal(rec.default instanceof Map, true);
115
+ assert.equal(rec.default, rec.default, 'made once, then held');
116
+ assert.equal(made, 1);
117
+ });
118
+ it('carries its rows without their collections in its other indexes, whichever is declared first', () => {
119
+ const rec = machines();
120
+ // by_site is declared before the nested index, and carries the lean machine all the same: the record knows both.
121
+ assert.ok(isTypeEqual(builtIndex(rec, rec.indexes.by_site).valueType, Machine));
122
+ assert.notEqual(builtIndex(rec, rec.indexes.by_site), rec.indexes.by_site);
123
+ assert.equal(builtIndex(rec, rec.indexes.in_time), rec.indexes.in_time, 'the nested index is built as declared');
124
+ assert.equal(builtIndex(rec, rec.indexes.by_site_status), rec.indexes.by_site_status, 'an index with a value of its own carries its own');
125
+ });
126
+ it('is never added to once declared', () => {
127
+ const rec = machines();
128
+ assert.ok(Object.isFrozen(rec.indexes) && Object.isFrozen(rec.mutations) && Object.isFrozen(rec.migrations));
129
+ assert.throws(() => { rec.indexes.extra = rec.indexes.by_site; }, TypeError);
130
+ });
131
+ it('is a package whole: the package builds what the record declares', () => {
132
+ const rec = machines();
133
+ const packaged = package_('plant', '1.0.0', rec).records.machines;
134
+ assert.deepEqual(Object.keys(packaged.indexes), Object.keys(rec.indexes));
135
+ assert.deepEqual(Object.keys(packaged.mutations), Object.keys(rec.mutations));
136
+ assert.deepEqual(packaged.migrations.map((step) => step.name), ['name_machines', 'fill_machines']);
137
+ });
138
+ it('types each part by its key, and holds each field a part names to the row', () => {
139
+ const rec = machines();
140
+ // Each part's name is its key, as a literal; each index's types as its builder read them.
141
+ const siteName = rec.indexes.by_site.name;
142
+ const tile = rec.indexes.in_time.nested.tile;
143
+ const patchName = rec.mutations.patch.name;
144
+ assert.deepEqual([siteName, tile, patchName], ['by_site', 'week', 'patch']);
145
+ // A field no machine has is refused as it is written, and where it is declared.
146
+ assert.throws(() => record('typo', Machines, {
147
+ indexes: (index) => ({
148
+ // @ts-expect-error 'sitee' is not a field of a machine
149
+ by_site: index.on(['sitee']),
150
+ }),
151
+ }), /^Error: e3\.record 'typo': index\.on 'by_site' on names unknown row field 'sitee'$/);
152
+ assert.throws(() => record('typo', Machines, {
153
+ indexes: (index) => ({
154
+ // @ts-expect-error a series index's key is a field of the row
155
+ planned: index.series({ key: 'sitee', from: 'planned_start', to: 'planned_end', tile: 'week' }),
156
+ }),
157
+ }), /^Error: e3\.record 'typo': index\.series 'planned' key names unknown row field 'sitee'$/);
158
+ assert.throws(() => record('typo', Machines, {
159
+ indexes: (index) => ({
160
+ // @ts-expect-error 'jobz' is no collection of a machine
161
+ in_time: index.nested({ collections: { jobz: index.nested.values() }, tile: 'week' }),
162
+ }),
163
+ }), /^Error: e3\.record 'typo': index\.nested 'in_time' collections names unknown row field 'jobz'$/);
164
+ assert.throws(() => record('typo', Machines, {
165
+ mutations: (mutation) => ({
166
+ // @ts-expect-error a reducer returns the record's type
167
+ set_status: mutation.reduce(East.function([Machines], StringType, () => 'idle')),
168
+ }),
169
+ }), /e3\.record 'typo': mutation\.reduce 'set_status' reducer must return the record's state type/);
170
+ });
171
+ });
172
+ describe('e3.record refuses, naming the record and the part', () => {
173
+ const declare = (config) => () => record('m', Machines, config);
174
+ it("an index's name that is not an identifier, or is primary", () => {
175
+ assert.throws(declare({ indexes: (index) => ({ 'by site': index.on(['site']) }) }), /^Error: e3\.record 'm': index\.on 'by site' must be an identifier — it names a query selector in URLs and on the command line\.$/);
176
+ assert.throws(declare({ indexes: (index) => ({ primary: index.on(['site']) }) }), /^Error: e3\.record 'm': index\.on cannot be named 'primary'/);
177
+ });
178
+ it('a second nested series index, naming the first', () => {
179
+ assert.throws(declare({
180
+ indexes: (index) => ({
181
+ in_time: index.nested({ collections: { load: index.nested.values() }, tile: 'week' }),
182
+ again: index.nested({ collections: { jobs: index.nested.items({ from: 'start', to: 'end' }) }, tile: 'day' }),
183
+ }),
184
+ }), /^Error: e3\.record 'm': index\.nested 'again': record 'm' has a nested series index already, 'in_time' — one declares every collection a record nests$/);
185
+ });
186
+ it("a series index given collections, and a nested one given a series index's fields, each naming the other", () => {
187
+ assert.throws(declare({
188
+ // @ts-expect-error collections are the nested index's
189
+ indexes: (index) => ({ in_time: index.series({ collections: { load: index.nested.values() }, tile: 'week' }) }),
190
+ }), /^Error: e3\.record 'm': index\.series 'in_time' takes key, from, to and tile — collections are a nested series index's: index\.nested\(\{ collections, tile, summary\? \}\)$/);
191
+ assert.throws(declare({
192
+ // @ts-expect-error key, from and to are a series index's
193
+ indexes: (index) => ({ in_time: index.nested({ collections: { load: index.nested.values() }, key: 'site', from: 'planned_start', to: 'planned_end', tile: 'week' }) }),
194
+ }), /^Error: e3\.record 'm': index\.nested 'in_time' takes collections, tile and summary — key, from and to file the record's own events: index\.series\(\{ key, from, to, tile \}\)$/);
195
+ });
196
+ it('an option a builder does not take', () => {
197
+ assert.throws(declare({
198
+ // @ts-expect-error an interval index carries nothing of its own
199
+ indexes: (index) => ({ in_window: index.interval({ from: 'planned_start', to: 'planned_end' }, { value: nameOf }) }),
200
+ }), /^Error: e3\.record 'm': index\.interval 'in_window' takes runner, not value$/);
201
+ });
202
+ it('a part its builder did not make', () => {
203
+ assert.throws(declare({
204
+ // @ts-expect-error an index is made by the index builder
205
+ indexes: () => ({ by_site: { on: ['site'] } }),
206
+ }), /^Error: e3\.record 'm': index 'by_site' is not one the index builder made/);
207
+ assert.throws(declare({
208
+ // @ts-expect-error the parts come back by name
209
+ indexes: (index) => [index.on(['site'])],
210
+ }), /^Error: e3\.record 'm': indexes returns its parts by name, as an object/);
211
+ });
212
+ it("a mutation's name that is not an identifier", () => {
213
+ assert.throws(declare({ mutations: (mutation) => ({ 'my patch': mutation.patch() }) }), /^Error: e3\.record 'm': mutation\.patch requires a name that is an identifier, got 'my patch'/);
214
+ });
215
+ it('migrations: two of one name, a step that does not follow the one before, a last step leaving another type, and no list', () => {
216
+ assert.throws(declare({ migrations: (migration) => [migration.value('again', named), migration.value('again', named)] }), /^Error: e3\.record 'm' has two migrations named 'again' — a workspace records the steps it has applied by their names$/);
217
+ assert.throws(declare({ migrations: (migration) => [migration.rows('fill_machines', filled), migration.value('name_machines', named)] }), /^Error: e3\.record 'm': migration\.value 'name_machines' takes the record as .+, but 'fill_machines', the step before it, leaves it as /);
218
+ assert.throws(declare({ migrations: (migration) => [migration.value('name_machines', named)] }), /^Error: e3\.record 'm' is declared as .+, but its last migration, 'name_machines', leaves it as /);
219
+ assert.throws(declare({
220
+ // @ts-expect-error the steps are a list, in order
221
+ migrations: (migration) => ({ first: migration.value('name_machines', named) }),
222
+ }), /^Error: e3\.record 'm': migrations returns the steps in order, as a list/);
223
+ });
224
+ it('a declaration that is not one: an initial value in its place, a key it does not take, a part that is not a function', () => {
225
+ // @ts-expect-error an initial value is declared as { initial: value }
226
+ assert.throws(() => record('m', Machines, new Map()), /^Error: e3\.record 'm' takes its declaration as \{ initial\?, indexes\?, mutations\?, migrations\? \} — its initial value is declared as \{ initial: value \}$/);
227
+ // @ts-expect-error a record's parts are its indexes, mutations and migrations
228
+ assert.throws(() => record('m', Machines, { initial: new Map(), views: () => ({}) }), /^Error: e3\.record 'm' takes initial, indexes, mutations and migrations, not 'views'$/);
229
+ // @ts-expect-error each part is a function of its builder
230
+ assert.throws(() => record('m', Machines, { mutations: { patch: mutation.editType(Machines) } }), /^Error: e3\.record 'm': mutations is a function of its builder — mutations: \(mutation\) => …$/);
231
+ });
232
+ });
233
+ describe('e3.package takes a record whole', () => {
234
+ it('refuses its part apart from it, naming the record', () => {
235
+ const rec = machines();
236
+ // @ts-expect-error a package takes the record, its parts with it
237
+ assert.throws(() => package_('p', '1.0.0', rec.indexes.by_site), /^Error: e3\.package 'p': the index 'by_site' is part of record 'machines' — a record is declared whole, its indexes in e3\.record, so pass the record$/);
238
+ // @ts-expect-error a package takes the record, its parts with it
239
+ assert.throws(() => package_('p', '1.0.0', rec.mutations.patch), /^Error: e3\.package 'p': the mutation 'patch' is part of record 'machines' — a record is declared whole, its mutations in e3\.record, so pass the record$/);
240
+ // @ts-expect-error a package takes the record, its parts with it
241
+ assert.throws(() => package_('p', '1.0.0', rec.migrations[0]), /^Error: e3\.package 'p': the migration 'name_machines' is part of record 'machines' — a record is declared whole, its migrations in e3\.record, so pass the record$/);
242
+ });
243
+ it('carries each record as it was declared, its parts with it', () => {
244
+ const rec = machines();
245
+ const pkg = package_('p', '1.0.0', rec);
246
+ assert.equal(pkg.records.machines, rec);
247
+ assert.deepEqual(Object.keys(pkg.records.machines.indexes), Object.keys(rec.indexes));
248
+ assert.ok(Object.isFrozen(rec.indexes) && Object.isFrozen(rec.mutations) && Object.isFrozen(rec.migrations));
249
+ });
250
+ });
251
+ //# sourceMappingURL=record-declared.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-declared.spec.js","sourceRoot":"","sources":["../../src/record-declared.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EACL,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,GAChG,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;AACxF,yEAAyE;AACzE,MAAM,OAAO,GAAG,UAAU,CAAC;IACzB,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY;IAC9G,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC;CACzE,CAAC,CAAC;AACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC/C,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,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EAAE,GAAG,EAAE;QACnE,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;QACvB,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QACxC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QACvF,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/G,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -10,6 +10,9 @@
10
10
  * @packageDocumentation
11
11
  */
12
12
  import type { EastType } from '@elaraai/east';
13
+ import { FunctionExpr } from '@elaraai/east';
14
+ import type { IRBundle, RecordDef } from './types.js';
15
+ import { type FunctionRunner } from './runner.js';
13
16
  /**
14
17
  * Whether two East types are the same type.
15
18
  *
@@ -27,7 +30,7 @@ export declare function sameEastType(a: EastType, b: EastType): boolean;
27
30
  * into nested closures, loop bodies and collection-op lambdas.
28
31
  *
29
32
  * @param subject - The function as the error names it, such as
30
- * `e3.mutation.reduce 'place' body`
33
+ * `e3.record 'orders': mutation.reduce 'place' body`
31
34
  * @param fn - The function
32
35
  * @param why - Why the declaration refuses each, which ends its error
33
36
  * @throws {Error} When the function is async, or calls a platform function.
@@ -38,4 +41,114 @@ export declare function checkPure(subject: string, fn: {
38
41
  async: string;
39
42
  platform: string;
40
43
  }): void;
44
+ /** The index name reserved for the record's own collection wherever an index
45
+ * is selected — a page, a key search, an arm of the mutation delta. */
46
+ export declare const RESERVED_INDEX_NAME = "primary";
47
+ /**
48
+ * What a declaration — an index, a mutation, a migration — needs of a
49
+ * function: a way to reach its IR, and through that its signature.
50
+ *
51
+ * @remarks
52
+ * Deliberately the weakest shape that works, because a stronger one silently
53
+ * breaks the authored surface. An index reads
54
+ * `key: East.function([K, V], IK, ($, k, v) => …)` written INLINE in the spec,
55
+ * and `East.function` infers its callback's parameters from its own first
56
+ * argument — but only if nothing is imposed on it from outside. Both a
57
+ * callable contextual type (`FunctionExpr<any, any>`) and a generic return
58
+ * type here (`toIR(): EastIR<any, any>`) make TypeScript infer against the
59
+ * expected type instead, and the body's `k` and `v` come out as the union of
60
+ * every expression class. `unknown` imposes nothing; the guards below read the
61
+ * signature at run time regardless.
62
+ */
63
+ export interface IndexFunction {
64
+ /** The function's IR bundle, as `EastIR` or `AsyncEastIR`. */
65
+ toIR(): unknown;
66
+ }
67
+ /** The declaration a refusal names: a builder of the record's, `e3.record 'plans': index.on`. */
68
+ export type IndexConstructor = string;
69
+ /**
70
+ * The signature of a function a declaration gives — an index's, a mutation's,
71
+ * a migration's — as the guards see it.
72
+ *
73
+ * @param fn - The function
74
+ * @returns Its parameter types and its output type
75
+ * @throws {Error} When it is not an East function
76
+ */
77
+ export declare function signatureOf(fn: IndexFunction): {
78
+ inputs: readonly EastType[];
79
+ output: EastType;
80
+ };
81
+ /**
82
+ * A declaration's function — an index's key, projection or merge, a migration's
83
+ * step, a mutation's body — as an East function of the signature its caller
84
+ * reads it at, checked to be exactly that. A definition keeps it as an
85
+ * expression ({@link IndexFunction}), whose signature only the run time knows.
86
+ *
87
+ * @param fn - The function
88
+ * @param inputs - Its parameter types
89
+ * @param output - Its output type
90
+ * @returns It, at that signature
91
+ * @throws {Error} When it is not an East function, or not of that signature
92
+ */
93
+ export declare function functionAt<I extends EastType[], O extends EastType>(fn: IndexFunction, inputs: [...I], output: O): FunctionExpr<I, O>;
94
+ /**
95
+ * A declaration's function as its IR bundle, which export links and encodes.
96
+ *
97
+ * @param fn - The function: an East function, as a declaration's guards have found it
98
+ * @returns Its IR bundle
99
+ * @throws {Error} When it is not an East function — an async one is refused before this
100
+ */
101
+ export declare function bundleOf(fn: IndexFunction): IRBundle;
102
+ /** Why an index function may be neither async nor reach a platform function:
103
+ * either makes the index non-deterministic, and an index that does not equal
104
+ * its rebuild is worse than no index, since the view it serves is quietly
105
+ * wrong. */
106
+ export declare const INDEX_PURITY: {
107
+ async: string;
108
+ platform: string;
109
+ };
110
+ /** Refuses an index function whose parameters are not the record's entry. */
111
+ export declare function checkEntryParams(constructor: IndexConstructor, name: string, role: string, keyType: EastType, valueType: EastType, inputs: readonly EastType[]): void;
112
+ /**
113
+ * A record's entry types, once an index's name and its record pass: a name that
114
+ * is an identifier, never `primary`, declared once on the record, over a Dict
115
+ * record.
116
+ *
117
+ * Every guard here is a definition-time error rather than a deploy failure.
118
+ *
119
+ * @param constructor - The constructor, as a refusal names it
120
+ * @param name - The index
121
+ * @param rec - Its record
122
+ * @returns The record's key and row types
123
+ * @throws {Error} Naming what to change
124
+ */
125
+ export declare function indexedEntry(constructor: IndexConstructor, name: string, rec: RecordDef): {
126
+ keyType: EastType;
127
+ valueType: EastType;
128
+ };
129
+ /** Refuses an option a constructor does not take, naming those it does. */
130
+ export declare function onlyOptions(constructor: IndexConstructor, name: string, spec: object, options: readonly string[], instead?: string): void;
131
+ /**
132
+ * An index's runner: the one it declares, or the default, checked now so a bad
133
+ * runner fails at definition time, not at export.
134
+ *
135
+ * @param config - The declaration's runner selection
136
+ * @returns The runner
137
+ */
138
+ export declare function indexRunner(config: {
139
+ runner?: FunctionRunner;
140
+ } | undefined): FunctionRunner;
141
+ /**
142
+ * An index's key and projection functions, checked as every constructor checks
143
+ * them: pure, over the record's entry, a `keys` function returning a Set.
144
+ *
145
+ * @returns The runner, and the index key and projection types the functions declare
146
+ */
147
+ export declare function indexFunctions(constructor: IndexConstructor, name: string, keyType: EastType, valueType: EastType, keyFn: IndexFunction, multi: boolean, valueFn: IndexFunction | undefined, config: {
148
+ runner?: FunctionRunner;
149
+ } | undefined): {
150
+ runner: FunctionRunner;
151
+ indexKeyType: EastType;
152
+ projectionType: EastType | undefined;
153
+ };
41
154
  //# sourceMappingURL=record-guards.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"record-guards.d.ts","sourceRoot":"","sources":["../../src/record-guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAO9C;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAE9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;IAAE,IAAI,IAAI,OAAO,CAAA;CAAE,EAAE,GAAG,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUlH"}
1
+ {"version":3,"file":"record-guards.d.ts","sourceRoot":"","sources":["../../src/record-guards.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAmC,YAAY,EAA8D,MAAM,eAAe,CAAC;AAC1I,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAmC,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAMnF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAE9D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;IAAE,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