@open-mercato/core 0.9.1-develop.7468.1.7ea720142b → 0.9.1-develop.7470.1.7d20749e53
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/payment_gateways/migrations/Migration20261009120000_payment_gateways.js +53 -0
- package/dist/modules/payment_gateways/migrations/Migration20261009120000_payment_gateways.js.map +7 -0
- package/package.json +7 -7
- package/src/modules/payment_gateways/migrations/Migration20261009120000_payment_gateways.ts +53 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Migration } from "@mikro-orm/migrations";
|
|
2
|
+
const WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE = "gateway_webhook_events_idempotency_unique";
|
|
3
|
+
class Migration20261009120000_payment_gateways extends Migration {
|
|
4
|
+
async up() {
|
|
5
|
+
this.addSql(`lock table "gateway_webhook_events" in share row exclusive mode;`);
|
|
6
|
+
this.addSql(`
|
|
7
|
+
delete from "gateway_webhook_events" duplicate
|
|
8
|
+
using (
|
|
9
|
+
select
|
|
10
|
+
event."id",
|
|
11
|
+
row_number() over (
|
|
12
|
+
partition by event."idempotency_key", event."provider_key", event."organization_id", event."tenant_id"
|
|
13
|
+
order by event."processed_at" asc, event."id" asc
|
|
14
|
+
) as claim_rank
|
|
15
|
+
from "gateway_webhook_events" event
|
|
16
|
+
) ranked
|
|
17
|
+
where duplicate."id" = ranked."id"
|
|
18
|
+
and ranked.claim_rank > 1;
|
|
19
|
+
`);
|
|
20
|
+
this.addSql(`
|
|
21
|
+
do $$
|
|
22
|
+
begin
|
|
23
|
+
if exists (
|
|
24
|
+
select 1
|
|
25
|
+
from pg_constraint
|
|
26
|
+
where conname = '${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}'
|
|
27
|
+
and conrelid = to_regclass('"gateway_webhook_events"')
|
|
28
|
+
and contype = 'u'
|
|
29
|
+
) then
|
|
30
|
+
return;
|
|
31
|
+
end if;
|
|
32
|
+
drop index if exists "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}";
|
|
33
|
+
alter table "gateway_webhook_events"
|
|
34
|
+
add constraint "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}"
|
|
35
|
+
unique ("idempotency_key", "provider_key", "organization_id", "tenant_id");
|
|
36
|
+
end
|
|
37
|
+
$$;
|
|
38
|
+
`);
|
|
39
|
+
}
|
|
40
|
+
async down() {
|
|
41
|
+
this.addSql(
|
|
42
|
+
`alter table "gateway_webhook_events" drop constraint if exists "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}";`
|
|
43
|
+
);
|
|
44
|
+
this.addSql(
|
|
45
|
+
`create index if not exists "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}" on "gateway_webhook_events" ("idempotency_key", "provider_key", "organization_id", "tenant_id");`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
Migration20261009120000_payment_gateways,
|
|
51
|
+
WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=Migration20261009120000_payment_gateways.js.map
|
package/dist/modules/payment_gateways/migrations/Migration20261009120000_payment_gateways.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/payment_gateways/migrations/Migration20261009120000_payment_gateways.ts"],
|
|
4
|
+
"sourcesContent": ["import { Migration } from '@mikro-orm/migrations'\n\nexport const WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE = 'gateway_webhook_events_idempotency_unique'\n\nexport class Migration20261009120000_payment_gateways extends Migration {\n override async up(): Promise<void> {\n this.addSql(`lock table \"gateway_webhook_events\" in share row exclusive mode;`)\n\n this.addSql(`\n delete from \"gateway_webhook_events\" duplicate\n using (\n select\n event.\"id\",\n row_number() over (\n partition by event.\"idempotency_key\", event.\"provider_key\", event.\"organization_id\", event.\"tenant_id\"\n order by event.\"processed_at\" asc, event.\"id\" asc\n ) as claim_rank\n from \"gateway_webhook_events\" event\n ) ranked\n where duplicate.\"id\" = ranked.\"id\"\n and ranked.claim_rank > 1;\n `)\n\n this.addSql(`\n do $$\n begin\n if exists (\n select 1\n from pg_constraint\n where conname = '${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}'\n and conrelid = to_regclass('\"gateway_webhook_events\"')\n and contype = 'u'\n ) then\n return;\n end if;\n drop index if exists \"${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}\";\n alter table \"gateway_webhook_events\"\n add constraint \"${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}\"\n unique (\"idempotency_key\", \"provider_key\", \"organization_id\", \"tenant_id\");\n end\n $$;\n `)\n }\n\n override async down(): Promise<void> {\n this.addSql(\n `alter table \"gateway_webhook_events\" drop constraint if exists \"${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}\";`,\n )\n this.addSql(\n `create index if not exists \"${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}\" on \"gateway_webhook_events\" (\"idempotency_key\", \"provider_key\", \"organization_id\", \"tenant_id\");`,\n )\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAEnB,MAAM,oCAAoC;AAE1C,MAAM,iDAAiD,UAAU;AAAA,EACtE,MAAe,KAAoB;AACjC,SAAK,OAAO,kEAAkE;AAE9E,SAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KAaX;AAED,SAAK,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAMa,iCAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAM9B,iCAAiC;AAAA;AAAA,4BAErC,iCAAiC;AAAA;AAAA;AAAA;AAAA,KAIxD;AAAA,EACH;AAAA,EAEA,MAAe,OAAsB;AACnC,SAAK;AAAA,MACH,mEAAmE,iCAAiC;AAAA,IACtG;AACA,SAAK;AAAA,MACH,+BAA+B,iCAAiC;AAAA,IAClE;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.9.1-develop.
|
|
3
|
+
"version": "0.9.1-develop.7470.1.7d20749e53",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -264,16 +264,16 @@
|
|
|
264
264
|
"zod": "^4.4.3"
|
|
265
265
|
},
|
|
266
266
|
"peerDependencies": {
|
|
267
|
-
"@open-mercato/ai-assistant": "0.9.1-develop.
|
|
268
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
269
|
-
"@open-mercato/ui": "0.9.1-develop.
|
|
267
|
+
"@open-mercato/ai-assistant": "0.9.1-develop.7470.1.7d20749e53",
|
|
268
|
+
"@open-mercato/shared": "0.9.1-develop.7470.1.7d20749e53",
|
|
269
|
+
"@open-mercato/ui": "0.9.1-develop.7470.1.7d20749e53",
|
|
270
270
|
"react": "^19.0.0",
|
|
271
271
|
"react-dom": "^19.0.0"
|
|
272
272
|
},
|
|
273
273
|
"devDependencies": {
|
|
274
|
-
"@open-mercato/ai-assistant": "0.9.1-develop.
|
|
275
|
-
"@open-mercato/shared": "0.9.1-develop.
|
|
276
|
-
"@open-mercato/ui": "0.9.1-develop.
|
|
274
|
+
"@open-mercato/ai-assistant": "0.9.1-develop.7470.1.7d20749e53",
|
|
275
|
+
"@open-mercato/shared": "0.9.1-develop.7470.1.7d20749e53",
|
|
276
|
+
"@open-mercato/ui": "0.9.1-develop.7470.1.7d20749e53",
|
|
277
277
|
"@testing-library/dom": "^10.4.1",
|
|
278
278
|
"@testing-library/jest-dom": "^7.0.1",
|
|
279
279
|
"@testing-library/react": "^16.3.3",
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Migration } from '@mikro-orm/migrations'
|
|
2
|
+
|
|
3
|
+
export const WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE = 'gateway_webhook_events_idempotency_unique'
|
|
4
|
+
|
|
5
|
+
export class Migration20261009120000_payment_gateways extends Migration {
|
|
6
|
+
override async up(): Promise<void> {
|
|
7
|
+
this.addSql(`lock table "gateway_webhook_events" in share row exclusive mode;`)
|
|
8
|
+
|
|
9
|
+
this.addSql(`
|
|
10
|
+
delete from "gateway_webhook_events" duplicate
|
|
11
|
+
using (
|
|
12
|
+
select
|
|
13
|
+
event."id",
|
|
14
|
+
row_number() over (
|
|
15
|
+
partition by event."idempotency_key", event."provider_key", event."organization_id", event."tenant_id"
|
|
16
|
+
order by event."processed_at" asc, event."id" asc
|
|
17
|
+
) as claim_rank
|
|
18
|
+
from "gateway_webhook_events" event
|
|
19
|
+
) ranked
|
|
20
|
+
where duplicate."id" = ranked."id"
|
|
21
|
+
and ranked.claim_rank > 1;
|
|
22
|
+
`)
|
|
23
|
+
|
|
24
|
+
this.addSql(`
|
|
25
|
+
do $$
|
|
26
|
+
begin
|
|
27
|
+
if exists (
|
|
28
|
+
select 1
|
|
29
|
+
from pg_constraint
|
|
30
|
+
where conname = '${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}'
|
|
31
|
+
and conrelid = to_regclass('"gateway_webhook_events"')
|
|
32
|
+
and contype = 'u'
|
|
33
|
+
) then
|
|
34
|
+
return;
|
|
35
|
+
end if;
|
|
36
|
+
drop index if exists "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}";
|
|
37
|
+
alter table "gateway_webhook_events"
|
|
38
|
+
add constraint "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}"
|
|
39
|
+
unique ("idempotency_key", "provider_key", "organization_id", "tenant_id");
|
|
40
|
+
end
|
|
41
|
+
$$;
|
|
42
|
+
`)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override async down(): Promise<void> {
|
|
46
|
+
this.addSql(
|
|
47
|
+
`alter table "gateway_webhook_events" drop constraint if exists "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}";`,
|
|
48
|
+
)
|
|
49
|
+
this.addSql(
|
|
50
|
+
`create index if not exists "${WEBHOOK_EVENTS_IDEMPOTENCY_UNIQUE}" on "gateway_webhook_events" ("idempotency_key", "provider_key", "organization_id", "tenant_id");`,
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
}
|