@salesforce/lds-store-nimbus 1.199.1
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/LICENSE.txt +82 -0
- package/dist/index.js +316 -0
- package/dist/types/NimbusSqliteStore.d.ts +21 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/tables/AbstractKeyValueDataTable.d.ts +14 -0
- package/dist/types/tables/LdsDataTable.d.ts +15 -0
- package/dist/types/tables/LdsDataTableBase.d.ts +8 -0
- package/dist/types/tables/LdsInternalDataTable.d.ts +15 -0
- package/dist/types/tables/index.d.ts +3 -0
- package/dist/types/tables/utils.d.ts +2 -0
- package/dist/types/utils/language.d.ts +29 -0
- package/package.json +43 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2022, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { DefaultDurableSegment } from '@luvio/environments';
|
|
2
|
+
|
|
3
|
+
const { keys, create, assign, entries } = Object;
|
|
4
|
+
const { stringify, parse } = JSON;
|
|
5
|
+
|
|
6
|
+
function selectColumnsFromTableWhereKeyIn(columnNames, table, keyColumnName, whereIn) {
|
|
7
|
+
const paramList = whereIn.map(() => '?').join(',');
|
|
8
|
+
return `SELECT ${columnNames.join(',')} FROM ${table} WHERE ${keyColumnName} IN (${paramList})`;
|
|
9
|
+
}
|
|
10
|
+
function selectColumnsFromTableWhereKeyInNamespaced(columnNames, table, keyColumnName, whereIn, namespaceColumnName) {
|
|
11
|
+
const paramList = whereIn.map(() => '?').join(',');
|
|
12
|
+
return `SELECT ${columnNames.join(',')} FROM ${table} WHERE ${namespaceColumnName} = ? AND ${keyColumnName} IN (${paramList})`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// These const values must be in sync with the latest
|
|
16
|
+
// @salesforce/nimbus-plugin-lds/sql schema file
|
|
17
|
+
const TABLE_NAME$1 = 'lds_data';
|
|
18
|
+
const COLUMN_NAME_KEY$2 = 'key';
|
|
19
|
+
const COLUMN_NAME_DATA$2 = 'data';
|
|
20
|
+
const COLUMN_NAME_METADATA$1 = 'metadata';
|
|
21
|
+
class LdsDataTable {
|
|
22
|
+
constructor(plugin) {
|
|
23
|
+
this.tableName = TABLE_NAME$1;
|
|
24
|
+
this.columnNames = [COLUMN_NAME_KEY$2, COLUMN_NAME_DATA$2, COLUMN_NAME_METADATA$1];
|
|
25
|
+
this.conflictColumnNames = [COLUMN_NAME_KEY$2];
|
|
26
|
+
this.getAllQuery = `SELECT ${this.columnNames.join(',')} FROM ${this.tableName}`;
|
|
27
|
+
this.plugin = plugin;
|
|
28
|
+
}
|
|
29
|
+
getByKeys(keys) {
|
|
30
|
+
const getQuery = selectColumnsFromTableWhereKeyIn(this.columnNames, this.tableName, COLUMN_NAME_KEY$2, keys);
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
this.plugin.query(getQuery, keys, (x) => {
|
|
33
|
+
resolve(this.mapToDurableEntries(x));
|
|
34
|
+
}, reject);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getAll() {
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
this.plugin.query(this.getAllQuery, [], (x) => {
|
|
40
|
+
resolve(this.mapToDurableEntries(x));
|
|
41
|
+
}, reject);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
entriesToUpsertOperations(entries, segment) {
|
|
45
|
+
return {
|
|
46
|
+
type: 'upsert',
|
|
47
|
+
table: this.tableName,
|
|
48
|
+
keyColumn: COLUMN_NAME_KEY$2,
|
|
49
|
+
context: {
|
|
50
|
+
segment,
|
|
51
|
+
},
|
|
52
|
+
conflictColumns: this.conflictColumnNames,
|
|
53
|
+
columns: this.columnNames,
|
|
54
|
+
rows: keys(entries).reduce((rows, key) => {
|
|
55
|
+
const entry = entries[key];
|
|
56
|
+
const { data, metadata } = entry;
|
|
57
|
+
const row = [key, stringify(data), metadata ? stringify(metadata) : null];
|
|
58
|
+
rows.push(row);
|
|
59
|
+
return rows;
|
|
60
|
+
}, []),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
mapToDurableEntries(sqliteResult) {
|
|
64
|
+
return sqliteResult.rows.reduce((entries, row) => {
|
|
65
|
+
const [key, stringifiedData, stringifiedMetadata] = row;
|
|
66
|
+
const durableStoreEntry = {
|
|
67
|
+
data: parse(stringifiedData),
|
|
68
|
+
};
|
|
69
|
+
if (stringifiedMetadata !== null) {
|
|
70
|
+
durableStoreEntry.metadata = parse(stringifiedMetadata);
|
|
71
|
+
}
|
|
72
|
+
entries[key] = durableStoreEntry;
|
|
73
|
+
return entries;
|
|
74
|
+
}, {});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// These const values must be in sync with the latest
|
|
79
|
+
// @salesforce/nimbus-plugin-lds/sql schema file
|
|
80
|
+
const TABLE_NAME = 'lds_internal';
|
|
81
|
+
const COLUMN_NAME_KEY$1 = 'key';
|
|
82
|
+
const COLUMN_NAME_DATA$1 = 'data';
|
|
83
|
+
const COLUMN_NAME_METADATA = 'metadata';
|
|
84
|
+
const COLUMN_NAME_NAMESPACE = 'namespace';
|
|
85
|
+
class LdsInternalDataTable {
|
|
86
|
+
constructor(plugin) {
|
|
87
|
+
this.tableName = TABLE_NAME;
|
|
88
|
+
this.columnNames = [
|
|
89
|
+
COLUMN_NAME_KEY$1,
|
|
90
|
+
COLUMN_NAME_DATA$1,
|
|
91
|
+
COLUMN_NAME_METADATA,
|
|
92
|
+
COLUMN_NAME_NAMESPACE,
|
|
93
|
+
];
|
|
94
|
+
this.conflictColumnNames = [COLUMN_NAME_KEY$1, COLUMN_NAME_NAMESPACE];
|
|
95
|
+
this.getAllQuery = `SELECT ${this.columnNames.join(',')} FROM ${this.tableName} WHERE ${COLUMN_NAME_NAMESPACE} = ?`;
|
|
96
|
+
this.plugin = plugin;
|
|
97
|
+
}
|
|
98
|
+
getByKeys(keys, namespace) {
|
|
99
|
+
if (namespace === undefined) {
|
|
100
|
+
throw Error('LdsInternalDataTable requires namespace');
|
|
101
|
+
}
|
|
102
|
+
const getQuery = selectColumnsFromTableWhereKeyInNamespaced(this.columnNames, this.tableName, COLUMN_NAME_KEY$1, keys, COLUMN_NAME_NAMESPACE);
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
this.plugin.query(getQuery, [namespace].concat(keys), (x) => {
|
|
105
|
+
resolve(this.mapToDurableEntries(x));
|
|
106
|
+
}, reject);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
getAll(namespace) {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
this.plugin.query(this.getAllQuery, [namespace], (x) => {
|
|
112
|
+
resolve(this.mapToDurableEntries(x));
|
|
113
|
+
}, reject);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
entriesToUpsertOperations(entries, segment) {
|
|
117
|
+
return {
|
|
118
|
+
type: 'upsert',
|
|
119
|
+
table: this.tableName,
|
|
120
|
+
keyColumn: COLUMN_NAME_KEY$1,
|
|
121
|
+
context: {
|
|
122
|
+
segment,
|
|
123
|
+
},
|
|
124
|
+
conflictColumns: this.conflictColumnNames,
|
|
125
|
+
columns: this.columnNames,
|
|
126
|
+
rows: keys(entries).reduce((rows, key) => {
|
|
127
|
+
const entry = entries[key];
|
|
128
|
+
const { data, metadata } = entry;
|
|
129
|
+
const row = [key, stringify(data)];
|
|
130
|
+
if (metadata) {
|
|
131
|
+
row.push(stringify(metadata));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
row.push(null);
|
|
135
|
+
}
|
|
136
|
+
row.push(segment);
|
|
137
|
+
rows.push(row);
|
|
138
|
+
return rows;
|
|
139
|
+
}, []),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
mapToDurableEntries(sqliteResult) {
|
|
143
|
+
return sqliteResult.rows.reduce((entries, row) => {
|
|
144
|
+
const [key, stringifiedData, stringifiedMetadata] = row;
|
|
145
|
+
const durableStoreEntry = {
|
|
146
|
+
data: parse(stringifiedData),
|
|
147
|
+
};
|
|
148
|
+
if (stringifiedMetadata !== null) {
|
|
149
|
+
durableStoreEntry.metadata = parse(stringifiedMetadata);
|
|
150
|
+
}
|
|
151
|
+
entries[key] = durableStoreEntry;
|
|
152
|
+
return entries;
|
|
153
|
+
}, {});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
class NimbusSqliteStore {
|
|
158
|
+
constructor(plugin, additionalTableMap = {}) {
|
|
159
|
+
this.plugin = plugin;
|
|
160
|
+
this.internalDataTable = new LdsInternalDataTable(plugin);
|
|
161
|
+
this.dataTableMap = {
|
|
162
|
+
...additionalTableMap,
|
|
163
|
+
[DefaultDurableSegment]: new LdsDataTable(plugin),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
isEvalSupported() {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
query(sql, params) {
|
|
170
|
+
return new Promise((resolve, reject) => {
|
|
171
|
+
this.plugin.query(sql, params, (result) => {
|
|
172
|
+
resolve(result);
|
|
173
|
+
}, (error) => {
|
|
174
|
+
reject(error);
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async getEntries(entryIds, segment) {
|
|
179
|
+
return this.getTable(segment).getByKeys(entryIds, segment);
|
|
180
|
+
}
|
|
181
|
+
getAllEntries(segment) {
|
|
182
|
+
return this.getTable(segment).getAll(segment);
|
|
183
|
+
}
|
|
184
|
+
setEntries(entries, segment) {
|
|
185
|
+
const table = this.getTable(segment);
|
|
186
|
+
const upsertOperation = table.entriesToUpsertOperations(entries, segment);
|
|
187
|
+
return this.batchOperationAsPromise([upsertOperation]);
|
|
188
|
+
}
|
|
189
|
+
batchOperations(operations) {
|
|
190
|
+
const sqliteOperations = operations.reduce((acc, cur) => {
|
|
191
|
+
if (cur.type === 'setEntries') {
|
|
192
|
+
const table = this.getTable(cur.segment);
|
|
193
|
+
acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
acc.push(this.idsToDeleteOperation(cur.ids, cur.segment));
|
|
197
|
+
}
|
|
198
|
+
return acc;
|
|
199
|
+
}, []);
|
|
200
|
+
return this.batchOperationAsPromise(sqliteOperations);
|
|
201
|
+
}
|
|
202
|
+
evictEntries(entryIds, segment) {
|
|
203
|
+
const sqliteOperation = this.idsToDeleteOperation(entryIds, segment);
|
|
204
|
+
return this.batchOperationAsPromise([sqliteOperation]);
|
|
205
|
+
}
|
|
206
|
+
registerOnChangedListener(listener) {
|
|
207
|
+
let unsubscribeId = undefined;
|
|
208
|
+
this.plugin
|
|
209
|
+
.registerOnChangedListener(async (changes) => {
|
|
210
|
+
const durableChanges = changes.map((c) => {
|
|
211
|
+
return {
|
|
212
|
+
type: c.type === 'upsert' ? 'setEntries' : 'evictEntries',
|
|
213
|
+
ids: c.keys,
|
|
214
|
+
isExternalChange: false,
|
|
215
|
+
segment: c.context.segment,
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
await listener(durableChanges);
|
|
219
|
+
})
|
|
220
|
+
.then((unsub) => {
|
|
221
|
+
unsubscribeId = unsub;
|
|
222
|
+
});
|
|
223
|
+
return () => {
|
|
224
|
+
if (unsubscribeId) {
|
|
225
|
+
return this.plugin.unsubscribeOnChangedListener(unsubscribeId);
|
|
226
|
+
}
|
|
227
|
+
return Promise.resolve();
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
getTable(segment) {
|
|
231
|
+
var _a;
|
|
232
|
+
return (_a = this.dataTableMap[segment]) !== null && _a !== void 0 ? _a : this.internalDataTable;
|
|
233
|
+
}
|
|
234
|
+
idsToDeleteOperation(entryIds, segment) {
|
|
235
|
+
const table = this.getTable(segment);
|
|
236
|
+
return {
|
|
237
|
+
type: 'delete',
|
|
238
|
+
table: table.tableName,
|
|
239
|
+
keyColumn: 'key',
|
|
240
|
+
context: {
|
|
241
|
+
segment,
|
|
242
|
+
},
|
|
243
|
+
ids: entryIds,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
batchOperationAsPromise(sqliteOperations) {
|
|
247
|
+
return new Promise((resolve, reject) => {
|
|
248
|
+
this.plugin.batchOperations(sqliteOperations, (error) => {
|
|
249
|
+
if (error && error !== null) {
|
|
250
|
+
reject(error);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
resolve();
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// These const values must be in sync with the latest
|
|
261
|
+
// @salesforce/nimbus-plugin-lds/sql schema file
|
|
262
|
+
const COLUMN_NAME_KEY = 'key';
|
|
263
|
+
const COLUMN_NAME_DATA = 'data';
|
|
264
|
+
class AbstractKeyValueDataTable {
|
|
265
|
+
constructor(plugin, tableName) {
|
|
266
|
+
this.columnNames = [COLUMN_NAME_KEY, COLUMN_NAME_DATA];
|
|
267
|
+
this.conflictColumnNames = [COLUMN_NAME_KEY];
|
|
268
|
+
this.plugin = plugin;
|
|
269
|
+
this.tableName = tableName;
|
|
270
|
+
}
|
|
271
|
+
getByKeys(keys) {
|
|
272
|
+
return new Promise((resolve, reject) => {
|
|
273
|
+
const getQuery = selectColumnsFromTableWhereKeyIn(this.columnNames, this.tableName, COLUMN_NAME_KEY, keys);
|
|
274
|
+
this.plugin.query(getQuery, keys, (x) => {
|
|
275
|
+
resolve(this.mapToDurableEntries(x));
|
|
276
|
+
}, reject);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
getAll() {
|
|
280
|
+
const getAllQuery = `SELECT ${this.columnNames.join(',')} FROM ${this.tableName}`;
|
|
281
|
+
return new Promise((resolve, reject) => {
|
|
282
|
+
this.plugin.query(getAllQuery, [], (x) => {
|
|
283
|
+
resolve(this.mapToDurableEntries(x));
|
|
284
|
+
}, reject);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
entriesToUpsertOperations(entries, segment) {
|
|
288
|
+
return {
|
|
289
|
+
type: 'upsert',
|
|
290
|
+
table: this.tableName,
|
|
291
|
+
keyColumn: COLUMN_NAME_KEY,
|
|
292
|
+
context: {
|
|
293
|
+
segment,
|
|
294
|
+
},
|
|
295
|
+
conflictColumns: this.conflictColumnNames,
|
|
296
|
+
columns: this.columnNames,
|
|
297
|
+
rows: keys(entries).reduce((rows, key) => {
|
|
298
|
+
const entry = entries[key];
|
|
299
|
+
rows.push([key, stringify(entry.data)]);
|
|
300
|
+
return rows;
|
|
301
|
+
}, []),
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
mapToDurableEntries(sqliteResult) {
|
|
305
|
+
return sqliteResult.rows.reduce((entries, row) => {
|
|
306
|
+
const [key, stringifiedData] = row;
|
|
307
|
+
const durableStoreEntry = {
|
|
308
|
+
data: parse(stringifiedData),
|
|
309
|
+
};
|
|
310
|
+
entries[key] = durableStoreEntry;
|
|
311
|
+
return entries;
|
|
312
|
+
}, {});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export { AbstractKeyValueDataTable, NimbusSqliteStore };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SqliteResult, SqliteStore, SqliteType } from '@salesforce/lds-store-sql';
|
|
2
|
+
import type { SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
|
|
3
|
+
import type { DurableStore, DurableStoreEntries, DurableStoreOperation, OnDurableStoreChangedListener } from '@luvio/environments';
|
|
4
|
+
import type { LdsDataTableBase } from './tables';
|
|
5
|
+
export declare class NimbusSqliteStore implements SqliteStore, DurableStore {
|
|
6
|
+
private plugin;
|
|
7
|
+
private readonly dataTableMap;
|
|
8
|
+
private readonly internalDataTable;
|
|
9
|
+
constructor(plugin: SqliteStorePlugin, additionalTableMap?: Record<string, LdsDataTableBase>);
|
|
10
|
+
isEvalSupported(): boolean;
|
|
11
|
+
query(sql: string, params: SqliteType[]): Promise<SqliteResult>;
|
|
12
|
+
getEntries<T>(entryIds: string[], segment: string): Promise<DurableStoreEntries<T> | undefined>;
|
|
13
|
+
getAllEntries<T>(segment: string): Promise<DurableStoreEntries<T> | undefined>;
|
|
14
|
+
setEntries<T>(entries: DurableStoreEntries<T>, segment: string): Promise<void>;
|
|
15
|
+
batchOperations<T>(operations: DurableStoreOperation<T>[]): Promise<void>;
|
|
16
|
+
evictEntries(entryIds: string[], segment: string): Promise<void>;
|
|
17
|
+
registerOnChangedListener(listener: OnDurableStoreChangedListener): () => Promise<void>;
|
|
18
|
+
private getTable;
|
|
19
|
+
private idsToDeleteOperation;
|
|
20
|
+
private batchOperationAsPromise;
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SqliteOperation, SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
|
|
2
|
+
import type { DurableStoreEntries } from '@luvio/environments';
|
|
3
|
+
import type { LdsDataTableBase } from '../tables/LdsDataTableBase';
|
|
4
|
+
export declare abstract class AbstractKeyValueDataTable implements LdsDataTableBase {
|
|
5
|
+
readonly tableName: SqliteOperation['table'];
|
|
6
|
+
readonly plugin: SqliteStorePlugin;
|
|
7
|
+
private columnNames;
|
|
8
|
+
private conflictColumnNames;
|
|
9
|
+
constructor(plugin: SqliteStorePlugin, tableName: SqliteOperation['table']);
|
|
10
|
+
getByKeys<T>(keys: string[]): Promise<DurableStoreEntries<T>>;
|
|
11
|
+
getAll<T>(): Promise<DurableStoreEntries<T>>;
|
|
12
|
+
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
13
|
+
private mapToDurableEntries;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SqliteOperation, SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
|
|
2
|
+
import type { DurableStoreEntries } from '@luvio/environments';
|
|
3
|
+
import type { LdsDataTableBase } from '../tables/LdsDataTableBase';
|
|
4
|
+
export declare class LdsDataTable implements LdsDataTableBase {
|
|
5
|
+
readonly tableName = "lds_data";
|
|
6
|
+
readonly plugin: SqliteStorePlugin;
|
|
7
|
+
private columnNames;
|
|
8
|
+
private conflictColumnNames;
|
|
9
|
+
private getAllQuery;
|
|
10
|
+
constructor(plugin: SqliteStorePlugin);
|
|
11
|
+
getByKeys<T>(keys: string[]): Promise<DurableStoreEntries<T>>;
|
|
12
|
+
getAll<T>(): Promise<DurableStoreEntries<T>>;
|
|
13
|
+
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
14
|
+
private mapToDurableEntries;
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DurableStoreEntries } from '@luvio/environments';
|
|
2
|
+
import type { SqliteOperation } from '@salesforce/nimbus-plugin-lds';
|
|
3
|
+
export interface LdsDataTableBase {
|
|
4
|
+
tableName: SqliteOperation['table'];
|
|
5
|
+
getByKeys<T>(keys: string[], segment?: string): Promise<DurableStoreEntries<T>>;
|
|
6
|
+
getAll<T>(segment?: string): Promise<DurableStoreEntries<T>>;
|
|
7
|
+
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
8
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SqliteOperation, SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
|
|
2
|
+
import type { DurableStoreEntries } from '@luvio/environments';
|
|
3
|
+
import type { LdsDataTableBase } from '../tables';
|
|
4
|
+
export declare class LdsInternalDataTable implements LdsDataTableBase {
|
|
5
|
+
readonly tableName = "lds_internal";
|
|
6
|
+
readonly plugin: SqliteStorePlugin;
|
|
7
|
+
private columnNames;
|
|
8
|
+
private conflictColumnNames;
|
|
9
|
+
private getAllQuery;
|
|
10
|
+
constructor(plugin: SqliteStorePlugin);
|
|
11
|
+
getByKeys<T>(keys: string[], namespace: string): Promise<DurableStoreEntries<T>>;
|
|
12
|
+
getAll<T>(namespace: string): Promise<DurableStoreEntries<T>>;
|
|
13
|
+
entriesToUpsertOperations<T>(entries: DurableStoreEntries<T>, segment: string): SqliteOperation;
|
|
14
|
+
private mapToDurableEntries;
|
|
15
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare function selectColumnsFromTableWhereKeyIn(columnNames: string[], table: string, keyColumnName: string, whereIn: string[]): string;
|
|
2
|
+
export declare function selectColumnsFromTableWhereKeyInNamespaced(columnNames: string[], table: string, keyColumnName: string, whereIn: string[], namespaceColumnName: string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
declare const keys: {
|
|
2
|
+
(o: object): string[];
|
|
3
|
+
(o: {}): string[];
|
|
4
|
+
}, create: {
|
|
5
|
+
(o: object | null): any;
|
|
6
|
+
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
7
|
+
}, assign: {
|
|
8
|
+
<T extends {}, U>(target: T, source: U): T & U;
|
|
9
|
+
<T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
10
|
+
<T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
11
|
+
(target: object, ...sources: any[]): any;
|
|
12
|
+
}, entries: {
|
|
13
|
+
<T>(o: {
|
|
14
|
+
[s: string]: T;
|
|
15
|
+
} | ArrayLike<T>): [string, T][];
|
|
16
|
+
(o: {}): [string, any][];
|
|
17
|
+
};
|
|
18
|
+
declare const stringify: {
|
|
19
|
+
(value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string;
|
|
20
|
+
(value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string;
|
|
21
|
+
}, parse: (text: string, reviver?: ((this: any, key: string, value: any) => any) | undefined) => any;
|
|
22
|
+
declare const push: (...items: any[]) => number, join: (separator?: string | undefined) => string, slice: (start?: number | undefined, end?: number | undefined) => any[];
|
|
23
|
+
declare const isArray: (arg: any) => arg is any[], from: {
|
|
24
|
+
<T>(arrayLike: ArrayLike<T>): T[];
|
|
25
|
+
<T_1, U>(arrayLike: ArrayLike<T_1>, mapfn: (v: T_1, k: number) => U, thisArg?: any): U[];
|
|
26
|
+
<T_2>(iterable: Iterable<T_2> | ArrayLike<T_2>): T_2[];
|
|
27
|
+
<T_3, U_1>(iterable: Iterable<T_3> | ArrayLike<T_3>, mapfn: (v: T_3, k: number) => U_1, thisArg?: any): U_1[];
|
|
28
|
+
};
|
|
29
|
+
export { keys as ObjectKeys, create as ObjectCreate, assign as ObjectAssign, entries as ObjectEntries, push as ArrayPrototypePush, join as ArrayPrototypeJoin, slice as ArrayPrototypeSlice, isArray as ArrayIsArray, from as ArrayFrom, stringify as JSONStringify, parse as JSONParse, };
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/lds-store-nimbus",
|
|
3
|
+
"version": "1.199.1",
|
|
4
|
+
"description": "A nimbus-plugin-based implementation of the Luvio DurableStore and SqliteStore.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"prepare": "yarn build",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"build": "rollup --config rollup.config.js",
|
|
23
|
+
"test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand",
|
|
24
|
+
"test:unit": "NODE_ENV=production jest",
|
|
25
|
+
"test:size": "luvioBundlesize"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@luvio/environments": "0.143.9",
|
|
30
|
+
"@salesforce/nimbus-plugin-lds": "*",
|
|
31
|
+
"@salesforce/lds-store-sql": "*"
|
|
32
|
+
},
|
|
33
|
+
"luvioBundlesize": [
|
|
34
|
+
{
|
|
35
|
+
"path": "./dist/index.js",
|
|
36
|
+
"maxSize": {
|
|
37
|
+
"none": "12 kB",
|
|
38
|
+
"min": "7 kB",
|
|
39
|
+
"compressed": "3 kB"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|