@quereus/quereus 0.6.2 → 0.6.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/src/runtime/emit/schema-declarative.js +1 -1
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/schema/schema-hasher.d.ts +3 -3
- package/dist/src/schema/schema-hasher.d.ts.map +1 -1
- package/dist/src/schema/schema-hasher.js +9 -27
- package/dist/src/schema/schema-hasher.js.map +1 -1
- package/dist/src/util/hash.d.ts +19 -0
- package/dist/src/util/hash.d.ts.map +1 -0
- package/dist/src/util/hash.js +76 -0
- package/dist/src/util/hash.js.map +1 -0
- package/package.json +1 -1
- package/src/planner/building/delete.ts +214 -214
- package/src/planner/building/insert.ts +428 -428
- package/src/planner/building/update.ts +319 -319
- package/src/runtime/emit/schema-declarative.ts +1 -1
- package/src/schema/schema-hasher.ts +9 -27
- package/src/util/ast-stringify.ts +864 -864
- package/src/util/hash.ts +90 -0
- package/src/vtab/memory/table.ts +256 -256
- package/src/vtab/table.ts +162 -162
|
@@ -1,44 +1,26 @@
|
|
|
1
1
|
import type * as AST from '../parser/ast.js';
|
|
2
2
|
import { generateDeclaredDDL } from './catalog.js';
|
|
3
|
+
import { fnv1aHash, toBase64Url } from '../util/hash.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Computes a hash of a declared schema for versioning
|
|
6
7
|
*/
|
|
7
|
-
export
|
|
8
|
+
export function computeSchemaHash(declaredSchema: AST.DeclareSchemaStmt): string {
|
|
8
9
|
// Generate canonical DDL representation
|
|
9
10
|
const ddlStatements = generateDeclaredDDL(declaredSchema);
|
|
10
11
|
const canonicalText = ddlStatements.join('\n');
|
|
11
12
|
|
|
12
|
-
// Compute
|
|
13
|
-
const
|
|
14
|
-
return
|
|
13
|
+
// Compute hash using FNV-1a algorithm and encode as base64url
|
|
14
|
+
const hashBytes = fnv1aHash(canonicalText);
|
|
15
|
+
return toBase64Url(hashBytes);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
|
-
* Computes
|
|
19
|
+
* Computes a short hash (first 8 characters) for display
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// Web Crypto API
|
|
24
|
-
const encoder = new TextEncoder();
|
|
25
|
-
const data = encoder.encode(message);
|
|
26
|
-
const hashBuffer = await globalThis.crypto.subtle.digest('SHA-256', data);
|
|
27
|
-
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
28
|
-
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
29
|
-
} else {
|
|
30
|
-
// Node.js crypto
|
|
31
|
-
const crypto = await import('node:crypto');
|
|
32
|
-
return crypto.createHash('sha256').update(message, 'utf8').digest('hex');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Computes a short hash (first 12 characters) for display
|
|
38
|
-
*/
|
|
39
|
-
export async function computeShortSchemaHash(declaredSchema: AST.DeclareSchemaStmt): Promise<string> {
|
|
40
|
-
const fullHash = await computeSchemaHash(declaredSchema);
|
|
41
|
-
return fullHash.substring(0, 12);
|
|
21
|
+
export function computeShortSchemaHash(declaredSchema: AST.DeclareSchemaStmt): string {
|
|
22
|
+
const fullHash = computeSchemaHash(declaredSchema);
|
|
23
|
+
return fullHash.substring(0, 8);
|
|
42
24
|
}
|
|
43
25
|
|
|
44
26
|
|