@composable-os/cli 0.1.0-beta.8 → 0.1.0-beta.9

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 (63) hide show
  1. package/dist/accounts-D6N77JGP.js +44 -0
  2. package/dist/{blocks-DEELKGDC.js → blocks-4CA4PP3P.js} +4 -4
  3. package/dist/{chunk-X6I2LWB3.js → chunk-2MLAPQU7.js} +1471 -359
  4. package/dist/{chunk-2S7375SC.js → chunk-3MIEYXRY.js} +3 -301
  5. package/dist/chunk-56A6RJIU.js +1040 -0
  6. package/dist/chunk-7CQGMVDO.js +63 -0
  7. package/dist/{chunk-STJZJIRA.js → chunk-7O4F3NU4.js} +1039 -1380
  8. package/dist/chunk-7U3OZLTK.js +1370 -0
  9. package/dist/{chunk-ZRWF6QZS.js → chunk-DU6OIFOU.js} +1 -0
  10. package/dist/chunk-E4WCYTCT.js +347 -0
  11. package/dist/{chunk-E5JLTLRM.js → chunk-GYTEW66E.js} +1 -1
  12. package/dist/chunk-LPD2VR5M.js +284 -0
  13. package/dist/chunk-NDKVIG23.js +2641 -0
  14. package/dist/chunk-NSSUOI3Z.js +333 -0
  15. package/dist/chunk-OV3OFYPI.js +746 -0
  16. package/dist/{chunk-KTXGEXTY.js → chunk-P6YZMS3F.js} +11 -5
  17. package/dist/{chunk-G3ORKXVP.js → chunk-RFJOPI42.js} +138 -14
  18. package/dist/{chunk-KOKYDJ7Z.js → chunk-RXRD34QW.js} +10 -8
  19. package/dist/{chunk-XDDBLYKW.js → chunk-STBMGUTM.js} +4613 -2307
  20. package/dist/chunk-VTQNOQGA.js +150 -0
  21. package/dist/chunk-XSE37HK5.js +426 -0
  22. package/dist/{chunk-LTQDLCP7.js → chunk-Z52IX5WL.js} +257 -845
  23. package/dist/chunk-ZSR5H4O7.js +552 -0
  24. package/dist/{cli-DTMGNDXN.js → cli-7A5XHYML.js} +16 -9
  25. package/dist/{cli-BRSACHSG.js → cli-T6MJM7TU.js} +20 -8
  26. package/dist/cli.js +4 -4
  27. package/dist/{client-repo-ZVZ6KW5S.js → client-repo-PC4ISVEZ.js} +4 -4
  28. package/dist/create.js +4 -4
  29. package/dist/{fields-64BQJA62.js → fields-L24XAIOA.js} +13 -11
  30. package/dist/invoke-TLYT6CFI.js +33 -0
  31. package/dist/order-IKQBUFCV.js +19 -0
  32. package/dist/{person-WMWRF2HV.js → person-DXEOOH2A.js} +9 -5
  33. package/dist/plan-on-sale-LRCK5MJG.js +24 -0
  34. package/dist/platform/migrations/0510_video_and_file_media.sql +109 -0
  35. package/dist/platform/migrations/0516_order_tax.sql +63 -0
  36. package/dist/platform/migrations/0530_subscriptions.sql +173 -0
  37. package/dist/platform/migrations/0531_subscription_trials.sql +56 -0
  38. package/dist/platform/migrations/0532_subscription_offers.sql +80 -0
  39. package/dist/platform/migrations/0533_allowances.sql +262 -0
  40. package/dist/platform/migrations/0560_recurring.sql +75 -0
  41. package/dist/platform/sdk/allowance.ts +508 -0
  42. package/dist/platform/sdk/capacity.ts +89 -0
  43. package/dist/platform/sdk/contract.ts +97 -1
  44. package/dist/platform/sdk/document.ts +161 -14
  45. package/dist/platform/sdk/field-types.ts +5 -0
  46. package/dist/platform/sdk/index.ts +3 -0
  47. package/dist/platform/sdk/manifest.ts +206 -5
  48. package/dist/platform/sdk/media.ts +62 -0
  49. package/dist/platform/sdk/recurring.ts +314 -0
  50. package/dist/platform/sdk/rich-text.ts +52 -4
  51. package/dist/platform/sdk/sellable.ts +120 -0
  52. package/dist/platform/sdk/states.ts +162 -1
  53. package/dist/platform/sdk/unique.ts +81 -0
  54. package/dist/run-BMSZKTN3.js +648 -0
  55. package/dist/run-GMQBAV6H.js +309 -0
  56. package/dist/{run-4JNFLYXV.js → run-TNHMG5RI.js} +51 -390
  57. package/dist/src-7DXXGZG2.js +38 -0
  58. package/dist/{src-J27WXNLY.js → src-BDG7PERB.js} +73 -1
  59. package/dist/visibility-XSBZTO66.js +33 -0
  60. package/package.json +2 -2
  61. package/dist/chunk-MAXLUQKB.js +0 -1287
  62. package/dist/invoke-NHHOLLF6.js +0 -26
  63. package/dist/src-G6OF5SKW.js +0 -31
@@ -1,28 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- product,
4
- productName
5
- } from "./chunk-6UWRT4VM.js";
3
+ defineOperation
4
+ } from "./chunk-VTQNOQGA.js";
6
5
  import {
7
- ACTORS,
8
6
  AUTOMATION_SETTINGS,
9
7
  BATCH_MAX,
10
- CompiledQuery,
11
- ConfigError,
12
- ConflictError,
13
8
  DRAFT_TARGET_ERRORS,
14
- FIELD_TYPE_REGISTRY,
15
- ForbiddenError,
16
9
  MAX_CASCADE_DEPTH,
17
- NotFoundError,
18
10
  OPS_BY_TYPE,
19
- OperationError,
20
- PERMISSIONS,
21
- PlanLimitError,
22
- RISK_CLASSES,
23
11
  RUN_STATUSES,
24
12
  TRASH_RETENTION_DAYS,
25
- ValidationError,
26
13
  WAITING_FOR_CONNECTIONS,
27
14
  assertUserExists,
28
15
  blankToNull,
@@ -31,40 +18,64 @@ import {
31
18
  connectionServes,
32
19
  declaredConnections,
33
20
  effectiveRails,
34
- fieldStorage,
35
21
  filterSchema,
36
- formulaFromStorage,
37
- ident,
22
+ holdsAccess,
38
23
  isTimeZone,
39
24
  jsonList,
40
- liveViewOf,
25
+ listInputSchema,
41
26
  loadAutomationSettings,
42
27
  loadBindings,
43
- loadGeneralSettings,
44
- newId,
45
28
  notifyStatements,
46
- objectTableOf,
29
+ pageSchema,
47
30
  parseSpec,
48
- refreshSchemaRegistry,
49
31
  restorableUntil,
50
32
  revokeBindingsPlan,
51
- roleHasPermission,
52
- sql,
53
- staffPrincipal,
33
+ runListQuery,
34
+ selectFields,
54
35
  triggerObject,
55
36
  unboundSlots,
56
37
  uniqueIds,
57
- viewColumnOf,
58
38
  withPrimary
59
- } from "./chunk-STJZJIRA.js";
39
+ } from "./chunk-56A6RJIU.js";
40
+ import {
41
+ CompiledQuery,
42
+ loadGeneralSettings,
43
+ newId,
44
+ releaseAllClaimsOfStatements
45
+ } from "./chunk-OV3OFYPI.js";
46
+ import {
47
+ product,
48
+ productName
49
+ } from "./chunk-6UWRT4VM.js";
50
+ import {
51
+ ConfigError,
52
+ ConflictError,
53
+ FIELD_TYPE_REGISTRY,
54
+ ForbiddenError,
55
+ NotFoundError,
56
+ OperationError,
57
+ PlanLimitError,
58
+ ValidationError,
59
+ fieldStorage,
60
+ formulaFromStorage,
61
+ objectTableOf,
62
+ ownedSource,
63
+ refreshSchemaRegistry,
64
+ roleHasPermission,
65
+ scopeOf,
66
+ sql,
67
+ unknownObject,
68
+ viewColumnOf,
69
+ visibleSource,
70
+ visibleTable
71
+ } from "./chunk-7O4F3NU4.js";
60
72
  import {
61
- BASE_TABLES,
62
73
  getObject,
63
74
  isCoreObject,
64
75
  listObjects,
65
76
  organisationObject,
66
77
  personObject
67
- } from "./chunk-2S7375SC.js";
78
+ } from "./chunk-3MIEYXRY.js";
68
79
  import {
69
80
  _enum,
70
81
  _instanceof,
@@ -89,472 +100,32 @@ import {
89
100
  toJSONSchema,
90
101
  union,
91
102
  unknown
92
- } from "./chunk-X6I2LWB3.js";
103
+ } from "./chunk-2MLAPQU7.js";
93
104
 
94
- // ../core/src/visibility/public.ts
95
- function publicProblems(object2) {
96
- const problems = readProblems(object2, "public");
97
- if (object2.public && object2.customer) {
98
- problems.unshift("an object declares customer or public, not both");
99
- }
100
- if (object2.public && object2.publishable) problems.push(...contentProblems(object2));
101
- return problems;
102
- }
103
- function contentProblems(object2) {
104
- const declared = object2.public;
105
- const publishable = object2.publishable;
106
- if (!declared || !publishable) return [];
107
- const problems = [];
108
- if (!publishable.slug) {
109
- problems.push("a publishable object the public reads names its slug (publishable.slug)");
110
- } else if (!declared.read.includes(publishable.slug)) {
111
- problems.push(`public.read lists the slug "${publishable.slug}": it is how the public reads`);
112
- }
113
- const content = new Set(publishable.content);
114
- for (const name4 of declared.read) {
115
- const field = object2.fields.find((f) => f.name === name4);
116
- if (field?.fieldType === "formula") {
117
- problems.push(`public.read lists "${name4}", a formula of the working copy`);
118
- }
119
- const path = field?.options?.documentPath;
120
- if (path && !content.has(path.field)) {
121
- problems.push(`public.read lists "${name4}", a path of a document that is not content`);
122
- }
123
- }
124
- if (object2.customer || object2.customerVia) {
125
- problems.push("a publishable object the public reads declares no customer or customerVia");
126
- }
127
- return problems;
128
- }
129
- function signedInProblems(object2) {
130
- const declared = object2.signedIn;
131
- if (!declared) return [];
132
- const problems = readProblems(object2, "signedIn");
133
- if (object2.public) problems.unshift("an object declares public or signedIn, not both");
134
- if (object2.customer) {
135
- for (const name4 of declared.read) {
136
- if (!object2.customer.read.includes(name4)) {
137
- problems.push(`signedIn.read lists "${name4}", which customer.read does not`);
138
- }
139
- }
140
- }
141
- return problems;
142
- }
143
- function readProblems(object2, key) {
144
- const declared = object2[key];
145
- if (!declared) return [];
146
- const problems = [];
147
- const field = (o, name4) => o.fields.find((f) => f.name === name4);
148
- if (new Set(declared.read).size !== declared.read.length) {
149
- problems.push(`${key}.read lists a field twice`);
150
- }
151
- for (const name4 of declared.read) {
152
- const f = field(object2, name4);
153
- if (!f) problems.push(`${key}.read lists "${name4}", which is not a field`);
154
- else if (!viewColumnOf(f)) problems.push(`${key}.read lists "${name4}", which has no column`);
155
- }
156
- const condition = resolveCondition(object2, declared, key);
157
- if (typeof condition === "string") problems.push(condition);
158
- return problems;
159
- }
160
- function resolveCondition(object2, declared, key = "public") {
161
- const { when } = declared;
162
- if (!when) return null;
163
- const fieldOf = (o, name4) => o.fields.find((f) => f.name === name4);
164
- if (when.via === void 0) {
165
- const own = fieldOf(object2, when.field);
166
- if (!own || own.fieldType !== "select" || !own.column) {
167
- return `${key}.when.field "${when.field}" must be a select field`;
168
- }
169
- return { column: own.column, values: [...when.in] };
170
- }
171
- const via = fieldOf(object2, when.via);
172
- const to = via?.options?.to;
173
- const target = to ? getObject(to) : void 0;
174
- if (!via || via.fieldType !== "relation" || via.options?.many || !via.column || !target) {
175
- return `${key}.when.via "${when.via}" must be a relation to one record`;
176
- }
177
- const tested = fieldOf(target, when.field);
178
- if (!tested || tested.fieldType !== "select" || !tested.column) {
179
- return `${key}.when.field "${when.field}" must be a select field of ${target.name}`;
180
- }
181
- return {
182
- column: via.column,
183
- values: [...when.in],
184
- via: { source: target.source, column: tested.column }
185
- };
186
- }
187
- function publicScope(object2) {
188
- return readScope(object2, "public");
189
- }
190
- function signedInScope(object2) {
191
- return readScope(object2, "signedIn");
192
- }
193
- function readScope(object2, key) {
194
- const declared = object2[key];
195
- if (!declared) return null;
196
- const problems = key === "public" ? publicProblems(object2) : signedInProblems(object2);
197
- if (problems.length) {
198
- throw new Error(`${object2.name}: invalid ${key} declaration: ${problems.join("; ")}`);
199
- }
200
- const readable = /* @__PURE__ */ new Set(["id", ...declared.read]);
201
- const fields = object2.fields.filter((f) => readable.has(f.name));
202
- const columns = [...new Set(fields.map((f) => viewColumnOf(f)))];
203
- return {
204
- kind: "public",
205
- from: key,
206
- fields,
207
- columns,
208
- condition: resolveCondition(object2, declared, key),
209
- declaration: declared,
210
- source: key === "public" && object2.publishable ? liveViewOf(object2.name) : object2.source
211
- };
212
- }
213
- function publicObject(object2, scope) {
214
- const names = new Set(scope.fields.map((f) => f.name));
215
- const sort = names.has(object2.defaultSort.field) ? object2.defaultSort : { field: "id", direction: "asc" };
216
- return {
217
- name: object2.name,
218
- label: object2.label,
219
- source: object2.source,
220
- fields: scope.fields,
221
- defaultSort: sort,
222
- ...object2.plural ? { plural: object2.plural } : {},
223
- ...object2.extension ? { extension: object2.extension } : {},
224
- ...object2.titleField && names.has(object2.titleField) ? { titleField: object2.titleField } : {},
225
- ...scope.from === "public" ? { public: scope.declaration } : { signedIn: scope.declaration }
226
- };
227
- }
228
-
229
- // ../core/src/visibility/customer.ts
230
- function customerProblems(object2) {
231
- const declared = object2.customer;
232
- if (!declared) return [];
233
- const problems = [];
234
- const field = (name4) => object2.fields.find((f) => f.name === name4);
235
- const owner = field(declared.field);
236
- if (!owner?.column) {
237
- problems.push(`customer.field "${declared.field}" is not a single-valued field`);
238
- } else if (object2.name === "person") {
239
- if (declared.field !== "id")
240
- problems.push("a person is their own customer: customer.field is id");
241
- } else if (owner.fieldType !== "relation" || owner.options?.to !== "person" || owner.options.many) {
242
- problems.push(`customer.field "${declared.field}" must be a relation to one person`);
243
- }
244
- for (const [key, names] of [
245
- ["read", declared.read],
246
- ["write", declared.write]
247
- ]) {
248
- if (new Set(names).size !== names.length) problems.push(`customer.${key} lists a field twice`);
249
- for (const name4 of names) {
250
- const f = field(name4);
251
- if (!f) problems.push(`customer.${key} lists "${name4}", which is not a field`);
252
- else if (!viewColumnOf(f))
253
- problems.push(`customer.${key} lists "${name4}", which has no column`);
254
- }
255
- }
256
- for (const name4 of declared.write) {
257
- if (name4 === declared.field) {
258
- problems.push("customer.write may not list the customer field: it is always the caller");
259
- }
260
- if (name4 === "id") problems.push("customer.write may not list id");
261
- if (field(name4)?.readOnly) problems.push(`customer.write lists "${name4}", which is read-only`);
262
- if (!declared.read.includes(name4)) {
263
- problems.push(`customer.write lists "${name4}", which customer.read does not`);
264
- }
265
- }
266
- return problems;
267
- }
268
- function customerScope(object2, personId3) {
269
- const declared = object2.customer;
270
- if (!declared) return null;
271
- const problems = customerProblems(object2);
272
- if (problems.length) {
273
- throw new Error(`${object2.name}: invalid customer declaration: ${problems.join("; ")}`);
274
- }
275
- const owner = object2.fields.find((f) => f.name === declared.field);
276
- const readable = /* @__PURE__ */ new Set(["id", ...declared.read]);
277
- const fields = object2.fields.filter((f) => readable.has(f.name));
278
- const columns = [...new Set(fields.map((f) => viewColumnOf(f)))];
279
- const shared = sharedPart(object2);
280
- return {
281
- kind: "customer",
282
- personId: personId3,
283
- column: owner.column,
284
- fields,
285
- columns,
286
- writable: new Set(declared.write),
287
- declaration: declared,
288
- ...shared ? { shared } : {}
289
- };
290
- }
291
- function sharedPart(object2) {
292
- const declared = object2.signedIn;
293
- if (!declared) return void 0;
294
- const problems = signedInProblems(object2);
295
- if (problems.length) {
296
- throw new Error(`${object2.name}: invalid signedIn declaration: ${problems.join("; ")}`);
297
- }
298
- const readable = /* @__PURE__ */ new Set(["id", ...declared.read]);
299
- const columns = new Set(
300
- object2.fields.filter((f) => readable.has(f.name)).map((f) => viewColumnOf(f))
105
+ // ../core/src/allowance/people.ts
106
+ function queueMergeAllowances(ctx, survivorId, mergedId) {
107
+ ctx.write(
108
+ ctx.db.updateTable("core_allowance").set({ person_id: survivorId, updated_at: ctx.now }).where("person_id", "=", mergedId),
109
+ ctx.db.updateTable("core_allowance_use").set({ person_id: survivorId }).where("person_id", "=", mergedId)
301
110
  );
302
- return {
303
- condition: resolveCondition(object2, declared, "signedIn"),
304
- columns
305
- };
306
- }
307
- function customerObject(object2, scope) {
308
- const names = new Set(scope.fields.map((f) => f.name));
309
- const sort = names.has(object2.defaultSort.field) ? object2.defaultSort : { field: "id", direction: "asc" };
310
- return {
311
- name: object2.name,
312
- label: object2.label,
313
- source: object2.source,
314
- fields: scope.fields,
315
- defaultSort: sort,
316
- ...object2.plural ? { plural: object2.plural } : {},
317
- ...object2.extension ? { extension: object2.extension } : {},
318
- ...object2.titleField && names.has(object2.titleField) ? { titleField: object2.titleField } : {},
319
- customer: scope.declaration
320
- };
321
- }
322
- function unknownObject(name4) {
323
- return new ValidationError(`Unknown object "${name4}"`, { object: name4 });
324
- }
325
-
326
- // ../core/src/visibility/via.ts
327
- function customerViaProblems(object2) {
328
- const declared = object2.customerVia;
329
- if (!declared) return [];
330
- const problems = [];
331
- if (object2.customer) {
332
- problems.push("an object that declares a customer cannot also declare customerVia");
333
- }
334
- if (new Set(declared.read).size !== declared.read.length) {
335
- problems.push("customerVia.read lists a field twice");
336
- }
337
- for (const name4 of declared.read) {
338
- const f = object2.fields.find((field) => field.name === name4);
339
- if (!f) problems.push(`customerVia.read lists "${name4}", which is not a field`);
340
- else if (!viewColumnOf(f)) {
341
- problems.push(`customerVia.read lists "${name4}", which has no column`);
342
- }
343
- }
344
- const link2 = resolveLink(object2, declared);
345
- if (typeof link2 === "string") problems.push(link2);
346
- return problems;
347
111
  }
348
- function resolveLink(object2, declared) {
349
- const from = getObject(declared.from);
350
- if (!from || from.name === object2.name || !object2.extension) {
351
- return `customerVia.from "${declared.from}" must be another object of the same extension`;
352
- }
353
- if (from.extension !== object2.extension) {
354
- return `customerVia.from "${declared.from}" must be an object of the same extension`;
355
- }
356
- const owner = from.customer ? from.fields.find((field) => field.name === from.customer?.field) : void 0;
357
- if (!from.customer || !owner?.column) {
358
- return `customerVia.from "${declared.from}" must declare a customer`;
359
- }
360
- const pointer = from.fields.find((field) => field.name === declared.field);
361
- if (!pointer?.column || pointer.fieldType !== "relation" || pointer.options?.many || pointer.options?.to !== object2.name) {
362
- return `customerVia.field "${declared.field}" must be a relation of ${from.name} to one ${object2.name}`;
363
- }
364
- if (!from.customer.read.includes(declared.field)) {
365
- return `customerVia.field "${declared.field}" must be one the customer of ${from.name} may read`;
366
- }
367
- return { source: from.source, pointer: pointer.column, owner: owner.column };
368
- }
369
- function customerViaScope(object2, personId3) {
370
- const declared = object2.customerVia;
371
- if (!declared) return null;
372
- const problems = customerViaProblems(object2);
373
- if (problems.length) {
374
- throw new Error(`${object2.name}: invalid customerVia declaration: ${problems.join("; ")}`);
375
- }
376
- const shared = signedInScope(object2) ?? publicScope(object2);
377
- const reached = /* @__PURE__ */ new Set(["id", ...declared.read]);
378
- const open = new Set(shared ? ["id", ...shared.declaration.read] : []);
379
- const fields = object2.fields.filter((f) => reached.has(f.name) || open.has(f.name));
380
- const columns = /* @__PURE__ */ new Map();
381
- for (const field of fields) {
382
- const column = viewColumnOf(field);
383
- const shownOn = !shared || reached.has(field.name) && open.has(field.name) ? "both" : reached.has(field.name) ? "reached" : "public";
384
- const before = columns.get(column);
385
- columns.set(column, before && before !== shownOn ? "both" : shownOn);
386
- }
387
- return {
388
- kind: "via",
389
- personId: personId3,
390
- fields,
391
- columns: [...columns].map(([column, shownOn]) => ({ column, shownOn })),
392
- link: resolveLink(object2, declared),
393
- public: shared,
394
- declaration: declared
395
- };
396
- }
397
- function viaObject(object2, scope) {
398
- const names = new Set(scope.fields.map((f) => f.name));
399
- const sort = names.has(object2.defaultSort.field) ? object2.defaultSort : { field: "id", direction: "asc" };
400
- return {
401
- name: object2.name,
402
- label: object2.label,
403
- source: object2.source,
404
- fields: scope.fields,
405
- defaultSort: sort,
406
- ...object2.plural ? { plural: object2.plural } : {},
407
- ...object2.extension ? { extension: object2.extension } : {},
408
- ...object2.titleField && names.has(object2.titleField) ? { titleField: object2.titleField } : {},
409
- customerVia: scope.declaration
410
- };
411
- }
412
-
413
- // ../core/src/visibility/index.ts
414
- var NONE = Object.freeze({ kind: "none" });
415
- function scopeOf(principal, given, throughOwnRecords = true) {
416
- const object2 = getObject(given.name) ?? given;
417
- switch (principal.kind) {
418
- case "staff":
419
- return { kind: "all" };
420
- case "customer":
421
- return customerScope(object2, principal.personId) ?? (throughOwnRecords ? customerViaScope(object2, principal.personId) : null) ?? signedInScope(object2) ?? publicScope(object2) ?? NONE;
422
- case "public":
423
- return publicScope(object2) ?? NONE;
424
- default:
425
- return NONE;
426
- }
427
- }
428
- function visibleObject(ctx, object2) {
429
- const definition = typeof object2 === "string" ? getObject(object2) : object2;
430
- if (!definition) throw unknownObject(String(object2));
431
- const scope = scopeOf(ctx.principal, definition);
432
- switch (scope.kind) {
433
- case "all":
434
- return definition;
435
- case "customer":
436
- return customerObject(definition, scope);
437
- case "public":
438
- return publicObject(definition, scope);
439
- case "via":
440
- return viaObject(definition, scope);
441
- case "none":
442
- throw unknownObject(definition.name);
443
- }
444
- }
445
- var CORE_SOURCES = {
446
- person: { view: "rec_person", table: "core_person" },
447
- organisation: { view: "rec_organisation", table: "core_organisation" },
448
- activity: { view: "rec_activity", table: "core_activity" },
449
- task: { view: "rec_task", table: "core_task" }
450
- };
451
- function resolve(object2) {
452
- if (typeof object2 !== "string") return object2;
453
- const definition = getObject(object2);
454
- if (!definition) throw new Error(`Unknown object ${object2}`);
455
- return definition;
456
- }
457
- function visibleSource(ctx, object2, alias) {
458
- const definition = resolve(object2);
459
- return sourceOf(scopeOf(ctx.principal, definition), definition, alias ?? definition.source);
460
- }
461
- function buyableSource(ctx, object2) {
462
- const definition = resolve(object2);
463
- return sourceOf(scopeOf(ctx.principal, definition, false), definition, definition.source);
464
- }
465
- function reachedWhere(scope) {
466
- const { link: link2 } = scope;
467
- return sql`id IN (SELECT ${sql.ref(link2.pointer)} FROM ${sql.table(link2.source)} WHERE ${sql.ref(link2.owner)} = ${scope.personId} AND ${sql.ref(link2.pointer)} IS NOT NULL)`;
468
- }
469
- function sourceOf(scope, definition, name4) {
470
- switch (scope.kind) {
471
- case "all":
472
- return sql`${sql.table(definition.source)}`.as(name4);
473
- case "customer": {
474
- const own = sql`${sql.ref(scope.column)} = ${scope.personId}`;
475
- if (!scope.shared) {
476
- const columns2 = sql.join(scope.columns.map((column) => sql.ref(column)));
477
- return sql`(SELECT ${columns2} FROM ${sql.table(definition.source)} WHERE ${own})`.as(
478
- name4
479
- );
480
- }
481
- const { shared } = scope;
482
- const columns = sql.join(
483
- scope.columns.map(
484
- (column) => shared.columns.has(column) ? sql.ref(column) : sql`CASE WHEN ${own} THEN ${sql.ref(column)} END AS ${sql.ref(column)}`
485
- )
486
- );
487
- return sql`(SELECT ${columns} FROM ${sql.table(definition.source)} WHERE ${own} OR ${conditionSql(shared.condition)})`.as(
488
- name4
489
- );
490
- }
491
- case "public": {
492
- const columns = sql.join(scope.columns.map((column) => sql.ref(column)));
493
- return sql`(SELECT ${columns} FROM ${sql.table(scope.source)} WHERE ${conditionSql(scope.condition)})`.as(
494
- name4
495
- );
496
- }
497
- case "via": {
498
- const reached = reachedWhere(scope);
499
- const shared = scope.public ? conditionSql(scope.public.condition) : null;
500
- const columns = sql.join(
501
- scope.columns.map(
502
- ({ column, shownOn }) => shownOn === "both" || !shared ? sql.ref(column) : sql`CASE WHEN ${shownOn === "reached" ? reached : shared} THEN ${sql.ref(column)} END AS ${sql.ref(column)}`
503
- )
504
- );
505
- const where = shared ? sql`(${reached}) OR (${shared})` : reached;
506
- return sql`(SELECT ${columns} FROM ${sql.table(definition.source)} WHERE ${where})`.as(
507
- name4
508
- );
509
- }
510
- case "none":
511
- throw unknownObject(definition.name);
512
- }
513
- }
514
- function previewSource(object2, id) {
515
- const definition = getObject(object2.name) ?? object2;
516
- const scope = publicScope(definition);
517
- if (!scope || !definition.publishable) throw unknownObject(definition.name);
518
- const columns = sql.join(scope.columns.map((column) => sql.ref(column)));
519
- return sql`(SELECT ${columns} FROM ${sql.table(definition.source)} WHERE id = ${id})`.as(
520
- definition.source
112
+ function queueEraseAllowances(ctx, personIds) {
113
+ if (!personIds.length) return;
114
+ const ids = JSON.stringify(personIds);
115
+ const people = sql`(SELECT value FROM json_each(${ids}))`;
116
+ ctx.write(
117
+ sql`UPDATE core_allowance_period SET used = used - (SELECT count(*) FROM core_allowance_use u WHERE u.returned_at IS NULL AND u.person_id IN ${people} AND u.object_type = core_allowance_period.object_type AND u.record_id = core_allowance_period.record_id AND u.period = core_allowance_period.period AND u.zone = core_allowance_period.zone), updated_at = ${ctx.now} WHERE (object_type, record_id, period, zone) IN (SELECT object_type, record_id, period, zone FROM core_allowance_use WHERE returned_at IS NULL AND person_id IN ${people})`.compile(
118
+ ctx.db
119
+ ),
120
+ sql`DELETE FROM core_allowance_use WHERE person_id IN ${people} OR (object_type, record_id) IN (SELECT object_type, record_id FROM core_allowance WHERE person_id IN ${people})`.compile(
121
+ ctx.db
122
+ ),
123
+ sql`DELETE FROM core_allowance_period WHERE (object_type, record_id) IN (SELECT object_type, record_id FROM core_allowance WHERE person_id IN ${people})`.compile(
124
+ ctx.db
125
+ ),
126
+ sql`DELETE FROM core_allowance WHERE person_id IN ${people}`.compile(ctx.db)
521
127
  );
522
128
  }
523
- function conditionSql(condition) {
524
- if (!condition) return sql`1 = 1`;
525
- const values = sql.join(condition.values.map((value) => sql`${value}`));
526
- return condition.via ? sql`${sql.ref(condition.column)} IN (SELECT id FROM ${sql.table(condition.via.source)} WHERE ${sql.ref(condition.via.column)} IN (${values}))` : sql`${sql.ref(condition.column)} IN (${values})`;
527
- }
528
- function ownedSource(ctx, object2, alias) {
529
- const scope = scopeOf(ctx.principal, object2);
530
- const name4 = alias ?? object2.source;
531
- switch (scope.kind) {
532
- case "all":
533
- return sql`${sql.table(object2.source)}`.as(name4);
534
- case "customer":
535
- return sql`(SELECT id FROM ${sql.table(object2.source)} WHERE ${sql.ref(scope.column)} = ${scope.personId})`.as(
536
- name4
537
- );
538
- default:
539
- throw unknownObject(object2.name);
540
- }
541
- }
542
- function visibleTable(ctx, object2, alias) {
543
- const definition = resolve(object2);
544
- const table2 = isCoreObject(definition.name) ? CORE_SOURCES[definition.name].table : Object.hasOwn(BASE_TABLES, definition.name) ? BASE_TABLES[definition.name] : objectTableOf(definition.name);
545
- if (!table2) throw new Error(`${definition.name} has no record table`);
546
- const scope = scopeOf(ctx.principal, definition);
547
- switch (scope.kind) {
548
- case "all":
549
- return sql`${sql.table(ident(table2))}`.as(alias ?? table2);
550
- default:
551
- throw unknownObject(definition.name);
552
- }
553
- }
554
- function orgReader(db) {
555
- return { db, principal: ORG_PRINCIPAL };
556
- }
557
- var ORG_PRINCIPAL = staffPrincipal({ id: "system", role: "admin" });
558
129
 
559
130
  // ../core/src/assignment/index.ts
560
131
  var ASSIGNMENT_OPS = ["eq", "in", "between", "is_null", "is_not_null"];
@@ -1233,262 +804,6 @@ async function assertRecordCapacity(db, adding) {
1233
804
  );
1234
805
  }
1235
806
 
1236
- // ../core/src/list.ts
1237
- var sortSchema = external_exports.object({
1238
- field: external_exports.string().min(1).max(64),
1239
- direction: external_exports.enum(["asc", "desc"]).default("asc")
1240
- });
1241
- var LIST_MAX_LIMIT = 200;
1242
- var LIST_DEFAULT_LIMIT = 50;
1243
- var listInputSchema = external_exports.object({
1244
- filter: filterSchema.optional().describe("Structured filter: { and | or: [...] } of { field, op, value }."),
1245
- sort: sortSchema.optional().describe("Sort field and direction. Defaults per object."),
1246
- cursor: external_exports.string().max(1e3).optional().describe("nextCursor from the previous page."),
1247
- limit: external_exports.number().int().min(1).max(LIST_MAX_LIMIT).default(LIST_DEFAULT_LIMIT),
1248
- fields: external_exports.array(external_exports.string().min(1).max(64)).max(100).optional().describe("Return only these fields of each item (id is always included).")
1249
- });
1250
- function pageSchema(item) {
1251
- return external_exports.object({ items: external_exports.array(item), nextCursor: external_exports.string().nullable() });
1252
- }
1253
- function base64UrlEncode(text3) {
1254
- const bytes = new TextEncoder().encode(text3);
1255
- let binary = "";
1256
- for (const byte of bytes) binary += String.fromCharCode(byte);
1257
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1258
- }
1259
- function base64UrlDecode(text3) {
1260
- const padded = text3.replace(/-/g, "+").replace(/_/g, "/");
1261
- const binary = atob(padded + "=".repeat((4 - padded.length % 4) % 4));
1262
- return new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0)));
1263
- }
1264
- function encodeCursor(payload) {
1265
- return base64UrlEncode(JSON.stringify(payload));
1266
- }
1267
- var cursorSchema = external_exports.object({
1268
- f: external_exports.string(),
1269
- d: external_exports.enum(["asc", "desc"]),
1270
- v: external_exports.union([external_exports.string(), external_exports.number(), external_exports.null()]),
1271
- id: external_exports.string()
1272
- });
1273
- function decodeCursor(cursor, sort) {
1274
- let payload;
1275
- try {
1276
- payload = cursorSchema.parse(JSON.parse(base64UrlDecode(cursor)));
1277
- } catch {
1278
- throw new ValidationError("Invalid cursor");
1279
- }
1280
- if (payload.f !== sort.field || payload.d !== sort.direction) {
1281
- throw new ValidationError("Cursor was issued for a different sort; start from the first page");
1282
- }
1283
- return payload;
1284
- }
1285
- function resolveSort(object2, sort) {
1286
- const resolved = sort ?? object2.defaultSort;
1287
- const field = object2.fields.find((f) => f.name === resolved.field);
1288
- if (!field) throw new ValidationError(`Unknown sort field "${resolved.field}"`);
1289
- if (!field.sortable || !field.column) {
1290
- throw new ValidationError(`${object2.name}.${resolved.field} is not sortable`);
1291
- }
1292
- return { sort: resolved, field };
1293
- }
1294
- function sortExpression(field, alias) {
1295
- const ref = sql.ref(`${alias}.${field.column}`);
1296
- return field.type === "text" ? sql`${ref} COLLATE NOCASE` : ref;
1297
- }
1298
- function afterCursor(field, alias, cursor) {
1299
- const col = sortExpression(field, alias);
1300
- const raw = sql.ref(`${alias}.${field.column}`);
1301
- const id = sql.ref(`${alias}.id`);
1302
- if (field.name === "id") {
1303
- return cursor.d === "asc" ? sql`${id} > ${cursor.id}` : sql`${id} < ${cursor.id}`;
1304
- }
1305
- if (cursor.d === "asc") {
1306
- return cursor.v === null ? sql`((${raw} IS NULL AND ${id} > ${cursor.id}) OR ${raw} IS NOT NULL)` : sql`(${col} > ${cursor.v} OR (${col} = ${cursor.v} AND ${id} > ${cursor.id}))`;
1307
- }
1308
- return cursor.v === null ? sql`(${raw} IS NULL AND ${id} < ${cursor.id})` : sql`(${col} < ${cursor.v} OR ${raw} IS NULL OR (${col} = ${cursor.v} AND ${id} < ${cursor.id}))`;
1309
- }
1310
- function indexOrdered(object2, field) {
1311
- return field.name === "id" || field.name === object2.defaultSort.field;
1312
- }
1313
- async function pageByIds(base, ordered, alias, column, take) {
1314
- const keys = await ordered.clearSelect().select([sql.ref(`${alias}.id`).as("id"), sql.ref(`${alias}.${column}`).as("sort_value")]).limit(take).execute();
1315
- if (!keys.length) return [];
1316
- const ids = keys.map((k) => k.id);
1317
- const rows = await base.where(
1318
- sql`${sql.ref(`${alias}.id`)} IN (SELECT value FROM json_each(${JSON.stringify(ids)}))`
1319
- ).execute();
1320
- const byId = new Map(rows.map((row) => [row.id, row]));
1321
- return ids.flatMap((id) => {
1322
- const row = byId.get(id);
1323
- return row ? [row] : [];
1324
- });
1325
- }
1326
- async function runListQuery(ctx, object2, input) {
1327
- const query = ctx.db.selectFrom(visibleSource(ctx, object2)).selectAll();
1328
- return pageQuery(query, visibleObject(ctx, object2), input, object2.source);
1329
- }
1330
- async function pageQuery(query, object2, input, alias = object2.source) {
1331
- const { sort, field } = resolveSort(object2, input.sort);
1332
- let q3 = query;
1333
- if (input.filter) q3 = q3.where(compileFilter(object2, input.filter, alias));
1334
- if (input.cursor) q3 = q3.where(afterCursor(field, alias, decodeCursor(input.cursor, sort)));
1335
- const direction = sql.raw(sort.direction === "asc" ? "ASC" : "DESC");
1336
- if (field.name !== "id") q3 = q3.orderBy(sql`${sortExpression(field, alias)} ${direction}`);
1337
- q3 = q3.orderBy(sql`${sql.ref(`${alias}.id`)} ${direction}`);
1338
- const limit2 = input.limit ?? LIST_DEFAULT_LIMIT;
1339
- const rows = indexOrdered(object2, field) ? await q3.limit(limit2 + 1).execute() : await pageByIds(query, q3, alias, field.column, limit2 + 1);
1340
- const page = rows.slice(0, limit2);
1341
- const last = page.at(-1);
1342
- let nextCursor = null;
1343
- if (rows.length > limit2 && last) {
1344
- const value = last[field.column];
1345
- nextCursor = encodeCursor({
1346
- f: sort.field,
1347
- d: sort.direction,
1348
- v: typeof value === "string" || typeof value === "number" ? value : null,
1349
- id: last.id
1350
- });
1351
- }
1352
- return { rows: page, nextCursor };
1353
- }
1354
- function selectFields(items, fields, allowed) {
1355
- if (!fields) return items;
1356
- const unknown2 = fields.filter((name4) => !allowed.includes(name4));
1357
- if (unknown2.length) throw new ValidationError(`Unknown fields: ${unknown2.join(", ")}`);
1358
- const keep = /* @__PURE__ */ new Set(["id", ...fields]);
1359
- return items.map(
1360
- (item) => Object.fromEntries(Object.entries(item).filter(([key]) => keep.has(key)))
1361
- );
1362
- }
1363
-
1364
- // ../core/src/audiences.ts
1365
- var AUDIENCES = ["staff", "customer", "public"];
1366
- var DEFAULT_AUDIENCES = Object.freeze(["staff"]);
1367
- var OUTSIDE_RISK_CLASSES = Object.freeze(["read", "write"]);
1368
- function audiencesOf(op) {
1369
- return op.audiences ?? DEFAULT_AUDIENCES;
1370
- }
1371
- function isOpenOutside(op) {
1372
- return audiencesOf(op).some((audience) => audience !== "staff");
1373
- }
1374
- function audienceOf(principal) {
1375
- return principal.kind;
1376
- }
1377
- function allowsAudience(op, principal) {
1378
- return audiencesOf(op).includes(audienceOf(principal));
1379
- }
1380
- function audienceProblems(op) {
1381
- const problems = [];
1382
- const declared = op.audiences;
1383
- if (declared !== void 0) {
1384
- if (!Array.isArray(declared) || declared.length === 0) {
1385
- problems.push("audiences must list at least one of staff, customer, public");
1386
- return problems;
1387
- }
1388
- if (declared.some((a) => !AUDIENCES.includes(a))) {
1389
- problems.push("audiences must be a subset of staff, customer, public");
1390
- return problems;
1391
- }
1392
- if (new Set(declared).size !== declared.length) problems.push("audiences lists one twice");
1393
- }
1394
- if (isOpenOutside(op) && !OUTSIDE_RISK_CLASSES.includes(op.risk)) {
1395
- const who = audiencesOf(op).filter((a) => a !== "staff");
1396
- problems.push(
1397
- `an operation open to ${who.join(" and ")} callers must have risk class read or write, not ${op.risk} (ADR 0402)`
1398
- );
1399
- }
1400
- return problems;
1401
- }
1402
- function packOf(name4) {
1403
- const [first, id] = name4.split(".");
1404
- return first === "x" && id ? id : void 0;
1405
- }
1406
- function forPacks(file, installed) {
1407
- return {
1408
- ...file,
1409
- operations: file.operations.filter((op) => {
1410
- const pack = op.pack ?? packOf(op.name);
1411
- return pack === void 0 || installed.includes(pack);
1412
- }).map(({ pack: _pack, ...op }) => op)
1413
- };
1414
- }
1415
-
1416
- // ../core/src/operation.ts
1417
- var AFTER_COMMIT = /* @__PURE__ */ Symbol("afterCommit");
1418
- function afterCommit(read) {
1419
- return { [AFTER_COMMIT]: read };
1420
- }
1421
- function isAfterCommit(value) {
1422
- return typeof value === "object" && value !== null && AFTER_COMMIT in value;
1423
- }
1424
- function runAfterCommit(value) {
1425
- return value[AFTER_COMMIT]();
1426
- }
1427
- function recordHostChange(ctx, change) {
1428
- (ctx.recordHostChange ?? ctx.recordChange)(change);
1429
- }
1430
- var HOST_TOOLS = /* @__PURE__ */ new WeakSet();
1431
- function markHostTool(op) {
1432
- HOST_TOOLS.add(op);
1433
- }
1434
- function isHostTool(op) {
1435
- return HOST_TOOLS.has(op);
1436
- }
1437
- var OPERATION_NAME_RE = /^[a-z][a-zA-Z0-9]*(\.[a-z][a-zA-Z0-9]*)+$/;
1438
- function defineOperation(definition) {
1439
- const problems = operationProblems(definition);
1440
- if (problems.length) {
1441
- throw new Error(`Operation ${definition.name}: ${problems.join("; ")}`);
1442
- }
1443
- return Object.freeze({ ...definition });
1444
- }
1445
- function operationProblems(op) {
1446
- const problems = [];
1447
- if (!OPERATION_NAME_RE.test(op.name ?? "")) problems.push("name must be <object>.<verb>");
1448
- if (typeof op.description !== "string" || op.description.trim().length < 20) {
1449
- problems.push("description must explain what it does, when to use it and side effects");
1450
- }
1451
- if (!op.input || typeof op.input.safeParse !== "function") problems.push("input schema missing");
1452
- if (!op.output || typeof op.output.safeParse !== "function") {
1453
- problems.push("output schema missing");
1454
- }
1455
- if (!PERMISSIONS.includes(op.permission)) problems.push("permission missing or unknown");
1456
- if (op.packPermission !== void 0) {
1457
- const extension = /^x\.([a-z][a-z0-9]{1,29})\./.exec(op.name ?? "")?.[1];
1458
- if (!extension) problems.push("packPermission is for extension tools only");
1459
- else if (!op.packPermission.startsWith(`${extension}:`)) {
1460
- problems.push(`packPermission is named ${extension}:<word>`);
1461
- }
1462
- }
1463
- if (!RISK_CLASSES.includes(op.risk)) problems.push("risk class missing or unknown");
1464
- if (op.actors && (op.actors.length === 0 || op.actors.some((a) => !ACTORS.includes(a)))) {
1465
- problems.push("actors must list known actor types");
1466
- }
1467
- if (typeof op.handler !== "function") problems.push("handler missing");
1468
- problems.push(...audienceProblems(op));
1469
- if (op.hostInternal !== void 0) {
1470
- if (op.hostInternal !== true) problems.push("hostInternal is true or left out");
1471
- if (op.name?.startsWith("x.")) problems.push("an extension tool can never be hostInternal");
1472
- if (!isOpenOutside(op)) {
1473
- problems.push("hostInternal is only for an operation open to customer or public callers");
1474
- }
1475
- }
1476
- if (op.toolOnly !== void 0) {
1477
- if (op.toolOnly !== true) problems.push("toolOnly is true or left out");
1478
- if (op.name?.startsWith("x.")) problems.push("an extension tool cannot be toolOnly");
1479
- if (!audiencesOf(op).includes("customer")) {
1480
- problems.push("toolOnly is only for an operation open to customer callers");
1481
- }
1482
- }
1483
- if (isOpenOutside(op) && op.alwaysReview) {
1484
- problems.push("an operation open to customer or public callers is never queued for review");
1485
- }
1486
- if ((op.risk === "bulk-write" || op.risk === "destructive") && op.name.endsWith("Many")) {
1487
- if (typeof op.bulkSize !== "function") problems.push("batch operations need bulkSize");
1488
- }
1489
- return problems;
1490
- }
1491
-
1492
807
  // ../core/src/records/tags.ts
1493
808
  var tagNameSchema = external_exports.string().trim().min(1).max(50);
1494
809
  var tagsInputSchema = external_exports.array(tagNameSchema).max(50).describe("Tag names. Unknown tags are created. Replaces the record's tags.");
@@ -1880,7 +1195,7 @@ async function relatedFacts(db, object2, id) {
1880
1195
  const facts2 = [];
1881
1196
  const ids = [];
1882
1197
  const refs = [];
1883
- const { listObjects: listObjects2 } = await import("./fields-64BQJA62.js");
1198
+ const { listObjects: listObjects2 } = await import("./fields-L24XAIOA.js");
1884
1199
  for (const def of listObjects2()) {
1885
1200
  if (!def.extension) continue;
1886
1201
  for (const field of def.fields) {
@@ -2209,15 +1524,15 @@ async function takeNextSlot(crm, settings, now) {
2209
1524
  return result.rows[0]?.id ?? null;
2210
1525
  }
2211
1526
  var DISPATCH_MAX = 32;
2212
- async function dispatchAgentJobs(crm, host2, now) {
2213
- if (!host2) return [];
1527
+ async function dispatchAgentJobs(crm, host3, now) {
1528
+ if (!host3) return [];
2214
1529
  const started = [];
2215
1530
  try {
2216
1531
  const settings = await loadAgentSettings(crm.query);
2217
1532
  for (let i = 0; i < DISPATCH_MAX; i += 1) {
2218
1533
  const id = await takeNextSlot(crm, settings, now);
2219
1534
  if (!id) break;
2220
- await host2.begin(id);
1535
+ await host3.begin(id);
2221
1536
  started.push(id);
2222
1537
  }
2223
1538
  } catch (error) {
@@ -2257,10 +1572,10 @@ async function queueScrubAgentJobs(ctx, subject) {
2257
1572
  ).execute();
2258
1573
  const live = rows.filter((r) => LIVE_STATES.includes(r.state));
2259
1574
  if (live.length && !ctx.simulation) {
2260
- const host2 = ctx.agentJobs;
2261
- if (host2) {
1575
+ const host3 = ctx.agentJobs;
1576
+ if (host3) {
2262
1577
  for (const batch of chunk(live, PARALLEL)) {
2263
- await Promise.all(batch.map((row) => host2.scrub(row.id, scrub)));
1578
+ await Promise.all(batch.map((row) => host3.scrub(row.id, scrub)));
2264
1579
  }
2265
1580
  } else if (live.some((row) => mentions(row, pattern))) {
2266
1581
  throw new ConfigError(
@@ -4701,7 +4016,7 @@ async function safeParseJSON({ text: text3, schema }) {
4701
4016
  };
4702
4017
  }
4703
4018
  }
4704
- async function resolve2(value) {
4019
+ async function resolve(value) {
4705
4020
  if (typeof value === "function") value = value();
4706
4021
  return value;
4707
4022
  }
@@ -5411,7 +4726,7 @@ var object$1 = ({ schema: inputSchema, name: name4, description }) => {
5411
4726
  const schema = asSchema(inputSchema);
5412
4727
  return {
5413
4728
  name: "object",
5414
- responseFormat: resolve2(schema.jsonSchema).then((jsonSchema2) => ({
4729
+ responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
5415
4730
  type: "json",
5416
4731
  schema: jsonSchema2,
5417
4732
  ...name4 != null && { name: name4 },
@@ -5473,7 +4788,7 @@ var array$1 = ({ element: inputElementSchema, minItems, maxItems, name: name4, d
5473
4788
  const elementSchema = asSchema(inputElementSchema);
5474
4789
  return {
5475
4790
  name: "array",
5476
- responseFormat: resolve2(elementSchema.jsonSchema).then((jsonSchema2) => {
4791
+ responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
5477
4792
  const { $schema: _$schema, definitions, $defs, ...itemSchema } = jsonSchema2;
5478
4793
  return {
5479
4794
  type: "json",
@@ -6509,6 +5824,25 @@ var searchGlobal = defineOperation({
6509
5824
  });
6510
5825
  var searchOperations = [searchGlobal];
6511
5826
 
5827
+ // ../core/src/records/stream.ts
5828
+ var PLAYBACK_MAX_SECONDS = 3600;
5829
+ var UPLOAD_ADDRESS_SECONDS = 6 * 3600;
5830
+ var BASIC_UPLOAD_MAX_BYTES = 200 * 1e3 * 1e3;
5831
+ var TUS_CHUNK_BYTES = 200 * 256 * 1024;
5832
+ var host;
5833
+ function videoHost() {
5834
+ return host;
5835
+ }
5836
+ function requireVideoHost() {
5837
+ if (!host) {
5838
+ throw new OperationError("config", "Video is not configured here: set up Cloudflare Stream", {
5839
+ reason: "stream_not_configured"
5840
+ });
5841
+ }
5842
+ return host;
5843
+ }
5844
+ var encoder3 = new TextEncoder();
5845
+
6512
5846
  // ../core/src/records/erase-log.ts
6513
5847
  var ERASE_LOG_PREFIX = "erase-log/";
6514
5848
  async function sha256Ref(value) {
@@ -6591,10 +5925,33 @@ async function planReapply(db, entries) {
6591
5925
  var BLOB_DRAIN_BATCH = 100;
6592
5926
  var BLOB_MAX_ATTEMPTS = 10;
6593
5927
  var BODY_PREFIX = "email-bodies/";
5928
+ var STREAM_PREFIX = "stream/";
6594
5929
  async function drainBlobDeletions(db, blobs, limit2 = BLOB_DRAIN_BATCH) {
6595
- const rows = await db.selectFrom("core_blob_deletion").select("key").where("attempts", "<", BLOB_MAX_ATTEMPTS).orderBy("attempts").orderBy("queued_at").limit(limit2).execute();
5930
+ const stream = videoHost()?.provider;
5931
+ let pending = db.selectFrom("core_blob_deletion").select("key").where("attempts", "<", BLOB_MAX_ATTEMPTS);
5932
+ if (!stream) pending = pending.where("key", "not like", `${STREAM_PREFIX}%`);
5933
+ const rows = await pending.orderBy("attempts").orderBy("queued_at").limit(limit2).execute();
6596
5934
  if (!rows.length) return { deleted: 0, kept: 0, failed: 0 };
6597
- const keys = rows.map((r) => r.key);
5935
+ const streamed = rows.map((r) => r.key).filter((k) => k.startsWith(STREAM_PREFIX));
5936
+ let streamFailed = 0;
5937
+ let streamDeleted = 0;
5938
+ if (stream) {
5939
+ for (const key of streamed) {
5940
+ try {
5941
+ await stream.delete(key.slice(STREAM_PREFIX.length));
5942
+ await db.deleteFrom("core_blob_deletion").where("key", "=", key).execute();
5943
+ streamDeleted += 1;
5944
+ } catch (error) {
5945
+ streamFailed += 1;
5946
+ await db.updateTable("core_blob_deletion").set({
5947
+ attempts: sql`attempts + 1`,
5948
+ last_error: error instanceof Error ? error.name : "error"
5949
+ }).where("key", "=", key).execute();
5950
+ }
5951
+ }
5952
+ }
5953
+ const keys = rows.map((r) => r.key).filter((k) => !k.startsWith(STREAM_PREFIX));
5954
+ if (!keys.length) return { deleted: streamDeleted, kept: 0, failed: streamFailed };
6598
5955
  const externals = keys.filter((k) => k.startsWith(BODY_PREFIX)).map((k) => {
6599
5956
  try {
6600
5957
  return decodeURIComponent(k.slice(BODY_PREFIX.length));
@@ -6611,10 +5968,18 @@ async function drainBlobDeletions(db, blobs, limit2 = BLOB_DRAIN_BATCH) {
6611
5968
  } catch (error) {
6612
5969
  const message = error instanceof Error ? error.name : "error";
6613
5970
  await db.updateTable("core_blob_deletion").set({ attempts: sql`attempts + 1`, last_error: message }).where("key", "in", jsonList(doomed)).execute();
6614
- return { deleted: 0, kept: keys.length - doomed.length, failed: doomed.length };
5971
+ return {
5972
+ deleted: streamDeleted,
5973
+ kept: keys.length - doomed.length,
5974
+ failed: doomed.length + streamFailed
5975
+ };
6615
5976
  }
6616
5977
  await db.deleteFrom("core_blob_deletion").where("key", "in", jsonList(keys)).execute();
6617
- return { deleted: doomed.length, kept: keys.length - doomed.length, failed: 0 };
5978
+ return {
5979
+ deleted: doomed.length + streamDeleted,
5980
+ kept: keys.length - doomed.length,
5981
+ failed: streamFailed
5982
+ };
6618
5983
  }
6619
5984
  async function drainAllBlobDeletions(db, blobs, rounds = 5) {
6620
5985
  let deleted = 0;
@@ -10240,7 +9605,7 @@ var automationBindingOperations = [
10240
9605
  // ../core/src/operations/automation.ts
10241
9606
  var DAY_MS3 = 864e5;
10242
9607
  var ROUTINE_EXTENSION = "routine";
10243
- function host(ctx) {
9608
+ function host2(ctx) {
10244
9609
  if (!ctx.automationHost) {
10245
9610
  throw new ConfigError("The automation runtime (cos-runner) is not available to this caller");
10246
9611
  }
@@ -10469,7 +9834,7 @@ var automationTest = defineOperation({
10469
9834
  { object: "automation", id: input.id }
10470
9835
  );
10471
9836
  });
10472
- const report2 = await host(ctx).testAutomation({
9837
+ const report2 = await host2(ctx).testAutomation({
10473
9838
  automationId: input.id,
10474
9839
  ...record3,
10475
9840
  userId: ctx.user.id
@@ -10477,7 +9842,7 @@ var automationTest = defineOperation({
10477
9842
  return { report: report2 };
10478
9843
  }
10479
9844
  const draft = await proposedAutomation(ctx, input.proposal);
10480
- const report = await host(ctx).testAutomation({ draft, ...record3, userId: ctx.user.id });
9845
+ const report = await host2(ctx).testAutomation({ draft, ...record3, userId: ctx.user.id });
10481
9846
  if (!report.ok && report.error && DRAFT_TARGET_ERRORS.includes(report.error.code)) {
10482
9847
  throw new ValidationError(report.error.message, {
10483
9848
  code: report.error.code,
@@ -10612,7 +9977,7 @@ async function toRunItems(db, rows) {
10612
9977
  finishedAt: r.finished_at
10613
9978
  }));
10614
9979
  }
10615
- function decodeCursor2(cursor) {
9980
+ function decodeCursor(cursor) {
10616
9981
  if (!cursor) return null;
10617
9982
  const at = cursor.indexOf("|");
10618
9983
  return at > 0 ? { at: cursor.slice(0, at), id: cursor.slice(at + 1) } : null;
@@ -10639,7 +10004,7 @@ var automationRuns = defineOperation({
10639
10004
  if (input.id) q3 = q3.where("r.automation_id", "=", input.id);
10640
10005
  if (input.status) q3 = q3.where("r.status", "=", input.status);
10641
10006
  if (!input.includeTests && !input.runId) q3 = q3.where("r.test", "=", 0);
10642
- const cursor = decodeCursor2(input.cursor);
10007
+ const cursor = decodeCursor(input.cursor);
10643
10008
  if (cursor) {
10644
10009
  q3 = q3.where(
10645
10010
  (eb) => eb.or([
@@ -10680,7 +10045,7 @@ var automationRun = defineOperation({
10680
10045
  if (row.removed_at || !row.enabled) {
10681
10046
  throw new ValidationError(`${input.id} is not enabled`, { id: input.id });
10682
10047
  }
10683
- return host(ctx).startManualRun({
10048
+ return host2(ctx).startManualRun({
10684
10049
  automationId: input.id,
10685
10050
  trigger: "manual",
10686
10051
  userId: ctx.user.id,
@@ -10700,7 +10065,7 @@ function runOperation(name4, description, call) {
10700
10065
  async handler(input, ctx) {
10701
10066
  const run = await ctx.db.selectFrom("core_automation_runs").select(["id", "status"]).where("id", "=", input.runId).where("extension_id", "!=", ROUTINE_EXTENSION).executeTakeFirst();
10702
10067
  if (!run) throw new NotFoundError("automation run", input.runId);
10703
- return call(host(ctx), input.runId);
10068
+ return call(host2(ctx), input.runId);
10704
10069
  }
10705
10070
  });
10706
10071
  }
@@ -11469,6 +10834,7 @@ var TEXT_TYPES = /* @__PURE__ */ new Set([
11469
10834
  "document",
11470
10835
  "richText",
11471
10836
  "image",
10837
+ "video",
11472
10838
  "slug"
11473
10839
  ]);
11474
10840
  var IDENT = /^[a-z][a-z0-9_]*$/;
@@ -11542,6 +10908,9 @@ async function queueEraseExtensions(ctx, s) {
11542
10908
  const id = String(row.id);
11543
10909
  rows += 1;
11544
10910
  handled.add(`${table2}|${id}`);
10911
+ if (object2 && getObject(object2)?.claims) {
10912
+ ctx.write(...releaseAllClaimsOfStatements(object2, id, ctx.now));
10913
+ }
11545
10914
  if (def.required && !def.many && object2) {
11546
10915
  deleted.push({ object: object2, id });
11547
10916
  ctx.write(CompiledQuery.raw(`DELETE FROM ${q(table2)} WHERE id = ?`, [id]));
@@ -11671,7 +11040,7 @@ async function queueEraseExtensions(ctx, s) {
11671
11040
  return rows;
11672
11041
  }
11673
11042
  function scrubField(value, type, m, pattern) {
11674
- if (type === "document" || type === "richText" || type === "image") {
11043
+ if (type === "document" || type === "richText" || type === "image" || type === "video") {
11675
11044
  return scrubDocument(value, m, pattern);
11676
11045
  }
11677
11046
  if (m.identifies(value)) return null;
@@ -11885,6 +11254,9 @@ async function queueEraseOrders(ctx, s) {
11885
11254
  if (s.object !== "person") return 0;
11886
11255
  const ids = jsonList(s.recordIds);
11887
11256
  const addresses = jsonList(s.addresses.length ? s.addresses.map((a) => a.toLowerCase()) : [""]);
11257
+ ctx.write(
11258
+ ctx.db.deleteFrom("core_subscription_offer").where((eb) => eb.or([eb("person_id", "in", ids), eb("email", "in", addresses)]))
11259
+ );
11888
11260
  const orders = await ctx.db.selectFrom("core_order").select("id").where((eb) => eb.or([eb("person_id", "in", ids), eb("email", "in", addresses)])).execute();
11889
11261
  for (const part of chunk(orders.map((o) => o.id))) {
11890
11262
  ctx.write(
@@ -12062,6 +11434,7 @@ async function queueErase(ctx, request) {
12062
11434
  await queueEraseRoutines(ctx, { terms: [...terms], names: [...subject.names] });
12063
11435
  const eraseRequests = await queueEraseCustomers(ctx, subject);
12064
11436
  await queueEraseOrders(ctx, subject);
11437
+ if (subject.object === "person") queueEraseAllowances(ctx, [...recordIds]);
12065
11438
  if (!ctx.simulation) await writeEraseLog(ctx, subject);
12066
11439
  const subjectIds = jsonList(recordIds);
12067
11440
  ctx.write(
@@ -14342,7 +13715,7 @@ var CHUNK = 500;
14342
13715
  var CHANGED_CHUNK = 200;
14343
13716
  var CHUNKS_PER_CALL = 20;
14344
13717
  var GROUP_MAX = 50;
14345
- var cursorSchema2 = external_exports.object({ at: external_exports.string(), id: external_exports.string() });
13718
+ var cursorSchema = external_exports.object({ at: external_exports.string(), id: external_exports.string() });
14346
13719
  var fullSchema = external_exports.object({
14347
13720
  startedAt: external_exports.string(),
14348
13721
  phase: external_exports.number().int().min(0),
@@ -14355,8 +13728,8 @@ var scanStateSchema = external_exports.object({
14355
13728
  done: external_exports.boolean().default(false)
14356
13729
  }).default({ person: null, organisation: null, done: false }),
14357
13730
  cursors: external_exports.object({
14358
- person: cursorSchema2.nullable().default(null),
14359
- organisation: cursorSchema2.nullable().default(null)
13731
+ person: cursorSchema.nullable().default(null),
13732
+ organisation: cursorSchema.nullable().default(null)
14360
13733
  }).default({ person: null, organisation: null }),
14361
13734
  full: fullSchema.nullable().default(null),
14362
13735
  needsFull: external_exports.boolean().default(true),
@@ -14860,6 +14233,44 @@ async function queueMergeCustomers(ctx, survivorId, mergedId, addresses) {
14860
14233
  );
14861
14234
  }
14862
14235
 
14236
+ // ../core/src/orders/merge.ts
14237
+ function queueMergeOrders(ctx, survivorId, mergedId) {
14238
+ ctx.write(
14239
+ ctx.db.updateTable("core_order").set({ person_id: survivorId, updated_at: ctx.now }).where("person_id", "=", mergedId)
14240
+ );
14241
+ }
14242
+
14243
+ // ../core/src/subscriptions/merge.ts
14244
+ async function queueMergeSubscriptions(ctx, survivorId, mergedId) {
14245
+ const rows = await ctx.db.selectFrom("core_subscription_trial").select(["checkout_id", "holder_person_id", "plan_object", "used_at", "created_at"]).where("holder_person_id", "in", [survivorId, mergedId]).execute();
14246
+ const drop = [];
14247
+ const byPlan = /* @__PURE__ */ new Map();
14248
+ for (const row of rows)
14249
+ byPlan.set(row.plan_object, [...byPlan.get(row.plan_object) ?? [], row]);
14250
+ for (const group of byPlan.values()) {
14251
+ const holders = new Set(group.map((r) => r.holder_person_id));
14252
+ if (holders.size < 2) continue;
14253
+ const used = group.filter((r) => r.used_at !== null);
14254
+ const pool = used.length ? used : group;
14255
+ const keep = [...pool].sort(
14256
+ (a, b) => (a.used_at ?? a.created_at).localeCompare(b.used_at ?? b.created_at)
14257
+ )[0];
14258
+ for (const r of group) if (r.checkout_id !== keep?.checkout_id) drop.push(r.checkout_id);
14259
+ }
14260
+ ctx.write(
14261
+ ctx.db.updateTable("core_subscription").set({ payer_person_id: survivorId }).where("payer_person_id", "=", mergedId),
14262
+ ctx.db.updateTable("core_subscription").set({ holder_person_id: survivorId }).where("holder_person_id", "=", mergedId),
14263
+ ctx.db.updateTable("core_subscription_checkout").set({ payer_person_id: survivorId }).where("payer_person_id", "=", mergedId),
14264
+ ctx.db.updateTable("core_subscription_checkout").set({ holder_person_id: survivorId }).where("holder_person_id", "=", mergedId),
14265
+ ...drop.length ? [ctx.db.deleteFrom("core_subscription_trial").where("checkout_id", "in", drop)] : [],
14266
+ ctx.db.updateTable("core_subscription_trial").set({ holder_person_id: survivorId }).where("holder_person_id", "=", mergedId),
14267
+ // Continuation offers (ADR 0491): still tied to their address, now the survivor's Person. One
14268
+ // is taken only by a customer signed in as that address, so an offer under an address the
14269
+ // survivor's account does not sign in with waits for staff to import it under that one.
14270
+ ctx.db.updateTable("core_subscription_offer").set({ person_id: survivorId, version: sql`version + 1` }).where("person_id", "=", mergedId)
14271
+ );
14272
+ }
14273
+
14863
14274
  // ../core/src/diff.ts
14864
14275
  function stable(value) {
14865
14276
  return JSON.stringify(value, (_key, v) => {
@@ -14984,8 +14395,21 @@ async function assertRelationsVisible(reader, object2, values) {
14984
14395
  if (unseen !== void 0) throw missing(unseen);
14985
14396
  }
14986
14397
  }
14398
+ async function assertAccessRequired(reader, object2, values, existing) {
14399
+ const required = object2.customer?.requireAccess ?? [];
14400
+ for (const name4 of required) {
14401
+ const field = object2.fields.find((f) => f.name === name4);
14402
+ const to = field?.options?.to;
14403
+ const target = to ? getObject(to) : void 0;
14404
+ const pointed = Object.hasOwn(values, name4) ? values[name4] : existing?.[name4];
14405
+ const id = pointed === null || pointed === void 0 ? null : String(pointed);
14406
+ if (!target || !id) throw new NotFoundError(to ?? name4, id ?? "");
14407
+ const held = await holdsAccess(reader, target, [id]);
14408
+ if (!held.has(id)) throw new NotFoundError(target.name, id);
14409
+ }
14410
+ }
14987
14411
  async function recording(writer, write) {
14988
- const host2 = Object.create(writer.host, {
14412
+ const host3 = Object.create(writer.host, {
14989
14413
  recordChange: {
14990
14414
  value: (change) => {
14991
14415
  writer.mark(change);
@@ -14993,7 +14417,7 @@ async function recording(writer, write) {
14993
14417
  }
14994
14418
  }
14995
14419
  });
14996
- return write(host2);
14420
+ return write(host3);
14997
14421
  }
14998
14422
  async function createVisible(writer, name4, values) {
14999
14423
  const { object: object2, scope } = customerScopeFor(writer, name4);
@@ -15002,9 +14426,10 @@ async function createVisible(writer, name4, values) {
15002
14426
  throw new ForbiddenError(`A customer cannot create a ${object2.name}`);
15003
14427
  }
15004
14428
  await assertRelationsVisible(writer.reader, object2, values);
14429
+ await assertAccessRequired(writer.reader, object2, values, null);
15005
14430
  const owned = { ...values, [scope.declaration.field]: scope.personId };
15006
14431
  const create = recordWriter.create;
15007
- return { id: await recording(writer, (host2) => create(host2, object2, owned)) };
14432
+ return { id: await recording(writer, (host3) => create(host3, object2, owned)) };
15008
14433
  }
15009
14434
  async function updateVisible(writer, name4, id, values, options = {}) {
15010
14435
  const { object: object2, scope } = customerScopeFor(writer, name4);
@@ -15012,10 +14437,20 @@ async function updateVisible(writer, name4, id, values, options = {}) {
15012
14437
  const row = await writer.reader.db.selectFrom(ownedSource(writer.reader, object2)).select("id").where("id", "=", id).executeTakeFirst();
15013
14438
  if (!row) throw new NotFoundError(object2.name, id);
15014
14439
  await assertRelationsVisible(writer.reader, object2, values);
14440
+ if (object2.customer?.requireAccess?.length) {
14441
+ const current = await writer.reader.db.selectFrom(visibleSource(writer.reader, object2)).selectAll().where("id", "=", id).executeTakeFirst();
14442
+ const existing = {};
14443
+ for (const name5 of object2.customer.requireAccess) {
14444
+ const field = object2.fields.find((f) => f.name === name5);
14445
+ const column = field ? viewColumnOf(field) : null;
14446
+ existing[name5] = column && current ? current[column] : null;
14447
+ }
14448
+ await assertAccessRequired(writer.reader, object2, values, existing);
14449
+ }
15015
14450
  const update = coreWriters.get(object2.name)?.update ?? (isCoreObject(object2.name) ? null : recordWriter?.update);
15016
14451
  if (!update) throw new OperationError("internal", `No writer for ${object2.name}`);
15017
14452
  const from = options.from === void 0 ? {} : { from: options.from };
15018
- await recording(writer, (host2) => update(host2, object2, id, values, from));
14453
+ await recording(writer, (host3) => update(host3, object2, id, values, from));
15019
14454
  }
15020
14455
 
15021
14456
  // ../core/src/operations/affiliation.ts
@@ -16087,6 +15522,9 @@ var personMerge = defineOperation({
16087
15522
  await queueMergeCustomers(ctx, survivor.id, merged.id, [
16088
15523
  ...new Set([...survivor.emails, ...merged.emails].map((e) => e.email))
16089
15524
  ]);
15525
+ queueMergeOrders(ctx, survivor.id, merged.id);
15526
+ await queueMergeSubscriptions(ctx, survivor.id, merged.id);
15527
+ queueMergeAllowances(ctx, survivor.id, merged.id);
16090
15528
  const emailSet = new Set(survivor.emails.map((e) => e.email));
16091
15529
  after.emails = [
16092
15530
  ...survivor.emails,
@@ -16236,62 +15674,6 @@ var personOperations = [
16236
15674
  ];
16237
15675
 
16238
15676
  export {
16239
- valuesEqual,
16240
- diffRecords,
16241
- errorForLog,
16242
- AUDIENCES,
16243
- OUTSIDE_RISK_CLASSES,
16244
- audiencesOf,
16245
- allowsAudience,
16246
- forPacks,
16247
- afterCommit,
16248
- isAfterCommit,
16249
- runAfterCommit,
16250
- recordHostChange,
16251
- markHostTool,
16252
- isHostTool,
16253
- defineOperation,
16254
- operationProblems,
16255
- choice3 as choice,
16256
- noul,
16257
- failureOf,
16258
- JUDGE_PLACEMENTS,
16259
- isJudgePlacement,
16260
- SWITCHABLE_PLACEMENTS,
16261
- JEV_MODEL,
16262
- JEV_PRICE,
16263
- judgeKeyStatus,
16264
- judgeUsageStatement,
16265
- judgeSpend,
16266
- vectorId,
16267
- SELF_ENQUEUEING,
16268
- isEmbeddable,
16269
- embeddingQueueStatement,
16270
- embeddingTexts,
16271
- unknownObject,
16272
- visibleObject,
16273
- visibleSource,
16274
- buyableSource,
16275
- previewSource,
16276
- visibleTable,
16277
- orgReader,
16278
- sortSchema,
16279
- LIST_MAX_LIMIT,
16280
- listInputSchema,
16281
- pageSchema,
16282
- encodeCursor,
16283
- decodeCursor,
16284
- resolveSort,
16285
- runListQuery,
16286
- pageQuery,
16287
- selectFields,
16288
- recordRefSchema2 as recordRefSchema,
16289
- linkedRecordSchema,
16290
- uniqueRefs,
16291
- assertLinkTargets,
16292
- loadRecordTitles,
16293
- loadLinks,
16294
- linkKeys,
16295
15677
  assignmentConditionSchema,
16296
15678
  ASSIGNMENT_METHODS,
16297
15679
  requireOwnedObject,
@@ -16324,6 +15706,11 @@ export {
16324
15706
  loadTags,
16325
15707
  uniqueTagNames,
16326
15708
  compareTagNames,
15709
+ vectorId,
15710
+ SELF_ENQUEUEING,
15711
+ isEmbeddable,
15712
+ embeddingQueueStatement,
15713
+ embeddingTexts,
16327
15714
  recordSummaryInput,
16328
15715
  meetingPrepInput,
16329
15716
  activitySummaryInput,
@@ -16332,6 +15719,8 @@ export {
16332
15719
  summariseModel,
16333
15720
  readCachedSummary,
16334
15721
  storeSummaryStatement,
15722
+ queueEraseAllowances,
15723
+ errorForLog,
16335
15724
  MAX_REFS_PER_TURN,
16336
15725
  conversationRefPattern,
16337
15726
  conversationRefs,
@@ -16362,6 +15751,9 @@ export {
16362
15751
  snippetSegments,
16363
15752
  loadDisplays,
16364
15753
  searchOperations,
15754
+ PLAYBACK_MAX_SECONDS,
15755
+ UPLOAD_ADDRESS_SECONDS,
15756
+ requireVideoHost,
16365
15757
  putEraseLog,
16366
15758
  readEraseLog,
16367
15759
  planReapply,
@@ -16410,12 +15802,22 @@ export {
16410
15802
  recipientWords,
16411
15803
  automationSummary,
16412
15804
  manifestSummaryContext,
15805
+ choice3 as choice,
15806
+ noul,
15807
+ failureOf,
16413
15808
  ROUTINE_GATE_CALIBRATED,
16414
15809
  NOTIFICATION_TYPES,
16415
15810
  ROUTABLE_NOTIFICATION_TYPES,
16416
15811
  notificationLinkSchema,
16417
15812
  EXTERNAL_CHANNELS,
16418
15813
  NOTIFICATION_OPERATION_SCHEMAS,
15814
+ recordRefSchema2 as recordRefSchema,
15815
+ linkedRecordSchema,
15816
+ uniqueRefs,
15817
+ assertLinkTargets,
15818
+ loadRecordTitles,
15819
+ loadLinks,
15820
+ linkKeys,
16419
15821
  automationBindingOperations,
16420
15822
  automationOperations,
16421
15823
  CARD_STATUS,
@@ -16444,18 +15846,8 @@ export {
16444
15846
  loadDomainOwners,
16445
15847
  newOrganisationValue,
16446
15848
  organisationOperations,
16447
- JOB_CHANGE_CALIBRATED,
16448
- SUGGESTION_THRESHOLD,
16449
- erasedAddresses,
16450
- syncOperations,
16451
- loadScanState,
16452
- queueScanAfterImport,
16453
- scanPending,
16454
- runScan,
16455
- personCheckValuesSchema,
16456
- organisationCheckValuesSchema,
16457
- checkPerson,
16458
- checkOrganisation,
15849
+ valuesEqual,
15850
+ diffRecords,
16459
15851
  assertVisibleWrites,
16460
15852
  setRecordWriter,
16461
15853
  createVisible,
@@ -16482,5 +15874,25 @@ export {
16482
15874
  personDeleteMany,
16483
15875
  personMerge,
16484
15876
  personErase,
16485
- personOperations
15877
+ personOperations,
15878
+ JOB_CHANGE_CALIBRATED,
15879
+ JUDGE_PLACEMENTS,
15880
+ isJudgePlacement,
15881
+ SWITCHABLE_PLACEMENTS,
15882
+ JEV_MODEL,
15883
+ JEV_PRICE,
15884
+ judgeKeyStatus,
15885
+ judgeUsageStatement,
15886
+ judgeSpend,
15887
+ SUGGESTION_THRESHOLD,
15888
+ erasedAddresses,
15889
+ syncOperations,
15890
+ loadScanState,
15891
+ queueScanAfterImport,
15892
+ scanPending,
15893
+ runScan,
15894
+ personCheckValuesSchema,
15895
+ organisationCheckValuesSchema,
15896
+ checkPerson,
15897
+ checkOrganisation
16486
15898
  };