@supacloud/compiler 0.31.2 → 0.33.0

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.
@@ -7,6 +7,40 @@ declare const requestSchema: Type.TObject<{
7
7
  generatedDirectory: Type.TString;
8
8
  options: Type.TObject<{
9
9
  version: Type.TLiteral<1>;
10
+ execution: Type.TOptional<Type.TObject<{
11
+ groups: Type.TArray<Type.TObject<{
12
+ name: Type.TString;
13
+ target: Type.TString;
14
+ workloadClass: Type.TUnion<[Type.TLiteral<"interactive">, Type.TLiteral<"batch">]>;
15
+ executor: Type.TLiteral<"pgflow-queue">;
16
+ runtime: Type.TLiteral<"bun">;
17
+ queue: Type.TString;
18
+ taskKey: Type.TString;
19
+ definitionVersion: Type.TString;
20
+ replicas: Type.TInteger;
21
+ maxReplicas: Type.TInteger;
22
+ concurrencyPerReplica: Type.TInteger;
23
+ resources: Type.TObject<{
24
+ cpuLimit: Type.TNumber;
25
+ memoryLimitMiB: Type.TInteger;
26
+ }>;
27
+ database: Type.TObject<{
28
+ engineConnectionsPerReplica: Type.TInteger;
29
+ handlerConnectionsPerReplica: Type.TInteger;
30
+ }>;
31
+ lifecycle: Type.TObject<{
32
+ executionTimeoutSeconds: Type.TInteger;
33
+ visibilityTimeoutSeconds: Type.TInteger;
34
+ shutdownGraceSeconds: Type.TInteger;
35
+ }>;
36
+ retry: Type.TObject<{
37
+ maxAttempts: Type.TInteger;
38
+ }>;
39
+ admission: Type.TObject<{
40
+ maxOutstandingOperations: Type.TInteger;
41
+ }>;
42
+ }>>;
43
+ }>>;
10
44
  targets: Type.TOptional<Type.TArray<Type.TObject<{
11
45
  name: Type.TString;
12
46
  kind: Type.TUnion<[Type.TLiteral<"api">, Type.TLiteral<"jobs">, Type.TLiteral<"webhook">]>;
@@ -9980,6 +9980,65 @@ var init_build2 = __esm(() => {
9980
9980
  init_types2();
9981
9981
  });
9982
9982
 
9983
+ // node_modules/@supacloud/delivery/src/worker-execution.ts
9984
+ function parseWorkerExecutionGroup(value) {
9985
+ if (!Check2(WorkerExecutionGroupSchema, value) || value.replicas > value.maxReplicas || !value.queue.endsWith(`_v${value.definitionVersion}`) || value.lifecycle.visibilityTimeoutSeconds < value.lifecycle.executionTimeoutSeconds + value.lifecycle.shutdownGraceSeconds + 30) {
9986
+ throw new Error("WORKER_EXECUTION_INVALID");
9987
+ }
9988
+ return structuredClone(value);
9989
+ }
9990
+ function validateWorkerExecution(groups) {
9991
+ const names = new Set, targets = new Set, queues = new Set, routes = new Set;
9992
+ for (const candidate of groups) {
9993
+ const group = parseWorkerExecutionGroup(candidate);
9994
+ const route = `${group.taskKey}:${group.definitionVersion}`;
9995
+ if (names.has(group.name) || targets.has(group.target) || queues.has(group.queue) || routes.has(route)) {
9996
+ throw new Error("WORKER_EXECUTION_CONFLICT");
9997
+ }
9998
+ names.add(group.name);
9999
+ targets.add(group.target);
10000
+ queues.add(group.queue);
10001
+ routes.add(route);
10002
+ }
10003
+ }
10004
+ var closed, positive = (maximum) => Integer({ minimum: 1, maximum }), WorkerExecutionGroupSchema, WorkerExecutionSchema;
10005
+ var init_worker_execution = __esm(() => {
10006
+ init_build2();
10007
+ init_value2();
10008
+ closed = { additionalProperties: false };
10009
+ WorkerExecutionGroupSchema = _Object_({
10010
+ name: String2({ pattern: "^[a-z][a-z0-9-]{0,47}$" }),
10011
+ target: String2({ pattern: "^[a-z][a-z0-9-]{0,53}$" }),
10012
+ workloadClass: Union([Literal("interactive"), Literal("batch")]),
10013
+ executor: Literal("pgflow-queue"),
10014
+ runtime: Literal("bun"),
10015
+ queue: String2({ pattern: "^scw_[a-z0-9_]{1,40}$" }),
10016
+ taskKey: String2({ pattern: "^[a-z][a-z0-9_.-]{0,99}$" }),
10017
+ definitionVersion: String2({ pattern: "^[1-9][0-9]{0,8}$" }),
10018
+ replicas: positive(16),
10019
+ maxReplicas: positive(16),
10020
+ concurrencyPerReplica: positive(32),
10021
+ resources: _Object_({
10022
+ cpuLimit: Number2({ minimum: 0.1, maximum: 64, multipleOf: 0.1 }),
10023
+ memoryLimitMiB: Integer({ minimum: 64, maximum: 262144 })
10024
+ }, closed),
10025
+ database: _Object_({
10026
+ engineConnectionsPerReplica: positive(16),
10027
+ handlerConnectionsPerReplica: positive(16)
10028
+ }, closed),
10029
+ lifecycle: _Object_({
10030
+ executionTimeoutSeconds: positive(3500),
10031
+ visibilityTimeoutSeconds: Integer({ minimum: 15, maximum: 3600 }),
10032
+ shutdownGraceSeconds: positive(300)
10033
+ }, closed),
10034
+ retry: _Object_({ maxAttempts: Integer({ minimum: 1, maximum: 10 }) }, closed),
10035
+ admission: _Object_({ maxOutstandingOperations: positive(1e6) }, closed)
10036
+ }, closed);
10037
+ WorkerExecutionSchema = _Object_({
10038
+ groups: _Array_(WorkerExecutionGroupSchema, { minItems: 1, maxItems: 32 })
10039
+ }, closed);
10040
+ });
10041
+
9983
10042
  // node_modules/@supacloud/delivery/src/delivery-schema.ts
9984
10043
  function parseDeliveryOptions(value) {
9985
10044
  if (value === undefined)
@@ -9987,6 +10046,11 @@ function parseDeliveryOptions(value) {
9987
10046
  if (!Check2(DeliveryOptionsSchema, value))
9988
10047
  throw new DeliveryConfigurationError;
9989
10048
  const migrations = value.build?.migrations ?? [];
10049
+ try {
10050
+ validateWorkerExecution(value.execution?.groups ?? []);
10051
+ } catch {
10052
+ throw new DeliveryConfigurationError;
10053
+ }
9990
10054
  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"))) {
9991
10055
  throw new DeliveryConfigurationError;
9992
10056
  }
@@ -10001,6 +10065,7 @@ var objectOptions, reference, references, kind, isolation, DeliveryFilePathSchem
10001
10065
  var init_delivery_schema = __esm(() => {
10002
10066
  init_build2();
10003
10067
  init_value2();
10068
+ init_worker_execution();
10004
10069
  objectOptions = { additionalProperties: false };
10005
10070
  reference = String2({ minLength: 1, maxLength: 128, pattern: "^[A-Za-z][A-Za-z0-9_.:/-]*$" });
10006
10071
  references = _Array_(reference, { uniqueItems: true });
@@ -10012,6 +10077,7 @@ var init_delivery_schema = __esm(() => {
10012
10077
  });
10013
10078
  DeliveryOptionsSchema = _Object_({
10014
10079
  version: Literal(1),
10080
+ execution: Optional(WorkerExecutionSchema),
10015
10081
  targets: Optional(_Array_(_Object_({
10016
10082
  name: String2({ pattern: "^[a-z][a-z0-9-]{0,62}$" }),
10017
10083
  kind,
@@ -10084,6 +10150,7 @@ var init_delivery_schema = __esm(() => {
10084
10150
  name: String2(),
10085
10151
  kind,
10086
10152
  isolation,
10153
+ execution: Optional(WorkerExecutionGroupSchema),
10087
10154
  roots: _Array_(String2()),
10088
10155
  modules: _Array_(_Object_({
10089
10156
  name: String2(),
@@ -10391,7 +10458,7 @@ init_value2();
10391
10458
  init_delivery_schema();
10392
10459
 
10393
10460
  // src/delivery-bundle-protocol.ts
10394
- var closed = { additionalProperties: false };
10461
+ var closed2 = { additionalProperties: false };
10395
10462
  var requestSchema = _Object_({
10396
10463
  parentPid: Integer({ minimum: 1 }),
10397
10464
  name: String2(),
@@ -10399,15 +10466,15 @@ var requestSchema = _Object_({
10399
10466
  project: String2(),
10400
10467
  generatedDirectory: String2(),
10401
10468
  options: DeliveryOptionsSchema
10402
- }, closed);
10469
+ }, closed2);
10403
10470
  var responseSchema = Union([
10404
10471
  _Object_({
10405
10472
  ok: Literal(true),
10406
10473
  files: _Array_(Tuple([DeliveryFilePathSchema, String2({ pattern: "^[A-Za-z0-9+/]*={0,2}$" })])),
10407
10474
  inputs: _Array_(Tuple([String2(), String2({ pattern: "^[a-f0-9]{64}$" })])),
10408
10475
  runtimeImports: _Array_(String2())
10409
- }, closed),
10410
- _Object_({ ok: Literal(false) }, closed)
10476
+ }, closed2),
10477
+ _Object_({ ok: Literal(false) }, closed2)
10411
10478
  ]);
10412
10479
  function parseDeliveryBundleRequest(input) {
10413
10480
  if (!Check2(requestSchema, input))