@infuro/cms-core 1.0.34 → 1.0.36
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/README.md +13 -0
- package/dist/OrderTrackPage-W3J6WIG2.js +426 -0
- package/dist/OrderTrackPage-Z6FCJQYY.cjs +428 -0
- package/dist/admin.cjs +35254 -21613
- package/dist/admin.d.cts +192 -9
- package/dist/admin.d.ts +192 -9
- package/dist/admin.js +34301 -20755
- package/dist/api.cjs +137 -17531
- package/dist/api.d.cts +633 -3
- package/dist/api.d.ts +633 -3
- package/dist/api.js +15 -17528
- package/dist/auth.cjs +192 -1034
- package/dist/auth.d.cts +197 -54
- package/dist/auth.d.ts +197 -54
- package/dist/auth.js +4 -966
- package/dist/chunk-2AEVFOQP.cjs +30436 -0
- package/dist/chunk-3DZRIZOD.cjs +52 -0
- package/dist/chunk-5ELSW2UP.js +150 -0
- package/dist/chunk-7NMT3GBR.cjs +29 -0
- package/dist/chunk-COBORIJH.cjs +2373 -0
- package/dist/chunk-CRFV5WJK.js +16 -0
- package/dist/chunk-D5FBNKQM.cjs +104 -0
- package/dist/chunk-FG6I64HP.js +604 -0
- package/dist/chunk-GO7PPYNU.js +76 -0
- package/dist/chunk-HCIRL37O.js +21 -0
- package/dist/chunk-HF3L2GIT.cjs +194 -0
- package/dist/chunk-HT5DI3XW.cjs +82 -0
- package/dist/chunk-JC6DLWTE.js +21 -0
- package/dist/chunk-JS2W7XZ4.js +30312 -0
- package/dist/chunk-JXF23MPG.js +25 -0
- package/dist/chunk-KFFB6EMZ.js +123 -0
- package/dist/chunk-KPKFNLQQ.cjs +648 -0
- package/dist/chunk-LI2IXVAY.js +171 -0
- package/dist/chunk-MQBT33IV.js +48 -0
- package/dist/chunk-OOTLNH63.cjs +18 -0
- package/dist/chunk-PNOKNSG2.cjs +222 -0
- package/dist/chunk-SHUYVCID.js +4 -0
- package/dist/chunk-SPQFNIYJ.cjs +132 -0
- package/dist/chunk-SYBOCAWB.js +97 -0
- package/dist/chunk-TDV6EJHV.js +192 -0
- package/dist/chunk-UCKN4BBY.cjs +24 -0
- package/dist/chunk-UF3BYUXY.js +616 -0
- package/dist/chunk-UPLVMVRX.cjs +23 -0
- package/dist/chunk-USNT2KNT.cjs +6 -0
- package/dist/chunk-VMY2S32H.js +2342 -0
- package/dist/chunk-WEMDMVHQ.js +216 -0
- package/dist/chunk-WO2DW4AU.cjs +182 -0
- package/dist/chunk-X47PBV4I.js +79 -0
- package/dist/chunk-X6H5VBQ2.cjs +620 -0
- package/dist/chunk-XQ3QUHWR.cjs +83 -0
- package/dist/chunk-XW5ATPRW.cjs +155 -0
- package/dist/cli.cjs +107 -86
- package/dist/cli.js +66 -29
- package/dist/email-queue-CGZBVVAS.js +2 -0
- package/dist/email-queue-TPZWLTIV.cjs +23 -0
- package/dist/emit-order-notification-trigger-D2N3KFHL.cjs +16 -0
- package/dist/emit-order-notification-trigger-IVLWKKJL.js +3 -0
- package/dist/erp-config-enabled-CUMQ6N2V.cjs +11 -0
- package/dist/erp-config-enabled-T37X7T34.js +2 -0
- package/dist/erp-order-invoice-3YISSOWW.js +3 -0
- package/dist/erp-order-invoice-ZR5F2KTA.cjs +12 -0
- package/dist/event-order-defaults-EMWBIGL3.cjs +39 -0
- package/dist/event-order-defaults-SDRNAZHC.js +2 -0
- package/dist/hooks.cjs +259 -132
- package/dist/hooks.d.cts +42 -1
- package/dist/hooks.d.ts +42 -1
- package/dist/hooks.js +234 -91
- package/dist/index.cjs +3679 -22356
- package/dist/index.d.cts +2173 -643
- package/dist/index.d.ts +2173 -643
- package/dist/index.js +2587 -22119
- package/dist/interpolate-WAKPN56R.cjs +11 -0
- package/dist/interpolate-WDUWDF3I.js +2 -0
- package/dist/migrations/1779400000000-ConvertStatusToEnum.ts +142 -0
- package/dist/migrations/1779400000000-SeedDefaultCurrencies.ts +33 -0
- package/dist/migrations/1779500000000-VendorRolesAndPermissions.ts +102 -0
- package/dist/migrations/1779600000000-VendorRegistrationProfile.ts +52 -0
- package/dist/migrations/1779700000000-CollectionIsCatalog.ts +22 -0
- package/dist/migrations/1779710000000-CollectionPlatformCatalog.ts +60 -0
- package/dist/migrations/1779720000000-ProductCategoryPlatformCatalog.ts +157 -0
- package/dist/migrations/1779800000000-EventsAndEventProducts.ts +173 -0
- package/dist/migrations/1779810000000-BackfillVendorRoleEventsPermissions.ts +38 -0
- package/dist/migrations/1779820000000-FixProductsCategoryForeignKey.ts +70 -0
- package/dist/migrations/1779830000000-ProductTitleColumn.ts +32 -0
- package/dist/migrations/1779840000000-EventAboutAndVisibilityFields.ts +34 -0
- package/dist/migrations/1779850000000-EventCityCountrySplit.ts +43 -0
- package/dist/migrations/1779860000000-CreateCombos.ts +140 -0
- package/dist/migrations/1780100000000-OrderAttendeesEventId.ts +55 -0
- package/dist/migrations/1780110000000-EventContactFormId.ts +49 -0
- package/dist/migrations/1780130000000-ProductVariants.ts +54 -0
- package/dist/migrations/1780140000000-EventManagementEnhancements.ts +44 -0
- package/dist/migrations/1780160000000-EventRegistrationGstProductContactForm.ts +79 -0
- package/dist/migrations/1780170000000-ComboCurrencyPrices.ts +20 -0
- package/dist/migrations/1781110000000-VendorOwnerCombosPermission.ts +38 -0
- package/dist/migrations/1781120000000-RefundPoliciesAndRequests.ts +225 -0
- package/dist/migrations/1781130000000-CreateAttendees.ts +44 -0
- package/dist/migrations/1781140000000-EventOrderNotifications.ts +29 -0
- package/dist/migrations/1781150000000-EventNamedLists.ts +28 -0
- package/dist/migrations/1781160000000-RefundPolicyEventTiers.ts +27 -0
- package/dist/migrations/1781170000000-EventRefundPolicy.ts +42 -0
- package/dist/migrations/1781180000000-RemoveCartItemsUniqueConstraint.ts +15 -0
- package/dist/migrations/1781190000000-RenameProductTaxesToProductConfig.ts +84 -0
- package/dist/migrations/1781200000000-VendorOwnerProductConfigPermissions.ts +51 -0
- package/dist/migrations/1781210000000-VendorRoleProductConfigPermissions.ts +46 -0
- package/dist/migrations/1781220000000-AddWhatsappTriggerBindings.ts +23 -0
- package/dist/migrations/1781230000000-AddOrderNotificationTriggers.ts +46 -0
- package/dist/migrations/1781240000000-DropEventOrderNotificationColumns.ts +29 -0
- package/dist/migrations/1781250000000-RemoveOrderRefundedTrigger.ts +36 -0
- package/dist/migrations/helpers/vendor-role-seed.ts +243 -0
- package/dist/paid-order-erp-3USEG6WL.js +3 -0
- package/dist/paid-order-erp-FSQ3GSXE.cjs +12 -0
- package/dist/pg-boss-service-4XF2TQ2E.js +2 -0
- package/dist/pg-boss-service-L6MTF4EQ.cjs +15 -0
- package/dist/razorpay-KLO2KNCB.js +49 -0
- package/dist/razorpay-U23LGY72.cjs +56 -0
- package/dist/rbac-debug-db-HWP65A4O.cjs +35 -0
- package/dist/rbac-debug-db-QJH3AD34.js +33 -0
- package/dist/sms-defaults-2NL24H57.js +2 -0
- package/dist/sms-defaults-KCOPKQBA.cjs +19 -0
- package/dist/stripe-4FD27QVJ.js +51 -0
- package/dist/stripe-VU6OEG2D.cjs +57 -0
- package/dist/theme.cjs +31 -59
- package/dist/theme.d.cts +78 -3
- package/dist/theme.d.ts +78 -3
- package/dist/theme.js +23 -20
- package/dist/vendor-invite-status-77O7ZQ3U.cjs +19 -0
- package/dist/vendor-invite-status-PWJ3DE76.js +2 -0
- package/dist/whatsapp-trigger-dispatcher-ONHXI7UY.cjs +19 -0
- package/dist/whatsapp-trigger-dispatcher-PWFI4FKP.js +6 -0
- package/package.json +147 -142
- package/dist/admin.cjs.map +0 -1
- package/dist/admin.js.map +0 -1
- package/dist/api.cjs.map +0 -1
- package/dist/api.js.map +0 -1
- package/dist/auth.cjs.map +0 -1
- package/dist/auth.js.map +0 -1
- package/dist/cli.cjs.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/config-DJ5CmQvS.d.cts +0 -8
- package/dist/config-DJ5CmQvS.d.ts +0 -8
- package/dist/hooks.cjs.map +0 -1
- package/dist/hooks.js.map +0 -1
- package/dist/index-Bf5GO8fu.d.cts +0 -583
- package/dist/index-DOiJuMQA.d.ts +0 -583
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/theme.cjs.map +0 -1
- package/dist/theme.js.map +0 -1
- package/dist/types-DCVaXlPV.d.cts +0 -78
- package/dist/types-DCVaXlPV.d.ts +0 -78
- package/dist/vendor-scope-DTYhJk_I.d.cts +0 -129
- package/dist/vendor-scope-DTYhJk_I.d.ts +0 -129
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export class RenameProductTaxesToProductConfig1781190000000
|
|
4
|
+
implements MigrationInterface
|
|
5
|
+
{
|
|
6
|
+
name = 'RenameProductTaxesToProductConfig1781190000000';
|
|
7
|
+
|
|
8
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
9
|
+
// Rename table if old table exists
|
|
10
|
+
await queryRunner.query(`
|
|
11
|
+
DO $$
|
|
12
|
+
BEGIN
|
|
13
|
+
IF EXISTS (
|
|
14
|
+
SELECT 1
|
|
15
|
+
FROM information_schema.tables
|
|
16
|
+
WHERE table_name = 'product_taxes'
|
|
17
|
+
) THEN
|
|
18
|
+
ALTER TABLE "product_taxes"
|
|
19
|
+
RENAME TO "product_config";
|
|
20
|
+
END IF;
|
|
21
|
+
END $$;
|
|
22
|
+
`);
|
|
23
|
+
|
|
24
|
+
// Add refundPolicyId
|
|
25
|
+
await queryRunner.query(`
|
|
26
|
+
ALTER TABLE "product_config"
|
|
27
|
+
ADD COLUMN IF NOT EXISTS "refundPolicyId" integer
|
|
28
|
+
`);
|
|
29
|
+
|
|
30
|
+
// FK to refund policies
|
|
31
|
+
await queryRunner.query(`
|
|
32
|
+
DO $$ BEGIN
|
|
33
|
+
IF NOT EXISTS (
|
|
34
|
+
SELECT 1
|
|
35
|
+
FROM pg_constraint
|
|
36
|
+
WHERE conname = 'FK_product_config_refund_policy'
|
|
37
|
+
) THEN
|
|
38
|
+
ALTER TABLE "product_config"
|
|
39
|
+
ADD CONSTRAINT "FK_product_config_refund_policy"
|
|
40
|
+
FOREIGN KEY ("refundPolicyId")
|
|
41
|
+
REFERENCES "refund_policies"("id")
|
|
42
|
+
ON DELETE SET NULL
|
|
43
|
+
ON UPDATE NO ACTION;
|
|
44
|
+
END IF;
|
|
45
|
+
END $$;
|
|
46
|
+
`);
|
|
47
|
+
|
|
48
|
+
// Index
|
|
49
|
+
await queryRunner.query(`
|
|
50
|
+
CREATE INDEX IF NOT EXISTS "IDX_product_config_refund_policy"
|
|
51
|
+
ON "product_config" ("refundPolicyId")
|
|
52
|
+
`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
56
|
+
await queryRunner.query(`
|
|
57
|
+
DROP INDEX IF EXISTS "IDX_product_config_refund_policy"
|
|
58
|
+
`);
|
|
59
|
+
|
|
60
|
+
await queryRunner.query(`
|
|
61
|
+
ALTER TABLE "product_config"
|
|
62
|
+
DROP CONSTRAINT IF EXISTS "FK_product_config_refund_policy"
|
|
63
|
+
`);
|
|
64
|
+
|
|
65
|
+
await queryRunner.query(`
|
|
66
|
+
ALTER TABLE "product_config"
|
|
67
|
+
DROP COLUMN IF EXISTS "refundPolicyId"
|
|
68
|
+
`);
|
|
69
|
+
|
|
70
|
+
await queryRunner.query(`
|
|
71
|
+
DO $$
|
|
72
|
+
BEGIN
|
|
73
|
+
IF EXISTS (
|
|
74
|
+
SELECT 1
|
|
75
|
+
FROM information_schema.tables
|
|
76
|
+
WHERE table_name = 'product_config'
|
|
77
|
+
) THEN
|
|
78
|
+
ALTER TABLE "product_config"
|
|
79
|
+
RENAME TO "product_taxes";
|
|
80
|
+
END IF;
|
|
81
|
+
END $$;
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export class VendorOwnerProductConfigPermissions1781200000000
|
|
4
|
+
implements MigrationInterface
|
|
5
|
+
{
|
|
6
|
+
name = 'VendorOwnerProductConfigPermissions1781200000000';
|
|
7
|
+
|
|
8
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
9
|
+
const entities = [
|
|
10
|
+
'product_variants',
|
|
11
|
+
'product_config',
|
|
12
|
+
'product_attributes',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
for (const entity of entities) {
|
|
16
|
+
await queryRunner.query(`
|
|
17
|
+
INSERT INTO "permissions"
|
|
18
|
+
("groupId", "entity", "canCreate", "canRead", "canUpdate", "canDelete")
|
|
19
|
+
SELECT
|
|
20
|
+
g.id,
|
|
21
|
+
'${entity}',
|
|
22
|
+
true,
|
|
23
|
+
true,
|
|
24
|
+
true,
|
|
25
|
+
true
|
|
26
|
+
FROM "user_groups" g
|
|
27
|
+
WHERE g.name = 'Vendor Owner'
|
|
28
|
+
AND g.deleted = false
|
|
29
|
+
ON CONFLICT ("groupId", "entity") DO UPDATE SET
|
|
30
|
+
"canCreate" = true,
|
|
31
|
+
"canRead" = true,
|
|
32
|
+
"canUpdate" = true,
|
|
33
|
+
"canDelete" = true
|
|
34
|
+
`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
39
|
+
await queryRunner.query(`
|
|
40
|
+
DELETE FROM "permissions" p
|
|
41
|
+
USING "user_groups" g
|
|
42
|
+
WHERE p."groupId" = g.id
|
|
43
|
+
AND g.name = 'Vendor Owner'
|
|
44
|
+
AND p.entity IN (
|
|
45
|
+
'product_variants',
|
|
46
|
+
'product_config',
|
|
47
|
+
'product_attributes'
|
|
48
|
+
)
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export class VendorRoleProductConfigPermissions1781210000000
|
|
4
|
+
implements MigrationInterface
|
|
5
|
+
{
|
|
6
|
+
name = 'VendorRoleProductConfigPermissions1781210000000';
|
|
7
|
+
|
|
8
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
9
|
+
const entities = [
|
|
10
|
+
'product_variants',
|
|
11
|
+
'product_config',
|
|
12
|
+
'product_attributes',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
for (const entity of entities) {
|
|
16
|
+
await queryRunner.query(`
|
|
17
|
+
INSERT INTO "vendor_role_permissions"
|
|
18
|
+
("vendorRoleId", "entity", "canCreate", "canRead", "canUpdate", "canDelete")
|
|
19
|
+
SELECT
|
|
20
|
+
vr.id,
|
|
21
|
+
'${entity}',
|
|
22
|
+
true,
|
|
23
|
+
true,
|
|
24
|
+
true,
|
|
25
|
+
true
|
|
26
|
+
FROM "vendor_roles" vr
|
|
27
|
+
ON CONFLICT ("vendorRoleId", "entity") DO UPDATE SET
|
|
28
|
+
"canCreate" = true,
|
|
29
|
+
"canRead" = true,
|
|
30
|
+
"canUpdate" = true,
|
|
31
|
+
"canDelete" = true
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
37
|
+
await queryRunner.query(`
|
|
38
|
+
DELETE FROM "vendor_role_permissions"
|
|
39
|
+
WHERE "entity" IN (
|
|
40
|
+
'product_variants',
|
|
41
|
+
'product_config',
|
|
42
|
+
'product_attributes'
|
|
43
|
+
)
|
|
44
|
+
`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export class AddWhatsappTriggerBindings1781220000000 implements MigrationInterface {
|
|
4
|
+
name = 'AddWhatsappTriggerBindings1781220000000';
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
CREATE TABLE "whatsapp_trigger_bindings" (
|
|
9
|
+
"id" SERIAL PRIMARY KEY,
|
|
10
|
+
"triggerKey" varchar NOT NULL UNIQUE,
|
|
11
|
+
"messageTemplateId" int NOT NULL,
|
|
12
|
+
"enabled" boolean NOT NULL DEFAULT true,
|
|
13
|
+
"createdAt" timestamp NOT NULL DEFAULT now(),
|
|
14
|
+
"updatedAt" timestamp NOT NULL DEFAULT now(),
|
|
15
|
+
CONSTRAINT "FK_whatsapp_trigger_bindings_template" FOREIGN KEY ("messageTemplateId") REFERENCES "message_templates"("id") ON DELETE CASCADE
|
|
16
|
+
);
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
await queryRunner.query(`DROP TABLE "whatsapp_trigger_bindings";`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export class AddOrderNotificationTriggers1781230000000 implements MigrationInterface {
|
|
4
|
+
name = 'AddOrderNotificationTriggers1781230000000';
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(`
|
|
8
|
+
CREATE TABLE "order_notification_triggers" (
|
|
9
|
+
"id" SERIAL PRIMARY KEY,
|
|
10
|
+
"triggerKey" varchar NOT NULL UNIQUE,
|
|
11
|
+
"label" varchar NOT NULL,
|
|
12
|
+
"description" text,
|
|
13
|
+
"category" varchar NOT NULL DEFAULT 'order',
|
|
14
|
+
"enabled" boolean NOT NULL DEFAULT true,
|
|
15
|
+
"sortOrder" int NOT NULL DEFAULT 0,
|
|
16
|
+
"createdAt" timestamp NOT NULL DEFAULT now(),
|
|
17
|
+
"updatedAt" timestamp NOT NULL DEFAULT now()
|
|
18
|
+
);
|
|
19
|
+
`);
|
|
20
|
+
|
|
21
|
+
await queryRunner.query(`
|
|
22
|
+
INSERT INTO "order_notification_triggers" ("triggerKey", "label", "description", "category", "sortOrder")
|
|
23
|
+
VALUES
|
|
24
|
+
('order_placed', 'Order placed', 'Fires when a new order is created (storefront checkout or admin).', 'order', 1),
|
|
25
|
+
('order_cancelled', 'Order cancelled', 'Fires when an order is cancelled.', 'order', 2),
|
|
26
|
+
('order_refunded', 'Order refunded', 'Fires when a refund amount is processed on cancellation.', 'order', 3)
|
|
27
|
+
ON CONFLICT ("triggerKey") DO NOTHING;
|
|
28
|
+
`);
|
|
29
|
+
|
|
30
|
+
await queryRunner.query(`
|
|
31
|
+
ALTER TABLE "whatsapp_trigger_bindings"
|
|
32
|
+
ALTER COLUMN "messageTemplateId" DROP NOT NULL;
|
|
33
|
+
`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
37
|
+
await queryRunner.query(`
|
|
38
|
+
DELETE FROM "whatsapp_trigger_bindings" WHERE "messageTemplateId" IS NULL;
|
|
39
|
+
`);
|
|
40
|
+
await queryRunner.query(`
|
|
41
|
+
ALTER TABLE "whatsapp_trigger_bindings"
|
|
42
|
+
ALTER COLUMN "messageTemplateId" SET NOT NULL;
|
|
43
|
+
`);
|
|
44
|
+
await queryRunner.query(`DROP TABLE "order_notification_triggers";`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
export class DropEventOrderNotificationColumns1781240000000 implements MigrationInterface {
|
|
4
|
+
name = 'DropEventOrderNotificationColumns1781240000000';
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
if (!(await queryRunner.hasTable('events'))) return;
|
|
8
|
+
await queryRunner.query(`ALTER TABLE "events" DROP COLUMN IF EXISTS "orderNotificationTemplates"`);
|
|
9
|
+
await queryRunner.query(`ALTER TABLE "events" DROP COLUMN IF EXISTS "orderNotificationChannels"`);
|
|
10
|
+
await queryRunner.query(`ALTER TABLE "events" DROP COLUMN IF EXISTS "orderNotificationsEnabled"`);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
14
|
+
if (!(await queryRunner.hasTable('events'))) return;
|
|
15
|
+
|
|
16
|
+
const table = await queryRunner.getTable('events');
|
|
17
|
+
if (!table?.findColumnByName('orderNotificationsEnabled')) {
|
|
18
|
+
await queryRunner.query(
|
|
19
|
+
`ALTER TABLE "events" ADD COLUMN "orderNotificationsEnabled" boolean NOT NULL DEFAULT false`,
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (!table?.findColumnByName('orderNotificationChannels')) {
|
|
23
|
+
await queryRunner.query(`ALTER TABLE "events" ADD COLUMN "orderNotificationChannels" jsonb;`);
|
|
24
|
+
}
|
|
25
|
+
if (!table?.findColumnByName('orderNotificationTemplates')) {
|
|
26
|
+
await queryRunner.query(`ALTER TABLE "events" ADD COLUMN "orderNotificationTemplates" jsonb;`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
/** Keep only order_placed and order_cancelled notification triggers. */
|
|
4
|
+
export class RemoveOrderRefundedTrigger1781250000000 implements MigrationInterface {
|
|
5
|
+
name = 'RemoveOrderRefundedTrigger1781250000000';
|
|
6
|
+
|
|
7
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
await queryRunner.query(`
|
|
9
|
+
DELETE FROM "whatsapp_trigger_bindings" WHERE "triggerKey" = 'order_refunded';
|
|
10
|
+
`);
|
|
11
|
+
await queryRunner.query(`
|
|
12
|
+
DELETE FROM "order_notification_triggers" WHERE "triggerKey" = 'order_refunded';
|
|
13
|
+
`);
|
|
14
|
+
await queryRunner.query(`
|
|
15
|
+
UPDATE "order_notification_triggers"
|
|
16
|
+
SET
|
|
17
|
+
"description" = 'Fires when an order is cancelled (includes refund amount when applicable).',
|
|
18
|
+
"updatedAt" = now()
|
|
19
|
+
WHERE "triggerKey" = 'order_cancelled';
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
24
|
+
await queryRunner.query(`
|
|
25
|
+
INSERT INTO "order_notification_triggers" ("triggerKey", "label", "description", "category", "sortOrder")
|
|
26
|
+
VALUES
|
|
27
|
+
('order_refunded', 'Order refunded', 'Fires when a refund amount is processed on cancellation.', 'order', 3)
|
|
28
|
+
ON CONFLICT ("triggerKey") DO NOTHING;
|
|
29
|
+
`);
|
|
30
|
+
await queryRunner.query(`
|
|
31
|
+
UPDATE "order_notification_triggers"
|
|
32
|
+
SET "description" = 'Fires when an order is cancelled.', "updatedAt" = now()
|
|
33
|
+
WHERE "triggerKey" = 'order_cancelled';
|
|
34
|
+
`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import type { QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
/** Self-contained for dist/migrations — do not import from src/lib. */
|
|
4
|
+
|
|
5
|
+
const RBAC_ENTITIES = [
|
|
6
|
+
'products',
|
|
7
|
+
'collections',
|
|
8
|
+
'brands',
|
|
9
|
+
'product_categories',
|
|
10
|
+
'orders',
|
|
11
|
+
'payments',
|
|
12
|
+
'taxes',
|
|
13
|
+
'attributes',
|
|
14
|
+
'vendor_customers',
|
|
15
|
+
'discounts',
|
|
16
|
+
'order_discounts',
|
|
17
|
+
'order_addresses',
|
|
18
|
+
'events',
|
|
19
|
+
'event_products',
|
|
20
|
+
'dashboard',
|
|
21
|
+
'settings',
|
|
22
|
+
'team',
|
|
23
|
+
'roles',
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
type Perm = { c: boolean; r: boolean; u: boolean; d: boolean };
|
|
27
|
+
|
|
28
|
+
type RoleDef = {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
isSystem: boolean;
|
|
32
|
+
isOwnerRole: boolean;
|
|
33
|
+
permissions: Record<string, Perm>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function full(): Perm {
|
|
37
|
+
return { c: true, r: true, u: true, d: true };
|
|
38
|
+
}
|
|
39
|
+
function read(): Perm {
|
|
40
|
+
return { c: false, r: true, u: false, d: false };
|
|
41
|
+
}
|
|
42
|
+
function none(): Perm {
|
|
43
|
+
return { c: false, r: false, u: false, d: false };
|
|
44
|
+
}
|
|
45
|
+
function readUpdate(): Perm {
|
|
46
|
+
return { c: false, r: true, u: true, d: false };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const STORE_ENTITIES = RBAC_ENTITIES.filter(
|
|
50
|
+
(e) => !['dashboard', 'settings', 'team', 'roles'].includes(e)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
function storePerms(spec: Record<string, Perm | 'full' | 'read' | 'none'>): Record<string, Perm> {
|
|
54
|
+
const resolve = (v: Perm | 'full' | 'read' | 'none'): Perm => {
|
|
55
|
+
if (v === 'full') return full();
|
|
56
|
+
if (v === 'read') return read();
|
|
57
|
+
if (v === 'none') return none();
|
|
58
|
+
return v;
|
|
59
|
+
};
|
|
60
|
+
const out: Record<string, Perm> = {};
|
|
61
|
+
for (const entity of STORE_ENTITIES) {
|
|
62
|
+
out[entity] = resolve(spec[entity] ?? 'none');
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const DEFAULT_ROLES: RoleDef[] = [
|
|
68
|
+
{
|
|
69
|
+
name: 'Owner',
|
|
70
|
+
description: 'Full store access and team/role management',
|
|
71
|
+
isSystem: true,
|
|
72
|
+
isOwnerRole: true,
|
|
73
|
+
permissions: {
|
|
74
|
+
...storePerms(Object.fromEntries(STORE_ENTITIES.map((e) => [e, 'full']))),
|
|
75
|
+
dashboard: read(),
|
|
76
|
+
settings: readUpdate(),
|
|
77
|
+
team: full(),
|
|
78
|
+
roles: full(),
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Manager',
|
|
83
|
+
description: 'Day-to-day store operations',
|
|
84
|
+
isSystem: true,
|
|
85
|
+
isOwnerRole: false,
|
|
86
|
+
permissions: {
|
|
87
|
+
...storePerms({
|
|
88
|
+
products: 'full',
|
|
89
|
+
collections: 'full',
|
|
90
|
+
brands: 'full',
|
|
91
|
+
product_categories: 'full',
|
|
92
|
+
orders: 'full',
|
|
93
|
+
vendor_customers: 'full',
|
|
94
|
+
discounts: 'full',
|
|
95
|
+
order_discounts: 'full',
|
|
96
|
+
order_addresses: 'full',
|
|
97
|
+
payments: 'read',
|
|
98
|
+
taxes: 'read',
|
|
99
|
+
attributes: 'read',
|
|
100
|
+
}),
|
|
101
|
+
dashboard: read(),
|
|
102
|
+
settings: read(),
|
|
103
|
+
team: none(),
|
|
104
|
+
roles: none(),
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'Catalog Staff',
|
|
109
|
+
description: 'Manage products and catalog content',
|
|
110
|
+
isSystem: true,
|
|
111
|
+
isOwnerRole: false,
|
|
112
|
+
permissions: {
|
|
113
|
+
...storePerms({
|
|
114
|
+
products: 'full',
|
|
115
|
+
collections: 'full',
|
|
116
|
+
brands: 'full',
|
|
117
|
+
product_categories: 'full',
|
|
118
|
+
attributes: 'full',
|
|
119
|
+
orders: 'read',
|
|
120
|
+
vendor_customers: 'read',
|
|
121
|
+
}),
|
|
122
|
+
dashboard: read(),
|
|
123
|
+
settings: none(),
|
|
124
|
+
team: none(),
|
|
125
|
+
roles: none(),
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'Fulfillment',
|
|
130
|
+
description: 'Orders and fulfillment',
|
|
131
|
+
isSystem: true,
|
|
132
|
+
isOwnerRole: false,
|
|
133
|
+
permissions: {
|
|
134
|
+
...storePerms({
|
|
135
|
+
products: 'read',
|
|
136
|
+
orders: 'full',
|
|
137
|
+
order_addresses: 'full',
|
|
138
|
+
order_discounts: 'read',
|
|
139
|
+
vendor_customers: 'read',
|
|
140
|
+
}),
|
|
141
|
+
dashboard: read(),
|
|
142
|
+
settings: none(),
|
|
143
|
+
team: none(),
|
|
144
|
+
roles: none(),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'Viewer',
|
|
149
|
+
description: 'Read-only access to store data',
|
|
150
|
+
isSystem: true,
|
|
151
|
+
isOwnerRole: false,
|
|
152
|
+
permissions: {
|
|
153
|
+
...storePerms(Object.fromEntries(STORE_ENTITIES.map((e) => [e, 'read']))),
|
|
154
|
+
dashboard: read(),
|
|
155
|
+
settings: none(),
|
|
156
|
+
team: none(),
|
|
157
|
+
roles: none(),
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
async function insertRolePermissions(
|
|
163
|
+
queryRunner: QueryRunner,
|
|
164
|
+
vendorRoleId: number,
|
|
165
|
+
permissions: Record<string, Perm>
|
|
166
|
+
): Promise<void> {
|
|
167
|
+
for (const entity of RBAC_ENTITIES) {
|
|
168
|
+
const p = permissions[entity];
|
|
169
|
+
if (!p) continue;
|
|
170
|
+
await queryRunner.query(
|
|
171
|
+
`
|
|
172
|
+
INSERT INTO "vendor_role_permissions"
|
|
173
|
+
("vendorRoleId", "entity", "canCreate", "canRead", "canUpdate", "canDelete")
|
|
174
|
+
VALUES ($1, $2, $3, $4, $5, $6)
|
|
175
|
+
ON CONFLICT ("vendorRoleId", "entity") DO NOTHING
|
|
176
|
+
`,
|
|
177
|
+
[vendorRoleId, entity, p.c, p.r, p.u, p.d]
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Seed default vendor roles + backfill vendor_users.vendorRoleId (migration-safe). */
|
|
183
|
+
export async function seedVendorRolesForMigration(
|
|
184
|
+
queryRunner: QueryRunner,
|
|
185
|
+
vendorId: number
|
|
186
|
+
): Promise<void> {
|
|
187
|
+
const existing = (await queryRunner.query(
|
|
188
|
+
`SELECT id, name, "isOwnerRole" FROM "vendor_roles" WHERE "vendorId" = $1 AND "deleted" = false`,
|
|
189
|
+
[vendorId]
|
|
190
|
+
)) as Array<{ id: number; name: string; isOwnerRole: boolean }>;
|
|
191
|
+
|
|
192
|
+
let ownerRoleId = 0;
|
|
193
|
+
let viewerRoleId = 0;
|
|
194
|
+
|
|
195
|
+
if (existing.length > 0) {
|
|
196
|
+
for (const r of existing) {
|
|
197
|
+
if (r.isOwnerRole) ownerRoleId = r.id;
|
|
198
|
+
if (r.name === 'Viewer') viewerRoleId = r.id;
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
for (const def of DEFAULT_ROLES) {
|
|
202
|
+
const inserted = (await queryRunner.query(
|
|
203
|
+
`
|
|
204
|
+
INSERT INTO "vendor_roles"
|
|
205
|
+
("vendorId", "name", "description", "isSystem", "isOwnerRole")
|
|
206
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
207
|
+
RETURNING id
|
|
208
|
+
`,
|
|
209
|
+
[vendorId, def.name, def.description, def.isSystem, def.isOwnerRole]
|
|
210
|
+
)) as Array<{ id: number }>;
|
|
211
|
+
const roleId = inserted[0]?.id;
|
|
212
|
+
if (!roleId) continue;
|
|
213
|
+
if (def.isOwnerRole) ownerRoleId = roleId;
|
|
214
|
+
if (def.name === 'Viewer') viewerRoleId = roleId;
|
|
215
|
+
await insertRolePermissions(queryRunner, roleId, def.permissions);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (ownerRoleId) {
|
|
220
|
+
await queryRunner.query(
|
|
221
|
+
`
|
|
222
|
+
UPDATE "vendor_users" vu
|
|
223
|
+
SET "vendorRoleId" = $1
|
|
224
|
+
WHERE vu."vendorId" = $2
|
|
225
|
+
AND vu."role" = 'owner'
|
|
226
|
+
AND vu."vendorRoleId" IS NULL
|
|
227
|
+
`,
|
|
228
|
+
[ownerRoleId, vendorId]
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (viewerRoleId) {
|
|
232
|
+
await queryRunner.query(
|
|
233
|
+
`
|
|
234
|
+
UPDATE "vendor_users" vu
|
|
235
|
+
SET "vendorRoleId" = $1
|
|
236
|
+
WHERE vu."vendorId" = $2
|
|
237
|
+
AND vu."role" = 'staff'
|
|
238
|
+
AND vu."vendorRoleId" IS NULL
|
|
239
|
+
`,
|
|
240
|
+
[viewerRoleId, vendorId]
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkHF3L2GIT_cjs = require('./chunk-HF3L2GIT.cjs');
|
|
4
|
+
require('./chunk-D5FBNKQM.cjs');
|
|
5
|
+
require('./chunk-USNT2KNT.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "queueErpPaidOrderForOrderId", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkHF3L2GIT_cjs.queueErpPaidOrderForOrderId; }
|
|
12
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXQ3QUHWR_cjs = require('./chunk-XQ3QUHWR.cjs');
|
|
4
|
+
require('./chunk-USNT2KNT.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "JOB_RUNNER_QUEUE", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkXQ3QUHWR_cjs.JOB_RUNNER_QUEUE; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "PgBossService", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkXQ3QUHWR_cjs.PgBossService; }
|
|
15
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { __name } from './chunk-SHUYVCID.js';
|
|
2
|
+
import Razorpay from 'razorpay';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
|
|
5
|
+
var RazorpayPaymentService = class {
|
|
6
|
+
static {
|
|
7
|
+
__name(this, "RazorpayPaymentService");
|
|
8
|
+
}
|
|
9
|
+
razorpay;
|
|
10
|
+
keySecret;
|
|
11
|
+
webhookSecret;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.razorpay = new Razorpay({
|
|
14
|
+
key_id: config.keyId,
|
|
15
|
+
key_secret: config.keySecret
|
|
16
|
+
});
|
|
17
|
+
this.keySecret = config.keySecret;
|
|
18
|
+
this.webhookSecret = config.webhookSecret;
|
|
19
|
+
}
|
|
20
|
+
async createPaymentIntent(amount, currency, metadata) {
|
|
21
|
+
const order = await this.razorpay.orders.create({
|
|
22
|
+
amount: Math.round(amount * 100),
|
|
23
|
+
currency: currency.toUpperCase(),
|
|
24
|
+
notes: metadata
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
id: order.id,
|
|
28
|
+
clientSecret: order.id,
|
|
29
|
+
amount,
|
|
30
|
+
currency,
|
|
31
|
+
status: order.status
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
async capturePayment(paymentId, amount) {
|
|
35
|
+
try {
|
|
36
|
+
await this.razorpay.payments.capture(paymentId, amount ? Math.round(amount * 100) : 0, "INR");
|
|
37
|
+
return true;
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
verifyWebhookSignature(payload, signature) {
|
|
43
|
+
const secret = this.webhookSecret || this.keySecret;
|
|
44
|
+
const expectedSignature = crypto.createHmac("sha256", secret).update(typeof payload === "string" ? payload : payload.toString("utf8")).digest("hex");
|
|
45
|
+
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { RazorpayPaymentService };
|