@blux.ai/web-sdk 1.1.7 → 1.2.0

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 (43) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/BluxClient.d.ts +5 -2
  3. package/dist/src/BluxClient.js +104 -30
  4. package/dist/src/BluxClient.js.map +1 -1
  5. package/dist/src/apis/APIs.d.ts +73 -50
  6. package/dist/src/apis/APIs.js +23 -18
  7. package/dist/src/apis/APIs.js.map +1 -1
  8. package/dist/src/apis/getItemRecommendations.d.ts +4 -0
  9. package/dist/src/apis/getItemRecommendations.js +7 -0
  10. package/dist/src/apis/getItemRecommendations.js.map +1 -0
  11. package/dist/src/index.d.ts +1 -1
  12. package/dist/src/index.js +1 -1
  13. package/dist/src/index.js.map +1 -1
  14. package/dist/src/recs/ItemRec.d.ts +14 -0
  15. package/dist/src/recs/ItemRec.js +41 -0
  16. package/dist/src/recs/ItemRec.js.map +1 -0
  17. package/dist/src/recs/Rec.d.ts +5 -0
  18. package/dist/src/{recommendations/Recommendation.js → recs/Rec.js} +2 -2
  19. package/dist/src/recs/Rec.js.map +1 -0
  20. package/dist/src/recs/index.d.ts +1 -0
  21. package/dist/src/recs/index.js +2 -0
  22. package/dist/src/recs/index.js.map +1 -0
  23. package/dist/src/recs/types.d.ts +27 -0
  24. package/dist/src/recs/types.js.map +1 -0
  25. package/dist/src/utils/zodSchemas.d.ts +65 -0
  26. package/dist/src/utils/zodSchemas.js +19 -0
  27. package/dist/src/utils/zodSchemas.js.map +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
  30. package/dist/src/apis/getItemRecommendation.d.ts +0 -4
  31. package/dist/src/apis/getItemRecommendation.js +0 -7
  32. package/dist/src/apis/getItemRecommendation.js.map +0 -1
  33. package/dist/src/recommendations/ItemRecommendation.d.ts +0 -5
  34. package/dist/src/recommendations/ItemRecommendation.js +0 -13
  35. package/dist/src/recommendations/ItemRecommendation.js.map +0 -1
  36. package/dist/src/recommendations/Recommendation.d.ts +0 -5
  37. package/dist/src/recommendations/Recommendation.js.map +0 -1
  38. package/dist/src/recommendations/index.d.ts +0 -1
  39. package/dist/src/recommendations/index.js +0 -2
  40. package/dist/src/recommendations/index.js.map +0 -1
  41. package/dist/src/recommendations/types.d.ts +0 -12
  42. package/dist/src/recommendations/types.js.map +0 -1
  43. /package/dist/src/{recommendations → recs}/types.js +0 -0
@@ -1,4 +1,4 @@
1
1
  import { BluxClient } from "./BluxClient";
2
2
  export * from "./events";
3
- export * from "./recommendations";
3
+ export * from "./recs";
4
4
  export { BluxClient };
package/dist/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BluxClient } from "./BluxClient";
2
2
  export * from "./events";
3
- export * from "./recommendations";
3
+ export * from "./recs";
4
4
  export { BluxClient };
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +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"]}
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,QAAQ,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { BluxClient } from \"./BluxClient\";\n\nexport * from \"./events\";\nexport * from \"./recs\";\n\nexport { BluxClient };\n"]}
@@ -0,0 +1,14 @@
1
+ import { Rec } from "./Rec";
2
+ import type { ICategoryRec, IItemRelatedRec, IItemsRelatedRec, IUserRec } from "./types";
3
+ export declare class UserRec extends Rec {
4
+ constructor({ call_type, limit, offset }: IUserRec);
5
+ }
6
+ export declare class ItemRelatedRec extends Rec {
7
+ constructor({ call_type, item_id, limit, offset }: IItemRelatedRec);
8
+ }
9
+ export declare class ItemsRelatedRec extends Rec {
10
+ constructor({ call_type, item_ids, limit, offset }: IItemsRelatedRec);
11
+ }
12
+ export declare class CategoryRec extends Rec {
13
+ constructor({ call_type, category_id, limit, offset }: ICategoryRec);
14
+ }
@@ -0,0 +1,41 @@
1
+ import { Rec } from "./Rec";
2
+ export class UserRec extends Rec {
3
+ constructor({ call_type, limit, offset }) {
4
+ super({
5
+ call_type,
6
+ limit,
7
+ offset,
8
+ });
9
+ }
10
+ }
11
+ export class ItemRelatedRec extends Rec {
12
+ constructor({ call_type, item_id, limit, offset }) {
13
+ super({
14
+ call_type,
15
+ item_id,
16
+ limit,
17
+ offset,
18
+ });
19
+ }
20
+ }
21
+ export class ItemsRelatedRec extends Rec {
22
+ constructor({ call_type, item_ids, limit, offset }) {
23
+ super({
24
+ call_type,
25
+ item_ids,
26
+ limit,
27
+ offset,
28
+ });
29
+ }
30
+ }
31
+ export class CategoryRec extends Rec {
32
+ constructor({ call_type, category_id, limit, offset }) {
33
+ super({
34
+ call_type,
35
+ category_id,
36
+ limit,
37
+ offset,
38
+ });
39
+ }
40
+ }
41
+ //# sourceMappingURL=ItemRec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemRec.js","sourceRoot":"/","sources":["src/recs/ItemRec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAQ5B,MAAM,OAAO,OAAQ,SAAQ,GAAG;IAC9B,YAAY,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAY;QAChD,KAAK,CAAC;YACJ,SAAS;YACT,KAAK;YACL,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,GAAG;IACrC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAmB;QAChE,KAAK,CAAC;YACJ,SAAS;YACT,OAAO;YACP,KAAK;YACL,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,GAAG;IACtC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAoB;QAClE,KAAK,CAAC;YACJ,SAAS;YACT,QAAQ;YACR,KAAK;YACL,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,GAAG;IAClC,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAgB;QACjE,KAAK,CAAC;YACJ,SAAS;YACT,WAAW;YACX,KAAK;YACL,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { Rec } from \"./Rec\";\nimport type {\n ICategoryRec,\n IItemRelatedRec,\n IItemsRelatedRec,\n IUserRec,\n} from \"./types\";\n\nexport class UserRec extends Rec {\n constructor({ call_type, limit, offset }: IUserRec) {\n super({\n call_type,\n limit,\n offset,\n });\n }\n}\n\nexport class ItemRelatedRec extends Rec {\n constructor({ call_type, item_id, limit, offset }: IItemRelatedRec) {\n super({\n call_type,\n item_id,\n limit,\n offset,\n });\n }\n}\n\nexport class ItemsRelatedRec extends Rec {\n constructor({ call_type, item_ids, limit, offset }: IItemsRelatedRec) {\n super({\n call_type,\n item_ids,\n limit,\n offset,\n });\n }\n}\n\nexport class CategoryRec extends Rec {\n constructor({ call_type, category_id, limit, offset }: ICategoryRec) {\n super({\n call_type,\n category_id,\n limit,\n offset,\n });\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import type { RecRequest } from "./types";
2
+ export declare abstract class Rec {
3
+ readonly request: RecRequest;
4
+ constructor(data: RecRequest);
5
+ }
@@ -1,4 +1,4 @@
1
- export class Recommendation {
1
+ export class Rec {
2
2
  request;
3
3
  constructor(data) {
4
4
  this.request = {
@@ -6,4 +6,4 @@ export class Recommendation {
6
6
  };
7
7
  }
8
8
  }
9
- //# sourceMappingURL=Recommendation.js.map
9
+ //# sourceMappingURL=Rec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rec.js","sourceRoot":"/","sources":["src/recs/Rec.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,GAAG;IACP,OAAO,CAAa;IAEpC,YAAY,IAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { RecRequest } from \"./types\";\n\nexport abstract class Rec {\n public readonly request: RecRequest;\n\n constructor(data: RecRequest) {\n this.request = {\n ...data,\n };\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from "./ItemRec";
@@ -0,0 +1,2 @@
1
+ export * from "./ItemRec";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["src/recs/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC","sourcesContent":["export * from \"./ItemRec\";\n"]}
@@ -0,0 +1,27 @@
1
+ interface CategoryId {
2
+ depth: "1" | "2" | "3";
3
+ value: string;
4
+ }
5
+ export interface RecRequest {
6
+ call_type: string;
7
+ limit: number;
8
+ offset?: number;
9
+ item_id?: string;
10
+ item_ids?: string[];
11
+ category_id?: CategoryId;
12
+ }
13
+ type BaseRec = Omit<RecRequest, "call_type" | "item_id" | "item_ids" | "category_id">;
14
+ export interface BaseItemRec extends BaseRec {
15
+ call_type: string;
16
+ }
17
+ export type IUserRec = BaseItemRec;
18
+ export interface IItemRelatedRec extends BaseItemRec {
19
+ item_id: string;
20
+ }
21
+ export interface IItemsRelatedRec extends BaseItemRec {
22
+ item_ids: string[];
23
+ }
24
+ export interface ICategoryRec extends BaseItemRec {
25
+ category_id: CategoryId;
26
+ }
27
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["src/recs/types.ts"],"names":[],"mappings":"","sourcesContent":["interface CategoryId {\n depth: \"1\" | \"2\" | \"3\";\n value: string;\n}\n\nexport interface RecRequest {\n call_type: string;\n limit: number;\n offset?: number;\n item_id?: string;\n item_ids?: string[];\n category_id?: CategoryId;\n}\n\ntype BaseRec = Omit<\n RecRequest,\n \"call_type\" | \"item_id\" | \"item_ids\" | \"category_id\"\n>;\n\nexport interface BaseItemRec extends BaseRec {\n call_type: string;\n}\n\nexport type IUserRec = BaseItemRec;\n\nexport interface IItemRelatedRec extends BaseItemRec {\n item_id: string;\n}\n\nexport interface IItemsRelatedRec extends BaseItemRec {\n item_ids: string[];\n}\n\nexport interface ICategoryRec extends BaseItemRec {\n category_id: CategoryId;\n}\n"]}
@@ -17,3 +17,68 @@ export declare enum CustomPropertyDataType {
17
17
  }
18
18
  export declare const stringToObjectIdsSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>, ObjectId[], string>;
19
19
  export declare const stringToArraySchema: z.ZodEffects<z.ZodEffects<z.ZodString, string[], string>, string[], string>;
20
+ export declare const inferencePipelineRequestSchema: z.ZodObject<{
21
+ application_id: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, ObjectId, string>;
22
+ blux_user_id: z.ZodDefault<z.ZodNullable<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, ObjectId, string>>>;
23
+ pipeline: z.ZodArray<z.ZodObject<{
24
+ name: z.ZodString;
25
+ kwargs: z.ZodRecord<z.ZodString, z.ZodAny>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ name: string;
28
+ kwargs: Record<string, any>;
29
+ }, {
30
+ name: string;
31
+ kwargs: Record<string, any>;
32
+ }>, "many">;
33
+ item_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
34
+ item_ids: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
35
+ category_id: z.ZodDefault<z.ZodNullable<z.ZodObject<{
36
+ depth: z.ZodEnum<["1", "2", "3"]>;
37
+ value: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ value: string;
40
+ depth: "1" | "2" | "3";
41
+ }, {
42
+ value: string;
43
+ depth: "1" | "2" | "3";
44
+ }>>>;
45
+ limit: z.ZodNumber;
46
+ offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
47
+ }, "strip", z.ZodTypeAny, {
48
+ item_id: string | null;
49
+ application_id: ObjectId;
50
+ blux_user_id: ObjectId | null;
51
+ pipeline: {
52
+ name: string;
53
+ kwargs: Record<string, any>;
54
+ }[];
55
+ item_ids: string[] | null;
56
+ category_id: {
57
+ value: string;
58
+ depth: "1" | "2" | "3";
59
+ } | null;
60
+ limit: number;
61
+ offset: number;
62
+ }, {
63
+ application_id: string;
64
+ pipeline: {
65
+ name: string;
66
+ kwargs: Record<string, any>;
67
+ }[];
68
+ limit: number;
69
+ item_id?: string | null | undefined;
70
+ blux_user_id?: string | null | undefined;
71
+ item_ids?: string[] | null | undefined;
72
+ category_id?: {
73
+ value: string;
74
+ depth: "1" | "2" | "3";
75
+ } | null | undefined;
76
+ offset?: number | undefined;
77
+ }>;
78
+ export type InferencePipelineResponse = {
79
+ item_ids: string[];
80
+ count: number;
81
+ metadata: Record<string, unknown>;
82
+ timestamp: number;
83
+ recommendation_id: string | null;
84
+ };
@@ -102,4 +102,23 @@ export const stringToArraySchema = z
102
102
  .refine((arr) => arr.every((item) => item.length > 0), {
103
103
  message: "Each item should not be empty",
104
104
  });
105
+ export const inferencePipelineRequestSchema = z.object({
106
+ application_id: objectIdSchema,
107
+ blux_user_id: objectIdSchema.nullable().default(null),
108
+ pipeline: z.array(z.object({
109
+ name: z.string(),
110
+ kwargs: z.record(z.any()),
111
+ })),
112
+ item_id: z.string().nullable().default(null),
113
+ item_ids: z.array(z.string()).nullable().default(null),
114
+ category_id: z
115
+ .object({
116
+ depth: z.enum(["1", "2", "3"]),
117
+ value: z.string(),
118
+ })
119
+ .nullable()
120
+ .default(null),
121
+ limit: z.number(),
122
+ offset: z.number().optional().default(0),
123
+ });
105
124
  //# sourceMappingURL=zodSchemas.js.map
@@ -1 +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,CAAC;AAC3D,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,EAAE;KACR,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAC1B,CAAC,CAAC,EAAE,EAAE,CACJ,IAAI,QAAQ,CAAC;IACX;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,qBAAqB,CAAC,EAAE;QACjC,IAAI,EAAE,CAAC,WAAW,CAAC;KACpB;CACF,CAAC,CACL;KACA,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC;KAClC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;KAC/B,MAAM,CACL,CAAC,CAAC,EAAE,EAAE;IACJ,IAAI,OAAO,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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 isObjectIdString(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) => isObjectIdString(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 (isObjectIdString(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"]}
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,CAAC;AAC3D,OAAO,QAAQ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C5C,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACtD,WAAW,EAAE,CAAC;SACX,MAAM,CAAC;QACN,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;SACD,QAAQ,EAAE;SACV,OAAO,CAAC,IAAI,CAAC;IAEhB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;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 isObjectIdString(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) => isObjectIdString(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 (isObjectIdString(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\nexport const inferencePipelineRequestSchema = z.object({\n application_id: objectIdSchema,\n blux_user_id: objectIdSchema.nullable().default(null),\n\n pipeline: z.array(\n z.object({\n name: z.string(),\n kwargs: z.record(z.any()),\n }),\n ),\n item_id: z.string().nullable().default(null),\n item_ids: z.array(z.string()).nullable().default(null),\n category_id: z\n .object({\n depth: z.enum([\"1\", \"2\", \"3\"]),\n value: z.string(),\n })\n .nullable()\n .default(null),\n\n limit: z.number(),\n offset: z.number().optional().default(0),\n});\n\nexport type InferencePipelineResponse = {\n item_ids: string[];\n count: number;\n metadata: Record<string, unknown>;\n timestamp: number;\n recommendation_id: string | null;\n};\n"]}