@composable-os/cli 0.1.0-beta.10 → 0.1.0-beta.11

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 (64) hide show
  1. package/dist/{accounts-X4CKM3HL.js → accounts-UHYLCLEY.js} +10 -11
  2. package/dist/{blocks-YWDHEBOK.js → blocks-5IFU25J6.js} +2 -2
  3. package/dist/chunk-2IVEVPMY.js +669 -0
  4. package/dist/{chunk-QGGJ2G6Z.js → chunk-2TWV3SVB.js} +3 -3
  5. package/dist/chunk-2XC5JLBO.js +1931 -0
  6. package/dist/chunk-324WJXNP.js +320 -0
  7. package/dist/chunk-6ELZRNUU.js +116 -0
  8. package/dist/{chunk-YJJHF65I.js → chunk-6WGFA2IV.js} +58 -174
  9. package/dist/{chunk-A4NTSYWV.js → chunk-6XTU2MTP.js} +196 -10
  10. package/dist/{chunk-Q4N55M2Z.js → chunk-7D4GKZOX.js} +66 -3
  11. package/dist/{chunk-GYSGVT6R.js → chunk-7OGCMQXG.js} +9 -9
  12. package/dist/chunk-DHS2CV2M.js +139 -0
  13. package/dist/{chunk-LJFLENFC.js → chunk-E64SG24J.js} +1 -1
  14. package/dist/{chunk-Z3RMMB6S.js → chunk-FJIZGS5Q.js} +45 -15
  15. package/dist/chunk-K34UKWEI.js +298 -0
  16. package/dist/{chunk-LLULPZAJ.js → chunk-LAAL4YGR.js} +4 -4
  17. package/dist/{chunk-CP6BXI6F.js → chunk-LO6WGU5Y.js} +1338 -974
  18. package/dist/{chunk-Y7JZFSTQ.js → chunk-MBIKVRAC.js} +6 -6
  19. package/dist/{chunk-WC5LHBBA.js → chunk-P6UWZ6QQ.js} +1 -1
  20. package/dist/{chunk-6VXHPKGG.js → chunk-PDD2ETVF.js} +8 -8
  21. package/dist/{chunk-6UPUF4ML.js → chunk-UB4I2QKR.js} +1957 -380
  22. package/dist/{chunk-M7A6FR2Z.js → chunk-WHKJGF36.js} +154 -322
  23. package/dist/{chunk-VY64DMQO.js → chunk-XIDLW3EP.js} +190 -21
  24. package/dist/{chunk-IFG4FRW5.js → chunk-YFTLIEWU.js} +1 -1
  25. package/dist/{chunk-JJHHNV46.js → chunk-YNUZRTPH.js} +5 -50
  26. package/dist/{chunk-WO6D3XP3.js → chunk-ZAWES2UD.js} +31 -18
  27. package/dist/{chunk-K6T42YCH.js → chunk-ZZFWMVJO.js} +5 -5
  28. package/dist/{cli-2DFENR62.js → cli-5UNY5G5L.js} +22 -20
  29. package/dist/{cli-YIOVSKOD.js → cli-UYZMVQMR.js} +16 -13
  30. package/dist/cli.js +1 -1
  31. package/dist/{client-repo-PRU3VCQQ.js → client-repo-SE4EKG6W.js} +2 -2
  32. package/dist/create.js +1 -1
  33. package/dist/{fields-2NC7LSYE.js → fields-FTWWMD7N.js} +3 -3
  34. package/dist/grants-LOW6TSWD.js +32 -0
  35. package/dist/invoke-6KVT6WJI.js +41 -0
  36. package/dist/moves-E2HKYCTK.js +41 -0
  37. package/dist/{order-PUWD65BC.js → order-U4KZLLSJ.js} +2 -2
  38. package/dist/{person-WIQQ7ITU.js → person-UHLVBVLR.js} +9 -10
  39. package/dist/plan-on-sale-TJPFCNL7.js +26 -0
  40. package/dist/platform/migrations/0610_waitlists.sql +54 -0
  41. package/dist/platform/migrations/0630_subscription_changes.sql +122 -0
  42. package/dist/platform/migrations/0650_person_links.sql +90 -0
  43. package/dist/platform/migrations/0670_unmoved_guard.sql +52 -0
  44. package/dist/platform/migrations/0690_sellable_refund_due.sql +98 -0
  45. package/dist/platform/sdk/capacity.ts +102 -0
  46. package/dist/platform/sdk/contract.ts +25 -0
  47. package/dist/platform/sdk/manifest.ts +77 -1
  48. package/dist/platform/sdk/sellable.ts +251 -1
  49. package/dist/platform/sdk/states.ts +163 -49
  50. package/dist/{run-RT2HVWMK.js → run-7P4RQALH.js} +2 -2
  51. package/dist/{run-PZUCSDDL.js → run-PO3W5BFA.js} +1 -1
  52. package/dist/{run-Y7T4TVOL.js → run-ZCGFMEZF.js} +2 -2
  53. package/dist/src-CRO35DYY.js +46 -0
  54. package/dist/{src-XTOD7EXW.js → src-I3IJ4NKC.js} +8 -2
  55. package/dist/{visibility-DLGHU4YN.js → visibility-TVXZ67FD.js} +12 -4
  56. package/package.json +2 -2
  57. package/dist/chunk-6GDEDOV7.js +0 -157
  58. package/dist/chunk-O2UIZHND.js +0 -249
  59. package/dist/chunk-R4W5XAUD.js +0 -837
  60. package/dist/chunk-TQFGGSA4.js +0 -748
  61. package/dist/grants-QXMKYMGB.js +0 -32
  62. package/dist/invoke-I3NNNXVL.js +0 -39
  63. package/dist/plan-on-sale-NB774CQL.js +0 -26
  64. package/dist/src-GYS6NBQB.js +0 -44
@@ -6,10 +6,7 @@ import {
6
6
  setCoreWriter,
7
7
  shortestCronGap,
8
8
  zonedTime
9
- } from "./chunk-Z3RMMB6S.js";
10
- import {
11
- defineOperation
12
- } from "./chunk-6GDEDOV7.js";
9
+ } from "./chunk-FJIZGS5Q.js";
13
10
  import {
14
11
  AUTOMATION_SETTINGS,
15
12
  DRAFT_TARGET_ERRORS,
@@ -26,7 +23,7 @@ import {
26
23
  revokeBindingsPlan,
27
24
  triggerObject,
28
25
  unboundSlots
29
- } from "./chunk-QGGJ2G6Z.js";
26
+ } from "./chunk-2TWV3SVB.js";
30
27
  import {
31
28
  BATCH_MAX,
32
29
  TRASH_RETENTION_DAYS,
@@ -44,42 +41,47 @@ import {
44
41
  selectFields,
45
42
  uniqueIds,
46
43
  withPrimary
47
- } from "./chunk-K6T42YCH.js";
44
+ } from "./chunk-ZZFWMVJO.js";
48
45
  import {
49
- CompiledQuery,
46
+ defineOperation,
47
+ erasedWaiter,
48
+ handOnAfterRelease,
50
49
  loadGeneralSettings,
51
50
  newId,
52
51
  releaseAllClaimsOfStatements
53
- } from "./chunk-TQFGGSA4.js";
52
+ } from "./chunk-2XC5JLBO.js";
54
53
  import {
55
54
  product,
56
55
  productName
57
56
  } from "./chunk-6UWRT4VM.js";
58
57
  import {
58
+ CompiledQuery,
59
59
  ConfigError,
60
60
  ConflictError,
61
61
  FIELD_TYPE_REGISTRY,
62
62
  ForbiddenError,
63
+ GUARDIAN_LINK,
63
64
  NotFoundError,
64
65
  OperationError,
65
66
  PlanLimitError,
66
67
  ValidationError,
67
68
  fieldStorage,
68
69
  formulaFromStorage,
70
+ holdsPermission,
69
71
  objectTableOf,
70
72
  refreshSchemaRegistry,
71
73
  roleHasPermission,
72
74
  sql,
73
75
  visibleSource,
74
76
  visibleTable
75
- } from "./chunk-A4NTSYWV.js";
77
+ } from "./chunk-6XTU2MTP.js";
76
78
  import {
77
79
  getObject,
78
80
  isCoreObject,
79
81
  listObjects,
80
82
  organisationObject,
81
83
  personObject
82
- } from "./chunk-IFG4FRW5.js";
84
+ } from "./chunk-YFTLIEWU.js";
83
85
  import {
84
86
  _enum,
85
87
  _instanceof,
@@ -104,7 +106,7 @@ import {
104
106
  toJSONSchema,
105
107
  union,
106
108
  unknown
107
- } from "./chunk-CP6BXI6F.js";
109
+ } from "./chunk-LO6WGU5Y.js";
108
110
 
109
111
  // ../core/src/allowance/people.ts
110
112
  function queueMergeAllowances(ctx, survivorId, mergedId) {
@@ -946,7 +948,7 @@ async function relatedFacts(db, object2, id) {
946
948
  const facts2 = [];
947
949
  const ids = [];
948
950
  const refs = [];
949
- const { listObjects: listObjects2 } = await import("./fields-2NC7LSYE.js");
951
+ const { listObjects: listObjects2 } = await import("./fields-FTWWMD7N.js");
950
952
  for (const def of listObjects2()) {
951
953
  if (!def.extension) continue;
952
954
  for (const field of def.fields) {
@@ -10471,6 +10473,8 @@ async function queueEraseExtensions(ctx, s) {
10471
10473
  }
10472
10474
  });
10473
10475
  const deleted = [];
10476
+ const gone = /* @__PURE__ */ new Set();
10477
+ const released = /* @__PURE__ */ new Set();
10474
10478
  for (const field of relations) {
10475
10479
  const def = JSON.parse(field.definition);
10476
10480
  const table2 = field.table_name;
@@ -10490,12 +10494,28 @@ async function queueEraseExtensions(ctx, s) {
10490
10494
  const object2 = objectOfTable.get(table2);
10491
10495
  for (const row of found.rows) {
10492
10496
  const id = String(row.id);
10497
+ const key = `${table2}|${id}`;
10498
+ if (gone.has(key)) continue;
10493
10499
  rows += 1;
10494
- handled.add(`${table2}|${id}`);
10495
- if (object2 && getObject(object2)?.claims) {
10500
+ handled.add(key);
10501
+ const claimant = object2 ? getObject(object2) : void 0;
10502
+ const ownColumn = claimant?.customer ? claimant.fields.find((f) => f.name === claimant.customer?.field)?.column : void 0;
10503
+ const own = !claimant?.customer || ownColumn === column;
10504
+ const waiter = object2 && own && claimant?.claims ? await erasedWaiter(ctx, claimant, id) : null;
10505
+ if (object2 && waiter) {
10506
+ gone.add(key);
10507
+ deleted.push({ object: object2, id });
10508
+ ctx.write(CompiledQuery.raw(`DELETE FROM ${q(table2)} WHERE id = ?`, [id]), ...waiter);
10509
+ continue;
10510
+ }
10511
+ if (object2 && own && claimant?.claims && !released.has(key)) {
10512
+ released.add(key);
10496
10513
  ctx.write(...releaseAllClaimsOfStatements(object2, id, ctx.now));
10514
+ await handOnAfterRelease(ctx, claimant, id);
10497
10515
  }
10498
- if (def.required && !def.many && object2) {
10516
+ const guestOwner = claimant?.sellable?.moves?.guest === true && claimant.fields.find((f) => f.name === claimant.customer?.field)?.column === column;
10517
+ if ((def.required || guestOwner) && !def.many && object2) {
10518
+ gone.add(key);
10499
10519
  deleted.push({ object: object2, id });
10500
10520
  ctx.write(CompiledQuery.raw(`DELETE FROM ${q(table2)} WHERE id = ?`, [id]));
10501
10521
  continue;
@@ -10841,6 +10861,19 @@ async function queueEraseOrders(ctx, s) {
10841
10861
  ctx.write(
10842
10862
  ctx.db.deleteFrom("core_subscription_offer").where((eb) => eb.or([eb("person_id", "in", ids), eb("email", "in", addresses)]))
10843
10863
  );
10864
+ ctx.write(
10865
+ ctx.db.updateTable("core_subscription_change").set({ reason: "", call_error: null, end_error: null, updated_at: ctx.now }).where(
10866
+ "subscription_id",
10867
+ "in",
10868
+ (eb) => eb.selectFrom("core_subscription").select("id").where(
10869
+ (w) => w.or([
10870
+ w("payer_person_id", "in", ids),
10871
+ w("holder_person_id", "in", ids),
10872
+ w("email", "in", addresses)
10873
+ ])
10874
+ )
10875
+ )
10876
+ );
10844
10877
  const orders = await ctx.db.selectFrom("core_order").select("id").where((eb) => eb.or([eb("person_id", "in", ids), eb("email", "in", addresses)])).execute();
10845
10878
  for (const part of chunk(orders.map((o) => o.id))) {
10846
10879
  ctx.write(
@@ -13845,6 +13878,98 @@ async function queueMergeOrders(ctx, survivorId, mergedId) {
13845
13878
  );
13846
13879
  }
13847
13880
 
13881
+ // ../core/src/records/person-links.ts
13882
+ async function hasLiveLink(db, personIds) {
13883
+ if (!personIds.length) return false;
13884
+ const ids = jsonList([...personIds]);
13885
+ const row = await db.selectFrom("core_person_link").select("id").where("ended_at", "is", null).where((eb) => eb.or([eb("guardian_id", "in", ids), eb("dependant_id", "in", ids)])).executeTakeFirst();
13886
+ return row !== void 0;
13887
+ }
13888
+ async function planMergeLinks(db, survivorId, mergedId) {
13889
+ const rows = await db.selectFrom("core_person_link").select(["id", "guardian_id", "dependant_id", "ended_at"]).where(
13890
+ (eb) => eb.or([
13891
+ eb("guardian_id", "in", [survivorId, mergedId]),
13892
+ eb("dependant_id", "in", [survivorId, mergedId])
13893
+ ])
13894
+ ).execute();
13895
+ const live = (g, d) => rows.some((r) => r.ended_at === null && r.guardian_id === g && r.dependant_id === d);
13896
+ let moved = 0;
13897
+ let deleted = 0;
13898
+ let history = 0;
13899
+ const ends = [];
13900
+ for (const row of rows) {
13901
+ if (row.guardian_id !== mergedId && row.dependant_id !== mergedId) continue;
13902
+ const g = row.guardian_id === mergedId ? survivorId : row.guardian_id;
13903
+ const d = row.dependant_id === mergedId ? survivorId : row.dependant_id;
13904
+ if (g === d) {
13905
+ deleted += 1;
13906
+ continue;
13907
+ }
13908
+ if (row.ended_at !== null) {
13909
+ history += 1;
13910
+ continue;
13911
+ }
13912
+ if (live(g, d)) ends.push({ id: row.id, reason: "merged: a duplicate" });
13913
+ else if (live(d, g)) ends.push({ id: row.id, reason: "merged: the other way round is linked" });
13914
+ else moved += 1;
13915
+ }
13916
+ const liveIds = rows.filter((r) => r.ended_at === null).map((r) => r.id).sort();
13917
+ return {
13918
+ moved,
13919
+ ended: ends.length,
13920
+ deleted,
13921
+ history,
13922
+ ends,
13923
+ live: liveIds.length ? liveIds.join(",") : "none",
13924
+ movesLive: rows.some(
13925
+ (r) => r.ended_at === null && (r.guardian_id === mergedId || r.dependant_id === mergedId)
13926
+ )
13927
+ };
13928
+ }
13929
+ function queueMergeLinks(ctx, survivorId, mergedId, plan) {
13930
+ ctx.write(
13931
+ // A link between the two would link the survivor to themselves: dropped.
13932
+ ctx.db.deleteFrom("core_person_link").where(
13933
+ (eb) => eb.or([
13934
+ eb.and([eb("guardian_id", "=", mergedId), eb("dependant_id", "=", survivorId)]),
13935
+ eb.and([eb("guardian_id", "=", survivorId), eb("dependant_id", "=", mergedId)])
13936
+ ])
13937
+ )
13938
+ );
13939
+ for (const end of plan.ends) {
13940
+ ctx.write(
13941
+ ctx.db.updateTable("core_person_link").set({ ended_at: ctx.now, ended_by: ctx.user.id, end_reason: end.reason }).where("id", "=", end.id).where("ended_at", "is", null)
13942
+ );
13943
+ }
13944
+ ctx.write(
13945
+ ctx.db.updateTable("core_person_link").set({ guardian_id: survivorId }).where("guardian_id", "=", mergedId),
13946
+ ctx.db.updateTable("core_person_link").set({ dependant_id: survivorId }).where("dependant_id", "=", mergedId)
13947
+ );
13948
+ }
13949
+ async function dependantsLeftAlone(ctx, personIds) {
13950
+ if (!personIds.length) return [];
13951
+ const erased = jsonList([...personIds]);
13952
+ const rows = await ctx.db.selectFrom("core_person_link as l").select("l.dependant_id").distinct().where("l.kind", "=", GUARDIAN_LINK).where("l.ended_at", "is", null).where("l.guardian_id", "in", erased).where("l.dependant_id", "not in", erased).where(
13953
+ sql`NOT EXISTS (SELECT 1 FROM core_person_link o WHERE o.dependant_id = l.dependant_id AND o.kind = l.kind AND o.ended_at IS NULL AND o.guardian_id NOT IN ${erased})`
13954
+ ).execute();
13955
+ return rows.map((row) => row.dependant_id);
13956
+ }
13957
+ function queueEraseLinks(ctx, personIds, leftAlone = []) {
13958
+ if (!personIds.length) return;
13959
+ const erased = jsonList([...personIds]);
13960
+ ctx.write(
13961
+ ctx.db.deleteFrom("core_person_link").where((eb) => eb.or([eb("guardian_id", "in", erased), eb("dependant_id", "in", erased)]))
13962
+ );
13963
+ for (const id of leftAlone) {
13964
+ ctx.postActivity({
13965
+ subject: "No guardian linked any more",
13966
+ body: "The record of this person's only linked guardian was erased. Nobody can book for them until staff link a guardian again.",
13967
+ payload: { kind: "person_link", action: "guardian_erased" },
13968
+ links: [{ object: "person", id }]
13969
+ });
13970
+ }
13971
+ }
13972
+
13848
13973
  // ../core/src/subscriptions/merge.ts
13849
13974
  async function queueMergeSubscriptions(ctx, survivorId, mergedId) {
13850
13975
  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();
@@ -14925,7 +15050,17 @@ var personMerge = defineOperation({
14925
15050
  fields: external_exports.partialRecord(external_exports.enum(PERSON_MERGE_FIELDS), external_exports.enum(["survivor", "merged"])).default({}).describe("Which record's value to keep for each field (default survivor)")
14926
15051
  }),
14927
15052
  output: personSchema.extend({
14928
- moved: external_exports.object({ affiliations: external_exports.number(), activities: external_exports.number(), tasks: external_exports.number() })
15053
+ moved: external_exports.object({
15054
+ affiliations: external_exports.number(),
15055
+ activities: external_exports.number(),
15056
+ tasks: external_exports.number()
15057
+ }),
15058
+ familyLinks: external_exports.object({
15059
+ moved: external_exports.number().describe("Live family links that moved to the survivor"),
15060
+ ended: external_exports.number().describe("Live links ended: a duplicate, or one whose other way round is linked"),
15061
+ deleted: external_exports.number().describe("Links between the two People, deleted"),
15062
+ history: external_exports.number().describe("Links that had already ended, moved as history")
15063
+ }).optional().describe("What happened to the duplicate's family links (guardians and children)")
14929
15064
  }),
14930
15065
  permission: "records:write",
14931
15066
  risk: "destructive",
@@ -14948,6 +15083,20 @@ var personMerge = defineOperation({
14948
15083
  await queueMergeOrders(ctx, survivor.id, merged.id);
14949
15084
  await queueMergeSubscriptions(ctx, survivor.id, merged.id);
14950
15085
  queueMergeAllowances(ctx, survivor.id, merged.id);
15086
+ const plan = await planMergeLinks(ctx.db, survivor.id, merged.id);
15087
+ if (plan.movesLive && !holdsPermission(ctx.user, ctx.permissionGrants, "people:link")) {
15088
+ throw new ForbiddenError(
15089
+ `${merged.displayName} has family links (a parent or a child), which a merge would move: merging them needs people:link`,
15090
+ { permission: "people:link" }
15091
+ );
15092
+ }
15093
+ queueMergeLinks(ctx, survivor.id, merged.id, plan);
15094
+ const familyLinks = {
15095
+ moved: plan.moved,
15096
+ ended: plan.ended,
15097
+ deleted: plan.deleted,
15098
+ history: plan.history
15099
+ };
14951
15100
  const emailSet = new Set(survivor.emails.map((e) => e.email));
14952
15101
  after.emails = [
14953
15102
  ...survivor.emails,
@@ -15010,8 +15159,15 @@ var personMerge = defineOperation({
15010
15159
  object: "person",
15011
15160
  id: survivor.id,
15012
15161
  action: "merge",
15013
- before: personSnapshot(survivor),
15014
- after: { ...personSnapshot(after), absorbedId: merged.id }
15162
+ // Family links (ADR 0540): before, the two People's live links as read; after, what the
15163
+ // merge does to them. Shown in the approval card, and an approval is held to the before: a
15164
+ // link made or ended after the preview makes applying it a conflict, never a surprise.
15165
+ before: { ...personSnapshot(survivor), familyLinks: plan.live },
15166
+ after: {
15167
+ ...personSnapshot(after),
15168
+ absorbedId: merged.id,
15169
+ familyLinks: `${plan.moved} moved, ${plan.ended} ended, ${plan.deleted} deleted${plan.history ? `, ${plan.history} past moved` : ""}`
15170
+ }
15015
15171
  });
15016
15172
  ctx.recordChange({
15017
15173
  object: "person",
@@ -15039,7 +15195,11 @@ var personMerge = defineOperation({
15039
15195
  activities: links.activities,
15040
15196
  tasks: links.tasks
15041
15197
  };
15042
- return ctx.afterCommit(async () => ({ ...await requirePerson(ctx, survivor.id), moved }));
15198
+ return ctx.afterCommit(async () => ({
15199
+ ...await requirePerson(ctx, survivor.id),
15200
+ moved,
15201
+ familyLinks
15202
+ }));
15043
15203
  }
15044
15204
  });
15045
15205
  var personErase = defineOperation({
@@ -15053,7 +15213,10 @@ var personErase = defineOperation({
15053
15213
  tasksDeleted: external_exports.number(),
15054
15214
  auditRowsRedacted: external_exports.number(),
15055
15215
  conversationsScrubbed: external_exports.number(),
15056
- ...eraseCountsOutput
15216
+ ...eraseCountsOutput,
15217
+ dependantsWithoutGuardian: external_exports.array(external_exports.string()).optional().describe(
15218
+ "People this person was the only live guardian of (ADR 0540): they stay, with no guardian linked, and a note on their timeline"
15219
+ )
15057
15220
  }),
15058
15221
  permission: "records:erase",
15059
15222
  risk: "destructive",
@@ -15062,6 +15225,8 @@ var personErase = defineOperation({
15062
15225
  await requirePerson(ctx, input.id, { includeDeleted: true });
15063
15226
  const ids = await withMergedRecords(ctx, "person", input.id);
15064
15227
  const subject = await personSubject(ctx.db, ids);
15228
+ const leftAlone = await dependantsLeftAlone(ctx, ids);
15229
+ queueEraseLinks(ctx, ids, leftAlone);
15065
15230
  const counts = await queueErase(ctx, {
15066
15231
  object: "person",
15067
15232
  recordId: input.id,
@@ -15078,7 +15243,8 @@ var personErase = defineOperation({
15078
15243
  tasksDeleted: counts.tasks,
15079
15244
  auditRowsRedacted: await countRedactions(ctx.db, "person", input.id),
15080
15245
  conversationsScrubbed: counts.conversations,
15081
- ...await afterErase(ctx, counts)
15246
+ ...await afterErase(ctx, counts),
15247
+ dependantsWithoutGuardian: leftAlone
15082
15248
  }));
15083
15249
  }
15084
15250
  });
@@ -15254,6 +15420,9 @@ export {
15254
15420
  loadDomainOwners,
15255
15421
  newOrganisationValue,
15256
15422
  organisationOperations,
15423
+ hasLiveLink,
15424
+ planMergeLinks,
15425
+ queueEraseLinks,
15257
15426
  affiliationOperations,
15258
15427
  emailInputSchema,
15259
15428
  phoneInputSchema,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BASE_OBJECTS,
4
4
  defineObject
5
- } from "./chunk-Q4N55M2Z.js";
5
+ } from "./chunk-7D4GKZOX.js";
6
6
 
7
7
  // ../core/src/fields/activity.ts
8
8
  var activityObject = defineObject({
@@ -2,51 +2,12 @@
2
2
  import {
3
3
  addLocalDays,
4
4
  localParts,
5
+ newId,
5
6
  wallClockToIso
6
- } from "./chunk-O2UIZHND.js";
7
+ } from "./chunk-2XC5JLBO.js";
7
8
  import {
8
- CompiledQuery,
9
- newId
10
- } from "./chunk-TQFGGSA4.js";
11
-
12
- // ../core/src/recurring/bookkeeping.ts
13
- function armSeriesStatement(object, id, at, now) {
14
- return CompiledQuery.raw(
15
- "INSERT INTO core_recurrence_series (object_type, record_id, next_run_at, version, updated_at) VALUES (?, ?, ?, 1, ?) ON CONFLICT (object_type, record_id) DO UPDATE SET next_run_at = excluded.next_run_at, version = core_recurrence_series.version + 1, updated_at = excluded.updated_at",
16
- [object, id, at, now]
17
- );
18
- }
19
- async function seriesVersion(db, object, id) {
20
- const row = await db.selectFrom("core_recurrence_series").select("version").where("object_type", "=", object).where("record_id", "=", id).executeTakeFirst();
21
- return row?.version ?? 0;
22
- }
23
- function guardStatement(kind, object, record, expected) {
24
- return CompiledQuery.raw(
25
- "INSERT INTO core_write_guard (kind, object_type, record_id, expected) VALUES (?, ?, ?, ?)",
26
- [kind, object, record, expected]
27
- );
28
- }
29
- function occurrenceStatement(input) {
30
- return CompiledQuery.raw(
31
- "INSERT INTO core_recurrence_occurrence (series_object, series_id, local_date, object_type, record_id, created_at) VALUES (?, ?, ?, ?, ?, ?)",
32
- [input.seriesObject, input.seriesId, input.date, input.object, input.record, input.now]
33
- );
34
- }
35
- function markEditedStatement(object, record, now) {
36
- return CompiledQuery.raw(
37
- "UPDATE core_recurrence_occurrence SET edited_at = ? WHERE object_type = ? AND record_id = ? AND edited_at IS NULL",
38
- [now, object, record]
39
- );
40
- }
41
- function dropRecurringStatements(object) {
42
- return [
43
- CompiledQuery.raw(
44
- "DELETE FROM core_recurrence_occurrence WHERE series_object = ? OR object_type = ?",
45
- [object, object]
46
- ),
47
- CompiledQuery.raw("DELETE FROM core_recurrence_series WHERE object_type = ?", [object])
48
- ];
49
- }
9
+ CompiledQuery
10
+ } from "./chunk-6XTU2MTP.js";
50
11
 
51
12
  // ../core/src/allowance/periods.ts
52
13
  var TOTAL_PERIOD = {
@@ -217,11 +178,5 @@ export {
217
178
  spendStatements,
218
179
  returnStatements,
219
180
  rekeyStatements,
220
- dropAllowanceStatements,
221
- armSeriesStatement,
222
- seriesVersion,
223
- guardStatement,
224
- occurrenceStatement,
225
- markEditedStatement,
226
- dropRecurringStatements
181
+ dropAllowanceStatements
227
182
  };
@@ -2,20 +2,17 @@
2
2
  import {
3
3
  callSubscriptionGatekeeper,
4
4
  paymentsTarget
5
- } from "./chunk-LJFLENFC.js";
5
+ } from "./chunk-E64SG24J.js";
6
6
  import {
7
7
  dropAllowanceStatements,
8
- dropRecurringStatements,
9
8
  termsSyncStatements
10
- } from "./chunk-JJHHNV46.js";
9
+ } from "./chunk-YNUZRTPH.js";
11
10
  import {
12
- loadOrderCurrency,
13
- realWallClock,
14
- zoneOffset
15
- } from "./chunk-O2UIZHND.js";
11
+ loadOrderCurrency
12
+ } from "./chunk-6ELZRNUU.js";
16
13
  import {
17
14
  automationSyncStatements
18
- } from "./chunk-QGGJ2G6Z.js";
15
+ } from "./chunk-2TWV3SVB.js";
19
16
  import {
20
17
  compileFilter,
21
18
  filterSchema,
@@ -23,20 +20,23 @@ import {
23
20
  holdsAccess,
24
21
  registerAccessSource,
25
22
  runListQuery
26
- } from "./chunk-K6T42YCH.js";
23
+ } from "./chunk-ZZFWMVJO.js";
27
24
  import {
28
- CompiledQuery,
29
25
  ORG_TIMEZONE_SETTING,
30
26
  backfillCounters,
31
27
  dropCapacityStatements,
28
+ dropRecurringStatements,
32
29
  loadGeneralSettings,
33
30
  newId,
34
- releaseAllClaimsStatements
35
- } from "./chunk-TQFGGSA4.js";
31
+ realWallClock,
32
+ releaseAllClaimsStatements,
33
+ zoneOffset
34
+ } from "./chunk-2XC5JLBO.js";
36
35
  import {
37
36
  CaseBuilder,
38
37
  CaseNode,
39
38
  ColumnNode,
39
+ CompiledQuery,
40
40
  ConfigError,
41
41
  ConflictError,
42
42
  DynamicReferenceBuilder,
@@ -67,6 +67,7 @@ import {
67
67
  coreFormulaFields,
68
68
  createFunctionModule,
69
69
  createQueryId,
70
+ familyOf,
70
71
  formulaFromStorage,
71
72
  freeze,
72
73
  holdsPermission,
@@ -109,11 +110,11 @@ import {
109
110
  visibleSource,
110
111
  visibleTable,
111
112
  waitOrAbort
112
- } from "./chunk-A4NTSYWV.js";
113
+ } from "./chunk-6XTU2MTP.js";
113
114
  import {
114
115
  getObject,
115
116
  listObjects
116
- } from "./chunk-IFG4FRW5.js";
117
+ } from "./chunk-YFTLIEWU.js";
117
118
  import {
118
119
  external_exports,
119
120
  hostFilledFields,
@@ -123,7 +124,7 @@ import {
123
124
  spenderAllows,
124
125
  spendsOnList,
125
126
  validateManifest
126
- } from "./chunk-CP6BXI6F.js";
127
+ } from "./chunk-LO6WGU5Y.js";
127
128
 
128
129
  // ../../node_modules/.pnpm/kysely@0.29.8/node_modules/kysely/dist/operation-node/alter-table-node.js
129
130
  var AlterTableNode = freeze({
@@ -7038,7 +7039,8 @@ function recordAccess(reader, writes) {
7038
7039
  count: (object, filter) => countVisible(reader, object, filter),
7039
7040
  capacity: (object, id) => readCapacity(reader, object, id),
7040
7041
  create: writes?.create ?? none,
7041
- update: writes?.update ?? none
7042
+ update: writes?.update ?? none,
7043
+ family: () => familyOf(reader)
7042
7044
  };
7043
7045
  }
7044
7046
 
@@ -7477,7 +7479,7 @@ async function importOffers(ctx, input) {
7477
7479
  );
7478
7480
  }
7479
7481
  const { timezone } = await loadGeneralSettings(ctx.db);
7480
- const { normaliseCustomerEmail, inviteCustomerStatement } = await import("./accounts-X4CKM3HL.js");
7482
+ const { normaliseCustomerEmail, inviteCustomerStatement } = await import("./accounts-UHYLCLEY.js");
7481
7483
  const addresses = input.rows.map((r) => normaliseCustomerEmail(r.email));
7482
7484
  const valid = [...new Set(addresses.filter((a) => a !== null))];
7483
7485
  const owners = /* @__PURE__ */ new Map();
@@ -8235,7 +8237,18 @@ async function dataIssues(db, current, next, ext) {
8235
8237
  }
8236
8238
  const was = before.definition.claims;
8237
8239
  const now = object.definition.claims;
8238
- if (JSON.stringify(was ?? null) === JSON.stringify(now ?? null)) continue;
8240
+ const placesOf = (c) => c ? JSON.stringify({ on: c.on, held: c.held ?? [], confirmed: c.confirmed ?? [] }) : null;
8241
+ if (was?.waitlist && !now?.waitlist) {
8242
+ const holds = await anyDb.selectFrom("core_capacity_claim").select("id").where("for_type", "=", "waitlist").where("for_id", "=", object.name).where("state", "=", "held").limit(1).execute();
8243
+ if (holds.length) {
8244
+ issues.push({
8245
+ code: "claims_conflict",
8246
+ path: `objects.${object.localName}.claims.waitlist`,
8247
+ message: `${object.name}: its waitlist holds places for people waiting; it cannot be dropped until they are promoted or the holds are given back (within a minute of nobody waiting).`
8248
+ });
8249
+ }
8250
+ }
8251
+ if (placesOf(was) === placesOf(now)) continue;
8239
8252
  const column = columnOf(object.definition.states?.field ?? before.definition.states?.field);
8240
8253
  const states = [
8241
8254
  .../* @__PURE__ */ new Set([
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  newId
4
- } from "./chunk-TQFGGSA4.js";
4
+ } from "./chunk-2XC5JLBO.js";
5
5
  import {
6
6
  ValidationError,
7
7
  liveViewOf,
@@ -9,17 +9,17 @@ import {
9
9
  viewColumnOf,
10
10
  visibleObject,
11
11
  visibleSource
12
- } from "./chunk-A4NTSYWV.js";
12
+ } from "./chunk-6XTU2MTP.js";
13
13
  import {
14
14
  getObject
15
- } from "./chunk-IFG4FRW5.js";
15
+ } from "./chunk-YFTLIEWU.js";
16
16
  import {
17
17
  getField
18
- } from "./chunk-Q4N55M2Z.js";
18
+ } from "./chunk-7D4GKZOX.js";
19
19
  import {
20
20
  documentRefs,
21
21
  external_exports
22
- } from "./chunk-CP6BXI6F.js";
22
+ } from "./chunk-LO6WGU5Y.js";
23
23
 
24
24
  // ../core/src/records/common.ts
25
25
  var TRASH_RETENTION_DAYS = 30;
@@ -2,29 +2,31 @@
2
2
  import {
3
3
  productContract,
4
4
  renderClient
5
- } from "./chunk-LLULPZAJ.js";
6
- import "./chunk-6UPUF4ML.js";
7
- import "./chunk-YJJHF65I.js";
8
- import "./chunk-M7A6FR2Z.js";
9
- import "./chunk-R4W5XAUD.js";
10
- import "./chunk-GYSGVT6R.js";
11
- import "./chunk-VY64DMQO.js";
12
- import "./chunk-Z3RMMB6S.js";
13
- import "./chunk-6GDEDOV7.js";
14
- import "./chunk-WO6D3XP3.js";
15
- import "./chunk-LJFLENFC.js";
16
- import "./chunk-JJHHNV46.js";
17
- import "./chunk-O2UIZHND.js";
18
- import "./chunk-QGGJ2G6Z.js";
19
- import "./chunk-K6T42YCH.js";
20
- import "./chunk-TQFGGSA4.js";
5
+ } from "./chunk-LAAL4YGR.js";
6
+ import "./chunk-UB4I2QKR.js";
7
+ import "./chunk-DHS2CV2M.js";
8
+ import "./chunk-K34UKWEI.js";
9
+ import "./chunk-2IVEVPMY.js";
10
+ import "./chunk-6WGFA2IV.js";
11
+ import "./chunk-WHKJGF36.js";
12
+ import "./chunk-324WJXNP.js";
13
+ import "./chunk-7OGCMQXG.js";
14
+ import "./chunk-XIDLW3EP.js";
15
+ import "./chunk-FJIZGS5Q.js";
16
+ import "./chunk-ZAWES2UD.js";
17
+ import "./chunk-E64SG24J.js";
18
+ import "./chunk-YNUZRTPH.js";
19
+ import "./chunk-6ELZRNUU.js";
20
+ import "./chunk-2TWV3SVB.js";
21
+ import "./chunk-ZZFWMVJO.js";
22
+ import "./chunk-2XC5JLBO.js";
21
23
  import "./chunk-DU6OIFOU.js";
22
24
  import "./chunk-KGHA67HG.js";
23
25
  import "./chunk-6UWRT4VM.js";
24
- import "./chunk-A4NTSYWV.js";
25
- import "./chunk-IFG4FRW5.js";
26
- import "./chunk-Q4N55M2Z.js";
27
- import "./chunk-CP6BXI6F.js";
26
+ import "./chunk-6XTU2MTP.js";
27
+ import "./chunk-YFTLIEWU.js";
28
+ import "./chunk-7D4GKZOX.js";
29
+ import "./chunk-LO6WGU5Y.js";
28
30
  import "./chunk-5KSXSK7Y.js";
29
31
 
30
32
  // ../client-gen/src/node/cli.ts