@salesforce/lds-adapters-uiapi-lex 1.285.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.
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@salesforce/lds-adapters-uiapi-lex",
3
+ "version": "1.285.0",
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
+ "exports": {
29
+ "./sfdc": {
30
+ "types": "./sfdc/sfdc.d.ts",
31
+ "import": "./sfdc/ldsAdaptersUiapiLex.js",
32
+ "default": "./sfdc/ldsAdaptersUiapiLex.js"
33
+ }
34
+ },
35
+ "scripts": {
36
+ "prepare": "yarn build",
37
+ "build": "rollup --bundleConfigAsCjs --config rollup.config.js",
38
+ "clean": "rm -rf sfdc"
39
+ },
40
+ "nx": {
41
+ "targets": {
42
+ "build": {
43
+ "outputs": [
44
+ "{projectRoot}/sfdc"
45
+ ]
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,307 @@
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 { convertAuraResponseToData, TypeRegistryCachePolicyCommand, CachePolicyCommand, DataNotFoundError, toError } from 'force/luvioRuntime3';
16
+ import { CommandWireAdapterConstructor } from 'force/luvioLwcBindings3';
17
+ import { register } from 'force/luvioRegistry';
18
+
19
+ /**
20
+ * Copyright (c) 2022, Salesforce, Inc.,
21
+ * All rights reserved.
22
+ * For full license text, see the LICENSE.txt file
23
+ */
24
+
25
+
26
+ /**
27
+ * Copyright (c) 2022, Salesforce, Inc.,
28
+ * All rights reserved.
29
+ * For full license text, see the LICENSE.txt file
30
+ */
31
+
32
+ const UiApiNamespace = 'UiApi';
33
+
34
+ const ObjectInfoRepresentationName = 'ObjectInfoRepresentation';
35
+ const objectInfoType = {
36
+ namespace: UiApiNamespace,
37
+ typeName: ObjectInfoRepresentationName,
38
+ // 15 * 60 * 1000 = 15 minutes
39
+ ttl: 900000,
40
+ buildKey: function (config) {
41
+ return `${this.namespace}::${this.typeName}::${config.apiName}`;
42
+ },
43
+ equals: function (x, y, _typeRegistry) {
44
+ return x.apiName === y.apiName && x.eTag === y.eTag;
45
+ },
46
+ read: function (key, services) {
47
+ return services.store.get(key);
48
+ },
49
+ write: function (key, data, services) {
50
+ const now = Date.now();
51
+ const store = services.store;
52
+ services.metadataRepository.set(key, {
53
+ namespace: this.namespace,
54
+ typeName: this.typeName,
55
+ ingestionTime: now,
56
+ expirationTime: now + this.ttl,
57
+ });
58
+ const existing = store.get(key);
59
+ if (existing && this.equals(existing, data, services)) {
60
+ return;
61
+ }
62
+ store.set(key, data);
63
+ },
64
+ };
65
+ function dedupe(value) {
66
+ if (value === undefined) {
67
+ return value;
68
+ }
69
+ const result = {};
70
+ for (let i = 0, len = value.length; i < len; i += 1) {
71
+ result[value[i]] = true;
72
+ }
73
+ return Object.keys(result);
74
+ }
75
+
76
+ class GetObjectInfoCommand extends TypeRegistryCachePolicyCommand {
77
+ constructor() {
78
+ super(...arguments);
79
+ this.returnTypeNamespace = objectInfoType.namespace;
80
+ this.returnTypeName = objectInfoType.typeName;
81
+ this.configJsonSchema = {
82
+ type: 'object',
83
+ properties: {
84
+ objectApiName: {
85
+ type: 'string',
86
+ },
87
+ },
88
+ required: ['objectApiName'],
89
+ additionalProperties: false,
90
+ };
91
+ }
92
+ buildKeyConfigFromInstance(instance) {
93
+ return {
94
+ apiName: instance.apiName,
95
+ };
96
+ }
97
+ buildKeyConfig() {
98
+ return {
99
+ apiName: this.config.objectApiName,
100
+ };
101
+ }
102
+ }
103
+ class GetObjectInfoCommandAura extends GetObjectInfoCommand {
104
+ fetch() {
105
+ return convertAuraResponseToData(
106
+ this.services.auraNetwork('RecordUiController.getObjectInfo', this.config)
107
+ );
108
+ }
109
+ }
110
+
111
+ function isUnknownResultRepresentation(result) {
112
+ return result.statusCode !== undefined && result.statusCode !== 200;
113
+ }
114
+
115
+ class UiApiCompositeCachingCommand extends CachePolicyCommand {
116
+ constructor() {
117
+ super(...arguments);
118
+ // errors don't get cached so we need to capture them during write so we can read then back out
119
+ this.capturedErrors = new Map();
120
+ }
121
+ areResultsEqual(data1, data2) {
122
+ const extractedData = this.extractDataFromEnvelope(data1);
123
+ const extractedData2 = this.extractDataFromEnvelope(data2);
124
+ if (extractedData.length !== extractedData2.length) {
125
+ return false;
126
+ }
127
+ for (let i = 0; i < extractedData.length; i++) {
128
+ if (!this.childReturnType.equals(extractedData[i], extractedData2[i], this.services)) {
129
+ return false;
130
+ }
131
+ }
132
+ return true;
133
+ }
134
+ readFromL1(services) {
135
+ try {
136
+ const childKeyConfigs = this.buildChildKeyConfigs();
137
+ const envelopeEntries = [];
138
+ let missingKeys = [];
139
+ for (const childKeyConfig of childKeyConfigs) {
140
+ const key = this.childReturnType.buildKey(childKeyConfig);
141
+ const data = this.childReturnType.read(key, {
142
+ ...this.services,
143
+ store: services.store,
144
+ });
145
+ if (data === undefined) {
146
+ let error = this.capturedErrors.get(key);
147
+ if (error !== undefined) {
148
+ envelopeEntries.push(error);
149
+ } else {
150
+ // TODO [W-14867120]: once commands cache errors we should check to see if there's a cached error
151
+ // keep reading so other keys get picked up for revive and dedupe
152
+ missingKeys.push(key);
153
+ envelopeEntries.push(undefined);
154
+ }
155
+ } else {
156
+ envelopeEntries.push(data);
157
+ }
158
+ }
159
+ let envelopeData = this.envelopeData(envelopeEntries);
160
+ if (missingKeys.length > 0) {
161
+ return {
162
+ dataComplete: false,
163
+ data: envelopeData,
164
+ // TODO [W-15288468]: DataNotFoundError should allow for an optional list of missing keys
165
+ errors: [new DataNotFoundError(`missing keys: ${missingKeys.join(',')}`)],
166
+ };
167
+ }
168
+ return {
169
+ dataComplete: true,
170
+ data: envelopeData,
171
+ errors: [],
172
+ };
173
+ } catch (e) {
174
+ return {
175
+ dataComplete: false,
176
+ data: undefined,
177
+ errors: [toError(e)],
178
+ };
179
+ }
180
+ }
181
+ writeToL1(networkResult, services) {
182
+ const childKeyConfigs = this.buildChildKeyConfigs();
183
+ if (networkResult.errors.length === 0 && networkResult.data && networkResult.data.results) {
184
+ if (childKeyConfigs.length !== networkResult.data.results.length) {
185
+ if (process.env.NODE_ENV !== 'production') {
186
+ throw new Error('Mismatched number of results');
187
+ }
188
+ return;
189
+ }
190
+ // Do we want to add a hook for a child command to define a validation fn if the
191
+ // composite response contains the correct data?
192
+ networkResult.dataComplete = true;
193
+ }
194
+ if (networkResult.dataComplete) {
195
+ for (let i = 0; i < childKeyConfigs.length; i++) {
196
+ const result = networkResult.data.results[i];
197
+ if (isUnknownResultRepresentation(result)) {
198
+ const keyConfig = childKeyConfigs[i];
199
+ const key = this.childReturnType.buildKey(keyConfig);
200
+ this.capturedErrors.set(key, result);
201
+ } else {
202
+ const keyConfig = this.buildChildKeyConfigFromInstance(result.result);
203
+ const key = this.childReturnType.buildKey(keyConfig);
204
+ this.childReturnType.write(key, result.result, services);
205
+ }
206
+ }
207
+ }
208
+ }
209
+ get childReturnType() {
210
+ return this.services.typeRegistry.get(this.compositeTypeNamespace, this.compositeTypeName);
211
+ }
212
+ envelopeData(data) {
213
+ const results = [];
214
+ for (let i = 0; i < data.length; i++) {
215
+ const result = data[i];
216
+ if (result === undefined || isUnknownResultRepresentation(result)) {
217
+ results.push(result);
218
+ } else {
219
+ results.push({
220
+ statusCode: 200,
221
+ result: result,
222
+ });
223
+ }
224
+ }
225
+ return { results };
226
+ }
227
+ extractDataFromEnvelope(envelope) {
228
+ return envelope.results.map((result) => {
229
+ if (isUnknownResultRepresentation(result)) {
230
+ return result;
231
+ } else {
232
+ return result.result;
233
+ }
234
+ });
235
+ }
236
+ }
237
+
238
+ class GetObjectInfosCommand extends UiApiCompositeCachingCommand {
239
+ constructor(config, commandContext, services) {
240
+ const coercedConfig = { objectApiNames: dedupe(config.objectApiNames) };
241
+ super(coercedConfig, commandContext, services);
242
+ this.configJsonSchema = {
243
+ type: 'object',
244
+ properties: {
245
+ objectApiNames: {
246
+ type: 'array',
247
+ items: {
248
+ type: 'string',
249
+ },
250
+ minItems: 1,
251
+ },
252
+ },
253
+ required: ['objectApiNames'],
254
+ additionalProperties: false,
255
+ };
256
+ this.compositeTypeNamespace = UiApiNamespace;
257
+ this.compositeTypeName = ObjectInfoRepresentationName;
258
+ }
259
+ buildChildKeyConfigs() {
260
+ return this.config.objectApiNames.map((objectApiName) => ({ apiName: objectApiName }));
261
+ }
262
+ buildChildKeyConfigFromInstance(instance) {
263
+ return { apiName: instance.apiName };
264
+ }
265
+ }
266
+ class GetObjectInfosCommandAura extends GetObjectInfosCommand {
267
+ fetch() {
268
+ return convertAuraResponseToData(
269
+ this.services.auraNetwork('RecordUiController.getObjectInfos', this.config)
270
+ );
271
+ }
272
+ }
273
+
274
+ const commandModuleRegistration = {
275
+ id: 'commandModule-uiapi',
276
+ services: {
277
+ // TODO [W-15288468]: version values need to be rolled up by the build
278
+ metadataRepository: '1.0.0',
279
+ store: '1.0.0',
280
+ keySubscription: '1.0.0',
281
+ typeRegistry: '1.0.0',
282
+ cacheInclusionPolicy: '1.0.0',
283
+ cachePolicy: '1.0.0',
284
+ auraNetwork: '1.0.0',
285
+ },
286
+ setServices: (services) => {
287
+ services.typeRegistry.register(objectInfoType);
288
+ return {
289
+ getObjectInfo: (getObjectInfo = class extends CommandWireAdapterConstructor {
290
+ getCommand() {
291
+ return new GetObjectInfoCommandAura(this.config, {}, services);
292
+ }
293
+ }),
294
+ getObjectInfos: (getObjectInfos = class extends CommandWireAdapterConstructor {
295
+ getCommand() {
296
+ return new GetObjectInfosCommandAura(this.config, {}, services);
297
+ }
298
+ }),
299
+ };
300
+ },
301
+ };
302
+ register(commandModuleRegistration);
303
+ let getObjectInfo;
304
+ let getObjectInfos;
305
+
306
+ export { getObjectInfo, getObjectInfos };
307
+ // version: 1.285.0-67d4d6869