@salesforce/lds-adapters-uiapi-lex 0.1.0-dev1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +82 -0
- package/package.json +42 -0
- package/sfdc/ldsAdaptersUiapiLex.js +590 -0
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.
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/lds-adapters-uiapi-lex",
|
|
3
|
+
"version": "0.1.0-dev1",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
|
+
"description": "UIAPI LWC Adapters built for LEX",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lds-adapters-uiapi.git",
|
|
9
|
+
"directory": "packages/lds-adapters-uiapi-lex"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "sfdc/ldsAdaptersUiapiLex.js",
|
|
13
|
+
"types": "src/main.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"sfdc"
|
|
16
|
+
],
|
|
17
|
+
"sfdc": {
|
|
18
|
+
"overrides": {
|
|
19
|
+
"artifacts": {
|
|
20
|
+
"ldsAdaptersUiapiLex.js": {
|
|
21
|
+
"output": {
|
|
22
|
+
"path": "ui-force-components/modules/force/ldsAdaptersUiapiLex/ldsAdaptersUiapiLex.js"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"prepare": "yarn build",
|
|
30
|
+
"build": "rollup --bundleConfigAsCjs --config rollup.config.js",
|
|
31
|
+
"clean": "rm -rf sfdc"
|
|
32
|
+
},
|
|
33
|
+
"nx": {
|
|
34
|
+
"targets": {
|
|
35
|
+
"build": {
|
|
36
|
+
"outputs": [
|
|
37
|
+
"{projectRoot}/sfdc"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,590 @@
|
|
|
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 { CommandWireAdapterConstructor } from 'force/luvioLwcBindings5';
|
|
16
|
+
|
|
17
|
+
/*!
|
|
18
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
19
|
+
* All rights reserved.
|
|
20
|
+
* For full license text, see the LICENSE.txt file
|
|
21
|
+
*/
|
|
22
|
+
function resolvedPromiseLike$1(result) {
|
|
23
|
+
if (isPromiseLike$1(result)) {
|
|
24
|
+
return result.then((nextResult) => nextResult);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
then: (onFulfilled, _onRejected) => {
|
|
28
|
+
try {
|
|
29
|
+
return resolvedPromiseLike$1(onFulfilled(result));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (onFulfilled === void 0) {
|
|
32
|
+
return resolvedPromiseLike$1(result);
|
|
33
|
+
}
|
|
34
|
+
return rejectedPromiseLike$1(e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function rejectedPromiseLike$1(reason) {
|
|
40
|
+
if (isPromiseLike$1(reason)) {
|
|
41
|
+
return reason.then((nextResult) => nextResult);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
then: (_onFulfilled, onRejected) => {
|
|
45
|
+
if (typeof onRejected === "function") {
|
|
46
|
+
try {
|
|
47
|
+
return resolvedPromiseLike$1(onRejected(reason));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return rejectedPromiseLike$1(e);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return rejectedPromiseLike$1(reason);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function isPromiseLike$1(x) {
|
|
57
|
+
return typeof (x == null ? void 0 : x.then) === "function";
|
|
58
|
+
}
|
|
59
|
+
function racesync$1(values) {
|
|
60
|
+
for (const value of values) {
|
|
61
|
+
let settled = void 0;
|
|
62
|
+
if (isPromiseLike$1(value)) {
|
|
63
|
+
value.then(
|
|
64
|
+
(_) => {
|
|
65
|
+
settled = value;
|
|
66
|
+
},
|
|
67
|
+
(_) => {
|
|
68
|
+
settled = value;
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
settled = resolvedPromiseLike$1(value);
|
|
73
|
+
}
|
|
74
|
+
if (settled !== void 0) {
|
|
75
|
+
return settled;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return Promise.race(values);
|
|
79
|
+
}
|
|
80
|
+
function satisfies(provided, requested) {
|
|
81
|
+
const providedN = provided.split(".").map((s) => parseInt(s));
|
|
82
|
+
const requestedN = requested.split(".").map((s) => parseInt(s));
|
|
83
|
+
return providedN[0] === requestedN[0] && providedN[1] >= requestedN[1];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/*!
|
|
87
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
88
|
+
* All rights reserved.
|
|
89
|
+
* For full license text, see the LICENSE.txt file
|
|
90
|
+
*/
|
|
91
|
+
function resolve(published, requested) {
|
|
92
|
+
const result = {};
|
|
93
|
+
for (const [name, request] of Object.entries(requested)) {
|
|
94
|
+
const matchingService = published.find(
|
|
95
|
+
(s) => (
|
|
96
|
+
// service types must match
|
|
97
|
+
s.type === request.type && // version of the service must satisfy the requested version
|
|
98
|
+
satisfies(s.version, request.version) && // no tags requested, or the service matches every requested tag value
|
|
99
|
+
(request.tags === void 0 || Object.keys(request.tags).every((tag) => {
|
|
100
|
+
var _a;
|
|
101
|
+
return ((_a = s.tags) == null ? void 0 : _a[tag]) === request.tags[tag];
|
|
102
|
+
}))
|
|
103
|
+
)
|
|
104
|
+
);
|
|
105
|
+
if (matchingService) {
|
|
106
|
+
result[name] = matchingService.service;
|
|
107
|
+
} else if (!("optional" in request && request.optional)) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
let waitForServices = new Promise(
|
|
114
|
+
(resolve2) => resolve2
|
|
115
|
+
);
|
|
116
|
+
function getServices(request, timeout = 3e4) {
|
|
117
|
+
const servicesPromise = waitForServices.then((services) => {
|
|
118
|
+
const result = resolve(services, request);
|
|
119
|
+
if (result) {
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
throw new Error("no matches found for one or more requested services");
|
|
123
|
+
});
|
|
124
|
+
let timeoutId;
|
|
125
|
+
let timeoutPromise = new Promise((_, reject) => {
|
|
126
|
+
timeoutId = setTimeout(() => reject(new Error("OneStore services unavailable")), timeout);
|
|
127
|
+
});
|
|
128
|
+
return racesync$1([servicesPromise, timeoutPromise]).then(
|
|
129
|
+
(value) => {
|
|
130
|
+
clearTimeout(timeoutId);
|
|
131
|
+
return value;
|
|
132
|
+
},
|
|
133
|
+
(reason) => {
|
|
134
|
+
clearTimeout(timeoutId);
|
|
135
|
+
console.error(reason);
|
|
136
|
+
throw reason;
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
143
|
+
* All rights reserved.
|
|
144
|
+
* For full license text, see the LICENSE.txt file
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns a PromiseLike object that resolves with the specified result.
|
|
150
|
+
*
|
|
151
|
+
* @param result resolved result
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
function resolvedPromiseLike(result) {
|
|
155
|
+
// Don't nest anything promise like
|
|
156
|
+
if (isPromiseLike(result)) {
|
|
157
|
+
return result.then((nextResult) => nextResult);
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
then: (onFulfilled, _onRejected) => {
|
|
161
|
+
if (onFulfilled) {
|
|
162
|
+
try {
|
|
163
|
+
return resolvedPromiseLike(onFulfilled(result));
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
return rejectedPromiseLike(e);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// assume TResult1 == Result and just pass result down the chain
|
|
170
|
+
return resolvedPromiseLike(result);
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns a PromiseLike object that rejects with the specified reason.
|
|
176
|
+
*
|
|
177
|
+
* @param reason rejection value
|
|
178
|
+
* @returns PromiseLike that rejects with reason
|
|
179
|
+
*/
|
|
180
|
+
function rejectedPromiseLike(reason) {
|
|
181
|
+
if (isPromiseLike(reason)) {
|
|
182
|
+
return reason.then((nextResult) => nextResult);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
then: (_onFulfilled, onRejected) => {
|
|
186
|
+
if (onRejected) {
|
|
187
|
+
try {
|
|
188
|
+
return resolvedPromiseLike(onRejected(reason));
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
return rejectedPromiseLike(e);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// assume TResult2 == Result and just pass rejection down the chain
|
|
195
|
+
return rejectedPromiseLike(reason);
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Indicates if an object is PromiseLike.
|
|
201
|
+
*
|
|
202
|
+
* @param x anything
|
|
203
|
+
* @returns true if x is PromiseLike; false if not
|
|
204
|
+
*/
|
|
205
|
+
function isPromiseLike(x) {
|
|
206
|
+
return typeof x === 'object' && typeof (x === null || x === void 0 ? void 0 : x.then) === 'function';
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* As Promise.race, but returns sychronously if any of the supplied values resolve/reject
|
|
210
|
+
* synchronously.
|
|
211
|
+
*
|
|
212
|
+
* @param values as Promise.race
|
|
213
|
+
* @returns as Promise.race
|
|
214
|
+
*/
|
|
215
|
+
function racesync(values) {
|
|
216
|
+
for (const value of values) {
|
|
217
|
+
let settled = undefined;
|
|
218
|
+
if (isPromiseLike(value)) {
|
|
219
|
+
value.then((_) => {
|
|
220
|
+
settled = value;
|
|
221
|
+
}, (_) => {
|
|
222
|
+
settled = value;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
settled = resolvedPromiseLike(value);
|
|
227
|
+
}
|
|
228
|
+
if (settled !== undefined) {
|
|
229
|
+
return settled;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return Promise.race(values);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
237
|
+
* All rights reserved.
|
|
238
|
+
* For full license text, see the LICENSE.txt file
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
function convertAuraResponseToData(data) {
|
|
243
|
+
return data;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
class TypeRegistryCachePolicyCommand {}
|
|
247
|
+
class CachePolicyCommand {}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
251
|
+
* All rights reserved.
|
|
252
|
+
* For full license text, see the LICENSE.txt file
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Converts an arbitrary value to an Error.
|
|
257
|
+
*
|
|
258
|
+
* @param x anything
|
|
259
|
+
* @returns Error corresponding to x
|
|
260
|
+
*/
|
|
261
|
+
function toError(x) {
|
|
262
|
+
if (x instanceof Error) {
|
|
263
|
+
return x;
|
|
264
|
+
}
|
|
265
|
+
return new Error(`${x}`);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// an error to indicate that the data inside a WithErrors construct
|
|
269
|
+
// is missing or incomplete
|
|
270
|
+
class DataNotFoundError extends Error {
|
|
271
|
+
constructor(message) {
|
|
272
|
+
super(message);
|
|
273
|
+
this.name = 'DataNotFoundError';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
279
|
+
* All rights reserved.
|
|
280
|
+
* For full license text, see the LICENSE.txt file
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
const UiApiNamespace = 'UiApi';
|
|
284
|
+
|
|
285
|
+
const ObjectInfoRepresentationName = 'ObjectInfoRepresentation';
|
|
286
|
+
const objectInfoType = {
|
|
287
|
+
namespace: UiApiNamespace,
|
|
288
|
+
typeName: ObjectInfoRepresentationName,
|
|
289
|
+
// 15 * 60 * 1000 = 15 minutes
|
|
290
|
+
ttl: 900000,
|
|
291
|
+
buildKey: function (config) {
|
|
292
|
+
return `${this.namespace}::${this.typeName}::${config.apiName}`;
|
|
293
|
+
},
|
|
294
|
+
equals: function (x, y, _typeRegistry) {
|
|
295
|
+
return x.apiName === y.apiName && x.eTag === y.eTag;
|
|
296
|
+
},
|
|
297
|
+
read: function (key, services) {
|
|
298
|
+
return services.store.get(key);
|
|
299
|
+
},
|
|
300
|
+
write: function (key, data, services) {
|
|
301
|
+
const now = Date.now();
|
|
302
|
+
const store = services.store;
|
|
303
|
+
services.metadataRepository.set(key, {
|
|
304
|
+
namespace: this.namespace,
|
|
305
|
+
typeName: this.typeName,
|
|
306
|
+
ingestionTime: now,
|
|
307
|
+
expirationTime: now + this.ttl,
|
|
308
|
+
});
|
|
309
|
+
const existing = store.get(key);
|
|
310
|
+
if (existing && this.equals(existing, data, services)) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
store.set(key, data);
|
|
314
|
+
},
|
|
315
|
+
delete: function (key, services) {
|
|
316
|
+
services.store.delete(key);
|
|
317
|
+
services.metadataRepository.delete(key);
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
function dedupe(value) {
|
|
321
|
+
if (value === undefined) {
|
|
322
|
+
return value;
|
|
323
|
+
}
|
|
324
|
+
const result = {};
|
|
325
|
+
for (let i = 0, len = value.length; i < len; i += 1) {
|
|
326
|
+
result[value[i]] = true;
|
|
327
|
+
}
|
|
328
|
+
return Object.keys(result);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const GET_OBJECT_INFO_CONFIG_SCHEMA = {
|
|
332
|
+
type: 'object',
|
|
333
|
+
properties: {
|
|
334
|
+
objectApiName: {
|
|
335
|
+
type: 'string',
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
required: ['objectApiName'],
|
|
339
|
+
additionalProperties: false,
|
|
340
|
+
};
|
|
341
|
+
class GetObjectInfoCommand extends TypeRegistryCachePolicyCommand {
|
|
342
|
+
constructor() {
|
|
343
|
+
super(...arguments);
|
|
344
|
+
this.returnTypeNamespace = objectInfoType.namespace;
|
|
345
|
+
this.returnTypeName = objectInfoType.typeName;
|
|
346
|
+
}
|
|
347
|
+
buildKeyConfigFromInstance(instance) {
|
|
348
|
+
return {
|
|
349
|
+
apiName: instance.apiName,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
buildKeyConfig() {
|
|
353
|
+
return {
|
|
354
|
+
apiName: this.config.objectApiName,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
class GetObjectInfoCommandAura extends GetObjectInfoCommand {
|
|
359
|
+
fetch() {
|
|
360
|
+
return convertAuraResponseToData(
|
|
361
|
+
this.services.auraNetwork('RecordUiController.getObjectInfo', this.config)
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function isUnknownResultRepresentation(result) {
|
|
367
|
+
return result.statusCode !== undefined && result.statusCode !== 200;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
class UiApiCompositeCachingCommand extends CachePolicyCommand {
|
|
371
|
+
constructor() {
|
|
372
|
+
super(...arguments);
|
|
373
|
+
// errors don't get cached so we need to capture them during write so we can read then back out
|
|
374
|
+
this.capturedErrors = new Map();
|
|
375
|
+
}
|
|
376
|
+
areResultsEqual(data1, data2) {
|
|
377
|
+
const extractedData = this.extractDataFromEnvelope(data1);
|
|
378
|
+
const extractedData2 = this.extractDataFromEnvelope(data2);
|
|
379
|
+
if (extractedData.length !== extractedData2.length) {
|
|
380
|
+
return false;
|
|
381
|
+
}
|
|
382
|
+
for (let i = 0; i < extractedData.length; i++) {
|
|
383
|
+
if (!this.childReturnType.equals(extractedData[i], extractedData2[i], this.services)) {
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
readFromL1(services) {
|
|
390
|
+
try {
|
|
391
|
+
const childKeyConfigs = this.buildChildKeyConfigs();
|
|
392
|
+
const envelopeEntries = [];
|
|
393
|
+
let missingKeys = [];
|
|
394
|
+
for (const childKeyConfig of childKeyConfigs) {
|
|
395
|
+
const key = this.childReturnType.buildKey(childKeyConfig);
|
|
396
|
+
const data = this.childReturnType.read(key, {
|
|
397
|
+
...this.services,
|
|
398
|
+
store: services.store,
|
|
399
|
+
});
|
|
400
|
+
if (data === undefined) {
|
|
401
|
+
let error = this.capturedErrors.get(key);
|
|
402
|
+
if (error !== undefined) {
|
|
403
|
+
envelopeEntries.push(error);
|
|
404
|
+
} else {
|
|
405
|
+
// TODO [W-14867120]: once commands cache errors we should check to see if there's a cached error
|
|
406
|
+
// keep reading so other keys get picked up for revive and dedupe
|
|
407
|
+
missingKeys.push(key);
|
|
408
|
+
envelopeEntries.push(undefined);
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
envelopeEntries.push(data);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
let envelopeData = this.envelopeData(envelopeEntries);
|
|
415
|
+
if (missingKeys.length > 0) {
|
|
416
|
+
return {
|
|
417
|
+
dataComplete: false,
|
|
418
|
+
data: envelopeData,
|
|
419
|
+
// TODO [W-15288468]: DataNotFoundError should allow for an optional list of missing keys
|
|
420
|
+
errors: [new DataNotFoundError(`missing keys: ${missingKeys.join(',')}`)],
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
dataComplete: true,
|
|
425
|
+
data: envelopeData,
|
|
426
|
+
errors: [],
|
|
427
|
+
};
|
|
428
|
+
} catch (e) {
|
|
429
|
+
return {
|
|
430
|
+
dataComplete: false,
|
|
431
|
+
data: undefined,
|
|
432
|
+
errors: [toError(e)],
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
writeToL1(networkResult, services) {
|
|
437
|
+
const childKeyConfigs = this.buildChildKeyConfigs();
|
|
438
|
+
if (networkResult.errors.length === 0 && networkResult.data && networkResult.data.results) {
|
|
439
|
+
if (childKeyConfigs.length !== networkResult.data.results.length) {
|
|
440
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
441
|
+
throw new Error('Mismatched number of results');
|
|
442
|
+
}
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
// Do we want to add a hook for a child command to define a validation fn if the
|
|
446
|
+
// composite response contains the correct data?
|
|
447
|
+
networkResult.dataComplete = true;
|
|
448
|
+
}
|
|
449
|
+
if (networkResult.dataComplete) {
|
|
450
|
+
for (let i = 0; i < childKeyConfigs.length; i++) {
|
|
451
|
+
const result = networkResult.data.results[i];
|
|
452
|
+
if (isUnknownResultRepresentation(result)) {
|
|
453
|
+
const keyConfig = childKeyConfigs[i];
|
|
454
|
+
const key = this.childReturnType.buildKey(keyConfig);
|
|
455
|
+
this.capturedErrors.set(key, result);
|
|
456
|
+
} else {
|
|
457
|
+
const keyConfig = this.buildChildKeyConfigFromInstance(result.result);
|
|
458
|
+
const key = this.childReturnType.buildKey(keyConfig);
|
|
459
|
+
this.childReturnType.write(key, result.result, services);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
get childReturnType() {
|
|
465
|
+
return this.services.typeRegistry.get(this.compositeTypeNamespace, this.compositeTypeName);
|
|
466
|
+
}
|
|
467
|
+
envelopeData(data) {
|
|
468
|
+
const results = [];
|
|
469
|
+
for (let i = 0; i < data.length; i++) {
|
|
470
|
+
const result = data[i];
|
|
471
|
+
if (result === undefined || isUnknownResultRepresentation(result)) {
|
|
472
|
+
results.push(result);
|
|
473
|
+
} else {
|
|
474
|
+
results.push({
|
|
475
|
+
statusCode: 200,
|
|
476
|
+
result: result,
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return { results };
|
|
481
|
+
}
|
|
482
|
+
extractDataFromEnvelope(envelope) {
|
|
483
|
+
return envelope.results.map((result) => {
|
|
484
|
+
if (isUnknownResultRepresentation(result)) {
|
|
485
|
+
return result;
|
|
486
|
+
} else {
|
|
487
|
+
return result.result;
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
const GET_OBJECT_INFOS_CONFIG_SCHEMA = {
|
|
494
|
+
type: 'object',
|
|
495
|
+
properties: {
|
|
496
|
+
objectApiNames: {
|
|
497
|
+
type: 'array',
|
|
498
|
+
items: {
|
|
499
|
+
type: 'string',
|
|
500
|
+
},
|
|
501
|
+
minItems: 1,
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
required: ['objectApiNames'],
|
|
505
|
+
additionalProperties: false,
|
|
506
|
+
};
|
|
507
|
+
class GetObjectInfosCommand extends UiApiCompositeCachingCommand {
|
|
508
|
+
constructor(config, commandContext, services) {
|
|
509
|
+
super({ objectApiNames: dedupe(config.objectApiNames) }, commandContext, services);
|
|
510
|
+
this.compositeTypeNamespace = UiApiNamespace;
|
|
511
|
+
this.compositeTypeName = ObjectInfoRepresentationName;
|
|
512
|
+
}
|
|
513
|
+
buildChildKeyConfigs() {
|
|
514
|
+
return this.config.objectApiNames.map((objectApiName) => ({ apiName: objectApiName }));
|
|
515
|
+
}
|
|
516
|
+
buildChildKeyConfigFromInstance(instance) {
|
|
517
|
+
return { apiName: instance.apiName };
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
class GetObjectInfosCommandAura extends GetObjectInfosCommand {
|
|
521
|
+
fetch() {
|
|
522
|
+
return convertAuraResponseToData(
|
|
523
|
+
this.services.auraNetwork('RecordUiController.getObjectInfos', this.config)
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
let getObjectInfo;
|
|
529
|
+
let getObjectInfos;
|
|
530
|
+
const serviceRequirements = {
|
|
531
|
+
metadataRepository: {
|
|
532
|
+
type: 'metadataRepository',
|
|
533
|
+
version: '1.0',
|
|
534
|
+
},
|
|
535
|
+
store: {
|
|
536
|
+
type: 'store',
|
|
537
|
+
version: '1.0',
|
|
538
|
+
},
|
|
539
|
+
keySubscription: {
|
|
540
|
+
type: 'keySubscription',
|
|
541
|
+
version: '1.0',
|
|
542
|
+
},
|
|
543
|
+
typeRegistry: {
|
|
544
|
+
type: 'typeRegistry',
|
|
545
|
+
version: '1.0',
|
|
546
|
+
},
|
|
547
|
+
cacheInclusionPolicy: {
|
|
548
|
+
type: 'cacheInclusionPolicy',
|
|
549
|
+
version: '1.0',
|
|
550
|
+
},
|
|
551
|
+
cachePolicy: {
|
|
552
|
+
type: 'cachePolicy',
|
|
553
|
+
version: '1.0',
|
|
554
|
+
},
|
|
555
|
+
auraNetwork: {
|
|
556
|
+
type: 'auraNetwork',
|
|
557
|
+
version: '1.0',
|
|
558
|
+
},
|
|
559
|
+
requestDedupe: {
|
|
560
|
+
type: 'requestDedupe',
|
|
561
|
+
version: '1.0',
|
|
562
|
+
},
|
|
563
|
+
};
|
|
564
|
+
racesync([getServices(serviceRequirements)]).then(
|
|
565
|
+
(services) => {
|
|
566
|
+
services.typeRegistry.register(objectInfoType);
|
|
567
|
+
getObjectInfo = class extends CommandWireAdapterConstructor {
|
|
568
|
+
constructor() {
|
|
569
|
+
super(...arguments);
|
|
570
|
+
this.configSchema = GET_OBJECT_INFO_CONFIG_SCHEMA;
|
|
571
|
+
}
|
|
572
|
+
getCommand() {
|
|
573
|
+
return new GetObjectInfoCommandAura(this.config, {}, services);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
getObjectInfos = class extends CommandWireAdapterConstructor {
|
|
577
|
+
constructor() {
|
|
578
|
+
super(...arguments);
|
|
579
|
+
this.configSchema = GET_OBJECT_INFOS_CONFIG_SCHEMA;
|
|
580
|
+
}
|
|
581
|
+
getCommand() {
|
|
582
|
+
return new GetObjectInfosCommandAura(this.config, {}, services);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
},
|
|
586
|
+
(_err) => {}
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
export { getObjectInfo, getObjectInfos };
|
|
590
|
+
// version: 0.1.0-dev1-54c03dd38c
|