@open-mercato/core 0.6.7-develop.6572.1.3d8e83062f → 0.6.7-develop.6574.1.05dcf72ba8

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 (36) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/dist/generated/entities/gateway_payment_operation/index.js +35 -0
  3. package/dist/generated/entities/gateway_payment_operation/index.js.map +7 -0
  4. package/dist/generated/entities.ids.generated.js +1 -0
  5. package/dist/generated/entities.ids.generated.js.map +2 -2
  6. package/dist/generated/entity-fields-registry.js +18 -0
  7. package/dist/generated/entity-fields-registry.js.map +2 -2
  8. package/dist/modules/payment_gateways/api/cancel/route.js +2 -1
  9. package/dist/modules/payment_gateways/api/cancel/route.js.map +2 -2
  10. package/dist/modules/payment_gateways/api/capture/route.js +2 -1
  11. package/dist/modules/payment_gateways/api/capture/route.js.map +2 -2
  12. package/dist/modules/payment_gateways/api/refund/route.js +2 -1
  13. package/dist/modules/payment_gateways/api/refund/route.js.map +2 -2
  14. package/dist/modules/payment_gateways/data/entities.js +67 -0
  15. package/dist/modules/payment_gateways/data/entities.js.map +2 -2
  16. package/dist/modules/payment_gateways/data/validators.js +6 -3
  17. package/dist/modules/payment_gateways/data/validators.js.map +2 -2
  18. package/dist/modules/payment_gateways/lib/gateway-service.js +145 -111
  19. package/dist/modules/payment_gateways/lib/gateway-service.js.map +2 -2
  20. package/dist/modules/payment_gateways/lib/payment-operation-idempotency.js +183 -0
  21. package/dist/modules/payment_gateways/lib/payment-operation-idempotency.js.map +7 -0
  22. package/dist/modules/payment_gateways/migrations/Migration20260709220735_payment_gateways.js +13 -0
  23. package/dist/modules/payment_gateways/migrations/Migration20260709220735_payment_gateways.js.map +7 -0
  24. package/generated/entities/gateway_payment_operation/index.ts +16 -0
  25. package/generated/entities.ids.generated.ts +1 -0
  26. package/generated/entity-fields-registry.ts +18 -0
  27. package/package.json +7 -7
  28. package/src/modules/payment_gateways/api/cancel/route.ts +1 -0
  29. package/src/modules/payment_gateways/api/capture/route.ts +1 -0
  30. package/src/modules/payment_gateways/api/refund/route.ts +1 -0
  31. package/src/modules/payment_gateways/data/entities.ts +59 -0
  32. package/src/modules/payment_gateways/data/validators.ts +3 -0
  33. package/src/modules/payment_gateways/lib/gateway-service.ts +168 -117
  34. package/src/modules/payment_gateways/lib/payment-operation-idempotency.ts +238 -0
  35. package/src/modules/payment_gateways/migrations/.snapshot-open-mercato.json +331 -1
  36. package/src/modules/payment_gateways/migrations/Migration20260709220735_payment_gateways.ts +12 -0
@@ -4,6 +4,336 @@
4
4
  "public"
5
5
  ],
6
6
  "tables": [
7
+ {
8
+ "name": "gateway_payment_operations",
9
+ "schema": "public",
10
+ "columns": {
11
+ "attempt_count": {
12
+ "name": "attempt_count",
13
+ "type": "int",
14
+ "unsigned": false,
15
+ "autoincrement": false,
16
+ "primary": false,
17
+ "nullable": false,
18
+ "unique": false,
19
+ "length": null,
20
+ "precision": null,
21
+ "scale": null,
22
+ "default": "1",
23
+ "comment": null,
24
+ "collation": null,
25
+ "enumItems": [],
26
+ "mappedType": "integer"
27
+ },
28
+ "attempt_token": {
29
+ "name": "attempt_token",
30
+ "type": "text",
31
+ "unsigned": false,
32
+ "autoincrement": false,
33
+ "primary": false,
34
+ "nullable": false,
35
+ "unique": false,
36
+ "length": null,
37
+ "precision": null,
38
+ "scale": null,
39
+ "default": null,
40
+ "comment": null,
41
+ "collation": null,
42
+ "enumItems": [],
43
+ "mappedType": "text"
44
+ },
45
+ "created_at": {
46
+ "name": "created_at",
47
+ "type": "timestamptz(6)",
48
+ "unsigned": false,
49
+ "autoincrement": false,
50
+ "primary": false,
51
+ "nullable": false,
52
+ "unique": false,
53
+ "length": 6,
54
+ "precision": null,
55
+ "scale": null,
56
+ "default": null,
57
+ "comment": null,
58
+ "collation": null,
59
+ "enumItems": [],
60
+ "mappedType": "datetime"
61
+ },
62
+ "id": {
63
+ "name": "id",
64
+ "type": "uuid",
65
+ "unsigned": false,
66
+ "autoincrement": false,
67
+ "primary": true,
68
+ "nullable": false,
69
+ "unique": false,
70
+ "length": null,
71
+ "precision": null,
72
+ "scale": null,
73
+ "default": "gen_random_uuid()",
74
+ "comment": null,
75
+ "collation": null,
76
+ "enumItems": [],
77
+ "mappedType": "uuid"
78
+ },
79
+ "lease_expires_at": {
80
+ "name": "lease_expires_at",
81
+ "type": "timestamptz(6)",
82
+ "unsigned": false,
83
+ "autoincrement": false,
84
+ "primary": false,
85
+ "nullable": true,
86
+ "unique": false,
87
+ "length": 6,
88
+ "precision": null,
89
+ "scale": null,
90
+ "default": null,
91
+ "comment": null,
92
+ "collation": null,
93
+ "enumItems": [],
94
+ "mappedType": "datetime"
95
+ },
96
+ "operation_id": {
97
+ "name": "operation_id",
98
+ "type": "text",
99
+ "unsigned": false,
100
+ "autoincrement": false,
101
+ "primary": false,
102
+ "nullable": false,
103
+ "unique": true,
104
+ "length": null,
105
+ "precision": null,
106
+ "scale": null,
107
+ "default": null,
108
+ "comment": null,
109
+ "collation": null,
110
+ "enumItems": [],
111
+ "mappedType": "text"
112
+ },
113
+ "operation_type": {
114
+ "name": "operation_type",
115
+ "type": "text",
116
+ "unsigned": false,
117
+ "autoincrement": false,
118
+ "primary": false,
119
+ "nullable": false,
120
+ "unique": false,
121
+ "length": null,
122
+ "precision": null,
123
+ "scale": null,
124
+ "default": null,
125
+ "comment": null,
126
+ "collation": null,
127
+ "enumItems": [],
128
+ "mappedType": "text"
129
+ },
130
+ "organization_id": {
131
+ "name": "organization_id",
132
+ "type": "uuid",
133
+ "unsigned": false,
134
+ "autoincrement": false,
135
+ "primary": false,
136
+ "nullable": false,
137
+ "unique": false,
138
+ "length": null,
139
+ "precision": null,
140
+ "scale": null,
141
+ "default": null,
142
+ "comment": null,
143
+ "collation": null,
144
+ "enumItems": [],
145
+ "mappedType": "uuid"
146
+ },
147
+ "provider_idempotency_key": {
148
+ "name": "provider_idempotency_key",
149
+ "type": "text",
150
+ "unsigned": false,
151
+ "autoincrement": false,
152
+ "primary": false,
153
+ "nullable": false,
154
+ "unique": false,
155
+ "length": null,
156
+ "precision": null,
157
+ "scale": null,
158
+ "default": null,
159
+ "comment": null,
160
+ "collation": null,
161
+ "enumItems": [],
162
+ "mappedType": "text"
163
+ },
164
+ "provider_key": {
165
+ "name": "provider_key",
166
+ "type": "text",
167
+ "unsigned": false,
168
+ "autoincrement": false,
169
+ "primary": false,
170
+ "nullable": false,
171
+ "unique": false,
172
+ "length": null,
173
+ "precision": null,
174
+ "scale": null,
175
+ "default": null,
176
+ "comment": null,
177
+ "collation": null,
178
+ "enumItems": [],
179
+ "mappedType": "text"
180
+ },
181
+ "request_hash": {
182
+ "name": "request_hash",
183
+ "type": "text",
184
+ "unsigned": false,
185
+ "autoincrement": false,
186
+ "primary": false,
187
+ "nullable": false,
188
+ "unique": false,
189
+ "length": null,
190
+ "precision": null,
191
+ "scale": null,
192
+ "default": null,
193
+ "comment": null,
194
+ "collation": null,
195
+ "enumItems": [],
196
+ "mappedType": "text"
197
+ },
198
+ "result": {
199
+ "name": "result",
200
+ "type": "jsonb",
201
+ "unsigned": false,
202
+ "autoincrement": false,
203
+ "primary": false,
204
+ "nullable": true,
205
+ "unique": false,
206
+ "length": null,
207
+ "precision": null,
208
+ "scale": null,
209
+ "default": null,
210
+ "comment": null,
211
+ "collation": null,
212
+ "enumItems": [],
213
+ "mappedType": "json"
214
+ },
215
+ "status": {
216
+ "name": "status",
217
+ "type": "text",
218
+ "unsigned": false,
219
+ "autoincrement": false,
220
+ "primary": false,
221
+ "nullable": false,
222
+ "unique": false,
223
+ "length": null,
224
+ "precision": null,
225
+ "scale": null,
226
+ "default": "'in_progress'",
227
+ "comment": null,
228
+ "collation": null,
229
+ "enumItems": [],
230
+ "mappedType": "text"
231
+ },
232
+ "tenant_id": {
233
+ "name": "tenant_id",
234
+ "type": "uuid",
235
+ "unsigned": false,
236
+ "autoincrement": false,
237
+ "primary": false,
238
+ "nullable": false,
239
+ "unique": false,
240
+ "length": null,
241
+ "precision": null,
242
+ "scale": null,
243
+ "default": null,
244
+ "comment": null,
245
+ "collation": null,
246
+ "enumItems": [],
247
+ "mappedType": "uuid"
248
+ },
249
+ "transaction_id": {
250
+ "name": "transaction_id",
251
+ "type": "uuid",
252
+ "unsigned": false,
253
+ "autoincrement": false,
254
+ "primary": false,
255
+ "nullable": false,
256
+ "unique": false,
257
+ "length": null,
258
+ "precision": null,
259
+ "scale": null,
260
+ "default": null,
261
+ "comment": null,
262
+ "collation": null,
263
+ "enumItems": [],
264
+ "mappedType": "uuid"
265
+ },
266
+ "updated_at": {
267
+ "name": "updated_at",
268
+ "type": "timestamptz(6)",
269
+ "unsigned": false,
270
+ "autoincrement": false,
271
+ "primary": false,
272
+ "nullable": false,
273
+ "unique": false,
274
+ "length": 6,
275
+ "precision": null,
276
+ "scale": null,
277
+ "default": null,
278
+ "comment": null,
279
+ "collation": null,
280
+ "enumItems": [],
281
+ "mappedType": "datetime"
282
+ }
283
+ },
284
+ "indexes": [
285
+ {
286
+ "columnNames": [
287
+ "id"
288
+ ],
289
+ "composite": false,
290
+ "constraint": true,
291
+ "keyName": "gateway_payment_operations_pkey",
292
+ "primary": true,
293
+ "unique": true
294
+ },
295
+ {
296
+ "columnNames": [
297
+ "operation_id",
298
+ "organization_id",
299
+ "tenant_id"
300
+ ],
301
+ "composite": true,
302
+ "constraint": true,
303
+ "keyName": "gateway_payment_operations_scope_operation_unique",
304
+ "primary": false,
305
+ "unique": true
306
+ },
307
+ {
308
+ "columnNames": [
309
+ "status",
310
+ "lease_expires_at"
311
+ ],
312
+ "composite": true,
313
+ "constraint": false,
314
+ "keyName": "gateway_payment_operations_status_lease_expires_at_index",
315
+ "primary": false,
316
+ "unique": false
317
+ },
318
+ {
319
+ "columnNames": [
320
+ "transaction_id",
321
+ "operation_type",
322
+ "organization_id",
323
+ "tenant_id"
324
+ ],
325
+ "composite": true,
326
+ "constraint": false,
327
+ "keyName": "gateway_payment_operations_transaction_id_operatio_615c8_index",
328
+ "primary": false,
329
+ "unique": false
330
+ }
331
+ ],
332
+ "checks": [],
333
+ "triggers": [],
334
+ "foreignKeys": {},
335
+ "comment": null
336
+ },
7
337
  {
8
338
  "name": "gateway_session_initializations",
9
339
  "schema": "public",
@@ -798,4 +1128,4 @@
798
1128
  ],
799
1129
  "views": [],
800
1130
  "nativeEnums": {}
801
- }
1131
+ }
@@ -0,0 +1,12 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+
3
+ export class Migration20260709220735_payment_gateways extends Migration {
4
+
5
+ override up(): void | Promise<void> {
6
+ this.addSql(`create table "gateway_payment_operations" ("id" uuid not null default gen_random_uuid(), "operation_id" text not null, "transaction_id" uuid not null, "operation_type" text not null, "provider_key" text not null, "request_hash" text not null, "provider_idempotency_key" text not null, "status" text not null default 'in_progress', "attempt_token" text not null, "attempt_count" int not null default 1, "result" jsonb null, "lease_expires_at" timestamptz null, "organization_id" uuid not null, "tenant_id" uuid not null, "created_at" timestamptz not null, "updated_at" timestamptz not null, primary key ("id"));`);
7
+ this.addSql(`create index "gateway_payment_operations_status_lease_expires_at_index" on "gateway_payment_operations" ("status", "lease_expires_at");`);
8
+ this.addSql(`create index "gateway_payment_operations_transaction_id_operatio_615c8_index" on "gateway_payment_operations" ("transaction_id", "operation_type", "organization_id", "tenant_id");`);
9
+ this.addSql(`alter table "gateway_payment_operations" add constraint "gateway_payment_operations_scope_operation_unique" unique ("operation_id", "organization_id", "tenant_id");`);
10
+ }
11
+
12
+ }