@smplkit/sdk 3.0.33 → 3.0.35

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
@@ -16624,6 +16624,7 @@ __export(index_exports, {
16624
16624
  AccountSettings: () => AccountSettings,
16625
16625
  AccountSettingsClient: () => AccountSettingsClient,
16626
16626
  AuditClient: () => AuditClient,
16627
+ AuditForwardersClient: () => ForwardersClient,
16627
16628
  BooleanFlag: () => BooleanFlag,
16628
16629
  Color: () => Color,
16629
16630
  Config: () => Config,
@@ -16655,6 +16656,7 @@ __export(index_exports, {
16655
16656
  LoggerEnvironment: () => LoggerEnvironment,
16656
16657
  LoggerSource: () => LoggerSource,
16657
16658
  LoggingClient: () => LoggingClient,
16659
+ ManagementAuditClient: () => ManagementAuditClient,
16658
16660
  NumberFlag: () => NumberFlag,
16659
16661
  Op: () => Op,
16660
16662
  PinoAdapter: () => PinoAdapter,
@@ -16666,12 +16668,14 @@ __export(index_exports, {
16666
16668
  SmplError: () => SmplError,
16667
16669
  SmplManagementClient: () => SmplManagementClient,
16668
16670
  SmplNotFoundError: () => SmplNotFoundError,
16671
+ SmplPaymentRequiredError: () => SmplPaymentRequiredError,
16669
16672
  SmplTimeoutError: () => SmplTimeoutError,
16670
16673
  SmplValidationError: () => SmplValidationError,
16671
16674
  SmplkitConflictError: () => SmplConflictError,
16672
16675
  SmplkitConnectionError: () => SmplConnectionError,
16673
16676
  SmplkitError: () => SmplError,
16674
16677
  SmplkitNotFoundError: () => SmplNotFoundError,
16678
+ SmplkitPaymentRequiredError: () => SmplPaymentRequiredError,
16675
16679
  SmplkitTimeoutError: () => SmplTimeoutError,
16676
16680
  SmplkitValidationError: () => SmplValidationError,
16677
16681
  StringFlag: () => StringFlag,
@@ -16685,6 +16689,122 @@ var import_openapi_fetch6 = __toESM(require("openapi-fetch"), 1);
16685
16689
  // src/audit/client.ts
16686
16690
  var import_openapi_fetch = __toESM(require("openapi-fetch"), 1);
16687
16691
 
16692
+ // src/errors.ts
16693
+ var SmplError = class extends Error {
16694
+ /** The HTTP status code, if the error originated from an HTTP response. */
16695
+ statusCode;
16696
+ /** The raw response body, if available. */
16697
+ responseBody;
16698
+ /** Structured JSON:API error objects from the server response, if available. */
16699
+ errors;
16700
+ constructor(message, statusCode, responseBody, errors) {
16701
+ super(message);
16702
+ this.name = "SmplError";
16703
+ this.statusCode = statusCode;
16704
+ this.responseBody = responseBody;
16705
+ this.errors = errors ?? [];
16706
+ Object.setPrototypeOf(this, new.target.prototype);
16707
+ }
16708
+ toString() {
16709
+ if (this.errors.length === 0) {
16710
+ return `${this.name}: ${this.message}`;
16711
+ }
16712
+ if (this.errors.length === 1) {
16713
+ return `${this.name}: ${this.message}
16714
+ Error: ${JSON.stringify(this.errors[0])}`;
16715
+ }
16716
+ const lines = this.errors.map((e, i) => ` [${i}] ${JSON.stringify(e)}`);
16717
+ return `${this.name}: ${this.message}
16718
+ Errors:
16719
+ ${lines.join("\n")}`;
16720
+ }
16721
+ };
16722
+ var SmplConnectionError = class extends SmplError {
16723
+ constructor(message, statusCode, responseBody, errors) {
16724
+ super(message, statusCode, responseBody, errors);
16725
+ this.name = "SmplConnectionError";
16726
+ Object.setPrototypeOf(this, new.target.prototype);
16727
+ }
16728
+ };
16729
+ var SmplTimeoutError = class extends SmplError {
16730
+ constructor(message, statusCode, responseBody, errors) {
16731
+ super(message, statusCode, responseBody, errors);
16732
+ this.name = "SmplTimeoutError";
16733
+ Object.setPrototypeOf(this, new.target.prototype);
16734
+ }
16735
+ };
16736
+ var SmplNotFoundError = class extends SmplError {
16737
+ constructor(message, statusCode, responseBody, errors) {
16738
+ super(message, statusCode ?? 404, responseBody, errors);
16739
+ this.name = "SmplNotFoundError";
16740
+ Object.setPrototypeOf(this, new.target.prototype);
16741
+ }
16742
+ };
16743
+ var SmplConflictError = class extends SmplError {
16744
+ constructor(message, statusCode, responseBody, errors) {
16745
+ super(message, statusCode ?? 409, responseBody, errors);
16746
+ this.name = "SmplConflictError";
16747
+ Object.setPrototypeOf(this, new.target.prototype);
16748
+ }
16749
+ };
16750
+ var SmplValidationError = class extends SmplError {
16751
+ constructor(message, statusCode, responseBody, errors) {
16752
+ super(message, statusCode ?? 422, responseBody, errors);
16753
+ this.name = "SmplValidationError";
16754
+ Object.setPrototypeOf(this, new.target.prototype);
16755
+ }
16756
+ };
16757
+ var SmplPaymentRequiredError = class extends SmplError {
16758
+ constructor(message, statusCode, responseBody, errors) {
16759
+ super(message, statusCode ?? 402, responseBody, errors);
16760
+ this.name = "SmplPaymentRequiredError";
16761
+ Object.setPrototypeOf(this, new.target.prototype);
16762
+ }
16763
+ };
16764
+ function parseJsonApiErrors(body) {
16765
+ try {
16766
+ const parsed = JSON.parse(body);
16767
+ if (parsed && Array.isArray(parsed.errors)) {
16768
+ return parsed.errors.map((e) => ({
16769
+ ...e.status !== void 0 ? { status: String(e.status) } : {},
16770
+ ...e.title !== void 0 ? { title: String(e.title) } : {},
16771
+ ...e.detail !== void 0 ? { detail: String(e.detail) } : {},
16772
+ ...e.source !== void 0 && typeof e.source === "object" && e.source !== null ? { source: e.source } : {}
16773
+ }));
16774
+ }
16775
+ } catch {
16776
+ }
16777
+ return [];
16778
+ }
16779
+ function deriveMessage(errors, statusCode, body) {
16780
+ if (errors.length === 0) {
16781
+ return body ? `HTTP ${statusCode}: ${body}` : `HTTP ${statusCode}`;
16782
+ }
16783
+ const first = errors[0];
16784
+ const base = first.detail ?? first.title ?? (first.status ? `HTTP ${first.status}` : `HTTP ${statusCode}`);
16785
+ if (errors.length > 1) {
16786
+ return `${base} (and ${errors.length - 1} more error${errors.length - 1 > 1 ? "s" : ""})`;
16787
+ }
16788
+ return base;
16789
+ }
16790
+ function throwForStatus(statusCode, body) {
16791
+ const errors = parseJsonApiErrors(body);
16792
+ const message = deriveMessage(errors, statusCode, body);
16793
+ switch (statusCode) {
16794
+ case 400:
16795
+ case 422:
16796
+ throw new SmplValidationError(message, statusCode, body, errors);
16797
+ case 402:
16798
+ throw new SmplPaymentRequiredError(message, statusCode, body, errors);
16799
+ case 404:
16800
+ throw new SmplNotFoundError(message, statusCode, body, errors);
16801
+ case 409:
16802
+ throw new SmplConflictError(message, statusCode, body, errors);
16803
+ default:
16804
+ throw new SmplError(message, statusCode, body, errors);
16805
+ }
16806
+ }
16807
+
16688
16808
  // src/audit/buffer.ts
16689
16809
  var MAX_BUFFER_SIZE = 1e3;
16690
16810
  var PERIODIC_FLUSH_INTERVAL_MS = 5e3;
@@ -16828,83 +16948,14 @@ function _eventFromResource(resource) {
16828
16948
  doNotForward: Boolean(attrs.do_not_forward ?? false)
16829
16949
  };
16830
16950
  }
16831
- function _httpToWire(http) {
16832
- return {
16833
- method: http.method,
16834
- url: http.url,
16835
- headers: http.headers.map((h) => ({ name: h.name, value: h.value })),
16836
- body: http.body,
16837
- success_status: http.successStatus
16838
- };
16839
- }
16840
- function _httpFromWire(raw) {
16841
- const r = raw ?? {};
16842
- const headers = (r.headers ?? []).map((h) => ({
16843
- name: String(h.name ?? ""),
16844
- value: String(h.value ?? "")
16845
- }));
16846
- return {
16847
- method: String(r.method ?? "POST"),
16848
- url: String(r.url ?? ""),
16849
- headers,
16850
- body: r.body ?? null,
16851
- successStatus: String(r.success_status ?? "2xx")
16852
- };
16853
- }
16854
- function _forwarderAttributes(input) {
16855
- const attrs = {
16856
- name: input.name,
16857
- forwarder_type: input.forwarderType,
16858
- enabled: input.enabled ?? true,
16859
- http: _httpToWire(input.http)
16860
- };
16861
- if (input.filter !== void 0) {
16862
- attrs.filter = input.filter;
16863
- }
16864
- if (input.transform !== void 0) attrs.transform = input.transform;
16865
- if (input.data !== void 0) {
16866
- attrs.data = input.data;
16867
- }
16868
- return attrs;
16869
- }
16870
- function _forwarderFromResource(resource) {
16871
- const a = resource.attributes;
16872
- return {
16873
- id: resource.id,
16874
- name: String(a.name ?? ""),
16875
- slug: String(a.slug ?? ""),
16876
- forwarderType: a.forwarder_type,
16877
- enabled: Boolean(a.enabled ?? true),
16878
- filter: a.filter ?? null,
16879
- transform: a.transform ?? null,
16880
- http: _httpFromWire(a.http),
16881
- data: a.data ?? {},
16882
- createdAt: a.created_at ?? null,
16883
- updatedAt: a.updated_at ?? null,
16884
- deletedAt: a.deleted_at ?? null,
16885
- version: a.version ?? null
16886
- };
16887
- }
16888
- function _deliveryFromResource(resource) {
16889
- const a = resource.attributes;
16890
- return {
16891
- id: resource.id,
16892
- forwarderId: String(a.forwarder_id ?? ""),
16893
- eventId: String(a.event_id ?? ""),
16894
- attemptNumber: Number(a.attempt_number ?? 1),
16895
- status: a.status ?? "FAILED",
16896
- request: a.request ?? null,
16897
- responseStatus: a.response_status ?? null,
16898
- responseBody: a.response_body ?? null,
16899
- latencyMs: a.latency_ms ?? null,
16900
- error: a.error ?? null,
16901
- createdAt: a.created_at ?? null
16902
- };
16903
- }
16904
16951
  function _nextCursorFromLinks(body) {
16905
16952
  const next = body.links?.next;
16906
16953
  if (typeof next !== "string" || !next.includes("page[after]=")) return null;
16907
- return next.split("page[after]=")[1];
16954
+ return next.split("page[after]=")[1].split("&")[0];
16955
+ }
16956
+ async function _throwForResponse(response) {
16957
+ const body = await response.text().catch(() => "");
16958
+ throwForStatus(response.status, body);
16908
16959
  }
16909
16960
  var EventsClient = class {
16910
16961
  /** @internal */
@@ -16961,31 +17012,26 @@ var EventsClient = class {
16961
17012
  if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
16962
17013
  const result = await this._http.GET("/api/v1/events", {
16963
17014
  // openapi-fetch's typed query map is constrained by the spec's
16964
- // exact param names (filteraction etc.); the JSON:API filter[*]
16965
- // / page[*] format isn't expressible in that shape, so we cast
16966
- // and let openapi-fetch URL-encode the literal keys.
17015
+ // exact param names; the JSON:API filter[*] / page[*] format isn't
17016
+ // expressible in that shape, so we cast and let openapi-fetch
17017
+ // URL-encode the literal keys.
16967
17018
  params: { query }
16968
17019
  });
16969
- if (!result.response.ok || result.data === void 0) {
16970
- throw new Error(`audit list failed: ${result.response.status} ${result.response.statusText}`);
16971
- }
17020
+ if (!result.response.ok) await _throwForResponse(result.response);
17021
+ if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
16972
17022
  const body = result.data;
16973
- const events = (body.data ?? []).map(_eventFromResource);
16974
- let nextCursor = null;
16975
- const nextLink = body.links?.next;
16976
- if (typeof nextLink === "string" && nextLink.includes("page[after]=")) {
16977
- nextCursor = nextLink.split("page[after]=")[1];
16978
- }
16979
- return { events, nextCursor };
17023
+ const rows = body.data ?? [];
17024
+ return { events: rows.map(_eventFromResource), nextCursor: _nextCursorFromLinks(body) };
16980
17025
  }
16981
17026
  async get(eventId) {
16982
17027
  const result = await this._http.GET("/api/v1/events/{event_id}", {
16983
17028
  params: { path: { event_id: eventId } }
16984
17029
  });
16985
- if (!result.response.ok || result.data === void 0) {
16986
- throw new Error(`audit get failed: ${result.response.status} ${result.response.statusText}`);
16987
- }
16988
- return _eventFromResource(result.data.data);
17030
+ if (!result.response.ok) await _throwForResponse(result.response);
17031
+ if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
17032
+ return _eventFromResource(
17033
+ result.data.data
17034
+ );
16989
17035
  }
16990
17036
  /** Block until the in-memory buffer is drained or `timeoutMs` elapses. */
16991
17037
  async flush(timeoutMs = 5e3) {
@@ -16996,332 +17042,86 @@ var EventsClient = class {
16996
17042
  await this._buffer.close();
16997
17043
  }
16998
17044
  };
16999
- var DeliveryActionsClient = class {
17000
- constructor(_http) {
17001
- this._http = _http;
17002
- }
17003
- /** Retry a single failed delivery. Records a new attempt row with
17004
- * attempt_number = prior + 1; the prior row is unchanged. */
17005
- async retry(forwarderId, deliveryId) {
17006
- const result = await this._http.POST(
17007
- "/api/v1/forwarders/{forwarder_id}/deliveries/{delivery_id}/actions/retry",
17008
- { params: { path: { forwarder_id: forwarderId, delivery_id: deliveryId } } }
17009
- );
17010
- if (!result.response.ok || result.data === void 0) {
17011
- throw new Error(
17012
- `audit retry delivery failed: ${result.response.status} ${result.response.statusText}`
17013
- );
17014
- }
17015
- return _deliveryFromResource(result.data.data);
17016
- }
17017
- };
17018
- var DeliveriesClient = class {
17019
- constructor(_http) {
17020
- this._http = _http;
17021
- this.actions = new DeliveryActionsClient(_http);
17022
- }
17023
- actions;
17024
- async list(forwarderId, params = {}) {
17025
- const query = {};
17026
- if (params.status !== void 0) query["filter[status]"] = params.status;
17027
- if (params.createdAtRange !== void 0) query["filter[created_at]"] = params.createdAtRange;
17028
- if (params.eventId !== void 0) query["filter[event_id]"] = params.eventId;
17029
- if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
17030
- if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
17031
- const result = await this._http.GET("/api/v1/forwarders/{forwarder_id}/deliveries", {
17032
- params: {
17033
- path: { forwarder_id: forwarderId },
17034
- query
17035
- }
17036
- });
17037
- if (!result.response.ok || result.data === void 0) {
17038
- throw new Error(
17039
- `audit list deliveries failed: ${result.response.status} ${result.response.statusText}`
17040
- );
17041
- }
17042
- const body = result.data;
17043
- return {
17044
- deliveries: (body.data ?? []).map(_deliveryFromResource),
17045
- nextCursor: _nextCursorFromLinks(body)
17046
- };
17047
- }
17048
- };
17049
- var ForwarderActionsClient = class {
17045
+ var ResourceTypesClient = class {
17050
17046
  constructor(_http) {
17051
17047
  this._http = _http;
17052
17048
  }
17053
- /** Retry every failed delivery for a forwarder. Returns a count summary. */
17054
- async retryFailedDeliveries(forwarderId) {
17055
- const result = await this._http.POST(
17056
- "/api/v1/forwarders/{forwarder_id}/actions/retry_failed_deliveries",
17057
- { params: { path: { forwarder_id: forwarderId } } }
17058
- );
17059
- if (!result.response.ok || result.data === void 0) {
17060
- throw new Error(
17061
- `audit bulk retry failed: ${result.response.status} ${result.response.statusText}`
17062
- );
17063
- }
17064
- const d = result.data;
17065
- return {
17066
- attempted: Number(d.attempted ?? 0),
17067
- succeeded: Number(d.succeeded ?? 0),
17068
- failed: Number(d.failed ?? 0)
17069
- };
17070
- }
17071
- };
17072
- var ForwardersClient = class {
17073
- constructor(_http) {
17074
- this._http = _http;
17075
- this.deliveries = new DeliveriesClient(_http);
17076
- this.actions = new ForwarderActionsClient(_http);
17077
- }
17078
- deliveries;
17079
- actions;
17080
- async create(input) {
17081
- const body = {
17082
- data: { id: "", type: "forwarder", attributes: _forwarderAttributes(input) }
17083
- };
17084
- const result = await this._http.POST("/api/v1/forwarders", { body });
17085
- if (!result.response.ok || result.data === void 0) {
17086
- throw new Error(
17087
- `audit create forwarder failed: ${result.response.status} ${result.response.statusText}`
17088
- );
17089
- }
17090
- return _forwarderFromResource(result.data.data);
17091
- }
17049
+ /**
17050
+ * List the distinct `resource_type` slugs recorded for this account.
17051
+ *
17052
+ * Backed by a maintain-by-write side table (ADR-047 §2.5), so the
17053
+ * response time is independent of event volume. Sorted alphabetically;
17054
+ * cursor pagination via `pageAfter`.
17055
+ */
17092
17056
  async list(params = {}) {
17093
17057
  const query = {};
17094
- if (params.forwarderType !== void 0) query["filter[forwarder_type]"] = params.forwarderType;
17095
- if (params.enabled !== void 0) query["filter[enabled]"] = params.enabled;
17096
17058
  if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
17097
17059
  if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
17098
- const result = await this._http.GET("/api/v1/forwarders", {
17099
- params: { query }
17100
- });
17101
- if (!result.response.ok || result.data === void 0) {
17102
- throw new Error(
17103
- `audit list forwarders failed: ${result.response.status} ${result.response.statusText}`
17104
- );
17105
- }
17106
- const body = result.data;
17107
- return {
17108
- forwarders: (body.data ?? []).map(_forwarderFromResource),
17109
- nextCursor: _nextCursorFromLinks(body)
17110
- };
17111
- }
17112
- async get(forwarderId) {
17113
- const result = await this._http.GET("/api/v1/forwarders/{forwarder_id}", {
17114
- params: { path: { forwarder_id: forwarderId } }
17115
- });
17116
- if (!result.response.ok || result.data === void 0) {
17117
- throw new Error(
17118
- `audit get forwarder failed: ${result.response.status} ${result.response.statusText}`
17119
- );
17120
- }
17121
- return _forwarderFromResource(result.data.data);
17122
- }
17123
- async update(forwarderId, input) {
17124
- const body = {
17125
- data: { id: forwarderId, type: "forwarder", attributes: _forwarderAttributes(input) }
17126
- };
17127
- const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
17128
- params: { path: { forwarder_id: forwarderId } },
17129
- body
17130
- });
17131
- if (!result.response.ok || result.data === void 0) {
17132
- throw new Error(
17133
- `audit update forwarder failed: ${result.response.status} ${result.response.statusText}`
17134
- );
17135
- }
17136
- return _forwarderFromResource(result.data.data);
17137
- }
17138
- async delete(forwarderId) {
17139
- const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
17140
- params: { path: { forwarder_id: forwarderId } }
17141
- });
17142
- if (result.response.status !== 204) {
17143
- throw new Error(
17144
- `audit delete forwarder failed: ${result.response.status} ${result.response.statusText}`
17145
- );
17146
- }
17147
- }
17148
- };
17149
- var TestForwarderActionsClient = class {
17150
- constructor(_http) {
17151
- this._http = _http;
17152
- }
17153
- /** Server-side proxy to a customer-supplied URL. SSRF-guarded; the
17154
- * audit service rejects private/loopback/link-local addresses (incl.
17155
- * the EC2 IMDS at 169.254.169.254) and ports outside the allowlist. */
17156
- async execute(input) {
17157
- const body = {
17158
- method: input.method ?? "POST",
17159
- url: input.url,
17160
- headers: (input.headers ?? []).map((h) => ({ name: h.name, value: h.value })),
17161
- body: input.body ?? null,
17162
- success_status: input.successStatus ?? "2xx"
17163
- };
17164
- if (input.timeoutMs !== void 0) body.timeout_ms = input.timeoutMs;
17165
- const result = await this._http.POST("/api/v1/functions/test_forwarder/actions/execute", {
17166
- // This endpoint serves and accepts plain JSON, NOT JSON:API. The
17167
- // openapi-fetch client adds its default JSON:API content-type
17168
- // header; we override here so the server's strict validator
17169
- // doesn't reject the request.
17170
- headers: { "Content-Type": "application/json", Accept: "application/json" },
17171
- body
17172
- });
17173
- if (!result.response.ok || result.data === void 0) {
17174
- throw new Error(
17175
- `audit test_forwarder failed: ${result.response.status} ${result.response.statusText}`
17176
- );
17177
- }
17178
- const d = result.data;
17179
- return {
17180
- succeeded: Boolean(d.succeeded),
17181
- responseStatus: d.response_status ?? null,
17182
- responseHeaders: d.response_headers ?? {},
17183
- responseBody: String(d.response_body ?? ""),
17184
- latencyMs: d.latency_ms ?? null,
17185
- error: d.error ?? null
17186
- };
17187
- }
17188
- };
17189
- var TestForwarderClient = class {
17190
- actions;
17191
- constructor(http) {
17192
- this.actions = new TestForwarderActionsClient(http);
17193
- }
17194
- };
17195
- var FunctionsClient = class {
17196
- test_forwarder;
17197
- constructor(http) {
17198
- this.test_forwarder = new TestForwarderClient(http);
17199
- }
17200
- };
17201
- var AuditClient = class {
17202
- events;
17203
- forwarders;
17204
- functions;
17205
- constructor(opts) {
17206
- this.events = new EventsClient(opts);
17207
- this.forwarders = new ForwardersClient(this.events._http);
17208
- this.functions = new FunctionsClient(this.events._http);
17209
- }
17210
- /** @internal */
17211
- async _close() {
17212
- await this.events._close();
17213
- }
17214
- };
17215
-
17216
- // src/config/client.ts
17217
- var import_openapi_fetch2 = __toESM(require("openapi-fetch"), 1);
17218
-
17219
- // src/errors.ts
17220
- var SmplError = class extends Error {
17221
- /** The HTTP status code, if the error originated from an HTTP response. */
17222
- statusCode;
17223
- /** The raw response body, if available. */
17224
- responseBody;
17225
- /** Structured JSON:API error objects from the server response, if available. */
17226
- errors;
17227
- constructor(message, statusCode, responseBody, errors) {
17228
- super(message);
17229
- this.name = "SmplError";
17230
- this.statusCode = statusCode;
17231
- this.responseBody = responseBody;
17232
- this.errors = errors ?? [];
17233
- Object.setPrototypeOf(this, new.target.prototype);
17234
- }
17235
- toString() {
17236
- if (this.errors.length === 0) {
17237
- return `${this.name}: ${this.message}`;
17238
- }
17239
- if (this.errors.length === 1) {
17240
- return `${this.name}: ${this.message}
17241
- Error: ${JSON.stringify(this.errors[0])}`;
17242
- }
17243
- const lines = this.errors.map((e, i) => ` [${i}] ${JSON.stringify(e)}`);
17244
- return `${this.name}: ${this.message}
17245
- Errors:
17246
- ${lines.join("\n")}`;
17247
- }
17248
- };
17249
- var SmplConnectionError = class extends SmplError {
17250
- constructor(message, statusCode, responseBody, errors) {
17251
- super(message, statusCode, responseBody, errors);
17252
- this.name = "SmplConnectionError";
17253
- Object.setPrototypeOf(this, new.target.prototype);
17254
- }
17255
- };
17256
- var SmplTimeoutError = class extends SmplError {
17257
- constructor(message, statusCode, responseBody, errors) {
17258
- super(message, statusCode, responseBody, errors);
17259
- this.name = "SmplTimeoutError";
17260
- Object.setPrototypeOf(this, new.target.prototype);
17261
- }
17262
- };
17263
- var SmplNotFoundError = class extends SmplError {
17264
- constructor(message, statusCode, responseBody, errors) {
17265
- super(message, statusCode ?? 404, responseBody, errors);
17266
- this.name = "SmplNotFoundError";
17267
- Object.setPrototypeOf(this, new.target.prototype);
17268
- }
17269
- };
17270
- var SmplConflictError = class extends SmplError {
17271
- constructor(message, statusCode, responseBody, errors) {
17272
- super(message, statusCode ?? 409, responseBody, errors);
17273
- this.name = "SmplConflictError";
17274
- Object.setPrototypeOf(this, new.target.prototype);
17275
- }
17276
- };
17277
- var SmplValidationError = class extends SmplError {
17278
- constructor(message, statusCode, responseBody, errors) {
17279
- super(message, statusCode ?? 422, responseBody, errors);
17280
- this.name = "SmplValidationError";
17281
- Object.setPrototypeOf(this, new.target.prototype);
17282
- }
17283
- };
17284
- function parseJsonApiErrors(body) {
17285
- try {
17286
- const parsed = JSON.parse(body);
17287
- if (parsed && Array.isArray(parsed.errors)) {
17288
- return parsed.errors.map((e) => ({
17289
- ...e.status !== void 0 ? { status: String(e.status) } : {},
17290
- ...e.title !== void 0 ? { title: String(e.title) } : {},
17291
- ...e.detail !== void 0 ? { detail: String(e.detail) } : {},
17292
- ...e.source !== void 0 && typeof e.source === "object" && e.source !== null ? { source: e.source } : {}
17293
- }));
17294
- }
17295
- } catch {
17060
+ const result = await this._http.GET("/api/v1/resource_types", {
17061
+ params: { query }
17062
+ });
17063
+ if (!result.response.ok) await _throwForResponse(result.response);
17064
+ if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
17065
+ const body = result.data;
17066
+ const resourceTypes = (body.data ?? []).map(
17067
+ (r) => ({
17068
+ id: r.id,
17069
+ createdAt: String(r.attributes.created_at ?? "")
17070
+ })
17071
+ );
17072
+ return { resourceTypes, nextCursor: _nextCursorFromLinks(body) };
17296
17073
  }
17297
- return [];
17298
- }
17299
- function deriveMessage(errors, statusCode, body) {
17300
- if (errors.length === 0) {
17301
- return body ? `HTTP ${statusCode}: ${body}` : `HTTP ${statusCode}`;
17074
+ };
17075
+ var ActionsClient = class {
17076
+ constructor(_http) {
17077
+ this._http = _http;
17302
17078
  }
17303
- const first = errors[0];
17304
- const base = first.detail ?? first.title ?? (first.status ? `HTTP ${first.status}` : `HTTP ${statusCode}`);
17305
- if (errors.length > 1) {
17306
- return `${base} (and ${errors.length - 1} more error${errors.length - 1 > 1 ? "s" : ""})`;
17079
+ /**
17080
+ * List the distinct `action` slugs recorded for this account.
17081
+ *
17082
+ * Without `filterResourceType`, returns one row per distinct action.
17083
+ * With `filterResourceType`, returns only the actions recorded with
17084
+ * that resource_type, powering cascading-filter UIs (ADR-047 §2.5).
17085
+ * Sorted alphabetically; cursor pagination via `pageAfter`.
17086
+ */
17087
+ async list(params = {}) {
17088
+ const query = {};
17089
+ if (params.filterResourceType !== void 0)
17090
+ query["filter[resource_type]"] = params.filterResourceType;
17091
+ if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
17092
+ if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
17093
+ const result = await this._http.GET("/api/v1/actions", {
17094
+ params: { query }
17095
+ });
17096
+ if (!result.response.ok) await _throwForResponse(result.response);
17097
+ if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
17098
+ const body = result.data;
17099
+ const actions = (body.data ?? []).map(
17100
+ (r) => ({
17101
+ id: r.id,
17102
+ createdAt: String(r.attributes.created_at ?? "")
17103
+ })
17104
+ );
17105
+ return { actions, nextCursor: _nextCursorFromLinks(body) };
17307
17106
  }
17308
- return base;
17309
- }
17310
- function throwForStatus(statusCode, body) {
17311
- const errors = parseJsonApiErrors(body);
17312
- const message = deriveMessage(errors, statusCode, body);
17313
- switch (statusCode) {
17314
- case 400:
17315
- case 422:
17316
- throw new SmplValidationError(message, statusCode, body, errors);
17317
- case 404:
17318
- throw new SmplNotFoundError(message, statusCode, body, errors);
17319
- case 409:
17320
- throw new SmplConflictError(message, statusCode, body, errors);
17321
- default:
17322
- throw new SmplError(message, statusCode, body, errors);
17107
+ };
17108
+ var AuditClient = class {
17109
+ events;
17110
+ resourceTypes;
17111
+ actions;
17112
+ constructor(opts) {
17113
+ this.events = new EventsClient(opts);
17114
+ this.resourceTypes = new ResourceTypesClient(this.events._http);
17115
+ this.actions = new ActionsClient(this.events._http);
17323
17116
  }
17324
- }
17117
+ /** @internal */
17118
+ async _close() {
17119
+ await this.events._close();
17120
+ }
17121
+ };
17122
+
17123
+ // src/config/client.ts
17124
+ var import_openapi_fetch2 = __toESM(require("openapi-fetch"), 1);
17325
17125
 
17326
17126
  // src/config/resolve.ts
17327
17127
  function deepMerge(base, override) {
@@ -20020,6 +19820,177 @@ var LogGroupsClient = class {
20020
19820
  }
20021
19821
  };
20022
19822
 
19823
+ // src/management/audit.ts
19824
+ async function checkError4(response) {
19825
+ const body = await response.text().catch(() => "");
19826
+ throwForStatus(response.status, body);
19827
+ }
19828
+ function wrapFetchError4(err) {
19829
+ if (err instanceof SmplError) throw err;
19830
+ if (err instanceof TypeError) {
19831
+ throw new SmplConnectionError(`Network error: ${err.message}`);
19832
+ }
19833
+ throw new SmplConnectionError(
19834
+ `Request failed: ${err instanceof Error ? err.message : String(err)}`
19835
+ );
19836
+ }
19837
+ function _nextCursorFromLinks2(body) {
19838
+ const next = body.links?.next;
19839
+ if (typeof next !== "string" || !next.includes("page[after]=")) return null;
19840
+ return next.split("page[after]=")[1].split("&")[0];
19841
+ }
19842
+ function _httpToWire(http) {
19843
+ return {
19844
+ method: http.method,
19845
+ url: http.url,
19846
+ headers: http.headers.map((h) => ({ name: h.name, value: h.value })),
19847
+ body: http.body,
19848
+ success_status: http.successStatus
19849
+ };
19850
+ }
19851
+ function _httpFromWire(raw) {
19852
+ const r = raw ?? {};
19853
+ const headers = (r.headers ?? []).map((h) => ({
19854
+ name: String(h.name ?? ""),
19855
+ value: String(h.value ?? "")
19856
+ }));
19857
+ return {
19858
+ method: String(r.method ?? "POST"),
19859
+ url: String(r.url ?? ""),
19860
+ headers,
19861
+ body: r.body ?? null,
19862
+ successStatus: String(r.success_status ?? "2xx")
19863
+ };
19864
+ }
19865
+ function _forwarderAttributes(input) {
19866
+ const attrs = {
19867
+ name: input.name,
19868
+ forwarder_type: input.forwarderType,
19869
+ enabled: input.enabled ?? true,
19870
+ http: _httpToWire(input.http)
19871
+ };
19872
+ if (input.filter !== void 0) {
19873
+ attrs.filter = input.filter;
19874
+ }
19875
+ if (input.transform !== void 0) attrs.transform = input.transform;
19876
+ return attrs;
19877
+ }
19878
+ function _forwarderFromResource(resource) {
19879
+ const a = resource.attributes;
19880
+ return {
19881
+ id: resource.id,
19882
+ name: String(a.name ?? ""),
19883
+ slug: String(a.slug ?? ""),
19884
+ forwarderType: a.forwarder_type,
19885
+ enabled: Boolean(a.enabled ?? true),
19886
+ filter: a.filter ?? null,
19887
+ transform: a.transform ?? null,
19888
+ http: _httpFromWire(a.http),
19889
+ createdAt: a.created_at ?? null,
19890
+ updatedAt: a.updated_at ?? null,
19891
+ deletedAt: a.deleted_at ?? null,
19892
+ version: a.version ?? null
19893
+ };
19894
+ }
19895
+ var ForwardersClient = class {
19896
+ /** @internal */
19897
+ constructor(_http) {
19898
+ this._http = _http;
19899
+ }
19900
+ async create(input) {
19901
+ const body = {
19902
+ data: { id: "", type: "forwarder", attributes: _forwarderAttributes(input) }
19903
+ };
19904
+ let data;
19905
+ try {
19906
+ const result = await this._http.POST("/api/v1/forwarders", { body });
19907
+ if (!result.response.ok) await checkError4(result.response);
19908
+ data = result.data;
19909
+ } catch (err) {
19910
+ wrapFetchError4(err);
19911
+ }
19912
+ if (!data?.data) throw new SmplError("Unexpected empty response from audit");
19913
+ return _forwarderFromResource(data.data);
19914
+ }
19915
+ async list(params = {}) {
19916
+ const query = {};
19917
+ if (params.forwarderType !== void 0) query["filter[forwarder_type]"] = params.forwarderType;
19918
+ if (params.enabled !== void 0) query["filter[enabled]"] = params.enabled;
19919
+ if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
19920
+ if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
19921
+ let data;
19922
+ try {
19923
+ const result = await this._http.GET("/api/v1/forwarders", {
19924
+ params: { query }
19925
+ });
19926
+ if (!result.response.ok) await checkError4(result.response);
19927
+ data = result.data;
19928
+ } catch (err) {
19929
+ wrapFetchError4(err);
19930
+ }
19931
+ return {
19932
+ forwarders: (data?.data ?? []).map(_forwarderFromResource),
19933
+ nextCursor: _nextCursorFromLinks2(data ?? {})
19934
+ };
19935
+ }
19936
+ async get(forwarderId) {
19937
+ let data;
19938
+ try {
19939
+ const result = await this._http.GET("/api/v1/forwarders/{forwarder_id}", {
19940
+ params: { path: { forwarder_id: forwarderId } }
19941
+ });
19942
+ if (!result.response.ok) await checkError4(result.response);
19943
+ data = result.data;
19944
+ } catch (err) {
19945
+ wrapFetchError4(err);
19946
+ }
19947
+ if (!data?.data) throw new SmplError("Unexpected empty response from audit");
19948
+ return _forwarderFromResource(data.data);
19949
+ }
19950
+ /**
19951
+ * Full-replace update. PUT semantics — every field is overwritten.
19952
+ *
19953
+ * Header values must be re-supplied as plaintext; the GET path
19954
+ * returns them in plaintext for exactly this round-trip.
19955
+ */
19956
+ async update(forwarderId, input) {
19957
+ const body = {
19958
+ data: { id: forwarderId, type: "forwarder", attributes: _forwarderAttributes(input) }
19959
+ };
19960
+ let data;
19961
+ try {
19962
+ const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
19963
+ params: { path: { forwarder_id: forwarderId } },
19964
+ body
19965
+ });
19966
+ if (!result.response.ok) await checkError4(result.response);
19967
+ data = result.data;
19968
+ } catch (err) {
19969
+ wrapFetchError4(err);
19970
+ }
19971
+ if (!data?.data) throw new SmplError("Unexpected empty response from audit");
19972
+ return _forwarderFromResource(data.data);
19973
+ }
19974
+ async delete(forwarderId) {
19975
+ try {
19976
+ const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
19977
+ params: { path: { forwarder_id: forwarderId } }
19978
+ });
19979
+ if (result.response.status !== 204) await checkError4(result.response);
19980
+ } catch (err) {
19981
+ wrapFetchError4(err);
19982
+ }
19983
+ }
19984
+ };
19985
+ var ManagementAuditClient = class {
19986
+ /** SIEM forwarder CRUD. */
19987
+ forwarders;
19988
+ /** @internal */
19989
+ constructor(http) {
19990
+ this.forwarders = new ForwardersClient(http);
19991
+ }
19992
+ };
19993
+
20023
19994
  // src/config.ts
20024
19995
  var import_node_fs = require("fs");
20025
19996
  var import_node_os = require("os");
@@ -20161,11 +20132,11 @@ function splitContextId(idOrType, key) {
20161
20132
  }
20162
20133
  return [idOrType, key];
20163
20134
  }
20164
- async function checkError4(response) {
20135
+ async function checkError5(response) {
20165
20136
  const body = await response.text().catch(() => "");
20166
20137
  throwForStatus(response.status, body);
20167
20138
  }
20168
- function wrapFetchError4(err) {
20139
+ function wrapFetchError5(err) {
20169
20140
  if (err instanceof SmplError) throw err;
20170
20141
  if (err instanceof TypeError) {
20171
20142
  throw new SmplConnectionError(`Network error: ${err.message}`);
@@ -20248,10 +20219,10 @@ var EnvironmentsClient = class {
20248
20219
  let data;
20249
20220
  try {
20250
20221
  const result = await this._http.GET("/api/v1/environments", {});
20251
- if (!result.response.ok) await checkError4(result.response);
20222
+ if (!result.response.ok) await checkError5(result.response);
20252
20223
  data = result.data;
20253
20224
  } catch (err) {
20254
- wrapFetchError4(err);
20225
+ wrapFetchError5(err);
20255
20226
  }
20256
20227
  const items = data?.data ?? [];
20257
20228
  return items.map((r) => envFromResource(r, this));
@@ -20262,10 +20233,10 @@ var EnvironmentsClient = class {
20262
20233
  const result = await this._http.GET("/api/v1/environments/{id}", {
20263
20234
  params: { path: { id } }
20264
20235
  });
20265
- if (!result.response.ok) await checkError4(result.response);
20236
+ if (!result.response.ok) await checkError5(result.response);
20266
20237
  data = result.data;
20267
20238
  } catch (err) {
20268
- wrapFetchError4(err);
20239
+ wrapFetchError5(err);
20269
20240
  }
20270
20241
  if (!data?.data)
20271
20242
  throw new SmplNotFoundError(`Environment with id ${JSON.stringify(id)} not found`);
@@ -20277,10 +20248,10 @@ var EnvironmentsClient = class {
20277
20248
  params: { path: { id } }
20278
20249
  });
20279
20250
  if (!result.response.ok && result.response.status !== 204) {
20280
- await checkError4(result.response);
20251
+ await checkError5(result.response);
20281
20252
  }
20282
20253
  } catch (err) {
20283
- wrapFetchError4(err);
20254
+ wrapFetchError5(err);
20284
20255
  }
20285
20256
  }
20286
20257
  /** @internal */
@@ -20299,10 +20270,10 @@ var EnvironmentsClient = class {
20299
20270
  let data;
20300
20271
  try {
20301
20272
  const result = await this._http.POST("/api/v1/environments", { body });
20302
- if (!result.response.ok) await checkError4(result.response);
20273
+ if (!result.response.ok) await checkError5(result.response);
20303
20274
  data = result.data;
20304
20275
  } catch (err) {
20305
- wrapFetchError4(err);
20276
+ wrapFetchError5(err);
20306
20277
  }
20307
20278
  if (!data?.data) throw new SmplValidationError("Failed to create environment");
20308
20279
  return envFromResource(data.data, this);
@@ -20327,10 +20298,10 @@ var EnvironmentsClient = class {
20327
20298
  params: { path: { id: env.id } },
20328
20299
  body
20329
20300
  });
20330
- if (!result.response.ok) await checkError4(result.response);
20301
+ if (!result.response.ok) await checkError5(result.response);
20331
20302
  data = result.data;
20332
20303
  } catch (err) {
20333
- wrapFetchError4(err);
20304
+ wrapFetchError5(err);
20334
20305
  }
20335
20306
  if (!data?.data) throw new SmplValidationError(`Failed to update environment ${env.id}`);
20336
20307
  return envFromResource(data.data, this);
@@ -20359,10 +20330,10 @@ var ContextTypesClient = class {
20359
20330
  let data;
20360
20331
  try {
20361
20332
  const result = await this._http.GET("/api/v1/context_types", {});
20362
- if (!result.response.ok) await checkError4(result.response);
20333
+ if (!result.response.ok) await checkError5(result.response);
20363
20334
  data = result.data;
20364
20335
  } catch (err) {
20365
- wrapFetchError4(err);
20336
+ wrapFetchError5(err);
20366
20337
  }
20367
20338
  const items = data?.data ?? [];
20368
20339
  return items.map((r) => ctFromResource(r, this));
@@ -20373,10 +20344,10 @@ var ContextTypesClient = class {
20373
20344
  const result = await this._http.GET("/api/v1/context_types/{id}", {
20374
20345
  params: { path: { id } }
20375
20346
  });
20376
- if (!result.response.ok) await checkError4(result.response);
20347
+ if (!result.response.ok) await checkError5(result.response);
20377
20348
  data = result.data;
20378
20349
  } catch (err) {
20379
- wrapFetchError4(err);
20350
+ wrapFetchError5(err);
20380
20351
  }
20381
20352
  if (!data?.data)
20382
20353
  throw new SmplNotFoundError(`ContextType with id ${JSON.stringify(id)} not found`);
@@ -20388,10 +20359,10 @@ var ContextTypesClient = class {
20388
20359
  params: { path: { id } }
20389
20360
  });
20390
20361
  if (!result.response.ok && result.response.status !== 204) {
20391
- await checkError4(result.response);
20362
+ await checkError5(result.response);
20392
20363
  }
20393
20364
  } catch (err) {
20394
- wrapFetchError4(err);
20365
+ wrapFetchError5(err);
20395
20366
  }
20396
20367
  }
20397
20368
  /** @internal */
@@ -20409,10 +20380,10 @@ var ContextTypesClient = class {
20409
20380
  let data;
20410
20381
  try {
20411
20382
  const result = await this._http.POST("/api/v1/context_types", { body });
20412
- if (!result.response.ok) await checkError4(result.response);
20383
+ if (!result.response.ok) await checkError5(result.response);
20413
20384
  data = result.data;
20414
20385
  } catch (err) {
20415
- wrapFetchError4(err);
20386
+ wrapFetchError5(err);
20416
20387
  }
20417
20388
  if (!data?.data) throw new SmplValidationError("Failed to create context type");
20418
20389
  return ctFromResource(data.data, this);
@@ -20436,10 +20407,10 @@ var ContextTypesClient = class {
20436
20407
  params: { path: { id: ct.id } },
20437
20408
  body
20438
20409
  });
20439
- if (!result.response.ok) await checkError4(result.response);
20410
+ if (!result.response.ok) await checkError5(result.response);
20440
20411
  data = result.data;
20441
20412
  } catch (err) {
20442
- wrapFetchError4(err);
20413
+ wrapFetchError5(err);
20443
20414
  }
20444
20415
  if (!data?.data) throw new SmplValidationError(`Failed to update context type ${ct.id}`);
20445
20416
  return ctFromResource(data.data, this);
@@ -20515,9 +20486,9 @@ var ContextsClient = class {
20515
20486
  }))
20516
20487
  }
20517
20488
  });
20518
- if (!result.response.ok) await checkError4(result.response);
20489
+ if (!result.response.ok) await checkError5(result.response);
20519
20490
  } catch (err) {
20520
- wrapFetchError4(err);
20491
+ wrapFetchError5(err);
20521
20492
  }
20522
20493
  }
20523
20494
  /** Number of contexts awaiting flush. */
@@ -20531,10 +20502,10 @@ var ContextsClient = class {
20531
20502
  const result = await this._http.GET("/api/v1/contexts", {
20532
20503
  params: { query: { "filter[context_type]": type } }
20533
20504
  });
20534
- if (!result.response.ok) await checkError4(result.response);
20505
+ if (!result.response.ok) await checkError5(result.response);
20535
20506
  data = result.data;
20536
20507
  } catch (err) {
20537
- wrapFetchError4(err);
20508
+ wrapFetchError5(err);
20538
20509
  }
20539
20510
  const items = data?.data ?? [];
20540
20511
  return items.map((r) => ctxFromResource(r, this));
@@ -20548,10 +20519,10 @@ var ContextsClient = class {
20548
20519
  const result = await this._http.GET("/api/v1/contexts/{id}", {
20549
20520
  params: { path: { id: composite } }
20550
20521
  });
20551
- if (!result.response.ok) await checkError4(result.response);
20522
+ if (!result.response.ok) await checkError5(result.response);
20552
20523
  data = result.data;
20553
20524
  } catch (err) {
20554
- wrapFetchError4(err);
20525
+ wrapFetchError5(err);
20555
20526
  }
20556
20527
  if (!data?.data)
20557
20528
  throw new SmplNotFoundError(`Context with id ${JSON.stringify(composite)} not found`);
@@ -20566,10 +20537,10 @@ var ContextsClient = class {
20566
20537
  params: { path: { id: composite } }
20567
20538
  });
20568
20539
  if (!result.response.ok && result.response.status !== 204) {
20569
- await checkError4(result.response);
20540
+ await checkError5(result.response);
20570
20541
  }
20571
20542
  } catch (err) {
20572
- wrapFetchError4(err);
20543
+ wrapFetchError5(err);
20573
20544
  }
20574
20545
  }
20575
20546
  /** @internal — called by `Context.save()`. */
@@ -20596,10 +20567,10 @@ var ContextsClient = class {
20596
20567
  params: { path: { id: ctx.id } },
20597
20568
  body
20598
20569
  });
20599
- if (!result.response.ok) await checkError4(result.response);
20570
+ if (!result.response.ok) await checkError5(result.response);
20600
20571
  data = result.data;
20601
20572
  } catch (err) {
20602
- wrapFetchError4(err);
20573
+ wrapFetchError5(err);
20603
20574
  }
20604
20575
  if (!data?.data) throw new SmplValidationError(`Failed to save context ${ctx.id}`);
20605
20576
  return ctxFromResource(data.data, this);
@@ -20673,6 +20644,8 @@ var SmplManagementClient = class {
20673
20644
  loggers;
20674
20645
  /** Log group CRUD. */
20675
20646
  logGroups;
20647
+ /** Audit SIEM forwarder CRUD. */
20648
+ audit;
20676
20649
  /** @internal — shared HTTP transports (so SmplClient can alias them). */
20677
20650
  _appHttp;
20678
20651
  /** @internal */
@@ -20692,6 +20665,7 @@ var SmplManagementClient = class {
20692
20665
  this.flags = this._flagsRef;
20693
20666
  this.loggers = this._loggersRef;
20694
20667
  this.logGroups = this._logGroupsRef;
20668
+ this.audit = this._auditRef;
20695
20669
  this._appHttp = this._appHttpRef;
20696
20670
  this._configHttp = this._configHttpRef;
20697
20671
  this._flagsHttp = this._flagsHttpRef;
@@ -20707,6 +20681,7 @@ var SmplManagementClient = class {
20707
20681
  _flagsRef;
20708
20682
  _loggersRef;
20709
20683
  _logGroupsRef;
20684
+ _auditRef;
20710
20685
  _appHttpRef;
20711
20686
  _configHttpRef;
20712
20687
  _flagsHttpRef;
@@ -20717,10 +20692,16 @@ var SmplManagementClient = class {
20717
20692
  const configBaseUrl = serviceUrl(cfg.scheme, "config", cfg.baseDomain);
20718
20693
  const flagsBaseUrl = serviceUrl(cfg.scheme, "flags", cfg.baseDomain);
20719
20694
  const loggingBaseUrl = serviceUrl(cfg.scheme, "logging", cfg.baseDomain);
20695
+ const auditBaseUrl = serviceUrl(cfg.scheme, "audit", cfg.baseDomain);
20720
20696
  const headers = {
20721
20697
  Authorization: `Bearer ${cfg.apiKey}`,
20722
20698
  Accept: "application/json"
20723
20699
  };
20700
+ const auditHeaders = {
20701
+ Authorization: `Bearer ${cfg.apiKey}`,
20702
+ Accept: "application/vnd.api+json",
20703
+ "Content-Type": "application/vnd.api+json"
20704
+ };
20724
20705
  this._appHttpRef = (0, import_openapi_fetch3.default)({
20725
20706
  baseUrl: appBaseUrl,
20726
20707
  headers
@@ -20737,6 +20718,10 @@ var SmplManagementClient = class {
20737
20718
  baseUrl: loggingBaseUrl,
20738
20719
  headers
20739
20720
  });
20721
+ const auditHttpRef = (0, import_openapi_fetch3.default)({
20722
+ baseUrl: auditBaseUrl,
20723
+ headers: auditHeaders
20724
+ });
20740
20725
  this._sharedContextBuffer = new ContextRegistrationBuffer();
20741
20726
  this._environmentsRef = new EnvironmentsClient(this._appHttpRef);
20742
20727
  this._contextTypesRef = new ContextTypesClient(this._appHttpRef);
@@ -20746,6 +20731,7 @@ var SmplManagementClient = class {
20746
20731
  this._flagsRef = new ManagementFlagsClient(this._flagsHttpRef);
20747
20732
  this._loggersRef = new LoggersClient(this._loggingHttpRef);
20748
20733
  this._logGroupsRef = new LogGroupsClient(this._loggingHttpRef);
20734
+ this._auditRef = new ManagementAuditClient(auditHttpRef);
20749
20735
  }
20750
20736
  /** @internal — used by SmplClient to share the buffer. */
20751
20737
  get _contextBuffer() {
@@ -20769,11 +20755,11 @@ var CACHE_MAX_SIZE = 1e4;
20769
20755
  var CONTEXT_BATCH_FLUSH_SIZE2 = 100;
20770
20756
  var FLAG_REGISTRATION_FLUSH_SIZE2 = 50;
20771
20757
  var FLAG_REGISTRATION_FLUSH_INTERVAL_MS = 3e4;
20772
- async function checkError5(response, _context) {
20758
+ async function checkError6(response, _context) {
20773
20759
  const body = await response.text().catch(() => "");
20774
20760
  throwForStatus(response.status, body);
20775
20761
  }
20776
- function wrapFetchError5(err) {
20762
+ function wrapFetchError6(err) {
20777
20763
  if (err instanceof SmplNotFoundError || err instanceof SmplConflictError || err instanceof SmplValidationError || err instanceof SmplError) {
20778
20764
  throw err;
20779
20765
  }
@@ -21549,10 +21535,10 @@ var FlagsClient = class {
21549
21535
  let data;
21550
21536
  try {
21551
21537
  const result = await this._http.GET("/api/v1/flags", {});
21552
- if (!result.response.ok) await checkError5(result.response, "Failed to list flags");
21538
+ if (!result.response.ok) await checkError6(result.response, "Failed to list flags");
21553
21539
  data = result.data;
21554
21540
  } catch (err) {
21555
- wrapFetchError5(err);
21541
+ wrapFetchError6(err);
21556
21542
  }
21557
21543
  if (!data) return [];
21558
21544
  const flags = data.data.map((r) => this._resourceToPlainDict(r));
@@ -23018,6 +23004,7 @@ var PinoAdapter = class {
23018
23004
  AccountSettings,
23019
23005
  AccountSettingsClient,
23020
23006
  AuditClient,
23007
+ AuditForwardersClient,
23021
23008
  BooleanFlag,
23022
23009
  Color,
23023
23010
  Config,
@@ -23049,6 +23036,7 @@ var PinoAdapter = class {
23049
23036
  LoggerEnvironment,
23050
23037
  LoggerSource,
23051
23038
  LoggingClient,
23039
+ ManagementAuditClient,
23052
23040
  NumberFlag,
23053
23041
  Op,
23054
23042
  PinoAdapter,
@@ -23060,12 +23048,14 @@ var PinoAdapter = class {
23060
23048
  SmplError,
23061
23049
  SmplManagementClient,
23062
23050
  SmplNotFoundError,
23051
+ SmplPaymentRequiredError,
23063
23052
  SmplTimeoutError,
23064
23053
  SmplValidationError,
23065
23054
  SmplkitConflictError,
23066
23055
  SmplkitConnectionError,
23067
23056
  SmplkitError,
23068
23057
  SmplkitNotFoundError,
23058
+ SmplkitPaymentRequiredError,
23069
23059
  SmplkitTimeoutError,
23070
23060
  SmplkitValidationError,
23071
23061
  StringFlag,