@elaraai/e3-ui 1.0.83 → 1.0.85

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 (121) hide show
  1. package/dist/src/bind/data.d.ts +4 -3
  2. package/dist/src/bind/data.d.ts.map +1 -1
  3. package/dist/src/bind/data.js +4 -3
  4. package/dist/src/bind/data.js.map +1 -1
  5. package/dist/src/bind/record.d.ts +234 -6
  6. package/dist/src/bind/record.d.ts.map +1 -1
  7. package/dist/src/bind/record.js +250 -7
  8. package/dist/src/bind/record.js.map +1 -1
  9. package/dist/src/bind/sources.d.ts +148 -0
  10. package/dist/src/bind/sources.d.ts.map +1 -0
  11. package/dist/src/bind/sources.js +116 -0
  12. package/dist/src/bind/sources.js.map +1 -0
  13. package/dist/src/index.d.ts +4 -1
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/index.js +9 -1
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/internal.d.ts +4 -1
  18. package/dist/src/internal.d.ts.map +1 -1
  19. package/dist/src/internal.js +11 -1
  20. package/dist/src/internal.js.map +1 -1
  21. package/dist/src/query/builder.d.ts +3257 -0
  22. package/dist/src/query/builder.d.ts.map +1 -0
  23. package/dist/src/query/builder.js +126 -0
  24. package/dist/src/query/builder.js.map +1 -0
  25. package/dist/src/query/index.d.ts +108 -0
  26. package/dist/src/query/index.d.ts.map +1 -0
  27. package/dist/src/query/index.js +76 -0
  28. package/dist/src/query/index.js.map +1 -0
  29. package/dist/src/query/library.d.ts +3241 -0
  30. package/dist/src/query/library.d.ts.map +1 -0
  31. package/dist/src/query/library.js +114 -0
  32. package/dist/src/query/library.js.map +1 -0
  33. package/dist/src/query/queries.d.ts +4696 -0
  34. package/dist/src/query/queries.d.ts.map +1 -0
  35. package/dist/src/query/queries.js +129 -0
  36. package/dist/src/query/queries.js.map +1 -0
  37. package/dist/src/query/saved.d.ts +72 -0
  38. package/dist/src/query/saved.d.ts.map +1 -0
  39. package/dist/src/query/saved.js +84 -0
  40. package/dist/src/query/saved.js.map +1 -0
  41. package/dist/src/query/steps.d.ts +613 -0
  42. package/dist/src/query/steps.d.ts.map +1 -0
  43. package/dist/src/query/steps.js +316 -0
  44. package/dist/src/query/steps.js.map +1 -0
  45. package/dist/src/query/types.d.ts +444 -0
  46. package/dist/src/query/types.d.ts.map +1 -0
  47. package/dist/src/query/types.js +113 -0
  48. package/dist/src/query/types.js.map +1 -0
  49. package/dist/src/studio/builder.d.ts +3123 -0
  50. package/dist/src/studio/builder.d.ts.map +1 -0
  51. package/dist/src/studio/builder.js +115 -0
  52. package/dist/src/studio/builder.js.map +1 -0
  53. package/dist/src/studio/canvas.d.ts +83 -0
  54. package/dist/src/studio/canvas.d.ts.map +1 -0
  55. package/dist/src/studio/canvas.js +71 -0
  56. package/dist/src/studio/canvas.js.map +1 -0
  57. package/dist/src/studio/component.d.ts +178 -0
  58. package/dist/src/studio/component.d.ts.map +1 -0
  59. package/dist/src/studio/component.js +189 -0
  60. package/dist/src/studio/component.js.map +1 -0
  61. package/dist/src/studio/index.d.ts +104 -0
  62. package/dist/src/studio/index.d.ts.map +1 -0
  63. package/dist/src/studio/index.js +75 -0
  64. package/dist/src/studio/index.js.map +1 -0
  65. package/dist/src/studio/inspector.d.ts +208 -0
  66. package/dist/src/studio/inspector.d.ts.map +1 -0
  67. package/dist/src/studio/inspector.js +155 -0
  68. package/dist/src/studio/inspector.js.map +1 -0
  69. package/dist/src/studio/library.d.ts +3506 -0
  70. package/dist/src/studio/library.d.ts.map +1 -0
  71. package/dist/src/studio/library.js +245 -0
  72. package/dist/src/studio/library.js.map +1 -0
  73. package/dist/src/studio/page.d.ts +305 -0
  74. package/dist/src/studio/page.d.ts.map +1 -0
  75. package/dist/src/studio/page.js +105 -0
  76. package/dist/src/studio/page.js.map +1 -0
  77. package/dist/src/studio/pages.d.ts +10929 -0
  78. package/dist/src/studio/pages.d.ts.map +1 -0
  79. package/dist/src/studio/pages.js +502 -0
  80. package/dist/src/studio/pages.js.map +1 -0
  81. package/dist/src/studio/palette.d.ts +179 -0
  82. package/dist/src/studio/palette.d.ts.map +1 -0
  83. package/dist/src/studio/palette.js +120 -0
  84. package/dist/src/studio/palette.js.map +1 -0
  85. package/dist/src/studio/publish.d.ts +397 -0
  86. package/dist/src/studio/publish.d.ts.map +1 -0
  87. package/dist/src/studio/publish.js +198 -0
  88. package/dist/src/studio/publish.js.map +1 -0
  89. package/dist/src/ui.d.ts +16 -3
  90. package/dist/src/ui.d.ts.map +1 -1
  91. package/dist/src/ui.js +21 -1
  92. package/dist/src/ui.js.map +1 -1
  93. package/dist/test/bind/data/data.examples.d.ts +76 -1
  94. package/dist/test/bind/data/data.examples.d.ts.map +1 -1
  95. package/dist/test/bind/data/data.examples.js +176 -3
  96. package/dist/test/bind/data/data.examples.js.map +1 -1
  97. package/dist/test/bind/func/func.examples.d.ts +8 -0
  98. package/dist/test/bind/func/func.examples.d.ts.map +1 -1
  99. package/dist/test/bind/func/func.examples.js +4 -3
  100. package/dist/test/bind/func/func.examples.js.map +1 -1
  101. package/dist/test/bind/record/record.examples.d.ts +65 -1
  102. package/dist/test/bind/record/record.examples.d.ts.map +1 -1
  103. package/dist/test/bind/record/record.examples.js +21 -3
  104. package/dist/test/bind/record/record.examples.js.map +1 -1
  105. package/dist/test/query/query.examples.d.ts +5022 -0
  106. package/dist/test/query/query.examples.d.ts.map +1 -0
  107. package/dist/test/query/query.examples.js +467 -0
  108. package/dist/test/query/query.examples.js.map +1 -0
  109. package/dist/test/studio/component.examples.d.ts +7 -0
  110. package/dist/test/studio/component.examples.d.ts.map +1 -0
  111. package/dist/test/studio/component.examples.js +46 -0
  112. package/dist/test/studio/component.examples.js.map +1 -0
  113. package/dist/test/studio/page.examples.d.ts +7 -0
  114. package/dist/test/studio/page.examples.d.ts.map +1 -0
  115. package/dist/test/studio/page.examples.js +64 -0
  116. package/dist/test/studio/page.examples.js.map +1 -0
  117. package/dist/test/studio/studio.examples.d.ts +1766 -0
  118. package/dist/test/studio/studio.examples.d.ts.map +1 -0
  119. package/dist/test/studio/studio.examples.js +354 -0
  120. package/dist/test/studio/studio.examples.js.map +1 -0
  121. package/package.json +9 -8
@@ -15,10 +15,16 @@
15
15
  * latest-wins mutation lifecycle. A record's mutations serialize server-side
16
16
  * under compare-and-swap, so one shared channel per record is the honest model.
17
17
  *
18
+ * `commit.<name>(…)` is the same write awaited: an async closure that resolves
19
+ * to the server's terminal outcome. `Record.onApply` builds on it — an
20
+ * editable collection's `onApply` that commits each batch to the record
21
+ * through its patch door, as one commit.
22
+ *
18
23
  * @packageDocumentation
19
24
  */
20
- import { East, ArrayType, BooleanType, FunctionType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, } from '@elaraai/east';
21
- import { DatasetStatusType, RecordCommitInfoType } from '@elaraai/e3-types';
25
+ import { East, ArrayType, AsyncFunctionType, BooleanType, DictType, Expr, FunctionType, IntegerType, NullType, OptionType, PatchType, StringType, StructType, VariantType, dictPatchOpsType, isTypeEqual, none, printType, some, variant, } from '@elaraai/east';
26
+ import { DatasetStatusType, MutationResultType, RecordCommitInfoType } from '@elaraai/e3-types';
27
+ import { Editing } from '@elaraai/east-ui';
22
28
  // ============================================================================
23
29
  // Status + error + descriptor types
24
30
  // ============================================================================
@@ -79,6 +85,29 @@ export const RecordBindingType = StructType({
79
85
  name: StringType,
80
86
  mutations: ArrayType(StringType),
81
87
  });
88
+ /**
89
+ * The outcome of an awaited write (`commit.<name>`): the server's terminal
90
+ * `MutationResult`, passed on as it came, and `transport` for a call that got
91
+ * no answer.
92
+ *
93
+ * @remarks
94
+ * Only `committed` wrote anything. `transport` is the one outcome that leaves
95
+ * it unknown whether the write committed — it may have reached the server
96
+ * before its answer was lost — which is what the write's request id is for: a
97
+ * retry with the same id resolves to that commit instead of writing twice.
98
+ *
99
+ * @property committed - The new commit, and the record state it wrote
100
+ * @property invalid - A lookup, arity or signature error; nothing ran
101
+ * @property failed - The mutation's program failed; see its stderr
102
+ * @property timed_out - The program ran out of time; nothing was written
103
+ * @property conflict - The compare-and-swap lost the race `attempts` times, or
104
+ * the write no longer matched the record — then `detail` names the key
105
+ * @property transport - The call got no answer, so whether it committed is unknown
106
+ */
107
+ export const RecordOutcomeType = VariantType({
108
+ ...MutationResultType.fields.outcome.cases,
109
+ transport: StructType({ message: StringType }),
110
+ });
82
111
  // ============================================================================
83
112
  // Bind handle — return type of `Record.bind`.
84
113
  // ============================================================================
@@ -86,7 +115,7 @@ export const RecordBindingType = StructType({
86
115
  * The struct returned by every {@link Record.bind} call. The read side
87
116
  * (`read` / `status` / `history`) is served reactively from the shared dataset
88
117
  * cache; the write side lives under `mutate` — one closure per mutation plus
89
- * the shared lifecycle accessors.
118
+ * the shared lifecycle accessors — and under `commit`, the same writes awaited.
90
119
  *
91
120
  * @remarks
92
121
  * The handle's shape IS the signature: the runtime recovers the state type
@@ -102,11 +131,22 @@ export const RecordBindingType = StructType({
102
131
  * @property read - The record's current committed state. Reactive — re-fires
103
132
  * when a mutation commits (the dataset cache refreshes the record's bytes).
104
133
  * @property status - Per-dataset freshness signal — see {@link DatasetStatusType}.
105
- * @property history - The commit chain, newest first; `none` until the first
106
- * load completes, then the cached chain (refreshed after each commit).
134
+ * @property history - The commit chain, newest first, as far as one request is
135
+ * answered: all of it, unless the server's host pages a record's history
136
+ * (e3-api-server's `historyLimit`), when it is the newest page; `none` until
137
+ * the first load completes, then the cached chain (refreshed after each
138
+ * commit).
107
139
  * @property mutate - The write surface: one fire-and-forget closure per
108
140
  * mutation (typed from its def), plus the shared `pending` / `status` /
109
141
  * `error` / `cancel`.
142
+ * @property commit - The writes awaited: one async closure per mutation,
143
+ * taking a request id before the mutation's own arguments and resolving to
144
+ * its {@link RecordOutcomeType}. The id makes a retry after an unanswered
145
+ * call resolve to the first call's commit rather than writing twice; `""`
146
+ * is a write without one. It runs on `mutate`'s channel, so `pending` /
147
+ * `status` / `error` show it too, and a conflict reads the record and its
148
+ * history again before the outcome settles — `read` and `history` then show
149
+ * what the write lost to.
110
150
  * @property start - Launch the workspace dataflow without mutating, so tasks
111
151
  * that consume this record recompute against its latest committed state.
112
152
  * The standalone "Run" affordance — a mutation refreshes the record's own
@@ -121,18 +161,21 @@ export const RecordBindHandleType = (stateType, mutations) => {
121
161
  error: FunctionType([], OptionType(RecordErrorType)),
122
162
  cancel: FunctionType([], NullType),
123
163
  };
164
+ const commitFields = {};
124
165
  for (const [name, argTypes] of Object.entries(mutations)) {
125
166
  if (name in mutateFields) {
126
167
  throw new Error(`Record.bind: mutation name "${name}" collides with a reserved mutate ` +
127
168
  `field (pending/status/error/cancel). Rename the mutation.`);
128
169
  }
129
170
  mutateFields[name] = FunctionType(argTypes, NullType);
171
+ commitFields[name] = AsyncFunctionType([StringType, ...argTypes], RecordOutcomeType);
130
172
  }
131
173
  return StructType({
132
174
  read: FunctionType([], stateType),
133
175
  status: FunctionType([], DatasetStatusType),
134
176
  history: FunctionType([], OptionType(ArrayType(RecordCommitInfoType))),
135
177
  mutate: StructType(mutateFields),
178
+ commit: StructType(commitFields),
136
179
  start: FunctionType([], NullType),
137
180
  binding: RecordBindingType,
138
181
  });
@@ -166,6 +209,7 @@ export const recordBindPlatformFn = East.genericPlatform("record_bind", ["H"], [
166
209
  // `record_mutate` is generic over the per-mutation `ArgsStruct` `A` (the N args
167
210
  // bundled into one struct, since platform fns are fixed-arity): the impl recovers
168
211
  // the per-arg types from `A`'s fields and the values from the passed struct.
212
+ // `record_commit` is its awaited sibling, which takes the write's request id too.
169
213
  const record_read = East.genericPlatform("record_read", ["T"], [StringType], "T", { optional: true });
170
214
  const record_status = East.platform("record_status", [StringType], DatasetStatusType, { optional: true });
171
215
  const record_history = East.platform("record_history", [StringType], OptionType(ArrayType(RecordCommitInfoType)), { optional: true });
@@ -175,6 +219,7 @@ const record_mutate_status = East.platform("record_mutate_status", [StringType],
175
219
  const record_mutate_error = East.platform("record_mutate_error", [StringType], OptionType(RecordErrorType), { optional: true });
176
220
  const record_mutate_cancel = East.platform("record_mutate_cancel", [StringType], NullType, { optional: true });
177
221
  const record_mutate = East.genericPlatform("record_mutate", ["A"], [StringType, StringType, "A"], NullType, { optional: true });
222
+ const record_commit = East.asyncGenericPlatform("record_commit", ["A"], [StringType, StringType, StringType, "A"], RecordOutcomeType, { optional: true });
178
223
  /**
179
224
  * Low-level platform primitives that back {@link Record.bind}'s handle methods.
180
225
  *
@@ -201,6 +246,8 @@ export const RecordBindPrimitives = {
201
246
  mutateCancel: record_mutate_cancel,
202
247
  /** `record_mutate([ArgsStruct], recordName, mutationName, argsStruct) -> Null`. */
203
248
  mutate: record_mutate,
249
+ /** `record_commit([ArgsStruct], recordName, mutationName, requestId, argsStruct) ~> RecordOutcome` — the awaited write. */
250
+ commit: record_commit,
204
251
  };
205
252
  // ============================================================================
206
253
  // User-facing factory.
@@ -267,20 +314,216 @@ function bindRecord(record, mutations) {
267
314
  const nameValue = East.value(record.name, StringType);
268
315
  return recordBindPlatformFn([handleType], nameValue);
269
316
  }
317
+ /**
318
+ * An awaited write's outcome as the editing session's answer. A commit is
319
+ * applied at the record state it wrote, which a pinned source installs; a
320
+ * conflict carries the issues naming what went stale; anything else refused
321
+ * the write. A call that got no answer may have committed, so it throws: the
322
+ * session keeps the request, and its retry sends the same request id, which
323
+ * resolves to that commit rather than writing twice.
324
+ */
325
+ const settleWrite = East.function([RecordOutcomeType, ArrayType(Editing.Types.Issue)], Editing.Types.ApplyResult, ($, outcome, conflicts) => {
326
+ const result = $.let(variant("conflict", conflicts), Editing.Types.ApplyResult);
327
+ $.match(outcome, {
328
+ committed: ($, done) => { $.assign(result, variant("applied", { revision: some(done.stateHash) })); },
329
+ invalid: ($, refused) => {
330
+ $.assign(result, variant("rejected", [{ entry: "", row: none, field: none, message: refused.message }]));
331
+ },
332
+ failed: ($, refused) => {
333
+ $.assign(result, variant("rejected", [{ entry: "", row: none, field: none, message: East.str `The write failed: ${refused.stderr}` }]));
334
+ },
335
+ timed_out: ($, refused) => {
336
+ $.assign(result, variant("rejected", [{ entry: "", row: none, field: none, message: East.str `The write ran out of time after ${refused.ms} ms and wrote nothing` }]));
337
+ },
338
+ transport: ($, lost) => {
339
+ $.error(East.str `The write got no answer, so it may have committed — retry to find out: ${lost.message}`);
340
+ },
341
+ });
342
+ return result;
343
+ });
344
+ function applyToRecord(handle, options = {}) {
345
+ const fields = Expr.type(handle).fields;
346
+ const recordType = fields["read"].output;
347
+ if (recordType.type !== "Dict") {
348
+ throw new Error(`Record.onApply: an Apply writes a record's entries by key, so the record must be a Dict — ` +
349
+ `this one holds ${printType(recordType)}`);
350
+ }
351
+ const mutation = options.mutation ?? "patch";
352
+ const commits = fields["commit"];
353
+ const door = commits?.type === "Struct" ? commits.fields[mutation] : undefined;
354
+ if (door === undefined || !isTypeEqual(door, AsyncFunctionType([StringType, PatchType(recordType)], RecordOutcomeType))) {
355
+ throw new Error(`Record.onApply: "${mutation}" is not bound as this record's patch door — bind the record with ` +
356
+ `e3.mutation.patch(record${mutation === "patch" ? "" : `, "${mutation}"`}) among its mutations`);
357
+ }
358
+ // The handle's fields as the Apply reads them; entries are opaque here, as
359
+ // in Editing.apply, and their runtime types are exact.
360
+ const bound = handle;
361
+ const write = bound.commit[mutation];
362
+ // Who changed the record last, for a conflict's words. A conflict reads the
363
+ // history again before the write settles, so it is current.
364
+ const lastChange = East.function([], StringType, (_$) => bound.history().match({
365
+ some: (_$2, commits) => commits.tryGet(0n).match({
366
+ some: (_$3, head) => East.str ` — last changed by ${head.actor}`,
367
+ none: (_$3) => East.str ``,
368
+ }),
369
+ none: (_$2) => East.str ``,
370
+ }));
371
+ if ("entry" in options) {
372
+ const entryType = recordType.value;
373
+ const get = East.value(options.get);
374
+ const read = Expr.type(get);
375
+ if (read.type !== "Function" || read.inputs.length !== 1 || !isTypeEqual(read.inputs[0], entryType)
376
+ || read.output.type !== "Array" || read.output.value.type !== "Struct") {
377
+ throw new Error("Record.onApply: `get` must be an East function from the record's entry to an Array of row structs");
378
+ }
379
+ const rowType = read.output.value;
380
+ const rowsType = ArrayType(rowType);
381
+ const set = East.value(options.set);
382
+ const replace = Expr.type(set);
383
+ if (replace.type !== "Function" || replace.inputs.length !== 2 || !isTypeEqual(replace.inputs[0], entryType)
384
+ || !isTypeEqual(replace.inputs[1], rowsType) || !isTypeEqual(replace.output, entryType)) {
385
+ throw new Error("Record.onApply: `set` must be an East function from the record's entry and its new rows to the entry");
386
+ }
387
+ const entryKey = East.value(options.entry, recordType.key);
388
+ const apply = Editing.apply(rowType, options.idField);
389
+ return East.asyncFunction([Editing.Types.ChangeSet(rowType)], Editing.Types.ApplyResult, ($, batch) => {
390
+ const rowsOf = $.const(get);
391
+ const withRows = $.const(set);
392
+ const applyRows = $.const(apply);
393
+ const commit = $.const(write);
394
+ const settle = $.const(settleWrite);
395
+ const changedBy = $.const(lastChange);
396
+ const key = $.const(entryKey);
397
+ const result = $.let(variant("conflict", []), Editing.Types.ApplyResult);
398
+ $.match(batch.base, {
399
+ revision: ($) => {
400
+ $.assign(result, variant("rejected", [{ entry: "", row: none, field: none,
401
+ message: "Rows inside a record entry are checked against the rows the edit began from — a snapshot, never a revision" }]));
402
+ },
403
+ snapshot: ($, rows) => {
404
+ $.match(bound.read().tryGet(key), {
405
+ none: ($) => {
406
+ $.assign(result, variant("conflict", [{ entry: "", row: none, field: none,
407
+ message: East.str `The entry was removed since this edit began${changedBy()}` }]));
408
+ },
409
+ some: ($, current) => {
410
+ $.match(applyRows(rows, batch, none), {
411
+ conflict: ($, issues) => { $.assign(result, variant("conflict", issues)); },
412
+ applied: ($, next) => {
413
+ const now = $.const(rowsOf(current));
414
+ // Moved since the edit began — unless to this very edit's
415
+ // rows, which a retry after an unanswered write finds.
416
+ $.if(East.notEqual(now, rows).and(() => East.notEqual(now, next)), ($) => {
417
+ $.assign(result, variant("conflict", [{ entry: "", row: none, field: none,
418
+ message: East.str `The entry changed since this edit began${changedBy()}` }]));
419
+ }).else(($) => {
420
+ // The entry before and after the edit, each alone in a record:
421
+ // their diff reaches the entry's rows and nothing else.
422
+ const before = $.let(new Map(), recordType);
423
+ $(before.insert(key, withRows(current, rows)));
424
+ const after = $.let(new Map(), recordType);
425
+ $(after.insert(key, withRows(current, next)));
426
+ const outcome = $.const(commit(batch.requestId, East.diff(before, after)));
427
+ const conflicts = $.let([], ArrayType(Editing.Types.Issue));
428
+ $.match(outcome, {
429
+ conflict: ($) => {
430
+ $(conflicts.pushLast({ entry: "", row: none, field: none,
431
+ message: East.str `The entry changed since this edit began${changedBy()}` }));
432
+ },
433
+ });
434
+ $.assign(result, settle(outcome, conflicts));
435
+ });
436
+ },
437
+ });
438
+ },
439
+ });
440
+ },
441
+ });
442
+ return result;
443
+ });
444
+ }
445
+ const keyType = recordType.key;
446
+ const entryType = recordType.value;
447
+ const batchType = "keyed" in options && options.keyed === true
448
+ ? Editing.Types.ChangeSet(entryType, keyType)
449
+ : Editing.Types.ChangeSet(entryType);
450
+ // A change names its entry by the key's text: a String key is its own
451
+ // text, any other key its `.east` printing, read back here.
452
+ const keyOf = keyType.type === "String"
453
+ ? East.function([StringType], StringType, (_$, id) => id)
454
+ : East.function([StringType], keyType, (_$, id) => id.parse(keyType));
455
+ return East.asyncFunction([batchType], Editing.Types.ApplyResult, ($, batch) => {
456
+ const keyFrom = $.const(keyOf);
457
+ const commit = $.const(write);
458
+ const settle = $.const(settleWrite);
459
+ const changedBy = $.const(lastChange);
460
+ // Each change is its entry's insert, update or delete, restated by key.
461
+ // The values and entry patches are the batch's own, carrying what each
462
+ // entry was when the edit began, which the record checks.
463
+ const ops = $.let(new Map(), DictType(keyType, dictPatchOpsType(entryType)));
464
+ $.for(batch.changes, ($, change) => {
465
+ const key = $.const(keyFrom(change.id));
466
+ $.match(change.patch, {
467
+ replace: ($, swap) => {
468
+ $.match(swap.after, {
469
+ some: ($, after) => {
470
+ $.match(swap.before, {
471
+ none: ($) => { $(ops.insert(key, variant("insert", after))); },
472
+ some: ($, before) => { $(ops.insert(key, variant("update", East.diff(before, after)))); },
473
+ });
474
+ },
475
+ none: ($) => {
476
+ $.match(swap.before, { some: ($, before) => { $(ops.insert(key, variant("delete", before))); } });
477
+ },
478
+ });
479
+ },
480
+ patch: ($, entry) => {
481
+ $.match(entry, { some: ($, update) => { $(ops.insert(key, variant("update", update))); } });
482
+ },
483
+ });
484
+ });
485
+ const outcome = $.const(commit(batch.requestId, variant("patch", ops)));
486
+ const conflicts = $.let([], ArrayType(Editing.Types.Issue));
487
+ $.match(outcome, {
488
+ conflict: ($) => {
489
+ // The entries whose change no longer applies to the record as it
490
+ // stands are the ones another write moved.
491
+ const current = $.const(bound.read());
492
+ const by = $.const(changedBy());
493
+ $.for(batch.changes, ($, change) => {
494
+ const key = $.const(keyFrom(change.id));
495
+ $.try(($) => {
496
+ $(East.applyPatch(current.tryGet(key), change.patch));
497
+ }).catch(($) => {
498
+ $(conflicts.pushLast({ entry: change.id, row: none, field: none, message: East.str `Changed since this edit began${by}` }));
499
+ });
500
+ });
501
+ $.if(conflicts.size().equal(0n), ($) => {
502
+ $(conflicts.pushLast({ entry: "", row: none, field: none, message: East.str `The record changed since this edit began${by}` }));
503
+ });
504
+ },
505
+ });
506
+ return settle(outcome, conflicts);
507
+ });
508
+ }
270
509
  /**
271
510
  * The Record namespace — reactive record (read + mutate + history) binding for
272
- * e3 UI tasks.
511
+ * e3 UI tasks, and the Apply that commits an editable collection to a record.
273
512
  *
274
513
  * @remarks
275
514
  * `Record.bind` binds an `e3.record` and its mutations to a handle: `read` /
276
515
  * `status` / `history` observe the record's current state (served from the
277
516
  * shared dataset cache), and `mutate.<name>` applies a typed mutation
278
- * fire-and-forget under compare-and-swap, refreshing `read()` on commit.
517
+ * fire-and-forget under compare-and-swap, refreshing `read()` on commit;
518
+ * `commit.<name>` is the same write awaited. `Record.onApply` commits a
519
+ * Sheet's, a Plan's or a SnapGrid's batches to the record, each Apply one commit
520
+ * through its patch door.
279
521
  *
280
522
  * Use inside `Reactive.Root` for reactive re-rendering as the record and the
281
523
  * mutation lifecycle change.
282
524
  */
283
525
  export const Record = {
284
526
  bind: bindRecord,
527
+ onApply: applyToRecord,
285
528
  };
286
529
  //# sourceMappingURL=record.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/bind/record.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACH,IAAI,EACJ,SAAS,EACT,WAAW,EACX,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,+EAA+E;AAC/E,oCAAoC;AACpC,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;IAC9C,IAAI,EAAO,QAAQ;IACnB,OAAO,EAAI,QAAQ;IACnB,SAAS,EAAE,QAAQ;IACnB,MAAM,EAAK,QAAQ;IACnB,SAAS,EAAE,QAAQ;CACtB,CAAC,CAAC;AAKH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;IACtC,IAAI,EAAE,WAAW,CAAC;QACd,OAAO,EAAI,UAAU,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;QAC9C,MAAM,EAAK,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAChD,SAAS,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;QAC1C,QAAQ,EAAG,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAChD,SAAS,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;KACjD,CAAC;IACF,OAAO,EAAE,UAAU;IACnB,MAAM,EAAG,UAAU;CACtB,CAAC,CAAC;AAKH;;;;;;GAMG;AAC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AI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;oBAC1D,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;wBACX,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAA,gCAAgC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;oBAC/H,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;gBACH,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;oBACnC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAA,2CAA2C,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;gBACnI,CAAC,CAAC,CAAC;YACP,CAAC;SACJ,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,aAAa;CAChB,CAAC"}
@@ -0,0 +1,148 @@
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
+ * Bound data sources (#935) — the datasets a component may read, as the page
7
+ * that holds it binds them: each a name, the binding's descriptor, and the
8
+ * value's East type, read off the handle.
9
+ *
10
+ * A component handed `datasets={{ orders, customers, bom }}` reads exactly
11
+ * those, by those names. The bindings are already in the `ui()` task's
12
+ * manifest — `Data.bind` under `paths`, `Data.bindPaged` under `pages`,
13
+ * `Record.bind` under `records` — so scope needs nothing new, and each name's
14
+ * type is known before any request.
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ import { ArrayType, StringType, StructType, VariantType, type BooleanType, type ExprType, type FunctionType } from "@elaraai/east";
19
+ import type { BoundValue, PagedValue } from "./data.js";
20
+ import type { RecordBindingType } from "./record.js";
21
+ /**
22
+ * A data source a component may read: the name it reads it by, the binding it
23
+ * is, and its value's type.
24
+ *
25
+ * @property name - The name it is read by — a query's root field: `orders` for `.orders`
26
+ * @property source - The binding:
27
+ * - `paged` — a `Data.bindPaged` handle's `id`: its dataset's path, printed;
28
+ * - `record` — a `Record.bind` handle's record name;
29
+ * - `value` — a `Data.bind` handle's dataset path
30
+ * @property type - The value's East type, from the handle's own type
31
+ */
32
+ export declare const DataSourceType: StructType<{
33
+ readonly name: StringType;
34
+ readonly source: VariantType<{
35
+ readonly paged: StringType;
36
+ readonly record: StringType;
37
+ readonly value: ArrayType<VariantType<{
38
+ readonly field: StringType;
39
+ }>>;
40
+ }>;
41
+ readonly type: import("@elaraai/east").RecursiveType<VariantType<{
42
+ readonly Never: import("@elaraai/east").NullType;
43
+ readonly Null: import("@elaraai/east").NullType;
44
+ readonly Boolean: import("@elaraai/east").NullType;
45
+ readonly Integer: import("@elaraai/east").NullType;
46
+ readonly Float: import("@elaraai/east").NullType;
47
+ readonly String: import("@elaraai/east").NullType;
48
+ readonly DateTime: import("@elaraai/east").NullType;
49
+ readonly Blob: import("@elaraai/east").NullType;
50
+ readonly Ref: import("@elaraai/east").RecursiveTypeMarker;
51
+ readonly Array: import("@elaraai/east").RecursiveTypeMarker;
52
+ readonly Set: import("@elaraai/east").RecursiveTypeMarker;
53
+ readonly Dict: StructType<{
54
+ readonly key: import("@elaraai/east").RecursiveTypeMarker;
55
+ readonly value: import("@elaraai/east").RecursiveTypeMarker;
56
+ }>;
57
+ readonly Struct: ArrayType<StructType<{
58
+ readonly name: StringType;
59
+ readonly type: import("@elaraai/east").RecursiveTypeMarker;
60
+ }>>;
61
+ readonly Variant: ArrayType<StructType<{
62
+ readonly name: StringType;
63
+ readonly type: import("@elaraai/east").RecursiveTypeMarker;
64
+ }>>;
65
+ readonly Recursive: VariantType<{
66
+ readonly ref: import("@elaraai/east").IntegerType;
67
+ readonly wrapper: StructType<{
68
+ readonly id: import("@elaraai/east").IntegerType;
69
+ readonly inner: import("@elaraai/east").RecursiveTypeMarker;
70
+ }>;
71
+ }>;
72
+ readonly Function: StructType<{
73
+ readonly inputs: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
74
+ readonly output: import("@elaraai/east").RecursiveTypeMarker;
75
+ }>;
76
+ readonly AsyncFunction: StructType<{
77
+ readonly inputs: ArrayType<import("@elaraai/east").RecursiveTypeMarker>;
78
+ readonly output: import("@elaraai/east").RecursiveTypeMarker;
79
+ }>;
80
+ readonly Vector: import("@elaraai/east").RecursiveTypeMarker;
81
+ readonly Matrix: import("@elaraai/east").RecursiveTypeMarker;
82
+ }>>;
83
+ }>;
84
+ /** Type representing a data source a component may read. */
85
+ export type DataSourceType = typeof DataSourceType;
86
+ /**
87
+ * A binding a component may read as a data source: a `Data.bind`,
88
+ * `Data.bindPaged` or `Record.bind` handle, over any value type.
89
+ *
90
+ * @remarks
91
+ * The value type is `any` because a handle's East type is invariant in it: a
92
+ * `PagedValue<ArrayType<Order>>` is not a `PagedValue<EastType>`. Each
93
+ * source's type is read off its handle at build time ({@link dataSources}).
94
+ */
95
+ export type BoundSource = BoundValue<any> | PagedValue<any> | BoundRecordSource;
96
+ /**
97
+ * A `Record.bind` handle as a data source reads it, whatever mutations it is
98
+ * bound with: its `read`, its `mutate` — which tells it from a `Data.bind`
99
+ * handle — and its `binding`, which names the record.
100
+ */
101
+ type BoundRecordSource = ExprType<StructType<{
102
+ read: FunctionType<[], any>;
103
+ mutate: StructType<{
104
+ pending: FunctionType<[], BooleanType>;
105
+ }>;
106
+ binding: RecordBindingType;
107
+ }>>;
108
+ /**
109
+ * Refuses a data source's name that a jq program can't read as a root field.
110
+ *
111
+ * @param component - The component or function, for the message (`"Query.Builder"`)
112
+ * @param name - The data source's name
113
+ * @throws {Error} When the name is not letters, digits and `_`, not starting
114
+ * with a digit, naming it
115
+ */
116
+ export declare function assertRootField(component: string, name: string): void;
117
+ /**
118
+ * The data sources a component reads, from the bindings it is handed, in the
119
+ * order they are given.
120
+ *
121
+ * @remarks
122
+ * Each binding's kind is told by its handle's East struct: a `page` field is a
123
+ * `Data.bindPaged` handle, a `mutate` field a `Record.bind` handle, and any
124
+ * other a `Data.bind` handle. The descriptor is read off the handle as an East
125
+ * expression — `id`, `binding.name` or `binding.source` — and the value type
126
+ * is written as a literal from the handle's type: `read`'s output, or the
127
+ * element of `page`'s `Option`.
128
+ *
129
+ * @param component - The component, for the messages (`"Query.Builder"`)
130
+ * @param sources - Each data source's name and binding
131
+ * @returns An East expression of the data sources
132
+ * @throws {Error} When a name is not a jq identifier — letters, digits and
133
+ * `_`, not starting with a digit — naming it; when no source is given; and
134
+ * when a binding is not a `Data.bind`, `Data.bindPaged` or `Record.bind`
135
+ * handle
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const orders = $.let(Data.bindPaged(d.orders));
140
+ * const customers = $.let(Data.bind(d.customers));
141
+ * const sources = dataSources("Query.Builder", { orders, customers });
142
+ * // [{ name: "orders", source: paged(".inputs.orders"), type: … },
143
+ * // { name: "customers", source: value([inputs, customers]), type: … }]
144
+ * ```
145
+ */
146
+ export declare function dataSources(component: string, sources: Readonly<Record<string, BoundSource>>): ExprType<ArrayType<DataSourceType>>;
147
+ export {};
148
+ //# sourceMappingURL=sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../../../src/bind/sources.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;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