@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
|
@@ -6,305 +6,305 @@
|
|
|
6
6
|
|
|
7
7
|
import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
|
|
8
8
|
|
|
9
|
-
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
-
const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
|
|
11
|
-
const { isArray: ArrayIsArray$1 } = Array;
|
|
12
|
-
/**
|
|
13
|
-
* Validates an adapter config is well-formed.
|
|
14
|
-
* @param config The config to validate.
|
|
15
|
-
* @param adapter The adapter validation configuration.
|
|
16
|
-
* @param oneOf The keys the config must contain at least one of.
|
|
17
|
-
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
18
|
-
*/
|
|
19
|
-
function validateConfig(config, adapter, oneOf) {
|
|
20
|
-
const { displayName } = adapter;
|
|
21
|
-
const { required, optional, unsupported } = adapter.parameters;
|
|
22
|
-
if (config === undefined ||
|
|
23
|
-
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
24
|
-
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
25
|
-
}
|
|
26
|
-
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
27
|
-
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
28
|
-
}
|
|
29
|
-
if (unsupported !== undefined &&
|
|
30
|
-
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
31
|
-
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
32
|
-
}
|
|
33
|
-
const supported = required.concat(optional);
|
|
34
|
-
if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
|
|
35
|
-
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function untrustedIsObject(untrusted) {
|
|
39
|
-
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
40
|
-
}
|
|
41
|
-
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
42
|
-
return configPropertyNames.parameters.required.every(req => req in config);
|
|
43
|
-
}
|
|
9
|
+
const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
|
|
10
|
+
const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
|
|
11
|
+
const { isArray: ArrayIsArray$1 } = Array;
|
|
12
|
+
/**
|
|
13
|
+
* Validates an adapter config is well-formed.
|
|
14
|
+
* @param config The config to validate.
|
|
15
|
+
* @param adapter The adapter validation configuration.
|
|
16
|
+
* @param oneOf The keys the config must contain at least one of.
|
|
17
|
+
* @throws A TypeError if config doesn't satisfy the adapter's config validation.
|
|
18
|
+
*/
|
|
19
|
+
function validateConfig(config, adapter, oneOf) {
|
|
20
|
+
const { displayName } = adapter;
|
|
21
|
+
const { required, optional, unsupported } = adapter.parameters;
|
|
22
|
+
if (config === undefined ||
|
|
23
|
+
required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
24
|
+
throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
|
|
25
|
+
}
|
|
26
|
+
if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
|
|
27
|
+
throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
if (unsupported !== undefined &&
|
|
30
|
+
unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
|
|
31
|
+
throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
const supported = required.concat(optional);
|
|
34
|
+
if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
|
|
35
|
+
throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function untrustedIsObject(untrusted) {
|
|
39
|
+
return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
|
|
40
|
+
}
|
|
41
|
+
function areRequiredParametersPresent(config, configPropertyNames) {
|
|
42
|
+
return configPropertyNames.parameters.required.every(req => req in config);
|
|
43
|
+
}
|
|
44
44
|
const keyPrefix = 'microbatching';
|
|
45
45
|
|
|
46
|
-
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
47
|
-
const { isArray: ArrayIsArray } = Array;
|
|
48
|
-
function deepFreeze(value) {
|
|
49
|
-
// No need to freeze primitives
|
|
50
|
-
if (typeof value !== 'object' || value === null) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (ArrayIsArray(value)) {
|
|
54
|
-
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
55
|
-
deepFreeze(value[i]);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
const keys = ObjectKeys(value);
|
|
60
|
-
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
61
|
-
deepFreeze(value[keys[i]]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
ObjectFreeze(value);
|
|
65
|
-
}
|
|
66
|
-
function createLink(ref) {
|
|
67
|
-
return {
|
|
68
|
-
__ref: serializeStructuredKey(ref),
|
|
69
|
-
};
|
|
46
|
+
const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
|
|
47
|
+
const { isArray: ArrayIsArray } = Array;
|
|
48
|
+
function deepFreeze(value) {
|
|
49
|
+
// No need to freeze primitives
|
|
50
|
+
if (typeof value !== 'object' || value === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (ArrayIsArray(value)) {
|
|
54
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
55
|
+
deepFreeze(value[i]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const keys = ObjectKeys(value);
|
|
60
|
+
for (let i = 0, len = keys.length; i < len; i += 1) {
|
|
61
|
+
deepFreeze(value[keys[i]]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
ObjectFreeze(value);
|
|
65
|
+
}
|
|
66
|
+
function createLink(ref) {
|
|
67
|
+
return {
|
|
68
|
+
__ref: serializeStructuredKey(ref),
|
|
69
|
+
};
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function validate$1(obj, path = 'MicrobatchingIngestionInputRepresentation') {
|
|
73
|
-
const v_error = (() => {
|
|
74
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
75
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
76
|
-
}
|
|
77
|
-
if (obj.groupBy !== undefined) {
|
|
78
|
-
const obj_groupBy = obj.groupBy;
|
|
79
|
-
const path_groupBy = path + '.groupBy';
|
|
80
|
-
if (typeof obj_groupBy !== 'string') {
|
|
81
|
-
return new TypeError('Expected "string" but received "' + typeof obj_groupBy + '" (at "' + path_groupBy + '")');
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (obj.keyPrefix !== undefined) {
|
|
85
|
-
const obj_keyPrefix = obj.keyPrefix;
|
|
86
|
-
const path_keyPrefix = path + '.keyPrefix';
|
|
87
|
-
if (typeof obj_keyPrefix !== 'string') {
|
|
88
|
-
return new TypeError('Expected "string" but received "' + typeof obj_keyPrefix + '" (at "' + path_keyPrefix + '")');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const obj_processType = obj.processType;
|
|
92
|
-
const path_processType = path + '.processType';
|
|
93
|
-
if (typeof obj_processType !== 'string') {
|
|
94
|
-
return new TypeError('Expected "string" but received "' + typeof obj_processType + '" (at "' + path_processType + '")');
|
|
95
|
-
}
|
|
96
|
-
const obj_requestBody = obj.requestBody;
|
|
97
|
-
const path_requestBody = path + '.requestBody';
|
|
98
|
-
if (typeof obj_requestBody !== 'object' || ArrayIsArray(obj_requestBody) || obj_requestBody === null) {
|
|
99
|
-
return new TypeError('Expected "object" but received "' + typeof obj_requestBody + '" (at "' + path_requestBody + '")');
|
|
100
|
-
}
|
|
101
|
-
const obj_requestBody_keys = ObjectKeys(obj_requestBody);
|
|
102
|
-
for (let i = 0; i < obj_requestBody_keys.length; i++) {
|
|
103
|
-
const key = obj_requestBody_keys[i];
|
|
104
|
-
const obj_requestBody_prop = obj_requestBody[key];
|
|
105
|
-
const path_requestBody_prop = path_requestBody + '["' + key + '"]';
|
|
106
|
-
if (obj_requestBody_prop === undefined) {
|
|
107
|
-
return new TypeError('Expected "defined" but received "' + typeof obj_requestBody_prop + '" (at "' + path_requestBody_prop + '")');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
})();
|
|
111
|
-
return v_error === undefined ? null : v_error;
|
|
72
|
+
function validate$1(obj, path = 'MicrobatchingIngestionInputRepresentation') {
|
|
73
|
+
const v_error = (() => {
|
|
74
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
75
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
76
|
+
}
|
|
77
|
+
if (obj.groupBy !== undefined) {
|
|
78
|
+
const obj_groupBy = obj.groupBy;
|
|
79
|
+
const path_groupBy = path + '.groupBy';
|
|
80
|
+
if (typeof obj_groupBy !== 'string') {
|
|
81
|
+
return new TypeError('Expected "string" but received "' + typeof obj_groupBy + '" (at "' + path_groupBy + '")');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (obj.keyPrefix !== undefined) {
|
|
85
|
+
const obj_keyPrefix = obj.keyPrefix;
|
|
86
|
+
const path_keyPrefix = path + '.keyPrefix';
|
|
87
|
+
if (typeof obj_keyPrefix !== 'string') {
|
|
88
|
+
return new TypeError('Expected "string" but received "' + typeof obj_keyPrefix + '" (at "' + path_keyPrefix + '")');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const obj_processType = obj.processType;
|
|
92
|
+
const path_processType = path + '.processType';
|
|
93
|
+
if (typeof obj_processType !== 'string') {
|
|
94
|
+
return new TypeError('Expected "string" but received "' + typeof obj_processType + '" (at "' + path_processType + '")');
|
|
95
|
+
}
|
|
96
|
+
const obj_requestBody = obj.requestBody;
|
|
97
|
+
const path_requestBody = path + '.requestBody';
|
|
98
|
+
if (typeof obj_requestBody !== 'object' || ArrayIsArray(obj_requestBody) || obj_requestBody === null) {
|
|
99
|
+
return new TypeError('Expected "object" but received "' + typeof obj_requestBody + '" (at "' + path_requestBody + '")');
|
|
100
|
+
}
|
|
101
|
+
const obj_requestBody_keys = ObjectKeys(obj_requestBody);
|
|
102
|
+
for (let i = 0; i < obj_requestBody_keys.length; i++) {
|
|
103
|
+
const key = obj_requestBody_keys[i];
|
|
104
|
+
const obj_requestBody_prop = obj_requestBody[key];
|
|
105
|
+
const path_requestBody_prop = path_requestBody + '["' + key + '"]';
|
|
106
|
+
if (obj_requestBody_prop === undefined) {
|
|
107
|
+
return new TypeError('Expected "defined" but received "' + typeof obj_requestBody_prop + '" (at "' + path_requestBody_prop + '")');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
})();
|
|
111
|
+
return v_error === undefined ? null : v_error;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const TTL = 100;
|
|
115
|
-
const VERSION = "d9a668888b418883dcdd91e33b218549";
|
|
116
|
-
function validate(obj, path = 'MicrobatchingIngestionOutputRepresentation') {
|
|
117
|
-
const v_error = (() => {
|
|
118
|
-
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
119
|
-
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
120
|
-
}
|
|
121
|
-
const obj_recordUUID = obj.recordUUID;
|
|
122
|
-
const path_recordUUID = path + '.recordUUID';
|
|
123
|
-
if (typeof obj_recordUUID !== 'string') {
|
|
124
|
-
return new TypeError('Expected "string" but received "' + typeof obj_recordUUID + '" (at "' + path_recordUUID + '")');
|
|
125
|
-
}
|
|
126
|
-
})();
|
|
127
|
-
return v_error === undefined ? null : v_error;
|
|
128
|
-
}
|
|
129
|
-
const RepresentationType = 'MicrobatchingIngestionOutputRepresentation';
|
|
130
|
-
function keyBuilder(luvio, config) {
|
|
131
|
-
return keyPrefix + '::' + RepresentationType + ':' + config.recordUUID;
|
|
132
|
-
}
|
|
133
|
-
function keyBuilderFromType(luvio, object) {
|
|
134
|
-
const keyParams = {
|
|
135
|
-
recordUUID: object.recordUUID
|
|
136
|
-
};
|
|
137
|
-
return keyBuilder(luvio, keyParams);
|
|
138
|
-
}
|
|
139
|
-
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
140
|
-
return input;
|
|
141
|
-
}
|
|
142
|
-
const select$1 = function MicrobatchingIngestionOutputRepresentationSelect() {
|
|
143
|
-
return {
|
|
144
|
-
kind: 'Fragment',
|
|
145
|
-
version: VERSION,
|
|
146
|
-
private: [],
|
|
147
|
-
selections: [
|
|
148
|
-
{
|
|
149
|
-
name: 'recordUUID',
|
|
150
|
-
kind: 'Scalar'
|
|
151
|
-
}
|
|
152
|
-
]
|
|
153
|
-
};
|
|
154
|
-
};
|
|
155
|
-
function equals(existing, incoming) {
|
|
156
|
-
const existing_recordUUID = existing.recordUUID;
|
|
157
|
-
const incoming_recordUUID = incoming.recordUUID;
|
|
158
|
-
if (!(existing_recordUUID === incoming_recordUUID)) {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
const ingest = function MicrobatchingIngestionOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
164
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
165
|
-
const validateError = validate(input);
|
|
166
|
-
if (validateError !== null) {
|
|
167
|
-
throw validateError;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const key = keyBuilderFromType(luvio, input);
|
|
171
|
-
const existingRecord = store.readEntry(key);
|
|
172
|
-
const ttlToUse = TTL;
|
|
173
|
-
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
174
|
-
fullPath: key,
|
|
175
|
-
parent: path.parent,
|
|
176
|
-
propertyName: path.propertyName,
|
|
177
|
-
ttl: ttlToUse
|
|
178
|
-
});
|
|
179
|
-
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
180
|
-
luvio.storePublish(key, incomingRecord);
|
|
181
|
-
}
|
|
182
|
-
{
|
|
183
|
-
const storeMetadataParams = {
|
|
184
|
-
ttl: ttlToUse,
|
|
185
|
-
namespace: "microbatching",
|
|
186
|
-
version: VERSION,
|
|
187
|
-
representationName: RepresentationType,
|
|
188
|
-
};
|
|
189
|
-
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
190
|
-
}
|
|
191
|
-
return createLink(key);
|
|
192
|
-
};
|
|
193
|
-
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
194
|
-
const rootKeySet = new StoreKeyMap();
|
|
195
|
-
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
196
|
-
const rootKey = keyBuilderFromType(luvio, input);
|
|
197
|
-
rootKeySet.set(rootKey, {
|
|
198
|
-
namespace: keyPrefix,
|
|
199
|
-
representationName: RepresentationType,
|
|
200
|
-
mergeable: false
|
|
201
|
-
});
|
|
202
|
-
return rootKeySet;
|
|
114
|
+
const TTL = 100;
|
|
115
|
+
const VERSION = "d9a668888b418883dcdd91e33b218549";
|
|
116
|
+
function validate(obj, path = 'MicrobatchingIngestionOutputRepresentation') {
|
|
117
|
+
const v_error = (() => {
|
|
118
|
+
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
119
|
+
return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
|
|
120
|
+
}
|
|
121
|
+
const obj_recordUUID = obj.recordUUID;
|
|
122
|
+
const path_recordUUID = path + '.recordUUID';
|
|
123
|
+
if (typeof obj_recordUUID !== 'string') {
|
|
124
|
+
return new TypeError('Expected "string" but received "' + typeof obj_recordUUID + '" (at "' + path_recordUUID + '")');
|
|
125
|
+
}
|
|
126
|
+
})();
|
|
127
|
+
return v_error === undefined ? null : v_error;
|
|
128
|
+
}
|
|
129
|
+
const RepresentationType = 'MicrobatchingIngestionOutputRepresentation';
|
|
130
|
+
function keyBuilder(luvio, config) {
|
|
131
|
+
return keyPrefix + '::' + RepresentationType + ':' + config.recordUUID;
|
|
132
|
+
}
|
|
133
|
+
function keyBuilderFromType(luvio, object) {
|
|
134
|
+
const keyParams = {
|
|
135
|
+
recordUUID: object.recordUUID
|
|
136
|
+
};
|
|
137
|
+
return keyBuilder(luvio, keyParams);
|
|
138
|
+
}
|
|
139
|
+
function normalize(input, existing, path, luvio, store, timestamp) {
|
|
140
|
+
return input;
|
|
141
|
+
}
|
|
142
|
+
const select$1 = function MicrobatchingIngestionOutputRepresentationSelect() {
|
|
143
|
+
return {
|
|
144
|
+
kind: 'Fragment',
|
|
145
|
+
version: VERSION,
|
|
146
|
+
private: [],
|
|
147
|
+
selections: [
|
|
148
|
+
{
|
|
149
|
+
name: 'recordUUID',
|
|
150
|
+
kind: 'Scalar'
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
function equals(existing, incoming) {
|
|
156
|
+
const existing_recordUUID = existing.recordUUID;
|
|
157
|
+
const incoming_recordUUID = incoming.recordUUID;
|
|
158
|
+
if (!(existing_recordUUID === incoming_recordUUID)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
const ingest = function MicrobatchingIngestionOutputRepresentationIngest(input, path, luvio, store, timestamp) {
|
|
164
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
165
|
+
const validateError = validate(input);
|
|
166
|
+
if (validateError !== null) {
|
|
167
|
+
throw validateError;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const key = keyBuilderFromType(luvio, input);
|
|
171
|
+
const existingRecord = store.readEntry(key);
|
|
172
|
+
const ttlToUse = TTL;
|
|
173
|
+
let incomingRecord = normalize(input, store.readEntry(key), {
|
|
174
|
+
fullPath: key,
|
|
175
|
+
parent: path.parent,
|
|
176
|
+
propertyName: path.propertyName,
|
|
177
|
+
ttl: ttlToUse
|
|
178
|
+
});
|
|
179
|
+
if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
|
|
180
|
+
luvio.storePublish(key, incomingRecord);
|
|
181
|
+
}
|
|
182
|
+
{
|
|
183
|
+
const storeMetadataParams = {
|
|
184
|
+
ttl: ttlToUse,
|
|
185
|
+
namespace: "microbatching",
|
|
186
|
+
version: VERSION,
|
|
187
|
+
representationName: RepresentationType,
|
|
188
|
+
};
|
|
189
|
+
luvio.publishStoreMetadata(key, storeMetadataParams);
|
|
190
|
+
}
|
|
191
|
+
return createLink(key);
|
|
192
|
+
};
|
|
193
|
+
function getTypeCacheKeys(luvio, input, fullPathFactory) {
|
|
194
|
+
const rootKeySet = new StoreKeyMap();
|
|
195
|
+
// root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
|
|
196
|
+
const rootKey = keyBuilderFromType(luvio, input);
|
|
197
|
+
rootKeySet.set(rootKey, {
|
|
198
|
+
namespace: keyPrefix,
|
|
199
|
+
representationName: RepresentationType,
|
|
200
|
+
mergeable: false
|
|
201
|
+
});
|
|
202
|
+
return rootKeySet;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
-
function select(luvio, params) {
|
|
206
|
-
return select$1();
|
|
207
|
-
}
|
|
208
|
-
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
209
|
-
return getTypeCacheKeys(luvio, response);
|
|
210
|
-
}
|
|
211
|
-
function ingestSuccess(luvio, resourceParams, response) {
|
|
212
|
-
const { body } = response;
|
|
213
|
-
const key = keyBuilderFromType(luvio, body);
|
|
214
|
-
luvio.storeIngest(key, ingest, body);
|
|
215
|
-
const snapshot = luvio.storeLookup({
|
|
216
|
-
recordId: key,
|
|
217
|
-
node: select(),
|
|
218
|
-
variables: {},
|
|
219
|
-
});
|
|
220
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
221
|
-
if (snapshot.state !== 'Fulfilled') {
|
|
222
|
-
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
return snapshot;
|
|
226
|
-
}
|
|
227
|
-
function createResourceRequest(config) {
|
|
228
|
-
const headers = {};
|
|
229
|
-
return {
|
|
230
|
-
baseUri: '/services/data/v58.0',
|
|
231
|
-
basePath: '/connect/communities/' + config.urlParams.communityId + '/microbatching',
|
|
232
|
-
method: 'post',
|
|
233
|
-
body: config.body,
|
|
234
|
-
urlParams: config.urlParams,
|
|
235
|
-
queryParams: {},
|
|
236
|
-
headers,
|
|
237
|
-
priority: 'normal',
|
|
238
|
-
};
|
|
205
|
+
function select(luvio, params) {
|
|
206
|
+
return select$1();
|
|
207
|
+
}
|
|
208
|
+
function getResponseCacheKeys(luvio, resourceParams, response) {
|
|
209
|
+
return getTypeCacheKeys(luvio, response);
|
|
210
|
+
}
|
|
211
|
+
function ingestSuccess(luvio, resourceParams, response) {
|
|
212
|
+
const { body } = response;
|
|
213
|
+
const key = keyBuilderFromType(luvio, body);
|
|
214
|
+
luvio.storeIngest(key, ingest, body);
|
|
215
|
+
const snapshot = luvio.storeLookup({
|
|
216
|
+
recordId: key,
|
|
217
|
+
node: select(),
|
|
218
|
+
variables: {},
|
|
219
|
+
});
|
|
220
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
221
|
+
if (snapshot.state !== 'Fulfilled') {
|
|
222
|
+
throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return snapshot;
|
|
226
|
+
}
|
|
227
|
+
function createResourceRequest(config) {
|
|
228
|
+
const headers = {};
|
|
229
|
+
return {
|
|
230
|
+
baseUri: '/services/data/v58.0',
|
|
231
|
+
basePath: '/connect/communities/' + config.urlParams.communityId + '/microbatching',
|
|
232
|
+
method: 'post',
|
|
233
|
+
body: config.body,
|
|
234
|
+
urlParams: config.urlParams,
|
|
235
|
+
queryParams: {},
|
|
236
|
+
headers,
|
|
237
|
+
priority: 'normal',
|
|
238
|
+
};
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
const ingestRecord_ConfigPropertyNames = {
|
|
242
|
-
displayName: 'ingestRecord',
|
|
243
|
-
parameters: {
|
|
244
|
-
required: ['communityId', 'requestIngestionInput'],
|
|
245
|
-
optional: []
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
function createResourceParams(config) {
|
|
249
|
-
const resourceParams = {
|
|
250
|
-
urlParams: {
|
|
251
|
-
communityId: config.communityId
|
|
252
|
-
},
|
|
253
|
-
body: {
|
|
254
|
-
requestIngestionInput: config.requestIngestionInput
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
return resourceParams;
|
|
258
|
-
}
|
|
259
|
-
function typeCheckConfig(untrustedConfig) {
|
|
260
|
-
const config = {};
|
|
261
|
-
const untrustedConfig_communityId = untrustedConfig.communityId;
|
|
262
|
-
if (typeof untrustedConfig_communityId === 'string') {
|
|
263
|
-
config.communityId = untrustedConfig_communityId;
|
|
264
|
-
}
|
|
265
|
-
const untrustedConfig_requestIngestionInput = untrustedConfig.requestIngestionInput;
|
|
266
|
-
const referenceMicrobatchingIngestionInputRepresentationValidationError = validate$1(untrustedConfig_requestIngestionInput);
|
|
267
|
-
if (referenceMicrobatchingIngestionInputRepresentationValidationError === null) {
|
|
268
|
-
config.requestIngestionInput = untrustedConfig_requestIngestionInput;
|
|
269
|
-
}
|
|
270
|
-
return config;
|
|
271
|
-
}
|
|
272
|
-
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
273
|
-
if (!untrustedIsObject(untrustedConfig)) {
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
277
|
-
validateConfig(untrustedConfig, configPropertyNames);
|
|
278
|
-
}
|
|
279
|
-
const config = typeCheckConfig(untrustedConfig);
|
|
280
|
-
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
281
|
-
return null;
|
|
282
|
-
}
|
|
283
|
-
return config;
|
|
284
|
-
}
|
|
285
|
-
function buildNetworkSnapshot(luvio, config, options) {
|
|
286
|
-
const resourceParams = createResourceParams(config);
|
|
287
|
-
const request = createResourceRequest(resourceParams);
|
|
288
|
-
return luvio.dispatchResourceRequest(request, options)
|
|
289
|
-
.then((response) => {
|
|
290
|
-
return luvio.handleSuccessResponse(() => {
|
|
291
|
-
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
292
|
-
return luvio.storeBroadcast().then(() => snapshot);
|
|
293
|
-
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
294
|
-
}, (response) => {
|
|
295
|
-
deepFreeze(response);
|
|
296
|
-
throw response;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
const ingestRecordAdapterFactory = (luvio) => {
|
|
300
|
-
return function ingestRecord(untrustedConfig) {
|
|
301
|
-
const config = validateAdapterConfig(untrustedConfig, ingestRecord_ConfigPropertyNames);
|
|
302
|
-
// Invalid or incomplete config
|
|
303
|
-
if (config === null) {
|
|
304
|
-
throw new Error('Invalid config for "ingestRecord"');
|
|
305
|
-
}
|
|
306
|
-
return buildNetworkSnapshot(luvio, config);
|
|
307
|
-
};
|
|
241
|
+
const ingestRecord_ConfigPropertyNames = {
|
|
242
|
+
displayName: 'ingestRecord',
|
|
243
|
+
parameters: {
|
|
244
|
+
required: ['communityId', 'requestIngestionInput'],
|
|
245
|
+
optional: []
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
function createResourceParams(config) {
|
|
249
|
+
const resourceParams = {
|
|
250
|
+
urlParams: {
|
|
251
|
+
communityId: config.communityId
|
|
252
|
+
},
|
|
253
|
+
body: {
|
|
254
|
+
requestIngestionInput: config.requestIngestionInput
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
return resourceParams;
|
|
258
|
+
}
|
|
259
|
+
function typeCheckConfig(untrustedConfig) {
|
|
260
|
+
const config = {};
|
|
261
|
+
const untrustedConfig_communityId = untrustedConfig.communityId;
|
|
262
|
+
if (typeof untrustedConfig_communityId === 'string') {
|
|
263
|
+
config.communityId = untrustedConfig_communityId;
|
|
264
|
+
}
|
|
265
|
+
const untrustedConfig_requestIngestionInput = untrustedConfig.requestIngestionInput;
|
|
266
|
+
const referenceMicrobatchingIngestionInputRepresentationValidationError = validate$1(untrustedConfig_requestIngestionInput);
|
|
267
|
+
if (referenceMicrobatchingIngestionInputRepresentationValidationError === null) {
|
|
268
|
+
config.requestIngestionInput = untrustedConfig_requestIngestionInput;
|
|
269
|
+
}
|
|
270
|
+
return config;
|
|
271
|
+
}
|
|
272
|
+
function validateAdapterConfig(untrustedConfig, configPropertyNames) {
|
|
273
|
+
if (!untrustedIsObject(untrustedConfig)) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
277
|
+
validateConfig(untrustedConfig, configPropertyNames);
|
|
278
|
+
}
|
|
279
|
+
const config = typeCheckConfig(untrustedConfig);
|
|
280
|
+
if (!areRequiredParametersPresent(config, configPropertyNames)) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
return config;
|
|
284
|
+
}
|
|
285
|
+
function buildNetworkSnapshot(luvio, config, options) {
|
|
286
|
+
const resourceParams = createResourceParams(config);
|
|
287
|
+
const request = createResourceRequest(resourceParams);
|
|
288
|
+
return luvio.dispatchResourceRequest(request, options)
|
|
289
|
+
.then((response) => {
|
|
290
|
+
return luvio.handleSuccessResponse(() => {
|
|
291
|
+
const snapshot = ingestSuccess(luvio, resourceParams, response);
|
|
292
|
+
return luvio.storeBroadcast().then(() => snapshot);
|
|
293
|
+
}, () => getResponseCacheKeys(luvio, resourceParams, response.body));
|
|
294
|
+
}, (response) => {
|
|
295
|
+
deepFreeze(response);
|
|
296
|
+
throw response;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
const ingestRecordAdapterFactory = (luvio) => {
|
|
300
|
+
return function ingestRecord(untrustedConfig) {
|
|
301
|
+
const config = validateAdapterConfig(untrustedConfig, ingestRecord_ConfigPropertyNames);
|
|
302
|
+
// Invalid or incomplete config
|
|
303
|
+
if (config === null) {
|
|
304
|
+
throw new Error('Invalid config for "ingestRecord"');
|
|
305
|
+
}
|
|
306
|
+
return buildNetworkSnapshot(luvio, config);
|
|
307
|
+
};
|
|
308
308
|
};
|
|
309
309
|
|
|
310
310
|
export { ingestRecordAdapterFactory };
|