@sakeetech/medusa-payment-viva 0.2.2
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/LICENSE +21 -0
- package/README.md +816 -0
- package/dist/api/index.d.ts +15 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +22 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/middlewares.d.ts +27 -0
- package/dist/api/middlewares.d.ts.map +1 -0
- package/dist/api/middlewares.js +62 -0
- package/dist/api/middlewares.js.map +1 -0
- package/dist/api/viva/admin/_admin-auth.d.ts +26 -0
- package/dist/api/viva/admin/_admin-auth.d.ts.map +1 -0
- package/dist/api/viva/admin/_admin-auth.js +49 -0
- package/dist/api/viva/admin/_admin-auth.js.map +1 -0
- package/dist/api/viva/admin/_mode-gate.d.ts +28 -0
- package/dist/api/viva/admin/_mode-gate.d.ts.map +1 -0
- package/dist/api/viva/admin/_mode-gate.js +45 -0
- package/dist/api/viva/admin/_mode-gate.js.map +1 -0
- package/dist/api/viva/admin/connected-accounts/[id]/reconcile/route.d.ts +21 -0
- package/dist/api/viva/admin/connected-accounts/[id]/reconcile/route.d.ts.map +1 -0
- package/dist/api/viva/admin/connected-accounts/[id]/reconcile/route.js +93 -0
- package/dist/api/viva/admin/connected-accounts/[id]/reconcile/route.js.map +1 -0
- package/dist/api/viva/admin/connected-accounts/[id]/route.d.ts +18 -0
- package/dist/api/viva/admin/connected-accounts/[id]/route.d.ts.map +1 -0
- package/dist/api/viva/admin/connected-accounts/[id]/route.js +59 -0
- package/dist/api/viva/admin/connected-accounts/[id]/route.js.map +1 -0
- package/dist/api/viva/admin/connected-accounts/[id]/sources/route.d.ts +34 -0
- package/dist/api/viva/admin/connected-accounts/[id]/sources/route.d.ts.map +1 -0
- package/dist/api/viva/admin/connected-accounts/[id]/sources/route.js +234 -0
- package/dist/api/viva/admin/connected-accounts/[id]/sources/route.js.map +1 -0
- package/dist/api/viva/admin/connected-accounts/route.d.ts +19 -0
- package/dist/api/viva/admin/connected-accounts/route.d.ts.map +1 -0
- package/dist/api/viva/admin/connected-accounts/route.js +78 -0
- package/dist/api/viva/admin/connected-accounts/route.js.map +1 -0
- package/dist/api/viva/internal/auth-status/route.d.ts +19 -0
- package/dist/api/viva/internal/auth-status/route.d.ts.map +1 -0
- package/dist/api/viva/internal/auth-status/route.js +91 -0
- package/dist/api/viva/internal/auth-status/route.js.map +1 -0
- package/dist/api/viva/internal/metrics/route.d.ts +13 -0
- package/dist/api/viva/internal/metrics/route.d.ts.map +1 -0
- package/dist/api/viva/internal/metrics/route.js +48 -0
- package/dist/api/viva/internal/metrics/route.js.map +1 -0
- package/dist/api/viva/webhook/health/route.d.ts +16 -0
- package/dist/api/viva/webhook/health/route.d.ts.map +1 -0
- package/dist/api/viva/webhook/health/route.js +27 -0
- package/dist/api/viva/webhook/health/route.js.map +1 -0
- package/dist/api/viva/webhook/route.d.ts +57 -0
- package/dist/api/viva/webhook/route.d.ts.map +1 -0
- package/dist/api/viva/webhook/route.js +269 -0
- package/dist/api/viva/webhook/route.js.map +1 -0
- package/dist/cli/bin.d.ts +12 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +78 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +14 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/plan.d.ts +51 -0
- package/dist/cli/plan.d.ts.map +1 -0
- package/dist/cli/plan.js +128 -0
- package/dist/cli/plan.js.map +1 -0
- package/dist/cli/register-webhooks.d.ts +54 -0
- package/dist/cli/register-webhooks.d.ts.map +1 -0
- package/dist/cli/register-webhooks.js +366 -0
- package/dist/cli/register-webhooks.js.map +1 -0
- package/dist/cli/types.d.ts +62 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +12 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config.d.ts +158 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +236 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/loaders/viva-oauth2-strategy.d.ts +26 -0
- package/dist/loaders/viva-oauth2-strategy.d.ts.map +1 -0
- package/dist/loaders/viva-oauth2-strategy.js +58 -0
- package/dist/loaders/viva-oauth2-strategy.js.map +1 -0
- package/dist/migrations/Migration_20260425000001_init_viva_payments.d.ts +19 -0
- package/dist/migrations/Migration_20260425000001_init_viva_payments.d.ts.map +1 -0
- package/dist/migrations/Migration_20260425000001_init_viva_payments.js +136 -0
- package/dist/migrations/Migration_20260425000001_init_viva_payments.js.map +1 -0
- package/dist/migrations/Migration_20260425000002_allow_null_order_code.d.ts +31 -0
- package/dist/migrations/Migration_20260425000002_allow_null_order_code.d.ts.map +1 -0
- package/dist/migrations/Migration_20260425000002_allow_null_order_code.js +71 -0
- package/dist/migrations/Migration_20260425000002_allow_null_order_code.js.map +1 -0
- package/dist/migrations/Migration_20260425000003_webhook_retry_count.d.ts +18 -0
- package/dist/migrations/Migration_20260425000003_webhook_retry_count.d.ts.map +1 -0
- package/dist/migrations/Migration_20260425000003_webhook_retry_count.js +42 -0
- package/dist/migrations/Migration_20260425000003_webhook_retry_count.js.map +1 -0
- package/dist/migrations/Migration_20260425000004_webhook_error_and_nullable_merchant.d.ts +29 -0
- package/dist/migrations/Migration_20260425000004_webhook_error_and_nullable_merchant.d.ts.map +1 -0
- package/dist/migrations/Migration_20260425000004_webhook_error_and_nullable_merchant.js +74 -0
- package/dist/migrations/Migration_20260425000004_webhook_error_and_nullable_merchant.js.map +1 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +10 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/viva-tenant-merchant.d.ts +11 -0
- package/dist/models/viva-tenant-merchant.d.ts.map +1 -0
- package/dist/models/viva-tenant-merchant.js +54 -0
- package/dist/models/viva-tenant-merchant.js.map +1 -0
- package/dist/models/viva-transaction.d.ts +34 -0
- package/dist/models/viva-transaction.d.ts.map +1 -0
- package/dist/models/viva-transaction.js +104 -0
- package/dist/models/viva-transaction.js.map +1 -0
- package/dist/models/viva-webhook-event.d.ts +32 -0
- package/dist/models/viva-webhook-event.d.ts.map +1 -0
- package/dist/models/viva-webhook-event.js +88 -0
- package/dist/models/viva-webhook-event.js.map +1 -0
- package/dist/observability/config.d.ts +34 -0
- package/dist/observability/config.d.ts.map +1 -0
- package/dist/observability/config.js +57 -0
- package/dist/observability/config.js.map +1 -0
- package/dist/observability/index.d.ts +8 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +15 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/prom-metrics.d.ts +41 -0
- package/dist/observability/prom-metrics.d.ts.map +1 -0
- package/dist/observability/prom-metrics.js +219 -0
- package/dist/observability/prom-metrics.js.map +1 -0
- package/dist/providers/payment-provider.d.ts +19 -0
- package/dist/providers/payment-provider.d.ts.map +1 -0
- package/dist/providers/payment-provider.js +24 -0
- package/dist/providers/payment-provider.js.map +1 -0
- package/dist/resolvers/auth-strategy-factory.d.ts +42 -0
- package/dist/resolvers/auth-strategy-factory.d.ts.map +1 -0
- package/dist/resolvers/auth-strategy-factory.js +60 -0
- package/dist/resolvers/auth-strategy-factory.js.map +1 -0
- package/dist/resolvers/tenant-resolver.d.ts +104 -0
- package/dist/resolvers/tenant-resolver.d.ts.map +1 -0
- package/dist/resolvers/tenant-resolver.js +118 -0
- package/dist/resolvers/tenant-resolver.js.map +1 -0
- package/dist/service.d.ts +200 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +1003 -0
- package/dist/service.js.map +1 -0
- package/dist/subscribers/index.d.ts +5 -0
- package/dist/subscribers/index.d.ts.map +1 -0
- package/dist/subscribers/index.js +10 -0
- package/dist/subscribers/index.js.map +1 -0
- package/dist/subscribers/viva-webhook-event.d.ts +38 -0
- package/dist/subscribers/viva-webhook-event.d.ts.map +1 -0
- package/dist/subscribers/viva-webhook-event.js +133 -0
- package/dist/subscribers/viva-webhook-event.js.map +1 -0
- package/dist/workflows/cleanup-old-webhook-events.d.ts +39 -0
- package/dist/workflows/cleanup-old-webhook-events.d.ts.map +1 -0
- package/dist/workflows/cleanup-old-webhook-events.js +68 -0
- package/dist/workflows/cleanup-old-webhook-events.js.map +1 -0
- package/dist/workflows/index.d.ts +14 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +19 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/per-tenant-semaphore.d.ts +47 -0
- package/dist/workflows/per-tenant-semaphore.d.ts.map +1 -0
- package/dist/workflows/per-tenant-semaphore.js +89 -0
- package/dist/workflows/per-tenant-semaphore.js.map +1 -0
- package/dist/workflows/process-webhook-event.d.ts +80 -0
- package/dist/workflows/process-webhook-event.d.ts.map +1 -0
- package/dist/workflows/process-webhook-event.js +280 -0
- package/dist/workflows/process-webhook-event.js.map +1 -0
- package/dist/workflows/reprocess-unresolved-tenants.d.ts +58 -0
- package/dist/workflows/reprocess-unresolved-tenants.d.ts.map +1 -0
- package/dist/workflows/reprocess-unresolved-tenants.js +121 -0
- package/dist/workflows/reprocess-unresolved-tenants.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration_20260425000001_init_viva_payments = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
/**
|
|
6
|
+
* S7 — initial migration: creates all three plugin-owned tables atomically.
|
|
7
|
+
*
|
|
8
|
+
* up() — CREATE TABLE IF NOT EXISTS + indexes (idempotent).
|
|
9
|
+
* down() — Attempts COPY of viva_webhook_event raw_payload to /tmp before drop
|
|
10
|
+
* for forensic preservation per plan line 205.
|
|
11
|
+
* NOTE: COPY TO file requires the postgres superuser role. If the
|
|
12
|
+
* migration runner connects as a non-superuser, this COPY will fail.
|
|
13
|
+
* In that case, wrap the COPY in a DO block that catches the error and
|
|
14
|
+
* logs a notice — data preservation is best-effort in non-superuser
|
|
15
|
+
* deployments. Operators should take a pg_dump backup before running
|
|
16
|
+
* down() in production.
|
|
17
|
+
*/
|
|
18
|
+
class Migration_20260425000001_init_viva_payments extends migrations_1.Migration {
|
|
19
|
+
async up() {
|
|
20
|
+
// Require gen_random_uuid() for viva_webhook_event PK default.
|
|
21
|
+
this.addSql(`CREATE EXTENSION IF NOT EXISTS pgcrypto;`);
|
|
22
|
+
// ------------------------------------------------------------------ --
|
|
23
|
+
// Table: viva_tenant_merchant
|
|
24
|
+
// ------------------------------------------------------------------ --
|
|
25
|
+
this.addSql(`
|
|
26
|
+
CREATE TABLE IF NOT EXISTS viva_tenant_merchant (
|
|
27
|
+
tenant_id text PRIMARY KEY,
|
|
28
|
+
connected_account_id uuid NOT NULL,
|
|
29
|
+
viva_merchant_id uuid NOT NULL,
|
|
30
|
+
verification_status text NOT NULL DEFAULT 'pending',
|
|
31
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
32
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
33
|
+
);
|
|
34
|
+
`);
|
|
35
|
+
this.addSql(`
|
|
36
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_tenant_merchant_viva_merchant_id_uniq
|
|
37
|
+
ON viva_tenant_merchant (viva_merchant_id);
|
|
38
|
+
`);
|
|
39
|
+
this.addSql(`
|
|
40
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_tenant_merchant_connected_account_id_uniq
|
|
41
|
+
ON viva_tenant_merchant (connected_account_id);
|
|
42
|
+
`);
|
|
43
|
+
// ------------------------------------------------------------------ --
|
|
44
|
+
// Table: viva_transaction
|
|
45
|
+
// ------------------------------------------------------------------ --
|
|
46
|
+
this.addSql(`
|
|
47
|
+
CREATE TABLE IF NOT EXISTS viva_transaction (
|
|
48
|
+
viva_transaction_id uuid PRIMARY KEY,
|
|
49
|
+
viva_order_code bigint NOT NULL,
|
|
50
|
+
medusa_payment_id text NOT NULL,
|
|
51
|
+
viva_merchant_id uuid NOT NULL,
|
|
52
|
+
status text NOT NULL CHECK (status IN (
|
|
53
|
+
'initiated','authorized','captured','refunded','cancelled','failed','disputed'
|
|
54
|
+
)),
|
|
55
|
+
claim_substate text,
|
|
56
|
+
amount_minor bigint NOT NULL,
|
|
57
|
+
refunded_amount_minor bigint NOT NULL DEFAULT 0,
|
|
58
|
+
currency_code text NOT NULL,
|
|
59
|
+
idempotency_key text NOT NULL,
|
|
60
|
+
raw_payload jsonb,
|
|
61
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
62
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
63
|
+
);
|
|
64
|
+
`);
|
|
65
|
+
this.addSql(`
|
|
66
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_transaction_idempotency_key_uniq
|
|
67
|
+
ON viva_transaction (idempotency_key);
|
|
68
|
+
`);
|
|
69
|
+
this.addSql(`
|
|
70
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_transaction_viva_order_code_uniq
|
|
71
|
+
ON viva_transaction (viva_order_code);
|
|
72
|
+
`);
|
|
73
|
+
this.addSql(`
|
|
74
|
+
CREATE INDEX IF NOT EXISTS viva_transaction_medusa_payment_id_idx
|
|
75
|
+
ON viva_transaction (medusa_payment_id);
|
|
76
|
+
`);
|
|
77
|
+
this.addSql(`
|
|
78
|
+
CREATE INDEX IF NOT EXISTS viva_transaction_merchant_created_idx
|
|
79
|
+
ON viva_transaction (viva_merchant_id, created_at);
|
|
80
|
+
`);
|
|
81
|
+
// ------------------------------------------------------------------ --
|
|
82
|
+
// Table: viva_webhook_event
|
|
83
|
+
// ------------------------------------------------------------------ --
|
|
84
|
+
this.addSql(`
|
|
85
|
+
CREATE TABLE IF NOT EXISTS viva_webhook_event (
|
|
86
|
+
viva_webhook_event_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
87
|
+
transaction_id uuid,
|
|
88
|
+
event_type_id int NOT NULL,
|
|
89
|
+
message_id uuid NOT NULL,
|
|
90
|
+
viva_merchant_id uuid,
|
|
91
|
+
connected_account_id uuid,
|
|
92
|
+
processed_at timestamptz,
|
|
93
|
+
raw_payload jsonb NOT NULL,
|
|
94
|
+
received_at timestamptz NOT NULL DEFAULT now()
|
|
95
|
+
);
|
|
96
|
+
`);
|
|
97
|
+
// Partial unique: one event_type_id per transaction (dedup), only when
|
|
98
|
+
// transaction_id IS NOT NULL (onboarding events have NULL transaction_id).
|
|
99
|
+
this.addSql(`
|
|
100
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_webhook_event_txn_type_uniq
|
|
101
|
+
ON viva_webhook_event (transaction_id, event_type_id)
|
|
102
|
+
WHERE transaction_id IS NOT NULL;
|
|
103
|
+
`);
|
|
104
|
+
this.addSql(`
|
|
105
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_webhook_event_message_id_uniq
|
|
106
|
+
ON viva_webhook_event (message_id);
|
|
107
|
+
`);
|
|
108
|
+
this.addSql(`
|
|
109
|
+
CREATE INDEX IF NOT EXISTS viva_webhook_event_type_received_idx
|
|
110
|
+
ON viva_webhook_event (event_type_id, received_at);
|
|
111
|
+
`);
|
|
112
|
+
}
|
|
113
|
+
async down() {
|
|
114
|
+
// Best-effort: export raw_payload rows to /tmp before drop.
|
|
115
|
+
// COPY TO requires pg superuser. Wrapped in a DO block so non-superuser
|
|
116
|
+
// deployments degrade gracefully (notice logged, drop proceeds).
|
|
117
|
+
// TODO(ops): run pg_dump before down() in production.
|
|
118
|
+
const exportTs = new Date().toISOString().replace(/[^0-9]/g, "").slice(0, 14);
|
|
119
|
+
this.addSql(`
|
|
120
|
+
DO $$
|
|
121
|
+
BEGIN
|
|
122
|
+
COPY (SELECT * FROM viva_webhook_event)
|
|
123
|
+
TO '/tmp/viva_webhook_event_${exportTs}.json';
|
|
124
|
+
RAISE NOTICE 'viva_webhook_event exported to /tmp/viva_webhook_event_${exportTs}.json';
|
|
125
|
+
EXCEPTION WHEN insufficient_privilege THEN
|
|
126
|
+
RAISE NOTICE 'COPY skipped (insufficient privilege) — backup viva_webhook_event manually before drop.';
|
|
127
|
+
END;
|
|
128
|
+
$$;
|
|
129
|
+
`);
|
|
130
|
+
this.addSql(`DROP TABLE IF EXISTS viva_webhook_event;`);
|
|
131
|
+
this.addSql(`DROP TABLE IF EXISTS viva_transaction;`);
|
|
132
|
+
this.addSql(`DROP TABLE IF EXISTS viva_tenant_merchant;`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.Migration_20260425000001_init_viva_payments = Migration_20260425000001_init_viva_payments;
|
|
136
|
+
//# sourceMappingURL=Migration_20260425000001_init_viva_payments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000001_init_viva_payments.js","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000001_init_viva_payments.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE;;;;;;;;;;;;GAYG;AACH,MAAa,2CAA4C,SAAQ,sBAAS;IAC/D,KAAK,CAAC,EAAE;QACf,+DAA+D;QAC/D,IAAI,CAAC,MAAM,CACT,0CAA0C,CAC3C,CAAC;QAEF,wEAAwE;QACxE,8BAA8B;QAC9B,wEAAwE;QACxE,IAAI,CAAC,MAAM,CAAC;;;;;;;;;KASX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,wEAAwE;QACxE,0BAA0B;QAC1B,wEAAwE;QACxE,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;KAkBX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,wEAAwE;QACxE,4BAA4B;QAC5B,wEAAwE;QACxE,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;KAYX,CAAC,CAAC;QAEH,uEAAuE;QACvE,2EAA2E;QAC3E,IAAI,CAAC,MAAM,CAAC;;;;KAIX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,4DAA4D;QAC5D,wEAAwE;QACxE,iEAAiE;QACjE,sDAAsD;QACtD,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,MAAM,CAAC;;;;wCAIwB,QAAQ;+EAC+B,QAAQ;;;;;KAKlF,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,0CAA0C,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;CACF;AApID,kGAoIC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Migration } from "@medusajs/framework/mikro-orm/migrations";
|
|
2
|
+
/**
|
|
3
|
+
* Migration_20260425000002_allow_null_order_code
|
|
4
|
+
*
|
|
5
|
+
* Write-pending-first (A4): makes viva_transaction.viva_order_code nullable
|
|
6
|
+
* so the plugin can INSERT a pending row BEFORE calling Viva's createOrder API.
|
|
7
|
+
*
|
|
8
|
+
* Rationale: the A4 amendment requires that a local DB record exists before any
|
|
9
|
+
* outbound HTTP call. If createOrder fails after INSERT, the row stays at
|
|
10
|
+
* status='initiated' with viva_order_code=NULL. A reaper job (S10/S11) will
|
|
11
|
+
* retry or expire these stuck rows. The alternative (NOT NULL DEFAULT 0) would
|
|
12
|
+
* require app-level enforcement that 0 means "not yet assigned", which is
|
|
13
|
+
* error-prone and not semantically clean.
|
|
14
|
+
*
|
|
15
|
+
* Decision: chose nullable over DEFAULT 0 because NULL is semantically honest —
|
|
16
|
+
* an absent order code is not the same as order code 0.
|
|
17
|
+
*
|
|
18
|
+
* The UNIQUE index on viva_order_code uses a partial index (WHERE viva_order_code
|
|
19
|
+
* IS NOT NULL) to allow multiple NULL rows without violating the constraint.
|
|
20
|
+
* Multiple in-flight pending rows (each with NULL order_code) are valid as long
|
|
21
|
+
* as their idempotency_key is unique — the idempotency_key UNIQUE index covers
|
|
22
|
+
* the dedup requirement.
|
|
23
|
+
*
|
|
24
|
+
* up(): ALTER COLUMN → nullable; recreate unique index as partial.
|
|
25
|
+
* down(): backfill NULLs to 0; ALTER COLUMN → NOT NULL.
|
|
26
|
+
*/
|
|
27
|
+
export declare class Migration_20260425000002_allow_null_order_code extends Migration {
|
|
28
|
+
up(): Promise<void>;
|
|
29
|
+
down(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=Migration_20260425000002_allow_null_order_code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000002_allow_null_order_code.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000002_allow_null_order_code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,8CAA+C,SAAQ,SAAS;IAC5D,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAwBrC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration_20260425000002_allow_null_order_code = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
/**
|
|
6
|
+
* Migration_20260425000002_allow_null_order_code
|
|
7
|
+
*
|
|
8
|
+
* Write-pending-first (A4): makes viva_transaction.viva_order_code nullable
|
|
9
|
+
* so the plugin can INSERT a pending row BEFORE calling Viva's createOrder API.
|
|
10
|
+
*
|
|
11
|
+
* Rationale: the A4 amendment requires that a local DB record exists before any
|
|
12
|
+
* outbound HTTP call. If createOrder fails after INSERT, the row stays at
|
|
13
|
+
* status='initiated' with viva_order_code=NULL. A reaper job (S10/S11) will
|
|
14
|
+
* retry or expire these stuck rows. The alternative (NOT NULL DEFAULT 0) would
|
|
15
|
+
* require app-level enforcement that 0 means "not yet assigned", which is
|
|
16
|
+
* error-prone and not semantically clean.
|
|
17
|
+
*
|
|
18
|
+
* Decision: chose nullable over DEFAULT 0 because NULL is semantically honest —
|
|
19
|
+
* an absent order code is not the same as order code 0.
|
|
20
|
+
*
|
|
21
|
+
* The UNIQUE index on viva_order_code uses a partial index (WHERE viva_order_code
|
|
22
|
+
* IS NOT NULL) to allow multiple NULL rows without violating the constraint.
|
|
23
|
+
* Multiple in-flight pending rows (each with NULL order_code) are valid as long
|
|
24
|
+
* as their idempotency_key is unique — the idempotency_key UNIQUE index covers
|
|
25
|
+
* the dedup requirement.
|
|
26
|
+
*
|
|
27
|
+
* up(): ALTER COLUMN → nullable; recreate unique index as partial.
|
|
28
|
+
* down(): backfill NULLs to 0; ALTER COLUMN → NOT NULL.
|
|
29
|
+
*/
|
|
30
|
+
class Migration_20260425000002_allow_null_order_code extends migrations_1.Migration {
|
|
31
|
+
async up() {
|
|
32
|
+
// 1. Drop the existing non-partial unique index on viva_order_code
|
|
33
|
+
this.addSql(`
|
|
34
|
+
DROP INDEX IF EXISTS viva_transaction_viva_order_code_uniq;
|
|
35
|
+
`);
|
|
36
|
+
// 2. Make viva_order_code nullable
|
|
37
|
+
this.addSql(`
|
|
38
|
+
ALTER TABLE viva_transaction
|
|
39
|
+
ALTER COLUMN viva_order_code DROP NOT NULL;
|
|
40
|
+
`);
|
|
41
|
+
// 3. Recreate as partial unique index (NULL values are excluded)
|
|
42
|
+
this.addSql(`
|
|
43
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_transaction_viva_order_code_uniq
|
|
44
|
+
ON viva_transaction (viva_order_code)
|
|
45
|
+
WHERE viva_order_code IS NOT NULL;
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
async down() {
|
|
49
|
+
// Backfill any NULL viva_order_code rows to 0 before restoring NOT NULL.
|
|
50
|
+
// 0 is not a valid Viva order code, so operators can identify affected rows.
|
|
51
|
+
this.addSql(`
|
|
52
|
+
UPDATE viva_transaction SET viva_order_code = 0 WHERE viva_order_code IS NULL;
|
|
53
|
+
`);
|
|
54
|
+
// Drop partial unique index
|
|
55
|
+
this.addSql(`
|
|
56
|
+
DROP INDEX IF EXISTS viva_transaction_viva_order_code_uniq;
|
|
57
|
+
`);
|
|
58
|
+
// Restore NOT NULL constraint
|
|
59
|
+
this.addSql(`
|
|
60
|
+
ALTER TABLE viva_transaction
|
|
61
|
+
ALTER COLUMN viva_order_code SET NOT NULL;
|
|
62
|
+
`);
|
|
63
|
+
// Recreate original non-partial unique index
|
|
64
|
+
this.addSql(`
|
|
65
|
+
CREATE UNIQUE INDEX IF NOT EXISTS viva_transaction_viva_order_code_uniq
|
|
66
|
+
ON viva_transaction (viva_order_code);
|
|
67
|
+
`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.Migration_20260425000002_allow_null_order_code = Migration_20260425000002_allow_null_order_code;
|
|
71
|
+
//# sourceMappingURL=Migration_20260425000002_allow_null_order_code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000002_allow_null_order_code.js","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000002_allow_null_order_code.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,8CAA+C,SAAQ,sBAAS;IAClE,KAAK,CAAC,EAAE;QACf,mEAAmE;QACnE,IAAI,CAAC,MAAM,CAAC;;KAEX,CAAC,CAAC;QAEH,mCAAmC;QACnC,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,iEAAiE;QACjE,IAAI,CAAC,MAAM,CAAC;;;;KAIX,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,yEAAyE;QACzE,6EAA6E;QAC7E,IAAI,CAAC,MAAM,CAAC;;KAEX,CAAC,CAAC;QAEH,4BAA4B;QAC5B,IAAI,CAAC,MAAM,CAAC;;KAEX,CAAC,CAAC;QAEH,8BAA8B;QAC9B,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,6CAA6C;QAC7C,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;CACF;AA7CD,wGA6CC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Migration } from "@medusajs/framework/mikro-orm/migrations";
|
|
2
|
+
/**
|
|
3
|
+
* Migration_20260425000003_webhook_retry_count
|
|
4
|
+
*
|
|
5
|
+
* A6: adds `retry_count int NOT NULL DEFAULT 0` to `viva_webhook_event`.
|
|
6
|
+
* Required by `reprocessUnresolvedTenants` to track how many times tenant
|
|
7
|
+
* resolution has been attempted for unresolved webhook events.
|
|
8
|
+
*
|
|
9
|
+
* up(): ADD COLUMN retry_count int NOT NULL DEFAULT 0.
|
|
10
|
+
* down(): DROP COLUMN retry_count.
|
|
11
|
+
*
|
|
12
|
+
* @see references/viva-docs/md/isv-partner-program.txt:61 (A6 tenant fallback + reprocess)
|
|
13
|
+
*/
|
|
14
|
+
export declare class Migration_20260425000003_webhook_retry_count extends Migration {
|
|
15
|
+
up(): Promise<void>;
|
|
16
|
+
down(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Migration_20260425000003_webhook_retry_count.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000003_webhook_retry_count.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000003_webhook_retry_count.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE;;;;;;;;;;;GAWG;AACH,qBAAa,4CAA6C,SAAQ,SAAS;IAC1D,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAenB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAUrC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration_20260425000003_webhook_retry_count = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
/**
|
|
6
|
+
* Migration_20260425000003_webhook_retry_count
|
|
7
|
+
*
|
|
8
|
+
* A6: adds `retry_count int NOT NULL DEFAULT 0` to `viva_webhook_event`.
|
|
9
|
+
* Required by `reprocessUnresolvedTenants` to track how many times tenant
|
|
10
|
+
* resolution has been attempted for unresolved webhook events.
|
|
11
|
+
*
|
|
12
|
+
* up(): ADD COLUMN retry_count int NOT NULL DEFAULT 0.
|
|
13
|
+
* down(): DROP COLUMN retry_count.
|
|
14
|
+
*
|
|
15
|
+
* @see references/viva-docs/md/isv-partner-program.txt:61 (A6 tenant fallback + reprocess)
|
|
16
|
+
*/
|
|
17
|
+
class Migration_20260425000003_webhook_retry_count extends migrations_1.Migration {
|
|
18
|
+
async up() {
|
|
19
|
+
this.addSql(`
|
|
20
|
+
ALTER TABLE viva_webhook_event
|
|
21
|
+
ADD COLUMN IF NOT EXISTS retry_count int NOT NULL DEFAULT 0;
|
|
22
|
+
`);
|
|
23
|
+
// Index to make the reprocess query efficient:
|
|
24
|
+
// SELECT ... WHERE processed_at IS NULL AND received_at < ... AND retry_count < ...
|
|
25
|
+
this.addSql(`
|
|
26
|
+
CREATE INDEX IF NOT EXISTS viva_webhook_event_unresolved_retry_idx
|
|
27
|
+
ON viva_webhook_event (received_at, retry_count)
|
|
28
|
+
WHERE processed_at IS NULL;
|
|
29
|
+
`);
|
|
30
|
+
}
|
|
31
|
+
async down() {
|
|
32
|
+
this.addSql(`
|
|
33
|
+
DROP INDEX IF EXISTS viva_webhook_event_unresolved_retry_idx;
|
|
34
|
+
`);
|
|
35
|
+
this.addSql(`
|
|
36
|
+
ALTER TABLE viva_webhook_event
|
|
37
|
+
DROP COLUMN IF EXISTS retry_count;
|
|
38
|
+
`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Migration_20260425000003_webhook_retry_count = Migration_20260425000003_webhook_retry_count;
|
|
42
|
+
//# sourceMappingURL=Migration_20260425000003_webhook_retry_count.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000003_webhook_retry_count.js","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000003_webhook_retry_count.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE;;;;;;;;;;;GAWG;AACH,MAAa,4CAA6C,SAAQ,sBAAS;IAChE,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,+CAA+C;QAC/C,oFAAoF;QACpF,IAAI,CAAC,MAAM,CAAC;;;;KAIX,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC;;KAEX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;CACF;AA1BD,oGA0BC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Migration } from "@medusajs/framework/mikro-orm/migrations";
|
|
2
|
+
/**
|
|
3
|
+
* Migration_20260425000004_webhook_error_and_nullable_merchant
|
|
4
|
+
*
|
|
5
|
+
* Phase 2 slice D — unifies the Medusa schema with Vendure for multi-mode v0.2.0.
|
|
6
|
+
*
|
|
7
|
+
* 1. viva_webhook_event.error (text, nullable) — last failure envelope (JSON);
|
|
8
|
+
* operator playbook in docs/ERRORS.md §6 reads this column to diagnose
|
|
9
|
+
* stuck payments. Vendure already has it.
|
|
10
|
+
* 2. viva_transaction.viva_merchant_id — drop NOT NULL. Merchant-mode rows
|
|
11
|
+
* don't have a per-cart merchant id (the plugin operates a single account).
|
|
12
|
+
*
|
|
13
|
+
* Forward-safe:
|
|
14
|
+
* - Existing viva_webhook_event rows get error=NULL (no backfill needed).
|
|
15
|
+
* - viva_transaction.viva_merchant_id stays populated for existing rows.
|
|
16
|
+
*
|
|
17
|
+
* Reversible:
|
|
18
|
+
* - down() drops the error column. The viva_merchant_id NOT NULL constraint
|
|
19
|
+
* is restored ONLY if no rows currently have NULL — otherwise the migration
|
|
20
|
+
* aborts with a clear error so the operator can backfill before retry.
|
|
21
|
+
*
|
|
22
|
+
* @see docs/plans/multi-mode-v0.md §9.6.5 (schema migration spec)
|
|
23
|
+
* @see docs/ERRORS.md §6 (operator playbook requires `error` column)
|
|
24
|
+
*/
|
|
25
|
+
export declare class Migration_20260425000004_webhook_error_and_nullable_merchant extends Migration {
|
|
26
|
+
up(): Promise<void>;
|
|
27
|
+
down(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Migration_20260425000004_webhook_error_and_nullable_merchant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000004_webhook_error_and_nullable_merchant.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000004_webhook_error_and_nullable_merchant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,4DAA6D,SAAQ,SAAS;IAC1E,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAcnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAiCrC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration_20260425000004_webhook_error_and_nullable_merchant = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
/**
|
|
6
|
+
* Migration_20260425000004_webhook_error_and_nullable_merchant
|
|
7
|
+
*
|
|
8
|
+
* Phase 2 slice D — unifies the Medusa schema with Vendure for multi-mode v0.2.0.
|
|
9
|
+
*
|
|
10
|
+
* 1. viva_webhook_event.error (text, nullable) — last failure envelope (JSON);
|
|
11
|
+
* operator playbook in docs/ERRORS.md §6 reads this column to diagnose
|
|
12
|
+
* stuck payments. Vendure already has it.
|
|
13
|
+
* 2. viva_transaction.viva_merchant_id — drop NOT NULL. Merchant-mode rows
|
|
14
|
+
* don't have a per-cart merchant id (the plugin operates a single account).
|
|
15
|
+
*
|
|
16
|
+
* Forward-safe:
|
|
17
|
+
* - Existing viva_webhook_event rows get error=NULL (no backfill needed).
|
|
18
|
+
* - viva_transaction.viva_merchant_id stays populated for existing rows.
|
|
19
|
+
*
|
|
20
|
+
* Reversible:
|
|
21
|
+
* - down() drops the error column. The viva_merchant_id NOT NULL constraint
|
|
22
|
+
* is restored ONLY if no rows currently have NULL — otherwise the migration
|
|
23
|
+
* aborts with a clear error so the operator can backfill before retry.
|
|
24
|
+
*
|
|
25
|
+
* @see docs/plans/multi-mode-v0.md §9.6.5 (schema migration spec)
|
|
26
|
+
* @see docs/ERRORS.md §6 (operator playbook requires `error` column)
|
|
27
|
+
*/
|
|
28
|
+
class Migration_20260425000004_webhook_error_and_nullable_merchant extends migrations_1.Migration {
|
|
29
|
+
async up() {
|
|
30
|
+
// ---- viva_webhook_event.error (nullable text) ----
|
|
31
|
+
this.addSql(`
|
|
32
|
+
ALTER TABLE viva_webhook_event
|
|
33
|
+
ADD COLUMN IF NOT EXISTS error text;
|
|
34
|
+
`);
|
|
35
|
+
// ---- viva_transaction.viva_merchant_id → nullable ----
|
|
36
|
+
this.addSql(`
|
|
37
|
+
ALTER TABLE viva_transaction
|
|
38
|
+
ALTER COLUMN viva_merchant_id DROP NOT NULL;
|
|
39
|
+
`);
|
|
40
|
+
}
|
|
41
|
+
async down() {
|
|
42
|
+
// Drop the error column (data loss for any recorded failures — log it).
|
|
43
|
+
this.addSql(`
|
|
44
|
+
ALTER TABLE viva_webhook_event
|
|
45
|
+
DROP COLUMN IF EXISTS error;
|
|
46
|
+
`);
|
|
47
|
+
// Restore NOT NULL on viva_merchant_id. Guard against NULL rows: if any
|
|
48
|
+
// exist (merchant-mode rows from v0.2.0+), the migration aborts cleanly.
|
|
49
|
+
// Operators must backfill or delete those rows before downgrading.
|
|
50
|
+
this.addSql(`
|
|
51
|
+
DO $$
|
|
52
|
+
DECLARE
|
|
53
|
+
null_count int;
|
|
54
|
+
BEGIN
|
|
55
|
+
SELECT count(*) INTO null_count
|
|
56
|
+
FROM viva_transaction
|
|
57
|
+
WHERE viva_merchant_id IS NULL;
|
|
58
|
+
IF null_count > 0 THEN
|
|
59
|
+
RAISE EXCEPTION
|
|
60
|
+
'Cannot restore NOT NULL on viva_transaction.viva_merchant_id: % rows have NULL. '
|
|
61
|
+
'Backfill or delete those rows (merchant-mode rows from v0.2.0+) before downgrading.',
|
|
62
|
+
null_count;
|
|
63
|
+
END IF;
|
|
64
|
+
END;
|
|
65
|
+
$$;
|
|
66
|
+
`);
|
|
67
|
+
this.addSql(`
|
|
68
|
+
ALTER TABLE viva_transaction
|
|
69
|
+
ALTER COLUMN viva_merchant_id SET NOT NULL;
|
|
70
|
+
`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Migration_20260425000004_webhook_error_and_nullable_merchant = Migration_20260425000004_webhook_error_and_nullable_merchant;
|
|
74
|
+
//# sourceMappingURL=Migration_20260425000004_webhook_error_and_nullable_merchant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration_20260425000004_webhook_error_and_nullable_merchant.js","sourceRoot":"","sources":["../../src/migrations/Migration_20260425000004_webhook_error_and_nullable_merchant.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,4DAA6D,SAAQ,sBAAS;IAChF,KAAK,CAAC,EAAE;QACf,qDAAqD;QACrD,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,yDAAyD;QACzD,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,wEAAwE;QACxE,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;QAEH,wEAAwE;QACxE,yEAAyE;QACzE,mEAAmE;QACnE,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;KAgBX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC;;;KAGX,CAAC,CAAC;IACL,CAAC;CACF;AAhDD,oIAgDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { VivaTenantMerchantSchema } from "./viva-tenant-merchant.js";
|
|
2
|
+
export type { VivaTenantMerchant } from "./viva-tenant-merchant.js";
|
|
3
|
+
export { VivaTransactionSchema } from "./viva-transaction.js";
|
|
4
|
+
export type { VivaTransaction, VivaTransactionStatus } from "./viva-transaction.js";
|
|
5
|
+
export { VivaWebhookEventSchema } from "./viva-webhook-event.js";
|
|
6
|
+
export type { VivaWebhookEvent } from "./viva-webhook-event.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VivaWebhookEventSchema = exports.VivaTransactionSchema = exports.VivaTenantMerchantSchema = void 0;
|
|
4
|
+
var viva_tenant_merchant_js_1 = require("./viva-tenant-merchant.js");
|
|
5
|
+
Object.defineProperty(exports, "VivaTenantMerchantSchema", { enumerable: true, get: function () { return viva_tenant_merchant_js_1.VivaTenantMerchantSchema; } });
|
|
6
|
+
var viva_transaction_js_1 = require("./viva-transaction.js");
|
|
7
|
+
Object.defineProperty(exports, "VivaTransactionSchema", { enumerable: true, get: function () { return viva_transaction_js_1.VivaTransactionSchema; } });
|
|
8
|
+
var viva_webhook_event_js_1 = require("./viva-webhook-event.js");
|
|
9
|
+
Object.defineProperty(exports, "VivaWebhookEventSchema", { enumerable: true, get: function () { return viva_webhook_event_js_1.VivaWebhookEventSchema; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AAA5D,mIAAA,wBAAwB,OAAA;AAEjC,6DAA8D;AAArD,4HAAA,qBAAqB,OAAA;AAE9B,iEAAiE;AAAxD,+HAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EntitySchema } from "@medusajs/framework/mikro-orm/core";
|
|
2
|
+
export interface VivaTenantMerchant {
|
|
3
|
+
tenant_id: string;
|
|
4
|
+
connected_account_id: string;
|
|
5
|
+
viva_merchant_id: string;
|
|
6
|
+
verification_status: string;
|
|
7
|
+
created_at: Date;
|
|
8
|
+
updated_at: Date;
|
|
9
|
+
}
|
|
10
|
+
export declare const VivaTenantMerchantSchema: EntitySchema<VivaTenantMerchant, never>;
|
|
11
|
+
//# sourceMappingURL=viva-tenant-merchant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viva-tenant-merchant.d.ts","sourceRoot":"","sources":["../../src/models/viva-tenant-merchant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CAClB;AAED,eAAO,MAAM,wBAAwB,yCAgDnC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VivaTenantMerchantSchema = void 0;
|
|
4
|
+
const core_1 = require("@medusajs/framework/mikro-orm/core");
|
|
5
|
+
exports.VivaTenantMerchantSchema = new core_1.EntitySchema({
|
|
6
|
+
name: "VivaTenantMerchant",
|
|
7
|
+
tableName: "viva_tenant_merchant",
|
|
8
|
+
uniques: [
|
|
9
|
+
{
|
|
10
|
+
name: "viva_tenant_merchant_viva_merchant_id_uniq",
|
|
11
|
+
properties: ["viva_merchant_id"],
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "viva_tenant_merchant_connected_account_id_uniq",
|
|
15
|
+
properties: ["connected_account_id"],
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
properties: {
|
|
19
|
+
tenant_id: {
|
|
20
|
+
type: "string",
|
|
21
|
+
columnType: "text",
|
|
22
|
+
primary: true,
|
|
23
|
+
},
|
|
24
|
+
connected_account_id: {
|
|
25
|
+
type: "string",
|
|
26
|
+
columnType: "uuid",
|
|
27
|
+
nullable: false,
|
|
28
|
+
},
|
|
29
|
+
viva_merchant_id: {
|
|
30
|
+
type: "string",
|
|
31
|
+
columnType: "uuid",
|
|
32
|
+
nullable: false,
|
|
33
|
+
},
|
|
34
|
+
verification_status: {
|
|
35
|
+
type: "string",
|
|
36
|
+
columnType: "text",
|
|
37
|
+
nullable: false,
|
|
38
|
+
default: "pending",
|
|
39
|
+
},
|
|
40
|
+
created_at: {
|
|
41
|
+
type: "Date",
|
|
42
|
+
columnType: "timestamptz",
|
|
43
|
+
nullable: false,
|
|
44
|
+
defaultRaw: "now()",
|
|
45
|
+
},
|
|
46
|
+
updated_at: {
|
|
47
|
+
type: "Date",
|
|
48
|
+
columnType: "timestamptz",
|
|
49
|
+
nullable: false,
|
|
50
|
+
defaultRaw: "now()",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=viva-tenant-merchant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viva-tenant-merchant.js","sourceRoot":"","sources":["../../src/models/viva-tenant-merchant.ts"],"names":[],"mappings":";;;AAAA,6DAAkE;AAWrD,QAAA,wBAAwB,GAAG,IAAI,mBAAY,CAAqB;IAC3E,IAAI,EAAE,oBAAoB;IAC1B,SAAS,EAAE,sBAAsB;IACjC,OAAO,EAAE;QACP;YACE,IAAI,EAAE,4CAA4C;YAClD,UAAU,EAAE,CAAC,kBAAkB,CAAC;SACjC;QACD;YACE,IAAI,EAAE,gDAAgD;YACtD,UAAU,EAAE,CAAC,sBAAsB,CAAC;SACrC;KACF;IACD,UAAU,EAAE;QACV,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,IAAI;SACd;QACD,oBAAoB,EAAE;YACpB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;SAChB;QACD,gBAAgB,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;SAChB;QACD,mBAAmB,EAAE;YACnB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,SAAS;SACnB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,OAAO;SACpB;QACD,UAAU,EAAE;YACV,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,aAAa;YACzB,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,OAAO;SACpB;KACF;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EntitySchema } from "@medusajs/framework/mikro-orm/core";
|
|
2
|
+
export type VivaTransactionStatus = "initiated" | "authorized" | "captured" | "refunded" | "cancelled" | "failed" | "disputed";
|
|
3
|
+
export interface VivaTransaction {
|
|
4
|
+
viva_transaction_id: string;
|
|
5
|
+
/**
|
|
6
|
+
* Viva order code (int64, stored as string for bigint safety).
|
|
7
|
+
* NULL until viva createOrder returns successfully (A4 write-pending-first).
|
|
8
|
+
* Migration_20260425000002 made this column nullable.
|
|
9
|
+
*
|
|
10
|
+
* @see references/viva-docs/md/payment-isv-api.txt:1 (createOrder response)
|
|
11
|
+
* @see references/viva-docs/md/isv-partner-program.txt:61 (A4 write-pending-first)
|
|
12
|
+
*/
|
|
13
|
+
viva_order_code: string | null | undefined;
|
|
14
|
+
medusa_payment_id: string;
|
|
15
|
+
/**
|
|
16
|
+
* Viva merchant id (uuid). NULL for merchant-mode rows where there is no
|
|
17
|
+
* per-cart tenant merchant id — the plugin operates a single account.
|
|
18
|
+
* Migration_20260425000004 made this column nullable.
|
|
19
|
+
*
|
|
20
|
+
* @see references/viva-docs/md/isv-partner-program.txt:61 (multi-mode v0.2.0)
|
|
21
|
+
*/
|
|
22
|
+
viva_merchant_id: string | null | undefined;
|
|
23
|
+
status: VivaTransactionStatus;
|
|
24
|
+
claim_substate: string | null | undefined;
|
|
25
|
+
amount_minor: string;
|
|
26
|
+
refunded_amount_minor: string;
|
|
27
|
+
currency_code: string;
|
|
28
|
+
idempotency_key: string;
|
|
29
|
+
raw_payload: Record<string, unknown> | null | undefined;
|
|
30
|
+
created_at: Date;
|
|
31
|
+
updated_at: Date;
|
|
32
|
+
}
|
|
33
|
+
export declare const VivaTransactionSchema: EntitySchema<VivaTransaction, never>;
|
|
34
|
+
//# sourceMappingURL=viva-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viva-transaction.d.ts","sourceRoot":"","sources":["../../src/models/viva-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GACX,YAAY,GACZ,UAAU,GACV,UAAU,GACV,WAAW,GACX,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC5C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE1C,YAAY,EAAE,MAAM,CAAC;IAErB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACxD,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CAClB;AAED,eAAO,MAAM,qBAAqB,sCAkGhC,CAAC"}
|