@salesforce/nimbus-plugin-lds 1.137.0 → 1.138.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/dist/index.js CHANGED
@@ -358,4 +358,46 @@ class JsSqliteStoreWebWorkerPlugin extends JsSqliteStorePluginBase {
358
358
  }
359
359
  }
360
360
 
361
- export { JsSqliteStorePlugin, JsSqliteStoreWebWorkerPlugin, isUpsertOperation, sortedSchemaMigrations };
361
+ /*eslint-env es2020 */
362
+ class MockNimbusNetworkAdapter {
363
+ constructor() {
364
+ this.mockResponses = [];
365
+ this.sentRequests = [];
366
+ }
367
+ setMockResponse(mockResponse) {
368
+ this.mockResponses = [mockResponse];
369
+ }
370
+ setMockResponses(mockResponses) {
371
+ this.mockResponses = mockResponses;
372
+ }
373
+ sendRequest(request, onResponse, onError) {
374
+ this.sentRequests.push(request);
375
+ const mockResponse = this.mockResponses.shift();
376
+ // invoke callbacks on async tick to align with how real implementation works
377
+ setTimeout(() => {
378
+ if (mockResponse === undefined) {
379
+ onError({ type: 'unspecified', message: 'response not set' });
380
+ }
381
+ else {
382
+ onResponse(mockResponse);
383
+ }
384
+ }, 0);
385
+ return Promise.resolve('mocked cancel token');
386
+ }
387
+ cancelRequest(_token) {
388
+ throw Error('Method not implemented.');
389
+ }
390
+ setAsGlobalNimbusPlugin() {
391
+ var _a;
392
+ globalThis.__nimbus = {
393
+ ...(globalThis.__nimbus || {}),
394
+ plugins: {
395
+ // eslint-disable-next-line @salesforce/lds/no-optional-chaining
396
+ ...(((_a = globalThis.__nimbus) === null || _a === void 0 ? void 0 : _a.plugins) || {}),
397
+ LdsNetworkAdapter: this,
398
+ },
399
+ };
400
+ }
401
+ }
402
+
403
+ export { JsSqliteStorePlugin, JsSqliteStoreWebWorkerPlugin, MockNimbusNetworkAdapter, isUpsertOperation, sortedSchemaMigrations };
@@ -8,3 +8,4 @@ export type { InspectorPlugin } from './InspectorPlugin';
8
8
  export { sortedSchemaMigrations, isUpsertOperation } from './SqliteStorePlugin';
9
9
  export { JsSqliteStorePlugin } from './JsSqliteStorePlugin/JsSqliteStorePlugin';
10
10
  export { JsSqliteStoreWebWorkerPlugin } from './JsSqliteStorePlugin/JsWorkerSqliteStorePlugin';
11
+ export { MockNimbusNetworkAdapter } from './mocks/MockNimbusNetworkAdapter';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/nimbus-plugin-lds",
3
- "version": "1.137.0",
3
+ "version": "1.138.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Nimbus plugins for LDS on Mobile native integrations: durable store, networking, and draft queue.",
6
6
  "types": "dist/types/index.d.ts",
@@ -15,11 +15,6 @@
15
15
  "types": "./dist/types/index.d.ts",
16
16
  "import": "./dist/index.js",
17
17
  "default": "./dist/index.js"
18
- },
19
- "./mocks": {
20
- "types": "./dist/types/index.d.ts",
21
- "import": "./dist/mocks/index.js",
22
- "default": "./dist/mocks/index.js"
23
18
  }
24
19
  },
25
20
  "scripts": {
@@ -1,43 +0,0 @@
1
- /*eslint-env es2020 */
2
- class MockNimbusNetworkAdapter {
3
- constructor() {
4
- this.mockResponses = [];
5
- this.sentRequests = [];
6
- }
7
- setMockResponse(mockResponse) {
8
- this.mockResponses = [mockResponse];
9
- }
10
- setMockResponses(mockResponses) {
11
- this.mockResponses = mockResponses;
12
- }
13
- sendRequest(request, onResponse, onError) {
14
- this.sentRequests.push(request);
15
- const mockResponse = this.mockResponses.shift();
16
- // invoke callbacks on async tick to align with how real implementation works
17
- setTimeout(() => {
18
- if (mockResponse === undefined) {
19
- onError({ type: 'unspecified', message: 'response not set' });
20
- }
21
- else {
22
- onResponse(mockResponse);
23
- }
24
- }, 0);
25
- return Promise.resolve('mocked cancel token');
26
- }
27
- cancelRequest(_token) {
28
- throw Error('Method not implemented.');
29
- }
30
- setAsGlobalNimbusPlugin() {
31
- var _a;
32
- globalThis.__nimbus = {
33
- ...(globalThis.__nimbus || {}),
34
- plugins: {
35
- // eslint-disable-next-line @salesforce/lds/no-optional-chaining
36
- ...(((_a = globalThis.__nimbus) === null || _a === void 0 ? void 0 : _a.plugins) || {}),
37
- LdsNetworkAdapter: this,
38
- },
39
- };
40
- }
41
- }
42
-
43
- export { MockNimbusNetworkAdapter };
@@ -1 +0,0 @@
1
- export { MockNimbusNetworkAdapter } from './MockNimbusNetworkAdapter';