@salesforce/lds-adapters-community-microbatching 1.124.1 → 1.124.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/es2018/community-microbatching.js +289 -289
- package/dist/{types → es/es2018/types}/src/generated/adapters/adapter-utils.d.ts +66 -66
- package/dist/{types → es/es2018/types}/src/generated/adapters/ingestRecord.d.ts +16 -16
- package/dist/{types → es/es2018/types}/src/generated/artifacts/main.d.ts +1 -1
- package/dist/{types → es/es2018/types}/src/generated/artifacts/sfdc.d.ts +2 -2
- package/dist/{types → es/es2018/types}/src/generated/resources/postConnectCommunitiesMicrobatchingByCommunityId.d.ts +16 -16
- package/dist/{types → es/es2018/types}/src/generated/types/MicrobatchingIngestionInputRepresentation.d.ts +42 -42
- package/dist/{types → es/es2018/types}/src/generated/types/MicrobatchingIngestionInputWrapperRepresentation.d.ts +29 -29
- package/dist/{types → es/es2018/types}/src/generated/types/MicrobatchingIngestionOutputRepresentation.d.ts +39 -39
- package/dist/{types → es/es2018/types}/src/generated/types/MicrobatchingIngestionRequestBodyInputRepresentation.d.ts +33 -33
- package/dist/{types → es/es2018/types}/src/generated/types/type-utils.d.ts +39 -39
- package/package.json +5 -5
- package/sfdc/index.d.ts +1 -1
- package/sfdc/index.js +305 -305
- package/dist/umd/es2018/community-microbatching.js +0 -318
- package/dist/umd/es5/community-microbatching.js +0 -320
|
@@ -1,318 +0,0 @@
|
|
|
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.communityMicrobatching = {}, 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 keyPrefix = 'microbatching';
|
|
49
|
-
|
|
50
|
-
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
51
|
-
const { isArray: ArrayIsArray } = Array;
|
|
52
|
-
function deepFreeze(value) {
|
|
53
|
-
// No need to freeze primitives
|
|
54
|
-
if (typeof value !== 'object' || value === null) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (ArrayIsArray(value)) {
|
|
58
|
-
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
59
|
-
deepFreeze(value[i]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const keys = ObjectKeys(value);
|
|
64
|
-
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
65
|
-
deepFreeze(value[keys[i]]);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
ObjectFreeze(value);
|
|
69
|
-
}
|
|
70
|
-
function createLink(ref) {
|
|
71
|
-
return {
|
|
72
|
-
__ref: engine.serializeStructuredKey(ref),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function validate$1(obj, path = 'MicrobatchingIngestionInputRepresentation') {
|
|
77
|
-
const v_error = (() => {
|
|
78
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
79
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
80
|
-
}
|
|
81
|
-
if (obj.groupBy !== undefined) {
|
|
82
|
-
const obj_groupBy = obj.groupBy;
|
|
83
|
-
const path_groupBy = path + '.groupBy';
|
|
84
|
-
if (typeof obj_groupBy !== 'string') {
|
|
85
|
-
return new TypeError('Expected "string" but received "' + typeof obj_groupBy + '" (at "' + path_groupBy + '")');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
if (obj.keyPrefix !== undefined) {
|
|
89
|
-
const obj_keyPrefix = obj.keyPrefix;
|
|
90
|
-
const path_keyPrefix = path + '.keyPrefix';
|
|
91
|
-
if (typeof obj_keyPrefix !== 'string') {
|
|
92
|
-
return new TypeError('Expected "string" but received "' + typeof obj_keyPrefix + '" (at "' + path_keyPrefix + '")');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const obj_processType = obj.processType;
|
|
96
|
-
const path_processType = path + '.processType';
|
|
97
|
-
if (typeof obj_processType !== 'string') {
|
|
98
|
-
return new TypeError('Expected "string" but received "' + typeof obj_processType + '" (at "' + path_processType + '")');
|
|
99
|
-
}
|
|
100
|
-
const obj_requestBody = obj.requestBody;
|
|
101
|
-
const path_requestBody = path + '.requestBody';
|
|
102
|
-
if (typeof obj_requestBody !== 'object' || ArrayIsArray(obj_requestBody) || obj_requestBody === null) {
|
|
103
|
-
return new TypeError('Expected "object" but received "' + typeof obj_requestBody + '" (at "' + path_requestBody + '")');
|
|
104
|
-
}
|
|
105
|
-
const obj_requestBody_keys = ObjectKeys(obj_requestBody);
|
|
106
|
-
for (let i = 0; i < obj_requestBody_keys.length; i++) {
|
|
107
|
-
const key = obj_requestBody_keys[i];
|
|
108
|
-
const obj_requestBody_prop = obj_requestBody[key];
|
|
109
|
-
const path_requestBody_prop = path_requestBody + '["' + key + '"]';
|
|
110
|
-
if (obj_requestBody_prop === undefined) {
|
|
111
|
-
return new TypeError('Expected "defined" but received "' + typeof obj_requestBody_prop + '" (at "' + path_requestBody_prop + '")');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
})();
|
|
115
|
-
return v_error === undefined ? null : v_error;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const TTL = 100;
|
|
119
|
-
const VERSION = "d9a668888b418883dcdd91e33b218549";
|
|
120
|
-
function validate(obj, path = 'MicrobatchingIngestionOutputRepresentation') {
|
|
121
|
-
const v_error = (() => {
|
|
122
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
123
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
124
|
-
}
|
|
125
|
-
const obj_recordUUID = obj.recordUUID;
|
|
126
|
-
const path_recordUUID = path + '.recordUUID';
|
|
127
|
-
if (typeof obj_recordUUID !== 'string') {
|
|
128
|
-
return new TypeError('Expected "string" but received "' + typeof obj_recordUUID + '" (at "' + path_recordUUID + '")');
|
|
129
|
-
}
|
|
130
|
-
})();
|
|
131
|
-
return v_error === undefined ? null : v_error;
|
|
132
|
-
}
|
|
133
|
-
const RepresentationType = 'MicrobatchingIngestionOutputRepresentation';
|
|
134
|
-
function keyBuilder(luvio, config) {
|
|
135
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.recordUUID;
|
|
136
|
-
}
|
|
137
|
-
function keyBuilderFromType(luvio, object) {
|
|
138
|
-
const keyParams = {
|
|
139
|
-
recordUUID: object.recordUUID
|
|
140
|
-
};
|
|
141
|
-
return keyBuilder(luvio, keyParams);
|
|
142
|
-
}
|
|
143
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
144
|
-
return input;
|
|
145
|
-
}
|
|
146
|
-
const select$1 = function MicrobatchingIngestionOutputRepresentationSelect() {
|
|
147
|
-
return {
|
|
148
|
-
kind: 'Fragment',
|
|
149
|
-
version: VERSION,
|
|
150
|
-
private: [],
|
|
151
|
-
selections: [
|
|
152
|
-
{
|
|
153
|
-
name: 'recordUUID',
|
|
154
|
-
kind: 'Scalar'
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
function equals(existing, incoming) {
|
|
160
|
-
const existing_recordUUID = existing.recordUUID;
|
|
161
|
-
const incoming_recordUUID = incoming.recordUUID;
|
|
162
|
-
if (!(existing_recordUUID === incoming_recordUUID)) {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
const ingest = function MicrobatchingIngestionOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
168
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
169
|
-
const validateError = validate(input);
|
|
170
|
-
if (validateError !== null) {
|
|
171
|
-
throw validateError;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const key = keyBuilderFromType(luvio, input);
|
|
175
|
-
const existingRecord = store.readEntry(key);
|
|
176
|
-
const ttlToUse = TTL;
|
|
177
|
-
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
178
|
-
fullPath: key,
|
|
179
|
-
parent: path.parent,
|
|
180
|
-
propertyName: path.propertyName,
|
|
181
|
-
ttl: ttlToUse
|
|
182
|
-
});
|
|
183
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
184
|
-
luvio.storePublish(key, incomingRecord);
|
|
185
|
-
}
|
|
186
|
-
{
|
|
187
|
-
const storeMetadataParams = {
|
|
188
|
-
ttl: ttlToUse,
|
|
189
|
-
namespace: "microbatching",
|
|
190
|
-
version: VERSION,
|
|
191
|
-
representationName: RepresentationType,
|
|
192
|
-
};
|
|
193
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
194
|
-
}
|
|
195
|
-
return createLink(key);
|
|
196
|
-
};
|
|
197
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
198
|
-
const rootKeySet = new engine.StoreKeyMap();
|
|
199
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
200
|
-
const rootKey = keyBuilderFromType(luvio, input);
|
|
201
|
-
rootKeySet.set(rootKey, {
|
|
202
|
-
namespace: keyPrefix,
|
|
203
|
-
representationName: RepresentationType,
|
|
204
|
-
mergeable: false
|
|
205
|
-
});
|
|
206
|
-
return rootKeySet;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function select(luvio, params) {
|
|
210
|
-
return select$1();
|
|
211
|
-
}
|
|
212
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
213
|
-
return getTypeCacheKeys(luvio, response);
|
|
214
|
-
}
|
|
215
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
216
|
-
const { body } = response;
|
|
217
|
-
const key = keyBuilderFromType(luvio, body);
|
|
218
|
-
luvio.storeIngest(key, ingest, body);
|
|
219
|
-
const snapshot = luvio.storeLookup({
|
|
220
|
-
recordId: key,
|
|
221
|
-
node: select(),
|
|
222
|
-
variables: {},
|
|
223
|
-
});
|
|
224
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
225
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
226
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
return snapshot;
|
|
230
|
-
}
|
|
231
|
-
function createResourceRequest(config) {
|
|
232
|
-
const headers = {};
|
|
233
|
-
return {
|
|
234
|
-
baseUri: '/services/data/v58.0',
|
|
235
|
-
basePath: '/connect/communities/' + config.urlParams.communityId + '/microbatching',
|
|
236
|
-
method: 'post',
|
|
237
|
-
body: config.body,
|
|
238
|
-
urlParams: config.urlParams,
|
|
239
|
-
queryParams: {},
|
|
240
|
-
headers,
|
|
241
|
-
priority: 'normal',
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const ingestRecord_ConfigPropertyNames = {
|
|
246
|
-
displayName: 'ingestRecord',
|
|
247
|
-
parameters: {
|
|
248
|
-
required: ['communityId', 'requestIngestionInput'],
|
|
249
|
-
optional: []
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
function createResourceParams(config) {
|
|
253
|
-
const resourceParams = {
|
|
254
|
-
urlParams: {
|
|
255
|
-
communityId: config.communityId
|
|
256
|
-
},
|
|
257
|
-
body: {
|
|
258
|
-
requestIngestionInput: config.requestIngestionInput
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
return resourceParams;
|
|
262
|
-
}
|
|
263
|
-
function typeCheckConfig(untrustedConfig) {
|
|
264
|
-
const config = {};
|
|
265
|
-
const untrustedConfig_communityId = untrustedConfig.communityId;
|
|
266
|
-
if (typeof untrustedConfig_communityId === 'string') {
|
|
267
|
-
config.communityId = untrustedConfig_communityId;
|
|
268
|
-
}
|
|
269
|
-
const untrustedConfig_requestIngestionInput = untrustedConfig.requestIngestionInput;
|
|
270
|
-
const referenceMicrobatchingIngestionInputRepresentationValidationError = validate$1(untrustedConfig_requestIngestionInput);
|
|
271
|
-
if (referenceMicrobatchingIngestionInputRepresentationValidationError === null) {
|
|
272
|
-
config.requestIngestionInput = untrustedConfig_requestIngestionInput;
|
|
273
|
-
}
|
|
274
|
-
return config;
|
|
275
|
-
}
|
|
276
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
277
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
278
|
-
return null;
|
|
279
|
-
}
|
|
280
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
281
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
282
|
-
}
|
|
283
|
-
const config = typeCheckConfig(untrustedConfig);
|
|
284
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
return config;
|
|
288
|
-
}
|
|
289
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
290
|
-
const resourceParams = createResourceParams(config);
|
|
291
|
-
const request = createResourceRequest(resourceParams);
|
|
292
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
293
|
-
.then((response) => {
|
|
294
|
-
return luvio.handleSuccessResponse(() => {
|
|
295
|
-
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
296
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
297
|
-
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
298
|
-
}, (response) => {
|
|
299
|
-
deepFreeze(response);
|
|
300
|
-
throw response;
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
const ingestRecordAdapterFactory = (luvio) => {
|
|
304
|
-
return function ingestRecord(untrustedConfig) {
|
|
305
|
-
const config = validateAdapterConfig(untrustedConfig, ingestRecord_ConfigPropertyNames);
|
|
306
|
-
// Invalid or incomplete config
|
|
307
|
-
if (config === null) {
|
|
308
|
-
throw new Error('Invalid config for "ingestRecord"');
|
|
309
|
-
}
|
|
310
|
-
return buildNetworkSnapshot(luvio, config);
|
|
311
|
-
};
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
exports.ingestRecordAdapterFactory = ingestRecordAdapterFactory;
|
|
315
|
-
|
|
316
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
317
|
-
|
|
318
|
-
}));
|
|
@@ -1,320 +0,0 @@
|
|
|
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.communityMicrobatching = {}, 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 keyPrefix = 'microbatching';
|
|
49
|
-
|
|
50
|
-
var ObjectFreeze = Object.freeze, ObjectKeys = Object.keys;
|
|
51
|
-
var ArrayIsArray = Array.isArray;
|
|
52
|
-
function deepFreeze(value) {
|
|
53
|
-
// No need to freeze primitives
|
|
54
|
-
if (typeof value !== 'object' || value === null) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (ArrayIsArray(value)) {
|
|
58
|
-
for (var i = 0, len = value.length; i < len; i += 1) {
|
|
59
|
-
deepFreeze(value[i]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
var keys = ObjectKeys(value);
|
|
64
|
-
for (var i = 0, len = keys.length; i < len; i += 1) {
|
|
65
|
-
deepFreeze(value[keys[i]]);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
ObjectFreeze(value);
|
|
69
|
-
}
|
|
70
|
-
function createLink(ref) {
|
|
71
|
-
return {
|
|
72
|
-
__ref: engine.serializeStructuredKey(ref),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function validate$1(obj, path) {
|
|
77
|
-
if (path === void 0) { path = 'MicrobatchingIngestionInputRepresentation'; }
|
|
78
|
-
var v_error = (function () {
|
|
79
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
80
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
81
|
-
}
|
|
82
|
-
if (obj.groupBy !== undefined) {
|
|
83
|
-
var obj_groupBy = obj.groupBy;
|
|
84
|
-
var path_groupBy = path + '.groupBy';
|
|
85
|
-
if (typeof obj_groupBy !== 'string') {
|
|
86
|
-
return new TypeError('Expected "string" but received "' + typeof obj_groupBy + '" (at "' + path_groupBy + '")');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (obj.keyPrefix !== undefined) {
|
|
90
|
-
var obj_keyPrefix = obj.keyPrefix;
|
|
91
|
-
var path_keyPrefix = path + '.keyPrefix';
|
|
92
|
-
if (typeof obj_keyPrefix !== 'string') {
|
|
93
|
-
return new TypeError('Expected "string" but received "' + typeof obj_keyPrefix + '" (at "' + path_keyPrefix + '")');
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
var obj_processType = obj.processType;
|
|
97
|
-
var path_processType = path + '.processType';
|
|
98
|
-
if (typeof obj_processType !== 'string') {
|
|
99
|
-
return new TypeError('Expected "string" but received "' + typeof obj_processType + '" (at "' + path_processType + '")');
|
|
100
|
-
}
|
|
101
|
-
var obj_requestBody = obj.requestBody;
|
|
102
|
-
var path_requestBody = path + '.requestBody';
|
|
103
|
-
if (typeof obj_requestBody !== 'object' || ArrayIsArray(obj_requestBody) || obj_requestBody === null) {
|
|
104
|
-
return new TypeError('Expected "object" but received "' + typeof obj_requestBody + '" (at "' + path_requestBody + '")');
|
|
105
|
-
}
|
|
106
|
-
var obj_requestBody_keys = ObjectKeys(obj_requestBody);
|
|
107
|
-
for (var i = 0; i < obj_requestBody_keys.length; i++) {
|
|
108
|
-
var key = obj_requestBody_keys[i];
|
|
109
|
-
var obj_requestBody_prop = obj_requestBody[key];
|
|
110
|
-
var path_requestBody_prop = path_requestBody + '["' + key + '"]';
|
|
111
|
-
if (obj_requestBody_prop === undefined) {
|
|
112
|
-
return new TypeError('Expected "defined" but received "' + typeof obj_requestBody_prop + '" (at "' + path_requestBody_prop + '")');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
})();
|
|
116
|
-
return v_error === undefined ? null : v_error;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
var TTL = 100;
|
|
120
|
-
var VERSION = "d9a668888b418883dcdd91e33b218549";
|
|
121
|
-
function validate(obj, path) {
|
|
122
|
-
if (path === void 0) { path = 'MicrobatchingIngestionOutputRepresentation'; }
|
|
123
|
-
var v_error = (function () {
|
|
124
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
125
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
126
|
-
}
|
|
127
|
-
var obj_recordUUID = obj.recordUUID;
|
|
128
|
-
var path_recordUUID = path + '.recordUUID';
|
|
129
|
-
if (typeof obj_recordUUID !== 'string') {
|
|
130
|
-
return new TypeError('Expected "string" but received "' + typeof obj_recordUUID + '" (at "' + path_recordUUID + '")');
|
|
131
|
-
}
|
|
132
|
-
})();
|
|
133
|
-
return v_error === undefined ? null : v_error;
|
|
134
|
-
}
|
|
135
|
-
var RepresentationType = 'MicrobatchingIngestionOutputRepresentation';
|
|
136
|
-
function keyBuilder(luvio, config) {
|
|
137
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.recordUUID;
|
|
138
|
-
}
|
|
139
|
-
function keyBuilderFromType(luvio, object) {
|
|
140
|
-
var keyParams = {
|
|
141
|
-
recordUUID: object.recordUUID
|
|
142
|
-
};
|
|
143
|
-
return keyBuilder(luvio, keyParams);
|
|
144
|
-
}
|
|
145
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
146
|
-
return input;
|
|
147
|
-
}
|
|
148
|
-
var select$1 = function MicrobatchingIngestionOutputRepresentationSelect() {
|
|
149
|
-
return {
|
|
150
|
-
kind: 'Fragment',
|
|
151
|
-
version: VERSION,
|
|
152
|
-
private: [],
|
|
153
|
-
selections: [
|
|
154
|
-
{
|
|
155
|
-
name: 'recordUUID',
|
|
156
|
-
kind: 'Scalar'
|
|
157
|
-
}
|
|
158
|
-
]
|
|
159
|
-
};
|
|
160
|
-
};
|
|
161
|
-
function equals(existing, incoming) {
|
|
162
|
-
var existing_recordUUID = existing.recordUUID;
|
|
163
|
-
var incoming_recordUUID = incoming.recordUUID;
|
|
164
|
-
if (!(existing_recordUUID === incoming_recordUUID)) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
var ingest = function MicrobatchingIngestionOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
170
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
171
|
-
var validateError = validate(input);
|
|
172
|
-
if (validateError !== null) {
|
|
173
|
-
throw validateError;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
var key = keyBuilderFromType(luvio, input);
|
|
177
|
-
var existingRecord = store.readEntry(key);
|
|
178
|
-
var ttlToUse = TTL;
|
|
179
|
-
var incomingRecord = normalize(input, store.readEntry(key), {
|
|
180
|
-
fullPath: key,
|
|
181
|
-
parent: path.parent,
|
|
182
|
-
propertyName: path.propertyName,
|
|
183
|
-
ttl: ttlToUse
|
|
184
|
-
});
|
|
185
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
186
|
-
luvio.storePublish(key, incomingRecord);
|
|
187
|
-
}
|
|
188
|
-
{
|
|
189
|
-
var storeMetadataParams = {
|
|
190
|
-
ttl: ttlToUse,
|
|
191
|
-
namespace: "microbatching",
|
|
192
|
-
version: VERSION,
|
|
193
|
-
representationName: RepresentationType,
|
|
194
|
-
};
|
|
195
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
196
|
-
}
|
|
197
|
-
return createLink(key);
|
|
198
|
-
};
|
|
199
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
200
|
-
var rootKeySet = new engine.StoreKeyMap();
|
|
201
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
202
|
-
var rootKey = keyBuilderFromType(luvio, input);
|
|
203
|
-
rootKeySet.set(rootKey, {
|
|
204
|
-
namespace: keyPrefix,
|
|
205
|
-
representationName: RepresentationType,
|
|
206
|
-
mergeable: false
|
|
207
|
-
});
|
|
208
|
-
return rootKeySet;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function select(luvio, params) {
|
|
212
|
-
return select$1();
|
|
213
|
-
}
|
|
214
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
215
|
-
return getTypeCacheKeys(luvio, response);
|
|
216
|
-
}
|
|
217
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
218
|
-
var body = response.body;
|
|
219
|
-
var key = keyBuilderFromType(luvio, body);
|
|
220
|
-
luvio.storeIngest(key, ingest, body);
|
|
221
|
-
var snapshot = luvio.storeLookup({
|
|
222
|
-
recordId: key,
|
|
223
|
-
node: select(),
|
|
224
|
-
variables: {},
|
|
225
|
-
});
|
|
226
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
227
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
228
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return snapshot;
|
|
232
|
-
}
|
|
233
|
-
function createResourceRequest(config) {
|
|
234
|
-
var headers = {};
|
|
235
|
-
return {
|
|
236
|
-
baseUri: '/services/data/v58.0',
|
|
237
|
-
basePath: '/connect/communities/' + config.urlParams.communityId + '/microbatching',
|
|
238
|
-
method: 'post',
|
|
239
|
-
body: config.body,
|
|
240
|
-
urlParams: config.urlParams,
|
|
241
|
-
queryParams: {},
|
|
242
|
-
headers: headers,
|
|
243
|
-
priority: 'normal',
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
var ingestRecord_ConfigPropertyNames = {
|
|
248
|
-
displayName: 'ingestRecord',
|
|
249
|
-
parameters: {
|
|
250
|
-
required: ['communityId', 'requestIngestionInput'],
|
|
251
|
-
optional: []
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
function createResourceParams(config) {
|
|
255
|
-
var resourceParams = {
|
|
256
|
-
urlParams: {
|
|
257
|
-
communityId: config.communityId
|
|
258
|
-
},
|
|
259
|
-
body: {
|
|
260
|
-
requestIngestionInput: config.requestIngestionInput
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
return resourceParams;
|
|
264
|
-
}
|
|
265
|
-
function typeCheckConfig(untrustedConfig) {
|
|
266
|
-
var config = {};
|
|
267
|
-
var untrustedConfig_communityId = untrustedConfig.communityId;
|
|
268
|
-
if (typeof untrustedConfig_communityId === 'string') {
|
|
269
|
-
config.communityId = untrustedConfig_communityId;
|
|
270
|
-
}
|
|
271
|
-
var untrustedConfig_requestIngestionInput = untrustedConfig.requestIngestionInput;
|
|
272
|
-
var referenceMicrobatchingIngestionInputRepresentationValidationError = validate$1(untrustedConfig_requestIngestionInput);
|
|
273
|
-
if (referenceMicrobatchingIngestionInputRepresentationValidationError === null) {
|
|
274
|
-
config.requestIngestionInput = untrustedConfig_requestIngestionInput;
|
|
275
|
-
}
|
|
276
|
-
return config;
|
|
277
|
-
}
|
|
278
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
279
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
283
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
284
|
-
}
|
|
285
|
-
var config = typeCheckConfig(untrustedConfig);
|
|
286
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
return config;
|
|
290
|
-
}
|
|
291
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
292
|
-
var resourceParams = createResourceParams(config);
|
|
293
|
-
var request = createResourceRequest(resourceParams);
|
|
294
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
295
|
-
.then(function (response) {
|
|
296
|
-
return luvio.handleSuccessResponse(function () {
|
|
297
|
-
var snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
298
|
-
return luvio.storeBroadcast().then(function () { return snapshot; });
|
|
299
|
-
}, function () { return getResponseCacheKeys(luvio, resourceParams, response.body); });
|
|
300
|
-
}, function (response) {
|
|
301
|
-
deepFreeze(response);
|
|
302
|
-
throw response;
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
var ingestRecordAdapterFactory = function (luvio) {
|
|
306
|
-
return function ingestRecord(untrustedConfig) {
|
|
307
|
-
var config = validateAdapterConfig(untrustedConfig, ingestRecord_ConfigPropertyNames);
|
|
308
|
-
// Invalid or incomplete config
|
|
309
|
-
if (config === null) {
|
|
310
|
-
throw new Error('Invalid config for "ingestRecord"');
|
|
311
|
-
}
|
|
312
|
-
return buildNetworkSnapshot(luvio, config);
|
|
313
|
-
};
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
exports.ingestRecordAdapterFactory = ingestRecordAdapterFactory;
|
|
317
|
-
|
|
318
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
319
|
-
|
|
320
|
-
}));
|