@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 +432 -442
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -103
- package/dist/index.d.ts +113 -103
- package/dist/index.js +428 -442
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16619,6 +16619,122 @@ import createClient6 from "openapi-fetch";
|
|
|
16619
16619
|
// src/audit/client.ts
|
|
16620
16620
|
import createClient from "openapi-fetch";
|
|
16621
16621
|
|
|
16622
|
+
// src/errors.ts
|
|
16623
|
+
var SmplError = class extends Error {
|
|
16624
|
+
/** The HTTP status code, if the error originated from an HTTP response. */
|
|
16625
|
+
statusCode;
|
|
16626
|
+
/** The raw response body, if available. */
|
|
16627
|
+
responseBody;
|
|
16628
|
+
/** Structured JSON:API error objects from the server response, if available. */
|
|
16629
|
+
errors;
|
|
16630
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16631
|
+
super(message);
|
|
16632
|
+
this.name = "SmplError";
|
|
16633
|
+
this.statusCode = statusCode;
|
|
16634
|
+
this.responseBody = responseBody;
|
|
16635
|
+
this.errors = errors ?? [];
|
|
16636
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16637
|
+
}
|
|
16638
|
+
toString() {
|
|
16639
|
+
if (this.errors.length === 0) {
|
|
16640
|
+
return `${this.name}: ${this.message}`;
|
|
16641
|
+
}
|
|
16642
|
+
if (this.errors.length === 1) {
|
|
16643
|
+
return `${this.name}: ${this.message}
|
|
16644
|
+
Error: ${JSON.stringify(this.errors[0])}`;
|
|
16645
|
+
}
|
|
16646
|
+
const lines = this.errors.map((e, i) => ` [${i}] ${JSON.stringify(e)}`);
|
|
16647
|
+
return `${this.name}: ${this.message}
|
|
16648
|
+
Errors:
|
|
16649
|
+
${lines.join("\n")}`;
|
|
16650
|
+
}
|
|
16651
|
+
};
|
|
16652
|
+
var SmplConnectionError = class extends SmplError {
|
|
16653
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16654
|
+
super(message, statusCode, responseBody, errors);
|
|
16655
|
+
this.name = "SmplConnectionError";
|
|
16656
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16657
|
+
}
|
|
16658
|
+
};
|
|
16659
|
+
var SmplTimeoutError = class extends SmplError {
|
|
16660
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16661
|
+
super(message, statusCode, responseBody, errors);
|
|
16662
|
+
this.name = "SmplTimeoutError";
|
|
16663
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16664
|
+
}
|
|
16665
|
+
};
|
|
16666
|
+
var SmplNotFoundError = class extends SmplError {
|
|
16667
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16668
|
+
super(message, statusCode ?? 404, responseBody, errors);
|
|
16669
|
+
this.name = "SmplNotFoundError";
|
|
16670
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16671
|
+
}
|
|
16672
|
+
};
|
|
16673
|
+
var SmplConflictError = class extends SmplError {
|
|
16674
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16675
|
+
super(message, statusCode ?? 409, responseBody, errors);
|
|
16676
|
+
this.name = "SmplConflictError";
|
|
16677
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16678
|
+
}
|
|
16679
|
+
};
|
|
16680
|
+
var SmplValidationError = class extends SmplError {
|
|
16681
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16682
|
+
super(message, statusCode ?? 422, responseBody, errors);
|
|
16683
|
+
this.name = "SmplValidationError";
|
|
16684
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16685
|
+
}
|
|
16686
|
+
};
|
|
16687
|
+
var SmplPaymentRequiredError = class extends SmplError {
|
|
16688
|
+
constructor(message, statusCode, responseBody, errors) {
|
|
16689
|
+
super(message, statusCode ?? 402, responseBody, errors);
|
|
16690
|
+
this.name = "SmplPaymentRequiredError";
|
|
16691
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
16692
|
+
}
|
|
16693
|
+
};
|
|
16694
|
+
function parseJsonApiErrors(body) {
|
|
16695
|
+
try {
|
|
16696
|
+
const parsed = JSON.parse(body);
|
|
16697
|
+
if (parsed && Array.isArray(parsed.errors)) {
|
|
16698
|
+
return parsed.errors.map((e) => ({
|
|
16699
|
+
...e.status !== void 0 ? { status: String(e.status) } : {},
|
|
16700
|
+
...e.title !== void 0 ? { title: String(e.title) } : {},
|
|
16701
|
+
...e.detail !== void 0 ? { detail: String(e.detail) } : {},
|
|
16702
|
+
...e.source !== void 0 && typeof e.source === "object" && e.source !== null ? { source: e.source } : {}
|
|
16703
|
+
}));
|
|
16704
|
+
}
|
|
16705
|
+
} catch {
|
|
16706
|
+
}
|
|
16707
|
+
return [];
|
|
16708
|
+
}
|
|
16709
|
+
function deriveMessage(errors, statusCode, body) {
|
|
16710
|
+
if (errors.length === 0) {
|
|
16711
|
+
return body ? `HTTP ${statusCode}: ${body}` : `HTTP ${statusCode}`;
|
|
16712
|
+
}
|
|
16713
|
+
const first = errors[0];
|
|
16714
|
+
const base = first.detail ?? first.title ?? (first.status ? `HTTP ${first.status}` : `HTTP ${statusCode}`);
|
|
16715
|
+
if (errors.length > 1) {
|
|
16716
|
+
return `${base} (and ${errors.length - 1} more error${errors.length - 1 > 1 ? "s" : ""})`;
|
|
16717
|
+
}
|
|
16718
|
+
return base;
|
|
16719
|
+
}
|
|
16720
|
+
function throwForStatus(statusCode, body) {
|
|
16721
|
+
const errors = parseJsonApiErrors(body);
|
|
16722
|
+
const message = deriveMessage(errors, statusCode, body);
|
|
16723
|
+
switch (statusCode) {
|
|
16724
|
+
case 400:
|
|
16725
|
+
case 422:
|
|
16726
|
+
throw new SmplValidationError(message, statusCode, body, errors);
|
|
16727
|
+
case 402:
|
|
16728
|
+
throw new SmplPaymentRequiredError(message, statusCode, body, errors);
|
|
16729
|
+
case 404:
|
|
16730
|
+
throw new SmplNotFoundError(message, statusCode, body, errors);
|
|
16731
|
+
case 409:
|
|
16732
|
+
throw new SmplConflictError(message, statusCode, body, errors);
|
|
16733
|
+
default:
|
|
16734
|
+
throw new SmplError(message, statusCode, body, errors);
|
|
16735
|
+
}
|
|
16736
|
+
}
|
|
16737
|
+
|
|
16622
16738
|
// src/audit/buffer.ts
|
|
16623
16739
|
var MAX_BUFFER_SIZE = 1e3;
|
|
16624
16740
|
var PERIODIC_FLUSH_INTERVAL_MS = 5e3;
|
|
@@ -16762,83 +16878,14 @@ function _eventFromResource(resource) {
|
|
|
16762
16878
|
doNotForward: Boolean(attrs.do_not_forward ?? false)
|
|
16763
16879
|
};
|
|
16764
16880
|
}
|
|
16765
|
-
function _httpToWire(http) {
|
|
16766
|
-
return {
|
|
16767
|
-
method: http.method,
|
|
16768
|
-
url: http.url,
|
|
16769
|
-
headers: http.headers.map((h) => ({ name: h.name, value: h.value })),
|
|
16770
|
-
body: http.body,
|
|
16771
|
-
success_status: http.successStatus
|
|
16772
|
-
};
|
|
16773
|
-
}
|
|
16774
|
-
function _httpFromWire(raw) {
|
|
16775
|
-
const r = raw ?? {};
|
|
16776
|
-
const headers = (r.headers ?? []).map((h) => ({
|
|
16777
|
-
name: String(h.name ?? ""),
|
|
16778
|
-
value: String(h.value ?? "")
|
|
16779
|
-
}));
|
|
16780
|
-
return {
|
|
16781
|
-
method: String(r.method ?? "POST"),
|
|
16782
|
-
url: String(r.url ?? ""),
|
|
16783
|
-
headers,
|
|
16784
|
-
body: r.body ?? null,
|
|
16785
|
-
successStatus: String(r.success_status ?? "2xx")
|
|
16786
|
-
};
|
|
16787
|
-
}
|
|
16788
|
-
function _forwarderAttributes(input) {
|
|
16789
|
-
const attrs = {
|
|
16790
|
-
name: input.name,
|
|
16791
|
-
forwarder_type: input.forwarderType,
|
|
16792
|
-
enabled: input.enabled ?? true,
|
|
16793
|
-
http: _httpToWire(input.http)
|
|
16794
|
-
};
|
|
16795
|
-
if (input.filter !== void 0) {
|
|
16796
|
-
attrs.filter = input.filter;
|
|
16797
|
-
}
|
|
16798
|
-
if (input.transform !== void 0) attrs.transform = input.transform;
|
|
16799
|
-
if (input.data !== void 0) {
|
|
16800
|
-
attrs.data = input.data;
|
|
16801
|
-
}
|
|
16802
|
-
return attrs;
|
|
16803
|
-
}
|
|
16804
|
-
function _forwarderFromResource(resource) {
|
|
16805
|
-
const a = resource.attributes;
|
|
16806
|
-
return {
|
|
16807
|
-
id: resource.id,
|
|
16808
|
-
name: String(a.name ?? ""),
|
|
16809
|
-
slug: String(a.slug ?? ""),
|
|
16810
|
-
forwarderType: a.forwarder_type,
|
|
16811
|
-
enabled: Boolean(a.enabled ?? true),
|
|
16812
|
-
filter: a.filter ?? null,
|
|
16813
|
-
transform: a.transform ?? null,
|
|
16814
|
-
http: _httpFromWire(a.http),
|
|
16815
|
-
data: a.data ?? {},
|
|
16816
|
-
createdAt: a.created_at ?? null,
|
|
16817
|
-
updatedAt: a.updated_at ?? null,
|
|
16818
|
-
deletedAt: a.deleted_at ?? null,
|
|
16819
|
-
version: a.version ?? null
|
|
16820
|
-
};
|
|
16821
|
-
}
|
|
16822
|
-
function _deliveryFromResource(resource) {
|
|
16823
|
-
const a = resource.attributes;
|
|
16824
|
-
return {
|
|
16825
|
-
id: resource.id,
|
|
16826
|
-
forwarderId: String(a.forwarder_id ?? ""),
|
|
16827
|
-
eventId: String(a.event_id ?? ""),
|
|
16828
|
-
attemptNumber: Number(a.attempt_number ?? 1),
|
|
16829
|
-
status: a.status ?? "FAILED",
|
|
16830
|
-
request: a.request ?? null,
|
|
16831
|
-
responseStatus: a.response_status ?? null,
|
|
16832
|
-
responseBody: a.response_body ?? null,
|
|
16833
|
-
latencyMs: a.latency_ms ?? null,
|
|
16834
|
-
error: a.error ?? null,
|
|
16835
|
-
createdAt: a.created_at ?? null
|
|
16836
|
-
};
|
|
16837
|
-
}
|
|
16838
16881
|
function _nextCursorFromLinks(body) {
|
|
16839
16882
|
const next = body.links?.next;
|
|
16840
16883
|
if (typeof next !== "string" || !next.includes("page[after]=")) return null;
|
|
16841
|
-
return next.split("page[after]=")[1];
|
|
16884
|
+
return next.split("page[after]=")[1].split("&")[0];
|
|
16885
|
+
}
|
|
16886
|
+
async function _throwForResponse(response) {
|
|
16887
|
+
const body = await response.text().catch(() => "");
|
|
16888
|
+
throwForStatus(response.status, body);
|
|
16842
16889
|
}
|
|
16843
16890
|
var EventsClient = class {
|
|
16844
16891
|
/** @internal */
|
|
@@ -16895,31 +16942,26 @@ var EventsClient = class {
|
|
|
16895
16942
|
if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
|
|
16896
16943
|
const result = await this._http.GET("/api/v1/events", {
|
|
16897
16944
|
// openapi-fetch's typed query map is constrained by the spec's
|
|
16898
|
-
// exact param names
|
|
16899
|
-
//
|
|
16900
|
-
//
|
|
16945
|
+
// exact param names; the JSON:API filter[*] / page[*] format isn't
|
|
16946
|
+
// expressible in that shape, so we cast and let openapi-fetch
|
|
16947
|
+
// URL-encode the literal keys.
|
|
16901
16948
|
params: { query }
|
|
16902
16949
|
});
|
|
16903
|
-
if (!result.response.ok
|
|
16904
|
-
|
|
16905
|
-
}
|
|
16950
|
+
if (!result.response.ok) await _throwForResponse(result.response);
|
|
16951
|
+
if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
|
|
16906
16952
|
const body = result.data;
|
|
16907
|
-
const
|
|
16908
|
-
|
|
16909
|
-
const nextLink = body.links?.next;
|
|
16910
|
-
if (typeof nextLink === "string" && nextLink.includes("page[after]=")) {
|
|
16911
|
-
nextCursor = nextLink.split("page[after]=")[1];
|
|
16912
|
-
}
|
|
16913
|
-
return { events, nextCursor };
|
|
16953
|
+
const rows = body.data ?? [];
|
|
16954
|
+
return { events: rows.map(_eventFromResource), nextCursor: _nextCursorFromLinks(body) };
|
|
16914
16955
|
}
|
|
16915
16956
|
async get(eventId) {
|
|
16916
16957
|
const result = await this._http.GET("/api/v1/events/{event_id}", {
|
|
16917
16958
|
params: { path: { event_id: eventId } }
|
|
16918
16959
|
});
|
|
16919
|
-
if (!result.response.ok
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
|
|
16960
|
+
if (!result.response.ok) await _throwForResponse(result.response);
|
|
16961
|
+
if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
|
|
16962
|
+
return _eventFromResource(
|
|
16963
|
+
result.data.data
|
|
16964
|
+
);
|
|
16923
16965
|
}
|
|
16924
16966
|
/** Block until the in-memory buffer is drained or `timeoutMs` elapses. */
|
|
16925
16967
|
async flush(timeoutMs = 5e3) {
|
|
@@ -16930,332 +16972,86 @@ var EventsClient = class {
|
|
|
16930
16972
|
await this._buffer.close();
|
|
16931
16973
|
}
|
|
16932
16974
|
};
|
|
16933
|
-
var
|
|
16934
|
-
constructor(_http) {
|
|
16935
|
-
this._http = _http;
|
|
16936
|
-
}
|
|
16937
|
-
/** Retry a single failed delivery. Records a new attempt row with
|
|
16938
|
-
* attempt_number = prior + 1; the prior row is unchanged. */
|
|
16939
|
-
async retry(forwarderId, deliveryId) {
|
|
16940
|
-
const result = await this._http.POST(
|
|
16941
|
-
"/api/v1/forwarders/{forwarder_id}/deliveries/{delivery_id}/actions/retry",
|
|
16942
|
-
{ params: { path: { forwarder_id: forwarderId, delivery_id: deliveryId } } }
|
|
16943
|
-
);
|
|
16944
|
-
if (!result.response.ok || result.data === void 0) {
|
|
16945
|
-
throw new Error(
|
|
16946
|
-
`audit retry delivery failed: ${result.response.status} ${result.response.statusText}`
|
|
16947
|
-
);
|
|
16948
|
-
}
|
|
16949
|
-
return _deliveryFromResource(result.data.data);
|
|
16950
|
-
}
|
|
16951
|
-
};
|
|
16952
|
-
var DeliveriesClient = class {
|
|
16953
|
-
constructor(_http) {
|
|
16954
|
-
this._http = _http;
|
|
16955
|
-
this.actions = new DeliveryActionsClient(_http);
|
|
16956
|
-
}
|
|
16957
|
-
actions;
|
|
16958
|
-
async list(forwarderId, params = {}) {
|
|
16959
|
-
const query = {};
|
|
16960
|
-
if (params.status !== void 0) query["filter[status]"] = params.status;
|
|
16961
|
-
if (params.createdAtRange !== void 0) query["filter[created_at]"] = params.createdAtRange;
|
|
16962
|
-
if (params.eventId !== void 0) query["filter[event_id]"] = params.eventId;
|
|
16963
|
-
if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
|
|
16964
|
-
if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
|
|
16965
|
-
const result = await this._http.GET("/api/v1/forwarders/{forwarder_id}/deliveries", {
|
|
16966
|
-
params: {
|
|
16967
|
-
path: { forwarder_id: forwarderId },
|
|
16968
|
-
query
|
|
16969
|
-
}
|
|
16970
|
-
});
|
|
16971
|
-
if (!result.response.ok || result.data === void 0) {
|
|
16972
|
-
throw new Error(
|
|
16973
|
-
`audit list deliveries failed: ${result.response.status} ${result.response.statusText}`
|
|
16974
|
-
);
|
|
16975
|
-
}
|
|
16976
|
-
const body = result.data;
|
|
16977
|
-
return {
|
|
16978
|
-
deliveries: (body.data ?? []).map(_deliveryFromResource),
|
|
16979
|
-
nextCursor: _nextCursorFromLinks(body)
|
|
16980
|
-
};
|
|
16981
|
-
}
|
|
16982
|
-
};
|
|
16983
|
-
var ForwarderActionsClient = class {
|
|
16975
|
+
var ResourceTypesClient = class {
|
|
16984
16976
|
constructor(_http) {
|
|
16985
16977
|
this._http = _http;
|
|
16986
16978
|
}
|
|
16987
|
-
/**
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
16993
|
-
|
|
16994
|
-
throw new Error(
|
|
16995
|
-
`audit bulk retry failed: ${result.response.status} ${result.response.statusText}`
|
|
16996
|
-
);
|
|
16997
|
-
}
|
|
16998
|
-
const d = result.data;
|
|
16999
|
-
return {
|
|
17000
|
-
attempted: Number(d.attempted ?? 0),
|
|
17001
|
-
succeeded: Number(d.succeeded ?? 0),
|
|
17002
|
-
failed: Number(d.failed ?? 0)
|
|
17003
|
-
};
|
|
17004
|
-
}
|
|
17005
|
-
};
|
|
17006
|
-
var ForwardersClient = class {
|
|
17007
|
-
constructor(_http) {
|
|
17008
|
-
this._http = _http;
|
|
17009
|
-
this.deliveries = new DeliveriesClient(_http);
|
|
17010
|
-
this.actions = new ForwarderActionsClient(_http);
|
|
17011
|
-
}
|
|
17012
|
-
deliveries;
|
|
17013
|
-
actions;
|
|
17014
|
-
async create(input) {
|
|
17015
|
-
const body = {
|
|
17016
|
-
data: { id: "", type: "forwarder", attributes: _forwarderAttributes(input) }
|
|
17017
|
-
};
|
|
17018
|
-
const result = await this._http.POST("/api/v1/forwarders", { body });
|
|
17019
|
-
if (!result.response.ok || result.data === void 0) {
|
|
17020
|
-
throw new Error(
|
|
17021
|
-
`audit create forwarder failed: ${result.response.status} ${result.response.statusText}`
|
|
17022
|
-
);
|
|
17023
|
-
}
|
|
17024
|
-
return _forwarderFromResource(result.data.data);
|
|
17025
|
-
}
|
|
16979
|
+
/**
|
|
16980
|
+
* List the distinct `resource_type` slugs recorded for this account.
|
|
16981
|
+
*
|
|
16982
|
+
* Backed by a maintain-by-write side table (ADR-047 §2.5), so the
|
|
16983
|
+
* response time is independent of event volume. Sorted alphabetically;
|
|
16984
|
+
* cursor pagination via `pageAfter`.
|
|
16985
|
+
*/
|
|
17026
16986
|
async list(params = {}) {
|
|
17027
16987
|
const query = {};
|
|
17028
|
-
if (params.forwarderType !== void 0) query["filter[forwarder_type]"] = params.forwarderType;
|
|
17029
|
-
if (params.enabled !== void 0) query["filter[enabled]"] = params.enabled;
|
|
17030
16988
|
if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
|
|
17031
16989
|
if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
|
|
17032
|
-
const result = await this._http.GET("/api/v1/
|
|
17033
|
-
params: { query }
|
|
17034
|
-
});
|
|
17035
|
-
if (!result.response.ok
|
|
17036
|
-
|
|
17037
|
-
|
|
17038
|
-
|
|
17039
|
-
|
|
17040
|
-
|
|
17041
|
-
|
|
17042
|
-
|
|
17043
|
-
|
|
17044
|
-
};
|
|
17045
|
-
}
|
|
17046
|
-
async get(forwarderId) {
|
|
17047
|
-
const result = await this._http.GET("/api/v1/forwarders/{forwarder_id}", {
|
|
17048
|
-
params: { path: { forwarder_id: forwarderId } }
|
|
17049
|
-
});
|
|
17050
|
-
if (!result.response.ok || result.data === void 0) {
|
|
17051
|
-
throw new Error(
|
|
17052
|
-
`audit get forwarder failed: ${result.response.status} ${result.response.statusText}`
|
|
17053
|
-
);
|
|
17054
|
-
}
|
|
17055
|
-
return _forwarderFromResource(result.data.data);
|
|
17056
|
-
}
|
|
17057
|
-
async update(forwarderId, input) {
|
|
17058
|
-
const body = {
|
|
17059
|
-
data: { id: forwarderId, type: "forwarder", attributes: _forwarderAttributes(input) }
|
|
17060
|
-
};
|
|
17061
|
-
const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
|
|
17062
|
-
params: { path: { forwarder_id: forwarderId } },
|
|
17063
|
-
body
|
|
17064
|
-
});
|
|
17065
|
-
if (!result.response.ok || result.data === void 0) {
|
|
17066
|
-
throw new Error(
|
|
17067
|
-
`audit update forwarder failed: ${result.response.status} ${result.response.statusText}`
|
|
17068
|
-
);
|
|
17069
|
-
}
|
|
17070
|
-
return _forwarderFromResource(result.data.data);
|
|
17071
|
-
}
|
|
17072
|
-
async delete(forwarderId) {
|
|
17073
|
-
const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
|
|
17074
|
-
params: { path: { forwarder_id: forwarderId } }
|
|
17075
|
-
});
|
|
17076
|
-
if (result.response.status !== 204) {
|
|
17077
|
-
throw new Error(
|
|
17078
|
-
`audit delete forwarder failed: ${result.response.status} ${result.response.statusText}`
|
|
17079
|
-
);
|
|
17080
|
-
}
|
|
17081
|
-
}
|
|
17082
|
-
};
|
|
17083
|
-
var TestForwarderActionsClient = class {
|
|
17084
|
-
constructor(_http) {
|
|
17085
|
-
this._http = _http;
|
|
17086
|
-
}
|
|
17087
|
-
/** Server-side proxy to a customer-supplied URL. SSRF-guarded; the
|
|
17088
|
-
* audit service rejects private/loopback/link-local addresses (incl.
|
|
17089
|
-
* the EC2 IMDS at 169.254.169.254) and ports outside the allowlist. */
|
|
17090
|
-
async execute(input) {
|
|
17091
|
-
const body = {
|
|
17092
|
-
method: input.method ?? "POST",
|
|
17093
|
-
url: input.url,
|
|
17094
|
-
headers: (input.headers ?? []).map((h) => ({ name: h.name, value: h.value })),
|
|
17095
|
-
body: input.body ?? null,
|
|
17096
|
-
success_status: input.successStatus ?? "2xx"
|
|
17097
|
-
};
|
|
17098
|
-
if (input.timeoutMs !== void 0) body.timeout_ms = input.timeoutMs;
|
|
17099
|
-
const result = await this._http.POST("/api/v1/functions/test_forwarder/actions/execute", {
|
|
17100
|
-
// This endpoint serves and accepts plain JSON, NOT JSON:API. The
|
|
17101
|
-
// openapi-fetch client adds its default JSON:API content-type
|
|
17102
|
-
// header; we override here so the server's strict validator
|
|
17103
|
-
// doesn't reject the request.
|
|
17104
|
-
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
17105
|
-
body
|
|
17106
|
-
});
|
|
17107
|
-
if (!result.response.ok || result.data === void 0) {
|
|
17108
|
-
throw new Error(
|
|
17109
|
-
`audit test_forwarder failed: ${result.response.status} ${result.response.statusText}`
|
|
17110
|
-
);
|
|
17111
|
-
}
|
|
17112
|
-
const d = result.data;
|
|
17113
|
-
return {
|
|
17114
|
-
succeeded: Boolean(d.succeeded),
|
|
17115
|
-
responseStatus: d.response_status ?? null,
|
|
17116
|
-
responseHeaders: d.response_headers ?? {},
|
|
17117
|
-
responseBody: String(d.response_body ?? ""),
|
|
17118
|
-
latencyMs: d.latency_ms ?? null,
|
|
17119
|
-
error: d.error ?? null
|
|
17120
|
-
};
|
|
17121
|
-
}
|
|
17122
|
-
};
|
|
17123
|
-
var TestForwarderClient = class {
|
|
17124
|
-
actions;
|
|
17125
|
-
constructor(http) {
|
|
17126
|
-
this.actions = new TestForwarderActionsClient(http);
|
|
17127
|
-
}
|
|
17128
|
-
};
|
|
17129
|
-
var FunctionsClient = class {
|
|
17130
|
-
test_forwarder;
|
|
17131
|
-
constructor(http) {
|
|
17132
|
-
this.test_forwarder = new TestForwarderClient(http);
|
|
17133
|
-
}
|
|
17134
|
-
};
|
|
17135
|
-
var AuditClient = class {
|
|
17136
|
-
events;
|
|
17137
|
-
forwarders;
|
|
17138
|
-
functions;
|
|
17139
|
-
constructor(opts) {
|
|
17140
|
-
this.events = new EventsClient(opts);
|
|
17141
|
-
this.forwarders = new ForwardersClient(this.events._http);
|
|
17142
|
-
this.functions = new FunctionsClient(this.events._http);
|
|
17143
|
-
}
|
|
17144
|
-
/** @internal */
|
|
17145
|
-
async _close() {
|
|
17146
|
-
await this.events._close();
|
|
17147
|
-
}
|
|
17148
|
-
};
|
|
17149
|
-
|
|
17150
|
-
// src/config/client.ts
|
|
17151
|
-
import createClient2 from "openapi-fetch";
|
|
17152
|
-
|
|
17153
|
-
// src/errors.ts
|
|
17154
|
-
var SmplError = class extends Error {
|
|
17155
|
-
/** The HTTP status code, if the error originated from an HTTP response. */
|
|
17156
|
-
statusCode;
|
|
17157
|
-
/** The raw response body, if available. */
|
|
17158
|
-
responseBody;
|
|
17159
|
-
/** Structured JSON:API error objects from the server response, if available. */
|
|
17160
|
-
errors;
|
|
17161
|
-
constructor(message, statusCode, responseBody, errors) {
|
|
17162
|
-
super(message);
|
|
17163
|
-
this.name = "SmplError";
|
|
17164
|
-
this.statusCode = statusCode;
|
|
17165
|
-
this.responseBody = responseBody;
|
|
17166
|
-
this.errors = errors ?? [];
|
|
17167
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
17168
|
-
}
|
|
17169
|
-
toString() {
|
|
17170
|
-
if (this.errors.length === 0) {
|
|
17171
|
-
return `${this.name}: ${this.message}`;
|
|
17172
|
-
}
|
|
17173
|
-
if (this.errors.length === 1) {
|
|
17174
|
-
return `${this.name}: ${this.message}
|
|
17175
|
-
Error: ${JSON.stringify(this.errors[0])}`;
|
|
17176
|
-
}
|
|
17177
|
-
const lines = this.errors.map((e, i) => ` [${i}] ${JSON.stringify(e)}`);
|
|
17178
|
-
return `${this.name}: ${this.message}
|
|
17179
|
-
Errors:
|
|
17180
|
-
${lines.join("\n")}`;
|
|
17181
|
-
}
|
|
17182
|
-
};
|
|
17183
|
-
var SmplConnectionError = class extends SmplError {
|
|
17184
|
-
constructor(message, statusCode, responseBody, errors) {
|
|
17185
|
-
super(message, statusCode, responseBody, errors);
|
|
17186
|
-
this.name = "SmplConnectionError";
|
|
17187
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
17188
|
-
}
|
|
17189
|
-
};
|
|
17190
|
-
var SmplTimeoutError = class extends SmplError {
|
|
17191
|
-
constructor(message, statusCode, responseBody, errors) {
|
|
17192
|
-
super(message, statusCode, responseBody, errors);
|
|
17193
|
-
this.name = "SmplTimeoutError";
|
|
17194
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
17195
|
-
}
|
|
17196
|
-
};
|
|
17197
|
-
var SmplNotFoundError = class extends SmplError {
|
|
17198
|
-
constructor(message, statusCode, responseBody, errors) {
|
|
17199
|
-
super(message, statusCode ?? 404, responseBody, errors);
|
|
17200
|
-
this.name = "SmplNotFoundError";
|
|
17201
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
17202
|
-
}
|
|
17203
|
-
};
|
|
17204
|
-
var SmplConflictError = class extends SmplError {
|
|
17205
|
-
constructor(message, statusCode, responseBody, errors) {
|
|
17206
|
-
super(message, statusCode ?? 409, responseBody, errors);
|
|
17207
|
-
this.name = "SmplConflictError";
|
|
17208
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
17209
|
-
}
|
|
17210
|
-
};
|
|
17211
|
-
var SmplValidationError = class extends SmplError {
|
|
17212
|
-
constructor(message, statusCode, responseBody, errors) {
|
|
17213
|
-
super(message, statusCode ?? 422, responseBody, errors);
|
|
17214
|
-
this.name = "SmplValidationError";
|
|
17215
|
-
Object.setPrototypeOf(this, new.target.prototype);
|
|
17216
|
-
}
|
|
17217
|
-
};
|
|
17218
|
-
function parseJsonApiErrors(body) {
|
|
17219
|
-
try {
|
|
17220
|
-
const parsed = JSON.parse(body);
|
|
17221
|
-
if (parsed && Array.isArray(parsed.errors)) {
|
|
17222
|
-
return parsed.errors.map((e) => ({
|
|
17223
|
-
...e.status !== void 0 ? { status: String(e.status) } : {},
|
|
17224
|
-
...e.title !== void 0 ? { title: String(e.title) } : {},
|
|
17225
|
-
...e.detail !== void 0 ? { detail: String(e.detail) } : {},
|
|
17226
|
-
...e.source !== void 0 && typeof e.source === "object" && e.source !== null ? { source: e.source } : {}
|
|
17227
|
-
}));
|
|
17228
|
-
}
|
|
17229
|
-
} catch {
|
|
16990
|
+
const result = await this._http.GET("/api/v1/resource_types", {
|
|
16991
|
+
params: { query }
|
|
16992
|
+
});
|
|
16993
|
+
if (!result.response.ok) await _throwForResponse(result.response);
|
|
16994
|
+
if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
|
|
16995
|
+
const body = result.data;
|
|
16996
|
+
const resourceTypes = (body.data ?? []).map(
|
|
16997
|
+
(r) => ({
|
|
16998
|
+
id: r.id,
|
|
16999
|
+
createdAt: String(r.attributes.created_at ?? "")
|
|
17000
|
+
})
|
|
17001
|
+
);
|
|
17002
|
+
return { resourceTypes, nextCursor: _nextCursorFromLinks(body) };
|
|
17230
17003
|
}
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17234
|
-
|
|
17235
|
-
return body ? `HTTP ${statusCode}: ${body}` : `HTTP ${statusCode}`;
|
|
17004
|
+
};
|
|
17005
|
+
var ActionsClient = class {
|
|
17006
|
+
constructor(_http) {
|
|
17007
|
+
this._http = _http;
|
|
17236
17008
|
}
|
|
17237
|
-
|
|
17238
|
-
|
|
17239
|
-
|
|
17240
|
-
|
|
17009
|
+
/**
|
|
17010
|
+
* List the distinct `action` slugs recorded for this account.
|
|
17011
|
+
*
|
|
17012
|
+
* Without `filterResourceType`, returns one row per distinct action.
|
|
17013
|
+
* With `filterResourceType`, returns only the actions recorded with
|
|
17014
|
+
* that resource_type, powering cascading-filter UIs (ADR-047 §2.5).
|
|
17015
|
+
* Sorted alphabetically; cursor pagination via `pageAfter`.
|
|
17016
|
+
*/
|
|
17017
|
+
async list(params = {}) {
|
|
17018
|
+
const query = {};
|
|
17019
|
+
if (params.filterResourceType !== void 0)
|
|
17020
|
+
query["filter[resource_type]"] = params.filterResourceType;
|
|
17021
|
+
if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
|
|
17022
|
+
if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
|
|
17023
|
+
const result = await this._http.GET("/api/v1/actions", {
|
|
17024
|
+
params: { query }
|
|
17025
|
+
});
|
|
17026
|
+
if (!result.response.ok) await _throwForResponse(result.response);
|
|
17027
|
+
if (result.data === void 0) throw new SmplError("Unexpected empty response from audit");
|
|
17028
|
+
const body = result.data;
|
|
17029
|
+
const actions = (body.data ?? []).map(
|
|
17030
|
+
(r) => ({
|
|
17031
|
+
id: r.id,
|
|
17032
|
+
createdAt: String(r.attributes.created_at ?? "")
|
|
17033
|
+
})
|
|
17034
|
+
);
|
|
17035
|
+
return { actions, nextCursor: _nextCursorFromLinks(body) };
|
|
17241
17036
|
}
|
|
17242
|
-
|
|
17243
|
-
|
|
17244
|
-
|
|
17245
|
-
|
|
17246
|
-
|
|
17247
|
-
|
|
17248
|
-
|
|
17249
|
-
|
|
17250
|
-
|
|
17251
|
-
case 404:
|
|
17252
|
-
throw new SmplNotFoundError(message, statusCode, body, errors);
|
|
17253
|
-
case 409:
|
|
17254
|
-
throw new SmplConflictError(message, statusCode, body, errors);
|
|
17255
|
-
default:
|
|
17256
|
-
throw new SmplError(message, statusCode, body, errors);
|
|
17037
|
+
};
|
|
17038
|
+
var AuditClient = class {
|
|
17039
|
+
events;
|
|
17040
|
+
resourceTypes;
|
|
17041
|
+
actions;
|
|
17042
|
+
constructor(opts) {
|
|
17043
|
+
this.events = new EventsClient(opts);
|
|
17044
|
+
this.resourceTypes = new ResourceTypesClient(this.events._http);
|
|
17045
|
+
this.actions = new ActionsClient(this.events._http);
|
|
17257
17046
|
}
|
|
17258
|
-
|
|
17047
|
+
/** @internal */
|
|
17048
|
+
async _close() {
|
|
17049
|
+
await this.events._close();
|
|
17050
|
+
}
|
|
17051
|
+
};
|
|
17052
|
+
|
|
17053
|
+
// src/config/client.ts
|
|
17054
|
+
import createClient2 from "openapi-fetch";
|
|
17259
17055
|
|
|
17260
17056
|
// src/config/resolve.ts
|
|
17261
17057
|
function deepMerge(base, override) {
|
|
@@ -19954,6 +19750,177 @@ var LogGroupsClient = class {
|
|
|
19954
19750
|
}
|
|
19955
19751
|
};
|
|
19956
19752
|
|
|
19753
|
+
// src/management/audit.ts
|
|
19754
|
+
async function checkError4(response) {
|
|
19755
|
+
const body = await response.text().catch(() => "");
|
|
19756
|
+
throwForStatus(response.status, body);
|
|
19757
|
+
}
|
|
19758
|
+
function wrapFetchError4(err) {
|
|
19759
|
+
if (err instanceof SmplError) throw err;
|
|
19760
|
+
if (err instanceof TypeError) {
|
|
19761
|
+
throw new SmplConnectionError(`Network error: ${err.message}`);
|
|
19762
|
+
}
|
|
19763
|
+
throw new SmplConnectionError(
|
|
19764
|
+
`Request failed: ${err instanceof Error ? err.message : String(err)}`
|
|
19765
|
+
);
|
|
19766
|
+
}
|
|
19767
|
+
function _nextCursorFromLinks2(body) {
|
|
19768
|
+
const next = body.links?.next;
|
|
19769
|
+
if (typeof next !== "string" || !next.includes("page[after]=")) return null;
|
|
19770
|
+
return next.split("page[after]=")[1].split("&")[0];
|
|
19771
|
+
}
|
|
19772
|
+
function _httpToWire(http) {
|
|
19773
|
+
return {
|
|
19774
|
+
method: http.method,
|
|
19775
|
+
url: http.url,
|
|
19776
|
+
headers: http.headers.map((h) => ({ name: h.name, value: h.value })),
|
|
19777
|
+
body: http.body,
|
|
19778
|
+
success_status: http.successStatus
|
|
19779
|
+
};
|
|
19780
|
+
}
|
|
19781
|
+
function _httpFromWire(raw) {
|
|
19782
|
+
const r = raw ?? {};
|
|
19783
|
+
const headers = (r.headers ?? []).map((h) => ({
|
|
19784
|
+
name: String(h.name ?? ""),
|
|
19785
|
+
value: String(h.value ?? "")
|
|
19786
|
+
}));
|
|
19787
|
+
return {
|
|
19788
|
+
method: String(r.method ?? "POST"),
|
|
19789
|
+
url: String(r.url ?? ""),
|
|
19790
|
+
headers,
|
|
19791
|
+
body: r.body ?? null,
|
|
19792
|
+
successStatus: String(r.success_status ?? "2xx")
|
|
19793
|
+
};
|
|
19794
|
+
}
|
|
19795
|
+
function _forwarderAttributes(input) {
|
|
19796
|
+
const attrs = {
|
|
19797
|
+
name: input.name,
|
|
19798
|
+
forwarder_type: input.forwarderType,
|
|
19799
|
+
enabled: input.enabled ?? true,
|
|
19800
|
+
http: _httpToWire(input.http)
|
|
19801
|
+
};
|
|
19802
|
+
if (input.filter !== void 0) {
|
|
19803
|
+
attrs.filter = input.filter;
|
|
19804
|
+
}
|
|
19805
|
+
if (input.transform !== void 0) attrs.transform = input.transform;
|
|
19806
|
+
return attrs;
|
|
19807
|
+
}
|
|
19808
|
+
function _forwarderFromResource(resource) {
|
|
19809
|
+
const a = resource.attributes;
|
|
19810
|
+
return {
|
|
19811
|
+
id: resource.id,
|
|
19812
|
+
name: String(a.name ?? ""),
|
|
19813
|
+
slug: String(a.slug ?? ""),
|
|
19814
|
+
forwarderType: a.forwarder_type,
|
|
19815
|
+
enabled: Boolean(a.enabled ?? true),
|
|
19816
|
+
filter: a.filter ?? null,
|
|
19817
|
+
transform: a.transform ?? null,
|
|
19818
|
+
http: _httpFromWire(a.http),
|
|
19819
|
+
createdAt: a.created_at ?? null,
|
|
19820
|
+
updatedAt: a.updated_at ?? null,
|
|
19821
|
+
deletedAt: a.deleted_at ?? null,
|
|
19822
|
+
version: a.version ?? null
|
|
19823
|
+
};
|
|
19824
|
+
}
|
|
19825
|
+
var ForwardersClient = class {
|
|
19826
|
+
/** @internal */
|
|
19827
|
+
constructor(_http) {
|
|
19828
|
+
this._http = _http;
|
|
19829
|
+
}
|
|
19830
|
+
async create(input) {
|
|
19831
|
+
const body = {
|
|
19832
|
+
data: { id: "", type: "forwarder", attributes: _forwarderAttributes(input) }
|
|
19833
|
+
};
|
|
19834
|
+
let data;
|
|
19835
|
+
try {
|
|
19836
|
+
const result = await this._http.POST("/api/v1/forwarders", { body });
|
|
19837
|
+
if (!result.response.ok) await checkError4(result.response);
|
|
19838
|
+
data = result.data;
|
|
19839
|
+
} catch (err) {
|
|
19840
|
+
wrapFetchError4(err);
|
|
19841
|
+
}
|
|
19842
|
+
if (!data?.data) throw new SmplError("Unexpected empty response from audit");
|
|
19843
|
+
return _forwarderFromResource(data.data);
|
|
19844
|
+
}
|
|
19845
|
+
async list(params = {}) {
|
|
19846
|
+
const query = {};
|
|
19847
|
+
if (params.forwarderType !== void 0) query["filter[forwarder_type]"] = params.forwarderType;
|
|
19848
|
+
if (params.enabled !== void 0) query["filter[enabled]"] = params.enabled;
|
|
19849
|
+
if (params.pageSize !== void 0) query["page[size]"] = params.pageSize;
|
|
19850
|
+
if (params.pageAfter !== void 0) query["page[after]"] = params.pageAfter;
|
|
19851
|
+
let data;
|
|
19852
|
+
try {
|
|
19853
|
+
const result = await this._http.GET("/api/v1/forwarders", {
|
|
19854
|
+
params: { query }
|
|
19855
|
+
});
|
|
19856
|
+
if (!result.response.ok) await checkError4(result.response);
|
|
19857
|
+
data = result.data;
|
|
19858
|
+
} catch (err) {
|
|
19859
|
+
wrapFetchError4(err);
|
|
19860
|
+
}
|
|
19861
|
+
return {
|
|
19862
|
+
forwarders: (data?.data ?? []).map(_forwarderFromResource),
|
|
19863
|
+
nextCursor: _nextCursorFromLinks2(data ?? {})
|
|
19864
|
+
};
|
|
19865
|
+
}
|
|
19866
|
+
async get(forwarderId) {
|
|
19867
|
+
let data;
|
|
19868
|
+
try {
|
|
19869
|
+
const result = await this._http.GET("/api/v1/forwarders/{forwarder_id}", {
|
|
19870
|
+
params: { path: { forwarder_id: forwarderId } }
|
|
19871
|
+
});
|
|
19872
|
+
if (!result.response.ok) await checkError4(result.response);
|
|
19873
|
+
data = result.data;
|
|
19874
|
+
} catch (err) {
|
|
19875
|
+
wrapFetchError4(err);
|
|
19876
|
+
}
|
|
19877
|
+
if (!data?.data) throw new SmplError("Unexpected empty response from audit");
|
|
19878
|
+
return _forwarderFromResource(data.data);
|
|
19879
|
+
}
|
|
19880
|
+
/**
|
|
19881
|
+
* Full-replace update. PUT semantics — every field is overwritten.
|
|
19882
|
+
*
|
|
19883
|
+
* Header values must be re-supplied as plaintext; the GET path
|
|
19884
|
+
* returns them in plaintext for exactly this round-trip.
|
|
19885
|
+
*/
|
|
19886
|
+
async update(forwarderId, input) {
|
|
19887
|
+
const body = {
|
|
19888
|
+
data: { id: forwarderId, type: "forwarder", attributes: _forwarderAttributes(input) }
|
|
19889
|
+
};
|
|
19890
|
+
let data;
|
|
19891
|
+
try {
|
|
19892
|
+
const result = await this._http.PUT("/api/v1/forwarders/{forwarder_id}", {
|
|
19893
|
+
params: { path: { forwarder_id: forwarderId } },
|
|
19894
|
+
body
|
|
19895
|
+
});
|
|
19896
|
+
if (!result.response.ok) await checkError4(result.response);
|
|
19897
|
+
data = result.data;
|
|
19898
|
+
} catch (err) {
|
|
19899
|
+
wrapFetchError4(err);
|
|
19900
|
+
}
|
|
19901
|
+
if (!data?.data) throw new SmplError("Unexpected empty response from audit");
|
|
19902
|
+
return _forwarderFromResource(data.data);
|
|
19903
|
+
}
|
|
19904
|
+
async delete(forwarderId) {
|
|
19905
|
+
try {
|
|
19906
|
+
const result = await this._http.DELETE("/api/v1/forwarders/{forwarder_id}", {
|
|
19907
|
+
params: { path: { forwarder_id: forwarderId } }
|
|
19908
|
+
});
|
|
19909
|
+
if (result.response.status !== 204) await checkError4(result.response);
|
|
19910
|
+
} catch (err) {
|
|
19911
|
+
wrapFetchError4(err);
|
|
19912
|
+
}
|
|
19913
|
+
}
|
|
19914
|
+
};
|
|
19915
|
+
var ManagementAuditClient = class {
|
|
19916
|
+
/** SIEM forwarder CRUD. */
|
|
19917
|
+
forwarders;
|
|
19918
|
+
/** @internal */
|
|
19919
|
+
constructor(http) {
|
|
19920
|
+
this.forwarders = new ForwardersClient(http);
|
|
19921
|
+
}
|
|
19922
|
+
};
|
|
19923
|
+
|
|
19957
19924
|
// src/config.ts
|
|
19958
19925
|
import { readFileSync } from "fs";
|
|
19959
19926
|
import { homedir } from "os";
|
|
@@ -20095,11 +20062,11 @@ function splitContextId(idOrType, key) {
|
|
|
20095
20062
|
}
|
|
20096
20063
|
return [idOrType, key];
|
|
20097
20064
|
}
|
|
20098
|
-
async function
|
|
20065
|
+
async function checkError5(response) {
|
|
20099
20066
|
const body = await response.text().catch(() => "");
|
|
20100
20067
|
throwForStatus(response.status, body);
|
|
20101
20068
|
}
|
|
20102
|
-
function
|
|
20069
|
+
function wrapFetchError5(err) {
|
|
20103
20070
|
if (err instanceof SmplError) throw err;
|
|
20104
20071
|
if (err instanceof TypeError) {
|
|
20105
20072
|
throw new SmplConnectionError(`Network error: ${err.message}`);
|
|
@@ -20182,10 +20149,10 @@ var EnvironmentsClient = class {
|
|
|
20182
20149
|
let data;
|
|
20183
20150
|
try {
|
|
20184
20151
|
const result = await this._http.GET("/api/v1/environments", {});
|
|
20185
|
-
if (!result.response.ok) await
|
|
20152
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20186
20153
|
data = result.data;
|
|
20187
20154
|
} catch (err) {
|
|
20188
|
-
|
|
20155
|
+
wrapFetchError5(err);
|
|
20189
20156
|
}
|
|
20190
20157
|
const items = data?.data ?? [];
|
|
20191
20158
|
return items.map((r) => envFromResource(r, this));
|
|
@@ -20196,10 +20163,10 @@ var EnvironmentsClient = class {
|
|
|
20196
20163
|
const result = await this._http.GET("/api/v1/environments/{id}", {
|
|
20197
20164
|
params: { path: { id } }
|
|
20198
20165
|
});
|
|
20199
|
-
if (!result.response.ok) await
|
|
20166
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20200
20167
|
data = result.data;
|
|
20201
20168
|
} catch (err) {
|
|
20202
|
-
|
|
20169
|
+
wrapFetchError5(err);
|
|
20203
20170
|
}
|
|
20204
20171
|
if (!data?.data)
|
|
20205
20172
|
throw new SmplNotFoundError(`Environment with id ${JSON.stringify(id)} not found`);
|
|
@@ -20211,10 +20178,10 @@ var EnvironmentsClient = class {
|
|
|
20211
20178
|
params: { path: { id } }
|
|
20212
20179
|
});
|
|
20213
20180
|
if (!result.response.ok && result.response.status !== 204) {
|
|
20214
|
-
await
|
|
20181
|
+
await checkError5(result.response);
|
|
20215
20182
|
}
|
|
20216
20183
|
} catch (err) {
|
|
20217
|
-
|
|
20184
|
+
wrapFetchError5(err);
|
|
20218
20185
|
}
|
|
20219
20186
|
}
|
|
20220
20187
|
/** @internal */
|
|
@@ -20233,10 +20200,10 @@ var EnvironmentsClient = class {
|
|
|
20233
20200
|
let data;
|
|
20234
20201
|
try {
|
|
20235
20202
|
const result = await this._http.POST("/api/v1/environments", { body });
|
|
20236
|
-
if (!result.response.ok) await
|
|
20203
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20237
20204
|
data = result.data;
|
|
20238
20205
|
} catch (err) {
|
|
20239
|
-
|
|
20206
|
+
wrapFetchError5(err);
|
|
20240
20207
|
}
|
|
20241
20208
|
if (!data?.data) throw new SmplValidationError("Failed to create environment");
|
|
20242
20209
|
return envFromResource(data.data, this);
|
|
@@ -20261,10 +20228,10 @@ var EnvironmentsClient = class {
|
|
|
20261
20228
|
params: { path: { id: env.id } },
|
|
20262
20229
|
body
|
|
20263
20230
|
});
|
|
20264
|
-
if (!result.response.ok) await
|
|
20231
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20265
20232
|
data = result.data;
|
|
20266
20233
|
} catch (err) {
|
|
20267
|
-
|
|
20234
|
+
wrapFetchError5(err);
|
|
20268
20235
|
}
|
|
20269
20236
|
if (!data?.data) throw new SmplValidationError(`Failed to update environment ${env.id}`);
|
|
20270
20237
|
return envFromResource(data.data, this);
|
|
@@ -20293,10 +20260,10 @@ var ContextTypesClient = class {
|
|
|
20293
20260
|
let data;
|
|
20294
20261
|
try {
|
|
20295
20262
|
const result = await this._http.GET("/api/v1/context_types", {});
|
|
20296
|
-
if (!result.response.ok) await
|
|
20263
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20297
20264
|
data = result.data;
|
|
20298
20265
|
} catch (err) {
|
|
20299
|
-
|
|
20266
|
+
wrapFetchError5(err);
|
|
20300
20267
|
}
|
|
20301
20268
|
const items = data?.data ?? [];
|
|
20302
20269
|
return items.map((r) => ctFromResource(r, this));
|
|
@@ -20307,10 +20274,10 @@ var ContextTypesClient = class {
|
|
|
20307
20274
|
const result = await this._http.GET("/api/v1/context_types/{id}", {
|
|
20308
20275
|
params: { path: { id } }
|
|
20309
20276
|
});
|
|
20310
|
-
if (!result.response.ok) await
|
|
20277
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20311
20278
|
data = result.data;
|
|
20312
20279
|
} catch (err) {
|
|
20313
|
-
|
|
20280
|
+
wrapFetchError5(err);
|
|
20314
20281
|
}
|
|
20315
20282
|
if (!data?.data)
|
|
20316
20283
|
throw new SmplNotFoundError(`ContextType with id ${JSON.stringify(id)} not found`);
|
|
@@ -20322,10 +20289,10 @@ var ContextTypesClient = class {
|
|
|
20322
20289
|
params: { path: { id } }
|
|
20323
20290
|
});
|
|
20324
20291
|
if (!result.response.ok && result.response.status !== 204) {
|
|
20325
|
-
await
|
|
20292
|
+
await checkError5(result.response);
|
|
20326
20293
|
}
|
|
20327
20294
|
} catch (err) {
|
|
20328
|
-
|
|
20295
|
+
wrapFetchError5(err);
|
|
20329
20296
|
}
|
|
20330
20297
|
}
|
|
20331
20298
|
/** @internal */
|
|
@@ -20343,10 +20310,10 @@ var ContextTypesClient = class {
|
|
|
20343
20310
|
let data;
|
|
20344
20311
|
try {
|
|
20345
20312
|
const result = await this._http.POST("/api/v1/context_types", { body });
|
|
20346
|
-
if (!result.response.ok) await
|
|
20313
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20347
20314
|
data = result.data;
|
|
20348
20315
|
} catch (err) {
|
|
20349
|
-
|
|
20316
|
+
wrapFetchError5(err);
|
|
20350
20317
|
}
|
|
20351
20318
|
if (!data?.data) throw new SmplValidationError("Failed to create context type");
|
|
20352
20319
|
return ctFromResource(data.data, this);
|
|
@@ -20370,10 +20337,10 @@ var ContextTypesClient = class {
|
|
|
20370
20337
|
params: { path: { id: ct.id } },
|
|
20371
20338
|
body
|
|
20372
20339
|
});
|
|
20373
|
-
if (!result.response.ok) await
|
|
20340
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20374
20341
|
data = result.data;
|
|
20375
20342
|
} catch (err) {
|
|
20376
|
-
|
|
20343
|
+
wrapFetchError5(err);
|
|
20377
20344
|
}
|
|
20378
20345
|
if (!data?.data) throw new SmplValidationError(`Failed to update context type ${ct.id}`);
|
|
20379
20346
|
return ctFromResource(data.data, this);
|
|
@@ -20449,9 +20416,9 @@ var ContextsClient = class {
|
|
|
20449
20416
|
}))
|
|
20450
20417
|
}
|
|
20451
20418
|
});
|
|
20452
|
-
if (!result.response.ok) await
|
|
20419
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20453
20420
|
} catch (err) {
|
|
20454
|
-
|
|
20421
|
+
wrapFetchError5(err);
|
|
20455
20422
|
}
|
|
20456
20423
|
}
|
|
20457
20424
|
/** Number of contexts awaiting flush. */
|
|
@@ -20465,10 +20432,10 @@ var ContextsClient = class {
|
|
|
20465
20432
|
const result = await this._http.GET("/api/v1/contexts", {
|
|
20466
20433
|
params: { query: { "filter[context_type]": type } }
|
|
20467
20434
|
});
|
|
20468
|
-
if (!result.response.ok) await
|
|
20435
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20469
20436
|
data = result.data;
|
|
20470
20437
|
} catch (err) {
|
|
20471
|
-
|
|
20438
|
+
wrapFetchError5(err);
|
|
20472
20439
|
}
|
|
20473
20440
|
const items = data?.data ?? [];
|
|
20474
20441
|
return items.map((r) => ctxFromResource(r, this));
|
|
@@ -20482,10 +20449,10 @@ var ContextsClient = class {
|
|
|
20482
20449
|
const result = await this._http.GET("/api/v1/contexts/{id}", {
|
|
20483
20450
|
params: { path: { id: composite } }
|
|
20484
20451
|
});
|
|
20485
|
-
if (!result.response.ok) await
|
|
20452
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20486
20453
|
data = result.data;
|
|
20487
20454
|
} catch (err) {
|
|
20488
|
-
|
|
20455
|
+
wrapFetchError5(err);
|
|
20489
20456
|
}
|
|
20490
20457
|
if (!data?.data)
|
|
20491
20458
|
throw new SmplNotFoundError(`Context with id ${JSON.stringify(composite)} not found`);
|
|
@@ -20500,10 +20467,10 @@ var ContextsClient = class {
|
|
|
20500
20467
|
params: { path: { id: composite } }
|
|
20501
20468
|
});
|
|
20502
20469
|
if (!result.response.ok && result.response.status !== 204) {
|
|
20503
|
-
await
|
|
20470
|
+
await checkError5(result.response);
|
|
20504
20471
|
}
|
|
20505
20472
|
} catch (err) {
|
|
20506
|
-
|
|
20473
|
+
wrapFetchError5(err);
|
|
20507
20474
|
}
|
|
20508
20475
|
}
|
|
20509
20476
|
/** @internal — called by `Context.save()`. */
|
|
@@ -20530,10 +20497,10 @@ var ContextsClient = class {
|
|
|
20530
20497
|
params: { path: { id: ctx.id } },
|
|
20531
20498
|
body
|
|
20532
20499
|
});
|
|
20533
|
-
if (!result.response.ok) await
|
|
20500
|
+
if (!result.response.ok) await checkError5(result.response);
|
|
20534
20501
|
data = result.data;
|
|
20535
20502
|
} catch (err) {
|
|
20536
|
-
|
|
20503
|
+
wrapFetchError5(err);
|
|
20537
20504
|
}
|
|
20538
20505
|
if (!data?.data) throw new SmplValidationError(`Failed to save context ${ctx.id}`);
|
|
20539
20506
|
return ctxFromResource(data.data, this);
|
|
@@ -20607,6 +20574,8 @@ var SmplManagementClient = class {
|
|
|
20607
20574
|
loggers;
|
|
20608
20575
|
/** Log group CRUD. */
|
|
20609
20576
|
logGroups;
|
|
20577
|
+
/** Audit SIEM forwarder CRUD. */
|
|
20578
|
+
audit;
|
|
20610
20579
|
/** @internal — shared HTTP transports (so SmplClient can alias them). */
|
|
20611
20580
|
_appHttp;
|
|
20612
20581
|
/** @internal */
|
|
@@ -20626,6 +20595,7 @@ var SmplManagementClient = class {
|
|
|
20626
20595
|
this.flags = this._flagsRef;
|
|
20627
20596
|
this.loggers = this._loggersRef;
|
|
20628
20597
|
this.logGroups = this._logGroupsRef;
|
|
20598
|
+
this.audit = this._auditRef;
|
|
20629
20599
|
this._appHttp = this._appHttpRef;
|
|
20630
20600
|
this._configHttp = this._configHttpRef;
|
|
20631
20601
|
this._flagsHttp = this._flagsHttpRef;
|
|
@@ -20641,6 +20611,7 @@ var SmplManagementClient = class {
|
|
|
20641
20611
|
_flagsRef;
|
|
20642
20612
|
_loggersRef;
|
|
20643
20613
|
_logGroupsRef;
|
|
20614
|
+
_auditRef;
|
|
20644
20615
|
_appHttpRef;
|
|
20645
20616
|
_configHttpRef;
|
|
20646
20617
|
_flagsHttpRef;
|
|
@@ -20651,10 +20622,16 @@ var SmplManagementClient = class {
|
|
|
20651
20622
|
const configBaseUrl = serviceUrl(cfg.scheme, "config", cfg.baseDomain);
|
|
20652
20623
|
const flagsBaseUrl = serviceUrl(cfg.scheme, "flags", cfg.baseDomain);
|
|
20653
20624
|
const loggingBaseUrl = serviceUrl(cfg.scheme, "logging", cfg.baseDomain);
|
|
20625
|
+
const auditBaseUrl = serviceUrl(cfg.scheme, "audit", cfg.baseDomain);
|
|
20654
20626
|
const headers = {
|
|
20655
20627
|
Authorization: `Bearer ${cfg.apiKey}`,
|
|
20656
20628
|
Accept: "application/json"
|
|
20657
20629
|
};
|
|
20630
|
+
const auditHeaders = {
|
|
20631
|
+
Authorization: `Bearer ${cfg.apiKey}`,
|
|
20632
|
+
Accept: "application/vnd.api+json",
|
|
20633
|
+
"Content-Type": "application/vnd.api+json"
|
|
20634
|
+
};
|
|
20658
20635
|
this._appHttpRef = createClient3({
|
|
20659
20636
|
baseUrl: appBaseUrl,
|
|
20660
20637
|
headers
|
|
@@ -20671,6 +20648,10 @@ var SmplManagementClient = class {
|
|
|
20671
20648
|
baseUrl: loggingBaseUrl,
|
|
20672
20649
|
headers
|
|
20673
20650
|
});
|
|
20651
|
+
const auditHttpRef = createClient3({
|
|
20652
|
+
baseUrl: auditBaseUrl,
|
|
20653
|
+
headers: auditHeaders
|
|
20654
|
+
});
|
|
20674
20655
|
this._sharedContextBuffer = new ContextRegistrationBuffer();
|
|
20675
20656
|
this._environmentsRef = new EnvironmentsClient(this._appHttpRef);
|
|
20676
20657
|
this._contextTypesRef = new ContextTypesClient(this._appHttpRef);
|
|
@@ -20680,6 +20661,7 @@ var SmplManagementClient = class {
|
|
|
20680
20661
|
this._flagsRef = new ManagementFlagsClient(this._flagsHttpRef);
|
|
20681
20662
|
this._loggersRef = new LoggersClient(this._loggingHttpRef);
|
|
20682
20663
|
this._logGroupsRef = new LogGroupsClient(this._loggingHttpRef);
|
|
20664
|
+
this._auditRef = new ManagementAuditClient(auditHttpRef);
|
|
20683
20665
|
}
|
|
20684
20666
|
/** @internal — used by SmplClient to share the buffer. */
|
|
20685
20667
|
get _contextBuffer() {
|
|
@@ -20703,11 +20685,11 @@ var CACHE_MAX_SIZE = 1e4;
|
|
|
20703
20685
|
var CONTEXT_BATCH_FLUSH_SIZE2 = 100;
|
|
20704
20686
|
var FLAG_REGISTRATION_FLUSH_SIZE2 = 50;
|
|
20705
20687
|
var FLAG_REGISTRATION_FLUSH_INTERVAL_MS = 3e4;
|
|
20706
|
-
async function
|
|
20688
|
+
async function checkError6(response, _context) {
|
|
20707
20689
|
const body = await response.text().catch(() => "");
|
|
20708
20690
|
throwForStatus(response.status, body);
|
|
20709
20691
|
}
|
|
20710
|
-
function
|
|
20692
|
+
function wrapFetchError6(err) {
|
|
20711
20693
|
if (err instanceof SmplNotFoundError || err instanceof SmplConflictError || err instanceof SmplValidationError || err instanceof SmplError) {
|
|
20712
20694
|
throw err;
|
|
20713
20695
|
}
|
|
@@ -21483,10 +21465,10 @@ var FlagsClient = class {
|
|
|
21483
21465
|
let data;
|
|
21484
21466
|
try {
|
|
21485
21467
|
const result = await this._http.GET("/api/v1/flags", {});
|
|
21486
|
-
if (!result.response.ok) await
|
|
21468
|
+
if (!result.response.ok) await checkError6(result.response, "Failed to list flags");
|
|
21487
21469
|
data = result.data;
|
|
21488
21470
|
} catch (err) {
|
|
21489
|
-
|
|
21471
|
+
wrapFetchError6(err);
|
|
21490
21472
|
}
|
|
21491
21473
|
if (!data) return [];
|
|
21492
21474
|
const flags = data.data.map((r) => this._resourceToPlainDict(r));
|
|
@@ -22951,6 +22933,7 @@ export {
|
|
|
22951
22933
|
AccountSettings,
|
|
22952
22934
|
AccountSettingsClient,
|
|
22953
22935
|
AuditClient,
|
|
22936
|
+
ForwardersClient as AuditForwardersClient,
|
|
22954
22937
|
BooleanFlag,
|
|
22955
22938
|
Color,
|
|
22956
22939
|
Config,
|
|
@@ -22982,6 +22965,7 @@ export {
|
|
|
22982
22965
|
LoggerEnvironment,
|
|
22983
22966
|
LoggerSource,
|
|
22984
22967
|
LoggingClient,
|
|
22968
|
+
ManagementAuditClient,
|
|
22985
22969
|
NumberFlag,
|
|
22986
22970
|
Op,
|
|
22987
22971
|
PinoAdapter,
|
|
@@ -22993,12 +22977,14 @@ export {
|
|
|
22993
22977
|
SmplError,
|
|
22994
22978
|
SmplManagementClient,
|
|
22995
22979
|
SmplNotFoundError,
|
|
22980
|
+
SmplPaymentRequiredError,
|
|
22996
22981
|
SmplTimeoutError,
|
|
22997
22982
|
SmplValidationError,
|
|
22998
22983
|
SmplConflictError as SmplkitConflictError,
|
|
22999
22984
|
SmplConnectionError as SmplkitConnectionError,
|
|
23000
22985
|
SmplError as SmplkitError,
|
|
23001
22986
|
SmplNotFoundError as SmplkitNotFoundError,
|
|
22987
|
+
SmplPaymentRequiredError as SmplkitPaymentRequiredError,
|
|
23002
22988
|
SmplTimeoutError as SmplkitTimeoutError,
|
|
23003
22989
|
SmplValidationError as SmplkitValidationError,
|
|
23004
22990
|
StringFlag,
|