@vritti/api-sdk 0.3.3 → 0.3.5

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.
Files changed (133) hide show
  1. package/dist/auth.cjs +942 -0
  2. package/dist/auth.cjs.map +1 -0
  3. package/dist/auth.d.cts +95 -0
  4. package/dist/auth.d.ts +95 -0
  5. package/dist/auth.js +884 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/cache.cjs +182 -14
  8. package/dist/cache.cjs.map +1 -1
  9. package/dist/cache.d.cts +48 -4
  10. package/dist/cache.d.ts +48 -4
  11. package/dist/cache.js +177 -12
  12. package/dist/cache.js.map +1 -1
  13. package/dist/catalog-resolver.cjs +226 -51
  14. package/dist/catalog-resolver.cjs.map +1 -1
  15. package/dist/catalog-resolver.d.cts +41 -19
  16. package/dist/catalog-resolver.d.ts +41 -19
  17. package/dist/catalog-resolver.js +212 -46
  18. package/dist/catalog-resolver.js.map +1 -1
  19. package/dist/code-pattern-BP4zkNtT.d.cts +12 -0
  20. package/dist/code-pattern-BP4zkNtT.d.ts +12 -0
  21. package/dist/context.cjs +93 -0
  22. package/dist/context.cjs.map +1 -0
  23. package/dist/context.d.cts +19 -0
  24. package/dist/context.d.ts +19 -0
  25. package/dist/context.js +64 -0
  26. package/dist/context.js.map +1 -0
  27. package/dist/countries.cjs +1559 -0
  28. package/dist/countries.cjs.map +1 -0
  29. package/dist/countries.d.cts +13 -0
  30. package/dist/countries.d.ts +13 -0
  31. package/dist/countries.js +1532 -0
  32. package/dist/countries.js.map +1 -0
  33. package/dist/data-table.cjs +1280 -0
  34. package/dist/data-table.cjs.map +1 -0
  35. package/dist/data-table.d.cts +123 -0
  36. package/dist/data-table.d.ts +123 -0
  37. package/dist/data-table.js +1260 -0
  38. package/dist/data-table.js.map +1 -0
  39. package/dist/database.cjs +1510 -0
  40. package/dist/database.cjs.map +1 -0
  41. package/dist/database.d.cts +287 -0
  42. package/dist/database.d.ts +287 -0
  43. package/dist/database.js +1469 -0
  44. package/dist/database.js.map +1 -0
  45. package/dist/decimal.d.cts +0 -1
  46. package/dist/decimal.d.ts +0 -1
  47. package/dist/decorators.cjs +1817 -0
  48. package/dist/decorators.cjs.map +1 -0
  49. package/dist/decorators.d.cts +24 -0
  50. package/dist/decorators.d.ts +24 -0
  51. package/dist/decorators.js +1780 -0
  52. package/dist/decorators.js.map +1 -0
  53. package/dist/drizzle-pg-core.cjs +25 -0
  54. package/dist/drizzle-pg-core.cjs.map +1 -1
  55. package/dist/drizzle-pg-core.d.cts +7 -0
  56. package/dist/drizzle-pg-core.d.ts +7 -0
  57. package/dist/drizzle-pg-core.js +22 -0
  58. package/dist/drizzle-pg-core.js.map +1 -1
  59. package/dist/exceptions.cjs +301 -0
  60. package/dist/exceptions.cjs.map +1 -0
  61. package/dist/exceptions.d.cts +90 -0
  62. package/dist/exceptions.d.ts +90 -0
  63. package/dist/exceptions.js +257 -0
  64. package/dist/exceptions.js.map +1 -0
  65. package/dist/filter.types-PuARU9XD.d.cts +50 -0
  66. package/dist/filter.types-PuARU9XD.d.ts +50 -0
  67. package/dist/filters.cjs +407 -0
  68. package/dist/filters.cjs.map +1 -0
  69. package/dist/filters.d.cts +55 -0
  70. package/dist/filters.d.ts +55 -0
  71. package/dist/filters.js +377 -0
  72. package/dist/filters.js.map +1 -0
  73. package/dist/index.cjs +0 -5423
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.cts +93 -854
  76. package/dist/index.d.ts +93 -854
  77. package/dist/index.js +0 -5301
  78. package/dist/index.js.map +1 -1
  79. package/dist/is-country.decorator-CcNwSSr5.d.cts +5 -0
  80. package/dist/is-country.decorator-CcNwSSr5.d.ts +5 -0
  81. package/dist/license.d.cts +1 -1
  82. package/dist/license.d.ts +1 -1
  83. package/dist/lodash.cjs.map +1 -1
  84. package/dist/lodash.js.map +1 -1
  85. package/dist/logger.cjs +862 -0
  86. package/dist/logger.cjs.map +1 -0
  87. package/dist/logger.d.cts +118 -0
  88. package/dist/logger.d.ts +118 -0
  89. package/dist/logger.js +816 -0
  90. package/dist/logger.js.map +1 -0
  91. package/dist/migrate.cjs +2 -2
  92. package/dist/migrate.cjs.map +1 -1
  93. package/dist/migrate.d.cts +2 -0
  94. package/dist/migrate.d.ts +2 -0
  95. package/dist/migrate.js +2 -2
  96. package/dist/migrate.js.map +1 -1
  97. package/dist/money.cjs +18 -3
  98. package/dist/money.cjs.map +1 -1
  99. package/dist/money.d.cts +13 -13
  100. package/dist/money.d.ts +13 -13
  101. package/dist/money.js +18 -3
  102. package/dist/money.js.map +1 -1
  103. package/dist/nats.cjs +34 -35
  104. package/dist/nats.cjs.map +1 -1
  105. package/dist/nats.d.cts +14 -14
  106. package/dist/nats.d.ts +14 -14
  107. package/dist/nats.js +32 -33
  108. package/dist/nats.js.map +1 -1
  109. package/dist/root.cjs +225 -0
  110. package/dist/root.cjs.map +1 -0
  111. package/dist/root.d.cts +4 -0
  112. package/dist/root.d.ts +4 -0
  113. package/dist/root.js +200 -0
  114. package/dist/root.js.map +1 -0
  115. package/dist/{types-DQRwj5rr.d.cts → types-C9jPdQqH.d.cts} +32 -6
  116. package/dist/{types-DQRwj5rr.d.ts → types-C9jPdQqH.d.ts} +32 -6
  117. package/dist/types.cjs +19 -0
  118. package/dist/types.cjs.map +1 -0
  119. package/dist/types.d.cts +17 -0
  120. package/dist/types.d.ts +17 -0
  121. package/dist/types.js +1 -0
  122. package/dist/types.js.map +1 -0
  123. package/dist/utils.cjs +273 -0
  124. package/dist/utils.cjs.map +1 -0
  125. package/dist/utils.d.cts +8 -0
  126. package/dist/utils.d.ts +8 -0
  127. package/dist/utils.js +245 -0
  128. package/dist/utils.js.map +1 -0
  129. package/package.json +122 -1
  130. package/dist/cache.service-_SuJIcNA.d.cts +0 -20
  131. package/dist/cache.service-_SuJIcNA.d.ts +0 -20
  132. package/dist/fastify-augmentation-CQPBNS5a.d.cts +0 -105
  133. package/dist/fastify-augmentation-CQPBNS5a.d.ts +0 -105
@@ -9,12 +9,14 @@ interface PlatformDenyCodes {
9
9
  mobile?: string[] | null;
10
10
  }
11
11
  type FeatureUnlocks = Record<string, PlatformCodes>;
12
- type BuFeatureLocks = Record<string, PlatformDenyCodes>;
12
+ type FeatureLocks = Record<string, PlatformDenyCodes>;
13
+ type SiteFeatureLocks = FeatureLocks;
13
14
  interface SnapshotPermission {
14
15
  code: string;
15
16
  label: string;
16
17
  isGlobal: boolean;
17
18
  businesses: string[];
19
+ dependsOn: string[];
18
20
  }
19
21
  interface SnapshotMicrofrontendWeb {
20
22
  code: string;
@@ -35,36 +37,59 @@ interface SnapshotMicrofrontends {
35
37
  web?: SnapshotMicrofrontendWeb;
36
38
  mobile?: SnapshotMicrofrontendMobile;
37
39
  }
40
+ type ScopeType = 'ORG' | 'LE' | 'SITE_GROUP' | 'SITE';
41
+ type SiteType = 'OUTLET' | 'WAREHOUSE' | 'PRODUCTION';
42
+ declare const SITE_TYPES: SiteType[];
38
43
  interface SnapshotFeature {
39
44
  code: string;
40
45
  name: string;
41
46
  lucideIcon: string;
42
47
  sfSymbol: string;
43
48
  materialSymbol: string;
49
+ scope: ScopeType;
50
+ applicableSiteTypes: SiteType[];
44
51
  permissions: SnapshotPermission[];
45
52
  microfrontends: SnapshotMicrofrontends;
46
53
  }
54
+ interface SnapshotAppFeatureRef {
55
+ code: string;
56
+ scope: ScopeType;
57
+ }
47
58
  interface SnapshotApp {
48
59
  code: string;
49
60
  name: string;
50
61
  icon: string;
51
62
  sortOrder: number;
52
- features: string[];
63
+ features: SnapshotAppFeatureRef[];
53
64
  }
54
65
  interface SnapshotRoleTemplate {
55
66
  name: string;
56
67
  code: string;
68
+ scope: ScopeType;
69
+ siteType: SiteType;
57
70
  features: FeatureUnlocks;
58
71
  }
59
72
  interface SnapshotPlan {
60
73
  code: string;
61
74
  name: string;
62
75
  isCustom: boolean;
63
- maxBusinessUnits: number | null;
76
+ maxSites: number | null;
64
77
  unlockedPermissions: FeatureUnlocks;
65
78
  }
79
+ interface VocabularyEntry {
80
+ singular: string;
81
+ plural: string;
82
+ }
83
+ interface BusinessVocabulary {
84
+ site?: VocabularyEntry;
85
+ siteGroup?: VocabularyEntry;
86
+ outlet?: VocabularyEntry;
87
+ warehouse?: VocabularyEntry;
88
+ production?: VocabularyEntry;
89
+ }
66
90
  interface SnapshotBusiness {
67
91
  name: string;
92
+ vocabulary?: BusinessVocabulary;
68
93
  apps: SnapshotApp[];
69
94
  roleTemplates: Record<string, SnapshotRoleTemplate>;
70
95
  plans: Record<string, SnapshotPlan>;
@@ -74,8 +99,9 @@ interface VersionSnapshot {
74
99
  features: Record<string, SnapshotFeature>;
75
100
  businesses: Record<string, SnapshotBusiness>;
76
101
  }
77
- declare const SNAPSHOT_SCHEMA_VERSION = 1;
78
- type LockReason = 'PLAN' | 'BU';
102
+ declare function snapshotFeatureKey(code: string, scope: ScopeType): string;
103
+ declare const SNAPSHOT_SCHEMA_VERSION = 2;
104
+ type LockReason = 'PLAN' | 'SITE';
79
105
  interface CatalogPermission {
80
106
  code: string;
81
107
  locked: boolean;
@@ -110,4 +136,4 @@ interface FeatureCatalogEntry {
110
136
  }
111
137
  type RoleItem = SnapshotRoleTemplate;
112
138
 
113
- export { type BuFeatureLocks as B, type CatalogPermission as C, type FeatureCatalogEntry as F, type LockReason as L, type PlatformBucket as P, type RoleItem as R, SNAPSHOT_SCHEMA_VERSION as S, type VersionSnapshot as V, type PlatformCodes as a, type FeatureUnlocks as b, type PlatformDenyCodes as c, PLATFORMS as d, type SnapshotApp as e, type SnapshotBusiness as f, type SnapshotFeature as g, type SnapshotMicrofrontendMobile as h, type SnapshotMicrofrontends as i, type SnapshotMicrofrontendWeb as j, type SnapshotPermission as k, type SnapshotPlan as l, type SnapshotRoleTemplate as m };
139
+ export { type BusinessVocabulary as B, type CatalogPermission as C, type FeatureCatalogEntry as F, type LockReason as L, type PlatformBucket as P, type RoleItem as R, type ScopeType as S, type VersionSnapshot as V, type SiteType as a, type SiteFeatureLocks as b, type SnapshotFeature as c, type PlatformCodes as d, type FeatureUnlocks as e, type PlatformDenyCodes as f, type FeatureLocks as g, PLATFORMS as h, SITE_TYPES as i, SNAPSHOT_SCHEMA_VERSION as j, type SnapshotApp as k, type SnapshotAppFeatureRef as l, type VocabularyEntry as m, type SnapshotBusiness as n, type SnapshotMicrofrontendMobile as o, type SnapshotMicrofrontends as p, type SnapshotMicrofrontendWeb as q, type SnapshotPermission as r, type SnapshotPlan as s, type SnapshotRoleTemplate as t, snapshotFeatureKey as u };
@@ -9,12 +9,14 @@ interface PlatformDenyCodes {
9
9
  mobile?: string[] | null;
10
10
  }
11
11
  type FeatureUnlocks = Record<string, PlatformCodes>;
12
- type BuFeatureLocks = Record<string, PlatformDenyCodes>;
12
+ type FeatureLocks = Record<string, PlatformDenyCodes>;
13
+ type SiteFeatureLocks = FeatureLocks;
13
14
  interface SnapshotPermission {
14
15
  code: string;
15
16
  label: string;
16
17
  isGlobal: boolean;
17
18
  businesses: string[];
19
+ dependsOn: string[];
18
20
  }
19
21
  interface SnapshotMicrofrontendWeb {
20
22
  code: string;
@@ -35,36 +37,59 @@ interface SnapshotMicrofrontends {
35
37
  web?: SnapshotMicrofrontendWeb;
36
38
  mobile?: SnapshotMicrofrontendMobile;
37
39
  }
40
+ type ScopeType = 'ORG' | 'LE' | 'SITE_GROUP' | 'SITE';
41
+ type SiteType = 'OUTLET' | 'WAREHOUSE' | 'PRODUCTION';
42
+ declare const SITE_TYPES: SiteType[];
38
43
  interface SnapshotFeature {
39
44
  code: string;
40
45
  name: string;
41
46
  lucideIcon: string;
42
47
  sfSymbol: string;
43
48
  materialSymbol: string;
49
+ scope: ScopeType;
50
+ applicableSiteTypes: SiteType[];
44
51
  permissions: SnapshotPermission[];
45
52
  microfrontends: SnapshotMicrofrontends;
46
53
  }
54
+ interface SnapshotAppFeatureRef {
55
+ code: string;
56
+ scope: ScopeType;
57
+ }
47
58
  interface SnapshotApp {
48
59
  code: string;
49
60
  name: string;
50
61
  icon: string;
51
62
  sortOrder: number;
52
- features: string[];
63
+ features: SnapshotAppFeatureRef[];
53
64
  }
54
65
  interface SnapshotRoleTemplate {
55
66
  name: string;
56
67
  code: string;
68
+ scope: ScopeType;
69
+ siteType: SiteType;
57
70
  features: FeatureUnlocks;
58
71
  }
59
72
  interface SnapshotPlan {
60
73
  code: string;
61
74
  name: string;
62
75
  isCustom: boolean;
63
- maxBusinessUnits: number | null;
76
+ maxSites: number | null;
64
77
  unlockedPermissions: FeatureUnlocks;
65
78
  }
79
+ interface VocabularyEntry {
80
+ singular: string;
81
+ plural: string;
82
+ }
83
+ interface BusinessVocabulary {
84
+ site?: VocabularyEntry;
85
+ siteGroup?: VocabularyEntry;
86
+ outlet?: VocabularyEntry;
87
+ warehouse?: VocabularyEntry;
88
+ production?: VocabularyEntry;
89
+ }
66
90
  interface SnapshotBusiness {
67
91
  name: string;
92
+ vocabulary?: BusinessVocabulary;
68
93
  apps: SnapshotApp[];
69
94
  roleTemplates: Record<string, SnapshotRoleTemplate>;
70
95
  plans: Record<string, SnapshotPlan>;
@@ -74,8 +99,9 @@ interface VersionSnapshot {
74
99
  features: Record<string, SnapshotFeature>;
75
100
  businesses: Record<string, SnapshotBusiness>;
76
101
  }
77
- declare const SNAPSHOT_SCHEMA_VERSION = 1;
78
- type LockReason = 'PLAN' | 'BU';
102
+ declare function snapshotFeatureKey(code: string, scope: ScopeType): string;
103
+ declare const SNAPSHOT_SCHEMA_VERSION = 2;
104
+ type LockReason = 'PLAN' | 'SITE';
79
105
  interface CatalogPermission {
80
106
  code: string;
81
107
  locked: boolean;
@@ -110,4 +136,4 @@ interface FeatureCatalogEntry {
110
136
  }
111
137
  type RoleItem = SnapshotRoleTemplate;
112
138
 
113
- export { type BuFeatureLocks as B, type CatalogPermission as C, type FeatureCatalogEntry as F, type LockReason as L, type PlatformBucket as P, type RoleItem as R, SNAPSHOT_SCHEMA_VERSION as S, type VersionSnapshot as V, type PlatformCodes as a, type FeatureUnlocks as b, type PlatformDenyCodes as c, PLATFORMS as d, type SnapshotApp as e, type SnapshotBusiness as f, type SnapshotFeature as g, type SnapshotMicrofrontendMobile as h, type SnapshotMicrofrontends as i, type SnapshotMicrofrontendWeb as j, type SnapshotPermission as k, type SnapshotPlan as l, type SnapshotRoleTemplate as m };
139
+ export { type BusinessVocabulary as B, type CatalogPermission as C, type FeatureCatalogEntry as F, type LockReason as L, type PlatformBucket as P, type RoleItem as R, type ScopeType as S, type VersionSnapshot as V, type SiteType as a, type SiteFeatureLocks as b, type SnapshotFeature as c, type PlatformCodes as d, type FeatureUnlocks as e, type PlatformDenyCodes as f, type FeatureLocks as g, PLATFORMS as h, SITE_TYPES as i, SNAPSHOT_SCHEMA_VERSION as j, type SnapshotApp as k, type SnapshotAppFeatureRef as l, type VocabularyEntry as m, type SnapshotBusiness as n, type SnapshotMicrofrontendMobile as o, type SnapshotMicrofrontends as p, type SnapshotMicrofrontendWeb as q, type SnapshotPermission as r, type SnapshotPlan as s, type SnapshotRoleTemplate as t, snapshotFeatureKey as u };
package/dist/types.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types/index.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types/index.ts"],"sourcesContent":["export type { ApiErrorResponse, FieldError, ProblemDetails } from './error-response.types';\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;;","names":[]}
@@ -0,0 +1,17 @@
1
+ interface FieldError {
2
+ field: string;
3
+ message: string;
4
+ }
5
+ interface ProblemDetails {
6
+ type: string;
7
+ title: string;
8
+ status: number;
9
+ label?: string;
10
+ detail: string;
11
+ instance?: string;
12
+ }
13
+ interface ApiErrorResponse extends ProblemDetails {
14
+ errors: FieldError[];
15
+ }
16
+
17
+ export type { ApiErrorResponse, FieldError, ProblemDetails };
@@ -0,0 +1,17 @@
1
+ interface FieldError {
2
+ field: string;
3
+ message: string;
4
+ }
5
+ interface ProblemDetails {
6
+ type: string;
7
+ title: string;
8
+ status: number;
9
+ label?: string;
10
+ detail: string;
11
+ instance?: string;
12
+ }
13
+ interface ApiErrorResponse extends ProblemDetails {
14
+ errors: FieldError[];
15
+ }
16
+
17
+ export type { ApiErrorResponse, FieldError, ProblemDetails };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/utils.cjs ADDED
@@ -0,0 +1,273 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/utils/index.ts
22
+ var utils_exports = {};
23
+ __export(utils_exports, {
24
+ extractCountryFromPhone: () => extractCountryFromPhone,
25
+ gcd: () => gcd,
26
+ normalizePhoneNumber: () => normalizePhoneNumber,
27
+ parseExpiryToMs: () => parseExpiryToMs
28
+ });
29
+ module.exports = __toCommonJS(utils_exports);
30
+
31
+ // src/utils/math.utils.ts
32
+ function gcd(a, b) {
33
+ return b === 0 ? a : gcd(b, a % b);
34
+ }
35
+ __name(gcd, "gcd");
36
+
37
+ // src/utils/phone.utils.ts
38
+ var CALLING_CODE_TO_COUNTRY = {
39
+ // 3-digit codes
40
+ "355": "AL",
41
+ "213": "DZ",
42
+ "376": "AD",
43
+ "244": "AO",
44
+ "672": "AQ",
45
+ "374": "AM",
46
+ "297": "AW",
47
+ "994": "AZ",
48
+ "973": "BH",
49
+ "880": "BD",
50
+ "375": "BY",
51
+ "501": "BZ",
52
+ "229": "BJ",
53
+ "975": "BT",
54
+ "591": "BO",
55
+ "387": "BA",
56
+ "267": "BW",
57
+ "673": "BN",
58
+ "359": "BG",
59
+ "226": "BF",
60
+ "257": "BI",
61
+ "855": "KH",
62
+ "237": "CM",
63
+ "238": "CV",
64
+ "236": "CF",
65
+ "235": "TD",
66
+ "269": "KM",
67
+ "242": "CG",
68
+ "243": "CD",
69
+ "506": "CR",
70
+ "385": "HR",
71
+ "357": "CY",
72
+ "420": "CZ",
73
+ "253": "DJ",
74
+ "593": "EC",
75
+ "503": "SV",
76
+ "240": "GQ",
77
+ "291": "ER",
78
+ "372": "EE",
79
+ "251": "ET",
80
+ "679": "FJ",
81
+ "358": "FI",
82
+ "241": "GA",
83
+ "220": "GM",
84
+ "995": "GE",
85
+ "233": "GH",
86
+ "350": "GI",
87
+ "299": "GL",
88
+ "502": "GT",
89
+ "224": "GN",
90
+ "245": "GW",
91
+ "592": "GY",
92
+ "509": "HT",
93
+ "504": "HN",
94
+ "354": "IS",
95
+ "964": "IQ",
96
+ "353": "IE",
97
+ "972": "IL",
98
+ "225": "CI",
99
+ "962": "JO",
100
+ "254": "KE",
101
+ "686": "KI",
102
+ "965": "KW",
103
+ "996": "KG",
104
+ "856": "LA",
105
+ "371": "LV",
106
+ "961": "LB",
107
+ "266": "LS",
108
+ "231": "LR",
109
+ "218": "LY",
110
+ "423": "LI",
111
+ "370": "LT",
112
+ "352": "LU",
113
+ "389": "MK",
114
+ "261": "MG",
115
+ "265": "MW",
116
+ "960": "MV",
117
+ "223": "ML",
118
+ "356": "MT",
119
+ "692": "MH",
120
+ "222": "MR",
121
+ "230": "MU",
122
+ "262": "YT",
123
+ "691": "FM",
124
+ "373": "MD",
125
+ "377": "MC",
126
+ "976": "MN",
127
+ "382": "ME",
128
+ "258": "MZ",
129
+ "264": "NA",
130
+ "674": "NR",
131
+ "977": "NP",
132
+ "505": "NI",
133
+ "227": "NE",
134
+ "234": "NG",
135
+ "683": "NU",
136
+ "968": "OM",
137
+ "680": "PW",
138
+ "970": "PS",
139
+ "507": "PA",
140
+ "675": "PG",
141
+ "595": "PY",
142
+ "351": "PT",
143
+ "974": "QA",
144
+ "250": "RW",
145
+ "685": "WS",
146
+ "378": "SM",
147
+ "239": "ST",
148
+ "966": "SA",
149
+ "221": "SN",
150
+ "381": "RS",
151
+ "248": "SC",
152
+ "232": "SL",
153
+ "421": "SK",
154
+ "386": "SI",
155
+ "677": "SB",
156
+ "252": "SO",
157
+ "211": "SS",
158
+ "249": "SD",
159
+ "597": "SR",
160
+ "268": "SZ",
161
+ "963": "SY",
162
+ "992": "TJ",
163
+ "255": "TZ",
164
+ "228": "TG",
165
+ "676": "TO",
166
+ "216": "TN",
167
+ "993": "TM",
168
+ "688": "TV",
169
+ "256": "UG",
170
+ "380": "UA",
171
+ "971": "AE",
172
+ "598": "UY",
173
+ "998": "UZ",
174
+ "678": "VU",
175
+ "379": "VA",
176
+ "967": "YE",
177
+ "260": "ZM",
178
+ "263": "ZW",
179
+ // 2-digit codes
180
+ "93": "AF",
181
+ "54": "AR",
182
+ "61": "AU",
183
+ "43": "AT",
184
+ "32": "BE",
185
+ "55": "BR",
186
+ "56": "CL",
187
+ "86": "CN",
188
+ "57": "CO",
189
+ "53": "CU",
190
+ "45": "DK",
191
+ "20": "EG",
192
+ "33": "FR",
193
+ "49": "DE",
194
+ "30": "GR",
195
+ "36": "HU",
196
+ "91": "IN",
197
+ "62": "ID",
198
+ "98": "IR",
199
+ "39": "IT",
200
+ "81": "JP",
201
+ "82": "KR",
202
+ "60": "MY",
203
+ "52": "MX",
204
+ "31": "NL",
205
+ "64": "NZ",
206
+ "47": "NO",
207
+ "92": "PK",
208
+ "51": "PE",
209
+ "63": "PH",
210
+ "48": "PL",
211
+ "40": "RO",
212
+ "65": "SG",
213
+ "27": "ZA",
214
+ "34": "ES",
215
+ "94": "LK",
216
+ "46": "SE",
217
+ "41": "CH",
218
+ "66": "TH",
219
+ "90": "TR",
220
+ "44": "GB",
221
+ "58": "VE",
222
+ "84": "VN",
223
+ // 1-digit codes (shared codes default to most common country)
224
+ "1": "US",
225
+ "7": "RU"
226
+ };
227
+ function extractCountryFromPhone(phone) {
228
+ const digits = phone.startsWith("+") ? phone.slice(1) : phone;
229
+ for (const length of [
230
+ 3,
231
+ 2,
232
+ 1
233
+ ]) {
234
+ const prefix = digits.slice(0, length);
235
+ if (CALLING_CODE_TO_COUNTRY[prefix]) {
236
+ return CALLING_CODE_TO_COUNTRY[prefix];
237
+ }
238
+ }
239
+ return void 0;
240
+ }
241
+ __name(extractCountryFromPhone, "extractCountryFromPhone");
242
+ function normalizePhoneNumber(phone) {
243
+ return phone.startsWith("+") ? phone : `+${phone}`;
244
+ }
245
+ __name(normalizePhoneNumber, "normalizePhoneNumber");
246
+
247
+ // src/utils/time.utils.ts
248
+ function parseExpiryToMs(expiry) {
249
+ const match = expiry.match(/^(\d+)([smhdwy])$/);
250
+ if (!match) throw new Error(`Invalid expiry format: ${expiry}`);
251
+ const [, digits = "", unit = ""] = match;
252
+ const value = Number.parseInt(digits, 10);
253
+ const multipliers = {
254
+ s: 1e3,
255
+ m: 6e4,
256
+ h: 36e5,
257
+ d: 864e5,
258
+ w: 6048e5,
259
+ y: 31536e6
260
+ };
261
+ const multiplier = multipliers[unit];
262
+ if (multiplier === void 0) throw new Error(`Invalid expiry format: ${expiry}`);
263
+ return value * multiplier;
264
+ }
265
+ __name(parseExpiryToMs, "parseExpiryToMs");
266
+ // Annotate the CommonJS export names for ESM import in node:
267
+ 0 && (module.exports = {
268
+ extractCountryFromPhone,
269
+ gcd,
270
+ normalizePhoneNumber,
271
+ parseExpiryToMs
272
+ });
273
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/index.ts","../src/utils/math.utils.ts","../src/utils/phone.utils.ts","../src/utils/time.utils.ts"],"sourcesContent":["export { gcd } from './math.utils';\nexport { extractCountryFromPhone, normalizePhoneNumber } from './phone.utils';\nexport { parseExpiryToMs } from './time.utils';\n","// Returns the greatest common divisor of two integers using the Euclidean algorithm\nexport function gcd(a: number, b: number): number {\n return b === 0 ? a : gcd(b, a % b);\n}\n","const CALLING_CODE_TO_COUNTRY: Record<string, string> = {\n // 3-digit codes\n '355': 'AL',\n '213': 'DZ',\n '376': 'AD',\n '244': 'AO',\n '672': 'AQ',\n '374': 'AM',\n '297': 'AW',\n '994': 'AZ',\n '973': 'BH',\n '880': 'BD',\n '375': 'BY',\n '501': 'BZ',\n '229': 'BJ',\n '975': 'BT',\n '591': 'BO',\n '387': 'BA',\n '267': 'BW',\n '673': 'BN',\n '359': 'BG',\n '226': 'BF',\n '257': 'BI',\n '855': 'KH',\n '237': 'CM',\n '238': 'CV',\n '236': 'CF',\n '235': 'TD',\n '269': 'KM',\n '242': 'CG',\n '243': 'CD',\n '506': 'CR',\n '385': 'HR',\n '357': 'CY',\n '420': 'CZ',\n '253': 'DJ',\n '593': 'EC',\n '503': 'SV',\n '240': 'GQ',\n '291': 'ER',\n '372': 'EE',\n '251': 'ET',\n '679': 'FJ',\n '358': 'FI',\n '241': 'GA',\n '220': 'GM',\n '995': 'GE',\n '233': 'GH',\n '350': 'GI',\n '299': 'GL',\n '502': 'GT',\n '224': 'GN',\n '245': 'GW',\n '592': 'GY',\n '509': 'HT',\n '504': 'HN',\n '354': 'IS',\n '964': 'IQ',\n '353': 'IE',\n '972': 'IL',\n '225': 'CI',\n '962': 'JO',\n '254': 'KE',\n '686': 'KI',\n '965': 'KW',\n '996': 'KG',\n '856': 'LA',\n '371': 'LV',\n '961': 'LB',\n '266': 'LS',\n '231': 'LR',\n '218': 'LY',\n '423': 'LI',\n '370': 'LT',\n '352': 'LU',\n '389': 'MK',\n '261': 'MG',\n '265': 'MW',\n '960': 'MV',\n '223': 'ML',\n '356': 'MT',\n '692': 'MH',\n '222': 'MR',\n '230': 'MU',\n '262': 'YT',\n '691': 'FM',\n '373': 'MD',\n '377': 'MC',\n '976': 'MN',\n '382': 'ME',\n '258': 'MZ',\n '264': 'NA',\n '674': 'NR',\n '977': 'NP',\n '505': 'NI',\n '227': 'NE',\n '234': 'NG',\n '683': 'NU',\n '968': 'OM',\n '680': 'PW',\n '970': 'PS',\n '507': 'PA',\n '675': 'PG',\n '595': 'PY',\n '351': 'PT',\n '974': 'QA',\n '250': 'RW',\n '685': 'WS',\n '378': 'SM',\n '239': 'ST',\n '966': 'SA',\n '221': 'SN',\n '381': 'RS',\n '248': 'SC',\n '232': 'SL',\n '421': 'SK',\n '386': 'SI',\n '677': 'SB',\n '252': 'SO',\n '211': 'SS',\n '249': 'SD',\n '597': 'SR',\n '268': 'SZ',\n '963': 'SY',\n '992': 'TJ',\n '255': 'TZ',\n '228': 'TG',\n '676': 'TO',\n '216': 'TN',\n '993': 'TM',\n '688': 'TV',\n '256': 'UG',\n '380': 'UA',\n '971': 'AE',\n '598': 'UY',\n '998': 'UZ',\n '678': 'VU',\n '379': 'VA',\n '967': 'YE',\n '260': 'ZM',\n '263': 'ZW',\n\n // 2-digit codes\n '93': 'AF',\n '54': 'AR',\n '61': 'AU',\n '43': 'AT',\n '32': 'BE',\n '55': 'BR',\n '56': 'CL',\n '86': 'CN',\n '57': 'CO',\n '53': 'CU',\n '45': 'DK',\n '20': 'EG',\n '33': 'FR',\n '49': 'DE',\n '30': 'GR',\n '36': 'HU',\n '91': 'IN',\n '62': 'ID',\n '98': 'IR',\n '39': 'IT',\n '81': 'JP',\n '82': 'KR',\n '60': 'MY',\n '52': 'MX',\n '31': 'NL',\n '64': 'NZ',\n '47': 'NO',\n '92': 'PK',\n '51': 'PE',\n '63': 'PH',\n '48': 'PL',\n '40': 'RO',\n '65': 'SG',\n '27': 'ZA',\n '34': 'ES',\n '94': 'LK',\n '46': 'SE',\n '41': 'CH',\n '66': 'TH',\n '90': 'TR',\n '44': 'GB',\n '58': 'VE',\n '84': 'VN',\n\n // 1-digit codes (shared codes default to most common country)\n '1': 'US', // Also CA, but default to US\n '7': 'RU', // Also KZ, but default to RU\n};\n\n// Extracts ISO 3166-1 alpha-2 country code from an E.164 phone number\nexport function extractCountryFromPhone(phone: string): string | undefined {\n // Remove + prefix if present\n const digits = phone.startsWith('+') ? phone.slice(1) : phone;\n\n // Try matching from longest to shortest prefix (3, 2, 1 digits)\n for (const length of [3, 2, 1]) {\n const prefix = digits.slice(0, length);\n if (CALLING_CODE_TO_COUNTRY[prefix]) {\n return CALLING_CODE_TO_COUNTRY[prefix];\n }\n }\n\n return undefined;\n}\n\n// Normalizes a phone number to E.164 format by ensuring a + prefix\nexport function normalizePhoneNumber(phone: string): string {\n return phone.startsWith('+') ? phone : `+${phone}`;\n}\n","// Parses a duration string (e.g. '10m', '1h', '30s', '7d') to milliseconds\nexport function parseExpiryToMs(expiry: string): number {\n const match = expiry.match(/^(\\d+)([smhdwy])$/);\n if (!match) throw new Error(`Invalid expiry format: ${expiry}`);\n\n const [, digits = '', unit = ''] = match;\n const value = Number.parseInt(digits, 10);\n const multipliers: Record<string, number> = {\n s: 1000,\n m: 60_000,\n h: 3_600_000,\n d: 86_400_000,\n w: 604_800_000,\n y: 31_536_000_000,\n };\n\n const multiplier = multipliers[unit];\n if (multiplier === undefined) throw new Error(`Invalid expiry format: ${expiry}`);\n\n return value * multiplier;\n}\n"],"mappings":"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","names":["gcd","a","b","CALLING_CODE_TO_COUNTRY","extractCountryFromPhone","phone","digits","startsWith","slice","length","prefix","undefined","normalizePhoneNumber","parseExpiryToMs","expiry","match","Error","digits","unit","value","Number","parseInt","multipliers","s","m","h","d","w","y","multiplier","undefined"]}
@@ -0,0 +1,8 @@
1
+ declare function gcd(a: number, b: number): number;
2
+
3
+ declare function extractCountryFromPhone(phone: string): string | undefined;
4
+ declare function normalizePhoneNumber(phone: string): string;
5
+
6
+ declare function parseExpiryToMs(expiry: string): number;
7
+
8
+ export { extractCountryFromPhone, gcd, normalizePhoneNumber, parseExpiryToMs };
@@ -0,0 +1,8 @@
1
+ declare function gcd(a: number, b: number): number;
2
+
3
+ declare function extractCountryFromPhone(phone: string): string | undefined;
4
+ declare function normalizePhoneNumber(phone: string): string;
5
+
6
+ declare function parseExpiryToMs(expiry: string): number;
7
+
8
+ export { extractCountryFromPhone, gcd, normalizePhoneNumber, parseExpiryToMs };