@smplkit/sdk 3.0.52 → 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.js CHANGED
@@ -17097,10 +17097,10 @@ function resolveChain(chain, environment) {
17097
17097
 
17098
17098
  // src/config/types.ts
17099
17099
  var ItemType = /* @__PURE__ */ ((ItemType2) => {
17100
- ItemType2["STRING"] = "STRING";
17101
- ItemType2["NUMBER"] = "NUMBER";
17102
17100
  ItemType2["BOOLEAN"] = "BOOLEAN";
17103
17101
  ItemType2["JSON"] = "JSON";
17102
+ ItemType2["NUMBER"] = "NUMBER";
17103
+ ItemType2["STRING"] = "STRING";
17104
17104
  return ItemType2;
17105
17105
  })(ItemType || {});
17106
17106
  var ConfigItem = class {
@@ -18279,8 +18279,8 @@ import createClient3 from "openapi-fetch";
18279
18279
 
18280
18280
  // src/management/types.ts
18281
18281
  var EnvironmentClassification = /* @__PURE__ */ ((EnvironmentClassification3) => {
18282
- EnvironmentClassification3["STANDARD"] = "STANDARD";
18283
18282
  EnvironmentClassification3["AD_HOC"] = "AD_HOC";
18283
+ EnvironmentClassification3["STANDARD"] = "STANDARD";
18284
18284
  return EnvironmentClassification3;
18285
18285
  })(EnvironmentClassification || {});
18286
18286
  var HEX_RE = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
@@ -18512,14 +18512,14 @@ var AccountSettings = class {
18512
18512
 
18513
18513
  // src/flags/types.ts
18514
18514
  var Op = /* @__PURE__ */ ((Op2) => {
18515
+ Op2["CONTAINS"] = "contains";
18515
18516
  Op2["EQ"] = "==";
18516
- Op2["NEQ"] = "!=";
18517
- Op2["LT"] = "<";
18518
- Op2["LTE"] = "<=";
18519
18517
  Op2["GT"] = ">";
18520
18518
  Op2["GTE"] = ">=";
18521
18519
  Op2["IN"] = "in";
18522
- Op2["CONTAINS"] = "contains";
18520
+ Op2["LT"] = "<";
18521
+ Op2["LTE"] = "<=";
18522
+ Op2["NEQ"] = "!=";
18523
18523
  return Op2;
18524
18524
  })(Op || {});
18525
18525
  var CONTEXT_FIELDS = /* @__PURE__ */ new Set([
@@ -19208,13 +19208,13 @@ function _coerceValues(values) {
19208
19208
 
19209
19209
  // src/logging/types.ts
19210
19210
  var LogLevel = /* @__PURE__ */ ((LogLevel5) => {
19211
- LogLevel5["TRACE"] = "TRACE";
19212
19211
  LogLevel5["DEBUG"] = "DEBUG";
19213
- LogLevel5["INFO"] = "INFO";
19214
- LogLevel5["WARN"] = "WARN";
19215
19212
  LogLevel5["ERROR"] = "ERROR";
19216
19213
  LogLevel5["FATAL"] = "FATAL";
19214
+ LogLevel5["INFO"] = "INFO";
19217
19215
  LogLevel5["SILENT"] = "SILENT";
19216
+ LogLevel5["TRACE"] = "TRACE";
19217
+ LogLevel5["WARN"] = "WARN";
19218
19218
  return LogLevel5;
19219
19219
  })(LogLevel || {});
19220
19220
  var LoggerChangeEvent = class {
@@ -19840,6 +19840,137 @@ var LogGroupsClient = class {
19840
19840
  }
19841
19841
  };
19842
19842
 
19843
+ // src/audit/types.ts
19844
+ var HttpConfiguration = class {
19845
+ /** HTTP verb used for delivery. Defaults to {@link HttpMethod.POST}. */
19846
+ method;
19847
+ /** Destination URL the audit service POSTs each event to. */
19848
+ url;
19849
+ /**
19850
+ * Headers attached to every outbound request. Values carry credentials
19851
+ * and are encrypted at rest server-side; reads return them redacted.
19852
+ */
19853
+ headers;
19854
+ /**
19855
+ * Status the destination must return for delivery to count as success
19856
+ * — either an exact code (`"200"`, `"204"`) or a status class
19857
+ * (`"2xx"`, `"4xx"`). Defaults to `"2xx"`.
19858
+ */
19859
+ successStatus;
19860
+ constructor(fields = {}) {
19861
+ this.method = fields.method ?? "POST" /* POST */;
19862
+ this.url = fields.url ?? "";
19863
+ this.headers = fields.headers ?? [];
19864
+ this.successStatus = fields.successStatus ?? "2xx";
19865
+ }
19866
+ };
19867
+ var Forwarder = class {
19868
+ /**
19869
+ * Server-assigned UUID for this forwarder. `null` until {@link save}
19870
+ * has run for the first time.
19871
+ */
19872
+ id;
19873
+ /** Display name. Free-form. */
19874
+ name;
19875
+ /** Destination type — see {@link ForwarderType}. */
19876
+ forwarderType;
19877
+ /** Destination request configuration. */
19878
+ configuration;
19879
+ /**
19880
+ * When `false`, the audit service skips delivery for this forwarder
19881
+ * but still records `filtered_out` deliveries.
19882
+ */
19883
+ enabled;
19884
+ /** Optional free-text description. */
19885
+ description;
19886
+ /**
19887
+ * Optional JSON Logic expression evaluated per event. When set, events
19888
+ * that don't match are recorded as `filtered_out` deliveries instead
19889
+ * of being POSTed to the destination.
19890
+ */
19891
+ filter;
19892
+ /**
19893
+ * Optional template applied to each event before delivery. Shape
19894
+ * depends on {@link transformType}; for `"JSONATA"`, a JSONata
19895
+ * expression string. `null` delivers the event JSON as-is.
19896
+ */
19897
+ transform;
19898
+ /**
19899
+ * Engine used to evaluate {@link transform}. Currently only
19900
+ * `"JSONATA"` is supported. Auto-filled by the SDK whenever
19901
+ * {@link transform} is set on save.
19902
+ */
19903
+ transformType;
19904
+ /**
19905
+ * When the audit service first persisted this forwarder. `null` for
19906
+ * an unsaved instance.
19907
+ */
19908
+ createdAt;
19909
+ /** When this forwarder was last mutated. */
19910
+ updatedAt;
19911
+ /** Soft-delete timestamp. `null` for live forwarders. */
19912
+ deletedAt;
19913
+ /** Monotonic version counter; bumped on every server-side write. */
19914
+ version;
19915
+ /** @internal */
19916
+ _client;
19917
+ constructor(client, fields) {
19918
+ this._client = client;
19919
+ this.id = fields.id ?? null;
19920
+ this.name = fields.name;
19921
+ this.forwarderType = fields.forwarderType;
19922
+ this.configuration = fields.configuration;
19923
+ this.enabled = fields.enabled ?? true;
19924
+ this.description = fields.description ?? null;
19925
+ this.filter = fields.filter ?? null;
19926
+ this.transform = fields.transform ?? null;
19927
+ this.transformType = fields.transformType ?? null;
19928
+ this.createdAt = fields.createdAt ?? null;
19929
+ this.updatedAt = fields.updatedAt ?? null;
19930
+ this.deletedAt = fields.deletedAt ?? null;
19931
+ this.version = fields.version ?? null;
19932
+ }
19933
+ /**
19934
+ * Create or update this forwarder on the server.
19935
+ *
19936
+ * Upsert behavior is driven by {@link createdAt}: a forwarder with
19937
+ * no `createdAt` is created (POST); otherwise it's full-replace
19938
+ * updated (PUT). After the call, every field is refreshed from the
19939
+ * server response (including newly-assigned `id`, `createdAt`,
19940
+ * `updatedAt`, `version`).
19941
+ */
19942
+ async save() {
19943
+ if (this._client === null) {
19944
+ throw new Error("Forwarder was constructed without a client; cannot save");
19945
+ }
19946
+ const other = this.createdAt === null ? await this._client._createForwarder(this) : await this._client._updateForwarder(this);
19947
+ this._apply(other);
19948
+ }
19949
+ /** Soft-delete this forwarder on the server. */
19950
+ async delete() {
19951
+ if (this._client === null || this.id === null) {
19952
+ throw new Error("Forwarder was constructed without a client or id; cannot delete");
19953
+ }
19954
+ await this._client._deleteForwarder(this.id);
19955
+ }
19956
+ /** @internal Copy every server-authoritative field from `other` onto self. */
19957
+ _apply(other) {
19958
+ this.id = other.id;
19959
+ this.name = other.name;
19960
+ this.forwarderType = other.forwarderType;
19961
+ this.configuration = other.configuration;
19962
+ this.enabled = other.enabled;
19963
+ this.description = other.description;
19964
+ this.filter = other.filter;
19965
+ this.transform = other.transform;
19966
+ this.transformType = other.transformType;
19967
+ this.createdAt = other.createdAt;
19968
+ this.updatedAt = other.updatedAt;
19969
+ this.deletedAt = other.deletedAt;
19970
+ this.version = other.version;
19971
+ }
19972
+ };
19973
+
19843
19974
  // src/management/audit.ts
19844
19975
  async function checkError4(response) {
19845
19976
  const body = await response.text().catch(() => "");
@@ -19880,31 +20011,33 @@ function _configurationFromWire(raw) {
19880
20011
  name: String(h.name ?? ""),
19881
20012
  value: String(h.value ?? "")
19882
20013
  }));
19883
- return {
19884
- method: String(r.method ?? "POST"),
20014
+ return new HttpConfiguration({
20015
+ method: r.method ?? "POST" /* POST */,
19885
20016
  url: String(r.url ?? ""),
19886
20017
  headers,
19887
20018
  successStatus: String(r.success_status ?? "2xx")
19888
- };
20019
+ });
19889
20020
  }
19890
- function _forwarderAttributes(input) {
20021
+ function _forwarderAttrs(forwarder) {
19891
20022
  const attrs = {
19892
- name: input.name,
19893
- forwarder_type: input.forwarderType,
19894
- enabled: input.enabled ?? true,
19895
- configuration: _configurationToWire(input.configuration)
20023
+ name: forwarder.name,
20024
+ forwarder_type: forwarder.forwarderType,
20025
+ enabled: forwarder.enabled,
20026
+ configuration: _configurationToWire(forwarder.configuration)
19896
20027
  };
19897
- if (input.description !== void 0) attrs.description = input.description;
19898
- if (input.filter !== void 0) {
19899
- attrs.filter = input.filter;
20028
+ if (forwarder.description !== null) attrs.description = forwarder.description;
20029
+ if (forwarder.filter !== null) {
20030
+ attrs.filter = forwarder.filter;
20031
+ }
20032
+ if (forwarder.transform !== null) {
20033
+ attrs.transform_type = "JSONATA" /* JSONATA */;
20034
+ attrs.transform = forwarder.transform;
19900
20035
  }
19901
- if (input.transformType !== void 0) attrs.transform_type = input.transformType;
19902
- if (input.transform !== void 0) attrs.transform = input.transform;
19903
20036
  return attrs;
19904
20037
  }
19905
- function _forwarderFromResource(resource) {
20038
+ function _forwarderFromResource(resource, client) {
19906
20039
  const a = resource.attributes;
19907
- return {
20040
+ return new Forwarder(client, {
19908
20041
  id: resource.id,
19909
20042
  name: String(a.name ?? ""),
19910
20043
  description: a.description ?? null,
@@ -19918,28 +20051,52 @@ function _forwarderFromResource(resource) {
19918
20051
  updatedAt: a.updated_at ?? null,
19919
20052
  deletedAt: a.deleted_at ?? null,
19920
20053
  version: a.version ?? null
19921
- };
20054
+ });
19922
20055
  }
19923
20056
  var ForwardersClient = class {
19924
20057
  /** @internal */
19925
20058
  constructor(_http) {
19926
20059
  this._http = _http;
19927
20060
  }
19928
- async create(input) {
19929
- const body = {
19930
- data: { id: "", type: "forwarder", attributes: _forwarderAttributes(input) }
19931
- };
19932
- let data;
19933
- try {
19934
- const result = await this._http.POST("/api/v1/forwarders", { body });
19935
- if (!result.response.ok) await checkError4(result.response);
19936
- data = result.data;
19937
- } catch (err) {
19938
- wrapFetchError4(err);
19939
- }
19940
- if (!data?.data) throw new SmplError("Unexpected empty response from audit");
19941
- return _forwarderFromResource(data.data);
20061
+ /**
20062
+ * Construct an unsaved {@link Forwarder}. Call {@link Forwarder.save}
20063
+ * to persist.
20064
+ *
20065
+ * @param fields.name Display name. Free-form.
20066
+ * @param fields.forwarderType Destination type — see {@link ForwarderType}.
20067
+ * @param fields.configuration Destination HTTP request configuration.
20068
+ * Headers carry credentials and are
20069
+ * encrypted at rest server-side; reads
20070
+ * return them redacted.
20071
+ * @param fields.enabled Whether the forwarder is active. Defaults true.
20072
+ * @param fields.description Optional free-text description.
20073
+ * @param fields.filter Optional JSON Logic filter; events that
20074
+ * don't match are recorded as
20075
+ * `filtered_out` deliveries.
20076
+ * @param fields.transform Optional JSONata template applied to
20077
+ * the event payload before POST. `null`
20078
+ * delivers the event as-is.
20079
+ */
20080
+ new(fields) {
20081
+ return new Forwarder(this, {
20082
+ name: fields.name,
20083
+ forwarderType: fields.forwarderType,
20084
+ configuration: fields.configuration,
20085
+ enabled: fields.enabled,
20086
+ description: fields.description,
20087
+ filter: fields.filter,
20088
+ transform: fields.transform
20089
+ });
19942
20090
  }
20091
+ /**
20092
+ * List forwarders for the authenticated account.
20093
+ *
20094
+ * Offset paginated per ADR-014: pass {@link ListForwardersParams.pageNumber}
20095
+ * (1-based) and {@link ListForwardersParams.pageSize} (default 1000,
20096
+ * max 1000). Pass `metaTotal=true` to populate `total` and `totalPages`
20097
+ * in the returned `pagination` (costs an extra `COUNT` query
20098
+ * server-side).
20099
+ */
19943
20100
  async list(params = {}) {
19944
20101
  const query = {};
19945
20102
  if (params.forwarderType !== void 0) query["filter[forwarder_type]"] = params.forwarderType;
@@ -19958,10 +20115,15 @@ var ForwardersClient = class {
19958
20115
  wrapFetchError4(err);
19959
20116
  }
19960
20117
  return {
19961
- forwarders: (data?.data ?? []).map(_forwarderFromResource),
20118
+ forwarders: (data?.data ?? []).map((r) => _forwarderFromResource(r, this)),
19962
20119
  pagination: _paginationFromBody2(data ?? {})
19963
20120
  };
19964
20121
  }
20122
+ /**
20123
+ * Fetch a single forwarder by id. The returned instance is bound to
20124
+ * this client so {@link Forwarder.save} and {@link Forwarder.delete}
20125
+ * round-trip back here.
20126
+ */
19965
20127
  async get(forwarderId) {
19966
20128
  let data;
19967
20129
  try {
@@ -19974,41 +20136,67 @@ var ForwardersClient = class {
19974
20136
  wrapFetchError4(err);
19975
20137
  }
19976
20138
  if (!data?.data) throw new SmplError("Unexpected empty response from audit");
19977
- return _forwarderFromResource(data.data);
20139
+ return _forwarderFromResource(data.data, this);
20140
+ }
20141
+ /** Soft-delete a forwarder by id. */
20142
+ async delete(forwarderId) {
20143
+ try {
20144
+ const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
20145
+ params: { path: { forwarder_id: forwarderId } }
20146
+ });
20147
+ if (result.response.status !== 204) await checkError4(result.response);
20148
+ } catch (err) {
20149
+ wrapFetchError4(err);
20150
+ }
19978
20151
  }
19979
20152
  /**
19980
- * Full-replace update. PUT semantics every field is overwritten.
19981
- *
19982
- * Header values must be re-supplied as plaintext; the GET path
19983
- * returns them in plaintext for exactly this round-trip.
20153
+ * @internal Called by `Forwarder.save()` on unsaved instances.
19984
20154
  */
19985
- async update(forwarderId, input) {
20155
+ async _createForwarder(forwarder) {
19986
20156
  const body = {
19987
- data: { id: forwarderId, type: "forwarder", attributes: _forwarderAttributes(input) }
20157
+ data: { id: "", type: "forwarder", attributes: _forwarderAttrs(forwarder) }
19988
20158
  };
19989
20159
  let data;
19990
20160
  try {
19991
- const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
19992
- params: { path: { forwarder_id: forwarderId } },
19993
- body
19994
- });
20161
+ const result = await this._http.POST("/api/v1/forwarders", { body });
19995
20162
  if (!result.response.ok) await checkError4(result.response);
19996
20163
  data = result.data;
19997
20164
  } catch (err) {
19998
20165
  wrapFetchError4(err);
19999
20166
  }
20000
20167
  if (!data?.data) throw new SmplError("Unexpected empty response from audit");
20001
- return _forwarderFromResource(data.data);
20168
+ return _forwarderFromResource(data.data, this);
20002
20169
  }
20003
- async delete(forwarderId) {
20170
+ /**
20171
+ * @internal Full-replace PUT. Called by `Forwarder.save()` on
20172
+ * instances that already have a `createdAt`. Header values must be
20173
+ * re-supplied as plaintext; the GET path redacts them, so a PUT body
20174
+ * containing `"<redacted>"` would persist that literal.
20175
+ */
20176
+ async _updateForwarder(forwarder) {
20177
+ if (forwarder.id === null) {
20178
+ throw new Error("cannot update a Forwarder with no id");
20179
+ }
20180
+ const body = {
20181
+ data: { id: forwarder.id, type: "forwarder", attributes: _forwarderAttrs(forwarder) }
20182
+ };
20183
+ let data;
20004
20184
  try {
20005
- const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
20006
- params: { path: { forwarder_id: forwarderId } }
20185
+ const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
20186
+ params: { path: { forwarder_id: forwarder.id } },
20187
+ body
20007
20188
  });
20008
- if (result.response.status !== 204) await checkError4(result.response);
20189
+ if (!result.response.ok) await checkError4(result.response);
20190
+ data = result.data;
20009
20191
  } catch (err) {
20010
20192
  wrapFetchError4(err);
20011
20193
  }
20194
+ if (!data?.data) throw new SmplError("Unexpected empty response from audit");
20195
+ return _forwarderFromResource(data.data, this);
20196
+ }
20197
+ /** @internal Called by `Forwarder.delete()`. */
20198
+ async _deleteForwarder(id) {
20199
+ return this.delete(id);
20012
20200
  }
20013
20201
  };
20014
20202
  var ManagementAuditClient = class {