@salesforce/lds-store-nimbus 1.415.0 → 1.416.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 +72 -0
- package/dist/types/NimbusSqliteStore.d.ts +1 -0
- package/dist/types/tables/AbstractKeyValueDataTable.d.ts +1 -0
- package/dist/types/tables/LdsDataTable.d.ts +1 -0
- package/dist/types/tables/LdsDataTableBase.d.ts +1 -0
- package/dist/types/tables/LdsInternalDataTable.d.ts +1 -0
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -35,6 +35,27 @@ class LdsDataTable {
|
|
|
35
35
|
}, reject);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
+
getByKeysWithSpecificFields(keys, fields, _segment) {
|
|
39
|
+
// SQLite json_object has a max argument limit (~127 pairs = 254 args)
|
|
40
|
+
// If too many fields requested, return undefined to indicate filtering not possible
|
|
41
|
+
if (fields.size > 100) {
|
|
42
|
+
return Promise.resolve(undefined);
|
|
43
|
+
}
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
// Build JSON object with only the specified fields from the nested 'fields' property
|
|
46
|
+
const jsonFields = Array.from(fields)
|
|
47
|
+
.map((field) => `'${field}', json_extract(${COLUMN_NAME_DATA$2}, '$.fields.${field}')`)
|
|
48
|
+
.join(', ');
|
|
49
|
+
const filteredFieldsExpr = `json_object(${jsonFields})`;
|
|
50
|
+
// Use json_set to replace the 'fields' property in the data with the filtered version
|
|
51
|
+
const filteredDataExpr = `json_set(${COLUMN_NAME_DATA$2}, '$.fields', ${filteredFieldsExpr})`;
|
|
52
|
+
const paramList = keys.map(() => '?').join(',');
|
|
53
|
+
const getQuery = `SELECT ${COLUMN_NAME_KEY$2}, ${filteredDataExpr} as ${COLUMN_NAME_DATA$2}, ${COLUMN_NAME_METADATA$1} FROM ${this.tableName} WHERE ${COLUMN_NAME_KEY$2} IN (${paramList})`;
|
|
54
|
+
this.plugin.query(getQuery, keys, (x) => {
|
|
55
|
+
resolve(this.mapToDurableEntries(x));
|
|
56
|
+
}, reject);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
38
59
|
getMetadataByKeys(keys) {
|
|
39
60
|
const query = selectColumnsFromTableWhereKeyIn([COLUMN_NAME_KEY$2, COLUMN_NAME_METADATA$1], this.tableName, COLUMN_NAME_KEY$2, keys);
|
|
40
61
|
return new Promise((resolve, reject) => {
|
|
@@ -141,6 +162,30 @@ class LdsInternalDataTable {
|
|
|
141
162
|
}, reject);
|
|
142
163
|
});
|
|
143
164
|
}
|
|
165
|
+
getByKeysWithSpecificFields(keys, fields, namespace) {
|
|
166
|
+
if (namespace === undefined) {
|
|
167
|
+
throw Error('LdsInternalDataTable requires namespace');
|
|
168
|
+
}
|
|
169
|
+
// SQLite json_object has a max argument limit (~127 pairs = 254 args)
|
|
170
|
+
// If too many fields requested, return undefined to indicate filtering not possible
|
|
171
|
+
if (fields.size > 100) {
|
|
172
|
+
return Promise.resolve(undefined);
|
|
173
|
+
}
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
175
|
+
// Build JSON object with only the specified fields from the nested 'fields' property
|
|
176
|
+
const jsonFields = Array.from(fields)
|
|
177
|
+
.map((field) => `'${field}', json_extract(${COLUMN_NAME_DATA$1}, '$.fields.${field}')`)
|
|
178
|
+
.join(', ');
|
|
179
|
+
const filteredFieldsExpr = `json_object(${jsonFields})`;
|
|
180
|
+
// Use json_set to replace the 'fields' property in the data with the filtered version
|
|
181
|
+
const filteredDataExpr = `json_set(${COLUMN_NAME_DATA$1}, '$.fields', ${filteredFieldsExpr})`;
|
|
182
|
+
const paramList = keys.map(() => '?').join(',');
|
|
183
|
+
const getQuery = `SELECT ${COLUMN_NAME_KEY$1}, ${filteredDataExpr} as ${COLUMN_NAME_DATA$1}, ${COLUMN_NAME_METADATA}, ${COLUMN_NAME_NAMESPACE} FROM ${this.tableName} WHERE ${COLUMN_NAME_NAMESPACE} = ? AND ${COLUMN_NAME_KEY$1} IN (${paramList})`;
|
|
184
|
+
this.plugin.query(getQuery, [namespace].concat(keys), (x) => {
|
|
185
|
+
resolve(this.mapToDurableEntries(x));
|
|
186
|
+
}, reject);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
144
189
|
getMetadataByKeys(keys, namespace) {
|
|
145
190
|
if (namespace === undefined) {
|
|
146
191
|
throw Error('LdsInternalDataTable requires namespace');
|
|
@@ -281,6 +326,12 @@ class NimbusSqliteStore {
|
|
|
281
326
|
.getByKeys(entryIds, segment)
|
|
282
327
|
.finally(() => tasker.done());
|
|
283
328
|
}
|
|
329
|
+
async getEntriesWithSpecificFields(entryIds, fields, segment) {
|
|
330
|
+
tasker.add();
|
|
331
|
+
return this.getTable(segment)
|
|
332
|
+
.getByKeysWithSpecificFields(entryIds, fields, segment)
|
|
333
|
+
.finally(() => tasker.done());
|
|
334
|
+
}
|
|
284
335
|
async getMetadata(entryIds, segment) {
|
|
285
336
|
tasker.add();
|
|
286
337
|
return this.getTable(segment)
|
|
@@ -440,6 +491,27 @@ class AbstractKeyValueDataTable {
|
|
|
440
491
|
}, reject);
|
|
441
492
|
});
|
|
442
493
|
}
|
|
494
|
+
getByKeysWithSpecificFields(keys, fields, _segment) {
|
|
495
|
+
// SQLite json_object has a max argument limit (~127 pairs = 254 args)
|
|
496
|
+
// If too many fields requested, return undefined to indicate filtering not possible
|
|
497
|
+
if (fields.size > 100) {
|
|
498
|
+
return Promise.resolve(undefined);
|
|
499
|
+
}
|
|
500
|
+
return new Promise((resolve, reject) => {
|
|
501
|
+
// Build JSON object with only the specified fields from the nested 'fields' property
|
|
502
|
+
const jsonFields = Array.from(fields)
|
|
503
|
+
.map((field) => `'${field}', json_extract(${COLUMN_NAME_DATA}, '$.fields.${field}')`)
|
|
504
|
+
.join(', ');
|
|
505
|
+
const filteredFieldsExpr = `json_object(${jsonFields})`;
|
|
506
|
+
// Use json_set to replace the 'fields' property in the data with the filtered version
|
|
507
|
+
const filteredDataExpr = `json_set(${COLUMN_NAME_DATA}, '$.fields', ${filteredFieldsExpr})`;
|
|
508
|
+
const paramList = keys.map(() => '?').join(',');
|
|
509
|
+
const getQuery = `SELECT ${COLUMN_NAME_KEY}, ${filteredDataExpr} as ${COLUMN_NAME_DATA} FROM ${this.tableName} WHERE ${COLUMN_NAME_KEY} IN (${paramList})`;
|
|
510
|
+
this.plugin.query(getQuery, keys, (x) => {
|
|
511
|
+
resolve(this.mapToDurableEntries(x));
|
|
512
|
+
}, reject);
|
|
513
|
+
});
|
|
514
|
+
}
|
|
443
515
|
getMetadataByKeys(_keys) {
|
|
444
516
|
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
445
517
|
throw new Error(`There is no metadata in the ${this.tableName} table.`);
|
|
@@ -16,6 +16,7 @@ export declare class NimbusSqliteStore implements SqliteStore, DurableStore {
|
|
|
16
16
|
query(sql: string, params: SqliteType[]): Promise<SqliteResult>;
|
|
17
17
|
batchQuery(queries: SQLQuery[]): Promise<SqliteResult[]>;
|
|
18
18
|
getEntries<T>(entryIds: string[], segment: string): Promise<DurableStoreEntries<T> | undefined>;
|
|
19
|
+
getEntriesWithSpecificFields<T>(entryIds: string[], fields: Set<string>, segment: string): Promise<DurableStoreEntries<T> | undefined>;
|
|
19
20
|
getMetadata(entryIds: string[], segment: string): Promise<DurableStoreMetadataEntries | undefined>;
|
|
20
21
|
getAllEntries<T>(segment: string): Promise<DurableStoreEntries<T> | undefined>;
|
|
21
22
|
setEntries<T>(entries: DurableStoreEntries<T>, segment: string): Promise<void>;
|
|
@@ -8,6 +8,7 @@ export declare abstract class AbstractKeyValueDataTable implements LdsDataTableB
|
|
|
8
8
|
private conflictColumnNames;
|
|
9
9
|
constructor(plugin: SqliteStorePlugin, tableName: SqliteOperation['table']);
|
|
10
10
|
getByKeys<T>(keys: string[]): Promise<DurableStoreEntries<T>>;
|
|
11
|
+
getByKeysWithSpecificFields<T>(keys: string[], fields: Set<string>, _segment?: string): Promise<DurableStoreEntries<T>>;
|
|
11
12
|
getMetadataByKeys(_keys: string[]): Promise<DurableStoreMetadataEntries | undefined>;
|
|
12
13
|
getAll<T>(): Promise<DurableStoreEntries<T>>;
|
|
13
14
|
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
@@ -9,6 +9,7 @@ export declare class LdsDataTable implements LdsDataTableBase {
|
|
|
9
9
|
private getAllQuery;
|
|
10
10
|
constructor(plugin: SqliteStorePlugin);
|
|
11
11
|
getByKeys<T>(keys: string[]): Promise<DurableStoreEntries<T>>;
|
|
12
|
+
getByKeysWithSpecificFields<T>(keys: string[], fields: Set<string>, _segment?: string): Promise<DurableStoreEntries<T>>;
|
|
12
13
|
getMetadataByKeys(keys: string[]): Promise<DurableStoreMetadataEntries | undefined>;
|
|
13
14
|
getAll<T>(): Promise<DurableStoreEntries<T>>;
|
|
14
15
|
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
@@ -3,6 +3,7 @@ import type { SqliteOperation } from '@salesforce/nimbus-plugin-lds';
|
|
|
3
3
|
export interface LdsDataTableBase {
|
|
4
4
|
tableName: SqliteOperation['table'];
|
|
5
5
|
getByKeys<T>(keys: string[], segment?: string): Promise<DurableStoreEntries<T>>;
|
|
6
|
+
getByKeysWithSpecificFields<T>(keys: string[], fields: Set<string>, segment?: string): Promise<DurableStoreEntries<T>>;
|
|
6
7
|
getMetadataByKeys(keys: string[], segment?: string): Promise<DurableStoreMetadataEntries | undefined>;
|
|
7
8
|
getAll<T>(segment?: string): Promise<DurableStoreEntries<T>>;
|
|
8
9
|
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
@@ -10,6 +10,7 @@ export declare class LdsInternalDataTable implements LdsDataTableBase {
|
|
|
10
10
|
private getAllQuery;
|
|
11
11
|
constructor(plugin: SqliteStorePlugin);
|
|
12
12
|
getByKeys<T>(keys: string[], namespace: string): Promise<DurableStoreEntries<T>>;
|
|
13
|
+
getByKeysWithSpecificFields<T>(keys: string[], fields: Set<string>, namespace?: string): Promise<DurableStoreEntries<T>>;
|
|
13
14
|
getMetadataByKeys(keys: string[], namespace: string): Promise<DurableStoreMetadataEntries | undefined>;
|
|
14
15
|
getAll<T>(namespace: string): Promise<DurableStoreEntries<T>>;
|
|
15
16
|
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-store-nimbus",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.416.0",
|
|
4
4
|
"description": "A nimbus-plugin-based implementation of the Luvio DurableStore and SqliteStore.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"o11y": "250.7.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@luvio/environments": "0.
|
|
32
|
-
"@salesforce/lds-store-sql": "^1.
|
|
33
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
31
|
+
"@luvio/environments": "0.159.0",
|
|
32
|
+
"@salesforce/lds-store-sql": "^1.416.0",
|
|
33
|
+
"@salesforce/nimbus-plugin-lds": "^1.416.0"
|
|
34
34
|
},
|
|
35
35
|
"luvioBundlesize": [
|
|
36
36
|
{
|
|
37
37
|
"path": "./dist/index.js",
|
|
38
38
|
"maxSize": {
|
|
39
|
-
"none": "
|
|
40
|
-
"min": "
|
|
41
|
-
"compressed": "3 kB"
|
|
39
|
+
"none": "23 kB",
|
|
40
|
+
"min": "10 kB",
|
|
41
|
+
"compressed": "3.5 kB"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
]
|