@salesforce/lds-adapters-marketing-assetcreation 1.100.2

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.
Files changed (25) hide show
  1. package/LICENSE.txt +82 -0
  2. package/dist/es/es2018/marketing-assetcreation.js +1001 -0
  3. package/dist/types/src/generated/adapters/adapter-utils.d.ts +66 -0
  4. package/dist/types/src/generated/adapters/createAsset.d.ts +15 -0
  5. package/dist/types/src/generated/adapters/getStarterTemplateById.d.ts +27 -0
  6. package/dist/types/src/generated/adapters/getStarterTemplates.d.ts +27 -0
  7. package/dist/types/src/generated/artifacts/main.d.ts +3 -0
  8. package/dist/types/src/generated/artifacts/sfdc.d.ts +6 -0
  9. package/dist/types/src/generated/resources/getAssetCreationStarterTemplates.d.ts +16 -0
  10. package/dist/types/src/generated/resources/getAssetCreationStarterTemplatesByStarterTemplateId.d.ts +18 -0
  11. package/dist/types/src/generated/resources/postAssetCreationObjects.d.ts +13 -0
  12. package/dist/types/src/generated/types/AssetInputRepresentation.d.ts +39 -0
  13. package/dist/types/src/generated/types/AssetInputWrapperRepresentation.d.ts +29 -0
  14. package/dist/types/src/generated/types/AssetOutputRepresentation.d.ts +42 -0
  15. package/dist/types/src/generated/types/StarterTemplateDetailRepresentation.d.ts +48 -0
  16. package/dist/types/src/generated/types/StarterTemplateListRepresentation.d.ts +31 -0
  17. package/dist/types/src/generated/types/StarterTemplateRepresentation.d.ts +38 -0
  18. package/dist/types/src/generated/types/type-utils.d.ts +39 -0
  19. package/dist/umd/es2018/marketing-assetcreation.js +1011 -0
  20. package/dist/umd/es5/marketing-assetcreation.js +1016 -0
  21. package/package.json +66 -0
  22. package/sfdc/index.d.ts +1 -0
  23. package/sfdc/index.js +1047 -0
  24. package/src/raml/api.raml +171 -0
  25. package/src/raml/luvio.raml +33 -0
@@ -0,0 +1,1011 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ (function (global, factory) {
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@luvio/engine')) :
9
+ typeof define === 'function' && define.amd ? define(['exports', '@luvio/engine'], factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.marketingAssetcreation = {}, global.engine));
11
+ })(this, (function (exports, engine) { 'use strict';
12
+
13
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
14
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
15
+ const { isArray: ArrayIsArray$1 } = Array;
16
+ /**
17
+ * Validates an adapter config is well-formed.
18
+ * @param config The config to validate.
19
+ * @param adapter The adapter validation configuration.
20
+ * @param oneOf The keys the config must contain at least one of.
21
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
22
+ */
23
+ function validateConfig(config, adapter, oneOf) {
24
+ const { displayName } = adapter;
25
+ const { required, optional, unsupported } = adapter.parameters;
26
+ if (config === undefined ||
27
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
28
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
29
+ }
30
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
31
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
32
+ }
33
+ if (unsupported !== undefined &&
34
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
35
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
36
+ }
37
+ const supported = required.concat(optional);
38
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
39
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
40
+ }
41
+ }
42
+ function untrustedIsObject(untrusted) {
43
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
44
+ }
45
+ function areRequiredParametersPresent(config, configPropertyNames) {
46
+ return configPropertyNames.parameters.required.every(req => req in config);
47
+ }
48
+ const snapshotRefreshOptions = {
49
+ overrides: {
50
+ headers: {
51
+ 'Cache-Control': 'no-cache',
52
+ },
53
+ }
54
+ };
55
+ const keyPrefix = 'assetcreation';
56
+
57
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
58
+ const { isArray: ArrayIsArray } = Array;
59
+ function equalsArray(a, b, equalsItem) {
60
+ const aLength = a.length;
61
+ const bLength = b.length;
62
+ if (aLength !== bLength) {
63
+ return false;
64
+ }
65
+ for (let i = 0; i < aLength; i++) {
66
+ if (equalsItem(a[i], b[i]) === false) {
67
+ return false;
68
+ }
69
+ }
70
+ return true;
71
+ }
72
+ function deepFreeze(value) {
73
+ // No need to freeze primitives
74
+ if (typeof value !== 'object' || value === null) {
75
+ return;
76
+ }
77
+ if (ArrayIsArray(value)) {
78
+ for (let i = 0, len = value.length; i < len; i += 1) {
79
+ deepFreeze(value[i]);
80
+ }
81
+ }
82
+ else {
83
+ const keys = ObjectKeys(value);
84
+ for (let i = 0, len = keys.length; i < len; i += 1) {
85
+ deepFreeze(value[keys[i]]);
86
+ }
87
+ }
88
+ ObjectFreeze(value);
89
+ }
90
+ function createLink(ref) {
91
+ return {
92
+ __ref: engine.serializeStructuredKey(ref),
93
+ };
94
+ }
95
+
96
+ function validate$4(obj, path = 'AssetInputRepresentation') {
97
+ const v_error = (() => {
98
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
99
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
100
+ }
101
+ const obj_fields = obj.fields;
102
+ const path_fields = path + '.fields';
103
+ if (typeof obj_fields !== 'object' || ArrayIsArray(obj_fields) || obj_fields === null) {
104
+ return new TypeError('Expected "object" but received "' + typeof obj_fields + '" (at "' + path_fields + '")');
105
+ }
106
+ const obj_fields_keys = ObjectKeys(obj_fields);
107
+ for (let i = 0; i < obj_fields_keys.length; i++) {
108
+ const key = obj_fields_keys[i];
109
+ const obj_fields_prop = obj_fields[key];
110
+ const path_fields_prop = path_fields + '["' + key + '"]';
111
+ if (typeof obj_fields_prop !== 'string') {
112
+ return new TypeError('Expected "string" but received "' + typeof obj_fields_prop + '" (at "' + path_fields_prop + '")');
113
+ }
114
+ }
115
+ const obj_starterTemplateId = obj.starterTemplateId;
116
+ const path_starterTemplateId = path + '.starterTemplateId';
117
+ if (typeof obj_starterTemplateId !== 'string') {
118
+ return new TypeError('Expected "string" but received "' + typeof obj_starterTemplateId + '" (at "' + path_starterTemplateId + '")');
119
+ }
120
+ const obj_type = obj.type;
121
+ const path_type = path + '.type';
122
+ if (typeof obj_type !== 'string') {
123
+ return new TypeError('Expected "string" but received "' + typeof obj_type + '" (at "' + path_type + '")');
124
+ }
125
+ })();
126
+ return v_error === undefined ? null : v_error;
127
+ }
128
+
129
+ const TTL$2 = 1000;
130
+ const VERSION$3 = "b43d0a7e53f816bf92d87798789baf3a";
131
+ function validate$3(obj, path = 'AssetOutputRepresentation') {
132
+ const v_error = (() => {
133
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
134
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
135
+ }
136
+ const obj_contentBuilderUrl = obj.contentBuilderUrl;
137
+ const path_contentBuilderUrl = path + '.contentBuilderUrl';
138
+ if (typeof obj_contentBuilderUrl !== 'string') {
139
+ return new TypeError('Expected "string" but received "' + typeof obj_contentBuilderUrl + '" (at "' + path_contentBuilderUrl + '")');
140
+ }
141
+ const obj_id = obj.id;
142
+ const path_id = path + '.id';
143
+ if (typeof obj_id !== 'string') {
144
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
145
+ }
146
+ })();
147
+ return v_error === undefined ? null : v_error;
148
+ }
149
+ const RepresentationType$2 = 'AssetOutputRepresentation';
150
+ function keyBuilder$4(luvio, config) {
151
+ return keyPrefix + '::' + RepresentationType$2 + ':' + config.id;
152
+ }
153
+ function keyBuilderFromType(luvio, object) {
154
+ const keyParams = {
155
+ id: object.id
156
+ };
157
+ return keyBuilder$4(luvio, keyParams);
158
+ }
159
+ function normalize$2(input, existing, path, luvio, store, timestamp) {
160
+ return input;
161
+ }
162
+ const select$6 = function AssetOutputRepresentationSelect() {
163
+ return {
164
+ kind: 'Fragment',
165
+ version: VERSION$3,
166
+ private: [],
167
+ selections: [
168
+ {
169
+ name: 'contentBuilderUrl',
170
+ kind: 'Scalar'
171
+ },
172
+ {
173
+ name: 'id',
174
+ kind: 'Scalar'
175
+ }
176
+ ]
177
+ };
178
+ };
179
+ function equals$3(existing, incoming) {
180
+ const existing_contentBuilderUrl = existing.contentBuilderUrl;
181
+ const incoming_contentBuilderUrl = incoming.contentBuilderUrl;
182
+ if (!(existing_contentBuilderUrl === incoming_contentBuilderUrl)) {
183
+ return false;
184
+ }
185
+ const existing_id = existing.id;
186
+ const incoming_id = incoming.id;
187
+ if (!(existing_id === incoming_id)) {
188
+ return false;
189
+ }
190
+ return true;
191
+ }
192
+ const ingest$2 = function AssetOutputRepresentationIngest(input, path, luvio, store, timestamp) {
193
+ if (process.env.NODE_ENV !== 'production') {
194
+ const validateError = validate$3(input);
195
+ if (validateError !== null) {
196
+ throw validateError;
197
+ }
198
+ }
199
+ const key = keyBuilderFromType(luvio, input);
200
+ const existingRecord = store.readEntry(key);
201
+ const ttlToUse = TTL$2;
202
+ let incomingRecord = normalize$2(input, store.readEntry(key), {
203
+ fullPath: key,
204
+ parent: path.parent,
205
+ propertyName: path.propertyName,
206
+ ttl: ttlToUse
207
+ });
208
+ if (existingRecord === undefined || equals$3(existingRecord, incomingRecord) === false) {
209
+ luvio.storePublish(key, incomingRecord);
210
+ }
211
+ {
212
+ const storeMetadataParams = {
213
+ ttl: ttlToUse,
214
+ namespace: "assetcreation",
215
+ version: VERSION$3,
216
+ representationName: RepresentationType$2,
217
+ };
218
+ luvio.publishStoreMetadata(key, storeMetadataParams);
219
+ }
220
+ return createLink(key);
221
+ };
222
+ function getTypeCacheKeys$2(luvio, input, fullPathFactory) {
223
+ const rootKeySet = new engine.StoreKeyMap();
224
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
225
+ const rootKey = keyBuilderFromType(luvio, input);
226
+ rootKeySet.set(rootKey, {
227
+ namespace: keyPrefix,
228
+ representationName: RepresentationType$2,
229
+ mergeable: false
230
+ });
231
+ return rootKeySet;
232
+ }
233
+
234
+ function select$5(luvio, params) {
235
+ return select$6();
236
+ }
237
+ function getResponseCacheKeys$2(luvio, resourceParams, response) {
238
+ return getTypeCacheKeys$2(luvio, response);
239
+ }
240
+ function ingestSuccess$2(luvio, resourceParams, response) {
241
+ const { body } = response;
242
+ const key = keyBuilderFromType(luvio, body);
243
+ luvio.storeIngest(key, ingest$2, body);
244
+ const snapshot = luvio.storeLookup({
245
+ recordId: key,
246
+ node: select$5(),
247
+ variables: {},
248
+ });
249
+ if (process.env.NODE_ENV !== 'production') {
250
+ if (snapshot.state !== 'Fulfilled') {
251
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
252
+ }
253
+ }
254
+ return snapshot;
255
+ }
256
+ function createResourceRequest$2(config) {
257
+ const headers = {};
258
+ return {
259
+ baseUri: '/services/data/v58.0',
260
+ basePath: '/asset-creation/objects',
261
+ method: 'post',
262
+ body: config.body,
263
+ urlParams: {},
264
+ queryParams: {},
265
+ headers,
266
+ priority: 'normal',
267
+ };
268
+ }
269
+
270
+ const createAsset_ConfigPropertyNames = {
271
+ displayName: 'createAsset',
272
+ parameters: {
273
+ required: ['AssetInput'],
274
+ optional: []
275
+ }
276
+ };
277
+ function createResourceParams$2(config) {
278
+ const resourceParams = {
279
+ body: {
280
+ AssetInput: config.AssetInput
281
+ }
282
+ };
283
+ return resourceParams;
284
+ }
285
+ function typeCheckConfig$2(untrustedConfig) {
286
+ const config = {};
287
+ const untrustedConfig_AssetInput = untrustedConfig.AssetInput;
288
+ const referenceAssetInputRepresentationValidationError = validate$4(untrustedConfig_AssetInput);
289
+ if (referenceAssetInputRepresentationValidationError === null) {
290
+ config.AssetInput = untrustedConfig_AssetInput;
291
+ }
292
+ return config;
293
+ }
294
+ function validateAdapterConfig$2(untrustedConfig, configPropertyNames) {
295
+ if (!untrustedIsObject(untrustedConfig)) {
296
+ return null;
297
+ }
298
+ if (process.env.NODE_ENV !== 'production') {
299
+ validateConfig(untrustedConfig, configPropertyNames);
300
+ }
301
+ const config = typeCheckConfig$2(untrustedConfig);
302
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
303
+ return null;
304
+ }
305
+ return config;
306
+ }
307
+ function buildNetworkSnapshot$2(luvio, config, options) {
308
+ const resourceParams = createResourceParams$2(config);
309
+ const request = createResourceRequest$2(resourceParams);
310
+ return luvio.dispatchResourceRequest(request, options)
311
+ .then((response) => {
312
+ return luvio.handleSuccessResponse(() => {
313
+ const snapshot = ingestSuccess$2(luvio, resourceParams, response);
314
+ return luvio.storeBroadcast().then(() => snapshot);
315
+ }, () => getResponseCacheKeys$2(luvio, resourceParams, response.body));
316
+ }, (response) => {
317
+ deepFreeze(response);
318
+ throw response;
319
+ });
320
+ }
321
+ const createAssetAdapterFactory = (luvio) => {
322
+ return function createAsset(untrustedConfig) {
323
+ const config = validateAdapterConfig$2(untrustedConfig, createAsset_ConfigPropertyNames);
324
+ // Invalid or incomplete config
325
+ if (config === null) {
326
+ throw new Error('Invalid config for "createAsset"');
327
+ }
328
+ return buildNetworkSnapshot$2(luvio, config);
329
+ };
330
+ };
331
+
332
+ const VERSION$2 = "6940195c96726bc70b9ad00de7d9c58a";
333
+ function validate$2(obj, path = 'StarterTemplateRepresentation') {
334
+ const v_error = (() => {
335
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
336
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
337
+ }
338
+ const obj_description = obj.description;
339
+ const path_description = path + '.description';
340
+ if (typeof obj_description !== 'string') {
341
+ return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
342
+ }
343
+ const obj_id = obj.id;
344
+ const path_id = path + '.id';
345
+ if (typeof obj_id !== 'string') {
346
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
347
+ }
348
+ const obj_name = obj.name;
349
+ const path_name = path + '.name';
350
+ if (typeof obj_name !== 'string') {
351
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
352
+ }
353
+ const obj_thumbnailUrl = obj.thumbnailUrl;
354
+ const path_thumbnailUrl = path + '.thumbnailUrl';
355
+ if (typeof obj_thumbnailUrl !== 'string') {
356
+ return new TypeError('Expected "string" but received "' + typeof obj_thumbnailUrl + '" (at "' + path_thumbnailUrl + '")');
357
+ }
358
+ })();
359
+ return v_error === undefined ? null : v_error;
360
+ }
361
+ const select$4 = function StarterTemplateRepresentationSelect() {
362
+ return {
363
+ kind: 'Fragment',
364
+ version: VERSION$2,
365
+ private: [],
366
+ selections: [
367
+ {
368
+ name: 'description',
369
+ kind: 'Scalar'
370
+ },
371
+ {
372
+ name: 'id',
373
+ kind: 'Scalar'
374
+ },
375
+ {
376
+ name: 'name',
377
+ kind: 'Scalar'
378
+ },
379
+ {
380
+ name: 'thumbnailUrl',
381
+ kind: 'Scalar'
382
+ }
383
+ ]
384
+ };
385
+ };
386
+ function equals$2(existing, incoming) {
387
+ const existing_description = existing.description;
388
+ const incoming_description = incoming.description;
389
+ if (!(existing_description === incoming_description)) {
390
+ return false;
391
+ }
392
+ const existing_id = existing.id;
393
+ const incoming_id = incoming.id;
394
+ if (!(existing_id === incoming_id)) {
395
+ return false;
396
+ }
397
+ const existing_name = existing.name;
398
+ const incoming_name = incoming.name;
399
+ if (!(existing_name === incoming_name)) {
400
+ return false;
401
+ }
402
+ const existing_thumbnailUrl = existing.thumbnailUrl;
403
+ const incoming_thumbnailUrl = incoming.thumbnailUrl;
404
+ if (!(existing_thumbnailUrl === incoming_thumbnailUrl)) {
405
+ return false;
406
+ }
407
+ return true;
408
+ }
409
+
410
+ const TTL$1 = 3000;
411
+ const VERSION$1 = "8b256fe58f3a26927a96dc6c87f2845e";
412
+ function validate$1(obj, path = 'StarterTemplateListRepresentation') {
413
+ const v_error = (() => {
414
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
415
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
416
+ }
417
+ const obj_starterTemplateList = obj.starterTemplateList;
418
+ const path_starterTemplateList = path + '.starterTemplateList';
419
+ if (!ArrayIsArray(obj_starterTemplateList)) {
420
+ return new TypeError('Expected "array" but received "' + typeof obj_starterTemplateList + '" (at "' + path_starterTemplateList + '")');
421
+ }
422
+ for (let i = 0; i < obj_starterTemplateList.length; i++) {
423
+ const obj_starterTemplateList_item = obj_starterTemplateList[i];
424
+ const path_starterTemplateList_item = path_starterTemplateList + '[' + i + ']';
425
+ const referencepath_starterTemplateList_itemValidationError = validate$2(obj_starterTemplateList_item, path_starterTemplateList_item);
426
+ if (referencepath_starterTemplateList_itemValidationError !== null) {
427
+ let message = 'Object doesn\'t match StarterTemplateRepresentation (at "' + path_starterTemplateList_item + '")\n';
428
+ message += referencepath_starterTemplateList_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
429
+ return new TypeError(message);
430
+ }
431
+ }
432
+ })();
433
+ return v_error === undefined ? null : v_error;
434
+ }
435
+ const RepresentationType$1 = 'StarterTemplateListRepresentation';
436
+ function normalize$1(input, existing, path, luvio, store, timestamp) {
437
+ return input;
438
+ }
439
+ const select$3 = function StarterTemplateListRepresentationSelect() {
440
+ const { selections: StarterTemplateRepresentation__selections, opaque: StarterTemplateRepresentation__opaque, } = select$4();
441
+ return {
442
+ kind: 'Fragment',
443
+ version: VERSION$1,
444
+ private: [],
445
+ selections: [
446
+ {
447
+ name: 'starterTemplateList',
448
+ kind: 'Object',
449
+ plural: true,
450
+ selections: StarterTemplateRepresentation__selections
451
+ }
452
+ ]
453
+ };
454
+ };
455
+ function equals$1(existing, incoming) {
456
+ const existing_starterTemplateList = existing.starterTemplateList;
457
+ const incoming_starterTemplateList = incoming.starterTemplateList;
458
+ const equals_starterTemplateList_items = equalsArray(existing_starterTemplateList, incoming_starterTemplateList, (existing_starterTemplateList_item, incoming_starterTemplateList_item) => {
459
+ if (!(equals$2(existing_starterTemplateList_item, incoming_starterTemplateList_item))) {
460
+ return false;
461
+ }
462
+ });
463
+ if (equals_starterTemplateList_items === false) {
464
+ return false;
465
+ }
466
+ return true;
467
+ }
468
+ const ingest$1 = function StarterTemplateListRepresentationIngest(input, path, luvio, store, timestamp) {
469
+ if (process.env.NODE_ENV !== 'production') {
470
+ const validateError = validate$1(input);
471
+ if (validateError !== null) {
472
+ throw validateError;
473
+ }
474
+ }
475
+ const key = path.fullPath;
476
+ const existingRecord = store.readEntry(key);
477
+ const ttlToUse = TTL$1;
478
+ let incomingRecord = normalize$1(input, store.readEntry(key), {
479
+ fullPath: key,
480
+ parent: path.parent,
481
+ propertyName: path.propertyName,
482
+ ttl: ttlToUse
483
+ });
484
+ if (existingRecord === undefined || equals$1(existingRecord, incomingRecord) === false) {
485
+ luvio.storePublish(key, incomingRecord);
486
+ }
487
+ {
488
+ const storeMetadataParams = {
489
+ ttl: ttlToUse,
490
+ namespace: "assetcreation",
491
+ version: VERSION$1,
492
+ representationName: RepresentationType$1,
493
+ };
494
+ luvio.publishStoreMetadata(key, storeMetadataParams);
495
+ }
496
+ return createLink(key);
497
+ };
498
+ function getTypeCacheKeys$1(luvio, input, fullPathFactory) {
499
+ const rootKeySet = new engine.StoreKeyMap();
500
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
501
+ const rootKey = fullPathFactory();
502
+ rootKeySet.set(rootKey, {
503
+ namespace: keyPrefix,
504
+ representationName: RepresentationType$1,
505
+ mergeable: false
506
+ });
507
+ return rootKeySet;
508
+ }
509
+
510
+ function select$2(luvio, params) {
511
+ return select$3();
512
+ }
513
+ function keyBuilder$3(luvio, params) {
514
+ return keyPrefix + '::StarterTemplateListRepresentation:(' + 'filter:' + params.queryParams.filter + ',' + 'type:' + params.queryParams.type + ')';
515
+ }
516
+ function getResponseCacheKeys$1(luvio, resourceParams, response) {
517
+ return getTypeCacheKeys$1(luvio, response, () => keyBuilder$3(luvio, resourceParams));
518
+ }
519
+ function ingestSuccess$1(luvio, resourceParams, response, snapshotRefresh) {
520
+ const { body } = response;
521
+ const key = keyBuilder$3(luvio, resourceParams);
522
+ luvio.storeIngest(key, ingest$1, body);
523
+ const snapshot = luvio.storeLookup({
524
+ recordId: key,
525
+ node: select$2(),
526
+ variables: {},
527
+ }, snapshotRefresh);
528
+ if (process.env.NODE_ENV !== 'production') {
529
+ if (snapshot.state !== 'Fulfilled') {
530
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
531
+ }
532
+ }
533
+ return snapshot;
534
+ }
535
+ function ingestError$1(luvio, params, error, snapshotRefresh) {
536
+ const key = keyBuilder$3(luvio, params);
537
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
538
+ const storeMetadataParams = {
539
+ ttl: TTL$1,
540
+ namespace: keyPrefix,
541
+ version: VERSION$1,
542
+ representationName: RepresentationType$1
543
+ };
544
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
545
+ return errorSnapshot;
546
+ }
547
+ function createResourceRequest$1(config) {
548
+ const headers = {};
549
+ return {
550
+ baseUri: '/services/data/v58.0',
551
+ basePath: '/asset-creation/starter-templates',
552
+ method: 'get',
553
+ body: null,
554
+ urlParams: {},
555
+ queryParams: config.queryParams,
556
+ headers,
557
+ priority: 'normal',
558
+ };
559
+ }
560
+
561
+ const getStarterTemplates_ConfigPropertyNames = {
562
+ displayName: 'getStarterTemplates',
563
+ parameters: {
564
+ required: [],
565
+ optional: ['filter', 'type']
566
+ }
567
+ };
568
+ function createResourceParams$1(config) {
569
+ const resourceParams = {
570
+ queryParams: {
571
+ filter: config.filter, type: config.type
572
+ }
573
+ };
574
+ return resourceParams;
575
+ }
576
+ function keyBuilder$2(luvio, config) {
577
+ const resourceParams = createResourceParams$1(config);
578
+ return keyBuilder$3(luvio, resourceParams);
579
+ }
580
+ function typeCheckConfig$1(untrustedConfig) {
581
+ const config = {};
582
+ const untrustedConfig_filter = untrustedConfig.filter;
583
+ if (typeof untrustedConfig_filter === 'string') {
584
+ config.filter = untrustedConfig_filter;
585
+ }
586
+ const untrustedConfig_type = untrustedConfig.type;
587
+ if (typeof untrustedConfig_type === 'string') {
588
+ config.type = untrustedConfig_type;
589
+ }
590
+ return config;
591
+ }
592
+ function validateAdapterConfig$1(untrustedConfig, configPropertyNames) {
593
+ if (!untrustedIsObject(untrustedConfig)) {
594
+ return null;
595
+ }
596
+ if (process.env.NODE_ENV !== 'production') {
597
+ validateConfig(untrustedConfig, configPropertyNames);
598
+ }
599
+ const config = typeCheckConfig$1(untrustedConfig);
600
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
601
+ return null;
602
+ }
603
+ return config;
604
+ }
605
+ function adapterFragment$1(luvio, config) {
606
+ createResourceParams$1(config);
607
+ return select$2();
608
+ }
609
+ function onFetchResponseSuccess$1(luvio, config, resourceParams, response) {
610
+ const snapshot = ingestSuccess$1(luvio, resourceParams, response, {
611
+ config,
612
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
613
+ });
614
+ return luvio.storeBroadcast().then(() => snapshot);
615
+ }
616
+ function onFetchResponseError$1(luvio, config, resourceParams, response) {
617
+ const snapshot = ingestError$1(luvio, resourceParams, response, {
618
+ config,
619
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
620
+ });
621
+ return luvio.storeBroadcast().then(() => snapshot);
622
+ }
623
+ function buildNetworkSnapshot$1(luvio, config, options) {
624
+ const resourceParams = createResourceParams$1(config);
625
+ const request = createResourceRequest$1(resourceParams);
626
+ return luvio.dispatchResourceRequest(request, options)
627
+ .then((response) => {
628
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess$1(luvio, config, resourceParams, response), () => getResponseCacheKeys$1(luvio, resourceParams, response.body));
629
+ }, (response) => {
630
+ return luvio.handleErrorResponse(() => onFetchResponseError$1(luvio, config, resourceParams, response));
631
+ });
632
+ }
633
+ function buildNetworkSnapshotCachePolicy$1(context, coercedAdapterRequestContext) {
634
+ const { luvio, config } = context;
635
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
636
+ const dispatchOptions = {
637
+ resourceRequestContext: {
638
+ requestCorrelator,
639
+ luvioRequestMethod: undefined,
640
+ },
641
+ eventObservers
642
+ };
643
+ if (networkPriority !== 'normal') {
644
+ dispatchOptions.overrides = {
645
+ priority: networkPriority
646
+ };
647
+ }
648
+ return buildNetworkSnapshot$1(luvio, config, dispatchOptions);
649
+ }
650
+ function buildCachedSnapshotCachePolicy$1(context, storeLookup) {
651
+ const { luvio, config } = context;
652
+ const selector = {
653
+ recordId: keyBuilder$2(luvio, config),
654
+ node: adapterFragment$1(luvio, config),
655
+ variables: {},
656
+ };
657
+ const cacheSnapshot = storeLookup(selector, {
658
+ config,
659
+ resolve: () => buildNetworkSnapshot$1(luvio, config, snapshotRefreshOptions)
660
+ });
661
+ return cacheSnapshot;
662
+ }
663
+ const getStarterTemplatesAdapterFactory = (luvio) => function assetcreation__getStarterTemplates(untrustedConfig, requestContext) {
664
+ const config = validateAdapterConfig$1(untrustedConfig, getStarterTemplates_ConfigPropertyNames);
665
+ // Invalid or incomplete config
666
+ if (config === null) {
667
+ return null;
668
+ }
669
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
670
+ buildCachedSnapshotCachePolicy$1, buildNetworkSnapshotCachePolicy$1);
671
+ };
672
+
673
+ const TTL = 1000;
674
+ const VERSION = "260c6823e9865ac87e1cb3929e85646c";
675
+ function validate(obj, path = 'StarterTemplateDetailRepresentation') {
676
+ const v_error = (() => {
677
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
678
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
679
+ }
680
+ const obj_contentBuilderUrl = obj.contentBuilderUrl;
681
+ const path_contentBuilderUrl = path + '.contentBuilderUrl';
682
+ if (typeof obj_contentBuilderUrl !== 'string') {
683
+ return new TypeError('Expected "string" but received "' + typeof obj_contentBuilderUrl + '" (at "' + path_contentBuilderUrl + '")');
684
+ }
685
+ const obj_createdBy = obj.createdBy;
686
+ const path_createdBy = path + '.createdBy';
687
+ if (typeof obj_createdBy !== 'string') {
688
+ return new TypeError('Expected "string" but received "' + typeof obj_createdBy + '" (at "' + path_createdBy + '")');
689
+ }
690
+ const obj_createdOn = obj.createdOn;
691
+ const path_createdOn = path + '.createdOn';
692
+ if (typeof obj_createdOn !== 'string') {
693
+ return new TypeError('Expected "string" but received "' + typeof obj_createdOn + '" (at "' + path_createdOn + '")');
694
+ }
695
+ const obj_description = obj.description;
696
+ const path_description = path + '.description';
697
+ if (typeof obj_description !== 'string') {
698
+ return new TypeError('Expected "string" but received "' + typeof obj_description + '" (at "' + path_description + '")');
699
+ }
700
+ const obj_html = obj.html;
701
+ const path_html = path + '.html';
702
+ if (typeof obj_html !== 'string') {
703
+ return new TypeError('Expected "string" but received "' + typeof obj_html + '" (at "' + path_html + '")');
704
+ }
705
+ const obj_id = obj.id;
706
+ const path_id = path + '.id';
707
+ if (typeof obj_id !== 'string') {
708
+ return new TypeError('Expected "string" but received "' + typeof obj_id + '" (at "' + path_id + '")');
709
+ }
710
+ const obj_name = obj.name;
711
+ const path_name = path + '.name';
712
+ if (typeof obj_name !== 'string') {
713
+ return new TypeError('Expected "string" but received "' + typeof obj_name + '" (at "' + path_name + '")');
714
+ }
715
+ })();
716
+ return v_error === undefined ? null : v_error;
717
+ }
718
+ const RepresentationType = 'StarterTemplateDetailRepresentation';
719
+ function normalize(input, existing, path, luvio, store, timestamp) {
720
+ return input;
721
+ }
722
+ const select$1 = function StarterTemplateDetailRepresentationSelect() {
723
+ return {
724
+ kind: 'Fragment',
725
+ version: VERSION,
726
+ private: [],
727
+ selections: [
728
+ {
729
+ name: 'contentBuilderUrl',
730
+ kind: 'Scalar'
731
+ },
732
+ {
733
+ name: 'createdBy',
734
+ kind: 'Scalar'
735
+ },
736
+ {
737
+ name: 'createdOn',
738
+ kind: 'Scalar'
739
+ },
740
+ {
741
+ name: 'description',
742
+ kind: 'Scalar'
743
+ },
744
+ {
745
+ name: 'html',
746
+ kind: 'Scalar'
747
+ },
748
+ {
749
+ name: 'id',
750
+ kind: 'Scalar'
751
+ },
752
+ {
753
+ name: 'name',
754
+ kind: 'Scalar'
755
+ }
756
+ ]
757
+ };
758
+ };
759
+ function equals(existing, incoming) {
760
+ const existing_contentBuilderUrl = existing.contentBuilderUrl;
761
+ const incoming_contentBuilderUrl = incoming.contentBuilderUrl;
762
+ if (!(existing_contentBuilderUrl === incoming_contentBuilderUrl)) {
763
+ return false;
764
+ }
765
+ const existing_createdBy = existing.createdBy;
766
+ const incoming_createdBy = incoming.createdBy;
767
+ if (!(existing_createdBy === incoming_createdBy)) {
768
+ return false;
769
+ }
770
+ const existing_createdOn = existing.createdOn;
771
+ const incoming_createdOn = incoming.createdOn;
772
+ if (!(existing_createdOn === incoming_createdOn)) {
773
+ return false;
774
+ }
775
+ const existing_description = existing.description;
776
+ const incoming_description = incoming.description;
777
+ if (!(existing_description === incoming_description)) {
778
+ return false;
779
+ }
780
+ const existing_html = existing.html;
781
+ const incoming_html = incoming.html;
782
+ if (!(existing_html === incoming_html)) {
783
+ return false;
784
+ }
785
+ const existing_id = existing.id;
786
+ const incoming_id = incoming.id;
787
+ if (!(existing_id === incoming_id)) {
788
+ return false;
789
+ }
790
+ const existing_name = existing.name;
791
+ const incoming_name = incoming.name;
792
+ if (!(existing_name === incoming_name)) {
793
+ return false;
794
+ }
795
+ return true;
796
+ }
797
+ const ingest = function StarterTemplateDetailRepresentationIngest(input, path, luvio, store, timestamp) {
798
+ if (process.env.NODE_ENV !== 'production') {
799
+ const validateError = validate(input);
800
+ if (validateError !== null) {
801
+ throw validateError;
802
+ }
803
+ }
804
+ const key = path.fullPath;
805
+ const existingRecord = store.readEntry(key);
806
+ const ttlToUse = TTL;
807
+ let incomingRecord = normalize(input, store.readEntry(key), {
808
+ fullPath: key,
809
+ parent: path.parent,
810
+ propertyName: path.propertyName,
811
+ ttl: ttlToUse
812
+ });
813
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
814
+ luvio.storePublish(key, incomingRecord);
815
+ }
816
+ {
817
+ const storeMetadataParams = {
818
+ ttl: ttlToUse,
819
+ namespace: "assetcreation",
820
+ version: VERSION,
821
+ representationName: RepresentationType,
822
+ };
823
+ luvio.publishStoreMetadata(key, storeMetadataParams);
824
+ }
825
+ return createLink(key);
826
+ };
827
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
828
+ const rootKeySet = new engine.StoreKeyMap();
829
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
830
+ const rootKey = fullPathFactory();
831
+ rootKeySet.set(rootKey, {
832
+ namespace: keyPrefix,
833
+ representationName: RepresentationType,
834
+ mergeable: false
835
+ });
836
+ return rootKeySet;
837
+ }
838
+
839
+ function select(luvio, params) {
840
+ return select$1();
841
+ }
842
+ function keyBuilder$1(luvio, params) {
843
+ return keyPrefix + '::StarterTemplateDetailRepresentation:(' + 'type:' + params.queryParams.type + ',' + 'starterTemplateId:' + params.urlParams.starterTemplateId + ')';
844
+ }
845
+ function getResponseCacheKeys(luvio, resourceParams, response) {
846
+ return getTypeCacheKeys(luvio, response, () => keyBuilder$1(luvio, resourceParams));
847
+ }
848
+ function ingestSuccess(luvio, resourceParams, response, snapshotRefresh) {
849
+ const { body } = response;
850
+ const key = keyBuilder$1(luvio, resourceParams);
851
+ luvio.storeIngest(key, ingest, body);
852
+ const snapshot = luvio.storeLookup({
853
+ recordId: key,
854
+ node: select(),
855
+ variables: {},
856
+ }, snapshotRefresh);
857
+ if (process.env.NODE_ENV !== 'production') {
858
+ if (snapshot.state !== 'Fulfilled') {
859
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
860
+ }
861
+ }
862
+ return snapshot;
863
+ }
864
+ function ingestError(luvio, params, error, snapshotRefresh) {
865
+ const key = keyBuilder$1(luvio, params);
866
+ const errorSnapshot = luvio.errorSnapshot(error, snapshotRefresh);
867
+ const storeMetadataParams = {
868
+ ttl: TTL,
869
+ namespace: keyPrefix,
870
+ version: VERSION,
871
+ representationName: RepresentationType
872
+ };
873
+ luvio.storeIngestError(key, errorSnapshot, storeMetadataParams);
874
+ return errorSnapshot;
875
+ }
876
+ function createResourceRequest(config) {
877
+ const headers = {};
878
+ return {
879
+ baseUri: '/services/data/v58.0',
880
+ basePath: '/asset-creation/starter-templates/' + config.urlParams.starterTemplateId + '',
881
+ method: 'get',
882
+ body: null,
883
+ urlParams: config.urlParams,
884
+ queryParams: config.queryParams,
885
+ headers,
886
+ priority: 'normal',
887
+ };
888
+ }
889
+
890
+ const getStarterTemplateById_ConfigPropertyNames = {
891
+ displayName: 'getStarterTemplateById',
892
+ parameters: {
893
+ required: ['starterTemplateId'],
894
+ optional: ['type']
895
+ }
896
+ };
897
+ function createResourceParams(config) {
898
+ const resourceParams = {
899
+ urlParams: {
900
+ starterTemplateId: config.starterTemplateId
901
+ },
902
+ queryParams: {
903
+ type: config.type
904
+ }
905
+ };
906
+ return resourceParams;
907
+ }
908
+ function keyBuilder(luvio, config) {
909
+ const resourceParams = createResourceParams(config);
910
+ return keyBuilder$1(luvio, resourceParams);
911
+ }
912
+ function typeCheckConfig(untrustedConfig) {
913
+ const config = {};
914
+ const untrustedConfig_starterTemplateId = untrustedConfig.starterTemplateId;
915
+ if (typeof untrustedConfig_starterTemplateId === 'string') {
916
+ config.starterTemplateId = untrustedConfig_starterTemplateId;
917
+ }
918
+ const untrustedConfig_type = untrustedConfig.type;
919
+ if (typeof untrustedConfig_type === 'string') {
920
+ config.type = untrustedConfig_type;
921
+ }
922
+ return config;
923
+ }
924
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
925
+ if (!untrustedIsObject(untrustedConfig)) {
926
+ return null;
927
+ }
928
+ if (process.env.NODE_ENV !== 'production') {
929
+ validateConfig(untrustedConfig, configPropertyNames);
930
+ }
931
+ const config = typeCheckConfig(untrustedConfig);
932
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
933
+ return null;
934
+ }
935
+ return config;
936
+ }
937
+ function adapterFragment(luvio, config) {
938
+ createResourceParams(config);
939
+ return select();
940
+ }
941
+ function onFetchResponseSuccess(luvio, config, resourceParams, response) {
942
+ const snapshot = ingestSuccess(luvio, resourceParams, response, {
943
+ config,
944
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
945
+ });
946
+ return luvio.storeBroadcast().then(() => snapshot);
947
+ }
948
+ function onFetchResponseError(luvio, config, resourceParams, response) {
949
+ const snapshot = ingestError(luvio, resourceParams, response, {
950
+ config,
951
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
952
+ });
953
+ return luvio.storeBroadcast().then(() => snapshot);
954
+ }
955
+ function buildNetworkSnapshot(luvio, config, options) {
956
+ const resourceParams = createResourceParams(config);
957
+ const request = createResourceRequest(resourceParams);
958
+ return luvio.dispatchResourceRequest(request, options)
959
+ .then((response) => {
960
+ return luvio.handleSuccessResponse(() => onFetchResponseSuccess(luvio, config, resourceParams, response), () => getResponseCacheKeys(luvio, resourceParams, response.body));
961
+ }, (response) => {
962
+ return luvio.handleErrorResponse(() => onFetchResponseError(luvio, config, resourceParams, response));
963
+ });
964
+ }
965
+ function buildNetworkSnapshotCachePolicy(context, coercedAdapterRequestContext) {
966
+ const { luvio, config } = context;
967
+ const { networkPriority, requestCorrelator, eventObservers } = coercedAdapterRequestContext;
968
+ const dispatchOptions = {
969
+ resourceRequestContext: {
970
+ requestCorrelator,
971
+ luvioRequestMethod: undefined,
972
+ },
973
+ eventObservers
974
+ };
975
+ if (networkPriority !== 'normal') {
976
+ dispatchOptions.overrides = {
977
+ priority: networkPriority
978
+ };
979
+ }
980
+ return buildNetworkSnapshot(luvio, config, dispatchOptions);
981
+ }
982
+ function buildCachedSnapshotCachePolicy(context, storeLookup) {
983
+ const { luvio, config } = context;
984
+ const selector = {
985
+ recordId: keyBuilder(luvio, config),
986
+ node: adapterFragment(luvio, config),
987
+ variables: {},
988
+ };
989
+ const cacheSnapshot = storeLookup(selector, {
990
+ config,
991
+ resolve: () => buildNetworkSnapshot(luvio, config, snapshotRefreshOptions)
992
+ });
993
+ return cacheSnapshot;
994
+ }
995
+ const getStarterTemplateByIdAdapterFactory = (luvio) => function assetcreation__getStarterTemplateById(untrustedConfig, requestContext) {
996
+ const config = validateAdapterConfig(untrustedConfig, getStarterTemplateById_ConfigPropertyNames);
997
+ // Invalid or incomplete config
998
+ if (config === null) {
999
+ return null;
1000
+ }
1001
+ return luvio.applyCachePolicy((requestContext || {}), { config, luvio }, // BuildSnapshotContext
1002
+ buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy);
1003
+ };
1004
+
1005
+ exports.createAssetAdapterFactory = createAssetAdapterFactory;
1006
+ exports.getStarterTemplateByIdAdapterFactory = getStarterTemplateByIdAdapterFactory;
1007
+ exports.getStarterTemplatesAdapterFactory = getStarterTemplatesAdapterFactory;
1008
+
1009
+ Object.defineProperty(exports, '__esModule', { value: true });
1010
+
1011
+ }));