@ninetailed/experience.js-utils-contentful 2.2.8 → 3.0.1-beta.3

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.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './types';
2
2
  export { AudienceMapper, ExperienceMapper, isEntry, isAudienceEntry, isExperienceEntry, } from './lib';
3
+ export type { MapVariant } from './lib';
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { Config, ExperienceMapper as ExperienceMapper$1 } from '@ninetailed/experience.js-utils';
3
- import { logger } from '@ninetailed/experience.js';
3
+ import { logger } from '@ninetailed/experience.js-shared';
4
4
 
5
5
  const EntryLink = z.object({
6
6
  type: z.literal('Link'),
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('zod'), require('@ninetailed/experience.js-utils'), require('@ninetailed/experience.js')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'zod', '@ninetailed/experience.js-utils', '@ninetailed/experience.js'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.UtilsContentful = {}, global.zod, global.experience_jsUtils, global.experience_js));
5
- })(this, (function (exports, zod, experience_jsUtils, experience_js) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('zod'), require('@ninetailed/experience.js-utils'), require('@ninetailed/experience.js-shared')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'zod', '@ninetailed/experience.js-utils', '@ninetailed/experience.js-shared'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.UtilsContentful = {}, global.zod, global.experience_jsUtils, global.experience_jsShared));
5
+ })(this, (function (exports, zod, experience_jsUtils, experience_jsShared) { 'use strict';
6
6
 
7
7
  var EntryLink = zod.z.object({
8
8
  type: zod.z.literal('Link'),
@@ -159,7 +159,7 @@
159
159
  var parsedExperience = ExperienceEntry.safeParse(entry);
160
160
 
161
161
  if (!parsedExperience.success) {
162
- experience_js.logger.warn('[Ninetailed Contentful ExperienceMapper]', 'Error parsing experience', parsedExperience.error.format());
162
+ experience_jsShared.logger.warn('[Ninetailed Contentful ExperienceMapper]', 'Error parsing experience', parsedExperience.error.format());
163
163
  throw new Error("[Ninetailed Contentful ExperienceMapper] The Experience Input is not valid. Please filter data first with \"ExperienceMapper.isExperienceEntry\".\n".concat(JSON.stringify(parsedExperience.error.format(), null, 2)));
164
164
  }
165
165
 
@@ -2,12 +2,12 @@ import { ExperienceConfiguration } from '@ninetailed/experience.js';
2
2
  import { Variant } from '@ninetailed/experience.js-utils';
3
3
  import { ExperienceEntry, Entry, ExperimentEntry } from '../types';
4
4
  import { BaselineWithExperiencesEntry } from '../types/BaselineWithExperiencesEntry';
5
- declare type MapVariant<VariantType = Entry> = (variant: VariantType) => Variant;
6
- declare type MapExperienceOptions<VariantType = Entry> = {
7
- mapVariant?: MapVariant<VariantType>;
5
+ export declare type MapVariant<VariantType extends Entry = Entry> = (variant: VariantType) => Variant;
6
+ declare type MapExperienceOptions = {
7
+ mapVariant?: MapVariant;
8
8
  };
9
9
  export declare class ExperienceMapper {
10
- static isExperienceEntry(entry: Entry): entry is ExperienceEntry;
10
+ static isExperienceEntry(entry: unknown): entry is ExperienceEntry;
11
11
  static mapExperience(entry: ExperienceEntry, options?: MapExperienceOptions): ExperienceConfiguration;
12
12
  static isExperiment(entry: Entry): entry is ExperimentEntry;
13
13
  static mapExperiment(entry: ExperienceEntry): ExperienceConfiguration;
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export { AudienceMapper } from './AudienceMapper';
2
2
  export { ExperienceMapper } from './ExperienceMapper';
3
+ export type { MapVariant } from './ExperienceMapper';
3
4
  export { isEntry } from './isEntry';
4
5
  export { isAudienceEntry } from './isAudienceEntry';
5
6
  export { isExperienceEntry } from './isExperienceEntry';
@@ -78,6 +78,19 @@ export declare const isExperienceEntry: (entry?: {
78
78
  id: string;
79
79
  };
80
80
  fields: {
81
+ nt_config?: {
82
+ distribution: number[];
83
+ traffic: number;
84
+ components: {
85
+ baseline: {
86
+ id: string;
87
+ };
88
+ variants: {
89
+ id: string;
90
+ hidden: boolean;
91
+ }[];
92
+ }[];
93
+ } | null | undefined;
81
94
  nt_audience?: {
82
95
  metadata?: {
83
96
  tags: {
@@ -124,19 +137,6 @@ export declare const isExperienceEntry: (entry?: {
124
137
  } | null | undefined;
125
138
  nt_name: string;
126
139
  nt_type: "nt_experiment" | "nt_personalization";
127
- nt_config: {
128
- distribution: number[];
129
- traffic: number;
130
- components: {
131
- baseline: {
132
- id: string;
133
- };
134
- variants: {
135
- id: string;
136
- hidden: boolean;
137
- }[];
138
- }[];
139
- };
140
140
  nt_variants: {
141
141
  metadata?: {
142
142
  tags: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-utils-contentful",
3
- "version": "2.2.8",
3
+ "version": "3.0.1-beta.3",
4
4
  "peerDependencies": {
5
5
  "contentful": "^9.1.32"
6
6
  },
@@ -8,17 +8,16 @@
8
8
  "module": "./index.esm.js",
9
9
  "typings": "./index.d.ts",
10
10
  "dependencies": {
11
- "@ninetailed/experience.js-utils": "2.2.8",
12
- "@ninetailed/experience.js": "2.2.8",
13
- "analytics": "^0.8.0",
14
- "@ninetailed/experience.js-shared": "2.2.8",
15
- "uuid": "^8.3.2",
11
+ "@ninetailed/experience.js-utils": "3.0.1-beta.3",
12
+ "@ninetailed/experience.js": "3.0.1-beta.3",
13
+ "@ninetailed/experience.js-shared": "3.0.1-beta.3",
16
14
  "ts-toolbelt": "^9.6.0",
15
+ "diary": "^0.3.1",
16
+ "zod": "^3.18.0",
17
17
  "locale-enum": "^1.1.1",
18
18
  "i18n-iso-countries": "^7.3.0",
19
+ "analytics": "^0.8.0",
19
20
  "lodash": "^4.17.21",
20
- "murmurhash-js": "^1.0.0",
21
- "diary": "^0.3.1",
22
- "zod": "^3.18.0"
21
+ "murmurhash-js": "^1.0.0"
23
22
  }
24
23
  }
@@ -203,7 +203,7 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
203
203
  fields: z.ZodObject<{
204
204
  nt_name: z.ZodString;
205
205
  nt_type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
206
- nt_config: z.ZodObject<{
206
+ nt_config: z.ZodNullable<z.ZodOptional<z.ZodObject<{
207
207
  distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
208
208
  traffic: z.ZodDefault<z.ZodNumber>;
209
209
  components: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -265,7 +265,7 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
265
265
  hidden?: boolean | undefined;
266
266
  }[];
267
267
  }[] | undefined;
268
- }>;
268
+ }>>>;
269
269
  nt_audience: z.ZodNullable<z.ZodOptional<z.ZodObject<z.extendShape<{
270
270
  sys: z.ZodObject<{
271
271
  type: z.ZodOptional<z.ZodString>;
@@ -846,6 +846,19 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
846
846
  fields: {};
847
847
  }>, "many">>;
848
848
  }, "strip", z.ZodTypeAny, {
849
+ nt_config?: {
850
+ distribution: number[];
851
+ traffic: number;
852
+ components: {
853
+ baseline: {
854
+ id: string;
855
+ };
856
+ variants: {
857
+ id: string;
858
+ hidden: boolean;
859
+ }[];
860
+ }[];
861
+ } | null | undefined;
849
862
  nt_audience?: {
850
863
  metadata?: {
851
864
  tags: {
@@ -892,19 +905,6 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
892
905
  } | null | undefined;
893
906
  nt_name: string;
894
907
  nt_type: "nt_experiment" | "nt_personalization";
895
- nt_config: {
896
- distribution: number[];
897
- traffic: number;
898
- components: {
899
- baseline: {
900
- id: string;
901
- };
902
- variants: {
903
- id: string;
904
- hidden: boolean;
905
- }[];
906
- }[];
907
- };
908
908
  nt_variants: {
909
909
  metadata?: {
910
910
  tags: {
@@ -947,6 +947,19 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
947
947
  fields: {};
948
948
  }[];
949
949
  }, {
950
+ nt_config?: {
951
+ distribution?: number[] | undefined;
952
+ traffic?: number | undefined;
953
+ components?: {
954
+ baseline: {
955
+ id?: string | undefined;
956
+ };
957
+ variants: {
958
+ id?: string | undefined;
959
+ hidden?: boolean | undefined;
960
+ }[];
961
+ }[] | undefined;
962
+ } | null | undefined;
950
963
  nt_audience?: {
951
964
  metadata?: {
952
965
  tags: {
@@ -1034,25 +1047,12 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1034
1047
  }[] | undefined;
1035
1048
  nt_name: string;
1036
1049
  nt_type: "nt_experiment" | "nt_personalization";
1037
- nt_config: {
1038
- distribution?: number[] | undefined;
1039
- traffic?: number | undefined;
1040
- components?: {
1041
- baseline: {
1042
- id?: string | undefined;
1043
- };
1044
- variants: {
1045
- id?: string | undefined;
1046
- hidden?: boolean | undefined;
1047
- }[];
1048
- }[] | undefined;
1049
- };
1050
1050
  }>;
1051
1051
  }>, {
1052
1052
  fields: z.ZodObject<z.extendShape<{
1053
1053
  nt_name: z.ZodString;
1054
1054
  nt_type: z.ZodUnion<[z.ZodLiteral<"nt_experiment">, z.ZodLiteral<"nt_personalization">]>;
1055
- nt_config: z.ZodObject<{
1055
+ nt_config: z.ZodNullable<z.ZodOptional<z.ZodObject<{
1056
1056
  distribution: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
1057
1057
  traffic: z.ZodDefault<z.ZodNumber>;
1058
1058
  components: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -1114,7 +1114,7 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1114
1114
  hidden?: boolean | undefined;
1115
1115
  }[];
1116
1116
  }[] | undefined;
1117
- }>;
1117
+ }>>>;
1118
1118
  nt_audience: z.ZodNullable<z.ZodOptional<z.ZodObject<z.extendShape<{
1119
1119
  sys: z.ZodObject<{
1120
1120
  type: z.ZodOptional<z.ZodString>;
@@ -1697,6 +1697,19 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1697
1697
  }, {
1698
1698
  nt_type: z.ZodLiteral<"nt_experiment">;
1699
1699
  }>, "strip", z.ZodTypeAny, {
1700
+ nt_config?: {
1701
+ distribution: number[];
1702
+ traffic: number;
1703
+ components: {
1704
+ baseline: {
1705
+ id: string;
1706
+ };
1707
+ variants: {
1708
+ id: string;
1709
+ hidden: boolean;
1710
+ }[];
1711
+ }[];
1712
+ } | null | undefined;
1700
1713
  nt_audience?: {
1701
1714
  metadata?: {
1702
1715
  tags: {
@@ -1743,19 +1756,6 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1743
1756
  } | null | undefined;
1744
1757
  nt_name: string;
1745
1758
  nt_type: "nt_experiment";
1746
- nt_config: {
1747
- distribution: number[];
1748
- traffic: number;
1749
- components: {
1750
- baseline: {
1751
- id: string;
1752
- };
1753
- variants: {
1754
- id: string;
1755
- hidden: boolean;
1756
- }[];
1757
- }[];
1758
- };
1759
1759
  nt_variants: {
1760
1760
  metadata?: {
1761
1761
  tags: {
@@ -1798,6 +1798,19 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1798
1798
  fields: {};
1799
1799
  }[];
1800
1800
  }, {
1801
+ nt_config?: {
1802
+ distribution?: number[] | undefined;
1803
+ traffic?: number | undefined;
1804
+ components?: {
1805
+ baseline: {
1806
+ id?: string | undefined;
1807
+ };
1808
+ variants: {
1809
+ id?: string | undefined;
1810
+ hidden?: boolean | undefined;
1811
+ }[];
1812
+ }[] | undefined;
1813
+ } | null | undefined;
1801
1814
  nt_audience?: {
1802
1815
  metadata?: {
1803
1816
  tags: {
@@ -1885,19 +1898,6 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1885
1898
  }[] | undefined;
1886
1899
  nt_name: string;
1887
1900
  nt_type: "nt_experiment";
1888
- nt_config: {
1889
- distribution?: number[] | undefined;
1890
- traffic?: number | undefined;
1891
- components?: {
1892
- baseline: {
1893
- id?: string | undefined;
1894
- };
1895
- variants: {
1896
- id?: string | undefined;
1897
- hidden?: boolean | undefined;
1898
- }[];
1899
- }[] | undefined;
1900
- };
1901
1901
  }>;
1902
1902
  }>, "strip", z.ZodTypeAny, {
1903
1903
  metadata?: {
@@ -1939,6 +1939,19 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1939
1939
  id: string;
1940
1940
  };
1941
1941
  fields: {
1942
+ nt_config?: {
1943
+ distribution: number[];
1944
+ traffic: number;
1945
+ components: {
1946
+ baseline: {
1947
+ id: string;
1948
+ };
1949
+ variants: {
1950
+ id: string;
1951
+ hidden: boolean;
1952
+ }[];
1953
+ }[];
1954
+ } | null | undefined;
1942
1955
  nt_audience?: {
1943
1956
  metadata?: {
1944
1957
  tags: {
@@ -1985,19 +1998,6 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
1985
1998
  } | null | undefined;
1986
1999
  nt_name: string;
1987
2000
  nt_type: "nt_experiment";
1988
- nt_config: {
1989
- distribution: number[];
1990
- traffic: number;
1991
- components: {
1992
- baseline: {
1993
- id: string;
1994
- };
1995
- variants: {
1996
- id: string;
1997
- hidden: boolean;
1998
- }[];
1999
- }[];
2000
- };
2001
2001
  nt_variants: {
2002
2002
  metadata?: {
2003
2003
  tags: {
@@ -2080,6 +2080,19 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
2080
2080
  id: string;
2081
2081
  };
2082
2082
  fields: {
2083
+ nt_config?: {
2084
+ distribution?: number[] | undefined;
2085
+ traffic?: number | undefined;
2086
+ components?: {
2087
+ baseline: {
2088
+ id?: string | undefined;
2089
+ };
2090
+ variants: {
2091
+ id?: string | undefined;
2092
+ hidden?: boolean | undefined;
2093
+ }[];
2094
+ }[] | undefined;
2095
+ } | null | undefined;
2083
2096
  nt_audience?: {
2084
2097
  metadata?: {
2085
2098
  tags: {
@@ -2167,19 +2180,6 @@ export declare const ExperimentEntry: z.ZodObject<z.extendShape<z.extendShape<{
2167
2180
  }[] | undefined;
2168
2181
  nt_name: string;
2169
2182
  nt_type: "nt_experiment";
2170
- nt_config: {
2171
- distribution?: number[] | undefined;
2172
- traffic?: number | undefined;
2173
- components?: {
2174
- baseline: {
2175
- id?: string | undefined;
2176
- };
2177
- variants: {
2178
- id?: string | undefined;
2179
- hidden?: boolean | undefined;
2180
- }[];
2181
- }[] | undefined;
2182
- };
2183
2183
  };
2184
2184
  }>;
2185
2185
  export declare type ExperimentEntry = z.infer<typeof ExperimentEntry>;