@ninetailed/experience.js-utils-contentful 2.0.0-beta.9 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-utils-contentful",
3
- "version": "2.0.0-beta.9",
3
+ "version": "2.0.0",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts"
package/src/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export * from './types';
2
- export { AudienceMapper, ExperienceMapper } from './lib';
2
+ export { AudienceMapper, ExperienceMapper, isEntry, isAudienceEntry, isExperienceEntry, } from './lib';
package/src/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExperienceMapper = exports.AudienceMapper = void 0;
3
+ exports.isExperienceEntry = exports.isAudienceEntry = exports.isEntry = exports.ExperienceMapper = exports.AudienceMapper = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  (0, tslib_1.__exportStar)(require("./types"), exports);
6
6
  var lib_1 = require("./lib");
7
7
  Object.defineProperty(exports, "AudienceMapper", { enumerable: true, get: function () { return lib_1.AudienceMapper; } });
8
8
  Object.defineProperty(exports, "ExperienceMapper", { enumerable: true, get: function () { return lib_1.ExperienceMapper; } });
9
+ Object.defineProperty(exports, "isEntry", { enumerable: true, get: function () { return lib_1.isEntry; } });
10
+ Object.defineProperty(exports, "isAudienceEntry", { enumerable: true, get: function () { return lib_1.isAudienceEntry; } });
11
+ Object.defineProperty(exports, "isExperienceEntry", { enumerable: true, get: function () { return lib_1.isExperienceEntry; } });
9
12
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/utils/contentful/src/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAwB;AACxB,6BAAyD;AAAhD,qGAAA,cAAc,OAAA;AAAE,uGAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/utils/contentful/src/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAwB;AACxB,6BAMe;AALb,qGAAA,cAAc,OAAA;AACd,uGAAA,gBAAgB,OAAA;AAChB,8FAAA,OAAO,OAAA;AACP,sGAAA,eAAe,OAAA;AACf,wGAAA,iBAAiB,OAAA"}
@@ -1,18 +1,15 @@
1
- import { Baseline, Variant, ExperienceConfiguration } from '@ninetailed/experience.js';
2
- import { Entry } from 'contentful';
3
- import { ExperienceEntry } from '../types';
1
+ import { Variant, ExperienceConfiguration } from '@ninetailed/experience.js';
2
+ import { ExperienceEntry, Entry } from '../types';
4
3
  import { BaselineWithExperiencesEntry } from '../types/BaselineWithExperiencesEntry';
5
4
  declare type MapVariantOptions = {
6
5
  hidden: boolean;
7
6
  };
8
- declare type MapBaseline<BaselineType = Entry<unknown>> = (baseline: BaselineType) => Baseline;
9
- declare type MapVariant<VariantType = Entry<unknown>> = (variant: VariantType, options: MapVariantOptions) => Variant;
10
- declare type MapExperienceOptions<BaselineType = Entry<unknown>, VariantType = Entry<unknown>> = {
11
- mapBaseline?: MapBaseline<BaselineType>;
7
+ declare type MapVariant<VariantType = Entry> = (variant: VariantType, options: MapVariantOptions) => Variant;
8
+ declare type MapExperienceOptions<VariantType = Entry> = {
12
9
  mapVariant?: MapVariant<VariantType>;
13
10
  };
14
11
  export declare class ExperienceMapper {
15
- static mapExperience<BaselineType = Entry<unknown>>(entry: ExperienceEntry, baseline: BaselineType, options?: MapExperienceOptions<BaselineType>): ExperienceConfiguration;
12
+ static mapExperience(entry: ExperienceEntry, options?: MapExperienceOptions): ExperienceConfiguration;
16
13
  static mapExperiment(entry: ExperienceEntry): ExperienceConfiguration;
17
14
  static mapBaselineWithExperiences(entry: BaselineWithExperiencesEntry): ExperienceConfiguration[];
18
15
  }
@@ -2,12 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExperienceMapper = void 0;
4
4
  const AudienceMapper_1 = require("./AudienceMapper");
5
- const defaultMapBaseline = (baseline) => (Object.assign(Object.assign({}, baseline), { id: baseline.sys.id }));
5
+ const isEntry_1 = require("./isEntry");
6
6
  const defaultMapVariant = (variant, { hidden }) => (Object.assign(Object.assign({}, variant), { id: variant.sys.id, hidden: hidden }));
7
7
  class ExperienceMapper {
8
- static mapExperience(entry, baseline, options) {
9
- const _mapBaseline = ((options === null || options === void 0 ? void 0 : options.mapBaseline) ||
10
- defaultMapBaseline);
8
+ static mapExperience(entry, options) {
11
9
  const _mapVariant = (options === null || options === void 0 ? void 0 : options.mapVariant) || defaultMapVariant;
12
10
  const config = Object.assign({ traffic: 0, distribution: [0.5, 0.5], components: [
13
11
  {
@@ -15,7 +13,7 @@ class ExperienceMapper {
15
13
  variants: [{ id: '', hidden: false }],
16
14
  },
17
15
  ] }, entry.fields.nt_config);
18
- const variantReferences = (entry.fields.nt_variants || []).filter((variantReference) => !!variantReference);
16
+ const variantReferences = (entry.fields.nt_variants || []).filter(isEntry_1.isEntry);
19
17
  return Object.assign(Object.assign({ id: entry.sys.id, type: entry.fields.nt_type }, (entry.fields.nt_audience
20
18
  ? {
21
19
  audience: AudienceMapper_1.AudienceMapper.mapAudience(entry.fields.nt_audience),
@@ -26,9 +24,12 @@ class ExperienceMapper {
26
24
  end: config.distribution.slice(0, index + 1).reduce((a, b) => a + b, 0),
27
25
  })), components: config.components.map((component) => {
28
26
  return {
29
- baseline: _mapBaseline(baseline),
27
+ baseline: component.baseline,
30
28
  variants: component.variants
31
29
  .map((variant) => {
30
+ if (variant.hidden) {
31
+ return variant;
32
+ }
32
33
  const matchingVariant = variantReferences.find((variantReference) => variantReference.sys.id === variant.id);
33
34
  if (!matchingVariant) {
34
35
  return null;
@@ -40,13 +41,14 @@ class ExperienceMapper {
40
41
  }) });
41
42
  }
42
43
  static mapExperiment(entry) {
43
- return this.mapExperience(entry, null, {
44
- mapBaseline: () => ({ id: '' }),
44
+ return ExperienceMapper.mapExperience(entry, {
45
45
  mapVariant: () => ({ id: '', hidden: false }),
46
46
  });
47
47
  }
48
48
  static mapBaselineWithExperiences(entry) {
49
- return entry.fields.nt_experiences.map((experience) => this.mapExperience(experience, entry));
49
+ return entry.fields.nt_experiences
50
+ .filter(isEntry_1.isEntry)
51
+ .map((experience) => ExperienceMapper.mapExperience(experience));
50
52
  }
51
53
  }
52
54
  exports.ExperienceMapper = ExperienceMapper;
@@ -1 +1 @@
1
- {"version":3,"file":"ExperienceMapper.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/ExperienceMapper.ts"],"names":[],"mappings":";;;AASA,qDAAkD;AAuBlD,MAAM,kBAAkB,GAAgC,CAAC,QAAQ,EAAE,EAAE,CAAC,iCACjE,QAAQ,KACX,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,IACnB,CAAC;AAEH,MAAM,iBAAiB,GAA+B,CACpD,OAAO,EACP,EAAE,MAAM,EAAE,EACV,EAAE,CAAC,iCACA,OAAO,KACV,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAClB,MAAM,EAAE,MAAM,IACd,CAAC;AAEH,MAAa,gBAAgB;IAC3B,MAAM,CAAC,aAAa,CAClB,KAAsB,EACtB,QAAsB,EACtB,OAA4C;QAE5C,MAAM,YAAY,GAAG,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW;YACxC,kBAAkB,CAA8B,CAAC;QACnD,MAAM,WAAW,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,KAAI,iBAAiB,CAAC;QAE7D,MAAM,MAAM,mBACV,OAAO,EAAE,CAAC,EACV,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EACxB,UAAU,EAAE;gBACV;oBACE,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;oBAC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E,YAAY,CAAC,QAAQ,CAAC;oBAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ;yBACzB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;wBACf,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAC5C,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAC7D,CAAC;wBAEF,IAAI,CAAC,eAAe,EAAE;4BACpB,OAAO,IAAI,CAAC;yBACb;wBAED,OAAO,WAAW,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;oBAClE,CAAC,CAAC;yBACD,MAAM,CAAC,CAAC,OAAO,EAAsB,EAAE,CAAC,OAAO,KAAK,IAAI,CAAC;iBAC7D,CAAC;YACJ,CAAC,CAAC,IACF;IACJ,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,KAAsB;QACzC,OAAO,IAAI,CAAC,aAAa,CAAO,KAAK,EAAE,IAAI,EAAE;YAC3C,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;YAC/B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;SAC9C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,0BAA0B,CAC/B,KAAmC;QAEnC,OAAO,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CACpD,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,CACtC,CAAC;IACJ,CAAC;CACF;AA3ED,4CA2EC"}
1
+ {"version":3,"file":"ExperienceMapper.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/ExperienceMapper.ts"],"names":[],"mappings":";;;AAOA,qDAAkD;AAClD,uCAAoC;AAepC,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,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;SAC9C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,0BAA0B,CAC/B,KAAmC;QAEnC,OAAO,KAAK,CAAC,MAAM,CAAC,cAAc;aAC/B,MAAM,CAAC,iBAAO,CAAC;aACf,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;IACrE,CAAC;CACF;AAxED,4CAwEC"}
@@ -1,2 +1,5 @@
1
1
  export { AudienceMapper } from './AudienceMapper';
2
2
  export { ExperienceMapper } from './ExperienceMapper';
3
+ export { isEntry } from './isEntry';
4
+ export { isAudienceEntry } from './isAudienceEntry';
5
+ export { isExperienceEntry } from './isExperienceEntry';
package/src/lib/index.js CHANGED
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExperienceMapper = exports.AudienceMapper = void 0;
3
+ exports.isExperienceEntry = exports.isAudienceEntry = exports.isEntry = exports.ExperienceMapper = exports.AudienceMapper = void 0;
4
4
  var AudienceMapper_1 = require("./AudienceMapper");
5
5
  Object.defineProperty(exports, "AudienceMapper", { enumerable: true, get: function () { return AudienceMapper_1.AudienceMapper; } });
6
6
  var ExperienceMapper_1 = require("./ExperienceMapper");
7
7
  Object.defineProperty(exports, "ExperienceMapper", { enumerable: true, get: function () { return ExperienceMapper_1.ExperienceMapper; } });
8
+ var isEntry_1 = require("./isEntry");
9
+ Object.defineProperty(exports, "isEntry", { enumerable: true, get: function () { return isEntry_1.isEntry; } });
10
+ var isAudienceEntry_1 = require("./isAudienceEntry");
11
+ Object.defineProperty(exports, "isAudienceEntry", { enumerable: true, get: function () { return isAudienceEntry_1.isAudienceEntry; } });
12
+ var isExperienceEntry_1 = require("./isExperienceEntry");
13
+ Object.defineProperty(exports, "isExperienceEntry", { enumerable: true, get: function () { return isExperienceEntry_1.isExperienceEntry; } });
8
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AAEzB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,84 @@
1
+ export declare const isAudienceEntry: (entry?: {
2
+ sys: {
3
+ revision?: number | undefined;
4
+ space?: {
5
+ sys: {
6
+ type: "Link";
7
+ linkType: "Space";
8
+ id: string;
9
+ };
10
+ } | undefined;
11
+ environment?: {
12
+ sys: {
13
+ type: "Link";
14
+ linkType: "Environment";
15
+ id: string;
16
+ };
17
+ } | undefined;
18
+ type: string;
19
+ id: string;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ locale: string;
23
+ contentType: {
24
+ sys: {
25
+ type: "Link";
26
+ linkType: "ContentType";
27
+ id: string;
28
+ };
29
+ };
30
+ };
31
+ fields: {};
32
+ metadata: {
33
+ tags: {
34
+ sys: {
35
+ type: "Link";
36
+ linkType: "Tag";
37
+ id: string;
38
+ };
39
+ }[];
40
+ };
41
+ } | undefined) => entry is {
42
+ sys: {
43
+ revision?: number | undefined;
44
+ space?: {
45
+ sys: {
46
+ type: "Link";
47
+ linkType: "Space";
48
+ id: string;
49
+ };
50
+ } | undefined;
51
+ environment?: {
52
+ sys: {
53
+ type: "Link";
54
+ linkType: "Environment";
55
+ id: string;
56
+ };
57
+ } | undefined;
58
+ type: string;
59
+ id: string;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ locale: string;
63
+ contentType: {
64
+ sys: {
65
+ type: "Link";
66
+ linkType: "ContentType";
67
+ id: string;
68
+ };
69
+ };
70
+ };
71
+ fields: {
72
+ nt_name: string;
73
+ nt_audience_id: string;
74
+ };
75
+ metadata: {
76
+ tags: {
77
+ sys: {
78
+ type: "Link";
79
+ linkType: "Tag";
80
+ id: string;
81
+ };
82
+ }[];
83
+ };
84
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAudienceEntry = void 0;
4
+ const types_1 = require("../types");
5
+ const isAudienceEntry = (entry) => {
6
+ try {
7
+ types_1.AudienceEntry.parse(entry);
8
+ return true;
9
+ }
10
+ catch (error) {
11
+ return false;
12
+ }
13
+ };
14
+ exports.isAudienceEntry = isAudienceEntry;
15
+ //# sourceMappingURL=isAudienceEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isAudienceEntry.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/isAudienceEntry.ts"],"names":[],"mappings":";;;AAAA,oCAAgD;AAEzC,MAAM,eAAe,GAAG,CAAC,KAAa,EAA0B,EAAE;IACvE,IAAI;QACF,qBAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE3B,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B"}
@@ -0,0 +1,81 @@
1
+ export declare const isEntry: (entry?: {
2
+ sys: {
3
+ revision?: number | undefined;
4
+ space?: {
5
+ sys: {
6
+ type: "Link";
7
+ linkType: "Space";
8
+ id: string;
9
+ };
10
+ } | undefined;
11
+ environment?: {
12
+ sys: {
13
+ type: "Link";
14
+ linkType: "Environment";
15
+ id: string;
16
+ };
17
+ } | undefined;
18
+ type: string;
19
+ id: string;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ locale: string;
23
+ contentType: {
24
+ sys: {
25
+ type: "Link";
26
+ linkType: "ContentType";
27
+ id: string;
28
+ };
29
+ };
30
+ };
31
+ fields: {};
32
+ metadata: {
33
+ tags: {
34
+ sys: {
35
+ type: "Link";
36
+ linkType: "Tag";
37
+ id: string;
38
+ };
39
+ }[];
40
+ };
41
+ } | undefined) => entry is {
42
+ sys: {
43
+ revision?: number | undefined;
44
+ space?: {
45
+ sys: {
46
+ type: "Link";
47
+ linkType: "Space";
48
+ id: string;
49
+ };
50
+ } | undefined;
51
+ environment?: {
52
+ sys: {
53
+ type: "Link";
54
+ linkType: "Environment";
55
+ id: string;
56
+ };
57
+ } | undefined;
58
+ type: string;
59
+ id: string;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ locale: string;
63
+ contentType: {
64
+ sys: {
65
+ type: "Link";
66
+ linkType: "ContentType";
67
+ id: string;
68
+ };
69
+ };
70
+ };
71
+ fields: {};
72
+ metadata: {
73
+ tags: {
74
+ sys: {
75
+ type: "Link";
76
+ linkType: "Tag";
77
+ id: string;
78
+ };
79
+ }[];
80
+ };
81
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEntry = void 0;
4
+ const types_1 = require("../types");
5
+ const isEntry = (entry) => {
6
+ try {
7
+ types_1.Entry.parse(entry);
8
+ return true;
9
+ }
10
+ catch (error) {
11
+ return false;
12
+ }
13
+ };
14
+ exports.isEntry = isEntry;
15
+ //# sourceMappingURL=isEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isEntry.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/isEntry.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAE1B,MAAM,OAAO,GAAG,CAAC,KAAa,EAAkB,EAAE;IACvD,IAAI;QACF,aAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEnB,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AARW,QAAA,OAAO,WAQlB"}
@@ -0,0 +1,182 @@
1
+ export declare const isExperienceEntry: (entry?: {
2
+ sys: {
3
+ revision?: number | undefined;
4
+ space?: {
5
+ sys: {
6
+ type: "Link";
7
+ linkType: "Space";
8
+ id: string;
9
+ };
10
+ } | undefined;
11
+ environment?: {
12
+ sys: {
13
+ type: "Link";
14
+ linkType: "Environment";
15
+ id: string;
16
+ };
17
+ } | undefined;
18
+ type: string;
19
+ id: string;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ locale: string;
23
+ contentType: {
24
+ sys: {
25
+ type: "Link";
26
+ linkType: "ContentType";
27
+ id: string;
28
+ };
29
+ };
30
+ };
31
+ fields: {};
32
+ metadata: {
33
+ tags: {
34
+ sys: {
35
+ type: "Link";
36
+ linkType: "Tag";
37
+ id: string;
38
+ };
39
+ }[];
40
+ };
41
+ } | undefined) => entry is {
42
+ sys: {
43
+ revision?: number | undefined;
44
+ space?: {
45
+ sys: {
46
+ type: "Link";
47
+ linkType: "Space";
48
+ id: string;
49
+ };
50
+ } | undefined;
51
+ environment?: {
52
+ sys: {
53
+ type: "Link";
54
+ linkType: "Environment";
55
+ id: string;
56
+ };
57
+ } | undefined;
58
+ type: string;
59
+ id: string;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ locale: string;
63
+ contentType: {
64
+ sys: {
65
+ type: "Link";
66
+ linkType: "ContentType";
67
+ id: string;
68
+ };
69
+ };
70
+ };
71
+ fields: {
72
+ nt_config?: {
73
+ distribution: number[];
74
+ traffic: number;
75
+ components: {
76
+ baseline: {
77
+ id: string;
78
+ };
79
+ variants: {
80
+ id: string;
81
+ hidden: boolean;
82
+ }[];
83
+ }[];
84
+ } | null | undefined;
85
+ nt_audience?: {
86
+ sys: {
87
+ revision?: number | undefined;
88
+ space?: {
89
+ sys: {
90
+ type: "Link";
91
+ linkType: "Space";
92
+ id: string;
93
+ };
94
+ } | undefined;
95
+ environment?: {
96
+ sys: {
97
+ type: "Link";
98
+ linkType: "Environment";
99
+ id: string;
100
+ };
101
+ } | undefined;
102
+ type: string;
103
+ id: string;
104
+ createdAt: string;
105
+ updatedAt: string;
106
+ locale: string;
107
+ contentType: {
108
+ sys: {
109
+ type: "Link";
110
+ linkType: "ContentType";
111
+ id: string;
112
+ };
113
+ };
114
+ };
115
+ fields: {
116
+ nt_name: string;
117
+ nt_audience_id: string;
118
+ };
119
+ metadata: {
120
+ tags: {
121
+ sys: {
122
+ type: "Link";
123
+ linkType: "Tag";
124
+ id: string;
125
+ };
126
+ }[];
127
+ };
128
+ } | null | undefined;
129
+ nt_name: string;
130
+ nt_type: "nt_experiment" | "nt_personalization";
131
+ nt_variants: {
132
+ sys: {
133
+ revision?: number | undefined;
134
+ space?: {
135
+ sys: {
136
+ type: "Link";
137
+ linkType: "Space";
138
+ id: string;
139
+ };
140
+ } | undefined;
141
+ environment?: {
142
+ sys: {
143
+ type: "Link";
144
+ linkType: "Environment";
145
+ id: string;
146
+ };
147
+ } | undefined;
148
+ type: string;
149
+ id: string;
150
+ createdAt: string;
151
+ updatedAt: string;
152
+ locale: string;
153
+ contentType: {
154
+ sys: {
155
+ type: "Link";
156
+ linkType: "ContentType";
157
+ id: string;
158
+ };
159
+ };
160
+ };
161
+ fields: {};
162
+ metadata: {
163
+ tags: {
164
+ sys: {
165
+ type: "Link";
166
+ linkType: "Tag";
167
+ id: string;
168
+ };
169
+ }[];
170
+ };
171
+ }[];
172
+ };
173
+ metadata: {
174
+ tags: {
175
+ sys: {
176
+ type: "Link";
177
+ linkType: "Tag";
178
+ id: string;
179
+ };
180
+ }[];
181
+ };
182
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExperienceEntry = void 0;
4
+ const types_1 = require("../types");
5
+ const isExperienceEntry = (entry) => {
6
+ try {
7
+ types_1.ExperienceEntry.parse(entry);
8
+ return true;
9
+ }
10
+ catch (error) {
11
+ console.error(error);
12
+ return false;
13
+ }
14
+ };
15
+ exports.isExperienceEntry = isExperienceEntry;
16
+ //# sourceMappingURL=isExperienceEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExperienceEntry.js","sourceRoot":"","sources":["../../../../../../packages/utils/contentful/src/lib/isExperienceEntry.ts"],"names":[],"mappings":";;;AAAA,oCAAkD;AAE3C,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAA4B,EAAE;IAC3E,IAAI;QACF,uBAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAErB,OAAO,KAAK,CAAC;KACd;AACH,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B"}