@supacloud/compiler 0.57.1 → 0.59.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,7 @@ export interface ContractManifest {
7
7
  module: string;
8
8
  permission?: string;
9
9
  rpc?: string;
10
+ branchesFallback?: "reject" | "command";
10
11
  branches?: Array<{
11
12
  when: string;
12
13
  adapter: string;
@@ -19,6 +19,7 @@ declare const requestSchema: Type.TObject<{
19
19
  definitionVersion: Type.TString;
20
20
  replicas: Type.TInteger;
21
21
  maxReplicas: Type.TInteger;
22
+ shardCount: Type.TOptional<Type.TInteger>;
22
23
  concurrencyPerReplica: Type.TInteger;
23
24
  resources: Type.TObject<{
24
25
  cpuLimit: Type.TNumber;
@@ -10103,23 +10103,49 @@ var init_build2 = __esm(() => {
10103
10103
  });
10104
10104
 
10105
10105
  // node_modules/@supacloud/delivery/src/worker-execution.ts
10106
+ function workerShardCount(group) {
10107
+ return group.shardCount ?? 1;
10108
+ }
10109
+ function shardSuffix(shard) {
10110
+ if (!Number.isSafeInteger(shard) || shard < 0 || shard >= 64) {
10111
+ throw new Error("WORKER_SHARD_INVALID");
10112
+ }
10113
+ return `s${shard.toString(36).padStart(2, "0")}`;
10114
+ }
10115
+ function workerShardQueue(group, shard) {
10116
+ const count = workerShardCount(group);
10117
+ if (!Number.isSafeInteger(shard) || shard < 0 || shard >= count) {
10118
+ throw new Error("WORKER_SHARD_INVALID");
10119
+ }
10120
+ if (count === 1)
10121
+ return group.queue;
10122
+ const queue = `${group.queue}_${shardSuffix(shard)}`;
10123
+ if (!/^scw_[a-z0-9_]{1,40}$/.test(queue))
10124
+ throw new Error("WORKER_QUEUE_INVALID");
10125
+ return queue;
10126
+ }
10106
10127
  function parseWorkerExecutionGroup(value) {
10107
10128
  if (!Check2(WorkerExecutionGroupSchema, value) || value.replicas > value.maxReplicas || !value.queue.endsWith(`_v${value.definitionVersion}`) || value.lifecycle.visibilityTimeoutSeconds < value.lifecycle.executionTimeoutSeconds + value.lifecycle.shutdownGraceSeconds + 30) {
10108
10129
  throw new Error("WORKER_EXECUTION_INVALID");
10109
10130
  }
10110
- return structuredClone(value);
10131
+ const group = structuredClone(value);
10132
+ for (let shard = 0;shard < workerShardCount(group); shard += 1)
10133
+ workerShardQueue(group, shard);
10134
+ return group;
10111
10135
  }
10112
10136
  function validateWorkerExecution(groups) {
10113
10137
  const names = new Set, targets = new Set, queues = new Set, routes = new Set;
10114
10138
  for (const candidate of groups) {
10115
10139
  const group = parseWorkerExecutionGroup(candidate);
10116
10140
  const route = `${group.taskKey}:${group.definitionVersion}`;
10117
- if (names.has(group.name) || targets.has(group.target) || queues.has(group.queue) || routes.has(route)) {
10141
+ const physicalQueues = Array.from({ length: workerShardCount(group) }, (_, shard) => workerShardQueue(group, shard));
10142
+ if (names.has(group.name) || targets.has(group.target) || queues.has(group.queue) || physicalQueues.some((queue) => queues.has(queue)) || routes.has(route)) {
10118
10143
  throw new Error("WORKER_EXECUTION_CONFLICT");
10119
10144
  }
10120
10145
  names.add(group.name);
10121
10146
  targets.add(group.target);
10122
10147
  queues.add(group.queue);
10148
+ physicalQueues.forEach((queue) => queues.add(queue));
10123
10149
  routes.add(route);
10124
10150
  }
10125
10151
  }
@@ -10143,6 +10169,7 @@ var init_worker_execution = __esm(() => {
10143
10169
  definitionVersion: String2({ pattern: "^[1-9][0-9]{0,8}$" }),
10144
10170
  replicas: positive(16),
10145
10171
  maxReplicas: positive(16),
10172
+ shardCount: Optional(positive(64)),
10146
10173
  concurrencyPerReplica: positive(32),
10147
10174
  resources: ComputeResourcesSchema,
10148
10175
  database: _Object_({