@ninetailed/experience.js-utils 7.20.5 → 7.21.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.
- package/index.cjs.js +26 -26
- package/index.esm.js +26 -26
- package/package.json +3 -3
- package/src/index.d.ts +11 -11
- package/src/lib/ExperienceMapper.d.ts +9 -9
- package/src/types/Audience.d.ts +16 -16
- package/src/types/Config.d.ts +346 -346
- package/src/types/Experience.d.ts +2138 -2138
- package/src/types/Experiment.d.ts +1939 -1939
- package/src/types/Variant.d.ts +10 -10
- package/src/types/zodArrayIgnoreUnknown.d.ts +14 -14
package/index.cjs.js
CHANGED
|
@@ -67,17 +67,17 @@ const Variant = zod.z.object({
|
|
|
67
67
|
id: zod.z.string()
|
|
68
68
|
}).catchall(zod.z.unknown());
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
* Zod helper for parsing arrays and ignore items not specified in the schema
|
|
72
|
-
*
|
|
73
|
-
* @param zodUnion - union of known types
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* const binaryArraySchema = arrayIgnoreUnknown(z.union([z.literal('0'), z.literal('1')]))
|
|
77
|
-
* type BinaryArray = z.TypeOf<typeof binaryArraySchema>
|
|
78
|
-
*
|
|
79
|
-
* const binaryArray: BinaryArray = binaryArraySchema.parse(['0', '1', '2', '0'])
|
|
80
|
-
* console.log(binaryArray) // ['0', '1', '0']
|
|
70
|
+
/**
|
|
71
|
+
* Zod helper for parsing arrays and ignore items not specified in the schema
|
|
72
|
+
*
|
|
73
|
+
* @param zodUnion - union of known types
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const binaryArraySchema = arrayIgnoreUnknown(z.union([z.literal('0'), z.literal('1')]))
|
|
77
|
+
* type BinaryArray = z.TypeOf<typeof binaryArraySchema>
|
|
78
|
+
*
|
|
79
|
+
* const binaryArray: BinaryArray = binaryArraySchema.parse(['0', '1', '2', '0'])
|
|
80
|
+
* console.log(binaryArray) // ['0', '1', '0']
|
|
81
81
|
*/
|
|
82
82
|
function zodArrayIgnoreUnknown(zodType) {
|
|
83
83
|
const isKnownItem = item => zodType.safeParse(item).success;
|
|
@@ -94,33 +94,33 @@ function isArray(item) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const ExperienceSchema = zod.z.object({
|
|
97
|
-
/**
|
|
98
|
-
* The experience's ID from the Experience API's standpoint.
|
|
99
|
-
* It maps to the `nt_experience_id` field on the Ninetailed Experience entry in Contentful.
|
|
97
|
+
/**
|
|
98
|
+
* The experience's ID from the Experience API's standpoint.
|
|
99
|
+
* It maps to the `nt_experience_id` field on the Ninetailed Experience entry in Contentful.
|
|
100
100
|
*/
|
|
101
101
|
id: zod.z.string(),
|
|
102
|
-
/**
|
|
103
|
-
* The name of the experience (Short Text)
|
|
102
|
+
/**
|
|
103
|
+
* The name of the experience (Short Text)
|
|
104
104
|
*/
|
|
105
105
|
name: zod.z.string(),
|
|
106
|
-
/**
|
|
107
|
-
* The description of the experience (Short Text)
|
|
106
|
+
/**
|
|
107
|
+
* The description of the experience (Short Text)
|
|
108
108
|
*/
|
|
109
109
|
description: zod.z.string().optional(),
|
|
110
|
-
/**
|
|
111
|
-
* The type if the experience (nt_experiment | nt_personalization)
|
|
110
|
+
/**
|
|
111
|
+
* The type if the experience (nt_experiment | nt_personalization)
|
|
112
112
|
*/
|
|
113
113
|
type: zod.z.union([zod.z.string().regex(/^nt_experiment$/g), zod.z.string().regex(/^nt_personalization$/g)]),
|
|
114
|
-
/**
|
|
115
|
-
* The config of the experience (JSON)
|
|
114
|
+
/**
|
|
115
|
+
* The config of the experience (JSON)
|
|
116
116
|
*/
|
|
117
117
|
config: Config.default({}),
|
|
118
|
-
/**
|
|
119
|
-
* The audience of the experience (Audience)
|
|
118
|
+
/**
|
|
119
|
+
* The audience of the experience (Audience)
|
|
120
120
|
*/
|
|
121
121
|
audience: Audience.optional().nullable(),
|
|
122
|
-
/**
|
|
123
|
-
* All used variants of the experience (References to other Content Types)
|
|
122
|
+
/**
|
|
123
|
+
* All used variants of the experience (References to other Content Types)
|
|
124
124
|
*/
|
|
125
125
|
variants: zodArrayIgnoreUnknown(Variant).default([])
|
|
126
126
|
});
|
package/index.esm.js
CHANGED
|
@@ -65,17 +65,17 @@ const Variant = z.object({
|
|
|
65
65
|
id: z.string()
|
|
66
66
|
}).catchall(z.unknown());
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Zod helper for parsing arrays and ignore items not specified in the schema
|
|
70
|
-
*
|
|
71
|
-
* @param zodUnion - union of known types
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* const binaryArraySchema = arrayIgnoreUnknown(z.union([z.literal('0'), z.literal('1')]))
|
|
75
|
-
* type BinaryArray = z.TypeOf<typeof binaryArraySchema>
|
|
76
|
-
*
|
|
77
|
-
* const binaryArray: BinaryArray = binaryArraySchema.parse(['0', '1', '2', '0'])
|
|
78
|
-
* console.log(binaryArray) // ['0', '1', '0']
|
|
68
|
+
/**
|
|
69
|
+
* Zod helper for parsing arrays and ignore items not specified in the schema
|
|
70
|
+
*
|
|
71
|
+
* @param zodUnion - union of known types
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const binaryArraySchema = arrayIgnoreUnknown(z.union([z.literal('0'), z.literal('1')]))
|
|
75
|
+
* type BinaryArray = z.TypeOf<typeof binaryArraySchema>
|
|
76
|
+
*
|
|
77
|
+
* const binaryArray: BinaryArray = binaryArraySchema.parse(['0', '1', '2', '0'])
|
|
78
|
+
* console.log(binaryArray) // ['0', '1', '0']
|
|
79
79
|
*/
|
|
80
80
|
function zodArrayIgnoreUnknown(zodType) {
|
|
81
81
|
const isKnownItem = item => zodType.safeParse(item).success;
|
|
@@ -92,33 +92,33 @@ function isArray(item) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
const ExperienceSchema = z.object({
|
|
95
|
-
/**
|
|
96
|
-
* The experience's ID from the Experience API's standpoint.
|
|
97
|
-
* It maps to the `nt_experience_id` field on the Ninetailed Experience entry in Contentful.
|
|
95
|
+
/**
|
|
96
|
+
* The experience's ID from the Experience API's standpoint.
|
|
97
|
+
* It maps to the `nt_experience_id` field on the Ninetailed Experience entry in Contentful.
|
|
98
98
|
*/
|
|
99
99
|
id: z.string(),
|
|
100
|
-
/**
|
|
101
|
-
* The name of the experience (Short Text)
|
|
100
|
+
/**
|
|
101
|
+
* The name of the experience (Short Text)
|
|
102
102
|
*/
|
|
103
103
|
name: z.string(),
|
|
104
|
-
/**
|
|
105
|
-
* The description of the experience (Short Text)
|
|
104
|
+
/**
|
|
105
|
+
* The description of the experience (Short Text)
|
|
106
106
|
*/
|
|
107
107
|
description: z.string().optional(),
|
|
108
|
-
/**
|
|
109
|
-
* The type if the experience (nt_experiment | nt_personalization)
|
|
108
|
+
/**
|
|
109
|
+
* The type if the experience (nt_experiment | nt_personalization)
|
|
110
110
|
*/
|
|
111
111
|
type: z.union([z.string().regex(/^nt_experiment$/g), z.string().regex(/^nt_personalization$/g)]),
|
|
112
|
-
/**
|
|
113
|
-
* The config of the experience (JSON)
|
|
112
|
+
/**
|
|
113
|
+
* The config of the experience (JSON)
|
|
114
114
|
*/
|
|
115
115
|
config: Config.default({}),
|
|
116
|
-
/**
|
|
117
|
-
* The audience of the experience (Audience)
|
|
116
|
+
/**
|
|
117
|
+
* The audience of the experience (Audience)
|
|
118
118
|
*/
|
|
119
119
|
audience: Audience.optional().nullable(),
|
|
120
|
-
/**
|
|
121
|
-
* All used variants of the experience (References to other Content Types)
|
|
120
|
+
/**
|
|
121
|
+
* All used variants of the experience (References to other Content Types)
|
|
122
122
|
*/
|
|
123
123
|
variants: zodArrayIgnoreUnknown(Variant).default([])
|
|
124
124
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-utils",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.21.0",
|
|
4
4
|
"description": "Ninetailed Experience.js Utils",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"sideEffects": false,
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ninetailed/experience.js": "7.
|
|
26
|
-
"@ninetailed/experience.js-shared": "7.
|
|
25
|
+
"@ninetailed/experience.js": "7.21.0",
|
|
26
|
+
"@ninetailed/experience.js-shared": "7.21.0",
|
|
27
27
|
"zod": "3.23.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { ExperienceMapper } from './lib/ExperienceMapper';
|
|
2
|
-
export { Audience } from './types/Audience';
|
|
3
|
-
export { Config } from './types/Config';
|
|
4
|
-
export { Experience } from './types/Experience';
|
|
5
|
-
export { Experiment } from './types/Experiment';
|
|
6
|
-
export { Variant } from './types/Variant';
|
|
7
|
-
export type { AudienceLike } from './types/Audience';
|
|
8
|
-
export type { ConfigLike } from './types/Config';
|
|
9
|
-
export type { ExperienceLike } from './types/Experience';
|
|
10
|
-
export type { ExperimentLike } from './types/Experiment';
|
|
11
|
-
export type { VariantLike } from './types/Variant';
|
|
1
|
+
export { ExperienceMapper } from './lib/ExperienceMapper';
|
|
2
|
+
export { Audience } from './types/Audience';
|
|
3
|
+
export { Config } from './types/Config';
|
|
4
|
+
export { Experience } from './types/Experience';
|
|
5
|
+
export { Experiment } from './types/Experiment';
|
|
6
|
+
export { Variant } from './types/Variant';
|
|
7
|
+
export type { AudienceLike } from './types/Audience';
|
|
8
|
+
export type { ConfigLike } from './types/Config';
|
|
9
|
+
export type { ExperienceLike } from './types/Experience';
|
|
10
|
+
export type { ExperimentLike } from './types/Experiment';
|
|
11
|
+
export type { VariantLike } from './types/Variant';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
|
|
2
|
-
import { Experience, ExperienceLike } from '../types/Experience';
|
|
3
|
-
import { ExperimentLike } from '../types/Experiment';
|
|
4
|
-
export declare class ExperienceMapper {
|
|
5
|
-
static isExperienceEntry<Variant extends Reference>(experience: ExperienceLike<Variant>): experience is Experience<Variant>;
|
|
6
|
-
static mapExperience<Variant extends Reference>(experience: ExperienceLike<Variant>): ExperienceConfiguration<Variant>;
|
|
7
|
-
static isExperimentEntry<Variant extends Reference>(experiment: ExperimentLike<Variant>): experiment is ExperimentLike<Variant>;
|
|
8
|
-
static mapExperiment<Variant extends Reference>(experiment: ExperimentLike<Variant>): ExperienceConfiguration<Variant>;
|
|
9
|
-
}
|
|
1
|
+
import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js-shared';
|
|
2
|
+
import { Experience, ExperienceLike } from '../types/Experience';
|
|
3
|
+
import { ExperimentLike } from '../types/Experiment';
|
|
4
|
+
export declare class ExperienceMapper {
|
|
5
|
+
static isExperienceEntry<Variant extends Reference>(experience: ExperienceLike<Variant>): experience is Experience<Variant>;
|
|
6
|
+
static mapExperience<Variant extends Reference>(experience: ExperienceLike<Variant>): ExperienceConfiguration<Variant>;
|
|
7
|
+
static isExperimentEntry<Variant extends Reference>(experiment: ExperimentLike<Variant>): experiment is ExperimentLike<Variant>;
|
|
8
|
+
static mapExperiment<Variant extends Reference>(experiment: ExperimentLike<Variant>): ExperienceConfiguration<Variant>;
|
|
9
|
+
}
|
package/src/types/Audience.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const Audience: z.ZodObject<{
|
|
3
|
-
id: z.ZodString;
|
|
4
|
-
name: z.ZodOptional<z.ZodString>;
|
|
5
|
-
description: z.ZodOptional<z.ZodString>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
id: string;
|
|
8
|
-
name?: string | undefined;
|
|
9
|
-
description?: string | undefined;
|
|
10
|
-
}, {
|
|
11
|
-
id: string;
|
|
12
|
-
name?: string | undefined;
|
|
13
|
-
description?: string | undefined;
|
|
14
|
-
}>;
|
|
15
|
-
export type AudienceLike = z.input<typeof Audience>;
|
|
16
|
-
export type Audience = z.infer<typeof Audience>;
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Audience: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
description: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
id: string;
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
description?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export type AudienceLike = z.input<typeof Audience>;
|
|
16
|
+
export type Audience = z.infer<typeof Audience>;
|