@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/dist/index.js CHANGED
@@ -1025,6 +1025,130 @@ var DomainOrders = class extends APIResource {
1025
1025
  }
1026
1026
  };
1027
1027
 
1028
+ // src/resources/functions.ts
1029
+ var FUNCTION_ZIP_MAX_BYTES = 25 * 1024 * 1024;
1030
+ var Functions = class extends APIResource {
1031
+ /** A function's versions, and rolling back to one. */
1032
+ versions = new FunctionVersions(this._client);
1033
+ /** Keys callers send to a function that requires one. */
1034
+ keys = new FunctionKeys(this._client);
1035
+ /** A function's calls of the last 7 days, with what each printed. */
1036
+ invocations = new FunctionInvocations(this._client);
1037
+ /** Calls, errors, durations and cold starts over a period. */
1038
+ metrics = new FunctionMetricsResource(this._client);
1039
+ /** Cron and rate schedules that call a function. */
1040
+ schedules = new FunctionSchedules(this._client);
1041
+ list(options) {
1042
+ return this._get("/functions", void 0, options);
1043
+ }
1044
+ /** Creates a function and gives it its URL. It serves nothing until its first deploy succeeds. `auth` defaults to `key`. */
1045
+ create(body, options) {
1046
+ return this._post("/functions", body, options);
1047
+ }
1048
+ get(functionId, options) {
1049
+ return this._get(path`/functions/${functionId}`, void 0, options);
1050
+ }
1051
+ /** Changes who may call the function (`auth`) or how many calls run at once (`max_concurrency`, 1 to 50). */
1052
+ update(functionId, body, options) {
1053
+ return this._patch(path`/functions/${functionId}`, body, options);
1054
+ }
1055
+ /** Deletes the function and every version of it; its URL stops answering. */
1056
+ delete(functionId, options) {
1057
+ return this._delete(path`/functions/${functionId}`, options);
1058
+ }
1059
+ /**
1060
+ * Builds a new version from one inline file (at most 256 KiB). It starts
1061
+ * `building` and serves once its build succeeds; the version serving keeps
1062
+ * serving until then. Variables marked `secret` are stored encrypted and
1063
+ * never returned.
1064
+ */
1065
+ deploy(functionId, body, options) {
1066
+ return this._post(path`/functions/${functionId}/deploy`, body, options);
1067
+ }
1068
+ /**
1069
+ * Builds a new version from a zip of a folder (at most 25 MiB, 250 MiB
1070
+ * unpacked), sent as multipart. With a `package.json` or
1071
+ * `requirements.txt` the dependencies are installed at build.
1072
+ */
1073
+ deployZip(functionId, settings, zip, options) {
1074
+ const blob = zip instanceof Blob ? zip : new Blob([zip], { type: "application/zip" });
1075
+ if (blob.size === 0 || blob.size > FUNCTION_ZIP_MAX_BYTES) {
1076
+ return Promise.reject(new RangeError(`A function zip must be 1 byte to 25 MiB, not ${blob.size} bytes.`));
1077
+ }
1078
+ const form = new FormData();
1079
+ form.append("spec", JSON.stringify(settings));
1080
+ form.append("code", blob, "code.zip");
1081
+ return this._request("POST", path`/functions/${functionId}/deploy`, { rawBody: form }, options);
1082
+ }
1083
+ /**
1084
+ * Runs the function once with `event` (any JSON value) and waits for its
1085
+ * handler, up to 60 s. Billed and logged like a call to its URL. Not
1086
+ * retried: each call runs the function.
1087
+ */
1088
+ invoke(functionId, event, options) {
1089
+ return this._post(path`/functions/${functionId}/invocations`, event ?? null, options, { noRetry: true });
1090
+ }
1091
+ };
1092
+ var FunctionVersions = class extends APIResource {
1093
+ /** Every version, newest first. */
1094
+ list(functionId, options) {
1095
+ return this._get(path`/functions/${functionId}/versions`, void 0, options);
1096
+ }
1097
+ /** Serves an earlier ready version at once, rebuilding nothing. */
1098
+ activate(functionId, number, options) {
1099
+ return this._post(path`/functions/${functionId}/versions/${String(number)}/activate`, void 0, options);
1100
+ }
1101
+ };
1102
+ var FunctionKeys = class extends APIResource {
1103
+ list(functionId, options) {
1104
+ return this._get(path`/functions/${functionId}/keys`, void 0, options);
1105
+ }
1106
+ /** Creates a key. Its secret, `key`, is in this response only. */
1107
+ create(functionId, body, options) {
1108
+ return this._post(path`/functions/${functionId}/keys`, body, options);
1109
+ }
1110
+ /** Revokes a key; callers using it are refused at once. */
1111
+ revoke(functionId, keyId, options) {
1112
+ return this._delete(path`/functions/${functionId}/keys/${keyId}`, options);
1113
+ }
1114
+ };
1115
+ var FunctionInvocations = class extends APIResource {
1116
+ /** Calls, newest first, filtered by `outcome`, text (`q`), `request_id` or time. Needs the write scope: logs hold whatever the code printed. */
1117
+ list(functionId, params = {}, options) {
1118
+ return this._get(path`/functions/${functionId}/invocations`, params, options);
1119
+ }
1120
+ listAll(functionId, params = {}, options) {
1121
+ return this._listAll(path`/functions/${functionId}/invocations`, params, options);
1122
+ }
1123
+ /** One call with every line it printed. */
1124
+ get(functionId, requestId, options) {
1125
+ return this._get(path`/functions/${functionId}/invocations/${requestId}`, void 0, options);
1126
+ }
1127
+ };
1128
+ var FunctionMetricsResource = class extends APIResource {
1129
+ /** `period`: `1h`, `6h`, `24h` (the default), `7d` or `14d`. */
1130
+ get(functionId, params = {}, options) {
1131
+ return this._get(path`/functions/${functionId}/metrics`, params, options);
1132
+ }
1133
+ };
1134
+ var FunctionSchedules = class extends APIResource {
1135
+ list(functionId, options) {
1136
+ return this._get(path`/functions/${functionId}/schedules`, void 0, options);
1137
+ }
1138
+ /** Adds a schedule (at most 10): five-field cron, `@daily`-style, or `rate(5 minutes)`, read in `time_zone` (UTC by default). */
1139
+ create(functionId, body, options) {
1140
+ return this._post(path`/functions/${functionId}/schedules`, body, options);
1141
+ }
1142
+ /** Changes a schedule; `state: "paused"` stops it firing, `"active"` resumes it. */
1143
+ update(functionId, scheduleId, body, options) {
1144
+ return this._patch(path`/functions/${functionId}/schedules/${scheduleId}`, body, options);
1145
+ }
1146
+ /** Deletes a schedule; it stops calling the function. */
1147
+ delete(functionId, scheduleId, options) {
1148
+ return this._delete(path`/functions/${functionId}/schedules/${scheduleId}`, options);
1149
+ }
1150
+ };
1151
+
1028
1152
  // src/resources/iam.ts
1029
1153
  var IAM = class extends APIResource {
1030
1154
  /** The actions a policy statement can name. */
@@ -2573,7 +2697,7 @@ var WebhookDeliveries = class extends APIResource {
2573
2697
  };
2574
2698
 
2575
2699
  // src/version.ts
2576
- var VERSION = "0.7.0";
2700
+ var VERSION = "0.8.0";
2577
2701
 
2578
2702
  // src/client.ts
2579
2703
  var DEFAULT_BASE_URL = "https://api.pantechdynamics.com/public/v1";
@@ -2632,6 +2756,8 @@ var Pantech = class {
2632
2756
  domains;
2633
2757
  /** The private container registry: namespace, repositories, tags and registry tokens. */
2634
2758
  registry;
2759
+ /** Serverless functions: code on its own URL, deploys, versions, keys, invoke, logs, metrics and schedules. */
2760
+ functions;
2635
2761
  /** Teams and access policies: who may do what, on which resources. */
2636
2762
  iam;
2637
2763
  /** TLS certificates Pantech issues and renews, or ones you import. */
@@ -2685,6 +2811,7 @@ var Pantech = class {
2685
2811
  this.dns = new DNS(this);
2686
2812
  this.domains = new Domains(this);
2687
2813
  this.registry = new Registry(this);
2814
+ this.functions = new Functions(this);
2688
2815
  this.iam = new IAM(this);
2689
2816
  this.certificates = new Certificates(this);
2690
2817
  this.objectStorage = new ObjectStorage(this);
@@ -2707,7 +2834,7 @@ var Pantech = class {
2707
2834
  let payload;
2708
2835
  if (req.rawBody !== void 0) {
2709
2836
  payload = req.rawBody;
2710
- if (!hasHeader(headers, "content-type")) {
2837
+ if (!(req.rawBody instanceof FormData) && !hasHeader(headers, "content-type")) {
2711
2838
  headers["Content-Type"] = "application/octet-stream";
2712
2839
  }
2713
2840
  } else if (req.body !== void 0) {
@@ -2851,6 +2978,13 @@ var MANAGED_POLICY_IDS = [
2851
2978
  "pol_pantech_database_admin",
2852
2979
  "pol_pantech_dns_manager",
2853
2980
  "pol_pantech_domain_manager",
2981
+ "pol_pantech_compute_admin",
2982
+ "pol_pantech_kubernetes_admin",
2983
+ "pol_pantech_object_storage_admin",
2984
+ "pol_pantech_functions_admin",
2985
+ "pol_pantech_email_manager",
2986
+ "pol_pantech_certificate_manager",
2987
+ "pol_pantech_migrate_manager",
2854
2988
  "pol_pantech_registry_push",
2855
2989
  "pol_pantech_registry_pull",
2856
2990
  "pol_pantech_billing_manager",
@@ -2966,6 +3100,6 @@ async function signWebhook(options) {
2966
3100
  return `t=${t},v1=${await hmacHex(options.secret, t, bytes(options.body))}`;
2967
3101
  }
2968
3102
 
2969
- export { APIConnectionError, APITimeoutError, AuthenticationError, BadRequestError, CERTIFICATE_ERROR_CODES, CertificateFailedError, CloudFailedError, ConflictError, DEFAULT_BASE_URL, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DNSFailedError, DNS_ERROR_CODES, DOMAIN_ERROR_CODES, IAM_ERROR_CODES, InternalServerError, NotFoundError, OperationFailedError, OrderFailedError, Pantech, PantechError, PaymentRequiredError, PermissionDeniedError, PreconditionFailedError, REGISTRY_ERROR_CODES, RateLimitError, VERSION, ValidationError, WEBHOOK_SIGNATURE_HEADER, WaitTimeoutError, WebhookVerificationError, iam, isPantechError, paginate, signWebhook, verifyWebhook };
3103
+ export { APIConnectionError, APITimeoutError, AuthenticationError, BadRequestError, CERTIFICATE_ERROR_CODES, CertificateFailedError, CloudFailedError, ConflictError, DEFAULT_BASE_URL, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, DNSFailedError, DNS_ERROR_CODES, DOMAIN_ERROR_CODES, FUNCTION_ZIP_MAX_BYTES, IAM_ERROR_CODES, InternalServerError, NotFoundError, OperationFailedError, OrderFailedError, Pantech, PantechError, PaymentRequiredError, PermissionDeniedError, PreconditionFailedError, REGISTRY_ERROR_CODES, RateLimitError, VERSION, ValidationError, WEBHOOK_SIGNATURE_HEADER, WaitTimeoutError, WebhookVerificationError, iam, isPantechError, paginate, signWebhook, verifyWebhook };
2970
3104
  //# sourceMappingURL=index.js.map
2971
3105
  //# sourceMappingURL=index.js.map