@salesforce/lds-adapters-uiapi-lex 1.327.0 → 1.329.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-adapters-uiapi-lex",
3
- "version": "1.327.0",
3
+ "version": "1.329.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "UIAPI LWC Adapters built for LEX",
6
6
  "repository": {
@@ -13,7 +13,188 @@
13
13
  */
14
14
  /* proxy-compat-disable */
15
15
  import { CommandWireAdapterConstructor } from 'force/luvioLwcBindings5';
16
- import { serviceBroker } from 'force/luvioServiceBroker5';
16
+
17
+ /**
18
+ * Copyright (c) 2022, Salesforce, Inc.,
19
+ * All rights reserved.
20
+ * For full license text, see the LICENSE.txt file
21
+ */
22
+
23
+
24
+ /**
25
+ * Indicates if a given instance of a service satisfies a request. Note that this function
26
+ * assumes the version numbers are valid strings.
27
+ *
28
+ * @param provided ServiceVersion of the service instance to be provided
29
+ * @param requested ServiceVersion requested
30
+ * @returns true if the service instance to be provided satisfies the request
31
+ */
32
+ function satisfies(provided, requested) {
33
+ const providedN = provided.split('.').map((s) => parseInt(s));
34
+ const requestedN = requested.split('.').map((s) => parseInt(s));
35
+ return providedN[0] === requestedN[0] && providedN[1] >= requestedN[1];
36
+ }
37
+
38
+ /**
39
+ * Copyright (c) 2022, Salesforce, Inc.,
40
+ * All rights reserved.
41
+ * For full license text, see the LICENSE.txt file
42
+ */
43
+
44
+
45
+ /**
46
+ * Attempts to resolve a set of requested services against a set of published services.
47
+ * Returns a map of the requested services if the published services satisfy the request;
48
+ * undefined if published services are missing one or more of the requested services.
49
+ *
50
+ * Note that this function is exported ONLY for use by runtime environments that need to
51
+ * override the default getServices() implementation below. Service consumers should only
52
+ * use the default export to request the services they need.
53
+ *
54
+ * @param published published services
55
+ * @param requested requested services
56
+ * @returns service map if published satisfies requests; undefined if not
57
+ */
58
+ function resolve(published, requested) {
59
+ const result = {};
60
+ for (const [name, request] of Object.entries(requested)) {
61
+ const matchingService = published.find((s) =>
62
+ // service types must match
63
+ s.type === request.type &&
64
+ // version of the service must satisfy the requested version
65
+ satisfies(s.version, request.version) &&
66
+ // no tags requested, or the service matches every requested tag value
67
+ (request.tags === undefined ||
68
+ Object.keys(request.tags).every((tag) => { var _a; return ((_a = s.tags) === null || _a === void 0 ? void 0 : _a[tag]) === request.tags[tag]; })));
69
+ if (matchingService) {
70
+ result[name] = matchingService.service;
71
+ }
72
+ else if (!('optional' in request && request.optional)) {
73
+ return;
74
+ }
75
+ }
76
+ return result;
77
+ }
78
+ let waitForServices = new Promise((resolve) => (resolve));
79
+ /**
80
+ * Requests a given set of services from the runtime environment.
81
+ *
82
+ * The default implementation of this function guarantees that the return
83
+ * PromiseLike will be resolved synchronously. That is, one of the functions
84
+ * supplied to its .then() will be invoked before .then() returns. Overrides
85
+ * of this function SHOULD preserve this behavior whenever possible, as
86
+ * some service consumer initialization patterns cannot support asynchronous
87
+ * initialization of services.
88
+ *
89
+ * @param request requested services
90
+ * @returns PromiseLike for the requested services; rejects if the requested
91
+ * services are not available
92
+ */
93
+ function getServices(request) {
94
+ return waitForServices.then((services) => {
95
+ // try to resolve the requested services against our services
96
+ const result = resolve(services, request);
97
+ // resolve/reject based on whether we have all the requested services
98
+ if (result) {
99
+ return result;
100
+ }
101
+ throw new Error('no matches found for one or more requested services');
102
+ });
103
+ }
104
+
105
+ /**
106
+ * Copyright (c) 2022, Salesforce, Inc.,
107
+ * All rights reserved.
108
+ * For full license text, see the LICENSE.txt file
109
+ */
110
+
111
+
112
+ /**
113
+ * Returns a PromiseLike object that resolves with the specified result.
114
+ *
115
+ * @param result resolved result
116
+ * @returns
117
+ */
118
+ function resolvedPromiseLike(result) {
119
+ // Don't nest anything promise like
120
+ if (isPromiseLike(result)) {
121
+ return result.then((nextResult) => nextResult);
122
+ }
123
+ return {
124
+ then: (onFulfilled, _onRejected) => {
125
+ if (onFulfilled) {
126
+ try {
127
+ return resolvedPromiseLike(onFulfilled(result));
128
+ }
129
+ catch (e) {
130
+ return rejectedPromiseLike(e);
131
+ }
132
+ }
133
+ // assume TResult1 == Result and just pass result down the chain
134
+ return resolvedPromiseLike(result);
135
+ },
136
+ };
137
+ }
138
+ /**
139
+ * Returns a PromiseLike object that rejects with the specified reason.
140
+ *
141
+ * @param reason rejection value
142
+ * @returns PromiseLike that rejects with reason
143
+ */
144
+ function rejectedPromiseLike(reason) {
145
+ if (isPromiseLike(reason)) {
146
+ return reason.then((nextResult) => nextResult);
147
+ }
148
+ return {
149
+ then: (_onFulfilled, onRejected) => {
150
+ if (onRejected) {
151
+ try {
152
+ return resolvedPromiseLike(onRejected(reason));
153
+ }
154
+ catch (e) {
155
+ return rejectedPromiseLike(e);
156
+ }
157
+ }
158
+ // assume TResult2 == Result and just pass rejection down the chain
159
+ return rejectedPromiseLike(reason);
160
+ },
161
+ };
162
+ }
163
+ /**
164
+ * Indicates if an object is PromiseLike.
165
+ *
166
+ * @param x anything
167
+ * @returns true if x is PromiseLike; false if not
168
+ */
169
+ function isPromiseLike(x) {
170
+ return typeof x === 'object' && typeof (x === null || x === void 0 ? void 0 : x.then) === 'function';
171
+ }
172
+ /**
173
+ * As Promise.race, but returns sychronously if any of the supplied values resolve/reject
174
+ * synchronously.
175
+ *
176
+ * @param values as Promise.race
177
+ * @returns as Promise.race
178
+ */
179
+ function racesync(values) {
180
+ for (const value of values) {
181
+ let settled = undefined;
182
+ if (isPromiseLike(value)) {
183
+ value.then((_) => {
184
+ settled = value;
185
+ }, (_) => {
186
+ settled = value;
187
+ });
188
+ }
189
+ else {
190
+ settled = resolvedPromiseLike(value);
191
+ }
192
+ if (settled !== undefined) {
193
+ return settled;
194
+ }
195
+ }
196
+ return Promise.race(values);
197
+ }
17
198
 
18
199
  /**
19
200
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -310,7 +491,7 @@ class GetObjectInfosCommandAura extends GetObjectInfosCommand {
310
491
 
311
492
  let getObjectInfo;
312
493
  let getObjectInfos;
313
- const serviceRequests = {
494
+ const serviceRequirements = {
314
495
  metadataRepository: {
315
496
  type: 'metadataRepository',
316
497
  version: '1.0',
@@ -344,27 +525,30 @@ const serviceRequests = {
344
525
  version: '1.0',
345
526
  },
346
527
  };
347
- serviceBroker.subscribe((services) => {
348
- services.typeRegistry.register(objectInfoType);
349
- getObjectInfo = class extends CommandWireAdapterConstructor {
350
- constructor() {
351
- super(...arguments);
352
- this.configSchema = GET_OBJECT_INFO_CONFIG_SCHEMA;
353
- }
354
- getCommand() {
355
- return new GetObjectInfoCommandAura(this.config, {}, services);
356
- }
357
- };
358
- getObjectInfos = class extends CommandWireAdapterConstructor {
359
- constructor() {
360
- super(...arguments);
361
- this.configSchema = GET_OBJECT_INFOS_CONFIG_SCHEMA;
362
- }
363
- getCommand() {
364
- return new GetObjectInfosCommandAura(this.config, {}, services);
365
- }
366
- };
367
- }, serviceRequests);
528
+ racesync([getServices(serviceRequirements)]).then(
529
+ (services) => {
530
+ services.typeRegistry.register(objectInfoType);
531
+ getObjectInfo = class extends CommandWireAdapterConstructor {
532
+ constructor() {
533
+ super(...arguments);
534
+ this.configSchema = GET_OBJECT_INFO_CONFIG_SCHEMA;
535
+ }
536
+ getCommand() {
537
+ return new GetObjectInfoCommandAura(this.config, {}, services);
538
+ }
539
+ };
540
+ getObjectInfos = class extends CommandWireAdapterConstructor {
541
+ constructor() {
542
+ super(...arguments);
543
+ this.configSchema = GET_OBJECT_INFOS_CONFIG_SCHEMA;
544
+ }
545
+ getCommand() {
546
+ return new GetObjectInfosCommandAura(this.config, {}, services);
547
+ }
548
+ };
549
+ },
550
+ (_err) => {}
551
+ );
368
552
 
369
553
  export { getObjectInfo, getObjectInfos };
370
- // version: 1.327.0-8614d511e1
554
+ // version: 1.329.0-9b52e8059d