@orq-ai/node 4.16.11 → 4.16.13

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.
Files changed (112) hide show
  1. package/jsr.json +1 -1
  2. package/lib/config.d.ts +2 -2
  3. package/lib/config.js +2 -2
  4. package/models/components/reasoningpart.js +1 -1
  5. package/models/operations/createtool.js +4 -4
  6. package/models/operations/getalltools.js +4 -4
  7. package/models/operations/getv2humanevalsets.js +2 -2
  8. package/models/operations/getv2humanevalsetsid.js +2 -2
  9. package/models/operations/listdeploymentversions.js +1 -1
  10. package/models/operations/patchv2humanevalsetsid.js +2 -2
  11. package/models/operations/postv2feedbackevaluation.js +4 -4
  12. package/models/operations/postv2humanevalsets.js +2 -2
  13. package/models/operations/retrievetool.js +4 -4
  14. package/models/operations/runagent.js +1 -1
  15. package/models/operations/streamrunagent.js +1 -1
  16. package/models/operations/updatetool.js +4 -4
  17. package/package.json +8 -8
  18. package/packages/orq-rc/src/funcs/auditLogDestinationsCreate.ts +172 -0
  19. package/packages/orq-rc/src/funcs/auditLogDestinationsDelete.ts +180 -0
  20. package/packages/orq-rc/src/funcs/auditLogDestinationsGet.ts +180 -0
  21. package/packages/orq-rc/src/funcs/auditLogDestinationsList.ts +181 -0
  22. package/packages/orq-rc/src/funcs/auditLogDestinationsListDeliveries.ts +190 -0
  23. package/packages/orq-rc/src/funcs/auditLogDestinationsReplay.ts +183 -0
  24. package/packages/orq-rc/src/funcs/auditLogDestinationsRotateSecret.ts +185 -0
  25. package/packages/orq-rc/src/funcs/auditLogDestinationsTest.ts +180 -0
  26. package/packages/orq-rc/src/funcs/auditLogDestinationsUpdate.ts +183 -0
  27. package/packages/orq-rc/src/funcs/websearchSearch.ts +3 -3
  28. package/packages/orq-rc/src/lib/config.ts +2 -2
  29. package/packages/orq-rc/src/models/components/auditlogdelivery.ts +100 -0
  30. package/packages/orq-rc/src/models/components/auditlogdeliverykind.ts +18 -0
  31. package/packages/orq-rc/src/models/components/auditlogdeliverystatus.ts +24 -0
  32. package/packages/orq-rc/src/models/components/auditlogdestination.ts +83 -0
  33. package/packages/orq-rc/src/models/components/auditlogdestinationstatus.ts +23 -0
  34. package/packages/orq-rc/src/models/components/budgetalert.ts +1 -0
  35. package/packages/orq-rc/src/models/components/budgetalertrestresponse.ts +1 -0
  36. package/packages/orq-rc/src/models/components/budgetscope.ts +1 -1
  37. package/packages/orq-rc/src/models/components/budgetscoperestresponse.ts +1 -1
  38. package/packages/orq-rc/src/models/components/createauditlogdestinationrequest.ts +53 -0
  39. package/packages/orq-rc/src/models/components/createauditlogdestinationresponse.ts +45 -0
  40. package/packages/orq-rc/src/models/components/createbudgetrequest.ts +3 -3
  41. package/packages/orq-rc/src/models/components/deleteauditlogdestinationresponse.ts +27 -0
  42. package/packages/orq-rc/src/models/components/effectiveuserpermissions.ts +31 -0
  43. package/packages/orq-rc/src/models/components/getauditlogdestinationresponse.ts +35 -0
  44. package/packages/orq-rc/src/models/components/guardrailruleplugin.ts +1 -1
  45. package/packages/orq-rc/src/models/components/index.ts +18 -0
  46. package/packages/orq-rc/src/models/components/listauditlogdeliveriesresponse.ts +44 -0
  47. package/packages/orq-rc/src/models/components/listauditlogdestinationsresponse.ts +44 -0
  48. package/packages/orq-rc/src/models/components/reasoningpart.ts +1 -1
  49. package/packages/orq-rc/src/models/components/replayauditlogdeliveriesrequest.ts +42 -0
  50. package/packages/orq-rc/src/models/components/replayauditlogdeliveriesresponse.ts +41 -0
  51. package/packages/orq-rc/src/models/components/rotateauditlogdestinationsecretresponse.ts +51 -0
  52. package/packages/orq-rc/src/models/components/routingruleplugin.ts +1 -1
  53. package/packages/orq-rc/src/models/components/spansummary.ts +6 -0
  54. package/packages/orq-rc/src/models/components/testauditlogdestinationresponse.ts +35 -0
  55. package/packages/orq-rc/src/models/components/updateauditlogdestinationrequest.ts +60 -0
  56. package/packages/orq-rc/src/models/components/updateauditlogdestinationresponse.ts +35 -0
  57. package/packages/orq-rc/src/models/components/workspacecapabilities.ts +11 -0
  58. package/packages/orq-rc/src/models/operations/auditlogdestinationdelete.ts +38 -0
  59. package/packages/orq-rc/src/models/operations/auditlogdestinationget.ts +38 -0
  60. package/packages/orq-rc/src/models/operations/auditlogdestinationlist.ts +45 -0
  61. package/packages/orq-rc/src/models/operations/auditlogdestinationlistdeliveries.ts +54 -0
  62. package/packages/orq-rc/src/models/operations/auditlogdestinationreplay.ts +45 -0
  63. package/packages/orq-rc/src/models/operations/auditlogdestinationrotatesecret.ts +39 -0
  64. package/packages/orq-rc/src/models/operations/auditlogdestinationtest.ts +38 -0
  65. package/packages/orq-rc/src/models/operations/auditlogdestinationupdate.ts +45 -0
  66. package/packages/orq-rc/src/models/operations/createagentrequest.ts +4 -4
  67. package/packages/orq-rc/src/models/operations/createchatcompletion.ts +2 -2
  68. package/packages/orq-rc/src/models/operations/createcompletion.ts +2 -2
  69. package/packages/orq-rc/src/models/operations/createimage.ts +2 -2
  70. package/packages/orq-rc/src/models/operations/createimageedit.ts +2 -2
  71. package/packages/orq-rc/src/models/operations/createimagevariation.ts +2 -2
  72. package/packages/orq-rc/src/models/operations/createprompt.ts +2 -2
  73. package/packages/orq-rc/src/models/operations/creatererank.ts +2 -2
  74. package/packages/orq-rc/src/models/operations/createtool.ts +4 -4
  75. package/packages/orq-rc/src/models/operations/getallprompts.ts +1 -1
  76. package/packages/orq-rc/src/models/operations/getalltools.ts +4 -4
  77. package/packages/orq-rc/src/models/operations/getoneprompt.ts +1 -1
  78. package/packages/orq-rc/src/models/operations/getpromptversion.ts +1 -1
  79. package/packages/orq-rc/src/models/operations/getv2humanevalsets.ts +2 -2
  80. package/packages/orq-rc/src/models/operations/getv2humanevalsetsid.ts +2 -2
  81. package/packages/orq-rc/src/models/operations/index.ts +8 -0
  82. package/packages/orq-rc/src/models/operations/listagents.ts +2 -2
  83. package/packages/orq-rc/src/models/operations/listdeploymentversions.ts +1 -1
  84. package/packages/orq-rc/src/models/operations/listpromptversions.ts +1 -1
  85. package/packages/orq-rc/src/models/operations/patchv2humanevalsetsid.ts +2 -2
  86. package/packages/orq-rc/src/models/operations/postv2feedbackevaluation.ts +4 -4
  87. package/packages/orq-rc/src/models/operations/postv2humanevalsets.ts +2 -2
  88. package/packages/orq-rc/src/models/operations/retrieveagentrequest.ts +2 -2
  89. package/packages/orq-rc/src/models/operations/retrievetool.ts +4 -4
  90. package/packages/orq-rc/src/models/operations/runagent.ts +3 -3
  91. package/packages/orq-rc/src/models/operations/searchweb.ts +3 -1
  92. package/packages/orq-rc/src/models/operations/streamrunagent.ts +3 -3
  93. package/packages/orq-rc/src/models/operations/updateagent.ts +4 -4
  94. package/packages/orq-rc/src/models/operations/updateprompt.ts +2 -2
  95. package/packages/orq-rc/src/models/operations/updatetool.ts +4 -4
  96. package/packages/orq-rc/src/sdk/auditlogdestinations.ts +172 -0
  97. package/packages/orq-rc/src/sdk/sdk.ts +8 -0
  98. package/packages/orq-rc/src/sdk/websearch.ts +3 -3
  99. package/src/lib/config.ts +2 -2
  100. package/src/models/components/reasoningpart.ts +1 -1
  101. package/src/models/operations/createtool.ts +4 -4
  102. package/src/models/operations/getalltools.ts +4 -4
  103. package/src/models/operations/getv2humanevalsets.ts +2 -2
  104. package/src/models/operations/getv2humanevalsetsid.ts +2 -2
  105. package/src/models/operations/listdeploymentversions.ts +1 -1
  106. package/src/models/operations/patchv2humanevalsetsid.ts +2 -2
  107. package/src/models/operations/postv2feedbackevaluation.ts +4 -4
  108. package/src/models/operations/postv2humanevalsets.ts +2 -2
  109. package/src/models/operations/retrievetool.ts +4 -4
  110. package/src/models/operations/runagent.ts +1 -1
  111. package/src/models/operations/streamrunagent.ts +1 -1
  112. package/src/models/operations/updatetool.ts +4 -4
@@ -0,0 +1,190 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { OrqCore } from "../core.js";
6
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { OrqError } from "../models/errors/orqerror.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+
30
+ /**
31
+ * List deliveries
32
+ *
33
+ * @remarks
34
+ * Returns the delivery history of a destination, newest first, optionally filtered by status.
35
+ */
36
+ export function auditLogDestinationsListDeliveries(
37
+ client: OrqCore,
38
+ request: operations.AuditLogDestinationListDeliveriesRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ components.ListAuditLogDeliveriesResponse,
43
+ | errors.ErrorResponse
44
+ | OrqError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: OrqCore,
63
+ request: operations.AuditLogDestinationListDeliveriesRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ components.ListAuditLogDeliveriesResponse,
69
+ | errors.ErrorResponse
70
+ | OrqError
71
+ | ResponseValidationError
72
+ | ConnectionError
73
+ | RequestAbortedError
74
+ | RequestTimeoutError
75
+ | InvalidRequestError
76
+ | UnexpectedClientError
77
+ | SDKValidationError
78
+ >,
79
+ APICall,
80
+ ]
81
+ > {
82
+ const parsed = safeParse(
83
+ request,
84
+ (value) =>
85
+ operations.AuditLogDestinationListDeliveriesRequest$outboundSchema.parse(
86
+ value,
87
+ ),
88
+ "Input validation failed",
89
+ );
90
+ if (!parsed.ok) {
91
+ return [parsed, { status: "invalid" }];
92
+ }
93
+ const payload = parsed.value;
94
+ const body = null;
95
+
96
+ const pathParams = {
97
+ destination_id: encodeSimple("destination_id", payload.destination_id, {
98
+ explode: false,
99
+ charEncoding: "percent",
100
+ }),
101
+ };
102
+ const path = pathToFunc(
103
+ "/v3/audit-log-destinations/{destination_id}/deliveries",
104
+ )(pathParams);
105
+
106
+ const query = encodeFormQuery({
107
+ "ending_before": payload.ending_before,
108
+ "limit": payload.limit,
109
+ "starting_after": payload.starting_after,
110
+ "status": payload.status,
111
+ });
112
+
113
+ const headers = new Headers(compactMap({
114
+ Accept: "application/json",
115
+ }));
116
+
117
+ const secConfig = await extractSecurity(client._options.apiKey);
118
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
119
+ const requestSecurity = resolveGlobalSecurity(securityInput);
120
+
121
+ const context = {
122
+ options: client._options,
123
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
124
+ operationID: "AuditLogDestinationListDeliveries",
125
+ oAuth2Scopes: null,
126
+
127
+ resolvedSecurity: requestSecurity,
128
+
129
+ securitySource: client._options.apiKey,
130
+ retryConfig: options?.retries
131
+ || client._options.retryConfig
132
+ || { strategy: "none" },
133
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
134
+ };
135
+
136
+ const requestRes = client._createRequest(context, {
137
+ security: requestSecurity,
138
+ method: "GET",
139
+ baseURL: options?.serverURL,
140
+ path: path,
141
+ headers: headers,
142
+ query: query,
143
+ body: body,
144
+ userAgent: client._options.userAgent,
145
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 600000,
146
+ }, options);
147
+ if (!requestRes.ok) {
148
+ return [requestRes, { status: "invalid" }];
149
+ }
150
+ const req = requestRes.value;
151
+
152
+ const doResult = await client._do(req, {
153
+ context,
154
+ isErrorStatusCode: (statusCode: number) =>
155
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
156
+ retryConfig: context.retryConfig,
157
+ retryCodes: context.retryCodes,
158
+ });
159
+ if (!doResult.ok) {
160
+ return [doResult, { status: "request-error", request: req }];
161
+ }
162
+ const response = doResult.value;
163
+
164
+ const responseFields = {
165
+ HttpMeta: { Response: response, Request: req },
166
+ };
167
+
168
+ const [result] = await M.match<
169
+ components.ListAuditLogDeliveriesResponse,
170
+ | errors.ErrorResponse
171
+ | OrqError
172
+ | ResponseValidationError
173
+ | ConnectionError
174
+ | RequestAbortedError
175
+ | RequestTimeoutError
176
+ | InvalidRequestError
177
+ | UnexpectedClientError
178
+ | SDKValidationError
179
+ >(
180
+ M.json(200, components.ListAuditLogDeliveriesResponse$inboundSchema),
181
+ M.jsonErr(401, errors.ErrorResponse$inboundSchema),
182
+ M.fail("4XX"),
183
+ M.fail("5XX"),
184
+ )(response, req, { extraFields: responseFields });
185
+ if (!result.ok) {
186
+ return [result, { status: "complete", request: req, response }];
187
+ }
188
+
189
+ return [result, { status: "complete", request: req, response }];
190
+ }
@@ -0,0 +1,183 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { OrqCore } from "../core.js";
6
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { OrqError } from "../models/errors/orqerror.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+
30
+ /**
31
+ * Replay audit events
32
+ *
33
+ * @remarks
34
+ * Queues a new delivery for every retained audit event recorded in the time window, up to 10,000 events per request. Replays keep the original event IDs and never extend event retention.
35
+ */
36
+ export function auditLogDestinationsReplay(
37
+ client: OrqCore,
38
+ request: operations.AuditLogDestinationReplayRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ components.ReplayAuditLogDeliveriesResponse,
43
+ | errors.ErrorResponse
44
+ | OrqError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: OrqCore,
63
+ request: operations.AuditLogDestinationReplayRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ components.ReplayAuditLogDeliveriesResponse,
69
+ | errors.ErrorResponse
70
+ | OrqError
71
+ | ResponseValidationError
72
+ | ConnectionError
73
+ | RequestAbortedError
74
+ | RequestTimeoutError
75
+ | InvalidRequestError
76
+ | UnexpectedClientError
77
+ | SDKValidationError
78
+ >,
79
+ APICall,
80
+ ]
81
+ > {
82
+ const parsed = safeParse(
83
+ request,
84
+ (value) =>
85
+ operations.AuditLogDestinationReplayRequest$outboundSchema.parse(value),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = encodeJSON("body", payload.ReplayAuditLogDeliveriesRequest, {
93
+ explode: true,
94
+ });
95
+
96
+ const pathParams = {
97
+ destination_id: encodeSimple("destination_id", payload.destination_id, {
98
+ explode: false,
99
+ charEncoding: "percent",
100
+ }),
101
+ };
102
+ const path = pathToFunc("/v3/audit-log-destinations/{destination_id}/replay")(
103
+ pathParams,
104
+ );
105
+
106
+ const headers = new Headers(compactMap({
107
+ "Content-Type": "application/json",
108
+ Accept: "application/json",
109
+ }));
110
+
111
+ const secConfig = await extractSecurity(client._options.apiKey);
112
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
113
+ const requestSecurity = resolveGlobalSecurity(securityInput);
114
+
115
+ const context = {
116
+ options: client._options,
117
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
118
+ operationID: "AuditLogDestinationReplay",
119
+ oAuth2Scopes: null,
120
+
121
+ resolvedSecurity: requestSecurity,
122
+
123
+ securitySource: client._options.apiKey,
124
+ retryConfig: options?.retries
125
+ || client._options.retryConfig
126
+ || { strategy: "none" },
127
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
128
+ };
129
+
130
+ const requestRes = client._createRequest(context, {
131
+ security: requestSecurity,
132
+ method: "POST",
133
+ baseURL: options?.serverURL,
134
+ path: path,
135
+ headers: headers,
136
+ body: body,
137
+ userAgent: client._options.userAgent,
138
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 600000,
139
+ }, options);
140
+ if (!requestRes.ok) {
141
+ return [requestRes, { status: "invalid" }];
142
+ }
143
+ const req = requestRes.value;
144
+
145
+ const doResult = await client._do(req, {
146
+ context,
147
+ isErrorStatusCode: (statusCode: number) =>
148
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
149
+ retryConfig: context.retryConfig,
150
+ retryCodes: context.retryCodes,
151
+ });
152
+ if (!doResult.ok) {
153
+ return [doResult, { status: "request-error", request: req }];
154
+ }
155
+ const response = doResult.value;
156
+
157
+ const responseFields = {
158
+ HttpMeta: { Response: response, Request: req },
159
+ };
160
+
161
+ const [result] = await M.match<
162
+ components.ReplayAuditLogDeliveriesResponse,
163
+ | errors.ErrorResponse
164
+ | OrqError
165
+ | ResponseValidationError
166
+ | ConnectionError
167
+ | RequestAbortedError
168
+ | RequestTimeoutError
169
+ | InvalidRequestError
170
+ | UnexpectedClientError
171
+ | SDKValidationError
172
+ >(
173
+ M.json(200, components.ReplayAuditLogDeliveriesResponse$inboundSchema),
174
+ M.jsonErr(401, errors.ErrorResponse$inboundSchema),
175
+ M.fail("4XX"),
176
+ M.fail("5XX"),
177
+ )(response, req, { extraFields: responseFields });
178
+ if (!result.ok) {
179
+ return [result, { status: "complete", request: req, response }];
180
+ }
181
+
182
+ return [result, { status: "complete", request: req, response }];
183
+ }
@@ -0,0 +1,185 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { OrqCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { OrqError } from "../models/errors/orqerror.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+
30
+ /**
31
+ * Rotate the signing secret
32
+ *
33
+ * @remarks
34
+ * Generates a new signing secret for the destination. Deliveries attempted after the rotation are signed with the new secret. The new secret is returned once in this response and never again.
35
+ */
36
+ export function auditLogDestinationsRotateSecret(
37
+ client: OrqCore,
38
+ request: operations.AuditLogDestinationRotateSecretRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ components.RotateAuditLogDestinationSecretResponse,
43
+ | errors.ErrorResponse
44
+ | OrqError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: OrqCore,
63
+ request: operations.AuditLogDestinationRotateSecretRequest,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ components.RotateAuditLogDestinationSecretResponse,
69
+ | errors.ErrorResponse
70
+ | OrqError
71
+ | ResponseValidationError
72
+ | ConnectionError
73
+ | RequestAbortedError
74
+ | RequestTimeoutError
75
+ | InvalidRequestError
76
+ | UnexpectedClientError
77
+ | SDKValidationError
78
+ >,
79
+ APICall,
80
+ ]
81
+ > {
82
+ const parsed = safeParse(
83
+ request,
84
+ (value) =>
85
+ operations.AuditLogDestinationRotateSecretRequest$outboundSchema.parse(
86
+ value,
87
+ ),
88
+ "Input validation failed",
89
+ );
90
+ if (!parsed.ok) {
91
+ return [parsed, { status: "invalid" }];
92
+ }
93
+ const payload = parsed.value;
94
+ const body = null;
95
+
96
+ const pathParams = {
97
+ destination_id: encodeSimple("destination_id", payload.destination_id, {
98
+ explode: false,
99
+ charEncoding: "percent",
100
+ }),
101
+ };
102
+ const path = pathToFunc(
103
+ "/v3/audit-log-destinations/{destination_id}/rotate-secret",
104
+ )(pathParams);
105
+
106
+ const headers = new Headers(compactMap({
107
+ Accept: "application/json",
108
+ }));
109
+
110
+ const secConfig = await extractSecurity(client._options.apiKey);
111
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
112
+ const requestSecurity = resolveGlobalSecurity(securityInput);
113
+
114
+ const context = {
115
+ options: client._options,
116
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
117
+ operationID: "AuditLogDestinationRotateSecret",
118
+ oAuth2Scopes: null,
119
+
120
+ resolvedSecurity: requestSecurity,
121
+
122
+ securitySource: client._options.apiKey,
123
+ retryConfig: options?.retries
124
+ || client._options.retryConfig
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "POST",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || 600000,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ isErrorStatusCode: (statusCode: number) =>
147
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
148
+ retryConfig: context.retryConfig,
149
+ retryCodes: context.retryCodes,
150
+ });
151
+ if (!doResult.ok) {
152
+ return [doResult, { status: "request-error", request: req }];
153
+ }
154
+ const response = doResult.value;
155
+
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+
160
+ const [result] = await M.match<
161
+ components.RotateAuditLogDestinationSecretResponse,
162
+ | errors.ErrorResponse
163
+ | OrqError
164
+ | ResponseValidationError
165
+ | ConnectionError
166
+ | RequestAbortedError
167
+ | RequestTimeoutError
168
+ | InvalidRequestError
169
+ | UnexpectedClientError
170
+ | SDKValidationError
171
+ >(
172
+ M.json(
173
+ 200,
174
+ components.RotateAuditLogDestinationSecretResponse$inboundSchema,
175
+ ),
176
+ M.jsonErr(401, errors.ErrorResponse$inboundSchema),
177
+ M.fail("4XX"),
178
+ M.fail("5XX"),
179
+ )(response, req, { extraFields: responseFields });
180
+ if (!result.ok) {
181
+ return [result, { status: "complete", request: req, response }];
182
+ }
183
+
184
+ return [result, { status: "complete", request: req, response }];
185
+ }