@blux.ai/web-sdk 1.0.0-rc0 → 1.0.0-rc2

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 (128) hide show
  1. package/dist/package.json +4 -4
  2. package/dist/src/BluxClient.d.ts +41 -0
  3. package/dist/src/BluxClient.js +208 -0
  4. package/dist/src/BluxClient.js.map +1 -0
  5. package/dist/src/apis/APIs.d.ts +348 -0
  6. package/dist/src/apis/APIs.js +145 -0
  7. package/dist/src/apis/APIs.js.map +1 -0
  8. package/dist/src/apis/createEvent.d.ts +4 -0
  9. package/dist/src/apis/createEvent.js +7 -0
  10. package/dist/src/apis/createEvent.js.map +1 -0
  11. package/dist/src/apis/getItemRecommendation.d.ts +4 -0
  12. package/dist/src/apis/getItemRecommendation.js +7 -0
  13. package/dist/src/apis/getItemRecommendation.js.map +1 -0
  14. package/dist/src/apis/initialize.d.ts +4 -0
  15. package/dist/src/apis/initialize.js +7 -0
  16. package/dist/src/apis/initialize.js.map +1 -0
  17. package/dist/src/apis/signIn.d.ts +4 -0
  18. package/dist/src/apis/signIn.js +7 -0
  19. package/dist/src/apis/signIn.js.map +1 -0
  20. package/dist/src/apis/signOut.d.ts +4 -0
  21. package/dist/src/apis/signOut.js +7 -0
  22. package/dist/src/apis/signOut.js.map +1 -0
  23. package/dist/src/apis/updateCustomUserProperties.d.ts +4 -0
  24. package/dist/src/apis/updateCustomUserProperties.js +7 -0
  25. package/dist/src/apis/updateCustomUserProperties.js.map +1 -0
  26. package/dist/src/apis/updateUserProperties.d.ts +4 -0
  27. package/dist/src/apis/updateUserProperties.js +7 -0
  28. package/dist/src/apis/updateUserProperties.js.map +1 -0
  29. package/dist/src/constants/COUNTRIES.d.ts +928 -0
  30. package/dist/src/constants/COUNTRIES.js +1159 -0
  31. package/dist/src/constants/COUNTRIES.js.map +1 -0
  32. package/dist/src/constants/ISO8601_REGEX.d.ts +1 -0
  33. package/dist/src/constants/ISO8601_REGEX.js +4 -0
  34. package/dist/src/constants/ISO8601_REGEX.js.map +1 -0
  35. package/dist/src/events/AddCartaddEvent.d.ts +5 -0
  36. package/dist/src/events/AddCartaddEvent.js +13 -0
  37. package/dist/src/events/AddCartaddEvent.js.map +1 -0
  38. package/dist/src/events/AddCustomEvent.d.ts +5 -0
  39. package/dist/src/events/AddCustomEvent.js +11 -0
  40. package/dist/src/events/AddCustomEvent.js.map +1 -0
  41. package/dist/src/events/AddInstantImpression.d.ts +5 -0
  42. package/dist/src/events/AddInstantImpression.js +17 -0
  43. package/dist/src/events/AddInstantImpression.js.map +1 -0
  44. package/dist/src/events/AddLikeEvent.d.ts +5 -0
  45. package/dist/src/events/AddLikeEvent.js +13 -0
  46. package/dist/src/events/AddLikeEvent.js.map +1 -0
  47. package/dist/src/events/AddPageViewEvent.d.ts +5 -0
  48. package/dist/src/events/AddPageViewEvent.js +11 -0
  49. package/dist/src/events/AddPageViewEvent.js.map +1 -0
  50. package/dist/src/events/AddPageVisitEvent.d.ts +5 -0
  51. package/dist/src/events/AddPageVisitEvent.js +10 -0
  52. package/dist/src/events/AddPageVisitEvent.js.map +1 -0
  53. package/dist/src/events/AddPersistentImpression.d.ts +5 -0
  54. package/dist/src/events/AddPersistentImpression.js +17 -0
  55. package/dist/src/events/AddPersistentImpression.js.map +1 -0
  56. package/dist/src/events/AddProductDetailViewEvent.d.ts +5 -0
  57. package/dist/src/events/AddProductDetailViewEvent.js +16 -0
  58. package/dist/src/events/AddProductDetailViewEvent.js.map +1 -0
  59. package/dist/src/events/AddPurchaseEvent.d.ts +5 -0
  60. package/dist/src/events/AddPurchaseEvent.js +15 -0
  61. package/dist/src/events/AddPurchaseEvent.js.map +1 -0
  62. package/dist/src/events/AddRateEvent.d.ts +5 -0
  63. package/dist/src/events/AddRateEvent.js +11 -0
  64. package/dist/src/events/AddRateEvent.js.map +1 -0
  65. package/dist/src/events/AddSectionViewEvent.d.ts +5 -0
  66. package/dist/src/events/AddSectionViewEvent.js +14 -0
  67. package/dist/src/events/AddSectionViewEvent.js.map +1 -0
  68. package/dist/src/events/Event.d.ts +24 -0
  69. package/dist/src/events/Event.js +33 -0
  70. package/dist/src/events/Event.js.map +1 -0
  71. package/dist/src/events/VisitEvent.d.ts +5 -0
  72. package/dist/src/events/VisitEvent.js +10 -0
  73. package/dist/src/events/VisitEvent.js.map +1 -0
  74. package/dist/src/events/index.d.ts +10 -0
  75. package/dist/src/events/index.js +11 -0
  76. package/dist/src/events/index.js.map +1 -0
  77. package/dist/src/events/types.d.ts +75 -0
  78. package/dist/src/events/types.js +3 -0
  79. package/dist/src/events/types.js.map +1 -0
  80. package/dist/src/index.d.ts +4 -0
  81. package/dist/src/index.js +5 -0
  82. package/dist/src/index.js.map +1 -0
  83. package/dist/src/recommendations/ItemRecommendation.d.ts +5 -0
  84. package/dist/src/recommendations/ItemRecommendation.js +12 -0
  85. package/dist/src/recommendations/ItemRecommendation.js.map +1 -0
  86. package/dist/src/recommendations/Recommendation.d.ts +5 -0
  87. package/dist/src/recommendations/Recommendation.js +9 -0
  88. package/dist/src/recommendations/Recommendation.js.map +1 -0
  89. package/dist/src/recommendations/index.d.ts +1 -0
  90. package/dist/src/recommendations/index.js +2 -0
  91. package/dist/src/recommendations/index.js.map +1 -0
  92. package/dist/src/recommendations/types.d.ts +11 -0
  93. package/dist/src/recommendations/types.js +2 -0
  94. package/dist/src/recommendations/types.js.map +1 -0
  95. package/dist/src/utils/Base.d.ts +13 -0
  96. package/dist/src/utils/Base.js +2 -0
  97. package/dist/src/utils/Base.js.map +1 -0
  98. package/dist/src/utils/LocalStorage.d.ts +8 -0
  99. package/dist/src/utils/LocalStorage.js +30 -0
  100. package/dist/src/utils/LocalStorage.js.map +1 -0
  101. package/dist/src/utils/Logger.d.ts +13 -0
  102. package/dist/src/utils/Logger.js +49 -0
  103. package/dist/src/utils/Logger.js.map +1 -0
  104. package/dist/src/utils/assertEqualTypes.d.ts +3 -0
  105. package/dist/src/utils/assertEqualTypes.js +5 -0
  106. package/dist/src/utils/assertEqualTypes.js.map +1 -0
  107. package/dist/src/utils/getPath.d.ts +1 -0
  108. package/dist/src/utils/getPath.js +9 -0
  109. package/dist/src/utils/getPath.js.map +1 -0
  110. package/dist/src/utils/helper.d.ts +1 -0
  111. package/dist/src/utils/helper.js +4 -0
  112. package/dist/src/utils/helper.js.map +1 -0
  113. package/dist/src/utils/operators.d.ts +2 -0
  114. package/dist/src/utils/operators.js +6 -0
  115. package/dist/src/utils/operators.js.map +1 -0
  116. package/dist/src/utils/zodSchemas.d.ts +19 -0
  117. package/dist/src/utils/zodSchemas.js +105 -0
  118. package/dist/src/utils/zodSchemas.js.map +1 -0
  119. package/package.json +4 -4
  120. package/demo/craco.config.js +0 -29
  121. package/demo/package.json +0 -50
  122. package/demo/public/favicon.ico +0 -0
  123. package/demo/public/index.html +0 -43
  124. package/demo/public/logo192.png +0 -0
  125. package/demo/public/logo512.png +0 -0
  126. package/demo/public/manifest.json +0 -25
  127. package/demo/public/robots.txt +0 -3
  128. package/demo/tailwind.config.js +0 -10
@@ -0,0 +1,4 @@
1
+ import { BluxClient } from "./BluxClient";
2
+ export * from "./events";
3
+ export * from "./recommendations";
4
+ export { BluxClient };
@@ -0,0 +1,5 @@
1
+ import { BluxClient } from "./BluxClient";
2
+ export * from "./events";
3
+ export * from "./recommendations";
4
+ export { BluxClient };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { BluxClient } from \"./BluxClient\";\n\nexport * from \"./events\";\nexport * from \"./recommendations\";\n\nexport { BluxClient };\n"]}
@@ -0,0 +1,5 @@
1
+ import type { IItemRecommendation } from "./types";
2
+ import { Recommendation } from "./Recommendation";
3
+ export declare class ItemRecommendation extends Recommendation {
4
+ constructor({ call_type, limit, offset, item_ids }: IItemRecommendation);
5
+ }
@@ -0,0 +1,12 @@
1
+ import { Recommendation } from "./Recommendation";
2
+ export class ItemRecommendation extends Recommendation {
3
+ constructor({ call_type, limit, offset, item_ids }) {
4
+ super({
5
+ call_type,
6
+ limit,
7
+ offset: offset ?? 0,
8
+ item_ids,
9
+ });
10
+ }
11
+ }
12
+ //# sourceMappingURL=ItemRecommendation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemRecommendation.js","sourceRoot":"/","sources":["src/recommendations/ItemRecommendation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACpD,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAuB;QACrE,KAAK,CAAC;YACJ,SAAS;YACT,KAAK;YACL,MAAM,EAAE,MAAM,IAAI,CAAC;YACnB,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { IItemRecommendation } from \"./types\";\nimport { Recommendation } from \"./Recommendation\";\n\nexport class ItemRecommendation extends Recommendation {\n constructor({ call_type, limit, offset, item_ids }: IItemRecommendation) {\n super({\n call_type,\n limit,\n offset: offset ?? 0,\n item_ids,\n });\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { RecommendationRequest } from "./types";
2
+ export declare abstract class Recommendation {
3
+ readonly request: RecommendationRequest;
4
+ constructor(data: RecommendationRequest);
5
+ }
@@ -0,0 +1,9 @@
1
+ export class Recommendation {
2
+ request;
3
+ constructor(data) {
4
+ this.request = {
5
+ ...data,
6
+ };
7
+ }
8
+ }
9
+ //# sourceMappingURL=Recommendation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Recommendation.js","sourceRoot":"/","sources":["src/recommendations/Recommendation.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,cAAc;IAClB,OAAO,CAAwB;IAE/C,YAAY,IAA2B;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { RecommendationRequest } from \"./types\";\n\nexport abstract class Recommendation {\n public readonly request: RecommendationRequest;\n\n constructor(data: RecommendationRequest) {\n this.request = {\n ...data,\n };\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from "./ItemRecommendation";
@@ -0,0 +1,2 @@
1
+ export * from "./ItemRecommendation";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["src/recommendations/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./ItemRecommendation\";\n"]}
@@ -0,0 +1,11 @@
1
+ export interface RecommendationRequest {
2
+ call_type: string;
3
+ limit: number;
4
+ offset: number;
5
+ item_ids?: string[];
6
+ }
7
+ type BaseRecommendation = Omit<RecommendationRequest, "offset">;
8
+ export interface IItemRecommendation extends BaseRecommendation {
9
+ offset?: number;
10
+ }
11
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["src/recommendations/types.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nexport interface RecommendationRequest {\n call_type: string;\n limit: number;\n offset: number;\n item_ids?: string[];\n}\n\ntype BaseRecommendation = Omit<RecommendationRequest, \"offset\">;\n\nexport interface IItemRecommendation extends BaseRecommendation {\n offset?: number;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type ObjectId from "bson-objectid";
2
+ type AllObjectIdsToString<T> = {
3
+ [K in keyof T]: T[K] extends ObjectId ? string : T[K] extends ObjectId | undefined ? string | undefined : T[K] extends ObjectId | null ? string | null : T[K] extends ObjectId | null | undefined ? string | null | undefined : T[K] extends Date ? string : T[K] extends Date | null ? string | null : T[K] extends Date | undefined ? string | undefined : T[K] extends Record<string, any> | undefined ? AllObjectIdsToString<T[K]> : T[K];
4
+ };
5
+ export type Serialize<T> = AllObjectIdsToString<Omit<T, "id">>;
6
+ export interface BaseInDB {
7
+ deleted_at?: Date | null;
8
+ memo?: string;
9
+ _id: ObjectId;
10
+ created_at: Date;
11
+ updated_at: Date;
12
+ }
13
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Base.js","sourceRoot":"/","sources":["src/utils/Base.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type ObjectId from \"bson-objectid\";\n\ntype AllObjectIdsToString<T> = {\n [K in keyof T]: T[K] extends ObjectId\n ? string\n : T[K] extends ObjectId | undefined\n ? string | undefined\n : T[K] extends ObjectId | null\n ? string | null\n : T[K] extends ObjectId | null | undefined\n ? string | null | undefined\n : T[K] extends Date\n ? string\n : T[K] extends Date | null\n ? string | null\n : T[K] extends Date | undefined\n ? string | undefined\n : T[K] extends Record<string, any> | undefined\n ? AllObjectIdsToString<T[K]>\n : T[K];\n};\n\nexport type Serialize<T> = AllObjectIdsToString<Omit<T, \"id\">>;\n\nexport interface BaseInDB {\n deleted_at?: Date | null;\n memo?: string;\n\n // auto generated\n _id: ObjectId;\n created_at: Date;\n updated_at: Date;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ export declare class LocalStorage {
2
+ static getDeviceId(): string | null;
3
+ static setDeviceId(deviceId: string): void;
4
+ static getUrl(): string | null;
5
+ static setUrl(url: string): void;
6
+ static getRef(): string | null;
7
+ static setRef(ref: string): void;
8
+ }
@@ -0,0 +1,30 @@
1
+ const BLUX_DEVICE_ID = "blux_deviceId";
2
+ const BLUX_URL = "blux_url";
3
+ const BLUX_REF = "blux_ref";
4
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
5
+ export class LocalStorage {
6
+ static getDeviceId() {
7
+ const deviceId = localStorage.getItem(BLUX_DEVICE_ID);
8
+ return deviceId === "undefined" || deviceId?.trim() === ""
9
+ ? null
10
+ : deviceId;
11
+ }
12
+ static setDeviceId(deviceId) {
13
+ localStorage.setItem(BLUX_DEVICE_ID, deviceId);
14
+ }
15
+ static getUrl() {
16
+ const url = localStorage.getItem(BLUX_URL);
17
+ return url === "undefined" || url?.trim() === "" ? null : url;
18
+ }
19
+ static setUrl(url) {
20
+ localStorage.setItem(BLUX_URL, url);
21
+ }
22
+ static getRef() {
23
+ const ref = localStorage.getItem(BLUX_REF);
24
+ return ref === "undefined" || ref?.trim() === "" ? null : ref;
25
+ }
26
+ static setRef(ref) {
27
+ localStorage.setItem(BLUX_REF, ref);
28
+ }
29
+ }
30
+ //# sourceMappingURL=LocalStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalStorage.js","sourceRoot":"/","sources":["src/utils/LocalStorage.ts"],"names":[],"mappings":"AAAA,MAAM,cAAc,GAAG,eAAe,CAAC;AACvC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B,kEAAkE;AAClE,MAAM,OAAO,YAAY;IACvB,MAAM,CAAC,WAAW;QAChB,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACtD,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;YACxD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,QAAQ,CAAC;IACf,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,QAAgB;QACjC,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,CAAC,MAAM;QACX,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,MAAM;QACX,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;IAChE,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACtC,CAAC;CACF","sourcesContent":["const BLUX_DEVICE_ID = \"blux_deviceId\";\nconst BLUX_URL = \"blux_url\";\nconst BLUX_REF = \"blux_ref\";\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class LocalStorage {\n static getDeviceId(): string | null {\n const deviceId = localStorage.getItem(BLUX_DEVICE_ID);\n return deviceId === \"undefined\" || deviceId?.trim() === \"\"\n ? null\n : deviceId;\n }\n\n static setDeviceId(deviceId: string) {\n localStorage.setItem(BLUX_DEVICE_ID, deviceId);\n }\n\n static getUrl(): string | null {\n const url = localStorage.getItem(BLUX_URL);\n return url === \"undefined\" || url?.trim() === \"\" ? null : url;\n }\n\n static setUrl(url: string) {\n localStorage.setItem(BLUX_URL, url);\n }\n\n static getRef(): string | null {\n const ref = localStorage.getItem(BLUX_REF);\n return ref === \"undefined\" || ref?.trim() === \"\" ? null : ref;\n }\n\n static setRef(ref: string) {\n localStorage.setItem(BLUX_REF, ref);\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { ScopeContext } from "@sentry/types";
2
+ export type LogLevel = "debug" | "log" | "warning" | "error" | "fatal";
3
+ export type Context = Partial<Pick<ScopeContext, "tags" | "extra">>;
4
+ export declare class Logger {
5
+ static logLevel: LogLevel;
6
+ private static base;
7
+ static debug(message: string | Error, context?: Context): void;
8
+ static log(message: string | Error, context?: Context): void;
9
+ static warning(message: string | Error, context?: Context): void;
10
+ static error(message: string | Error, context?: Context): void;
11
+ static fatal(message: string | Error, context?: Context): void;
12
+ static setLevel(level: LogLevel): void;
13
+ }
@@ -0,0 +1,49 @@
1
+ const consoleMethodByLevel = {
2
+ debug: console.debug.bind(console),
3
+ log: console.log.bind(console),
4
+ warning: console.warn.bind(console),
5
+ error: console.error.bind(console),
6
+ fatal: console.error.bind(console),
7
+ };
8
+ const LOG_LEVEL_ORDERS = {
9
+ debug: 0,
10
+ log: 1,
11
+ warning: 2,
12
+ error: 3,
13
+ fatal: 4,
14
+ };
15
+ // eslint-disable-next-line @typescript-eslint/no-extraneous-class
16
+ export class Logger {
17
+ static logLevel = "error";
18
+ static base(message, level, context) {
19
+ if (LOG_LEVEL_ORDERS[level] >= LOG_LEVEL_ORDERS[this.logLevel]) {
20
+ const logForConsole = ["[BluxClient]", message];
21
+ if (context?.extra) {
22
+ logForConsole.push(context.extra);
23
+ }
24
+ if (context?.tags) {
25
+ logForConsole.push(context.tags);
26
+ }
27
+ consoleMethodByLevel[level]?.(...logForConsole);
28
+ }
29
+ }
30
+ static debug(message, context) {
31
+ this.base(message, "debug", context);
32
+ }
33
+ static log(message, context) {
34
+ this.base(message, "log", context);
35
+ }
36
+ static warning(message, context) {
37
+ this.base(message, "warning", context);
38
+ }
39
+ static error(message, context) {
40
+ this.base(message, "error", context);
41
+ }
42
+ static fatal(message, context) {
43
+ this.base(message, "fatal", context);
44
+ }
45
+ static setLevel(level) {
46
+ this.logLevel = level;
47
+ }
48
+ }
49
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","sourceRoot":"/","sources":["src/utils/Logger.ts"],"names":[],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AAC,CAAC;IACvC,CAAC;IACM,MAAM,CAAC,GAAG,CAAC,OAAuB,EAAE,OAAiB;QAC1D,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IACM,MAAM,CAAC,OAAO,CAAC,OAAuB,EAAE,OAAiB;QAC9D,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,OAAuB,EAAE,OAAiB;QAC5D,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACM,MAAM,CAAC,KAAK,CAAC,OAAuB,EAAE,OAAiB;QAC5D,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,KAAe;QACpC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport type { ScopeContext } from \"@sentry/types\";\n\nconst consoleMethodByLevel = {\n debug: console.debug.bind(console),\n log: console.log.bind(console),\n warning: console.warn.bind(console),\n error: console.error.bind(console),\n fatal: console.error.bind(console),\n} as const;\n\nexport type LogLevel = \"debug\" | \"log\" | \"warning\" | \"error\" | \"fatal\";\n\nconst LOG_LEVEL_ORDERS = {\n debug: 0,\n log: 1,\n warning: 2,\n error: 3,\n fatal: 4,\n};\n\nexport type Context = Partial<Pick<ScopeContext, \"tags\" | \"extra\">>;\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport class Logger {\n public static logLevel: LogLevel = \"error\";\n\n private static base(\n message: string | Error,\n level: LogLevel,\n context?: Context,\n ) {\n if (LOG_LEVEL_ORDERS[level] >= LOG_LEVEL_ORDERS[this.logLevel]) {\n const logForConsole: unknown[] = [\"[BluxClient]\", message];\n\n if (context?.extra) {\n logForConsole.push(context.extra);\n }\n if (context?.tags) {\n logForConsole.push(context.tags);\n }\n\n consoleMethodByLevel[level]?.(...logForConsole);\n }\n }\n public static debug(message: string | Error, context?: Context) {\n this.base(message, \"debug\", context);\n }\n public static log(message: string | Error, context?: Context) {\n this.base(message, \"log\", context);\n }\n public static warning(message: string | Error, context?: Context) {\n this.base(message, \"warning\", context);\n }\n public static error(message: string | Error, context?: Context) {\n this.base(message, \"error\", context);\n }\n public static fatal(message: string | Error, context?: Context) {\n this.base(message, \"fatal\", context);\n }\n\n public static setLevel(level: LogLevel) {\n this.logLevel = level;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ type AssertEqual<T, U> = T extends U ? (U extends T ? true : never) : never;
2
+ export declare function assertEqualTypes<T, U>(_arg: AssertEqual<T, U>): void;
3
+ export {};
@@ -0,0 +1,5 @@
1
+ export function assertEqualTypes(_arg) {
2
+ // do nothing
3
+ }
4
+ assertEqualTypes(true);
5
+ //# sourceMappingURL=assertEqualTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertEqualTypes.js","sourceRoot":"/","sources":["src/utils/assertEqualTypes.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAO,IAAuB;IAC5D,aAAa;AACf,CAAC;AAKD,gBAAgB,CAAe,IAAI,CAAC,CAAC","sourcesContent":["type AssertEqual<T, U> = T extends U ? (U extends T ? true : never) : never;\n\nexport function assertEqualTypes<T, U>(_arg: AssertEqual<T, U>): void {\n // do nothing\n}\n\n// exmaples\ntype TypeA = { name: string; age: number };\ntype TypeB = { name: string; age: number };\nassertEqualTypes<TypeA, TypeB>(true);\n"]}
@@ -0,0 +1 @@
1
+ export declare function getPath(path: string, pathParams: Record<string, string>): string;
@@ -0,0 +1,9 @@
1
+ export function getPath(path, pathParams) {
2
+ return Object.keys(pathParams).reduce((acc, key) => {
3
+ const value = pathParams[key];
4
+ if (value === undefined)
5
+ return acc;
6
+ return acc.replace(new RegExp(`\\{${key}\\}`, "g"), value);
7
+ }, path);
8
+ }
9
+ //# sourceMappingURL=getPath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPath.js","sourceRoot":"/","sources":["src/utils/getPath.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,UAAkC;IACtE,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACjD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC;QAEpC,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,KAAK,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC","sourcesContent":["export function getPath(path: string, pathParams: Record<string, string>) {\n return Object.keys(pathParams).reduce((acc, key) => {\n const value = pathParams[key];\n if (value === undefined) return acc;\n\n return acc.replace(new RegExp(`\\\\{${key}\\\\}`, \"g\"), value);\n }, path);\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const getCurrentUnixTimestamp: () => number;
@@ -0,0 +1,4 @@
1
+ export const getCurrentUnixTimestamp = () => {
2
+ return new Date().getTime() / 1e3;
3
+ };
4
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"/","sources":["src/utils/helper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAC1C,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC;AACpC,CAAC,CAAC","sourcesContent":["export const getCurrentUnixTimestamp = () => {\n return new Date().getTime() / 1e3;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ import type { OperatorFunction } from "rxjs";
2
+ export declare function filterNullable<T>(): OperatorFunction<T | null | undefined, T>;
@@ -0,0 +1,6 @@
1
+ import { filter } from "rxjs";
2
+ export function filterNullable() {
3
+ // eslint-disable-next-line no-eq-null,eqeqeq
4
+ return filter((v) => v != null);
5
+ }
6
+ //# sourceMappingURL=operators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operators.js","sourceRoot":"/","sources":["src/utils/operators.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,MAAM,UAAU,cAAc;IAC5B,6CAA6C;IAC7C,OAAO,MAAM,CAAC,CAAC,CAAC,EAAU,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import type { OperatorFunction } from \"rxjs\";\nimport { filter } from \"rxjs\";\n\nexport function filterNullable<T>(): OperatorFunction<T | null | undefined, T> {\n // eslint-disable-next-line no-eq-null,eqeqeq\n return filter((v): v is T => v != null);\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import ObjectId from "bson-objectid";
3
+ export declare const objectIdSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, ObjectId, string>;
4
+ export declare const stringToNumberSchema: z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, string | number, string | number>, number, string | number>;
5
+ export declare const dateSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>;
6
+ export declare const anonymousObjectSchema: <T extends object = object>() => z.ZodEffects<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, T, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
7
+ export declare const countryCodeWithLowerCaseSchema: z.ZodEffects<z.ZodEnum<["AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BA" | "BW" | "BR" | "IO" | "BN" | "BG" | "BF" | "BI" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "CI" | "HR" | "CU" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "JM" | "JP" | "JO" | "KE" | "KI" | "KP" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "GY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "RO" | "RU" | "KZ" | "RW" | "RE" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SK" | "SI" | "SB" | "SO" | "ZA" | "SS" | "ES" | "LK" | "SD" | "SR" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "US" | "CA" | "UY" | "UZ" | "VU" | "VE" | "VN" | "VG" | "VI" | "WF" | "YE" | "ZM" | "ZW", ...("AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BA" | "BW" | "BR" | "IO" | "BN" | "BG" | "BF" | "BI" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "CI" | "HR" | "CU" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "JM" | "JP" | "JO" | "KE" | "KI" | "KP" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "GY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "RO" | "RU" | "KZ" | "RW" | "RE" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SK" | "SI" | "SB" | "SO" | "ZA" | "SS" | "ES" | "LK" | "SD" | "SR" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "US" | "CA" | "UY" | "UZ" | "VU" | "VE" | "VN" | "VG" | "VI" | "WF" | "YE" | "ZM" | "ZW")[]]>, "AF" | "AL" | "DZ" | "AS" | "AD" | "AO" | "AI" | "AG" | "AR" | "AM" | "AW" | "AU" | "AT" | "AZ" | "BS" | "BH" | "BD" | "BB" | "BY" | "BE" | "BZ" | "BJ" | "BM" | "BT" | "BO" | "BA" | "BW" | "BR" | "IO" | "BN" | "BG" | "BF" | "BI" | "KH" | "CM" | "CV" | "KY" | "CF" | "TD" | "CL" | "CN" | "CO" | "KM" | "CG" | "CD" | "CK" | "CR" | "CI" | "HR" | "CU" | "CY" | "CZ" | "DK" | "DJ" | "DM" | "DO" | "EC" | "EG" | "SV" | "GQ" | "ER" | "EE" | "ET" | "FK" | "FO" | "FJ" | "FI" | "FR" | "GF" | "PF" | "GA" | "GM" | "GE" | "DE" | "GH" | "GI" | "GR" | "GL" | "GD" | "GP" | "GU" | "GT" | "GN" | "GW" | "HT" | "VA" | "HN" | "HK" | "HU" | "IS" | "IN" | "ID" | "IR" | "IQ" | "IE" | "IL" | "IT" | "JM" | "JP" | "JO" | "KE" | "KI" | "KP" | "KR" | "KW" | "KG" | "LA" | "LV" | "LB" | "LS" | "LR" | "LY" | "LI" | "LT" | "LU" | "MO" | "MK" | "MG" | "MW" | "MY" | "MV" | "ML" | "MT" | "MH" | "MQ" | "MR" | "MU" | "YT" | "MX" | "FM" | "MD" | "MC" | "MN" | "ME" | "MS" | "MA" | "MZ" | "MM" | "NA" | "NR" | "NP" | "NL" | "NC" | "NZ" | "NI" | "NE" | "NG" | "NU" | "NF" | "MP" | "NO" | "OM" | "PK" | "PW" | "PS" | "PA" | "PG" | "PY" | "GY" | "PE" | "PH" | "PL" | "PT" | "PR" | "QA" | "RO" | "RU" | "KZ" | "RW" | "RE" | "BL" | "SH" | "KN" | "LC" | "MF" | "PM" | "VC" | "WS" | "SM" | "ST" | "SA" | "SN" | "RS" | "SC" | "SL" | "SG" | "SK" | "SI" | "SB" | "SO" | "ZA" | "SS" | "ES" | "LK" | "SD" | "SR" | "SZ" | "SE" | "CH" | "SY" | "TW" | "TJ" | "TZ" | "TH" | "TL" | "TG" | "TK" | "TO" | "TT" | "TN" | "TR" | "TM" | "TC" | "TV" | "UG" | "UA" | "AE" | "GB" | "US" | "CA" | "UY" | "UZ" | "VU" | "VE" | "VN" | "VG" | "VI" | "WF" | "YE" | "ZM" | "ZW", unknown>;
8
+ export declare const customPropertiesRequestSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString, "many">, z.ZodNull]>>;
9
+ export declare const customPropertiesSchema: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, Date, string>, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString, "many">]>>;
10
+ export type CustomProperties = z.infer<typeof customPropertiesSchema>;
11
+ export declare enum CustomPropertyDataType {
12
+ DATE = "DATE",
13
+ STRING = "STRING",
14
+ NUMBER = "NUMBER",
15
+ BOOLEAN = "BOOLEAN",
16
+ ARRAY_OF_STRING = "ARRAY_OF_STRING"
17
+ }
18
+ export declare const stringToObjectIdsSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>, ObjectId[], string>;
19
+ export declare const stringToArraySchema: z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>;
@@ -0,0 +1,105 @@
1
+ import { z, ZodError } from "zod";
2
+ import { COUNTRY_CODES } from "../constants/COUNTRIES";
3
+ import { assertEqualTypes } from "./assertEqualTypes";
4
+ import { ISO8601_REGEX } from "../constants/ISO8601_REGEX";
5
+ import ObjectId from "bson-objectid";
6
+ function isObjectId(value) {
7
+ return (typeof value === "string" && value.length === 24 && ObjectId.isValid(value));
8
+ }
9
+ export const objectIdSchema = z
10
+ .string()
11
+ .refine((v) => isObjectId(v), (v) => new ZodError([
12
+ {
13
+ code: "custom",
14
+ message: `Invalid ObjectId: ${v}`,
15
+ path: ["some_path"],
16
+ },
17
+ ]))
18
+ .transform((v) => new ObjectId(v));
19
+ export const stringToNumberSchema = z
20
+ .union([z.string(), z.number()])
21
+ .refine((v) => {
22
+ if (typeof v === "number")
23
+ return true;
24
+ const parsed = Number(v);
25
+ return !isNaN(parsed);
26
+ }, {
27
+ message: "Invalid number or string in stringToNumberSchema",
28
+ })
29
+ .transform((v) => (typeof v === "number" ? v : Number(v)));
30
+ export const dateSchema = z
31
+ .string()
32
+ .refine((dateString) => {
33
+ return ISO8601_REGEX.test(dateString);
34
+ }, {
35
+ message: "Invalid date string",
36
+ })
37
+ .transform((dateString) => new Date(dateString));
38
+ function convertAllObjectId(input) {
39
+ if (Array.isArray(input)) {
40
+ return input.map((item) => convertAllObjectId(item));
41
+ }
42
+ else if (isObjectId(input)) {
43
+ return new ObjectId(input);
44
+ }
45
+ else if (typeof input === "string" &&
46
+ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(input)) {
47
+ return new Date(input);
48
+ }
49
+ else if (input !== null && typeof input === "object") {
50
+ return Object.entries(input).reduce((acc, [key, value]) => {
51
+ acc[key] = convertAllObjectId(value);
52
+ return acc;
53
+ }, {});
54
+ }
55
+ return input;
56
+ }
57
+ export const anonymousObjectSchema = () => z
58
+ .object({})
59
+ .passthrough()
60
+ .transform((v) => convertAllObjectId(v));
61
+ export const countryCodeWithLowerCaseSchema = z.preprocess((v) => {
62
+ if (v === "419")
63
+ return undefined; // https://en.wikipedia.org/wiki/Language_code
64
+ if (typeof v === "string")
65
+ return v.toUpperCase();
66
+ return v;
67
+ }, z.enum(COUNTRY_CODES));
68
+ export const customPropertiesRequestSchema = z.record(z.union([
69
+ dateSchema,
70
+ z.string(),
71
+ z.number(),
72
+ z.boolean(),
73
+ z.array(z.string()),
74
+ z.null(),
75
+ ]));
76
+ export const customPropertiesSchema = z.record(z.union([
77
+ dateSchema,
78
+ z.string(),
79
+ z.number(),
80
+ z.boolean(),
81
+ z.array(z.string()),
82
+ ]));
83
+ assertEqualTypes(true);
84
+ export var CustomPropertyDataType;
85
+ (function (CustomPropertyDataType) {
86
+ CustomPropertyDataType["DATE"] = "DATE";
87
+ CustomPropertyDataType["STRING"] = "STRING";
88
+ CustomPropertyDataType["NUMBER"] = "NUMBER";
89
+ CustomPropertyDataType["BOOLEAN"] = "BOOLEAN";
90
+ CustomPropertyDataType["ARRAY_OF_STRING"] = "ARRAY_OF_STRING";
91
+ })(CustomPropertyDataType || (CustomPropertyDataType = {}));
92
+ export const stringToObjectIdsSchema = z
93
+ .string()
94
+ .transform((v) => v.split(","))
95
+ .refine((arr) => arr.every((item) => item.length > 0), {
96
+ message: "Each ObjectId should not be empty",
97
+ })
98
+ .transform((arr) => arr.map((id) => objectIdSchema.parse(id)));
99
+ export const stringToArraySchema = z
100
+ .string()
101
+ .transform((v) => v.split(",").map((item) => item.trim()))
102
+ .refine((arr) => arr.every((item) => item.length > 0), {
103
+ message: "Each item should not be empty",
104
+ });
105
+ //# sourceMappingURL=zodSchemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zodSchemas.js","sourceRoot":"/","sources":["src/utils/zodSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CA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CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KAC9B,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;IACrD,OAAO,EAAE,mCAAmC;CAC7C,CAAC;KACD,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,EAAE;KACR,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;KACzD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;IACrD,OAAO,EAAE,+BAA+B;CACzC,CAAC,CAAC","sourcesContent":["import { z, ZodError } from \"zod\";\nimport type { CountryCode } from \"../constants/COUNTRIES\";\nimport { COUNTRY_CODES } from \"../constants/COUNTRIES\";\nimport { assertEqualTypes } from \"./assertEqualTypes\";\nimport { ISO8601_REGEX } from \"../constants/ISO8601_REGEX\";\nimport ObjectId from \"bson-objectid\";\n\nfunction isObjectId(value: unknown): value is string {\n return (\n typeof value === \"string\" && value.length === 24 && ObjectId.isValid(value)\n );\n}\n\nexport const objectIdSchema = z\n .string()\n .refine(\n (v) => isObjectId(v),\n (v) =>\n new ZodError([\n {\n code: \"custom\",\n message: `Invalid ObjectId: ${v}`,\n path: [\"some_path\"],\n },\n ]),\n )\n .transform((v) => new ObjectId(v));\n\nexport const stringToNumberSchema = z\n .union([z.string(), z.number()])\n .refine(\n (v) => {\n if (typeof v === \"number\") return true;\n const parsed = Number(v);\n return !isNaN(parsed);\n },\n {\n message: \"Invalid number or string in stringToNumberSchema\",\n },\n )\n .transform((v): number => (typeof v === \"number\" ? v : Number(v)));\n\nexport const dateSchema = z\n .string()\n .refine(\n (dateString) => {\n return ISO8601_REGEX.test(dateString);\n },\n {\n message: \"Invalid date string\",\n },\n )\n .transform((dateString) => new Date(dateString));\n\nfunction convertAllObjectId(input: unknown): unknown {\n if (Array.isArray(input)) {\n return input.map((item) => convertAllObjectId(item));\n } else if (isObjectId(input)) {\n return new ObjectId(input);\n } else if (\n typeof input === \"string\" &&\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/.test(input)\n ) {\n return new Date(input);\n } else if (input !== null && typeof input === \"object\") {\n return Object.entries(input).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n acc[key] = convertAllObjectId(value);\n return acc;\n },\n {},\n );\n }\n return input;\n}\n\nexport const anonymousObjectSchema = <T extends object = object>() =>\n z\n .object({})\n .passthrough()\n .transform((v) => convertAllObjectId(v) as T);\n\nexport const countryCodeWithLowerCaseSchema = z.preprocess(\n (v) => {\n if (v === \"419\") return undefined; // https://en.wikipedia.org/wiki/Language_code\n if (typeof v === \"string\") return v.toUpperCase();\n return v;\n },\n z.enum(COUNTRY_CODES as [CountryCode, ...CountryCode[]]),\n);\n\nexport const customPropertiesRequestSchema = z.record(\n z.union([\n dateSchema,\n z.string(),\n z.number(),\n z.boolean(),\n z.array(z.string()),\n z.null(),\n ]),\n);\n\ntype CustomPropertiesRequest = z.infer<typeof customPropertiesRequestSchema>;\n\nexport const customPropertiesSchema = z.record(\n z.union([\n dateSchema,\n z.string(),\n z.number(),\n z.boolean(),\n z.array(z.string()),\n ]),\n);\n\nexport type CustomProperties = z.infer<typeof customPropertiesSchema>;\n\nassertEqualTypes<\n {\n [K in keyof CustomPropertiesRequest]: Exclude<\n CustomPropertiesRequest[K],\n null\n >;\n },\n CustomProperties\n>(true);\n\nexport enum CustomPropertyDataType {\n DATE = \"DATE\",\n STRING = \"STRING\",\n NUMBER = \"NUMBER\",\n BOOLEAN = \"BOOLEAN\",\n ARRAY_OF_STRING = \"ARRAY_OF_STRING\",\n}\n\nexport const stringToObjectIdsSchema = z\n .string()\n .transform((v) => v.split(\",\"))\n .refine((arr) => arr.every((item) => item.length > 0), {\n message: \"Each ObjectId should not be empty\",\n })\n .transform((arr) => arr.map((id) => objectIdSchema.parse(id)));\n\nexport const stringToArraySchema = z\n .string()\n .transform((v) => v.split(\",\").map((item) => item.trim()))\n .refine((arr) => arr.every((item) => item.length > 0), {\n message: \"Each item should not be empty\",\n });\n"]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@blux.ai/web-sdk",
3
- "version": "1.0.0-rc0",
3
+ "version": "1.0.0-rc2",
4
4
  "description": "The official Blux JavaScript browser client library",
5
- "main": "dist/index.js",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
5
+ "main": "dist/src/index.js",
6
+ "module": "dist/src/index.js",
7
+ "types": "dist//src/index.d.ts",
8
8
  "license": "UNLICENSED",
9
9
  "scripts": {
10
10
  "test": "jest",
@@ -1,29 +0,0 @@
1
- /* eslint-disable no-undef */
2
-
3
- module.exports = {
4
- webpack: {
5
- configure: (config) => {
6
- // ...
7
- const fileLoaderRule = getFileLoaderRule(config.module.rules);
8
- if (!fileLoaderRule) {
9
- throw new Error("File loader not found");
10
- }
11
- fileLoaderRule.exclude.push(/\.cjs$/);
12
- // ...
13
- return config;
14
- },
15
- },
16
- };
17
-
18
- function getFileLoaderRule(rules) {
19
- for (const rule of rules) {
20
- if ("oneOf" in rule) {
21
- const found = getFileLoaderRule(rule.oneOf);
22
- if (found) {
23
- return found;
24
- }
25
- } else if (rule.test === undefined && rule.type === "asset/resource") {
26
- return rule;
27
- }
28
- }
29
- }
package/demo/package.json DELETED
@@ -1,50 +0,0 @@
1
- {
2
- "name": "demo",
3
- "version": "0.1.0",
4
- "private": true,
5
- "dependencies": {
6
- "@blux.ai/web-sdk": "workspace:*",
7
- "@testing-library/jest-dom": "^5.14.1",
8
- "@testing-library/react": "^13.0.0",
9
- "@types/jest": "^27.0.1",
10
- "@types/node": "^16.7.13",
11
- "@types/react": "^18.0.0",
12
- "@types/react-dom": "^18.0.0",
13
- "react": "^18.3.1",
14
- "react-dom": "^18.3.1",
15
- "react-scripts": "5.0.1",
16
- "typescript": "^4.4.2",
17
- "web-vitals": "^2.1.0"
18
- },
19
- "scripts": {
20
- "start": "craco start",
21
- "build": "craco build",
22
- "test": "craco test",
23
- "eject": "react-scripts eject"
24
- },
25
- "eslintConfig": {
26
- "extends": [
27
- "react-app",
28
- "react-app/jest"
29
- ]
30
- },
31
- "browserslist": {
32
- "production": [
33
- ">0.2%",
34
- "not dead",
35
- "not op_mini all"
36
- ],
37
- "development": [
38
- "last 1 chrome version",
39
- "last 1 firefox version",
40
- "last 1 safari version"
41
- ]
42
- },
43
- "devDependencies": {
44
- "@craco/craco": "^7.1.0",
45
- "tailwindcss": "^3.4.4"
46
- },
47
- "installConfig": {
48
- "hoistingLimits": "workspaces"
49
- }
50
- }
Binary file
@@ -1,43 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>React App</title>
28
- </head>
29
- <body>
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
Binary file
Binary file