@salesforce/nimbus-plugin-lds 1.112.2 → 1.113.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.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NetworkAdapter, NetworkError, Request, Response } from '../NetworkAdapter';
|
|
2
|
+
export declare class MockNimbusNetworkAdapter implements NetworkAdapter {
|
|
3
|
+
private mockResponses;
|
|
4
|
+
sentRequests: Request[];
|
|
5
|
+
setMockResponse(mockResponse: Response): void;
|
|
6
|
+
setMockResponses(mockResponses: Response[]): void;
|
|
7
|
+
sendRequest(request: Request, onResponse: (response: Response) => void, onError: (error: NetworkError) => void): Promise<string>;
|
|
8
|
+
cancelRequest(_token: string): void;
|
|
9
|
+
setAsGlobalNimbusPlugin(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MockNimbusNetworkAdapter } from './MockNimbusNetworkAdapter';
|
|
@@ -0,0 +1,43 @@
|
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/nimbus-plugin-lds",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.113.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/index.d.ts",
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
],
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"import": "./dist/index.js",
|
|
16
15
|
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./mocks": {
|
|
20
|
+
"types": "./dist/mocks/index.d.ts",
|
|
21
|
+
"import": "./dist/mocks/index.js",
|
|
22
|
+
"default": "./dist/mocks/index.js"
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
"scripts": {
|
|
@@ -25,7 +30,7 @@
|
|
|
25
30
|
},
|
|
26
31
|
"devDependencies": {
|
|
27
32
|
"@rollup/plugin-wasm": "^5.2.0",
|
|
28
|
-
"@salesforce/lds-store-sql": "^1.
|
|
33
|
+
"@salesforce/lds-store-sql": "^1.113.0",
|
|
29
34
|
"@types/sql.js": "1.4.3",
|
|
30
35
|
"nimbus-types": "^2.0.0-alpha1",
|
|
31
36
|
"rollup-plugin-string": "^3.0.0",
|