@ninetailed/experience.js-utils-contentful 7.7.0-beta.2 → 7.7.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 CHANGED
@@ -98,6 +98,31 @@ AudienceMapper.isAudienceEntry = entry => {
98
98
  return AudienceEntry.safeParse(entry).success;
99
99
  };
100
100
 
101
+ /******************************************************************************
102
+ Copyright (c) Microsoft Corporation.
103
+
104
+ Permission to use, copy, modify, and/or distribute this software for any
105
+ purpose with or without fee is hereby granted.
106
+
107
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
108
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
109
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
110
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
111
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
112
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
113
+ PERFORMANCE OF THIS SOFTWARE.
114
+ ***************************************************************************** */
115
+
116
+ function __awaiter(thisArg, _arguments, P, generator) {
117
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
118
+ return new (P || (P = Promise))(function (resolve, reject) {
119
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
120
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
121
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
122
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
123
+ });
124
+ }
125
+
101
126
  const ExperienceEntryFields = zod.z.object({
102
127
  /**
103
128
  * The name of the experience (Short Text)
@@ -250,6 +275,17 @@ class ExperienceMapper {
250
275
  const experience = createExperience(sys.id, fields, variants);
251
276
  return experience_jsUtils.ExperienceMapper.mapExperience(experience);
252
277
  }
278
+ static mapCustomExperienceAsync(ctfEntry, mapFn) {
279
+ return __awaiter(this, void 0, void 0, function* () {
280
+ const {
281
+ sys,
282
+ fields
283
+ } = validateExperienceEntry(ctfEntry);
284
+ const variants = yield Promise.all(fields.nt_variants.map(mapFn));
285
+ const experience = createExperience(sys.id, fields, variants);
286
+ return experience_jsUtils.ExperienceMapper.mapExperience(experience);
287
+ });
288
+ }
253
289
  static isExperiment(entry) {
254
290
  return ExperimentEntry.safeParse(entry).success;
255
291
  }
package/index.esm.js CHANGED
@@ -246,6 +246,15 @@ class ExperienceMapper {
246
246
  const experience = createExperience(sys.id, fields, variants);
247
247
  return ExperienceMapper$1.mapExperience(experience);
248
248
  }
249
+ static async mapCustomExperienceAsync(ctfEntry, mapFn) {
250
+ const {
251
+ sys,
252
+ fields
253
+ } = validateExperienceEntry(ctfEntry);
254
+ const variants = await Promise.all(fields.nt_variants.map(mapFn));
255
+ const experience = createExperience(sys.id, fields, variants);
256
+ return ExperienceMapper$1.mapExperience(experience);
257
+ }
249
258
  static isExperiment(entry) {
250
259
  return ExperimentEntry.safeParse(entry).success;
251
260
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-utils-contentful",
3
- "version": "7.7.0-beta.2",
3
+ "version": "7.7.0",
4
4
  "description": "Contentful utilities for Experience.js",
5
5
  "dependencies": {
6
6
  "contentful": "^9.1.32",
7
7
  "@contentful/rich-text-types": "16.2.0",
8
- "@ninetailed/experience.js-utils": "7.7.0-beta.2",
9
- "@ninetailed/experience.js": "7.7.0-beta.2",
10
- "@ninetailed/experience.js-shared": "7.7.0-beta.2",
8
+ "@ninetailed/experience.js-utils": "7.7.0",
9
+ "@ninetailed/experience.js": "7.7.0",
10
+ "@ninetailed/experience.js-shared": "7.7.0",
11
11
  "zod": "3.23.0"
12
12
  },
13
13
  "license": "MIT",
@@ -5,6 +5,7 @@ import type { EntryFields } from '../types/EntryFields';
5
5
  import { ExperienceEntry, ExperienceEntryLike } from '../types/ExperienceEntry';
6
6
  import { ExperimentEntry } from '../types/ExperimentEntry';
7
7
  export type MapVariantFunction<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Out;
8
+ export type MapVariantFunctionAsync<In extends EntryFields, Out extends Reference> = (input: EntryLike<In>) => Promise<Out>;
8
9
  export declare class ExperienceMapper {
9
10
  static isExperienceEntry<VariantFields extends EntryFields>(entry: ExperienceEntryLike<VariantFields>): entry is ExperienceEntry<VariantFields>;
10
11
  static mapExperience<VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>): import("@ninetailed/experience.js").ExperienceConfiguration<{
@@ -50,6 +51,7 @@ export declare class ExperienceMapper {
50
51
  fields: VariantFields;
51
52
  }>;
52
53
  static mapCustomExperience<Variant extends Reference, VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>, mapFn: MapVariantFunction<VariantFields, Variant>): import("@ninetailed/experience.js").ExperienceConfiguration<Variant>;
54
+ static mapCustomExperienceAsync<Variant extends Reference, VariantFields extends EntryFields>(ctfEntry: ExperienceEntryLike<VariantFields>, mapFn: MapVariantFunctionAsync<VariantFields, Variant>): Promise<import("@ninetailed/experience.js").ExperienceConfiguration<Awaited<Variant>>>;
53
55
  static isExperiment(entry: ExperienceEntryLike): entry is ExperimentEntry;
54
56
  static mapExperiment(entry: ExperienceEntryLike): import("@ninetailed/experience.js").ExperienceConfiguration<{
55
57
  id: string;