@gemina/sdk 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/index.cjs +1381 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1487 -168
- package/dist/index.d.ts +1487 -168
- package/dist/index.js +1302 -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,13 @@ 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) {
|
|
11596
|
+
super(message);
|
|
11597
|
+
this.reason = reason;
|
|
11598
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
11599
|
+
}
|
|
11600
|
+
};
|
|
10555
11601
|
|
|
10556
11602
|
// src/helpers.ts
|
|
10557
11603
|
var DEFAULT_BASE_URL = "https://api.gemina.co";
|
|
@@ -10688,6 +11734,10 @@ var GeminaClient = class _GeminaClient {
|
|
|
10688
11734
|
* Build a client authenticated with a short-lived session token
|
|
10689
11735
|
* (`OAuth2PasswordBearer` bearer scheme) instead of an API key. Use this
|
|
10690
11736
|
* in browser/session contexts — never ship the API key to a browser.
|
|
11737
|
+
*
|
|
11738
|
+
* The factory sends whatever bearer token it is given. A retrieval token
|
|
11739
|
+
* from `sessions` does not reach the `webhooks` group, which needs the
|
|
11740
|
+
* account-login JWT (the token the console signs in with).
|
|
10691
11741
|
*/
|
|
10692
11742
|
static withSessionToken(token, baseUrl = DEFAULT_BASE_URL, options = {}) {
|
|
10693
11743
|
const headerValue = token.startsWith("Bearer ") ? token : `Bearer ${token}`;
|
|
@@ -10737,6 +11787,15 @@ var GeminaClient = class _GeminaClient {
|
|
|
10737
11787
|
var _a;
|
|
10738
11788
|
return (_a = this.apiCache).billing ?? (_a.billing = this.apiOverrides.billing ?? new BillingApi(this.configuration));
|
|
10739
11789
|
}
|
|
11790
|
+
/**
|
|
11791
|
+
* Webhook endpoints and their delivery log. These routes need the
|
|
11792
|
+
* account-login token (build the client with {@link GeminaClient.withSessionToken});
|
|
11793
|
+
* an API key is refused.
|
|
11794
|
+
*/
|
|
11795
|
+
get webhooks() {
|
|
11796
|
+
var _a;
|
|
11797
|
+
return (_a = this.apiCache).webhooks ?? (_a.webhooks = this.apiOverrides.webhooks ?? new WebhooksApi(this.configuration));
|
|
11798
|
+
}
|
|
10740
11799
|
// --- Stateful chat convenience ---
|
|
10741
11800
|
/**
|
|
10742
11801
|
* Start a stateful chat {@link GeminaChatConversation} that threads the
|
|
@@ -10935,8 +11994,171 @@ async function asProcessingErrorIfFailedResult(error) {
|
|
|
10935
11994
|
return new GeminaProcessingError(DocumentProcessingResultOutDTOFromJSON(json));
|
|
10936
11995
|
}
|
|
10937
11996
|
|
|
11997
|
+
// src/webhooks.ts
|
|
11998
|
+
var SECRET_PREFIX = "whsec_";
|
|
11999
|
+
var DEFAULT_TOLERANCE_SECONDS = 300;
|
|
12000
|
+
var BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
|
12001
|
+
var TIMESTAMP = /^[0-9]{1,12}$/;
|
|
12002
|
+
function isExtractionCompleted(event) {
|
|
12003
|
+
return event.type === "extraction.completed";
|
|
12004
|
+
}
|
|
12005
|
+
function isWebhookTest(event) {
|
|
12006
|
+
return event.type === "webhook.test";
|
|
12007
|
+
}
|
|
12008
|
+
var REQUIRED = {
|
|
12009
|
+
"extraction.completed": { correlationId: "string", status: "string", resultIncluded: "boolean", resultPath: "string" },
|
|
12010
|
+
"webhook.test": { message: "string" }
|
|
12011
|
+
};
|
|
12012
|
+
var fail = (reason, message) => new GeminaWebhookVerificationError(reason, message);
|
|
12013
|
+
function isObject(value) {
|
|
12014
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
12015
|
+
}
|
|
12016
|
+
var asciiLower = (text) => text.replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
12017
|
+
function isComplete(type, data) {
|
|
12018
|
+
if (!isObject(data)) return false;
|
|
12019
|
+
if (Object.entries(REQUIRED[type]).some(([field, kind]) => typeof data[field] !== kind)) return false;
|
|
12020
|
+
if (type !== "extraction.completed") return true;
|
|
12021
|
+
const result = data.result ?? null;
|
|
12022
|
+
const error = data.error ?? null;
|
|
12023
|
+
if (result !== null && error !== null) return false;
|
|
12024
|
+
if (result !== null && !(isObject(result) && typeof result.status === "string" && isObject(result.meta) && "data" in result)) {
|
|
12025
|
+
return false;
|
|
12026
|
+
}
|
|
12027
|
+
return error === null || isObject(error) && typeof error.status === "string";
|
|
12028
|
+
}
|
|
12029
|
+
function header(headers, name) {
|
|
12030
|
+
const values = [];
|
|
12031
|
+
const add = (value) => {
|
|
12032
|
+
for (const part of value.split(", ")) if (!values.includes(part)) values.push(part);
|
|
12033
|
+
};
|
|
12034
|
+
const fromEntries = (entries) => {
|
|
12035
|
+
for (const [key, value] of entries) {
|
|
12036
|
+
if (asciiLower(String(key)) !== name || value === void 0 || value === null) continue;
|
|
12037
|
+
for (const item of Array.isArray(value) ? value : [value]) add(String(item));
|
|
12038
|
+
}
|
|
12039
|
+
};
|
|
12040
|
+
if (headers === null || headers === void 0) {
|
|
12041
|
+
} else if (headers instanceof Map) {
|
|
12042
|
+
fromEntries(headers.entries());
|
|
12043
|
+
} else if (typeof headers.get === "function") {
|
|
12044
|
+
const value = headers.get(name);
|
|
12045
|
+
if (value != null) add(String(value));
|
|
12046
|
+
} else {
|
|
12047
|
+
fromEntries(Object.entries(headers));
|
|
12048
|
+
}
|
|
12049
|
+
if (values.length === 0) throw fail("missing_header", `The ${name} header is missing.`);
|
|
12050
|
+
if (values.length > 1) throw fail("ambiguous_header", `The ${name} header was sent more than once with different values.`);
|
|
12051
|
+
return values[0];
|
|
12052
|
+
}
|
|
12053
|
+
function decodeBase64(text) {
|
|
12054
|
+
if (!BASE64.test(text)) return void 0;
|
|
12055
|
+
const binary = atob(text);
|
|
12056
|
+
const bytes = new Uint8Array(binary.length);
|
|
12057
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
12058
|
+
return bytes;
|
|
12059
|
+
}
|
|
12060
|
+
function constantTimeEqual(a, b) {
|
|
12061
|
+
if (a.length !== b.length) return false;
|
|
12062
|
+
let difference = 0;
|
|
12063
|
+
for (let i = 0; i < a.length; i++) difference |= a[i] ^ b[i];
|
|
12064
|
+
return difference === 0;
|
|
12065
|
+
}
|
|
12066
|
+
function copyBody(body) {
|
|
12067
|
+
if (typeof body === "string") return new TextEncoder().encode(body);
|
|
12068
|
+
if (body == null) return new Uint8Array(0);
|
|
12069
|
+
const source = ArrayBuffer.isView(body) ? new Uint8Array(body.buffer, body.byteOffset, body.byteLength) : new Uint8Array(body);
|
|
12070
|
+
const copy = new Uint8Array(source.length);
|
|
12071
|
+
copy.set(source);
|
|
12072
|
+
return copy;
|
|
12073
|
+
}
|
|
12074
|
+
async function subtleCrypto() {
|
|
12075
|
+
const global = globalThis.crypto;
|
|
12076
|
+
if (global?.subtle) return global.subtle;
|
|
12077
|
+
const nodeCrypto = "node:crypto";
|
|
12078
|
+
const module = await import(
|
|
12079
|
+
/* @vite-ignore */
|
|
12080
|
+
/* webpackIgnore: true */
|
|
12081
|
+
nodeCrypto
|
|
12082
|
+
);
|
|
12083
|
+
return module.webcrypto.subtle;
|
|
12084
|
+
}
|
|
12085
|
+
async function unwrapWebhook(body, headers, secret, options = {}) {
|
|
12086
|
+
let rawBody;
|
|
12087
|
+
try {
|
|
12088
|
+
rawBody = copyBody(body);
|
|
12089
|
+
} catch (error) {
|
|
12090
|
+
if (!(error instanceof TypeError)) throw error;
|
|
12091
|
+
throw fail("invalid_body", "The webhook body cannot be read: its buffer was detached.");
|
|
12092
|
+
}
|
|
12093
|
+
options = options ?? {};
|
|
12094
|
+
const id = header(headers, "webhook-id");
|
|
12095
|
+
const timestampText = header(headers, "webhook-timestamp");
|
|
12096
|
+
const signatureHeader = header(headers, "webhook-signature");
|
|
12097
|
+
if (!TIMESTAMP.test(timestampText)) {
|
|
12098
|
+
throw fail("invalid_timestamp", "The webhook-timestamp header is not a whole number of seconds.");
|
|
12099
|
+
}
|
|
12100
|
+
const tolerance = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;
|
|
12101
|
+
const clock = (options.now ?? (() => Date.now() / 1e3))();
|
|
12102
|
+
if (!Number.isFinite(clock) || !Number.isFinite(tolerance) || tolerance < 0) {
|
|
12103
|
+
throw fail(
|
|
12104
|
+
"timestamp_out_of_tolerance",
|
|
12105
|
+
"The clock or the tolerance is not a finite number, so the timestamp cannot be checked."
|
|
12106
|
+
);
|
|
12107
|
+
}
|
|
12108
|
+
if (Math.abs(Math.floor(clock) - Number(timestampText)) > tolerance) {
|
|
12109
|
+
throw fail(
|
|
12110
|
+
"timestamp_out_of_tolerance",
|
|
12111
|
+
`The webhook timestamp is more than ${tolerance} seconds from the current time.`
|
|
12112
|
+
);
|
|
12113
|
+
}
|
|
12114
|
+
const key = typeof secret === "string" ? decodeBase64(secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret) : void 0;
|
|
12115
|
+
if (key === void 0 || key.length === 0) {
|
|
12116
|
+
throw fail("invalid_secret", "The signing secret is not valid: expected whsec_ followed by base64.");
|
|
12117
|
+
}
|
|
12118
|
+
const prefix = new TextEncoder().encode(`${id}.${timestampText}.`);
|
|
12119
|
+
const signed = new Uint8Array(prefix.length + rawBody.length);
|
|
12120
|
+
signed.set(prefix, 0);
|
|
12121
|
+
signed.set(rawBody, prefix.length);
|
|
12122
|
+
const subtle = await subtleCrypto();
|
|
12123
|
+
const verifiedBody = signed.subarray(prefix.length);
|
|
12124
|
+
const cryptoKey = await subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
12125
|
+
const expected = new Uint8Array(await subtle.sign("HMAC", cryptoKey, signed));
|
|
12126
|
+
let matched = false;
|
|
12127
|
+
for (const entry of signatureHeader.split(" ")) {
|
|
12128
|
+
const comma = entry.indexOf(",");
|
|
12129
|
+
if (comma < 0 || entry.slice(0, comma) !== "v1") continue;
|
|
12130
|
+
const candidate = decodeBase64(entry.slice(comma + 1));
|
|
12131
|
+
if (candidate !== void 0 && constantTimeEqual(candidate, expected)) matched = true;
|
|
12132
|
+
}
|
|
12133
|
+
if (!matched) throw fail("no_matching_signature", "No signature in the webhook-signature header matches.");
|
|
12134
|
+
if (verifiedBody.length >= 3 && verifiedBody[0] === 239 && verifiedBody[1] === 187 && verifiedBody[2] === 191) {
|
|
12135
|
+
throw fail("invalid_body", "The webhook body starts with a byte order mark.");
|
|
12136
|
+
}
|
|
12137
|
+
let parsed;
|
|
12138
|
+
try {
|
|
12139
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(verifiedBody));
|
|
12140
|
+
} catch {
|
|
12141
|
+
throw fail("invalid_body", "The webhook body is not valid JSON.");
|
|
12142
|
+
}
|
|
12143
|
+
if (!isObject(parsed)) throw fail("invalid_body", "The webhook body is not a JSON object.");
|
|
12144
|
+
const type = typeof parsed.type === "string" ? parsed.type : null;
|
|
12145
|
+
const timestamp = typeof parsed.timestamp === "string" ? parsed.timestamp : null;
|
|
12146
|
+
let data = parsed.data;
|
|
12147
|
+
if (type !== null && Object.prototype.hasOwnProperty.call(REQUIRED, type)) {
|
|
12148
|
+
if (!isComplete(type, data)) {
|
|
12149
|
+
throw fail("invalid_body", `The data of this ${type} event is missing a required field.`);
|
|
12150
|
+
}
|
|
12151
|
+
try {
|
|
12152
|
+
data = type === "extraction.completed" ? ExtractionCompletedEventDataFromJSON(data) : WebhookTestEventDataFromJSON(data);
|
|
12153
|
+
} catch {
|
|
12154
|
+
throw fail("invalid_body", `The data of this ${type} event could not be read.`);
|
|
12155
|
+
}
|
|
12156
|
+
}
|
|
12157
|
+
return { id, type, timestamp, data, raw: parsed };
|
|
12158
|
+
}
|
|
12159
|
+
|
|
10938
12160
|
// src/version.ts
|
|
10939
|
-
var VERSION = "0.
|
|
12161
|
+
var VERSION = "0.17.0";
|
|
10940
12162
|
export {
|
|
10941
12163
|
AddExtractionsInDTOFromJSON,
|
|
10942
12164
|
AddExtractionsInDTOFromJSONTyped,
|
|
@@ -11022,6 +12244,11 @@ export {
|
|
|
11022
12244
|
CreateTemplateInDTOFromJSONTyped,
|
|
11023
12245
|
CreateTemplateInDTOToJSON,
|
|
11024
12246
|
CreateTemplateInDTOToJSONTyped,
|
|
12247
|
+
CreatedWebhookEndpointOutDTODisabledReasonEnum,
|
|
12248
|
+
CreatedWebhookEndpointOutDTOFromJSON,
|
|
12249
|
+
CreatedWebhookEndpointOutDTOFromJSONTyped,
|
|
12250
|
+
CreatedWebhookEndpointOutDTOToJSON,
|
|
12251
|
+
CreatedWebhookEndpointOutDTOToJSONTyped,
|
|
11025
12252
|
CreditMeter,
|
|
11026
12253
|
CreditMeterFilter,
|
|
11027
12254
|
CreditMeterFilterFromJSON,
|
|
@@ -11120,6 +12347,15 @@ export {
|
|
|
11120
12347
|
EnterpriseTransactionOutDTOFromJSONTyped,
|
|
11121
12348
|
EnterpriseTransactionOutDTOToJSON,
|
|
11122
12349
|
EnterpriseTransactionOutDTOToJSONTyped,
|
|
12350
|
+
ExtractionCompletedEventDataFromJSON,
|
|
12351
|
+
ExtractionCompletedEventDataFromJSONTyped,
|
|
12352
|
+
ExtractionCompletedEventDataToJSON,
|
|
12353
|
+
ExtractionCompletedEventDataToJSONTyped,
|
|
12354
|
+
ExtractionCompletedEventFromJSON,
|
|
12355
|
+
ExtractionCompletedEventFromJSONTyped,
|
|
12356
|
+
ExtractionCompletedEventToJSON,
|
|
12357
|
+
ExtractionCompletedEventToJSONTyped,
|
|
12358
|
+
ExtractionCompletedEventTypeEnum,
|
|
11123
12359
|
ExtractionCostOutDTOFromJSON,
|
|
11124
12360
|
ExtractionCostOutDTOFromJSONTyped,
|
|
11125
12361
|
ExtractionCostOutDTOToJSON,
|
|
@@ -11263,6 +12499,7 @@ export {
|
|
|
11263
12499
|
GeminaError,
|
|
11264
12500
|
GeminaProcessingError,
|
|
11265
12501
|
GeminaTimeoutError,
|
|
12502
|
+
GeminaWebhookVerificationError,
|
|
11266
12503
|
GenerateTemplateFromUrlInDTOFromJSON,
|
|
11267
12504
|
GenerateTemplateFromUrlInDTOFromJSONTyped,
|
|
11268
12505
|
GenerateTemplateFromUrlInDTOToJSON,
|
|
@@ -11295,6 +12532,7 @@ export {
|
|
|
11295
12532
|
InvoiceTypeToJSONTyped,
|
|
11296
12533
|
JSONApiResponse,
|
|
11297
12534
|
LegalApi,
|
|
12535
|
+
ListWebhookEventsStatusEnum,
|
|
11298
12536
|
LocationInnerFromJSON,
|
|
11299
12537
|
LocationInnerFromJSONTyped,
|
|
11300
12538
|
LocationInnerToJSON,
|
|
@@ -11610,10 +12848,56 @@ export {
|
|
|
11610
12848
|
WebDocumentUploadInDTOFromJSONTyped,
|
|
11611
12849
|
WebDocumentUploadInDTOToJSON,
|
|
11612
12850
|
WebDocumentUploadInDTOToJSONTyped,
|
|
12851
|
+
WebhookAttemptOutDTOFromJSON,
|
|
12852
|
+
WebhookAttemptOutDTOFromJSONTyped,
|
|
12853
|
+
WebhookAttemptOutDTOToJSON,
|
|
12854
|
+
WebhookAttemptOutDTOToJSONTyped,
|
|
12855
|
+
WebhookDeliveryResultOutDTOFromJSON,
|
|
12856
|
+
WebhookDeliveryResultOutDTOFromJSONTyped,
|
|
12857
|
+
WebhookDeliveryResultOutDTOToJSON,
|
|
12858
|
+
WebhookDeliveryResultOutDTOToJSONTyped,
|
|
12859
|
+
WebhookEndpointCreateInDTOFromJSON,
|
|
12860
|
+
WebhookEndpointCreateInDTOFromJSONTyped,
|
|
12861
|
+
WebhookEndpointCreateInDTOToJSON,
|
|
12862
|
+
WebhookEndpointCreateInDTOToJSONTyped,
|
|
12863
|
+
WebhookEndpointListOutDTOFromJSON,
|
|
12864
|
+
WebhookEndpointListOutDTOFromJSONTyped,
|
|
12865
|
+
WebhookEndpointListOutDTOToJSON,
|
|
12866
|
+
WebhookEndpointListOutDTOToJSONTyped,
|
|
12867
|
+
WebhookEndpointOutDTODisabledReasonEnum,
|
|
12868
|
+
WebhookEndpointOutDTOFromJSON,
|
|
12869
|
+
WebhookEndpointOutDTOFromJSONTyped,
|
|
12870
|
+
WebhookEndpointOutDTOToJSON,
|
|
12871
|
+
WebhookEndpointOutDTOToJSONTyped,
|
|
12872
|
+
WebhookEndpointUpdateInDTOFromJSON,
|
|
12873
|
+
WebhookEndpointUpdateInDTOFromJSONTyped,
|
|
12874
|
+
WebhookEndpointUpdateInDTOToJSON,
|
|
12875
|
+
WebhookEndpointUpdateInDTOToJSONTyped,
|
|
12876
|
+
WebhookEventListOutDTOFromJSON,
|
|
12877
|
+
WebhookEventListOutDTOFromJSONTyped,
|
|
12878
|
+
WebhookEventListOutDTOToJSON,
|
|
12879
|
+
WebhookEventListOutDTOToJSONTyped,
|
|
12880
|
+
WebhookEventOutDTOFailureReasonEnum,
|
|
12881
|
+
WebhookEventOutDTOFromJSON,
|
|
12882
|
+
WebhookEventOutDTOFromJSONTyped,
|
|
12883
|
+
WebhookEventOutDTOStatusEnum,
|
|
12884
|
+
WebhookEventOutDTOToJSON,
|
|
12885
|
+
WebhookEventOutDTOToJSONTyped,
|
|
12886
|
+
WebhookEventOutDTOTypeEnum,
|
|
11613
12887
|
WebhookResponseDTOFromJSON,
|
|
11614
12888
|
WebhookResponseDTOFromJSONTyped,
|
|
11615
12889
|
WebhookResponseDTOToJSON,
|
|
11616
12890
|
WebhookResponseDTOToJSONTyped,
|
|
12891
|
+
WebhookTestEventDataFromJSON,
|
|
12892
|
+
WebhookTestEventDataFromJSONTyped,
|
|
12893
|
+
WebhookTestEventDataToJSON,
|
|
12894
|
+
WebhookTestEventDataToJSONTyped,
|
|
12895
|
+
WebhookTestEventFromJSON,
|
|
12896
|
+
WebhookTestEventFromJSONTyped,
|
|
12897
|
+
WebhookTestEventToJSON,
|
|
12898
|
+
WebhookTestEventToJSONTyped,
|
|
12899
|
+
WebhookTestEventTypeEnum,
|
|
12900
|
+
WebhooksApi,
|
|
11617
12901
|
canConsumeForm,
|
|
11618
12902
|
exists,
|
|
11619
12903
|
instanceOfAddExtractionsInDTO,
|
|
@@ -11634,6 +12918,7 @@ export {
|
|
|
11634
12918
|
instanceOfContractStatus,
|
|
11635
12919
|
instanceOfCountBreakdownModel,
|
|
11636
12920
|
instanceOfCreateTemplateInDTO,
|
|
12921
|
+
instanceOfCreatedWebhookEndpointOutDTO,
|
|
11637
12922
|
instanceOfCreditMeter,
|
|
11638
12923
|
instanceOfCreditMeterFilter,
|
|
11639
12924
|
instanceOfCreditTransactionListOutDTO,
|
|
@@ -11656,6 +12941,8 @@ export {
|
|
|
11656
12941
|
instanceOfDocumentsViewOutDTO,
|
|
11657
12942
|
instanceOfEnterpriseTransactionListOutDTO,
|
|
11658
12943
|
instanceOfEnterpriseTransactionOutDTO,
|
|
12944
|
+
instanceOfExtractionCompletedEvent,
|
|
12945
|
+
instanceOfExtractionCompletedEventData,
|
|
11659
12946
|
instanceOfExtractionCostOutDTO,
|
|
11660
12947
|
instanceOfExtractionCostOutResultDTO,
|
|
11661
12948
|
instanceOfExtractionCostStateModel,
|
|
@@ -11765,8 +13052,21 @@ export {
|
|
|
11765
13052
|
instanceOfViewMetaOutDTO,
|
|
11766
13053
|
instanceOfVolumeDiscountTierOutDTO,
|
|
11767
13054
|
instanceOfWebDocumentUploadInDTO,
|
|
13055
|
+
instanceOfWebhookAttemptOutDTO,
|
|
13056
|
+
instanceOfWebhookDeliveryResultOutDTO,
|
|
13057
|
+
instanceOfWebhookEndpointCreateInDTO,
|
|
13058
|
+
instanceOfWebhookEndpointListOutDTO,
|
|
13059
|
+
instanceOfWebhookEndpointOutDTO,
|
|
13060
|
+
instanceOfWebhookEndpointUpdateInDTO,
|
|
13061
|
+
instanceOfWebhookEventListOutDTO,
|
|
13062
|
+
instanceOfWebhookEventOutDTO,
|
|
11768
13063
|
instanceOfWebhookResponseDTO,
|
|
13064
|
+
instanceOfWebhookTestEvent,
|
|
13065
|
+
instanceOfWebhookTestEventData,
|
|
13066
|
+
isExtractionCompleted,
|
|
13067
|
+
isWebhookTest,
|
|
11769
13068
|
mapValues,
|
|
11770
|
-
querystring
|
|
13069
|
+
querystring,
|
|
13070
|
+
unwrapWebhook
|
|
11771
13071
|
};
|
|
11772
13072
|
//# sourceMappingURL=index.js.map
|