@supacloud/cli 0.64.1 → 0.64.3

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 (3) hide show
  1. package/README.md +2 -0
  2. package/dist/index.js +241 -59
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -962,3 +962,5 @@ supacloud-cli gateway rebuild --ref abc123 --clean
962
962
  ```
963
963
 
964
964
  For server installation, SSH diagnostics, and tenant administration, use `@supacloud/admin`.
965
+
966
+ <!-- Keep Reactive Integration coverage active for CLI package changes. -->
package/dist/index.js CHANGED
@@ -213194,6 +213194,61 @@ var Delete = _Object_2({
213194
213194
  path: String3()
213195
213195
  });
213196
213196
  var Edit = Union3([Insert2, Update2, Delete]);
213197
+ // node_modules/@supacloud/delivery/src/worker-execution.ts
213198
+ var closed = { additionalProperties: false };
213199
+ var positive = (maximum) => Integer2({ minimum: 1, maximum });
213200
+ var WorkerExecutionGroupSchema = _Object_2({
213201
+ name: String3({ pattern: "^[a-z][a-z0-9-]{0,47}$" }),
213202
+ target: String3({ pattern: "^[a-z][a-z0-9-]{0,53}$" }),
213203
+ workloadClass: Union3([Literal2("interactive"), Literal2("batch")]),
213204
+ executor: Literal2("pgflow-queue"),
213205
+ runtime: Literal2("bun"),
213206
+ queue: String3({ pattern: "^scw_[a-z0-9_]{1,40}$" }),
213207
+ taskKey: String3({ pattern: "^[a-z][a-z0-9_.-]{0,99}$" }),
213208
+ definitionVersion: String3({ pattern: "^[1-9][0-9]{0,8}$" }),
213209
+ replicas: positive(16),
213210
+ maxReplicas: positive(16),
213211
+ concurrencyPerReplica: positive(32),
213212
+ resources: _Object_2({
213213
+ cpuLimit: Number3({ minimum: 0.1, maximum: 64, multipleOf: 0.1 }),
213214
+ memoryLimitMiB: Integer2({ minimum: 64, maximum: 262144 })
213215
+ }, closed),
213216
+ database: _Object_2({
213217
+ engineConnectionsPerReplica: positive(16),
213218
+ handlerConnectionsPerReplica: positive(16)
213219
+ }, closed),
213220
+ lifecycle: _Object_2({
213221
+ executionTimeoutSeconds: positive(3500),
213222
+ visibilityTimeoutSeconds: Integer2({ minimum: 15, maximum: 3600 }),
213223
+ shutdownGraceSeconds: positive(300)
213224
+ }, closed),
213225
+ retry: _Object_2({ maxAttempts: Integer2({ minimum: 1, maximum: 10 }) }, closed),
213226
+ admission: _Object_2({ maxOutstandingOperations: positive(1e6) }, closed)
213227
+ }, closed);
213228
+ var WorkerExecutionSchema = _Object_2({
213229
+ groups: _Array_(WorkerExecutionGroupSchema, { minItems: 1, maxItems: 32 })
213230
+ }, closed);
213231
+ function parseWorkerExecutionGroup(value) {
213232
+ if (!Check3(WorkerExecutionGroupSchema, value) || value.replicas > value.maxReplicas || !value.queue.endsWith(`_v${value.definitionVersion}`) || value.lifecycle.visibilityTimeoutSeconds < value.lifecycle.executionTimeoutSeconds + value.lifecycle.shutdownGraceSeconds + 30) {
213233
+ throw new Error("WORKER_EXECUTION_INVALID");
213234
+ }
213235
+ return structuredClone(value);
213236
+ }
213237
+ function validateWorkerExecution(groups) {
213238
+ const names = new Set, targets = new Set, queues = new Set, routes = new Set;
213239
+ for (const candidate of groups) {
213240
+ const group = parseWorkerExecutionGroup(candidate);
213241
+ const route = `${group.taskKey}:${group.definitionVersion}`;
213242
+ if (names.has(group.name) || targets.has(group.target) || queues.has(group.queue) || routes.has(route)) {
213243
+ throw new Error("WORKER_EXECUTION_CONFLICT");
213244
+ }
213245
+ names.add(group.name);
213246
+ targets.add(group.target);
213247
+ queues.add(group.queue);
213248
+ routes.add(route);
213249
+ }
213250
+ }
213251
+
213197
213252
  // node_modules/@supacloud/delivery/src/delivery-schema.ts
213198
213253
  var objectOptions = { additionalProperties: false };
213199
213254
  var reference = String3({ minLength: 1, maxLength: 128, pattern: "^[A-Za-z][A-Za-z0-9_.:/-]*$" });
@@ -213206,6 +213261,7 @@ var DeliveryFilePathSchema = String3({
213206
213261
  });
213207
213262
  var DeliveryOptionsSchema = _Object_2({
213208
213263
  version: Literal2(1),
213264
+ execution: Optional2(WorkerExecutionSchema),
213209
213265
  targets: Optional2(_Array_(_Object_2({
213210
213266
  name: String3({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
213211
213267
  kind,
@@ -213278,6 +213334,7 @@ var DeliveryTargetSchema = _Object_2({
213278
213334
  name: String3(),
213279
213335
  kind,
213280
213336
  isolation,
213337
+ execution: Optional2(WorkerExecutionGroupSchema),
213281
213338
  roots: _Array_(String3()),
213282
213339
  modules: _Array_(_Object_2({
213283
213340
  name: String3(),
@@ -213376,7 +213433,7 @@ async function readBoundedOwned(root, path, maximum) {
213376
213433
  }
213377
213434
 
213378
213435
  // node_modules/@supacloud/delivery/src/delivery-build-schema.ts
213379
- var closed = { additionalProperties: false };
213436
+ var closed2 = { additionalProperties: false };
213380
213437
  var digest2 = String3({ pattern: "^[a-f0-9]{64}$" });
213381
213438
  var DeliveryObjectSchema = _Object_2({
213382
213439
  name: String3({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
@@ -213393,8 +213450,8 @@ var DeliveryObjectSchema = _Object_2({
213393
213450
  path: DeliveryFilePathSchema,
213394
213451
  sha256: digest2,
213395
213452
  bytes: Integer2({ minimum: 0 })
213396
- }, closed), { minItems: 1 })
213397
- }, closed);
213453
+ }, closed2), { minItems: 1 })
213454
+ }, closed2);
213398
213455
  var DeliveryBuildManifestSchema = _Object_2({
213399
213456
  schemaVersion: Literal2(1),
213400
213457
  producer: Literal2("@supacloud/compiler/delivery-build-v1"),
@@ -213405,9 +213462,9 @@ var DeliveryBuildManifestSchema = _Object_2({
213405
213462
  method: String3(),
213406
213463
  path: String3(),
213407
213464
  target: String3()
213408
- }, closed)),
213409
- jobs: _Array_(_Object_2({ name: String3(), target: String3() }, closed))
213410
- }, closed);
213465
+ }, closed2)),
213466
+ jobs: _Array_(_Object_2({ name: String3(), target: String3() }, closed2))
213467
+ }, closed2);
213411
213468
  var resultFields = {
213412
213469
  diagnostics: _Array_(DeliveryDiagnosticSchema),
213413
213470
  written: _Array_(String3()),
@@ -213421,13 +213478,13 @@ var DeliveryBuildResultSchema = Union3([
213421
213478
  changedTargets: _Array_(String3()),
213422
213479
  unchangedTargets: _Array_(String3()),
213423
213480
  removedTargets: _Array_(String3())
213424
- }, closed),
213481
+ }, closed2),
213425
213482
  _Object_2({
213426
213483
  ...resultFields,
213427
213484
  written: _Array_(String3(), { maxItems: 0 }),
213428
213485
  ok: Literal2(false),
213429
213486
  manifest: Null2()
213430
- }, closed)
213487
+ }, closed2)
213431
213488
  ]);
213432
213489
  function deliveryObjectDigest(object) {
213433
213490
  return digest(canonical({
@@ -213439,6 +213496,12 @@ function deliveryObjectDigest(object) {
213439
213496
  function parseDeliveryBuildManifest(value) {
213440
213497
  if (!Check3(DeliveryBuildManifestSchema, value))
213441
213498
  throw new Error("Invalid delivery build manifest.");
213499
+ validateWorkerExecution(value.plan.targets.flatMap((target) => target.execution ? [target.execution] : []));
213500
+ for (const target of value.plan.targets) {
213501
+ if (target.execution && (target.kind !== "jobs" || target.isolation !== "process" || target.execution.target !== target.name || target.jobs.length !== 1 || target.jobs[0]?.name !== target.execution.taskKey || value.objects.find((object) => object.name === target.name)?.entryKind !== "bun-worker-application")) {
213502
+ throw new Error("Invalid delivery execution binding.");
213503
+ }
213504
+ }
213442
213505
  if (new Set(value.objects.map((item) => item.name)).size !== value.objects.length) {
213443
213506
  throw new Error("Duplicate delivery object owner.");
213444
213507
  }
@@ -213516,7 +213579,6 @@ async function readVerifiedDeliveryFiles(root, object, target, selectedPaths) {
213516
213579
  }
213517
213580
  return retained;
213518
213581
  }
213519
-
213520
213582
  // node_modules/@supacloud/delivery/src/application-release.ts
213521
213583
  var ApplicationIdSchema = String3({ pattern: "^[A-Za-z0-9_-]{1,64}$" });
213522
213584
  var ApplicationReleaseIdSchema = String3({ pattern: "^[a-f0-9]{64}$" });
@@ -213531,7 +213593,8 @@ var ApplicationReleaseRecordSchema = _Object_2({
213531
213593
  name: String3({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
213532
213594
  object_id: ApplicationReleaseIdSchema,
213533
213595
  kind: Union3([Literal2("http"), Literal2("worker")]),
213534
- entrypoint: Literal2("bundle/index.js")
213596
+ entrypoint: Literal2("bundle/index.js"),
213597
+ execution: Optional2(WorkerExecutionGroupSchema)
213535
213598
  }, { additionalProperties: false }), { minItems: 1, maxItems: 32 })
213536
213599
  }, { additionalProperties: false });
213537
213600
  function applicationReleaseId(projectRef, applicationId, manifestSha256) {
@@ -213546,6 +213609,10 @@ function parseApplicationReleaseRecord(candidate) {
213546
213609
  if (!Check3(ApplicationReleaseRecordSchema, candidate) || applicationReleaseId(candidate.project_ref, candidate.application_id, candidate.manifest_sha256) !== candidate.release_id || !Number.isFinite(Date.parse(candidate.created_at)) || new Date(candidate.created_at).toISOString() !== candidate.created_at || new Set(candidate.targets.map((target) => target.name)).size !== candidate.targets.length) {
213547
213610
  throw new Error("Invalid application release record.");
213548
213611
  }
213612
+ validateWorkerExecution(candidate.targets.flatMap((target) => target.execution ? [target.execution] : []));
213613
+ if (candidate.targets.some((target) => target.execution && (target.kind !== "worker" || target.execution.target !== target.name))) {
213614
+ throw new Error("Invalid application execution binding.");
213615
+ }
213549
213616
  return candidate;
213550
213617
  }
213551
213618
 
@@ -213603,7 +213670,9 @@ var APPLICATION_RESERVED_ENVIRONMENT_NAMES = new Set([
213603
213670
  "SUPACLOUD_ACTIVATION_ID",
213604
213671
  "SUPACLOUD_ENVIRONMENT_ID",
213605
213672
  "SUPACLOUD_TARGET",
213606
- "SUPACLOUD_OBJECT_ID"
213673
+ "SUPACLOUD_OBJECT_ID",
213674
+ "SUPACLOUD_WORKER_EXECUTION",
213675
+ "SUPACLOUD_WORKER_REPLICA"
213607
213676
  ]);
213608
213677
  function assertTargets(targets) {
213609
213678
  const names = new Set, usedHosts = new Set;
@@ -239852,12 +239921,77 @@ var init_value2 = __esm2(() => {
239852
239921
  init_repair2();
239853
239922
  init_shared();
239854
239923
  });
239924
+ function parseWorkerExecutionGroup2(value) {
239925
+ if (!Check22(WorkerExecutionGroupSchema2, value) || value.replicas > value.maxReplicas || !value.queue.endsWith(`_v${value.definitionVersion}`) || value.lifecycle.visibilityTimeoutSeconds < value.lifecycle.executionTimeoutSeconds + value.lifecycle.shutdownGraceSeconds + 30) {
239926
+ throw new Error("WORKER_EXECUTION_INVALID");
239927
+ }
239928
+ return structuredClone(value);
239929
+ }
239930
+ function validateWorkerExecution2(groups) {
239931
+ const names = new Set, targets = new Set, queues = new Set, routes = new Set;
239932
+ for (const candidate of groups) {
239933
+ const group = parseWorkerExecutionGroup2(candidate);
239934
+ const route = `${group.taskKey}:${group.definitionVersion}`;
239935
+ if (names.has(group.name) || targets.has(group.target) || queues.has(group.queue) || routes.has(route)) {
239936
+ throw new Error("WORKER_EXECUTION_CONFLICT");
239937
+ }
239938
+ names.add(group.name);
239939
+ targets.add(group.target);
239940
+ queues.add(group.queue);
239941
+ routes.add(route);
239942
+ }
239943
+ }
239944
+ var closed3;
239945
+ var positive2 = (maximum) => Integer4({ minimum: 1, maximum });
239946
+ var WorkerExecutionGroupSchema2;
239947
+ var WorkerExecutionSchema2;
239948
+ var init_worker_execution = __esm2(() => {
239949
+ init_build();
239950
+ init_value2();
239951
+ closed3 = { additionalProperties: false };
239952
+ WorkerExecutionGroupSchema2 = _Object_3({
239953
+ name: String22({ pattern: "^[a-z][a-z0-9-]{0,47}$" }),
239954
+ target: String22({ pattern: "^[a-z][a-z0-9-]{0,53}$" }),
239955
+ workloadClass: Union4([Literal3("interactive"), Literal3("batch")]),
239956
+ executor: Literal3("pgflow-queue"),
239957
+ runtime: Literal3("bun"),
239958
+ queue: String22({ pattern: "^scw_[a-z0-9_]{1,40}$" }),
239959
+ taskKey: String22({ pattern: "^[a-z][a-z0-9_.-]{0,99}$" }),
239960
+ definitionVersion: String22({ pattern: "^[1-9][0-9]{0,8}$" }),
239961
+ replicas: positive2(16),
239962
+ maxReplicas: positive2(16),
239963
+ concurrencyPerReplica: positive2(32),
239964
+ resources: _Object_3({
239965
+ cpuLimit: Number22({ minimum: 0.1, maximum: 64, multipleOf: 0.1 }),
239966
+ memoryLimitMiB: Integer4({ minimum: 64, maximum: 262144 })
239967
+ }, closed3),
239968
+ database: _Object_3({
239969
+ engineConnectionsPerReplica: positive2(16),
239970
+ handlerConnectionsPerReplica: positive2(16)
239971
+ }, closed3),
239972
+ lifecycle: _Object_3({
239973
+ executionTimeoutSeconds: positive2(3500),
239974
+ visibilityTimeoutSeconds: Integer4({ minimum: 15, maximum: 3600 }),
239975
+ shutdownGraceSeconds: positive2(300)
239976
+ }, closed3),
239977
+ retry: _Object_3({ maxAttempts: Integer4({ minimum: 1, maximum: 10 }) }, closed3),
239978
+ admission: _Object_3({ maxOutstandingOperations: positive2(1e6) }, closed3)
239979
+ }, closed3);
239980
+ WorkerExecutionSchema2 = _Object_3({
239981
+ groups: _Array_2(WorkerExecutionGroupSchema2, { minItems: 1, maxItems: 32 })
239982
+ }, closed3);
239983
+ });
239855
239984
  function parseDeliveryOptions(value) {
239856
239985
  if (value === undefined)
239857
239986
  return { version: 1 };
239858
239987
  if (!Check22(DeliveryOptionsSchema2, value))
239859
239988
  throw new DeliveryConfigurationError;
239860
239989
  const migrations = value.build?.migrations ?? [];
239990
+ try {
239991
+ validateWorkerExecution2(value.execution?.groups ?? []);
239992
+ } catch {
239993
+ throw new DeliveryConfigurationError;
239994
+ }
239861
239995
  if (new Set(migrations.map((item) => item.version)).size !== migrations.length || new Set(migrations.map((item) => item.source)).size !== migrations.length || migrations.some((item) => BigInt(item.version) > 9223372036854775807n || !/\.sql$/i.test(item.source) || item.source.split("/").includes("node_modules"))) {
239862
239996
  throw new DeliveryConfigurationError;
239863
239997
  }
@@ -239885,6 +240019,7 @@ var DeliveryConfigurationError;
239885
240019
  var init_delivery_schema = __esm2(() => {
239886
240020
  init_build();
239887
240021
  init_value2();
240022
+ init_worker_execution();
239888
240023
  objectOptions2 = { additionalProperties: false };
239889
240024
  reference2 = String22({ minLength: 1, maxLength: 128, pattern: "^[A-Za-z][A-Za-z0-9_.:/-]*$" });
239890
240025
  references2 = _Array_2(reference2, { uniqueItems: true });
@@ -239896,6 +240031,7 @@ var init_delivery_schema = __esm2(() => {
239896
240031
  });
239897
240032
  DeliveryOptionsSchema2 = _Object_3({
239898
240033
  version: Literal3(1),
240034
+ execution: Optional4(WorkerExecutionSchema2),
239899
240035
  targets: Optional4(_Array_2(_Object_3({
239900
240036
  name: String22({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
239901
240037
  kind: kind3,
@@ -239968,6 +240104,7 @@ var init_delivery_schema = __esm2(() => {
239968
240104
  name: String22(),
239969
240105
  kind: kind3,
239970
240106
  isolation: isolation2,
240107
+ execution: Optional4(WorkerExecutionGroupSchema2),
239971
240108
  roots: _Array_2(String22()),
239972
240109
  modules: _Array_2(_Object_3({
239973
240110
  name: String22(),
@@ -240175,6 +240312,12 @@ function deliveryObjectDigest2(object) {
240175
240312
  function parseDeliveryBuildManifest2(value) {
240176
240313
  if (!Check22(DeliveryBuildManifestSchema2, value))
240177
240314
  throw new Error("Invalid delivery build manifest.");
240315
+ validateWorkerExecution2(value.plan.targets.flatMap((target) => target.execution ? [target.execution] : []));
240316
+ for (const target of value.plan.targets) {
240317
+ if (target.execution && (target.kind !== "jobs" || target.isolation !== "process" || target.execution.target !== target.name || target.jobs.length !== 1 || target.jobs[0]?.name !== target.execution.taskKey || value.objects.find((object) => object.name === target.name)?.entryKind !== "bun-worker-application")) {
240318
+ throw new Error("Invalid delivery execution binding.");
240319
+ }
240320
+ }
240178
240321
  if (new Set(value.objects.map((item) => item.name)).size !== value.objects.length) {
240179
240322
  throw new Error("Duplicate delivery object owner.");
240180
240323
  }
@@ -240204,7 +240347,7 @@ function parseDeliveryBuildResult(value) {
240204
240347
  parseDeliveryBuildManifest2(value.manifest);
240205
240348
  return value;
240206
240349
  }
240207
- var closed2;
240350
+ var closed22;
240208
240351
  var digest22;
240209
240352
  var DeliveryObjectSchema2;
240210
240353
  var DeliveryBuildManifestSchema2;
@@ -240215,7 +240358,8 @@ var init_delivery_build_schema = __esm2(() => {
240215
240358
  init_value2();
240216
240359
  init_delivery_schema();
240217
240360
  init_delivery_files();
240218
- closed2 = { additionalProperties: false };
240361
+ init_worker_execution();
240362
+ closed22 = { additionalProperties: false };
240219
240363
  digest22 = String22({ pattern: "^[a-f0-9]{64}$" });
240220
240364
  DeliveryObjectSchema2 = _Object_3({
240221
240365
  name: String22({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
@@ -240232,8 +240376,8 @@ var init_delivery_build_schema = __esm2(() => {
240232
240376
  path: DeliveryFilePathSchema2,
240233
240377
  sha256: digest22,
240234
240378
  bytes: Integer4({ minimum: 0 })
240235
- }, closed2), { minItems: 1 })
240236
- }, closed2);
240379
+ }, closed22), { minItems: 1 })
240380
+ }, closed22);
240237
240381
  DeliveryBuildManifestSchema2 = _Object_3({
240238
240382
  schemaVersion: Literal3(1),
240239
240383
  producer: Literal3("@supacloud/compiler/delivery-build-v1"),
@@ -240244,9 +240388,9 @@ var init_delivery_build_schema = __esm2(() => {
240244
240388
  method: String22(),
240245
240389
  path: String22(),
240246
240390
  target: String22()
240247
- }, closed2)),
240248
- jobs: _Array_2(_Object_3({ name: String22(), target: String22() }, closed2))
240249
- }, closed2);
240391
+ }, closed22)),
240392
+ jobs: _Array_2(_Object_3({ name: String22(), target: String22() }, closed22))
240393
+ }, closed22);
240250
240394
  resultFields2 = {
240251
240395
  diagnostics: _Array_2(DeliveryDiagnosticSchema2),
240252
240396
  written: _Array_2(String22()),
@@ -240260,13 +240404,13 @@ var init_delivery_build_schema = __esm2(() => {
240260
240404
  changedTargets: _Array_2(String22()),
240261
240405
  unchangedTargets: _Array_2(String22()),
240262
240406
  removedTargets: _Array_2(String22())
240263
- }, closed2),
240407
+ }, closed22),
240264
240408
  _Object_3({
240265
240409
  ...resultFields2,
240266
240410
  written: _Array_2(String22(), { maxItems: 0 }),
240267
240411
  ok: Literal3(false),
240268
240412
  manifest: Null3()
240269
- }, closed2)
240413
+ }, closed22)
240270
240414
  ]);
240271
240415
  });
240272
240416
  function createContextPack(graph, subject) {
@@ -240621,7 +240765,7 @@ function serializedExecutionSnapshot(graph) {
240621
240765
  parseExecutionSnapshot(wire);
240622
240766
  return json;
240623
240767
  }
240624
- var closed22;
240768
+ var closed32;
240625
240769
  var text2;
240626
240770
  var kind22;
240627
240771
  var SnapshotSchema;
@@ -240632,7 +240776,7 @@ var init_execution_snapshot = __esm2(() => {
240632
240776
  init_build();
240633
240777
  init_value2();
240634
240778
  init_inspect();
240635
- closed22 = { additionalProperties: false };
240779
+ closed32 = { additionalProperties: false };
240636
240780
  text2 = String22({ minLength: 1, maxLength: 512, pattern: "^[^\\u0000-\\u001f\\u007f]+$" });
240637
240781
  kind22 = Union4([Literal3("route"), Literal3("command"), Literal3("job")]);
240638
240782
  SnapshotSchema = _Object_3({
@@ -240643,12 +240787,12 @@ var init_execution_snapshot = __esm2(() => {
240643
240787
  name: text2,
240644
240788
  command: Optional4(text2),
240645
240789
  stages: _Array_2(text2)
240646
- }, closed22)),
240647
- commandAliases: _Array_2(_Object_3({ module: text2, name: text2, alias: text2 }, closed22)),
240790
+ }, closed32)),
240791
+ commandAliases: _Array_2(_Object_3({ module: text2, name: text2, alias: text2 }, closed32)),
240648
240792
  contexts: _Array_2(_Object_3({
240649
240793
  subject: text2,
240650
240794
  aliases: _Array_2(text2),
240651
- modules: _Array_2(_Object_3({ name: text2, file: Optional4(text2) }, closed22)),
240795
+ modules: _Array_2(_Object_3({ name: text2, file: Optional4(text2) }, closed32)),
240652
240796
  files: _Array_2(text2),
240653
240797
  diagnostics: _Array_2(_Object_3({
240654
240798
  code: text2,
@@ -240658,10 +240802,10 @@ var init_execution_snapshot = __esm2(() => {
240658
240802
  repair: Optional4(_Object_3({
240659
240803
  type: text2,
240660
240804
  readiness: Union4([Literal3("preview"), Literal3("input-required"), Literal3("manual")])
240661
- }, closed22))
240662
- }, closed22))
240663
- }, closed22))
240664
- }, closed22);
240805
+ }, closed32))
240806
+ }, closed32))
240807
+ }, closed32))
240808
+ }, closed32);
240665
240809
  indices = _Array_2(Integer4({ minimum: 0 }));
240666
240810
  WireSnapshotSchema = _Object_3({
240667
240811
  version: Literal3(1),
@@ -240676,8 +240820,8 @@ var init_execution_snapshot = __esm2(() => {
240676
240820
  modules: indices,
240677
240821
  files: indices,
240678
240822
  diagnostics: indices
240679
- }, closed22))
240680
- }, closed22);
240823
+ }, closed32))
240824
+ }, closed32);
240681
240825
  });
240682
240826
  function safeSourceFile(file) {
240683
240827
  return !file.startsWith("/") && !file.startsWith("\\") && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(file) && !file.split(/[\\/]/).includes("..");
@@ -240713,7 +240857,7 @@ var APPLICATION_DEVELOPMENT_SCHEMA = "supacloud.application-development.v1";
240713
240857
  var APPLICATION_DEVELOPMENT_ARCHIVE_MAX_BYTES = 524288;
240714
240858
  var APPLICATION_DEVELOPMENT_LIMITS;
240715
240859
  var DevelopmentContractError;
240716
- var closed3;
240860
+ var closed4;
240717
240861
  var text22;
240718
240862
  var texts;
240719
240863
  var count;
@@ -240746,13 +240890,13 @@ var init_application_development = __esm2(() => {
240746
240890
  this.name = "DevelopmentContractError";
240747
240891
  }
240748
240892
  };
240749
- closed3 = { additionalProperties: false };
240893
+ closed4 = { additionalProperties: false };
240750
240894
  text22 = String22({ minLength: 1, maxLength: 512, pattern: "^[^\\u0000-\\u001f\\u007f]+$" });
240751
240895
  texts = _Array_2(text22);
240752
240896
  count = Integer4({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER });
240753
240897
  mode = Union4([Literal3("required"), Literal3("none")]);
240754
240898
  operations2 = _Array_2(Union4([Literal3("read"), Literal3("write"), Literal3("publish"), Literal3("consume")]));
240755
- resourceUse = _Object_3({ resource: text22, operations: operations2 }, closed3);
240899
+ resourceUse = _Object_3({ resource: text22, operations: operations2 }, closed4);
240756
240900
  schemaKind = Optional4(Union4([Literal3("opaque"), Literal3("declared")]));
240757
240901
  stage = Union4([
240758
240902
  Union4([Literal3("commandExecutor"), Literal3("jobExecutor"), Literal3("authorize"), Literal3("idempotency"), Literal3("transaction"), Literal3("handler"), Literal3("audit")]),
@@ -240777,7 +240921,7 @@ var init_application_development = __esm2(() => {
240777
240921
  jobs: texts,
240778
240922
  queries: texts,
240779
240923
  resources: texts
240780
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.modules }),
240924
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.modules }),
240781
240925
  routes: _Array_2(_Object_3({
240782
240926
  module: text22,
240783
240927
  method: Union4([Literal3("GET"), Literal3("POST"), Literal3("PUT"), Literal3("PATCH"), Literal3("DELETE"), Literal3("HEAD"), Literal3("OPTIONS")]),
@@ -240793,8 +240937,8 @@ var init_application_development = __esm2(() => {
240793
240937
  headers: schemaKind,
240794
240938
  cookie: schemaKind,
240795
240939
  response: schemaKind
240796
- }, closed3))
240797
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.routes }),
240940
+ }, closed4))
240941
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.routes }),
240798
240942
  commands: _Array_2(_Object_3({
240799
240943
  module: text22,
240800
240944
  name: text22,
@@ -240803,28 +240947,28 @@ var init_application_development = __esm2(() => {
240803
240947
  idempotency: mode,
240804
240948
  audit: Optional4(text22),
240805
240949
  resources: _Array_2(resourceUse)
240806
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.commands }),
240950
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.commands }),
240807
240951
  jobs: _Array_2(_Object_3({
240808
240952
  module: text22,
240809
240953
  name: text22,
240810
240954
  mode: Optional4(Union4([Literal3("task"), Literal3("workflow")])),
240811
240955
  resources: _Array_2(resourceUse)
240812
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.jobs }),
240813
- resources: _Array_2(_Object_3({ name: text22, kind: Union4([Literal3("database"), Literal3("bucket"), Literal3("queue"), Literal3("config"), Literal3("secret")]) }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resources }),
240956
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.jobs }),
240957
+ resources: _Array_2(_Object_3({ name: text22, kind: Union4([Literal3("database"), Literal3("bucket"), Literal3("queue"), Literal3("config"), Literal3("secret")]) }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resources }),
240814
240958
  resourceUses: _Array_2(_Object_3({
240815
240959
  module: text22,
240816
240960
  owner: text22,
240817
240961
  ownerKind: Union4([Literal3("command"), Literal3("job")]),
240818
240962
  resource: text22,
240819
240963
  operations: operations2
240820
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resourceUses }),
240964
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.resourceUses }),
240821
240965
  executionPlans: _Array_2(_Object_3({
240822
240966
  module: text22,
240823
240967
  kind: Union4([Literal3("route"), Literal3("command"), Literal3("job")]),
240824
240968
  name: text22,
240825
240969
  command: Optional4(text22),
240826
240970
  stages: _Array_2(stage)
240827
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.plans }),
240971
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.plans }),
240828
240972
  diagnostics: _Array_2(_Object_3({
240829
240973
  code: text22,
240830
240974
  severity: Union4([Literal3("error"), Literal3("warn")]),
@@ -240833,8 +240977,8 @@ var init_application_development = __esm2(() => {
240833
240977
  repair: Optional4(_Object_3({
240834
240978
  type: Union4([Literal3("set_command_mode"), Literal3("add_module_import"), Literal3("add_provider"), Literal3("mark_optional_dependency"), Literal3("change_provider_scope"), Literal3("add_command_permission"), Literal3("add_route_parameter_binding"), Literal3("remove_route_body_binding")]),
240835
240979
  readiness: Union4([Literal3("preview"), Literal3("input-required"), Literal3("manual")])
240836
- }, closed3))
240837
- }, closed3), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.diagnostics }),
240980
+ }, closed4))
240981
+ }, closed4), { maxItems: APPLICATION_DEVELOPMENT_LIMITS.diagnostics }),
240838
240982
  omitted: _Object_3({
240839
240983
  modules: count,
240840
240984
  providers: count,
@@ -240845,7 +240989,7 @@ var init_application_development = __esm2(() => {
240845
240989
  resourceUses: count,
240846
240990
  plans: count,
240847
240991
  diagnostics: count
240848
- }, closed3),
240992
+ }, closed4),
240849
240993
  limits: _Object_3({
240850
240994
  outputBytes: Literal3(APPLICATION_DEVELOPMENT_LIMITS.outputBytes),
240851
240995
  modules: Literal3(APPLICATION_DEVELOPMENT_LIMITS.modules),
@@ -240857,8 +241001,8 @@ var init_application_development = __esm2(() => {
240857
241001
  resourceUses: Literal3(APPLICATION_DEVELOPMENT_LIMITS.resourceUses),
240858
241002
  plans: Literal3(APPLICATION_DEVELOPMENT_LIMITS.plans),
240859
241003
  diagnostics: Literal3(APPLICATION_DEVELOPMENT_LIMITS.diagnostics)
240860
- }, closed3)
240861
- }, closed3);
241004
+ }, closed4)
241005
+ }, closed4);
240862
241006
  });
240863
241007
  function parseApplicationDevelopmentContext(input) {
240864
241008
  try {
@@ -241038,6 +241182,7 @@ var init_application_release = __esm2(() => {
241038
241182
  init_build();
241039
241183
  init_value2();
241040
241184
  init_delivery_files();
241185
+ init_worker_execution();
241041
241186
  ApplicationIdSchema3 = String22({ pattern: "^[A-Za-z0-9_-]{1,64}$" });
241042
241187
  ApplicationReleaseIdSchema3 = String22({ pattern: "^[a-f0-9]{64}$" });
241043
241188
  ApplicationReleaseRecordSchema3 = _Object_3({
@@ -241051,7 +241196,8 @@ var init_application_release = __esm2(() => {
241051
241196
  name: String22({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
241052
241197
  object_id: ApplicationReleaseIdSchema3,
241053
241198
  kind: Union4([Literal3("http"), Literal3("worker")]),
241054
- entrypoint: Literal3("bundle/index.js")
241199
+ entrypoint: Literal3("bundle/index.js"),
241200
+ execution: Optional4(WorkerExecutionGroupSchema2)
241055
241201
  }, { additionalProperties: false }), { minItems: 1, maxItems: 32 })
241056
241202
  }, { additionalProperties: false });
241057
241203
  });
@@ -241122,7 +241268,9 @@ var init_application_configuration = __esm2(() => {
241122
241268
  "SUPACLOUD_ACTIVATION_ID",
241123
241269
  "SUPACLOUD_ENVIRONMENT_ID",
241124
241270
  "SUPACLOUD_TARGET",
241125
- "SUPACLOUD_OBJECT_ID"
241271
+ "SUPACLOUD_OBJECT_ID",
241272
+ "SUPACLOUD_WORKER_EXECUTION",
241273
+ "SUPACLOUD_WORKER_REPLICA"
241126
241274
  ]);
241127
241275
  });
241128
241276
  var ApplicationActivationIdSchema3;
@@ -241229,6 +241377,7 @@ var init_delivery_migration_archive = __esm2(() => {
241229
241377
  var init_delivery_migration_plan = () => {};
241230
241378
  var init_src = __esm2(() => {
241231
241379
  init_delivery_artifact();
241380
+ init_worker_execution();
241232
241381
  init_application_activation();
241233
241382
  init_application_release();
241234
241383
  init_application_configuration();
@@ -245166,6 +245315,17 @@ function createDeliveryPlan(graph, input) {
245166
245315
  }
245167
245316
  }
245168
245317
  }
245318
+ for (const group of options.execution?.groups ?? []) {
245319
+ const target = targets.get(group.target);
245320
+ if (!target || target.kind !== "jobs" || target.isolation !== "process" || target.jobs.length !== 1 || target.jobs[0]?.name !== group.taskKey || !options.build?.workerApplications?.some((item) => item.target === group.target)) {
245321
+ fail("delivery-execution-binding-invalid", `Execution group "${group.name}" requires one matching compiled Job and a Worker host.`, "Bind one versioned queue/task to one process-isolated jobs target with build.workerApplications.");
245322
+ } else {
245323
+ target.execution = group;
245324
+ }
245325
+ }
245326
+ if ([...targets.values()].reduce((count, target) => count + (target.execution?.replicas ?? 1), 0) > 32) {
245327
+ fail("delivery-execution-replica-limit", "A release supports at most 32 runtime targets including replicas.", "Reduce the replica count or split independent applications.");
245328
+ }
245169
245329
  const canonicalDiagnostics = [...new Map(diagnostics.map((item) => [JSON.stringify(item), item])).values()].sort((a, b) => compare2(JSON.stringify(a), JSON.stringify(b)));
245170
245330
  if (canonicalDiagnostics.some((item) => item.severity === "error")) {
245171
245331
  return parseDeliveryPlanResult({ ok: false, plan: null, diagnostics: canonicalDiagnostics, written: [] });
@@ -245244,7 +245404,7 @@ function renderDeliveryTarget(graph, target, options) {
245244
245404
  init_delivery_files2();
245245
245405
  init_build();
245246
245406
  init_value2();
245247
- var closed4 = { additionalProperties: false };
245407
+ var closed5 = { additionalProperties: false };
245248
245408
  var requestSchema = _Object_3({
245249
245409
  parentPid: Integer4({ minimum: 1 }),
245250
245410
  name: String22(),
@@ -245252,15 +245412,15 @@ var requestSchema = _Object_3({
245252
245412
  project: String22(),
245253
245413
  generatedDirectory: String22(),
245254
245414
  options: DeliveryOptionsSchema2
245255
- }, closed4);
245415
+ }, closed5);
245256
245416
  var responseSchema2 = Union4([
245257
245417
  _Object_3({
245258
245418
  ok: Literal3(true),
245259
245419
  files: _Array_2(Tuple3([DeliveryFilePathSchema2, String22({ pattern: "^[A-Za-z0-9+/]*={0,2}$" })])),
245260
245420
  inputs: _Array_2(Tuple3([String22(), String22({ pattern: "^[a-f0-9]{64}$" })])),
245261
245421
  runtimeImports: _Array_2(String22())
245262
- }, closed4),
245263
- _Object_3({ ok: Literal3(false) }, closed4)
245422
+ }, closed5),
245423
+ _Object_3({ ok: Literal3(false) }, closed5)
245264
245424
  ]);
245265
245425
  function parseDeliveryBundleResponse(input) {
245266
245426
  if (!Check22(responseSchema2, input))
@@ -245489,6 +245649,7 @@ function renderDeliveryWorkerEntry(generatedDirectory, hostPath) {
245489
245649
  const specifier = relativeImportPath(generatedDirectory, hostPath);
245490
245650
  return `
245491
245651
  import deliveryProcess from "node:process";
245652
+ import { isDeepStrictEqual as deliveryPolicyEqual } from "node:util";
245492
245653
  import { createDeliveryWorker } from ${JSON.stringify(specifier)};
245493
245654
  ${renderDeliveryRuntimeIdentity()}
245494
245655
 
@@ -245496,6 +245657,8 @@ interface DeliveryWorkerHost {
245496
245657
  start(): void | Promise<void>;
245497
245658
  close(): void | Promise<void>;
245498
245659
  failure?: Promise<never>;
245660
+ execution?: unknown;
245661
+ health?(): Promise<{ ready: boolean; active: number; completed: number; failed: number; timedOut: number }>;
245499
245662
  }
245500
245663
 
245501
245664
  {
@@ -245507,6 +245670,7 @@ interface DeliveryWorkerHost {
245507
245670
  let closing: Promise<void> | undefined;
245508
245671
  let deadline: ReturnType<typeof setTimeout> | undefined;
245509
245672
  let keepAlive: ReturnType<typeof setInterval> | undefined;
245673
+ let healthPending = false;
245510
245674
  const finish = (failed: boolean) => {
245511
245675
  clearTimeout(deadline);
245512
245676
  clearInterval(keepAlive);
@@ -245567,6 +245731,13 @@ interface DeliveryWorkerHost {
245567
245731
  const candidate = await createHost(createCompiledModules(), { signal: lifecycle.signal });
245568
245732
  if (!candidate || typeof candidate.close !== "function") throw new Error("Invalid delivery worker host.");
245569
245733
  host = candidate;
245734
+ const execution = deliveryProcess.env.SUPACLOUD_WORKER_EXECUTION;
245735
+ if (execution) {
245736
+ const expected: unknown = JSON.parse(Buffer.from(execution, "base64").toString("utf8"));
245737
+ if (!deliveryPolicyEqual(host.execution, expected) || typeof host.health !== "function" || !host.failure) {
245738
+ throw new Error("Delivery worker execution policy was not adopted.");
245739
+ }
245740
+ }
245570
245741
  if (typeof host.start !== "function") throw new Error("Invalid delivery worker host.");
245571
245742
  if (host.failure !== undefined) {
245572
245743
  if (!host.failure || typeof host.failure.then !== "function") throw new Error("Invalid worker failure signal.");
@@ -245578,7 +245749,18 @@ interface DeliveryWorkerHost {
245578
245749
  await finishShutdown();
245579
245750
  } else {
245580
245751
  running = true;
245581
- keepAlive = setInterval(() => {}, 1000);
245752
+ const health = async () => {
245753
+ if (!execution || !host?.health || healthPending || lifecycle.signal.aborted) return;
245754
+ healthPending = true;
245755
+ try {
245756
+ const status = await host.health();
245757
+ console.log(JSON.stringify({ event: "delivery-worker-health", identity, observedAt: new Date().toISOString(), ...status }));
245758
+ } catch {
245759
+ console.log(JSON.stringify({ event: "delivery-worker-health", identity, observedAt: new Date().toISOString(), ready: false }));
245760
+ } finally { healthPending = false; }
245761
+ };
245762
+ keepAlive = setInterval(() => { void health(); }, execution ? 5000 : 1000);
245763
+ await health();
245582
245764
  console.log(JSON.stringify({ event: "delivery-worker-started", ...(identity ? { identity } : {}) }));
245583
245765
  }
245584
245766
  } catch {
@@ -246666,7 +246848,7 @@ var starter_metadata_default = {
246666
246848
  generatedBy: "supacloud/starter-metadata-v1",
246667
246849
  packages: {
246668
246850
  compiler: {
246669
- version: "0.31.2"
246851
+ version: "0.32.0"
246670
246852
  },
246671
246853
  app: {
246672
246854
  version: "0.22.0",
@@ -254397,7 +254579,7 @@ function registerRemoteDevTools(server2, options = {}) {
254397
254579
  // package.json
254398
254580
  var package_default = {
254399
254581
  name: "@supacloud/cli",
254400
- version: "0.64.1",
254582
+ version: "0.64.3",
254401
254583
  description: "Project-scoped CLI for SupaCloud users",
254402
254584
  type: "module",
254403
254585
  main: "./dist/index.js",
@@ -254432,14 +254614,14 @@ var package_default = {
254432
254614
  },
254433
254615
  dependencies: {
254434
254616
  "@sinclair/typebox": "^0.34.52",
254435
- "@supacloud/compiler": "^0.31.2",
254436
- "@supacloud/delivery": "0.4.0",
254617
+ "@supacloud/compiler": "^0.32.0",
254618
+ "@supacloud/delivery": "0.5.0",
254437
254619
  "@supacloud/db": "^0.2.0",
254438
254620
  fflate: "^0.8.3",
254439
254621
  typebox: "1.3.34"
254440
254622
  },
254441
254623
  overrides: {
254442
- "@supacloud/delivery": "0.4.0"
254624
+ "@supacloud/delivery": "0.5.0"
254443
254625
  },
254444
254626
  devDependencies: {
254445
254627
  "@supacloud/elysia": "^0.23.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.64.1",
3
+ "version": "0.64.3",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@sinclair/typebox": "^0.34.52",
38
- "@supacloud/compiler": "^0.31.2",
39
- "@supacloud/delivery": "0.4.0",
38
+ "@supacloud/compiler": "^0.32.0",
39
+ "@supacloud/delivery": "0.5.0",
40
40
  "@supacloud/db": "^0.2.0",
41
41
  "fflate": "^0.8.3",
42
42
  "typebox": "1.3.34"
43
43
  },
44
44
  "overrides": {
45
- "@supacloud/delivery": "0.4.0"
45
+ "@supacloud/delivery": "0.5.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@supacloud/elysia": "^0.23.1",