@keystrokehq/posthog 0.0.9 → 0.0.16-integration-id-canonicalization.0
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/README.md +28 -48
- package/dist/{client.mjs → client-BZWd9-On.mjs} +195 -4
- package/dist/credential-sets/index.d.mts +2 -0
- package/dist/credential-sets/index.mjs +3 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +5 -1
- package/dist/operations/index.d.mts +2 -0
- package/dist/operations/index.mjs +3 -0
- package/dist/posthog.credential-set-C8TimFgo.d.mts +30 -0
- package/dist/posthog.credential-set-DwYnDkeD.mjs +28 -0
- package/dist/{schemas.d.mts → schemas/index.d.mts} +4 -4
- package/dist/{schemas.mjs → schemas/index.mjs} +1 -1
- package/dist/surveys-update.operation-C0MYZZ04.mjs +3836 -0
- package/dist/surveys-update.operation-gxREsmzk.d.mts +4578 -0
- package/dist/{triggers.d.mts → triggers/index.d.mts} +4 -4
- package/dist/{triggers.mjs → triggers/index.mjs} +5 -6
- package/package.json +13 -85
- package/dist/_official/index.d.mts +0 -2
- package/dist/_official/index.mjs +0 -3
- package/dist/_runtime/index.d.mts +0 -6
- package/dist/_runtime/index.mjs +0 -3
- package/dist/actions.d.mts +0 -244
- package/dist/actions.mjs +0 -129
- package/dist/annotations.d.mts +0 -185
- package/dist/annotations.mjs +0 -141
- package/dist/capture.d.mts +0 -177
- package/dist/capture.mjs +0 -241
- package/dist/client.d.mts +0 -50
- package/dist/cohorts.d.mts +0 -229
- package/dist/cohorts.mjs +0 -185
- package/dist/connection.d.mts +0 -2
- package/dist/connection.mjs +0 -3
- package/dist/dashboards.d.mts +0 -434
- package/dist/dashboards.mjs +0 -356
- package/dist/decide.d.mts +0 -74
- package/dist/decide.mjs +0 -75
- package/dist/errors.d.mts +0 -58
- package/dist/errors.mjs +0 -120
- package/dist/events-management.d.mts +0 -294
- package/dist/events-management.mjs +0 -242
- package/dist/factory-C3ssyfSy.mjs +0 -7
- package/dist/feature-flags.d.mts +0 -416
- package/dist/feature-flags.mjs +0 -317
- package/dist/http-BYcjqxPi.mjs +0 -84
- package/dist/insights.d.mts +0 -409
- package/dist/insights.mjs +0 -346
- package/dist/integration-BN7xcpga.d.mts +0 -63
- package/dist/integration-D0HdrI0T.mjs +0 -120
- package/dist/organizations.d.mts +0 -257
- package/dist/organizations.mjs +0 -219
- package/dist/persons.d.mts +0 -369
- package/dist/persons.mjs +0 -345
- package/dist/projects.d.mts +0 -348
- package/dist/projects.mjs +0 -287
- package/dist/session-recordings.d.mts +0 -391
- package/dist/session-recordings.mjs +0 -308
- package/dist/surveys.d.mts +0 -287
- package/dist/surveys.mjs +0 -208
- package/dist/webhook-management.d.mts +0 -188
- package/dist/webhook-management.mjs +0 -152
package/dist/feature-flags.mjs
DELETED
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import { createPosthogManagementClient } from "./client.mjs";
|
|
2
|
-
import { featureFlagFiltersSchema, featureFlagRoleAccessSchema, featureFlagSchema, paginatedResponseSchema, projectIdInputShape } from "./schemas.mjs";
|
|
3
|
-
import { t as posthogOperation } from "./factory-C3ssyfSy.mjs";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
//#region src/feature-flags.ts
|
|
7
|
-
/**
|
|
8
|
-
* posthog/feature-flags.ts
|
|
9
|
-
*
|
|
10
|
-
* Feature-flag management — CRUD, status changes, role access, dashboards,
|
|
11
|
-
* remote config, and activity. Uses the management client (personal API key).
|
|
12
|
-
*
|
|
13
|
-
* Docs: https://posthog.com/docs/api/feature-flags
|
|
14
|
-
*/
|
|
15
|
-
const idInput = {
|
|
16
|
-
...projectIdInputShape,
|
|
17
|
-
id: z.number().int()
|
|
18
|
-
};
|
|
19
|
-
const flagWriteShape = {
|
|
20
|
-
key: z.string().min(1),
|
|
21
|
-
name: z.string().optional(),
|
|
22
|
-
filters: featureFlagFiltersSchema.optional(),
|
|
23
|
-
active: z.boolean().optional(),
|
|
24
|
-
deleted: z.boolean().optional(),
|
|
25
|
-
rollout_percentage: z.number().nullable().optional(),
|
|
26
|
-
ensure_experience_continuity: z.boolean().optional(),
|
|
27
|
-
tags: z.array(z.string()).optional()
|
|
28
|
-
};
|
|
29
|
-
const listInput = z.object({
|
|
30
|
-
...projectIdInputShape,
|
|
31
|
-
limit: z.number().int().min(1).max(500).optional(),
|
|
32
|
-
offset: z.number().int().min(0).optional(),
|
|
33
|
-
active: z.boolean().optional(),
|
|
34
|
-
search: z.string().optional(),
|
|
35
|
-
type: z.string().optional(),
|
|
36
|
-
created_by: z.number().int().optional()
|
|
37
|
-
});
|
|
38
|
-
const listOutput = paginatedResponseSchema(featureFlagSchema);
|
|
39
|
-
const listFeatureFlags = posthogOperation({
|
|
40
|
-
id: "posthog.feature-flags-list",
|
|
41
|
-
name: "PostHog List Feature Flags",
|
|
42
|
-
description: "List feature flags for a project",
|
|
43
|
-
input: listInput,
|
|
44
|
-
output: listOutput,
|
|
45
|
-
run: async (input, credentials) => {
|
|
46
|
-
const client = createPosthogManagementClient(credentials);
|
|
47
|
-
const projectId = client.projectId(input.projectId);
|
|
48
|
-
return client.request({
|
|
49
|
-
method: "GET",
|
|
50
|
-
path: `/api/projects/${projectId}/feature_flags/`,
|
|
51
|
-
query: {
|
|
52
|
-
limit: input.limit,
|
|
53
|
-
offset: input.offset,
|
|
54
|
-
active: input.active,
|
|
55
|
-
search: input.search,
|
|
56
|
-
type: input.type,
|
|
57
|
-
created_by: input.created_by
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const getFeatureFlag = posthogOperation({
|
|
63
|
-
id: "posthog.feature-flags-get",
|
|
64
|
-
name: "PostHog Get Feature Flag",
|
|
65
|
-
description: "Retrieve a feature flag by numeric id",
|
|
66
|
-
input: z.object(idInput),
|
|
67
|
-
output: featureFlagSchema,
|
|
68
|
-
run: async (input, credentials) => {
|
|
69
|
-
const client = createPosthogManagementClient(credentials);
|
|
70
|
-
const projectId = client.projectId(input.projectId);
|
|
71
|
-
return client.request({
|
|
72
|
-
method: "GET",
|
|
73
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/`
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
const createFeatureFlag = posthogOperation({
|
|
78
|
-
id: "posthog.feature-flags-create",
|
|
79
|
-
name: "PostHog Create Feature Flag",
|
|
80
|
-
description: "Create a new feature flag",
|
|
81
|
-
input: z.object({
|
|
82
|
-
...projectIdInputShape,
|
|
83
|
-
...flagWriteShape
|
|
84
|
-
}),
|
|
85
|
-
output: featureFlagSchema,
|
|
86
|
-
needsApproval: true,
|
|
87
|
-
run: async (input, credentials) => {
|
|
88
|
-
const client = createPosthogManagementClient(credentials);
|
|
89
|
-
const projectId = client.projectId(input.projectId);
|
|
90
|
-
const { projectId: _ignored, ...body } = input;
|
|
91
|
-
return client.request({
|
|
92
|
-
method: "POST",
|
|
93
|
-
path: `/api/projects/${projectId}/feature_flags/`,
|
|
94
|
-
body
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
const updateFeatureFlag = posthogOperation({
|
|
99
|
-
id: "posthog.feature-flags-update",
|
|
100
|
-
name: "PostHog Update Feature Flag",
|
|
101
|
-
description: "Partially update a feature flag",
|
|
102
|
-
input: z.object({
|
|
103
|
-
...idInput,
|
|
104
|
-
key: z.string().min(1).optional(),
|
|
105
|
-
name: z.string().optional(),
|
|
106
|
-
filters: featureFlagFiltersSchema.optional(),
|
|
107
|
-
active: z.boolean().optional(),
|
|
108
|
-
deleted: z.boolean().optional(),
|
|
109
|
-
rollout_percentage: z.number().nullable().optional(),
|
|
110
|
-
ensure_experience_continuity: z.boolean().optional(),
|
|
111
|
-
tags: z.array(z.string()).optional()
|
|
112
|
-
}),
|
|
113
|
-
output: featureFlagSchema,
|
|
114
|
-
needsApproval: true,
|
|
115
|
-
run: async (input, credentials) => {
|
|
116
|
-
const client = createPosthogManagementClient(credentials);
|
|
117
|
-
const projectId = client.projectId(input.projectId);
|
|
118
|
-
const { projectId: _pid, id, ...body } = input;
|
|
119
|
-
return client.request({
|
|
120
|
-
method: "PATCH",
|
|
121
|
-
path: `/api/projects/${projectId}/feature_flags/${id}/`,
|
|
122
|
-
body
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
const deleteFeatureFlag = posthogOperation({
|
|
127
|
-
id: "posthog.feature-flags-delete",
|
|
128
|
-
name: "PostHog Delete Feature Flag",
|
|
129
|
-
description: "Soft-delete a feature flag",
|
|
130
|
-
input: z.object(idInput),
|
|
131
|
-
output: featureFlagSchema,
|
|
132
|
-
needsApproval: true,
|
|
133
|
-
run: async (input, credentials) => {
|
|
134
|
-
const client = createPosthogManagementClient(credentials);
|
|
135
|
-
const projectId = client.projectId(input.projectId);
|
|
136
|
-
return client.request({
|
|
137
|
-
method: "PATCH",
|
|
138
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
139
|
-
body: { deleted: true }
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
const enableFeatureFlag = posthogOperation({
|
|
144
|
-
id: "posthog.feature-flags-enable",
|
|
145
|
-
name: "PostHog Enable Feature Flag",
|
|
146
|
-
description: "Activate a feature flag",
|
|
147
|
-
input: z.object(idInput),
|
|
148
|
-
output: featureFlagSchema,
|
|
149
|
-
needsApproval: true,
|
|
150
|
-
run: async (input, credentials) => {
|
|
151
|
-
const client = createPosthogManagementClient(credentials);
|
|
152
|
-
const projectId = client.projectId(input.projectId);
|
|
153
|
-
return client.request({
|
|
154
|
-
method: "PATCH",
|
|
155
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
156
|
-
body: { active: true }
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
const disableFeatureFlag = posthogOperation({
|
|
161
|
-
id: "posthog.feature-flags-disable",
|
|
162
|
-
name: "PostHog Disable Feature Flag",
|
|
163
|
-
description: "Deactivate a feature flag",
|
|
164
|
-
input: z.object(idInput),
|
|
165
|
-
output: featureFlagSchema,
|
|
166
|
-
needsApproval: true,
|
|
167
|
-
run: async (input, credentials) => {
|
|
168
|
-
const client = createPosthogManagementClient(credentials);
|
|
169
|
-
const projectId = client.projectId(input.projectId);
|
|
170
|
-
return client.request({
|
|
171
|
-
method: "PATCH",
|
|
172
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/`,
|
|
173
|
-
body: { active: false }
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
const getFeatureFlagActivity = posthogOperation({
|
|
178
|
-
id: "posthog.feature-flags-activity",
|
|
179
|
-
name: "PostHog Feature Flag Activity",
|
|
180
|
-
description: "Fetch activity log for a feature flag",
|
|
181
|
-
input: z.object({
|
|
182
|
-
...idInput,
|
|
183
|
-
limit: z.number().int().min(1).max(200).optional()
|
|
184
|
-
}),
|
|
185
|
-
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
186
|
-
run: async (input, credentials) => {
|
|
187
|
-
const client = createPosthogManagementClient(credentials);
|
|
188
|
-
const projectId = client.projectId(input.projectId);
|
|
189
|
-
return client.request({
|
|
190
|
-
method: "GET",
|
|
191
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/activity/`,
|
|
192
|
-
query: { limit: input.limit }
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
const getMyFeatureFlags = posthogOperation({
|
|
197
|
-
id: "posthog.feature-flags-my-flags",
|
|
198
|
-
name: "PostHog My Feature Flags",
|
|
199
|
-
description: "Fetch the feature flags evaluated for the calling user",
|
|
200
|
-
input: z.object(projectIdInputShape),
|
|
201
|
-
output: z.array(z.record(z.string(), z.unknown())),
|
|
202
|
-
run: async (input, credentials) => {
|
|
203
|
-
const client = createPosthogManagementClient(credentials);
|
|
204
|
-
const projectId = client.projectId(input.projectId);
|
|
205
|
-
return client.request({
|
|
206
|
-
method: "GET",
|
|
207
|
-
path: `/api/projects/${projectId}/feature_flags/my_flags/`
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
const getFeatureFlagRoleAccess = posthogOperation({
|
|
212
|
-
id: "posthog.feature-flags-role-access-list",
|
|
213
|
-
name: "PostHog List Feature Flag Role Access",
|
|
214
|
-
description: "List role access rules for a feature flag",
|
|
215
|
-
input: z.object(idInput),
|
|
216
|
-
output: paginatedResponseSchema(featureFlagRoleAccessSchema),
|
|
217
|
-
run: async (input, credentials) => {
|
|
218
|
-
const client = createPosthogManagementClient(credentials);
|
|
219
|
-
const projectId = client.projectId(input.projectId);
|
|
220
|
-
return client.request({
|
|
221
|
-
method: "GET",
|
|
222
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/`
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
const createFeatureFlagRoleAccess = posthogOperation({
|
|
227
|
-
id: "posthog.feature-flags-role-access-create",
|
|
228
|
-
name: "PostHog Create Feature Flag Role Access",
|
|
229
|
-
description: "Grant a role access to a feature flag",
|
|
230
|
-
input: z.object({
|
|
231
|
-
...idInput,
|
|
232
|
-
role: z.number().int()
|
|
233
|
-
}),
|
|
234
|
-
output: featureFlagRoleAccessSchema,
|
|
235
|
-
needsApproval: true,
|
|
236
|
-
run: async (input, credentials) => {
|
|
237
|
-
const client = createPosthogManagementClient(credentials);
|
|
238
|
-
const projectId = client.projectId(input.projectId);
|
|
239
|
-
return client.request({
|
|
240
|
-
method: "POST",
|
|
241
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/`,
|
|
242
|
-
body: { role: input.role }
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
const deleteFeatureFlagRoleAccess = posthogOperation({
|
|
247
|
-
id: "posthog.feature-flags-role-access-delete",
|
|
248
|
-
name: "PostHog Delete Feature Flag Role Access",
|
|
249
|
-
description: "Revoke a role access rule for a feature flag",
|
|
250
|
-
input: z.object({
|
|
251
|
-
...idInput,
|
|
252
|
-
roleAccessId: z.number().int()
|
|
253
|
-
}),
|
|
254
|
-
output: z.object({ success: z.boolean() }),
|
|
255
|
-
needsApproval: true,
|
|
256
|
-
run: async (input, credentials) => {
|
|
257
|
-
const client = createPosthogManagementClient(credentials);
|
|
258
|
-
const projectId = client.projectId(input.projectId);
|
|
259
|
-
await client.request({
|
|
260
|
-
method: "DELETE",
|
|
261
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/role_access/${input.roleAccessId}/`
|
|
262
|
-
});
|
|
263
|
-
return { success: true };
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
const getFeatureFlagDashboards = posthogOperation({
|
|
267
|
-
id: "posthog.feature-flags-dashboards",
|
|
268
|
-
name: "PostHog Feature Flag Dashboards",
|
|
269
|
-
description: "Fetch dashboards linked to a feature flag",
|
|
270
|
-
input: z.object(idInput),
|
|
271
|
-
output: z.object({ results: z.array(z.record(z.string(), z.unknown())) }),
|
|
272
|
-
run: async (input, credentials) => {
|
|
273
|
-
const client = createPosthogManagementClient(credentials);
|
|
274
|
-
const projectId = client.projectId(input.projectId);
|
|
275
|
-
return client.request({
|
|
276
|
-
method: "GET",
|
|
277
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/dashboards/`
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
const getFeatureFlagRemoteConfig = posthogOperation({
|
|
282
|
-
id: "posthog.feature-flags-remote-config",
|
|
283
|
-
name: "PostHog Feature Flag Remote Config",
|
|
284
|
-
description: "Fetch the remote-config payload for a feature flag",
|
|
285
|
-
input: z.object({
|
|
286
|
-
...idInput,
|
|
287
|
-
distinctId: z.string().min(1)
|
|
288
|
-
}),
|
|
289
|
-
output: z.record(z.string(), z.unknown()),
|
|
290
|
-
run: async (input, credentials) => {
|
|
291
|
-
const client = createPosthogManagementClient(credentials);
|
|
292
|
-
const projectId = client.projectId(input.projectId);
|
|
293
|
-
return client.request({
|
|
294
|
-
method: "GET",
|
|
295
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/remote_config/`,
|
|
296
|
-
query: { distinct_id: input.distinctId }
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
const getFeatureFlagStatus = posthogOperation({
|
|
301
|
-
id: "posthog.feature-flags-status",
|
|
302
|
-
name: "PostHog Feature Flag Status",
|
|
303
|
-
description: "Fetch computed status summary for a feature flag",
|
|
304
|
-
input: z.object(idInput),
|
|
305
|
-
output: z.record(z.string(), z.unknown()),
|
|
306
|
-
run: async (input, credentials) => {
|
|
307
|
-
const client = createPosthogManagementClient(credentials);
|
|
308
|
-
const projectId = client.projectId(input.projectId);
|
|
309
|
-
return client.request({
|
|
310
|
-
method: "GET",
|
|
311
|
-
path: `/api/projects/${projectId}/feature_flags/${input.id}/status/`
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
//#endregion
|
|
317
|
-
export { createFeatureFlag, createFeatureFlagRoleAccess, deleteFeatureFlag, deleteFeatureFlagRoleAccess, disableFeatureFlag, enableFeatureFlag, getFeatureFlag, getFeatureFlagActivity, getFeatureFlagDashboards, getFeatureFlagRemoteConfig, getFeatureFlagRoleAccess, getFeatureFlagStatus, getMyFeatureFlags, listFeatureFlags, updateFeatureFlag };
|
package/dist/http-BYcjqxPi.mjs
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
//#region ../../packages/integration-authoring/dist/http.mjs
|
|
2
|
-
/**
|
|
3
|
-
* Typed error thrown by `createJsonRestClient` for non-2xx responses.
|
|
4
|
-
*
|
|
5
|
-
* Includes the full HTTP status, status text, response headers, raw body
|
|
6
|
-
* string, and request URL/method so callers can make structured decisions
|
|
7
|
-
* (retry on 5xx, map 401/403 to `CredentialRevokedError`, read
|
|
8
|
-
* `Retry-After`, etc.) instead of parsing error messages.
|
|
9
|
-
*/
|
|
10
|
-
var JsonRestError = class extends Error {
|
|
11
|
-
name = "JsonRestError";
|
|
12
|
-
status;
|
|
13
|
-
statusText;
|
|
14
|
-
body;
|
|
15
|
-
headers;
|
|
16
|
-
url;
|
|
17
|
-
method;
|
|
18
|
-
constructor(init) {
|
|
19
|
-
super(`${init.errorPrefix}: ${init.status} ${init.statusText}${init.body ? ` — ${init.body}` : ""}`);
|
|
20
|
-
this.status = init.status;
|
|
21
|
-
this.statusText = init.statusText;
|
|
22
|
-
this.body = init.body;
|
|
23
|
-
this.headers = init.headers;
|
|
24
|
-
this.url = init.url;
|
|
25
|
-
this.method = init.method;
|
|
26
|
-
}
|
|
27
|
-
/** True for 401 and 403 responses (auth / permission failures). */
|
|
28
|
-
static isAuthError(error) {
|
|
29
|
-
return isJsonRestError(error) && (error.status === 401 || error.status === 403);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Structural type guard for `JsonRestError`. Tolerates cross-realm errors by
|
|
34
|
-
* checking the `name` property instead of relying on `instanceof`.
|
|
35
|
-
*/
|
|
36
|
-
function isJsonRestError(error) {
|
|
37
|
-
if (!error || typeof error !== "object") return false;
|
|
38
|
-
const candidate = error;
|
|
39
|
-
return candidate.name === "JsonRestError" && typeof candidate.status === "number" && typeof candidate.body === "string";
|
|
40
|
-
}
|
|
41
|
-
function buildQueryString(query) {
|
|
42
|
-
if (!query) return "";
|
|
43
|
-
const params = new URLSearchParams();
|
|
44
|
-
for (const [key, value] of Object.entries(query)) if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
45
|
-
const qs = params.toString();
|
|
46
|
-
return qs ? `?${qs}` : "";
|
|
47
|
-
}
|
|
48
|
-
function createJsonRestClient(config) {
|
|
49
|
-
const fetchImpl = config.fetchImpl ?? fetch;
|
|
50
|
-
const request = async (options) => {
|
|
51
|
-
const { method, path, body, query, headers: requestHeaders } = options;
|
|
52
|
-
const url = `${config.baseUrl}${path}${buildQueryString(query)}`;
|
|
53
|
-
const headers = {
|
|
54
|
-
Accept: "application/json",
|
|
55
|
-
...config.defaultHeaders,
|
|
56
|
-
...config.authHeaders(),
|
|
57
|
-
...requestHeaders
|
|
58
|
-
};
|
|
59
|
-
if (body !== void 0) headers["Content-Type"] ??= "application/json";
|
|
60
|
-
const response = await fetchImpl(url, {
|
|
61
|
-
method,
|
|
62
|
-
headers,
|
|
63
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
64
|
-
});
|
|
65
|
-
if (!response.ok) {
|
|
66
|
-
const errorBody = await response.text().catch(() => "");
|
|
67
|
-
throw new JsonRestError({
|
|
68
|
-
errorPrefix: config.errorPrefix,
|
|
69
|
-
status: response.status,
|
|
70
|
-
statusText: response.statusText,
|
|
71
|
-
body: errorBody,
|
|
72
|
-
headers: response.headers,
|
|
73
|
-
url,
|
|
74
|
-
method
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (response.status === 204) return;
|
|
78
|
-
return await response.json();
|
|
79
|
-
};
|
|
80
|
-
return { request };
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
//#endregion
|
|
84
|
-
export { isJsonRestError as n, createJsonRestClient as t };
|