fuze-store-shared 1.0.0 → 1.0.1
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/.prettierignore +2 -0
- package/.prettierrc +9 -0
- package/dist/enums/index.d.ts +11 -0
- package/dist/enums/index.d.ts.map +1 -0
- package/dist/enums/index.js +50 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/enums/plan.enum.d.ts +47 -0
- package/dist/enums/plan.enum.d.ts.map +1 -0
- package/dist/enums/plan.enum.js +52 -0
- package/dist/enums/plan.enum.js.map +1 -0
- package/dist/enums/subscription.enum.d.ts +13 -0
- package/dist/enums/subscription.enum.d.ts.map +1 -0
- package/dist/enums/subscription.enum.js +17 -0
- package/dist/enums/subscription.enum.js.map +1 -0
- package/dist/helpers/date.helper.d.ts +18 -0
- package/dist/helpers/date.helper.d.ts.map +1 -0
- package/dist/helpers/date.helper.js +27 -0
- package/dist/helpers/date.helper.js.map +1 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/index.d.ts.map +1 -0
- package/dist/helpers/index.js +47 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/plan.helper.d.ts +72 -0
- package/dist/helpers/plan.helper.d.ts.map +1 -0
- package/dist/helpers/plan.helper.js +211 -0
- package/dist/helpers/plan.helper.js.map +1 -0
- package/dist/types/plan.d.ts +3 -2
- package/dist/types/plan.d.ts.map +1 -1
- package/eslint.config.mjs +28 -0
- package/package.json +20 -4
- package/src/enums/index.ts +14 -0
- package/src/enums/plan.enum.ts +48 -0
- package/src/enums/subscription.enum.ts +13 -0
- package/src/helpers/date.helper.ts +29 -0
- package/src/helpers/index.ts +11 -0
- package/src/helpers/plan.helper.ts +249 -0
- package/src/index.ts +0 -1
- package/src/types/plan.ts +3 -2
- package/src/types/subscription.ts +4 -4
- package/tsconfig.json +4 -2
package/.prettierignore
ADDED
package/.prettierrc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
export * from './plan.enum';
|
2
|
+
export * from './subscription.enum';
|
3
|
+
import * as planEnum from './plan.enum';
|
4
|
+
import * as subscriptionEnum from './subscription.enum';
|
5
|
+
declare const enums: {
|
6
|
+
Status: typeof subscriptionEnum.Status;
|
7
|
+
Feature: typeof planEnum.Feature;
|
8
|
+
Plan: typeof planEnum.Plan;
|
9
|
+
};
|
10
|
+
export default enums;
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AAGpC,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAC;AAGxD,QAAA,MAAM,KAAK;;;;CAGV,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
20
|
+
};
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
22
|
+
var ownKeys = function(o) {
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
24
|
+
var ar = [];
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
26
|
+
return ar;
|
27
|
+
};
|
28
|
+
return ownKeys(o);
|
29
|
+
};
|
30
|
+
return function (mod) {
|
31
|
+
if (mod && mod.__esModule) return mod;
|
32
|
+
var result = {};
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
34
|
+
__setModuleDefault(result, mod);
|
35
|
+
return result;
|
36
|
+
};
|
37
|
+
})();
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
// Named exports
|
40
|
+
__exportStar(require("./plan.enum"), exports);
|
41
|
+
__exportStar(require("./subscription.enum"), exports);
|
42
|
+
// Default export object
|
43
|
+
const planEnum = __importStar(require("./plan.enum"));
|
44
|
+
const subscriptionEnum = __importStar(require("./subscription.enum"));
|
45
|
+
const enums = {
|
46
|
+
...planEnum,
|
47
|
+
...subscriptionEnum,
|
48
|
+
};
|
49
|
+
exports.default = enums;
|
50
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/enums/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAgB;AAChB,8CAA4B;AAC5B,sDAAoC;AAEpC,wBAAwB;AACxB,sDAAwC;AACxC,sEAAwD;AAGxD,MAAM,KAAK,GAAG;IACZ,GAAG,QAAQ;IACX,GAAG,gBAAgB;CACpB,CAAC;AAEF,kBAAe,KAAK,CAAC"}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/**
|
2
|
+
* List of plan enums
|
3
|
+
*
|
4
|
+
* @module PlanEnums
|
5
|
+
* @category Enums
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
export declare enum Feature {
|
9
|
+
DASHBOARD = "dashboard",
|
10
|
+
POS = "pos",
|
11
|
+
EVENT_BASIC = "event_basic",// List View
|
12
|
+
EVENT_ADVANCED = "event_advanced",// Calendar, Agenda, Day, List View
|
13
|
+
AREA = "area",// Area Management
|
14
|
+
UNIT = "unit",// Unit Management
|
15
|
+
TRANSACTIONS = "transactions",// Order Histories, Sales Transactions
|
16
|
+
REFUNDS = "refunds",// Sales Refunds
|
17
|
+
CATALOGS = "catalogs",// Categories, Products, Services, Modifiers
|
18
|
+
STAFFS = "staffs",
|
19
|
+
CUSTOMERS = "customers",
|
20
|
+
ROLES_AND_PERMISSIONS = "roles_and_permissions",
|
21
|
+
REALTIME_SYNC = "realtime_sync",
|
22
|
+
IMPORT_DATA = "import_data",
|
23
|
+
EXPORT_DATA = "export_data",
|
24
|
+
TAXES = "taxes",
|
25
|
+
ORDER_HISTORIES = "order_histories",
|
26
|
+
GIFT_CARDS = "gift_cards",
|
27
|
+
REPORTS_BASICS = "reports_basic",// View Basic Reports
|
28
|
+
REPORTS_ADVANCED = "reports_advanced",// View, Download Reports
|
29
|
+
EXPENSES = "expenses",
|
30
|
+
DISCOUNTS_BASIC = "discounts_basic",// Basic Discounts
|
31
|
+
DISCOUNTS_ADVANCED = "discounts_advanced",// Basic with Schedules
|
32
|
+
STORE_SESSION = "store_session",// Store Session Management
|
33
|
+
EMAIL_NOTIFICATIONS = "email_notifications",// Email Notifications
|
34
|
+
SMS_NOTIFICATIONS = "sms_notifications",// TODO=
|
35
|
+
PRINTER = "printer",
|
36
|
+
STORE_LIMIT = "store_limit",
|
37
|
+
WAITING_LIST = "waiting_list",
|
38
|
+
AI_AGENT = "ai_agent"
|
39
|
+
}
|
40
|
+
export declare enum Plan {
|
41
|
+
FREETRIAL = "FREETRIAL",
|
42
|
+
STARTER = "STARTER",
|
43
|
+
BASIC = "BASIC",
|
44
|
+
STANDARD = "STANDARD",
|
45
|
+
PREMIUM = "PREMIUM"
|
46
|
+
}
|
47
|
+
//# sourceMappingURL=plan.enum.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plan.enum.d.ts","sourceRoot":"","sources":["../../src/enums/plan.enum.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oBAAY,OAAO;IACjB,SAAS,cAAc;IACvB,GAAG,QAAQ;IACX,WAAW,gBAAgB,CAAE,YAAY;IACzC,cAAc,mBAAmB,CAAE,mCAAmC;IACtE,IAAI,SAAS,CAAE,kBAAkB;IACjC,IAAI,SAAS,CAAE,kBAAkB;IACjC,YAAY,iBAAiB,CAAE,sCAAsC;IACrE,OAAO,YAAY,CAAE,gBAAgB;IACrC,QAAQ,aAAa,CAAE,4CAA4C;IACnE,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,qBAAqB,0BAA0B;IAC/C,aAAa,kBAAkB;IAC/B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,KAAK,UAAU;IACf,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,cAAc,kBAAkB,CAAE,qBAAqB;IACvD,gBAAgB,qBAAqB,CAAE,yBAAyB;IAChE,QAAQ,aAAa;IACrB,eAAe,oBAAoB,CAAE,kBAAkB;IACvD,kBAAkB,uBAAuB,CAAE,uBAAuB;IAClE,aAAa,kBAAkB,CAAE,2BAA2B;IAC5D,mBAAmB,wBAAwB,CAAE,sBAAsB;IACnE,iBAAiB,sBAAsB,CAAE,QAAQ;IACjD,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;CACtB;AAED,oBAAY,IAAI;IACd,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB"}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* List of plan enums
|
4
|
+
*
|
5
|
+
* @module PlanEnums
|
6
|
+
* @category Enums
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.Plan = exports.Feature = void 0;
|
11
|
+
var Feature;
|
12
|
+
(function (Feature) {
|
13
|
+
Feature["DASHBOARD"] = "dashboard";
|
14
|
+
Feature["POS"] = "pos";
|
15
|
+
Feature["EVENT_BASIC"] = "event_basic";
|
16
|
+
Feature["EVENT_ADVANCED"] = "event_advanced";
|
17
|
+
Feature["AREA"] = "area";
|
18
|
+
Feature["UNIT"] = "unit";
|
19
|
+
Feature["TRANSACTIONS"] = "transactions";
|
20
|
+
Feature["REFUNDS"] = "refunds";
|
21
|
+
Feature["CATALOGS"] = "catalogs";
|
22
|
+
Feature["STAFFS"] = "staffs";
|
23
|
+
Feature["CUSTOMERS"] = "customers";
|
24
|
+
Feature["ROLES_AND_PERMISSIONS"] = "roles_and_permissions";
|
25
|
+
Feature["REALTIME_SYNC"] = "realtime_sync";
|
26
|
+
Feature["IMPORT_DATA"] = "import_data";
|
27
|
+
Feature["EXPORT_DATA"] = "export_data";
|
28
|
+
Feature["TAXES"] = "taxes";
|
29
|
+
Feature["ORDER_HISTORIES"] = "order_histories";
|
30
|
+
Feature["GIFT_CARDS"] = "gift_cards";
|
31
|
+
Feature["REPORTS_BASICS"] = "reports_basic";
|
32
|
+
Feature["REPORTS_ADVANCED"] = "reports_advanced";
|
33
|
+
Feature["EXPENSES"] = "expenses";
|
34
|
+
Feature["DISCOUNTS_BASIC"] = "discounts_basic";
|
35
|
+
Feature["DISCOUNTS_ADVANCED"] = "discounts_advanced";
|
36
|
+
Feature["STORE_SESSION"] = "store_session";
|
37
|
+
Feature["EMAIL_NOTIFICATIONS"] = "email_notifications";
|
38
|
+
Feature["SMS_NOTIFICATIONS"] = "sms_notifications";
|
39
|
+
Feature["PRINTER"] = "printer";
|
40
|
+
Feature["STORE_LIMIT"] = "store_limit";
|
41
|
+
Feature["WAITING_LIST"] = "waiting_list";
|
42
|
+
Feature["AI_AGENT"] = "ai_agent";
|
43
|
+
})(Feature || (exports.Feature = Feature = {}));
|
44
|
+
var Plan;
|
45
|
+
(function (Plan) {
|
46
|
+
Plan["FREETRIAL"] = "FREETRIAL";
|
47
|
+
Plan["STARTER"] = "STARTER";
|
48
|
+
Plan["BASIC"] = "BASIC";
|
49
|
+
Plan["STANDARD"] = "STANDARD";
|
50
|
+
Plan["PREMIUM"] = "PREMIUM";
|
51
|
+
})(Plan || (exports.Plan = Plan = {}));
|
52
|
+
//# sourceMappingURL=plan.enum.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plan.enum.js","sourceRoot":"","sources":["../../src/enums/plan.enum.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,IAAY,OA+BX;AA/BD,WAAY,OAAO;IACjB,kCAAuB,CAAA;IACvB,sBAAW,CAAA;IACX,sCAA2B,CAAA;IAC3B,4CAAiC,CAAA;IACjC,wBAAa,CAAA;IACb,wBAAa,CAAA;IACb,wCAA6B,CAAA;IAC7B,8BAAmB,CAAA;IACnB,gCAAqB,CAAA;IACrB,4BAAiB,CAAA;IACjB,kCAAuB,CAAA;IACvB,0DAA+C,CAAA;IAC/C,0CAA+B,CAAA;IAC/B,sCAA2B,CAAA;IAC3B,sCAA2B,CAAA;IAC3B,0BAAe,CAAA;IACf,8CAAmC,CAAA;IACnC,oCAAyB,CAAA;IACzB,2CAAgC,CAAA;IAChC,gDAAqC,CAAA;IACrC,gCAAqB,CAAA;IACrB,8CAAmC,CAAA;IACnC,oDAAyC,CAAA;IACzC,0CAA+B,CAAA;IAC/B,sDAA2C,CAAA;IAC3C,kDAAuC,CAAA;IACvC,8BAAmB,CAAA;IACnB,sCAA2B,CAAA;IAC3B,wCAA6B,CAAA;IAC7B,gCAAqB,CAAA;AACvB,CAAC,EA/BW,OAAO,uBAAP,OAAO,QA+BlB;AAED,IAAY,IAMX;AAND,WAAY,IAAI;IACd,+BAAuB,CAAA;IACvB,2BAAmB,CAAA;IACnB,uBAAe,CAAA;IACf,6BAAqB,CAAA;IACrB,2BAAmB,CAAA;AACrB,CAAC,EANW,IAAI,oBAAJ,IAAI,QAMf"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"subscription.enum.d.ts","sourceRoot":"","sources":["../../src/enums/subscription.enum.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oBAAY,MAAM;IAChB,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* List of subscription enums
|
4
|
+
*
|
5
|
+
* @module SubscriptionEnums
|
6
|
+
* @category Enums
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.Status = void 0;
|
11
|
+
var Status;
|
12
|
+
(function (Status) {
|
13
|
+
Status["ACTIVE"] = "ACTIVE";
|
14
|
+
Status["PENDING"] = "PENDING";
|
15
|
+
Status["CANCELED"] = "CANCELED";
|
16
|
+
})(Status || (exports.Status = Status = {}));
|
17
|
+
//# sourceMappingURL=subscription.enum.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"subscription.enum.js","sourceRoot":"","sources":["../../src/enums/subscription.enum.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,6BAAmB,CAAA;IACnB,+BAAqB,CAAA;AACvB,CAAC,EAJW,MAAM,sBAAN,MAAM,QAIjB"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* List of date helpers
|
3
|
+
*
|
4
|
+
* @module DateHelper
|
5
|
+
* @category Helpers
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
/**
|
9
|
+
* Formats a given date into a specified string pattern.
|
10
|
+
*
|
11
|
+
* @param date - The date to format, which can be a `Date` object or an ISO date string. If omitted, returns an empty string.
|
12
|
+
* @param patterns - The format pattern to use (default: `'MMM dd, yyyy hh:mm aa'`).
|
13
|
+
* @returns The formatted date string, or an empty string if no date is provided.
|
14
|
+
*
|
15
|
+
* @see https://date-fns.org/docs/format
|
16
|
+
*/
|
17
|
+
export declare function formatDate(date?: Date | string, patterns?: string): string;
|
18
|
+
//# sourceMappingURL=date.helper.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"date.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/date.helper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,EACpB,QAAQ,SAA0B,UAOnC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* List of date helpers
|
4
|
+
*
|
5
|
+
* @module DateHelper
|
6
|
+
* @category Helpers
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.formatDate = formatDate;
|
11
|
+
const date_fns_1 = require("date-fns");
|
12
|
+
/**
|
13
|
+
* Formats a given date into a specified string pattern.
|
14
|
+
*
|
15
|
+
* @param date - The date to format, which can be a `Date` object or an ISO date string. If omitted, returns an empty string.
|
16
|
+
* @param patterns - The format pattern to use (default: `'MMM dd, yyyy hh:mm aa'`).
|
17
|
+
* @returns The formatted date string, or an empty string if no date is provided.
|
18
|
+
*
|
19
|
+
* @see https://date-fns.org/docs/format
|
20
|
+
*/
|
21
|
+
function formatDate(date, patterns = 'MMM dd, yyyy hh:mm aa') {
|
22
|
+
if (date) {
|
23
|
+
return (0, date_fns_1.format)(new Date(date), patterns);
|
24
|
+
}
|
25
|
+
return '';
|
26
|
+
}
|
27
|
+
//# sourceMappingURL=date.helper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"date.helper.js","sourceRoot":"","sources":["../../src/helpers/date.helper.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAaH,gCASC;AApBD,uCAAkC;AAElC;;;;;;;;GAQG;AACH,SAAgB,UAAU,CACxB,IAAoB,EACpB,QAAQ,GAAG,uBAAuB;IAElC,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAA,iBAAM,EAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC;AAM9B,QAAA,MAAM,MAAM;;CAEX,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
20
|
+
};
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
22
|
+
var ownKeys = function(o) {
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
24
|
+
var ar = [];
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
26
|
+
return ar;
|
27
|
+
};
|
28
|
+
return ownKeys(o);
|
29
|
+
};
|
30
|
+
return function (mod) {
|
31
|
+
if (mod && mod.__esModule) return mod;
|
32
|
+
var result = {};
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
34
|
+
__setModuleDefault(result, mod);
|
35
|
+
return result;
|
36
|
+
};
|
37
|
+
})();
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
// Named exports
|
40
|
+
__exportStar(require("./date.helper"), exports);
|
41
|
+
// Default export object
|
42
|
+
const dateHelper = __importStar(require("./date.helper"));
|
43
|
+
const helper = {
|
44
|
+
...dateHelper,
|
45
|
+
};
|
46
|
+
exports.default = helper;
|
47
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gBAAgB;AAChB,gDAA8B;AAE9B,wBAAwB;AACxB,0DAA4C;AAG5C,MAAM,MAAM,GAAG;IACb,GAAG,UAAU;CACd,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/**
|
2
|
+
* List of plan helpers
|
3
|
+
*
|
4
|
+
* @module PlanHelper
|
5
|
+
* @category Helpers
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
import { Plan as SubscriptionPlan } from '../enums/plan.enum';
|
9
|
+
import { Plan, PlanFeatureValue } from '../types/plan';
|
10
|
+
/**
|
11
|
+
* A mapping of feature keys to their corresponding human-readable labels.
|
12
|
+
*
|
13
|
+
* This record is used to display user-friendly names for various features
|
14
|
+
* throughout the application, such as in plan selection, feature lists, or UI components.
|
15
|
+
*
|
16
|
+
* @remarks
|
17
|
+
* Each key represents a unique feature identifier, and the value is the label shown to users.
|
18
|
+
*
|
19
|
+
* @example
|
20
|
+
* ```typescript
|
21
|
+
* const label = featureLabels['dashboard']; // "Dashboard"
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export declare const featureLabels: Record<string, string>;
|
25
|
+
/**
|
26
|
+
* Returns the features that are unique to a specific plan compared to all lower-tier plans.
|
27
|
+
*
|
28
|
+
* The function compares the features of the target plan against all plans lower in the hierarchy.
|
29
|
+
* A feature is considered unique if all lower-tier plans either lack the feature or have a strictly lesser value.
|
30
|
+
* Supports boolean and numeric feature values.
|
31
|
+
*
|
32
|
+
* @param planCode - The code of the target plan to compare (case-insensitive).
|
33
|
+
* @param plans - An array of all available plans, each with a code and features.
|
34
|
+
* @returns An object mapping feature keys to their unique values for the target plan.
|
35
|
+
* @throws If the plan code is invalid or the plan is not found in the provided plans array.
|
36
|
+
*/
|
37
|
+
export declare function getUniqueFeaturesByPlan(planCode: SubscriptionPlan, plans: Plan[]): Record<string, PlanFeatureValue>;
|
38
|
+
/**
|
39
|
+
* Returns an array of unique feature names for a given subscription plan.
|
40
|
+
*
|
41
|
+
* @param planCode - The code representing the subscription plan to retrieve features for.
|
42
|
+
* @param plans - An array of available plans to search for unique features.
|
43
|
+
* @returns An array of strings representing the names of unique features for the specified plan.
|
44
|
+
*/
|
45
|
+
export declare function getUniqueKeyFeaturesByPlan(planCode: SubscriptionPlan, plans: Plan[]): string[];
|
46
|
+
/**
|
47
|
+
* Returns a mapping of feature keys to the values of those features in plans
|
48
|
+
* that differ from the PREMIUM plan.
|
49
|
+
*
|
50
|
+
* For each feature in the PREMIUM plan, if any other plan has a different value
|
51
|
+
* for that feature, the result will include an entry for that feature. The entry
|
52
|
+
* maps each plan code (excluding PREMIUM) to its differing feature value.
|
53
|
+
*
|
54
|
+
* @param plans - Array of Plan objects to compare, each containing a set of features.
|
55
|
+
* @returns An object where each key is a feature that differs from the PREMIUM plan,
|
56
|
+
* and the value is an object mapping plan codes to their differing feature values.
|
57
|
+
*/
|
58
|
+
export declare function getDifferentFeaturesValues(plans: Plan[]): Record<string, Record<string, PlanFeatureValue>>;
|
59
|
+
/**
|
60
|
+
* Returns a formatted string representation of a plan feature value based on the feature type.
|
61
|
+
*
|
62
|
+
* - For numeric values, formats the value and appends a descriptive label depending on the feature.
|
63
|
+
* - For boolean values, returns "Unlimited" for certain features if `true`, otherwise "Included".
|
64
|
+
* - For string values, returns the value as-is.
|
65
|
+
* - Returns "--" if the value does not match any expected type.
|
66
|
+
*
|
67
|
+
* @param value - The value of the plan feature, which can be a number, boolean, or string.
|
68
|
+
* @param feature - The feature key used to determine formatting and labeling.
|
69
|
+
* @returns A formatted string representing the feature value for display purposes.
|
70
|
+
*/
|
71
|
+
export declare function getFeatureValue(value: PlanFeatureValue, feature: string): string;
|
72
|
+
//# sourceMappingURL=plan.helper.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plan.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/plan.helper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAW,IAAI,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8BhD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,IAAI,EAAE,oCAwCd;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,IAAI,EAAE,YAId;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,IAAI,EAAE,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CA0BlD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,UAkEvE"}
|
@@ -0,0 +1,211 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* List of plan helpers
|
4
|
+
*
|
5
|
+
* @module PlanHelper
|
6
|
+
* @category Helpers
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
10
|
+
exports.featureLabels = void 0;
|
11
|
+
exports.getUniqueFeaturesByPlan = getUniqueFeaturesByPlan;
|
12
|
+
exports.getUniqueKeyFeaturesByPlan = getUniqueKeyFeaturesByPlan;
|
13
|
+
exports.getDifferentFeaturesValues = getDifferentFeaturesValues;
|
14
|
+
exports.getFeatureValue = getFeatureValue;
|
15
|
+
const plan_enum_1 = require("../enums/plan.enum");
|
16
|
+
/**
|
17
|
+
* A mapping of feature keys to their corresponding human-readable labels.
|
18
|
+
*
|
19
|
+
* This record is used to display user-friendly names for various features
|
20
|
+
* throughout the application, such as in plan selection, feature lists, or UI components.
|
21
|
+
*
|
22
|
+
* @remarks
|
23
|
+
* Each key represents a unique feature identifier, and the value is the label shown to users.
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
* ```typescript
|
27
|
+
* const label = featureLabels['dashboard']; // "Dashboard"
|
28
|
+
* ```
|
29
|
+
*/
|
30
|
+
exports.featureLabels = {
|
31
|
+
dashboard: 'Dashboard',
|
32
|
+
pos: 'Point of Sales',
|
33
|
+
event_basic: 'Basic Events',
|
34
|
+
event_advanced: 'Advanced Events',
|
35
|
+
area: 'Area Management',
|
36
|
+
unit: 'Table/Room Management',
|
37
|
+
transactions: 'Sale Transactions',
|
38
|
+
refunds: 'Refunds',
|
39
|
+
catalogs: 'Catalog Management',
|
40
|
+
staffs: 'Staffs',
|
41
|
+
customers: 'Customers',
|
42
|
+
roles_and_permissions: 'Roles and Permissions',
|
43
|
+
import_data: 'Import Data',
|
44
|
+
export_data: 'Export Data',
|
45
|
+
order_histories: 'Order Histories',
|
46
|
+
waiting_list: 'Waiting List',
|
47
|
+
taxes: 'Taxes',
|
48
|
+
gift_cards: 'Gift Cards',
|
49
|
+
reports_basic: 'Basic Reports',
|
50
|
+
reports_advanced: 'Advanced Reports',
|
51
|
+
discounts_basic: 'Basic Discounts',
|
52
|
+
discounts_advanced: 'Advanced Discounts',
|
53
|
+
store_session: 'Store Session',
|
54
|
+
email_notifications: 'Email Notifications',
|
55
|
+
sms_notifications: 'SMS Notifications',
|
56
|
+
printer: 'Printer Integration',
|
57
|
+
ai_agent: 'AI Assistant',
|
58
|
+
store_limit: 'Store Limit',
|
59
|
+
realtime_sync: 'Real-time Sync',
|
60
|
+
};
|
61
|
+
/**
|
62
|
+
* Returns the features that are unique to a specific plan compared to all lower-tier plans.
|
63
|
+
*
|
64
|
+
* The function compares the features of the target plan against all plans lower in the hierarchy.
|
65
|
+
* A feature is considered unique if all lower-tier plans either lack the feature or have a strictly lesser value.
|
66
|
+
* Supports boolean and numeric feature values.
|
67
|
+
*
|
68
|
+
* @param planCode - The code of the target plan to compare (case-insensitive).
|
69
|
+
* @param plans - An array of all available plans, each with a code and features.
|
70
|
+
* @returns An object mapping feature keys to their unique values for the target plan.
|
71
|
+
* @throws If the plan code is invalid or the plan is not found in the provided plans array.
|
72
|
+
*/
|
73
|
+
function getUniqueFeaturesByPlan(planCode, plans) {
|
74
|
+
const hierarchy = [
|
75
|
+
plan_enum_1.Plan.FREETRIAL,
|
76
|
+
plan_enum_1.Plan.BASIC,
|
77
|
+
plan_enum_1.Plan.STARTER,
|
78
|
+
plan_enum_1.Plan.STANDARD,
|
79
|
+
plan_enum_1.Plan.PREMIUM,
|
80
|
+
];
|
81
|
+
const targetIndex = hierarchy.indexOf(planCode);
|
82
|
+
if (targetIndex === -1)
|
83
|
+
throw new Error('Invalid plan code');
|
84
|
+
const targetPlan = plans.find((p) => p.code === planCode);
|
85
|
+
if (!targetPlan)
|
86
|
+
throw new Error('Plan not found');
|
87
|
+
const lowerPlans = plans.filter((p) => hierarchy.indexOf(p.code) < targetIndex);
|
88
|
+
const uniqueFeatures = {};
|
89
|
+
// 1️⃣ Find features unique/improved vs lower plans
|
90
|
+
for (const [featureKey, featureValue] of Object.entries(targetPlan.features)) {
|
91
|
+
const isUnique = lowerPlans.every((lp) => {
|
92
|
+
const lowerValue = lp.features[featureKey];
|
93
|
+
if (typeof featureValue === 'boolean') {
|
94
|
+
return featureValue && !lowerValue;
|
95
|
+
}
|
96
|
+
if (typeof featureValue === 'number' && typeof lowerValue === 'number') {
|
97
|
+
return featureValue > lowerValue;
|
98
|
+
}
|
99
|
+
return featureValue !== lowerValue;
|
100
|
+
});
|
101
|
+
if (isUnique)
|
102
|
+
uniqueFeatures[featureKey] = featureValue;
|
103
|
+
}
|
104
|
+
return uniqueFeatures;
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Returns an array of unique feature names for a given subscription plan.
|
108
|
+
*
|
109
|
+
* @param planCode - The code representing the subscription plan to retrieve features for.
|
110
|
+
* @param plans - An array of available plans to search for unique features.
|
111
|
+
* @returns An array of strings representing the names of unique features for the specified plan.
|
112
|
+
*/
|
113
|
+
function getUniqueKeyFeaturesByPlan(planCode, plans) {
|
114
|
+
const uniqueFeatures = getUniqueFeaturesByPlan(planCode, plans);
|
115
|
+
return Object.keys(uniqueFeatures);
|
116
|
+
}
|
117
|
+
/**
|
118
|
+
* Returns a mapping of feature keys to the values of those features in plans
|
119
|
+
* that differ from the PREMIUM plan.
|
120
|
+
*
|
121
|
+
* For each feature in the PREMIUM plan, if any other plan has a different value
|
122
|
+
* for that feature, the result will include an entry for that feature. The entry
|
123
|
+
* maps each plan code (excluding PREMIUM) to its differing feature value.
|
124
|
+
*
|
125
|
+
* @param plans - Array of Plan objects to compare, each containing a set of features.
|
126
|
+
* @returns An object where each key is a feature that differs from the PREMIUM plan,
|
127
|
+
* and the value is an object mapping plan codes to their differing feature values.
|
128
|
+
*/
|
129
|
+
function getDifferentFeaturesValues(plans) {
|
130
|
+
const targetPlan = plans.find((p) => p.code === plan_enum_1.Plan.PREMIUM);
|
131
|
+
if (!targetPlan)
|
132
|
+
return {};
|
133
|
+
const differentFeatures = {};
|
134
|
+
// Find features that differ from any other plan (lower OR higher)
|
135
|
+
for (const [featureKey, featureValue] of Object.entries(targetPlan.features)) {
|
136
|
+
const otherValues = plans.map((p) => p.features[featureKey]);
|
137
|
+
const hasDifference = otherValues.some((v) => v !== featureValue);
|
138
|
+
if (hasDifference) {
|
139
|
+
differentFeatures[featureKey] = Object.fromEntries(plans
|
140
|
+
.map((p) => [p.code, p.features[featureKey]])
|
141
|
+
.filter(([_, v]) => v !== featureValue));
|
142
|
+
}
|
143
|
+
}
|
144
|
+
return differentFeatures;
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
* Returns a formatted string representation of a plan feature value based on the feature type.
|
148
|
+
*
|
149
|
+
* - For numeric values, formats the value and appends a descriptive label depending on the feature.
|
150
|
+
* - For boolean values, returns "Unlimited" for certain features if `true`, otherwise "Included".
|
151
|
+
* - For string values, returns the value as-is.
|
152
|
+
* - Returns "--" if the value does not match any expected type.
|
153
|
+
*
|
154
|
+
* @param value - The value of the plan feature, which can be a number, boolean, or string.
|
155
|
+
* @param feature - The feature key used to determine formatting and labeling.
|
156
|
+
* @returns A formatted string representing the feature value for display purposes.
|
157
|
+
*/
|
158
|
+
function getFeatureValue(value, feature) {
|
159
|
+
if (typeof value === 'number') {
|
160
|
+
const formattedValue = Intl.NumberFormat('en-US', {
|
161
|
+
maximumFractionDigits: 0,
|
162
|
+
}).format(value);
|
163
|
+
if (feature === plan_enum_1.Feature.POS) {
|
164
|
+
return `${formattedValue} orders per month`;
|
165
|
+
}
|
166
|
+
if (feature === plan_enum_1.Feature.AREA) {
|
167
|
+
return `${formattedValue} area(s)`;
|
168
|
+
}
|
169
|
+
if (feature === plan_enum_1.Feature.TRANSACTIONS ||
|
170
|
+
feature === plan_enum_1.Feature.ORDER_HISTORIES) {
|
171
|
+
return `up to last ${formattedValue} month(s)`;
|
172
|
+
}
|
173
|
+
if (feature === plan_enum_1.Feature.CATALOGS) {
|
174
|
+
return `${formattedValue} products / services`;
|
175
|
+
}
|
176
|
+
if (feature === plan_enum_1.Feature.STAFFS) {
|
177
|
+
return `${formattedValue} staff(s)`;
|
178
|
+
}
|
179
|
+
if (feature === plan_enum_1.Feature.CUSTOMERS) {
|
180
|
+
return `${formattedValue} saved customer(s)`;
|
181
|
+
}
|
182
|
+
if (feature === plan_enum_1.Feature.STORE_LIMIT) {
|
183
|
+
return `up to ${formattedValue} store(s)`;
|
184
|
+
}
|
185
|
+
}
|
186
|
+
if ((feature === plan_enum_1.Feature.STORE_LIMIT ||
|
187
|
+
feature === plan_enum_1.Feature.EVENT_ADVANCED ||
|
188
|
+
feature === plan_enum_1.Feature.STAFFS ||
|
189
|
+
feature === plan_enum_1.Feature.UNIT ||
|
190
|
+
feature === plan_enum_1.Feature.POS ||
|
191
|
+
feature === plan_enum_1.Feature.TRANSACTIONS ||
|
192
|
+
feature === plan_enum_1.Feature.CATALOGS ||
|
193
|
+
feature === plan_enum_1.Feature.CUSTOMERS ||
|
194
|
+
feature === plan_enum_1.Feature.SMS_NOTIFICATIONS ||
|
195
|
+
feature === plan_enum_1.Feature.AI_AGENT ||
|
196
|
+
feature === plan_enum_1.Feature.AREA) &&
|
197
|
+
value === true) {
|
198
|
+
return 'Unlimited';
|
199
|
+
}
|
200
|
+
if (value === true) {
|
201
|
+
return 'Included';
|
202
|
+
}
|
203
|
+
else if (typeof value === 'number') {
|
204
|
+
return Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(value);
|
205
|
+
}
|
206
|
+
else if (typeof value === 'string') {
|
207
|
+
return value;
|
208
|
+
}
|
209
|
+
return '--';
|
210
|
+
}
|
211
|
+
//# sourceMappingURL=plan.helper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"plan.helper.js","sourceRoot":"","sources":["../../src/helpers/plan.helper.ts"],"names":[],"mappings":"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"}
|
package/dist/types/plan.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
import { Plan as PlanCode } from '../enums/plan.enum';
|
2
|
+
export type PlanFeatureValue = string | number | boolean;
|
2
3
|
export type Plan = {
|
3
4
|
id: string;
|
4
5
|
name: string;
|
@@ -8,6 +9,6 @@ export type Plan = {
|
|
8
9
|
commissionRate: number;
|
9
10
|
currency: string;
|
10
11
|
code: PlanCode;
|
11
|
-
features: Record<string,
|
12
|
+
features: Record<string, PlanFeatureValue>;
|
12
13
|
};
|
13
14
|
//# sourceMappingURL=plan.d.ts.map
|
package/dist/types/plan.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/types/plan.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/types/plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEzD,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC5C,CAAC"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
2
|
+
import js from '@eslint/js';
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
4
|
+
|
5
|
+
const compat = new FlatCompat({
|
6
|
+
// import.meta.dirname is available after Node.js v20.11.0
|
7
|
+
baseDirectory: import.meta.dirname,
|
8
|
+
recommendedConfig: js.configs.recommended,
|
9
|
+
});
|
10
|
+
|
11
|
+
const eslintConfig = [
|
12
|
+
...compat.config({
|
13
|
+
root: true,
|
14
|
+
extends: ['eslint:recommended', 'prettier'],
|
15
|
+
ignorePatterns: ['node_modules/', 'dist/'],
|
16
|
+
parserOptions: {
|
17
|
+
ecmaVersion: 2020,
|
18
|
+
sourceType: 'module',
|
19
|
+
project: './tsconfig.json', // Required for type-aware linting
|
20
|
+
},
|
21
|
+
rules: {
|
22
|
+
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
23
|
+
},
|
24
|
+
}),
|
25
|
+
eslintPluginPrettierRecommended,
|
26
|
+
];
|
27
|
+
|
28
|
+
export default eslintConfig;
|
package/package.json
CHANGED
@@ -1,15 +1,31 @@
|
|
1
1
|
{
|
2
2
|
"name": "fuze-store-shared",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"types": "dist/index.d.ts",
|
6
6
|
"repository": "https://github.com/Fuze-Store/fuze-store-shared.git",
|
7
|
-
"author": "
|
7
|
+
"author": "sherlock003 <kimuel.delrosario@gmail.com>",
|
8
8
|
"license": "MIT",
|
9
9
|
"scripts": {
|
10
|
-
"build": "tsc"
|
10
|
+
"build": "tsc",
|
11
|
+
"lint": "eslint src/**/*.ts --fix",
|
12
|
+
"lint:check": "eslint src/**/*.ts"
|
11
13
|
},
|
12
14
|
"devDependencies": {
|
15
|
+
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
16
|
+
"@typescript-eslint/parser": "^8.46.0",
|
17
|
+
"eslint": "^9.37.0",
|
18
|
+
"eslint-config-prettier": "^10.1.8",
|
19
|
+
"eslint-plugin-prettier": "^5.5.4",
|
20
|
+
"prettier": "^3.6.2",
|
13
21
|
"typescript": "^5.9.3"
|
22
|
+
},
|
23
|
+
"dependencies": {
|
24
|
+
"date-fns": "^4.1.0"
|
25
|
+
},
|
26
|
+
"exports": {
|
27
|
+
"./helpers": "./dist/helpers/index.js",
|
28
|
+
"./enums": "./dist/enums/index.js",
|
29
|
+
".": "./dist/index.js"
|
14
30
|
}
|
15
|
-
}
|
31
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// Named exports
|
2
|
+
export * from './plan.enum';
|
3
|
+
export * from './subscription.enum';
|
4
|
+
|
5
|
+
// Default export object
|
6
|
+
import * as planEnum from './plan.enum';
|
7
|
+
import * as subscriptionEnum from './subscription.enum';
|
8
|
+
|
9
|
+
const enums = {
|
10
|
+
...planEnum,
|
11
|
+
...subscriptionEnum,
|
12
|
+
};
|
13
|
+
|
14
|
+
export default enums;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/**
|
2
|
+
* List of plan enums
|
3
|
+
*
|
4
|
+
* @module PlanEnums
|
5
|
+
* @category Enums
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
export enum Feature {
|
10
|
+
DASHBOARD = 'dashboard',
|
11
|
+
POS = 'pos',
|
12
|
+
EVENT_BASIC = 'event_basic', // List View
|
13
|
+
EVENT_ADVANCED = 'event_advanced', // Calendar, Agenda, Day, List View
|
14
|
+
AREA = 'area', // Area Management
|
15
|
+
UNIT = 'unit', // Unit Management
|
16
|
+
TRANSACTIONS = 'transactions', // Order Histories, Sales Transactions
|
17
|
+
REFUNDS = 'refunds', // Sales Refunds
|
18
|
+
CATALOGS = 'catalogs', // Categories, Products, Services, Modifiers
|
19
|
+
STAFFS = 'staffs',
|
20
|
+
CUSTOMERS = 'customers',
|
21
|
+
ROLES_AND_PERMISSIONS = 'roles_and_permissions',
|
22
|
+
REALTIME_SYNC = 'realtime_sync',
|
23
|
+
IMPORT_DATA = 'import_data',
|
24
|
+
EXPORT_DATA = 'export_data',
|
25
|
+
TAXES = 'taxes',
|
26
|
+
ORDER_HISTORIES = 'order_histories',
|
27
|
+
GIFT_CARDS = 'gift_cards',
|
28
|
+
REPORTS_BASICS = 'reports_basic', // View Basic Reports
|
29
|
+
REPORTS_ADVANCED = 'reports_advanced', // View, Download Reports
|
30
|
+
EXPENSES = 'expenses',
|
31
|
+
DISCOUNTS_BASIC = 'discounts_basic', // Basic Discounts
|
32
|
+
DISCOUNTS_ADVANCED = 'discounts_advanced', // Basic with Schedules
|
33
|
+
STORE_SESSION = 'store_session', // Store Session Management
|
34
|
+
EMAIL_NOTIFICATIONS = 'email_notifications', // Email Notifications
|
35
|
+
SMS_NOTIFICATIONS = 'sms_notifications', // TODO=
|
36
|
+
PRINTER = 'printer',
|
37
|
+
STORE_LIMIT = 'store_limit',
|
38
|
+
WAITING_LIST = 'waiting_list',
|
39
|
+
AI_AGENT = 'ai_agent', // TODO=
|
40
|
+
}
|
41
|
+
|
42
|
+
export enum Plan {
|
43
|
+
FREETRIAL = 'FREETRIAL',
|
44
|
+
STARTER = 'STARTER',
|
45
|
+
BASIC = 'BASIC',
|
46
|
+
STANDARD = 'STANDARD',
|
47
|
+
PREMIUM = 'PREMIUM',
|
48
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/**
|
2
|
+
* List of date helpers
|
3
|
+
*
|
4
|
+
* @module DateHelper
|
5
|
+
* @category Helpers
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
import { format } from 'date-fns';
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Formats a given date into a specified string pattern.
|
13
|
+
*
|
14
|
+
* @param date - The date to format, which can be a `Date` object or an ISO date string. If omitted, returns an empty string.
|
15
|
+
* @param patterns - The format pattern to use (default: `'MMM dd, yyyy hh:mm aa'`).
|
16
|
+
* @returns The formatted date string, or an empty string if no date is provided.
|
17
|
+
*
|
18
|
+
* @see https://date-fns.org/docs/format
|
19
|
+
*/
|
20
|
+
export function formatDate(
|
21
|
+
date?: Date | string,
|
22
|
+
patterns = 'MMM dd, yyyy hh:mm aa',
|
23
|
+
) {
|
24
|
+
if (date) {
|
25
|
+
return format(new Date(date), patterns);
|
26
|
+
}
|
27
|
+
|
28
|
+
return '';
|
29
|
+
}
|
@@ -0,0 +1,249 @@
|
|
1
|
+
/**
|
2
|
+
* List of plan helpers
|
3
|
+
*
|
4
|
+
* @module PlanHelper
|
5
|
+
* @category Helpers
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
import { Feature, Plan as SubscriptionPlan } from '../enums/plan.enum';
|
10
|
+
import { Plan, PlanFeatureValue } from '../types/plan';
|
11
|
+
|
12
|
+
/**
|
13
|
+
* A mapping of feature keys to their corresponding human-readable labels.
|
14
|
+
*
|
15
|
+
* This record is used to display user-friendly names for various features
|
16
|
+
* throughout the application, such as in plan selection, feature lists, or UI components.
|
17
|
+
*
|
18
|
+
* @remarks
|
19
|
+
* Each key represents a unique feature identifier, and the value is the label shown to users.
|
20
|
+
*
|
21
|
+
* @example
|
22
|
+
* ```typescript
|
23
|
+
* const label = featureLabels['dashboard']; // "Dashboard"
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
export const featureLabels: Record<string, string> = {
|
27
|
+
dashboard: 'Dashboard',
|
28
|
+
pos: 'Point of Sales',
|
29
|
+
event_basic: 'Basic Events',
|
30
|
+
event_advanced: 'Advanced Events',
|
31
|
+
area: 'Area Management',
|
32
|
+
unit: 'Table/Room Management',
|
33
|
+
transactions: 'Sale Transactions',
|
34
|
+
refunds: 'Refunds',
|
35
|
+
catalogs: 'Catalog Management',
|
36
|
+
staffs: 'Staffs',
|
37
|
+
customers: 'Customers',
|
38
|
+
roles_and_permissions: 'Roles and Permissions',
|
39
|
+
import_data: 'Import Data',
|
40
|
+
export_data: 'Export Data',
|
41
|
+
order_histories: 'Order Histories',
|
42
|
+
waiting_list: 'Waiting List',
|
43
|
+
taxes: 'Taxes',
|
44
|
+
gift_cards: 'Gift Cards',
|
45
|
+
reports_basic: 'Basic Reports',
|
46
|
+
reports_advanced: 'Advanced Reports',
|
47
|
+
discounts_basic: 'Basic Discounts',
|
48
|
+
discounts_advanced: 'Advanced Discounts',
|
49
|
+
store_session: 'Store Session',
|
50
|
+
email_notifications: 'Email Notifications',
|
51
|
+
sms_notifications: 'SMS Notifications',
|
52
|
+
printer: 'Printer Integration',
|
53
|
+
ai_agent: 'AI Assistant',
|
54
|
+
store_limit: 'Store Limit',
|
55
|
+
realtime_sync: 'Real-time Sync',
|
56
|
+
};
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Returns the features that are unique to a specific plan compared to all lower-tier plans.
|
60
|
+
*
|
61
|
+
* The function compares the features of the target plan against all plans lower in the hierarchy.
|
62
|
+
* A feature is considered unique if all lower-tier plans either lack the feature or have a strictly lesser value.
|
63
|
+
* Supports boolean and numeric feature values.
|
64
|
+
*
|
65
|
+
* @param planCode - The code of the target plan to compare (case-insensitive).
|
66
|
+
* @param plans - An array of all available plans, each with a code and features.
|
67
|
+
* @returns An object mapping feature keys to their unique values for the target plan.
|
68
|
+
* @throws If the plan code is invalid or the plan is not found in the provided plans array.
|
69
|
+
*/
|
70
|
+
export function getUniqueFeaturesByPlan(
|
71
|
+
planCode: SubscriptionPlan,
|
72
|
+
plans: Plan[],
|
73
|
+
) {
|
74
|
+
const hierarchy = [
|
75
|
+
SubscriptionPlan.FREETRIAL,
|
76
|
+
SubscriptionPlan.BASIC,
|
77
|
+
SubscriptionPlan.STARTER,
|
78
|
+
SubscriptionPlan.STANDARD,
|
79
|
+
SubscriptionPlan.PREMIUM,
|
80
|
+
];
|
81
|
+
const targetIndex = hierarchy.indexOf(planCode);
|
82
|
+
if (targetIndex === -1) throw new Error('Invalid plan code');
|
83
|
+
|
84
|
+
const targetPlan = plans.find((p) => p.code === planCode);
|
85
|
+
if (!targetPlan) throw new Error('Plan not found');
|
86
|
+
|
87
|
+
const lowerPlans = plans.filter(
|
88
|
+
(p) => hierarchy.indexOf(p.code) < targetIndex,
|
89
|
+
);
|
90
|
+
|
91
|
+
const uniqueFeatures: Plan['features'] = {};
|
92
|
+
|
93
|
+
// 1️⃣ Find features unique/improved vs lower plans
|
94
|
+
for (const [featureKey, featureValue] of Object.entries(
|
95
|
+
targetPlan.features,
|
96
|
+
)) {
|
97
|
+
const isUnique = lowerPlans.every((lp) => {
|
98
|
+
const lowerValue = lp.features[featureKey];
|
99
|
+
if (typeof featureValue === 'boolean') {
|
100
|
+
return featureValue && !lowerValue;
|
101
|
+
}
|
102
|
+
if (typeof featureValue === 'number' && typeof lowerValue === 'number') {
|
103
|
+
return featureValue > lowerValue;
|
104
|
+
}
|
105
|
+
return featureValue !== lowerValue;
|
106
|
+
});
|
107
|
+
|
108
|
+
if (isUnique) uniqueFeatures[featureKey] = featureValue;
|
109
|
+
}
|
110
|
+
|
111
|
+
return uniqueFeatures;
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Returns an array of unique feature names for a given subscription plan.
|
116
|
+
*
|
117
|
+
* @param planCode - The code representing the subscription plan to retrieve features for.
|
118
|
+
* @param plans - An array of available plans to search for unique features.
|
119
|
+
* @returns An array of strings representing the names of unique features for the specified plan.
|
120
|
+
*/
|
121
|
+
export function getUniqueKeyFeaturesByPlan(
|
122
|
+
planCode: SubscriptionPlan,
|
123
|
+
plans: Plan[],
|
124
|
+
) {
|
125
|
+
const uniqueFeatures = getUniqueFeaturesByPlan(planCode, plans);
|
126
|
+
return Object.keys(uniqueFeatures);
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Returns a mapping of feature keys to the values of those features in plans
|
131
|
+
* that differ from the PREMIUM plan.
|
132
|
+
*
|
133
|
+
* For each feature in the PREMIUM plan, if any other plan has a different value
|
134
|
+
* for that feature, the result will include an entry for that feature. The entry
|
135
|
+
* maps each plan code (excluding PREMIUM) to its differing feature value.
|
136
|
+
*
|
137
|
+
* @param plans - Array of Plan objects to compare, each containing a set of features.
|
138
|
+
* @returns An object where each key is a feature that differs from the PREMIUM plan,
|
139
|
+
* and the value is an object mapping plan codes to their differing feature values.
|
140
|
+
*/
|
141
|
+
export function getDifferentFeaturesValues(
|
142
|
+
plans: Plan[],
|
143
|
+
): Record<string, Record<string, PlanFeatureValue>> {
|
144
|
+
const targetPlan = plans.find((p) => p.code === SubscriptionPlan.PREMIUM);
|
145
|
+
if (!targetPlan) return {};
|
146
|
+
|
147
|
+
const differentFeatures: Record<
|
148
|
+
string,
|
149
|
+
Record<string, PlanFeatureValue>
|
150
|
+
> = {};
|
151
|
+
|
152
|
+
// Find features that differ from any other plan (lower OR higher)
|
153
|
+
for (const [featureKey, featureValue] of Object.entries(
|
154
|
+
targetPlan.features,
|
155
|
+
)) {
|
156
|
+
const otherValues = plans.map((p) => p.features[featureKey]);
|
157
|
+
const hasDifference = otherValues.some((v) => v !== featureValue);
|
158
|
+
|
159
|
+
if (hasDifference) {
|
160
|
+
differentFeatures[featureKey] = Object.fromEntries(
|
161
|
+
plans
|
162
|
+
.map((p) => [p.code, p.features[featureKey]])
|
163
|
+
.filter(([_, v]) => v !== featureValue),
|
164
|
+
);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
return differentFeatures;
|
169
|
+
}
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Returns a formatted string representation of a plan feature value based on the feature type.
|
173
|
+
*
|
174
|
+
* - For numeric values, formats the value and appends a descriptive label depending on the feature.
|
175
|
+
* - For boolean values, returns "Unlimited" for certain features if `true`, otherwise "Included".
|
176
|
+
* - For string values, returns the value as-is.
|
177
|
+
* - Returns "--" if the value does not match any expected type.
|
178
|
+
*
|
179
|
+
* @param value - The value of the plan feature, which can be a number, boolean, or string.
|
180
|
+
* @param feature - The feature key used to determine formatting and labeling.
|
181
|
+
* @returns A formatted string representing the feature value for display purposes.
|
182
|
+
*/
|
183
|
+
export function getFeatureValue(value: PlanFeatureValue, feature: string) {
|
184
|
+
if (typeof value === 'number') {
|
185
|
+
const formattedValue = Intl.NumberFormat('en-US', {
|
186
|
+
maximumFractionDigits: 0,
|
187
|
+
}).format(value);
|
188
|
+
|
189
|
+
if (feature === Feature.POS) {
|
190
|
+
return `${formattedValue} orders per month`;
|
191
|
+
}
|
192
|
+
|
193
|
+
if (feature === Feature.AREA) {
|
194
|
+
return `${formattedValue} area(s)`;
|
195
|
+
}
|
196
|
+
|
197
|
+
if (
|
198
|
+
feature === Feature.TRANSACTIONS ||
|
199
|
+
feature === Feature.ORDER_HISTORIES
|
200
|
+
) {
|
201
|
+
return `up to last ${formattedValue} month(s)`;
|
202
|
+
}
|
203
|
+
|
204
|
+
if (feature === Feature.CATALOGS) {
|
205
|
+
return `${formattedValue} products / services`;
|
206
|
+
}
|
207
|
+
|
208
|
+
if (feature === Feature.STAFFS) {
|
209
|
+
return `${formattedValue} staff(s)`;
|
210
|
+
}
|
211
|
+
|
212
|
+
if (feature === Feature.CUSTOMERS) {
|
213
|
+
return `${formattedValue} saved customer(s)`;
|
214
|
+
}
|
215
|
+
|
216
|
+
if (feature === Feature.STORE_LIMIT) {
|
217
|
+
return `up to ${formattedValue} store(s)`;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
if (
|
222
|
+
(feature === Feature.STORE_LIMIT ||
|
223
|
+
feature === Feature.EVENT_ADVANCED ||
|
224
|
+
feature === Feature.STAFFS ||
|
225
|
+
feature === Feature.UNIT ||
|
226
|
+
feature === Feature.POS ||
|
227
|
+
feature === Feature.TRANSACTIONS ||
|
228
|
+
feature === Feature.CATALOGS ||
|
229
|
+
feature === Feature.CUSTOMERS ||
|
230
|
+
feature === Feature.SMS_NOTIFICATIONS ||
|
231
|
+
feature === Feature.AI_AGENT ||
|
232
|
+
feature === Feature.AREA) &&
|
233
|
+
value === true
|
234
|
+
) {
|
235
|
+
return 'Unlimited';
|
236
|
+
}
|
237
|
+
|
238
|
+
if (value === true) {
|
239
|
+
return 'Included';
|
240
|
+
} else if (typeof value === 'number') {
|
241
|
+
return Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(
|
242
|
+
value,
|
243
|
+
);
|
244
|
+
} else if (typeof value === 'string') {
|
245
|
+
return value;
|
246
|
+
}
|
247
|
+
|
248
|
+
return '--';
|
249
|
+
}
|
package/src/index.ts
CHANGED
package/src/types/plan.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
import { Plan as PlanCode } from '../enums/plan.enum';
|
1
2
|
|
2
|
-
export type
|
3
|
+
export type PlanFeatureValue = string | number | boolean;
|
3
4
|
|
4
5
|
export type Plan = {
|
5
6
|
id: string;
|
@@ -10,5 +11,5 @@ export type Plan = {
|
|
10
11
|
commissionRate: number;
|
11
12
|
currency: string;
|
12
13
|
code: PlanCode;
|
13
|
-
features: Record<string,
|
14
|
+
features: Record<string, PlanFeatureValue>;
|
14
15
|
};
|
@@ -51,8 +51,8 @@ export type Subscription = {
|
|
51
51
|
* list of subscription invoices
|
52
52
|
*/
|
53
53
|
invoices?: Invoice[];
|
54
|
-
// /**
|
55
|
-
// * list of active coupon redemptions
|
56
|
-
// */
|
57
|
-
// activeRedemptions?: CouponRedemption[];
|
54
|
+
// /**
|
55
|
+
// * list of active coupon redemptions
|
56
|
+
// */
|
57
|
+
// activeRedemptions?: CouponRedemption[];
|
58
58
|
};
|
package/tsconfig.json
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
"module": "nodenext",
|
11
11
|
"target": "esnext",
|
12
12
|
"types": [],
|
13
|
+
"moduleResolution": "nodenext",
|
14
|
+
"esModuleInterop": true,
|
13
15
|
// For nodejs:
|
14
16
|
// "lib": ["esnext"],
|
15
17
|
// "types": ["node"],
|
@@ -39,7 +41,7 @@
|
|
39
41
|
"isolatedModules": true,
|
40
42
|
"noUncheckedSideEffectImports": true,
|
41
43
|
"moduleDetection": "force",
|
42
|
-
"skipLibCheck": true
|
44
|
+
"skipLibCheck": true
|
43
45
|
},
|
44
|
-
"include": ["src"]
|
46
|
+
"include": ["src/**/*.ts"]
|
45
47
|
}
|