polytomic 25.9.3 → 25.9.5

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 (183) hide show
  1. package/BaseClient.d.ts +15 -0
  2. package/BaseClient.js +17 -2
  3. package/Client.d.ts +3 -0
  4. package/Client.js +41 -36
  5. package/api/errors/BadGatewayError.d.ts +1 -0
  6. package/api/errors/BadGatewayError.js +1 -1
  7. package/api/errors/BadRequestError.d.ts +1 -0
  8. package/api/errors/BadRequestError.js +1 -1
  9. package/api/errors/ConflictError.d.ts +1 -0
  10. package/api/errors/ConflictError.js +1 -1
  11. package/api/errors/ForbiddenError.d.ts +1 -0
  12. package/api/errors/ForbiddenError.js +1 -1
  13. package/api/errors/GatewayTimeoutError.d.ts +1 -0
  14. package/api/errors/GatewayTimeoutError.js +1 -1
  15. package/api/errors/GoneError.d.ts +7 -0
  16. package/api/errors/GoneError.js +54 -0
  17. package/api/errors/InternalServerError.d.ts +1 -0
  18. package/api/errors/InternalServerError.js +1 -1
  19. package/api/errors/NotFoundError.d.ts +1 -0
  20. package/api/errors/NotFoundError.js +1 -1
  21. package/api/errors/RequestTimeoutError.d.ts +1 -0
  22. package/api/errors/RequestTimeoutError.js +1 -1
  23. package/api/errors/ServiceUnavailableError.d.ts +1 -0
  24. package/api/errors/ServiceUnavailableError.js +1 -1
  25. package/api/errors/TooManyRequestsError.d.ts +1 -0
  26. package/api/errors/TooManyRequestsError.js +1 -1
  27. package/api/errors/UnauthorizedError.d.ts +1 -0
  28. package/api/errors/UnauthorizedError.js +1 -1
  29. package/api/errors/UnprocessableEntityError.d.ts +1 -0
  30. package/api/errors/UnprocessableEntityError.js +1 -1
  31. package/api/errors/index.d.ts +1 -0
  32. package/api/errors/index.js +1 -0
  33. package/api/resources/activity/client/Client.d.ts +144 -0
  34. package/api/resources/activity/client/Client.js +359 -0
  35. package/api/resources/activity/client/index.d.ts +1 -0
  36. package/api/resources/activity/client/index.js +17 -0
  37. package/api/resources/activity/client/requests/ActivityGetSessionRequest.d.ts +17 -0
  38. package/api/resources/activity/client/requests/ActivityGetSessionRequest.js +3 -0
  39. package/api/resources/activity/client/requests/ActivityListRequest.d.ts +47 -0
  40. package/api/resources/activity/client/requests/ActivityListRequest.js +3 -0
  41. package/api/resources/activity/client/requests/index.d.ts +2 -0
  42. package/api/resources/activity/client/requests/index.js +2 -0
  43. package/api/resources/activity/exports.d.ts +2 -0
  44. package/api/resources/activity/exports.js +21 -0
  45. package/api/resources/activity/index.d.ts +2 -0
  46. package/api/resources/activity/index.js +18 -0
  47. package/api/resources/activity/types/ActivityGetSessionRequestOrder.d.ts +6 -0
  48. package/api/resources/activity/types/ActivityGetSessionRequestOrder.js +9 -0
  49. package/api/resources/activity/types/ActivityListRequestOrder.d.ts +6 -0
  50. package/api/resources/activity/types/ActivityListRequestOrder.js +9 -0
  51. package/api/resources/activity/types/index.d.ts +2 -0
  52. package/api/resources/activity/types/index.js +18 -0
  53. package/api/resources/bulkSync/client/Client.d.ts +22 -0
  54. package/api/resources/bulkSync/client/Client.js +27 -4
  55. package/api/resources/bulkSync/resources/errorHandling/client/Client.d.ts +4 -0
  56. package/api/resources/bulkSync/resources/errorHandling/client/Client.js +6 -1
  57. package/api/resources/bulkSync/resources/errorHandling/client/requests/UpdateBulkSyncErrorHandlingRequest.d.ts +2 -0
  58. package/api/resources/bulkSync/resources/executions/client/Client.d.ts +18 -0
  59. package/api/resources/bulkSync/resources/executions/client/Client.js +18 -0
  60. package/api/resources/bulkSync/resources/schedules/client/Client.d.ts +10 -0
  61. package/api/resources/bulkSync/resources/schedules/client/Client.js +13 -2
  62. package/api/resources/bulkSync/resources/schemas/client/Client.d.ts +10 -0
  63. package/api/resources/bulkSync/resources/schemas/client/Client.js +13 -2
  64. package/api/resources/bulkSync/resources/schemas/client/requests/SchemasListRequest.d.ts +1 -1
  65. package/api/resources/connections/client/Client.d.ts +38 -0
  66. package/api/resources/connections/client/Client.js +48 -5
  67. package/api/resources/connections/resources/proxy/client/Client.d.ts +8 -0
  68. package/api/resources/connections/resources/proxy/client/Client.js +11 -2
  69. package/api/resources/connections/resources/sharedConnections/client/Client.d.ts +6 -0
  70. package/api/resources/connections/resources/sharedConnections/client/Client.js +8 -1
  71. package/api/resources/entities/client/Client.d.ts +4 -0
  72. package/api/resources/entities/client/Client.js +4 -0
  73. package/api/resources/events/client/Client.d.ts +5 -0
  74. package/api/resources/events/client/Client.js +5 -0
  75. package/api/resources/harbors/client/Client.d.ts +71 -64
  76. package/api/resources/harbors/client/Client.js +81 -73
  77. package/api/resources/identity/client/Client.d.ts +2 -0
  78. package/api/resources/identity/client/Client.js +2 -0
  79. package/api/resources/index.d.ts +3 -0
  80. package/api/resources/index.js +4 -1
  81. package/api/resources/jobs/client/Client.d.ts +2 -0
  82. package/api/resources/jobs/client/Client.js +2 -0
  83. package/api/resources/modelSync/client/Client.d.ts +24 -0
  84. package/api/resources/modelSync/client/Client.js +29 -4
  85. package/api/resources/modelSync/client/requests/ModelSyncGetSourceFieldsRequest.d.ts +1 -1
  86. package/api/resources/modelSync/client/requests/ModelSyncGetSourceRequest.d.ts +1 -1
  87. package/api/resources/modelSync/resources/errorHandling/client/Client.d.ts +4 -0
  88. package/api/resources/modelSync/resources/errorHandling/client/Client.js +6 -1
  89. package/api/resources/modelSync/resources/executions/client/Client.d.ts +14 -0
  90. package/api/resources/modelSync/resources/executions/client/Client.js +14 -0
  91. package/api/resources/modelSync/resources/targets/client/Client.d.ts +6 -0
  92. package/api/resources/modelSync/resources/targets/client/Client.js +6 -0
  93. package/api/resources/modelSync/resources/targets/client/requests/TargetsGetTargetFieldsRequest.d.ts +1 -1
  94. package/api/resources/models/client/Client.d.ts +18 -0
  95. package/api/resources/models/client/Client.js +23 -4
  96. package/api/resources/models/client/requests/ModelsGetEnrichmentSourceRequest.d.ts +1 -1
  97. package/api/resources/notifications/client/Client.d.ts +4 -0
  98. package/api/resources/notifications/client/Client.js +6 -1
  99. package/api/resources/organization/client/Client.d.ts +16 -0
  100. package/api/resources/organization/client/Client.js +20 -3
  101. package/api/resources/permissions/resources/policies/client/Client.d.ts +10 -0
  102. package/api/resources/permissions/resources/policies/client/Client.js +13 -2
  103. package/api/resources/permissions/resources/roles/client/Client.d.ts +10 -0
  104. package/api/resources/permissions/resources/roles/client/Client.js +13 -2
  105. package/api/resources/queryRunner/client/Client.d.ts +15 -1
  106. package/api/resources/queryRunner/client/Client.js +35 -4
  107. package/api/resources/queryRunner/client/requests/QueryRunnerGetQueryRequest.d.ts +2 -0
  108. package/api/resources/queryRunner/client/requests/RunQueryRequest.d.ts +2 -0
  109. package/api/resources/recordViewLinks/client/Client.d.ts +6 -4
  110. package/api/resources/recordViewLinks/client/Client.js +26 -5
  111. package/api/resources/recordViewLinks/client/requests/CreateRecordViewLinkRequest.d.ts +2 -0
  112. package/api/resources/schemas/client/Client.d.ts +18 -0
  113. package/api/resources/schemas/client/Client.js +22 -3
  114. package/api/resources/temporaryCredentials/client/Client.d.ts +2 -2
  115. package/api/resources/temporaryCredentials/client/Client.js +4 -3
  116. package/api/resources/users/client/Client.d.ts +22 -0
  117. package/api/resources/users/client/Client.js +27 -4
  118. package/api/resources/webhooks/client/Client.d.ts +14 -0
  119. package/api/resources/webhooks/client/Client.js +17 -2
  120. package/api/types/BulkSyncErrorHandling.d.ts +2 -0
  121. package/api/types/ConnectionParameterValuesResponseEnvelope.d.ts +1 -1
  122. package/api/types/ConnectionProxyResponse.d.ts +1 -1
  123. package/api/types/Filter.d.ts +1 -0
  124. package/api/types/HarborActivityEventEnvelope.d.ts +4 -0
  125. package/api/types/HarborActivityEventEnvelope.js +3 -0
  126. package/api/types/HarborActivityListEnvelope.d.ts +5 -0
  127. package/api/types/HarborActivityListEnvelope.js +3 -0
  128. package/api/types/HarborActivitySessionEnvelope.d.ts +5 -0
  129. package/api/types/HarborActivitySessionEnvelope.js +3 -0
  130. package/api/types/HarborPipelineStatusResponse.d.ts +1 -1
  131. package/api/types/HarborSourceMappingResponse.d.ts +1 -1
  132. package/api/types/HarboractivityapiHarborActivityActorSnapshot.d.ts +6 -0
  133. package/api/types/HarboractivityapiHarborActivityActorSnapshot.js +3 -0
  134. package/api/types/HarboractivityapiHarborActivityEvent.d.ts +24 -0
  135. package/api/types/HarboractivityapiHarborActivityEvent.js +3 -0
  136. package/api/types/HarboractivityapiHarborActivityIdentitySnapshot.d.ts +3 -0
  137. package/api/types/HarboractivityapiHarborActivityIdentitySnapshot.js +3 -0
  138. package/api/types/HarboractivityapiHarborActivityMetadata.d.ts +31 -0
  139. package/api/types/HarboractivityapiHarborActivityMetadata.js +3 -0
  140. package/api/types/HarboractivityapiHarborActivitySession.d.ts +27 -0
  141. package/api/types/HarboractivityapiHarborActivitySession.js +12 -0
  142. package/api/types/HarboractivityapiHarborActivityTarget.d.ts +6 -0
  143. package/api/types/HarboractivityapiHarborActivityTarget.js +3 -0
  144. package/api/types/ModelFilterCondition.d.ts +1 -1
  145. package/api/types/ModelFilters.d.ts +1 -1
  146. package/api/types/QueryStatus.d.ts +8 -0
  147. package/api/types/QueryStatus.js +11 -0
  148. package/api/types/RunQueryResult.d.ts +2 -2
  149. package/api/types/SchemaField.d.ts +4 -0
  150. package/api/types/SupportedFilterFunction.d.ts +12 -0
  151. package/api/types/SupportedFilterFunction.js +3 -0
  152. package/api/types/SyncSourceMetaResponse.d.ts +1 -1
  153. package/api/types/TargetField.d.ts +2 -0
  154. package/api/types/TargetFilterCondition.d.ts +2 -2
  155. package/api/types/TargetFilters.d.ts +1 -1
  156. package/api/types/index.d.ts +11 -0
  157. package/api/types/index.js +11 -0
  158. package/core/auth/AuthProvider.d.ts +1 -0
  159. package/core/auth/AuthProvider.js +7 -0
  160. package/core/auth/index.d.ts +1 -1
  161. package/core/auth/index.js +3 -1
  162. package/core/fetcher/Fetcher.js +9 -92
  163. package/core/fetcher/getResponseBody.js +11 -0
  164. package/core/fetcher/makePassthroughRequest.js +26 -4
  165. package/core/fetcher/redactUrl.d.ts +2 -0
  166. package/core/fetcher/redactUrl.js +88 -0
  167. package/core/fetcher/requestWithRetries.js +4 -1
  168. package/core/fetcher/signals.js +9 -1
  169. package/core/requestBody.d.ts +12 -0
  170. package/core/requestBody.js +26 -0
  171. package/core/runtime/index.d.ts +1 -1
  172. package/core/runtime/index.js +2 -1
  173. package/core/runtime/runtime.d.ts +19 -0
  174. package/core/runtime/runtime.js +74 -2
  175. package/core/url/qs.js +2 -2
  176. package/errors/PolytomicError.d.ts +1 -0
  177. package/errors/PolytomicError.js +5 -1
  178. package/errors/PolytomicTimeoutError.d.ts +2 -2
  179. package/errors/PolytomicTimeoutError.js +40 -6
  180. package/package.json +2 -2
  181. package/reference.md +291 -1
  182. package/version.d.ts +1 -1
  183. package/version.js +1 -1
@@ -4,10 +4,10 @@ export interface TargetFilterCondition {
4
4
  field: string;
5
5
  /** Comparison this condition applies to the field's value. */
6
6
  function: Polytomic.FilterFunction;
7
- /** Handle naming this condition in 'logic'. Labels are scoped to this object, so a model condition and a target condition may share one. Optional: label every condition in the object or none of them, and an unlabelled object is labelled by position -- A, B, C -- which is how labels are always reported back. */
7
+ /** Handle naming this condition in 'logic'. A label starts with a letter or underscore and continues with letters, digits and underscores. Labels are scoped to this object, so a model condition and a target condition may share one. Optional: label every condition in the object or none of them, and an unlabelled object is labelled by position -- A, B, C -- which is how labels are always reported back. */
8
8
  label?: string | undefined;
9
9
  /** Value the field is compared against. Omitted for functions which take no value, such as 'IsNotNull'. */
10
10
  value?: unknown | undefined;
11
- /** Model field whose value the destination field is compared against, resolved separately for every record, named the way a model condition names its source. Mutually exclusive with 'value', and accepted only by destinations whose mode reports 'supports_filter_value_fields'. */
11
+ /** Model field whose value the destination field is compared against, resolved separately for every record, named the way a model condition names its source. Mutually exclusive with 'value', and accepted only by destinations reporting 'supports_filter_value_fields'. */
12
12
  value_source?: Polytomic.Source | undefined;
13
13
  }
@@ -5,6 +5,6 @@ import type * as Polytomic from "../index";
5
5
  export interface TargetFilters {
6
6
  /** Conditions a destination record must satisfy to be written. An empty list writes every matched record. */
7
7
  conditions?: Polytomic.TargetFilterCondition[] | undefined;
8
- /** Expression combining the conditions in this object by their labels; 'and', 'or', and parentheses are supported. An empty expression means every condition must be satisfied. */
8
+ /** Expression combining the conditions in this object by their labels; 'and', 'or', and parentheses are supported. The operators are not case-sensitive but the labels are, and the expression has to name every condition in this object -- a condition may be repeated, as in '(A and B) or (A and C)' -- and an expression which leaves one out is rejected. An empty expression means every condition must be satisfied. */
9
9
  logic?: string | undefined;
10
10
  }
@@ -147,7 +147,16 @@ export * from "./GetIdentityResponseSchema";
147
147
  export * from "./GetRecordViewCapabilitiesEnvelope";
148
148
  export * from "./GetSyncSourceMetaEnvelope";
149
149
  export * from "./GlobalErrorSubscribersResponse";
150
+ export * from "./HarborActivityEventEnvelope";
151
+ export * from "./HarborActivityListEnvelope";
152
+ export * from "./HarborActivitySessionEnvelope";
150
153
  export * from "./HarborApiKeyCreatedResponse";
154
+ export * from "./HarboractivityapiHarborActivityActorSnapshot";
155
+ export * from "./HarboractivityapiHarborActivityEvent";
156
+ export * from "./HarboractivityapiHarborActivityIdentitySnapshot";
157
+ export * from "./HarboractivityapiHarborActivityMetadata";
158
+ export * from "./HarboractivityapiHarborActivitySession";
159
+ export * from "./HarboractivityapiHarborActivityTarget";
151
160
  export * from "./HarborConnectionListEnvelope";
152
161
  export * from "./HarborConnectionResponse";
153
162
  export * from "./HarborConnectionSchemaEnvelope";
@@ -237,6 +246,7 @@ export * from "./PolicyAction";
237
246
  export * from "./PolicyResponse";
238
247
  export * from "./PolicyResponseEnvelope";
239
248
  export * from "./QueryResultsEnvelope";
249
+ export * from "./QueryStatus";
240
250
  export * from "./RecordLoggingSettingsEnvelope";
241
251
  export * from "./RecordLoggingSettingsResponse";
242
252
  export * from "./RecordviewCapabilities";
@@ -274,6 +284,7 @@ export * from "./SourceMeta";
274
284
  export * from "./StartSyncResponseEnvelope";
275
285
  export * from "./StartSyncResponseSchema";
276
286
  export * from "./SupportedBulkMode";
287
+ export * from "./SupportedFilterFunction";
277
288
  export * from "./SupportedMode";
278
289
  export * from "./SyncDestinationProperties";
279
290
  export * from "./SyncErrorHandling";
@@ -163,7 +163,16 @@ __exportStar(require("./GetIdentityResponseSchema"), exports);
163
163
  __exportStar(require("./GetRecordViewCapabilitiesEnvelope"), exports);
164
164
  __exportStar(require("./GetSyncSourceMetaEnvelope"), exports);
165
165
  __exportStar(require("./GlobalErrorSubscribersResponse"), exports);
166
+ __exportStar(require("./HarborActivityEventEnvelope"), exports);
167
+ __exportStar(require("./HarborActivityListEnvelope"), exports);
168
+ __exportStar(require("./HarborActivitySessionEnvelope"), exports);
166
169
  __exportStar(require("./HarborApiKeyCreatedResponse"), exports);
170
+ __exportStar(require("./HarboractivityapiHarborActivityActorSnapshot"), exports);
171
+ __exportStar(require("./HarboractivityapiHarborActivityEvent"), exports);
172
+ __exportStar(require("./HarboractivityapiHarborActivityIdentitySnapshot"), exports);
173
+ __exportStar(require("./HarboractivityapiHarborActivityMetadata"), exports);
174
+ __exportStar(require("./HarboractivityapiHarborActivitySession"), exports);
175
+ __exportStar(require("./HarboractivityapiHarborActivityTarget"), exports);
167
176
  __exportStar(require("./HarborConnectionListEnvelope"), exports);
168
177
  __exportStar(require("./HarborConnectionResponse"), exports);
169
178
  __exportStar(require("./HarborConnectionSchemaEnvelope"), exports);
@@ -253,6 +262,7 @@ __exportStar(require("./PolicyAction"), exports);
253
262
  __exportStar(require("./PolicyResponse"), exports);
254
263
  __exportStar(require("./PolicyResponseEnvelope"), exports);
255
264
  __exportStar(require("./QueryResultsEnvelope"), exports);
265
+ __exportStar(require("./QueryStatus"), exports);
256
266
  __exportStar(require("./RecordLoggingSettingsEnvelope"), exports);
257
267
  __exportStar(require("./RecordLoggingSettingsResponse"), exports);
258
268
  __exportStar(require("./RecordviewCapabilities"), exports);
@@ -290,6 +300,7 @@ __exportStar(require("./SourceMeta"), exports);
290
300
  __exportStar(require("./StartSyncResponseEnvelope"), exports);
291
301
  __exportStar(require("./StartSyncResponseSchema"), exports);
292
302
  __exportStar(require("./SupportedBulkMode"), exports);
303
+ __exportStar(require("./SupportedFilterFunction"), exports);
293
304
  __exportStar(require("./SupportedMode"), exports);
294
305
  __exportStar(require("./SyncDestinationProperties"), exports);
295
306
  __exportStar(require("./SyncErrorHandling"), exports);
@@ -5,3 +5,4 @@ export interface AuthProvider {
5
5
  endpointMetadata?: EndpointMetadata;
6
6
  }): Promise<AuthRequest>;
7
7
  }
8
+ export declare function isAuthProvider(value: unknown): value is AuthProvider;
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAuthProvider = isAuthProvider;
4
+ function isAuthProvider(value) {
5
+ return (typeof value === "object" &&
6
+ value !== null &&
7
+ "getAuthRequest" in value &&
8
+ typeof value.getAuthRequest === "function");
9
+ }
@@ -1,4 +1,4 @@
1
- export type { AuthProvider } from "./AuthProvider";
1
+ export { type AuthProvider, isAuthProvider } from "./AuthProvider";
2
2
  export type { AuthRequest } from "./AuthRequest";
3
3
  export { BasicAuth } from "./BasicAuth";
4
4
  export { BearerToken } from "./BearerToken";
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = void 0;
3
+ exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = exports.isAuthProvider = void 0;
4
+ var AuthProvider_1 = require("./AuthProvider");
5
+ Object.defineProperty(exports, "isAuthProvider", { enumerable: true, get: function () { return AuthProvider_1.isAuthProvider; } });
4
6
  var BasicAuth_1 = require("./BasicAuth");
5
7
  Object.defineProperty(exports, "BasicAuth", { enumerable: true, get: function () { return BasicAuth_1.BasicAuth; } });
6
8
  var BearerToken_1 = require("./BearerToken");
@@ -22,6 +22,7 @@ const getResponseBody_1 = require("./getResponseBody");
22
22
  const Headers_1 = require("./Headers");
23
23
  const makeRequest_1 = require("./makeRequest");
24
24
  const RawResponse_1 = require("./RawResponse");
25
+ const redactUrl_1 = require("./redactUrl");
25
26
  const requestWithRetries_1 = require("./requestWithRetries");
26
27
  const SENSITIVE_HEADERS = new Set([
27
28
  "authorization",
@@ -53,100 +54,16 @@ function redactHeaders(headers) {
53
54
  }
54
55
  return filtered;
55
56
  }
56
- const SENSITIVE_QUERY_PARAMS = new Set([
57
- "api_key",
58
- "api-key",
59
- "apikey",
60
- "token",
61
- "access_token",
62
- "access-token",
63
- "auth_token",
64
- "auth-token",
65
- "password",
66
- "passwd",
67
- "secret",
68
- "api_secret",
69
- "api-secret",
70
- "apisecret",
71
- "key",
72
- "session",
73
- "session_id",
74
- "session-id",
75
- ]);
76
57
  function redactQueryParameters(queryParameters) {
77
58
  if (queryParameters == null) {
78
59
  return undefined;
79
60
  }
80
61
  const redacted = {};
81
62
  for (const [key, value] of Object.entries(queryParameters)) {
82
- redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
63
+ redacted[key] = redactUrl_1.SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
83
64
  }
84
65
  return redacted;
85
66
  }
86
- function redactUrl(url) {
87
- const protocolIndex = url.indexOf("://");
88
- if (protocolIndex === -1)
89
- return url;
90
- const afterProtocol = protocolIndex + 3;
91
- // Find the first delimiter that marks the end of the authority section
92
- const pathStart = url.indexOf("/", afterProtocol);
93
- let queryStart = url.indexOf("?", afterProtocol);
94
- let fragmentStart = url.indexOf("#", afterProtocol);
95
- const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
96
- // Find the LAST @ before the delimiter (handles multiple @ in credentials)
97
- let atIndex = -1;
98
- for (let i = afterProtocol; i < firstDelimiter; i++) {
99
- if (url[i] === "@") {
100
- atIndex = i;
101
- }
102
- }
103
- if (atIndex !== -1) {
104
- url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
105
- }
106
- // Recalculate queryStart since url might have changed
107
- queryStart = url.indexOf("?");
108
- if (queryStart === -1)
109
- return url;
110
- fragmentStart = url.indexOf("#", queryStart);
111
- const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
112
- const queryString = url.slice(queryStart + 1, queryEnd);
113
- if (queryString.length === 0)
114
- return url;
115
- // FAST PATH: Quick check if any sensitive keywords present
116
- // Using indexOf is faster than regex for simple substring matching
117
- const lower = queryString.toLowerCase();
118
- const hasSensitive = lower.includes("token") ||
119
- lower.includes("key") ||
120
- lower.includes("password") ||
121
- lower.includes("passwd") ||
122
- lower.includes("secret") ||
123
- lower.includes("session") ||
124
- lower.includes("auth");
125
- if (!hasSensitive) {
126
- return url;
127
- }
128
- // SLOW PATH: Parse and redact
129
- const redactedParams = [];
130
- const params = queryString.split("&");
131
- for (const param of params) {
132
- const equalIndex = param.indexOf("=");
133
- if (equalIndex === -1) {
134
- redactedParams.push(param);
135
- continue;
136
- }
137
- const key = param.slice(0, equalIndex);
138
- let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
139
- if (!shouldRedact && key.includes("%")) {
140
- try {
141
- const decodedKey = decodeURIComponent(key);
142
- shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
143
- }
144
- catch (_a) { }
145
- }
146
- redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
147
- }
148
- return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
149
- }
150
67
  function getHeaders(args) {
151
68
  return __awaiter(this, void 0, void 0, function* () {
152
69
  var _a;
@@ -198,7 +115,7 @@ function fetcherImpl(args) {
198
115
  if (logger.isDebug()) {
199
116
  const metadata = {
200
117
  method: args.method,
201
- url: redactUrl(url),
118
+ url: (0, redactUrl_1.redactUrl)(url),
202
119
  headers: redactHeaders(headers),
203
120
  queryParameters: redactQueryParameters(args.queryParameters),
204
121
  hasBody: requestBody != null,
@@ -213,7 +130,7 @@ function fetcherImpl(args) {
213
130
  if (logger.isDebug()) {
214
131
  const metadata = {
215
132
  method: args.method,
216
- url: redactUrl(url),
133
+ url: (0, redactUrl_1.redactUrl)(url),
217
134
  statusCode: response.status,
218
135
  responseHeaders: redactHeaders(response.headers),
219
136
  };
@@ -231,7 +148,7 @@ function fetcherImpl(args) {
231
148
  if (logger.isError()) {
232
149
  const metadata = {
233
150
  method: args.method,
234
- url: redactUrl(url),
151
+ url: (0, redactUrl_1.redactUrl)(url),
235
152
  statusCode: response.status,
236
153
  responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
237
154
  };
@@ -253,7 +170,7 @@ function fetcherImpl(args) {
253
170
  if (logger.isError()) {
254
171
  const metadata = {
255
172
  method: args.method,
256
- url: redactUrl(url),
173
+ url: (0, redactUrl_1.redactUrl)(url),
257
174
  };
258
175
  logger.error("HTTP request was aborted", metadata);
259
176
  }
@@ -271,7 +188,7 @@ function fetcherImpl(args) {
271
188
  if (logger.isError()) {
272
189
  const metadata = {
273
190
  method: args.method,
274
- url: redactUrl(url),
191
+ url: (0, redactUrl_1.redactUrl)(url),
275
192
  timeoutMs: args.timeoutMs,
276
193
  };
277
194
  logger.error("HTTP request timed out", metadata);
@@ -289,7 +206,7 @@ function fetcherImpl(args) {
289
206
  if (logger.isError()) {
290
207
  const metadata = {
291
208
  method: args.method,
292
- url: redactUrl(url),
209
+ url: (0, redactUrl_1.redactUrl)(url),
293
210
  errorMessage: error.message,
294
211
  };
295
212
  logger.error("HTTP request failed with error", metadata);
@@ -307,7 +224,7 @@ function fetcherImpl(args) {
307
224
  if (logger.isError()) {
308
225
  const metadata = {
309
226
  method: args.method,
310
- url: redactUrl(url),
227
+ url: (0, redactUrl_1.redactUrl)(url),
311
228
  error: (0, json_1.toJson)(error),
312
229
  };
313
230
  logger.error("HTTP request failed with unknown error", metadata);
@@ -12,6 +12,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getResponseBody = getResponseBody;
13
13
  const json_1 = require("../json");
14
14
  const BinaryResponse_1 = require("./BinaryResponse");
15
+ // Pins the upstream Response so undici's FinalizationRegistry can't GC it and cancel the body stream.
16
+ function retainResponse(target, response) {
17
+ Object.defineProperty(target, "__fern_response_ref", {
18
+ value: response,
19
+ enumerable: false,
20
+ configurable: true,
21
+ writable: false,
22
+ });
23
+ }
15
24
  function getResponseBody(response, responseType) {
16
25
  return __awaiter(this, void 0, void 0, function* () {
17
26
  switch (responseType) {
@@ -31,6 +40,7 @@ function getResponseBody(response, responseType) {
31
40
  },
32
41
  };
33
42
  }
43
+ retainResponse(response.body, response);
34
44
  return response.body;
35
45
  case "streaming":
36
46
  if (response.body == null) {
@@ -42,6 +52,7 @@ function getResponseBody(response, responseType) {
42
52
  },
43
53
  };
44
54
  }
55
+ retainResponse(response.body, response);
45
56
  return response.body;
46
57
  case "text":
47
58
  return yield response.text();
@@ -15,6 +15,7 @@ const join_1 = require("../url/join");
15
15
  const EndpointSupplier_1 = require("./EndpointSupplier");
16
16
  const getFetchFn_1 = require("./getFetchFn");
17
17
  const makeRequest_1 = require("./makeRequest");
18
+ const redactUrl_1 = require("./redactUrl");
18
19
  const requestWithRetries_1 = require("./requestWithRetries");
19
20
  const Supplier_1 = require("./Supplier");
20
21
  /**
@@ -79,8 +80,10 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
79
80
  }
80
81
  }
81
82
  }
82
- // Apply auth headers
83
- if (clientOptions.getAuthHeaders != null) {
83
+ // Apply auth headers, but only when the resolved URL targets the configured base URL.
84
+ // This prevents the SDK's credentials from leaking to an unrelated host when a caller
85
+ // passes an absolute cross-origin URL into the passthrough fetch escape hatch.
86
+ if (clientOptions.getAuthHeaders != null && targetsBaseUrl(fullUrl, baseUrl)) {
84
87
  const authHeaders = yield clientOptions.getAuthHeaders();
85
88
  for (const [key, value] of Object.entries(authHeaders)) {
86
89
  mergedHeaders[key.toLowerCase()] = value;
@@ -115,7 +118,7 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
115
118
  if (logger.isDebug()) {
116
119
  logger.debug("Making passthrough HTTP request", {
117
120
  method,
118
- url: fullUrl,
121
+ url: (0, redactUrl_1.redactUrl)(fullUrl),
119
122
  hasBody: body != null,
120
123
  });
121
124
  }
@@ -126,10 +129,29 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
126
129
  if (logger.isDebug()) {
127
130
  logger.debug("Passthrough HTTP request completed", {
128
131
  method,
129
- url: fullUrl,
132
+ url: (0, redactUrl_1.redactUrl)(fullUrl),
130
133
  statusCode: response.status,
131
134
  });
132
135
  }
133
136
  return response;
134
137
  });
135
138
  }
139
+ /**
140
+ * Returns true when the resolved request URL points at the same origin as the
141
+ * configured base URL. Relative paths are always joined onto the base URL, so
142
+ * they resolve to the base origin and return true. Absolute URLs only match when
143
+ * their origin equals the base origin. When there is no base URL to compare
144
+ * against, or either value is not a parseable absolute URL, this returns false so
145
+ * auth headers are not attached.
146
+ */
147
+ function targetsBaseUrl(fullUrl, baseUrl) {
148
+ if (baseUrl == null) {
149
+ return false;
150
+ }
151
+ try {
152
+ return new URL(fullUrl).origin === new URL(baseUrl).origin;
153
+ }
154
+ catch (_a) {
155
+ return false;
156
+ }
157
+ }
@@ -0,0 +1,2 @@
1
+ export declare const SENSITIVE_QUERY_PARAMS: Set<string>;
2
+ export declare function redactUrl(url: string): string;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SENSITIVE_QUERY_PARAMS = void 0;
4
+ exports.redactUrl = redactUrl;
5
+ exports.SENSITIVE_QUERY_PARAMS = new Set([
6
+ "api_key",
7
+ "api-key",
8
+ "apikey",
9
+ "token",
10
+ "access_token",
11
+ "access-token",
12
+ "auth_token",
13
+ "auth-token",
14
+ "password",
15
+ "passwd",
16
+ "secret",
17
+ "api_secret",
18
+ "api-secret",
19
+ "apisecret",
20
+ "key",
21
+ "session",
22
+ "session_id",
23
+ "session-id",
24
+ ]);
25
+ function redactUrl(url) {
26
+ const protocolIndex = url.indexOf("://");
27
+ if (protocolIndex === -1)
28
+ return url;
29
+ const afterProtocol = protocolIndex + 3;
30
+ // Find the first delimiter that marks the end of the authority section
31
+ const pathStart = url.indexOf("/", afterProtocol);
32
+ let queryStart = url.indexOf("?", afterProtocol);
33
+ let fragmentStart = url.indexOf("#", afterProtocol);
34
+ const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
35
+ // Find the LAST @ before the delimiter (handles multiple @ in credentials)
36
+ let atIndex = -1;
37
+ for (let i = afterProtocol; i < firstDelimiter; i++) {
38
+ if (url[i] === "@") {
39
+ atIndex = i;
40
+ }
41
+ }
42
+ if (atIndex !== -1) {
43
+ url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
44
+ }
45
+ // Recalculate queryStart since url might have changed
46
+ queryStart = url.indexOf("?");
47
+ if (queryStart === -1)
48
+ return url;
49
+ fragmentStart = url.indexOf("#", queryStart);
50
+ const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
51
+ const queryString = url.slice(queryStart + 1, queryEnd);
52
+ if (queryString.length === 0)
53
+ return url;
54
+ // FAST PATH: Quick check if any sensitive keywords present
55
+ // Using indexOf is faster than regex for simple substring matching
56
+ const lower = queryString.toLowerCase();
57
+ const hasSensitive = lower.includes("token") ||
58
+ lower.includes("key") ||
59
+ lower.includes("password") ||
60
+ lower.includes("passwd") ||
61
+ lower.includes("secret") ||
62
+ lower.includes("session") ||
63
+ lower.includes("auth");
64
+ if (!hasSensitive) {
65
+ return url;
66
+ }
67
+ // SLOW PATH: Parse and redact
68
+ const redactedParams = [];
69
+ const params = queryString.split("&");
70
+ for (const param of params) {
71
+ const equalIndex = param.indexOf("=");
72
+ if (equalIndex === -1) {
73
+ redactedParams.push(param);
74
+ continue;
75
+ }
76
+ const key = param.slice(0, equalIndex);
77
+ let shouldRedact = exports.SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
78
+ if (!shouldRedact && key.includes("%")) {
79
+ try {
80
+ const decodedKey = decodeURIComponent(key);
81
+ shouldRedact = exports.SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
82
+ }
83
+ catch (_a) { }
84
+ }
85
+ redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
86
+ }
87
+ return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
88
+ }
@@ -14,6 +14,9 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
14
14
  const MAX_RETRY_DELAY = 60000; // in milliseconds
15
15
  const DEFAULT_MAX_RETRIES = 2;
16
16
  const JITTER_FACTOR = 0.2; // 20% random jitter
17
+ function isRetryableStatusCode(statusCode) {
18
+ return [408, 429].includes(statusCode) || statusCode >= 500;
19
+ }
17
20
  function addPositiveJitter(delay) {
18
21
  const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
19
22
  return delay * jitterMultiplier;
@@ -53,7 +56,7 @@ function requestWithRetries(requestFn_1) {
53
56
  return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
54
57
  let response = yield requestFn();
55
58
  for (let i = 0; i < maxRetries; ++i) {
56
- if ([408, 429].includes(response.status) || response.status >= 500) {
59
+ if (isRetryableStatusCode(response.status)) {
57
60
  const delay = getRetryDelayFromHeaders(response, i);
58
61
  yield new Promise((resolve) => setTimeout(resolve, delay));
59
62
  response = yield requestFn();
@@ -14,11 +14,19 @@ function anySignal(...args) {
14
14
  for (const signal of signals) {
15
15
  if (signal.aborted) {
16
16
  controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
17
- break;
17
+ return controller.signal;
18
18
  }
19
19
  signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
20
20
  signal: controller.signal,
21
21
  });
22
+ // Re-check after adding listener: the signal may have aborted
23
+ // between the initial `signal.aborted` check and the `addEventListener`
24
+ // call above. If it did, the abort event was already dispatched and
25
+ // the listener will never fire — we must manually abort.
26
+ if (signal.aborted) {
27
+ controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
28
+ return controller.signal;
29
+ }
22
30
  }
23
31
  return controller.signal;
24
32
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Spreads caller-supplied `additionalBodyParameters` (from `requestOptions.additionalBodyParameters`)
3
+ * on top of the request body. Caller-supplied properties win over the endpoint body. When no
4
+ * additional body parameters are provided, the original body is returned unchanged so serialization
5
+ * is unaffected.
6
+ *
7
+ * The merge only applies to plain-object (JSON object) bodies. When the body is `null`/`undefined`
8
+ * the additional parameters become the body; when the body is an array or a primitive JSON value it
9
+ * is returned unchanged, since object properties cannot be spread into it. This mirrors the Python
10
+ * SDK, which only merges additional body parameters into mapping bodies.
11
+ */
12
+ export declare function mergeAdditionalBodyParameters(body: unknown, additionalBodyParameters: Record<string, unknown> | undefined): unknown;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeAdditionalBodyParameters = mergeAdditionalBodyParameters;
4
+ /**
5
+ * Spreads caller-supplied `additionalBodyParameters` (from `requestOptions.additionalBodyParameters`)
6
+ * on top of the request body. Caller-supplied properties win over the endpoint body. When no
7
+ * additional body parameters are provided, the original body is returned unchanged so serialization
8
+ * is unaffected.
9
+ *
10
+ * The merge only applies to plain-object (JSON object) bodies. When the body is `null`/`undefined`
11
+ * the additional parameters become the body; when the body is an array or a primitive JSON value it
12
+ * is returned unchanged, since object properties cannot be spread into it. This mirrors the Python
13
+ * SDK, which only merges additional body parameters into mapping bodies.
14
+ */
15
+ function mergeAdditionalBodyParameters(body, additionalBodyParameters) {
16
+ if (additionalBodyParameters == null) {
17
+ return body;
18
+ }
19
+ if (body == null) {
20
+ return Object.assign({}, additionalBodyParameters);
21
+ }
22
+ if (typeof body === "object" && !Array.isArray(body)) {
23
+ return Object.assign(Object.assign({}, body), additionalBodyParameters);
24
+ }
25
+ return body;
26
+ }
@@ -1 +1 @@
1
- export { RUNTIME } from "./runtime";
1
+ export { getUserAgent, RUNTIME } from "./runtime";
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RUNTIME = void 0;
3
+ exports.RUNTIME = exports.getUserAgent = void 0;
4
4
  var runtime_1 = require("./runtime");
5
+ Object.defineProperty(exports, "getUserAgent", { enumerable: true, get: function () { return runtime_1.getUserAgent; } });
5
6
  Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return runtime_1.RUNTIME; } });
@@ -6,4 +6,23 @@ export interface Runtime {
6
6
  type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime";
7
7
  version?: string;
8
8
  parsedVersion?: number;
9
+ /**
10
+ * The operating system the SDK is running on, when it can be determined
11
+ * (e.g. "linux", "darwin", "win32" on server runtimes). Undefined in
12
+ * environments where the OS is not observable (e.g. browsers).
13
+ */
14
+ os?: string;
15
+ /**
16
+ * The CPU architecture the SDK is running on, when it can be determined
17
+ * (e.g. "x64", "arm64" on server runtimes). Undefined in environments where
18
+ * the architecture is not observable (e.g. browsers).
19
+ */
20
+ arch?: string;
9
21
  }
22
+ /**
23
+ * Builds a structured User-Agent string of the form
24
+ * `{sdkName}/{sdkVersion} ({os}; {arch}) {runtime}/{runtimeVersion}`
25
+ * where the platform group and runtime segment are omitted gracefully when the
26
+ * underlying values cannot be determined (e.g. in a browser).
27
+ */
28
+ export declare function getUserAgent(sdkName: string, sdkVersion: string): string;