@blux.ai/web-sdk 1.1.7 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +1 -1
- package/dist/src/BluxClient.d.ts +5 -2
- package/dist/src/BluxClient.js +110 -37
- package/dist/src/BluxClient.js.map +1 -1
- package/dist/src/apis/APIs.d.ts +240 -65
- package/dist/src/apis/APIs.js +14 -19
- package/dist/src/apis/APIs.js.map +1 -1
- package/dist/src/apis/getItemRecommendations.d.ts +4 -0
- package/dist/src/apis/getItemRecommendations.js +7 -0
- package/dist/src/apis/getItemRecommendations.js.map +1 -0
- package/dist/src/events/AddCartaddEvent.d.ts +1 -1
- package/dist/src/events/AddCartaddEvent.js +2 -1
- package/dist/src/events/AddCartaddEvent.js.map +1 -1
- package/dist/src/events/AddInstantImpressionEvent.d.ts +1 -1
- package/dist/src/events/AddInstantImpressionEvent.js +2 -1
- package/dist/src/events/AddInstantImpressionEvent.js.map +1 -1
- package/dist/src/events/AddPageViewEvent.d.ts +1 -1
- package/dist/src/events/AddPageViewEvent.js +2 -2
- package/dist/src/events/AddPageViewEvent.js.map +1 -1
- package/dist/src/events/AddPersistentImpressionEvent.d.ts +1 -1
- package/dist/src/events/AddPersistentImpressionEvent.js +2 -1
- package/dist/src/events/AddPersistentImpressionEvent.js.map +1 -1
- package/dist/src/events/AddProductDetailViewEvent.d.ts +1 -1
- package/dist/src/events/AddProductDetailViewEvent.js +2 -1
- package/dist/src/events/AddProductDetailViewEvent.js.map +1 -1
- package/dist/src/events/AddSectionViewEvent.d.ts +1 -1
- package/dist/src/events/AddSectionViewEvent.js +2 -1
- package/dist/src/events/AddSectionViewEvent.js.map +1 -1
- package/dist/src/events/types.d.ts +12 -0
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/recs/ItemRec.d.ts +14 -0
- package/dist/src/recs/ItemRec.js +42 -0
- package/dist/src/recs/ItemRec.js.map +1 -0
- package/dist/src/recs/Rec.d.ts +5 -0
- package/dist/src/{recommendations/Recommendation.js → recs/Rec.js} +2 -2
- package/dist/src/recs/Rec.js.map +1 -0
- package/dist/src/recs/index.d.ts +1 -0
- package/dist/src/recs/index.js +2 -0
- package/dist/src/recs/index.js.map +1 -0
- package/dist/src/recs/types.d.ts +23 -0
- package/dist/src/recs/types.js.map +1 -0
- package/dist/src/utils/zodSchemas.d.ts +124 -11
- package/dist/src/utils/zodSchemas.js +64 -22
- package/dist/src/utils/zodSchemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/apis/getItemRecommendation.d.ts +0 -4
- package/dist/src/apis/getItemRecommendation.js +0 -7
- package/dist/src/apis/getItemRecommendation.js.map +0 -1
- package/dist/src/recommendations/ItemRecommendation.d.ts +0 -5
- package/dist/src/recommendations/ItemRecommendation.js +0 -13
- package/dist/src/recommendations/ItemRecommendation.js.map +0 -1
- package/dist/src/recommendations/Recommendation.d.ts +0 -5
- package/dist/src/recommendations/Recommendation.js.map +0 -1
- package/dist/src/recommendations/index.d.ts +0 -1
- package/dist/src/recommendations/index.js +0 -2
- package/dist/src/recommendations/index.js.map +0 -1
- package/dist/src/recommendations/types.d.ts +0 -12
- package/dist/src/recommendations/types.js.map +0 -1
- /package/dist/src/{recommendations → recs}/types.js +0 -0
|
@@ -58,20 +58,23 @@ export const anonymousObjectSchema = () => z
|
|
|
58
58
|
.object({})
|
|
59
59
|
.passthrough()
|
|
60
60
|
.transform((v) => convertAllObjectId(v));
|
|
61
|
-
export const countryCodeWithLowerCaseSchema = z
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
export const countryCodeWithLowerCaseSchema = z
|
|
62
|
+
.string()
|
|
63
|
+
.transform((v) => v.toUpperCase())
|
|
64
|
+
.pipe(z.union([
|
|
65
|
+
z.literal("419"),
|
|
66
|
+
z.enum(COUNTRY_CODES),
|
|
67
|
+
]))
|
|
68
|
+
.transform((v) => (v === "419" ? undefined : v));
|
|
68
69
|
export const customPropertiesRequestSchema = z.record(z.union([
|
|
69
70
|
dateSchema,
|
|
70
71
|
z.string(),
|
|
71
72
|
z.number(),
|
|
72
73
|
z.boolean(),
|
|
73
74
|
z.array(z.string()),
|
|
75
|
+
z.array(z.object({})),
|
|
74
76
|
z.null(),
|
|
77
|
+
z.undefined(),
|
|
75
78
|
]));
|
|
76
79
|
export const customPropertiesSchema = z.record(z.union([
|
|
77
80
|
dateSchema,
|
|
@@ -79,27 +82,66 @@ export const customPropertiesSchema = z.record(z.union([
|
|
|
79
82
|
z.number(),
|
|
80
83
|
z.boolean(),
|
|
81
84
|
z.array(z.string()),
|
|
85
|
+
z.array(z.object({})),
|
|
86
|
+
z.undefined(),
|
|
82
87
|
]));
|
|
83
88
|
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
89
|
export const stringToArraySchema = z
|
|
100
90
|
.string()
|
|
101
91
|
.transform((v) => v.split(",").map((item) => item.trim()))
|
|
102
92
|
.refine((arr) => arr.every((item) => item.length > 0), {
|
|
103
93
|
message: "Each item should not be empty",
|
|
104
94
|
});
|
|
95
|
+
export const eventPropertiesSchema = z.object({
|
|
96
|
+
section: z.string().optional(),
|
|
97
|
+
prev_section: z.string().optional(),
|
|
98
|
+
recommendation_id: z.string().optional(),
|
|
99
|
+
price: z.number().optional(),
|
|
100
|
+
order_id: z.string().optional(),
|
|
101
|
+
rating: z.number().optional(),
|
|
102
|
+
prev_page: z.string().optional(),
|
|
103
|
+
page: z.string().optional(),
|
|
104
|
+
position: z.number().optional(),
|
|
105
|
+
item_id: z.string().optional(),
|
|
106
|
+
items: z
|
|
107
|
+
.array(z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
price: z.number(),
|
|
110
|
+
}))
|
|
111
|
+
.optional(),
|
|
112
|
+
search_query: z.string().optional(),
|
|
113
|
+
order_amount: z.number().optional(),
|
|
114
|
+
paid_amount: z.number().optional(),
|
|
115
|
+
trackings: z
|
|
116
|
+
.array(z.object({
|
|
117
|
+
id: z.string(),
|
|
118
|
+
type: z.string(),
|
|
119
|
+
}))
|
|
120
|
+
.optional(),
|
|
121
|
+
});
|
|
122
|
+
// Schema for Inference API
|
|
123
|
+
const inferenceRequestSchema = z.object({
|
|
124
|
+
application_id: objectIdSchema,
|
|
125
|
+
blux_user_id: objectIdSchema.nullish(),
|
|
126
|
+
pipeline: z.array(z.object({
|
|
127
|
+
name: z.string(),
|
|
128
|
+
kwargs: z.record(z.any()),
|
|
129
|
+
})),
|
|
130
|
+
item_id: z.string().nullish(),
|
|
131
|
+
item_ids: z.array(z.string()).nullish(),
|
|
132
|
+
limit: z.number(),
|
|
133
|
+
offset: z.number().nullish().default(0),
|
|
134
|
+
options: z.record(z.string(), z.any()).nullish(), // todo: legacy 클라이언트 migration만을 위한 필드라는 점을 고려하여 필드명 수정 필요 ex. legacy_options
|
|
135
|
+
});
|
|
136
|
+
export const recommendationRequestSchema = inferenceRequestSchema
|
|
137
|
+
.pick({
|
|
138
|
+
item_id: true,
|
|
139
|
+
item_ids: true,
|
|
140
|
+
limit: true,
|
|
141
|
+
offset: true,
|
|
142
|
+
})
|
|
143
|
+
.extend({
|
|
144
|
+
call_type: z.string(),
|
|
145
|
+
category_id: z.string().nullish(),
|
|
146
|
+
});
|
|
105
147
|
//# 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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,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 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,MA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AE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,8EAA8E;CACjI,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,sBAAsB;KAC9D,IAAI,CAAC;IACJ,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;CACb,CAAC;KACD,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;CAClC,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\n .string()\n .transform((v) => v.toUpperCase())\n .pipe(\n z.union([\n z.literal(\"419\"), // https://en.wikipedia.org/wiki/Language_code\n z.enum(COUNTRY_CODES as [CountryCode, ...CountryCode[]]),\n ]),\n )\n .transform((v) => (v === \"419\" ? undefined : v));\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.array(z.object({})),\n z.null(),\n z.undefined(),\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 z.array(z.object({})),\n z.undefined(),\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 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 eventPropertiesSchema = z.object({\n section: z.string().optional(),\n prev_section: z.string().optional(),\n recommendation_id: z.string().optional(),\n price: z.number().optional(),\n order_id: z.string().optional(),\n rating: z.number().optional(),\n prev_page: z.string().optional(),\n page: z.string().optional(),\n position: z.number().optional(),\n item_id: z.string().optional(),\n items: z\n .array(\n z.object({\n id: z.string(),\n price: z.number(),\n }),\n )\n .optional(),\n search_query: z.string().optional(),\n order_amount: z.number().optional(),\n paid_amount: z.number().optional(),\n trackings: z\n .array(\n z.object({\n id: z.string(),\n type: z.string(),\n }),\n )\n .optional(),\n});\nexport type EventProperties = z.infer<typeof eventPropertiesSchema>;\n\n// Schema for Inference API\nconst inferenceRequestSchema = z.object({\n application_id: objectIdSchema,\n blux_user_id: objectIdSchema.nullish(),\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().nullish(),\n item_ids: z.array(z.string()).nullish(),\n\n limit: z.number(),\n offset: z.number().nullish().default(0),\n options: z.record(z.string(), z.any()).nullish(), // todo: legacy 클라이언트 migration만을 위한 필드라는 점을 고려하여 필드명 수정 필요 ex. legacy_options\n});\n\nexport const recommendationRequestSchema = inferenceRequestSchema\n .pick({\n item_id: true,\n item_ids: true,\n limit: true,\n offset: true,\n })\n .extend({\n call_type: z.string(),\n category_id: z.string().nullish(),\n });\n\nexport type RecResponse = {\n item_ids: string[];\n metadata: Record<string, unknown>;\n recommendation_id: string | null;\n};\n"]}
|