@salesforce/lds-adapters-revenue-place-order 1.244.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,287 @@
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, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$1, typeCheckConfig as typeCheckConfig$1 } from '@luvio/engine';
8
+
9
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
10
+ const { keys: ObjectKeys, create: ObjectCreate } = 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(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
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
45
+ return {
46
+ name,
47
+ required,
48
+ resourceType,
49
+ typeCheckShape,
50
+ isArrayShape,
51
+ coerceFn,
52
+ };
53
+ }
54
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
55
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
56
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
57
+ return {
58
+ displayName,
59
+ parameters: {
60
+ required,
61
+ optional,
62
+ }
63
+ };
64
+ }
65
+ const keyPrefix = 'place-order';
66
+
67
+ const { isArray: ArrayIsArray } = Array;
68
+ const { stringify: JSONStringify } = JSON;
69
+ function createLink(ref) {
70
+ return {
71
+ __ref: serializeStructuredKey(ref),
72
+ };
73
+ }
74
+
75
+ function validate$1(obj, path = 'PlaceOrderErrorResponseRepresentation') {
76
+ const v_error = (() => {
77
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
78
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
79
+ }
80
+ const obj_errorCode = obj.errorCode;
81
+ const path_errorCode = path + '.errorCode';
82
+ if (typeof obj_errorCode !== 'string') {
83
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
84
+ }
85
+ const obj_message = obj.message;
86
+ const path_message = path + '.message';
87
+ if (typeof obj_message !== 'string') {
88
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
89
+ }
90
+ const obj_referenceId = obj.referenceId;
91
+ const path_referenceId = path + '.referenceId';
92
+ if (typeof obj_referenceId !== 'string') {
93
+ return new TypeError('Expected "string" but received "' + typeof obj_referenceId + '" (at "' + path_referenceId + '")');
94
+ }
95
+ })();
96
+ return v_error === undefined ? null : v_error;
97
+ }
98
+
99
+ const TTL = 1000;
100
+ const VERSION = "205b108036e34eea59a3126a8814b36b";
101
+ function validate(obj, path = 'PlaceOrderOutputRepresentation') {
102
+ const v_error = (() => {
103
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
104
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
105
+ }
106
+ const obj_errors = obj.errors;
107
+ const path_errors = path + '.errors';
108
+ if (!ArrayIsArray(obj_errors)) {
109
+ return new TypeError('Expected "array" but received "' + typeof obj_errors + '" (at "' + path_errors + '")');
110
+ }
111
+ for (let i = 0; i < obj_errors.length; i++) {
112
+ const obj_errors_item = obj_errors[i];
113
+ const path_errors_item = path_errors + '[' + i + ']';
114
+ const referencepath_errors_itemValidationError = validate$1(obj_errors_item, path_errors_item);
115
+ if (referencepath_errors_itemValidationError !== null) {
116
+ let message = 'Object doesn\'t match PlaceOrderErrorResponseRepresentation (at "' + path_errors_item + '")\n';
117
+ message += referencepath_errors_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
118
+ return new TypeError(message);
119
+ }
120
+ }
121
+ const obj_orderId = obj.orderId;
122
+ const path_orderId = path + '.orderId';
123
+ if (typeof obj_orderId !== 'string') {
124
+ return new TypeError('Expected "string" but received "' + typeof obj_orderId + '" (at "' + path_orderId + '")');
125
+ }
126
+ const obj_requestId = obj.requestId;
127
+ const path_requestId = path + '.requestId';
128
+ if (typeof obj_requestId !== 'string') {
129
+ return new TypeError('Expected "string" but received "' + typeof obj_requestId + '" (at "' + path_requestId + '")');
130
+ }
131
+ const obj_statusURL = obj.statusURL;
132
+ const path_statusURL = path + '.statusURL';
133
+ if (typeof obj_statusURL !== 'string') {
134
+ return new TypeError('Expected "string" but received "' + typeof obj_statusURL + '" (at "' + path_statusURL + '")');
135
+ }
136
+ const obj_success = obj.success;
137
+ const path_success = path + '.success';
138
+ if (typeof obj_success !== 'boolean') {
139
+ return new TypeError('Expected "boolean" but received "' + typeof obj_success + '" (at "' + path_success + '")');
140
+ }
141
+ })();
142
+ return v_error === undefined ? null : v_error;
143
+ }
144
+ const RepresentationType = 'PlaceOrderOutputRepresentation';
145
+ function keyBuilder(luvio, config) {
146
+ return keyPrefix + '::' + RepresentationType + ':' + config.orderId;
147
+ }
148
+ function keyBuilderFromType(luvio, object) {
149
+ const keyParams = {
150
+ orderId: object.orderId
151
+ };
152
+ return keyBuilder(luvio, keyParams);
153
+ }
154
+ function normalize(input, existing, path, luvio, store, timestamp) {
155
+ return input;
156
+ }
157
+ const select$1 = function PlaceOrderOutputRepresentationSelect() {
158
+ return {
159
+ kind: 'Fragment',
160
+ version: VERSION,
161
+ private: [],
162
+ opaque: true
163
+ };
164
+ };
165
+ function equals(existing, incoming) {
166
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
167
+ return false;
168
+ }
169
+ return true;
170
+ }
171
+ const ingest = function PlaceOrderOutputRepresentationIngest(input, path, luvio, store, timestamp) {
172
+ if (process.env.NODE_ENV !== 'production') {
173
+ const validateError = validate(input);
174
+ if (validateError !== null) {
175
+ throw validateError;
176
+ }
177
+ }
178
+ const key = keyBuilderFromType(luvio, input);
179
+ const ttlToUse = TTL;
180
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "place-order", VERSION, RepresentationType, equals);
181
+ return createLink(key);
182
+ };
183
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
184
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
185
+ const rootKey = keyBuilderFromType(luvio, input);
186
+ rootKeySet.set(rootKey, {
187
+ namespace: keyPrefix,
188
+ representationName: RepresentationType,
189
+ mergeable: false
190
+ });
191
+ }
192
+
193
+ function select(luvio, params) {
194
+ return select$1();
195
+ }
196
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
197
+ getTypeCacheKeys(storeKeyMap, luvio, response);
198
+ }
199
+ function ingestSuccess(luvio, resourceParams, response) {
200
+ const { body } = response;
201
+ const key = keyBuilderFromType(luvio, body);
202
+ luvio.storeIngest(key, ingest, body);
203
+ const snapshot = luvio.storeLookup({
204
+ recordId: key,
205
+ node: select(),
206
+ variables: {},
207
+ });
208
+ if (process.env.NODE_ENV !== 'production') {
209
+ if (snapshot.state !== 'Fulfilled') {
210
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
211
+ }
212
+ }
213
+ deepFreeze(snapshot.data);
214
+ return snapshot;
215
+ }
216
+ function createResourceRequest(config) {
217
+ const headers = {};
218
+ return {
219
+ baseUri: '/services/data/v60.0',
220
+ basePath: '/commerce/sales-orders/orders/actions/place',
221
+ method: 'post',
222
+ body: config.body,
223
+ urlParams: {},
224
+ queryParams: {},
225
+ headers,
226
+ priority: 'normal',
227
+ };
228
+ }
229
+
230
+ const adapterName = 'placeOrder';
231
+ const placeOrder_ConfigPropertyMetadata = [
232
+ generateParamConfigMetadata('graph', true, 2 /* Body */, 4 /* Unsupported */),
233
+ generateParamConfigMetadata('pricingPref', true, 2 /* Body */, 0 /* String */),
234
+ generateParamConfigMetadata('shouldSkipValidation', true, 2 /* Body */, 1 /* Boolean */),
235
+ ];
236
+ const placeOrder_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, placeOrder_ConfigPropertyMetadata);
237
+ const createResourceParams = /*#__PURE__*/ createResourceParams$1(placeOrder_ConfigPropertyMetadata);
238
+ function typeCheckConfig(untrustedConfig) {
239
+ const config = {};
240
+ typeCheckConfig$1(untrustedConfig, config, placeOrder_ConfigPropertyMetadata);
241
+ const untrustedConfig_graph = untrustedConfig.graph;
242
+ config.graph = untrustedConfig_graph;
243
+ return config;
244
+ }
245
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
246
+ if (!untrustedIsObject(untrustedConfig)) {
247
+ return null;
248
+ }
249
+ if (process.env.NODE_ENV !== 'production') {
250
+ validateConfig(untrustedConfig, configPropertyNames);
251
+ }
252
+ const config = typeCheckConfig(untrustedConfig);
253
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
254
+ return null;
255
+ }
256
+ return config;
257
+ }
258
+ function buildNetworkSnapshot(luvio, config, options) {
259
+ const resourceParams = createResourceParams(config);
260
+ const request = createResourceRequest(resourceParams);
261
+ return luvio.dispatchResourceRequest(request, options)
262
+ .then((response) => {
263
+ return luvio.handleSuccessResponse(() => {
264
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
265
+ return luvio.storeBroadcast().then(() => snapshot);
266
+ }, () => {
267
+ const cache = new StoreKeyMap();
268
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
269
+ return cache;
270
+ });
271
+ }, (response) => {
272
+ deepFreeze(response);
273
+ throw response;
274
+ });
275
+ }
276
+ const placeOrderAdapterFactory = (luvio) => {
277
+ return function placeOrder(untrustedConfig) {
278
+ const config = validateAdapterConfig(untrustedConfig, placeOrder_ConfigPropertyNames);
279
+ // Invalid or incomplete config
280
+ if (config === null) {
281
+ throw new Error('Invalid config for "placeOrder"');
282
+ }
283
+ return buildNetworkSnapshot(luvio, config);
284
+ };
285
+ };
286
+
287
+ export { placeOrderAdapterFactory };
@@ -0,0 +1,62 @@
1
+ import { Adapter as $64$luvio_engine_Adapter, Snapshot as $64$luvio_engine_Snapshot, UnfulfilledSnapshot as $64$luvio_engine_UnfulfilledSnapshot, AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata } from '@luvio/engine';
2
+ export declare const ObjectPrototypeHasOwnProperty: (v: PropertyKey) => boolean;
3
+ declare const ObjectKeys: {
4
+ (o: object): string[];
5
+ (o: {}): string[];
6
+ }, ObjectCreate: {
7
+ (o: object | null): any;
8
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
9
+ };
10
+ export { ObjectCreate, ObjectKeys };
11
+ export declare const ArrayIsArray: (arg: any) => arg is any[];
12
+ export declare const ArrayPrototypePush: (...items: any[]) => number;
13
+ export interface AdapterValidationConfig {
14
+ displayName: string;
15
+ parameters: {
16
+ required: string[];
17
+ optional: string[];
18
+ unsupported?: string[];
19
+ };
20
+ }
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
+ export declare function validateConfig<T>(config: Untrusted<T>, adapter: AdapterValidationConfig, oneOf?: string[]): void;
29
+ export declare function untrustedIsObject<Base>(untrusted: unknown): untrusted is Untrusted<Base>;
30
+ export type UncoercedConfiguration<Base, Options extends {
31
+ [key in keyof Base]?: any;
32
+ }> = {
33
+ [Key in keyof Base]?: Base[Key] | Options[Key];
34
+ };
35
+ export type Untrusted<Base> = Partial<Base>;
36
+ export declare function areRequiredParametersPresent<T>(config: any, configPropertyNames: AdapterValidationConfig): config is T;
37
+ 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>;
38
+ export declare const SNAPSHOT_STATE_FULFILLED = "Fulfilled";
39
+ export declare const SNAPSHOT_STATE_UNFULFILLED = "Unfulfilled";
40
+ export declare const snapshotRefreshOptions: {
41
+ overrides: {
42
+ headers: {
43
+ 'Cache-Control': string;
44
+ };
45
+ };
46
+ };
47
+ /**
48
+ * A deterministic JSON stringify implementation. Heavily adapted from https://github.com/epoberezkin/fast-json-stable-stringify.
49
+ * This is needed because insertion order for JSON.stringify(object) affects output:
50
+ * JSON.stringify({a: 1, b: 2})
51
+ * "{"a":1,"b":2}"
52
+ * JSON.stringify({b: 2, a: 1})
53
+ * "{"b":2,"a":1}"
54
+ * @param data Data to be JSON-stringified.
55
+ * @returns JSON.stringified value with consistent ordering of keys.
56
+ */
57
+ export declare function stableJSONStringify(node: any): string | undefined;
58
+ export declare function getFetchResponseStatusText(status: number): string;
59
+ export declare function isUnfulfilledSnapshot<T, U>(snapshot: $64$luvio_engine_Snapshot<T, U>): snapshot is $64$luvio_engine_UnfulfilledSnapshot<T, U>;
60
+ export declare function generateParamConfigMetadata(name: string, required: boolean, resourceType: $64$luvio_engine_AdapterConfigMetadata['resourceType'], typeCheckShape: $64$luvio_engine_AdapterConfigMetadata['typeCheckShape'], isArrayShape?: boolean, coerceFn?: (v: unknown) => unknown): $64$luvio_engine_AdapterConfigMetadata;
61
+ export declare function buildAdapterValidationConfig(displayName: string, paramsMeta: $64$luvio_engine_AdapterConfigMetadata[]): AdapterValidationConfig;
62
+ export declare const keyPrefix = "place-order";
@@ -0,0 +1,17 @@
1
+ import { AdapterConfigMetadata as $64$luvio_engine_AdapterConfigMetadata, Luvio as $64$luvio_engine_Luvio, DispatchResourceRequestContext as $64$luvio_engine_DispatchResourceRequestContext, AdapterFactory as $64$luvio_engine_AdapterFactory } from '@luvio/engine';
2
+ import { Untrusted as adapter$45$utils_Untrusted, AdapterValidationConfig as adapter$45$utils_AdapterValidationConfig } from './adapter-utils';
3
+ import { ResourceRequestConfig as resources_postCommerceSalesOrdersOrdersActionsPlace_ResourceRequestConfig } from '../resources/postCommerceSalesOrdersOrdersActionsPlace';
4
+ import { PlaceOrderOutputRepresentation as types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation } from '../types/PlaceOrderOutputRepresentation';
5
+ export declare const adapterName = "placeOrder";
6
+ export declare const placeOrder_ConfigPropertyMetadata: $64$luvio_engine_AdapterConfigMetadata[];
7
+ export declare const placeOrder_ConfigPropertyNames: adapter$45$utils_AdapterValidationConfig;
8
+ export interface PlaceOrderConfig {
9
+ graph: unknown;
10
+ pricingPref: string;
11
+ shouldSkipValidation: boolean;
12
+ }
13
+ export declare const createResourceParams: (config: PlaceOrderConfig) => resources_postCommerceSalesOrdersOrdersActionsPlace_ResourceRequestConfig;
14
+ export declare function typeCheckConfig(untrustedConfig: adapter$45$utils_Untrusted<PlaceOrderConfig>): adapter$45$utils_Untrusted<PlaceOrderConfig>;
15
+ export declare function validateAdapterConfig(untrustedConfig: unknown, configPropertyNames: adapter$45$utils_AdapterValidationConfig): PlaceOrderConfig | null;
16
+ export declare function buildNetworkSnapshot(luvio: $64$luvio_engine_Luvio, config: PlaceOrderConfig, options?: $64$luvio_engine_DispatchResourceRequestContext): Promise<import("@luvio/engine").FulfilledSnapshot<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation, {}> | import("@luvio/engine").StaleSnapshot<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation, {}> | import("@luvio/engine").PendingSnapshot<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation, any>>;
17
+ export declare const placeOrderAdapterFactory: $64$luvio_engine_AdapterFactory<PlaceOrderConfig, types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation>;
@@ -0,0 +1 @@
1
+ export { placeOrderAdapterFactory } from '../adapters/placeOrder';
@@ -0,0 +1,2 @@
1
+ declare let placeOrder: any;
2
+ export { placeOrder, };
@@ -0,0 +1,14 @@
1
+ import { Luvio as $64$luvio_engine_Luvio, Fragment as $64$luvio_engine_Fragment, 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';
2
+ import { PlaceOrderOutputRepresentation as types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation } from '../types/PlaceOrderOutputRepresentation';
3
+ export interface ResourceRequestConfig {
4
+ body: {
5
+ graph: unknown;
6
+ pricingPref: string;
7
+ shouldSkipValidation: boolean;
8
+ };
9
+ }
10
+ export declare function select(luvio: $64$luvio_engine_Luvio, params: ResourceRequestConfig): $64$luvio_engine_Fragment;
11
+ export declare function getResponseCacheKeys(storeKeyMap: any, luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation): void;
12
+ export declare function ingestSuccess(luvio: $64$luvio_engine_Luvio, resourceParams: ResourceRequestConfig, response: $64$luvio_engine_FetchResponse<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation>): $64$luvio_engine_FulfilledSnapshot<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation, {}> | $64$luvio_engine_StaleSnapshot<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation, {}> | $64$luvio_engine_PendingSnapshot<types_PlaceOrderOutputRepresentation_PlaceOrderOutputRepresentation, any>;
13
+ export declare function createResourceRequest(config: ResourceRequestConfig): $64$luvio_engine_ResourceRequest;
14
+ export default createResourceRequest;
@@ -0,0 +1,34 @@
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, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const VERSION = "ddf623566240bfe3028730fe73fe0892";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: PlaceOrderErrorResponseRepresentation, existing: PlaceOrderErrorResponseRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): PlaceOrderErrorResponseRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: PlaceOrderErrorResponseRepresentationNormalized, incoming: PlaceOrderErrorResponseRepresentationNormalized): boolean;
8
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
9
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: PlaceOrderErrorResponseRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
10
+ /**
11
+ * Place Order Error response representation
12
+ *
13
+ * Keys:
14
+ * (none)
15
+ */
16
+ export interface PlaceOrderErrorResponseRepresentationNormalized {
17
+ /** Error Code */
18
+ errorCode: string;
19
+ /** Message stating the reason for error, if any */
20
+ message: string;
21
+ /** Reference ID */
22
+ referenceId: string;
23
+ }
24
+ /**
25
+ * Place Order Error response representation
26
+ *
27
+ * Keys:
28
+ * (none)
29
+ */
30
+ export interface PlaceOrderErrorResponseRepresentation {
31
+ errorCode: string;
32
+ message: string;
33
+ referenceId: string;
34
+ }
@@ -0,0 +1,34 @@
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, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap, NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const VERSION = "ad6f3150e482483e967be97965b19bc7";
3
+ export declare function validate(obj: any, path?: string): TypeError | null;
4
+ export declare const RepresentationType: string;
5
+ export declare function normalize(input: PlaceOrderInputRepresentation, existing: PlaceOrderInputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): PlaceOrderInputRepresentationNormalized;
6
+ export declare const select: () => $64$luvio_engine_FragmentSelection;
7
+ export declare function equals(existing: PlaceOrderInputRepresentationNormalized, incoming: PlaceOrderInputRepresentationNormalized): boolean;
8
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
9
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: PlaceOrderInputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
10
+ /**
11
+ * Place Order API input representation
12
+ *
13
+ * Keys:
14
+ * (none)
15
+ */
16
+ export interface PlaceOrderInputRepresentationNormalized {
17
+ /** The sobject graph representing the order payload to be ingested. */
18
+ graph: unknown;
19
+ /** Pricing Preference for this place order process. */
20
+ pricingPref: string;
21
+ /** Indicates whether to run business rule validations, such as configuration rules, product eligibility rules, asset rules, etc., after the ingestion is completed (true) or not (false). The default is false. */
22
+ shouldSkipValidation: boolean;
23
+ }
24
+ /**
25
+ * Place Order API input representation
26
+ *
27
+ * Keys:
28
+ * (none)
29
+ */
30
+ export interface PlaceOrderInputRepresentation {
31
+ graph: unknown;
32
+ pricingPref: string;
33
+ shouldSkipValidation: boolean;
34
+ }
@@ -0,0 +1,51 @@
1
+ import { PlaceOrderErrorResponseRepresentation as PlaceOrderErrorResponseRepresentation_PlaceOrderErrorResponseRepresentation } from './PlaceOrderErrorResponseRepresentation';
2
+ 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, BaseFragment as $64$luvio_engine_BaseFragment, ResourceIngest as $64$luvio_engine_ResourceIngest, DurableStoreKeyMetadataMap as $64$luvio_engine_DurableStoreKeyMetadataMap } from '@luvio/engine';
3
+ export declare const TTL = 1000;
4
+ export declare const VERSION = "205b108036e34eea59a3126a8814b36b";
5
+ export declare function validate(obj: any, path?: string): TypeError | null;
6
+ export declare const RepresentationType: string;
7
+ export interface KeyParams extends $64$luvio_engine_KeyMetadata {
8
+ orderId: string;
9
+ }
10
+ export type PlaceOrderOutputRepresentationNormalizedKeyMetadata = KeyParams & $64$luvio_engine_NormalizedKeyMetadata;
11
+ export type PartialPlaceOrderOutputRepresentationNormalizedKeyMetadata = Partial<KeyParams> & $64$luvio_engine_NormalizedKeyMetadata;
12
+ export declare function keyBuilder(luvio: $64$luvio_engine_Luvio, config: KeyParams): string;
13
+ export declare function keyBuilder_StructuredKey(luvio: $64$luvio_engine_Luvio, config: KeyParams): PlaceOrderOutputRepresentationNormalizedKeyMetadata;
14
+ export declare function keyBuilderFromType(luvio: $64$luvio_engine_Luvio, object: PlaceOrderOutputRepresentation): string;
15
+ export declare function keyBuilderFromType_StructuredKey(luvio: $64$luvio_engine_Luvio, object: PlaceOrderOutputRepresentation): $64$luvio_engine_NormalizedKeyMetadata;
16
+ export declare function normalize(input: PlaceOrderOutputRepresentation, existing: PlaceOrderOutputRepresentationNormalized, path: $64$luvio_engine_IngestPath, luvio: $64$luvio_engine_Luvio, store: $64$luvio_engine_Store, timestamp: number): PlaceOrderOutputRepresentationNormalized;
17
+ export declare const select: () => $64$luvio_engine_BaseFragment;
18
+ export declare function equals(existing: PlaceOrderOutputRepresentationNormalized, incoming: PlaceOrderOutputRepresentationNormalized): boolean;
19
+ export declare const ingest: $64$luvio_engine_ResourceIngest;
20
+ export declare function getTypeCacheKeys(rootKeySet: $64$luvio_engine_DurableStoreKeyMetadataMap, luvio: $64$luvio_engine_Luvio, input: PlaceOrderOutputRepresentation, fullPathFactory: () => string | $64$luvio_engine_NormalizedKeyMetadata): void;
21
+ /**
22
+ * Place Order API output representation
23
+ *
24
+ * Keys:
25
+ * orderId (string): orderId
26
+ */
27
+ export interface PlaceOrderOutputRepresentationNormalized {
28
+ /** List of errors encountered during the synchronous processing. */
29
+ errors: Array<PlaceOrderErrorResponseRepresentation_PlaceOrderErrorResponseRepresentation>;
30
+ /** Order Id */
31
+ orderId: string;
32
+ /** The request id of the process that can be used to query async status. */
33
+ requestId: string;
34
+ /** The async status URL, if available */
35
+ statusURL: string;
36
+ /** Whether or not the synchronous part of the processing is successful */
37
+ success: boolean;
38
+ }
39
+ /**
40
+ * Place Order API output representation
41
+ *
42
+ * Keys:
43
+ * orderId (string): orderId
44
+ */
45
+ export interface PlaceOrderOutputRepresentation {
46
+ errors: Array<PlaceOrderErrorResponseRepresentation_PlaceOrderErrorResponseRepresentation>;
47
+ orderId: string;
48
+ requestId: string;
49
+ statusURL: string;
50
+ success: boolean;
51
+ }
@@ -0,0 +1,32 @@
1
+ import { NormalizedKeyMetadata as $64$luvio_engine_NormalizedKeyMetadata } from '@luvio/engine';
2
+ export declare const ObjectKeys: {
3
+ (o: object): string[];
4
+ (o: {}): string[];
5
+ }, ObjectCreate: {
6
+ (o: object | null): any;
7
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
8
+ }, ObjectAssign: {
9
+ <T extends {}, U>(target: T, source: U): T & U;
10
+ <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
11
+ <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;
12
+ (target: object, ...sources: any[]): any;
13
+ };
14
+ export declare const ArrayIsArray: (arg: any) => arg is any[];
15
+ export declare const JSONStringify: {
16
+ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
17
+ (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
18
+ };
19
+ type AllowedPrimitives = boolean | string | number | Date | null;
20
+ type Value<T> = T extends AllowedPrimitives ? T : RecursivePartial<T>;
21
+ export type RecursivePartial<T> = null | {
22
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<Value<U>> | null : Value<T[P]> | null;
23
+ };
24
+ export declare function equalsArray<U, V extends U[]>(a: V, b: V, equalsItem: (itemA: U, itemB: U) => boolean | void): boolean;
25
+ export declare function equalsObject<U, V extends {
26
+ [key: string]: U;
27
+ }>(a: V, b: V, equalsProp: (propA: U, propB: U) => boolean | void): boolean;
28
+ export declare function createLink(ref: string | $64$luvio_engine_NormalizedKeyMetadata): {
29
+ __ref: string;
30
+ };
31
+ export declare function assignMetadataLink(entry: any, metadataKey: string | $64$luvio_engine_NormalizedKeyMetadata): void;
32
+ export {};
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@salesforce/lds-adapters-revenue-place-order",
3
+ "version": "1.244.0",
4
+ "description": "Place Order Connect API ",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "dist/es/es2018/revenue-place-order.js",
7
+ "module": "dist/es/es2018/revenue-place-order.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
+ "types": "./dist/es/es2018/types/src/generated/artifacts/main.d.ts",
17
+ "import": "./dist/es/es2018/revenue-place-order.js",
18
+ "require": "./dist/es/es2018/revenue-place-order.js"
19
+ },
20
+ "./sfdc": {
21
+ "types": "./sfdc/index.d.ts",
22
+ "import": "./sfdc/index.js",
23
+ "default": "./sfdc/index.js"
24
+ }
25
+ },
26
+ "sfdc": {
27
+ "namespace": "lightning",
28
+ "module": "revenuePlaceOrderApi"
29
+ },
30
+ "contributors": [
31
+ "hkoti@salesforce.com",
32
+ "s.vishwabharathi@salesforce.com"
33
+ ],
34
+ "scripts": {
35
+ "build": "yarn build:raml && yarn build:services",
36
+ "build:raml": "luvio generate src/raml/luvio.raml src/generated -p '../lds-compiler-plugins'",
37
+ "build:services": "rollup --bundleConfigAsCjs --config rollup.config.js",
38
+ "clean": "rm -rf dist sfdc src/generated",
39
+ "release:core": "../../scripts/release/core.js --adapter=lds-adapters-revenue-place-order",
40
+ "release:corejar": "yarn build && ../core-build/scripts/core.js --adapter=lds-adapters-revenue-place-order",
41
+ "test:unit": "jest"
42
+ },
43
+ "dependencies": {
44
+ "@salesforce/lds-bindings": "*",
45
+ "raml2html": "^7.8.0"
46
+ },
47
+ "devDependencies": {
48
+ "@salesforce/lds-compiler-plugins": "*",
49
+ "@salesforce/lds-karma": "*"
50
+ },
51
+ "nx": {
52
+ "targets": {
53
+ "build": {
54
+ "outputs": [
55
+ "{projectRoot}/dist",
56
+ "{projectRoot}/sfdc",
57
+ "{projectRoot}/src/generated"
58
+ ]
59
+ }
60
+ }
61
+ },
62
+ "volta": {
63
+ "extends": "../../package.json"
64
+ }
65
+ }
@@ -0,0 +1 @@
1
+ export * from '../dist/es/es2018/types/src/generated/artifacts/sfdc';
package/sfdc/index.js ADDED
@@ -0,0 +1,314 @@
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, ingestShape, deepFreeze, StoreKeyMap, createResourceParams as createResourceParams$1, typeCheckConfig as typeCheckConfig$1 } from 'force/luvioEngine';
17
+
18
+ const { hasOwnProperty: ObjectPrototypeHasOwnProperty } = Object.prototype;
19
+ const { keys: ObjectKeys, create: ObjectCreate } = 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(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
+ function generateParamConfigMetadata(name, required, resourceType, typeCheckShape, isArrayShape = false, coerceFn) {
54
+ return {
55
+ name,
56
+ required,
57
+ resourceType,
58
+ typeCheckShape,
59
+ isArrayShape,
60
+ coerceFn,
61
+ };
62
+ }
63
+ function buildAdapterValidationConfig(displayName, paramsMeta) {
64
+ const required = paramsMeta.filter(p => p.required).map(p => p.name);
65
+ const optional = paramsMeta.filter(p => !p.required).map(p => p.name);
66
+ return {
67
+ displayName,
68
+ parameters: {
69
+ required,
70
+ optional,
71
+ }
72
+ };
73
+ }
74
+ const keyPrefix = 'place-order';
75
+
76
+ const { isArray: ArrayIsArray } = Array;
77
+ const { stringify: JSONStringify } = JSON;
78
+ function createLink(ref) {
79
+ return {
80
+ __ref: serializeStructuredKey(ref),
81
+ };
82
+ }
83
+
84
+ function validate$1(obj, path = 'PlaceOrderErrorResponseRepresentation') {
85
+ const v_error = (() => {
86
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
87
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
88
+ }
89
+ const obj_errorCode = obj.errorCode;
90
+ const path_errorCode = path + '.errorCode';
91
+ if (typeof obj_errorCode !== 'string') {
92
+ return new TypeError('Expected "string" but received "' + typeof obj_errorCode + '" (at "' + path_errorCode + '")');
93
+ }
94
+ const obj_message = obj.message;
95
+ const path_message = path + '.message';
96
+ if (typeof obj_message !== 'string') {
97
+ return new TypeError('Expected "string" but received "' + typeof obj_message + '" (at "' + path_message + '")');
98
+ }
99
+ const obj_referenceId = obj.referenceId;
100
+ const path_referenceId = path + '.referenceId';
101
+ if (typeof obj_referenceId !== 'string') {
102
+ return new TypeError('Expected "string" but received "' + typeof obj_referenceId + '" (at "' + path_referenceId + '")');
103
+ }
104
+ })();
105
+ return v_error === undefined ? null : v_error;
106
+ }
107
+
108
+ const TTL = 1000;
109
+ const VERSION = "205b108036e34eea59a3126a8814b36b";
110
+ function validate(obj, path = 'PlaceOrderOutputRepresentation') {
111
+ const v_error = (() => {
112
+ if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
113
+ return new TypeError('Expected "object" but received "' + typeof obj + '" (at "' + path + '")');
114
+ }
115
+ const obj_errors = obj.errors;
116
+ const path_errors = path + '.errors';
117
+ if (!ArrayIsArray(obj_errors)) {
118
+ return new TypeError('Expected "array" but received "' + typeof obj_errors + '" (at "' + path_errors + '")');
119
+ }
120
+ for (let i = 0; i < obj_errors.length; i++) {
121
+ const obj_errors_item = obj_errors[i];
122
+ const path_errors_item = path_errors + '[' + i + ']';
123
+ const referencepath_errors_itemValidationError = validate$1(obj_errors_item, path_errors_item);
124
+ if (referencepath_errors_itemValidationError !== null) {
125
+ let message = 'Object doesn\'t match PlaceOrderErrorResponseRepresentation (at "' + path_errors_item + '")\n';
126
+ message += referencepath_errors_itemValidationError.message.split('\n').map((line) => '\t' + line).join('\n');
127
+ return new TypeError(message);
128
+ }
129
+ }
130
+ const obj_orderId = obj.orderId;
131
+ const path_orderId = path + '.orderId';
132
+ if (typeof obj_orderId !== 'string') {
133
+ return new TypeError('Expected "string" but received "' + typeof obj_orderId + '" (at "' + path_orderId + '")');
134
+ }
135
+ const obj_requestId = obj.requestId;
136
+ const path_requestId = path + '.requestId';
137
+ if (typeof obj_requestId !== 'string') {
138
+ return new TypeError('Expected "string" but received "' + typeof obj_requestId + '" (at "' + path_requestId + '")');
139
+ }
140
+ const obj_statusURL = obj.statusURL;
141
+ const path_statusURL = path + '.statusURL';
142
+ if (typeof obj_statusURL !== 'string') {
143
+ return new TypeError('Expected "string" but received "' + typeof obj_statusURL + '" (at "' + path_statusURL + '")');
144
+ }
145
+ const obj_success = obj.success;
146
+ const path_success = path + '.success';
147
+ if (typeof obj_success !== 'boolean') {
148
+ return new TypeError('Expected "boolean" but received "' + typeof obj_success + '" (at "' + path_success + '")');
149
+ }
150
+ })();
151
+ return v_error === undefined ? null : v_error;
152
+ }
153
+ const RepresentationType = 'PlaceOrderOutputRepresentation';
154
+ function keyBuilder(luvio, config) {
155
+ return keyPrefix + '::' + RepresentationType + ':' + config.orderId;
156
+ }
157
+ function keyBuilderFromType(luvio, object) {
158
+ const keyParams = {
159
+ orderId: object.orderId
160
+ };
161
+ return keyBuilder(luvio, keyParams);
162
+ }
163
+ function normalize(input, existing, path, luvio, store, timestamp) {
164
+ return input;
165
+ }
166
+ const select$1 = function PlaceOrderOutputRepresentationSelect() {
167
+ return {
168
+ kind: 'Fragment',
169
+ version: VERSION,
170
+ private: [],
171
+ opaque: true
172
+ };
173
+ };
174
+ function equals(existing, incoming) {
175
+ if (JSONStringify(incoming) !== JSONStringify(existing)) {
176
+ return false;
177
+ }
178
+ return true;
179
+ }
180
+ const ingest = function PlaceOrderOutputRepresentationIngest(input, path, luvio, store, timestamp) {
181
+ if (process.env.NODE_ENV !== 'production') {
182
+ const validateError = validate(input);
183
+ if (validateError !== null) {
184
+ throw validateError;
185
+ }
186
+ }
187
+ const key = keyBuilderFromType(luvio, input);
188
+ const ttlToUse = TTL;
189
+ ingestShape(input, path, luvio, store, timestamp, ttlToUse, key, normalize, "place-order", VERSION, RepresentationType, equals);
190
+ return createLink(key);
191
+ };
192
+ function getTypeCacheKeys(rootKeySet, luvio, input, fullPathFactory) {
193
+ // root cache key (uses fullPathFactory if keyBuilderFromType isn't defined)
194
+ const rootKey = keyBuilderFromType(luvio, input);
195
+ rootKeySet.set(rootKey, {
196
+ namespace: keyPrefix,
197
+ representationName: RepresentationType,
198
+ mergeable: false
199
+ });
200
+ }
201
+
202
+ function select(luvio, params) {
203
+ return select$1();
204
+ }
205
+ function getResponseCacheKeys(storeKeyMap, luvio, resourceParams, response) {
206
+ getTypeCacheKeys(storeKeyMap, luvio, response);
207
+ }
208
+ function ingestSuccess(luvio, resourceParams, response) {
209
+ const { body } = response;
210
+ const key = keyBuilderFromType(luvio, body);
211
+ luvio.storeIngest(key, ingest, body);
212
+ const snapshot = luvio.storeLookup({
213
+ recordId: key,
214
+ node: select(),
215
+ variables: {},
216
+ });
217
+ if (process.env.NODE_ENV !== 'production') {
218
+ if (snapshot.state !== 'Fulfilled') {
219
+ throw new Error('Invalid network response. Expected resource response to result in Fulfilled snapshot');
220
+ }
221
+ }
222
+ deepFreeze(snapshot.data);
223
+ return snapshot;
224
+ }
225
+ function createResourceRequest(config) {
226
+ const headers = {};
227
+ return {
228
+ baseUri: '/services/data/v60.0',
229
+ basePath: '/commerce/sales-orders/orders/actions/place',
230
+ method: 'post',
231
+ body: config.body,
232
+ urlParams: {},
233
+ queryParams: {},
234
+ headers,
235
+ priority: 'normal',
236
+ };
237
+ }
238
+
239
+ const adapterName = 'placeOrder';
240
+ const placeOrder_ConfigPropertyMetadata = [
241
+ generateParamConfigMetadata('graph', true, 2 /* Body */, 4 /* Unsupported */),
242
+ generateParamConfigMetadata('pricingPref', true, 2 /* Body */, 0 /* String */),
243
+ generateParamConfigMetadata('shouldSkipValidation', true, 2 /* Body */, 1 /* Boolean */),
244
+ ];
245
+ const placeOrder_ConfigPropertyNames = /*#__PURE__*/ buildAdapterValidationConfig(adapterName, placeOrder_ConfigPropertyMetadata);
246
+ const createResourceParams = /*#__PURE__*/ createResourceParams$1(placeOrder_ConfigPropertyMetadata);
247
+ function typeCheckConfig(untrustedConfig) {
248
+ const config = {};
249
+ typeCheckConfig$1(untrustedConfig, config, placeOrder_ConfigPropertyMetadata);
250
+ const untrustedConfig_graph = untrustedConfig.graph;
251
+ config.graph = untrustedConfig_graph;
252
+ return config;
253
+ }
254
+ function validateAdapterConfig(untrustedConfig, configPropertyNames) {
255
+ if (!untrustedIsObject(untrustedConfig)) {
256
+ return null;
257
+ }
258
+ if (process.env.NODE_ENV !== 'production') {
259
+ validateConfig(untrustedConfig, configPropertyNames);
260
+ }
261
+ const config = typeCheckConfig(untrustedConfig);
262
+ if (!areRequiredParametersPresent(config, configPropertyNames)) {
263
+ return null;
264
+ }
265
+ return config;
266
+ }
267
+ function buildNetworkSnapshot(luvio, config, options) {
268
+ const resourceParams = createResourceParams(config);
269
+ const request = createResourceRequest(resourceParams);
270
+ return luvio.dispatchResourceRequest(request, options)
271
+ .then((response) => {
272
+ return luvio.handleSuccessResponse(() => {
273
+ const snapshot = ingestSuccess(luvio, resourceParams, response);
274
+ return luvio.storeBroadcast().then(() => snapshot);
275
+ }, () => {
276
+ const cache = new StoreKeyMap();
277
+ getResponseCacheKeys(cache, luvio, resourceParams, response.body);
278
+ return cache;
279
+ });
280
+ }, (response) => {
281
+ deepFreeze(response);
282
+ throw response;
283
+ });
284
+ }
285
+ const placeOrderAdapterFactory = (luvio) => {
286
+ return function placeOrder(untrustedConfig) {
287
+ const config = validateAdapterConfig(untrustedConfig, placeOrder_ConfigPropertyNames);
288
+ // Invalid or incomplete config
289
+ if (config === null) {
290
+ throw new Error('Invalid config for "placeOrder"');
291
+ }
292
+ return buildNetworkSnapshot(luvio, config);
293
+ };
294
+ };
295
+
296
+ let placeOrder;
297
+ function bindExportsTo(luvio) {
298
+ function unwrapSnapshotData(factory) {
299
+ const adapter = factory(luvio);
300
+ return (config) => adapter(config).then(snapshot => snapshot.data);
301
+ }
302
+ return {
303
+ placeOrder: unwrapSnapshotData(placeOrderAdapterFactory),
304
+ // Imperative GET Adapters
305
+ };
306
+ }
307
+ withDefaultLuvio((luvio) => {
308
+ ({
309
+ placeOrder,
310
+ } = bindExportsTo(luvio));
311
+ });
312
+
313
+ export { placeOrder };
314
+ // version: 1.244.0-4d142822f
@@ -0,0 +1,97 @@
1
+ #%RAML 1.0
2
+ securedBy:
3
+ - OAuth2
4
+ title: Salesforce Connect API
5
+ version: '60.0'
6
+ mediaType: application/json
7
+ protocols:
8
+ - https
9
+ baseUri: /services/data/v60.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
+ PlaceOrderErrorResponseRepresentation:
29
+ description: Place Order Error response representation
30
+ type: object
31
+ properties:
32
+ errorCode:
33
+ description: Error Code
34
+ type: string
35
+ message:
36
+ description: Message stating the reason for error, if any
37
+ type: string
38
+ referenceId:
39
+ description: Reference ID
40
+ type: string
41
+ PlaceOrderInputRepresentation:
42
+ description: Place Order API input representation
43
+ type: object
44
+ properties:
45
+ graph:
46
+ description: The sobject graph representing the order payload to be ingested.
47
+ type: any #handrolled
48
+ pricingPref:
49
+ description: Pricing Preference for this place order process.
50
+ type: string
51
+ enum:
52
+ - Force
53
+ - Skip
54
+ - System
55
+ shouldSkipValidation:
56
+ description: Indicates whether to run business rule validations, such as configuration
57
+ rules, product eligibility rules, asset rules, etc., after the ingestion
58
+ is completed (true) or not (false). The default is false.
59
+ type: boolean
60
+ PlaceOrderOutputRepresentation:
61
+ description: Place Order API output representation
62
+ type: object
63
+ properties:
64
+ errors:
65
+ description: List of errors encountered during the synchronous processing.
66
+ type: array
67
+ items:
68
+ type: PlaceOrderErrorResponseRepresentation
69
+ orderId:
70
+ description: Order Id
71
+ type: string
72
+ requestId:
73
+ description: The request id of the process that can be used to query async
74
+ status.
75
+ type: string
76
+ statusURL:
77
+ description: The async status URL, if available
78
+ type: string
79
+ success:
80
+ description: Whether or not the synchronous part of the processing is successful
81
+ type: boolean
82
+ /commerce/sales-orders:
83
+ /orders:
84
+ /actions/place:
85
+ post:
86
+ displayName: postPlaceOrder
87
+ description: Place an Order
88
+ responses:
89
+ '200':
90
+ description: Success
91
+ body:
92
+ application/json:
93
+ type: PlaceOrderOutputRepresentation
94
+ body:
95
+ application/json:
96
+ type: PlaceOrderInputRepresentation
97
+ (oas-body-name): inputRequest
@@ -0,0 +1,80 @@
1
+ #%RAML 1.0 Overlay
2
+ extends: ./api.raml
3
+
4
+ uses:
5
+ luvio: 'luvio://annotations.raml'
6
+
7
+ (luvio.keyPrefix): 'place-order'
8
+
9
+ types:
10
+ PlaceOrderOutputRepresentation:
11
+ (luvio.ttl): 1000
12
+ (luvio.opaque): true
13
+ (luvio.key):
14
+ orderId: orderId
15
+
16
+ /commerce/sales-orders/orders/actions/place:
17
+ post:
18
+ (luvio.adapter):
19
+ name: placeOrder
20
+ tests:
21
+ validConfigs:
22
+ - |
23
+ {
24
+ "pricingPref": "Force",
25
+ "shouldSkipValidation": true,
26
+ "graph":
27
+ {
28
+ "graphId": "placeOrder",
29
+ "records":
30
+ [
31
+ {
32
+ "referenceId": "refOrder",
33
+ "record":
34
+ {
35
+ "attributes":
36
+ {
37
+ "type": "Order",
38
+ "method": "PATCH",
39
+ "id": "8011Q00000NvSX6QAN"
40
+ },
41
+ "Description": "Update Order description"
42
+ }
43
+ },
44
+ {
45
+ "referenceId": "refOrderItem",
46
+ "record":
47
+ {
48
+ "attributes":
49
+ {
50
+ "type": "OrderItem",
51
+ "method": "PATCH",
52
+ "id": "8021Q00000d82aEQAQ"
53
+ },
54
+ "Quantity": 5.0
55
+ }
56
+ }
57
+ ]
58
+ }
59
+ }
60
+ invalidConfigs:
61
+ - |
62
+ {
63
+ "shouldSkipValidation": true
64
+ }
65
+ - |
66
+ {
67
+ "graph": {}
68
+ }
69
+ - |
70
+ { "inputRequest":
71
+ {
72
+ "graph": {}
73
+ }
74
+ }
75
+ - |
76
+ { "inputRequest":
77
+ {
78
+ "pricingPref": "force"
79
+ }
80
+ }