@eltjs/elt-sqlite 0.1.1 → 0.1.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/computed-dataset.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hash } from 'node:crypto';
|
|
2
2
|
import { Declaration } from '@zukhruf/sqlite-drift';
|
|
3
3
|
import { open } from '@zukhruf/sqlite-open';
|
|
4
4
|
import { transaction } from '@zukhruf/sqlite-transaction';
|
|
@@ -119,9 +119,7 @@ export class ComputedDataset extends DerivedDataset {
|
|
|
119
119
|
for (const [id, input] of inputs) {
|
|
120
120
|
if (signal?.aborted)
|
|
121
121
|
return;
|
|
122
|
-
const inputHash =
|
|
123
|
-
.update(JSON.stringify(input))
|
|
124
|
-
.digest('hex');
|
|
122
|
+
const inputHash = hash('sha256', JSON.stringify(input));
|
|
125
123
|
const rule = await this.#rule.identity(input);
|
|
126
124
|
const before = stored.get(id);
|
|
127
125
|
// A rule that does not handle the input keeps what it made before.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hash } from 'node:crypto';
|
|
2
2
|
import { SQLiteColumns } from './sqlite-columns.js';
|
|
3
3
|
import { SQLiteWriter, op, seq } from './sqlite-writer.js';
|
|
4
4
|
export class SQLiteDeduplicatingWriter extends SQLiteWriter {
|
|
@@ -29,9 +29,7 @@ export class SQLiteDeduplicatingWriter extends SQLiteWriter {
|
|
|
29
29
|
// Named after the table and its key, so a changed key builds a new index
|
|
30
30
|
// and an unchanged one is never rebuilt.
|
|
31
31
|
get #dedupIndex() {
|
|
32
|
-
return `_elt_dedup_${
|
|
33
|
-
.update(JSON.stringify([this.table.name, this.keys.map((key) => key.name)]))
|
|
34
|
-
.digest('hex')}`;
|
|
32
|
+
return `_elt_dedup_${hash('sha256', JSON.stringify([this.table.name, this.keys.map((key) => key.name)]))}`;
|
|
35
33
|
}
|
|
36
34
|
// A stored table the load merges into must hold keys and cursors of the
|
|
37
35
|
// stream's types, none null, and no key twice, which its index forbids once
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hash } from 'node:crypto';
|
|
2
2
|
import { identifiers } from './sqlite-identifiers.js';
|
|
3
3
|
const quote = (name) => `"${name.replaceAll('"', '""')}"`;
|
|
4
4
|
const tablePrefix = '_elt_files_';
|
|
@@ -26,10 +26,7 @@ export class SQLiteFileStore {
|
|
|
26
26
|
// table a_b with column c and table a with column b_c would share chunks
|
|
27
27
|
// and prune each other's.
|
|
28
28
|
static tableName(table, column) {
|
|
29
|
-
const key =
|
|
30
|
-
.update(JSON.stringify([table.location, identifiers.key(column.name)]))
|
|
31
|
-
.digest('hex')
|
|
32
|
-
.slice(0, 40);
|
|
29
|
+
const key = hash('sha256', JSON.stringify([table.location, identifiers.key(column.name)])).slice(0, 40);
|
|
33
30
|
return `${tablePrefix}${key}`;
|
|
34
31
|
}
|
|
35
32
|
#exists(location) {
|
package/dist/sqlite-writer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hash } from 'node:crypto';
|
|
2
2
|
import { Declaration } from '@zukhruf/sqlite-drift';
|
|
3
3
|
import { transaction } from '@zukhruf/sqlite-transaction';
|
|
4
4
|
import { FileContent, TargetOwnedError, Writer, describeTarget, errorMessage, reloadMode, } from '@eltjs/elt';
|
|
@@ -71,7 +71,7 @@ export class SQLiteWriter extends Writer {
|
|
|
71
71
|
database.exec(`DELETE FROM ${this.table.quotedName}`);
|
|
72
72
|
}
|
|
73
73
|
get hash() {
|
|
74
|
-
return
|
|
74
|
+
return hash('sha256', this.table.location);
|
|
75
75
|
}
|
|
76
76
|
get fields() {
|
|
77
77
|
return [
|
package/dist/view.js
CHANGED
|
@@ -33,7 +33,7 @@ export class View extends DerivedDataset {
|
|
|
33
33
|
database.prepare(this.#view.query);
|
|
34
34
|
}
|
|
35
35
|
catch (error) {
|
|
36
|
-
const missing = error
|
|
36
|
+
const missing = Error.isError(error)
|
|
37
37
|
? /^no such table: (?:main\.)?(.+)$/.exec(error.message)?.[1]
|
|
38
38
|
: undefined;
|
|
39
39
|
const missingName = missing?.toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eltjs/elt-sqlite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "The SQLite destination of elt: each stream is a raw table in one SQLite file, with a reader view over it and a catalog of each table, view and column.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=24"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@eltjs/elt": "^0.1.
|
|
42
|
+
"@eltjs/elt": "^0.1.3",
|
|
43
43
|
"@zukhruf/mutex": "^0.8.10",
|
|
44
44
|
"@zukhruf/sqlite-drift": "^0.8.10",
|
|
45
45
|
"@zukhruf/sqlite-open": "^0.8.10",
|