@gemina/sdk 0.16.1 → 0.17.1
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 +100 -0
- package/dist/index.cjs +1397 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1489 -168
- package/dist/index.d.ts +1489 -168
- package/dist/index.js +1318 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10291,6 +10291,892 @@ var TemplatesApi = class extends BaseAPI {
|
|
|
10291
10291
|
}
|
|
10292
10292
|
};
|
|
10293
10293
|
|
|
10294
|
+
// src/generated/models/CreatedWebhookEndpointOutDTO.ts
|
|
10295
|
+
var CreatedWebhookEndpointOutDTODisabledReasonEnum = {
|
|
10296
|
+
User: "user",
|
|
10297
|
+
Gone: "gone",
|
|
10298
|
+
Failing: "failing",
|
|
10299
|
+
AccountDeleted: "account_deleted",
|
|
10300
|
+
Operator: "operator"
|
|
10301
|
+
};
|
|
10302
|
+
function instanceOfCreatedWebhookEndpointOutDTO(value) {
|
|
10303
|
+
if (!("enabled" in value) || value["enabled"] === void 0) return false;
|
|
10304
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
10305
|
+
if (!("notBefore" in value) || value["notBefore"] === void 0) return false;
|
|
10306
|
+
if (!("secret" in value) || value["secret"] === void 0) return false;
|
|
10307
|
+
if (!("url" in value) || value["url"] === void 0) return false;
|
|
10308
|
+
return true;
|
|
10309
|
+
}
|
|
10310
|
+
function CreatedWebhookEndpointOutDTOFromJSON(json) {
|
|
10311
|
+
return CreatedWebhookEndpointOutDTOFromJSONTyped(json, false);
|
|
10312
|
+
}
|
|
10313
|
+
function CreatedWebhookEndpointOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10314
|
+
if (json == null) {
|
|
10315
|
+
return json;
|
|
10316
|
+
}
|
|
10317
|
+
return {
|
|
10318
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10319
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10320
|
+
"description": json["description"] == null ? void 0 : json["description"],
|
|
10321
|
+
"disabledAt": json["disabledAt"] == null ? void 0 : new Date(json["disabledAt"]),
|
|
10322
|
+
"disabledReason": json["disabledReason"] == null ? void 0 : json["disabledReason"],
|
|
10323
|
+
"enabled": json["enabled"],
|
|
10324
|
+
"failing": json["failing"] == null ? void 0 : json["failing"],
|
|
10325
|
+
"failingSince": json["failingSince"] == null ? void 0 : new Date(json["failingSince"]),
|
|
10326
|
+
"id": json["id"],
|
|
10327
|
+
"lastDeliveredAt": json["lastDeliveredAt"] == null ? void 0 : new Date(json["lastDeliveredAt"]),
|
|
10328
|
+
"lastTestSucceededAt": json["lastTestSucceededAt"] == null ? void 0 : new Date(json["lastTestSucceededAt"]),
|
|
10329
|
+
"notBefore": new Date(json["notBefore"]),
|
|
10330
|
+
"previousSecretExpiresAt": json["previousSecretExpiresAt"] == null ? void 0 : new Date(json["previousSecretExpiresAt"]),
|
|
10331
|
+
"secret": json["secret"],
|
|
10332
|
+
"url": json["url"]
|
|
10333
|
+
};
|
|
10334
|
+
}
|
|
10335
|
+
function CreatedWebhookEndpointOutDTOToJSON(json) {
|
|
10336
|
+
return CreatedWebhookEndpointOutDTOToJSONTyped(json, false);
|
|
10337
|
+
}
|
|
10338
|
+
function CreatedWebhookEndpointOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10339
|
+
if (value == null) {
|
|
10340
|
+
return value;
|
|
10341
|
+
}
|
|
10342
|
+
return {
|
|
10343
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10344
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10345
|
+
"description": value["description"],
|
|
10346
|
+
"disabledAt": value["disabledAt"] == null ? value["disabledAt"] : value["disabledAt"].toISOString(),
|
|
10347
|
+
"disabledReason": value["disabledReason"],
|
|
10348
|
+
"enabled": value["enabled"],
|
|
10349
|
+
"failing": value["failing"],
|
|
10350
|
+
"failingSince": value["failingSince"] == null ? value["failingSince"] : value["failingSince"].toISOString(),
|
|
10351
|
+
"id": value["id"],
|
|
10352
|
+
"lastDeliveredAt": value["lastDeliveredAt"] == null ? value["lastDeliveredAt"] : value["lastDeliveredAt"].toISOString(),
|
|
10353
|
+
"lastTestSucceededAt": value["lastTestSucceededAt"] == null ? value["lastTestSucceededAt"] : value["lastTestSucceededAt"].toISOString(),
|
|
10354
|
+
"notBefore": value["notBefore"].toISOString(),
|
|
10355
|
+
"previousSecretExpiresAt": value["previousSecretExpiresAt"] == null ? value["previousSecretExpiresAt"] : value["previousSecretExpiresAt"].toISOString(),
|
|
10356
|
+
"secret": value["secret"],
|
|
10357
|
+
"url": value["url"]
|
|
10358
|
+
};
|
|
10359
|
+
}
|
|
10360
|
+
|
|
10361
|
+
// src/generated/models/WebhookDeliveryResultOutDTO.ts
|
|
10362
|
+
function instanceOfWebhookDeliveryResultOutDTO(value) {
|
|
10363
|
+
if (!("attemptId" in value) || value["attemptId"] === void 0) return false;
|
|
10364
|
+
if (!("eventId" in value) || value["eventId"] === void 0) return false;
|
|
10365
|
+
return true;
|
|
10366
|
+
}
|
|
10367
|
+
function WebhookDeliveryResultOutDTOFromJSON(json) {
|
|
10368
|
+
return WebhookDeliveryResultOutDTOFromJSONTyped(json, false);
|
|
10369
|
+
}
|
|
10370
|
+
function WebhookDeliveryResultOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10371
|
+
if (json == null) {
|
|
10372
|
+
return json;
|
|
10373
|
+
}
|
|
10374
|
+
return {
|
|
10375
|
+
"attemptId": json["attemptId"],
|
|
10376
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10377
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10378
|
+
"delivered": json["delivered"] == null ? void 0 : json["delivered"],
|
|
10379
|
+
"durationMs": json["durationMs"] == null ? void 0 : json["durationMs"],
|
|
10380
|
+
"error": json["error"] == null ? void 0 : json["error"],
|
|
10381
|
+
"eventId": json["eventId"],
|
|
10382
|
+
"httpStatus": json["httpStatus"] == null ? void 0 : json["httpStatus"],
|
|
10383
|
+
"pending": json["pending"] == null ? void 0 : json["pending"],
|
|
10384
|
+
"responseSnippet": json["responseSnippet"] == null ? void 0 : json["responseSnippet"],
|
|
10385
|
+
"servedAt": json["servedAt"] == null ? void 0 : new Date(json["servedAt"]),
|
|
10386
|
+
"servedAtTimestamp": json["servedAtTimestamp"] == null ? void 0 : json["servedAtTimestamp"]
|
|
10387
|
+
};
|
|
10388
|
+
}
|
|
10389
|
+
function WebhookDeliveryResultOutDTOToJSON(json) {
|
|
10390
|
+
return WebhookDeliveryResultOutDTOToJSONTyped(json, false);
|
|
10391
|
+
}
|
|
10392
|
+
function WebhookDeliveryResultOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10393
|
+
if (value == null) {
|
|
10394
|
+
return value;
|
|
10395
|
+
}
|
|
10396
|
+
return {
|
|
10397
|
+
"attemptId": value["attemptId"],
|
|
10398
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10399
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10400
|
+
"delivered": value["delivered"],
|
|
10401
|
+
"durationMs": value["durationMs"],
|
|
10402
|
+
"error": value["error"],
|
|
10403
|
+
"eventId": value["eventId"],
|
|
10404
|
+
"httpStatus": value["httpStatus"],
|
|
10405
|
+
"pending": value["pending"],
|
|
10406
|
+
"responseSnippet": value["responseSnippet"],
|
|
10407
|
+
"servedAt": value["servedAt"] == null ? value["servedAt"] : value["servedAt"].toISOString(),
|
|
10408
|
+
"servedAtTimestamp": value["servedAtTimestamp"]
|
|
10409
|
+
};
|
|
10410
|
+
}
|
|
10411
|
+
|
|
10412
|
+
// src/generated/models/WebhookEndpointCreateInDTO.ts
|
|
10413
|
+
function instanceOfWebhookEndpointCreateInDTO(value) {
|
|
10414
|
+
if (!("url" in value) || value["url"] === void 0) return false;
|
|
10415
|
+
return true;
|
|
10416
|
+
}
|
|
10417
|
+
function WebhookEndpointCreateInDTOFromJSON(json) {
|
|
10418
|
+
return WebhookEndpointCreateInDTOFromJSONTyped(json, false);
|
|
10419
|
+
}
|
|
10420
|
+
function WebhookEndpointCreateInDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10421
|
+
if (json == null) {
|
|
10422
|
+
return json;
|
|
10423
|
+
}
|
|
10424
|
+
return {
|
|
10425
|
+
"description": json["description"] == null ? void 0 : json["description"],
|
|
10426
|
+
"url": json["url"]
|
|
10427
|
+
};
|
|
10428
|
+
}
|
|
10429
|
+
function WebhookEndpointCreateInDTOToJSON(json) {
|
|
10430
|
+
return WebhookEndpointCreateInDTOToJSONTyped(json, false);
|
|
10431
|
+
}
|
|
10432
|
+
function WebhookEndpointCreateInDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10433
|
+
if (value == null) {
|
|
10434
|
+
return value;
|
|
10435
|
+
}
|
|
10436
|
+
return {
|
|
10437
|
+
"description": value["description"],
|
|
10438
|
+
"url": value["url"]
|
|
10439
|
+
};
|
|
10440
|
+
}
|
|
10441
|
+
|
|
10442
|
+
// src/generated/models/WebhookEndpointOutDTO.ts
|
|
10443
|
+
var WebhookEndpointOutDTODisabledReasonEnum = {
|
|
10444
|
+
User: "user",
|
|
10445
|
+
Gone: "gone",
|
|
10446
|
+
Failing: "failing",
|
|
10447
|
+
AccountDeleted: "account_deleted",
|
|
10448
|
+
Operator: "operator"
|
|
10449
|
+
};
|
|
10450
|
+
function instanceOfWebhookEndpointOutDTO(value) {
|
|
10451
|
+
if (!("enabled" in value) || value["enabled"] === void 0) return false;
|
|
10452
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
10453
|
+
if (!("notBefore" in value) || value["notBefore"] === void 0) return false;
|
|
10454
|
+
if (!("url" in value) || value["url"] === void 0) return false;
|
|
10455
|
+
return true;
|
|
10456
|
+
}
|
|
10457
|
+
function WebhookEndpointOutDTOFromJSON(json) {
|
|
10458
|
+
return WebhookEndpointOutDTOFromJSONTyped(json, false);
|
|
10459
|
+
}
|
|
10460
|
+
function WebhookEndpointOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10461
|
+
if (json == null) {
|
|
10462
|
+
return json;
|
|
10463
|
+
}
|
|
10464
|
+
return {
|
|
10465
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10466
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10467
|
+
"description": json["description"] == null ? void 0 : json["description"],
|
|
10468
|
+
"disabledAt": json["disabledAt"] == null ? void 0 : new Date(json["disabledAt"]),
|
|
10469
|
+
"disabledReason": json["disabledReason"] == null ? void 0 : json["disabledReason"],
|
|
10470
|
+
"enabled": json["enabled"],
|
|
10471
|
+
"failing": json["failing"] == null ? void 0 : json["failing"],
|
|
10472
|
+
"failingSince": json["failingSince"] == null ? void 0 : new Date(json["failingSince"]),
|
|
10473
|
+
"id": json["id"],
|
|
10474
|
+
"lastDeliveredAt": json["lastDeliveredAt"] == null ? void 0 : new Date(json["lastDeliveredAt"]),
|
|
10475
|
+
"lastTestSucceededAt": json["lastTestSucceededAt"] == null ? void 0 : new Date(json["lastTestSucceededAt"]),
|
|
10476
|
+
"notBefore": new Date(json["notBefore"]),
|
|
10477
|
+
"previousSecretExpiresAt": json["previousSecretExpiresAt"] == null ? void 0 : new Date(json["previousSecretExpiresAt"]),
|
|
10478
|
+
"url": json["url"]
|
|
10479
|
+
};
|
|
10480
|
+
}
|
|
10481
|
+
function WebhookEndpointOutDTOToJSON(json) {
|
|
10482
|
+
return WebhookEndpointOutDTOToJSONTyped(json, false);
|
|
10483
|
+
}
|
|
10484
|
+
function WebhookEndpointOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10485
|
+
if (value == null) {
|
|
10486
|
+
return value;
|
|
10487
|
+
}
|
|
10488
|
+
return {
|
|
10489
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10490
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10491
|
+
"description": value["description"],
|
|
10492
|
+
"disabledAt": value["disabledAt"] == null ? value["disabledAt"] : value["disabledAt"].toISOString(),
|
|
10493
|
+
"disabledReason": value["disabledReason"],
|
|
10494
|
+
"enabled": value["enabled"],
|
|
10495
|
+
"failing": value["failing"],
|
|
10496
|
+
"failingSince": value["failingSince"] == null ? value["failingSince"] : value["failingSince"].toISOString(),
|
|
10497
|
+
"id": value["id"],
|
|
10498
|
+
"lastDeliveredAt": value["lastDeliveredAt"] == null ? value["lastDeliveredAt"] : value["lastDeliveredAt"].toISOString(),
|
|
10499
|
+
"lastTestSucceededAt": value["lastTestSucceededAt"] == null ? value["lastTestSucceededAt"] : value["lastTestSucceededAt"].toISOString(),
|
|
10500
|
+
"notBefore": value["notBefore"].toISOString(),
|
|
10501
|
+
"previousSecretExpiresAt": value["previousSecretExpiresAt"] == null ? value["previousSecretExpiresAt"] : value["previousSecretExpiresAt"].toISOString(),
|
|
10502
|
+
"url": value["url"]
|
|
10503
|
+
};
|
|
10504
|
+
}
|
|
10505
|
+
|
|
10506
|
+
// src/generated/models/WebhookEndpointListOutDTO.ts
|
|
10507
|
+
function instanceOfWebhookEndpointListOutDTO(value) {
|
|
10508
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
10509
|
+
if (!("endpoints" in value) || value["endpoints"] === void 0) return false;
|
|
10510
|
+
return true;
|
|
10511
|
+
}
|
|
10512
|
+
function WebhookEndpointListOutDTOFromJSON(json) {
|
|
10513
|
+
return WebhookEndpointListOutDTOFromJSONTyped(json, false);
|
|
10514
|
+
}
|
|
10515
|
+
function WebhookEndpointListOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10516
|
+
if (json == null) {
|
|
10517
|
+
return json;
|
|
10518
|
+
}
|
|
10519
|
+
return {
|
|
10520
|
+
"count": json["count"],
|
|
10521
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10522
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10523
|
+
"endpoints": json["endpoints"].map(WebhookEndpointOutDTOFromJSON),
|
|
10524
|
+
"servedAt": json["servedAt"] == null ? void 0 : new Date(json["servedAt"]),
|
|
10525
|
+
"servedAtTimestamp": json["servedAtTimestamp"] == null ? void 0 : json["servedAtTimestamp"]
|
|
10526
|
+
};
|
|
10527
|
+
}
|
|
10528
|
+
function WebhookEndpointListOutDTOToJSON(json) {
|
|
10529
|
+
return WebhookEndpointListOutDTOToJSONTyped(json, false);
|
|
10530
|
+
}
|
|
10531
|
+
function WebhookEndpointListOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10532
|
+
if (value == null) {
|
|
10533
|
+
return value;
|
|
10534
|
+
}
|
|
10535
|
+
return {
|
|
10536
|
+
"count": value["count"],
|
|
10537
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10538
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10539
|
+
"endpoints": value["endpoints"].map(WebhookEndpointOutDTOToJSON),
|
|
10540
|
+
"servedAt": value["servedAt"] == null ? value["servedAt"] : value["servedAt"].toISOString(),
|
|
10541
|
+
"servedAtTimestamp": value["servedAtTimestamp"]
|
|
10542
|
+
};
|
|
10543
|
+
}
|
|
10544
|
+
|
|
10545
|
+
// src/generated/models/WebhookEndpointUpdateInDTO.ts
|
|
10546
|
+
function instanceOfWebhookEndpointUpdateInDTO(value) {
|
|
10547
|
+
return true;
|
|
10548
|
+
}
|
|
10549
|
+
function WebhookEndpointUpdateInDTOFromJSON(json) {
|
|
10550
|
+
return WebhookEndpointUpdateInDTOFromJSONTyped(json, false);
|
|
10551
|
+
}
|
|
10552
|
+
function WebhookEndpointUpdateInDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10553
|
+
if (json == null) {
|
|
10554
|
+
return json;
|
|
10555
|
+
}
|
|
10556
|
+
return {
|
|
10557
|
+
"description": json["description"] == null ? void 0 : json["description"],
|
|
10558
|
+
"enabled": json["enabled"] == null ? void 0 : json["enabled"],
|
|
10559
|
+
"url": json["url"] == null ? void 0 : json["url"]
|
|
10560
|
+
};
|
|
10561
|
+
}
|
|
10562
|
+
function WebhookEndpointUpdateInDTOToJSON(json) {
|
|
10563
|
+
return WebhookEndpointUpdateInDTOToJSONTyped(json, false);
|
|
10564
|
+
}
|
|
10565
|
+
function WebhookEndpointUpdateInDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10566
|
+
if (value == null) {
|
|
10567
|
+
return value;
|
|
10568
|
+
}
|
|
10569
|
+
return {
|
|
10570
|
+
"description": value["description"],
|
|
10571
|
+
"enabled": value["enabled"],
|
|
10572
|
+
"url": value["url"]
|
|
10573
|
+
};
|
|
10574
|
+
}
|
|
10575
|
+
|
|
10576
|
+
// src/generated/models/WebhookAttemptOutDTO.ts
|
|
10577
|
+
function instanceOfWebhookAttemptOutDTO(value) {
|
|
10578
|
+
if (!("attemptNumber" in value) || value["attemptNumber"] === void 0) return false;
|
|
10579
|
+
if (!("attemptedAt" in value) || value["attemptedAt"] === void 0) return false;
|
|
10580
|
+
if (!("durationMs" in value) || value["durationMs"] === void 0) return false;
|
|
10581
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
10582
|
+
return true;
|
|
10583
|
+
}
|
|
10584
|
+
function WebhookAttemptOutDTOFromJSON(json) {
|
|
10585
|
+
return WebhookAttemptOutDTOFromJSONTyped(json, false);
|
|
10586
|
+
}
|
|
10587
|
+
function WebhookAttemptOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10588
|
+
if (json == null) {
|
|
10589
|
+
return json;
|
|
10590
|
+
}
|
|
10591
|
+
return {
|
|
10592
|
+
"attemptNumber": json["attemptNumber"],
|
|
10593
|
+
"attemptedAt": new Date(json["attemptedAt"]),
|
|
10594
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10595
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10596
|
+
"durationMs": json["durationMs"],
|
|
10597
|
+
"error": json["error"] == null ? void 0 : json["error"],
|
|
10598
|
+
"httpStatus": json["httpStatus"] == null ? void 0 : json["httpStatus"],
|
|
10599
|
+
"id": json["id"],
|
|
10600
|
+
"responseSnippet": json["responseSnippet"] == null ? void 0 : json["responseSnippet"]
|
|
10601
|
+
};
|
|
10602
|
+
}
|
|
10603
|
+
function WebhookAttemptOutDTOToJSON(json) {
|
|
10604
|
+
return WebhookAttemptOutDTOToJSONTyped(json, false);
|
|
10605
|
+
}
|
|
10606
|
+
function WebhookAttemptOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10607
|
+
if (value == null) {
|
|
10608
|
+
return value;
|
|
10609
|
+
}
|
|
10610
|
+
return {
|
|
10611
|
+
"attemptNumber": value["attemptNumber"],
|
|
10612
|
+
"attemptedAt": value["attemptedAt"].toISOString(),
|
|
10613
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10614
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10615
|
+
"durationMs": value["durationMs"],
|
|
10616
|
+
"error": value["error"],
|
|
10617
|
+
"httpStatus": value["httpStatus"],
|
|
10618
|
+
"id": value["id"],
|
|
10619
|
+
"responseSnippet": value["responseSnippet"]
|
|
10620
|
+
};
|
|
10621
|
+
}
|
|
10622
|
+
|
|
10623
|
+
// src/generated/models/WebhookEventOutDTO.ts
|
|
10624
|
+
var WebhookEventOutDTOFailureReasonEnum = {
|
|
10625
|
+
EndpointDisabled: "endpoint_disabled",
|
|
10626
|
+
RetriesExhausted: "retries_exhausted",
|
|
10627
|
+
Failed: "failed",
|
|
10628
|
+
Gone: "gone",
|
|
10629
|
+
NotFinal: "not_final",
|
|
10630
|
+
Unavailable: "unavailable",
|
|
10631
|
+
Superseded: "superseded"
|
|
10632
|
+
};
|
|
10633
|
+
var WebhookEventOutDTOStatusEnum = {
|
|
10634
|
+
Pending: "pending",
|
|
10635
|
+
Delivered: "delivered",
|
|
10636
|
+
Failed: "failed",
|
|
10637
|
+
Superseded: "superseded"
|
|
10638
|
+
};
|
|
10639
|
+
var WebhookEventOutDTOTypeEnum = {
|
|
10640
|
+
ExtractionCompleted: "extraction.completed",
|
|
10641
|
+
WebhookTest: "webhook.test"
|
|
10642
|
+
};
|
|
10643
|
+
function instanceOfWebhookEventOutDTO(value) {
|
|
10644
|
+
if (!("attemptCount" in value) || value["attemptCount"] === void 0) return false;
|
|
10645
|
+
if (!("endpointId" in value) || value["endpointId"] === void 0) return false;
|
|
10646
|
+
if (!("id" in value) || value["id"] === void 0) return false;
|
|
10647
|
+
if (!("manual" in value) || value["manual"] === void 0) return false;
|
|
10648
|
+
if (!("occurredAt" in value) || value["occurredAt"] === void 0) return false;
|
|
10649
|
+
if (!("status" in value) || value["status"] === void 0) return false;
|
|
10650
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
10651
|
+
if (!("webhookId" in value) || value["webhookId"] === void 0) return false;
|
|
10652
|
+
return true;
|
|
10653
|
+
}
|
|
10654
|
+
function WebhookEventOutDTOFromJSON(json) {
|
|
10655
|
+
return WebhookEventOutDTOFromJSONTyped(json, false);
|
|
10656
|
+
}
|
|
10657
|
+
function WebhookEventOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10658
|
+
if (json == null) {
|
|
10659
|
+
return json;
|
|
10660
|
+
}
|
|
10661
|
+
return {
|
|
10662
|
+
"attemptCount": json["attemptCount"],
|
|
10663
|
+
"attempts": json["attempts"] == null ? void 0 : json["attempts"].map(WebhookAttemptOutDTOFromJSON),
|
|
10664
|
+
"correlationId": json["correlationId"] == null ? void 0 : json["correlationId"],
|
|
10665
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10666
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10667
|
+
"deliveredAt": json["deliveredAt"] == null ? void 0 : new Date(json["deliveredAt"]),
|
|
10668
|
+
"documentId": json["documentId"] == null ? void 0 : json["documentId"],
|
|
10669
|
+
"endpointId": json["endpointId"],
|
|
10670
|
+
"externalId": json["externalId"] == null ? void 0 : json["externalId"],
|
|
10671
|
+
"failureReason": json["failureReason"] == null ? void 0 : json["failureReason"],
|
|
10672
|
+
"id": json["id"],
|
|
10673
|
+
"manual": json["manual"],
|
|
10674
|
+
"nextAttemptAt": json["nextAttemptAt"] == null ? void 0 : new Date(json["nextAttemptAt"]),
|
|
10675
|
+
"occurredAt": new Date(json["occurredAt"]),
|
|
10676
|
+
"outcome": json["outcome"] == null ? void 0 : json["outcome"],
|
|
10677
|
+
"status": json["status"],
|
|
10678
|
+
"type": json["type"],
|
|
10679
|
+
"webhookId": json["webhookId"]
|
|
10680
|
+
};
|
|
10681
|
+
}
|
|
10682
|
+
function WebhookEventOutDTOToJSON(json) {
|
|
10683
|
+
return WebhookEventOutDTOToJSONTyped(json, false);
|
|
10684
|
+
}
|
|
10685
|
+
function WebhookEventOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10686
|
+
if (value == null) {
|
|
10687
|
+
return value;
|
|
10688
|
+
}
|
|
10689
|
+
return {
|
|
10690
|
+
"attemptCount": value["attemptCount"],
|
|
10691
|
+
"attempts": value["attempts"] == null ? void 0 : value["attempts"].map(WebhookAttemptOutDTOToJSON),
|
|
10692
|
+
"correlationId": value["correlationId"],
|
|
10693
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10694
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10695
|
+
"deliveredAt": value["deliveredAt"] == null ? value["deliveredAt"] : value["deliveredAt"].toISOString(),
|
|
10696
|
+
"documentId": value["documentId"],
|
|
10697
|
+
"endpointId": value["endpointId"],
|
|
10698
|
+
"externalId": value["externalId"],
|
|
10699
|
+
"failureReason": value["failureReason"],
|
|
10700
|
+
"id": value["id"],
|
|
10701
|
+
"manual": value["manual"],
|
|
10702
|
+
"nextAttemptAt": value["nextAttemptAt"] == null ? value["nextAttemptAt"] : value["nextAttemptAt"].toISOString(),
|
|
10703
|
+
"occurredAt": value["occurredAt"].toISOString(),
|
|
10704
|
+
"outcome": value["outcome"],
|
|
10705
|
+
"status": value["status"],
|
|
10706
|
+
"type": value["type"],
|
|
10707
|
+
"webhookId": value["webhookId"]
|
|
10708
|
+
};
|
|
10709
|
+
}
|
|
10710
|
+
|
|
10711
|
+
// src/generated/models/WebhookEventListOutDTO.ts
|
|
10712
|
+
function instanceOfWebhookEventListOutDTO(value) {
|
|
10713
|
+
if (!("count" in value) || value["count"] === void 0) return false;
|
|
10714
|
+
if (!("events" in value) || value["events"] === void 0) return false;
|
|
10715
|
+
return true;
|
|
10716
|
+
}
|
|
10717
|
+
function WebhookEventListOutDTOFromJSON(json) {
|
|
10718
|
+
return WebhookEventListOutDTOFromJSONTyped(json, false);
|
|
10719
|
+
}
|
|
10720
|
+
function WebhookEventListOutDTOFromJSONTyped(json, ignoreDiscriminator) {
|
|
10721
|
+
if (json == null) {
|
|
10722
|
+
return json;
|
|
10723
|
+
}
|
|
10724
|
+
return {
|
|
10725
|
+
"count": json["count"],
|
|
10726
|
+
"createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
|
|
10727
|
+
"createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
|
|
10728
|
+
"events": json["events"].map(WebhookEventOutDTOFromJSON),
|
|
10729
|
+
"hasMore": json["hasMore"] == null ? void 0 : json["hasMore"],
|
|
10730
|
+
"nextCreatedBefore": json["nextCreatedBefore"] == null ? void 0 : json["nextCreatedBefore"],
|
|
10731
|
+
"servedAt": json["servedAt"] == null ? void 0 : new Date(json["servedAt"]),
|
|
10732
|
+
"servedAtTimestamp": json["servedAtTimestamp"] == null ? void 0 : json["servedAtTimestamp"]
|
|
10733
|
+
};
|
|
10734
|
+
}
|
|
10735
|
+
function WebhookEventListOutDTOToJSON(json) {
|
|
10736
|
+
return WebhookEventListOutDTOToJSONTyped(json, false);
|
|
10737
|
+
}
|
|
10738
|
+
function WebhookEventListOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
10739
|
+
if (value == null) {
|
|
10740
|
+
return value;
|
|
10741
|
+
}
|
|
10742
|
+
return {
|
|
10743
|
+
"count": value["count"],
|
|
10744
|
+
"createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
|
|
10745
|
+
"createdAtTimestamp": value["createdAtTimestamp"],
|
|
10746
|
+
"events": value["events"].map(WebhookEventOutDTOToJSON),
|
|
10747
|
+
"hasMore": value["hasMore"],
|
|
10748
|
+
"nextCreatedBefore": value["nextCreatedBefore"],
|
|
10749
|
+
"servedAt": value["servedAt"] == null ? value["servedAt"] : value["servedAt"].toISOString(),
|
|
10750
|
+
"servedAtTimestamp": value["servedAtTimestamp"]
|
|
10751
|
+
};
|
|
10752
|
+
}
|
|
10753
|
+
|
|
10754
|
+
// src/generated/apis/WebhooksApi.ts
|
|
10755
|
+
var WebhooksApi = class extends BaseAPI {
|
|
10756
|
+
/**
|
|
10757
|
+
* Creates request options for createWebhookEndpoint without sending the request
|
|
10758
|
+
*/
|
|
10759
|
+
async createWebhookEndpointRequestOpts(requestParameters) {
|
|
10760
|
+
if (requestParameters["webhookEndpointCreateInDTO"] == null) {
|
|
10761
|
+
throw new RequiredError(
|
|
10762
|
+
"webhookEndpointCreateInDTO",
|
|
10763
|
+
'Required parameter "webhookEndpointCreateInDTO" was null or undefined when calling createWebhookEndpoint().'
|
|
10764
|
+
);
|
|
10765
|
+
}
|
|
10766
|
+
const queryParameters = {};
|
|
10767
|
+
const headerParameters = {};
|
|
10768
|
+
headerParameters["Content-Type"] = "application/json";
|
|
10769
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
10770
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
10771
|
+
}
|
|
10772
|
+
let urlPath = `/api/v1/webhooks/endpoints`;
|
|
10773
|
+
return {
|
|
10774
|
+
path: urlPath,
|
|
10775
|
+
method: "POST",
|
|
10776
|
+
headers: headerParameters,
|
|
10777
|
+
query: queryParameters,
|
|
10778
|
+
body: WebhookEndpointCreateInDTOToJSON(requestParameters["webhookEndpointCreateInDTO"])
|
|
10779
|
+
};
|
|
10780
|
+
}
|
|
10781
|
+
/**
|
|
10782
|
+
* Register the account\'s webhook endpoint. The signing secret is returned once, here.
|
|
10783
|
+
* Create Webhook Endpoint
|
|
10784
|
+
*/
|
|
10785
|
+
async createWebhookEndpointRaw(requestParameters, initOverrides) {
|
|
10786
|
+
const requestOptions = await this.createWebhookEndpointRequestOpts(requestParameters);
|
|
10787
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
10788
|
+
return new JSONApiResponse(response, (jsonValue) => CreatedWebhookEndpointOutDTOFromJSON(jsonValue));
|
|
10789
|
+
}
|
|
10790
|
+
/**
|
|
10791
|
+
* Register the account\'s webhook endpoint. The signing secret is returned once, here.
|
|
10792
|
+
* Create Webhook Endpoint
|
|
10793
|
+
*/
|
|
10794
|
+
async createWebhookEndpoint(requestParameters, initOverrides) {
|
|
10795
|
+
const response = await this.createWebhookEndpointRaw(requestParameters, initOverrides);
|
|
10796
|
+
return await response.value();
|
|
10797
|
+
}
|
|
10798
|
+
/**
|
|
10799
|
+
* Creates request options for deleteWebhookEndpoint without sending the request
|
|
10800
|
+
*/
|
|
10801
|
+
async deleteWebhookEndpointRequestOpts(requestParameters) {
|
|
10802
|
+
if (requestParameters["endpointId"] == null) {
|
|
10803
|
+
throw new RequiredError(
|
|
10804
|
+
"endpointId",
|
|
10805
|
+
'Required parameter "endpointId" was null or undefined when calling deleteWebhookEndpoint().'
|
|
10806
|
+
);
|
|
10807
|
+
}
|
|
10808
|
+
const queryParameters = {};
|
|
10809
|
+
const headerParameters = {};
|
|
10810
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
10811
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
10812
|
+
}
|
|
10813
|
+
let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}`;
|
|
10814
|
+
urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
|
|
10815
|
+
return {
|
|
10816
|
+
path: urlPath,
|
|
10817
|
+
method: "DELETE",
|
|
10818
|
+
headers: headerParameters,
|
|
10819
|
+
query: queryParameters
|
|
10820
|
+
};
|
|
10821
|
+
}
|
|
10822
|
+
/**
|
|
10823
|
+
* Delete the endpoint. Its pending events are failed and nothing more is sent.
|
|
10824
|
+
* Delete Webhook Endpoint
|
|
10825
|
+
*/
|
|
10826
|
+
async deleteWebhookEndpointRaw(requestParameters, initOverrides) {
|
|
10827
|
+
const requestOptions = await this.deleteWebhookEndpointRequestOpts(requestParameters);
|
|
10828
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
10829
|
+
return new VoidApiResponse(response);
|
|
10830
|
+
}
|
|
10831
|
+
/**
|
|
10832
|
+
* Delete the endpoint. Its pending events are failed and nothing more is sent.
|
|
10833
|
+
* Delete Webhook Endpoint
|
|
10834
|
+
*/
|
|
10835
|
+
async deleteWebhookEndpoint(requestParameters, initOverrides) {
|
|
10836
|
+
await this.deleteWebhookEndpointRaw(requestParameters, initOverrides);
|
|
10837
|
+
}
|
|
10838
|
+
/**
|
|
10839
|
+
* Creates request options for getWebhookEndpoint without sending the request
|
|
10840
|
+
*/
|
|
10841
|
+
async getWebhookEndpointRequestOpts(requestParameters) {
|
|
10842
|
+
if (requestParameters["endpointId"] == null) {
|
|
10843
|
+
throw new RequiredError(
|
|
10844
|
+
"endpointId",
|
|
10845
|
+
'Required parameter "endpointId" was null or undefined when calling getWebhookEndpoint().'
|
|
10846
|
+
);
|
|
10847
|
+
}
|
|
10848
|
+
const queryParameters = {};
|
|
10849
|
+
const headerParameters = {};
|
|
10850
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
10851
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
10852
|
+
}
|
|
10853
|
+
let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}`;
|
|
10854
|
+
urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
|
|
10855
|
+
return {
|
|
10856
|
+
path: urlPath,
|
|
10857
|
+
method: "GET",
|
|
10858
|
+
headers: headerParameters,
|
|
10859
|
+
query: queryParameters
|
|
10860
|
+
};
|
|
10861
|
+
}
|
|
10862
|
+
/**
|
|
10863
|
+
* One webhook endpoint. The signing secret is never returned here.
|
|
10864
|
+
* Get Webhook Endpoint
|
|
10865
|
+
*/
|
|
10866
|
+
async getWebhookEndpointRaw(requestParameters, initOverrides) {
|
|
10867
|
+
const requestOptions = await this.getWebhookEndpointRequestOpts(requestParameters);
|
|
10868
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
10869
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookEndpointOutDTOFromJSON(jsonValue));
|
|
10870
|
+
}
|
|
10871
|
+
/**
|
|
10872
|
+
* One webhook endpoint. The signing secret is never returned here.
|
|
10873
|
+
* Get Webhook Endpoint
|
|
10874
|
+
*/
|
|
10875
|
+
async getWebhookEndpoint(requestParameters, initOverrides) {
|
|
10876
|
+
const response = await this.getWebhookEndpointRaw(requestParameters, initOverrides);
|
|
10877
|
+
return await response.value();
|
|
10878
|
+
}
|
|
10879
|
+
/**
|
|
10880
|
+
* Creates request options for getWebhookEvent without sending the request
|
|
10881
|
+
*/
|
|
10882
|
+
async getWebhookEventRequestOpts(requestParameters) {
|
|
10883
|
+
if (requestParameters["eventId"] == null) {
|
|
10884
|
+
throw new RequiredError(
|
|
10885
|
+
"eventId",
|
|
10886
|
+
'Required parameter "eventId" was null or undefined when calling getWebhookEvent().'
|
|
10887
|
+
);
|
|
10888
|
+
}
|
|
10889
|
+
const queryParameters = {};
|
|
10890
|
+
const headerParameters = {};
|
|
10891
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
10892
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
10893
|
+
}
|
|
10894
|
+
let urlPath = `/api/v1/webhooks/events/{event_id}`;
|
|
10895
|
+
urlPath = urlPath.replace("{event_id}", encodeURIComponent(String(requestParameters["eventId"])));
|
|
10896
|
+
return {
|
|
10897
|
+
path: urlPath,
|
|
10898
|
+
method: "GET",
|
|
10899
|
+
headers: headerParameters,
|
|
10900
|
+
query: queryParameters
|
|
10901
|
+
};
|
|
10902
|
+
}
|
|
10903
|
+
/**
|
|
10904
|
+
* One event with its delivery attempts. Use it to follow a test or a resend that was still pending.
|
|
10905
|
+
* Get Webhook Event
|
|
10906
|
+
*/
|
|
10907
|
+
async getWebhookEventRaw(requestParameters, initOverrides) {
|
|
10908
|
+
const requestOptions = await this.getWebhookEventRequestOpts(requestParameters);
|
|
10909
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
10910
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookEventOutDTOFromJSON(jsonValue));
|
|
10911
|
+
}
|
|
10912
|
+
/**
|
|
10913
|
+
* One event with its delivery attempts. Use it to follow a test or a resend that was still pending.
|
|
10914
|
+
* Get Webhook Event
|
|
10915
|
+
*/
|
|
10916
|
+
async getWebhookEvent(requestParameters, initOverrides) {
|
|
10917
|
+
const response = await this.getWebhookEventRaw(requestParameters, initOverrides);
|
|
10918
|
+
return await response.value();
|
|
10919
|
+
}
|
|
10920
|
+
/**
|
|
10921
|
+
* Creates request options for listWebhookEndpoints without sending the request
|
|
10922
|
+
*/
|
|
10923
|
+
async listWebhookEndpointsRequestOpts() {
|
|
10924
|
+
const queryParameters = {};
|
|
10925
|
+
const headerParameters = {};
|
|
10926
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
10927
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
10928
|
+
}
|
|
10929
|
+
let urlPath = `/api/v1/webhooks/endpoints`;
|
|
10930
|
+
return {
|
|
10931
|
+
path: urlPath,
|
|
10932
|
+
method: "GET",
|
|
10933
|
+
headers: headerParameters,
|
|
10934
|
+
query: queryParameters
|
|
10935
|
+
};
|
|
10936
|
+
}
|
|
10937
|
+
/**
|
|
10938
|
+
* The account\'s webhook endpoint, as a list (an account has at most one).
|
|
10939
|
+
* List Webhook Endpoints
|
|
10940
|
+
*/
|
|
10941
|
+
async listWebhookEndpointsRaw(initOverrides) {
|
|
10942
|
+
const requestOptions = await this.listWebhookEndpointsRequestOpts();
|
|
10943
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
10944
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookEndpointListOutDTOFromJSON(jsonValue));
|
|
10945
|
+
}
|
|
10946
|
+
/**
|
|
10947
|
+
* The account\'s webhook endpoint, as a list (an account has at most one).
|
|
10948
|
+
* List Webhook Endpoints
|
|
10949
|
+
*/
|
|
10950
|
+
async listWebhookEndpoints(initOverrides) {
|
|
10951
|
+
const response = await this.listWebhookEndpointsRaw(initOverrides);
|
|
10952
|
+
return await response.value();
|
|
10953
|
+
}
|
|
10954
|
+
/**
|
|
10955
|
+
* Creates request options for listWebhookEvents without sending the request
|
|
10956
|
+
*/
|
|
10957
|
+
async listWebhookEventsRequestOpts(requestParameters) {
|
|
10958
|
+
const queryParameters = {};
|
|
10959
|
+
if (requestParameters["status"] != null) {
|
|
10960
|
+
queryParameters["status"] = requestParameters["status"];
|
|
10961
|
+
}
|
|
10962
|
+
if (requestParameters["skip"] != null) {
|
|
10963
|
+
queryParameters["skip"] = requestParameters["skip"];
|
|
10964
|
+
}
|
|
10965
|
+
if (requestParameters["limit"] != null) {
|
|
10966
|
+
queryParameters["limit"] = requestParameters["limit"];
|
|
10967
|
+
}
|
|
10968
|
+
if (requestParameters["createdBefore"] != null) {
|
|
10969
|
+
queryParameters["createdBefore"] = requestParameters["createdBefore"];
|
|
10970
|
+
}
|
|
10971
|
+
const headerParameters = {};
|
|
10972
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
10973
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
10974
|
+
}
|
|
10975
|
+
let urlPath = `/api/v1/webhooks/events`;
|
|
10976
|
+
return {
|
|
10977
|
+
path: urlPath,
|
|
10978
|
+
method: "GET",
|
|
10979
|
+
headers: headerParameters,
|
|
10980
|
+
query: queryParameters
|
|
10981
|
+
};
|
|
10982
|
+
}
|
|
10983
|
+
/**
|
|
10984
|
+
* Events of the last 30 days, newest first, each with its delivery attempts. `count` is the size of this page; `hasMore` says whether another follows. `skip` stops at 100,000; `createdBefore` reaches every event.
|
|
10985
|
+
* List Webhook Events
|
|
10986
|
+
*/
|
|
10987
|
+
async listWebhookEventsRaw(requestParameters, initOverrides) {
|
|
10988
|
+
const requestOptions = await this.listWebhookEventsRequestOpts(requestParameters);
|
|
10989
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
10990
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookEventListOutDTOFromJSON(jsonValue));
|
|
10991
|
+
}
|
|
10992
|
+
/**
|
|
10993
|
+
* Events of the last 30 days, newest first, each with its delivery attempts. `count` is the size of this page; `hasMore` says whether another follows. `skip` stops at 100,000; `createdBefore` reaches every event.
|
|
10994
|
+
* List Webhook Events
|
|
10995
|
+
*/
|
|
10996
|
+
async listWebhookEvents(requestParameters = {}, initOverrides) {
|
|
10997
|
+
const response = await this.listWebhookEventsRaw(requestParameters, initOverrides);
|
|
10998
|
+
return await response.value();
|
|
10999
|
+
}
|
|
11000
|
+
/**
|
|
11001
|
+
* Creates request options for resendWebhookEvent without sending the request
|
|
11002
|
+
*/
|
|
11003
|
+
async resendWebhookEventRequestOpts(requestParameters) {
|
|
11004
|
+
if (requestParameters["eventId"] == null) {
|
|
11005
|
+
throw new RequiredError(
|
|
11006
|
+
"eventId",
|
|
11007
|
+
'Required parameter "eventId" was null or undefined when calling resendWebhookEvent().'
|
|
11008
|
+
);
|
|
11009
|
+
}
|
|
11010
|
+
const queryParameters = {};
|
|
11011
|
+
const headerParameters = {};
|
|
11012
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
11013
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
11014
|
+
}
|
|
11015
|
+
let urlPath = `/api/v1/webhooks/events/{event_id}/resend`;
|
|
11016
|
+
urlPath = urlPath.replace("{event_id}", encodeURIComponent(String(requestParameters["eventId"])));
|
|
11017
|
+
return {
|
|
11018
|
+
path: urlPath,
|
|
11019
|
+
method: "POST",
|
|
11020
|
+
headers: headerParameters,
|
|
11021
|
+
query: queryParameters
|
|
11022
|
+
};
|
|
11023
|
+
}
|
|
11024
|
+
/**
|
|
11025
|
+
* Deliver a finished event once more and wait up to 20 seconds for the endpoint\'s answer. `pending: true` means the outcome is not known yet: read the event by `eventId` and look for the attempt whose id is `attemptId`.
|
|
11026
|
+
* Resend Webhook Event
|
|
11027
|
+
*/
|
|
11028
|
+
async resendWebhookEventRaw(requestParameters, initOverrides) {
|
|
11029
|
+
const requestOptions = await this.resendWebhookEventRequestOpts(requestParameters);
|
|
11030
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
11031
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookDeliveryResultOutDTOFromJSON(jsonValue));
|
|
11032
|
+
}
|
|
11033
|
+
/**
|
|
11034
|
+
* Deliver a finished event once more and wait up to 20 seconds for the endpoint\'s answer. `pending: true` means the outcome is not known yet: read the event by `eventId` and look for the attempt whose id is `attemptId`.
|
|
11035
|
+
* Resend Webhook Event
|
|
11036
|
+
*/
|
|
11037
|
+
async resendWebhookEvent(requestParameters, initOverrides) {
|
|
11038
|
+
const response = await this.resendWebhookEventRaw(requestParameters, initOverrides);
|
|
11039
|
+
return await response.value();
|
|
11040
|
+
}
|
|
11041
|
+
/**
|
|
11042
|
+
* Creates request options for rotateWebhookEndpointSecret without sending the request
|
|
11043
|
+
*/
|
|
11044
|
+
async rotateWebhookEndpointSecretRequestOpts(requestParameters) {
|
|
11045
|
+
if (requestParameters["endpointId"] == null) {
|
|
11046
|
+
throw new RequiredError(
|
|
11047
|
+
"endpointId",
|
|
11048
|
+
'Required parameter "endpointId" was null or undefined when calling rotateWebhookEndpointSecret().'
|
|
11049
|
+
);
|
|
11050
|
+
}
|
|
11051
|
+
const queryParameters = {};
|
|
11052
|
+
const headerParameters = {};
|
|
11053
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
11054
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
11055
|
+
}
|
|
11056
|
+
let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}/rotate-secret`;
|
|
11057
|
+
urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
|
|
11058
|
+
return {
|
|
11059
|
+
path: urlPath,
|
|
11060
|
+
method: "POST",
|
|
11061
|
+
headers: headerParameters,
|
|
11062
|
+
query: queryParameters
|
|
11063
|
+
};
|
|
11064
|
+
}
|
|
11065
|
+
/**
|
|
11066
|
+
* Issue a new signing secret. For 24 hours each delivery is signed with both the old and the new one; a second rotation is refused until then.
|
|
11067
|
+
* Rotate Webhook Endpoint Secret
|
|
11068
|
+
*/
|
|
11069
|
+
async rotateWebhookEndpointSecretRaw(requestParameters, initOverrides) {
|
|
11070
|
+
const requestOptions = await this.rotateWebhookEndpointSecretRequestOpts(requestParameters);
|
|
11071
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
11072
|
+
return new JSONApiResponse(response, (jsonValue) => CreatedWebhookEndpointOutDTOFromJSON(jsonValue));
|
|
11073
|
+
}
|
|
11074
|
+
/**
|
|
11075
|
+
* Issue a new signing secret. For 24 hours each delivery is signed with both the old and the new one; a second rotation is refused until then.
|
|
11076
|
+
* Rotate Webhook Endpoint Secret
|
|
11077
|
+
*/
|
|
11078
|
+
async rotateWebhookEndpointSecret(requestParameters, initOverrides) {
|
|
11079
|
+
const response = await this.rotateWebhookEndpointSecretRaw(requestParameters, initOverrides);
|
|
11080
|
+
return await response.value();
|
|
11081
|
+
}
|
|
11082
|
+
/**
|
|
11083
|
+
* Creates request options for sendWebhookTestEvent without sending the request
|
|
11084
|
+
*/
|
|
11085
|
+
async sendWebhookTestEventRequestOpts(requestParameters) {
|
|
11086
|
+
if (requestParameters["endpointId"] == null) {
|
|
11087
|
+
throw new RequiredError(
|
|
11088
|
+
"endpointId",
|
|
11089
|
+
'Required parameter "endpointId" was null or undefined when calling sendWebhookTestEvent().'
|
|
11090
|
+
);
|
|
11091
|
+
}
|
|
11092
|
+
const queryParameters = {};
|
|
11093
|
+
const headerParameters = {};
|
|
11094
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
11095
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
11096
|
+
}
|
|
11097
|
+
let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}/test`;
|
|
11098
|
+
urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
|
|
11099
|
+
return {
|
|
11100
|
+
path: urlPath,
|
|
11101
|
+
method: "POST",
|
|
11102
|
+
headers: headerParameters,
|
|
11103
|
+
query: queryParameters
|
|
11104
|
+
};
|
|
11105
|
+
}
|
|
11106
|
+
/**
|
|
11107
|
+
* Send one `webhook.test` event and wait up to 20 seconds for the endpoint\'s answer. Not retried. `pending: true` means the outcome is not known yet: read the event by `eventId` and look for the attempt whose id is `attemptId`.
|
|
11108
|
+
* Send Webhook Test Event
|
|
11109
|
+
*/
|
|
11110
|
+
async sendWebhookTestEventRaw(requestParameters, initOverrides) {
|
|
11111
|
+
const requestOptions = await this.sendWebhookTestEventRequestOpts(requestParameters);
|
|
11112
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
11113
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookDeliveryResultOutDTOFromJSON(jsonValue));
|
|
11114
|
+
}
|
|
11115
|
+
/**
|
|
11116
|
+
* Send one `webhook.test` event and wait up to 20 seconds for the endpoint\'s answer. Not retried. `pending: true` means the outcome is not known yet: read the event by `eventId` and look for the attempt whose id is `attemptId`.
|
|
11117
|
+
* Send Webhook Test Event
|
|
11118
|
+
*/
|
|
11119
|
+
async sendWebhookTestEvent(requestParameters, initOverrides) {
|
|
11120
|
+
const response = await this.sendWebhookTestEventRaw(requestParameters, initOverrides);
|
|
11121
|
+
return await response.value();
|
|
11122
|
+
}
|
|
11123
|
+
/**
|
|
11124
|
+
* Creates request options for updateWebhookEndpoint without sending the request
|
|
11125
|
+
*/
|
|
11126
|
+
async updateWebhookEndpointRequestOpts(requestParameters) {
|
|
11127
|
+
if (requestParameters["endpointId"] == null) {
|
|
11128
|
+
throw new RequiredError(
|
|
11129
|
+
"endpointId",
|
|
11130
|
+
'Required parameter "endpointId" was null or undefined when calling updateWebhookEndpoint().'
|
|
11131
|
+
);
|
|
11132
|
+
}
|
|
11133
|
+
if (requestParameters["webhookEndpointUpdateInDTO"] == null) {
|
|
11134
|
+
throw new RequiredError(
|
|
11135
|
+
"webhookEndpointUpdateInDTO",
|
|
11136
|
+
'Required parameter "webhookEndpointUpdateInDTO" was null or undefined when calling updateWebhookEndpoint().'
|
|
11137
|
+
);
|
|
11138
|
+
}
|
|
11139
|
+
const queryParameters = {};
|
|
11140
|
+
const headerParameters = {};
|
|
11141
|
+
headerParameters["Content-Type"] = "application/json";
|
|
11142
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
11143
|
+
headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
|
|
11144
|
+
}
|
|
11145
|
+
let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}`;
|
|
11146
|
+
urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
|
|
11147
|
+
return {
|
|
11148
|
+
path: urlPath,
|
|
11149
|
+
method: "PATCH",
|
|
11150
|
+
headers: headerParameters,
|
|
11151
|
+
query: queryParameters,
|
|
11152
|
+
body: WebhookEndpointUpdateInDTOToJSON(requestParameters["webhookEndpointUpdateInDTO"])
|
|
11153
|
+
};
|
|
11154
|
+
}
|
|
11155
|
+
/**
|
|
11156
|
+
* Change the URL or description, or enable or disable the endpoint.
|
|
11157
|
+
* Update Webhook Endpoint
|
|
11158
|
+
*/
|
|
11159
|
+
async updateWebhookEndpointRaw(requestParameters, initOverrides) {
|
|
11160
|
+
const requestOptions = await this.updateWebhookEndpointRequestOpts(requestParameters);
|
|
11161
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
11162
|
+
return new JSONApiResponse(response, (jsonValue) => WebhookEndpointOutDTOFromJSON(jsonValue));
|
|
11163
|
+
}
|
|
11164
|
+
/**
|
|
11165
|
+
* Change the URL or description, or enable or disable the endpoint.
|
|
11166
|
+
* Update Webhook Endpoint
|
|
11167
|
+
*/
|
|
11168
|
+
async updateWebhookEndpoint(requestParameters, initOverrides) {
|
|
11169
|
+
const response = await this.updateWebhookEndpointRaw(requestParameters, initOverrides);
|
|
11170
|
+
return await response.value();
|
|
11171
|
+
}
|
|
11172
|
+
};
|
|
11173
|
+
var ListWebhookEventsStatusEnum = {
|
|
11174
|
+
Pending: "pending",
|
|
11175
|
+
Delivered: "delivered",
|
|
11176
|
+
Failed: "failed",
|
|
11177
|
+
Superseded: "superseded"
|
|
11178
|
+
};
|
|
11179
|
+
|
|
10294
11180
|
// src/generated/models/CreditMeterFilter.ts
|
|
10295
11181
|
var CreditMeterFilter = {
|
|
10296
11182
|
ProcessingCredits: "processing_credits",
|
|
@@ -10362,6 +11248,93 @@ function FoundationDTOToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
10362
11248
|
};
|
|
10363
11249
|
}
|
|
10364
11250
|
|
|
11251
|
+
// src/generated/models/ExtractionCompletedEventData.ts
|
|
11252
|
+
function instanceOfExtractionCompletedEventData(value) {
|
|
11253
|
+
if (!("correlationId" in value) || value["correlationId"] === void 0) return false;
|
|
11254
|
+
if (!("resultIncluded" in value) || value["resultIncluded"] === void 0) return false;
|
|
11255
|
+
if (!("resultPath" in value) || value["resultPath"] === void 0) return false;
|
|
11256
|
+
if (!("status" in value) || value["status"] === void 0) return false;
|
|
11257
|
+
return true;
|
|
11258
|
+
}
|
|
11259
|
+
function ExtractionCompletedEventDataFromJSON(json) {
|
|
11260
|
+
return ExtractionCompletedEventDataFromJSONTyped(json, false);
|
|
11261
|
+
}
|
|
11262
|
+
function ExtractionCompletedEventDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
11263
|
+
if (json == null) {
|
|
11264
|
+
return json;
|
|
11265
|
+
}
|
|
11266
|
+
return {
|
|
11267
|
+
"channel": json["channel"] == null ? void 0 : json["channel"],
|
|
11268
|
+
"correlationId": json["correlationId"],
|
|
11269
|
+
"documentId": json["documentId"] == null ? void 0 : json["documentId"],
|
|
11270
|
+
"endUserId": json["endUserId"] == null ? void 0 : json["endUserId"],
|
|
11271
|
+
"error": json["error"] == null ? void 0 : FoundationDTOFromJSON(json["error"]),
|
|
11272
|
+
"externalId": json["externalId"] == null ? void 0 : json["externalId"],
|
|
11273
|
+
"result": json["result"] == null ? void 0 : DocumentProcessingResultOutDTOFromJSON(json["result"]),
|
|
11274
|
+
"resultIncluded": json["resultIncluded"],
|
|
11275
|
+
"resultPath": json["resultPath"],
|
|
11276
|
+
"status": json["status"]
|
|
11277
|
+
};
|
|
11278
|
+
}
|
|
11279
|
+
function ExtractionCompletedEventDataToJSON(json) {
|
|
11280
|
+
return ExtractionCompletedEventDataToJSONTyped(json, false);
|
|
11281
|
+
}
|
|
11282
|
+
function ExtractionCompletedEventDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
11283
|
+
if (value == null) {
|
|
11284
|
+
return value;
|
|
11285
|
+
}
|
|
11286
|
+
return {
|
|
11287
|
+
"channel": value["channel"],
|
|
11288
|
+
"correlationId": value["correlationId"],
|
|
11289
|
+
"documentId": value["documentId"],
|
|
11290
|
+
"endUserId": value["endUserId"],
|
|
11291
|
+
"error": FoundationDTOToJSON(value["error"]),
|
|
11292
|
+
"externalId": value["externalId"],
|
|
11293
|
+
"result": DocumentProcessingResultOutDTOToJSON(value["result"]),
|
|
11294
|
+
"resultIncluded": value["resultIncluded"],
|
|
11295
|
+
"resultPath": value["resultPath"],
|
|
11296
|
+
"status": value["status"]
|
|
11297
|
+
};
|
|
11298
|
+
}
|
|
11299
|
+
|
|
11300
|
+
// src/generated/models/ExtractionCompletedEvent.ts
|
|
11301
|
+
var ExtractionCompletedEventTypeEnum = {
|
|
11302
|
+
ExtractionCompleted: "extraction.completed"
|
|
11303
|
+
};
|
|
11304
|
+
function instanceOfExtractionCompletedEvent(value) {
|
|
11305
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
11306
|
+
if (!("timestamp" in value) || value["timestamp"] === void 0) return false;
|
|
11307
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
11308
|
+
if (value["type"] !== "extraction.completed") return false;
|
|
11309
|
+
return true;
|
|
11310
|
+
}
|
|
11311
|
+
function ExtractionCompletedEventFromJSON(json) {
|
|
11312
|
+
return ExtractionCompletedEventFromJSONTyped(json, false);
|
|
11313
|
+
}
|
|
11314
|
+
function ExtractionCompletedEventFromJSONTyped(json, ignoreDiscriminator) {
|
|
11315
|
+
if (json == null) {
|
|
11316
|
+
return json;
|
|
11317
|
+
}
|
|
11318
|
+
return {
|
|
11319
|
+
"data": ExtractionCompletedEventDataFromJSON(json["data"]),
|
|
11320
|
+
"timestamp": new Date(json["timestamp"]),
|
|
11321
|
+
"type": json["type"]
|
|
11322
|
+
};
|
|
11323
|
+
}
|
|
11324
|
+
function ExtractionCompletedEventToJSON(json) {
|
|
11325
|
+
return ExtractionCompletedEventToJSONTyped(json, false);
|
|
11326
|
+
}
|
|
11327
|
+
function ExtractionCompletedEventToJSONTyped(value, ignoreDiscriminator = false) {
|
|
11328
|
+
if (value == null) {
|
|
11329
|
+
return value;
|
|
11330
|
+
}
|
|
11331
|
+
return {
|
|
11332
|
+
"data": ExtractionCompletedEventDataToJSON(value["data"]),
|
|
11333
|
+
"timestamp": value["timestamp"].toISOString(),
|
|
11334
|
+
"type": value["type"]
|
|
11335
|
+
};
|
|
11336
|
+
}
|
|
11337
|
+
|
|
10365
11338
|
// src/generated/models/LocationInner.ts
|
|
10366
11339
|
function instanceOfLocationInner(value) {
|
|
10367
11340
|
return true;
|
|
@@ -10527,6 +11500,72 @@ function ValueAnyOfInnerToJSONTyped(value, ignoreDiscriminator = false) {
|
|
|
10527
11500
|
return value;
|
|
10528
11501
|
}
|
|
10529
11502
|
|
|
11503
|
+
// src/generated/models/WebhookTestEventData.ts
|
|
11504
|
+
function instanceOfWebhookTestEventData(value) {
|
|
11505
|
+
if (!("message" in value) || value["message"] === void 0) return false;
|
|
11506
|
+
return true;
|
|
11507
|
+
}
|
|
11508
|
+
function WebhookTestEventDataFromJSON(json) {
|
|
11509
|
+
return WebhookTestEventDataFromJSONTyped(json, false);
|
|
11510
|
+
}
|
|
11511
|
+
function WebhookTestEventDataFromJSONTyped(json, ignoreDiscriminator) {
|
|
11512
|
+
if (json == null) {
|
|
11513
|
+
return json;
|
|
11514
|
+
}
|
|
11515
|
+
return {
|
|
11516
|
+
"message": json["message"]
|
|
11517
|
+
};
|
|
11518
|
+
}
|
|
11519
|
+
function WebhookTestEventDataToJSON(json) {
|
|
11520
|
+
return WebhookTestEventDataToJSONTyped(json, false);
|
|
11521
|
+
}
|
|
11522
|
+
function WebhookTestEventDataToJSONTyped(value, ignoreDiscriminator = false) {
|
|
11523
|
+
if (value == null) {
|
|
11524
|
+
return value;
|
|
11525
|
+
}
|
|
11526
|
+
return {
|
|
11527
|
+
"message": value["message"]
|
|
11528
|
+
};
|
|
11529
|
+
}
|
|
11530
|
+
|
|
11531
|
+
// src/generated/models/WebhookTestEvent.ts
|
|
11532
|
+
var WebhookTestEventTypeEnum = {
|
|
11533
|
+
WebhookTest: "webhook.test"
|
|
11534
|
+
};
|
|
11535
|
+
function instanceOfWebhookTestEvent(value) {
|
|
11536
|
+
if (!("data" in value) || value["data"] === void 0) return false;
|
|
11537
|
+
if (!("timestamp" in value) || value["timestamp"] === void 0) return false;
|
|
11538
|
+
if (!("type" in value) || value["type"] === void 0) return false;
|
|
11539
|
+
if (value["type"] !== "webhook.test") return false;
|
|
11540
|
+
return true;
|
|
11541
|
+
}
|
|
11542
|
+
function WebhookTestEventFromJSON(json) {
|
|
11543
|
+
return WebhookTestEventFromJSONTyped(json, false);
|
|
11544
|
+
}
|
|
11545
|
+
function WebhookTestEventFromJSONTyped(json, ignoreDiscriminator) {
|
|
11546
|
+
if (json == null) {
|
|
11547
|
+
return json;
|
|
11548
|
+
}
|
|
11549
|
+
return {
|
|
11550
|
+
"data": WebhookTestEventDataFromJSON(json["data"]),
|
|
11551
|
+
"timestamp": new Date(json["timestamp"]),
|
|
11552
|
+
"type": json["type"]
|
|
11553
|
+
};
|
|
11554
|
+
}
|
|
11555
|
+
function WebhookTestEventToJSON(json) {
|
|
11556
|
+
return WebhookTestEventToJSONTyped(json, false);
|
|
11557
|
+
}
|
|
11558
|
+
function WebhookTestEventToJSONTyped(value, ignoreDiscriminator = false) {
|
|
11559
|
+
if (value == null) {
|
|
11560
|
+
return value;
|
|
11561
|
+
}
|
|
11562
|
+
return {
|
|
11563
|
+
"data": WebhookTestEventDataToJSON(value["data"]),
|
|
11564
|
+
"timestamp": value["timestamp"].toISOString(),
|
|
11565
|
+
"type": value["type"]
|
|
11566
|
+
};
|
|
11567
|
+
}
|
|
11568
|
+
|
|
10530
11569
|
// src/errors.ts
|
|
10531
11570
|
var GeminaError = class extends Error {
|
|
10532
11571
|
constructor(message) {
|
|
@@ -10552,6 +11591,14 @@ var GeminaTimeoutError = class extends GeminaError {
|
|
|
10552
11591
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
10553
11592
|
}
|
|
10554
11593
|
};
|
|
11594
|
+
var GeminaWebhookVerificationError = class extends GeminaError {
|
|
11595
|
+
constructor(reason, message, cause) {
|
|
11596
|
+
super(message);
|
|
11597
|
+
this.reason = reason;
|
|
11598
|
+
if (cause !== void 0) this.cause = cause;
|
|
11599
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
11600
|
+
}
|
|
11601
|
+
};
|
|
10555
11602
|
|
|
10556
11603
|
// src/helpers.ts
|
|
10557
11604
|
var DEFAULT_BASE_URL = "https://api.gemina.co";
|
|
@@ -10688,6 +11735,10 @@ var GeminaClient = class _GeminaClient {
|
|
|
10688
11735
|
* Build a client authenticated with a short-lived session token
|
|
10689
11736
|
* (`OAuth2PasswordBearer` bearer scheme) instead of an API key. Use this
|
|
10690
11737
|
* in browser/session contexts — never ship the API key to a browser.
|
|
11738
|
+
*
|
|
11739
|
+
* The factory sends whatever bearer token it is given. A retrieval token
|
|
11740
|
+
* from `sessions` does not reach the `webhooks` group, which needs the
|
|
11741
|
+
* account-login JWT (the token the console signs in with).
|
|
10691
11742
|
*/
|
|
10692
11743
|
static withSessionToken(token, baseUrl = DEFAULT_BASE_URL, options = {}) {
|
|
10693
11744
|
const headerValue = token.startsWith("Bearer ") ? token : `Bearer ${token}`;
|
|
@@ -10737,6 +11788,15 @@ var GeminaClient = class _GeminaClient {
|
|
|
10737
11788
|
var _a;
|
|
10738
11789
|
return (_a = this.apiCache).billing ?? (_a.billing = this.apiOverrides.billing ?? new BillingApi(this.configuration));
|
|
10739
11790
|
}
|
|
11791
|
+
/**
|
|
11792
|
+
* Webhook endpoints and their delivery log. These routes need the
|
|
11793
|
+
* account-login token (build the client with {@link GeminaClient.withSessionToken});
|
|
11794
|
+
* an API key is refused.
|
|
11795
|
+
*/
|
|
11796
|
+
get webhooks() {
|
|
11797
|
+
var _a;
|
|
11798
|
+
return (_a = this.apiCache).webhooks ?? (_a.webhooks = this.apiOverrides.webhooks ?? new WebhooksApi(this.configuration));
|
|
11799
|
+
}
|
|
10740
11800
|
// --- Stateful chat convenience ---
|
|
10741
11801
|
/**
|
|
10742
11802
|
* Start a stateful chat {@link GeminaChatConversation} that threads the
|
|
@@ -10935,8 +11995,186 @@ async function asProcessingErrorIfFailedResult(error) {
|
|
|
10935
11995
|
return new GeminaProcessingError(DocumentProcessingResultOutDTOFromJSON(json));
|
|
10936
11996
|
}
|
|
10937
11997
|
|
|
11998
|
+
// src/webhooks.ts
|
|
11999
|
+
var SECRET_PREFIX = "whsec_";
|
|
12000
|
+
var DEFAULT_TOLERANCE_SECONDS = 300;
|
|
12001
|
+
var BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
12002
|
+
var TIMESTAMP = /^[0-9]{1,12}$/;
|
|
12003
|
+
function isExtractionCompleted(event) {
|
|
12004
|
+
return event.type === "extraction.completed";
|
|
12005
|
+
}
|
|
12006
|
+
function isWebhookTest(event) {
|
|
12007
|
+
return event.type === "webhook.test";
|
|
12008
|
+
}
|
|
12009
|
+
var KNOWN = {
|
|
12010
|
+
"extraction.completed": {
|
|
12011
|
+
required: { correlationId: "string", status: "string", resultIncluded: "boolean", resultPath: "string" },
|
|
12012
|
+
read: ExtractionCompletedEventDataFromJSON
|
|
12013
|
+
},
|
|
12014
|
+
"webhook.test": { required: { message: "string" }, read: WebhookTestEventDataFromJSON }
|
|
12015
|
+
};
|
|
12016
|
+
var fail = (reason, message, cause) => new GeminaWebhookVerificationError(reason, message, cause);
|
|
12017
|
+
function isObject(value) {
|
|
12018
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12019
|
+
}
|
|
12020
|
+
var asciiLower = (text) => text.replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
12021
|
+
function isComplete(type, data) {
|
|
12022
|
+
if (!isObject(data)) return false;
|
|
12023
|
+
if (Object.entries(KNOWN[type].required).some(([field, kind]) => typeof data[field] !== kind)) return false;
|
|
12024
|
+
if (type !== "extraction.completed") return true;
|
|
12025
|
+
const result = data.result ?? null;
|
|
12026
|
+
const error = data.error ?? null;
|
|
12027
|
+
if (result !== null && error !== null) return false;
|
|
12028
|
+
if (result !== null && !(isObject(result) && typeof result.status === "string" && isObject(result.meta) && "data" in result)) {
|
|
12029
|
+
return false;
|
|
12030
|
+
}
|
|
12031
|
+
return error === null || isObject(error) && typeof error.status === "string";
|
|
12032
|
+
}
|
|
12033
|
+
function header(headers, name) {
|
|
12034
|
+
const values = [];
|
|
12035
|
+
const add = (value) => {
|
|
12036
|
+
for (const part of value.split(", ")) if (!values.includes(part)) values.push(part);
|
|
12037
|
+
};
|
|
12038
|
+
const fromEntries = (entries) => {
|
|
12039
|
+
for (const [key, value] of entries) {
|
|
12040
|
+
if (typeof key !== "string" || asciiLower(key) !== name) continue;
|
|
12041
|
+
for (const item of Array.isArray(value) ? value : [value]) if (typeof item === "string") add(item);
|
|
12042
|
+
}
|
|
12043
|
+
};
|
|
12044
|
+
if (headers === null || headers === void 0) {
|
|
12045
|
+
} else if (headers instanceof Map) {
|
|
12046
|
+
fromEntries(headers.entries());
|
|
12047
|
+
} else if (typeof headers.get === "function") {
|
|
12048
|
+
const value = headers.get(name);
|
|
12049
|
+
if (typeof value === "string") add(value);
|
|
12050
|
+
} else {
|
|
12051
|
+
fromEntries(Object.entries(headers));
|
|
12052
|
+
}
|
|
12053
|
+
if (values.length === 0) throw fail("missing_header", `The ${name} header is missing.`);
|
|
12054
|
+
if (values.length > 1) throw fail("ambiguous_header", `The ${name} header was sent more than once with different values.`);
|
|
12055
|
+
return values[0];
|
|
12056
|
+
}
|
|
12057
|
+
function decodeBase64(text) {
|
|
12058
|
+
if (!BASE64.test(text)) return void 0;
|
|
12059
|
+
const binary = atob(text);
|
|
12060
|
+
const bytes = new Uint8Array(binary.length);
|
|
12061
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
12062
|
+
return bytes;
|
|
12063
|
+
}
|
|
12064
|
+
function constantTimeEqual(a, b) {
|
|
12065
|
+
if (a.length !== b.length) return false;
|
|
12066
|
+
let difference = 0;
|
|
12067
|
+
for (let i = 0; i < a.length; i++) difference |= a[i] ^ b[i];
|
|
12068
|
+
return difference === 0;
|
|
12069
|
+
}
|
|
12070
|
+
function isRawBuffer(value) {
|
|
12071
|
+
const tag = Object.prototype.toString.call(value);
|
|
12072
|
+
return tag === "[object ArrayBuffer]" || tag === "[object SharedArrayBuffer]";
|
|
12073
|
+
}
|
|
12074
|
+
function copyBody(body) {
|
|
12075
|
+
if (typeof body === "string") return new TextEncoder().encode(body);
|
|
12076
|
+
if (body == null) return new Uint8Array(0);
|
|
12077
|
+
if (!isRawBuffer(body) && !ArrayBuffer.isView(body)) {
|
|
12078
|
+
throw fail("invalid_body", "The webhook body must be the raw request bytes or text, not a parsed value.");
|
|
12079
|
+
}
|
|
12080
|
+
try {
|
|
12081
|
+
const source = ArrayBuffer.isView(body) ? new Uint8Array(body.buffer, body.byteOffset, body.byteLength) : new Uint8Array(body);
|
|
12082
|
+
const copy = new Uint8Array(source.length);
|
|
12083
|
+
copy.set(source);
|
|
12084
|
+
return copy;
|
|
12085
|
+
} catch (error) {
|
|
12086
|
+
throw fail("invalid_body", "The webhook body cannot be read: its buffer was detached.", error);
|
|
12087
|
+
}
|
|
12088
|
+
}
|
|
12089
|
+
async function subtleCrypto() {
|
|
12090
|
+
const global = globalThis.crypto;
|
|
12091
|
+
if (global?.subtle) return global.subtle;
|
|
12092
|
+
const nodeCrypto = "node:crypto";
|
|
12093
|
+
const module = await import(
|
|
12094
|
+
/* @vite-ignore */
|
|
12095
|
+
/* webpackIgnore: true */
|
|
12096
|
+
nodeCrypto
|
|
12097
|
+
);
|
|
12098
|
+
return module.webcrypto.subtle;
|
|
12099
|
+
}
|
|
12100
|
+
async function verifySignature(rawBody, id, timestampText, signatureHeader, secret) {
|
|
12101
|
+
const key = typeof secret === "string" ? decodeBase64(secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret) : void 0;
|
|
12102
|
+
if (key === void 0 || key.length === 0) {
|
|
12103
|
+
throw fail("invalid_secret", "The signing secret is not valid: expected whsec_ followed by base64.");
|
|
12104
|
+
}
|
|
12105
|
+
const prefix = new TextEncoder().encode(`${id}.${timestampText}.`);
|
|
12106
|
+
const signed = new Uint8Array(prefix.length + rawBody.length);
|
|
12107
|
+
signed.set(prefix, 0);
|
|
12108
|
+
signed.set(rawBody, prefix.length);
|
|
12109
|
+
const subtle = await subtleCrypto();
|
|
12110
|
+
const cryptoKey = await subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
12111
|
+
const expected = new Uint8Array(await subtle.sign("HMAC", cryptoKey, signed));
|
|
12112
|
+
let matched = false;
|
|
12113
|
+
for (const entry of signatureHeader.split(" ")) {
|
|
12114
|
+
const comma = entry.indexOf(",");
|
|
12115
|
+
if (comma < 0 || entry.slice(0, comma) !== "v1") continue;
|
|
12116
|
+
const candidate = decodeBase64(entry.slice(comma + 1));
|
|
12117
|
+
if (candidate !== void 0 && constantTimeEqual(candidate, expected)) matched = true;
|
|
12118
|
+
}
|
|
12119
|
+
if (!matched) throw fail("no_matching_signature", "No signature in the webhook-signature header matches.");
|
|
12120
|
+
return signed.subarray(prefix.length);
|
|
12121
|
+
}
|
|
12122
|
+
function parseBody(verifiedBody) {
|
|
12123
|
+
if (verifiedBody.length >= 3 && verifiedBody[0] === 239 && verifiedBody[1] === 187 && verifiedBody[2] === 191) {
|
|
12124
|
+
throw fail("invalid_body", "The webhook body starts with a byte order mark.");
|
|
12125
|
+
}
|
|
12126
|
+
let parsed;
|
|
12127
|
+
try {
|
|
12128
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(verifiedBody));
|
|
12129
|
+
} catch (error) {
|
|
12130
|
+
throw fail("invalid_body", "The webhook body is not valid JSON.", error);
|
|
12131
|
+
}
|
|
12132
|
+
if (!isObject(parsed)) throw fail("invalid_body", "The webhook body is not a JSON object.");
|
|
12133
|
+
return parsed;
|
|
12134
|
+
}
|
|
12135
|
+
function typeData(type, data) {
|
|
12136
|
+
if (type === null || !Object.prototype.hasOwnProperty.call(KNOWN, type)) return data;
|
|
12137
|
+
if (!isComplete(type, data)) {
|
|
12138
|
+
throw fail("invalid_body", `The data of this ${type} event is missing a required field.`);
|
|
12139
|
+
}
|
|
12140
|
+
try {
|
|
12141
|
+
return KNOWN[type].read(data);
|
|
12142
|
+
} catch (error) {
|
|
12143
|
+
throw fail("invalid_body", `The data of this ${type} event could not be read.`, error);
|
|
12144
|
+
}
|
|
12145
|
+
}
|
|
12146
|
+
async function unwrapWebhook(body, headers, secret, options = {}) {
|
|
12147
|
+
const rawBody = copyBody(body);
|
|
12148
|
+
options = options ?? {};
|
|
12149
|
+
const id = header(headers, "webhook-id");
|
|
12150
|
+
const timestampText = header(headers, "webhook-timestamp");
|
|
12151
|
+
const signatureHeader = header(headers, "webhook-signature");
|
|
12152
|
+
if (!TIMESTAMP.test(timestampText)) {
|
|
12153
|
+
throw fail("invalid_timestamp", "The webhook-timestamp header is not a whole number of seconds.");
|
|
12154
|
+
}
|
|
12155
|
+
const tolerance = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;
|
|
12156
|
+
const clock = (options.now ?? (() => Date.now() / 1e3))();
|
|
12157
|
+
if (!Number.isFinite(clock) || !Number.isFinite(tolerance) || tolerance < 0) {
|
|
12158
|
+
throw fail(
|
|
12159
|
+
"timestamp_out_of_tolerance",
|
|
12160
|
+
"The clock or the tolerance is not a finite number, so the timestamp cannot be checked."
|
|
12161
|
+
);
|
|
12162
|
+
}
|
|
12163
|
+
if (Math.abs(Math.floor(clock) - Number(timestampText)) > tolerance) {
|
|
12164
|
+
throw fail(
|
|
12165
|
+
"timestamp_out_of_tolerance",
|
|
12166
|
+
`The webhook timestamp is more than ${tolerance} seconds from the current time.`
|
|
12167
|
+
);
|
|
12168
|
+
}
|
|
12169
|
+
const verifiedBody = await verifySignature(rawBody, id, timestampText, signatureHeader, secret);
|
|
12170
|
+
const parsed = parseBody(verifiedBody);
|
|
12171
|
+
const type = typeof parsed.type === "string" ? parsed.type : null;
|
|
12172
|
+
const timestamp = typeof parsed.timestamp === "string" ? parsed.timestamp : null;
|
|
12173
|
+
return { id, type, timestamp, data: typeData(type, parsed.data ?? null), raw: parsed };
|
|
12174
|
+
}
|
|
12175
|
+
|
|
10938
12176
|
// src/version.ts
|
|
10939
|
-
var VERSION = "0.
|
|
12177
|
+
var VERSION = "0.17.1";
|
|
10940
12178
|
export {
|
|
10941
12179
|
AddExtractionsInDTOFromJSON,
|
|
10942
12180
|
AddExtractionsInDTOFromJSONTyped,
|
|
@@ -11022,6 +12260,11 @@ export {
|
|
|
11022
12260
|
CreateTemplateInDTOFromJSONTyped,
|
|
11023
12261
|
CreateTemplateInDTOToJSON,
|
|
11024
12262
|
CreateTemplateInDTOToJSONTyped,
|
|
12263
|
+
CreatedWebhookEndpointOutDTODisabledReasonEnum,
|
|
12264
|
+
CreatedWebhookEndpointOutDTOFromJSON,
|
|
12265
|
+
CreatedWebhookEndpointOutDTOFromJSONTyped,
|
|
12266
|
+
CreatedWebhookEndpointOutDTOToJSON,
|
|
12267
|
+
CreatedWebhookEndpointOutDTOToJSONTyped,
|
|
11025
12268
|
CreditMeter,
|
|
11026
12269
|
CreditMeterFilter,
|
|
11027
12270
|
CreditMeterFilterFromJSON,
|
|
@@ -11120,6 +12363,15 @@ export {
|
|
|
11120
12363
|
EnterpriseTransactionOutDTOFromJSONTyped,
|
|
11121
12364
|
EnterpriseTransactionOutDTOToJSON,
|
|
11122
12365
|
EnterpriseTransactionOutDTOToJSONTyped,
|
|
12366
|
+
ExtractionCompletedEventDataFromJSON,
|
|
12367
|
+
ExtractionCompletedEventDataFromJSONTyped,
|
|
12368
|
+
ExtractionCompletedEventDataToJSON,
|
|
12369
|
+
ExtractionCompletedEventDataToJSONTyped,
|
|
12370
|
+
ExtractionCompletedEventFromJSON,
|
|
12371
|
+
ExtractionCompletedEventFromJSONTyped,
|
|
12372
|
+
ExtractionCompletedEventToJSON,
|
|
12373
|
+
ExtractionCompletedEventToJSONTyped,
|
|
12374
|
+
ExtractionCompletedEventTypeEnum,
|
|
11123
12375
|
ExtractionCostOutDTOFromJSON,
|
|
11124
12376
|
ExtractionCostOutDTOFromJSONTyped,
|
|
11125
12377
|
ExtractionCostOutDTOToJSON,
|
|
@@ -11263,6 +12515,7 @@ export {
|
|
|
11263
12515
|
GeminaError,
|
|
11264
12516
|
GeminaProcessingError,
|
|
11265
12517
|
GeminaTimeoutError,
|
|
12518
|
+
GeminaWebhookVerificationError,
|
|
11266
12519
|
GenerateTemplateFromUrlInDTOFromJSON,
|
|
11267
12520
|
GenerateTemplateFromUrlInDTOFromJSONTyped,
|
|
11268
12521
|
GenerateTemplateFromUrlInDTOToJSON,
|
|
@@ -11295,6 +12548,7 @@ export {
|
|
|
11295
12548
|
InvoiceTypeToJSONTyped,
|
|
11296
12549
|
JSONApiResponse,
|
|
11297
12550
|
LegalApi,
|
|
12551
|
+
ListWebhookEventsStatusEnum,
|
|
11298
12552
|
LocationInnerFromJSON,
|
|
11299
12553
|
LocationInnerFromJSONTyped,
|
|
11300
12554
|
LocationInnerToJSON,
|
|
@@ -11610,10 +12864,56 @@ export {
|
|
|
11610
12864
|
WebDocumentUploadInDTOFromJSONTyped,
|
|
11611
12865
|
WebDocumentUploadInDTOToJSON,
|
|
11612
12866
|
WebDocumentUploadInDTOToJSONTyped,
|
|
12867
|
+
WebhookAttemptOutDTOFromJSON,
|
|
12868
|
+
WebhookAttemptOutDTOFromJSONTyped,
|
|
12869
|
+
WebhookAttemptOutDTOToJSON,
|
|
12870
|
+
WebhookAttemptOutDTOToJSONTyped,
|
|
12871
|
+
WebhookDeliveryResultOutDTOFromJSON,
|
|
12872
|
+
WebhookDeliveryResultOutDTOFromJSONTyped,
|
|
12873
|
+
WebhookDeliveryResultOutDTOToJSON,
|
|
12874
|
+
WebhookDeliveryResultOutDTOToJSONTyped,
|
|
12875
|
+
WebhookEndpointCreateInDTOFromJSON,
|
|
12876
|
+
WebhookEndpointCreateInDTOFromJSONTyped,
|
|
12877
|
+
WebhookEndpointCreateInDTOToJSON,
|
|
12878
|
+
WebhookEndpointCreateInDTOToJSONTyped,
|
|
12879
|
+
WebhookEndpointListOutDTOFromJSON,
|
|
12880
|
+
WebhookEndpointListOutDTOFromJSONTyped,
|
|
12881
|
+
WebhookEndpointListOutDTOToJSON,
|
|
12882
|
+
WebhookEndpointListOutDTOToJSONTyped,
|
|
12883
|
+
WebhookEndpointOutDTODisabledReasonEnum,
|
|
12884
|
+
WebhookEndpointOutDTOFromJSON,
|
|
12885
|
+
WebhookEndpointOutDTOFromJSONTyped,
|
|
12886
|
+
WebhookEndpointOutDTOToJSON,
|
|
12887
|
+
WebhookEndpointOutDTOToJSONTyped,
|
|
12888
|
+
WebhookEndpointUpdateInDTOFromJSON,
|
|
12889
|
+
WebhookEndpointUpdateInDTOFromJSONTyped,
|
|
12890
|
+
WebhookEndpointUpdateInDTOToJSON,
|
|
12891
|
+
WebhookEndpointUpdateInDTOToJSONTyped,
|
|
12892
|
+
WebhookEventListOutDTOFromJSON,
|
|
12893
|
+
WebhookEventListOutDTOFromJSONTyped,
|
|
12894
|
+
WebhookEventListOutDTOToJSON,
|
|
12895
|
+
WebhookEventListOutDTOToJSONTyped,
|
|
12896
|
+
WebhookEventOutDTOFailureReasonEnum,
|
|
12897
|
+
WebhookEventOutDTOFromJSON,
|
|
12898
|
+
WebhookEventOutDTOFromJSONTyped,
|
|
12899
|
+
WebhookEventOutDTOStatusEnum,
|
|
12900
|
+
WebhookEventOutDTOToJSON,
|
|
12901
|
+
WebhookEventOutDTOToJSONTyped,
|
|
12902
|
+
WebhookEventOutDTOTypeEnum,
|
|
11613
12903
|
WebhookResponseDTOFromJSON,
|
|
11614
12904
|
WebhookResponseDTOFromJSONTyped,
|
|
11615
12905
|
WebhookResponseDTOToJSON,
|
|
11616
12906
|
WebhookResponseDTOToJSONTyped,
|
|
12907
|
+
WebhookTestEventDataFromJSON,
|
|
12908
|
+
WebhookTestEventDataFromJSONTyped,
|
|
12909
|
+
WebhookTestEventDataToJSON,
|
|
12910
|
+
WebhookTestEventDataToJSONTyped,
|
|
12911
|
+
WebhookTestEventFromJSON,
|
|
12912
|
+
WebhookTestEventFromJSONTyped,
|
|
12913
|
+
WebhookTestEventToJSON,
|
|
12914
|
+
WebhookTestEventToJSONTyped,
|
|
12915
|
+
WebhookTestEventTypeEnum,
|
|
12916
|
+
WebhooksApi,
|
|
11617
12917
|
canConsumeForm,
|
|
11618
12918
|
exists,
|
|
11619
12919
|
instanceOfAddExtractionsInDTO,
|
|
@@ -11634,6 +12934,7 @@ export {
|
|
|
11634
12934
|
instanceOfContractStatus,
|
|
11635
12935
|
instanceOfCountBreakdownModel,
|
|
11636
12936
|
instanceOfCreateTemplateInDTO,
|
|
12937
|
+
instanceOfCreatedWebhookEndpointOutDTO,
|
|
11637
12938
|
instanceOfCreditMeter,
|
|
11638
12939
|
instanceOfCreditMeterFilter,
|
|
11639
12940
|
instanceOfCreditTransactionListOutDTO,
|
|
@@ -11656,6 +12957,8 @@ export {
|
|
|
11656
12957
|
instanceOfDocumentsViewOutDTO,
|
|
11657
12958
|
instanceOfEnterpriseTransactionListOutDTO,
|
|
11658
12959
|
instanceOfEnterpriseTransactionOutDTO,
|
|
12960
|
+
instanceOfExtractionCompletedEvent,
|
|
12961
|
+
instanceOfExtractionCompletedEventData,
|
|
11659
12962
|
instanceOfExtractionCostOutDTO,
|
|
11660
12963
|
instanceOfExtractionCostOutResultDTO,
|
|
11661
12964
|
instanceOfExtractionCostStateModel,
|
|
@@ -11765,8 +13068,21 @@ export {
|
|
|
11765
13068
|
instanceOfViewMetaOutDTO,
|
|
11766
13069
|
instanceOfVolumeDiscountTierOutDTO,
|
|
11767
13070
|
instanceOfWebDocumentUploadInDTO,
|
|
13071
|
+
instanceOfWebhookAttemptOutDTO,
|
|
13072
|
+
instanceOfWebhookDeliveryResultOutDTO,
|
|
13073
|
+
instanceOfWebhookEndpointCreateInDTO,
|
|
13074
|
+
instanceOfWebhookEndpointListOutDTO,
|
|
13075
|
+
instanceOfWebhookEndpointOutDTO,
|
|
13076
|
+
instanceOfWebhookEndpointUpdateInDTO,
|
|
13077
|
+
instanceOfWebhookEventListOutDTO,
|
|
13078
|
+
instanceOfWebhookEventOutDTO,
|
|
11768
13079
|
instanceOfWebhookResponseDTO,
|
|
13080
|
+
instanceOfWebhookTestEvent,
|
|
13081
|
+
instanceOfWebhookTestEventData,
|
|
13082
|
+
isExtractionCompleted,
|
|
13083
|
+
isWebhookTest,
|
|
11769
13084
|
mapValues,
|
|
11770
|
-
querystring
|
|
13085
|
+
querystring,
|
|
13086
|
+
unwrapWebhook
|
|
11771
13087
|
};
|
|
11772
13088
|
//# sourceMappingURL=index.js.map
|