@gpt-core/client 0.7.22 → 0.7.41
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.d.mts +716 -193
- package/dist/index.d.ts +716 -193
- package/dist/index.js +241 -1
- package/dist/index.mjs +236 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -45,6 +45,9 @@ __export(index_exports, {
|
|
|
45
45
|
ThreadCreateSchema: () => ThreadCreateSchema,
|
|
46
46
|
TimeoutError: () => TimeoutError,
|
|
47
47
|
ValidationError: () => ValidationError,
|
|
48
|
+
WebhookConfigCreateSchema: () => WebhookConfigCreateSchema,
|
|
49
|
+
WebhookConfigUpdateSchema: () => WebhookConfigUpdateSchema,
|
|
50
|
+
WebhookError: () => WebhookError,
|
|
48
51
|
WorkspaceCreateSchema: () => WorkspaceCreateSchema,
|
|
49
52
|
calculateBackoff: () => calculateBackoff,
|
|
50
53
|
client: () => client,
|
|
@@ -193,6 +196,7 @@ __export(index_exports, {
|
|
|
193
196
|
patchApiKeysByIdAllocate: () => patchApiKeysByIdAllocate,
|
|
194
197
|
patchApiKeysByIdRevoke: () => patchApiKeysByIdRevoke,
|
|
195
198
|
patchApiKeysByIdRotate: () => patchApiKeysByIdRotate,
|
|
199
|
+
patchApiKeysByIdSetBudget: () => patchApiKeysByIdSetBudget,
|
|
196
200
|
patchApplicationsById: () => patchApplicationsById,
|
|
197
201
|
patchApplicationsByIdGrantCredits: () => patchApplicationsByIdGrantCredits,
|
|
198
202
|
patchBucketsById: () => patchBucketsById,
|
|
@@ -315,6 +319,7 @@ __export(index_exports, {
|
|
|
315
319
|
sleep: () => sleep,
|
|
316
320
|
streamMessage: () => streamMessage,
|
|
317
321
|
streamSSE: () => streamSSE,
|
|
322
|
+
webhooks: () => webhooks,
|
|
318
323
|
withRetry: () => withRetry
|
|
319
324
|
});
|
|
320
325
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -461,6 +466,7 @@ __export(sdk_gen_exports, {
|
|
|
461
466
|
patchApiKeysByIdAllocate: () => patchApiKeysByIdAllocate,
|
|
462
467
|
patchApiKeysByIdRevoke: () => patchApiKeysByIdRevoke,
|
|
463
468
|
patchApiKeysByIdRotate: () => patchApiKeysByIdRotate,
|
|
469
|
+
patchApiKeysByIdSetBudget: () => patchApiKeysByIdSetBudget,
|
|
464
470
|
patchApplicationsById: () => patchApplicationsById,
|
|
465
471
|
patchApplicationsByIdGrantCredits: () => patchApplicationsByIdGrantCredits,
|
|
466
472
|
patchBucketsById: () => patchBucketsById,
|
|
@@ -1726,6 +1732,16 @@ var postTokens = (options) => (options.client ?? client).post({
|
|
|
1726
1732
|
...options.headers
|
|
1727
1733
|
}
|
|
1728
1734
|
});
|
|
1735
|
+
var patchApiKeysByIdSetBudget = (options) => (options.client ?? client).patch({
|
|
1736
|
+
querySerializer: { parameters: { fields: { object: { style: "form" } } } },
|
|
1737
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1738
|
+
url: "/api_keys/{id}/set_budget",
|
|
1739
|
+
...options,
|
|
1740
|
+
headers: {
|
|
1741
|
+
"Content-Type": "application/vnd.api+json",
|
|
1742
|
+
...options.headers
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1729
1745
|
var deleteTrainingExamplesById = (options) => (options.client ?? client).delete({
|
|
1730
1746
|
querySerializer: { parameters: { fields: { object: { style: "form" } } } },
|
|
1731
1747
|
security: [{ scheme: "bearer", type: "http" }],
|
|
@@ -3909,6 +3925,28 @@ var PresignedUploadSchema = import_zod.z.object({
|
|
|
3909
3925
|
var PresignedDownloadSchema = import_zod.z.object({
|
|
3910
3926
|
file_id: import_zod.z.string().uuid()
|
|
3911
3927
|
});
|
|
3928
|
+
var WebhookConfigCreateSchema = import_zod.z.object({
|
|
3929
|
+
name: import_zod.z.string().min(1).max(255),
|
|
3930
|
+
url: import_zod.z.string().url(),
|
|
3931
|
+
events: import_zod.z.array(import_zod.z.string()).optional(),
|
|
3932
|
+
enabled: import_zod.z.boolean().optional().default(true),
|
|
3933
|
+
secret: import_zod.z.string().optional(),
|
|
3934
|
+
// Tenant-level webhook: set tenant_id to scope to a specific tenant
|
|
3935
|
+
tenant_id: import_zod.z.string().uuid().optional(),
|
|
3936
|
+
// ISV filter: specific tenant UUIDs to receive events from (null = all)
|
|
3937
|
+
tenant_ids: import_zod.z.array(import_zod.z.string().uuid()).optional(),
|
|
3938
|
+
// Tenant filter: specific workspace UUIDs to receive events from (null = all)
|
|
3939
|
+
workspace_ids: import_zod.z.array(import_zod.z.string().uuid()).optional()
|
|
3940
|
+
});
|
|
3941
|
+
var WebhookConfigUpdateSchema = import_zod.z.object({
|
|
3942
|
+
name: import_zod.z.string().min(1).max(255).optional(),
|
|
3943
|
+
url: import_zod.z.string().url().optional(),
|
|
3944
|
+
events: import_zod.z.array(import_zod.z.string()).optional(),
|
|
3945
|
+
enabled: import_zod.z.boolean().optional(),
|
|
3946
|
+
secret: import_zod.z.string().optional(),
|
|
3947
|
+
tenant_ids: import_zod.z.array(import_zod.z.string().uuid()).optional(),
|
|
3948
|
+
workspace_ids: import_zod.z.array(import_zod.z.string().uuid()).optional()
|
|
3949
|
+
});
|
|
3912
3950
|
|
|
3913
3951
|
// src/utils/retry.ts
|
|
3914
3952
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -4060,10 +4098,207 @@ async function collectStreamedMessage(stream) {
|
|
|
4060
4098
|
return fullMessage;
|
|
4061
4099
|
}
|
|
4062
4100
|
|
|
4101
|
+
// src/webhooks.ts
|
|
4102
|
+
var WebhookError = class extends Error {
|
|
4103
|
+
constructor(message, status, errors) {
|
|
4104
|
+
super(message);
|
|
4105
|
+
this.status = status;
|
|
4106
|
+
this.errors = errors;
|
|
4107
|
+
this.name = "WebhookError";
|
|
4108
|
+
}
|
|
4109
|
+
};
|
|
4110
|
+
function unwrap(data) {
|
|
4111
|
+
if (data && typeof data === "object" && "attributes" in data) {
|
|
4112
|
+
const obj = data;
|
|
4113
|
+
return { id: obj.id, ...obj.attributes };
|
|
4114
|
+
}
|
|
4115
|
+
return data;
|
|
4116
|
+
}
|
|
4117
|
+
function handleError(error) {
|
|
4118
|
+
if (error && typeof error === "object") {
|
|
4119
|
+
const err = error;
|
|
4120
|
+
throw new WebhookError(
|
|
4121
|
+
err.detail || "Webhook operation failed",
|
|
4122
|
+
err.status,
|
|
4123
|
+
err.errors
|
|
4124
|
+
);
|
|
4125
|
+
}
|
|
4126
|
+
throw new WebhookError("Unknown error");
|
|
4127
|
+
}
|
|
4128
|
+
function processResult(result) {
|
|
4129
|
+
const r = result;
|
|
4130
|
+
if (r.error) handleError(r.error);
|
|
4131
|
+
return r.data?.data;
|
|
4132
|
+
}
|
|
4133
|
+
function processArrayResult(result) {
|
|
4134
|
+
const r = result;
|
|
4135
|
+
if (r.error) handleError(r.error);
|
|
4136
|
+
return (r.data?.data || []).map((d) => unwrap(d));
|
|
4137
|
+
}
|
|
4138
|
+
var webhooks = {
|
|
4139
|
+
/**
|
|
4140
|
+
* List all webhook configurations accessible to the current user.
|
|
4141
|
+
*
|
|
4142
|
+
* For tenant users, this returns webhooks scoped to their tenant.
|
|
4143
|
+
* For ISV/app owners, this returns application-level webhooks.
|
|
4144
|
+
*/
|
|
4145
|
+
async list(options) {
|
|
4146
|
+
const result = await getWebhookConfigs({
|
|
4147
|
+
headers: { "x-application-key": "" },
|
|
4148
|
+
query: options?.filter
|
|
4149
|
+
});
|
|
4150
|
+
return processArrayResult(result);
|
|
4151
|
+
},
|
|
4152
|
+
/**
|
|
4153
|
+
* Get a single webhook configuration by ID.
|
|
4154
|
+
*/
|
|
4155
|
+
async get(id) {
|
|
4156
|
+
const result = await getWebhookConfigsById({
|
|
4157
|
+
headers: { "x-application-key": "" },
|
|
4158
|
+
path: { id }
|
|
4159
|
+
});
|
|
4160
|
+
return unwrap(processResult(result));
|
|
4161
|
+
},
|
|
4162
|
+
/**
|
|
4163
|
+
* Create a new webhook configuration.
|
|
4164
|
+
*
|
|
4165
|
+
* For tenant-level webhooks, include `tenant_id` in the attributes.
|
|
4166
|
+
* The tenant_id is typically obtained from the user's profile.
|
|
4167
|
+
*
|
|
4168
|
+
* @example
|
|
4169
|
+
* ```typescript
|
|
4170
|
+
* // Tenant-level webhook (receives only this tenant's events)
|
|
4171
|
+
* const webhook = await webhooks.create({
|
|
4172
|
+
* name: 'My Webhook',
|
|
4173
|
+
* url: 'https://example.com/webhook',
|
|
4174
|
+
* events: ['extraction.completed', 'document.processed'],
|
|
4175
|
+
* tenant_id: userProfile.tenant_id,
|
|
4176
|
+
* });
|
|
4177
|
+
*
|
|
4178
|
+
* // With workspace filtering (only events from specific workspaces)
|
|
4179
|
+
* const webhook = await webhooks.create({
|
|
4180
|
+
* name: 'Workspace Webhook',
|
|
4181
|
+
* url: 'https://example.com/webhook',
|
|
4182
|
+
* tenant_id: userProfile.tenant_id,
|
|
4183
|
+
* workspace_ids: ['workspace-uuid-1', 'workspace-uuid-2'],
|
|
4184
|
+
* });
|
|
4185
|
+
* ```
|
|
4186
|
+
*/
|
|
4187
|
+
async create(attributes) {
|
|
4188
|
+
const validated = WebhookConfigCreateSchema.parse(attributes);
|
|
4189
|
+
const result = await postWebhookConfigs({
|
|
4190
|
+
headers: { "x-application-key": "" },
|
|
4191
|
+
body: {
|
|
4192
|
+
data: {
|
|
4193
|
+
type: "webhook_config",
|
|
4194
|
+
attributes: validated
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
});
|
|
4198
|
+
return unwrap(processResult(result));
|
|
4199
|
+
},
|
|
4200
|
+
/**
|
|
4201
|
+
* Update an existing webhook configuration.
|
|
4202
|
+
*/
|
|
4203
|
+
async update(id, attributes) {
|
|
4204
|
+
const validated = WebhookConfigUpdateSchema.parse(attributes);
|
|
4205
|
+
const result = await patchWebhookConfigsById({
|
|
4206
|
+
headers: { "x-application-key": "" },
|
|
4207
|
+
path: { id },
|
|
4208
|
+
body: {
|
|
4209
|
+
data: {
|
|
4210
|
+
type: "webhook_config",
|
|
4211
|
+
id,
|
|
4212
|
+
attributes: validated
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
});
|
|
4216
|
+
return unwrap(processResult(result));
|
|
4217
|
+
},
|
|
4218
|
+
/**
|
|
4219
|
+
* Delete a webhook configuration.
|
|
4220
|
+
*/
|
|
4221
|
+
async delete(id) {
|
|
4222
|
+
const result = await deleteWebhookConfigsById({
|
|
4223
|
+
headers: { "x-application-key": "" },
|
|
4224
|
+
path: { id }
|
|
4225
|
+
});
|
|
4226
|
+
const r = result;
|
|
4227
|
+
if (r.error) handleError(r.error);
|
|
4228
|
+
},
|
|
4229
|
+
/**
|
|
4230
|
+
* Send a test webhook to verify the endpoint is reachable.
|
|
4231
|
+
*
|
|
4232
|
+
* This enqueues a test webhook delivery with a sample payload.
|
|
4233
|
+
* Check the deliveries list to see the result.
|
|
4234
|
+
*/
|
|
4235
|
+
async test(id) {
|
|
4236
|
+
const result = await postWebhookConfigsByIdTest({
|
|
4237
|
+
headers: { "x-application-key": "" },
|
|
4238
|
+
path: { id }
|
|
4239
|
+
});
|
|
4240
|
+
return unwrap(processResult(result));
|
|
4241
|
+
},
|
|
4242
|
+
/**
|
|
4243
|
+
* Rotate the webhook secret.
|
|
4244
|
+
*
|
|
4245
|
+
* This generates a new secret for the webhook. The old secret
|
|
4246
|
+
* becomes invalid immediately. Make sure to update your endpoint
|
|
4247
|
+
* with the new secret.
|
|
4248
|
+
*/
|
|
4249
|
+
async rotateSecret(id) {
|
|
4250
|
+
const result = await patchWebhookConfigsByIdRotateSecret({
|
|
4251
|
+
headers: { "x-application-key": "" },
|
|
4252
|
+
path: { id }
|
|
4253
|
+
});
|
|
4254
|
+
return unwrap(processResult(result));
|
|
4255
|
+
},
|
|
4256
|
+
/**
|
|
4257
|
+
* Webhook delivery management
|
|
4258
|
+
*/
|
|
4259
|
+
deliveries: {
|
|
4260
|
+
/**
|
|
4261
|
+
* List webhook deliveries.
|
|
4262
|
+
*
|
|
4263
|
+
* Deliveries are sorted by newest first by default.
|
|
4264
|
+
*/
|
|
4265
|
+
async list(options) {
|
|
4266
|
+
const result = await getWebhookDeliveries({
|
|
4267
|
+
headers: { "x-application-key": "" },
|
|
4268
|
+
query: options?.filter
|
|
4269
|
+
});
|
|
4270
|
+
return processArrayResult(result);
|
|
4271
|
+
},
|
|
4272
|
+
/**
|
|
4273
|
+
* Get a single webhook delivery by ID.
|
|
4274
|
+
*/
|
|
4275
|
+
async get(id) {
|
|
4276
|
+
const result = await getWebhookDeliveriesById({
|
|
4277
|
+
headers: { "x-application-key": "" },
|
|
4278
|
+
path: { id }
|
|
4279
|
+
});
|
|
4280
|
+
return unwrap(processResult(result));
|
|
4281
|
+
},
|
|
4282
|
+
/**
|
|
4283
|
+
* Retry a failed webhook delivery.
|
|
4284
|
+
*
|
|
4285
|
+
* This re-enqueues the delivery for another attempt.
|
|
4286
|
+
*/
|
|
4287
|
+
async retry(id) {
|
|
4288
|
+
const result = await postWebhookDeliveriesByIdRetry({
|
|
4289
|
+
headers: { "x-application-key": "" },
|
|
4290
|
+
path: { id }
|
|
4291
|
+
});
|
|
4292
|
+
return unwrap(processResult(result));
|
|
4293
|
+
}
|
|
4294
|
+
}
|
|
4295
|
+
};
|
|
4296
|
+
|
|
4063
4297
|
// src/index.ts
|
|
4064
4298
|
var gptCore = {
|
|
4065
4299
|
...sdk_gen_exports,
|
|
4066
|
-
client
|
|
4300
|
+
client,
|
|
4301
|
+
webhooks
|
|
4067
4302
|
};
|
|
4068
4303
|
var index_default = gptCore;
|
|
4069
4304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -4093,6 +4328,9 @@ var index_default = gptCore;
|
|
|
4093
4328
|
ThreadCreateSchema,
|
|
4094
4329
|
TimeoutError,
|
|
4095
4330
|
ValidationError,
|
|
4331
|
+
WebhookConfigCreateSchema,
|
|
4332
|
+
WebhookConfigUpdateSchema,
|
|
4333
|
+
WebhookError,
|
|
4096
4334
|
WorkspaceCreateSchema,
|
|
4097
4335
|
calculateBackoff,
|
|
4098
4336
|
client,
|
|
@@ -4240,6 +4478,7 @@ var index_default = gptCore;
|
|
|
4240
4478
|
patchApiKeysByIdAllocate,
|
|
4241
4479
|
patchApiKeysByIdRevoke,
|
|
4242
4480
|
patchApiKeysByIdRotate,
|
|
4481
|
+
patchApiKeysByIdSetBudget,
|
|
4243
4482
|
patchApplicationsById,
|
|
4244
4483
|
patchApplicationsByIdGrantCredits,
|
|
4245
4484
|
patchBucketsById,
|
|
@@ -4362,5 +4601,6 @@ var index_default = gptCore;
|
|
|
4362
4601
|
sleep,
|
|
4363
4602
|
streamMessage,
|
|
4364
4603
|
streamSSE,
|
|
4604
|
+
webhooks,
|
|
4365
4605
|
withRetry
|
|
4366
4606
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -146,6 +146,7 @@ __export(sdk_gen_exports, {
|
|
|
146
146
|
patchApiKeysByIdAllocate: () => patchApiKeysByIdAllocate,
|
|
147
147
|
patchApiKeysByIdRevoke: () => patchApiKeysByIdRevoke,
|
|
148
148
|
patchApiKeysByIdRotate: () => patchApiKeysByIdRotate,
|
|
149
|
+
patchApiKeysByIdSetBudget: () => patchApiKeysByIdSetBudget,
|
|
149
150
|
patchApplicationsById: () => patchApplicationsById,
|
|
150
151
|
patchApplicationsByIdGrantCredits: () => patchApplicationsByIdGrantCredits,
|
|
151
152
|
patchBucketsById: () => patchBucketsById,
|
|
@@ -1411,6 +1412,16 @@ var postTokens = (options) => (options.client ?? client).post({
|
|
|
1411
1412
|
...options.headers
|
|
1412
1413
|
}
|
|
1413
1414
|
});
|
|
1415
|
+
var patchApiKeysByIdSetBudget = (options) => (options.client ?? client).patch({
|
|
1416
|
+
querySerializer: { parameters: { fields: { object: { style: "form" } } } },
|
|
1417
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1418
|
+
url: "/api_keys/{id}/set_budget",
|
|
1419
|
+
...options,
|
|
1420
|
+
headers: {
|
|
1421
|
+
"Content-Type": "application/vnd.api+json",
|
|
1422
|
+
...options.headers
|
|
1423
|
+
}
|
|
1424
|
+
});
|
|
1414
1425
|
var deleteTrainingExamplesById = (options) => (options.client ?? client).delete({
|
|
1415
1426
|
querySerializer: { parameters: { fields: { object: { style: "form" } } } },
|
|
1416
1427
|
security: [{ scheme: "bearer", type: "http" }],
|
|
@@ -3594,6 +3605,28 @@ var PresignedUploadSchema = z.object({
|
|
|
3594
3605
|
var PresignedDownloadSchema = z.object({
|
|
3595
3606
|
file_id: z.string().uuid()
|
|
3596
3607
|
});
|
|
3608
|
+
var WebhookConfigCreateSchema = z.object({
|
|
3609
|
+
name: z.string().min(1).max(255),
|
|
3610
|
+
url: z.string().url(),
|
|
3611
|
+
events: z.array(z.string()).optional(),
|
|
3612
|
+
enabled: z.boolean().optional().default(true),
|
|
3613
|
+
secret: z.string().optional(),
|
|
3614
|
+
// Tenant-level webhook: set tenant_id to scope to a specific tenant
|
|
3615
|
+
tenant_id: z.string().uuid().optional(),
|
|
3616
|
+
// ISV filter: specific tenant UUIDs to receive events from (null = all)
|
|
3617
|
+
tenant_ids: z.array(z.string().uuid()).optional(),
|
|
3618
|
+
// Tenant filter: specific workspace UUIDs to receive events from (null = all)
|
|
3619
|
+
workspace_ids: z.array(z.string().uuid()).optional()
|
|
3620
|
+
});
|
|
3621
|
+
var WebhookConfigUpdateSchema = z.object({
|
|
3622
|
+
name: z.string().min(1).max(255).optional(),
|
|
3623
|
+
url: z.string().url().optional(),
|
|
3624
|
+
events: z.array(z.string()).optional(),
|
|
3625
|
+
enabled: z.boolean().optional(),
|
|
3626
|
+
secret: z.string().optional(),
|
|
3627
|
+
tenant_ids: z.array(z.string().uuid()).optional(),
|
|
3628
|
+
workspace_ids: z.array(z.string().uuid()).optional()
|
|
3629
|
+
});
|
|
3597
3630
|
|
|
3598
3631
|
// src/utils/retry.ts
|
|
3599
3632
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -3745,10 +3778,207 @@ async function collectStreamedMessage(stream) {
|
|
|
3745
3778
|
return fullMessage;
|
|
3746
3779
|
}
|
|
3747
3780
|
|
|
3781
|
+
// src/webhooks.ts
|
|
3782
|
+
var WebhookError = class extends Error {
|
|
3783
|
+
constructor(message, status, errors) {
|
|
3784
|
+
super(message);
|
|
3785
|
+
this.status = status;
|
|
3786
|
+
this.errors = errors;
|
|
3787
|
+
this.name = "WebhookError";
|
|
3788
|
+
}
|
|
3789
|
+
};
|
|
3790
|
+
function unwrap(data) {
|
|
3791
|
+
if (data && typeof data === "object" && "attributes" in data) {
|
|
3792
|
+
const obj = data;
|
|
3793
|
+
return { id: obj.id, ...obj.attributes };
|
|
3794
|
+
}
|
|
3795
|
+
return data;
|
|
3796
|
+
}
|
|
3797
|
+
function handleError(error) {
|
|
3798
|
+
if (error && typeof error === "object") {
|
|
3799
|
+
const err = error;
|
|
3800
|
+
throw new WebhookError(
|
|
3801
|
+
err.detail || "Webhook operation failed",
|
|
3802
|
+
err.status,
|
|
3803
|
+
err.errors
|
|
3804
|
+
);
|
|
3805
|
+
}
|
|
3806
|
+
throw new WebhookError("Unknown error");
|
|
3807
|
+
}
|
|
3808
|
+
function processResult(result) {
|
|
3809
|
+
const r = result;
|
|
3810
|
+
if (r.error) handleError(r.error);
|
|
3811
|
+
return r.data?.data;
|
|
3812
|
+
}
|
|
3813
|
+
function processArrayResult(result) {
|
|
3814
|
+
const r = result;
|
|
3815
|
+
if (r.error) handleError(r.error);
|
|
3816
|
+
return (r.data?.data || []).map((d) => unwrap(d));
|
|
3817
|
+
}
|
|
3818
|
+
var webhooks = {
|
|
3819
|
+
/**
|
|
3820
|
+
* List all webhook configurations accessible to the current user.
|
|
3821
|
+
*
|
|
3822
|
+
* For tenant users, this returns webhooks scoped to their tenant.
|
|
3823
|
+
* For ISV/app owners, this returns application-level webhooks.
|
|
3824
|
+
*/
|
|
3825
|
+
async list(options) {
|
|
3826
|
+
const result = await getWebhookConfigs({
|
|
3827
|
+
headers: { "x-application-key": "" },
|
|
3828
|
+
query: options?.filter
|
|
3829
|
+
});
|
|
3830
|
+
return processArrayResult(result);
|
|
3831
|
+
},
|
|
3832
|
+
/**
|
|
3833
|
+
* Get a single webhook configuration by ID.
|
|
3834
|
+
*/
|
|
3835
|
+
async get(id) {
|
|
3836
|
+
const result = await getWebhookConfigsById({
|
|
3837
|
+
headers: { "x-application-key": "" },
|
|
3838
|
+
path: { id }
|
|
3839
|
+
});
|
|
3840
|
+
return unwrap(processResult(result));
|
|
3841
|
+
},
|
|
3842
|
+
/**
|
|
3843
|
+
* Create a new webhook configuration.
|
|
3844
|
+
*
|
|
3845
|
+
* For tenant-level webhooks, include `tenant_id` in the attributes.
|
|
3846
|
+
* The tenant_id is typically obtained from the user's profile.
|
|
3847
|
+
*
|
|
3848
|
+
* @example
|
|
3849
|
+
* ```typescript
|
|
3850
|
+
* // Tenant-level webhook (receives only this tenant's events)
|
|
3851
|
+
* const webhook = await webhooks.create({
|
|
3852
|
+
* name: 'My Webhook',
|
|
3853
|
+
* url: 'https://example.com/webhook',
|
|
3854
|
+
* events: ['extraction.completed', 'document.processed'],
|
|
3855
|
+
* tenant_id: userProfile.tenant_id,
|
|
3856
|
+
* });
|
|
3857
|
+
*
|
|
3858
|
+
* // With workspace filtering (only events from specific workspaces)
|
|
3859
|
+
* const webhook = await webhooks.create({
|
|
3860
|
+
* name: 'Workspace Webhook',
|
|
3861
|
+
* url: 'https://example.com/webhook',
|
|
3862
|
+
* tenant_id: userProfile.tenant_id,
|
|
3863
|
+
* workspace_ids: ['workspace-uuid-1', 'workspace-uuid-2'],
|
|
3864
|
+
* });
|
|
3865
|
+
* ```
|
|
3866
|
+
*/
|
|
3867
|
+
async create(attributes) {
|
|
3868
|
+
const validated = WebhookConfigCreateSchema.parse(attributes);
|
|
3869
|
+
const result = await postWebhookConfigs({
|
|
3870
|
+
headers: { "x-application-key": "" },
|
|
3871
|
+
body: {
|
|
3872
|
+
data: {
|
|
3873
|
+
type: "webhook_config",
|
|
3874
|
+
attributes: validated
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
});
|
|
3878
|
+
return unwrap(processResult(result));
|
|
3879
|
+
},
|
|
3880
|
+
/**
|
|
3881
|
+
* Update an existing webhook configuration.
|
|
3882
|
+
*/
|
|
3883
|
+
async update(id, attributes) {
|
|
3884
|
+
const validated = WebhookConfigUpdateSchema.parse(attributes);
|
|
3885
|
+
const result = await patchWebhookConfigsById({
|
|
3886
|
+
headers: { "x-application-key": "" },
|
|
3887
|
+
path: { id },
|
|
3888
|
+
body: {
|
|
3889
|
+
data: {
|
|
3890
|
+
type: "webhook_config",
|
|
3891
|
+
id,
|
|
3892
|
+
attributes: validated
|
|
3893
|
+
}
|
|
3894
|
+
}
|
|
3895
|
+
});
|
|
3896
|
+
return unwrap(processResult(result));
|
|
3897
|
+
},
|
|
3898
|
+
/**
|
|
3899
|
+
* Delete a webhook configuration.
|
|
3900
|
+
*/
|
|
3901
|
+
async delete(id) {
|
|
3902
|
+
const result = await deleteWebhookConfigsById({
|
|
3903
|
+
headers: { "x-application-key": "" },
|
|
3904
|
+
path: { id }
|
|
3905
|
+
});
|
|
3906
|
+
const r = result;
|
|
3907
|
+
if (r.error) handleError(r.error);
|
|
3908
|
+
},
|
|
3909
|
+
/**
|
|
3910
|
+
* Send a test webhook to verify the endpoint is reachable.
|
|
3911
|
+
*
|
|
3912
|
+
* This enqueues a test webhook delivery with a sample payload.
|
|
3913
|
+
* Check the deliveries list to see the result.
|
|
3914
|
+
*/
|
|
3915
|
+
async test(id) {
|
|
3916
|
+
const result = await postWebhookConfigsByIdTest({
|
|
3917
|
+
headers: { "x-application-key": "" },
|
|
3918
|
+
path: { id }
|
|
3919
|
+
});
|
|
3920
|
+
return unwrap(processResult(result));
|
|
3921
|
+
},
|
|
3922
|
+
/**
|
|
3923
|
+
* Rotate the webhook secret.
|
|
3924
|
+
*
|
|
3925
|
+
* This generates a new secret for the webhook. The old secret
|
|
3926
|
+
* becomes invalid immediately. Make sure to update your endpoint
|
|
3927
|
+
* with the new secret.
|
|
3928
|
+
*/
|
|
3929
|
+
async rotateSecret(id) {
|
|
3930
|
+
const result = await patchWebhookConfigsByIdRotateSecret({
|
|
3931
|
+
headers: { "x-application-key": "" },
|
|
3932
|
+
path: { id }
|
|
3933
|
+
});
|
|
3934
|
+
return unwrap(processResult(result));
|
|
3935
|
+
},
|
|
3936
|
+
/**
|
|
3937
|
+
* Webhook delivery management
|
|
3938
|
+
*/
|
|
3939
|
+
deliveries: {
|
|
3940
|
+
/**
|
|
3941
|
+
* List webhook deliveries.
|
|
3942
|
+
*
|
|
3943
|
+
* Deliveries are sorted by newest first by default.
|
|
3944
|
+
*/
|
|
3945
|
+
async list(options) {
|
|
3946
|
+
const result = await getWebhookDeliveries({
|
|
3947
|
+
headers: { "x-application-key": "" },
|
|
3948
|
+
query: options?.filter
|
|
3949
|
+
});
|
|
3950
|
+
return processArrayResult(result);
|
|
3951
|
+
},
|
|
3952
|
+
/**
|
|
3953
|
+
* Get a single webhook delivery by ID.
|
|
3954
|
+
*/
|
|
3955
|
+
async get(id) {
|
|
3956
|
+
const result = await getWebhookDeliveriesById({
|
|
3957
|
+
headers: { "x-application-key": "" },
|
|
3958
|
+
path: { id }
|
|
3959
|
+
});
|
|
3960
|
+
return unwrap(processResult(result));
|
|
3961
|
+
},
|
|
3962
|
+
/**
|
|
3963
|
+
* Retry a failed webhook delivery.
|
|
3964
|
+
*
|
|
3965
|
+
* This re-enqueues the delivery for another attempt.
|
|
3966
|
+
*/
|
|
3967
|
+
async retry(id) {
|
|
3968
|
+
const result = await postWebhookDeliveriesByIdRetry({
|
|
3969
|
+
headers: { "x-application-key": "" },
|
|
3970
|
+
path: { id }
|
|
3971
|
+
});
|
|
3972
|
+
return unwrap(processResult(result));
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
};
|
|
3976
|
+
|
|
3748
3977
|
// src/index.ts
|
|
3749
3978
|
var gptCore = {
|
|
3750
3979
|
...sdk_gen_exports,
|
|
3751
|
-
client
|
|
3980
|
+
client,
|
|
3981
|
+
webhooks
|
|
3752
3982
|
};
|
|
3753
3983
|
var index_default = gptCore;
|
|
3754
3984
|
export {
|
|
@@ -3777,6 +4007,9 @@ export {
|
|
|
3777
4007
|
ThreadCreateSchema,
|
|
3778
4008
|
TimeoutError,
|
|
3779
4009
|
ValidationError,
|
|
4010
|
+
WebhookConfigCreateSchema,
|
|
4011
|
+
WebhookConfigUpdateSchema,
|
|
4012
|
+
WebhookError,
|
|
3780
4013
|
WorkspaceCreateSchema,
|
|
3781
4014
|
calculateBackoff,
|
|
3782
4015
|
client,
|
|
@@ -3925,6 +4158,7 @@ export {
|
|
|
3925
4158
|
patchApiKeysByIdAllocate,
|
|
3926
4159
|
patchApiKeysByIdRevoke,
|
|
3927
4160
|
patchApiKeysByIdRotate,
|
|
4161
|
+
patchApiKeysByIdSetBudget,
|
|
3928
4162
|
patchApplicationsById,
|
|
3929
4163
|
patchApplicationsByIdGrantCredits,
|
|
3930
4164
|
patchBucketsById,
|
|
@@ -4047,5 +4281,6 @@ export {
|
|
|
4047
4281
|
sleep,
|
|
4048
4282
|
streamMessage,
|
|
4049
4283
|
streamSSE,
|
|
4284
|
+
webhooks,
|
|
4050
4285
|
withRetry
|
|
4051
4286
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpt-core/client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.41",
|
|
4
4
|
"description": "TypeScript SDK for GPT Core Client API - Document extraction, AI agents, and workspace management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -43,14 +43,6 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"scripts": {
|
|
47
|
-
"generate": "openapi-ts",
|
|
48
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
49
|
-
"test": "vitest run",
|
|
50
|
-
"test:watch": "vitest",
|
|
51
|
-
"test:ui": "vitest --ui",
|
|
52
|
-
"test:coverage": "vitest run --coverage"
|
|
53
|
-
},
|
|
54
46
|
"dependencies": {
|
|
55
47
|
"eventsource-parser": "^3.0.6",
|
|
56
48
|
"zod": "^3.25.76"
|
|
@@ -62,5 +54,13 @@
|
|
|
62
54
|
"tsup": "^8.5.1",
|
|
63
55
|
"typescript": "^5.9.3",
|
|
64
56
|
"vitest": "^4.0.15"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"generate": "openapi-ts",
|
|
60
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest",
|
|
63
|
+
"test:ui": "vitest --ui",
|
|
64
|
+
"test:coverage": "vitest run --coverage"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|