@salesforce/nimbus-plugin-lds 1.124.2 → 1.124.3
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 +262 -262
- package/dist/mocks/index.js +40 -40
- package/dist/{BinaryStorePlugin.d.ts → types/BinaryStorePlugin.d.ts} +82 -82
- package/dist/{DraftQueue.d.ts → types/DraftQueue.d.ts} +22 -22
- package/dist/{InspectorPlugin.d.ts → types/InspectorPlugin.d.ts} +8 -8
- package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/JsSqliteStorePlugin.d.ts +23 -23
- package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/JsSqliteStorePluginBase.d.ts +17 -17
- package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/JsWorkerSqliteStorePlugin.d.ts +12 -12
- package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/JsWorkerSqliteStorePlugin.worker.d.ts +24 -24
- package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/PluginFunctions.d.ts +9 -9
- package/dist/{NetworkAdapter.d.ts → types/NetworkAdapter.d.ts} +89 -89
- package/dist/{SqliteStorePlugin.d.ts → types/SqliteStorePlugin.d.ts} +152 -152
- package/dist/{index.d.ts → types/index.d.ts} +10 -10
- package/dist/{mocks → types/mocks}/MockNimbusNetworkAdapter.d.ts +10 -10
- package/dist/{mocks → types/mocks}/index.d.ts +1 -1
- package/package.json +4 -4
package/dist/mocks/index.js
CHANGED
|
@@ -1,43 +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
|
-
}
|
|
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
41
|
}
|
|
42
42
|
|
|
43
43
|
export { MockNimbusNetworkAdapter };
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
declare module 'nimbus-types' {
|
|
2
|
-
interface NimbusPlugins {
|
|
3
|
-
LdsBinaryStorePlugin: BinaryStorePlugin;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* A nimbus plugin for interacting with a binary file store.
|
|
8
|
-
*
|
|
9
|
-
* The implementation can be used as a "store" where the file in the store is the only
|
|
10
|
-
* copy and there is essentially no expiration (the file is never stale). Or it can be
|
|
11
|
-
* used as a "cache" where the canonical copy of the file exists somewhere else (like
|
|
12
|
-
* on a remote server).
|
|
13
|
-
*
|
|
14
|
-
* The caching behavior should follow the "stale-while-revalidate" pattern, where
|
|
15
|
-
* a cached file (which has a non-null expiration and a canonical URI) should always
|
|
16
|
-
* return the cached version, and if the file is past expiration (ie: "stale") then
|
|
17
|
-
* the implementation should attempt to re-downloaded the file from the canonical
|
|
18
|
-
* URI in the background.
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export interface BinaryStorePlugin {
|
|
22
|
-
/**
|
|
23
|
-
* Stores a binary file in the store. The file will not have a TTL. This is
|
|
24
|
-
* meant to store local-only files.
|
|
25
|
-
*
|
|
26
|
-
* @param data The data of the binary file to put into the store.
|
|
27
|
-
* @param type The MIME type of the binary file. Ex: "image/png".
|
|
28
|
-
* @param size The number of bytes of data contained within the file.
|
|
29
|
-
* @param onSuccess Callback to call with the string representing the URI of
|
|
30
|
-
* the binary file.
|
|
31
|
-
* @param onError Callback to call if there was an error.
|
|
32
|
-
*/
|
|
33
|
-
storeBinary(data: Uint8Array, type: string, size: number, onSuccess: (uri: string) => void, onError: (errorMessage: string) => void): void;
|
|
34
|
-
/**
|
|
35
|
-
* Caches a binary file in the store. This is meant to locally cache a file
|
|
36
|
-
* thats source-of-truth exists at the given URL.
|
|
37
|
-
*
|
|
38
|
-
* If the file is unable to be downloaded the onError callback will be called.
|
|
39
|
-
*
|
|
40
|
-
* This method should return a URI to the file, which may or may not be the
|
|
41
|
-
* same as the remote URL. In other words, the URI returned to callers should
|
|
42
|
-
* be treated as opaque by the callers.
|
|
43
|
-
*
|
|
44
|
-
* @param url The URL of the file.
|
|
45
|
-
* @param ttlSeconds The TTL in seconds for this file. The file's expiration
|
|
46
|
-
* should be calculated by Date.now + ttlSeconds.
|
|
47
|
-
* @param onSuccess Callback to call with the string representing the URI of
|
|
48
|
-
* the binary file.
|
|
49
|
-
* @param onError Callback to call if there was an error.
|
|
50
|
-
*/
|
|
51
|
-
cacheBinary(url: string, ttlSeconds: number, onSuccess: (uri: string) => void, onError: (errorMessage: string) => void): void;
|
|
52
|
-
/**
|
|
53
|
-
* Removes the binary file given its URI.
|
|
54
|
-
*
|
|
55
|
-
* @param uri The URI of the binary file
|
|
56
|
-
* @param onSuccess Callback to be called once finished. The wasFound
|
|
57
|
-
* parameter will be true if the file existed and has been removed, or
|
|
58
|
-
* false if the file does not exist.
|
|
59
|
-
* @param onError Callback to call if there was an unexpected error.
|
|
60
|
-
*/
|
|
61
|
-
removeBinary(uri: string, onSuccess: (wasFound: boolean) => void, onError: (errorMessage: string) => void): void;
|
|
62
|
-
/**
|
|
63
|
-
* Set the canonical URL for the file at the given uri. The file will immediately
|
|
64
|
-
* be marked as stale (since we know the file's source of truth has changed).
|
|
65
|
-
*
|
|
66
|
-
* If there is no file at the given URI then this method will immediately cache
|
|
67
|
-
* the file at the canonicalUrl (essentially the same as calling {@link cacheBinary}).
|
|
68
|
-
*
|
|
69
|
-
* This method should return a URI to the file, which may or may not be
|
|
70
|
-
* different from the original URI, and may or may not be the same as the
|
|
71
|
-
* canonicalUrl.
|
|
72
|
-
*
|
|
73
|
-
* @param uri The URI of the existing, local binary file
|
|
74
|
-
* @param canonicalUrl The new, canonical URL (a URL is a type of URI) of the file
|
|
75
|
-
* @param ttlSeconds The TTL in seconds for this file. The file's expiration
|
|
76
|
-
* should be calculated by Date.now + ttlSeconds.
|
|
77
|
-
* @param onSuccess Callback to call with the string representing the new URI
|
|
78
|
-
* to the file, which may or may not be the same as canonicalUrl.
|
|
79
|
-
* @param onError Callback to call if there was an error.
|
|
80
|
-
*/
|
|
81
|
-
setCanonicalUrl(uri: string, canonicalUrl: string, ttlSeconds: number, onSuccess: (uri: string) => void, onError: (errorMessage: string) => void): void;
|
|
82
|
-
}
|
|
1
|
+
declare module 'nimbus-types' {
|
|
2
|
+
interface NimbusPlugins {
|
|
3
|
+
LdsBinaryStorePlugin: BinaryStorePlugin;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A nimbus plugin for interacting with a binary file store.
|
|
8
|
+
*
|
|
9
|
+
* The implementation can be used as a "store" where the file in the store is the only
|
|
10
|
+
* copy and there is essentially no expiration (the file is never stale). Or it can be
|
|
11
|
+
* used as a "cache" where the canonical copy of the file exists somewhere else (like
|
|
12
|
+
* on a remote server).
|
|
13
|
+
*
|
|
14
|
+
* The caching behavior should follow the "stale-while-revalidate" pattern, where
|
|
15
|
+
* a cached file (which has a non-null expiration and a canonical URI) should always
|
|
16
|
+
* return the cached version, and if the file is past expiration (ie: "stale") then
|
|
17
|
+
* the implementation should attempt to re-downloaded the file from the canonical
|
|
18
|
+
* URI in the background.
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export interface BinaryStorePlugin {
|
|
22
|
+
/**
|
|
23
|
+
* Stores a binary file in the store. The file will not have a TTL. This is
|
|
24
|
+
* meant to store local-only files.
|
|
25
|
+
*
|
|
26
|
+
* @param data The data of the binary file to put into the store.
|
|
27
|
+
* @param type The MIME type of the binary file. Ex: "image/png".
|
|
28
|
+
* @param size The number of bytes of data contained within the file.
|
|
29
|
+
* @param onSuccess Callback to call with the string representing the URI of
|
|
30
|
+
* the binary file.
|
|
31
|
+
* @param onError Callback to call if there was an error.
|
|
32
|
+
*/
|
|
33
|
+
storeBinary(data: Uint8Array, type: string, size: number, onSuccess: (uri: string) => void, onError: (errorMessage: string) => void): void;
|
|
34
|
+
/**
|
|
35
|
+
* Caches a binary file in the store. This is meant to locally cache a file
|
|
36
|
+
* thats source-of-truth exists at the given URL.
|
|
37
|
+
*
|
|
38
|
+
* If the file is unable to be downloaded the onError callback will be called.
|
|
39
|
+
*
|
|
40
|
+
* This method should return a URI to the file, which may or may not be the
|
|
41
|
+
* same as the remote URL. In other words, the URI returned to callers should
|
|
42
|
+
* be treated as opaque by the callers.
|
|
43
|
+
*
|
|
44
|
+
* @param url The URL of the file.
|
|
45
|
+
* @param ttlSeconds The TTL in seconds for this file. The file's expiration
|
|
46
|
+
* should be calculated by Date.now + ttlSeconds.
|
|
47
|
+
* @param onSuccess Callback to call with the string representing the URI of
|
|
48
|
+
* the binary file.
|
|
49
|
+
* @param onError Callback to call if there was an error.
|
|
50
|
+
*/
|
|
51
|
+
cacheBinary(url: string, ttlSeconds: number, onSuccess: (uri: string) => void, onError: (errorMessage: string) => void): void;
|
|
52
|
+
/**
|
|
53
|
+
* Removes the binary file given its URI.
|
|
54
|
+
*
|
|
55
|
+
* @param uri The URI of the binary file
|
|
56
|
+
* @param onSuccess Callback to be called once finished. The wasFound
|
|
57
|
+
* parameter will be true if the file existed and has been removed, or
|
|
58
|
+
* false if the file does not exist.
|
|
59
|
+
* @param onError Callback to call if there was an unexpected error.
|
|
60
|
+
*/
|
|
61
|
+
removeBinary(uri: string, onSuccess: (wasFound: boolean) => void, onError: (errorMessage: string) => void): void;
|
|
62
|
+
/**
|
|
63
|
+
* Set the canonical URL for the file at the given uri. The file will immediately
|
|
64
|
+
* be marked as stale (since we know the file's source of truth has changed).
|
|
65
|
+
*
|
|
66
|
+
* If there is no file at the given URI then this method will immediately cache
|
|
67
|
+
* the file at the canonicalUrl (essentially the same as calling {@link cacheBinary}).
|
|
68
|
+
*
|
|
69
|
+
* This method should return a URI to the file, which may or may not be
|
|
70
|
+
* different from the original URI, and may or may not be the same as the
|
|
71
|
+
* canonicalUrl.
|
|
72
|
+
*
|
|
73
|
+
* @param uri The URI of the existing, local binary file
|
|
74
|
+
* @param canonicalUrl The new, canonical URL (a URL is a type of URI) of the file
|
|
75
|
+
* @param ttlSeconds The TTL in seconds for this file. The file's expiration
|
|
76
|
+
* should be calculated by Date.now + ttlSeconds.
|
|
77
|
+
* @param onSuccess Callback to call with the string representing the new URI
|
|
78
|
+
* to the file, which may or may not be the same as canonicalUrl.
|
|
79
|
+
* @param onError Callback to call if there was an error.
|
|
80
|
+
*/
|
|
81
|
+
setCanonicalUrl(uri: string, canonicalUrl: string, ttlSeconds: number, onSuccess: (uri: string) => void, onError: (errorMessage: string) => void): void;
|
|
82
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
declare module 'nimbus-types' {
|
|
2
|
-
interface NimbusPlugins {
|
|
3
|
-
LdsDraftQueue: DraftQueue;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Defines the DraftQueue that allows LDS running in the webview to interact with the
|
|
8
|
-
* DraftQueue instance running in JSCore. Since the method parameters are opaque
|
|
9
|
-
* to the native container everything passed into the nimbus plugin is serialized
|
|
10
|
-
* and the jscore-side of the plugin implementation will perform the
|
|
11
|
-
* serialization/deserialization of the parameters
|
|
12
|
-
*/
|
|
13
|
-
export interface DraftQueue {
|
|
14
|
-
/**
|
|
15
|
-
* A generic proxy method to invoke various methods on the draft queue
|
|
16
|
-
* @param methodName The name of the proxy method to invoke
|
|
17
|
-
* @param serializedArgsArray A serialized array of arguments
|
|
18
|
-
* @param resultCallback Success callback containing serialized result
|
|
19
|
-
* @param errorCallback Error callback containing serialized error
|
|
20
|
-
*/
|
|
21
|
-
callProxyMethod(methodName: string, serializedArgsArray: string, resultCallback: (serializedResult: string) => void, errorCallback: (serializedError: string) => void): void;
|
|
22
|
-
}
|
|
1
|
+
declare module 'nimbus-types' {
|
|
2
|
+
interface NimbusPlugins {
|
|
3
|
+
LdsDraftQueue: DraftQueue;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Defines the DraftQueue that allows LDS running in the webview to interact with the
|
|
8
|
+
* DraftQueue instance running in JSCore. Since the method parameters are opaque
|
|
9
|
+
* to the native container everything passed into the nimbus plugin is serialized
|
|
10
|
+
* and the jscore-side of the plugin implementation will perform the
|
|
11
|
+
* serialization/deserialization of the parameters
|
|
12
|
+
*/
|
|
13
|
+
export interface DraftQueue {
|
|
14
|
+
/**
|
|
15
|
+
* A generic proxy method to invoke various methods on the draft queue
|
|
16
|
+
* @param methodName The name of the proxy method to invoke
|
|
17
|
+
* @param serializedArgsArray A serialized array of arguments
|
|
18
|
+
* @param resultCallback Success callback containing serialized result
|
|
19
|
+
* @param errorCallback Error callback containing serialized error
|
|
20
|
+
*/
|
|
21
|
+
callProxyMethod(methodName: string, serializedArgsArray: string, resultCallback: (serializedResult: string) => void, errorCallback: (serializedError: string) => void): void;
|
|
22
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare module 'nimbus-types' {
|
|
2
|
-
interface NimbusPlugins {
|
|
3
|
-
LdsInspectorPlugin: InspectorPlugin;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
export interface InspectorPlugin {
|
|
7
|
-
sendAdapterReport(serializedReport: string): void;
|
|
8
|
-
}
|
|
1
|
+
declare module 'nimbus-types' {
|
|
2
|
+
interface NimbusPlugins {
|
|
3
|
+
LdsInspectorPlugin: InspectorPlugin;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export interface InspectorPlugin {
|
|
7
|
+
sendAdapterReport(serializedReport: string): void;
|
|
8
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
-
import type { Database } from 'sql.js';
|
|
3
|
-
import type { SqliteOperation, SqliteStorePlugin } from '../SqliteStorePlugin';
|
|
4
|
-
import { JsSqliteStorePluginBase } from './JsSqliteStorePluginBase';
|
|
5
|
-
type DatabaseFactory = () => Promise<Database>;
|
|
6
|
-
/**
|
|
7
|
-
* A class that implements the {@link SqliteStorePlugin} interface based on
|
|
8
|
-
* sql.js (https://sql.js.org/)
|
|
9
|
-
*/
|
|
10
|
-
export declare class JsSqliteStorePlugin extends JsSqliteStorePluginBase implements SqliteStorePlugin {
|
|
11
|
-
private db;
|
|
12
|
-
private readonly dbFactory;
|
|
13
|
-
/**
|
|
14
|
-
* @param factory A factory that returns a Promise to a sql.js Database object
|
|
15
|
-
*/
|
|
16
|
-
constructor(factory: DatabaseFactory);
|
|
17
|
-
private factoryPromise;
|
|
18
|
-
private getDatabase;
|
|
19
|
-
resetDatabase(): void;
|
|
20
|
-
query(sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): Promise<void>;
|
|
21
|
-
batchOperations(operations: SqliteOperation[], onCompletion: (error: string | null) => void): Promise<void>;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
1
|
+
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
+
import type { Database } from 'sql.js';
|
|
3
|
+
import type { SqliteOperation, SqliteStorePlugin } from '../SqliteStorePlugin';
|
|
4
|
+
import { JsSqliteStorePluginBase } from './JsSqliteStorePluginBase';
|
|
5
|
+
type DatabaseFactory = () => Promise<Database>;
|
|
6
|
+
/**
|
|
7
|
+
* A class that implements the {@link SqliteStorePlugin} interface based on
|
|
8
|
+
* sql.js (https://sql.js.org/)
|
|
9
|
+
*/
|
|
10
|
+
export declare class JsSqliteStorePlugin extends JsSqliteStorePluginBase implements SqliteStorePlugin {
|
|
11
|
+
private db;
|
|
12
|
+
private readonly dbFactory;
|
|
13
|
+
/**
|
|
14
|
+
* @param factory A factory that returns a Promise to a sql.js Database object
|
|
15
|
+
*/
|
|
16
|
+
constructor(factory: DatabaseFactory);
|
|
17
|
+
private factoryPromise;
|
|
18
|
+
private getDatabase;
|
|
19
|
+
resetDatabase(): void;
|
|
20
|
+
query(sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): Promise<void>;
|
|
21
|
+
batchOperations(operations: SqliteOperation[], onCompletion: (error: string | null) => void): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
-
import type { SqliteOperation, SqliteStoreChange, SqliteStorePlugin } from '../SqliteStorePlugin';
|
|
3
|
-
type ListenerMap = Map<string, (changes: SqliteStoreChange[]) => void>;
|
|
4
|
-
export declare abstract class JsSqliteStorePluginBase implements SqliteStorePlugin {
|
|
5
|
-
private listenerCounter;
|
|
6
|
-
protected listeners: ListenerMap;
|
|
7
|
-
abstract query(sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): Promise<void>;
|
|
8
|
-
abstract batchOperations(operations: SqliteOperation[], onCompletion: (error: string | null) => void): Promise<void>;
|
|
9
|
-
registerOnChangedListener(listener: (changes: SqliteStoreChange[]) => void): Promise<string>;
|
|
10
|
-
unsubscribeOnChangedListener(id: string): Promise<void>;
|
|
11
|
-
protected notifyListeners(operations: SqliteOperation[]): void;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* This function takes an unknown error and normalizes it to an Error object
|
|
15
|
-
*/
|
|
16
|
-
export declare function normalizeError(error: unknown): Error;
|
|
17
|
-
export {};
|
|
1
|
+
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
+
import type { SqliteOperation, SqliteStoreChange, SqliteStorePlugin } from '../SqliteStorePlugin';
|
|
3
|
+
type ListenerMap = Map<string, (changes: SqliteStoreChange[]) => void>;
|
|
4
|
+
export declare abstract class JsSqliteStorePluginBase implements SqliteStorePlugin {
|
|
5
|
+
private listenerCounter;
|
|
6
|
+
protected listeners: ListenerMap;
|
|
7
|
+
abstract query(sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): Promise<void>;
|
|
8
|
+
abstract batchOperations(operations: SqliteOperation[], onCompletion: (error: string | null) => void): Promise<void>;
|
|
9
|
+
registerOnChangedListener(listener: (changes: SqliteStoreChange[]) => void): Promise<string>;
|
|
10
|
+
unsubscribeOnChangedListener(id: string): Promise<void>;
|
|
11
|
+
protected notifyListeners(operations: SqliteOperation[]): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* This function takes an unknown error and normalizes it to an Error object
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeError(error: unknown): Error;
|
|
17
|
+
export {};
|
package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/JsWorkerSqliteStorePlugin.d.ts
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
-
import { JsSqliteStorePluginBase } from './JsSqliteStorePluginBase';
|
|
3
|
-
import type { SqliteOperation, SqliteStorePlugin } from '../SqliteStorePlugin';
|
|
4
|
-
export declare class JsSqliteStoreWebWorkerPlugin extends JsSqliteStorePluginBase implements SqliteStorePlugin {
|
|
5
|
-
private callbackId;
|
|
6
|
-
private readonly queryCallbackMap;
|
|
7
|
-
private readonly batchCallbackMap;
|
|
8
|
-
private readonly worker;
|
|
9
|
-
constructor();
|
|
10
|
-
query(sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): Promise<void>;
|
|
11
|
-
batchOperations(operations: SqliteOperation[], onCompletion: (error: string | null) => void): Promise<void>;
|
|
12
|
-
}
|
|
1
|
+
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
+
import { JsSqliteStorePluginBase } from './JsSqliteStorePluginBase';
|
|
3
|
+
import type { SqliteOperation, SqliteStorePlugin } from '../SqliteStorePlugin';
|
|
4
|
+
export declare class JsSqliteStoreWebWorkerPlugin extends JsSqliteStorePluginBase implements SqliteStorePlugin {
|
|
5
|
+
private callbackId;
|
|
6
|
+
private readonly queryCallbackMap;
|
|
7
|
+
private readonly batchCallbackMap;
|
|
8
|
+
private readonly worker;
|
|
9
|
+
constructor();
|
|
10
|
+
query(sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): Promise<void>;
|
|
11
|
+
batchOperations(operations: SqliteOperation[], onCompletion: (error: string | null) => void): Promise<void>;
|
|
12
|
+
}
|
package/dist/{JsSqliteStorePlugin → types/JsSqliteStorePlugin}/JsWorkerSqliteStorePlugin.worker.d.ts
RENAMED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { SqliteType } from '@salesforce/lds-store-sql';
|
|
2
|
-
import type { SqliteOperation } from '../SqliteStorePlugin';
|
|
3
|
-
export type QueryRequest = {
|
|
4
|
-
functionName: 'query';
|
|
5
|
-
sql: string;
|
|
6
|
-
params: SqliteType[];
|
|
7
|
-
callbackId: number;
|
|
8
|
-
};
|
|
9
|
-
export type BatchOperationsRequest = {
|
|
10
|
-
functionName: 'batchOperations';
|
|
11
|
-
operations: SqliteOperation[];
|
|
12
|
-
callbackId: number;
|
|
13
|
-
};
|
|
14
|
-
export type Response<T, E = Error> = {
|
|
15
|
-
callbackId: number;
|
|
16
|
-
functionName: 'query' | 'batchOperations';
|
|
17
|
-
result: T;
|
|
18
|
-
error: undefined;
|
|
19
|
-
} | {
|
|
20
|
-
callbackId: number;
|
|
21
|
-
functionName: 'query' | 'batchOperations';
|
|
22
|
-
result: undefined;
|
|
23
|
-
error: E;
|
|
24
|
-
};
|
|
1
|
+
import type { SqliteType } from '@salesforce/lds-store-sql';
|
|
2
|
+
import type { SqliteOperation } from '../SqliteStorePlugin';
|
|
3
|
+
export type QueryRequest = {
|
|
4
|
+
functionName: 'query';
|
|
5
|
+
sql: string;
|
|
6
|
+
params: SqliteType[];
|
|
7
|
+
callbackId: number;
|
|
8
|
+
};
|
|
9
|
+
export type BatchOperationsRequest = {
|
|
10
|
+
functionName: 'batchOperations';
|
|
11
|
+
operations: SqliteOperation[];
|
|
12
|
+
callbackId: number;
|
|
13
|
+
};
|
|
14
|
+
export type Response<T, E = Error> = {
|
|
15
|
+
callbackId: number;
|
|
16
|
+
functionName: 'query' | 'batchOperations';
|
|
17
|
+
result: T;
|
|
18
|
+
error: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
callbackId: number;
|
|
21
|
+
functionName: 'query' | 'batchOperations';
|
|
22
|
+
result: undefined;
|
|
23
|
+
error: E;
|
|
24
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
-
import type { Database } from 'sql.js';
|
|
3
|
-
import type { SqliteOperation } from '../SqliteStorePlugin';
|
|
4
|
-
export declare function query(database: Database, sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): void;
|
|
5
|
-
/**
|
|
6
|
-
* Performs the operations on the DB. NOTE: this function does not do anything
|
|
7
|
-
* with notifying change listeners. Callers need to handle that.
|
|
8
|
-
*/
|
|
9
|
-
export declare function batchOperations(database: Database, operations: SqliteOperation[]): void;
|
|
1
|
+
import type { SqliteType, SqliteResult } from '@salesforce/lds-store-sql';
|
|
2
|
+
import type { Database } from 'sql.js';
|
|
3
|
+
import type { SqliteOperation } from '../SqliteStorePlugin';
|
|
4
|
+
export declare function query(database: Database, sql: string, params: SqliteType[], onResult: (result: SqliteResult) => void, onError: (message: string) => void): void;
|
|
5
|
+
/**
|
|
6
|
+
* Performs the operations on the DB. NOTE: this function does not do anything
|
|
7
|
+
* with notifying change listeners. Callers need to handle that.
|
|
8
|
+
*/
|
|
9
|
+
export declare function batchOperations(database: Database, operations: SqliteOperation[]): void;
|