@chordcommerce/analytics 1.5.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/LICENSE.md +21 -0
- package/README.md +86 -0
- package/dist/client/index.d.ts +84 -0
- package/dist/client/index.js +412 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/client.d.ts +86 -0
- package/dist/types/client.js +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +4 -0
- package/dist/types/input.d.ts +223 -0
- package/dist/types/input.js +1 -0
- package/dist/types/objects.d.ts +379 -0
- package/dist/types/objects.js +1 -0
- package/dist/types/typewriter.d.ts +6502 -0
- package/dist/types/typewriter.js +4 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +21 -0
- package/dist/validators/custom.d.ts +43 -0
- package/dist/validators/custom.js +15 -0
- package/dist/validators/index.d.ts +4 -0
- package/dist/validators/index.js +4 -0
- package/dist/validators/objects.d.ts +693 -0
- package/dist/validators/objects.js +122 -0
- package/dist/validators/tracking-plan-map.d.ts +6386 -0
- package/dist/validators/tracking-plan-map.js +69 -0
- package/dist/validators/tracking-plan.d.ts +8942 -0
- package/dist/validators/tracking-plan.js +1628 -0
- package/package.json +38 -0
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const pruneNullValues = (props) => {
|
|
2
|
+
if (typeof props !== 'object' || props === null)
|
|
3
|
+
return props;
|
|
4
|
+
if (!Array.isArray(props)) {
|
|
5
|
+
for (const key in props) {
|
|
6
|
+
if (props.hasOwnProperty(key)) {
|
|
7
|
+
props[key] = pruneNullValues(props[key]);
|
|
8
|
+
if (props[key] === null)
|
|
9
|
+
delete props[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
for (let i = 0; i < props.length; i++) {
|
|
15
|
+
props[i] = pruneNullValues(props[i]);
|
|
16
|
+
if (props[i] === null)
|
|
17
|
+
props.splice(i--, 1);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return props;
|
|
21
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const productInProductsSchema: z.ZodEffects<z.ZodObject<{
|
|
3
|
+
product_id: z.ZodString;
|
|
4
|
+
sku: z.ZodString;
|
|
5
|
+
products: z.ZodArray<z.ZodObject<{
|
|
6
|
+
product_id: z.ZodString;
|
|
7
|
+
sku: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
product_id?: string;
|
|
10
|
+
sku?: string;
|
|
11
|
+
}, {
|
|
12
|
+
product_id?: string;
|
|
13
|
+
sku?: string;
|
|
14
|
+
}>, "many">;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
product_id?: string;
|
|
17
|
+
sku?: string;
|
|
18
|
+
products?: {
|
|
19
|
+
product_id?: string;
|
|
20
|
+
sku?: string;
|
|
21
|
+
}[];
|
|
22
|
+
}, {
|
|
23
|
+
product_id?: string;
|
|
24
|
+
sku?: string;
|
|
25
|
+
products?: {
|
|
26
|
+
product_id?: string;
|
|
27
|
+
sku?: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>, {
|
|
30
|
+
product_id?: string;
|
|
31
|
+
sku?: string;
|
|
32
|
+
products?: {
|
|
33
|
+
product_id?: string;
|
|
34
|
+
sku?: string;
|
|
35
|
+
}[];
|
|
36
|
+
}, {
|
|
37
|
+
product_id?: string;
|
|
38
|
+
sku?: string;
|
|
39
|
+
products?: {
|
|
40
|
+
product_id?: string;
|
|
41
|
+
sku?: string;
|
|
42
|
+
}[];
|
|
43
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const productInProductsSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
product_id: z.string(),
|
|
5
|
+
sku: z.string(),
|
|
6
|
+
products: z.array(z.object({ product_id: z.string(), sku: z.string() })),
|
|
7
|
+
})
|
|
8
|
+
.refine((event) => {
|
|
9
|
+
const productInCart = event.products.find((p) => {
|
|
10
|
+
return p.product_id === event.product_id && p.sku === event.sku;
|
|
11
|
+
});
|
|
12
|
+
return !!productInCart;
|
|
13
|
+
}, {
|
|
14
|
+
message: '`products` array must contain the product_id and sku provided',
|
|
15
|
+
});
|