@pantechdynamic/sdk 0.7.0 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,27 @@ until then.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 0.8.0 (2026-11-29)
10
+
11
+ - Serverless functions: `pantech.functions` covers every functions operation of the public API.
12
+ `list`, `create`, `get`, `update` (`auth`, `max_concurrency`) and `delete`; `deploy` for one
13
+ inline file and `deployZip` for a zip of a folder (multipart, dependencies installed at build),
14
+ both with environment variables and secrets; `invoke` (sent once, never retried);
15
+ `versions.list` and `versions.activate`; `keys.list`, `keys.create` and `keys.revoke`;
16
+ `invocations.list`, `invocations.listAll` and `invocations.get` for logs; `metrics.get`; and
17
+ `schedules.list`, `create`, `update` (pause and resume) and `delete`. Types such as `Function`,
18
+ `FunctionVersion`, `FunctionSchedule` and `FunctionInvokeResult` are exported, with
19
+ `FUNCTION_ZIP_MAX_BYTES`.
20
+ - A request's `rawBody` may be a `FormData`, sent as multipart with fetch's own boundary.
21
+ - `iam.MANAGED_POLICY_IDS` includes `pol_pantech_functions_admin`.
22
+ - Types follow the latest spec, including dynamic IP's `fallback_policy` and `paused`.
23
+
24
+ ## 0.7.1 (2026-11-28)
25
+
26
+ - `iam.MANAGED_POLICY_IDS` and `ManagedPolicyId` include Pantech's six new managed policies:
27
+ `pol_pantech_compute_admin`, `pol_pantech_kubernetes_admin`, `pol_pantech_object_storage_admin`,
28
+ `pol_pantech_email_manager`, `pol_pantech_certificate_manager` and `pol_pantech_migrate_manager`.
29
+
9
30
  ## 0.7.0 (2026-11-28)
10
31
 
11
32
  - Object Storage parity across settings, uploads, versioning, multipart, sharing, notifications,
package/README.md CHANGED
@@ -326,6 +326,35 @@ console.log(sim.allowed, sim.decision); // false "explicit_deny"
326
326
  member, `iam.settings` the organization's `member_baseline`, and `iam.MANAGED_POLICY_IDS`
327
327
  Pantech's ready-made policies. See `examples/access-policies.ts`.
328
328
 
329
+ ## Serverless functions
330
+
331
+ `client.functions` runs your code on each request to its own URL, on a schedule, or when invoked.
332
+
333
+ ```ts
334
+ const fn = await client.functions.create({ name: "hello", zone_id: "af-abj-1", auth: "public" });
335
+ await client.functions.deploy(fn.id, {
336
+ runtime: "nodejs22",
337
+ environment: [{ name: "TOKEN", value: process.env.TOKEN ?? "", secret: true }],
338
+ source: {
339
+ filename: "index.mjs",
340
+ content: `export async function handler(event) {
341
+ return { status: 200, body: "hello " + (event.query.name ?? "world") };
342
+ }`,
343
+ },
344
+ });
345
+ // Or a zip of a folder, with its package.json dependencies installed at build:
346
+ // await client.functions.deployZip(fn.id, { runtime: "nodejs22" }, await readFile("fn.zip"));
347
+
348
+ const result = await client.functions.invoke(fn.id, { query: { name: "Ada" } });
349
+ for await (const call of client.functions.invocations.listAll(fn.id, { outcome: "error" })) {
350
+ console.log(call.request_id, call.status);
351
+ }
352
+ await client.functions.schedules.create(fn.id, { expression: "0 6 * * *", time_zone: "Africa/Lagos" });
353
+ ```
354
+
355
+ Once `versions.list` shows the version `ready`, `fn.url` answers. See the
356
+ [guide](https://docs.pantechdynamics.com/compute/serverless-functions).
357
+
329
358
  ## Container registry
330
359
 
331
360
  `client.registry` manages your private registry at `registry.pantechdynamics.com`: one namespace per
package/dist/index.cjs CHANGED
@@ -1027,6 +1027,130 @@ var DomainOrders = class extends APIResource {
1027
1027
  }
1028
1028
  };
1029
1029
 
1030
+ // src/resources/functions.ts
1031
+ var FUNCTION_ZIP_MAX_BYTES = 25 * 1024 * 1024;
1032
+ var Functions = class extends APIResource {
1033
+ /** A function's versions, and rolling back to one. */
1034
+ versions = new FunctionVersions(this._client);
1035
+ /** Keys callers send to a function that requires one. */
1036
+ keys = new FunctionKeys(this._client);
1037
+ /** A function's calls of the last 7 days, with what each printed. */
1038
+ invocations = new FunctionInvocations(this._client);
1039
+ /** Calls, errors, durations and cold starts over a period. */
1040
+ metrics = new FunctionMetricsResource(this._client);
1041
+ /** Cron and rate schedules that call a function. */
1042
+ schedules = new FunctionSchedules(this._client);
1043
+ list(options) {
1044
+ return this._get("/functions", void 0, options);
1045
+ }
1046
+ /** Creates a function and gives it its URL. It serves nothing until its first deploy succeeds. `auth` defaults to `key`. */
1047
+ create(body, options) {
1048
+ return this._post("/functions", body, options);
1049
+ }
1050
+ get(functionId, options) {
1051
+ return this._get(path`/functions/${functionId}`, void 0, options);
1052
+ }
1053
+ /** Changes who may call the function (`auth`) or how many calls run at once (`max_concurrency`, 1 to 50). */
1054
+ update(functionId, body, options) {
1055
+ return this._patch(path`/functions/${functionId}`, body, options);
1056
+ }
1057
+ /** Deletes the function and every version of it; its URL stops answering. */
1058
+ delete(functionId, options) {
1059
+ return this._delete(path`/functions/${functionId}`, options);
1060
+ }
1061
+ /**
1062
+ * Builds a new version from one inline file (at most 256 KiB). It starts
1063
+ * `building` and serves once its build succeeds; the version serving keeps
1064
+ * serving until then. Variables marked `secret` are stored encrypted and
1065
+ * never returned.
1066
+ */
1067
+ deploy(functionId, body, options) {
1068
+ return this._post(path`/functions/${functionId}/deploy`, body, options);
1069
+ }
1070
+ /**
1071
+ * Builds a new version from a zip of a folder (at most 25 MiB, 250 MiB
1072
+ * unpacked), sent as multipart. With a `package.json` or
1073
+ * `requirements.txt` the dependencies are installed at build.
1074
+ */
1075
+ deployZip(functionId, settings, zip, options) {
1076
+ const blob = zip instanceof Blob ? zip : new Blob([zip], { type: "application/zip" });
1077
+ if (blob.size === 0 || blob.size > FUNCTION_ZIP_MAX_BYTES) {
1078
+ return Promise.reject(new RangeError(`A function zip must be 1 byte to 25 MiB, not ${blob.size} bytes.`));
1079
+ }
1080
+ const form = new FormData();
1081
+ form.append("spec", JSON.stringify(settings));
1082
+ form.append("code", blob, "code.zip");
1083
+ return this._request("POST", path`/functions/${functionId}/deploy`, { rawBody: form }, options);
1084
+ }
1085
+ /**
1086
+ * Runs the function once with `event` (any JSON value) and waits for its
1087
+ * handler, up to 60 s. Billed and logged like a call to its URL. Not
1088
+ * retried: each call runs the function.
1089
+ */
1090
+ invoke(functionId, event, options) {
1091
+ return this._post(path`/functions/${functionId}/invocations`, event ?? null, options, { noRetry: true });
1092
+ }
1093
+ };
1094
+ var FunctionVersions = class extends APIResource {
1095
+ /** Every version, newest first. */
1096
+ list(functionId, options) {
1097
+ return this._get(path`/functions/${functionId}/versions`, void 0, options);
1098
+ }
1099
+ /** Serves an earlier ready version at once, rebuilding nothing. */
1100
+ activate(functionId, number, options) {
1101
+ return this._post(path`/functions/${functionId}/versions/${String(number)}/activate`, void 0, options);
1102
+ }
1103
+ };
1104
+ var FunctionKeys = class extends APIResource {
1105
+ list(functionId, options) {
1106
+ return this._get(path`/functions/${functionId}/keys`, void 0, options);
1107
+ }
1108
+ /** Creates a key. Its secret, `key`, is in this response only. */
1109
+ create(functionId, body, options) {
1110
+ return this._post(path`/functions/${functionId}/keys`, body, options);
1111
+ }
1112
+ /** Revokes a key; callers using it are refused at once. */
1113
+ revoke(functionId, keyId, options) {
1114
+ return this._delete(path`/functions/${functionId}/keys/${keyId}`, options);
1115
+ }
1116
+ };
1117
+ var FunctionInvocations = class extends APIResource {
1118
+ /** Calls, newest first, filtered by `outcome`, text (`q`), `request_id` or time. Needs the write scope: logs hold whatever the code printed. */
1119
+ list(functionId, params = {}, options) {
1120
+ return this._get(path`/functions/${functionId}/invocations`, params, options);
1121
+ }
1122
+ listAll(functionId, params = {}, options) {
1123
+ return this._listAll(path`/functions/${functionId}/invocations`, params, options);
1124
+ }
1125
+ /** One call with every line it printed. */
1126
+ get(functionId, requestId, options) {
1127
+ return this._get(path`/functions/${functionId}/invocations/${requestId}`, void 0, options);
1128
+ }
1129
+ };
1130
+ var FunctionMetricsResource = class extends APIResource {
1131
+ /** `period`: `1h`, `6h`, `24h` (the default), `7d` or `14d`. */
1132
+ get(functionId, params = {}, options) {
1133
+ return this._get(path`/functions/${functionId}/metrics`, params, options);
1134
+ }
1135
+ };
1136
+ var FunctionSchedules = class extends APIResource {
1137
+ list(functionId, options) {
1138
+ return this._get(path`/functions/${functionId}/schedules`, void 0, options);
1139
+ }
1140
+ /** Adds a schedule (at most 10): five-field cron, `@daily`-style, or `rate(5 minutes)`, read in `time_zone` (UTC by default). */
1141
+ create(functionId, body, options) {
1142
+ return this._post(path`/functions/${functionId}/schedules`, body, options);
1143
+ }
1144
+ /** Changes a schedule; `state: "paused"` stops it firing, `"active"` resumes it. */
1145
+ update(functionId, scheduleId, body, options) {
1146
+ return this._patch(path`/functions/${functionId}/schedules/${scheduleId}`, body, options);
1147
+ }
1148
+ /** Deletes a schedule; it stops calling the function. */
1149
+ delete(functionId, scheduleId, options) {
1150
+ return this._delete(path`/functions/${functionId}/schedules/${scheduleId}`, options);
1151
+ }
1152
+ };
1153
+
1030
1154
  // src/resources/iam.ts
1031
1155
  var IAM = class extends APIResource {
1032
1156
  /** The actions a policy statement can name. */
@@ -2575,7 +2699,7 @@ var WebhookDeliveries = class extends APIResource {
2575
2699
  };
2576
2700
 
2577
2701
  // src/version.ts
2578
- var VERSION = "0.7.0";
2702
+ var VERSION = "0.8.0";
2579
2703
 
2580
2704
  // src/client.ts
2581
2705
  var DEFAULT_BASE_URL = "https://api.pantechdynamics.com/public/v1";
@@ -2634,6 +2758,8 @@ var Pantech = class {
2634
2758
  domains;
2635
2759
  /** The private container registry: namespace, repositories, tags and registry tokens. */
2636
2760
  registry;
2761
+ /** Serverless functions: code on its own URL, deploys, versions, keys, invoke, logs, metrics and schedules. */
2762
+ functions;
2637
2763
  /** Teams and access policies: who may do what, on which resources. */
2638
2764
  iam;
2639
2765
  /** TLS certificates Pantech issues and renews, or ones you import. */
@@ -2687,6 +2813,7 @@ var Pantech = class {
2687
2813
  this.dns = new DNS(this);
2688
2814
  this.domains = new Domains(this);
2689
2815
  this.registry = new Registry(this);
2816
+ this.functions = new Functions(this);
2690
2817
  this.iam = new IAM(this);
2691
2818
  this.certificates = new Certificates(this);
2692
2819
  this.objectStorage = new ObjectStorage(this);
@@ -2709,7 +2836,7 @@ var Pantech = class {
2709
2836
  let payload;
2710
2837
  if (req.rawBody !== void 0) {
2711
2838
  payload = req.rawBody;
2712
- if (!hasHeader(headers, "content-type")) {
2839
+ if (!(req.rawBody instanceof FormData) && !hasHeader(headers, "content-type")) {
2713
2840
  headers["Content-Type"] = "application/octet-stream";
2714
2841
  }
2715
2842
  } else if (req.body !== void 0) {
@@ -2853,6 +2980,13 @@ var MANAGED_POLICY_IDS = [
2853
2980
  "pol_pantech_database_admin",
2854
2981
  "pol_pantech_dns_manager",
2855
2982
  "pol_pantech_domain_manager",
2983
+ "pol_pantech_compute_admin",
2984
+ "pol_pantech_kubernetes_admin",
2985
+ "pol_pantech_object_storage_admin",
2986
+ "pol_pantech_functions_admin",
2987
+ "pol_pantech_email_manager",
2988
+ "pol_pantech_certificate_manager",
2989
+ "pol_pantech_migrate_manager",
2856
2990
  "pol_pantech_registry_push",
2857
2991
  "pol_pantech_registry_pull",
2858
2992
  "pol_pantech_billing_manager",
@@ -2981,6 +3115,7 @@ exports.DEFAULT_WEBHOOK_TOLERANCE_SECONDS = DEFAULT_WEBHOOK_TOLERANCE_SECONDS;
2981
3115
  exports.DNSFailedError = DNSFailedError;
2982
3116
  exports.DNS_ERROR_CODES = DNS_ERROR_CODES;
2983
3117
  exports.DOMAIN_ERROR_CODES = DOMAIN_ERROR_CODES;
3118
+ exports.FUNCTION_ZIP_MAX_BYTES = FUNCTION_ZIP_MAX_BYTES;
2984
3119
  exports.IAM_ERROR_CODES = IAM_ERROR_CODES;
2985
3120
  exports.InternalServerError = InternalServerError;
2986
3121
  exports.NotFoundError = NotFoundError;