@composable-os/cli 0.1.0-beta.7 → 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 (64) hide show
  1. package/dist/accounts-D6N77JGP.js +44 -0
  2. package/dist/{blocks-HVTAQ5W2.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-2P4AZTFL.js → chunk-P6YZMS3F.js} +11 -5
  17. package/dist/{chunk-Y7PQ7NIL.js → chunk-RFJOPI42.js} +138 -14
  18. package/dist/{chunk-VL62IMBN.js → chunk-RXRD34QW.js} +10 -8
  19. package/dist/{chunk-BEKL3CA2.js → chunk-STBMGUTM.js} +7065 -4580
  20. package/dist/chunk-VTQNOQGA.js +150 -0
  21. package/dist/chunk-XSE37HK5.js +426 -0
  22. package/dist/{chunk-MINQ46RU.js → chunk-Z52IX5WL.js} +257 -844
  23. package/dist/chunk-ZSR5H4O7.js +552 -0
  24. package/dist/{cli-XHC6QBQW.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-G55G4OLV.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-AZFEPZOE.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/0520_publish_requests.sql +20 -0
  37. package/dist/platform/migrations/0530_subscriptions.sql +173 -0
  38. package/dist/platform/migrations/0531_subscription_trials.sql +56 -0
  39. package/dist/platform/migrations/0532_subscription_offers.sql +80 -0
  40. package/dist/platform/migrations/0533_allowances.sql +262 -0
  41. package/dist/platform/migrations/0560_recurring.sql +75 -0
  42. package/dist/platform/sdk/allowance.ts +508 -0
  43. package/dist/platform/sdk/capacity.ts +89 -0
  44. package/dist/platform/sdk/contract.ts +97 -1
  45. package/dist/platform/sdk/document.ts +161 -14
  46. package/dist/platform/sdk/field-types.ts +5 -0
  47. package/dist/platform/sdk/index.ts +3 -0
  48. package/dist/platform/sdk/manifest.ts +206 -5
  49. package/dist/platform/sdk/media.ts +62 -0
  50. package/dist/platform/sdk/recurring.ts +314 -0
  51. package/dist/platform/sdk/rich-text.ts +52 -4
  52. package/dist/platform/sdk/sellable.ts +120 -0
  53. package/dist/platform/sdk/states.ts +162 -1
  54. package/dist/platform/sdk/unique.ts +81 -0
  55. package/dist/run-BMSZKTN3.js +648 -0
  56. package/dist/run-GMQBAV6H.js +309 -0
  57. package/dist/{run-4JNFLYXV.js → run-TNHMG5RI.js} +51 -390
  58. package/dist/src-7DXXGZG2.js +38 -0
  59. package/dist/{src-J27WXNLY.js → src-BDG7PERB.js} +73 -1
  60. package/dist/visibility-XSBZTO66.js +33 -0
  61. package/package.json +2 -2
  62. package/dist/chunk-MAXLUQKB.js +0 -1287
  63. package/dist/invoke-5SR5ZWW7.js +0 -26
  64. package/dist/src-SSVOBH6L.js +0 -31
@@ -12,19 +12,21 @@ import {
12
12
  STATEMENTS_CALIBRATED,
13
13
  coreRegistry,
14
14
  toolOperation
15
- } from "./chunk-BEKL3CA2.js";
15
+ } from "./chunk-STBMGUTM.js";
16
16
  import {
17
- AUDIENCES,
18
17
  JOB_CHANGE_CALIBRATED,
19
18
  ROUTINE_GATE_CALIBRATED,
19
+ choice
20
+ } from "./chunk-Z52IX5WL.js";
21
+ import {
22
+ AUDIENCES,
20
23
  audiencesOf,
21
- choice,
22
24
  forPacks
23
- } from "./chunk-MINQ46RU.js";
25
+ } from "./chunk-VTQNOQGA.js";
24
26
  import {
25
27
  external_exports,
26
28
  toManifest
27
- } from "./chunk-X6I2LWB3.js";
29
+ } from "./chunk-2MLAPQU7.js";
28
30
 
29
31
  // ../core/src/judge/questions/orchestrator-suggest.ts
30
32
  var ORCHESTRATOR_PLACEMENT = "orchestrator.suggest";
@@ -93,6 +95,10 @@ var SIGN_IN_CONFIRM_TTL_MS = 5 * 60 * 1e3;
93
95
  // ../core/src/http/idempotency.ts
94
96
  var IDEMPOTENCY_TTL_MS = 24 * 3600 * 1e3;
95
97
 
98
+ // ../core/src/http/media.ts
99
+ var PUBLIC_MEDIA_ROUTE = "/api/v1/media";
100
+ var FAKE_STREAM_PREFIX = `${PUBLIC_MEDIA_ROUTE}/fake-stream/`;
101
+
96
102
  // ../core/src/judge/calibrated.ts
97
103
  var CALIBRATED = {
98
104
  ...Object.fromEntries(
@@ -43,7 +43,13 @@ import {
43
43
  withDeploymentVar,
44
44
  workersDevHostname,
45
45
  writeDeploymentState
46
- } from "./chunk-ZRWF6QZS.js";
46
+ } from "./chunk-DU6OIFOU.js";
47
+ import {
48
+ PROVIDER_INFO,
49
+ ROLE_PRESETS,
50
+ RoleLayerError,
51
+ modelRolesVar
52
+ } from "./chunk-KGHA67HG.js";
47
53
  import {
48
54
  DEFAULT_PRODUCT,
49
55
  products
@@ -51,12 +57,6 @@ import {
51
57
  import {
52
58
  PRODUCT_LABEL_VAR
53
59
  } from "./chunk-6UWRT4VM.js";
54
- import {
55
- PROVIDER_INFO,
56
- ROLE_PRESETS,
57
- RoleLayerError,
58
- modelRolesVar
59
- } from "./chunk-KGHA67HG.js";
60
60
 
61
61
  // src/io.ts
62
62
  import { createInterface } from "node:readline/promises";
@@ -151,6 +151,24 @@ A client repo (stage 24)
151
151
  problem; a re-run creates nothing twice; --publish
152
152
  publishes (or schedules) them with their own dates
153
153
  (docs/importing.md)
154
+ cos courses import <folder> --host <url> [--email <you>] [--dry-run] [--publish] [--yes]
155
+ [--wait <minutes>]
156
+ load courses, bundles, their videos (to Stream) and the
157
+ students' access, completions and lesson progress from an
158
+ old course platform, as you; checks first, uploads nothing
159
+ twice on a re-run, keeps a student's own progress
160
+ (docs/importing.md)
161
+ cos subscriptions offers import <offers.csv> --host <url> --plan <object>[:<id>]
162
+ [--email <you>] [--dry-run] [--invite] [--reissue]
163
+ continuation offers for people subscribed on another
164
+ platform (email, paid-up date): each signs in and
165
+ subscribes again, free until that date; people come
166
+ first, none is created; --invite lets them sign in under
167
+ any sign-up setting; --reissue gives an address staff
168
+ withdrew a fresh offer (docs/importing.md)
169
+ cos subscriptions offers report --host <url> [--status taken] [--out <file.csv>]
170
+ who has taken their offer and when they are charged from,
171
+ so you end exactly those old subscriptions
154
172
 
155
173
  Installing a product with no client repo
156
174
  cos install [options] install, or repair an existing install (idempotent)
@@ -242,7 +260,9 @@ function parseArgs(argv) {
242
260
  "accept",
243
261
  "with-mobile",
244
262
  "dry-run",
245
- "publish"
263
+ "publish",
264
+ "invite",
265
+ "reissue"
246
266
  ].includes(key);
247
267
  let value = true;
248
268
  if (takesValue) {
@@ -431,6 +451,23 @@ function aiChoice(flags, env) {
431
451
  function randomSecret() {
432
452
  return toHex(crypto.getRandomValues(new Uint8Array(32)));
433
453
  }
454
+ var FAKE_PROVIDER_VAR = "PAYMENTS_FAKE_PROVIDER";
455
+ var FAKE_SECRET = "FAKE_WEBHOOK_SECRET";
456
+ function generateFakePaymentsSecrets(manifest, gatekeepers, vars, secrets, stored, redactor) {
457
+ for (const name of gatekeepers) {
458
+ const worker = manifest.workers.find((w) => w.name === name);
459
+ if (!worker?.secrets?.some((s) => s.name === FAKE_SECRET)) continue;
460
+ if (vars[name] && FAKE_SECRET in vars[name]) {
461
+ const { [FAKE_SECRET]: _plain, ...rest } = vars[name];
462
+ vars[name] = rest;
463
+ }
464
+ if (vars[name]?.[FAKE_PROVIDER_VAR] !== "true") continue;
465
+ if (stored.get(name)?.includes(FAKE_SECRET) || secrets[name]?.[FAKE_SECRET]) continue;
466
+ const secret = randomSecret();
467
+ redactor.add(secret);
468
+ secrets[name] = { ...secrets[name], [FAKE_SECRET]: secret };
469
+ }
470
+ }
434
471
  async function latestVersion(s, channel) {
435
472
  const releases = await listReleases(channel, s.github);
436
473
  const latest = releases[0];
@@ -580,9 +617,11 @@ async function install(flags, deps) {
580
617
  );
581
618
  }
582
619
  }
620
+ const gatekeeperSet = /* @__PURE__ */ new Map();
583
621
  for (const name of gatekeepers) {
584
622
  const worker = manifest.workers.find((w) => w.name === name);
585
623
  const set = scripts.has(deployedAs(name)) ? await s.api.listSecrets(s.accountId, deployedAs(name)) : [];
624
+ gatekeeperSet.set(name, set);
586
625
  for (const secret of worker?.secrets ?? []) {
587
626
  if (!secret.required || set.includes(secret.name) || secrets[name]?.[secret.name]) continue;
588
627
  if (flags.yes || !io.interactive) {
@@ -632,6 +671,7 @@ async function install(flags, deps) {
632
671
  vars[worker] = { ...vars[worker], ...values };
633
672
  }
634
673
  }
674
+ generateFakePaymentsSecrets(manifest, gatekeepers, vars, secrets, gatekeeperSet, deps.redactor);
635
675
  const sendEmailFlag = str(flags, "send-email");
636
676
  const sendEmail = {
637
677
  ...previous?.sendEmail ?? {},
@@ -1042,7 +1082,7 @@ async function uninstall(flags, deps) {
1042
1082
  async function ext(argv, deps) {
1043
1083
  let runExt;
1044
1084
  try {
1045
- ({ runExt } = await import("./cli-BRSACHSG.js"));
1085
+ ({ runExt } = await import("./cli-T6MJM7TU.js"));
1046
1086
  return await runExt(argv, deps.io);
1047
1087
  } catch (error) {
1048
1088
  if (error.code === "ERR_MODULE_NOT_FOUND") {
@@ -1056,7 +1096,7 @@ async function ext(argv, deps) {
1056
1096
  }
1057
1097
  async function client(argv, deps) {
1058
1098
  if (argv[0] === "generate" && !argv.includes("--out")) {
1059
- const repo = await import("./client-repo-G55G4OLV.js");
1099
+ const repo = await import("./client-repo-PC4ISVEZ.js");
1060
1100
  const parsed = parseArgs(["client", ...argv.slice(1)]);
1061
1101
  const dir = str(parsed.flags, "dir") ?? process.cwd();
1062
1102
  if (repo.isClientRepo(dir)) {
@@ -1070,7 +1110,7 @@ async function client(argv, deps) {
1070
1110
  }
1071
1111
  }
1072
1112
  try {
1073
- const { runClient } = await import("./cli-XHC6QBQW.js");
1113
+ const { runClient } = await import("./cli-7A5XHYML.js");
1074
1114
  return await runClient(argv, deps.io);
1075
1115
  } catch (error) {
1076
1116
  if (error.code === "ERR_MODULE_NOT_FOUND") {
@@ -1098,7 +1138,7 @@ async function content(argv, deps) {
1098
1138
  deps.io.err(error.message);
1099
1139
  return 2;
1100
1140
  }
1101
- const { contentImport } = await import("./run-4JNFLYXV.js");
1141
+ const { contentImport } = await import("./run-TNHMG5RI.js");
1102
1142
  try {
1103
1143
  return await contentImport(
1104
1144
  positional,
@@ -1116,9 +1156,93 @@ async function content(argv, deps) {
1116
1156
  return 1;
1117
1157
  }
1118
1158
  }
1159
+ async function courses(argv, deps) {
1160
+ const usage = "Usage: cos courses import <folder> --host <url> [--email <you>] [--dry-run] [--publish] [--yes] [--wait <minutes>]";
1161
+ if (argv[0] !== "import") {
1162
+ deps.io.err(usage);
1163
+ return 2;
1164
+ }
1165
+ const rest = argv.slice(1);
1166
+ const positional = rest[0] && !rest[0].startsWith("-") ? [rest[0]] : [];
1167
+ let parsed;
1168
+ try {
1169
+ parsed = parseArgs(["import", ...rest.slice(positional.length)]);
1170
+ } catch (error) {
1171
+ deps.io.err(error.message);
1172
+ return 2;
1173
+ }
1174
+ const wait = str(parsed.flags, "wait");
1175
+ if (wait !== void 0 && !/^\d{1,4}$/.test(wait)) {
1176
+ deps.io.err("--wait is minutes, a whole number");
1177
+ return 2;
1178
+ }
1179
+ const { coursesImport } = await import("./run-BMSZKTN3.js");
1180
+ try {
1181
+ return await coursesImport(
1182
+ positional,
1183
+ {
1184
+ ...str(parsed.flags, "host") ? { host: str(parsed.flags, "host") } : {},
1185
+ ...str(parsed.flags, "email") ? { email: str(parsed.flags, "email") } : {},
1186
+ dryRun: Boolean(parsed.flags["dry-run"]),
1187
+ publish: Boolean(parsed.flags.publish),
1188
+ yes: Boolean(parsed.flags.yes),
1189
+ ...wait !== void 0 ? { wait: Number(wait) } : {}
1190
+ },
1191
+ deps.io
1192
+ );
1193
+ } catch (error) {
1194
+ deps.io.err(`Error: ${error.message}`);
1195
+ return 1;
1196
+ }
1197
+ }
1198
+ async function subscriptions(argv, deps) {
1199
+ const { OFFERS_USAGE, offersImport, offersReport } = await import("./run-GMQBAV6H.js");
1200
+ if (argv[0] !== "offers" || argv[1] !== "import" && argv[1] !== "report") {
1201
+ deps.io.err(OFFERS_USAGE);
1202
+ return 2;
1203
+ }
1204
+ const rest = argv.slice(2);
1205
+ const positional = argv[1] === "import" && rest[0] && !rest[0].startsWith("-") ? [rest[0]] : [];
1206
+ let parsed;
1207
+ try {
1208
+ parsed = parseArgs([argv[1], ...rest.slice(positional.length)]);
1209
+ } catch (error) {
1210
+ deps.io.err(error.message);
1211
+ return 2;
1212
+ }
1213
+ const flag = (name) => {
1214
+ const value = str(parsed.flags, name);
1215
+ return value !== void 0 ? { [name]: value } : {};
1216
+ };
1217
+ try {
1218
+ if (argv[1] === "report") {
1219
+ return await offersReport(
1220
+ { ...flag("host"), ...flag("email"), ...flag("status"), ...flag("out") },
1221
+ deps.io
1222
+ );
1223
+ }
1224
+ return await offersImport(
1225
+ positional,
1226
+ {
1227
+ ...flag("host"),
1228
+ ...flag("email"),
1229
+ ...flag("plan"),
1230
+ dryRun: Boolean(parsed.flags["dry-run"]),
1231
+ invite: Boolean(parsed.flags.invite),
1232
+ reissue: Boolean(parsed.flags.reissue)
1233
+ },
1234
+ deps.io
1235
+ );
1236
+ } catch (error) {
1237
+ deps.io.err(`Error: ${error.message}`);
1238
+ return 1;
1239
+ }
1240
+ }
1119
1241
  async function runCli(argv, input) {
1120
1242
  const deps = input;
1121
1243
  if (argv[0] === "content") return content(argv.slice(1), deps);
1244
+ if (argv[0] === "courses") return courses(argv.slice(1), deps);
1245
+ if (argv[0] === "subscriptions") return subscriptions(argv.slice(1), deps);
1122
1246
  if (argv[0] === "ext") return ext(argv.slice(1), deps);
1123
1247
  if (argv[0] === "client") return client(argv.slice(1), deps);
1124
1248
  const positional = ["create", "add", "diff"].includes(argv[0] ?? "") && argv[1] && !argv[1].startsWith("-") ? [argv[1]] : [];
@@ -1133,8 +1257,8 @@ async function runCli(argv, input) {
1133
1257
  deps.io.out(HELP);
1134
1258
  return argv.length ? 0 : 2;
1135
1259
  }
1136
- const repo = await import("./client-repo-G55G4OLV.js");
1137
- const blocks = await import("./blocks-HVTAQ5W2.js");
1260
+ const repo = await import("./client-repo-PC4ISVEZ.js");
1261
+ const blocks = await import("./blocks-4CA4PP3P.js");
1138
1262
  const commands = {
1139
1263
  install,
1140
1264
  // In a client repo (its product.ts is a client product), `cos upgrade` moves the repo to a
@@ -7,7 +7,7 @@ import {
7
7
  str,
8
8
  upgrade,
9
9
  verified
10
- } from "./chunk-Y7PQ7NIL.js";
10
+ } from "./chunk-RFJOPI42.js";
11
11
  import {
12
12
  CloudflareClient,
13
13
  assetHash,
@@ -16,7 +16,7 @@ import {
16
16
  releaseAssetNames,
17
17
  sha256Hex,
18
18
  toBase64
19
- } from "./chunk-ZRWF6QZS.js";
19
+ } from "./chunk-DU6OIFOU.js";
20
20
  import {
21
21
  DEFAULT_PRODUCT,
22
22
  products
@@ -413,8 +413,8 @@ function appClients(product) {
413
413
  return out;
414
414
  }
415
415
  async function generateClients(root, product, kit, io) {
416
- const { releaseContract, renderClient } = await import("./src-SSVOBH6L.js");
417
- const { loadExtension } = await import("./cli-XHC6QBQW.js");
416
+ const { releaseContract, renderClient } = await import("./src-7DXXGZG2.js");
417
+ const { loadExtension } = await import("./cli-7A5XHYML.js");
418
418
  const perAudience = ["customer", "public", "staff"].map((audience) => {
419
419
  const bytes = kit.get(`${KIT.contract}${audience}.json`);
420
420
  if (!bytes) throw new CliError(`The release's client kit has no ${audience} contract.`);
@@ -431,7 +431,7 @@ async function generateClients(root, product, kit, io) {
431
431
  }
432
432
  const roles = product.mobile?.roles ?? [];
433
433
  if (roles.length && product.mobile) {
434
- const { renderRoleClient } = await import("./src-SSVOBH6L.js");
434
+ const { renderRoleClient } = await import("./src-7DXXGZG2.js");
435
435
  const rolesFile = kit.get(`${KIT.contract}roles.json`);
436
436
  if (!rolesFile) {
437
437
  throw new CliError(
@@ -941,7 +941,7 @@ function orgExtensionSources(root) {
941
941
  async function checkOrgExtensions(root, io) {
942
942
  const dirs = orgExtensionDirs(root);
943
943
  if (!dirs.length) return true;
944
- const { runExt } = await import("./cli-BRSACHSG.js");
944
+ const { runExt } = await import("./cli-T6MJM7TU.js");
945
945
  let ok = true;
946
946
  for (const dir of dirs) {
947
947
  io.out(`cos ext check ${relative2(root, dir)}`);
@@ -1268,7 +1268,9 @@ async function deploy(flags, deps) {
1268
1268
  for (const worker of gatekeepers.workers) {
1269
1269
  const deployedAs = deployedWorker(worker.name);
1270
1270
  const set = await api.listSecrets(accountId, deployedAs);
1271
- const missing2 = (worker.secrets ?? []).filter((s) => !set.includes(s.name));
1271
+ const missing2 = (worker.secrets ?? []).filter(
1272
+ (s) => s.source !== "generated" && !set.includes(s.name)
1273
+ );
1272
1274
  if (!missing2.length) continue;
1273
1275
  io.out(`
1274
1276
  ${deployedAs} has no ${missing2.map((s) => s.name).join(", ")}. A person sets each:`);
@@ -1315,7 +1317,7 @@ async function upgradeRepo(flags, deps) {
1315
1317
  return packagesAndTypes(root, product, version, io);
1316
1318
  }
1317
1319
  io.out(`Moving from ${product.platform.version} to ${version}.`);
1318
- const { CONTRACT_VERSION } = await import("./src-J27WXNLY.js");
1320
+ const { CONTRACT_VERSION } = await import("./src-BDG7PERB.js");
1319
1321
  if (orgExtensionDirs(root).length && !manifest.extensionContract.supported.includes(CONTRACT_VERSION)) {
1320
1322
  io.err(
1321
1323
  `${version} does not support extension contract ${CONTRACT_VERSION}, which extensions/ is written against: nothing changed.`