@open-mercato/webhooks 0.6.7 → 0.6.8-develop.6875.1.871a4afc94
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.js +15 -0
- package/dist/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.js.map +2 -2
- package/dist/modules/webhooks/api/inbound/[endpointId]/route.js +152 -7
- package/dist/modules/webhooks/api/inbound/[endpointId]/route.js.map +3 -3
- package/dist/modules/webhooks/backend/webhooks/[id]/page.js +5 -4
- package/dist/modules/webhooks/backend/webhooks/[id]/page.js.map +2 -2
- package/dist/modules/webhooks/backend/webhooks/page.js +3 -2
- package/dist/modules/webhooks/backend/webhooks/page.js.map +2 -2
- package/dist/modules/webhooks/components/WebhookSecretPanel.js +3 -3
- package/dist/modules/webhooks/components/WebhookSecretPanel.js.map +2 -2
- package/dist/modules/webhooks/components/webhook-form-config.js +6 -6
- package/dist/modules/webhooks/components/webhook-form-config.js.map +2 -2
- package/dist/modules/webhooks/data/entities.js +101 -1
- package/dist/modules/webhooks/data/entities.js.map +2 -2
- package/dist/modules/webhooks/encryption.js +7 -0
- package/dist/modules/webhooks/encryption.js.map +2 -2
- package/dist/modules/webhooks/events.js +2 -0
- package/dist/modules/webhooks/events.js.map +2 -2
- package/dist/modules/webhooks/extension-points.js +15 -0
- package/dist/modules/webhooks/extension-points.js.map +7 -0
- package/dist/modules/webhooks/generators.js +57 -0
- package/dist/modules/webhooks/generators.js.map +7 -0
- package/dist/modules/webhooks/lib/inbound-dispatch.js +105 -0
- package/dist/modules/webhooks/lib/inbound-dispatch.js.map +7 -0
- package/dist/modules/webhooks/lib/inbound-registry.js +76 -0
- package/dist/modules/webhooks/lib/inbound-registry.js.map +7 -0
- package/dist/modules/webhooks/lib/module-webhook-registry.js +12 -0
- package/dist/modules/webhooks/lib/module-webhook-registry.js.map +7 -0
- package/dist/modules/webhooks/lib/queue.js +47 -0
- package/dist/modules/webhooks/lib/queue.js.map +2 -2
- package/dist/modules/webhooks/migrations/Migration20260617141327_webhooks.js +16 -0
- package/dist/modules/webhooks/migrations/Migration20260617141327_webhooks.js.map +7 -0
- package/dist/modules/webhooks/widgets/injection/integration-deliveries/widget.client.js +2 -1
- package/dist/modules/webhooks/widgets/injection/integration-deliveries/widget.client.js.map +2 -2
- package/dist/modules/webhooks/workers/inbound-dispatch.js +29 -0
- package/dist/modules/webhooks/workers/inbound-dispatch.js.map +7 -0
- package/generated/entities/inbound_endpoint_config_entity/index.ts +8 -0
- package/generated/entities/webhook_ingestion_entity/index.ts +16 -0
- package/generated/entities.ids.generated.ts +3 -1
- package/generated/entity-fields-registry.ts +28 -0
- package/package.json +12 -11
- package/src/modules/webhooks/__integration__/TC-WEBHOOK-003.spec.ts +16 -0
- package/src/modules/webhooks/api/inbound/[endpointId]/__tests__/route.test.ts +99 -1
- package/src/modules/webhooks/api/inbound/[endpointId]/__tests__/route.unify.test.ts +149 -0
- package/src/modules/webhooks/api/inbound/[endpointId]/route.ts +178 -7
- package/src/modules/webhooks/backend/webhooks/[id]/page.tsx +5 -4
- package/src/modules/webhooks/backend/webhooks/page.tsx +3 -2
- package/src/modules/webhooks/components/WebhookSecretPanel.tsx +3 -3
- package/src/modules/webhooks/components/webhook-form-config.tsx +6 -6
- package/src/modules/webhooks/data/entities.ts +84 -0
- package/src/modules/webhooks/encryption.ts +7 -0
- package/src/modules/webhooks/events.ts +2 -0
- package/src/modules/webhooks/extension-points.ts +12 -0
- package/src/modules/webhooks/generators.ts +57 -0
- package/src/modules/webhooks/i18n/de.json +1 -1
- package/src/modules/webhooks/i18n/en.json +1 -1
- package/src/modules/webhooks/i18n/es.json +1 -1
- package/src/modules/webhooks/i18n/ko.json +161 -0
- package/src/modules/webhooks/i18n/pl.json +1 -1
- package/src/modules/webhooks/lib/__tests__/inbound-dispatch.test.ts +186 -0
- package/src/modules/webhooks/lib/__tests__/inbound-registry.test.ts +102 -0
- package/src/modules/webhooks/lib/__tests__/module-webhook-registry.test.ts +53 -0
- package/src/modules/webhooks/lib/inbound-dispatch.ts +147 -0
- package/src/modules/webhooks/lib/inbound-registry.ts +92 -0
- package/src/modules/webhooks/lib/module-webhook-registry.ts +33 -0
- package/src/modules/webhooks/lib/queue.ts +60 -0
- package/src/modules/webhooks/migrations/.snapshot-open-mercato.json +907 -338
- package/src/modules/webhooks/migrations/Migration20260617141327_webhooks.ts +16 -0
- package/src/modules/webhooks/widgets/injection/integration-deliveries/widget.client.tsx +2 -1
- package/src/modules/webhooks/workers/inbound-dispatch.ts +31 -0
|
@@ -223,9 +223,109 @@ WebhookInboundReceiptEntity = __decorateClass([
|
|
|
223
223
|
Unique({ name: "webhook_inbound_receipts_endpoint_message_unique", properties: ["endpointId", "messageId"] }),
|
|
224
224
|
Index({ properties: ["providerKey", "createdAt"] })
|
|
225
225
|
], WebhookInboundReceiptEntity);
|
|
226
|
+
let WebhookIngestionEntity = class {
|
|
227
|
+
constructor() {
|
|
228
|
+
this.status = "received";
|
|
229
|
+
this.handlerCount = 0;
|
|
230
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
231
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
__decorateClass([
|
|
235
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
236
|
+
], WebhookIngestionEntity.prototype, "id", 2);
|
|
237
|
+
__decorateClass([
|
|
238
|
+
Property({ name: "source_key", type: "text" })
|
|
239
|
+
], WebhookIngestionEntity.prototype, "sourceKey", 2);
|
|
240
|
+
__decorateClass([
|
|
241
|
+
Property({ name: "event_type", type: "text" })
|
|
242
|
+
], WebhookIngestionEntity.prototype, "eventType", 2);
|
|
243
|
+
__decorateClass([
|
|
244
|
+
Property({ name: "external_message_id", type: "text", nullable: true })
|
|
245
|
+
], WebhookIngestionEntity.prototype, "externalMessageId", 2);
|
|
246
|
+
__decorateClass([
|
|
247
|
+
Property({ name: "payload", type: "json" })
|
|
248
|
+
], WebhookIngestionEntity.prototype, "payload", 2);
|
|
249
|
+
__decorateClass([
|
|
250
|
+
Property({ name: "headers", type: "json", nullable: true })
|
|
251
|
+
], WebhookIngestionEntity.prototype, "headers", 2);
|
|
252
|
+
__decorateClass([
|
|
253
|
+
Property({ name: "status", type: "text", default: "received" })
|
|
254
|
+
], WebhookIngestionEntity.prototype, "status", 2);
|
|
255
|
+
__decorateClass([
|
|
256
|
+
Property({ name: "error_message", type: "text", nullable: true })
|
|
257
|
+
], WebhookIngestionEntity.prototype, "errorMessage", 2);
|
|
258
|
+
__decorateClass([
|
|
259
|
+
Property({ name: "processed_at", type: Date, nullable: true })
|
|
260
|
+
], WebhookIngestionEntity.prototype, "processedAt", 2);
|
|
261
|
+
__decorateClass([
|
|
262
|
+
Property({ name: "handler_count", type: "int", default: 0 })
|
|
263
|
+
], WebhookIngestionEntity.prototype, "handlerCount", 2);
|
|
264
|
+
__decorateClass([
|
|
265
|
+
Property({ name: "handler_results", type: "json", nullable: true })
|
|
266
|
+
], WebhookIngestionEntity.prototype, "handlerResults", 2);
|
|
267
|
+
__decorateClass([
|
|
268
|
+
Property({ name: "duration_ms", type: "int", nullable: true })
|
|
269
|
+
], WebhookIngestionEntity.prototype, "durationMs", 2);
|
|
270
|
+
__decorateClass([
|
|
271
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
272
|
+
], WebhookIngestionEntity.prototype, "organizationId", 2);
|
|
273
|
+
__decorateClass([
|
|
274
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
275
|
+
], WebhookIngestionEntity.prototype, "tenantId", 2);
|
|
276
|
+
__decorateClass([
|
|
277
|
+
Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
|
|
278
|
+
], WebhookIngestionEntity.prototype, "createdAt", 2);
|
|
279
|
+
__decorateClass([
|
|
280
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
281
|
+
], WebhookIngestionEntity.prototype, "updatedAt", 2);
|
|
282
|
+
WebhookIngestionEntity = __decorateClass([
|
|
283
|
+
Entity({ tableName: "webhook_ingestions" }),
|
|
284
|
+
Index({ properties: ["sourceKey", "status", "createdAt"] }),
|
|
285
|
+
Index({ properties: ["organizationId", "tenantId", "createdAt"] }),
|
|
286
|
+
Index({ properties: ["externalMessageId"] })
|
|
287
|
+
], WebhookIngestionEntity);
|
|
288
|
+
let InboundEndpointConfigEntity = class {
|
|
289
|
+
constructor() {
|
|
290
|
+
this.isActive = true;
|
|
291
|
+
this.createdAt = /* @__PURE__ */ new Date();
|
|
292
|
+
this.updatedAt = /* @__PURE__ */ new Date();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
__decorateClass([
|
|
296
|
+
PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
|
|
297
|
+
], InboundEndpointConfigEntity.prototype, "id", 2);
|
|
298
|
+
__decorateClass([
|
|
299
|
+
Property({ name: "source_key", type: "text" })
|
|
300
|
+
], InboundEndpointConfigEntity.prototype, "sourceKey", 2);
|
|
301
|
+
__decorateClass([
|
|
302
|
+
Property({ name: "is_active", type: "boolean", default: true })
|
|
303
|
+
], InboundEndpointConfigEntity.prototype, "isActive", 2);
|
|
304
|
+
__decorateClass([
|
|
305
|
+
Property({ name: "integration_id", type: "text", nullable: true })
|
|
306
|
+
], InboundEndpointConfigEntity.prototype, "integrationId", 2);
|
|
307
|
+
__decorateClass([
|
|
308
|
+
Property({ name: "organization_id", type: "uuid" })
|
|
309
|
+
], InboundEndpointConfigEntity.prototype, "organizationId", 2);
|
|
310
|
+
__decorateClass([
|
|
311
|
+
Property({ name: "tenant_id", type: "uuid" })
|
|
312
|
+
], InboundEndpointConfigEntity.prototype, "tenantId", 2);
|
|
313
|
+
__decorateClass([
|
|
314
|
+
Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
|
|
315
|
+
], InboundEndpointConfigEntity.prototype, "createdAt", 2);
|
|
316
|
+
__decorateClass([
|
|
317
|
+
Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
|
|
318
|
+
], InboundEndpointConfigEntity.prototype, "updatedAt", 2);
|
|
319
|
+
InboundEndpointConfigEntity = __decorateClass([
|
|
320
|
+
Entity({ tableName: "webhook_inbound_configs" }),
|
|
321
|
+
Unique({ name: "webhook_inbound_configs_source_scope_unique", properties: ["sourceKey", "organizationId", "tenantId"] }),
|
|
322
|
+
Index({ properties: ["sourceKey", "isActive"] })
|
|
323
|
+
], InboundEndpointConfigEntity);
|
|
226
324
|
export {
|
|
325
|
+
InboundEndpointConfigEntity,
|
|
227
326
|
WebhookDeliveryEntity,
|
|
228
327
|
WebhookEntity,
|
|
229
|
-
WebhookInboundReceiptEntity
|
|
328
|
+
WebhookInboundReceiptEntity,
|
|
329
|
+
WebhookIngestionEntity
|
|
230
330
|
};
|
|
231
331
|
//# sourceMappingURL=entities.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/webhooks/data/entities.ts"],
|
|
4
|
-
"sourcesContent": ["import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\n\n@Entity({ tableName: 'webhooks' })\n@Index({ properties: ['organizationId', 'tenantId', 'isActive'] })\n@Index({ properties: ['organizationId', 'tenantId', 'deletedAt'] })\nexport class WebhookEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ type: 'text' })\n name!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'url', type: 'text' })\n url!: string\n\n @Property({ name: 'secret', type: 'text' })\n secret!: string\n\n @Property({ name: 'previous_secret', type: 'text', nullable: true })\n previousSecret?: string | null\n\n @Property({ name: 'previous_secret_set_at', type: Date, nullable: true })\n previousSecretSetAt?: Date | null\n\n @Property({ name: 'subscribed_events', type: 'json' })\n subscribedEvents!: string[]\n\n @Property({ name: 'http_method', type: 'text', default: 'POST' })\n httpMethod: string = 'POST'\n\n @Property({ name: 'custom_headers', type: 'json', nullable: true })\n customHeaders?: Record<string, string> | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'delivery_strategy', type: 'text', default: 'http' })\n deliveryStrategy: string = 'http'\n\n @Property({ name: 'strategy_config', type: 'json', nullable: true })\n strategyConfig?: Record<string, unknown> | null\n\n @Property({ name: 'max_retries', type: 'int', default: 10 })\n maxRetries: number = 10\n\n @Property({ name: 'timeout_ms', type: 'int', default: 15000 })\n timeoutMs: number = 15000\n\n @Property({ name: 'rate_limit_per_minute', type: 'int', default: 0 })\n rateLimitPerMinute: number = 0\n\n @Property({ name: 'consecutive_failures', type: 'int', default: 0 })\n consecutiveFailures: number = 0\n\n @Property({ name: 'auto_disable_threshold', type: 'int', default: 100 })\n autoDisableThreshold: number = 100\n\n @Property({ name: 'last_success_at', type: Date, nullable: true })\n lastSuccessAt?: Date | null\n\n @Property({ name: 'last_failure_at', type: Date, nullable: true })\n lastFailureAt?: Date | null\n\n @Property({ name: 'integration_id', type: 'text', nullable: true })\n integrationId?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'webhook_deliveries' })\n@Index({ properties: ['webhookId', 'status'] })\n@Index({ properties: ['organizationId', 'tenantId', 'createdAt'] })\n@Index({ properties: ['webhookId', 'createdAt'] })\n@Index({ properties: ['eventType', 'organizationId'] })\nexport class WebhookDeliveryEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'webhook_id', type: 'uuid' })\n webhookId!: string\n\n @Property({ name: 'event_type', type: 'text' })\n eventType!: string\n\n @Property({ name: 'message_id', type: 'text' })\n messageId!: string\n\n @Property({ name: 'payload', type: 'json' })\n payload!: Record<string, unknown>\n\n @Property({ name: 'status', type: 'text', default: 'pending' })\n status: string = 'pending'\n\n @Property({ name: 'response_status', type: 'int', nullable: true })\n responseStatus?: number | null\n\n @Property({ name: 'response_body', type: 'text', nullable: true })\n responseBody?: string | null\n\n @Property({ name: 'response_headers', type: 'json', nullable: true })\n responseHeaders?: Record<string, string> | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'attempt_number', type: 'int', default: 0 })\n attemptNumber: number = 0\n\n @Property({ name: 'max_attempts', type: 'int', default: 10 })\n maxAttempts: number = 10\n\n @Property({ name: 'next_retry_at', type: Date, nullable: true })\n nextRetryAt?: Date | null\n\n @Property({ name: 'duration_ms', type: 'int', nullable: true })\n durationMs?: number | null\n\n @Property({ name: 'target_url', type: 'text' })\n targetUrl!: string\n\n @Property({ name: 'enqueued_at', type: Date })\n enqueuedAt: Date = new Date()\n\n @Property({ name: 'last_attempt_at', type: Date, nullable: true })\n lastAttemptAt?: Date | null\n\n @Property({ name: 'delivered_at', type: Date, nullable: true })\n deliveredAt?: Date | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'webhook_inbound_receipts' })\n@Unique({ name: 'webhook_inbound_receipts_endpoint_message_unique', properties: ['endpointId', 'messageId'] })\n@Index({ properties: ['providerKey', 'createdAt'] })\nexport class WebhookInboundReceiptEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'endpoint_id', type: 'text' })\n endpointId!: string\n\n @Property({ name: 'message_id', type: 'text' })\n messageId!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n @Property({ name: 'event_type', type: 'text', nullable: true })\n eventType?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid', nullable: true })\n tenantId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAAA,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;
|
|
4
|
+
"sourcesContent": ["import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'\nimport type { WebhookHandlerResult, WebhookIngestionStatus } from '@open-mercato/shared/lib/webhooks'\n\n@Entity({ tableName: 'webhooks' })\n@Index({ properties: ['organizationId', 'tenantId', 'isActive'] })\n@Index({ properties: ['organizationId', 'tenantId', 'deletedAt'] })\nexport class WebhookEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ type: 'text' })\n name!: string\n\n @Property({ name: 'description', type: 'text', nullable: true })\n description?: string | null\n\n @Property({ name: 'url', type: 'text' })\n url!: string\n\n @Property({ name: 'secret', type: 'text' })\n secret!: string\n\n @Property({ name: 'previous_secret', type: 'text', nullable: true })\n previousSecret?: string | null\n\n @Property({ name: 'previous_secret_set_at', type: Date, nullable: true })\n previousSecretSetAt?: Date | null\n\n @Property({ name: 'subscribed_events', type: 'json' })\n subscribedEvents!: string[]\n\n @Property({ name: 'http_method', type: 'text', default: 'POST' })\n httpMethod: string = 'POST'\n\n @Property({ name: 'custom_headers', type: 'json', nullable: true })\n customHeaders?: Record<string, string> | null\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'delivery_strategy', type: 'text', default: 'http' })\n deliveryStrategy: string = 'http'\n\n @Property({ name: 'strategy_config', type: 'json', nullable: true })\n strategyConfig?: Record<string, unknown> | null\n\n @Property({ name: 'max_retries', type: 'int', default: 10 })\n maxRetries: number = 10\n\n @Property({ name: 'timeout_ms', type: 'int', default: 15000 })\n timeoutMs: number = 15000\n\n @Property({ name: 'rate_limit_per_minute', type: 'int', default: 0 })\n rateLimitPerMinute: number = 0\n\n @Property({ name: 'consecutive_failures', type: 'int', default: 0 })\n consecutiveFailures: number = 0\n\n @Property({ name: 'auto_disable_threshold', type: 'int', default: 100 })\n autoDisableThreshold: number = 100\n\n @Property({ name: 'last_success_at', type: Date, nullable: true })\n lastSuccessAt?: Date | null\n\n @Property({ name: 'last_failure_at', type: Date, nullable: true })\n lastFailureAt?: Date | null\n\n @Property({ name: 'integration_id', type: 'text', nullable: true })\n integrationId?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n\n @Property({ name: 'deleted_at', type: Date, nullable: true })\n deletedAt?: Date | null\n}\n\n@Entity({ tableName: 'webhook_deliveries' })\n@Index({ properties: ['webhookId', 'status'] })\n@Index({ properties: ['organizationId', 'tenantId', 'createdAt'] })\n@Index({ properties: ['webhookId', 'createdAt'] })\n@Index({ properties: ['eventType', 'organizationId'] })\nexport class WebhookDeliveryEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'webhook_id', type: 'uuid' })\n webhookId!: string\n\n @Property({ name: 'event_type', type: 'text' })\n eventType!: string\n\n @Property({ name: 'message_id', type: 'text' })\n messageId!: string\n\n @Property({ name: 'payload', type: 'json' })\n payload!: Record<string, unknown>\n\n @Property({ name: 'status', type: 'text', default: 'pending' })\n status: string = 'pending'\n\n @Property({ name: 'response_status', type: 'int', nullable: true })\n responseStatus?: number | null\n\n @Property({ name: 'response_body', type: 'text', nullable: true })\n responseBody?: string | null\n\n @Property({ name: 'response_headers', type: 'json', nullable: true })\n responseHeaders?: Record<string, string> | null\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'attempt_number', type: 'int', default: 0 })\n attemptNumber: number = 0\n\n @Property({ name: 'max_attempts', type: 'int', default: 10 })\n maxAttempts: number = 10\n\n @Property({ name: 'next_retry_at', type: Date, nullable: true })\n nextRetryAt?: Date | null\n\n @Property({ name: 'duration_ms', type: 'int', nullable: true })\n durationMs?: number | null\n\n @Property({ name: 'target_url', type: 'text' })\n targetUrl!: string\n\n @Property({ name: 'enqueued_at', type: Date })\n enqueuedAt: Date = new Date()\n\n @Property({ name: 'last_attempt_at', type: Date, nullable: true })\n lastAttemptAt?: Date | null\n\n @Property({ name: 'delivered_at', type: Date, nullable: true })\n deliveredAt?: Date | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'webhook_inbound_receipts' })\n@Unique({ name: 'webhook_inbound_receipts_endpoint_message_unique', properties: ['endpointId', 'messageId'] })\n@Index({ properties: ['providerKey', 'createdAt'] })\nexport class WebhookInboundReceiptEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'endpoint_id', type: 'text' })\n endpointId!: string\n\n @Property({ name: 'message_id', type: 'text' })\n messageId!: string\n\n @Property({ name: 'provider_key', type: 'text' })\n providerKey!: string\n\n @Property({ name: 'event_type', type: 'text', nullable: true })\n eventType?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid', nullable: true })\n organizationId?: string | null\n\n @Property({ name: 'tenant_id', type: 'uuid', nullable: true })\n tenantId?: string | null\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n}\n\n@Entity({ tableName: 'webhook_ingestions' })\n@Index({ properties: ['sourceKey', 'status', 'createdAt'] })\n@Index({ properties: ['organizationId', 'tenantId', 'createdAt'] })\n@Index({ properties: ['externalMessageId'] })\nexport class WebhookIngestionEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'source_key', type: 'text' })\n sourceKey!: string\n\n @Property({ name: 'event_type', type: 'text' })\n eventType!: string\n\n @Property({ name: 'external_message_id', type: 'text', nullable: true })\n externalMessageId?: string | null\n\n @Property({ name: 'payload', type: 'json' })\n payload!: Record<string, unknown>\n\n @Property({ name: 'headers', type: 'json', nullable: true })\n headers?: Record<string, string> | null\n\n @Property({ name: 'status', type: 'text', default: 'received' })\n status: WebhookIngestionStatus = 'received'\n\n @Property({ name: 'error_message', type: 'text', nullable: true })\n errorMessage?: string | null\n\n @Property({ name: 'processed_at', type: Date, nullable: true })\n processedAt?: Date | null\n\n @Property({ name: 'handler_count', type: 'int', default: 0 })\n handlerCount: number = 0\n\n @Property({ name: 'handler_results', type: 'json', nullable: true })\n handlerResults?: WebhookHandlerResult[] | null\n\n @Property({ name: 'duration_ms', type: 'int', nullable: true })\n durationMs?: number | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n\n@Entity({ tableName: 'webhook_inbound_configs' })\n@Unique({ name: 'webhook_inbound_configs_source_scope_unique', properties: ['sourceKey', 'organizationId', 'tenantId'] })\n@Index({ properties: ['sourceKey', 'isActive'] })\nexport class InboundEndpointConfigEntity {\n @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })\n id!: string\n\n @Property({ name: 'source_key', type: 'text' })\n sourceKey!: string\n\n @Property({ name: 'is_active', type: 'boolean', default: true })\n isActive: boolean = true\n\n @Property({ name: 'integration_id', type: 'text', nullable: true })\n integrationId?: string | null\n\n @Property({ name: 'organization_id', type: 'uuid' })\n organizationId!: string\n\n @Property({ name: 'tenant_id', type: 'uuid' })\n tenantId!: string\n\n @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })\n createdAt: Date = new Date()\n\n @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })\n updatedAt: Date = new Date()\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAAA,SAAS,QAAQ,OAAO,YAAY,UAAU,cAAc;AAMrD,IAAM,gBAAN,MAAoB;AAAA,EAApB;AA0BL,sBAAqB;AAMrB,oBAAoB;AAGpB,4BAA2B;AAM3B,sBAAqB;AAGrB,qBAAoB;AAGpB,8BAA6B;AAG7B,+BAA8B;AAG9B,gCAA+B;AAkB/B,qBAAkB,oBAAI,KAAK;AAG3B,qBAAkB,oBAAI,KAAK;AAAA;AAI7B;AA5EE;AAAA,EADC,WAAW,EAAE,MAAM,QAAQ,YAAY,oBAAoB,CAAC;AAAA,GADlD,cAEX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAJf,cAKX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,CAAC;AAAA,GAPpD,cAQX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,OAAO,MAAM,OAAO,CAAC;AAAA,GAV5B,cAWX;AAGA;AAAA,EADC,SAAS,EAAE,MAAM,UAAU,MAAM,OAAO,CAA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EAAE,CAAC;AAAA,EACvH,MAAM,EAAE,YAAY,CAAC,aAAa,UAAU,EAAE,CAAC;AAAA,GACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,6 +5,13 @@ const defaultEncryptionMaps = [
|
|
|
5
5
|
{ field: "secret" },
|
|
6
6
|
{ field: "previous_secret" }
|
|
7
7
|
]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
entityId: "webhooks:webhook_ingestion_entity",
|
|
11
|
+
fields: [
|
|
12
|
+
{ field: "payload" },
|
|
13
|
+
{ field: "headers" }
|
|
14
|
+
]
|
|
8
15
|
}
|
|
9
16
|
];
|
|
10
17
|
var encryption_default = defaultEncryptionMaps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/webhooks/encryption.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ModuleEncryptionMap } from '@open-mercato/shared/modules/encryption'\n\nexport const defaultEncryptionMaps: ModuleEncryptionMap[] = [\n {\n entityId: 'webhooks:webhook_entity',\n fields: [\n { field: 'secret' },\n { field: 'previous_secret' },\n ],\n },\n]\n\nexport default defaultEncryptionMaps\n"],
|
|
5
|
-
"mappings": "AAEO,MAAM,wBAA+C;AAAA,EAC1D;AAAA,IACE,UAAU;AAAA,IACV,QAAQ;AAAA,MACN,EAAE,OAAO,SAAS;AAAA,MAClB,EAAE,OAAO,kBAAkB;AAAA,IAC7B;AAAA,EACF;AACF;AAEA,IAAO,qBAAQ;",
|
|
4
|
+
"sourcesContent": ["import type { ModuleEncryptionMap } from '@open-mercato/shared/modules/encryption'\n\nexport const defaultEncryptionMaps: ModuleEncryptionMap[] = [\n {\n entityId: 'webhooks:webhook_entity',\n fields: [\n { field: 'secret' },\n { field: 'previous_secret' },\n ],\n },\n {\n entityId: 'webhooks:webhook_ingestion_entity',\n fields: [\n { field: 'payload' },\n { field: 'headers' },\n ],\n },\n]\n\nexport default defaultEncryptionMaps\n"],
|
|
5
|
+
"mappings": "AAEO,MAAM,wBAA+C;AAAA,EAC1D;AAAA,IACE,UAAU;AAAA,IACV,QAAQ;AAAA,MACN,EAAE,OAAO,SAAS;AAAA,MAClB,EAAE,OAAO,kBAAkB;AAAA,IAC7B;AAAA,EACF;AAAA,EACA;AAAA,IACE,UAAU;AAAA,IACV,QAAQ;AAAA,MACN,EAAE,OAAO,UAAU;AAAA,MACnB,EAAE,OAAO,UAAU;AAAA,IACrB;AAAA,EACF;AACF;AAEA,IAAO,qBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,6 +9,8 @@ const events = [
|
|
|
9
9
|
{ id: "webhooks.delivery.exhausted", label: "Webhook Delivery Retries Exhausted", entity: "delivery", category: "lifecycle", clientBroadcast: true },
|
|
10
10
|
{ id: "webhooks.webhook.disabled", label: "Webhook Auto-Disabled", entity: "webhook", category: "lifecycle", clientBroadcast: true },
|
|
11
11
|
{ id: "webhooks.inbound.received", label: "Inbound Webhook Received", entity: "inbound", category: "custom" },
|
|
12
|
+
{ id: "webhooks.inbound.processed", label: "Inbound Webhook Processed", entity: "inbound", category: "lifecycle" },
|
|
13
|
+
{ id: "webhooks.inbound.handler_failed", label: "Inbound Handler Failed", entity: "inbound", category: "lifecycle", clientBroadcast: true },
|
|
12
14
|
{ id: "webhooks.secret.rotated", label: "Webhook Secret Rotated", entity: "webhook", category: "lifecycle" }
|
|
13
15
|
];
|
|
14
16
|
const eventsConfig = createModuleEvents({ moduleId: "webhooks", events });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/modules/webhooks/events.ts"],
|
|
4
|
-
"sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\nconst events = [\n { id: 'webhooks.webhook.created', label: 'Webhook Created', entity: 'webhook', category: 'crud' as const },\n { id: 'webhooks.webhook.updated', label: 'Webhook Updated', entity: 'webhook', category: 'crud' as const },\n { id: 'webhooks.webhook.deleted', label: 'Webhook Deleted', entity: 'webhook', category: 'crud' as const },\n { id: 'webhooks.delivery.enqueued', label: 'Webhook Delivery Enqueued', entity: 'delivery', category: 'lifecycle' as const },\n { id: 'webhooks.delivery.succeeded', label: 'Webhook Delivery Succeeded', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.delivery.failed', label: 'Webhook Delivery Failed', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.delivery.exhausted', label: 'Webhook Delivery Retries Exhausted', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.webhook.disabled', label: 'Webhook Auto-Disabled', entity: 'webhook', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.inbound.received', label: 'Inbound Webhook Received', entity: 'inbound', category: 'custom' as const },\n { id: 'webhooks.secret.rotated', label: 'Webhook Secret Rotated', entity: 'webhook', category: 'lifecycle' as const },\n] as const\n\nexport const eventsConfig = createModuleEvents({ moduleId: 'webhooks', events })\nexport const emitWebhooksEvent = eventsConfig.emit\nexport type WebhooksEventId = typeof events[number]['id']\nexport default eventsConfig\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,MAAM,SAAS;AAAA,EACb,EAAE,IAAI,4BAA4B,OAAO,mBAAmB,QAAQ,WAAW,UAAU,OAAgB;AAAA,EACzG,EAAE,IAAI,4BAA4B,OAAO,mBAAmB,QAAQ,WAAW,UAAU,OAAgB;AAAA,EACzG,EAAE,IAAI,4BAA4B,OAAO,mBAAmB,QAAQ,WAAW,UAAU,OAAgB;AAAA,EACzG,EAAE,IAAI,8BAA8B,OAAO,6BAA6B,QAAQ,YAAY,UAAU,YAAqB;AAAA,EAC3H,EAAE,IAAI,+BAA+B,OAAO,8BAA8B,QAAQ,YAAY,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EACpJ,EAAE,IAAI,4BAA4B,OAAO,2BAA2B,QAAQ,YAAY,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EAC9I,EAAE,IAAI,+BAA+B,OAAO,sCAAsC,QAAQ,YAAY,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EAC5J,EAAE,IAAI,6BAA6B,OAAO,yBAAyB,QAAQ,WAAW,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EAC5I,EAAE,IAAI,6BAA6B,OAAO,4BAA4B,QAAQ,WAAW,UAAU,SAAkB;AAAA,EACrH,EAAE,IAAI,2BAA2B,OAAO,0BAA0B,QAAQ,WAAW,UAAU,YAAqB;AACtH;AAEO,MAAM,eAAe,mBAAmB,EAAE,UAAU,YAAY,OAAO,CAAC;AACxE,MAAM,oBAAoB,aAAa;AAE9C,IAAO,iBAAQ;",
|
|
4
|
+
"sourcesContent": ["import { createModuleEvents } from '@open-mercato/shared/modules/events'\n\nconst events = [\n { id: 'webhooks.webhook.created', label: 'Webhook Created', entity: 'webhook', category: 'crud' as const },\n { id: 'webhooks.webhook.updated', label: 'Webhook Updated', entity: 'webhook', category: 'crud' as const },\n { id: 'webhooks.webhook.deleted', label: 'Webhook Deleted', entity: 'webhook', category: 'crud' as const },\n { id: 'webhooks.delivery.enqueued', label: 'Webhook Delivery Enqueued', entity: 'delivery', category: 'lifecycle' as const },\n { id: 'webhooks.delivery.succeeded', label: 'Webhook Delivery Succeeded', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.delivery.failed', label: 'Webhook Delivery Failed', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.delivery.exhausted', label: 'Webhook Delivery Retries Exhausted', entity: 'delivery', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.webhook.disabled', label: 'Webhook Auto-Disabled', entity: 'webhook', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.inbound.received', label: 'Inbound Webhook Received', entity: 'inbound', category: 'custom' as const },\n { id: 'webhooks.inbound.processed', label: 'Inbound Webhook Processed', entity: 'inbound', category: 'lifecycle' as const },\n { id: 'webhooks.inbound.handler_failed', label: 'Inbound Handler Failed', entity: 'inbound', category: 'lifecycle' as const, clientBroadcast: true },\n { id: 'webhooks.secret.rotated', label: 'Webhook Secret Rotated', entity: 'webhook', category: 'lifecycle' as const },\n] as const\n\nexport const eventsConfig = createModuleEvents({ moduleId: 'webhooks', events })\nexport const emitWebhooksEvent = eventsConfig.emit\nexport type WebhooksEventId = typeof events[number]['id']\nexport default eventsConfig\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA0B;AAEnC,MAAM,SAAS;AAAA,EACb,EAAE,IAAI,4BAA4B,OAAO,mBAAmB,QAAQ,WAAW,UAAU,OAAgB;AAAA,EACzG,EAAE,IAAI,4BAA4B,OAAO,mBAAmB,QAAQ,WAAW,UAAU,OAAgB;AAAA,EACzG,EAAE,IAAI,4BAA4B,OAAO,mBAAmB,QAAQ,WAAW,UAAU,OAAgB;AAAA,EACzG,EAAE,IAAI,8BAA8B,OAAO,6BAA6B,QAAQ,YAAY,UAAU,YAAqB;AAAA,EAC3H,EAAE,IAAI,+BAA+B,OAAO,8BAA8B,QAAQ,YAAY,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EACpJ,EAAE,IAAI,4BAA4B,OAAO,2BAA2B,QAAQ,YAAY,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EAC9I,EAAE,IAAI,+BAA+B,OAAO,sCAAsC,QAAQ,YAAY,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EAC5J,EAAE,IAAI,6BAA6B,OAAO,yBAAyB,QAAQ,WAAW,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EAC5I,EAAE,IAAI,6BAA6B,OAAO,4BAA4B,QAAQ,WAAW,UAAU,SAAkB;AAAA,EACrH,EAAE,IAAI,8BAA8B,OAAO,6BAA6B,QAAQ,WAAW,UAAU,YAAqB;AAAA,EAC1H,EAAE,IAAI,mCAAmC,OAAO,0BAA0B,QAAQ,WAAW,UAAU,aAAsB,iBAAiB,KAAK;AAAA,EACnJ,EAAE,IAAI,2BAA2B,OAAO,0BAA0B,QAAQ,WAAW,UAAU,YAAqB;AACtH;AAEO,MAAM,eAAe,mBAAmB,EAAE,UAAU,YAAY,OAAO,CAAC;AACxE,MAAM,oBAAoB,aAAa;AAE9C,IAAO,iBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dataTableExtensionHost, defineModuleExtensionPoints } from "@open-mercato/shared/modules/widgets/extension-points";
|
|
2
|
+
const extensionPoints = defineModuleExtensionPoints({
|
|
3
|
+
moduleId: "webhooks",
|
|
4
|
+
hosts: {
|
|
5
|
+
webhooksTable: dataTableExtensionHost({ tableId: "webhooks.list", source: "backend/webhooks/page.tsx" }),
|
|
6
|
+
deliveriesTable: dataTableExtensionHost({ tableId: "webhooks.deliveries", source: "backend/webhooks/[id]/page.tsx" }),
|
|
7
|
+
integrationDeliveriesTable: dataTableExtensionHost({ tableId: "webhooks.integration-deliveries", source: "widgets/injection/integration-deliveries/widget.client.tsx" })
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
var extension_points_default = extensionPoints;
|
|
11
|
+
export {
|
|
12
|
+
extension_points_default as default,
|
|
13
|
+
extensionPoints
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=extension-points.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/webhooks/extension-points.ts"],
|
|
4
|
+
"sourcesContent": ["import { dataTableExtensionHost, defineModuleExtensionPoints } from '@open-mercato/shared/modules/widgets/extension-points'\n\nexport const extensionPoints = defineModuleExtensionPoints({\n moduleId: 'webhooks',\n hosts: {\n webhooksTable: dataTableExtensionHost({ tableId: 'webhooks.list', source: 'backend/webhooks/page.tsx' }),\n deliveriesTable: dataTableExtensionHost({ tableId: 'webhooks.deliveries', source: 'backend/webhooks/[id]/page.tsx' }),\n integrationDeliveriesTable: dataTableExtensionHost({ tableId: 'webhooks.integration-deliveries', source: 'widgets/injection/integration-deliveries/widget.client.tsx' }),\n },\n})\n\nexport default extensionPoints\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wBAAwB,mCAAmC;AAE7D,MAAM,kBAAkB,4BAA4B;AAAA,EACzD,UAAU;AAAA,EACV,OAAO;AAAA,IACL,eAAe,uBAAuB,EAAE,SAAS,iBAAiB,QAAQ,4BAA4B,CAAC;AAAA,IACvG,iBAAiB,uBAAuB,EAAE,SAAS,uBAAuB,QAAQ,iCAAiC,CAAC;AAAA,IACpH,4BAA4B,uBAAuB,EAAE,SAAS,mCAAmC,QAAQ,6DAA6D,CAAC;AAAA,EACzK;AACF,CAAC;AAED,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function buildSourcesOutput({ importSection, entriesLiteral }) {
|
|
2
|
+
return `// AUTO-GENERATED by mercato generate registry
|
|
3
|
+
import type { WebhookSourceConfig } from '@open-mercato/shared/lib/webhooks'
|
|
4
|
+
${importSection ? `${importSection}
|
|
5
|
+
` : ""}type WebhookSourceModuleEntry = { moduleId: string; sources: WebhookSourceConfig[] }
|
|
6
|
+
|
|
7
|
+
export const webhookSourceEntries: WebhookSourceModuleEntry[] = [
|
|
8
|
+
${entriesLiteral ? ` ${entriesLiteral}
|
|
9
|
+
` : ""}]
|
|
10
|
+
`;
|
|
11
|
+
}
|
|
12
|
+
function buildHandlersOutput({ importSection, entriesLiteral }) {
|
|
13
|
+
return `// AUTO-GENERATED by mercato generate registry
|
|
14
|
+
import type { WebhookHandlerRegistryEntry } from '@open-mercato/shared/lib/webhooks'
|
|
15
|
+
${importSection ? `${importSection}
|
|
16
|
+
` : ""}type WebhookHandlerModuleEntry = { moduleId: string; handlers: WebhookHandlerRegistryEntry[] }
|
|
17
|
+
|
|
18
|
+
export const webhookHandlerEntries: WebhookHandlerModuleEntry[] = [
|
|
19
|
+
${entriesLiteral ? ` ${entriesLiteral}
|
|
20
|
+
` : ""}]
|
|
21
|
+
`;
|
|
22
|
+
}
|
|
23
|
+
const sourcesPlugin = {
|
|
24
|
+
id: "webhooks.sources",
|
|
25
|
+
conventionFile: "webhook-sources.ts",
|
|
26
|
+
importPrefix: "WEBHOOK_SOURCES",
|
|
27
|
+
configExpr: (importName, moduleId) => `{ moduleId: '${moduleId}', sources: ((${importName}.default ?? ${importName}.webhookSources ?? []) as WebhookSourceConfig[]) }`,
|
|
28
|
+
outputFileName: "webhook-sources.generated.ts",
|
|
29
|
+
buildOutput: buildSourcesOutput,
|
|
30
|
+
bootstrapRegistration: {
|
|
31
|
+
entriesExportName: "webhookSourceEntries",
|
|
32
|
+
registrationImports: [
|
|
33
|
+
`import { registerWebhookSourceEntries } from '@open-mercato/webhooks/modules/webhooks/lib/module-webhook-registry'`
|
|
34
|
+
],
|
|
35
|
+
buildCall: (name) => `registerWebhookSourceEntries(${name})`
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const handlersPlugin = {
|
|
39
|
+
id: "webhooks.handlers",
|
|
40
|
+
conventionFile: "webhook-handlers.ts",
|
|
41
|
+
importPrefix: "WEBHOOK_HANDLERS",
|
|
42
|
+
configExpr: (importName, moduleId) => `{ moduleId: '${moduleId}', handlers: ((${importName}.default ?? ${importName}.webhookHandlers ?? []) as WebhookHandlerRegistryEntry[]) }`,
|
|
43
|
+
outputFileName: "webhook-handlers.generated.ts",
|
|
44
|
+
buildOutput: buildHandlersOutput,
|
|
45
|
+
bootstrapRegistration: {
|
|
46
|
+
entriesExportName: "webhookHandlerEntries",
|
|
47
|
+
registrationImports: [
|
|
48
|
+
`import { registerWebhookHandlerEntries } from '@open-mercato/webhooks/modules/webhooks/lib/module-webhook-registry'`
|
|
49
|
+
],
|
|
50
|
+
buildCall: (name) => `registerWebhookHandlerEntries(${name})`
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const generatorPlugins = [sourcesPlugin, handlersPlugin];
|
|
54
|
+
export {
|
|
55
|
+
generatorPlugins
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=generators.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/modules/webhooks/generators.ts"],
|
|
4
|
+
"sourcesContent": ["import type { GeneratorPlugin } from '@open-mercato/shared/modules/generators'\n\nfunction buildSourcesOutput({ importSection, entriesLiteral }: { importSection: string; entriesLiteral: string }): string {\n return `// AUTO-GENERATED by mercato generate registry\nimport type { WebhookSourceConfig } from '@open-mercato/shared/lib/webhooks'\n${importSection ? `${importSection}\\n` : ''}type WebhookSourceModuleEntry = { moduleId: string; sources: WebhookSourceConfig[] }\n\nexport const webhookSourceEntries: WebhookSourceModuleEntry[] = [\n${entriesLiteral ? ` ${entriesLiteral}\\n` : ''}]\n`\n}\n\nfunction buildHandlersOutput({ importSection, entriesLiteral }: { importSection: string; entriesLiteral: string }): string {\n return `// AUTO-GENERATED by mercato generate registry\nimport type { WebhookHandlerRegistryEntry } from '@open-mercato/shared/lib/webhooks'\n${importSection ? `${importSection}\\n` : ''}type WebhookHandlerModuleEntry = { moduleId: string; handlers: WebhookHandlerRegistryEntry[] }\n\nexport const webhookHandlerEntries: WebhookHandlerModuleEntry[] = [\n${entriesLiteral ? ` ${entriesLiteral}\\n` : ''}]\n`\n}\n\nconst sourcesPlugin: GeneratorPlugin = {\n id: 'webhooks.sources',\n conventionFile: 'webhook-sources.ts',\n importPrefix: 'WEBHOOK_SOURCES',\n configExpr: (importName: string, moduleId: string) =>\n `{ moduleId: '${moduleId}', sources: ((${importName}.default ?? ${importName}.webhookSources ?? []) as WebhookSourceConfig[]) }`,\n outputFileName: 'webhook-sources.generated.ts',\n buildOutput: buildSourcesOutput,\n bootstrapRegistration: {\n entriesExportName: 'webhookSourceEntries',\n registrationImports: [\n `import { registerWebhookSourceEntries } from '@open-mercato/webhooks/modules/webhooks/lib/module-webhook-registry'`,\n ],\n buildCall: (name: string) => `registerWebhookSourceEntries(${name})`,\n },\n}\n\nconst handlersPlugin: GeneratorPlugin = {\n id: 'webhooks.handlers',\n conventionFile: 'webhook-handlers.ts',\n importPrefix: 'WEBHOOK_HANDLERS',\n configExpr: (importName: string, moduleId: string) =>\n `{ moduleId: '${moduleId}', handlers: ((${importName}.default ?? ${importName}.webhookHandlers ?? []) as WebhookHandlerRegistryEntry[]) }`,\n outputFileName: 'webhook-handlers.generated.ts',\n buildOutput: buildHandlersOutput,\n bootstrapRegistration: {\n entriesExportName: 'webhookHandlerEntries',\n registrationImports: [\n `import { registerWebhookHandlerEntries } from '@open-mercato/webhooks/modules/webhooks/lib/module-webhook-registry'`,\n ],\n buildCall: (name: string) => `registerWebhookHandlerEntries(${name})`,\n },\n}\n\nexport const generatorPlugins: GeneratorPlugin[] = [sourcesPlugin, handlersPlugin]\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,mBAAmB,EAAE,eAAe,eAAe,GAA8D;AACxH,SAAO;AAAA;AAAA,EAEP,gBAAgB,GAAG,aAAa;AAAA,IAAO,EAAE;AAAA;AAAA;AAAA,EAGzC,iBAAiB,KAAK,cAAc;AAAA,IAAO,EAAE;AAAA;AAE/C;AAEA,SAAS,oBAAoB,EAAE,eAAe,eAAe,GAA8D;AACzH,SAAO;AAAA;AAAA,EAEP,gBAAgB,GAAG,aAAa;AAAA,IAAO,EAAE;AAAA;AAAA;AAAA,EAGzC,iBAAiB,KAAK,cAAc;AAAA,IAAO,EAAE;AAAA;AAE/C;AAEA,MAAM,gBAAiC;AAAA,EACrC,IAAI;AAAA,EACJ,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,YAAY,CAAC,YAAoB,aAC/B,gBAAgB,QAAQ,iBAAiB,UAAU,eAAe,UAAU;AAAA,EAC9E,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,uBAAuB;AAAA,IACrB,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,MACnB;AAAA,IACF;AAAA,IACA,WAAW,CAAC,SAAiB,gCAAgC,IAAI;AAAA,EACnE;AACF;AAEA,MAAM,iBAAkC;AAAA,EACtC,IAAI;AAAA,EACJ,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,YAAY,CAAC,YAAoB,aAC/B,gBAAgB,QAAQ,kBAAkB,UAAU,eAAe,UAAU;AAAA,EAC/E,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,uBAAuB;AAAA,IACrB,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,MACnB;AAAA,IACF;AAAA,IACA,WAAW,CAAC,SAAiB,iCAAiC,IAAI;AAAA,EACpE;AACF;AAEO,MAAM,mBAAsC,CAAC,eAAe,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
2
|
+
import { WebhookIngestionEntity } from "../data/entities.js";
|
|
3
|
+
import { emitWebhooksEvent } from "../events.js";
|
|
4
|
+
import { resolveWebhookHandlers } from "./inbound-registry.js";
|
|
5
|
+
const MAX_HANDLER_RESULTS = 50;
|
|
6
|
+
const MAX_ERROR_MESSAGE_LENGTH = 1024;
|
|
7
|
+
function truncateError(message) {
|
|
8
|
+
return message.length > MAX_ERROR_MESSAGE_LENGTH ? `${message.slice(0, MAX_ERROR_MESSAGE_LENGTH)}\u2026` : message;
|
|
9
|
+
}
|
|
10
|
+
function moduleOfHandler(handlerId) {
|
|
11
|
+
const separatorIndex = handlerId.indexOf(":");
|
|
12
|
+
return separatorIndex > 0 ? handlerId.slice(0, separatorIndex) : handlerId;
|
|
13
|
+
}
|
|
14
|
+
async function processInboundDispatchJob(em, job, ctx) {
|
|
15
|
+
const startedAtMs = Date.now();
|
|
16
|
+
const ingestion = await findOneWithDecryption(
|
|
17
|
+
em,
|
|
18
|
+
WebhookIngestionEntity,
|
|
19
|
+
{
|
|
20
|
+
id: job.ingestionId,
|
|
21
|
+
tenantId: job.tenantId,
|
|
22
|
+
organizationId: job.organizationId
|
|
23
|
+
},
|
|
24
|
+
{}
|
|
25
|
+
);
|
|
26
|
+
if (!ingestion || ingestion.status === "processed") return;
|
|
27
|
+
ingestion.status = "processing";
|
|
28
|
+
await em.flush();
|
|
29
|
+
const handlers = resolveWebhookHandlers(job.sourceKey, job.eventType);
|
|
30
|
+
const payload = {
|
|
31
|
+
data: ingestion.payload,
|
|
32
|
+
eventType: job.eventType,
|
|
33
|
+
sourceKey: job.sourceKey,
|
|
34
|
+
headers: ingestion.headers ?? {},
|
|
35
|
+
ingestionId: job.ingestionId,
|
|
36
|
+
tenantId: job.tenantId,
|
|
37
|
+
organizationId: job.organizationId
|
|
38
|
+
};
|
|
39
|
+
const previousResults = Array.isArray(ingestion.handlerResults) ? ingestion.handlerResults : [];
|
|
40
|
+
const alreadySucceeded = new Map(
|
|
41
|
+
previousResults.filter((result) => result?.status === "success").map((result) => [result.handlerId, result])
|
|
42
|
+
);
|
|
43
|
+
const results = [];
|
|
44
|
+
let failedCount = 0;
|
|
45
|
+
for (const entry of handlers) {
|
|
46
|
+
const previousSuccess = alreadySucceeded.get(entry.meta.id);
|
|
47
|
+
if (previousSuccess) {
|
|
48
|
+
results.push(previousSuccess);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const handlerStartedMs = Date.now();
|
|
52
|
+
const handlerStartedAt = new Date(handlerStartedMs).toISOString();
|
|
53
|
+
try {
|
|
54
|
+
const mod = await entry.handler();
|
|
55
|
+
await mod.default(payload, ctx);
|
|
56
|
+
results.push({
|
|
57
|
+
handlerId: entry.meta.id,
|
|
58
|
+
module: moduleOfHandler(entry.meta.id),
|
|
59
|
+
status: "success",
|
|
60
|
+
durationMs: Date.now() - handlerStartedMs,
|
|
61
|
+
startedAt: handlerStartedAt
|
|
62
|
+
});
|
|
63
|
+
} catch (error) {
|
|
64
|
+
failedCount += 1;
|
|
65
|
+
const message = truncateError(error instanceof Error ? error.message : String(error));
|
|
66
|
+
results.push({
|
|
67
|
+
handlerId: entry.meta.id,
|
|
68
|
+
module: moduleOfHandler(entry.meta.id),
|
|
69
|
+
status: "failed",
|
|
70
|
+
errorMessage: message,
|
|
71
|
+
durationMs: Date.now() - handlerStartedMs,
|
|
72
|
+
startedAt: handlerStartedAt
|
|
73
|
+
});
|
|
74
|
+
await emitWebhooksEvent("webhooks.inbound.handler_failed", {
|
|
75
|
+
ingestionId: job.ingestionId,
|
|
76
|
+
sourceKey: job.sourceKey,
|
|
77
|
+
eventType: job.eventType,
|
|
78
|
+
handlerId: entry.meta.id,
|
|
79
|
+
errorMessage: message,
|
|
80
|
+
tenantId: job.tenantId,
|
|
81
|
+
organizationId: job.organizationId
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
ingestion.handlerCount = handlers.length;
|
|
86
|
+
ingestion.handlerResults = results.slice(0, MAX_HANDLER_RESULTS);
|
|
87
|
+
ingestion.status = failedCount > 0 ? "failed" : "processed";
|
|
88
|
+
ingestion.processedAt = /* @__PURE__ */ new Date();
|
|
89
|
+
ingestion.durationMs = Date.now() - startedAtMs;
|
|
90
|
+
ingestion.errorMessage = failedCount > 0 ? `${failedCount}/${handlers.length} handlers failed` : null;
|
|
91
|
+
await em.flush();
|
|
92
|
+
await emitWebhooksEvent("webhooks.inbound.processed", {
|
|
93
|
+
ingestionId: job.ingestionId,
|
|
94
|
+
sourceKey: job.sourceKey,
|
|
95
|
+
eventType: job.eventType,
|
|
96
|
+
handlerCount: handlers.length,
|
|
97
|
+
failedCount,
|
|
98
|
+
tenantId: job.tenantId,
|
|
99
|
+
organizationId: job.organizationId
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
processInboundDispatchJob
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=inbound-dispatch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/webhooks/lib/inbound-dispatch.ts"],
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport type {\n WebhookHandlerContext,\n WebhookHandlerPayload,\n WebhookHandlerResult,\n} from '@open-mercato/shared/lib/webhooks'\nimport { WebhookIngestionEntity } from '../data/entities'\nimport { emitWebhooksEvent } from '../events'\nimport { resolveWebhookHandlers } from './inbound-registry'\n\nconst MAX_HANDLER_RESULTS = 50\nconst MAX_ERROR_MESSAGE_LENGTH = 1024\n\nexport type InboundDispatchJob = {\n ingestionId: string\n sourceKey: string\n eventType: string\n tenantId: string\n organizationId: string\n}\n\nfunction truncateError(message: string): string {\n return message.length > MAX_ERROR_MESSAGE_LENGTH\n ? `${message.slice(0, MAX_ERROR_MESSAGE_LENGTH)}\u2026`\n : message\n}\n\nfunction moduleOfHandler(handlerId: string): string {\n const separatorIndex = handlerId.indexOf(':')\n return separatorIndex > 0 ? handlerId.slice(0, separatorIndex) : handlerId\n}\n\n/**\n * Process a queued inbound-dispatch job: load the ingestion, run every matching\n * handler independently (a failing handler never blocks the others), record\n * per-handler results, and emit lifecycle events. The payload and headers are\n * read from the (decrypted) ingestion row rather than carried on the job, so the\n * queue never stores the raw webhook body. Idempotent \u2014 a job whose ingestion is\n * already `processed` returns early, and a retry after a partial failure re-runs\n * only the handlers that have not already succeeded.\n */\nexport async function processInboundDispatchJob(\n em: EntityManager,\n job: InboundDispatchJob,\n ctx: WebhookHandlerContext,\n): Promise<void> {\n const startedAtMs = Date.now()\n const ingestion = await findOneWithDecryption(\n em,\n WebhookIngestionEntity,\n {\n id: job.ingestionId,\n tenantId: job.tenantId,\n organizationId: job.organizationId,\n },\n {},\n )\n\n if (!ingestion || ingestion.status === 'processed') return\n\n ingestion.status = 'processing'\n await em.flush()\n\n const handlers = resolveWebhookHandlers(job.sourceKey, job.eventType)\n const payload: WebhookHandlerPayload = {\n data: ingestion.payload,\n eventType: job.eventType,\n sourceKey: job.sourceKey,\n headers: ingestion.headers ?? {},\n ingestionId: job.ingestionId,\n tenantId: job.tenantId,\n organizationId: job.organizationId,\n }\n\n const previousResults = Array.isArray(ingestion.handlerResults) ? ingestion.handlerResults : []\n const alreadySucceeded = new Map(\n previousResults\n .filter((result) => result?.status === 'success')\n .map((result) => [result.handlerId, result]),\n )\n\n const results: WebhookHandlerResult[] = []\n let failedCount = 0\n\n for (const entry of handlers) {\n const previousSuccess = alreadySucceeded.get(entry.meta.id)\n if (previousSuccess) {\n results.push(previousSuccess)\n continue\n }\n\n const handlerStartedMs = Date.now()\n const handlerStartedAt = new Date(handlerStartedMs).toISOString()\n try {\n const mod = await entry.handler()\n await mod.default(payload, ctx)\n results.push({\n handlerId: entry.meta.id,\n module: moduleOfHandler(entry.meta.id),\n status: 'success',\n durationMs: Date.now() - handlerStartedMs,\n startedAt: handlerStartedAt,\n })\n } catch (error) {\n failedCount += 1\n const message = truncateError(error instanceof Error ? error.message : String(error))\n results.push({\n handlerId: entry.meta.id,\n module: moduleOfHandler(entry.meta.id),\n status: 'failed',\n errorMessage: message,\n durationMs: Date.now() - handlerStartedMs,\n startedAt: handlerStartedAt,\n })\n await emitWebhooksEvent('webhooks.inbound.handler_failed', {\n ingestionId: job.ingestionId,\n sourceKey: job.sourceKey,\n eventType: job.eventType,\n handlerId: entry.meta.id,\n errorMessage: message,\n tenantId: job.tenantId,\n organizationId: job.organizationId,\n })\n }\n }\n\n ingestion.handlerCount = handlers.length\n ingestion.handlerResults = results.slice(0, MAX_HANDLER_RESULTS)\n ingestion.status = failedCount > 0 ? 'failed' : 'processed'\n ingestion.processedAt = new Date()\n ingestion.durationMs = Date.now() - startedAtMs\n ingestion.errorMessage = failedCount > 0\n ? `${failedCount}/${handlers.length} handlers failed`\n : null\n await em.flush()\n\n await emitWebhooksEvent('webhooks.inbound.processed', {\n ingestionId: job.ingestionId,\n sourceKey: job.sourceKey,\n eventType: job.eventType,\n handlerCount: handlers.length,\n failedCount,\n tenantId: job.tenantId,\n organizationId: job.organizationId,\n })\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,6BAA6B;AAMtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAEvC,MAAM,sBAAsB;AAC5B,MAAM,2BAA2B;AAUjC,SAAS,cAAc,SAAyB;AAC9C,SAAO,QAAQ,SAAS,2BACpB,GAAG,QAAQ,MAAM,GAAG,wBAAwB,CAAC,WAC7C;AACN;AAEA,SAAS,gBAAgB,WAA2B;AAClD,QAAM,iBAAiB,UAAU,QAAQ,GAAG;AAC5C,SAAO,iBAAiB,IAAI,UAAU,MAAM,GAAG,cAAc,IAAI;AACnE;AAWA,eAAsB,0BACpB,IACA,KACA,KACe;AACf,QAAM,cAAc,KAAK,IAAI;AAC7B,QAAM,YAAY,MAAM;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,MACE,IAAI,IAAI;AAAA,MACR,UAAU,IAAI;AAAA,MACd,gBAAgB,IAAI;AAAA,IACtB;AAAA,IACA,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,aAAa,UAAU,WAAW,YAAa;AAEpD,YAAU,SAAS;AACnB,QAAM,GAAG,MAAM;AAEf,QAAM,WAAW,uBAAuB,IAAI,WAAW,IAAI,SAAS;AACpE,QAAM,UAAiC;AAAA,IACrC,MAAM,UAAU;AAAA,IAChB,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,IACf,SAAS,UAAU,WAAW,CAAC;AAAA,IAC/B,aAAa,IAAI;AAAA,IACjB,UAAU,IAAI;AAAA,IACd,gBAAgB,IAAI;AAAA,EACtB;AAEA,QAAM,kBAAkB,MAAM,QAAQ,UAAU,cAAc,IAAI,UAAU,iBAAiB,CAAC;AAC9F,QAAM,mBAAmB,IAAI;AAAA,IAC3B,gBACG,OAAO,CAAC,WAAW,QAAQ,WAAW,SAAS,EAC/C,IA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c,IAAI,WAAW;AAChD,YAAU,cAAc,oBAAI,KAAK;AACjC,YAAU,aAAa,KAAK,IAAI,IAAI;AACpC,YAAU,eAAe,cAAc,IACnC,GAAG,WAAW,IAAI,SAAS,MAAM,qBACjC;AACJ,QAAM,GAAG,MAAM;AAEf,QAAM,kBAAkB,8BAA8B;AAAA,IACpD,aAAa,IAAI;AAAA,IACjB,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,IACf,cAAc,SAAS;AAAA,IACvB;AAAA,IACA,UAAU,IAAI;AAAA,IACd,gBAAgB,IAAI;AAAA,EACtB,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { matchWebhookEventPattern } from "@open-mercato/shared/lib/events/patterns";
|
|
2
|
+
const WEBHOOK_SOURCES_KEY = "__openMercatoWebhookSources__";
|
|
3
|
+
const WEBHOOK_HANDLERS_KEY = "__openMercatoWebhookHandlers__";
|
|
4
|
+
function getSourceRegistry() {
|
|
5
|
+
const globalState = globalThis;
|
|
6
|
+
if (!globalState[WEBHOOK_SOURCES_KEY]) {
|
|
7
|
+
globalState[WEBHOOK_SOURCES_KEY] = /* @__PURE__ */ new Map();
|
|
8
|
+
}
|
|
9
|
+
return globalState[WEBHOOK_SOURCES_KEY];
|
|
10
|
+
}
|
|
11
|
+
function getHandlerRegistry() {
|
|
12
|
+
const globalState = globalThis;
|
|
13
|
+
if (!globalState[WEBHOOK_HANDLERS_KEY]) {
|
|
14
|
+
globalState[WEBHOOK_HANDLERS_KEY] = [];
|
|
15
|
+
}
|
|
16
|
+
return globalState[WEBHOOK_HANDLERS_KEY];
|
|
17
|
+
}
|
|
18
|
+
function registerWebhookSource(config) {
|
|
19
|
+
const registry = getSourceRegistry();
|
|
20
|
+
registry.set(config.key, config);
|
|
21
|
+
return () => {
|
|
22
|
+
if (registry.get(config.key) === config) registry.delete(config.key);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function setWebhookSources(configs) {
|
|
26
|
+
const registry = getSourceRegistry();
|
|
27
|
+
registry.clear();
|
|
28
|
+
for (const config of configs) registry.set(config.key, config);
|
|
29
|
+
}
|
|
30
|
+
function getWebhookSource(sourceKey) {
|
|
31
|
+
return getSourceRegistry().get(sourceKey);
|
|
32
|
+
}
|
|
33
|
+
function listWebhookSources() {
|
|
34
|
+
return Array.from(getSourceRegistry().values());
|
|
35
|
+
}
|
|
36
|
+
function clearWebhookSources() {
|
|
37
|
+
getSourceRegistry().clear();
|
|
38
|
+
}
|
|
39
|
+
function registerWebhookHandler(entry) {
|
|
40
|
+
const registry = getHandlerRegistry();
|
|
41
|
+
registry.push(entry);
|
|
42
|
+
return () => {
|
|
43
|
+
const index = registry.indexOf(entry);
|
|
44
|
+
if (index >= 0) registry.splice(index, 1);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function setWebhookHandlers(entries) {
|
|
48
|
+
const registry = getHandlerRegistry();
|
|
49
|
+
registry.length = 0;
|
|
50
|
+
registry.push(...entries);
|
|
51
|
+
}
|
|
52
|
+
function listWebhookHandlers() {
|
|
53
|
+
return [...getHandlerRegistry()];
|
|
54
|
+
}
|
|
55
|
+
function clearWebhookHandlers() {
|
|
56
|
+
getHandlerRegistry().length = 0;
|
|
57
|
+
}
|
|
58
|
+
function resolveWebhookHandlers(sourceKey, eventType) {
|
|
59
|
+
return getHandlerRegistry().filter((entry) => {
|
|
60
|
+
if (entry.meta.source !== sourceKey) return false;
|
|
61
|
+
return matchWebhookEventPattern(eventType, entry.meta.event);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
clearWebhookHandlers,
|
|
66
|
+
clearWebhookSources,
|
|
67
|
+
getWebhookSource,
|
|
68
|
+
listWebhookHandlers,
|
|
69
|
+
listWebhookSources,
|
|
70
|
+
registerWebhookHandler,
|
|
71
|
+
registerWebhookSource,
|
|
72
|
+
resolveWebhookHandlers,
|
|
73
|
+
setWebhookHandlers,
|
|
74
|
+
setWebhookSources
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=inbound-registry.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/webhooks/lib/inbound-registry.ts"],
|
|
4
|
+
"sourcesContent": ["import { matchWebhookEventPattern } from '@open-mercato/shared/lib/events/patterns'\nimport type {\n WebhookHandlerRegistryEntry,\n WebhookSourceConfig,\n} from '@open-mercato/shared/lib/webhooks'\n\nconst WEBHOOK_SOURCES_KEY = '__openMercatoWebhookSources__'\nconst WEBHOOK_HANDLERS_KEY = '__openMercatoWebhookHandlers__'\n\ntype GlobalState = typeof globalThis & {\n [WEBHOOK_SOURCES_KEY]?: Map<string, WebhookSourceConfig>\n [WEBHOOK_HANDLERS_KEY]?: WebhookHandlerRegistryEntry[]\n}\n\nfunction getSourceRegistry(): Map<string, WebhookSourceConfig> {\n const globalState = globalThis as GlobalState\n if (!globalState[WEBHOOK_SOURCES_KEY]) {\n globalState[WEBHOOK_SOURCES_KEY] = new Map<string, WebhookSourceConfig>()\n }\n return globalState[WEBHOOK_SOURCES_KEY]\n}\n\nfunction getHandlerRegistry(): WebhookHandlerRegistryEntry[] {\n const globalState = globalThis as GlobalState\n if (!globalState[WEBHOOK_HANDLERS_KEY]) {\n globalState[WEBHOOK_HANDLERS_KEY] = []\n }\n return globalState[WEBHOOK_HANDLERS_KEY]\n}\n\nexport function registerWebhookSource(config: WebhookSourceConfig): () => void {\n const registry = getSourceRegistry()\n registry.set(config.key, config)\n return () => {\n if (registry.get(config.key) === config) registry.delete(config.key)\n }\n}\n\nexport function setWebhookSources(configs: WebhookSourceConfig[]): void {\n const registry = getSourceRegistry()\n registry.clear()\n for (const config of configs) registry.set(config.key, config)\n}\n\nexport function getWebhookSource(sourceKey: string): WebhookSourceConfig | undefined {\n return getSourceRegistry().get(sourceKey)\n}\n\nexport function listWebhookSources(): WebhookSourceConfig[] {\n return Array.from(getSourceRegistry().values())\n}\n\nexport function clearWebhookSources(): void {\n getSourceRegistry().clear()\n}\n\nexport function registerWebhookHandler(entry: WebhookHandlerRegistryEntry): () => void {\n const registry = getHandlerRegistry()\n registry.push(entry)\n return () => {\n const index = registry.indexOf(entry)\n if (index >= 0) registry.splice(index, 1)\n }\n}\n\nexport function setWebhookHandlers(entries: WebhookHandlerRegistryEntry[]): void {\n const registry = getHandlerRegistry()\n registry.length = 0\n registry.push(...entries)\n}\n\nexport function listWebhookHandlers(): WebhookHandlerRegistryEntry[] {\n return [...getHandlerRegistry()]\n}\n\nexport function clearWebhookHandlers(): void {\n getHandlerRegistry().length = 0\n}\n\n/**\n * Resolve the handlers that match an inbound webhook's source key and event type.\n * Event matching reuses the outbound prefix-wildcard semantics (`*`, `payment_intent.*`).\n */\nexport function resolveWebhookHandlers(\n sourceKey: string,\n eventType: string,\n): WebhookHandlerRegistryEntry[] {\n return getHandlerRegistry().filter((entry) => {\n if (entry.meta.source !== sourceKey) return false\n return matchWebhookEventPattern(eventType, entry.meta.event)\n })\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gCAAgC;AAMzC,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;AAO7B,SAAS,oBAAsD;AAC7D,QAAM,cAAc;AACpB,MAAI,CAAC,YAAY,mBAAmB,GAAG;AACrC,gBAAY,mBAAmB,IAAI,oBAAI,IAAiC;AAAA,EAC1E;AACA,SAAO,YAAY,mBAAmB;AACxC;AAEA,SAAS,qBAAoD;AAC3D,QAAM,cAAc;AACpB,MAAI,CAAC,YAAY,oBAAoB,GAAG;AACtC,gBAAY,oBAAoB,IAAI,CAAC;AAAA,EACvC;AACA,SAAO,YAAY,oBAAoB;AACzC;AAEO,SAAS,sBAAsB,QAAyC;AAC7E,QAAM,WAAW,kBAAkB;AACnC,WAAS,IAAI,OAAO,KAAK,MAAM;AAC/B,SAAO,MAAM;AACX,QAAI,SAAS,IAAI,OAAO,GAAG,MAAM,OAAQ,UAAS,OAAO,OAAO,GAAG;AAAA,EACrE;AACF;AAEO,SAAS,kBAAkB,SAAsC;AACtE,QAAM,WAAW,kBAAkB;AACnC,WAAS,MAAM;AACf,aAAW,UAAU,QAAS,UAAS,IAAI,OAAO,KAAK,MAAM;AAC/D;AAEO,SAAS,iBAAiB,WAAoD;AACnF,SAAO,kBAAkB,EAAE,IAAI,SAAS;AAC1C;AAEO,SAAS,qBAA4C;AAC1D,SAAO,MAAM,KAAK,kBAAkB,EAAE,OAAO,CAAC;AAChD;AAEO,SAAS,sBAA4B;AAC1C,oBAAkB,EAAE,MAAM;AAC5B;AAEO,SAAS,uBAAuB,OAAgD;AACrF,QAAM,WAAW,mBAAmB;AACpC,WAAS,KAAK,KAAK;AACnB,SAAO,MAAM;AACX,UAAM,QAAQ,SAAS,QAAQ,KAAK;AACpC,QAAI,SAAS,EAAG,UAAS,OAAO,OAAO,CAAC;AAAA,EAC1C;AACF;AAEO,SAAS,mBAAmB,SAA8C;AAC/E,QAAM,WAAW,mBAAmB;AACpC,WAAS,SAAS;AAClB,WAAS,KAAK,GAAG,OAAO;AAC1B;AAEO,SAAS,sBAAqD;AACnE,SAAO,CAAC,GAAG,mBAAmB,CAAC;AACjC;AAEO,SAAS,uBAA6B;AAC3C,qBAAmB,EAAE,SAAS;AAChC;AAMO,SAAS,uBACd,WACA,WAC+B;AAC/B,SAAO,mBAAmB,EAAE,OAAO,CAAC,UAAU;AAC5C,QAAI,MAAM,KAAK,WAAW,UAAW,QAAO;AAC5C,WAAO,yBAAyB,WAAW,MAAM,KAAK,KAAK;AAAA,EAC7D,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { setWebhookHandlers, setWebhookSources } from "./inbound-registry.js";
|
|
2
|
+
function registerWebhookSourceEntries(entries) {
|
|
3
|
+
setWebhookSources(entries.flatMap((entry) => entry.sources ?? []));
|
|
4
|
+
}
|
|
5
|
+
function registerWebhookHandlerEntries(entries) {
|
|
6
|
+
setWebhookHandlers(entries.flatMap((entry) => entry.handlers ?? []));
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
registerWebhookHandlerEntries,
|
|
10
|
+
registerWebhookSourceEntries
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=module-webhook-registry.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/webhooks/lib/module-webhook-registry.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n WebhookHandlerRegistryEntry,\n WebhookSourceConfig,\n} from '@open-mercato/shared/lib/webhooks'\nimport { setWebhookHandlers, setWebhookSources } from './inbound-registry'\n\nexport type WebhookSourceModuleEntry = {\n moduleId: string\n sources: WebhookSourceConfig[]\n}\n\nexport type WebhookHandlerModuleEntry = {\n moduleId: string\n handlers: WebhookHandlerRegistryEntry[]\n}\n\n/**\n * Bootstrap-time registration for module-declared webhook sources.\n * Driven by the `webhooks.sources` generator plugin via\n * `bootstrap-registrations.generated.ts` \u2014 modules contribute a\n * `webhook-sources.ts` and are wired here without bootstrap.ts edits.\n */\nexport function registerWebhookSourceEntries(entries: WebhookSourceModuleEntry[]): void {\n setWebhookSources(entries.flatMap((entry) => entry.sources ?? []))\n}\n\n/**\n * Bootstrap-time registration for module-declared webhook handlers.\n * Driven by the `webhooks.handlers` generator plugin.\n */\nexport function registerWebhookHandlerEntries(entries: WebhookHandlerModuleEntry[]): void {\n setWebhookHandlers(entries.flatMap((entry) => entry.handlers ?? []))\n}\n"],
|
|
5
|
+
"mappings": "AAIA,SAAS,oBAAoB,yBAAyB;AAkB/C,SAAS,6BAA6B,SAA2C;AACtF,oBAAkB,QAAQ,QAAQ,CAAC,UAAU,MAAM,WAAW,CAAC,CAAC,CAAC;AACnE;AAMO,SAAS,8BAA8B,SAA4C;AACxF,qBAAmB,QAAQ,QAAQ,CAAC,UAAU,MAAM,YAAY,CAAC,CAAC,CAAC;AACrE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|