@smplkit/sdk 3.0.51 → 3.0.53

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.cjs CHANGED
@@ -17167,10 +17167,10 @@ function resolveChain(chain, environment) {
17167
17167
 
17168
17168
  // src/config/types.ts
17169
17169
  var ItemType = /* @__PURE__ */ ((ItemType2) => {
17170
- ItemType2["STRING"] = "STRING";
17171
- ItemType2["NUMBER"] = "NUMBER";
17172
17170
  ItemType2["BOOLEAN"] = "BOOLEAN";
17173
17171
  ItemType2["JSON"] = "JSON";
17172
+ ItemType2["NUMBER"] = "NUMBER";
17173
+ ItemType2["STRING"] = "STRING";
17174
17174
  return ItemType2;
17175
17175
  })(ItemType || {});
17176
17176
  var ConfigItem = class {
@@ -18349,8 +18349,8 @@ var import_openapi_fetch3 = __toESM(require("openapi-fetch"), 1);
18349
18349
 
18350
18350
  // src/management/types.ts
18351
18351
  var EnvironmentClassification = /* @__PURE__ */ ((EnvironmentClassification3) => {
18352
- EnvironmentClassification3["STANDARD"] = "STANDARD";
18353
18352
  EnvironmentClassification3["AD_HOC"] = "AD_HOC";
18353
+ EnvironmentClassification3["STANDARD"] = "STANDARD";
18354
18354
  return EnvironmentClassification3;
18355
18355
  })(EnvironmentClassification || {});
18356
18356
  var HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
@@ -18582,14 +18582,14 @@ var AccountSettings = class {
18582
18582
 
18583
18583
  // src/flags/types.ts
18584
18584
  var Op = /* @__PURE__ */ ((Op2) => {
18585
+ Op2["CONTAINS"] = "contains";
18585
18586
  Op2["EQ"] = "==";
18586
- Op2["NEQ"] = "!=";
18587
- Op2["LT"] = "<";
18588
- Op2["LTE"] = "<=";
18589
18587
  Op2["GT"] = ">";
18590
18588
  Op2["GTE"] = ">=";
18591
18589
  Op2["IN"] = "in";
18592
- Op2["CONTAINS"] = "contains";
18590
+ Op2["LT"] = "<";
18591
+ Op2["LTE"] = "<=";
18592
+ Op2["NEQ"] = "!=";
18593
18593
  return Op2;
18594
18594
  })(Op || {});
18595
18595
  var CONTEXT_FIELDS = /* @__PURE__ */ new Set([
@@ -19278,13 +19278,13 @@ function _coerceValues(values) {
19278
19278
 
19279
19279
  // src/logging/types.ts
19280
19280
  var LogLevel = /* @__PURE__ */ ((LogLevel5) => {
19281
- LogLevel5["TRACE"] = "TRACE";
19282
19281
  LogLevel5["DEBUG"] = "DEBUG";
19283
- LogLevel5["INFO"] = "INFO";
19284
- LogLevel5["WARN"] = "WARN";
19285
19282
  LogLevel5["ERROR"] = "ERROR";
19286
19283
  LogLevel5["FATAL"] = "FATAL";
19284
+ LogLevel5["INFO"] = "INFO";
19287
19285
  LogLevel5["SILENT"] = "SILENT";
19286
+ LogLevel5["TRACE"] = "TRACE";
19287
+ LogLevel5["WARN"] = "WARN";
19288
19288
  return LogLevel5;
19289
19289
  })(LogLevel || {});
19290
19290
  var LoggerChangeEvent = class {
@@ -19910,6 +19910,137 @@ var LogGroupsClient = class {
19910
19910
  }
19911
19911
  };
19912
19912
 
19913
+ // src/audit/types.ts
19914
+ var HttpConfiguration = class {
19915
+ /** HTTP verb used for delivery. Defaults to {@link HttpMethod.POST}. */
19916
+ method;
19917
+ /** Destination URL the audit service POSTs each event to. */
19918
+ url;
19919
+ /**
19920
+ * Headers attached to every outbound request. Values carry credentials
19921
+ * and are encrypted at rest server-side; reads return them redacted.
19922
+ */
19923
+ headers;
19924
+ /**
19925
+ * Status the destination must return for delivery to count as success
19926
+ * — either an exact code (`"200"`, `"204"`) or a status class
19927
+ * (`"2xx"`, `"4xx"`). Defaults to `"2xx"`.
19928
+ */
19929
+ successStatus;
19930
+ constructor(fields = {}) {
19931
+ this.method = fields.method ?? "POST" /* POST */;
19932
+ this.url = fields.url ?? "";
19933
+ this.headers = fields.headers ?? [];
19934
+ this.successStatus = fields.successStatus ?? "2xx";
19935
+ }
19936
+ };
19937
+ var Forwarder = class {
19938
+ /**
19939
+ * Server-assigned UUID for this forwarder. `null` until {@link save}
19940
+ * has run for the first time.
19941
+ */
19942
+ id;
19943
+ /** Display name. Free-form. */
19944
+ name;
19945
+ /** Destination type — see {@link ForwarderType}. */
19946
+ forwarderType;
19947
+ /** Destination request configuration. */
19948
+ configuration;
19949
+ /**
19950
+ * When `false`, the audit service skips delivery for this forwarder
19951
+ * but still records `filtered_out` deliveries.
19952
+ */
19953
+ enabled;
19954
+ /** Optional free-text description. */
19955
+ description;
19956
+ /**
19957
+ * Optional JSON Logic expression evaluated per event. When set, events
19958
+ * that don't match are recorded as `filtered_out` deliveries instead
19959
+ * of being POSTed to the destination.
19960
+ */
19961
+ filter;
19962
+ /**
19963
+ * Optional template applied to each event before delivery. Shape
19964
+ * depends on {@link transformType}; for `"JSONATA"`, a JSONata
19965
+ * expression string. `null` delivers the event JSON as-is.
19966
+ */
19967
+ transform;
19968
+ /**
19969
+ * Engine used to evaluate {@link transform}. Currently only
19970
+ * `"JSONATA"` is supported. Auto-filled by the SDK whenever
19971
+ * {@link transform} is set on save.
19972
+ */
19973
+ transformType;
19974
+ /**
19975
+ * When the audit service first persisted this forwarder. `null` for
19976
+ * an unsaved instance.
19977
+ */
19978
+ createdAt;
19979
+ /** When this forwarder was last mutated. */
19980
+ updatedAt;
19981
+ /** Soft-delete timestamp. `null` for live forwarders. */
19982
+ deletedAt;
19983
+ /** Monotonic version counter; bumped on every server-side write. */
19984
+ version;
19985
+ /** @internal */
19986
+ _client;
19987
+ constructor(client, fields) {
19988
+ this._client = client;
19989
+ this.id = fields.id ?? null;
19990
+ this.name = fields.name;
19991
+ this.forwarderType = fields.forwarderType;
19992
+ this.configuration = fields.configuration;
19993
+ this.enabled = fields.enabled ?? true;
19994
+ this.description = fields.description ?? null;
19995
+ this.filter = fields.filter ?? null;
19996
+ this.transform = fields.transform ?? null;
19997
+ this.transformType = fields.transformType ?? null;
19998
+ this.createdAt = fields.createdAt ?? null;
19999
+ this.updatedAt = fields.updatedAt ?? null;
20000
+ this.deletedAt = fields.deletedAt ?? null;
20001
+ this.version = fields.version ?? null;
20002
+ }
20003
+ /**
20004
+ * Create or update this forwarder on the server.
20005
+ *
20006
+ * Upsert behavior is driven by {@link createdAt}: a forwarder with
20007
+ * no `createdAt` is created (POST); otherwise it's full-replace
20008
+ * updated (PUT). After the call, every field is refreshed from the
20009
+ * server response (including newly-assigned `id`, `createdAt`,
20010
+ * `updatedAt`, `version`).
20011
+ */
20012
+ async save() {
20013
+ if (this._client === null) {
20014
+ throw new Error("Forwarder was constructed without a client; cannot save");
20015
+ }
20016
+ const other = this.createdAt === null ? await this._client._createForwarder(this) : await this._client._updateForwarder(this);
20017
+ this._apply(other);
20018
+ }
20019
+ /** Soft-delete this forwarder on the server. */
20020
+ async delete() {
20021
+ if (this._client === null || this.id === null) {
20022
+ throw new Error("Forwarder was constructed without a client or id; cannot delete");
20023
+ }
20024
+ await this._client._deleteForwarder(this.id);
20025
+ }
20026
+ /** @internal Copy every server-authoritative field from `other` onto self. */
20027
+ _apply(other) {
20028
+ this.id = other.id;
20029
+ this.name = other.name;
20030
+ this.forwarderType = other.forwarderType;
20031
+ this.configuration = other.configuration;
20032
+ this.enabled = other.enabled;
20033
+ this.description = other.description;
20034
+ this.filter = other.filter;
20035
+ this.transform = other.transform;
20036
+ this.transformType = other.transformType;
20037
+ this.createdAt = other.createdAt;
20038
+ this.updatedAt = other.updatedAt;
20039
+ this.deletedAt = other.deletedAt;
20040
+ this.version = other.version;
20041
+ }
20042
+ };
20043
+
19913
20044
  // src/management/audit.ts
19914
20045
  async function checkError4(response) {
19915
20046
  const body = await response.text().catch(() => "");
@@ -19936,79 +20067,106 @@ function _paginationFromBody2(body) {
19936
20067
  }
19937
20068
  return out;
19938
20069
  }
19939
- function _httpToWire(http) {
20070
+ function _configurationToWire(config) {
19940
20071
  return {
19941
- method: http.method,
19942
- url: http.url,
19943
- headers: http.headers.map((h) => ({ name: h.name, value: h.value })),
19944
- body: http.body,
19945
- success_status: http.successStatus
20072
+ method: config.method,
20073
+ url: config.url,
20074
+ headers: config.headers.map((h) => ({ name: h.name, value: h.value })),
20075
+ success_status: config.successStatus
19946
20076
  };
19947
20077
  }
19948
- function _httpFromWire(raw) {
20078
+ function _configurationFromWire(raw) {
19949
20079
  const r = raw ?? {};
19950
20080
  const headers = (r.headers ?? []).map((h) => ({
19951
20081
  name: String(h.name ?? ""),
19952
20082
  value: String(h.value ?? "")
19953
20083
  }));
19954
- return {
19955
- method: String(r.method ?? "POST"),
20084
+ return new HttpConfiguration({
20085
+ method: r.method ?? "POST" /* POST */,
19956
20086
  url: String(r.url ?? ""),
19957
20087
  headers,
19958
- body: r.body ?? null,
19959
20088
  successStatus: String(r.success_status ?? "2xx")
19960
- };
20089
+ });
19961
20090
  }
19962
- function _forwarderAttributes(input) {
20091
+ function _forwarderAttrs(forwarder) {
19963
20092
  const attrs = {
19964
- name: input.name,
19965
- forwarder_type: input.forwarderType,
19966
- enabled: input.enabled ?? true,
19967
- http: _httpToWire(input.http)
20093
+ name: forwarder.name,
20094
+ forwarder_type: forwarder.forwarderType,
20095
+ enabled: forwarder.enabled,
20096
+ configuration: _configurationToWire(forwarder.configuration)
19968
20097
  };
19969
- if (input.filter !== void 0) {
19970
- attrs.filter = input.filter;
20098
+ if (forwarder.description !== null) attrs.description = forwarder.description;
20099
+ if (forwarder.filter !== null) {
20100
+ attrs.filter = forwarder.filter;
20101
+ }
20102
+ if (forwarder.transform !== null) {
20103
+ attrs.transform_type = "JSONATA" /* JSONATA */;
20104
+ attrs.transform = forwarder.transform;
19971
20105
  }
19972
- if (input.transform !== void 0) attrs.transform = input.transform;
19973
20106
  return attrs;
19974
20107
  }
19975
- function _forwarderFromResource(resource) {
20108
+ function _forwarderFromResource(resource, client) {
19976
20109
  const a = resource.attributes;
19977
- return {
20110
+ return new Forwarder(client, {
19978
20111
  id: resource.id,
19979
20112
  name: String(a.name ?? ""),
19980
- slug: String(a.slug ?? ""),
20113
+ description: a.description ?? null,
19981
20114
  forwarderType: a.forwarder_type,
19982
20115
  enabled: Boolean(a.enabled ?? true),
19983
20116
  filter: a.filter ?? null,
20117
+ transformType: a.transform_type ?? null,
19984
20118
  transform: a.transform ?? null,
19985
- http: _httpFromWire(a.http),
20119
+ configuration: _configurationFromWire(a.configuration),
19986
20120
  createdAt: a.created_at ?? null,
19987
20121
  updatedAt: a.updated_at ?? null,
19988
20122
  deletedAt: a.deleted_at ?? null,
19989
20123
  version: a.version ?? null
19990
- };
20124
+ });
19991
20125
  }
19992
20126
  var ForwardersClient = class {
19993
20127
  /** @internal */
19994
20128
  constructor(_http) {
19995
20129
  this._http = _http;
19996
20130
  }
19997
- async create(input) {
19998
- const body = {
19999
- data: { id: "", type: "forwarder", attributes: _forwarderAttributes(input) }
20000
- };
20001
- let data;
20002
- try {
20003
- const result = await this._http.POST("/api/v1/forwarders", { body });
20004
- if (!result.response.ok) await checkError4(result.response);
20005
- data = result.data;
20006
- } catch (err) {
20007
- wrapFetchError4(err);
20008
- }
20009
- if (!data?.data) throw new SmplError("Unexpected empty response from audit");
20010
- return _forwarderFromResource(data.data);
20131
+ /**
20132
+ * Construct an unsaved {@link Forwarder}. Call {@link Forwarder.save}
20133
+ * to persist.
20134
+ *
20135
+ * @param fields.name Display name. Free-form.
20136
+ * @param fields.forwarderType Destination type — see {@link ForwarderType}.
20137
+ * @param fields.configuration Destination HTTP request configuration.
20138
+ * Headers carry credentials and are
20139
+ * encrypted at rest server-side; reads
20140
+ * return them redacted.
20141
+ * @param fields.enabled Whether the forwarder is active. Defaults true.
20142
+ * @param fields.description Optional free-text description.
20143
+ * @param fields.filter Optional JSON Logic filter; events that
20144
+ * don't match are recorded as
20145
+ * `filtered_out` deliveries.
20146
+ * @param fields.transform Optional JSONata template applied to
20147
+ * the event payload before POST. `null`
20148
+ * delivers the event as-is.
20149
+ */
20150
+ new(fields) {
20151
+ return new Forwarder(this, {
20152
+ name: fields.name,
20153
+ forwarderType: fields.forwarderType,
20154
+ configuration: fields.configuration,
20155
+ enabled: fields.enabled,
20156
+ description: fields.description,
20157
+ filter: fields.filter,
20158
+ transform: fields.transform
20159
+ });
20011
20160
  }
20161
+ /**
20162
+ * List forwarders for the authenticated account.
20163
+ *
20164
+ * Offset paginated per ADR-014: pass {@link ListForwardersParams.pageNumber}
20165
+ * (1-based) and {@link ListForwardersParams.pageSize} (default 1000,
20166
+ * max 1000). Pass `metaTotal=true` to populate `total` and `totalPages`
20167
+ * in the returned `pagination` (costs an extra `COUNT` query
20168
+ * server-side).
20169
+ */
20012
20170
  async list(params = {}) {
20013
20171
  const query = {};
20014
20172
  if (params.forwarderType !== void 0) query["filter[forwarder_type]"] = params.forwarderType;
@@ -20027,10 +20185,15 @@ var ForwardersClient = class {
20027
20185
  wrapFetchError4(err);
20028
20186
  }
20029
20187
  return {
20030
- forwarders: (data?.data ?? []).map(_forwarderFromResource),
20188
+ forwarders: (data?.data ?? []).map((r) => _forwarderFromResource(r, this)),
20031
20189
  pagination: _paginationFromBody2(data ?? {})
20032
20190
  };
20033
20191
  }
20192
+ /**
20193
+ * Fetch a single forwarder by id. The returned instance is bound to
20194
+ * this client so {@link Forwarder.save} and {@link Forwarder.delete}
20195
+ * round-trip back here.
20196
+ */
20034
20197
  async get(forwarderId) {
20035
20198
  let data;
20036
20199
  try {
@@ -20043,41 +20206,67 @@ var ForwardersClient = class {
20043
20206
  wrapFetchError4(err);
20044
20207
  }
20045
20208
  if (!data?.data) throw new SmplError("Unexpected empty response from audit");
20046
- return _forwarderFromResource(data.data);
20209
+ return _forwarderFromResource(data.data, this);
20210
+ }
20211
+ /** Soft-delete a forwarder by id. */
20212
+ async delete(forwarderId) {
20213
+ try {
20214
+ const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
20215
+ params: { path: { forwarder_id: forwarderId } }
20216
+ });
20217
+ if (result.response.status !== 204) await checkError4(result.response);
20218
+ } catch (err) {
20219
+ wrapFetchError4(err);
20220
+ }
20047
20221
  }
20048
20222
  /**
20049
- * Full-replace update. PUT semantics every field is overwritten.
20050
- *
20051
- * Header values must be re-supplied as plaintext; the GET path
20052
- * returns them in plaintext for exactly this round-trip.
20223
+ * @internal Called by `Forwarder.save()` on unsaved instances.
20053
20224
  */
20054
- async update(forwarderId, input) {
20225
+ async _createForwarder(forwarder) {
20055
20226
  const body = {
20056
- data: { id: forwarderId, type: "forwarder", attributes: _forwarderAttributes(input) }
20227
+ data: { id: "", type: "forwarder", attributes: _forwarderAttrs(forwarder) }
20057
20228
  };
20058
20229
  let data;
20059
20230
  try {
20060
- const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
20061
- params: { path: { forwarder_id: forwarderId } },
20062
- body
20063
- });
20231
+ const result = await this._http.POST("/api/v1/forwarders", { body });
20064
20232
  if (!result.response.ok) await checkError4(result.response);
20065
20233
  data = result.data;
20066
20234
  } catch (err) {
20067
20235
  wrapFetchError4(err);
20068
20236
  }
20069
20237
  if (!data?.data) throw new SmplError("Unexpected empty response from audit");
20070
- return _forwarderFromResource(data.data);
20238
+ return _forwarderFromResource(data.data, this);
20071
20239
  }
20072
- async delete(forwarderId) {
20240
+ /**
20241
+ * @internal Full-replace PUT. Called by `Forwarder.save()` on
20242
+ * instances that already have a `createdAt`. Header values must be
20243
+ * re-supplied as plaintext; the GET path redacts them, so a PUT body
20244
+ * containing `"<redacted>"` would persist that literal.
20245
+ */
20246
+ async _updateForwarder(forwarder) {
20247
+ if (forwarder.id === null) {
20248
+ throw new Error("cannot update a Forwarder with no id");
20249
+ }
20250
+ const body = {
20251
+ data: { id: forwarder.id, type: "forwarder", attributes: _forwarderAttrs(forwarder) }
20252
+ };
20253
+ let data;
20073
20254
  try {
20074
- const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
20075
- params: { path: { forwarder_id: forwarderId } }
20255
+ const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
20256
+ params: { path: { forwarder_id: forwarder.id } },
20257
+ body
20076
20258
  });
20077
- if (result.response.status !== 204) await checkError4(result.response);
20259
+ if (!result.response.ok) await checkError4(result.response);
20260
+ data = result.data;
20078
20261
  } catch (err) {
20079
20262
  wrapFetchError4(err);
20080
20263
  }
20264
+ if (!data?.data) throw new SmplError("Unexpected empty response from audit");
20265
+ return _forwarderFromResource(data.data, this);
20266
+ }
20267
+ /** @internal Called by `Forwarder.delete()`. */
20268
+ async _deleteForwarder(id) {
20269
+ return this.delete(id);
20081
20270
  }
20082
20271
  };
20083
20272
  var ManagementAuditClient = class {