@salesforce/lds-adapters-community-microbatching 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,82 @@
1
+ Terms of Use
2
+
3
+ Copyright 2022 Salesforce, Inc. All rights reserved.
4
+
5
+ These Terms of Use govern the download, installation, and/or use of this
6
+ software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
7
+ last updated on April 15, 2022, and constitute a legally binding
8
+ agreement between you and Salesforce. If you do not agree to these Terms of
9
+ Use, do not install or use the Software.
10
+
11
+ Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
12
+ copyright license to reproduce, prepare derivative works of, publicly
13
+ display, publicly perform, sublicense, and distribute the Software and
14
+ derivative works subject to these Terms. These Terms shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ Subject to the limited rights expressly granted hereunder, Salesforce
18
+ reserves all rights, title, and interest in and to all intellectual
19
+ property subsisting in the Software. No rights are granted to you hereunder
20
+ other than as expressly set forth herein. Users residing in countries on
21
+ the United States Office of Foreign Assets Control sanction list, or which
22
+ are otherwise subject to a US export embargo, may not use the Software.
23
+
24
+ Implementation of the Software may require development work, for which you
25
+ are responsible. The Software may contain bugs, errors and
26
+ incompatibilities and is made available on an AS IS basis without support,
27
+ updates, or service level commitments.
28
+
29
+ Salesforce reserves the right at any time to modify, suspend, or
30
+ discontinue, the Software (or any part thereof) with or without notice. You
31
+ agree that Salesforce shall not be liable to you or to any third party for
32
+ any modification, suspension, or discontinuance.
33
+
34
+ You agree to defend Salesforce against any claim, demand, suit or
35
+ proceeding made or brought against Salesforce by a third party arising out
36
+ of or accruing from (a) your use of the Software, and (b) any application
37
+ you develop with the Software that infringes any copyright, trademark,
38
+ trade secret, trade dress, patent, or other intellectual property right of
39
+ any person or defames any person or violates their rights of publicity or
40
+ privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
41
+ from any damages, attorney fees, and costs finally awarded against
42
+ Salesforce as a result of, or for any amounts paid by Salesforce under a
43
+ settlement approved by you in writing of, a Claim Against Salesforce,
44
+ provided Salesforce (x) promptly gives you written notice of the Claim
45
+ Against Salesforce, (y) gives you sole control of the defense and
46
+ settlement of the Claim Against Salesforce (except that you may not settle
47
+ any Claim Against Salesforce unless it unconditionally releases Salesforce
48
+ of all liability), and (z) gives you all reasonable assistance, at your
49
+ expense.
50
+
51
+ WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
52
+ SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
54
+ INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
55
+ PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
56
+ OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
57
+ CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
58
+ HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
59
+
60
+ These Terms of Use shall be governed exclusively by the internal laws of
61
+ the State of California, without regard to its conflicts of laws
62
+ rules. Each party hereby consents to the exclusive jurisdiction of the
63
+ state and federal courts located in San Francisco County, California to
64
+ adjudicate any dispute arising out of or relating to these Terms of Use and
65
+ the download, installation, and/or use of the Software. Except as expressly
66
+ stated herein, these Terms of Use constitute the entire agreement between
67
+ the parties, and supersede all prior and contemporaneous agreements,
68
+ proposals, or representations, written or oral, concerning their subject
69
+ matter. No modification, amendment, or waiver of any provision of these
70
+ Terms of Use shall be effective unless it is by an update to these Terms of
71
+ Use that Salesforce makes available, or is in writing and signed by the
72
+ party against whom the modification, amendment, or waiver is to be
73
+ asserted.
74
+
75
+ Data Privacy: Salesforce may collect, process, and store device,
76
+ system, and other information related to your use of the Software. This
77
+ information includes, but is not limited to, IP address, user metrics, and
78
+ other data ("Usage Data"). Salesforce may use Usage Data for analytics,
79
+ product development, and marketing purposes. You acknowledge that files
80
+ generated in conjunction with the Software may contain sensitive or
81
+ confidential data, and you are solely responsible for anonymizing and
82
+ protecting such data.
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ import { serializeStructuredKey, StoreKeyMap } from '@luvio/engine';
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
+ }
44
+ const keyPrefix = 'microbatching';
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
+ };
70
+ }
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;
112
+ }
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;
203
+ }
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
+ };
239
+ }
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
+ };
308
+ };
309
+
310
+ export { ingestRecordAdapterFactory };
@@ -0,0 +1,66 @@
1
+ import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot } from '@luvio/engine';
2
+ export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
3
+ declare const ObjectKeys: {
4
+ (o: object): string[];
5
+ (o: {}): string[];
6
+ }, ObjectFreeze: {
7
+ <T extends Function>(f: T): T;
8
+ <T_1 extends {
9
+ [idx: string]: object | U | null | undefined;
10
+ }, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>;
11
+ <T_2>(o: T_2): Readonly<T_2>;
12
+ }, ObjectCreate: {
13
+ (o: object | null): any;
14
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
15
+ };
16
+ export { ObjectFreeze, ObjectCreate, ObjectKeys };
17
+ export declare const ArrayIsArray: (arg: any) => arg is any[];
18
+ export declare const ArrayPrototypePush: (...items: any[]) => number;
19
+ export interface AdapterValidationConfig {
20
+ displayName: string;
21
+ parameters: {
22
+ required: string[];
23
+ optional: string[];
24
+ unsupported?: string[];
25
+ };
26
+ }
27
+ /**
28
+ * Validates an adapter config is well-formed.
29
+ * @param config The config to validate.
30
+ * @param adapter The adapter validation configuration.
31
+ * @param oneOf The keys the config must contain at least one of.
32
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
33
+ */
34
+ export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
35
+ export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
36
+ export type UncoercedConfiguration<Base, Options extends {
37
+ [key in keyof Base]?: any;
38
+ }> = {
39
+ [Key in keyof Base]?: Base[Key] | Options[Key];
40
+ };
41
+ export type Untrusted<Base> = Partial<Base>;
42
+ export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
43
+ export declare function refreshable<C, D, R>(adapter: $64$luvio_engine_Adapter<C, D>, resolve: (config: unknown) => Promise<$64$luvio_engine_Snapshot<R>>): $64$luvio_engine_Adapter<C, D>;
44
+ export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
45
+ export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
46
+ export declare const snapshotRefreshOptions: {
47
+ overrides: {
48
+ headers: {
49
+ 'Cache-Control': string;
50
+ };
51
+ };
52
+ };
53
+ /**
54
+ * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
55
+ * This is needed because insertion order for JSON.stringify(object) affects output:
56
+ * JSON.stringify({a: 1, b: 2})
57
+ * "{"a":1,"b":2}"
58
+ * JSON.stringify({b: 2, a: 1})
59
+ * "{"b":2,"a":1}"
60
+ * @param data Data to be JSON-stringified.
61
+ * @returns JSON.stringified value with consistent ordering of keys.
62
+ */
63
+ export declare function stableJSONStringify(node: any): string | undefined;
64
+ export declare function getFetchResponseStatusText(status: number): string;
65
+ export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
66
+ export declare const keyPrefix = "microbatching";
@@ -0,0 +1,16 @@
1
+ import { AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig, Untrusted as adapter$45$utils_Untrusted } from './adapter-utils';
2
+ import { MicrobatchingIngestionInputRepresentation as types_MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation } from '../types/MicrobatchingIngestionInputRepresentation';
3
+ import { ResourceRequestConfig as resources_postConnectCommunitiesMicrobatchingByCommunityId_ResourceRequestConfig } from '../resources/postConnectCommunitiesMicrobatchingByCommunityId';
4
+ import { Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
5
+ import { MicrobatchingIngestionOutputRepresentation as types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation } from '../types/MicrobatchingIngestionOutputRepresentation';
6
+ export declare const adapterName = "ingestRecord";
7
+ export declare const ingestRecord_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
8
+ export interface IngestRecordConfig {
9
+ communityId: string;
10
+ requestIngestionInput: types_MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation;
11
+ }
12
+ export declare function createResourceParams(config: IngestRecordConfig): resources_postConnectCommunitiesMicrobatchingByCommunityId_ResourceRequestConfig;
13
+ export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<IngestRecordConfig>): adapter$45$utils_Untrusted<IngestRecordConfig>;
14
+ export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): IngestRecordConfig | null;
15
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: IngestRecordConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation, any>>;
16
+ export declare const ingestRecordAdapterFactory: $64$luvio_engine_AdapterFactory<IngestRecordConfig, types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation>;
@@ -0,0 +1 @@
1
+ export { ingestRecordAdapterFactory } from '../adapters/ingestRecord';
@@ -0,0 +1,2 @@
1
+ declare let ingestRecord: any;
2
+ export { ingestRecord, };
@@ -0,0 +1,16 @@
1
+ import { MicrobatchingIngestionInputRepresentation as types_MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation } from '../types/MicrobatchingIngestionInputRepresentation';
2
+ import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, FetchResponse as $64$luvio_engine_FetchResponse, FulfilledSnapshot as $64$luvio_engine_FulfilledSnapshot, StaleSnapshot as $64$luvio_engine_StaleSnapshot, PendingSnapshot as $64$luvio_engine_PendingSnapshot, ResourceRequest as $64$luvio_engine_ResourceRequest } from '@luvio/engine';
3
+ import { MicrobatchingIngestionOutputRepresentation as types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation } from '../types/MicrobatchingIngestionOutputRepresentation';
4
+ export interface ResourceRequestConfig {
5
+ urlParams: {
6
+ communityId: string;
7
+ };
8
+ body: {
9
+ requestIngestionInput: types_MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation;
10
+ };
11
+ }
12
+ export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
13
+ export declare function getResponseCacheKeys(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation): $64$luvio_engine_DurableStoreKeyMetadataMap;
14
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_MicrobatchingIngestionOutputRepresentation_MicrobatchingIngestionOutputRepresentation, any>;
15
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
16
+ export default createResourceRequest;
@@ -0,0 +1,42 @@
1
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const VERSION = "d6460a3f3b539eaacae325efca70eb0e";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: MicrobatchingIngestionInputRepresentation, existing: MicrobatchingIngestionInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): MicrobatchingIngestionInputRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: MicrobatchingIngestionInputRepresentationNormalized, incoming: MicrobatchingIngestionInputRepresentationNormalized): boolean;
8
+ export declare function deepFreeze(input: MicrobatchingIngestionInputRepresentation): void;
9
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
10
+ export declare function getTypeCacheKeys(luvio: $64$luvio_engine_Luvio, input: MicrobatchingIngestionInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): $64$luvio_engine_DurableStoreKeyMetadataMap;
11
+ /**
12
+ * Microbatching Ingestion Input Representation
13
+ *
14
+ * Keys:
15
+ * (none)
16
+ */
17
+ export interface MicrobatchingIngestionInputRepresentationNormalized {
18
+ /** GroupBy */
19
+ groupBy?: string;
20
+ /** KeyPrefix */
21
+ keyPrefix?: string;
22
+ /** ProcessType */
23
+ processType: string;
24
+ /** RequestBody */
25
+ requestBody: {
26
+ [key: string]: unknown;
27
+ };
28
+ }
29
+ /**
30
+ * Microbatching Ingestion Input Representation
31
+ *
32
+ * Keys:
33
+ * (none)
34
+ */
35
+ export interface MicrobatchingIngestionInputRepresentation {
36
+ groupBy?: string;
37
+ keyPrefix?: string;
38
+ processType: string;
39
+ requestBody: {
40
+ [key: string]: unknown;
41
+ };
42
+ }
@@ -0,0 +1,29 @@
1
+ import { MicrobatchingIngestionInputRepresentation as MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation } from './MicrobatchingIngestionInputRepresentation';
2
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
3
+ export declare const VERSION = "9ee748701cf95cd53730e834dc12dafd";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export declare function normalize(input: MicrobatchingIngestionInputWrapperRepresentation, existing: MicrobatchingIngestionInputWrapperRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): MicrobatchingIngestionInputWrapperRepresentationNormalized;
7
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
8
+ export declare function equals(existing: MicrobatchingIngestionInputWrapperRepresentationNormalized, incoming: MicrobatchingIngestionInputWrapperRepresentationNormalized): boolean;
9
+ export declare function deepFreeze(input: MicrobatchingIngestionInputWrapperRepresentation): void;
10
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
11
+ export declare function getTypeCacheKeys(luvio: $64$luvio_engine_Luvio, input: MicrobatchingIngestionInputWrapperRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): $64$luvio_engine_DurableStoreKeyMetadataMap;
12
+ /**
13
+ * Wrapper Microbatching Ingestion Input Representation
14
+ *
15
+ * Keys:
16
+ * (none)
17
+ */
18
+ export interface MicrobatchingIngestionInputWrapperRepresentationNormalized {
19
+ requestIngestionInput: MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation;
20
+ }
21
+ /**
22
+ * Wrapper Microbatching Ingestion Input Representation
23
+ *
24
+ * Keys:
25
+ * (none)
26
+ */
27
+ export interface MicrobatchingIngestionInputWrapperRepresentation {
28
+ requestIngestionInput: MicrobatchingIngestionInputRepresentation_MicrobatchingIngestionInputRepresentation;
29
+ }
@@ -0,0 +1,39 @@
1
+ import { KeyMetadata as $64$luvio_engine_KeyMetadata, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, Luvio as $64$luvio_engine_Luvio, IngestPath as $64$luvio_engine_IngestPath, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const TTL = 100;
3
+ export declare const VERSION = "d9a668888b418883dcdd91e33b218549";
4
+ export declare function validate(obj: any, path?: string): TypeError | null;
5
+ export declare const RepresentationType: string;
6
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
7
+ recordUUID: string;
8
+ }
9
+ export type MicrobatchingIngestionOutputRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
10
+ export type PartialMicrobatchingIngestionOutputRepresentationNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
11
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
12
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): MicrobatchingIngestionOutputRepresentationNormalizedKeyMetadata;
13
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: MicrobatchingIngestionOutputRepresentation): string;
14
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: MicrobatchingIngestionOutputRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
15
+ export declare function normalize(input: MicrobatchingIngestionOutputRepresentation, existing: MicrobatchingIngestionOutputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): MicrobatchingIngestionOutputRepresentationNormalized;
16
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
17
+ export declare function equals(existing: MicrobatchingIngestionOutputRepresentationNormalized, incoming: MicrobatchingIngestionOutputRepresentationNormalized): boolean;
18
+ export declare function deepFreeze(input: MicrobatchingIngestionOutputRepresentation): void;
19
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
20
+ export declare function getTypeCacheKeys(luvio: $64$luvio_engine_Luvio, input: MicrobatchingIngestionOutputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): $64$luvio_engine_DurableStoreKeyMetadataMap;
21
+ /**
22
+ * Representation for microbatching buffering response
23
+ *
24
+ * Keys:
25
+ * recordUUID (string): recordUUID
26
+ */
27
+ export interface MicrobatchingIngestionOutputRepresentationNormalized {
28
+ /** UUID of the ingested record */
29
+ recordUUID: string;
30
+ }
31
+ /**
32
+ * Representation for microbatching buffering response
33
+ *
34
+ * Keys:
35
+ * recordUUID (string): recordUUID
36
+ */
37
+ export interface MicrobatchingIngestionOutputRepresentation {
38
+ recordUUID: string;
39
+ }
@@ -0,0 +1,33 @@
1
+ import { IngestPath as $64$luvio_engine_IngestPath, Luvio as $64$luvio_engine_Luvio, Store as $64$luvio_engine_Store, FragmentSelection as $64$luvio_engine_FragmentSelection, ResourceIngest as $64$luvio_engine_ResourceIngest, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
2
+ export declare const VERSION = "fff7567386d4c0f9e9c816c13d022a25";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: MicrobatchingIngestionRequestBodyInputRepresentation, existing: MicrobatchingIngestionRequestBodyInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): MicrobatchingIngestionRequestBodyInputRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: MicrobatchingIngestionRequestBodyInputRepresentationNormalized, incoming: MicrobatchingIngestionRequestBodyInputRepresentationNormalized): boolean;
8
+ export declare function deepFreeze(input: MicrobatchingIngestionRequestBodyInputRepresentation): void;
9
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
10
+ export declare function getTypeCacheKeys(luvio: $64$luvio_engine_Luvio, input: MicrobatchingIngestionRequestBodyInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): $64$luvio_engine_DurableStoreKeyMetadataMap;
11
+ /**
12
+ * Encapsulates request body payload
13
+ *
14
+ * Keys:
15
+ * (none)
16
+ */
17
+ export interface MicrobatchingIngestionRequestBodyInputRepresentationNormalized {
18
+ /** RequestBody */
19
+ requestBody: {
20
+ [key: string]: {};
21
+ };
22
+ }
23
+ /**
24
+ * Encapsulates request body payload
25
+ *
26
+ * Keys:
27
+ * (none)
28
+ */
29
+ export interface MicrobatchingIngestionRequestBodyInputRepresentation {
30
+ requestBody: {
31
+ [key: string]: {};
32
+ };
33
+ }
@@ -0,0 +1,39 @@
1
+ import { NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const ObjectFreeze: {
3
+ <T extends Function>(f: T): T;
4
+ <T_1 extends {
5
+ [idx: string]: object | U | null | undefined;
6
+ }, U extends string | number | bigint | boolean | symbol>(o: T_1): Readonly<T_1>;
7
+ <T_2>(o: T_2): Readonly<T_2>;
8
+ }, ObjectKeys: {
9
+ (o: object): string[];
10
+ (o: {}): string[];
11
+ }, ObjectCreate: {
12
+ (o: object | null): any;
13
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
14
+ }, ObjectAssign: {
15
+ <T extends {}, U>(target: T, source: U): T & U;
16
+ <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
17
+ <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
18
+ (target: object, ...sources: any[]): any;
19
+ };
20
+ export declare const ArrayIsArray: (arg: any) => arg is any[];
21
+ export declare const JSONStringify: {
22
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
23
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
24
+ };
25
+ type AllowedPrimitives = boolean | string | number | Date | null;
26
+ type Value<T> = T extends AllowedPrimitives ? T : RecursivePartial<T>;
27
+ export type RecursivePartial<T> = null | {
28
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<Value<U>> | null : Value<T[P]> | null;
29
+ };
30
+ export declare function equalsArray<U, V extends U[]>(a: V, b: V, equalsItem: (itemA: U, itemB: U) => boolean | void): boolean;
31
+ export declare function equalsObject<U, V extends {
32
+ [key: string]: U;
33
+ }>(a: V, b: V, equalsProp: (propA: U, propB: U) => boolean | void): boolean;
34
+ export declare function deepFreeze(value: any): void;
35
+ export declare function createLink(ref: string | $64$luvio_engine_NormalizedKeyMetadata): {
36
+ __ref: string;
37
+ };
38
+ export declare function assignMetadataLink(entry: any, metadataKey: string | $64$luvio_engine_NormalizedKeyMetadata): void;
39
+ export {};
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@salesforce/lds-adapters-community-microbatching",
3
+ "version": "0.131.0",
4
+ "license": "SEE LICENSE IN LICENSE.txt",
5
+ "description": "Microbatching requests",
6
+ "main": "dist/es/es2018/community-microbatching.js",
7
+ "module": "dist/es/es2018/community-microbatching.js",
8
+ "types": "dist/es/es2018/types/src/generated/artifacts/main.d.ts",
9
+ "files": [
10
+ "dist",
11
+ "sfdc",
12
+ "src/raml/*"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/es/es2018/community-microbatching.js",
17
+ "require": "./dist/es/es2018/community-microbatching.js",
18
+ "types": "./dist/es/es2018/types/src/generated/artifacts/main.d.ts"
19
+ },
20
+ "./sfdc": {
21
+ "import": "./sfdc/index.js",
22
+ "types": "./sfdc/index.d.ts",
23
+ "default": "./sfdc/index.js"
24
+ }
25
+ },
26
+ "contributors": [
27
+ "pmaliwat@salesforce.com"
28
+ ],
29
+ "scripts": {
30
+ "build": "yarn build:raml && yarn build:services && yarn build:karma",
31
+ "build:karma": "rollup --config rollup.config.karma.js",
32
+ "build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
33
+ "build:services": "rollup --config rollup.config.js",
34
+ "clean": "rm -rf dist sfdc src/generated karma/dist",
35
+ "release:core": "../../scripts/release/core.js --adapter=lds-adapters-community-microbatching",
36
+ "release:corejar": "yarn build && packages/core-build/scripts/core.js --adapter=lds-adapters-community-microbatching",
37
+ "start": "karma start",
38
+ "test": "karma start --single-run",
39
+ "test:compat": "karma start --single-run --compat"
40
+ },
41
+ "dependencies": {
42
+ "@salesforce/lds-bindings": "1.131.0-244.6"
43
+ },
44
+ "devDependencies": {
45
+ "@salesforce/lds-compiler-plugins": "1.131.0-244.6",
46
+ "@salesforce/lds-karma": "1.131.0-244.6"
47
+ },
48
+ "nx": {
49
+ "targets": {
50
+ "build": {
51
+ "outputs": [
52
+ "packages/lds-adapters-community-microbatching/dist",
53
+ "packages/lds-adapters-community-microbatching/karma/dist",
54
+ "packages/lds-adapters-community-microbatching/sfdc",
55
+ "packages/lds-adapters-community-microbatching/src/generated"
56
+ ]
57
+ }
58
+ }
59
+ },
60
+ "volta": {
61
+ "extends": "../../package.json"
62
+ }
63
+ }
@@ -0,0 +1 @@
1
+ export * from '../dist/es/es2018/types/src/generated/artifacts/sfdc';
package/sfdc/index.js ADDED
@@ -0,0 +1,337 @@
1
+ /**
2
+ * Copyright (c) 2022, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /* *******************************************************************************************
8
+ * ATTENTION!
9
+ * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
10
+ * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
11
+ * Any changes made to this file in p4 will be automatically overwritten.
12
+ * *******************************************************************************************
13
+ */
14
+ /* proxy-compat-disable */
15
+ import { withDefaultLuvio } from 'force/ldsEngine';
16
+ import { serializeStructuredKey, StoreKeyMap } from 'force/luvioEngine';
17
+
18
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
19
+ const { keys: ObjectKeys$1, freeze: ObjectFreeze$1, create: ObjectCreate$1 } = Object;
20
+ const { isArray: ArrayIsArray$1 } = Array;
21
+ /**
22
+ * Validates an adapter config is well-formed.
23
+ * @param config The config to validate.
24
+ * @param adapter The adapter validation configuration.
25
+ * @param oneOf The keys the config must contain at least one of.
26
+ * @throws A TypeError if config doesn't satisfy the adapter's config validation.
27
+ */
28
+ function validateConfig(config, adapter, oneOf) {
29
+ const { displayName } = adapter;
30
+ const { required, optional, unsupported } = adapter.parameters;
31
+ if (config === undefined ||
32
+ required.every(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
33
+ throw new TypeError(`adapter ${displayName} configuration must specify ${required.sort().join(', ')}`);
34
+ }
35
+ if (oneOf && oneOf.some(req => ObjectPrototypeHasOwnProperty.call(config, req)) === false) {
36
+ throw new TypeError(`adapter ${displayName} configuration must specify one of ${oneOf.sort().join(', ')}`);
37
+ }
38
+ if (unsupported !== undefined &&
39
+ unsupported.some(req => ObjectPrototypeHasOwnProperty.call(config, req))) {
40
+ throw new TypeError(`adapter ${displayName} does not yet support ${unsupported.sort().join(', ')}`);
41
+ }
42
+ const supported = required.concat(optional);
43
+ if (ObjectKeys$1(config).some(key => !supported.includes(key))) {
44
+ throw new TypeError(`adapter ${displayName} configuration supports only ${supported.sort().join(', ')}`);
45
+ }
46
+ }
47
+ function untrustedIsObject(untrusted) {
48
+ return typeof untrusted === 'object' && untrusted !== null && ArrayIsArray$1(untrusted) === false;
49
+ }
50
+ function areRequiredParametersPresent(config, configPropertyNames) {
51
+ return configPropertyNames.parameters.required.every(req => req in config);
52
+ }
53
+ const keyPrefix = 'microbatching';
54
+
55
+ const { freeze: ObjectFreeze, keys: ObjectKeys, create: ObjectCreate, assign: ObjectAssign } = Object;
56
+ const { isArray: ArrayIsArray } = Array;
57
+ function deepFreeze(value) {
58
+ // No need to freeze primitives
59
+ if (typeof value !== 'object' || value === null) {
60
+ return;
61
+ }
62
+ if (ArrayIsArray(value)) {
63
+ for (let i = 0, len = value.length; i < len; i += 1) {
64
+ deepFreeze(value[i]);
65
+ }
66
+ }
67
+ else {
68
+ const keys = ObjectKeys(value);
69
+ for (let i = 0, len = keys.length; i < len; i += 1) {
70
+ deepFreeze(value[keys[i]]);
71
+ }
72
+ }
73
+ ObjectFreeze(value);
74
+ }
75
+ function createLink(ref) {
76
+ return {
77
+ __ref: serializeStructuredKey(ref),
78
+ };
79
+ }
80
+
81
+ function validate$1(obj, path = 'MicrobatchingIngestionInputRepresentation') {
82
+ const v_error = (() => {
83
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
84
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
85
+ }
86
+ if (obj.groupBy !== undefined) {
87
+ const obj_groupBy = obj.groupBy;
88
+ const path_groupBy = path + '.groupBy';
89
+ if (typeof obj_groupBy !== 'string') {
90
+ return new TypeError('Expected "string" but received "' + typeof obj_groupBy + '" (at "' + path_groupBy + '")');
91
+ }
92
+ }
93
+ if (obj.keyPrefix !== undefined) {
94
+ const obj_keyPrefix = obj.keyPrefix;
95
+ const path_keyPrefix = path + '.keyPrefix';
96
+ if (typeof obj_keyPrefix !== 'string') {
97
+ return new TypeError('Expected "string" but received "' + typeof obj_keyPrefix + '" (at "' + path_keyPrefix + '")');
98
+ }
99
+ }
100
+ const obj_processType = obj.processType;
101
+ const path_processType = path + '.processType';
102
+ if (typeof obj_processType !== 'string') {
103
+ return new TypeError('Expected "string" but received "' + typeof obj_processType + '" (at "' + path_processType + '")');
104
+ }
105
+ const obj_requestBody = obj.requestBody;
106
+ const path_requestBody = path + '.requestBody';
107
+ if (typeof obj_requestBody !== 'object' || ArrayIsArray(obj_requestBody) || obj_requestBody === null) {
108
+ return new TypeError('Expected "object" but received "' + typeof obj_requestBody + '" (at "' + path_requestBody + '")');
109
+ }
110
+ const obj_requestBody_keys = ObjectKeys(obj_requestBody);
111
+ for (let i = 0; i < obj_requestBody_keys.length; i++) {
112
+ const key = obj_requestBody_keys[i];
113
+ const obj_requestBody_prop = obj_requestBody[key];
114
+ const path_requestBody_prop = path_requestBody + '["' + key + '"]';
115
+ if (obj_requestBody_prop === undefined) {
116
+ return new TypeError('Expected "defined" but received "' + typeof obj_requestBody_prop + '" (at "' + path_requestBody_prop + '")');
117
+ }
118
+ }
119
+ })();
120
+ return v_error === undefined ? null : v_error;
121
+ }
122
+
123
+ const TTL = 100;
124
+ const VERSION = "d9a668888b418883dcdd91e33b218549";
125
+ function validate(obj, path = 'MicrobatchingIngestionOutputRepresentation') {
126
+ const v_error = (() => {
127
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
128
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
129
+ }
130
+ const obj_recordUUID = obj.recordUUID;
131
+ const path_recordUUID = path + '.recordUUID';
132
+ if (typeof obj_recordUUID !== 'string') {
133
+ return new TypeError('Expected "string" but received "' + typeof obj_recordUUID + '" (at "' + path_recordUUID + '")');
134
+ }
135
+ })();
136
+ return v_error === undefined ? null : v_error;
137
+ }
138
+ const RepresentationType = 'MicrobatchingIngestionOutputRepresentation';
139
+ function keyBuilder(luvio, config) {
140
+ return keyPrefix + '::' + RepresentationType + ':' + config.recordUUID;
141
+ }
142
+ function keyBuilderFromType(luvio, object) {
143
+ const keyParams = {
144
+ recordUUID: object.recordUUID
145
+ };
146
+ return keyBuilder(luvio, keyParams);
147
+ }
148
+ function normalize(input, existing, path, luvio, store, timestamp) {
149
+ return input;
150
+ }
151
+ const select$1 = function MicrobatchingIngestionOutputRepresentationSelect() {
152
+ return {
153
+ kind: 'Fragment',
154
+ version: VERSION,
155
+ private: [],
156
+ selections: [
157
+ {
158
+ name: 'recordUUID',
159
+ kind: 'Scalar'
160
+ }
161
+ ]
162
+ };
163
+ };
164
+ function equals(existing, incoming) {
165
+ const existing_recordUUID = existing.recordUUID;
166
+ const incoming_recordUUID = incoming.recordUUID;
167
+ if (!(existing_recordUUID === incoming_recordUUID)) {
168
+ return false;
169
+ }
170
+ return true;
171
+ }
172
+ const ingest = function MicrobatchingIngestionOutputRepresentationIngest(input, path, luvio, store, timestamp) {
173
+ if (process.env.NODE_ENV !== 'production') {
174
+ const validateError = validate(input);
175
+ if (validateError !== null) {
176
+ throw validateError;
177
+ }
178
+ }
179
+ const key = keyBuilderFromType(luvio, input);
180
+ const existingRecord = store.readEntry(key);
181
+ const ttlToUse = TTL;
182
+ let incomingRecord = normalize(input, store.readEntry(key), {
183
+ fullPath: key,
184
+ parent: path.parent,
185
+ propertyName: path.propertyName,
186
+ ttl: ttlToUse
187
+ });
188
+ if (existingRecord === undefined || equals(existingRecord, incomingRecord) === false) {
189
+ luvio.storePublish(key, incomingRecord);
190
+ }
191
+ {
192
+ const storeMetadataParams = {
193
+ ttl: ttlToUse,
194
+ namespace: "microbatching",
195
+ version: VERSION,
196
+ representationName: RepresentationType,
197
+ };
198
+ luvio.publishStoreMetadata(key, storeMetadataParams);
199
+ }
200
+ return createLink(key);
201
+ };
202
+ function getTypeCacheKeys(luvio, input, fullPathFactory) {
203
+ const rootKeySet = new StoreKeyMap();
204
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
205
+ const rootKey = keyBuilderFromType(luvio, input);
206
+ rootKeySet.set(rootKey, {
207
+ namespace: keyPrefix,
208
+ representationName: RepresentationType,
209
+ mergeable: false
210
+ });
211
+ return rootKeySet;
212
+ }
213
+
214
+ function select(luvio, params) {
215
+ return select$1();
216
+ }
217
+ function getResponseCacheKeys(luvio, resourceParams, response) {
218
+ return getTypeCacheKeys(luvio, response);
219
+ }
220
+ function ingestSuccess(luvio, resourceParams, response) {
221
+ const { body } = response;
222
+ const key = keyBuilderFromType(luvio, body);
223
+ luvio.storeIngest(key, ingest, body);
224
+ const snapshot = luvio.storeLookup({
225
+ recordId: key,
226
+ node: select(),
227
+ variables: {},
228
+ });
229
+ if (process.env.NODE_ENV !== 'production') {
230
+ if (snapshot.state !== 'Fulfilled') {
231
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
232
+ }
233
+ }
234
+ return snapshot;
235
+ }
236
+ function createResourceRequest(config) {
237
+ const headers = {};
238
+ return {
239
+ baseUri: '/services/data/v58.0',
240
+ basePath: '/connect/communities/' + config.urlParams.communityId + '/microbatching',
241
+ method: 'post',
242
+ body: config.body,
243
+ urlParams: config.urlParams,
244
+ queryParams: {},
245
+ headers,
246
+ priority: 'normal',
247
+ };
248
+ }
249
+
250
+ const ingestRecord_ConfigPropertyNames = {
251
+ displayName: 'ingestRecord',
252
+ parameters: {
253
+ required: ['communityId', 'requestIngestionInput'],
254
+ optional: []
255
+ }
256
+ };
257
+ function createResourceParams(config) {
258
+ const resourceParams = {
259
+ urlParams: {
260
+ communityId: config.communityId
261
+ },
262
+ body: {
263
+ requestIngestionInput: config.requestIngestionInput
264
+ }
265
+ };
266
+ return resourceParams;
267
+ }
268
+ function typeCheckConfig(untrustedConfig) {
269
+ const config = {};
270
+ const untrustedConfig_communityId = untrustedConfig.communityId;
271
+ if (typeof untrustedConfig_communityId === 'string') {
272
+ config.communityId = untrustedConfig_communityId;
273
+ }
274
+ const untrustedConfig_requestIngestionInput = untrustedConfig.requestIngestionInput;
275
+ const referenceMicrobatchingIngestionInputRepresentationValidationError = validate$1(untrustedConfig_requestIngestionInput);
276
+ if (referenceMicrobatchingIngestionInputRepresentationValidationError === null) {
277
+ config.requestIngestionInput = untrustedConfig_requestIngestionInput;
278
+ }
279
+ return config;
280
+ }
281
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
282
+ if (!untrustedIsObject(untrustedConfig)) {
283
+ return null;
284
+ }
285
+ if (process.env.NODE_ENV !== 'production') {
286
+ validateConfig(untrustedConfig, configPropertyNames);
287
+ }
288
+ const config = typeCheckConfig(untrustedConfig);
289
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
290
+ return null;
291
+ }
292
+ return config;
293
+ }
294
+ function buildNetworkSnapshot(luvio, config, options) {
295
+ const resourceParams = createResourceParams(config);
296
+ const request = createResourceRequest(resourceParams);
297
+ return luvio.dispatchResourceRequest(request, options)
298
+ .then((response) => {
299
+ return luvio.handleSuccessResponse(() => {
300
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
301
+ return luvio.storeBroadcast().then(() => snapshot);
302
+ }, () => getResponseCacheKeys(luvio, resourceParams, response.body));
303
+ }, (response) => {
304
+ deepFreeze(response);
305
+ throw response;
306
+ });
307
+ }
308
+ const ingestRecordAdapterFactory = (luvio) => {
309
+ return function ingestRecord(untrustedConfig) {
310
+ const config = validateAdapterConfig(untrustedConfig, ingestRecord_ConfigPropertyNames);
311
+ // Invalid or incomplete config
312
+ if (config === null) {
313
+ throw new Error('Invalid config for "ingestRecord"');
314
+ }
315
+ return buildNetworkSnapshot(luvio, config);
316
+ };
317
+ };
318
+
319
+ let ingestRecord;
320
+ function bindExportsTo(luvio) {
321
+ function unwrapSnapshotData(factory) {
322
+ const adapter = factory(luvio);
323
+ return (config) => adapter(config).then(snapshot => snapshot.data);
324
+ }
325
+ return {
326
+ ingestRecord: unwrapSnapshotData(ingestRecordAdapterFactory),
327
+ // Imperative GET Adapters
328
+ };
329
+ }
330
+ withDefaultLuvio((luvio) => {
331
+ ({
332
+ ingestRecord,
333
+ } = bindExportsTo(luvio));
334
+ });
335
+
336
+ export { ingestRecord };
337
+ // version: 0.131.0-c1ec5b7de
@@ -0,0 +1,89 @@
1
+ #%RAML 1.0
2
+ securedBy:
3
+ - OAuth2
4
+ title: Salesforce Connect API
5
+ version: '54.0'
6
+ mediaType: application/json
7
+ protocols:
8
+ - https
9
+ baseUri: /services/data/v58.0
10
+ securitySchemes:
11
+ OAuth2:
12
+ type: OAuth 2.0
13
+ settings:
14
+ authorizationUri: https://example.com/oauth/authorize
15
+ accessTokenUri: ''
16
+ authorizationGrants:
17
+ - implicit
18
+ annotationTypes:
19
+ oas-readOnly:
20
+ type: boolean
21
+ allowedTargets: TypeDeclaration
22
+ oas-collectionFormat:
23
+ type: string
24
+ oas-body-name:
25
+ type: string
26
+ allowedTargets: TypeDeclaration
27
+ types:
28
+ MicrobatchingIngestionInputWrapperRepresentation: # TODO Hand-rolled W-8334626
29
+ description: Wrapper Microbatching Ingestion Input Representation
30
+ type: object
31
+ properties:
32
+ requestIngestionInput:
33
+ description: Set parameters for ingestion.
34
+ type: MicrobatchingIngestionInputRepresentation
35
+ MicrobatchingIngestionInputRepresentation:
36
+ description: Microbatching Ingestion Input Representation
37
+ type: object
38
+ properties:
39
+ groupBy:
40
+ description: GroupBy
41
+ type: string
42
+ required: false # TODO handrolled W-9314597
43
+ keyPrefix:
44
+ description: KeyPrefix
45
+ type: string
46
+ required: false # TODO handrolled W-9314597
47
+ processType:
48
+ description: ProcessType
49
+ type: string
50
+ requestBody:
51
+ description: RequestBody
52
+ type: object
53
+ properties:
54
+ //:
55
+ type: any # TODO Hand-rolled W-10049570
56
+ MicrobatchingIngestionOutputRepresentation:
57
+ description: Representation for microbatching buffering response
58
+ type: object
59
+ properties:
60
+ recordUUID:
61
+ description: UUID of the ingested record
62
+ type: string
63
+ MicrobatchingIngestionRequestBodyInputRepresentation:
64
+ description: Encapsulates request body payload
65
+ type: object
66
+ properties:
67
+ requestBody:
68
+ description: RequestBody
69
+ type: object
70
+ properties:
71
+ //:
72
+ type: object
73
+ /connect/communities/{communityId}/microbatching:
74
+ post:
75
+ description: Microbatching record ingestion.
76
+ responses:
77
+ '200':
78
+ description: Success
79
+ body:
80
+ application/json:
81
+ type: MicrobatchingIngestionOutputRepresentation
82
+ body:
83
+ application/json:
84
+ type: MicrobatchingIngestionInputWrapperRepresentation
85
+ (oas-body-name): requestIngestionInput
86
+ uriParameters:
87
+ communityId:
88
+ type: string
89
+ required: true
@@ -0,0 +1,18 @@
1
+ #%RAML 1.0 Overlay
2
+ extends: ./api.raml
3
+
4
+ uses:
5
+ luvio: luvio://annotations.raml
6
+
7
+ (luvio.keyPrefix): 'microbatching'
8
+
9
+ types:
10
+ MicrobatchingIngestionOutputRepresentation:
11
+ (luvio.ttl): 100
12
+ (luvio.key):
13
+ recordUUID: recordUUID
14
+
15
+ /connect/communities/{communityId}/microbatching:
16
+ post:
17
+ (luvio.adapter):
18
+ name: ingestRecord