@orthacms/webhooks-server 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/index.d.ts +19 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +33 -0
  6. package/dist/lib/application/dto/list-deliveries-query.dto.d.ts +8 -0
  7. package/dist/lib/application/dto/list-deliveries-query.dto.d.ts.map +1 -0
  8. package/dist/lib/application/dto/list-deliveries-query.dto.js +64 -0
  9. package/dist/lib/application/dto/save-webhook-endpoint.dto.d.ts +23 -0
  10. package/dist/lib/application/dto/save-webhook-endpoint.dto.d.ts.map +1 -0
  11. package/dist/lib/application/dto/save-webhook-endpoint.dto.js +127 -0
  12. package/dist/lib/application/webhook-endpoints.service.d.ts +82 -0
  13. package/dist/lib/application/webhook-endpoints.service.d.ts.map +1 -0
  14. package/dist/lib/application/webhook-endpoints.service.js +213 -0
  15. package/dist/lib/docs/describe-webhooks-api.d.ts +16 -0
  16. package/dist/lib/docs/describe-webhooks-api.d.ts.map +1 -0
  17. package/dist/lib/docs/describe-webhooks-api.js +170 -0
  18. package/dist/lib/docs/webhook-schemas.d.ts +21 -0
  19. package/dist/lib/docs/webhook-schemas.d.ts.map +1 -0
  20. package/dist/lib/docs/webhook-schemas.js +360 -0
  21. package/dist/lib/domain/errors/index.d.ts +3 -0
  22. package/dist/lib/domain/errors/index.d.ts.map +1 -0
  23. package/dist/lib/domain/errors/index.js +7 -0
  24. package/dist/lib/domain/errors/webhook-delivery-not-found.error.d.ts +12 -0
  25. package/dist/lib/domain/errors/webhook-delivery-not-found.error.d.ts.map +1 -0
  26. package/dist/lib/domain/errors/webhook-delivery-not-found.error.js +19 -0
  27. package/dist/lib/domain/errors/webhook-endpoint-not-found.error.d.ts +6 -0
  28. package/dist/lib/domain/errors/webhook-endpoint-not-found.error.d.ts.map +1 -0
  29. package/dist/lib/domain/errors/webhook-endpoint-not-found.error.js +13 -0
  30. package/dist/lib/domain/webhook-secret.d.ts +29 -0
  31. package/dist/lib/domain/webhook-secret.d.ts.map +1 -0
  32. package/dist/lib/domain/webhook-secret.js +34 -0
  33. package/dist/lib/domain/webhook-views.d.ts +85 -0
  34. package/dist/lib/domain/webhook-views.d.ts.map +1 -0
  35. package/dist/lib/domain/webhook-views.js +2 -0
  36. package/dist/lib/http/controllers/webhook-deliveries.controller.d.ts +28 -0
  37. package/dist/lib/http/controllers/webhook-deliveries.controller.d.ts.map +1 -0
  38. package/dist/lib/http/controllers/webhook-deliveries.controller.js +110 -0
  39. package/dist/lib/http/controllers/webhook-endpoints.controller.d.ts +61 -0
  40. package/dist/lib/http/controllers/webhook-endpoints.controller.d.ts.map +1 -0
  41. package/dist/lib/http/controllers/webhook-endpoints.controller.js +213 -0
  42. package/dist/lib/http/controllers/webhook-events.controller.d.ts +13 -0
  43. package/dist/lib/http/controllers/webhook-events.controller.d.ts.map +1 -0
  44. package/dist/lib/http/controllers/webhook-events.controller.js +38 -0
  45. package/dist/lib/infrastructure/event-mapping.d.ts +13 -0
  46. package/dist/lib/infrastructure/event-mapping.d.ts.map +1 -0
  47. package/dist/lib/infrastructure/event-mapping.js +69 -0
  48. package/dist/lib/infrastructure/purge/webhook-workspaces.purger.d.ts +42 -0
  49. package/dist/lib/infrastructure/purge/webhook-workspaces.purger.d.ts.map +1 -0
  50. package/dist/lib/infrastructure/purge/webhook-workspaces.purger.js +66 -0
  51. package/dist/lib/infrastructure/schema/index.d.ts +3 -0
  52. package/dist/lib/infrastructure/schema/index.d.ts.map +1 -0
  53. package/dist/lib/infrastructure/schema/index.js +8 -0
  54. package/dist/lib/infrastructure/schema/webhook-deliveries.d.ts +332 -0
  55. package/dist/lib/infrastructure/schema/webhook-deliveries.d.ts.map +1 -0
  56. package/dist/lib/infrastructure/schema/webhook-deliveries.js +92 -0
  57. package/dist/lib/infrastructure/schema/webhook-endpoints.d.ts +330 -0
  58. package/dist/lib/infrastructure/schema/webhook-endpoints.d.ts.map +1 -0
  59. package/dist/lib/infrastructure/schema/webhook-endpoints.js +94 -0
  60. package/dist/lib/infrastructure/webhook-delivery.repository.d.ts +99 -0
  61. package/dist/lib/infrastructure/webhook-delivery.repository.d.ts.map +1 -0
  62. package/dist/lib/infrastructure/webhook-delivery.repository.js +255 -0
  63. package/dist/lib/infrastructure/webhook-delivery.worker.d.ts +72 -0
  64. package/dist/lib/infrastructure/webhook-delivery.worker.d.ts.map +1 -0
  65. package/dist/lib/infrastructure/webhook-delivery.worker.js +216 -0
  66. package/dist/lib/infrastructure/webhook-endpoint.repository.d.ts +88 -0
  67. package/dist/lib/infrastructure/webhook-endpoint.repository.d.ts.map +1 -0
  68. package/dist/lib/infrastructure/webhook-endpoint.repository.js +306 -0
  69. package/dist/lib/infrastructure/webhook-fanout.subscriber.d.ts +36 -0
  70. package/dist/lib/infrastructure/webhook-fanout.subscriber.d.ts.map +1 -0
  71. package/dist/lib/infrastructure/webhook-fanout.subscriber.js +83 -0
  72. package/dist/lib/infrastructure/webhook-http.client.d.ts +76 -0
  73. package/dist/lib/infrastructure/webhook-http.client.d.ts.map +1 -0
  74. package/dist/lib/infrastructure/webhook-http.client.js +225 -0
  75. package/dist/lib/types/webhooks-config.d.ts +64 -0
  76. package/dist/lib/types/webhooks-config.d.ts.map +1 -0
  77. package/dist/lib/types/webhooks-config.js +24 -0
  78. package/dist/lib/utils/webhooks-plugin.d.ts +35 -0
  79. package/dist/lib/utils/webhooks-plugin.d.ts.map +1 -0
  80. package/dist/lib/utils/webhooks-plugin.js +90 -0
  81. package/dist/lib/webhooks.module.d.ts +18 -0
  82. package/dist/lib/webhooks.module.d.ts.map +1 -0
  83. package/dist/lib/webhooks.module.js +72 -0
  84. package/dist/lib/webhooks.tokens.d.ts +5 -0
  85. package/dist/lib/webhooks.tokens.d.ts.map +1 -0
  86. package/dist/lib/webhooks.tokens.js +9 -0
  87. package/migrations/0000_init_webhooks.sql +53 -0
  88. package/migrations/meta/0000_snapshot.json +424 -0
  89. package/migrations/meta/_journal.json +13 -0
  90. package/package.json +45 -0
@@ -0,0 +1,424 @@
1
+ {
2
+ "id": "d2791c91-e6e4-4db2-8a9a-8d60eacfea58",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.webhook_deliveries": {
8
+ "name": "webhook_deliveries",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "uuid",
14
+ "primaryKey": true,
15
+ "notNull": true,
16
+ "default": "gen_random_uuid()"
17
+ },
18
+ "endpoint_id": {
19
+ "name": "endpoint_id",
20
+ "type": "uuid",
21
+ "primaryKey": false,
22
+ "notNull": true
23
+ },
24
+ "event_id": {
25
+ "name": "event_id",
26
+ "type": "uuid",
27
+ "primaryKey": false,
28
+ "notNull": true
29
+ },
30
+ "event_kind": {
31
+ "name": "event_kind",
32
+ "type": "text",
33
+ "primaryKey": false,
34
+ "notNull": true
35
+ },
36
+ "workspace_id": {
37
+ "name": "workspace_id",
38
+ "type": "uuid",
39
+ "primaryKey": false,
40
+ "notNull": false
41
+ },
42
+ "content_type": {
43
+ "name": "content_type",
44
+ "type": "text",
45
+ "primaryKey": false,
46
+ "notNull": false
47
+ },
48
+ "payload": {
49
+ "name": "payload",
50
+ "type": "jsonb",
51
+ "primaryKey": false,
52
+ "notNull": true
53
+ },
54
+ "status": {
55
+ "name": "status",
56
+ "type": "text",
57
+ "primaryKey": false,
58
+ "notNull": true,
59
+ "default": "'pending'"
60
+ },
61
+ "attempts": {
62
+ "name": "attempts",
63
+ "type": "integer",
64
+ "primaryKey": false,
65
+ "notNull": true,
66
+ "default": 0
67
+ },
68
+ "next_attempt_at": {
69
+ "name": "next_attempt_at",
70
+ "type": "timestamp with time zone",
71
+ "primaryKey": false,
72
+ "notNull": false
73
+ },
74
+ "claimed_at": {
75
+ "name": "claimed_at",
76
+ "type": "timestamp with time zone",
77
+ "primaryKey": false,
78
+ "notNull": false
79
+ },
80
+ "last_status_code": {
81
+ "name": "last_status_code",
82
+ "type": "integer",
83
+ "primaryKey": false,
84
+ "notNull": false
85
+ },
86
+ "last_error": {
87
+ "name": "last_error",
88
+ "type": "text",
89
+ "primaryKey": false,
90
+ "notNull": false
91
+ },
92
+ "response_snippet": {
93
+ "name": "response_snippet",
94
+ "type": "text",
95
+ "primaryKey": false,
96
+ "notNull": false
97
+ },
98
+ "duration_ms": {
99
+ "name": "duration_ms",
100
+ "type": "integer",
101
+ "primaryKey": false,
102
+ "notNull": false
103
+ },
104
+ "redelivery_of": {
105
+ "name": "redelivery_of",
106
+ "type": "uuid",
107
+ "primaryKey": false,
108
+ "notNull": false
109
+ },
110
+ "created_at": {
111
+ "name": "created_at",
112
+ "type": "timestamp with time zone",
113
+ "primaryKey": false,
114
+ "notNull": true,
115
+ "default": "now()"
116
+ },
117
+ "completed_at": {
118
+ "name": "completed_at",
119
+ "type": "timestamp with time zone",
120
+ "primaryKey": false,
121
+ "notNull": false
122
+ }
123
+ },
124
+ "indexes": {
125
+ "webhook_deliveries_endpoint_event_unique": {
126
+ "name": "webhook_deliveries_endpoint_event_unique",
127
+ "columns": [
128
+ {
129
+ "expression": "endpoint_id",
130
+ "isExpression": false,
131
+ "asc": true,
132
+ "nulls": "last"
133
+ },
134
+ {
135
+ "expression": "event_id",
136
+ "isExpression": false,
137
+ "asc": true,
138
+ "nulls": "last"
139
+ }
140
+ ],
141
+ "isUnique": true,
142
+ "where": "\"webhook_deliveries\".\"redelivery_of\" is null",
143
+ "concurrently": false,
144
+ "method": "btree",
145
+ "with": {}
146
+ },
147
+ "webhook_deliveries_claimable_idx": {
148
+ "name": "webhook_deliveries_claimable_idx",
149
+ "columns": [
150
+ {
151
+ "expression": "next_attempt_at",
152
+ "isExpression": false,
153
+ "asc": true,
154
+ "nulls": "last"
155
+ }
156
+ ],
157
+ "isUnique": false,
158
+ "where": "\"webhook_deliveries\".\"status\" in ('pending', 'failed')",
159
+ "concurrently": false,
160
+ "method": "btree",
161
+ "with": {}
162
+ },
163
+ "webhook_deliveries_endpoint_idx": {
164
+ "name": "webhook_deliveries_endpoint_idx",
165
+ "columns": [
166
+ {
167
+ "expression": "endpoint_id",
168
+ "isExpression": false,
169
+ "asc": true,
170
+ "nulls": "last"
171
+ },
172
+ {
173
+ "expression": "created_at",
174
+ "isExpression": false,
175
+ "asc": true,
176
+ "nulls": "last"
177
+ }
178
+ ],
179
+ "isUnique": false,
180
+ "concurrently": false,
181
+ "method": "btree",
182
+ "with": {}
183
+ },
184
+ "webhook_deliveries_completed_idx": {
185
+ "name": "webhook_deliveries_completed_idx",
186
+ "columns": [
187
+ {
188
+ "expression": "completed_at",
189
+ "isExpression": false,
190
+ "asc": true,
191
+ "nulls": "last"
192
+ }
193
+ ],
194
+ "isUnique": false,
195
+ "concurrently": false,
196
+ "method": "btree",
197
+ "with": {}
198
+ }
199
+ },
200
+ "foreignKeys": {
201
+ "webhook_deliveries_endpoint_id_webhook_endpoints_id_fk": {
202
+ "name": "webhook_deliveries_endpoint_id_webhook_endpoints_id_fk",
203
+ "tableFrom": "webhook_deliveries",
204
+ "tableTo": "webhook_endpoints",
205
+ "columnsFrom": [
206
+ "endpoint_id"
207
+ ],
208
+ "columnsTo": [
209
+ "id"
210
+ ],
211
+ "onDelete": "cascade",
212
+ "onUpdate": "no action"
213
+ }
214
+ },
215
+ "compositePrimaryKeys": {},
216
+ "uniqueConstraints": {},
217
+ "policies": {},
218
+ "checkConstraints": {},
219
+ "isRLSEnabled": false
220
+ },
221
+ "public.webhook_endpoint_workspaces": {
222
+ "name": "webhook_endpoint_workspaces",
223
+ "schema": "",
224
+ "columns": {
225
+ "endpoint_id": {
226
+ "name": "endpoint_id",
227
+ "type": "uuid",
228
+ "primaryKey": false,
229
+ "notNull": true
230
+ },
231
+ "workspace_id": {
232
+ "name": "workspace_id",
233
+ "type": "uuid",
234
+ "primaryKey": false,
235
+ "notNull": true
236
+ }
237
+ },
238
+ "indexes": {
239
+ "webhook_endpoint_workspaces_workspace_idx": {
240
+ "name": "webhook_endpoint_workspaces_workspace_idx",
241
+ "columns": [
242
+ {
243
+ "expression": "workspace_id",
244
+ "isExpression": false,
245
+ "asc": true,
246
+ "nulls": "last"
247
+ }
248
+ ],
249
+ "isUnique": false,
250
+ "concurrently": false,
251
+ "method": "btree",
252
+ "with": {}
253
+ }
254
+ },
255
+ "foreignKeys": {
256
+ "webhook_endpoint_workspaces_endpoint_id_webhook_endpoints_id_fk": {
257
+ "name": "webhook_endpoint_workspaces_endpoint_id_webhook_endpoints_id_fk",
258
+ "tableFrom": "webhook_endpoint_workspaces",
259
+ "tableTo": "webhook_endpoints",
260
+ "columnsFrom": [
261
+ "endpoint_id"
262
+ ],
263
+ "columnsTo": [
264
+ "id"
265
+ ],
266
+ "onDelete": "cascade",
267
+ "onUpdate": "no action"
268
+ }
269
+ },
270
+ "compositePrimaryKeys": {
271
+ "webhook_endpoint_workspaces_endpoint_id_workspace_id_pk": {
272
+ "name": "webhook_endpoint_workspaces_endpoint_id_workspace_id_pk",
273
+ "columns": [
274
+ "endpoint_id",
275
+ "workspace_id"
276
+ ]
277
+ }
278
+ },
279
+ "uniqueConstraints": {},
280
+ "policies": {},
281
+ "checkConstraints": {},
282
+ "isRLSEnabled": false
283
+ },
284
+ "public.webhook_endpoints": {
285
+ "name": "webhook_endpoints",
286
+ "schema": "",
287
+ "columns": {
288
+ "id": {
289
+ "name": "id",
290
+ "type": "uuid",
291
+ "primaryKey": true,
292
+ "notNull": true,
293
+ "default": "gen_random_uuid()"
294
+ },
295
+ "name": {
296
+ "name": "name",
297
+ "type": "text",
298
+ "primaryKey": false,
299
+ "notNull": true
300
+ },
301
+ "url": {
302
+ "name": "url",
303
+ "type": "text",
304
+ "primaryKey": false,
305
+ "notNull": true
306
+ },
307
+ "secret": {
308
+ "name": "secret",
309
+ "type": "text",
310
+ "primaryKey": false,
311
+ "notNull": true
312
+ },
313
+ "secret_hint": {
314
+ "name": "secret_hint",
315
+ "type": "text",
316
+ "primaryKey": false,
317
+ "notNull": true
318
+ },
319
+ "enabled": {
320
+ "name": "enabled",
321
+ "type": "boolean",
322
+ "primaryKey": false,
323
+ "notNull": true,
324
+ "default": true
325
+ },
326
+ "event_kinds": {
327
+ "name": "event_kinds",
328
+ "type": "jsonb",
329
+ "primaryKey": false,
330
+ "notNull": true,
331
+ "default": "'[]'::jsonb"
332
+ },
333
+ "content_types": {
334
+ "name": "content_types",
335
+ "type": "jsonb",
336
+ "primaryKey": false,
337
+ "notNull": true,
338
+ "default": "'[]'::jsonb"
339
+ },
340
+ "all_workspaces": {
341
+ "name": "all_workspaces",
342
+ "type": "boolean",
343
+ "primaryKey": false,
344
+ "notNull": true,
345
+ "default": false
346
+ },
347
+ "headers": {
348
+ "name": "headers",
349
+ "type": "jsonb",
350
+ "primaryKey": false,
351
+ "notNull": true,
352
+ "default": "'{}'::jsonb"
353
+ },
354
+ "disabled_reason": {
355
+ "name": "disabled_reason",
356
+ "type": "text",
357
+ "primaryKey": false,
358
+ "notNull": false
359
+ },
360
+ "consecutive_failures": {
361
+ "name": "consecutive_failures",
362
+ "type": "integer",
363
+ "primaryKey": false,
364
+ "notNull": true,
365
+ "default": 0
366
+ },
367
+ "created_by": {
368
+ "name": "created_by",
369
+ "type": "uuid",
370
+ "primaryKey": false,
371
+ "notNull": false
372
+ },
373
+ "created_at": {
374
+ "name": "created_at",
375
+ "type": "timestamp with time zone",
376
+ "primaryKey": false,
377
+ "notNull": true,
378
+ "default": "now()"
379
+ },
380
+ "updated_at": {
381
+ "name": "updated_at",
382
+ "type": "timestamp with time zone",
383
+ "primaryKey": false,
384
+ "notNull": true,
385
+ "default": "now()"
386
+ }
387
+ },
388
+ "indexes": {
389
+ "webhook_endpoints_enabled_idx": {
390
+ "name": "webhook_endpoints_enabled_idx",
391
+ "columns": [
392
+ {
393
+ "expression": "enabled",
394
+ "isExpression": false,
395
+ "asc": true,
396
+ "nulls": "last"
397
+ }
398
+ ],
399
+ "isUnique": false,
400
+ "concurrently": false,
401
+ "method": "btree",
402
+ "with": {}
403
+ }
404
+ },
405
+ "foreignKeys": {},
406
+ "compositePrimaryKeys": {},
407
+ "uniqueConstraints": {},
408
+ "policies": {},
409
+ "checkConstraints": {},
410
+ "isRLSEnabled": false
411
+ }
412
+ },
413
+ "enums": {},
414
+ "schemas": {},
415
+ "sequences": {},
416
+ "roles": {},
417
+ "policies": {},
418
+ "views": {},
419
+ "_meta": {
420
+ "columns": {},
421
+ "schemas": {},
422
+ "tables": {}
423
+ }
424
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1788012400196,
9
+ "tag": "0000_init_webhooks",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@orthacms/webhooks-server",
3
+ "version": "0.5.0",
4
+ "description": "@orthacms/webhooks-server — part of Ortha CMS.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/ortha-source/ortha-cms/tree/main/packages/webhooks/server",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ortha-source/ortha-cms.git",
10
+ "directory": "packages/webhooks/server"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/ortha-source/ortha-cms/issues"
14
+ },
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "migrations"
27
+ ],
28
+ "dependencies": {
29
+ "@nestjs/common": "^11.0.0",
30
+ "@nestjs/swagger": "^11.4.6",
31
+ "@orthacms/bootstrap-server": "^0.5.0",
32
+ "@orthacms/database": "^0.5.0",
33
+ "@orthacms/identity-server": "^0.5.0",
34
+ "@orthacms/webhooks-domain": "^0.5.0",
35
+ "@orthacms/workspaces-server": "^0.5.0",
36
+ "class-transformer": "^0.5.1",
37
+ "class-validator": "^0.15.1",
38
+ "drizzle-orm": "^0.45.0",
39
+ "tslib": "^2.3.0",
40
+ "undici": "^7.28.0"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ }
45
+ }