@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/dist/index.cjs CHANGED
@@ -104,6 +104,11 @@ __export(index_exports, {
104
104
  CreateTemplateInDTOFromJSONTyped: () => CreateTemplateInDTOFromJSONTyped,
105
105
  CreateTemplateInDTOToJSON: () => CreateTemplateInDTOToJSON,
106
106
  CreateTemplateInDTOToJSONTyped: () => CreateTemplateInDTOToJSONTyped,
107
+ CreatedWebhookEndpointOutDTODisabledReasonEnum: () => CreatedWebhookEndpointOutDTODisabledReasonEnum,
108
+ CreatedWebhookEndpointOutDTOFromJSON: () => CreatedWebhookEndpointOutDTOFromJSON,
109
+ CreatedWebhookEndpointOutDTOFromJSONTyped: () => CreatedWebhookEndpointOutDTOFromJSONTyped,
110
+ CreatedWebhookEndpointOutDTOToJSON: () => CreatedWebhookEndpointOutDTOToJSON,
111
+ CreatedWebhookEndpointOutDTOToJSONTyped: () => CreatedWebhookEndpointOutDTOToJSONTyped,
107
112
  CreditMeter: () => CreditMeter,
108
113
  CreditMeterFilter: () => CreditMeterFilter,
109
114
  CreditMeterFilterFromJSON: () => CreditMeterFilterFromJSON,
@@ -202,6 +207,15 @@ __export(index_exports, {
202
207
  EnterpriseTransactionOutDTOFromJSONTyped: () => EnterpriseTransactionOutDTOFromJSONTyped,
203
208
  EnterpriseTransactionOutDTOToJSON: () => EnterpriseTransactionOutDTOToJSON,
204
209
  EnterpriseTransactionOutDTOToJSONTyped: () => EnterpriseTransactionOutDTOToJSONTyped,
210
+ ExtractionCompletedEventDataFromJSON: () => ExtractionCompletedEventDataFromJSON,
211
+ ExtractionCompletedEventDataFromJSONTyped: () => ExtractionCompletedEventDataFromJSONTyped,
212
+ ExtractionCompletedEventDataToJSON: () => ExtractionCompletedEventDataToJSON,
213
+ ExtractionCompletedEventDataToJSONTyped: () => ExtractionCompletedEventDataToJSONTyped,
214
+ ExtractionCompletedEventFromJSON: () => ExtractionCompletedEventFromJSON,
215
+ ExtractionCompletedEventFromJSONTyped: () => ExtractionCompletedEventFromJSONTyped,
216
+ ExtractionCompletedEventToJSON: () => ExtractionCompletedEventToJSON,
217
+ ExtractionCompletedEventToJSONTyped: () => ExtractionCompletedEventToJSONTyped,
218
+ ExtractionCompletedEventTypeEnum: () => ExtractionCompletedEventTypeEnum,
205
219
  ExtractionCostOutDTOFromJSON: () => ExtractionCostOutDTOFromJSON,
206
220
  ExtractionCostOutDTOFromJSONTyped: () => ExtractionCostOutDTOFromJSONTyped,
207
221
  ExtractionCostOutDTOToJSON: () => ExtractionCostOutDTOToJSON,
@@ -345,6 +359,7 @@ __export(index_exports, {
345
359
  GeminaError: () => GeminaError,
346
360
  GeminaProcessingError: () => GeminaProcessingError,
347
361
  GeminaTimeoutError: () => GeminaTimeoutError,
362
+ GeminaWebhookVerificationError: () => GeminaWebhookVerificationError,
348
363
  GenerateTemplateFromUrlInDTOFromJSON: () => GenerateTemplateFromUrlInDTOFromJSON,
349
364
  GenerateTemplateFromUrlInDTOFromJSONTyped: () => GenerateTemplateFromUrlInDTOFromJSONTyped,
350
365
  GenerateTemplateFromUrlInDTOToJSON: () => GenerateTemplateFromUrlInDTOToJSON,
@@ -377,6 +392,7 @@ __export(index_exports, {
377
392
  InvoiceTypeToJSONTyped: () => InvoiceTypeToJSONTyped,
378
393
  JSONApiResponse: () => JSONApiResponse,
379
394
  LegalApi: () => LegalApi,
395
+ ListWebhookEventsStatusEnum: () => ListWebhookEventsStatusEnum,
380
396
  LocationInnerFromJSON: () => LocationInnerFromJSON,
381
397
  LocationInnerFromJSONTyped: () => LocationInnerFromJSONTyped,
382
398
  LocationInnerToJSON: () => LocationInnerToJSON,
@@ -692,10 +708,56 @@ __export(index_exports, {
692
708
  WebDocumentUploadInDTOFromJSONTyped: () => WebDocumentUploadInDTOFromJSONTyped,
693
709
  WebDocumentUploadInDTOToJSON: () => WebDocumentUploadInDTOToJSON,
694
710
  WebDocumentUploadInDTOToJSONTyped: () => WebDocumentUploadInDTOToJSONTyped,
711
+ WebhookAttemptOutDTOFromJSON: () => WebhookAttemptOutDTOFromJSON,
712
+ WebhookAttemptOutDTOFromJSONTyped: () => WebhookAttemptOutDTOFromJSONTyped,
713
+ WebhookAttemptOutDTOToJSON: () => WebhookAttemptOutDTOToJSON,
714
+ WebhookAttemptOutDTOToJSONTyped: () => WebhookAttemptOutDTOToJSONTyped,
715
+ WebhookDeliveryResultOutDTOFromJSON: () => WebhookDeliveryResultOutDTOFromJSON,
716
+ WebhookDeliveryResultOutDTOFromJSONTyped: () => WebhookDeliveryResultOutDTOFromJSONTyped,
717
+ WebhookDeliveryResultOutDTOToJSON: () => WebhookDeliveryResultOutDTOToJSON,
718
+ WebhookDeliveryResultOutDTOToJSONTyped: () => WebhookDeliveryResultOutDTOToJSONTyped,
719
+ WebhookEndpointCreateInDTOFromJSON: () => WebhookEndpointCreateInDTOFromJSON,
720
+ WebhookEndpointCreateInDTOFromJSONTyped: () => WebhookEndpointCreateInDTOFromJSONTyped,
721
+ WebhookEndpointCreateInDTOToJSON: () => WebhookEndpointCreateInDTOToJSON,
722
+ WebhookEndpointCreateInDTOToJSONTyped: () => WebhookEndpointCreateInDTOToJSONTyped,
723
+ WebhookEndpointListOutDTOFromJSON: () => WebhookEndpointListOutDTOFromJSON,
724
+ WebhookEndpointListOutDTOFromJSONTyped: () => WebhookEndpointListOutDTOFromJSONTyped,
725
+ WebhookEndpointListOutDTOToJSON: () => WebhookEndpointListOutDTOToJSON,
726
+ WebhookEndpointListOutDTOToJSONTyped: () => WebhookEndpointListOutDTOToJSONTyped,
727
+ WebhookEndpointOutDTODisabledReasonEnum: () => WebhookEndpointOutDTODisabledReasonEnum,
728
+ WebhookEndpointOutDTOFromJSON: () => WebhookEndpointOutDTOFromJSON,
729
+ WebhookEndpointOutDTOFromJSONTyped: () => WebhookEndpointOutDTOFromJSONTyped,
730
+ WebhookEndpointOutDTOToJSON: () => WebhookEndpointOutDTOToJSON,
731
+ WebhookEndpointOutDTOToJSONTyped: () => WebhookEndpointOutDTOToJSONTyped,
732
+ WebhookEndpointUpdateInDTOFromJSON: () => WebhookEndpointUpdateInDTOFromJSON,
733
+ WebhookEndpointUpdateInDTOFromJSONTyped: () => WebhookEndpointUpdateInDTOFromJSONTyped,
734
+ WebhookEndpointUpdateInDTOToJSON: () => WebhookEndpointUpdateInDTOToJSON,
735
+ WebhookEndpointUpdateInDTOToJSONTyped: () => WebhookEndpointUpdateInDTOToJSONTyped,
736
+ WebhookEventListOutDTOFromJSON: () => WebhookEventListOutDTOFromJSON,
737
+ WebhookEventListOutDTOFromJSONTyped: () => WebhookEventListOutDTOFromJSONTyped,
738
+ WebhookEventListOutDTOToJSON: () => WebhookEventListOutDTOToJSON,
739
+ WebhookEventListOutDTOToJSONTyped: () => WebhookEventListOutDTOToJSONTyped,
740
+ WebhookEventOutDTOFailureReasonEnum: () => WebhookEventOutDTOFailureReasonEnum,
741
+ WebhookEventOutDTOFromJSON: () => WebhookEventOutDTOFromJSON,
742
+ WebhookEventOutDTOFromJSONTyped: () => WebhookEventOutDTOFromJSONTyped,
743
+ WebhookEventOutDTOStatusEnum: () => WebhookEventOutDTOStatusEnum,
744
+ WebhookEventOutDTOToJSON: () => WebhookEventOutDTOToJSON,
745
+ WebhookEventOutDTOToJSONTyped: () => WebhookEventOutDTOToJSONTyped,
746
+ WebhookEventOutDTOTypeEnum: () => WebhookEventOutDTOTypeEnum,
695
747
  WebhookResponseDTOFromJSON: () => WebhookResponseDTOFromJSON,
696
748
  WebhookResponseDTOFromJSONTyped: () => WebhookResponseDTOFromJSONTyped,
697
749
  WebhookResponseDTOToJSON: () => WebhookResponseDTOToJSON,
698
750
  WebhookResponseDTOToJSONTyped: () => WebhookResponseDTOToJSONTyped,
751
+ WebhookTestEventDataFromJSON: () => WebhookTestEventDataFromJSON,
752
+ WebhookTestEventDataFromJSONTyped: () => WebhookTestEventDataFromJSONTyped,
753
+ WebhookTestEventDataToJSON: () => WebhookTestEventDataToJSON,
754
+ WebhookTestEventDataToJSONTyped: () => WebhookTestEventDataToJSONTyped,
755
+ WebhookTestEventFromJSON: () => WebhookTestEventFromJSON,
756
+ WebhookTestEventFromJSONTyped: () => WebhookTestEventFromJSONTyped,
757
+ WebhookTestEventToJSON: () => WebhookTestEventToJSON,
758
+ WebhookTestEventToJSONTyped: () => WebhookTestEventToJSONTyped,
759
+ WebhookTestEventTypeEnum: () => WebhookTestEventTypeEnum,
760
+ WebhooksApi: () => WebhooksApi,
699
761
  canConsumeForm: () => canConsumeForm,
700
762
  exists: () => exists,
701
763
  instanceOfAddExtractionsInDTO: () => instanceOfAddExtractionsInDTO,
@@ -716,6 +778,7 @@ __export(index_exports, {
716
778
  instanceOfContractStatus: () => instanceOfContractStatus,
717
779
  instanceOfCountBreakdownModel: () => instanceOfCountBreakdownModel,
718
780
  instanceOfCreateTemplateInDTO: () => instanceOfCreateTemplateInDTO,
781
+ instanceOfCreatedWebhookEndpointOutDTO: () => instanceOfCreatedWebhookEndpointOutDTO,
719
782
  instanceOfCreditMeter: () => instanceOfCreditMeter,
720
783
  instanceOfCreditMeterFilter: () => instanceOfCreditMeterFilter,
721
784
  instanceOfCreditTransactionListOutDTO: () => instanceOfCreditTransactionListOutDTO,
@@ -738,6 +801,8 @@ __export(index_exports, {
738
801
  instanceOfDocumentsViewOutDTO: () => instanceOfDocumentsViewOutDTO,
739
802
  instanceOfEnterpriseTransactionListOutDTO: () => instanceOfEnterpriseTransactionListOutDTO,
740
803
  instanceOfEnterpriseTransactionOutDTO: () => instanceOfEnterpriseTransactionOutDTO,
804
+ instanceOfExtractionCompletedEvent: () => instanceOfExtractionCompletedEvent,
805
+ instanceOfExtractionCompletedEventData: () => instanceOfExtractionCompletedEventData,
741
806
  instanceOfExtractionCostOutDTO: () => instanceOfExtractionCostOutDTO,
742
807
  instanceOfExtractionCostOutResultDTO: () => instanceOfExtractionCostOutResultDTO,
743
808
  instanceOfExtractionCostStateModel: () => instanceOfExtractionCostStateModel,
@@ -847,9 +912,22 @@ __export(index_exports, {
847
912
  instanceOfViewMetaOutDTO: () => instanceOfViewMetaOutDTO,
848
913
  instanceOfVolumeDiscountTierOutDTO: () => instanceOfVolumeDiscountTierOutDTO,
849
914
  instanceOfWebDocumentUploadInDTO: () => instanceOfWebDocumentUploadInDTO,
915
+ instanceOfWebhookAttemptOutDTO: () => instanceOfWebhookAttemptOutDTO,
916
+ instanceOfWebhookDeliveryResultOutDTO: () => instanceOfWebhookDeliveryResultOutDTO,
917
+ instanceOfWebhookEndpointCreateInDTO: () => instanceOfWebhookEndpointCreateInDTO,
918
+ instanceOfWebhookEndpointListOutDTO: () => instanceOfWebhookEndpointListOutDTO,
919
+ instanceOfWebhookEndpointOutDTO: () => instanceOfWebhookEndpointOutDTO,
920
+ instanceOfWebhookEndpointUpdateInDTO: () => instanceOfWebhookEndpointUpdateInDTO,
921
+ instanceOfWebhookEventListOutDTO: () => instanceOfWebhookEventListOutDTO,
922
+ instanceOfWebhookEventOutDTO: () => instanceOfWebhookEventOutDTO,
850
923
  instanceOfWebhookResponseDTO: () => instanceOfWebhookResponseDTO,
924
+ instanceOfWebhookTestEvent: () => instanceOfWebhookTestEvent,
925
+ instanceOfWebhookTestEventData: () => instanceOfWebhookTestEventData,
926
+ isExtractionCompleted: () => isExtractionCompleted,
927
+ isWebhookTest: () => isWebhookTest,
851
928
  mapValues: () => mapValues,
852
- querystring: () => querystring
929
+ querystring: () => querystring,
930
+ unwrapWebhook: () => unwrapWebhook
853
931
  });
854
932
  module.exports = __toCommonJS(index_exports);
855
933
 
@@ -11146,6 +11224,892 @@ var TemplatesApi = class extends BaseAPI {
11146
11224
  }
11147
11225
  };
11148
11226
 
11227
+ // src/generated/models/CreatedWebhookEndpointOutDTO.ts
11228
+ var CreatedWebhookEndpointOutDTODisabledReasonEnum = {
11229
+ User: "user",
11230
+ Gone: "gone",
11231
+ Failing: "failing",
11232
+ AccountDeleted: "account_deleted",
11233
+ Operator: "operator"
11234
+ };
11235
+ function instanceOfCreatedWebhookEndpointOutDTO(value) {
11236
+ if (!("enabled" in value) || value["enabled"] === void 0) return false;
11237
+ if (!("id" in value) || value["id"] === void 0) return false;
11238
+ if (!("notBefore" in value) || value["notBefore"] === void 0) return false;
11239
+ if (!("secret" in value) || value["secret"] === void 0) return false;
11240
+ if (!("url" in value) || value["url"] === void 0) return false;
11241
+ return true;
11242
+ }
11243
+ function CreatedWebhookEndpointOutDTOFromJSON(json) {
11244
+ return CreatedWebhookEndpointOutDTOFromJSONTyped(json, false);
11245
+ }
11246
+ function CreatedWebhookEndpointOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11247
+ if (json == null) {
11248
+ return json;
11249
+ }
11250
+ return {
11251
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11252
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11253
+ "description": json["description"] == null ? void 0 : json["description"],
11254
+ "disabledAt": json["disabledAt"] == null ? void 0 : new Date(json["disabledAt"]),
11255
+ "disabledReason": json["disabledReason"] == null ? void 0 : json["disabledReason"],
11256
+ "enabled": json["enabled"],
11257
+ "failing": json["failing"] == null ? void 0 : json["failing"],
11258
+ "failingSince": json["failingSince"] == null ? void 0 : new Date(json["failingSince"]),
11259
+ "id": json["id"],
11260
+ "lastDeliveredAt": json["lastDeliveredAt"] == null ? void 0 : new Date(json["lastDeliveredAt"]),
11261
+ "lastTestSucceededAt": json["lastTestSucceededAt"] == null ? void 0 : new Date(json["lastTestSucceededAt"]),
11262
+ "notBefore": new Date(json["notBefore"]),
11263
+ "previousSecretExpiresAt": json["previousSecretExpiresAt"] == null ? void 0 : new Date(json["previousSecretExpiresAt"]),
11264
+ "secret": json["secret"],
11265
+ "url": json["url"]
11266
+ };
11267
+ }
11268
+ function CreatedWebhookEndpointOutDTOToJSON(json) {
11269
+ return CreatedWebhookEndpointOutDTOToJSONTyped(json, false);
11270
+ }
11271
+ function CreatedWebhookEndpointOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11272
+ if (value == null) {
11273
+ return value;
11274
+ }
11275
+ return {
11276
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11277
+ "createdAtTimestamp": value["createdAtTimestamp"],
11278
+ "description": value["description"],
11279
+ "disabledAt": value["disabledAt"] == null ? value["disabledAt"] : value["disabledAt"].toISOString(),
11280
+ "disabledReason": value["disabledReason"],
11281
+ "enabled": value["enabled"],
11282
+ "failing": value["failing"],
11283
+ "failingSince": value["failingSince"] == null ? value["failingSince"] : value["failingSince"].toISOString(),
11284
+ "id": value["id"],
11285
+ "lastDeliveredAt": value["lastDeliveredAt"] == null ? value["lastDeliveredAt"] : value["lastDeliveredAt"].toISOString(),
11286
+ "lastTestSucceededAt": value["lastTestSucceededAt"] == null ? value["lastTestSucceededAt"] : value["lastTestSucceededAt"].toISOString(),
11287
+ "notBefore": value["notBefore"].toISOString(),
11288
+ "previousSecretExpiresAt": value["previousSecretExpiresAt"] == null ? value["previousSecretExpiresAt"] : value["previousSecretExpiresAt"].toISOString(),
11289
+ "secret": value["secret"],
11290
+ "url": value["url"]
11291
+ };
11292
+ }
11293
+
11294
+ // src/generated/models/WebhookDeliveryResultOutDTO.ts
11295
+ function instanceOfWebhookDeliveryResultOutDTO(value) {
11296
+ if (!("attemptId" in value) || value["attemptId"] === void 0) return false;
11297
+ if (!("eventId" in value) || value["eventId"] === void 0) return false;
11298
+ return true;
11299
+ }
11300
+ function WebhookDeliveryResultOutDTOFromJSON(json) {
11301
+ return WebhookDeliveryResultOutDTOFromJSONTyped(json, false);
11302
+ }
11303
+ function WebhookDeliveryResultOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11304
+ if (json == null) {
11305
+ return json;
11306
+ }
11307
+ return {
11308
+ "attemptId": json["attemptId"],
11309
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11310
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11311
+ "delivered": json["delivered"] == null ? void 0 : json["delivered"],
11312
+ "durationMs": json["durationMs"] == null ? void 0 : json["durationMs"],
11313
+ "error": json["error"] == null ? void 0 : json["error"],
11314
+ "eventId": json["eventId"],
11315
+ "httpStatus": json["httpStatus"] == null ? void 0 : json["httpStatus"],
11316
+ "pending": json["pending"] == null ? void 0 : json["pending"],
11317
+ "responseSnippet": json["responseSnippet"] == null ? void 0 : json["responseSnippet"],
11318
+ "servedAt": json["servedAt"] == null ? void 0 : new Date(json["servedAt"]),
11319
+ "servedAtTimestamp": json["servedAtTimestamp"] == null ? void 0 : json["servedAtTimestamp"]
11320
+ };
11321
+ }
11322
+ function WebhookDeliveryResultOutDTOToJSON(json) {
11323
+ return WebhookDeliveryResultOutDTOToJSONTyped(json, false);
11324
+ }
11325
+ function WebhookDeliveryResultOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11326
+ if (value == null) {
11327
+ return value;
11328
+ }
11329
+ return {
11330
+ "attemptId": value["attemptId"],
11331
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11332
+ "createdAtTimestamp": value["createdAtTimestamp"],
11333
+ "delivered": value["delivered"],
11334
+ "durationMs": value["durationMs"],
11335
+ "error": value["error"],
11336
+ "eventId": value["eventId"],
11337
+ "httpStatus": value["httpStatus"],
11338
+ "pending": value["pending"],
11339
+ "responseSnippet": value["responseSnippet"],
11340
+ "servedAt": value["servedAt"] == null ? value["servedAt"] : value["servedAt"].toISOString(),
11341
+ "servedAtTimestamp": value["servedAtTimestamp"]
11342
+ };
11343
+ }
11344
+
11345
+ // src/generated/models/WebhookEndpointCreateInDTO.ts
11346
+ function instanceOfWebhookEndpointCreateInDTO(value) {
11347
+ if (!("url" in value) || value["url"] === void 0) return false;
11348
+ return true;
11349
+ }
11350
+ function WebhookEndpointCreateInDTOFromJSON(json) {
11351
+ return WebhookEndpointCreateInDTOFromJSONTyped(json, false);
11352
+ }
11353
+ function WebhookEndpointCreateInDTOFromJSONTyped(json, ignoreDiscriminator) {
11354
+ if (json == null) {
11355
+ return json;
11356
+ }
11357
+ return {
11358
+ "description": json["description"] == null ? void 0 : json["description"],
11359
+ "url": json["url"]
11360
+ };
11361
+ }
11362
+ function WebhookEndpointCreateInDTOToJSON(json) {
11363
+ return WebhookEndpointCreateInDTOToJSONTyped(json, false);
11364
+ }
11365
+ function WebhookEndpointCreateInDTOToJSONTyped(value, ignoreDiscriminator = false) {
11366
+ if (value == null) {
11367
+ return value;
11368
+ }
11369
+ return {
11370
+ "description": value["description"],
11371
+ "url": value["url"]
11372
+ };
11373
+ }
11374
+
11375
+ // src/generated/models/WebhookEndpointOutDTO.ts
11376
+ var WebhookEndpointOutDTODisabledReasonEnum = {
11377
+ User: "user",
11378
+ Gone: "gone",
11379
+ Failing: "failing",
11380
+ AccountDeleted: "account_deleted",
11381
+ Operator: "operator"
11382
+ };
11383
+ function instanceOfWebhookEndpointOutDTO(value) {
11384
+ if (!("enabled" in value) || value["enabled"] === void 0) return false;
11385
+ if (!("id" in value) || value["id"] === void 0) return false;
11386
+ if (!("notBefore" in value) || value["notBefore"] === void 0) return false;
11387
+ if (!("url" in value) || value["url"] === void 0) return false;
11388
+ return true;
11389
+ }
11390
+ function WebhookEndpointOutDTOFromJSON(json) {
11391
+ return WebhookEndpointOutDTOFromJSONTyped(json, false);
11392
+ }
11393
+ function WebhookEndpointOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11394
+ if (json == null) {
11395
+ return json;
11396
+ }
11397
+ return {
11398
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11399
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11400
+ "description": json["description"] == null ? void 0 : json["description"],
11401
+ "disabledAt": json["disabledAt"] == null ? void 0 : new Date(json["disabledAt"]),
11402
+ "disabledReason": json["disabledReason"] == null ? void 0 : json["disabledReason"],
11403
+ "enabled": json["enabled"],
11404
+ "failing": json["failing"] == null ? void 0 : json["failing"],
11405
+ "failingSince": json["failingSince"] == null ? void 0 : new Date(json["failingSince"]),
11406
+ "id": json["id"],
11407
+ "lastDeliveredAt": json["lastDeliveredAt"] == null ? void 0 : new Date(json["lastDeliveredAt"]),
11408
+ "lastTestSucceededAt": json["lastTestSucceededAt"] == null ? void 0 : new Date(json["lastTestSucceededAt"]),
11409
+ "notBefore": new Date(json["notBefore"]),
11410
+ "previousSecretExpiresAt": json["previousSecretExpiresAt"] == null ? void 0 : new Date(json["previousSecretExpiresAt"]),
11411
+ "url": json["url"]
11412
+ };
11413
+ }
11414
+ function WebhookEndpointOutDTOToJSON(json) {
11415
+ return WebhookEndpointOutDTOToJSONTyped(json, false);
11416
+ }
11417
+ function WebhookEndpointOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11418
+ if (value == null) {
11419
+ return value;
11420
+ }
11421
+ return {
11422
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11423
+ "createdAtTimestamp": value["createdAtTimestamp"],
11424
+ "description": value["description"],
11425
+ "disabledAt": value["disabledAt"] == null ? value["disabledAt"] : value["disabledAt"].toISOString(),
11426
+ "disabledReason": value["disabledReason"],
11427
+ "enabled": value["enabled"],
11428
+ "failing": value["failing"],
11429
+ "failingSince": value["failingSince"] == null ? value["failingSince"] : value["failingSince"].toISOString(),
11430
+ "id": value["id"],
11431
+ "lastDeliveredAt": value["lastDeliveredAt"] == null ? value["lastDeliveredAt"] : value["lastDeliveredAt"].toISOString(),
11432
+ "lastTestSucceededAt": value["lastTestSucceededAt"] == null ? value["lastTestSucceededAt"] : value["lastTestSucceededAt"].toISOString(),
11433
+ "notBefore": value["notBefore"].toISOString(),
11434
+ "previousSecretExpiresAt": value["previousSecretExpiresAt"] == null ? value["previousSecretExpiresAt"] : value["previousSecretExpiresAt"].toISOString(),
11435
+ "url": value["url"]
11436
+ };
11437
+ }
11438
+
11439
+ // src/generated/models/WebhookEndpointListOutDTO.ts
11440
+ function instanceOfWebhookEndpointListOutDTO(value) {
11441
+ if (!("count" in value) || value["count"] === void 0) return false;
11442
+ if (!("endpoints" in value) || value["endpoints"] === void 0) return false;
11443
+ return true;
11444
+ }
11445
+ function WebhookEndpointListOutDTOFromJSON(json) {
11446
+ return WebhookEndpointListOutDTOFromJSONTyped(json, false);
11447
+ }
11448
+ function WebhookEndpointListOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11449
+ if (json == null) {
11450
+ return json;
11451
+ }
11452
+ return {
11453
+ "count": json["count"],
11454
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11455
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11456
+ "endpoints": json["endpoints"].map(WebhookEndpointOutDTOFromJSON),
11457
+ "servedAt": json["servedAt"] == null ? void 0 : new Date(json["servedAt"]),
11458
+ "servedAtTimestamp": json["servedAtTimestamp"] == null ? void 0 : json["servedAtTimestamp"]
11459
+ };
11460
+ }
11461
+ function WebhookEndpointListOutDTOToJSON(json) {
11462
+ return WebhookEndpointListOutDTOToJSONTyped(json, false);
11463
+ }
11464
+ function WebhookEndpointListOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11465
+ if (value == null) {
11466
+ return value;
11467
+ }
11468
+ return {
11469
+ "count": value["count"],
11470
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11471
+ "createdAtTimestamp": value["createdAtTimestamp"],
11472
+ "endpoints": value["endpoints"].map(WebhookEndpointOutDTOToJSON),
11473
+ "servedAt": value["servedAt"] == null ? value["servedAt"] : value["servedAt"].toISOString(),
11474
+ "servedAtTimestamp": value["servedAtTimestamp"]
11475
+ };
11476
+ }
11477
+
11478
+ // src/generated/models/WebhookEndpointUpdateInDTO.ts
11479
+ function instanceOfWebhookEndpointUpdateInDTO(value) {
11480
+ return true;
11481
+ }
11482
+ function WebhookEndpointUpdateInDTOFromJSON(json) {
11483
+ return WebhookEndpointUpdateInDTOFromJSONTyped(json, false);
11484
+ }
11485
+ function WebhookEndpointUpdateInDTOFromJSONTyped(json, ignoreDiscriminator) {
11486
+ if (json == null) {
11487
+ return json;
11488
+ }
11489
+ return {
11490
+ "description": json["description"] == null ? void 0 : json["description"],
11491
+ "enabled": json["enabled"] == null ? void 0 : json["enabled"],
11492
+ "url": json["url"] == null ? void 0 : json["url"]
11493
+ };
11494
+ }
11495
+ function WebhookEndpointUpdateInDTOToJSON(json) {
11496
+ return WebhookEndpointUpdateInDTOToJSONTyped(json, false);
11497
+ }
11498
+ function WebhookEndpointUpdateInDTOToJSONTyped(value, ignoreDiscriminator = false) {
11499
+ if (value == null) {
11500
+ return value;
11501
+ }
11502
+ return {
11503
+ "description": value["description"],
11504
+ "enabled": value["enabled"],
11505
+ "url": value["url"]
11506
+ };
11507
+ }
11508
+
11509
+ // src/generated/models/WebhookAttemptOutDTO.ts
11510
+ function instanceOfWebhookAttemptOutDTO(value) {
11511
+ if (!("attemptNumber" in value) || value["attemptNumber"] === void 0) return false;
11512
+ if (!("attemptedAt" in value) || value["attemptedAt"] === void 0) return false;
11513
+ if (!("durationMs" in value) || value["durationMs"] === void 0) return false;
11514
+ if (!("id" in value) || value["id"] === void 0) return false;
11515
+ return true;
11516
+ }
11517
+ function WebhookAttemptOutDTOFromJSON(json) {
11518
+ return WebhookAttemptOutDTOFromJSONTyped(json, false);
11519
+ }
11520
+ function WebhookAttemptOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11521
+ if (json == null) {
11522
+ return json;
11523
+ }
11524
+ return {
11525
+ "attemptNumber": json["attemptNumber"],
11526
+ "attemptedAt": new Date(json["attemptedAt"]),
11527
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11528
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11529
+ "durationMs": json["durationMs"],
11530
+ "error": json["error"] == null ? void 0 : json["error"],
11531
+ "httpStatus": json["httpStatus"] == null ? void 0 : json["httpStatus"],
11532
+ "id": json["id"],
11533
+ "responseSnippet": json["responseSnippet"] == null ? void 0 : json["responseSnippet"]
11534
+ };
11535
+ }
11536
+ function WebhookAttemptOutDTOToJSON(json) {
11537
+ return WebhookAttemptOutDTOToJSONTyped(json, false);
11538
+ }
11539
+ function WebhookAttemptOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11540
+ if (value == null) {
11541
+ return value;
11542
+ }
11543
+ return {
11544
+ "attemptNumber": value["attemptNumber"],
11545
+ "attemptedAt": value["attemptedAt"].toISOString(),
11546
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11547
+ "createdAtTimestamp": value["createdAtTimestamp"],
11548
+ "durationMs": value["durationMs"],
11549
+ "error": value["error"],
11550
+ "httpStatus": value["httpStatus"],
11551
+ "id": value["id"],
11552
+ "responseSnippet": value["responseSnippet"]
11553
+ };
11554
+ }
11555
+
11556
+ // src/generated/models/WebhookEventOutDTO.ts
11557
+ var WebhookEventOutDTOFailureReasonEnum = {
11558
+ EndpointDisabled: "endpoint_disabled",
11559
+ RetriesExhausted: "retries_exhausted",
11560
+ Failed: "failed",
11561
+ Gone: "gone",
11562
+ NotFinal: "not_final",
11563
+ Unavailable: "unavailable",
11564
+ Superseded: "superseded"
11565
+ };
11566
+ var WebhookEventOutDTOStatusEnum = {
11567
+ Pending: "pending",
11568
+ Delivered: "delivered",
11569
+ Failed: "failed",
11570
+ Superseded: "superseded"
11571
+ };
11572
+ var WebhookEventOutDTOTypeEnum = {
11573
+ ExtractionCompleted: "extraction.completed",
11574
+ WebhookTest: "webhook.test"
11575
+ };
11576
+ function instanceOfWebhookEventOutDTO(value) {
11577
+ if (!("attemptCount" in value) || value["attemptCount"] === void 0) return false;
11578
+ if (!("endpointId" in value) || value["endpointId"] === void 0) return false;
11579
+ if (!("id" in value) || value["id"] === void 0) return false;
11580
+ if (!("manual" in value) || value["manual"] === void 0) return false;
11581
+ if (!("occurredAt" in value) || value["occurredAt"] === void 0) return false;
11582
+ if (!("status" in value) || value["status"] === void 0) return false;
11583
+ if (!("type" in value) || value["type"] === void 0) return false;
11584
+ if (!("webhookId" in value) || value["webhookId"] === void 0) return false;
11585
+ return true;
11586
+ }
11587
+ function WebhookEventOutDTOFromJSON(json) {
11588
+ return WebhookEventOutDTOFromJSONTyped(json, false);
11589
+ }
11590
+ function WebhookEventOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11591
+ if (json == null) {
11592
+ return json;
11593
+ }
11594
+ return {
11595
+ "attemptCount": json["attemptCount"],
11596
+ "attempts": json["attempts"] == null ? void 0 : json["attempts"].map(WebhookAttemptOutDTOFromJSON),
11597
+ "correlationId": json["correlationId"] == null ? void 0 : json["correlationId"],
11598
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11599
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11600
+ "deliveredAt": json["deliveredAt"] == null ? void 0 : new Date(json["deliveredAt"]),
11601
+ "documentId": json["documentId"] == null ? void 0 : json["documentId"],
11602
+ "endpointId": json["endpointId"],
11603
+ "externalId": json["externalId"] == null ? void 0 : json["externalId"],
11604
+ "failureReason": json["failureReason"] == null ? void 0 : json["failureReason"],
11605
+ "id": json["id"],
11606
+ "manual": json["manual"],
11607
+ "nextAttemptAt": json["nextAttemptAt"] == null ? void 0 : new Date(json["nextAttemptAt"]),
11608
+ "occurredAt": new Date(json["occurredAt"]),
11609
+ "outcome": json["outcome"] == null ? void 0 : json["outcome"],
11610
+ "status": json["status"],
11611
+ "type": json["type"],
11612
+ "webhookId": json["webhookId"]
11613
+ };
11614
+ }
11615
+ function WebhookEventOutDTOToJSON(json) {
11616
+ return WebhookEventOutDTOToJSONTyped(json, false);
11617
+ }
11618
+ function WebhookEventOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11619
+ if (value == null) {
11620
+ return value;
11621
+ }
11622
+ return {
11623
+ "attemptCount": value["attemptCount"],
11624
+ "attempts": value["attempts"] == null ? void 0 : value["attempts"].map(WebhookAttemptOutDTOToJSON),
11625
+ "correlationId": value["correlationId"],
11626
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11627
+ "createdAtTimestamp": value["createdAtTimestamp"],
11628
+ "deliveredAt": value["deliveredAt"] == null ? value["deliveredAt"] : value["deliveredAt"].toISOString(),
11629
+ "documentId": value["documentId"],
11630
+ "endpointId": value["endpointId"],
11631
+ "externalId": value["externalId"],
11632
+ "failureReason": value["failureReason"],
11633
+ "id": value["id"],
11634
+ "manual": value["manual"],
11635
+ "nextAttemptAt": value["nextAttemptAt"] == null ? value["nextAttemptAt"] : value["nextAttemptAt"].toISOString(),
11636
+ "occurredAt": value["occurredAt"].toISOString(),
11637
+ "outcome": value["outcome"],
11638
+ "status": value["status"],
11639
+ "type": value["type"],
11640
+ "webhookId": value["webhookId"]
11641
+ };
11642
+ }
11643
+
11644
+ // src/generated/models/WebhookEventListOutDTO.ts
11645
+ function instanceOfWebhookEventListOutDTO(value) {
11646
+ if (!("count" in value) || value["count"] === void 0) return false;
11647
+ if (!("events" in value) || value["events"] === void 0) return false;
11648
+ return true;
11649
+ }
11650
+ function WebhookEventListOutDTOFromJSON(json) {
11651
+ return WebhookEventListOutDTOFromJSONTyped(json, false);
11652
+ }
11653
+ function WebhookEventListOutDTOFromJSONTyped(json, ignoreDiscriminator) {
11654
+ if (json == null) {
11655
+ return json;
11656
+ }
11657
+ return {
11658
+ "count": json["count"],
11659
+ "createdAt": json["createdAt"] == null ? void 0 : new Date(json["createdAt"]),
11660
+ "createdAtTimestamp": json["createdAtTimestamp"] == null ? void 0 : json["createdAtTimestamp"],
11661
+ "events": json["events"].map(WebhookEventOutDTOFromJSON),
11662
+ "hasMore": json["hasMore"] == null ? void 0 : json["hasMore"],
11663
+ "nextCreatedBefore": json["nextCreatedBefore"] == null ? void 0 : json["nextCreatedBefore"],
11664
+ "servedAt": json["servedAt"] == null ? void 0 : new Date(json["servedAt"]),
11665
+ "servedAtTimestamp": json["servedAtTimestamp"] == null ? void 0 : json["servedAtTimestamp"]
11666
+ };
11667
+ }
11668
+ function WebhookEventListOutDTOToJSON(json) {
11669
+ return WebhookEventListOutDTOToJSONTyped(json, false);
11670
+ }
11671
+ function WebhookEventListOutDTOToJSONTyped(value, ignoreDiscriminator = false) {
11672
+ if (value == null) {
11673
+ return value;
11674
+ }
11675
+ return {
11676
+ "count": value["count"],
11677
+ "createdAt": value["createdAt"] == null ? value["createdAt"] : value["createdAt"].toISOString(),
11678
+ "createdAtTimestamp": value["createdAtTimestamp"],
11679
+ "events": value["events"].map(WebhookEventOutDTOToJSON),
11680
+ "hasMore": value["hasMore"],
11681
+ "nextCreatedBefore": value["nextCreatedBefore"],
11682
+ "servedAt": value["servedAt"] == null ? value["servedAt"] : value["servedAt"].toISOString(),
11683
+ "servedAtTimestamp": value["servedAtTimestamp"]
11684
+ };
11685
+ }
11686
+
11687
+ // src/generated/apis/WebhooksApi.ts
11688
+ var WebhooksApi = class extends BaseAPI {
11689
+ /**
11690
+ * Creates request options for createWebhookEndpoint without sending the request
11691
+ */
11692
+ async createWebhookEndpointRequestOpts(requestParameters) {
11693
+ if (requestParameters["webhookEndpointCreateInDTO"] == null) {
11694
+ throw new RequiredError(
11695
+ "webhookEndpointCreateInDTO",
11696
+ 'Required parameter "webhookEndpointCreateInDTO" was null or undefined when calling createWebhookEndpoint().'
11697
+ );
11698
+ }
11699
+ const queryParameters = {};
11700
+ const headerParameters = {};
11701
+ headerParameters["Content-Type"] = "application/json";
11702
+ if (this.configuration && this.configuration.accessToken) {
11703
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11704
+ }
11705
+ let urlPath = `/api/v1/webhooks/endpoints`;
11706
+ return {
11707
+ path: urlPath,
11708
+ method: "POST",
11709
+ headers: headerParameters,
11710
+ query: queryParameters,
11711
+ body: WebhookEndpointCreateInDTOToJSON(requestParameters["webhookEndpointCreateInDTO"])
11712
+ };
11713
+ }
11714
+ /**
11715
+ * Register the account\'s webhook endpoint. The signing secret is returned once, here.
11716
+ * Create Webhook Endpoint
11717
+ */
11718
+ async createWebhookEndpointRaw(requestParameters, initOverrides) {
11719
+ const requestOptions = await this.createWebhookEndpointRequestOpts(requestParameters);
11720
+ const response = await this.request(requestOptions, initOverrides);
11721
+ return new JSONApiResponse(response, (jsonValue) => CreatedWebhookEndpointOutDTOFromJSON(jsonValue));
11722
+ }
11723
+ /**
11724
+ * Register the account\'s webhook endpoint. The signing secret is returned once, here.
11725
+ * Create Webhook Endpoint
11726
+ */
11727
+ async createWebhookEndpoint(requestParameters, initOverrides) {
11728
+ const response = await this.createWebhookEndpointRaw(requestParameters, initOverrides);
11729
+ return await response.value();
11730
+ }
11731
+ /**
11732
+ * Creates request options for deleteWebhookEndpoint without sending the request
11733
+ */
11734
+ async deleteWebhookEndpointRequestOpts(requestParameters) {
11735
+ if (requestParameters["endpointId"] == null) {
11736
+ throw new RequiredError(
11737
+ "endpointId",
11738
+ 'Required parameter "endpointId" was null or undefined when calling deleteWebhookEndpoint().'
11739
+ );
11740
+ }
11741
+ const queryParameters = {};
11742
+ const headerParameters = {};
11743
+ if (this.configuration && this.configuration.accessToken) {
11744
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11745
+ }
11746
+ let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}`;
11747
+ urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
11748
+ return {
11749
+ path: urlPath,
11750
+ method: "DELETE",
11751
+ headers: headerParameters,
11752
+ query: queryParameters
11753
+ };
11754
+ }
11755
+ /**
11756
+ * Delete the endpoint. Its pending events are failed and nothing more is sent.
11757
+ * Delete Webhook Endpoint
11758
+ */
11759
+ async deleteWebhookEndpointRaw(requestParameters, initOverrides) {
11760
+ const requestOptions = await this.deleteWebhookEndpointRequestOpts(requestParameters);
11761
+ const response = await this.request(requestOptions, initOverrides);
11762
+ return new VoidApiResponse(response);
11763
+ }
11764
+ /**
11765
+ * Delete the endpoint. Its pending events are failed and nothing more is sent.
11766
+ * Delete Webhook Endpoint
11767
+ */
11768
+ async deleteWebhookEndpoint(requestParameters, initOverrides) {
11769
+ await this.deleteWebhookEndpointRaw(requestParameters, initOverrides);
11770
+ }
11771
+ /**
11772
+ * Creates request options for getWebhookEndpoint without sending the request
11773
+ */
11774
+ async getWebhookEndpointRequestOpts(requestParameters) {
11775
+ if (requestParameters["endpointId"] == null) {
11776
+ throw new RequiredError(
11777
+ "endpointId",
11778
+ 'Required parameter "endpointId" was null or undefined when calling getWebhookEndpoint().'
11779
+ );
11780
+ }
11781
+ const queryParameters = {};
11782
+ const headerParameters = {};
11783
+ if (this.configuration && this.configuration.accessToken) {
11784
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11785
+ }
11786
+ let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}`;
11787
+ urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
11788
+ return {
11789
+ path: urlPath,
11790
+ method: "GET",
11791
+ headers: headerParameters,
11792
+ query: queryParameters
11793
+ };
11794
+ }
11795
+ /**
11796
+ * One webhook endpoint. The signing secret is never returned here.
11797
+ * Get Webhook Endpoint
11798
+ */
11799
+ async getWebhookEndpointRaw(requestParameters, initOverrides) {
11800
+ const requestOptions = await this.getWebhookEndpointRequestOpts(requestParameters);
11801
+ const response = await this.request(requestOptions, initOverrides);
11802
+ return new JSONApiResponse(response, (jsonValue) => WebhookEndpointOutDTOFromJSON(jsonValue));
11803
+ }
11804
+ /**
11805
+ * One webhook endpoint. The signing secret is never returned here.
11806
+ * Get Webhook Endpoint
11807
+ */
11808
+ async getWebhookEndpoint(requestParameters, initOverrides) {
11809
+ const response = await this.getWebhookEndpointRaw(requestParameters, initOverrides);
11810
+ return await response.value();
11811
+ }
11812
+ /**
11813
+ * Creates request options for getWebhookEvent without sending the request
11814
+ */
11815
+ async getWebhookEventRequestOpts(requestParameters) {
11816
+ if (requestParameters["eventId"] == null) {
11817
+ throw new RequiredError(
11818
+ "eventId",
11819
+ 'Required parameter "eventId" was null or undefined when calling getWebhookEvent().'
11820
+ );
11821
+ }
11822
+ const queryParameters = {};
11823
+ const headerParameters = {};
11824
+ if (this.configuration && this.configuration.accessToken) {
11825
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11826
+ }
11827
+ let urlPath = `/api/v1/webhooks/events/{event_id}`;
11828
+ urlPath = urlPath.replace("{event_id}", encodeURIComponent(String(requestParameters["eventId"])));
11829
+ return {
11830
+ path: urlPath,
11831
+ method: "GET",
11832
+ headers: headerParameters,
11833
+ query: queryParameters
11834
+ };
11835
+ }
11836
+ /**
11837
+ * One event with its delivery attempts. Use it to follow a test or a resend that was still pending.
11838
+ * Get Webhook Event
11839
+ */
11840
+ async getWebhookEventRaw(requestParameters, initOverrides) {
11841
+ const requestOptions = await this.getWebhookEventRequestOpts(requestParameters);
11842
+ const response = await this.request(requestOptions, initOverrides);
11843
+ return new JSONApiResponse(response, (jsonValue) => WebhookEventOutDTOFromJSON(jsonValue));
11844
+ }
11845
+ /**
11846
+ * One event with its delivery attempts. Use it to follow a test or a resend that was still pending.
11847
+ * Get Webhook Event
11848
+ */
11849
+ async getWebhookEvent(requestParameters, initOverrides) {
11850
+ const response = await this.getWebhookEventRaw(requestParameters, initOverrides);
11851
+ return await response.value();
11852
+ }
11853
+ /**
11854
+ * Creates request options for listWebhookEndpoints without sending the request
11855
+ */
11856
+ async listWebhookEndpointsRequestOpts() {
11857
+ const queryParameters = {};
11858
+ const headerParameters = {};
11859
+ if (this.configuration && this.configuration.accessToken) {
11860
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11861
+ }
11862
+ let urlPath = `/api/v1/webhooks/endpoints`;
11863
+ return {
11864
+ path: urlPath,
11865
+ method: "GET",
11866
+ headers: headerParameters,
11867
+ query: queryParameters
11868
+ };
11869
+ }
11870
+ /**
11871
+ * The account\'s webhook endpoint, as a list (an account has at most one).
11872
+ * List Webhook Endpoints
11873
+ */
11874
+ async listWebhookEndpointsRaw(initOverrides) {
11875
+ const requestOptions = await this.listWebhookEndpointsRequestOpts();
11876
+ const response = await this.request(requestOptions, initOverrides);
11877
+ return new JSONApiResponse(response, (jsonValue) => WebhookEndpointListOutDTOFromJSON(jsonValue));
11878
+ }
11879
+ /**
11880
+ * The account\'s webhook endpoint, as a list (an account has at most one).
11881
+ * List Webhook Endpoints
11882
+ */
11883
+ async listWebhookEndpoints(initOverrides) {
11884
+ const response = await this.listWebhookEndpointsRaw(initOverrides);
11885
+ return await response.value();
11886
+ }
11887
+ /**
11888
+ * Creates request options for listWebhookEvents without sending the request
11889
+ */
11890
+ async listWebhookEventsRequestOpts(requestParameters) {
11891
+ const queryParameters = {};
11892
+ if (requestParameters["status"] != null) {
11893
+ queryParameters["status"] = requestParameters["status"];
11894
+ }
11895
+ if (requestParameters["skip"] != null) {
11896
+ queryParameters["skip"] = requestParameters["skip"];
11897
+ }
11898
+ if (requestParameters["limit"] != null) {
11899
+ queryParameters["limit"] = requestParameters["limit"];
11900
+ }
11901
+ if (requestParameters["createdBefore"] != null) {
11902
+ queryParameters["createdBefore"] = requestParameters["createdBefore"];
11903
+ }
11904
+ const headerParameters = {};
11905
+ if (this.configuration && this.configuration.accessToken) {
11906
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11907
+ }
11908
+ let urlPath = `/api/v1/webhooks/events`;
11909
+ return {
11910
+ path: urlPath,
11911
+ method: "GET",
11912
+ headers: headerParameters,
11913
+ query: queryParameters
11914
+ };
11915
+ }
11916
+ /**
11917
+ * 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.
11918
+ * List Webhook Events
11919
+ */
11920
+ async listWebhookEventsRaw(requestParameters, initOverrides) {
11921
+ const requestOptions = await this.listWebhookEventsRequestOpts(requestParameters);
11922
+ const response = await this.request(requestOptions, initOverrides);
11923
+ return new JSONApiResponse(response, (jsonValue) => WebhookEventListOutDTOFromJSON(jsonValue));
11924
+ }
11925
+ /**
11926
+ * 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.
11927
+ * List Webhook Events
11928
+ */
11929
+ async listWebhookEvents(requestParameters = {}, initOverrides) {
11930
+ const response = await this.listWebhookEventsRaw(requestParameters, initOverrides);
11931
+ return await response.value();
11932
+ }
11933
+ /**
11934
+ * Creates request options for resendWebhookEvent without sending the request
11935
+ */
11936
+ async resendWebhookEventRequestOpts(requestParameters) {
11937
+ if (requestParameters["eventId"] == null) {
11938
+ throw new RequiredError(
11939
+ "eventId",
11940
+ 'Required parameter "eventId" was null or undefined when calling resendWebhookEvent().'
11941
+ );
11942
+ }
11943
+ const queryParameters = {};
11944
+ const headerParameters = {};
11945
+ if (this.configuration && this.configuration.accessToken) {
11946
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11947
+ }
11948
+ let urlPath = `/api/v1/webhooks/events/{event_id}/resend`;
11949
+ urlPath = urlPath.replace("{event_id}", encodeURIComponent(String(requestParameters["eventId"])));
11950
+ return {
11951
+ path: urlPath,
11952
+ method: "POST",
11953
+ headers: headerParameters,
11954
+ query: queryParameters
11955
+ };
11956
+ }
11957
+ /**
11958
+ * 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`.
11959
+ * Resend Webhook Event
11960
+ */
11961
+ async resendWebhookEventRaw(requestParameters, initOverrides) {
11962
+ const requestOptions = await this.resendWebhookEventRequestOpts(requestParameters);
11963
+ const response = await this.request(requestOptions, initOverrides);
11964
+ return new JSONApiResponse(response, (jsonValue) => WebhookDeliveryResultOutDTOFromJSON(jsonValue));
11965
+ }
11966
+ /**
11967
+ * 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`.
11968
+ * Resend Webhook Event
11969
+ */
11970
+ async resendWebhookEvent(requestParameters, initOverrides) {
11971
+ const response = await this.resendWebhookEventRaw(requestParameters, initOverrides);
11972
+ return await response.value();
11973
+ }
11974
+ /**
11975
+ * Creates request options for rotateWebhookEndpointSecret without sending the request
11976
+ */
11977
+ async rotateWebhookEndpointSecretRequestOpts(requestParameters) {
11978
+ if (requestParameters["endpointId"] == null) {
11979
+ throw new RequiredError(
11980
+ "endpointId",
11981
+ 'Required parameter "endpointId" was null or undefined when calling rotateWebhookEndpointSecret().'
11982
+ );
11983
+ }
11984
+ const queryParameters = {};
11985
+ const headerParameters = {};
11986
+ if (this.configuration && this.configuration.accessToken) {
11987
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
11988
+ }
11989
+ let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}/rotate-secret`;
11990
+ urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
11991
+ return {
11992
+ path: urlPath,
11993
+ method: "POST",
11994
+ headers: headerParameters,
11995
+ query: queryParameters
11996
+ };
11997
+ }
11998
+ /**
11999
+ * 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.
12000
+ * Rotate Webhook Endpoint Secret
12001
+ */
12002
+ async rotateWebhookEndpointSecretRaw(requestParameters, initOverrides) {
12003
+ const requestOptions = await this.rotateWebhookEndpointSecretRequestOpts(requestParameters);
12004
+ const response = await this.request(requestOptions, initOverrides);
12005
+ return new JSONApiResponse(response, (jsonValue) => CreatedWebhookEndpointOutDTOFromJSON(jsonValue));
12006
+ }
12007
+ /**
12008
+ * 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.
12009
+ * Rotate Webhook Endpoint Secret
12010
+ */
12011
+ async rotateWebhookEndpointSecret(requestParameters, initOverrides) {
12012
+ const response = await this.rotateWebhookEndpointSecretRaw(requestParameters, initOverrides);
12013
+ return await response.value();
12014
+ }
12015
+ /**
12016
+ * Creates request options for sendWebhookTestEvent without sending the request
12017
+ */
12018
+ async sendWebhookTestEventRequestOpts(requestParameters) {
12019
+ if (requestParameters["endpointId"] == null) {
12020
+ throw new RequiredError(
12021
+ "endpointId",
12022
+ 'Required parameter "endpointId" was null or undefined when calling sendWebhookTestEvent().'
12023
+ );
12024
+ }
12025
+ const queryParameters = {};
12026
+ const headerParameters = {};
12027
+ if (this.configuration && this.configuration.accessToken) {
12028
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
12029
+ }
12030
+ let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}/test`;
12031
+ urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
12032
+ return {
12033
+ path: urlPath,
12034
+ method: "POST",
12035
+ headers: headerParameters,
12036
+ query: queryParameters
12037
+ };
12038
+ }
12039
+ /**
12040
+ * 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`.
12041
+ * Send Webhook Test Event
12042
+ */
12043
+ async sendWebhookTestEventRaw(requestParameters, initOverrides) {
12044
+ const requestOptions = await this.sendWebhookTestEventRequestOpts(requestParameters);
12045
+ const response = await this.request(requestOptions, initOverrides);
12046
+ return new JSONApiResponse(response, (jsonValue) => WebhookDeliveryResultOutDTOFromJSON(jsonValue));
12047
+ }
12048
+ /**
12049
+ * 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`.
12050
+ * Send Webhook Test Event
12051
+ */
12052
+ async sendWebhookTestEvent(requestParameters, initOverrides) {
12053
+ const response = await this.sendWebhookTestEventRaw(requestParameters, initOverrides);
12054
+ return await response.value();
12055
+ }
12056
+ /**
12057
+ * Creates request options for updateWebhookEndpoint without sending the request
12058
+ */
12059
+ async updateWebhookEndpointRequestOpts(requestParameters) {
12060
+ if (requestParameters["endpointId"] == null) {
12061
+ throw new RequiredError(
12062
+ "endpointId",
12063
+ 'Required parameter "endpointId" was null or undefined when calling updateWebhookEndpoint().'
12064
+ );
12065
+ }
12066
+ if (requestParameters["webhookEndpointUpdateInDTO"] == null) {
12067
+ throw new RequiredError(
12068
+ "webhookEndpointUpdateInDTO",
12069
+ 'Required parameter "webhookEndpointUpdateInDTO" was null or undefined when calling updateWebhookEndpoint().'
12070
+ );
12071
+ }
12072
+ const queryParameters = {};
12073
+ const headerParameters = {};
12074
+ headerParameters["Content-Type"] = "application/json";
12075
+ if (this.configuration && this.configuration.accessToken) {
12076
+ headerParameters["Authorization"] = await this.configuration.accessToken("OAuth2PasswordBearer", []);
12077
+ }
12078
+ let urlPath = `/api/v1/webhooks/endpoints/{endpoint_id}`;
12079
+ urlPath = urlPath.replace("{endpoint_id}", encodeURIComponent(String(requestParameters["endpointId"])));
12080
+ return {
12081
+ path: urlPath,
12082
+ method: "PATCH",
12083
+ headers: headerParameters,
12084
+ query: queryParameters,
12085
+ body: WebhookEndpointUpdateInDTOToJSON(requestParameters["webhookEndpointUpdateInDTO"])
12086
+ };
12087
+ }
12088
+ /**
12089
+ * Change the URL or description, or enable or disable the endpoint.
12090
+ * Update Webhook Endpoint
12091
+ */
12092
+ async updateWebhookEndpointRaw(requestParameters, initOverrides) {
12093
+ const requestOptions = await this.updateWebhookEndpointRequestOpts(requestParameters);
12094
+ const response = await this.request(requestOptions, initOverrides);
12095
+ return new JSONApiResponse(response, (jsonValue) => WebhookEndpointOutDTOFromJSON(jsonValue));
12096
+ }
12097
+ /**
12098
+ * Change the URL or description, or enable or disable the endpoint.
12099
+ * Update Webhook Endpoint
12100
+ */
12101
+ async updateWebhookEndpoint(requestParameters, initOverrides) {
12102
+ const response = await this.updateWebhookEndpointRaw(requestParameters, initOverrides);
12103
+ return await response.value();
12104
+ }
12105
+ };
12106
+ var ListWebhookEventsStatusEnum = {
12107
+ Pending: "pending",
12108
+ Delivered: "delivered",
12109
+ Failed: "failed",
12110
+ Superseded: "superseded"
12111
+ };
12112
+
11149
12113
  // src/generated/models/CreditMeterFilter.ts
11150
12114
  var CreditMeterFilter = {
11151
12115
  ProcessingCredits: "processing_credits",
@@ -11217,6 +12181,93 @@ function FoundationDTOToJSONTyped(value, ignoreDiscriminator = false) {
11217
12181
  };
11218
12182
  }
11219
12183
 
12184
+ // src/generated/models/ExtractionCompletedEventData.ts
12185
+ function instanceOfExtractionCompletedEventData(value) {
12186
+ if (!("correlationId" in value) || value["correlationId"] === void 0) return false;
12187
+ if (!("resultIncluded" in value) || value["resultIncluded"] === void 0) return false;
12188
+ if (!("resultPath" in value) || value["resultPath"] === void 0) return false;
12189
+ if (!("status" in value) || value["status"] === void 0) return false;
12190
+ return true;
12191
+ }
12192
+ function ExtractionCompletedEventDataFromJSON(json) {
12193
+ return ExtractionCompletedEventDataFromJSONTyped(json, false);
12194
+ }
12195
+ function ExtractionCompletedEventDataFromJSONTyped(json, ignoreDiscriminator) {
12196
+ if (json == null) {
12197
+ return json;
12198
+ }
12199
+ return {
12200
+ "channel": json["channel"] == null ? void 0 : json["channel"],
12201
+ "correlationId": json["correlationId"],
12202
+ "documentId": json["documentId"] == null ? void 0 : json["documentId"],
12203
+ "endUserId": json["endUserId"] == null ? void 0 : json["endUserId"],
12204
+ "error": json["error"] == null ? void 0 : FoundationDTOFromJSON(json["error"]),
12205
+ "externalId": json["externalId"] == null ? void 0 : json["externalId"],
12206
+ "result": json["result"] == null ? void 0 : DocumentProcessingResultOutDTOFromJSON(json["result"]),
12207
+ "resultIncluded": json["resultIncluded"],
12208
+ "resultPath": json["resultPath"],
12209
+ "status": json["status"]
12210
+ };
12211
+ }
12212
+ function ExtractionCompletedEventDataToJSON(json) {
12213
+ return ExtractionCompletedEventDataToJSONTyped(json, false);
12214
+ }
12215
+ function ExtractionCompletedEventDataToJSONTyped(value, ignoreDiscriminator = false) {
12216
+ if (value == null) {
12217
+ return value;
12218
+ }
12219
+ return {
12220
+ "channel": value["channel"],
12221
+ "correlationId": value["correlationId"],
12222
+ "documentId": value["documentId"],
12223
+ "endUserId": value["endUserId"],
12224
+ "error": FoundationDTOToJSON(value["error"]),
12225
+ "externalId": value["externalId"],
12226
+ "result": DocumentProcessingResultOutDTOToJSON(value["result"]),
12227
+ "resultIncluded": value["resultIncluded"],
12228
+ "resultPath": value["resultPath"],
12229
+ "status": value["status"]
12230
+ };
12231
+ }
12232
+
12233
+ // src/generated/models/ExtractionCompletedEvent.ts
12234
+ var ExtractionCompletedEventTypeEnum = {
12235
+ ExtractionCompleted: "extraction.completed"
12236
+ };
12237
+ function instanceOfExtractionCompletedEvent(value) {
12238
+ if (!("data" in value) || value["data"] === void 0) return false;
12239
+ if (!("timestamp" in value) || value["timestamp"] === void 0) return false;
12240
+ if (!("type" in value) || value["type"] === void 0) return false;
12241
+ if (value["type"] !== "extraction.completed") return false;
12242
+ return true;
12243
+ }
12244
+ function ExtractionCompletedEventFromJSON(json) {
12245
+ return ExtractionCompletedEventFromJSONTyped(json, false);
12246
+ }
12247
+ function ExtractionCompletedEventFromJSONTyped(json, ignoreDiscriminator) {
12248
+ if (json == null) {
12249
+ return json;
12250
+ }
12251
+ return {
12252
+ "data": ExtractionCompletedEventDataFromJSON(json["data"]),
12253
+ "timestamp": new Date(json["timestamp"]),
12254
+ "type": json["type"]
12255
+ };
12256
+ }
12257
+ function ExtractionCompletedEventToJSON(json) {
12258
+ return ExtractionCompletedEventToJSONTyped(json, false);
12259
+ }
12260
+ function ExtractionCompletedEventToJSONTyped(value, ignoreDiscriminator = false) {
12261
+ if (value == null) {
12262
+ return value;
12263
+ }
12264
+ return {
12265
+ "data": ExtractionCompletedEventDataToJSON(value["data"]),
12266
+ "timestamp": value["timestamp"].toISOString(),
12267
+ "type": value["type"]
12268
+ };
12269
+ }
12270
+
11220
12271
  // src/generated/models/LocationInner.ts
11221
12272
  function instanceOfLocationInner(value) {
11222
12273
  return true;
@@ -11382,6 +12433,72 @@ function ValueAnyOfInnerToJSONTyped(value, ignoreDiscriminator = false) {
11382
12433
  return value;
11383
12434
  }
11384
12435
 
12436
+ // src/generated/models/WebhookTestEventData.ts
12437
+ function instanceOfWebhookTestEventData(value) {
12438
+ if (!("message" in value) || value["message"] === void 0) return false;
12439
+ return true;
12440
+ }
12441
+ function WebhookTestEventDataFromJSON(json) {
12442
+ return WebhookTestEventDataFromJSONTyped(json, false);
12443
+ }
12444
+ function WebhookTestEventDataFromJSONTyped(json, ignoreDiscriminator) {
12445
+ if (json == null) {
12446
+ return json;
12447
+ }
12448
+ return {
12449
+ "message": json["message"]
12450
+ };
12451
+ }
12452
+ function WebhookTestEventDataToJSON(json) {
12453
+ return WebhookTestEventDataToJSONTyped(json, false);
12454
+ }
12455
+ function WebhookTestEventDataToJSONTyped(value, ignoreDiscriminator = false) {
12456
+ if (value == null) {
12457
+ return value;
12458
+ }
12459
+ return {
12460
+ "message": value["message"]
12461
+ };
12462
+ }
12463
+
12464
+ // src/generated/models/WebhookTestEvent.ts
12465
+ var WebhookTestEventTypeEnum = {
12466
+ WebhookTest: "webhook.test"
12467
+ };
12468
+ function instanceOfWebhookTestEvent(value) {
12469
+ if (!("data" in value) || value["data"] === void 0) return false;
12470
+ if (!("timestamp" in value) || value["timestamp"] === void 0) return false;
12471
+ if (!("type" in value) || value["type"] === void 0) return false;
12472
+ if (value["type"] !== "webhook.test") return false;
12473
+ return true;
12474
+ }
12475
+ function WebhookTestEventFromJSON(json) {
12476
+ return WebhookTestEventFromJSONTyped(json, false);
12477
+ }
12478
+ function WebhookTestEventFromJSONTyped(json, ignoreDiscriminator) {
12479
+ if (json == null) {
12480
+ return json;
12481
+ }
12482
+ return {
12483
+ "data": WebhookTestEventDataFromJSON(json["data"]),
12484
+ "timestamp": new Date(json["timestamp"]),
12485
+ "type": json["type"]
12486
+ };
12487
+ }
12488
+ function WebhookTestEventToJSON(json) {
12489
+ return WebhookTestEventToJSONTyped(json, false);
12490
+ }
12491
+ function WebhookTestEventToJSONTyped(value, ignoreDiscriminator = false) {
12492
+ if (value == null) {
12493
+ return value;
12494
+ }
12495
+ return {
12496
+ "data": WebhookTestEventDataToJSON(value["data"]),
12497
+ "timestamp": value["timestamp"].toISOString(),
12498
+ "type": value["type"]
12499
+ };
12500
+ }
12501
+
11385
12502
  // src/errors.ts
11386
12503
  var GeminaError = class extends Error {
11387
12504
  constructor(message) {
@@ -11407,6 +12524,14 @@ var GeminaTimeoutError = class extends GeminaError {
11407
12524
  Object.setPrototypeOf(this, new.target.prototype);
11408
12525
  }
11409
12526
  };
12527
+ var GeminaWebhookVerificationError = class extends GeminaError {
12528
+ constructor(reason, message, cause) {
12529
+ super(message);
12530
+ this.reason = reason;
12531
+ if (cause !== void 0) this.cause = cause;
12532
+ Object.setPrototypeOf(this, new.target.prototype);
12533
+ }
12534
+ };
11410
12535
 
11411
12536
  // src/helpers.ts
11412
12537
  var DEFAULT_BASE_URL = "https://api.gemina.co";
@@ -11543,6 +12668,10 @@ var GeminaClient = class _GeminaClient {
11543
12668
  * Build a client authenticated with a short-lived session token
11544
12669
  * (`OAuth2PasswordBearer` bearer scheme) instead of an API key. Use this
11545
12670
  * in browser/session contexts — never ship the API key to a browser.
12671
+ *
12672
+ * The factory sends whatever bearer token it is given. A retrieval token
12673
+ * from `sessions` does not reach the `webhooks` group, which needs the
12674
+ * account-login JWT (the token the console signs in with).
11546
12675
  */
11547
12676
  static withSessionToken(token, baseUrl = DEFAULT_BASE_URL, options = {}) {
11548
12677
  const headerValue = token.startsWith("Bearer ") ? token : `Bearer ${token}`;
@@ -11592,6 +12721,15 @@ var GeminaClient = class _GeminaClient {
11592
12721
  var _a;
11593
12722
  return (_a = this.apiCache).billing ?? (_a.billing = this.apiOverrides.billing ?? new BillingApi(this.configuration));
11594
12723
  }
12724
+ /**
12725
+ * Webhook endpoints and their delivery log. These routes need the
12726
+ * account-login token (build the client with {@link GeminaClient.withSessionToken});
12727
+ * an API key is refused.
12728
+ */
12729
+ get webhooks() {
12730
+ var _a;
12731
+ return (_a = this.apiCache).webhooks ?? (_a.webhooks = this.apiOverrides.webhooks ?? new WebhooksApi(this.configuration));
12732
+ }
11595
12733
  // --- Stateful chat convenience ---
11596
12734
  /**
11597
12735
  * Start a stateful chat {@link GeminaChatConversation} that threads the
@@ -11790,8 +12928,186 @@ async function asProcessingErrorIfFailedResult(error) {
11790
12928
  return new GeminaProcessingError(DocumentProcessingResultOutDTOFromJSON(json));
11791
12929
  }
11792
12930
 
12931
+ // src/webhooks.ts
12932
+ var SECRET_PREFIX = "whsec_";
12933
+ var DEFAULT_TOLERANCE_SECONDS = 300;
12934
+ var BASE64 = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
12935
+ var TIMESTAMP = /^[0-9]{1,12}$/;
12936
+ function isExtractionCompleted(event) {
12937
+ return event.type === "extraction.completed";
12938
+ }
12939
+ function isWebhookTest(event) {
12940
+ return event.type === "webhook.test";
12941
+ }
12942
+ var KNOWN = {
12943
+ "extraction.completed": {
12944
+ required: { correlationId: "string", status: "string", resultIncluded: "boolean", resultPath: "string" },
12945
+ read: ExtractionCompletedEventDataFromJSON
12946
+ },
12947
+ "webhook.test": { required: { message: "string" }, read: WebhookTestEventDataFromJSON }
12948
+ };
12949
+ var fail = (reason, message, cause) => new GeminaWebhookVerificationError(reason, message, cause);
12950
+ function isObject(value) {
12951
+ return value !== null && typeof value === "object" && !Array.isArray(value);
12952
+ }
12953
+ var asciiLower = (text) => text.replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32));
12954
+ function isComplete(type, data) {
12955
+ if (!isObject(data)) return false;
12956
+ if (Object.entries(KNOWN[type].required).some(([field, kind]) => typeof data[field] !== kind)) return false;
12957
+ if (type !== "extraction.completed") return true;
12958
+ const result = data.result ?? null;
12959
+ const error = data.error ?? null;
12960
+ if (result !== null && error !== null) return false;
12961
+ if (result !== null && !(isObject(result) && typeof result.status === "string" && isObject(result.meta) && "data" in result)) {
12962
+ return false;
12963
+ }
12964
+ return error === null || isObject(error) && typeof error.status === "string";
12965
+ }
12966
+ function header(headers, name) {
12967
+ const values = [];
12968
+ const add = (value) => {
12969
+ for (const part of value.split(", ")) if (!values.includes(part)) values.push(part);
12970
+ };
12971
+ const fromEntries = (entries) => {
12972
+ for (const [key, value] of entries) {
12973
+ if (typeof key !== "string" || asciiLower(key) !== name) continue;
12974
+ for (const item of Array.isArray(value) ? value : [value]) if (typeof item === "string") add(item);
12975
+ }
12976
+ };
12977
+ if (headers === null || headers === void 0) {
12978
+ } else if (headers instanceof Map) {
12979
+ fromEntries(headers.entries());
12980
+ } else if (typeof headers.get === "function") {
12981
+ const value = headers.get(name);
12982
+ if (typeof value === "string") add(value);
12983
+ } else {
12984
+ fromEntries(Object.entries(headers));
12985
+ }
12986
+ if (values.length === 0) throw fail("missing_header", `The ${name} header is missing.`);
12987
+ if (values.length > 1) throw fail("ambiguous_header", `The ${name} header was sent more than once with different values.`);
12988
+ return values[0];
12989
+ }
12990
+ function decodeBase64(text) {
12991
+ if (!BASE64.test(text)) return void 0;
12992
+ const binary = atob(text);
12993
+ const bytes = new Uint8Array(binary.length);
12994
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
12995
+ return bytes;
12996
+ }
12997
+ function constantTimeEqual(a, b) {
12998
+ if (a.length !== b.length) return false;
12999
+ let difference = 0;
13000
+ for (let i = 0; i < a.length; i++) difference |= a[i] ^ b[i];
13001
+ return difference === 0;
13002
+ }
13003
+ function isRawBuffer(value) {
13004
+ const tag = Object.prototype.toString.call(value);
13005
+ return tag === "[object ArrayBuffer]" || tag === "[object SharedArrayBuffer]";
13006
+ }
13007
+ function copyBody(body) {
13008
+ if (typeof body === "string") return new TextEncoder().encode(body);
13009
+ if (body == null) return new Uint8Array(0);
13010
+ if (!isRawBuffer(body) && !ArrayBuffer.isView(body)) {
13011
+ throw fail("invalid_body", "The webhook body must be the raw request bytes or text, not a parsed value.");
13012
+ }
13013
+ try {
13014
+ const source = ArrayBuffer.isView(body) ? new Uint8Array(body.buffer, body.byteOffset, body.byteLength) : new Uint8Array(body);
13015
+ const copy = new Uint8Array(source.length);
13016
+ copy.set(source);
13017
+ return copy;
13018
+ } catch (error) {
13019
+ throw fail("invalid_body", "The webhook body cannot be read: its buffer was detached.", error);
13020
+ }
13021
+ }
13022
+ async function subtleCrypto() {
13023
+ const global = globalThis.crypto;
13024
+ if (global?.subtle) return global.subtle;
13025
+ const nodeCrypto = "node:crypto";
13026
+ const module2 = await import(
13027
+ /* @vite-ignore */
13028
+ /* webpackIgnore: true */
13029
+ nodeCrypto
13030
+ );
13031
+ return module2.webcrypto.subtle;
13032
+ }
13033
+ async function verifySignature(rawBody, id, timestampText, signatureHeader, secret) {
13034
+ const key = typeof secret === "string" ? decodeBase64(secret.startsWith(SECRET_PREFIX) ? secret.slice(SECRET_PREFIX.length) : secret) : void 0;
13035
+ if (key === void 0 || key.length === 0) {
13036
+ throw fail("invalid_secret", "The signing secret is not valid: expected whsec_ followed by base64.");
13037
+ }
13038
+ const prefix = new TextEncoder().encode(`${id}.${timestampText}.`);
13039
+ const signed = new Uint8Array(prefix.length + rawBody.length);
13040
+ signed.set(prefix, 0);
13041
+ signed.set(rawBody, prefix.length);
13042
+ const subtle = await subtleCrypto();
13043
+ const cryptoKey = await subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
13044
+ const expected = new Uint8Array(await subtle.sign("HMAC", cryptoKey, signed));
13045
+ let matched = false;
13046
+ for (const entry of signatureHeader.split(" ")) {
13047
+ const comma = entry.indexOf(",");
13048
+ if (comma < 0 || entry.slice(0, comma) !== "v1") continue;
13049
+ const candidate = decodeBase64(entry.slice(comma + 1));
13050
+ if (candidate !== void 0 && constantTimeEqual(candidate, expected)) matched = true;
13051
+ }
13052
+ if (!matched) throw fail("no_matching_signature", "No signature in the webhook-signature header matches.");
13053
+ return signed.subarray(prefix.length);
13054
+ }
13055
+ function parseBody(verifiedBody) {
13056
+ if (verifiedBody.length >= 3 && verifiedBody[0] === 239 && verifiedBody[1] === 187 && verifiedBody[2] === 191) {
13057
+ throw fail("invalid_body", "The webhook body starts with a byte order mark.");
13058
+ }
13059
+ let parsed;
13060
+ try {
13061
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(verifiedBody));
13062
+ } catch (error) {
13063
+ throw fail("invalid_body", "The webhook body is not valid JSON.", error);
13064
+ }
13065
+ if (!isObject(parsed)) throw fail("invalid_body", "The webhook body is not a JSON object.");
13066
+ return parsed;
13067
+ }
13068
+ function typeData(type, data) {
13069
+ if (type === null || !Object.prototype.hasOwnProperty.call(KNOWN, type)) return data;
13070
+ if (!isComplete(type, data)) {
13071
+ throw fail("invalid_body", `The data of this ${type} event is missing a required field.`);
13072
+ }
13073
+ try {
13074
+ return KNOWN[type].read(data);
13075
+ } catch (error) {
13076
+ throw fail("invalid_body", `The data of this ${type} event could not be read.`, error);
13077
+ }
13078
+ }
13079
+ async function unwrapWebhook(body, headers, secret, options = {}) {
13080
+ const rawBody = copyBody(body);
13081
+ options = options ?? {};
13082
+ const id = header(headers, "webhook-id");
13083
+ const timestampText = header(headers, "webhook-timestamp");
13084
+ const signatureHeader = header(headers, "webhook-signature");
13085
+ if (!TIMESTAMP.test(timestampText)) {
13086
+ throw fail("invalid_timestamp", "The webhook-timestamp header is not a whole number of seconds.");
13087
+ }
13088
+ const tolerance = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;
13089
+ const clock = (options.now ?? (() => Date.now() / 1e3))();
13090
+ if (!Number.isFinite(clock) || !Number.isFinite(tolerance) || tolerance < 0) {
13091
+ throw fail(
13092
+ "timestamp_out_of_tolerance",
13093
+ "The clock or the tolerance is not a finite number, so the timestamp cannot be checked."
13094
+ );
13095
+ }
13096
+ if (Math.abs(Math.floor(clock) - Number(timestampText)) > tolerance) {
13097
+ throw fail(
13098
+ "timestamp_out_of_tolerance",
13099
+ `The webhook timestamp is more than ${tolerance} seconds from the current time.`
13100
+ );
13101
+ }
13102
+ const verifiedBody = await verifySignature(rawBody, id, timestampText, signatureHeader, secret);
13103
+ const parsed = parseBody(verifiedBody);
13104
+ const type = typeof parsed.type === "string" ? parsed.type : null;
13105
+ const timestamp = typeof parsed.timestamp === "string" ? parsed.timestamp : null;
13106
+ return { id, type, timestamp, data: typeData(type, parsed.data ?? null), raw: parsed };
13107
+ }
13108
+
11793
13109
  // src/version.ts
11794
- var VERSION = "0.16.1";
13110
+ var VERSION = "0.17.1";
11795
13111
  // Annotate the CommonJS export names for ESM import in node:
11796
13112
  0 && (module.exports = {
11797
13113
  AddExtractionsInDTOFromJSON,
@@ -11878,6 +13194,11 @@ var VERSION = "0.16.1";
11878
13194
  CreateTemplateInDTOFromJSONTyped,
11879
13195
  CreateTemplateInDTOToJSON,
11880
13196
  CreateTemplateInDTOToJSONTyped,
13197
+ CreatedWebhookEndpointOutDTODisabledReasonEnum,
13198
+ CreatedWebhookEndpointOutDTOFromJSON,
13199
+ CreatedWebhookEndpointOutDTOFromJSONTyped,
13200
+ CreatedWebhookEndpointOutDTOToJSON,
13201
+ CreatedWebhookEndpointOutDTOToJSONTyped,
11881
13202
  CreditMeter,
11882
13203
  CreditMeterFilter,
11883
13204
  CreditMeterFilterFromJSON,
@@ -11976,6 +13297,15 @@ var VERSION = "0.16.1";
11976
13297
  EnterpriseTransactionOutDTOFromJSONTyped,
11977
13298
  EnterpriseTransactionOutDTOToJSON,
11978
13299
  EnterpriseTransactionOutDTOToJSONTyped,
13300
+ ExtractionCompletedEventDataFromJSON,
13301
+ ExtractionCompletedEventDataFromJSONTyped,
13302
+ ExtractionCompletedEventDataToJSON,
13303
+ ExtractionCompletedEventDataToJSONTyped,
13304
+ ExtractionCompletedEventFromJSON,
13305
+ ExtractionCompletedEventFromJSONTyped,
13306
+ ExtractionCompletedEventToJSON,
13307
+ ExtractionCompletedEventToJSONTyped,
13308
+ ExtractionCompletedEventTypeEnum,
11979
13309
  ExtractionCostOutDTOFromJSON,
11980
13310
  ExtractionCostOutDTOFromJSONTyped,
11981
13311
  ExtractionCostOutDTOToJSON,
@@ -12119,6 +13449,7 @@ var VERSION = "0.16.1";
12119
13449
  GeminaError,
12120
13450
  GeminaProcessingError,
12121
13451
  GeminaTimeoutError,
13452
+ GeminaWebhookVerificationError,
12122
13453
  GenerateTemplateFromUrlInDTOFromJSON,
12123
13454
  GenerateTemplateFromUrlInDTOFromJSONTyped,
12124
13455
  GenerateTemplateFromUrlInDTOToJSON,
@@ -12151,6 +13482,7 @@ var VERSION = "0.16.1";
12151
13482
  InvoiceTypeToJSONTyped,
12152
13483
  JSONApiResponse,
12153
13484
  LegalApi,
13485
+ ListWebhookEventsStatusEnum,
12154
13486
  LocationInnerFromJSON,
12155
13487
  LocationInnerFromJSONTyped,
12156
13488
  LocationInnerToJSON,
@@ -12466,10 +13798,56 @@ var VERSION = "0.16.1";
12466
13798
  WebDocumentUploadInDTOFromJSONTyped,
12467
13799
  WebDocumentUploadInDTOToJSON,
12468
13800
  WebDocumentUploadInDTOToJSONTyped,
13801
+ WebhookAttemptOutDTOFromJSON,
13802
+ WebhookAttemptOutDTOFromJSONTyped,
13803
+ WebhookAttemptOutDTOToJSON,
13804
+ WebhookAttemptOutDTOToJSONTyped,
13805
+ WebhookDeliveryResultOutDTOFromJSON,
13806
+ WebhookDeliveryResultOutDTOFromJSONTyped,
13807
+ WebhookDeliveryResultOutDTOToJSON,
13808
+ WebhookDeliveryResultOutDTOToJSONTyped,
13809
+ WebhookEndpointCreateInDTOFromJSON,
13810
+ WebhookEndpointCreateInDTOFromJSONTyped,
13811
+ WebhookEndpointCreateInDTOToJSON,
13812
+ WebhookEndpointCreateInDTOToJSONTyped,
13813
+ WebhookEndpointListOutDTOFromJSON,
13814
+ WebhookEndpointListOutDTOFromJSONTyped,
13815
+ WebhookEndpointListOutDTOToJSON,
13816
+ WebhookEndpointListOutDTOToJSONTyped,
13817
+ WebhookEndpointOutDTODisabledReasonEnum,
13818
+ WebhookEndpointOutDTOFromJSON,
13819
+ WebhookEndpointOutDTOFromJSONTyped,
13820
+ WebhookEndpointOutDTOToJSON,
13821
+ WebhookEndpointOutDTOToJSONTyped,
13822
+ WebhookEndpointUpdateInDTOFromJSON,
13823
+ WebhookEndpointUpdateInDTOFromJSONTyped,
13824
+ WebhookEndpointUpdateInDTOToJSON,
13825
+ WebhookEndpointUpdateInDTOToJSONTyped,
13826
+ WebhookEventListOutDTOFromJSON,
13827
+ WebhookEventListOutDTOFromJSONTyped,
13828
+ WebhookEventListOutDTOToJSON,
13829
+ WebhookEventListOutDTOToJSONTyped,
13830
+ WebhookEventOutDTOFailureReasonEnum,
13831
+ WebhookEventOutDTOFromJSON,
13832
+ WebhookEventOutDTOFromJSONTyped,
13833
+ WebhookEventOutDTOStatusEnum,
13834
+ WebhookEventOutDTOToJSON,
13835
+ WebhookEventOutDTOToJSONTyped,
13836
+ WebhookEventOutDTOTypeEnum,
12469
13837
  WebhookResponseDTOFromJSON,
12470
13838
  WebhookResponseDTOFromJSONTyped,
12471
13839
  WebhookResponseDTOToJSON,
12472
13840
  WebhookResponseDTOToJSONTyped,
13841
+ WebhookTestEventDataFromJSON,
13842
+ WebhookTestEventDataFromJSONTyped,
13843
+ WebhookTestEventDataToJSON,
13844
+ WebhookTestEventDataToJSONTyped,
13845
+ WebhookTestEventFromJSON,
13846
+ WebhookTestEventFromJSONTyped,
13847
+ WebhookTestEventToJSON,
13848
+ WebhookTestEventToJSONTyped,
13849
+ WebhookTestEventTypeEnum,
13850
+ WebhooksApi,
12473
13851
  canConsumeForm,
12474
13852
  exists,
12475
13853
  instanceOfAddExtractionsInDTO,
@@ -12490,6 +13868,7 @@ var VERSION = "0.16.1";
12490
13868
  instanceOfContractStatus,
12491
13869
  instanceOfCountBreakdownModel,
12492
13870
  instanceOfCreateTemplateInDTO,
13871
+ instanceOfCreatedWebhookEndpointOutDTO,
12493
13872
  instanceOfCreditMeter,
12494
13873
  instanceOfCreditMeterFilter,
12495
13874
  instanceOfCreditTransactionListOutDTO,
@@ -12512,6 +13891,8 @@ var VERSION = "0.16.1";
12512
13891
  instanceOfDocumentsViewOutDTO,
12513
13892
  instanceOfEnterpriseTransactionListOutDTO,
12514
13893
  instanceOfEnterpriseTransactionOutDTO,
13894
+ instanceOfExtractionCompletedEvent,
13895
+ instanceOfExtractionCompletedEventData,
12515
13896
  instanceOfExtractionCostOutDTO,
12516
13897
  instanceOfExtractionCostOutResultDTO,
12517
13898
  instanceOfExtractionCostStateModel,
@@ -12621,8 +14002,21 @@ var VERSION = "0.16.1";
12621
14002
  instanceOfViewMetaOutDTO,
12622
14003
  instanceOfVolumeDiscountTierOutDTO,
12623
14004
  instanceOfWebDocumentUploadInDTO,
14005
+ instanceOfWebhookAttemptOutDTO,
14006
+ instanceOfWebhookDeliveryResultOutDTO,
14007
+ instanceOfWebhookEndpointCreateInDTO,
14008
+ instanceOfWebhookEndpointListOutDTO,
14009
+ instanceOfWebhookEndpointOutDTO,
14010
+ instanceOfWebhookEndpointUpdateInDTO,
14011
+ instanceOfWebhookEventListOutDTO,
14012
+ instanceOfWebhookEventOutDTO,
12624
14013
  instanceOfWebhookResponseDTO,
14014
+ instanceOfWebhookTestEvent,
14015
+ instanceOfWebhookTestEventData,
14016
+ isExtractionCompleted,
14017
+ isWebhookTest,
12625
14018
  mapValues,
12626
- querystring
14019
+ querystring,
14020
+ unwrapWebhook
12627
14021
  });
12628
14022
  //# sourceMappingURL=index.cjs.map