@supacloud/cli 0.36.0 → 0.37.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.
Files changed (2) hide show
  1. package/dist/index.js +94 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10108,6 +10108,45 @@ function canonicalVersion(candidate) {
10108
10108
  function stringRoutes(candidate) {
10109
10109
  return Array.isArray(candidate) && candidate.every((route) => typeof route === "string");
10110
10110
  }
10111
+ function projectedFunctionCapabilities(candidate) {
10112
+ const record = objectRecord(candidate);
10113
+ if (!record)
10114
+ return null;
10115
+ const projected = {};
10116
+ for (const field of ["secrets", "outbound_hosts", "bindings"]) {
10117
+ if (record[field] !== undefined && (!Array.isArray(record[field]) || record[field].some((entry) => typeof entry !== "string")))
10118
+ return null;
10119
+ if (record[field] !== undefined)
10120
+ projected[field] = record[field];
10121
+ }
10122
+ if (record.background !== undefined && typeof record.background !== "boolean")
10123
+ return null;
10124
+ if (typeof record.background === "boolean")
10125
+ projected.background = record.background;
10126
+ return projected;
10127
+ }
10128
+ function projectedFunctionLimits(candidate) {
10129
+ const record = objectRecord(candidate);
10130
+ if (!record)
10131
+ return null;
10132
+ const projected = {};
10133
+ const maxima = {
10134
+ timeout_ms: 900000,
10135
+ max_request_body_bytes: 30 * 1024 * 1024,
10136
+ max_response_body_bytes: 30 * 1024 * 1024,
10137
+ wait_until_timeout_ms: 900000
10138
+ };
10139
+ for (const field of Object.keys(maxima)) {
10140
+ const value = record[field];
10141
+ if (value === undefined)
10142
+ continue;
10143
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > maxima[field]) {
10144
+ return null;
10145
+ }
10146
+ projected[field] = value;
10147
+ }
10148
+ return projected;
10149
+ }
10111
10150
  function optionalTypedFields(source, fields, expectedType) {
10112
10151
  return fields.every((field) => source[field] === undefined || typeof source[field] === expectedType);
10113
10152
  }
@@ -10121,6 +10160,10 @@ function projectedFunctionListEntry(candidate) {
10121
10160
  const functionRecord = objectRecord(candidate);
10122
10161
  if (!functionRecord || typeof functionRecord.slug !== "string" || !SAFE_SLUG_PATTERN.test(functionRecord.slug) || typeof functionRecord.version !== "number" || !Number.isSafeInteger(functionRecord.version) || functionRecord.version < 0 || !validObservedFunctionActivationId(functionRecord.activation_id) || !optionalTypedFields(functionRecord, LIST_STRING_FIELDS, "string") || !optionalTypedFields(functionRecord, LIST_BOOLEAN_FIELDS, "boolean") || functionRecord.framework !== undefined && !FUNCTION_FRAMEWORKS.includes(functionRecord.framework) || functionRecord.background_routes !== undefined && !stringRoutes(functionRecord.background_routes))
10123
10162
  return null;
10163
+ const capabilities = functionRecord.capabilities === undefined ? undefined : projectedFunctionCapabilities(functionRecord.capabilities);
10164
+ const limits = functionRecord.limits === undefined ? undefined : projectedFunctionLimits(functionRecord.limits);
10165
+ if (capabilities === null || limits === null)
10166
+ return null;
10124
10167
  const projected = {
10125
10168
  slug: functionRecord.slug,
10126
10169
  version: functionRecord.version,
@@ -10133,6 +10176,10 @@ function projectedFunctionListEntry(candidate) {
10133
10176
  if (functionRecord.background_routes !== undefined) {
10134
10177
  projected.background_routes = functionRecord.background_routes;
10135
10178
  }
10179
+ if (capabilities !== undefined)
10180
+ projected.capabilities = capabilities;
10181
+ if (limits !== undefined)
10182
+ projected.limits = limits;
10136
10183
  return projected;
10137
10184
  }
10138
10185
  function projectedFunctionList(payload) {
@@ -10182,6 +10229,10 @@ function projectedFunctionIdentity(payload, expectedProjectRef, expectedSlug) {
10182
10229
  const framework = response.framework;
10183
10230
  if (framework !== undefined && !FUNCTION_FRAMEWORKS.includes(framework))
10184
10231
  return null;
10232
+ const capabilities = response.capabilities === undefined ? undefined : projectedFunctionCapabilities(response.capabilities);
10233
+ const limits = response.limits === undefined ? undefined : projectedFunctionLimits(response.limits);
10234
+ if (capabilities === null || limits === null)
10235
+ return null;
10185
10236
  return {
10186
10237
  project_ref: expectedProjectRef,
10187
10238
  slug: expectedSlug,
@@ -10190,6 +10241,8 @@ function projectedFunctionIdentity(payload, expectedProjectRef, expectedSlug) {
10190
10241
  background_routes: response.background_routes,
10191
10242
  ...framework === undefined ? {} : { framework },
10192
10243
  ...optionalFields,
10244
+ ...capabilities === undefined ? {} : { capabilities },
10245
+ ...limits === undefined ? {} : { limits },
10193
10246
  activation_id: response.activation_id
10194
10247
  };
10195
10248
  }
@@ -10206,12 +10259,20 @@ function configMatchesExpectation(response, expected) {
10206
10259
  return false;
10207
10260
  if (expected.framework !== undefined && response.framework !== expected.framework)
10208
10261
  return false;
10262
+ if (expected.capabilities !== undefined && JSON.stringify(response.capabilities) !== JSON.stringify(expected.capabilities))
10263
+ return false;
10264
+ if (expected.limits !== undefined && JSON.stringify(response.limits) !== JSON.stringify(expected.limits))
10265
+ return false;
10209
10266
  return expected.background_routes === undefined || JSON.stringify(response.background_routes) === JSON.stringify(expected.background_routes);
10210
10267
  }
10211
10268
  function confirmedFunctionConfigMutation(payload, expectation) {
10212
10269
  const response = objectRecord(payload);
10213
10270
  if (!response || !mutationIdentityMatches(response, expectation) || !configMatchesExpectation(response, expectation.config))
10214
10271
  return null;
10272
+ const capabilities = response.capabilities === undefined ? undefined : projectedFunctionCapabilities(response.capabilities);
10273
+ const limits = response.limits === undefined ? undefined : projectedFunctionLimits(response.limits);
10274
+ if (capabilities === null || limits === null)
10275
+ return null;
10215
10276
  const optionalFields = optionalConfigFields(response);
10216
10277
  if (!optionalFields)
10217
10278
  return null;
@@ -10223,7 +10284,9 @@ function confirmedFunctionConfigMutation(payload, expectation) {
10223
10284
  verify_jwt: response.verify_jwt,
10224
10285
  background_routes: response.background_routes,
10225
10286
  ...response.framework === undefined ? {} : { framework: response.framework },
10226
- ...optionalFields
10287
+ ...optionalFields,
10288
+ ...capabilities === undefined ? {} : { capabilities },
10289
+ ...limits === undefined ? {} : { limits }
10227
10290
  };
10228
10291
  }
10229
10292
  function confirmedFunctionDeletion(payload, expectation) {
@@ -10540,6 +10603,18 @@ function parseBackgroundRoutes(value) {
10540
10603
  }
10541
10604
  var backgroundRoutesSchema = Type.Optional(decodedSchema(Type.Union([Type.String(), Type.Array(Type.String())]), Type.Array(Type.String()), parseBackgroundRoutes));
10542
10605
  var functionFilesRecordSchema = Type.Record(Type.String(), Type.String());
10606
+ var functionCapabilitiesSchema = Type.Object({
10607
+ secrets: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 128 })),
10608
+ outbound_hosts: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 128 })),
10609
+ bindings: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { maxItems: 128 })),
10610
+ background: Type.Optional(Type.Boolean())
10611
+ }, { additionalProperties: false });
10612
+ var functionLimitsSchema = Type.Object({
10613
+ timeout_ms: Type.Optional(Type.Integer({ minimum: 1, maximum: 900000 })),
10614
+ max_request_body_bytes: Type.Optional(Type.Integer({ minimum: 1, maximum: 30 * 1024 * 1024 })),
10615
+ max_response_body_bytes: Type.Optional(Type.Integer({ minimum: 1, maximum: 30 * 1024 * 1024 })),
10616
+ wait_until_timeout_ms: Type.Optional(Type.Integer({ minimum: 1, maximum: 900000 }))
10617
+ }, { additionalProperties: false });
10543
10618
  function parseFunctionFiles(input) {
10544
10619
  if (typeof input !== "string")
10545
10620
  return input;
@@ -10755,6 +10830,10 @@ function confirmedFunctionConfig(payload, expected) {
10755
10830
  if (JSON.stringify(response.background_routes) !== JSON.stringify(expected.background_routes))
10756
10831
  return false;
10757
10832
  }
10833
+ if (expected.capabilities !== undefined && JSON.stringify(response.capabilities) !== JSON.stringify(expected.capabilities))
10834
+ return false;
10835
+ if (expected.limits !== undefined && JSON.stringify(response.limits) !== JSON.stringify(expected.limits))
10836
+ return false;
10758
10837
  return true;
10759
10838
  }
10760
10839
  function functionSourceCode(payload, field = "code") {
@@ -10854,7 +10933,9 @@ function confirmedFunctionMutation(expectation, payload) {
10854
10933
  activeVersion,
10855
10934
  activationId,
10856
10935
  verifyJwt: config.verify_jwt,
10857
- ...framework === undefined ? {} : { framework }
10936
+ ...framework === undefined ? {} : { framework },
10937
+ ...config.capabilities === undefined ? {} : { capabilities: config.capabilities },
10938
+ ...config.limits === undefined ? {} : { limits: config.limits }
10858
10939
  };
10859
10940
  }
10860
10941
  function functionMutationResponse(expectation, response) {
@@ -10873,7 +10954,9 @@ function functionMutationResponse(expectation, response) {
10873
10954
  active_version: confirmed.activeVersion,
10874
10955
  version: confirmed.activeVersion,
10875
10956
  verify_jwt: confirmed.verifyJwt,
10876
- ...confirmed.framework === undefined ? {} : { framework: confirmed.framework }
10957
+ ...confirmed.framework === undefined ? {} : { framework: confirmed.framework },
10958
+ ...confirmed.capabilities === undefined ? {} : { capabilities: confirmed.capabilities },
10959
+ ...confirmed.limits === undefined ? {} : { limits: confirmed.limits }
10877
10960
  });
10878
10961
  }
10879
10962
  function readOnlyActivationResult() {
@@ -10952,6 +11035,8 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
10952
11035
  verify_jwt: optional(Type.Boolean(), "[deploy/deploy_bundle/config] Set JWT verification for this function"),
10953
11036
  background_routes: withDescription(backgroundRoutesSchema, "[deploy/deploy_bundle/config] Background route paths; pass comma-separated or JSON array in CLI"),
10954
11037
  framework: optional(withDescription(stringEnum(["fetch", "elysia", "hono", "sveltekit-function"]), "[deploy/deploy_bundle/config/scaffold] Fetch framework adapter profile")),
11038
+ capabilities: optional(functionCapabilitiesSchema, "[deploy/deploy_bundle/config] Host capabilities: secrets, outbound_hosts, bindings, background"),
11039
+ limits: optional(functionLimitsSchema, "[deploy/deploy_bundle/config] Execution limits in milliseconds/bytes"),
10955
11040
  "expected-active-version": withDescription(expectedActiveVersionSchema, "[deploy/deploy_bundle/activate] Required current active version, or 'absent' when none exists"),
10956
11041
  "expected-activation-id": withDescription(expectedActivationIdSchema, "[deploy/deploy_bundle/config/activate/delete] Required activation ID from list, or 'legacy' for a new or legacy function")
10957
11042
  }, async (args) => {
@@ -10960,7 +11045,7 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
10960
11045
  if (args.action === "scaffold") {
10961
11046
  return { content: [{ type: "text", text: scaffoldFunction(args.path, args.slug, args.framework) }] };
10962
11047
  }
10963
- const { action, ref, slug, path: pathArg, output, entrypoint, minify, verify_jwt, background_routes, framework } = args;
11048
+ const { action, ref, slug, path: pathArg, output, entrypoint, minify, verify_jwt, background_routes, framework, capabilities, limits } = args;
10964
11049
  rejectActionSpecificFlags(action, args);
10965
11050
  const expectedActiveVersion = action === "deploy" || action === "deploy_bundle" ? requiredExpectedActiveVersion(args, action) : undefined;
10966
11051
  const expectedActivationId = FUNCTION_IDENTITY_MUTATIONS.has(action) ? requiredExpectedActivationId(args, action) : undefined;
@@ -10973,7 +11058,9 @@ Actions: list, get_config, deploy, deploy_bundle, config, source, activate, dele
10973
11058
  const functionConfig = () => ({
10974
11059
  ...typeof verify_jwt === "boolean" ? { verify_jwt } : {},
10975
11060
  ...Array.isArray(background_routes) ? { background_routes } : {},
10976
- ...typeof framework === "string" ? { framework } : {}
11061
+ ...typeof framework === "string" ? { framework } : {},
11062
+ ...capabilities === undefined ? {} : { capabilities },
11063
+ ...limits === undefined ? {} : { limits }
10977
11064
  });
10978
11065
  const hasFunctionConfig = () => Object.keys(functionConfig()).length > 0;
10979
11066
  const checkSyntax = async (sourceCode) => {
@@ -11062,7 +11149,7 @@ ${deployCheck.err}`;
11062
11149
  case "config":
11063
11150
  need("slug", slug);
11064
11151
  if (!hasFunctionConfig()) {
11065
- throw new Error("'verify_jwt', 'background_routes', or 'framework' required for 'config'");
11152
+ throw new Error("'verify_jwt', 'background_routes', 'framework', 'capabilities', or 'limits' required for 'config'");
11066
11153
  }
11067
11154
  return updateFunctionConfiguration(http, {
11068
11155
  projectRef: ref,
@@ -15071,7 +15158,7 @@ function registerReleaseTools(server, http, options = {}) {
15071
15158
  // package.json
15072
15159
  var package_default = {
15073
15160
  name: "@supacloud/cli",
15074
- version: "0.36.0",
15161
+ version: "0.37.0",
15075
15162
  description: "Project-scoped CLI for SupaCloud users",
15076
15163
  type: "module",
15077
15164
  main: "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",