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

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 (166) hide show
  1. package/dist/{accounts-UHYLCLEY.js → accounts-GOCNY6WI.js} +17 -13
  2. package/dist/app-OSPZHKOI.js +43 -0
  3. package/dist/app-upload-LH4PXKI4.js +198 -0
  4. package/dist/{blocks-5IFU25J6.js → blocks-6DZIP47W.js} +207 -25
  5. package/dist/{chunk-XIDLW3EP.js → chunk-2B6YUYZV.js} +23499 -11766
  6. package/dist/{run-7P4RQALH.js → chunk-2CCHB37H.js} +9 -146
  7. package/dist/{chunk-DU6OIFOU.js → chunk-3OGDWKJ3.js} +530 -434
  8. package/dist/{chunk-DHS2CV2M.js → chunk-5D7BDF4Y.js} +15 -13
  9. package/dist/{chunk-MBIKVRAC.js → chunk-5YDYQM6V.js} +830 -47
  10. package/dist/{chunk-ZAWES2UD.js → chunk-6CM3WZG5.js} +13 -2483
  11. package/dist/{chunk-7D4GKZOX.js → chunk-CIBJGB5H.js} +422 -75
  12. package/dist/chunk-EPDTPGZJ.js +330 -0
  13. package/dist/{chunk-LAAL4YGR.js → chunk-HAYF4G5V.js} +66 -23
  14. package/dist/chunk-HCG6T53D.js +61904 -0
  15. package/dist/{chunk-K34UKWEI.js → chunk-JX4IFWNT.js} +64 -32
  16. package/dist/{chunk-6XTU2MTP.js → chunk-KFHKNXGH.js} +632 -418
  17. package/dist/chunk-KMFMD52Z.js +13276 -0
  18. package/dist/{chunk-E4WCYTCT.js → chunk-LX2TTLVY.js} +174 -55
  19. package/dist/{chunk-PDD2ETVF.js → chunk-O37YUZ52.js} +172 -16
  20. package/dist/{chunk-GYTEW66E.js → chunk-O3R4FS2J.js} +1 -1
  21. package/dist/{chunk-E64SG24J.js → chunk-Q6Y45DY6.js} +25 -2
  22. package/dist/chunk-RGKJKC5T.js +876 -0
  23. package/dist/{chunk-YFTLIEWU.js → chunk-RSEWEFAV.js} +12 -2
  24. package/dist/{chunk-2ABSVMGB.js → chunk-SMJZIK2O.js} +1 -1
  25. package/dist/{chunk-LO6WGU5Y.js → chunk-U72NEGCT.js} +8089 -3464
  26. package/dist/{chunk-P6UWZ6QQ.js → chunk-Z4IKF23A.js} +11 -7
  27. package/dist/{chunk-2IVEVPMY.js → chunk-Z7OVQ6BC.js} +105 -61
  28. package/dist/{chunk-6UWRT4VM.js → chunk-ZJSFX4RD.js} +175 -3
  29. package/dist/{cli-5UNY5G5L.js → cli-OKQHHSOE.js} +17 -25
  30. package/dist/{cli-UYZMVQMR.js → cli-VYSD2S4Z.js} +227 -81
  31. package/dist/cli.js +5 -5
  32. package/dist/{client-repo-SE4EKG6W.js → client-repo-MPCPTXLF.js} +7 -5
  33. package/dist/create.js +5 -5
  34. package/dist/{fields-FTWWMD7N.js → fields-GTHE6TTS.js} +27 -3
  35. package/dist/gateway-DPPEQZT4.js +25 -0
  36. package/dist/grants-6JY4XZO7.js +27 -0
  37. package/dist/invoke-MRONRZ5Q.js +33 -0
  38. package/dist/moves-UAUCMWL5.js +36 -0
  39. package/dist/{order-U4KZLLSJ.js → order-RKLGT74L.js} +2 -2
  40. package/dist/{person-UHLVBVLR.js → person-YOZTFV4Q.js} +11 -10
  41. package/dist/plan-on-sale-H4F26YIN.js +26 -0
  42. package/dist/platform/migrations/0730_practitioners.sql +79 -0
  43. package/dist/platform/migrations/0750_routine_mail.sql +98 -0
  44. package/dist/platform/migrations/0770_clear_fixed_role_grants.sql +64 -0
  45. package/dist/platform/migrations/0810_recurrence_exceptions.sql +66 -0
  46. package/dist/platform/migrations/0811_staff_time.sql +109 -0
  47. package/dist/platform/migrations/0812_staff_offers.sql +112 -0
  48. package/dist/platform/migrations/0813_pay_periods.sql +241 -0
  49. package/dist/platform/migrations/0814_staff_feed.sql +47 -0
  50. package/dist/platform/migrations/0815_checklists.sql +237 -0
  51. package/dist/platform/migrations/0816_checklist_schedules.sql +121 -0
  52. package/dist/platform/migrations/0817_checklist_day_window.sql +35 -0
  53. package/dist/platform/migrations/0850_agreements.sql +271 -0
  54. package/dist/platform/migrations/0851_agreement_acceptances.sql +387 -0
  55. package/dist/platform/migrations/0853_agreement_enforcement.sql +58 -0
  56. package/dist/platform/migrations/0854_agreement_copy.sql +149 -0
  57. package/dist/platform/migrations/0855_agreement_retention.sql +279 -0
  58. package/dist/platform/migrations/0856_subscription_cooling_off.sql +159 -0
  59. package/dist/platform/migrations/0857_agreement_copy_guardian.sql +337 -0
  60. package/dist/platform/migrations/0858_agreement_desk.sql +175 -0
  61. package/dist/platform/migrations/0910_routine_messages.sql +99 -0
  62. package/dist/platform/migrations/0911_texts.sql +60 -0
  63. package/dist/platform/migrations/0913_contact_consent.sql +93 -0
  64. package/dist/platform/migrations/0916_contact_mailbox_index.sql +29 -0
  65. package/dist/platform/migrations/0930_stock_movements.sql +95 -0
  66. package/dist/platform/migrations/0931_stock_low.sql +25 -0
  67. package/dist/platform/migrations/0932_order_delivery.sql +78 -0
  68. package/dist/platform/migrations/0950_order_adjustments.sql +111 -0
  69. package/dist/platform/migrations/0951_order_price_guards.sql +33 -0
  70. package/dist/platform/migrations/0952_order_paid_another_way.sql +194 -0
  71. package/dist/platform/migrations/0953_discount_uses.sql +183 -0
  72. package/dist/platform/migrations/0955_folded_addresses.sql +92 -0
  73. package/dist/platform/migrations/0970_published_text.sql +59 -0
  74. package/dist/platform/migrations/0971_publish_acks.sql +68 -0
  75. package/dist/platform/migrations/0990_customer_email_change.sql +65 -0
  76. package/dist/platform/migrations/1010_intake_links.sql +148 -0
  77. package/dist/platform/migrations/1030_invoices.sql +747 -0
  78. package/dist/platform/migrations/1031_invoice_orders.sql +327 -0
  79. package/dist/platform/migrations/1050_inbox_conversations.sql +83 -0
  80. package/dist/platform/migrations/1090_staff_hours.sql +43 -0
  81. package/dist/platform/migrations/1091_staff_time_margins.sql +12 -0
  82. package/dist/platform/migrations/1092_client_guard.sql +26 -0
  83. package/dist/platform/migrations/1095_thing_time.sql +70 -0
  84. package/dist/platform/migrations/1130_devices.sql +162 -0
  85. package/dist/platform/migrations/1135_person_codes.sql +88 -0
  86. package/dist/platform/migrations/1150_finance_periods.sql +316 -0
  87. package/dist/platform/migrations/1151_payouts.sql +202 -0
  88. package/dist/platform/migrations/1153_finance_money_dates.sql +18 -0
  89. package/dist/platform/migrations/1170_journeys.sql +318 -0
  90. package/dist/platform/migrations/1171_person_birthday.sql +52 -0
  91. package/dist/platform/migrations/1175_person_signals.sql +29 -0
  92. package/dist/platform/migrations/1190_restricted_values.sql +25 -0
  93. package/dist/platform/migrations/1230_note_levels.sql +113 -0
  94. package/dist/platform/migrations/1231_person_carers.sql +33 -0
  95. package/dist/platform/migrations/1232_note_kinds.sql +122 -0
  96. package/dist/platform/migrations/1270_time_entries.sql +145 -0
  97. package/dist/platform/migrations/1271_leave.sql +249 -0
  98. package/dist/platform/migrations/1273_time_entry_reopened.sql +21 -0
  99. package/dist/platform/migrations/1330_accounting.sql +260 -0
  100. package/dist/platform/migrations/1350_customer_feed.sql +24 -0
  101. package/dist/platform/migrations/1390_locations.sql +77 -0
  102. package/dist/platform/migrations/1410_outside_copy.sql +213 -0
  103. package/dist/platform/migrations/1430_inbox_activities.sql +231 -0
  104. package/dist/platform/migrations/1450_wrong_guesses.sql +23 -0
  105. package/dist/platform/sdk/acknowledge.ts +100 -0
  106. package/dist/platform/sdk/agreements.ts +185 -0
  107. package/dist/platform/sdk/allowance.ts +98 -8
  108. package/dist/platform/sdk/automation-check.ts +120 -9
  109. package/dist/platform/sdk/automation.ts +78 -10
  110. package/dist/platform/sdk/behaviour.ts +26 -6
  111. package/dist/platform/sdk/calendar-entry.ts +258 -0
  112. package/dist/platform/sdk/capacity.ts +1 -2
  113. package/dist/platform/sdk/checklists.ts +118 -0
  114. package/dist/platform/sdk/contract.ts +489 -27
  115. package/dist/platform/sdk/discount.ts +408 -0
  116. package/dist/platform/sdk/document.ts +4 -2
  117. package/dist/platform/sdk/field-types.ts +5 -0
  118. package/dist/platform/sdk/formula/compile.ts +10 -0
  119. package/dist/platform/sdk/index.ts +17 -0
  120. package/dist/platform/sdk/intake.ts +380 -0
  121. package/dist/platform/sdk/journey-signals.ts +215 -0
  122. package/dist/platform/sdk/manifest.ts +1236 -65
  123. package/dist/platform/sdk/mine.ts +161 -0
  124. package/dist/platform/sdk/occupies.ts +192 -0
  125. package/dist/platform/sdk/questions.ts +681 -0
  126. package/dist/platform/sdk/recurring.ts +90 -9
  127. package/dist/platform/sdk/restricted-fields.ts +129 -0
  128. package/dist/platform/sdk/rich-text.ts +112 -0
  129. package/dist/platform/sdk/routine-mail.ts +1272 -0
  130. package/dist/platform/sdk/runtime.ts +25 -12
  131. package/dist/platform/sdk/screens.ts +91 -0
  132. package/dist/platform/sdk/sellable.ts +344 -0
  133. package/dist/platform/sdk/slug.ts +7 -2
  134. package/dist/platform/sdk/staffed.ts +474 -0
  135. package/dist/platform/sdk/states.ts +68 -26
  136. package/dist/platform/sdk/stock.ts +332 -0
  137. package/dist/platform/sdk/team.ts +83 -0
  138. package/dist/platform/sdk/testing.ts +70 -6
  139. package/dist/platform/sdk/worked-on.ts +134 -0
  140. package/dist/{products-2H5DR232.js → products-GCQLSZ3U.js} +2 -2
  141. package/dist/run-7ID64RA6.js +65 -0
  142. package/dist/run-FH7OGGTV.js +131 -0
  143. package/dist/run-OYZIAP6M.js +3363 -0
  144. package/dist/{run-ZCGFMEZF.js → run-QOFRRSZV.js} +41 -60
  145. package/dist/{run-PO3W5BFA.js → run-TJAEWR5U.js} +21 -51
  146. package/dist/{src-I3IJ4NKC.js → src-52VERUPK.js} +306 -4
  147. package/dist/src-PHRELWN5.js +40 -0
  148. package/dist/{visibility-TVXZ67FD.js → visibility-SZCINPP4.js} +21 -4
  149. package/package.json +2 -2
  150. package/dist/chunk-2TWV3SVB.js +0 -349
  151. package/dist/chunk-2XC5JLBO.js +0 -1931
  152. package/dist/chunk-324WJXNP.js +0 -320
  153. package/dist/chunk-6ELZRNUU.js +0 -116
  154. package/dist/chunk-6WGFA2IV.js +0 -643
  155. package/dist/chunk-7CQGMVDO.js +0 -63
  156. package/dist/chunk-7OGCMQXG.js +0 -284
  157. package/dist/chunk-FJIZGS5Q.js +0 -698
  158. package/dist/chunk-UB4I2QKR.js +0 -31575
  159. package/dist/chunk-WHKJGF36.js +0 -2418
  160. package/dist/chunk-YNUZRTPH.js +0 -182
  161. package/dist/chunk-ZZFWMVJO.js +0 -704
  162. package/dist/grants-LOW6TSWD.js +0 -32
  163. package/dist/invoke-6KVT6WJI.js +0 -41
  164. package/dist/moves-E2HKYCTK.js +0 -41
  165. package/dist/plan-on-sale-TJPFCNL7.js +0 -26
  166. package/dist/src-CRO35DYY.js +0 -46
@@ -1,26 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- checkEvaluated,
4
- checkManifest,
5
3
  createDb
6
- } from "./chunk-ZAWES2UD.js";
7
- import "./chunk-E64SG24J.js";
8
- import "./chunk-YNUZRTPH.js";
9
- import "./chunk-6ELZRNUU.js";
10
- import "./chunk-2TWV3SVB.js";
11
- import "./chunk-ZZFWMVJO.js";
12
- import "./chunk-2XC5JLBO.js";
4
+ } from "./chunk-6CM3WZG5.js";
5
+ import {
6
+ checkEvaluated,
7
+ checkManifest
8
+ } from "./chunk-2B6YUYZV.js";
9
+ import "./chunk-KMFMD52Z.js";
13
10
  import "./chunk-KGHA67HG.js";
11
+ import "./chunk-ZJSFX4RD.js";
14
12
  import {
15
13
  refreshSchemaRegistry
16
- } from "./chunk-6XTU2MTP.js";
17
- import "./chunk-YFTLIEWU.js";
18
- import "./chunk-7D4GKZOX.js";
14
+ } from "./chunk-KFHKNXGH.js";
15
+ import "./chunk-RSEWEFAV.js";
16
+ import "./chunk-CIBJGB5H.js";
19
17
  import {
20
18
  OLD_OPS_SPECIFIER,
21
19
  OPS_MODULE,
22
20
  OPS_SPECIFIER
23
- } from "./chunk-LO6WGU5Y.js";
21
+ } from "./chunk-U72NEGCT.js";
22
+ import "./chunk-Q6Y45DY6.js";
23
+ import "./chunk-RGKJKC5T.js";
24
24
  import {
25
25
  __commonJS,
26
26
  __toESM
@@ -23663,8 +23663,8 @@ var require_dist2 = __commonJS({
23663
23663
  import { relative as relative3, resolve as resolve4 } from "node:path";
23664
23664
 
23665
23665
  // ../extension-check/src/node/check.ts
23666
- import { existsSync as existsSync2 } from "node:fs";
23667
- import { basename as basename2, dirname as dirname3, join as join4, resolve as resolve2 } from "node:path";
23666
+ import { existsSync as existsSync3 } from "node:fs";
23667
+ import { basename as basename2, dirname as dirname3, join as join5, resolve as resolve2 } from "node:path";
23668
23668
 
23669
23669
  // ../extension-check/src/node/evaluate.ts
23670
23670
  import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -23674,15 +23674,8 @@ import { pathToFileURL } from "node:url";
23674
23674
 
23675
23675
  // ../extension-check/src/build.ts
23676
23676
  var import_sucrase = __toESM(require_dist2(), 1);
23677
- var SDK_SPECIFIER = "cos-sdk";
23678
- var MAX_FILES = 100;
23679
- var MAX_SOURCE_BYTES = 1e6;
23680
- var SOURCE_RE = /\.(ts|js)$/;
23681
- var IMPORT_FROM_RE = /(\b(?:import|export)\b[^'"`;]*?\bfrom\s*)(["'])([^"'\n]+)\2/g;
23682
- var BARE_IMPORT_RE = /(?<!["'`])(\bimport\s*)(["'])([^"'\n]+)\2/g;
23683
- function stripComments(code) {
23684
- return code.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:\\])\/\/.*$/gm, "$1");
23685
- }
23677
+
23678
+ // ../extension-check/src/resolve.ts
23686
23679
  function normalise(path) {
23687
23680
  const parts = [];
23688
23681
  for (const part of path.split("/")) {
@@ -23694,18 +23687,27 @@ function normalise(path) {
23694
23687
  }
23695
23688
  return parts.join("/");
23696
23689
  }
23697
- function dirOf(path) {
23698
- const i = path.lastIndexOf("/");
23699
- return i === -1 ? "" : path.slice(0, i);
23700
- }
23701
- function resolveRelative(from, specifier, files) {
23702
- const base = normalise(`${dirOf(from)}/${specifier}`);
23690
+ function resolveOwnImport(from, specifier, has) {
23691
+ const i = from.lastIndexOf("/");
23692
+ const base = normalise(`${i === -1 ? "" : from.slice(0, i)}/${specifier}`);
23703
23693
  if (base === null) return null;
23704
- for (const candidate of [base, `${base}.ts`, `${base}.js`, `${base}/index.ts`]) {
23705
- if (Object.hasOwn(files, candidate) && SOURCE_RE.test(candidate)) return candidate;
23694
+ const stem = base.replace(/\.js$/, "");
23695
+ for (const candidate of [base, `${base}.ts`, `${stem}.ts`, `${base}.js`, `${base}/index.ts`]) {
23696
+ if (/\.(ts|js)$/.test(candidate) && has(candidate)) return candidate;
23706
23697
  }
23707
23698
  return null;
23708
23699
  }
23700
+
23701
+ // ../extension-check/src/build.ts
23702
+ var SDK_SPECIFIER = "cos-sdk";
23703
+ var MAX_FILES = 100;
23704
+ var MAX_SOURCE_BYTES = 1e6;
23705
+ var SOURCE_RE = /\.(ts|js)$/;
23706
+ var IMPORT_FROM_RE = /(\b(?:import|export)\b[^'"`;]*?\bfrom\s*)(["'])([^"'\n]+)\2/g;
23707
+ var BARE_IMPORT_RE = /(?<!["'`])(\bimport\s*)(["'])([^"'\n]+)\2/g;
23708
+ function stripComments(code) {
23709
+ return code.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:\\])\/\/.*$/gm, "$1");
23710
+ }
23709
23711
  var jsName = (path) => path.replace(/\.ts$/, ".js");
23710
23712
  function buildExtension(files) {
23711
23713
  const issues = [];
@@ -23765,7 +23767,7 @@ function buildExtension(files) {
23765
23767
  const rewrite = (_match, head, quote, specifier) => {
23766
23768
  if (specifier === "@composable-os/sdk") return `${head}${quote}${SDK_SPECIFIER}${quote}`;
23767
23769
  if (specifier.startsWith("./") || specifier.startsWith("../")) {
23768
- const target = resolveRelative(path, specifier, files);
23770
+ const target = resolveOwnImport(path, specifier, (p) => Object.hasOwn(files, p));
23769
23771
  if (!target) {
23770
23772
  issues.push({
23771
23773
  code: "import",
@@ -23884,17 +23886,6 @@ var MAX_TYPE_ISSUES = 50;
23884
23886
  var MAX_MESSAGE_LENGTH = 2e3;
23885
23887
  var ROOT = "/ext/";
23886
23888
  var SDK_SPECIFIER2 = "@composable-os/sdk";
23887
- function normalise2(path) {
23888
- const parts = [];
23889
- for (const part of path.split("/")) {
23890
- if (part === "" || part === ".") continue;
23891
- if (part === "..") {
23892
- if (!parts.length) return null;
23893
- parts.pop();
23894
- } else parts.push(part);
23895
- }
23896
- return parts.join("/");
23897
- }
23898
23889
  function createTypechecker(ts, types) {
23899
23890
  const OPTIONS = {
23900
23891
  target: ts.ScriptTarget.ES2022,
@@ -23926,17 +23917,14 @@ function createTypechecker(ts, types) {
23926
23917
  return { resolvedFileName: types.entry, extension: ts.Extension.Dts };
23927
23918
  }
23928
23919
  if (!specifier.startsWith("./") && !specifier.startsWith("../")) return void 0;
23929
- const dir = from.slice(ROOT.length).split("/").slice(0, -1).join("/");
23930
- const base = normalise2(`${dir}/${specifier}`);
23931
- if (base === null) return void 0;
23932
- const stem = base.replace(/\.js$/, "");
23933
- for (const candidate of [base, `${base}.ts`, `${stem}.ts`, `${base}.js`, `${base}/index.ts`]) {
23934
- if (/\.(ts|js)$/.test(candidate) && Object.hasOwn(files, candidate)) {
23935
- const extension = candidate.endsWith(".ts") ? ts.Extension.Ts : ts.Extension.Js;
23936
- return { resolvedFileName: `${ROOT}${candidate}`, extension };
23937
- }
23938
- }
23939
- return void 0;
23920
+ const target = resolveOwnImport(
23921
+ from.slice(ROOT.length),
23922
+ specifier,
23923
+ (p) => Object.hasOwn(files, p)
23924
+ );
23925
+ if (target === null) return void 0;
23926
+ const extension = target.endsWith(".ts") ? ts.Extension.Ts : ts.Extension.Js;
23927
+ return { resolvedFileName: `${ROOT}${target}`, extension };
23940
23928
  }
23941
23929
  function extensionOf(fileName) {
23942
23930
  if (fileName.endsWith(".d.cts")) return ts.Extension.Dcts;
@@ -24209,6 +24197,99 @@ function bundledPlatform() {
24209
24197
  return null;
24210
24198
  }
24211
24199
 
24200
+ // ../extension-check/src/node/portal.ts
24201
+ import { existsSync as existsSync2, readdirSync as readdirSync3, readFileSync as readFileSync3, statSync } from "node:fs";
24202
+ import { join as join4 } from "node:path";
24203
+ function openOperations(platformRoot) {
24204
+ const names = /* @__PURE__ */ new Set();
24205
+ for (const audience of ["customer", "public"]) {
24206
+ const file = join4(platformRoot, "packages", "core", "api", "v1", `${audience}.json`);
24207
+ if (!existsSync2(file)) return null;
24208
+ const contract = JSON.parse(readFileSync3(file, "utf8"));
24209
+ for (const op of contract.operations ?? []) names.add(op.name);
24210
+ }
24211
+ return names;
24212
+ }
24213
+ function codeFiles(dir) {
24214
+ const found = [];
24215
+ for (const name of readdirSync3(dir)) {
24216
+ const path = join4(dir, name);
24217
+ if (statSync(path).isDirectory()) found.push(...codeFiles(path));
24218
+ else if (/\.(tsx?|jsx?)$/.test(name)) found.push(path);
24219
+ }
24220
+ return found;
24221
+ }
24222
+ function portalBlockIssues(dir, manifest, platformRoot) {
24223
+ const sections = Object.entries(manifest.portal ?? {});
24224
+ if (!sections.length) return [];
24225
+ const issues = [];
24226
+ const issue = (path, message) => issues.push({ stage: "contract", code: "contract", path, message });
24227
+ const open = openOperations(platformRoot);
24228
+ const own = new Set(
24229
+ Object.entries(manifest.tools ?? {}).filter(([, tool]) => (tool.audiences ?? ["staff"]).some((a) => a !== "staff")).map(([name]) => `x.${manifest.id}.${name}`)
24230
+ );
24231
+ for (const [key, section] of sections) {
24232
+ for (const skin of ["web", "native"]) {
24233
+ const named = section[skin];
24234
+ if (!named) continue;
24235
+ const path = `portal.${key}.${skin}.block`;
24236
+ const folder = join4(dir, "blocks", named.block);
24237
+ const file = join4(folder, "block.json");
24238
+ if (!existsSync2(file)) {
24239
+ issue(
24240
+ path,
24241
+ `"${named.block}" is not a block of this pack: no blocks/${named.block}/block.json`
24242
+ );
24243
+ continue;
24244
+ }
24245
+ let block;
24246
+ try {
24247
+ block = JSON.parse(readFileSync3(file, "utf8"));
24248
+ } catch {
24249
+ issue(path, `blocks/${named.block}/block.json does not parse`);
24250
+ continue;
24251
+ }
24252
+ if (block.pack !== manifest.id) {
24253
+ issue(
24254
+ path,
24255
+ `"${named.block}" is not this pack's block: its block.json names pack ${JSON.stringify(block.pack)}`
24256
+ );
24257
+ }
24258
+ if (block.skin !== skin) {
24259
+ issue(
24260
+ path,
24261
+ `"${named.block}" is a ${String(block.skin)} block, named for the ${skin} section`
24262
+ );
24263
+ }
24264
+ const operations = Array.isArray(block.operations) ? block.operations : [];
24265
+ if (!open) {
24266
+ issue(
24267
+ path,
24268
+ "The platform's customer and public contracts (packages/core/api/v1) could not be read to check what the block calls"
24269
+ );
24270
+ } else {
24271
+ for (const op of operations) {
24272
+ if (typeof op !== "string" || !open.has(op) && !own.has(op)) {
24273
+ issue(
24274
+ path,
24275
+ `"${named.block}" calls ${String(op)}, which no customer may call: a section of My account calls only customer or public operations`
24276
+ );
24277
+ }
24278
+ }
24279
+ }
24280
+ const exported = new RegExp(`\\bexport\\s+(?:function|const)\\s+${named.export}\\b`);
24281
+ const found = codeFiles(folder).some((f) => exported.test(readFileSync3(f, "utf8")));
24282
+ if (!found) {
24283
+ issue(
24284
+ `portal.${key}.${skin}.export`,
24285
+ `"${named.block}" exports no component ${named.export}`
24286
+ );
24287
+ }
24288
+ }
24289
+ }
24290
+ return issues;
24291
+ }
24292
+
24212
24293
  // ../extension-check/src/node/check.ts
24213
24294
  var ExtCheckError = class extends Error {
24214
24295
  name = "ExtCheckError";
@@ -24220,24 +24301,33 @@ function siblingsNamed(dir, id, manifest) {
24220
24301
  const names = /* @__PURE__ */ new Set();
24221
24302
  for (const match of JSON.stringify(manifest).matchAll(/"([a-z][a-z0-9]{1,29})\.[A-Za-z]/g)) {
24222
24303
  const name = match[1];
24223
- if (name !== id && existsSync2(join4(dirname3(resolve2(dir)), name, "index.ts"))) names.add(name);
24304
+ if (name !== id && existsSync3(join5(dirname3(resolve2(dir)), name, "index.ts"))) names.add(name);
24224
24305
  }
24225
- const required = manifest?.requires;
24226
- for (const name of Array.isArray(required) ? required : []) {
24227
- if (typeof name === "string" && name !== id && existsSync2(join4(dirname3(resolve2(dir)), name, "index.ts"))) {
24306
+ const m = manifest;
24307
+ const onlyWith = Object.values(m?.automations ?? {}).flatMap((a) => {
24308
+ const ids = a?.onlyWith;
24309
+ return Array.isArray(ids) ? ids : [];
24310
+ });
24311
+ for (const name of [...Array.isArray(m?.requires) ? m.requires : [], ...onlyWith]) {
24312
+ if (typeof name === "string" && name !== id && existsSync3(join5(dirname3(resolve2(dir)), name, "index.ts"))) {
24228
24313
  names.add(name);
24229
24314
  }
24230
24315
  }
24231
24316
  return [...names].sort();
24232
24317
  }
24233
- async function installSibling(platform, local, dir, now, done) {
24318
+ async function installSibling(platform, local, dir, now, done, root) {
24234
24319
  const id = extensionIdOf(dir);
24235
24320
  if (done.has(id)) return null;
24236
24321
  done.add(id);
24237
24322
  const evaluated = await evaluateFiles(platform, readExtensionFiles(dir));
24238
24323
  if (!evaluated.ok) return evaluated.issues[0]?.message ?? "it does not evaluate";
24324
+ const requires = evaluated.manifest?.requires;
24325
+ if (Array.isArray(requires) && requires.includes(root)) {
24326
+ done.delete(id);
24327
+ return null;
24328
+ }
24239
24329
  for (const sibling of siblingsNamed(dir, id, evaluated.manifest)) {
24240
- const why = await installSibling(platform, local, join4(dirname3(dir), sibling), now, done);
24330
+ const why = await installSibling(platform, local, join5(dirname3(dir), sibling), now, done, root);
24241
24331
  if (why) return `${sibling}: ${why}`;
24242
24332
  }
24243
24333
  await refreshSchemaRegistry(local.db);
@@ -24284,7 +24374,7 @@ function located(files, issue) {
24284
24374
  }
24285
24375
  async function checkExtensionDir(dir, options = {}) {
24286
24376
  const root = resolve2(dir);
24287
- if (!existsSync2(root)) throw new ExtCheckError(`No such directory: ${dir}`);
24377
+ if (!existsSync3(root)) throw new ExtCheckError(`No such directory: ${dir}`);
24288
24378
  const platform = findPlatform(root);
24289
24379
  if (!platform) {
24290
24380
  throw new ExtCheckError(
@@ -24301,7 +24391,14 @@ async function checkExtensionDir(dir, options = {}) {
24301
24391
  const done = /* @__PURE__ */ new Set([id]);
24302
24392
  if (evaluated.ok) {
24303
24393
  for (const sibling of siblingsNamed(root, id, evaluated.manifest)) {
24304
- const why = await installSibling(platform, local, join4(dirname3(root), sibling), now, done);
24394
+ const why = await installSibling(
24395
+ platform,
24396
+ local,
24397
+ join5(dirname3(root), sibling),
24398
+ now,
24399
+ done,
24400
+ id
24401
+ );
24305
24402
  if (why) {
24306
24403
  before.push({
24307
24404
  stage: "reconcile",
@@ -24315,7 +24412,8 @@ async function checkExtensionDir(dir, options = {}) {
24315
24412
  }
24316
24413
  await refreshSchemaRegistry(local.db);
24317
24414
  const result = await checkEvaluated(local.db, id, evaluated, now, { installed: [...done] });
24318
- const issues = [...before, ...result.issues];
24415
+ const portal = result.manifest ? portalBlockIssues(root, result.manifest, platform.root) : [];
24416
+ const issues = [...before, ...result.issues, ...portal];
24319
24417
  return {
24320
24418
  ...result,
24321
24419
  id,
@@ -24329,17 +24427,17 @@ async function checkExtensionDir(dir, options = {}) {
24329
24427
 
24330
24428
  // ../extension-check/src/node/test.ts
24331
24429
  import { spawn } from "node:child_process";
24332
- import { existsSync as existsSync3, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "node:fs";
24333
- import { join as join5, resolve as resolve3 } from "node:path";
24430
+ import { existsSync as existsSync4, readdirSync as readdirSync4, readFileSync as readFileSync4 } from "node:fs";
24431
+ import { join as join6, resolve as resolve3 } from "node:path";
24334
24432
  function testFiles(dir) {
24335
24433
  const files = {};
24336
24434
  const walk = (current) => {
24337
- for (const entry of readdirSync3(current, { withFileTypes: true })) {
24338
- const path = join5(current, entry.name);
24435
+ for (const entry of readdirSync4(current, { withFileTypes: true })) {
24436
+ const path = join6(current, entry.name);
24339
24437
  if (entry.isDirectory()) {
24340
24438
  if (!["node_modules", "dist", ".turbo"].includes(entry.name)) walk(path);
24341
24439
  } else if (/\.test\.(ts|js)$/.test(entry.name)) {
24342
- files[path] = readFileSync3(path, "utf8");
24440
+ files[path] = readFileSync4(path, "utf8");
24343
24441
  }
24344
24442
  }
24345
24443
  };
@@ -24371,8 +24469,8 @@ async function untested(dir) {
24371
24469
  }
24372
24470
  function runVitest(dir) {
24373
24471
  const root = resolve3(dir);
24374
- const bin = join5(root, "node_modules", ".bin", "vitest");
24375
- if (!existsSync3(bin)) {
24472
+ const bin = join6(root, "node_modules", ".bin", "vitest");
24473
+ if (!existsSync4(bin)) {
24376
24474
  throw new ExtCheckError(
24377
24475
  `${dir} has no vitest installed (node_modules/.bin/vitest). Give it a package.json with vitest in devDependencies, as packs/deals has, and run pnpm install`
24378
24476
  );
@@ -24433,18 +24531,65 @@ async function check(dir, json, io) {
24433
24531
  );
24434
24532
  for (const line of outsideSummary(result.manifest)) io.out(line);
24435
24533
  for (const line of rolesSummary(result.manifest)) io.out(line);
24534
+ for (const line of routineMailSummary(result.manifest)) io.out(line);
24535
+ for (const line of journeySignalsSummary(result.manifest)) io.out(line);
24436
24536
  return 0;
24437
24537
  }
24538
+ function journeySignalsSummary(manifest) {
24539
+ const signals = Object.entries(manifest?.journeySignals ?? {});
24540
+ if (!manifest || !signals.length) return [];
24541
+ return [
24542
+ "This extension declares journey signals, recorded by the host for the Person on every write:",
24543
+ ...signals.map(
24544
+ ([name, signal]) => ` ${manifest.id}.${name} (${signal.label}): ${signal.object} ` + (signal.enters ? `enters ${signal.enters.join(" or ")}${signal.from ? ` from ${signal.from.join(" or ")}` : ""}` : "created")
24545
+ )
24546
+ ];
24547
+ }
24548
+ function routineMailSummary(manifest) {
24549
+ const kinds = Object.entries(manifest?.routineMail ?? {});
24550
+ if (!manifest || !kinds.length) return [];
24551
+ return [
24552
+ "This extension declares routine email, sent without a person's approval to whoever the record belongs to. Review its words:",
24553
+ ...kinds.map(
24554
+ ([name, kind]) => ` ${manifest.id}.${name} (${kind.label}): about ${kind.about}; messages ${Object.keys(kind.messages).join(", ")}; by ${(kind.channels ?? ["email"]).join(", ")}${kind.essential ?? (kind.purpose ?? "account") === "account" ? "" : "; optional"}${kind.urgent ? "; urgent" : ""}${kind.on === false ? "; off until an admin turns it on" : ""}`
24555
+ )
24556
+ ];
24557
+ }
24438
24558
  function rolesSummary(manifest) {
24439
24559
  const roles = Object.entries(manifest?.roles ?? {});
24440
- if (!manifest || !roles.length) return [];
24560
+ const grantable = manifest?.grantable ?? [];
24561
+ const restricted = manifest?.restricted ?? [];
24562
+ if (!manifest || !roles.length && !grantable.length && !restricted.length) return [];
24563
+ const opens = (permission) => Object.entries(manifest.tools ?? {}).filter(
24564
+ ([, tool]) => (typeof tool.permission === "string" ? [tool.permission] : tool.permission ?? []).includes(permission)
24565
+ ).map(([name]) => name);
24441
24566
  return [
24442
- "This extension declares staff roles. An account given one may do this and nothing else:",
24443
- ...roles.map(
24444
- ([name, role]) => ` role ${manifest.id}.${name} (${role.label}): tools with ${role.permissions.join(", ") || "no permission"}; reads ${role.read.join(", ") || "nothing"}`
24445
- )
24567
+ ...roles.length ? [
24568
+ grantable.length ? "This extension declares staff roles. An account given one may do this, and what it is granted below, and nothing else:" : "This extension declares staff roles. An account given one may do this and nothing else:",
24569
+ ...roles.map(
24570
+ ([name, role]) => ` role ${manifest.id}.${name} (${role.label}): tools with ${role.permissions.join(", ") || "no permission"}; reads ${role.read.join(", ") || "nothing"}` + // Limited to the People its holder looks after (ADR 0889).
24571
+ (role.looksAfter && Object.keys(role.looksAfter).length ? `; only the people its holder looks after on ${Object.keys(role.looksAfter).join(", ")}` : "") + // Reaching only the records that name its holder (ADR 0755).
24572
+ (role.mine && Object.keys(role.mine).length ? `; only through the ${[...new Set(Object.values(role.mine).map((m) => m.through))].join(", ")} records naming its holder on ${Object.keys(role.mine).join(", ")}` : "")
24573
+ )
24574
+ ] : [],
24575
+ // Granted one by one by a human admin (ADR 0449), to a role's account too (ADR 0600).
24576
+ ...grantable.length ? [
24577
+ "Permissions an admin may grant one by one (to an account with a role too):",
24578
+ ...grantable.map(
24579
+ (permission) => ` ${permission}: tools ${opens(permission).join(", ") || "none"}${restricted.includes(permission) ? " (restricted)" : ""}`
24580
+ )
24581
+ ] : [],
24582
+ // Held by admins and by grant only (ADR 0625): a member does not hold these tools.
24583
+ ...restricted.length ? [
24584
+ `Restricted (admins, and accounts an admin granted it; never a member otherwise): ${restricted.join(", ")}`
24585
+ ] : []
24446
24586
  ];
24447
24587
  }
24588
+ function whileText(when) {
24589
+ return (Array.isArray(when) ? when : [when]).map(
24590
+ (c) => c.field === void 0 ? `its ${c.via} is public` : `${c.via ? `its ${c.via}'s ` : ""}${c.field} is ${(c.in ?? []).join(" or ")}`
24591
+ ).join(" and ");
24592
+ }
24448
24593
  function outsideSummary(manifest) {
24449
24594
  if (!manifest) return [];
24450
24595
  const lines = [];
@@ -24458,8 +24603,7 @@ function outsideSummary(manifest) {
24458
24603
  }
24459
24604
  const p = object.public;
24460
24605
  if (p) {
24461
- const via = p.when?.via ? `its ${p.when.via}'s ` : "";
24462
- const while_ = p.when ? ` while ${via}${p.when.field} is ${p.when.in.join(" or ")}` : object.publishable ? "" : ", every record";
24606
+ const while_ = p.when ? ` while ${whileText(p.when)}` : object.publishable ? "" : ", every record";
24463
24607
  const published = object.publishable ? ", published versions only, by its slug" : "";
24464
24608
  lines.push(
24465
24609
  ` the public sees ${manifest.id}.${name}${published}${while_}: read ${p.read.join(", ")}`
@@ -24467,8 +24611,7 @@ function outsideSummary(manifest) {
24467
24611
  }
24468
24612
  const s = object.signedIn;
24469
24613
  if (s) {
24470
- const via = s.when?.via ? `its ${s.when.via}'s ` : "";
24471
- const while_ = s.when ? ` while ${via}${s.when.field} is ${s.when.in.join(" or ")}` : ", every record";
24614
+ const while_ = s.when ? ` while ${whileText(s.when)}` : ", every record";
24472
24615
  lines.push(
24473
24616
  ` every signed-in customer sees ${manifest.id}.${name}${while_}: read ${s.read.join(", ")}`
24474
24617
  );
@@ -24484,7 +24627,8 @@ function outsideSummary(manifest) {
24484
24627
  const g = c.guardians;
24485
24628
  const whose = g ? `is them or a child linked to them (${g.write ? "read and write" : "read only"})` : "is them";
24486
24629
  lines.push(
24487
- ` customers see ${manifest.id}.${name} where ${c.field} ${whose}: read ${c.read.join(", ") || "nothing"}; write ${c.write.join(", ") || "nothing"}`
24630
+ ` customers see ${manifest.id}.${name} where ${c.field} ${whose}: read ${c.read.join(", ") || "nothing"}; write ${c.write.join(", ") || "nothing"}` + // A customer's own records they may put in the Trash (ADR 0414, amended).
24631
+ (c.delete ? "; may put their own in the Trash (my.delete)" : "")
24488
24632
  );
24489
24633
  }
24490
24634
  for (const [name, tool] of Object.entries(manifest.tools)) {
@@ -24528,7 +24672,9 @@ async function runExt(argv, io) {
24528
24672
  export {
24529
24673
  EXT_HELP,
24530
24674
  formatIssue,
24675
+ journeySignalsSummary,
24531
24676
  outsideSummary,
24532
24677
  rolesSummary,
24678
+ routineMailSummary,
24533
24679
  runExt
24534
24680
  };
package/dist/cli.js CHANGED
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  ghAvailable,
4
4
  ghVerifier
5
- } from "./chunk-GYTEW66E.js";
5
+ } from "./chunk-O3R4FS2J.js";
6
6
  import {
7
7
  Redactor,
8
8
  runCli,
9
9
  terminalIo
10
- } from "./chunk-PDD2ETVF.js";
11
- import "./chunk-DU6OIFOU.js";
10
+ } from "./chunk-O37YUZ52.js";
11
+ import "./chunk-3OGDWKJ3.js";
12
12
  import "./chunk-KGHA67HG.js";
13
- import "./chunk-2ABSVMGB.js";
14
- import "./chunk-6UWRT4VM.js";
13
+ import "./chunk-SMJZIK2O.js";
14
+ import "./chunk-ZJSFX4RD.js";
15
15
  import "./chunk-5KSXSK7Y.js";
16
16
 
17
17
  // src/cli.ts
@@ -17,17 +17,18 @@ import {
17
17
  nativeRedirectUri,
18
18
  nativeRedirectUris,
19
19
  regenerate,
20
+ requiredPacks,
20
21
  templateFiles,
21
22
  typeErrors,
22
23
  upgradeRepo,
23
24
  withEnvBinding,
24
25
  withTsExtensions
25
- } from "./chunk-MBIKVRAC.js";
26
- import "./chunk-PDD2ETVF.js";
27
- import "./chunk-DU6OIFOU.js";
26
+ } from "./chunk-5YDYQM6V.js";
27
+ import "./chunk-O37YUZ52.js";
28
+ import "./chunk-3OGDWKJ3.js";
28
29
  import "./chunk-KGHA67HG.js";
29
- import "./chunk-2ABSVMGB.js";
30
- import "./chunk-6UWRT4VM.js";
30
+ import "./chunk-SMJZIK2O.js";
31
+ import "./chunk-ZJSFX4RD.js";
31
32
  import "./chunk-5KSXSK7Y.js";
32
33
  export {
33
34
  IMPORT_LOOPBACK_REDIRECT,
@@ -47,6 +48,7 @@ export {
47
48
  nativeRedirectUri,
48
49
  nativeRedirectUris,
49
50
  regenerate,
51
+ requiredPacks,
50
52
  templateFiles,
51
53
  typeErrors,
52
54
  upgradeRepo,
package/dist/create.js CHANGED
@@ -2,16 +2,16 @@
2
2
  import {
3
3
  ghAvailable,
4
4
  ghVerifier
5
- } from "./chunk-GYTEW66E.js";
5
+ } from "./chunk-O3R4FS2J.js";
6
6
  import {
7
7
  Redactor,
8
8
  runCli,
9
9
  terminalIo
10
- } from "./chunk-PDD2ETVF.js";
11
- import "./chunk-DU6OIFOU.js";
10
+ } from "./chunk-O37YUZ52.js";
11
+ import "./chunk-3OGDWKJ3.js";
12
12
  import "./chunk-KGHA67HG.js";
13
- import "./chunk-2ABSVMGB.js";
14
- import "./chunk-6UWRT4VM.js";
13
+ import "./chunk-SMJZIK2O.js";
14
+ import "./chunk-ZJSFX4RD.js";
15
15
  import "./chunk-5KSXSK7Y.js";
16
16
 
17
17
  // src/create.ts
@@ -9,41 +9,65 @@ import {
9
9
  personObject,
10
10
  setExtensionObjects,
11
11
  taskObject
12
- } from "./chunk-YFTLIEWU.js";
12
+ } from "./chunk-RSEWEFAV.js";
13
13
  import {
14
14
  BASE_OBJECTS,
15
15
  BASE_TABLES,
16
+ CREDIT_NOTE_STATES,
17
+ INVOICE_KINDS,
18
+ INVOICE_STATES,
19
+ LOCATION_STATES,
20
+ MAIN_LOCATION_FALLBACK,
21
+ MAIN_LOCATION_ID,
16
22
  ORDER_MACHINE,
17
23
  ORDER_STATES,
24
+ QUOTE_STATES,
25
+ TAX_MODES,
26
+ creditNoteObject,
18
27
  defineObject,
19
28
  getField,
29
+ invoiceObject,
30
+ locationObject,
20
31
  mediaObject,
21
32
  orderLineObject,
22
33
  orderObject,
34
+ quoteObject,
23
35
  timelineFields
24
- } from "./chunk-7D4GKZOX.js";
36
+ } from "./chunk-CIBJGB5H.js";
25
37
  import {
26
38
  MEDIA_TYPES
27
- } from "./chunk-LO6WGU5Y.js";
39
+ } from "./chunk-U72NEGCT.js";
28
40
  import "./chunk-5KSXSK7Y.js";
29
41
  export {
30
42
  BASE_OBJECTS,
31
43
  BASE_TABLES,
32
44
  CORE_OBJECTS,
45
+ CREDIT_NOTE_STATES,
46
+ INVOICE_KINDS,
47
+ INVOICE_STATES,
48
+ LOCATION_STATES,
49
+ MAIN_LOCATION_FALLBACK,
50
+ MAIN_LOCATION_ID,
33
51
  MEDIA_TYPES,
34
52
  ORDER_MACHINE,
35
53
  ORDER_STATES,
54
+ QUOTE_STATES,
55
+ TAX_MODES,
36
56
  activityObject,
57
+ creditNoteObject,
37
58
  defineObject,
38
59
  getField,
39
60
  getObject,
61
+ invoiceObject,
40
62
  isCoreObject,
41
63
  listObjects,
64
+ locationObject,
42
65
  mediaObject,
43
66
  orderLineObject,
44
67
  orderObject,
45
68
  organisationObject,
46
69
  personObject,
70
+ quoteObject,
47
71
  setExtensionObjects,
48
72
  taskObject,
49
73
  timelineFields
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ PAYMENTS_RESOURCE_PATTERN,
4
+ PAYMENTS_VENDOR,
5
+ REFUND_ACTION_KIND,
6
+ callSubscriptionGatekeeper,
7
+ openProviderCheckout,
8
+ paymentsTarget,
9
+ providerOfUrl,
10
+ requestProviderRefund,
11
+ sendHostEmail
12
+ } from "./chunk-Q6Y45DY6.js";
13
+ import "./chunk-RGKJKC5T.js";
14
+ import "./chunk-5KSXSK7Y.js";
15
+ export {
16
+ PAYMENTS_RESOURCE_PATTERN,
17
+ PAYMENTS_VENDOR,
18
+ REFUND_ACTION_KIND,
19
+ callSubscriptionGatekeeper,
20
+ openProviderCheckout,
21
+ paymentsTarget,
22
+ providerOfUrl,
23
+ requestProviderRefund,
24
+ sendHostEmail
25
+ };
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ GRANT_CODE_LENGTH,
4
+ grantFieldValue,
5
+ grantsFollowPerson,
6
+ handGrantValues,
7
+ newGrantCode,
8
+ readGrantItem,
9
+ validFrom
10
+ } from "./chunk-JX4IFWNT.js";
11
+ import "./chunk-KMFMD52Z.js";
12
+ import "./chunk-KGHA67HG.js";
13
+ import "./chunk-KFHKNXGH.js";
14
+ import "./chunk-RSEWEFAV.js";
15
+ import "./chunk-CIBJGB5H.js";
16
+ import "./chunk-U72NEGCT.js";
17
+ import "./chunk-RGKJKC5T.js";
18
+ import "./chunk-5KSXSK7Y.js";
19
+ export {
20
+ GRANT_CODE_LENGTH,
21
+ grantFieldValue,
22
+ grantsFollowPerson,
23
+ handGrantValues,
24
+ newGrantCode,
25
+ readGrantItem,
26
+ validFrom
27
+ };