@infuro/cms-core 1.0.61 → 1.0.63
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/dist/admin.cjs +3624 -2642
- package/dist/admin.js +2415 -1433
- package/dist/api.cjs +41 -37
- package/dist/api.js +9 -5
- package/dist/chunk-3VZAAQUV.js +106 -0
- package/dist/{chunk-UHT4INVW.js → chunk-77YWLP4X.js} +625 -252
- package/dist/{chunk-BXYZDMTZ.cjs → chunk-7L556RGL.cjs} +3 -94
- package/dist/{chunk-T3HPSF7K.js → chunk-AYWDQFJZ.js} +3 -0
- package/dist/{chunk-URN7GS23.js → chunk-BWOITUNI.js} +203 -1062
- package/dist/{chunk-CNAHVRRU.cjs → chunk-CJEOH6QC.cjs} +676 -312
- package/dist/{chunk-O2642WVS.js → chunk-DTUL3Q5L.js} +17 -3
- package/dist/{chunk-YSYX4GUD.cjs → chunk-EWXG4E74.cjs} +213 -1082
- package/dist/chunk-GWDI752Q.js +83 -0
- package/dist/chunk-H3IVLIPR.cjs +86 -0
- package/dist/chunk-JLDHK2QE.cjs +109 -0
- package/dist/chunk-KAOHOHCA.js +901 -0
- package/dist/{chunk-2KUCQVAQ.js → chunk-MWEK7N3F.js} +2 -91
- package/dist/{chunk-V25RDUOU.cjs → chunk-MXABMVF7.cjs} +38 -4
- package/dist/chunk-OVTOP42W.js +199 -0
- package/dist/{chunk-73WVHINE.cjs → chunk-RHYVNRYG.cjs} +18 -4
- package/dist/{chunk-L3525VXI.js → chunk-RXTUSF3R.js} +36 -2
- package/dist/{chunk-77I3KS7V.cjs → chunk-UEE4PTTB.cjs} +3 -0
- package/dist/chunk-WFMVD567.cjs +209 -0
- package/dist/chunk-YVP4NQII.cjs +914 -0
- package/dist/{email-queue-6NJY6HNM.cjs → email-queue-VTYL2KFA.cjs} +7 -6
- package/dist/{email-queue-OI2HSCGE.js → email-queue-YPRSVG56.js} +3 -2
- package/dist/email-service-ATCPJFWG.cjs +28 -0
- package/dist/email-service-DPKVQOKP.js +3 -0
- package/dist/{emit-order-notification-trigger-TNEZOYEE.cjs → emit-order-notification-trigger-WI4HGMKH.cjs} +4 -4
- package/dist/{emit-order-notification-trigger-CZU3V2WE.js → emit-order-notification-trigger-XVG2B5ZF.js} +2 -2
- package/dist/{erp-order-invoice-3GXDE443.js → erp-order-invoice-3UGWLICU.js} +2 -1
- package/dist/{erp-order-invoice-EYYNR526.cjs → erp-order-invoice-KJYJNWMG.cjs} +6 -5
- package/dist/index.cjs +366 -316
- package/dist/index.d.cts +61 -21
- package/dist/index.d.ts +61 -21
- package/dist/index.js +79 -29
- package/dist/migrations/1783000000000-AddOrderPendingProcessingCompletedTriggers.ts +56 -0
- package/dist/migrations/1783100000000-AddSmsToOrderNotificationBindingsChannelEnum.ts +17 -0
- package/dist/migrations/1783200000000-AddOrderAssigneeColumns.ts +30 -0
- package/dist/order-assignees-handlers-LKMAGLG6.js +150 -0
- package/dist/order-assignees-handlers-NPKD64P6.cjs +152 -0
- package/dist/order-completion-otp-handlers-IMMQGHDR.cjs +363 -0
- package/dist/order-completion-otp-handlers-WGM7HWG4.js +361 -0
- package/dist/order-notification-dispatcher-5TUFCDU7.cjs +35 -0
- package/dist/order-notification-dispatcher-JKFQJYGG.js +10 -0
- package/dist/sms-notification-templates-handlers-SJLO7JGZ.js +47 -0
- package/dist/sms-notification-templates-handlers-YSB3L2PK.cjs +49 -0
- package/package.json +1 -1
- package/dist/order-notification-dispatcher-KJVGLK5E.cjs +0 -24
- package/dist/order-notification-dispatcher-ZSFKEYMP.js +0 -7
package/dist/index.d.cts
CHANGED
|
@@ -252,8 +252,10 @@ interface OrderPlacedLineItem {
|
|
|
252
252
|
tax?: number | string | null;
|
|
253
253
|
hsn?: string | null;
|
|
254
254
|
}
|
|
255
|
-
/** Merge branding + email plugin settings for layout (email overrides when set).
|
|
256
|
-
|
|
255
|
+
/** Merge branding + email plugin settings for layout (email overrides when set).
|
|
256
|
+
* Optional `storeSettings` supplies Store → Company Logo / name / contact fallbacks.
|
|
257
|
+
*/
|
|
258
|
+
declare function mergeEmailLayoutCompanyDetails(branding: Record<string, string>, emailSettings: Record<string, string>, storeSettings?: Record<string, string>): CompanyDetails;
|
|
257
259
|
interface EmailTemplateResult {
|
|
258
260
|
subject: string;
|
|
259
261
|
bodyHtml: string;
|
|
@@ -361,6 +363,10 @@ declare const emailTemplates: {
|
|
|
361
363
|
};
|
|
362
364
|
};
|
|
363
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Branded HTML shell for transactional email: header logo, card body, footer.
|
|
368
|
+
* Inline styles only (email-client safe).
|
|
369
|
+
*/
|
|
364
370
|
declare function renderLayout(options: {
|
|
365
371
|
bodyHtml: string;
|
|
366
372
|
companyDetails: CompanyDetails;
|
|
@@ -1900,7 +1906,7 @@ declare function serializeEmailRecipients(emails: string[]): string;
|
|
|
1900
1906
|
/** Join for SMTP `to` header (multiple recipients). */
|
|
1901
1907
|
declare function joinRecipientsForSend(emails: string[]): string | null;
|
|
1902
1908
|
|
|
1903
|
-
type OtpPurpose = 'login' | 'verify_email' | 'verify_phone';
|
|
1909
|
+
type OtpPurpose = 'login' | 'verify_email' | 'verify_phone' | 'order_completion';
|
|
1904
1910
|
type OtpChannel = 'email' | 'sms';
|
|
1905
1911
|
declare function hashOtpCode(code: string, purpose: string, identifier: string, pepper?: string): string;
|
|
1906
1912
|
declare function verifyOtpCodeHash(code: string, storedHash: string, purpose: string, identifier: string, pepper?: string): boolean;
|
|
@@ -2566,6 +2572,9 @@ declare class Order {
|
|
|
2566
2572
|
customerContact: Customer_Contacts | null;
|
|
2567
2573
|
billingAddress: OrderAddresses | null;
|
|
2568
2574
|
shippingAddress: OrderAddresses | null;
|
|
2575
|
+
assignedUserId: number | null;
|
|
2576
|
+
assignedAt: Date | null;
|
|
2577
|
+
assignedUser: User | null;
|
|
2569
2578
|
items: OrderItem[];
|
|
2570
2579
|
payments: Payment[];
|
|
2571
2580
|
}
|
|
@@ -2819,19 +2828,10 @@ declare function fireOrderNotificationTrigger(triggerKey: string, orderId: numbe
|
|
|
2819
2828
|
extraVariables?: Record<string, string>;
|
|
2820
2829
|
}): void;
|
|
2821
2830
|
|
|
2822
|
-
interface OrderNotificationDispatcherDeps {
|
|
2823
|
-
dataSource: any;
|
|
2824
|
-
entityMap: EntityMap$2;
|
|
2825
|
-
getCms: () => Promise<CmsAppLike$1>;
|
|
2826
|
-
}
|
|
2827
|
-
declare function initWhatsappTriggerDispatcher(deps: OrderNotificationDispatcherDeps): void;
|
|
2828
|
-
/** Manually re-fire a trigger for an existing order (admin testing / resend). */
|
|
2829
|
-
declare function resendOrderNotification(triggerKey: string, orderId: number, deps: OrderNotificationDispatcherDeps): Promise<{
|
|
2830
|
-
ok: boolean;
|
|
2831
|
-
error?: string;
|
|
2832
|
-
}>;
|
|
2833
|
-
|
|
2834
2831
|
declare const KNOWN_NOTIFICATION_TRIGGERS: {
|
|
2832
|
+
readonly ORDER_PENDING: "order_pending";
|
|
2833
|
+
readonly ORDER_PROCESSING: "order_processing";
|
|
2834
|
+
readonly ORDER_COMPLETED: "order_completed";
|
|
2835
2835
|
readonly ORDER_PLACED: "order_placed";
|
|
2836
2836
|
readonly ORDER_CANCELLED: "order_cancelled";
|
|
2837
2837
|
readonly PAYMENT_SUCCESS: "payment_success";
|
|
@@ -2855,41 +2855,80 @@ declare class NotificationTriggerEmitter extends EventEmitter {
|
|
|
2855
2855
|
}
|
|
2856
2856
|
declare const notificationTriggerEmitter: NotificationTriggerEmitter;
|
|
2857
2857
|
|
|
2858
|
+
interface OrderNotificationDispatcherDeps {
|
|
2859
|
+
dataSource: any;
|
|
2860
|
+
entityMap: EntityMap$2;
|
|
2861
|
+
getCms: () => Promise<CmsAppLike$1>;
|
|
2862
|
+
}
|
|
2863
|
+
declare function initWhatsappTriggerDispatcher(deps: OrderNotificationDispatcherDeps): void;
|
|
2864
|
+
/** Manually re-fire a trigger for an existing order (admin testing / resend). */
|
|
2865
|
+
declare function resendOrderNotification(triggerKey: string, orderId: number, deps: OrderNotificationDispatcherDeps): Promise<{
|
|
2866
|
+
ok: boolean;
|
|
2867
|
+
error?: string;
|
|
2868
|
+
}>;
|
|
2869
|
+
|
|
2858
2870
|
/** Default order lifecycle triggers — seeded by migration, not tied to the `events` table. */
|
|
2859
2871
|
declare const DEFAULT_ORDER_NOTIFICATION_TRIGGER_SEEDS: readonly [{
|
|
2872
|
+
readonly triggerKey: "order_pending";
|
|
2873
|
+
readonly label: "Order pending";
|
|
2874
|
+
readonly description: "Fires when an order is created and pending confirmation or payment.";
|
|
2875
|
+
readonly category: "order";
|
|
2876
|
+
readonly sortOrder: 1;
|
|
2877
|
+
}, {
|
|
2878
|
+
readonly triggerKey: "order_processing";
|
|
2879
|
+
readonly label: "Order processing";
|
|
2880
|
+
readonly description: "Fires when an order moves to processing after being assigned.";
|
|
2881
|
+
readonly category: "order";
|
|
2882
|
+
readonly sortOrder: 2;
|
|
2883
|
+
}, {
|
|
2884
|
+
readonly triggerKey: "order_completed";
|
|
2885
|
+
readonly label: "Order completed";
|
|
2886
|
+
readonly description: "Fires when an order is completed after customer OTP validation.";
|
|
2887
|
+
readonly category: "order";
|
|
2888
|
+
readonly sortOrder: 3;
|
|
2889
|
+
}, {
|
|
2860
2890
|
readonly triggerKey: "order_placed";
|
|
2861
2891
|
readonly label: "Order placed";
|
|
2862
2892
|
readonly description: "Fires when a new order is created (storefront checkout or admin).";
|
|
2863
2893
|
readonly category: "order";
|
|
2864
|
-
readonly sortOrder:
|
|
2894
|
+
readonly sortOrder: 4;
|
|
2865
2895
|
}, {
|
|
2866
2896
|
readonly triggerKey: "order_cancelled";
|
|
2867
2897
|
readonly label: "Order cancelled";
|
|
2868
2898
|
readonly description: "Fires when an order is cancelled (includes refund amount when applicable).";
|
|
2869
2899
|
readonly category: "order";
|
|
2870
|
-
readonly sortOrder:
|
|
2900
|
+
readonly sortOrder: 5;
|
|
2871
2901
|
}, {
|
|
2872
2902
|
readonly triggerKey: "payment_success";
|
|
2873
2903
|
readonly label: "Payment success";
|
|
2874
2904
|
readonly description: "Fires when order is placed and payment status is paid.";
|
|
2875
2905
|
readonly category: "order";
|
|
2876
|
-
readonly sortOrder:
|
|
2906
|
+
readonly sortOrder: 6;
|
|
2877
2907
|
}, {
|
|
2878
2908
|
readonly triggerKey: "payment_failed";
|
|
2879
2909
|
readonly label: "Payment failed";
|
|
2880
2910
|
readonly description: "Fires when payment status is pending, unpaid, or failed, or when order is cancelled without payment.";
|
|
2881
2911
|
readonly category: "order";
|
|
2882
|
-
readonly sortOrder:
|
|
2912
|
+
readonly sortOrder: 7;
|
|
2883
2913
|
}, {
|
|
2884
2914
|
readonly triggerKey: "payment_refund_initiated";
|
|
2885
2915
|
readonly label: "Payment refund initiated";
|
|
2886
2916
|
readonly description: "Fires when order is cancelled and its payment status is paid (refund initiated).";
|
|
2887
2917
|
readonly category: "order";
|
|
2888
|
-
readonly sortOrder:
|
|
2918
|
+
readonly sortOrder: 8;
|
|
2889
2919
|
}];
|
|
2890
2920
|
|
|
2891
2921
|
/** @deprecated Use DB catalog `order_notification_triggers`; kept for type hints. */
|
|
2892
2922
|
declare const ORDER_NOTIFICATION_TRIGGERS: readonly [{
|
|
2923
|
+
readonly key: "order_pending";
|
|
2924
|
+
readonly label: "Order pending";
|
|
2925
|
+
}, {
|
|
2926
|
+
readonly key: "order_processing";
|
|
2927
|
+
readonly label: "Order processing";
|
|
2928
|
+
}, {
|
|
2929
|
+
readonly key: "order_completed";
|
|
2930
|
+
readonly label: "Order completed";
|
|
2931
|
+
}, {
|
|
2893
2932
|
readonly key: "order_placed";
|
|
2894
2933
|
readonly label: "Order placed";
|
|
2895
2934
|
}, {
|
|
@@ -4065,7 +4104,8 @@ declare class Attendee {
|
|
|
4065
4104
|
declare enum NotificationChannel {
|
|
4066
4105
|
WHATSAPP = "whatsapp",
|
|
4067
4106
|
EMAIL = "email",
|
|
4068
|
-
MOBILE = "mobile"
|
|
4107
|
+
MOBILE = "mobile",
|
|
4108
|
+
SMS = "sms"
|
|
4069
4109
|
}
|
|
4070
4110
|
declare enum NotificationAudienceType {
|
|
4071
4111
|
CUSTOMERS = "customers",
|
package/dist/index.d.ts
CHANGED
|
@@ -252,8 +252,10 @@ interface OrderPlacedLineItem {
|
|
|
252
252
|
tax?: number | string | null;
|
|
253
253
|
hsn?: string | null;
|
|
254
254
|
}
|
|
255
|
-
/** Merge branding + email plugin settings for layout (email overrides when set).
|
|
256
|
-
|
|
255
|
+
/** Merge branding + email plugin settings for layout (email overrides when set).
|
|
256
|
+
* Optional `storeSettings` supplies Store → Company Logo / name / contact fallbacks.
|
|
257
|
+
*/
|
|
258
|
+
declare function mergeEmailLayoutCompanyDetails(branding: Record<string, string>, emailSettings: Record<string, string>, storeSettings?: Record<string, string>): CompanyDetails;
|
|
257
259
|
interface EmailTemplateResult {
|
|
258
260
|
subject: string;
|
|
259
261
|
bodyHtml: string;
|
|
@@ -361,6 +363,10 @@ declare const emailTemplates: {
|
|
|
361
363
|
};
|
|
362
364
|
};
|
|
363
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Branded HTML shell for transactional email: header logo, card body, footer.
|
|
368
|
+
* Inline styles only (email-client safe).
|
|
369
|
+
*/
|
|
364
370
|
declare function renderLayout(options: {
|
|
365
371
|
bodyHtml: string;
|
|
366
372
|
companyDetails: CompanyDetails;
|
|
@@ -1900,7 +1906,7 @@ declare function serializeEmailRecipients(emails: string[]): string;
|
|
|
1900
1906
|
/** Join for SMTP `to` header (multiple recipients). */
|
|
1901
1907
|
declare function joinRecipientsForSend(emails: string[]): string | null;
|
|
1902
1908
|
|
|
1903
|
-
type OtpPurpose = 'login' | 'verify_email' | 'verify_phone';
|
|
1909
|
+
type OtpPurpose = 'login' | 'verify_email' | 'verify_phone' | 'order_completion';
|
|
1904
1910
|
type OtpChannel = 'email' | 'sms';
|
|
1905
1911
|
declare function hashOtpCode(code: string, purpose: string, identifier: string, pepper?: string): string;
|
|
1906
1912
|
declare function verifyOtpCodeHash(code: string, storedHash: string, purpose: string, identifier: string, pepper?: string): boolean;
|
|
@@ -2566,6 +2572,9 @@ declare class Order {
|
|
|
2566
2572
|
customerContact: Customer_Contacts | null;
|
|
2567
2573
|
billingAddress: OrderAddresses | null;
|
|
2568
2574
|
shippingAddress: OrderAddresses | null;
|
|
2575
|
+
assignedUserId: number | null;
|
|
2576
|
+
assignedAt: Date | null;
|
|
2577
|
+
assignedUser: User | null;
|
|
2569
2578
|
items: OrderItem[];
|
|
2570
2579
|
payments: Payment[];
|
|
2571
2580
|
}
|
|
@@ -2819,19 +2828,10 @@ declare function fireOrderNotificationTrigger(triggerKey: string, orderId: numbe
|
|
|
2819
2828
|
extraVariables?: Record<string, string>;
|
|
2820
2829
|
}): void;
|
|
2821
2830
|
|
|
2822
|
-
interface OrderNotificationDispatcherDeps {
|
|
2823
|
-
dataSource: any;
|
|
2824
|
-
entityMap: EntityMap$2;
|
|
2825
|
-
getCms: () => Promise<CmsAppLike$1>;
|
|
2826
|
-
}
|
|
2827
|
-
declare function initWhatsappTriggerDispatcher(deps: OrderNotificationDispatcherDeps): void;
|
|
2828
|
-
/** Manually re-fire a trigger for an existing order (admin testing / resend). */
|
|
2829
|
-
declare function resendOrderNotification(triggerKey: string, orderId: number, deps: OrderNotificationDispatcherDeps): Promise<{
|
|
2830
|
-
ok: boolean;
|
|
2831
|
-
error?: string;
|
|
2832
|
-
}>;
|
|
2833
|
-
|
|
2834
2831
|
declare const KNOWN_NOTIFICATION_TRIGGERS: {
|
|
2832
|
+
readonly ORDER_PENDING: "order_pending";
|
|
2833
|
+
readonly ORDER_PROCESSING: "order_processing";
|
|
2834
|
+
readonly ORDER_COMPLETED: "order_completed";
|
|
2835
2835
|
readonly ORDER_PLACED: "order_placed";
|
|
2836
2836
|
readonly ORDER_CANCELLED: "order_cancelled";
|
|
2837
2837
|
readonly PAYMENT_SUCCESS: "payment_success";
|
|
@@ -2855,41 +2855,80 @@ declare class NotificationTriggerEmitter extends EventEmitter {
|
|
|
2855
2855
|
}
|
|
2856
2856
|
declare const notificationTriggerEmitter: NotificationTriggerEmitter;
|
|
2857
2857
|
|
|
2858
|
+
interface OrderNotificationDispatcherDeps {
|
|
2859
|
+
dataSource: any;
|
|
2860
|
+
entityMap: EntityMap$2;
|
|
2861
|
+
getCms: () => Promise<CmsAppLike$1>;
|
|
2862
|
+
}
|
|
2863
|
+
declare function initWhatsappTriggerDispatcher(deps: OrderNotificationDispatcherDeps): void;
|
|
2864
|
+
/** Manually re-fire a trigger for an existing order (admin testing / resend). */
|
|
2865
|
+
declare function resendOrderNotification(triggerKey: string, orderId: number, deps: OrderNotificationDispatcherDeps): Promise<{
|
|
2866
|
+
ok: boolean;
|
|
2867
|
+
error?: string;
|
|
2868
|
+
}>;
|
|
2869
|
+
|
|
2858
2870
|
/** Default order lifecycle triggers — seeded by migration, not tied to the `events` table. */
|
|
2859
2871
|
declare const DEFAULT_ORDER_NOTIFICATION_TRIGGER_SEEDS: readonly [{
|
|
2872
|
+
readonly triggerKey: "order_pending";
|
|
2873
|
+
readonly label: "Order pending";
|
|
2874
|
+
readonly description: "Fires when an order is created and pending confirmation or payment.";
|
|
2875
|
+
readonly category: "order";
|
|
2876
|
+
readonly sortOrder: 1;
|
|
2877
|
+
}, {
|
|
2878
|
+
readonly triggerKey: "order_processing";
|
|
2879
|
+
readonly label: "Order processing";
|
|
2880
|
+
readonly description: "Fires when an order moves to processing after being assigned.";
|
|
2881
|
+
readonly category: "order";
|
|
2882
|
+
readonly sortOrder: 2;
|
|
2883
|
+
}, {
|
|
2884
|
+
readonly triggerKey: "order_completed";
|
|
2885
|
+
readonly label: "Order completed";
|
|
2886
|
+
readonly description: "Fires when an order is completed after customer OTP validation.";
|
|
2887
|
+
readonly category: "order";
|
|
2888
|
+
readonly sortOrder: 3;
|
|
2889
|
+
}, {
|
|
2860
2890
|
readonly triggerKey: "order_placed";
|
|
2861
2891
|
readonly label: "Order placed";
|
|
2862
2892
|
readonly description: "Fires when a new order is created (storefront checkout or admin).";
|
|
2863
2893
|
readonly category: "order";
|
|
2864
|
-
readonly sortOrder:
|
|
2894
|
+
readonly sortOrder: 4;
|
|
2865
2895
|
}, {
|
|
2866
2896
|
readonly triggerKey: "order_cancelled";
|
|
2867
2897
|
readonly label: "Order cancelled";
|
|
2868
2898
|
readonly description: "Fires when an order is cancelled (includes refund amount when applicable).";
|
|
2869
2899
|
readonly category: "order";
|
|
2870
|
-
readonly sortOrder:
|
|
2900
|
+
readonly sortOrder: 5;
|
|
2871
2901
|
}, {
|
|
2872
2902
|
readonly triggerKey: "payment_success";
|
|
2873
2903
|
readonly label: "Payment success";
|
|
2874
2904
|
readonly description: "Fires when order is placed and payment status is paid.";
|
|
2875
2905
|
readonly category: "order";
|
|
2876
|
-
readonly sortOrder:
|
|
2906
|
+
readonly sortOrder: 6;
|
|
2877
2907
|
}, {
|
|
2878
2908
|
readonly triggerKey: "payment_failed";
|
|
2879
2909
|
readonly label: "Payment failed";
|
|
2880
2910
|
readonly description: "Fires when payment status is pending, unpaid, or failed, or when order is cancelled without payment.";
|
|
2881
2911
|
readonly category: "order";
|
|
2882
|
-
readonly sortOrder:
|
|
2912
|
+
readonly sortOrder: 7;
|
|
2883
2913
|
}, {
|
|
2884
2914
|
readonly triggerKey: "payment_refund_initiated";
|
|
2885
2915
|
readonly label: "Payment refund initiated";
|
|
2886
2916
|
readonly description: "Fires when order is cancelled and its payment status is paid (refund initiated).";
|
|
2887
2917
|
readonly category: "order";
|
|
2888
|
-
readonly sortOrder:
|
|
2918
|
+
readonly sortOrder: 8;
|
|
2889
2919
|
}];
|
|
2890
2920
|
|
|
2891
2921
|
/** @deprecated Use DB catalog `order_notification_triggers`; kept for type hints. */
|
|
2892
2922
|
declare const ORDER_NOTIFICATION_TRIGGERS: readonly [{
|
|
2923
|
+
readonly key: "order_pending";
|
|
2924
|
+
readonly label: "Order pending";
|
|
2925
|
+
}, {
|
|
2926
|
+
readonly key: "order_processing";
|
|
2927
|
+
readonly label: "Order processing";
|
|
2928
|
+
}, {
|
|
2929
|
+
readonly key: "order_completed";
|
|
2930
|
+
readonly label: "Order completed";
|
|
2931
|
+
}, {
|
|
2893
2932
|
readonly key: "order_placed";
|
|
2894
2933
|
readonly label: "Order placed";
|
|
2895
2934
|
}, {
|
|
@@ -4065,7 +4104,8 @@ declare class Attendee {
|
|
|
4065
4104
|
declare enum NotificationChannel {
|
|
4066
4105
|
WHATSAPP = "whatsapp",
|
|
4067
4106
|
EMAIL = "email",
|
|
4068
|
-
MOBILE = "mobile"
|
|
4107
|
+
MOBILE = "mobile",
|
|
4108
|
+
SMS = "sms"
|
|
4069
4109
|
}
|
|
4070
4110
|
declare enum NotificationAudienceType {
|
|
4071
4111
|
CUSTOMERS = "customers",
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
export { emitOrderNotificationTrigger, fireOrderNotificationTrigger } from './chunk-
|
|
2
|
-
import { checkMultiVendorEnabled, loadUserVendorContext, getPublicSettingsGroup, BlogGeneratorService } from './chunk-
|
|
3
|
-
export { Address, Attendee, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, BlogGeneratorService, Brand, CMS_ENTITY_MAP, Cart, CartItem, Category, ChatConversation, ChatMessage, Collection, Combo, ComboItem, Comment, Config, Contact, Currency, CurrencyExchange, Customer, Customer_Contacts, Discount, DiscountRules, Event, EventProduct, Form, FormField, FormSubmission, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, LlmAgent, LlmAgentKnowledgeDocument, Media, MessageTemplate, Order, OrderAddresses, OrderDiscounts, OrderItem, OrderNotificationBinding, OrderNotificationTrigger, OtpChallenge, Page, PasswordResetToken, Payment, Permission, Product, ProductAttribute, ProductCategory, ProductConfig, ProductVariant, RefundPolicy, RefundRequest, RssArticle, RssFeed, Seo, Tag, Tax, User, UserDeviceToken, UserGroup, Vendor, VendorCustomer, VendorRole, VendorRolePermission, VendorUser, VendorUserProfile, Wishlist, WishlistItem, ZIP_MIME_TYPES, applyApprovalStatusSideEffects, applyEventApprovalStatusSideEffects, applyRotatingVendorInvite, applyVendorCustomersContactFilter, applyVendorEventCreateApproval, applyVendorProductCreateApproval, assertCaptchaOk, assertContactAllowedForVendorOrder, assertEventApprovalUpdate, assertProductApprovalUpdate, autoExpireOrderIfPaymentTimeExceeded, buildBlogMetadataUserPrompt, buildCronFromSchedule, buildRssUserPromptFromFeeds, buildUserInviteLink, buildVendorInviteLink, calculateOrderRefundPreview, calculateRefundFromPolicy, checkAndIncrementDiscountUsage, checkEventsEnabled, checkMultiVendorEnabled, completeUserInviteAccept, consumeAppliedDiscountUsages, contactIsVendorCustomer, countDiscountOrdersForContact,
|
|
1
|
+
export { emitOrderNotificationTrigger, fireOrderNotificationTrigger } from './chunk-DTUL3Q5L.js';
|
|
2
|
+
import { checkMultiVendorEnabled, loadUserVendorContext, getPublicSettingsGroup, BlogGeneratorService } from './chunk-77YWLP4X.js';
|
|
3
|
+
export { Address, Attendee, Attribute, BLOG_GENERATOR_AGENT_NAME, BLOG_GENERATOR_DEFAULT_SYSTEM_INSTRUCTION, BLOG_GENERATOR_DEFAULT_VALIDATION_RULES, BLOG_GENERATOR_LLM_AGENT_SLUG, BLOG_GENERATOR_MARKDOWN_ARTICLE_SEPARATOR, BLOG_METADATA_ENRICHER_AGENT_NAME, BLOG_METADATA_ENRICHER_DEFAULT_SYSTEM_INSTRUCTION, BLOG_METADATA_ENRICHER_DEFAULT_VALIDATION_RULES, BLOG_METADATA_ENRICHER_LLM_AGENT_SLUG, Blog, BlogGeneratorService, Brand, CMS_ENTITY_MAP, Cart, CartItem, Category, ChatConversation, ChatMessage, Collection, Combo, ComboItem, Comment, Config, Contact, Currency, CurrencyExchange, Customer, Customer_Contacts, Discount, DiscountRules, Event, EventProduct, Form, FormField, FormSubmission, JobSchedule, JobScheduleRun, KnowledgeBaseChunk, KnowledgeBaseDocument, LlmAgent, LlmAgentKnowledgeDocument, Media, MessageTemplate, Order, OrderAddresses, OrderDiscounts, OrderItem, OrderNotificationBinding, OrderNotificationTrigger, OtpChallenge, Page, PasswordResetToken, Payment, Permission, Product, ProductAttribute, ProductCategory, ProductConfig, ProductVariant, RefundPolicy, RefundRequest, RssArticle, RssFeed, Seo, Tag, Tax, User, UserDeviceToken, UserGroup, Vendor, VendorCustomer, VendorRole, VendorRolePermission, VendorUser, VendorUserProfile, Wishlist, WishlistItem, ZIP_MIME_TYPES, applyApprovalStatusSideEffects, applyEventApprovalStatusSideEffects, applyRotatingVendorInvite, applyVendorCustomersContactFilter, applyVendorEventCreateApproval, applyVendorProductCreateApproval, assertCaptchaOk, assertContactAllowedForVendorOrder, assertEventApprovalUpdate, assertProductApprovalUpdate, autoExpireOrderIfPaymentTimeExceeded, buildBlogMetadataUserPrompt, buildCronFromSchedule, buildRssUserPromptFromFeeds, buildUserInviteLink, buildVendorInviteLink, calculateOrderRefundPreview, calculateRefundFromPolicy, checkAndIncrementDiscountUsage, checkEventsEnabled, checkMultiVendorEnabled, completeUserInviteAccept, consumeAppliedDiscountUsages, contactIsVendorCustomer, countDiscountOrdersForContact, createAnalyticsHandlers, createBlogBySlugHandler, createChangePasswordHandler, createCmsApiHandler, createCmsApp, createCmsAppWithMessaging, createCrudByIdHandler, createCrudHandler, createDashboardStatsHandler, createEcommerceAnalyticsHandler, createEventOrderMessageTemplateHandlers, createForgotPasswordHandler, createFormBySlugHandler, createInviteAcceptHandler, createJobScheduleHandlers, createLlmAgentKnowledgeHandlers, createMediaZipExtractHandler, createMessageTemplateRowLoader, createSetPasswordHandler, createSettingsApiHandlers, createSocialMediaHandlers, createStorefrontApiHandler, createUploadHandler, createUserAuthApiRouter, createUserAvatarHandler, createUserProfileHandler, createUsersApiHandlers, createVendorDashboardHandler, createVendorOnboardHandlers, daysBeforeEventStart, decrementDiscountUsage, describeEventTierPolicy, ensureMessagingPluginsOnCms, ensureScheduleQueueWorker, ensureVendorCustomerForOrderContact, ensureVendorCustomersForOrder, findActiveRefundPolicyForVendor, findUserByInviteToken, findVendorByInviteToken, formatTierRange, getPublicSettingsGroup, getRequireEventApproval, getRequireProductApproval, getRssArticleSummaryFromItem, getVendorCatalogCreateFlags, hydrateVendorSessionUser, invalidateEventsCache, invalidateMultiVendorCache, invalidateRequireEventApprovalCache, invalidateRequireProductApprovalCache, invalidateVendorCatalogCreateFlagsCache, isCustomerTypeContact, isMaxPerUserUsageReached, isMaxTotalUsageReached, isZipMedia, llmAgentToChatAgentOptions, loadSettingsGroupFromDb, loadUserVendorContext, mergeGuardrailsIntoSystemPrompt, messagingPlugins, metaFetchUserManagedPages, metaPostPageFeed, metaPostPagePhoto, metaResolvePageAccessToken, newUserInviteToken, normalizeRefundTiers, overlayCmsPlugins, parseBlogGeneratorAgentContent, parseBlogGeneratorModelOutput, parseBlogMetadataEnrichmentJson, parseLlmAgentValidationRules, pgBossScheduleNameForId, queueErpCreateContactIfEnabled, queueJobScheduleNow, queuePlugin, recordDiscountUsage, registerJobRunnerWorker, registerMessagingQueueProcessors, relativePathFromMediaParentId, resolveBlogCategoryIdByName, resolveSettingsEncryptionKey, resolveVendorIdForContactCheck, sanitizeMediaFolderPath, sanitizeStorageSegment, sendVendorOnboardEmails, simpleDecrypt, simpleEncrypt, syncJobScheduleToPgBoss, validateRefundTiers, validateScheduleInput, validateUserMessageAgainstAgentRules, validateUserMessageAgainstStructuredRules, whatsappPlugin, wrapGetCmsWithMessaging } from './chunk-77YWLP4X.js';
|
|
4
|
+
export { countRecentOtpSends, createOtpChallenge, generateNumericOtp, hashOtpCode, normalizePhoneE164, queueSms, registerSmsQueueProcessor, verifyAndConsumeOtpChallenge, verifyOtpCodeHash } from './chunk-OVTOP42W.js';
|
|
4
5
|
import { PgBossService } from './chunk-GO7PPYNU.js';
|
|
5
6
|
export { JOB_RUNNER_QUEUE, PgBossService } from './chunk-GO7PPYNU.js';
|
|
6
7
|
export { deductInventoryForConfirmedOrder, mergeInventoryLines, orderInventorySnapshotFromRow, orderStatusHoldsStock, reconcileOrderInventoryBetweenSnapshots, restoreInventoryForCancelledOrder, validateInventoryForConfirmedOrderLines, validateInventoryForOrderBecomingConfirmed } from './chunk-3K5AIEIZ.js';
|
|
7
|
-
import { parseEmailRecipientsFromConfig } from './chunk-
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
import { parseEmailRecipientsFromConfig } from './chunk-BWOITUNI.js';
|
|
9
|
+
export { buildEventOrderTemplateVariables, emailPlugin, initWhatsappTriggerDispatcher, joinRecipientsForSend, parseEmailRecipientsFromConfig, resendOrderNotification, serializeEmailRecipients } from './chunk-BWOITUNI.js';
|
|
10
|
+
export { queueWhatsApp, registerWhatsAppQueueProcessor } from './chunk-GWDI752Q.js';
|
|
11
|
+
export { KNOWN_NOTIFICATION_TRIGGERS, notificationTriggerEmitter } from './chunk-AYWDQFJZ.js';
|
|
10
12
|
import './chunk-JXF23MPG.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export { INVOICE_TEMPLATE_IDS, INVOICE_TEMPLATE_OPTIONS, buildLocalInvoicePdfForOrder, generateLocalInvoicePdf,
|
|
13
|
+
export { EmailService, emailTemplates, renderEmail, renderLayout } from './chunk-KAOHOHCA.js';
|
|
14
|
+
import { queueOrderPlacedEmails } from './chunk-RXTUSF3R.js';
|
|
15
|
+
export { queueEmail, queueOrderPlacedEmails, queueVendorOnboardEmails, registerEmailQueueProcessor } from './chunk-RXTUSF3R.js';
|
|
16
|
+
export { INVOICE_TEMPLATE_IDS, INVOICE_TEMPLATE_OPTIONS, buildLocalInvoicePdfForOrder, generateLocalInvoicePdf, isOrderEligibleForInvoiceEmail, normalizeInvoiceTemplateId, resolveInvoiceAssetUrl, resolveOrderInvoicePdfBytes, streamOrderInvoicePdf } from './chunk-MWEK7N3F.js';
|
|
15
17
|
import './chunk-JC6DLWTE.js';
|
|
18
|
+
import { mergeEmailLayoutCompanyDetails } from './chunk-3VZAAQUV.js';
|
|
19
|
+
export { getCompanyDetailsFromSettings, mergeEmailLayoutCompanyDetails } from './chunk-3VZAAQUV.js';
|
|
16
20
|
import './chunk-MQBT33IV.js';
|
|
17
21
|
import './chunk-CRFV5WJK.js';
|
|
18
22
|
export { EVENT_ORDER_MESSAGE_TEMPLATE_DEFAULTS, EVENT_ORDER_TEMPLATE_KEY, EVENT_ORDER_TEMPLATE_VARIABLES, resolveEventOrderTemplate } from './chunk-AYERBA7I.js';
|
|
@@ -774,10 +778,6 @@ function resolveSmsProvider(cfg) {
|
|
|
774
778
|
return null;
|
|
775
779
|
}
|
|
776
780
|
__name(resolveSmsProvider, "resolveSmsProvider");
|
|
777
|
-
function anySmsProviderConfigured(cfg) {
|
|
778
|
-
return resolveSmsProvider(cfg) !== null;
|
|
779
|
-
}
|
|
780
|
-
__name(anySmsProviderConfigured, "anySmsProviderConfigured");
|
|
781
781
|
var MSG91_FLOW_URL = "https://control.msg91.com/api/v5/flow/";
|
|
782
782
|
async function sendViaMsg91Flow(cfg, to, body, opts, overrides) {
|
|
783
783
|
const authkey = cfg.msg91AuthKey;
|
|
@@ -987,17 +987,33 @@ function smsPlugin(config = {}) {
|
|
|
987
987
|
async init(context) {
|
|
988
988
|
const env = context.config;
|
|
989
989
|
const { getSmsSettings, getMessageTemplateRow, ...staticRest } = config;
|
|
990
|
+
let settingsLoader = getSmsSettings;
|
|
991
|
+
if (!settingsLoader && context.dataSource) {
|
|
992
|
+
settingsLoader = /* @__PURE__ */ __name(async () => {
|
|
993
|
+
try {
|
|
994
|
+
const ds = context.dataSource;
|
|
995
|
+
const repo = ds.getRepository("configs");
|
|
996
|
+
const rows = await repo.find({
|
|
997
|
+
where: {
|
|
998
|
+
settings: "sms",
|
|
999
|
+
deleted: false
|
|
1000
|
+
}
|
|
1001
|
+
});
|
|
1002
|
+
return Object.fromEntries(rows.map((r) => [
|
|
1003
|
+
r.key,
|
|
1004
|
+
r.value
|
|
1005
|
+
]));
|
|
1006
|
+
} catch {
|
|
1007
|
+
return {};
|
|
1008
|
+
}
|
|
1009
|
+
}, "settingsLoader");
|
|
1010
|
+
}
|
|
990
1011
|
let db = {};
|
|
991
1012
|
try {
|
|
992
|
-
db = await
|
|
1013
|
+
db = await settingsLoader?.() ?? {};
|
|
993
1014
|
} catch {
|
|
994
1015
|
}
|
|
995
|
-
const
|
|
996
|
-
if (!anySmsProviderConfigured(merged)) {
|
|
997
|
-
context.logger.warn("SMS plugin skipped: set MSG91_AUTH_KEY (Flow template id per Plugins \u2192 SMS templates or MSG91_TEMPLATE_ID; or sendhttp: MSG91_SENDER_ID), or TWILIO_*, or SMS_WEBHOOK_URL");
|
|
998
|
-
return null;
|
|
999
|
-
}
|
|
1000
|
-
const svc = new SmsService(env, staticRest, getSmsSettings, getMessageTemplateRow);
|
|
1016
|
+
const svc = new SmsService(env, staticRest, settingsLoader, getMessageTemplateRow);
|
|
1001
1017
|
return {
|
|
1002
1018
|
send: /* @__PURE__ */ __name((opts) => svc.send(opts), "send")
|
|
1003
1019
|
};
|
|
@@ -2673,11 +2689,12 @@ async function sendOrderPlacedEmailsAfterConfirmation(orderId, deps) {
|
|
|
2673
2689
|
}
|
|
2674
2690
|
} catch {
|
|
2675
2691
|
}
|
|
2676
|
-
const [branding, emailSettings] = await Promise.all([
|
|
2692
|
+
const [branding, emailSettings, storeSettings] = await Promise.all([
|
|
2677
2693
|
getSettingsGroup(deps, "branding"),
|
|
2678
|
-
getSettingsGroup(deps, "email")
|
|
2694
|
+
getSettingsGroup(deps, "email"),
|
|
2695
|
+
getSettingsGroup(deps, "store")
|
|
2679
2696
|
]);
|
|
2680
|
-
const companyDetails = mergeEmailLayoutCompanyDetails(branding, emailSettings);
|
|
2697
|
+
const companyDetails = mergeEmailLayoutCompanyDetails(branding, emailSettings, storeSettings);
|
|
2681
2698
|
const salesTeamEmails = parseEmailRecipientsFromConfig(emailSettings.salesTeamEmails ?? emailSettings.salesTeamEmail);
|
|
2682
2699
|
const cms = await deps.getCms();
|
|
2683
2700
|
if (customerEmail) {
|
|
@@ -2721,45 +2738,78 @@ __name(sendOrderPlacedEmailsAfterConfirmation, "sendOrderPlacedEmailsAfterConfir
|
|
|
2721
2738
|
|
|
2722
2739
|
// src/lib/order-notification-trigger-seeds.ts
|
|
2723
2740
|
var DEFAULT_ORDER_NOTIFICATION_TRIGGER_SEEDS = [
|
|
2741
|
+
{
|
|
2742
|
+
triggerKey: "order_pending",
|
|
2743
|
+
label: "Order pending",
|
|
2744
|
+
description: "Fires when an order is created and pending confirmation or payment.",
|
|
2745
|
+
category: "order",
|
|
2746
|
+
sortOrder: 1
|
|
2747
|
+
},
|
|
2748
|
+
{
|
|
2749
|
+
triggerKey: "order_processing",
|
|
2750
|
+
label: "Order processing",
|
|
2751
|
+
description: "Fires when an order moves to processing after being assigned.",
|
|
2752
|
+
category: "order",
|
|
2753
|
+
sortOrder: 2
|
|
2754
|
+
},
|
|
2755
|
+
{
|
|
2756
|
+
triggerKey: "order_completed",
|
|
2757
|
+
label: "Order completed",
|
|
2758
|
+
description: "Fires when an order is completed after customer OTP validation.",
|
|
2759
|
+
category: "order",
|
|
2760
|
+
sortOrder: 3
|
|
2761
|
+
},
|
|
2724
2762
|
{
|
|
2725
2763
|
triggerKey: "order_placed",
|
|
2726
2764
|
label: "Order placed",
|
|
2727
2765
|
description: "Fires when a new order is created (storefront checkout or admin).",
|
|
2728
2766
|
category: "order",
|
|
2729
|
-
sortOrder:
|
|
2767
|
+
sortOrder: 4
|
|
2730
2768
|
},
|
|
2731
2769
|
{
|
|
2732
2770
|
triggerKey: "order_cancelled",
|
|
2733
2771
|
label: "Order cancelled",
|
|
2734
2772
|
description: "Fires when an order is cancelled (includes refund amount when applicable).",
|
|
2735
2773
|
category: "order",
|
|
2736
|
-
sortOrder:
|
|
2774
|
+
sortOrder: 5
|
|
2737
2775
|
},
|
|
2738
2776
|
{
|
|
2739
2777
|
triggerKey: "payment_success",
|
|
2740
2778
|
label: "Payment success",
|
|
2741
2779
|
description: "Fires when order is placed and payment status is paid.",
|
|
2742
2780
|
category: "order",
|
|
2743
|
-
sortOrder:
|
|
2781
|
+
sortOrder: 6
|
|
2744
2782
|
},
|
|
2745
2783
|
{
|
|
2746
2784
|
triggerKey: "payment_failed",
|
|
2747
2785
|
label: "Payment failed",
|
|
2748
2786
|
description: "Fires when payment status is pending, unpaid, or failed, or when order is cancelled without payment.",
|
|
2749
2787
|
category: "order",
|
|
2750
|
-
sortOrder:
|
|
2788
|
+
sortOrder: 7
|
|
2751
2789
|
},
|
|
2752
2790
|
{
|
|
2753
2791
|
triggerKey: "payment_refund_initiated",
|
|
2754
2792
|
label: "Payment refund initiated",
|
|
2755
2793
|
description: "Fires when order is cancelled and its payment status is paid (refund initiated).",
|
|
2756
2794
|
category: "order",
|
|
2757
|
-
sortOrder:
|
|
2795
|
+
sortOrder: 8
|
|
2758
2796
|
}
|
|
2759
2797
|
];
|
|
2760
2798
|
|
|
2761
2799
|
// src/lib/order-notification-triggers.ts
|
|
2762
2800
|
var ORDER_NOTIFICATION_TRIGGERS = [
|
|
2801
|
+
{
|
|
2802
|
+
key: "order_pending",
|
|
2803
|
+
label: "Order pending"
|
|
2804
|
+
},
|
|
2805
|
+
{
|
|
2806
|
+
key: "order_processing",
|
|
2807
|
+
label: "Order processing"
|
|
2808
|
+
},
|
|
2809
|
+
{
|
|
2810
|
+
key: "order_completed",
|
|
2811
|
+
label: "Order completed"
|
|
2812
|
+
},
|
|
2763
2813
|
{
|
|
2764
2814
|
key: "order_placed",
|
|
2765
2815
|
label: "Order placed"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class AddOrderPendingProcessingCompletedTriggers1783000000000 implements MigrationInterface {
|
|
4
|
+
name = "AddOrderPendingProcessingCompletedTriggers1783000000000";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
const tableExists = await queryRunner.hasTable("notification_triggers");
|
|
8
|
+
if (!tableExists) return;
|
|
9
|
+
|
|
10
|
+
const triggers = [
|
|
11
|
+
{
|
|
12
|
+
id: "order.pending",
|
|
13
|
+
name: "Order Pending",
|
|
14
|
+
description: "Triggered when a customer places an order and it is pending confirmation or payment.",
|
|
15
|
+
category: "orders",
|
|
16
|
+
enabled: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "order.processing",
|
|
20
|
+
name: "Order Processing",
|
|
21
|
+
description: "Triggered when an order transitions to processing status after being assigned to a team member.",
|
|
22
|
+
category: "orders",
|
|
23
|
+
enabled: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "order.completed",
|
|
27
|
+
name: "Order Completed",
|
|
28
|
+
description: "Triggered when an order is completed after customer OTP validation.",
|
|
29
|
+
category: "orders",
|
|
30
|
+
enabled: true,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
for (const t of triggers) {
|
|
35
|
+
await queryRunner.query(
|
|
36
|
+
`INSERT INTO "notification_triggers" ("id", "name", "description", "category", "enabled")
|
|
37
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
38
|
+
ON CONFLICT ("id") DO UPDATE
|
|
39
|
+
SET "name" = EXCLUDED."name",
|
|
40
|
+
"description" = EXCLUDED."description",
|
|
41
|
+
"category" = EXCLUDED."category",
|
|
42
|
+
"enabled" = EXCLUDED."enabled"`,
|
|
43
|
+
[t.id, t.name, t.description, t.category, t.enabled]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
49
|
+
const tableExists = await queryRunner.hasTable("notification_triggers");
|
|
50
|
+
if (!tableExists) return;
|
|
51
|
+
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`DELETE FROM "notification_triggers" WHERE "id" IN ('order.pending', 'order.processing', 'order.completed')`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class AddSmsToOrderNotificationBindingsChannelEnum1783100000000 implements MigrationInterface {
|
|
4
|
+
name = "AddSmsToOrderNotificationBindingsChannelEnum1783100000000";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
try {
|
|
8
|
+
await queryRunner.query(`ALTER TYPE "order_notification_bindings_channel_enum" ADD VALUE IF NOT EXISTS 'sms'`);
|
|
9
|
+
} catch {
|
|
10
|
+
/* ignore if enum doesn't exist or already added */
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public async down(_queryRunner: QueryRunner): Promise<void> {
|
|
15
|
+
// Enum values cannot easily be removed in Postgres without recreating
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
/** Add assignedUserId and assignedAt columns to orders table. */
|
|
4
|
+
export class AddOrderAssigneeColumns1783200000000 implements MigrationInterface {
|
|
5
|
+
name = 'AddOrderAssigneeColumns1783200000000';
|
|
6
|
+
|
|
7
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
8
|
+
await queryRunner.query(`
|
|
9
|
+
ALTER TABLE "orders"
|
|
10
|
+
ADD COLUMN IF NOT EXISTS "assignedUserId" integer NULL,
|
|
11
|
+
ADD COLUMN IF NOT EXISTS "assignedAt" TIMESTAMP NULL;
|
|
12
|
+
`);
|
|
13
|
+
|
|
14
|
+
await queryRunner.query(`
|
|
15
|
+
CREATE INDEX IF NOT EXISTS "IDX_orders_assigned_user"
|
|
16
|
+
ON "orders" ("assignedUserId");
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
21
|
+
await queryRunner.query(`
|
|
22
|
+
DROP INDEX IF EXISTS "IDX_orders_assigned_user";
|
|
23
|
+
`);
|
|
24
|
+
await queryRunner.query(`
|
|
25
|
+
ALTER TABLE "orders"
|
|
26
|
+
DROP COLUMN IF EXISTS "assignedAt",
|
|
27
|
+
DROP COLUMN IF EXISTS "assignedUserId";
|
|
28
|
+
`);
|
|
29
|
+
}
|
|
30
|
+
}
|