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