@gpt-core/client 0.7.1 → 0.7.3
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 +567 -193
- package/dist/index.d.ts +567 -193
- package/dist/index.js +228 -10
- package/dist/index.mjs +224 -10
- package/package.json +22 -13
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,
|
|
@@ -315,6 +318,7 @@ __export(index_exports, {
|
|
|
315
318
|
sleep: () => sleep,
|
|
316
319
|
streamMessage: () => streamMessage,
|
|
317
320
|
streamSSE: () => streamSSE,
|
|
321
|
+
webhooks: () => webhooks,
|
|
318
322
|
withRetry: () => withRetry
|
|
319
323
|
});
|
|
320
324
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -589,15 +593,6 @@ var jsonBodySerializer = {
|
|
|
589
593
|
)
|
|
590
594
|
};
|
|
591
595
|
|
|
592
|
-
// src/_internal/core/params.gen.ts
|
|
593
|
-
var extraPrefixesMap = {
|
|
594
|
-
$body_: "body",
|
|
595
|
-
$headers_: "headers",
|
|
596
|
-
$path_: "path",
|
|
597
|
-
$query_: "query"
|
|
598
|
-
};
|
|
599
|
-
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
600
|
-
|
|
601
596
|
// src/_internal/core/serverSentEvents.gen.ts
|
|
602
597
|
var createSseClient = ({
|
|
603
598
|
onRequest,
|
|
@@ -3918,6 +3913,28 @@ var PresignedUploadSchema = import_zod.z.object({
|
|
|
3918
3913
|
var PresignedDownloadSchema = import_zod.z.object({
|
|
3919
3914
|
file_id: import_zod.z.string().uuid()
|
|
3920
3915
|
});
|
|
3916
|
+
var WebhookConfigCreateSchema = import_zod.z.object({
|
|
3917
|
+
name: import_zod.z.string().min(1).max(255),
|
|
3918
|
+
url: import_zod.z.string().url(),
|
|
3919
|
+
events: import_zod.z.array(import_zod.z.string()).optional(),
|
|
3920
|
+
enabled: import_zod.z.boolean().optional().default(true),
|
|
3921
|
+
secret: import_zod.z.string().optional(),
|
|
3922
|
+
// Tenant-level webhook: set tenant_id to scope to a specific tenant
|
|
3923
|
+
tenant_id: import_zod.z.string().uuid().optional(),
|
|
3924
|
+
// ISV filter: specific tenant UUIDs to receive events from (null = all)
|
|
3925
|
+
tenant_ids: import_zod.z.array(import_zod.z.string().uuid()).optional(),
|
|
3926
|
+
// Tenant filter: specific workspace UUIDs to receive events from (null = all)
|
|
3927
|
+
workspace_ids: import_zod.z.array(import_zod.z.string().uuid()).optional()
|
|
3928
|
+
});
|
|
3929
|
+
var WebhookConfigUpdateSchema = import_zod.z.object({
|
|
3930
|
+
name: import_zod.z.string().min(1).max(255).optional(),
|
|
3931
|
+
url: import_zod.z.string().url().optional(),
|
|
3932
|
+
events: import_zod.z.array(import_zod.z.string()).optional(),
|
|
3933
|
+
enabled: import_zod.z.boolean().optional(),
|
|
3934
|
+
secret: import_zod.z.string().optional(),
|
|
3935
|
+
tenant_ids: import_zod.z.array(import_zod.z.string().uuid()).optional(),
|
|
3936
|
+
workspace_ids: import_zod.z.array(import_zod.z.string().uuid()).optional()
|
|
3937
|
+
});
|
|
3921
3938
|
|
|
3922
3939
|
// src/utils/retry.ts
|
|
3923
3940
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -4069,10 +4086,207 @@ async function collectStreamedMessage(stream) {
|
|
|
4069
4086
|
return fullMessage;
|
|
4070
4087
|
}
|
|
4071
4088
|
|
|
4089
|
+
// src/webhooks.ts
|
|
4090
|
+
var WebhookError = class extends Error {
|
|
4091
|
+
constructor(message, status, errors) {
|
|
4092
|
+
super(message);
|
|
4093
|
+
this.status = status;
|
|
4094
|
+
this.errors = errors;
|
|
4095
|
+
this.name = "WebhookError";
|
|
4096
|
+
}
|
|
4097
|
+
};
|
|
4098
|
+
function unwrap(data) {
|
|
4099
|
+
if (data && typeof data === "object" && "attributes" in data) {
|
|
4100
|
+
const obj = data;
|
|
4101
|
+
return { id: obj.id, ...obj.attributes };
|
|
4102
|
+
}
|
|
4103
|
+
return data;
|
|
4104
|
+
}
|
|
4105
|
+
function handleError(error) {
|
|
4106
|
+
if (error && typeof error === "object") {
|
|
4107
|
+
const err = error;
|
|
4108
|
+
throw new WebhookError(
|
|
4109
|
+
err.detail || "Webhook operation failed",
|
|
4110
|
+
err.status,
|
|
4111
|
+
err.errors
|
|
4112
|
+
);
|
|
4113
|
+
}
|
|
4114
|
+
throw new WebhookError("Unknown error");
|
|
4115
|
+
}
|
|
4116
|
+
function processResult(result) {
|
|
4117
|
+
const r = result;
|
|
4118
|
+
if (r.error) handleError(r.error);
|
|
4119
|
+
return r.data?.data;
|
|
4120
|
+
}
|
|
4121
|
+
function processArrayResult(result) {
|
|
4122
|
+
const r = result;
|
|
4123
|
+
if (r.error) handleError(r.error);
|
|
4124
|
+
return (r.data?.data || []).map((d) => unwrap(d));
|
|
4125
|
+
}
|
|
4126
|
+
var webhooks = {
|
|
4127
|
+
/**
|
|
4128
|
+
* List all webhook configurations accessible to the current user.
|
|
4129
|
+
*
|
|
4130
|
+
* For tenant users, this returns webhooks scoped to their tenant.
|
|
4131
|
+
* For ISV/app owners, this returns application-level webhooks.
|
|
4132
|
+
*/
|
|
4133
|
+
async list(options) {
|
|
4134
|
+
const result = await getWebhookConfigs({
|
|
4135
|
+
headers: { "x-application-key": "" },
|
|
4136
|
+
query: options?.filter
|
|
4137
|
+
});
|
|
4138
|
+
return processArrayResult(result);
|
|
4139
|
+
},
|
|
4140
|
+
/**
|
|
4141
|
+
* Get a single webhook configuration by ID.
|
|
4142
|
+
*/
|
|
4143
|
+
async get(id) {
|
|
4144
|
+
const result = await getWebhookConfigsById({
|
|
4145
|
+
headers: { "x-application-key": "" },
|
|
4146
|
+
path: { id }
|
|
4147
|
+
});
|
|
4148
|
+
return unwrap(processResult(result));
|
|
4149
|
+
},
|
|
4150
|
+
/**
|
|
4151
|
+
* Create a new webhook configuration.
|
|
4152
|
+
*
|
|
4153
|
+
* For tenant-level webhooks, include `tenant_id` in the attributes.
|
|
4154
|
+
* The tenant_id is typically obtained from the user's profile.
|
|
4155
|
+
*
|
|
4156
|
+
* @example
|
|
4157
|
+
* ```typescript
|
|
4158
|
+
* // Tenant-level webhook (receives only this tenant's events)
|
|
4159
|
+
* const webhook = await webhooks.create({
|
|
4160
|
+
* name: 'My Webhook',
|
|
4161
|
+
* url: 'https://example.com/webhook',
|
|
4162
|
+
* events: ['extraction.completed', 'document.processed'],
|
|
4163
|
+
* tenant_id: userProfile.tenant_id,
|
|
4164
|
+
* });
|
|
4165
|
+
*
|
|
4166
|
+
* // With workspace filtering (only events from specific workspaces)
|
|
4167
|
+
* const webhook = await webhooks.create({
|
|
4168
|
+
* name: 'Workspace Webhook',
|
|
4169
|
+
* url: 'https://example.com/webhook',
|
|
4170
|
+
* tenant_id: userProfile.tenant_id,
|
|
4171
|
+
* workspace_ids: ['workspace-uuid-1', 'workspace-uuid-2'],
|
|
4172
|
+
* });
|
|
4173
|
+
* ```
|
|
4174
|
+
*/
|
|
4175
|
+
async create(attributes) {
|
|
4176
|
+
const validated = WebhookConfigCreateSchema.parse(attributes);
|
|
4177
|
+
const result = await postWebhookConfigs({
|
|
4178
|
+
headers: { "x-application-key": "" },
|
|
4179
|
+
body: {
|
|
4180
|
+
data: {
|
|
4181
|
+
type: "webhook_config",
|
|
4182
|
+
attributes: validated
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4185
|
+
});
|
|
4186
|
+
return unwrap(processResult(result));
|
|
4187
|
+
},
|
|
4188
|
+
/**
|
|
4189
|
+
* Update an existing webhook configuration.
|
|
4190
|
+
*/
|
|
4191
|
+
async update(id, attributes) {
|
|
4192
|
+
const validated = WebhookConfigUpdateSchema.parse(attributes);
|
|
4193
|
+
const result = await patchWebhookConfigsById({
|
|
4194
|
+
headers: { "x-application-key": "" },
|
|
4195
|
+
path: { id },
|
|
4196
|
+
body: {
|
|
4197
|
+
data: {
|
|
4198
|
+
type: "webhook_config",
|
|
4199
|
+
id,
|
|
4200
|
+
attributes: validated
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
});
|
|
4204
|
+
return unwrap(processResult(result));
|
|
4205
|
+
},
|
|
4206
|
+
/**
|
|
4207
|
+
* Delete a webhook configuration.
|
|
4208
|
+
*/
|
|
4209
|
+
async delete(id) {
|
|
4210
|
+
const result = await deleteWebhookConfigsById({
|
|
4211
|
+
headers: { "x-application-key": "" },
|
|
4212
|
+
path: { id }
|
|
4213
|
+
});
|
|
4214
|
+
const r = result;
|
|
4215
|
+
if (r.error) handleError(r.error);
|
|
4216
|
+
},
|
|
4217
|
+
/**
|
|
4218
|
+
* Send a test webhook to verify the endpoint is reachable.
|
|
4219
|
+
*
|
|
4220
|
+
* This enqueues a test webhook delivery with a sample payload.
|
|
4221
|
+
* Check the deliveries list to see the result.
|
|
4222
|
+
*/
|
|
4223
|
+
async test(id) {
|
|
4224
|
+
const result = await postWebhookConfigsByIdTest({
|
|
4225
|
+
headers: { "x-application-key": "" },
|
|
4226
|
+
path: { id }
|
|
4227
|
+
});
|
|
4228
|
+
return unwrap(processResult(result));
|
|
4229
|
+
},
|
|
4230
|
+
/**
|
|
4231
|
+
* Rotate the webhook secret.
|
|
4232
|
+
*
|
|
4233
|
+
* This generates a new secret for the webhook. The old secret
|
|
4234
|
+
* becomes invalid immediately. Make sure to update your endpoint
|
|
4235
|
+
* with the new secret.
|
|
4236
|
+
*/
|
|
4237
|
+
async rotateSecret(id) {
|
|
4238
|
+
const result = await patchWebhookConfigsByIdRotateSecret({
|
|
4239
|
+
headers: { "x-application-key": "" },
|
|
4240
|
+
path: { id }
|
|
4241
|
+
});
|
|
4242
|
+
return unwrap(processResult(result));
|
|
4243
|
+
},
|
|
4244
|
+
/**
|
|
4245
|
+
* Webhook delivery management
|
|
4246
|
+
*/
|
|
4247
|
+
deliveries: {
|
|
4248
|
+
/**
|
|
4249
|
+
* List webhook deliveries.
|
|
4250
|
+
*
|
|
4251
|
+
* Deliveries are sorted by newest first by default.
|
|
4252
|
+
*/
|
|
4253
|
+
async list(options) {
|
|
4254
|
+
const result = await getWebhookDeliveries({
|
|
4255
|
+
headers: { "x-application-key": "" },
|
|
4256
|
+
query: options?.filter
|
|
4257
|
+
});
|
|
4258
|
+
return processArrayResult(result);
|
|
4259
|
+
},
|
|
4260
|
+
/**
|
|
4261
|
+
* Get a single webhook delivery by ID.
|
|
4262
|
+
*/
|
|
4263
|
+
async get(id) {
|
|
4264
|
+
const result = await getWebhookDeliveriesById({
|
|
4265
|
+
headers: { "x-application-key": "" },
|
|
4266
|
+
path: { id }
|
|
4267
|
+
});
|
|
4268
|
+
return unwrap(processResult(result));
|
|
4269
|
+
},
|
|
4270
|
+
/**
|
|
4271
|
+
* Retry a failed webhook delivery.
|
|
4272
|
+
*
|
|
4273
|
+
* This re-enqueues the delivery for another attempt.
|
|
4274
|
+
*/
|
|
4275
|
+
async retry(id) {
|
|
4276
|
+
const result = await postWebhookDeliveriesByIdRetry({
|
|
4277
|
+
headers: { "x-application-key": "" },
|
|
4278
|
+
path: { id }
|
|
4279
|
+
});
|
|
4280
|
+
return unwrap(processResult(result));
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
};
|
|
4284
|
+
|
|
4072
4285
|
// src/index.ts
|
|
4073
4286
|
var gptCore = {
|
|
4074
4287
|
...sdk_gen_exports,
|
|
4075
|
-
client
|
|
4288
|
+
client,
|
|
4289
|
+
webhooks
|
|
4076
4290
|
};
|
|
4077
4291
|
var index_default = gptCore;
|
|
4078
4292
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -4102,6 +4316,9 @@ var index_default = gptCore;
|
|
|
4102
4316
|
ThreadCreateSchema,
|
|
4103
4317
|
TimeoutError,
|
|
4104
4318
|
ValidationError,
|
|
4319
|
+
WebhookConfigCreateSchema,
|
|
4320
|
+
WebhookConfigUpdateSchema,
|
|
4321
|
+
WebhookError,
|
|
4105
4322
|
WorkspaceCreateSchema,
|
|
4106
4323
|
calculateBackoff,
|
|
4107
4324
|
client,
|
|
@@ -4371,5 +4588,6 @@ var index_default = gptCore;
|
|
|
4371
4588
|
sleep,
|
|
4372
4589
|
streamMessage,
|
|
4373
4590
|
streamSSE,
|
|
4591
|
+
webhooks,
|
|
4374
4592
|
withRetry
|
|
4375
4593
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -274,15 +274,6 @@ var jsonBodySerializer = {
|
|
|
274
274
|
)
|
|
275
275
|
};
|
|
276
276
|
|
|
277
|
-
// src/_internal/core/params.gen.ts
|
|
278
|
-
var extraPrefixesMap = {
|
|
279
|
-
$body_: "body",
|
|
280
|
-
$headers_: "headers",
|
|
281
|
-
$path_: "path",
|
|
282
|
-
$query_: "query"
|
|
283
|
-
};
|
|
284
|
-
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
285
|
-
|
|
286
277
|
// src/_internal/core/serverSentEvents.gen.ts
|
|
287
278
|
var createSseClient = ({
|
|
288
279
|
onRequest,
|
|
@@ -3603,6 +3594,28 @@ var PresignedUploadSchema = z.object({
|
|
|
3603
3594
|
var PresignedDownloadSchema = z.object({
|
|
3604
3595
|
file_id: z.string().uuid()
|
|
3605
3596
|
});
|
|
3597
|
+
var WebhookConfigCreateSchema = z.object({
|
|
3598
|
+
name: z.string().min(1).max(255),
|
|
3599
|
+
url: z.string().url(),
|
|
3600
|
+
events: z.array(z.string()).optional(),
|
|
3601
|
+
enabled: z.boolean().optional().default(true),
|
|
3602
|
+
secret: z.string().optional(),
|
|
3603
|
+
// Tenant-level webhook: set tenant_id to scope to a specific tenant
|
|
3604
|
+
tenant_id: z.string().uuid().optional(),
|
|
3605
|
+
// ISV filter: specific tenant UUIDs to receive events from (null = all)
|
|
3606
|
+
tenant_ids: z.array(z.string().uuid()).optional(),
|
|
3607
|
+
// Tenant filter: specific workspace UUIDs to receive events from (null = all)
|
|
3608
|
+
workspace_ids: z.array(z.string().uuid()).optional()
|
|
3609
|
+
});
|
|
3610
|
+
var WebhookConfigUpdateSchema = z.object({
|
|
3611
|
+
name: z.string().min(1).max(255).optional(),
|
|
3612
|
+
url: z.string().url().optional(),
|
|
3613
|
+
events: z.array(z.string()).optional(),
|
|
3614
|
+
enabled: z.boolean().optional(),
|
|
3615
|
+
secret: z.string().optional(),
|
|
3616
|
+
tenant_ids: z.array(z.string().uuid()).optional(),
|
|
3617
|
+
workspace_ids: z.array(z.string().uuid()).optional()
|
|
3618
|
+
});
|
|
3606
3619
|
|
|
3607
3620
|
// src/utils/retry.ts
|
|
3608
3621
|
var DEFAULT_RETRY_CONFIG = {
|
|
@@ -3754,10 +3767,207 @@ async function collectStreamedMessage(stream) {
|
|
|
3754
3767
|
return fullMessage;
|
|
3755
3768
|
}
|
|
3756
3769
|
|
|
3770
|
+
// src/webhooks.ts
|
|
3771
|
+
var WebhookError = class extends Error {
|
|
3772
|
+
constructor(message, status, errors) {
|
|
3773
|
+
super(message);
|
|
3774
|
+
this.status = status;
|
|
3775
|
+
this.errors = errors;
|
|
3776
|
+
this.name = "WebhookError";
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
function unwrap(data) {
|
|
3780
|
+
if (data && typeof data === "object" && "attributes" in data) {
|
|
3781
|
+
const obj = data;
|
|
3782
|
+
return { id: obj.id, ...obj.attributes };
|
|
3783
|
+
}
|
|
3784
|
+
return data;
|
|
3785
|
+
}
|
|
3786
|
+
function handleError(error) {
|
|
3787
|
+
if (error && typeof error === "object") {
|
|
3788
|
+
const err = error;
|
|
3789
|
+
throw new WebhookError(
|
|
3790
|
+
err.detail || "Webhook operation failed",
|
|
3791
|
+
err.status,
|
|
3792
|
+
err.errors
|
|
3793
|
+
);
|
|
3794
|
+
}
|
|
3795
|
+
throw new WebhookError("Unknown error");
|
|
3796
|
+
}
|
|
3797
|
+
function processResult(result) {
|
|
3798
|
+
const r = result;
|
|
3799
|
+
if (r.error) handleError(r.error);
|
|
3800
|
+
return r.data?.data;
|
|
3801
|
+
}
|
|
3802
|
+
function processArrayResult(result) {
|
|
3803
|
+
const r = result;
|
|
3804
|
+
if (r.error) handleError(r.error);
|
|
3805
|
+
return (r.data?.data || []).map((d) => unwrap(d));
|
|
3806
|
+
}
|
|
3807
|
+
var webhooks = {
|
|
3808
|
+
/**
|
|
3809
|
+
* List all webhook configurations accessible to the current user.
|
|
3810
|
+
*
|
|
3811
|
+
* For tenant users, this returns webhooks scoped to their tenant.
|
|
3812
|
+
* For ISV/app owners, this returns application-level webhooks.
|
|
3813
|
+
*/
|
|
3814
|
+
async list(options) {
|
|
3815
|
+
const result = await getWebhookConfigs({
|
|
3816
|
+
headers: { "x-application-key": "" },
|
|
3817
|
+
query: options?.filter
|
|
3818
|
+
});
|
|
3819
|
+
return processArrayResult(result);
|
|
3820
|
+
},
|
|
3821
|
+
/**
|
|
3822
|
+
* Get a single webhook configuration by ID.
|
|
3823
|
+
*/
|
|
3824
|
+
async get(id) {
|
|
3825
|
+
const result = await getWebhookConfigsById({
|
|
3826
|
+
headers: { "x-application-key": "" },
|
|
3827
|
+
path: { id }
|
|
3828
|
+
});
|
|
3829
|
+
return unwrap(processResult(result));
|
|
3830
|
+
},
|
|
3831
|
+
/**
|
|
3832
|
+
* Create a new webhook configuration.
|
|
3833
|
+
*
|
|
3834
|
+
* For tenant-level webhooks, include `tenant_id` in the attributes.
|
|
3835
|
+
* The tenant_id is typically obtained from the user's profile.
|
|
3836
|
+
*
|
|
3837
|
+
* @example
|
|
3838
|
+
* ```typescript
|
|
3839
|
+
* // Tenant-level webhook (receives only this tenant's events)
|
|
3840
|
+
* const webhook = await webhooks.create({
|
|
3841
|
+
* name: 'My Webhook',
|
|
3842
|
+
* url: 'https://example.com/webhook',
|
|
3843
|
+
* events: ['extraction.completed', 'document.processed'],
|
|
3844
|
+
* tenant_id: userProfile.tenant_id,
|
|
3845
|
+
* });
|
|
3846
|
+
*
|
|
3847
|
+
* // With workspace filtering (only events from specific workspaces)
|
|
3848
|
+
* const webhook = await webhooks.create({
|
|
3849
|
+
* name: 'Workspace Webhook',
|
|
3850
|
+
* url: 'https://example.com/webhook',
|
|
3851
|
+
* tenant_id: userProfile.tenant_id,
|
|
3852
|
+
* workspace_ids: ['workspace-uuid-1', 'workspace-uuid-2'],
|
|
3853
|
+
* });
|
|
3854
|
+
* ```
|
|
3855
|
+
*/
|
|
3856
|
+
async create(attributes) {
|
|
3857
|
+
const validated = WebhookConfigCreateSchema.parse(attributes);
|
|
3858
|
+
const result = await postWebhookConfigs({
|
|
3859
|
+
headers: { "x-application-key": "" },
|
|
3860
|
+
body: {
|
|
3861
|
+
data: {
|
|
3862
|
+
type: "webhook_config",
|
|
3863
|
+
attributes: validated
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
});
|
|
3867
|
+
return unwrap(processResult(result));
|
|
3868
|
+
},
|
|
3869
|
+
/**
|
|
3870
|
+
* Update an existing webhook configuration.
|
|
3871
|
+
*/
|
|
3872
|
+
async update(id, attributes) {
|
|
3873
|
+
const validated = WebhookConfigUpdateSchema.parse(attributes);
|
|
3874
|
+
const result = await patchWebhookConfigsById({
|
|
3875
|
+
headers: { "x-application-key": "" },
|
|
3876
|
+
path: { id },
|
|
3877
|
+
body: {
|
|
3878
|
+
data: {
|
|
3879
|
+
type: "webhook_config",
|
|
3880
|
+
id,
|
|
3881
|
+
attributes: validated
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
});
|
|
3885
|
+
return unwrap(processResult(result));
|
|
3886
|
+
},
|
|
3887
|
+
/**
|
|
3888
|
+
* Delete a webhook configuration.
|
|
3889
|
+
*/
|
|
3890
|
+
async delete(id) {
|
|
3891
|
+
const result = await deleteWebhookConfigsById({
|
|
3892
|
+
headers: { "x-application-key": "" },
|
|
3893
|
+
path: { id }
|
|
3894
|
+
});
|
|
3895
|
+
const r = result;
|
|
3896
|
+
if (r.error) handleError(r.error);
|
|
3897
|
+
},
|
|
3898
|
+
/**
|
|
3899
|
+
* Send a test webhook to verify the endpoint is reachable.
|
|
3900
|
+
*
|
|
3901
|
+
* This enqueues a test webhook delivery with a sample payload.
|
|
3902
|
+
* Check the deliveries list to see the result.
|
|
3903
|
+
*/
|
|
3904
|
+
async test(id) {
|
|
3905
|
+
const result = await postWebhookConfigsByIdTest({
|
|
3906
|
+
headers: { "x-application-key": "" },
|
|
3907
|
+
path: { id }
|
|
3908
|
+
});
|
|
3909
|
+
return unwrap(processResult(result));
|
|
3910
|
+
},
|
|
3911
|
+
/**
|
|
3912
|
+
* Rotate the webhook secret.
|
|
3913
|
+
*
|
|
3914
|
+
* This generates a new secret for the webhook. The old secret
|
|
3915
|
+
* becomes invalid immediately. Make sure to update your endpoint
|
|
3916
|
+
* with the new secret.
|
|
3917
|
+
*/
|
|
3918
|
+
async rotateSecret(id) {
|
|
3919
|
+
const result = await patchWebhookConfigsByIdRotateSecret({
|
|
3920
|
+
headers: { "x-application-key": "" },
|
|
3921
|
+
path: { id }
|
|
3922
|
+
});
|
|
3923
|
+
return unwrap(processResult(result));
|
|
3924
|
+
},
|
|
3925
|
+
/**
|
|
3926
|
+
* Webhook delivery management
|
|
3927
|
+
*/
|
|
3928
|
+
deliveries: {
|
|
3929
|
+
/**
|
|
3930
|
+
* List webhook deliveries.
|
|
3931
|
+
*
|
|
3932
|
+
* Deliveries are sorted by newest first by default.
|
|
3933
|
+
*/
|
|
3934
|
+
async list(options) {
|
|
3935
|
+
const result = await getWebhookDeliveries({
|
|
3936
|
+
headers: { "x-application-key": "" },
|
|
3937
|
+
query: options?.filter
|
|
3938
|
+
});
|
|
3939
|
+
return processArrayResult(result);
|
|
3940
|
+
},
|
|
3941
|
+
/**
|
|
3942
|
+
* Get a single webhook delivery by ID.
|
|
3943
|
+
*/
|
|
3944
|
+
async get(id) {
|
|
3945
|
+
const result = await getWebhookDeliveriesById({
|
|
3946
|
+
headers: { "x-application-key": "" },
|
|
3947
|
+
path: { id }
|
|
3948
|
+
});
|
|
3949
|
+
return unwrap(processResult(result));
|
|
3950
|
+
},
|
|
3951
|
+
/**
|
|
3952
|
+
* Retry a failed webhook delivery.
|
|
3953
|
+
*
|
|
3954
|
+
* This re-enqueues the delivery for another attempt.
|
|
3955
|
+
*/
|
|
3956
|
+
async retry(id) {
|
|
3957
|
+
const result = await postWebhookDeliveriesByIdRetry({
|
|
3958
|
+
headers: { "x-application-key": "" },
|
|
3959
|
+
path: { id }
|
|
3960
|
+
});
|
|
3961
|
+
return unwrap(processResult(result));
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
};
|
|
3965
|
+
|
|
3757
3966
|
// src/index.ts
|
|
3758
3967
|
var gptCore = {
|
|
3759
3968
|
...sdk_gen_exports,
|
|
3760
|
-
client
|
|
3969
|
+
client,
|
|
3970
|
+
webhooks
|
|
3761
3971
|
};
|
|
3762
3972
|
var index_default = gptCore;
|
|
3763
3973
|
export {
|
|
@@ -3786,6 +3996,9 @@ export {
|
|
|
3786
3996
|
ThreadCreateSchema,
|
|
3787
3997
|
TimeoutError,
|
|
3788
3998
|
ValidationError,
|
|
3999
|
+
WebhookConfigCreateSchema,
|
|
4000
|
+
WebhookConfigUpdateSchema,
|
|
4001
|
+
WebhookError,
|
|
3789
4002
|
WorkspaceCreateSchema,
|
|
3790
4003
|
calculateBackoff,
|
|
3791
4004
|
client,
|
|
@@ -4056,5 +4269,6 @@ export {
|
|
|
4056
4269
|
sleep,
|
|
4057
4270
|
streamMessage,
|
|
4058
4271
|
streamSSE,
|
|
4272
|
+
webhooks,
|
|
4059
4273
|
withRetry
|
|
4060
4274
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpt-core/client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
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",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
15
24
|
"files": [
|
|
16
25
|
"dist"
|
|
17
26
|
],
|
|
@@ -34,6 +43,14 @@
|
|
|
34
43
|
"publishConfig": {
|
|
35
44
|
"access": "public"
|
|
36
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
|
+
},
|
|
37
54
|
"dependencies": {
|
|
38
55
|
"eventsource-parser": "^3.0.6",
|
|
39
56
|
"zod": "^3.25.76"
|
|
@@ -45,13 +62,5 @@
|
|
|
45
62
|
"tsup": "^8.5.1",
|
|
46
63
|
"typescript": "^5.9.3",
|
|
47
64
|
"vitest": "^4.0.15"
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"generate": "openapi-ts",
|
|
51
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
52
|
-
"test": "vitest run",
|
|
53
|
-
"test:watch": "vitest",
|
|
54
|
-
"test:ui": "vitest --ui",
|
|
55
|
-
"test:coverage": "vitest run --coverage"
|
|
56
65
|
}
|
|
57
|
-
}
|
|
66
|
+
}
|