@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
@@ -1 +1 @@
1
- {"version":3,"file":"record-tiles.d.ts","sourceRoot":"","sources":["../../src/record-tiles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAQ,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEnG,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvE,oCAAoC;AACpC,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAgD,CAAC;AAE/F;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AASrC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;EAAsD,CAAC;AACjF,4C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,GAAG,UAAU,CAGtF;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc;;;;;;gCAA8D,CAAC;AAE1F;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;EAA6D,CAAC;AACzF,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC;AAOnD;;;;GAIG;AACH,eAAO,MAAM,QAAQ;IACnB;;;;;;;;OAQG;;;;;;;;IAaH,gHAAgH;;IAYhH;;;;OAIG;;;;;;;;IAaH,uDAAuD;;;;;;;;IAMvD;;;;;;;;;;;OAWG;;;;;;;;;;;;;;;;;;;;;;;IA6BH;;;;;;;;;;OAUG;;;;;;;;;;;IAQH,4EAA4E;;;;;;;;IAM5E;;;;;;;;;;;;;OAaG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiCH;;;;;OAKG;;;;;;;;;;;;;;;;;IAQH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAaH;;;;;;OAMG;;;;;;;;;;;;;;;;;IAWH;;;;;OAKG;;;;;;;;;;;;;;;;;;;;;;;IAaH;;;;;;;OAOG;;;;;;;;;;;CAWH,CAAC"}
@@ -7,25 +7,58 @@
7
7
  * (#1039): a day, an ISO week from Monday, a calendar month, a quarter or a
8
8
  * year, each in UTC and half-open, `[its start, the next tile's start)`.
9
9
  *
10
- * An event `[start, end)` touches every tile it overlaps, and covers the
11
- * milliseconds of each that it overlaps: its shares, which add up to its
12
- * length exactly. An instant — no end, or an end at or before its start —
13
- * touches the one tile holding it and covers none of it. The arithmetic is
14
- * Integer milliseconds and East's own calendar, so every runtime files an event
15
- * under the same tiles with the same shares, which is what lets a maintained
16
- * index equal its rebuild byte for byte.
10
+ * A summary index splits an event over every tile it overlaps
11
+ * (`tileShares`): its shares, the milliseconds of each tile it covers,
12
+ * which add up to its length exactly. An instant — no end, or an end at or
13
+ * before its start — touches the one tile holding it and covers none of it.
14
+ *
15
+ * A series index files an event once (#1433, `eventFilings`): at the
16
+ * finest level, from its tile up, whose shortest tile holds the event's
17
+ * length, under the tile of that level holding its start — or, past a year,
18
+ * under each year it touches. An event filed at a level ends before the end of
19
+ * the tile after the one holding its start, so a reader finds every event at a
20
+ * level that overlaps a range by reading its tiles from the one before the
21
+ * range's first.
22
+ *
23
+ * Each is one East function, the tile an East value it is given
24
+ * (`RecordLevelType`), and the arithmetic Integer milliseconds and East's own
25
+ * calendar, so every runtime files an event alike, which is what lets a
26
+ * maintained index equal its rebuild byte for byte.
17
27
  *
18
28
  * @packageDocumentation
19
29
  */
20
- import { ArrayType, DateTimeType, East, IntegerType, StringType, StructType } from '@elaraai/east';
30
+ import { ArrayType, DateTimeType, East, FunctionType, IntegerType, OptionType, StringType, StructType, variant } from '@elaraai/east';
31
+ import { RecordLevelType } from '@elaraai/e3-types';
32
+ import { lazyBuilds } from './lazy-build.js';
21
33
  /** The tiles, from the shortest. */
22
34
  export const RECORD_TILES = ['day', 'week', 'month', 'quarter', 'year'];
23
35
  /**
24
- * The most tiles one event may touch: one row of a series or a summary index
25
- * never writes more entries than this, whatever its span. An event touching
26
- * more is refused where it is written, naming it and the tile.
36
+ * The most tiles one event is filed under or split over: a series index files
37
+ * an event longer than a year under each year it touches, as many as this
38
+ * (`eventFilings`), and a summary index splits one over its tiles, as
39
+ * many as this (`tileShares`). An event past either is refused where it
40
+ * is written, naming it.
27
41
  */
28
42
  export const MAX_EVENT_TILES = 4096n;
43
+ /** The most tiles, as a refusal names it. */
44
+ const MAX_TILES_TEXT = `${MAX_EVENT_TILES}`;
45
+ /** What a refusal says of an event split over too many tiles, after the tile's name. */
46
+ const TOO_MANY_TILES = ' tiles: declare a coarser tile';
47
+ /** What a refusal says of an event filed under too many years. */
48
+ const TOO_MANY_YEARS = `touches more than ${MAX_EVENT_TILES} year tiles: end it within ${MAX_EVENT_TILES} years of its start`;
49
+ /**
50
+ * Each level's shortest tile, in milliseconds: a day; a week; a month's 28
51
+ * days; a quarter's 90, January to March in a common year; a year's 365. An
52
+ * event filed at a level is no longer than this, so the tile after the one
53
+ * holding its start, at least as long, holds its end.
54
+ */
55
+ export const SHORTEST_MS = {
56
+ day: 86400000n,
57
+ week: 604800000n,
58
+ month: 2419200000n,
59
+ quarter: 7776000000n,
60
+ year: 31536000000n,
61
+ };
29
62
  /** A day, in milliseconds. */
30
63
  const DAY_MS = 86400000n;
31
64
  /** An ISO week, in milliseconds. */
@@ -55,102 +88,258 @@ export function checkTile(constructor, name, tile) {
55
88
  throw new Error(`${constructor} '${name}' takes a tile: ${RECORD_TILES.map((t) => `"${t}"`).join(', ')} — got ${JSON.stringify(tile)}`);
56
89
  }
57
90
  /**
58
- * A fixed-length tile's start: the instant floored to a whole number of
59
- * `length` milliseconds from `origin`, whichever sign the runtime's remainder
60
- * takes, so an instant before 1970 is tiled as one after it.
61
- */
62
- function fixedStart(length, origin) {
63
- return East.function([DateTimeType], DateTimeType, ($, at) => {
64
- const ms = $.let(at.toEpochMilliseconds());
65
- // The offset into its tile, in [0, length).
66
- const into = $.let(ms.subtract(origin).remainder(length).add(length).remainder(length));
67
- return East.DateTime.fromEpochMilliseconds(ms.subtract(into));
68
- });
69
- }
70
- /**
71
- * The start of the tile holding an instant: an East function, so every runtime
72
- * computes it alike — a day and a week counted in whole milliseconds from
73
- * midnight of the epoch and from the Monday before it, a month, a quarter and
74
- * a year by East's calendar (`roundDownMonth`, `roundDownYear`).
75
- *
76
- * @param tile - The tile
77
- * @returns `(at) → the start of the tile holding it`
91
+ * `(level, at) → a tile's start`: the type of `tileStart` and
92
+ * `tileNext`, which a function given either takes.
78
93
  */
79
- export function tileStart(tile) {
80
- switch (tile) {
81
- case 'day': return fixedStart(DAY_MS, 0n);
82
- case 'week': return fixedStart(WEEK_MS, MONDAY_MS);
83
- case 'month': return East.function([DateTimeType], DateTimeType, (_$, at) => East.DateTime.roundDownMonth(at, 1n));
84
- case 'quarter': return East.function([DateTimeType], DateTimeType, (_$, at) => East.DateTime.roundDownMonth(at, 3n));
85
- case 'year': return East.function([DateTimeType], DateTimeType, (_$, at) => East.DateTime.roundDownYear(at, 1n));
86
- }
87
- }
88
- /** A calendar tile's next start: `months` on, January of the next year past December. */
89
- function calendarNext(months) {
90
- return East.function([DateTimeType], DateTimeType, ($, start) => {
91
- const year = $.let(start.getYear());
92
- const month = $.let(start.getMonth().add(months));
93
- $.if(month.greater(12n), ($) => {
94
- $.assign(year, year.add(1n));
95
- $.assign(month, month.subtract(12n));
96
- });
97
- return East.DateTime.fromComponents(year, month, 1n, 0n, 0n, 0n, 0n);
98
- });
99
- }
94
+ export const TileStepFnType = FunctionType([RecordLevelType, DateTimeType], DateTimeType);
100
95
  /**
101
- * The start of the tile after one: an East function, so every runtime computes
102
- * it alike.
96
+ * One place a series index files an event (#1433): the level, and the start of
97
+ * that level's tile.
103
98
  *
104
- * @param tile - The tile
105
- * @returns `(start) → the next tile's start`, for a tile's start
99
+ * @property level - The level it is filed at
100
+ * @property tile - The start of the level's tile, UTC
106
101
  */
107
- export function tileNext(tile) {
108
- switch (tile) {
109
- case 'day': return East.function([DateTimeType], DateTimeType, (_$, start) => East.DateTime.fromEpochMilliseconds(start.toEpochMilliseconds().add(DAY_MS)));
110
- case 'week': return East.function([DateTimeType], DateTimeType, (_$, start) => East.DateTime.fromEpochMilliseconds(start.toEpochMilliseconds().add(WEEK_MS)));
111
- case 'month': return calendarNext(1n);
112
- case 'quarter': return calendarNext(3n);
113
- case 'year': return calendarNext(12n);
114
- }
115
- }
102
+ export const TileFilingType = StructType({ level: RecordLevelType, tile: DateTimeType });
103
+ /** The levels, from the finest. */
104
+ const LEVELS = [variant('day', null), variant('week', null), variant('month', null), variant('quarter', null), variant('year', null)];
105
+ // ── The functions, each built the first time it is read ──────────────────────
116
106
  /**
117
- * The tiles an event touches, and its share of each: an East function, so
118
- * every runtime files an event alike (see the module docs).
119
- *
120
- * @param tile - The tile
121
- * @returns `(start, end, what) → each tile it touches, in order, and the
122
- * milliseconds of it the event covers`: one tile, covered for none, when
123
- * `end` is at or before `start`. `what` names the event in a refusal.
124
- * @throws East runtime error when the event touches more than
125
- * {@link MAX_EVENT_TILES} tiles, naming `what`, its span and the tile
107
+ * The tiles' East functions (see the module docs), each built the first time
108
+ * it is read, with no location captured ({@link lazyBuilds}, #1466):
109
+ * importing the SDK builds none of them.
126
110
  */
127
- export function tileShares(tile) {
128
- const startOf = tileStart(tile);
129
- const nextOf = tileNext(tile);
130
- const tooMany = `touches more than ${MAX_EVENT_TILES} ${tile} tiles: declare a coarser tile`;
131
- return East.function([DateTimeType, DateTimeType, StringType], ArrayType(TileShareType), ($, start, end, what) => {
132
- const first = $.const(startOf);
133
- const next = $.const(nextOf);
134
- const shares = $.let([], ArrayType(TileShareType));
135
- const from = $.let(start.toEpochMilliseconds());
136
- const to = $.let(end.toEpochMilliseconds());
137
- const at = $.let(first(start));
138
- // An instant: the tile holding it, none of it covered.
139
- $.if(to.lessEqual(from), ($) => {
140
- $(shares.pushLast({ tile: at, ms: 0n }));
141
- $.return(shares);
111
+ export const TILE_FNS = lazyBuilds({
112
+ /**
113
+ * The start of the tile of a level holding an instant: a day and a week
114
+ * counted in whole milliseconds from midnight of the epoch and from the Monday
115
+ * before it — whichever sign the runtime's remainder takes, so an instant
116
+ * before 1970 is tiled as one after it — and a month, a quarter and a year by
117
+ * East's calendar (`roundDownMonth`, `roundDownYear`).
118
+ *
119
+ * `(level, at) → the start of the tile holding it`
120
+ */
121
+ get tileStart() {
122
+ return East.function([RecordLevelType, DateTimeType], DateTimeType, ($, level, at) => {
123
+ const ms = $.let(at.toEpochMilliseconds());
124
+ return level.match({
125
+ day: () => East.DateTime.fromEpochMilliseconds(ms.subtract(ms.remainder(DAY_MS).add(DAY_MS).remainder(DAY_MS))),
126
+ week: () => East.DateTime.fromEpochMilliseconds(ms.subtract(ms.subtract(MONDAY_MS).remainder(WEEK_MS).add(WEEK_MS).remainder(WEEK_MS))),
127
+ month: () => East.DateTime.roundDownMonth(at, 1n),
128
+ quarter: () => East.DateTime.roundDownMonth(at, 3n),
129
+ year: () => East.DateTime.roundDownYear(at, 1n),
130
+ });
142
131
  });
143
- $.while(at.toEpochMilliseconds().less(to), ($) => {
144
- $.if(shares.size().greaterEqual(MAX_EVENT_TILES), ($) => {
145
- $.error(East.str `${what}, from ${East.print(start)} to ${East.print(end)}, ${tooMany}`);
132
+ },
133
+ /** `(start, months) → the start of the calendar month that many on`: January of the next year past December. */
134
+ get monthsOn() {
135
+ return East.function([DateTimeType, IntegerType], DateTimeType, ($, start, months) => {
136
+ const year = $.let(start.getYear());
137
+ const month = $.let(start.getMonth().add(months));
138
+ $.if(month.greater(12n), ($) => {
139
+ $.assign(year, year.add(1n));
140
+ $.assign(month, month.subtract(12n));
146
141
  });
147
- const after = $.let(next(at));
148
- const lo = $.let(at.toEpochMilliseconds().greater(from).ifElse(() => at.toEpochMilliseconds(), () => from));
149
- const hi = $.let(after.toEpochMilliseconds().less(to).ifElse(() => after.toEpochMilliseconds(), () => to));
150
- $(shares.pushLast({ tile: at, ms: hi.subtract(lo) }));
151
- $.assign(at, after);
142
+ return East.DateTime.fromComponents(year, month, 1n, 0n, 0n, 0n, 0n);
152
143
  });
153
- return shares;
154
- });
155
- }
144
+ },
145
+ /**
146
+ * The start of the tile after one, for a tile's start.
147
+ *
148
+ * `(level, start) → the next tile's start`
149
+ */
150
+ get tileNext() {
151
+ return East.function([RecordLevelType, DateTimeType], DateTimeType, ($, level, start) => {
152
+ const calendar = $.const(TILE_FNS.monthsOn);
153
+ return level.match({
154
+ day: () => East.DateTime.fromEpochMilliseconds(start.toEpochMilliseconds().add(DAY_MS)),
155
+ week: () => East.DateTime.fromEpochMilliseconds(start.toEpochMilliseconds().add(WEEK_MS)),
156
+ month: () => calendar(start, 1n),
157
+ quarter: () => calendar(start, 3n),
158
+ year: () => calendar(start, 12n),
159
+ });
160
+ });
161
+ },
162
+ /** `(level) → its name`, as a refusal names a tile. */
163
+ get levelName() {
164
+ return East.function([RecordLevelType], StringType, (_$, level) => level.match({
165
+ day: () => 'day', week: () => 'week', month: () => 'month', quarter: () => 'quarter', year: () => 'year',
166
+ }));
167
+ },
168
+ /**
169
+ * The tiles of a level an event touches, and its share of each (
170
+ * `tileShares`), given the functions that step through the tiles: a program
171
+ * binding `tileStart` and `tileNext` once hands them to each
172
+ * function that calls either.
173
+ *
174
+ * `(level, start, end, what, first, next) → each tile it touches, in order,
175
+ * and the milliseconds of it the event covers`
176
+ *
177
+ * Throws an East runtime error when the event touches more than
178
+ * {@link MAX_EVENT_TILES} tiles, naming `what`, its span and the tile.
179
+ */
180
+ get tileSharesOver() {
181
+ return East.function([RecordLevelType, DateTimeType, DateTimeType, StringType, TileStepFnType, TileStepFnType], ArrayType(TileShareType), ($, level, start, end, what, first, next) => {
182
+ const shares = $.let([], ArrayType(TileShareType));
183
+ const from = $.let(start.toEpochMilliseconds());
184
+ const to = $.let(end.toEpochMilliseconds());
185
+ const at = $.let(first(level, start));
186
+ // An instant: the tile holding it, none of it covered.
187
+ $.if(to.lessEqual(from), ($) => {
188
+ $(shares.pushLast({ tile: at, ms: 0n }));
189
+ $.return(shares);
190
+ });
191
+ $.while(at.toEpochMilliseconds().less(to), ($) => {
192
+ $.if(shares.size().greaterEqual(MAX_EVENT_TILES), ($) => {
193
+ const name = $.const(TILE_FNS.levelName);
194
+ $.error(East.str `${what}, from ${East.print(start)} to ${East.print(end)}, touches more than ${MAX_TILES_TEXT} ${name(level)}${TOO_MANY_TILES}`);
195
+ });
196
+ const after = $.let(next(level, at));
197
+ const lo = $.let(at.toEpochMilliseconds().greater(from).ifElse(() => at.toEpochMilliseconds(), () => from));
198
+ const hi = $.let(after.toEpochMilliseconds().less(to).ifElse(() => after.toEpochMilliseconds(), () => to));
199
+ $(shares.pushLast({ tile: at, ms: hi.subtract(lo) }));
200
+ $.assign(at, after);
201
+ });
202
+ return shares;
203
+ });
204
+ },
205
+ /**
206
+ * The tiles of a level an event touches, and its share of each (see the
207
+ * module docs).
208
+ *
209
+ * `(level, start, end, what) → each tile it touches, in order, and the
210
+ * milliseconds of it the event covers`: one tile, covered for none, when `end`
211
+ * is at or before `start`. `what` names the event in a refusal.
212
+ *
213
+ * Throws an East runtime error when the event touches more than
214
+ * {@link MAX_EVENT_TILES} tiles, naming `what`, its span and the tile.
215
+ */
216
+ get tileShares() {
217
+ return East.function([RecordLevelType, DateTimeType, DateTimeType, StringType], ArrayType(TileShareType), ($, level, start, end, what) => {
218
+ const first = $.const(TILE_FNS.tileStart);
219
+ const next = $.const(TILE_FNS.tileNext);
220
+ return TILE_FNS.tileSharesOver(level, start, end, what, first, next);
221
+ });
222
+ },
223
+ /** `(level) → its shortest tile, in milliseconds` ({@link SHORTEST_MS}). */
224
+ get shortestMs() {
225
+ return East.function([RecordLevelType], IntegerType, (_$, level) => level.match({
226
+ day: () => SHORTEST_MS.day, week: () => SHORTEST_MS.week, month: () => SHORTEST_MS.month, quarter: () => SHORTEST_MS.quarter, year: () => SHORTEST_MS.year,
227
+ }));
228
+ },
229
+ /**
230
+ * Where a series index files an event (see the module docs), given the
231
+ * functions that step through the tiles (`tileSharesOver`'s): once, at
232
+ * the finest level from the index's tile up whose shortest tile
233
+ * ({@link SHORTEST_MS}) holds its length, under the tile of that level holding
234
+ * its start; past a year, under each year it touches.
235
+ *
236
+ * `(tile, start, end, what, startOf, nextOf) → each place it is filed, in
237
+ * order`: an instant — `end` at or before `start` — at `tile`. `what` names
238
+ * the event in a refusal, as `tileShares`' does.
239
+ *
240
+ * Throws an East runtime error when an event longer than a year touches more
241
+ * than {@link MAX_EVENT_TILES} years, naming `what` and its span.
242
+ */
243
+ get eventFilingsOver() {
244
+ return East.function([RecordLevelType, DateTimeType, DateTimeType, StringType, TileStepFnType, TileStepFnType], ArrayType(TileFilingType), ($, tile, start, end, what, startOf, nextOf) => {
245
+ const shortest = $.const(TILE_FNS.shortestMs);
246
+ const levels = $.const(LEVELS, ArrayType(RecordLevelType));
247
+ const length = $.let(end.toEpochMilliseconds().subtract(start.toEpochMilliseconds()));
248
+ const filed = $.let([], ArrayType(TileFilingType));
249
+ // The levels from the index's tile up, the first whose shortest tile holds the event.
250
+ const reached = $.let(false);
251
+ $.for(levels, ($, level) => {
252
+ $.if(East.equal(level, tile), ($) => { $.assign(reached, true); });
253
+ $.if(reached.and(() => filed.size().equal(0n)).and(() => length.lessEqual(shortest(level))), ($) => {
254
+ $(filed.pushLast({ level, tile: startOf(level, start) }));
255
+ });
256
+ });
257
+ // Longer than a year: each year it touches, as many as MAX_EVENT_TILES.
258
+ $.if(filed.size().equal(0n), ($) => {
259
+ const year = $.const(variant('year', null), RecordLevelType);
260
+ const at = $.let(startOf(year, start));
261
+ $.while(at.toEpochMilliseconds().less(end.toEpochMilliseconds()), ($) => {
262
+ $.if(filed.size().greaterEqual(MAX_EVENT_TILES), ($) => {
263
+ $.error(East.str `${what}, from ${East.print(start)} to ${East.print(end)}, ${TOO_MANY_YEARS}`);
264
+ });
265
+ $(filed.pushLast({ level: year, tile: at }));
266
+ $.assign(at, nextOf(year, at));
267
+ });
268
+ });
269
+ return filed;
270
+ });
271
+ },
272
+ /**
273
+ * Where a series index files an event: `eventFilingsOver`, its tiles
274
+ * stepped through by `tileStart` and `tileNext`.
275
+ *
276
+ * `(tile, start, end, what) → each place it is filed, in order`
277
+ */
278
+ get eventFilings() {
279
+ return East.function([RecordLevelType, DateTimeType, DateTimeType, StringType], ArrayType(TileFilingType), ($, tile, start, end, what) => {
280
+ const startOf = $.const(TILE_FNS.tileStart);
281
+ const nextOf = $.const(TILE_FNS.tileNext);
282
+ return TILE_FNS.eventFilingsOver(tile, start, end, what, startOf, nextOf);
283
+ });
284
+ },
285
+ /**
286
+ * The places an event is filed (`eventFilingsOver`) — a series index's, a nested one's item's: none for an
287
+ * event with no start; one with no end is an instant.
288
+ *
289
+ * `(tile, start, end, what, startOf, nextOf) → each place it is filed, in order`
290
+ */
291
+ get placedFilingsOver() {
292
+ return East.function([RecordLevelType, OptionType(DateTimeType), OptionType(DateTimeType), StringType, TileStepFnType, TileStepFnType], ArrayType(TileFilingType), ($, tile, start, end, what, startOf, nextOf) => {
293
+ $.match(start, {
294
+ some: ($, from) => { $.return(TILE_FNS.eventFilingsOver(tile, from, end.unwrap('some', () => from), what, startOf, nextOf)); },
295
+ none: () => { },
296
+ });
297
+ return [];
298
+ });
299
+ },
300
+ /**
301
+ * The places an event is filed — a series index's, a nested one's item's: none
302
+ * for an event with no start; one with no end is an instant (
303
+ * `placedFilingsOver`, stepping by `tileStart` and `tileNext`).
304
+ *
305
+ * `(tile, start, end, what) → each place it is filed, in order`
306
+ */
307
+ get placedFilings() {
308
+ return East.function([RecordLevelType, OptionType(DateTimeType), OptionType(DateTimeType), StringType], ArrayType(TileFilingType), ($, tile, start, end, what) => {
309
+ const startOf = $.const(TILE_FNS.tileStart);
310
+ const nextOf = $.const(TILE_FNS.tileNext);
311
+ return TILE_FNS.placedFilingsOver(tile, start, end, what, startOf, nextOf);
312
+ });
313
+ },
314
+ /**
315
+ * The tiles an event touches, and its share of each (`tileSharesOver`) — a summary's, a nested index's totals':
316
+ * none for an event with no start; one with no end is an instant.
317
+ *
318
+ * `(tile, start, end, what, first, next) → each tile it touches, in order, and the milliseconds of it the event covers`
319
+ */
320
+ get placedSharesOver() {
321
+ return East.function([RecordLevelType, OptionType(DateTimeType), OptionType(DateTimeType), StringType, TileStepFnType, TileStepFnType], ArrayType(TileShareType), ($, tile, start, end, what, first, next) => {
322
+ $.match(start, {
323
+ some: ($, from) => { $.return(TILE_FNS.tileSharesOver(tile, from, end.unwrap('some', () => from), what, first, next)); },
324
+ none: () => { },
325
+ });
326
+ return [];
327
+ });
328
+ },
329
+ /**
330
+ * The tiles an event touches, and its share of each — a summary's, a nested
331
+ * index's totals': none for an event with no start; one with no end is an
332
+ * instant (`placedSharesOver`, stepping by `tileStart` and
333
+ * `tileNext`).
334
+ *
335
+ * `(tile, start, end, what) → each tile it touches, in order, and the milliseconds of it the event covers`
336
+ */
337
+ get placedShares() {
338
+ return East.function([RecordLevelType, OptionType(DateTimeType), OptionType(DateTimeType), StringType], ArrayType(TileShareType), ($, tile, start, end, what) => {
339
+ const first = $.const(TILE_FNS.tileStart);
340
+ const next = $.const(TILE_FNS.tileNext);
341
+ return TILE_FNS.placedSharesOver(tile, start, end, what, first, next);
342
+ });
343
+ },
344
+ });
156
345
  //# sourceMappingURL=record-tiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"record-tiles.js","sourceRoot":"","sources":["../../src/record-tiles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAKnG,oCAAoC;AACpC,MAAM,CAAC,MAAM,YAAY,GAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAE/F;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC,8BAA8B;AAC9B,MAAM,MAAM,GAAG,SAAW,CAAC;AAC3B,oCAAoC;AACpC,MAAM,OAAO,GAAG,UAAY,CAAC;AAC7B,wGAAwG;AACxG,MAAM,SAAS,GAAG,CAAC,UAAY,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;AAIjF;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,WAAmB,EAAE,IAAY,EAAE,IAAa;IACxE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAK,YAAkC,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,IAAkB,CAAC;IAC9G,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,KAAK,IAAI,mBAAmB,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,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,EAAE,GAAE,CAAC;aACf,CAAC,CAAC;YACH,OAAO,EAAE,CAAC;QACZ,CAAC,CACF,CAAC;IACJ,CAAC;IACD;;;;;;;OAOG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAClB,CAAC,eAAe,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,aAAa,CAAC,EAC3G,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAC5B,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACxC,OAAO,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACxE,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -5,15 +5,39 @@
5
5
  /**
6
6
  * Record dataset definitions for e3 packages.
7
7
  *
8
- * `e3.record` declares a root dataset whose writes go through typed, pure East
9
- * mutations (`e3.mutation`) instead of blind replace — durable, audited,
10
- * compare-and-swap state that participates in reactive dataflow as a root
11
- * input. The current state reads exactly like a value dataset; only the write
12
- * protocol differs.
8
+ * `e3.record` declares a root dataset written only through the typed, pure
9
+ * East mutations its declaration names, never by blind replace: durable,
10
+ * audited, compare-and-swap state that participates in reactive dataflow as a
11
+ * root input. The current state reads exactly like a value dataset; only the
12
+ * write protocol differs.
13
13
  */
14
14
  import type { EastType, ValueTypeOf } from '@elaraai/east';
15
15
  import { variant } from '@elaraai/east';
16
16
  import type { DataTreeDef, RecordDef } from './types.js';
17
+ import { type IndexBuilder, type IndexDraft, type IndexesOf, type MigrationBuilder, type MigrationDraft, type MutationBuilder, type MutationDraft, type MutationsOf } from './record-builders.js';
18
+ /**
19
+ * What `e3.record` takes beside its name and type: its initial state, and its
20
+ * parts through the builders it hands each.
21
+ *
22
+ * @typeParam T - The record's state type
23
+ * @typeParam I - Its indexes, as `indexes` returns them
24
+ * @typeParam M - Its mutations, as `mutations` returns them
25
+ */
26
+ export interface RecordConfig<T extends EastType, I extends object, M extends object> {
27
+ /**
28
+ * The initial state, the genesis commit, or a function that makes it — once,
29
+ * when it is first read, as its package is exported: a large one is never
30
+ * made where the declaration is only read, as a page binding the record
31
+ * reads it. Omitted for a record whose first state is committed from outside.
32
+ */
33
+ readonly initial?: NoInfer<ValueTypeOf<T>> | (() => NoInfer<ValueTypeOf<T>>);
34
+ /** Its indexes by name, from the `index` builder. */
35
+ readonly indexes?: (index: IndexBuilder<T>) => I;
36
+ /** Its mutations by name, from the `mutation` builder. */
37
+ readonly mutations?: (mutation: MutationBuilder<T>) => M;
38
+ /** Its migrations in order, each named, from the `migration` builder. */
39
+ readonly migrations?: (migration: MigrationBuilder) => readonly MigrationDraft[];
40
+ }
17
41
  /**
18
42
  * Singleton datatree definition for `.records`.
19
43
  *
@@ -21,7 +45,9 @@ import type { DataTreeDef, RecordDef } from './types.js';
21
45
  */
22
46
  export declare const recordsTree: DataTreeDef;
23
47
  /**
24
- * Defines a record — a root dataset written only through mutations.
48
+ * Defines a record — a root dataset written only through mutations — declared
49
+ * whole: its type, its initial value, its indexes, its mutations and its
50
+ * migrations, in one call, never changed after.
25
51
  *
26
52
  * Creates a dataset at `.records.${name}` with `writable: false` (so raw
27
53
  * `e3 set` / `Data.write` is rejected). With an initial value, deploy writes
@@ -33,22 +59,50 @@ export declare const recordsTree: DataTreeDef;
33
59
  * it holds a state. So a record whose first state is data that arrives after
34
60
  * the deploy never runs its dependents on an empty value first.
35
61
  *
62
+ * Its parts are declared through the builders it hands each: `indexes` gets
63
+ * `index` and returns them by name, `mutations` gets `mutation` and returns
64
+ * them by name, and `migrations` gets `migration` and returns its steps in
65
+ * order, each named. Each is built and checked here, every refusal naming the
66
+ * record and the part, and the record's type carries each by its name — so a
67
+ * binding names them, and TypeScript holds each name to the record. The parts
68
+ * are frozen: nothing adds to a record once declared.
69
+ *
70
+ * @typeParam Name - Record name (literal type)
36
71
  * @typeParam T - The East type of the record state
72
+ * @typeParam I - Its indexes, as `indexes` returns them
73
+ * @typeParam M - Its mutations, as `mutations` returns them
37
74
  * @param name - Record name (used as path segment in the tree)
38
75
  * @param type - East type of the record state
39
- * @param initialValue - The initial state, the genesis commit; omitted for a
40
- * record whose first state is committed from outside
41
- * @returns A RecordDef, usable anywhere a dataset is plus as a mutation target
76
+ * @param config - `initial`, the genesis state, omitted for a record whose first
77
+ * state is committed from outside; `indexes`, `mutations` and `migrations`
78
+ * @returns A RecordDef, usable anywhere a dataset is, its parts by name
79
+ * @throws {Error} For a declaration that is not an object of `initial`,
80
+ * `indexes`, `mutations` and `migrations` — an initial value passed in its
81
+ * place is refused, naming `{ initial: value }` — and naming the record and
82
+ * the part: a part's name that is not an identifier, or `primary` for an
83
+ * index; a second nested series index; a part not made by its builder; two
84
+ * migrations of one name, or a migration that does not take the record as the
85
+ * step before it leaves it, or a last step that leaves it as other than its
86
+ * type; or anything a part's builder refuses
42
87
  *
43
88
  * @example
44
89
  * ```ts
45
90
  * import { DictType, StringType } from '@elaraai/east';
46
91
  *
47
- * const orders = record('orders', DictType(StringType, OrderType), new Map());
92
+ * const orders = e3.record('orders', DictType(StringType, OrderType), {
93
+ * initial: new Map(),
94
+ * indexes: (index) => ({
95
+ * orders_by_status: index.on(['status']),
96
+ * }),
97
+ * mutations: (mutation) => ({
98
+ * place_order: mutation.reduce(placeOrder),
99
+ * patch: mutation.patch(),
100
+ * }),
101
+ * });
48
102
  * // Unassigned until its first state is committed: `e3 seed` from a beast2
49
103
  * // file, or a host's file intake
50
- * const customers = record('customers', DictType(StringType, CustomerType));
104
+ * const customers = e3.record('customers', DictType(StringType, CustomerType));
51
105
  * ```
52
106
  */
53
- export declare function record<Name extends string, T extends EastType>(name: Name, type: T, initialValue?: ValueTypeOf<T>): RecordDef<T, [variant<"field", "records">, variant<"field", Name>]>;
107
+ export declare function record<Name extends string, T extends EastType, I extends Readonly<Record<string, IndexDraft>> = Record<never, never>, M extends Readonly<Record<string, MutationDraft>> = Record<never, never>>(name: Name, type: T, config?: RecordConfig<T, I, M>): RecordDef<T, [variant<'field', 'records'>, variant<'field', Name>], IndexesOf<I, T>, MutationsOf<M, T>>;
54
108
  //# sourceMappingURL=record.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,WAKzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,CAAC,SAAS,QAAQ,EAC5D,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,CAAC,EACP,YAAY,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAC5B,SAAS,CAAC,CAAC,EAAE,CAAE,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAE,CAAC,CAcvE"}
1
+ {"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAwB,OAAO,E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