@bandeira-tech/b3nd-save 0.8.1 → 0.13.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/esm/clients/save-client.d.ts +63 -29
- package/esm/clients/save-client.d.ts.map +1 -1
- package/esm/clients/save-client.js +148 -68
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/mod.d.ts +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/client-console/client.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/encoding/encoding.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/encrypt/mod.d.ts +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/encrypt/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/encrypt/mod.js +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/encrypt/utils.d.ts +6 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/encrypt/utils.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/encrypt/utils.js +12 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/functional-client/functional-client.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/match-pattern/match-pattern.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/decorators.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/network.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/peer.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/flood.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/path-vector.d.ts +3 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/network/policies/path-vector.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/path-vector.js +3 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/tell-and-read.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/types.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/observe-emitter/observe-emitter.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/connection.d.ts +13 -5
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/rig/connection.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/connection.js +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/events.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/hooks.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/identity.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/operation-handle.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/reactions.d.ts.map +1 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/rig.d.ts +3 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/rig/rig.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/rig.js +46 -4
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/types.d.ts +4 -4
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/rig/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/types/types.d.ts +119 -80
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/types/types.d.ts.map +1 -0
- package/esm/dispatch.d.ts +116 -3
- package/esm/dispatch.d.ts.map +1 -1
- package/esm/dispatch.js +381 -5
- package/esm/elasticsearch/store.d.ts +124 -25
- package/esm/elasticsearch/store.d.ts.map +1 -1
- package/esm/elasticsearch/store.js +451 -92
- package/esm/entity-store.d.ts +1 -1
- package/esm/errors.d.ts +1 -1
- package/esm/errors.js +1 -1
- package/esm/fs/mod.d.ts +26 -0
- package/esm/fs/mod.d.ts.map +1 -1
- package/esm/fs/store.d.ts +100 -23
- package/esm/fs/store.d.ts.map +1 -1
- package/esm/fs/store.js +250 -66
- package/esm/glob.d.ts +114 -0
- package/esm/glob.d.ts.map +1 -0
- package/esm/glob.js +352 -0
- package/esm/identifiers.d.ts +18 -0
- package/esm/identifiers.d.ts.map +1 -0
- package/esm/identifiers.js +19 -0
- package/esm/indexeddb/fields.d.ts +32 -0
- package/esm/indexeddb/fields.d.ts.map +1 -0
- package/esm/indexeddb/fields.js +51 -0
- package/esm/indexeddb/store.d.ts +72 -17
- package/esm/indexeddb/store.d.ts.map +1 -1
- package/esm/indexeddb/store.js +362 -106
- package/esm/ipfs/mod.d.ts +19 -0
- package/esm/ipfs/mod.d.ts.map +1 -1
- package/esm/ipfs/mod.js +19 -0
- package/esm/ipfs/store.d.ts +82 -21
- package/esm/ipfs/store.d.ts.map +1 -1
- package/esm/ipfs/store.js +269 -68
- package/esm/json-fields.d.ts +61 -0
- package/esm/json-fields.d.ts.map +1 -0
- package/esm/json-fields.js +121 -0
- package/esm/localstorage/store.d.ts +89 -21
- package/esm/localstorage/store.d.ts.map +1 -1
- package/esm/localstorage/store.js +247 -54
- package/esm/memory/store.d.ts +35 -4
- package/esm/memory/store.d.ts.map +1 -1
- package/esm/memory/store.js +69 -47
- package/esm/mod.d.ts +2 -0
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +1 -0
- package/esm/mongo/fields.d.ts +53 -0
- package/esm/mongo/fields.d.ts.map +1 -0
- package/esm/mongo/fields.js +71 -0
- package/esm/mongo/mod.d.ts +19 -4
- package/esm/mongo/mod.d.ts.map +1 -1
- package/esm/mongo/mod.js +4 -2
- package/esm/mongo/store.d.ts +114 -25
- package/esm/mongo/store.d.ts.map +1 -1
- package/esm/mongo/store.js +355 -102
- package/esm/postgres/store.d.ts +50 -1
- package/esm/postgres/store.d.ts.map +1 -1
- package/esm/postgres/store.js +133 -13
- package/esm/read.d.ts +54 -7
- package/esm/read.d.ts.map +1 -1
- package/esm/read.js +141 -16
- package/esm/s3/store.d.ts +125 -23
- package/esm/s3/store.d.ts.map +1 -1
- package/esm/s3/store.js +313 -57
- package/esm/sqlite/columns.d.ts +33 -0
- package/esm/sqlite/columns.d.ts.map +1 -0
- package/esm/sqlite/columns.js +51 -0
- package/esm/sqlite/store.d.ts +73 -25
- package/esm/sqlite/store.d.ts.map +1 -1
- package/esm/sqlite/store.js +411 -107
- package/esm/types.d.ts +1 -1
- package/esm/url.d.ts +122 -19
- package/esm/url.d.ts.map +1 -1
- package/esm/url.js +218 -24
- package/esm/walk-via-ls.d.ts +122 -0
- package/esm/walk-via-ls.d.ts.map +1 -0
- package/esm/walk-via-ls.js +178 -0
- package/package.json +1 -1
- package/esm/byte-entity-shim.d.ts +0 -47
- package/esm/byte-entity-shim.d.ts.map +0 -1
- package/esm/byte-entity-shim.js +0 -138
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/encrypt/mod.d.ts.map +0 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/network/policies/path-vector.d.ts.map +0 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/connection.d.ts.map +0 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/rig.d.ts.map +0 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/rig/types.d.ts.map +0 -1
- package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/0.22.0/src/types/types.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/mod.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/client-console/client.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/client-console/client.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/encoding/encoding.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/encoding/encoding.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/functional-client/functional-client.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/functional-client/functional-client.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/match-pattern/match-pattern.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/match-pattern/match-pattern.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/decorators.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/decorators.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/network.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/network.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/peer.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/peer.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/flood.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/flood.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/tell-and-read.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/policies/tell-and-read.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/types.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/network/types.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/observe-emitter/observe-emitter.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/observe-emitter/observe-emitter.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/events.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/events.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/hooks.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/hooks.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/identity.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/identity.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/operation-handle.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/operation-handle.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/reactions.d.ts +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/reactions.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/rig/types.js +0 -0
- /package/esm/deps/jsr.io/@bandeira-tech/b3nd-core/{0.22.0 → 0.25.0}/src/types/types.js +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TYPE_TAGS → SQLite column type mapping for native entity tables.
|
|
3
|
+
*
|
|
4
|
+
* SQLite uses type affinity rather than strict types — a single field
|
|
5
|
+
* picks the first recognized canonical tag in declaration order and
|
|
6
|
+
* resolves to an affinity that matches Postgres's storage semantics
|
|
7
|
+
* as closely as the medium allows.
|
|
8
|
+
*/
|
|
9
|
+
import { type EntityField } from "../entity.js";
|
|
10
|
+
export interface ColumnPlan {
|
|
11
|
+
/** Field/column name. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** SQLite SQL type (affinity). */
|
|
14
|
+
sqlType: string;
|
|
15
|
+
/** The recognized canonical tag — drives adapt-for-write/read. */
|
|
16
|
+
tag: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ColumnPlanResult {
|
|
19
|
+
columns: ColumnPlan[];
|
|
20
|
+
unsupported: {
|
|
21
|
+
name: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a schema's fields into SQLite column plans.
|
|
27
|
+
*
|
|
28
|
+
* Skips fields whose tags are all outside `TYPE_TAGS`; reports them
|
|
29
|
+
* via `unsupported`. Rejects invalid field names up front so we never
|
|
30
|
+
* emit unsafe SQL identifiers.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planColumns(fields: EntityField[]): ColumnPlanResult;
|
|
33
|
+
//# sourceMappingURL=columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../../src/sqlite/columns.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,cAAc,CAAC;AAc3D,MAAM,WAAW,UAAU;IACzB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACjD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,CA0BnE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TYPE_TAGS → SQLite column type mapping for native entity tables.
|
|
3
|
+
*
|
|
4
|
+
* SQLite uses type affinity rather than strict types — a single field
|
|
5
|
+
* picks the first recognized canonical tag in declaration order and
|
|
6
|
+
* resolves to an affinity that matches Postgres's storage semantics
|
|
7
|
+
* as closely as the medium allows.
|
|
8
|
+
*/
|
|
9
|
+
import { TYPE_TAGS } from "../entity.js";
|
|
10
|
+
const SQL_TYPE = {
|
|
11
|
+
[TYPE_TAGS.STRING]: "TEXT",
|
|
12
|
+
[TYPE_TAGS.NUMBER]: "REAL",
|
|
13
|
+
[TYPE_TAGS.BIGINT]: "INTEGER",
|
|
14
|
+
[TYPE_TAGS.BOOLEAN]: "INTEGER",
|
|
15
|
+
[TYPE_TAGS.BYTES]: "BLOB",
|
|
16
|
+
[TYPE_TAGS.TIMESTAMP]: "TEXT",
|
|
17
|
+
[TYPE_TAGS.JSON]: "TEXT",
|
|
18
|
+
};
|
|
19
|
+
const FIELD_NAME = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve a schema's fields into SQLite column plans.
|
|
22
|
+
*
|
|
23
|
+
* Skips fields whose tags are all outside `TYPE_TAGS`; reports them
|
|
24
|
+
* via `unsupported`. Rejects invalid field names up front so we never
|
|
25
|
+
* emit unsafe SQL identifiers.
|
|
26
|
+
*/
|
|
27
|
+
export function planColumns(fields) {
|
|
28
|
+
const columns = [];
|
|
29
|
+
const unsupported = [];
|
|
30
|
+
for (const field of fields) {
|
|
31
|
+
if (!FIELD_NAME.test(field.name)) {
|
|
32
|
+
unsupported.push({
|
|
33
|
+
name: field.name,
|
|
34
|
+
reason: `field name must match ${FIELD_NAME.source}; got '${field.name}'`,
|
|
35
|
+
});
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const tag = field.type.find((t) => SQL_TYPE[t] !== undefined);
|
|
39
|
+
if (!tag) {
|
|
40
|
+
unsupported.push({
|
|
41
|
+
name: field.name,
|
|
42
|
+
reason: field.type.length === 0
|
|
43
|
+
? "field declares no type tags"
|
|
44
|
+
: `no recognised tag in [${field.type.join(", ")}]`,
|
|
45
|
+
});
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
columns.push({ name: field.name, sqlType: SQL_TYPE[tag], tag });
|
|
49
|
+
}
|
|
50
|
+
return { columns, unsupported };
|
|
51
|
+
}
|
package/esm/sqlite/store.d.ts
CHANGED
|
@@ -1,42 +1,90 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SqliteStore — SQLite implementation of
|
|
2
|
+
* SqliteStore — SQLite implementation of `EntityStore`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* One layout for every schema: `{prefix}_{entity}_data` with `uri TEXT
|
|
5
|
+
* PRIMARY KEY` and one column per supported field, typed by the
|
|
6
|
+
* canonical `TYPE_TAGS` it carries (see `./columns.ts`). `BYTES_ENTITY`
|
|
7
|
+
* is just an entity with one `payload BLOB` column — no legacy
|
|
8
|
+
* special case.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* is
|
|
10
|
+
* ## Lifecycle
|
|
11
|
+
*
|
|
12
|
+
* `entitySupport(schema)` is pure — it runs `planColumns` and returns
|
|
13
|
+
* a `SqliteEntityMeta` with the target table name, column plans,
|
|
14
|
+
* bytes-column set, and the support report. No IO.
|
|
15
|
+
*
|
|
16
|
+
* `provisionEntity(meta)` runs `CREATE TABLE IF NOT EXISTS` and then
|
|
17
|
+
* verifies the live shape matches the meta (catches same-name-
|
|
18
|
+
* different-shape collisions). `entityStatus(meta)` performs the same
|
|
19
|
+
* check in isolation via `PRAGMA table_info`.
|
|
20
|
+
*
|
|
21
|
+
* Writes/reads/deletes consume the meta directly: no per-call cache
|
|
22
|
+
* gate. Operations against a not-yet-provisioned meta surface
|
|
23
|
+
* SQLite's natural failure per entry.
|
|
24
|
+
*
|
|
25
|
+
* `fn=ls` / `fn=count` push down to SQL — the shallow-direct-leaves
|
|
26
|
+
* predicate (`uri LIKE prefix || '%' AND uri NOT LIKE prefix || '%/%'`)
|
|
27
|
+
* is enforced in the WHERE clause against the entity's table.
|
|
28
|
+
*
|
|
29
|
+
* `fn=find` (v2 spec §3.5; foundation PR #82) reuses the same `_ls`
|
|
30
|
+
* SQL composition with a single branch: under `fn=find` the shallow
|
|
31
|
+
* safety predicate (`AND uri NOT LIKE prefix || '%/%'`) is DROPPED so
|
|
32
|
+
* the LIKE prefix walk crosses `/` and matches the whole subtree.
|
|
33
|
+
* The prefix bind is still a two-arg `[prefix, globToSqlLike(pattern)]`
|
|
34
|
+
* pair — never concatenated into the pattern body, so room/segment
|
|
35
|
+
* names containing literal `%`/`_` cannot break out of the parameter
|
|
36
|
+
* (LIKE-injection safety via `ESCAPE '\'`). `pushDownFind: true` is
|
|
37
|
+
* advertised so dispatch trusts the backend's deep walk.
|
|
38
|
+
*
|
|
39
|
+
* Writes are wrapped in a transaction (`capabilities.atomicBatch =
|
|
40
|
+
* true`). Stream-shaped values on `BLOB` columns are collected to
|
|
41
|
+
* `Uint8Array` *before* the transaction opens.
|
|
11
42
|
*/
|
|
12
|
-
import type { DeleteResult, Output, StatusResult } from "../deps/jsr.io/@bandeira-tech/b3nd-core/0.
|
|
13
|
-
import { type BytesOnlyEntityMeta } from "../byte-entity-shim.js";
|
|
43
|
+
import type { DeleteResult, Output, StatusResult } from "../deps/jsr.io/@bandeira-tech/b3nd-core/0.25.0/src/types/types.js";
|
|
14
44
|
import type { EntityStore } from "../entity-store.js";
|
|
15
|
-
import type
|
|
45
|
+
import { type EntityMeta, type EntityRecord, type EntitySchema } from "../entity.js";
|
|
16
46
|
import type { StoreCapabilities, StoreWriteResult } from "../types.js";
|
|
47
|
+
import { type ColumnPlan } from "./columns.js";
|
|
17
48
|
import type { SqliteExecutor } from "./mod.js";
|
|
18
|
-
|
|
19
|
-
|
|
49
|
+
/**
|
|
50
|
+
* SqliteStore-specific entity handle.
|
|
51
|
+
*
|
|
52
|
+
* `tableName` is the prefixed-and-suffixed target table; `columns`
|
|
53
|
+
* are the planned user columns (without the always-present `uri`,
|
|
54
|
+
* `created_at`, `updated_at`); `declared` is the set of user column
|
|
55
|
+
* names for the per-write extras check; `bytesColumns` drives stream
|
|
56
|
+
* normalisation; `jsonColumns`/`tsColumns`/`booleanColumns` drive
|
|
57
|
+
* the per-tag adapt-for-write/read coercions.
|
|
58
|
+
*/
|
|
59
|
+
export interface SqliteEntityMeta extends EntityMeta {
|
|
60
|
+
readonly tableName: string;
|
|
61
|
+
readonly columns: readonly ColumnPlan[];
|
|
62
|
+
readonly declared: ReadonlySet<string>;
|
|
63
|
+
readonly bytesColumns: ReadonlySet<string>;
|
|
64
|
+
}
|
|
65
|
+
export declare class SqliteStore implements EntityStore<SqliteEntityMeta> {
|
|
66
|
+
private readonly tablePrefix;
|
|
20
67
|
private readonly executor;
|
|
21
|
-
private readonly provisioned;
|
|
22
68
|
constructor(tablePrefix: string, executor: SqliteExecutor);
|
|
23
|
-
entitySupport(schema: EntitySchema):
|
|
24
|
-
entityStatus(meta:
|
|
25
|
-
provisionEntity(meta:
|
|
26
|
-
write(meta:
|
|
69
|
+
entitySupport(schema: EntitySchema): SqliteEntityMeta;
|
|
70
|
+
entityStatus(meta: SqliteEntityMeta): Promise<"live" | "unprovisioned">;
|
|
71
|
+
provisionEntity(meta: SqliteEntityMeta): Promise<void>;
|
|
72
|
+
write(meta: SqliteEntityMeta, entries: {
|
|
27
73
|
uri: string;
|
|
28
74
|
record: EntityRecord;
|
|
29
75
|
}[]): Promise<StoreWriteResult[]>;
|
|
30
|
-
read<T = EntityRecord | undefined>(meta:
|
|
31
|
-
delete(meta:
|
|
32
|
-
|
|
33
|
-
|
|
76
|
+
read<T = EntityRecord | undefined>(meta: SqliteEntityMeta, urls: string[]): Promise<Output<T>[]>;
|
|
77
|
+
delete(meta: SqliteEntityMeta, uris: string[]): Promise<DeleteResult[]>;
|
|
78
|
+
status(): Promise<StatusResult>;
|
|
79
|
+
capabilities(): StoreCapabilities;
|
|
34
80
|
private _readOne;
|
|
35
81
|
private _ls;
|
|
36
82
|
private _count;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Enumerate every `{tablePrefix}_*_data` table currently in the
|
|
85
|
+
* database. Used by `status()` to advertise the entities a peer can
|
|
86
|
+
* talk to without per-entity bookkeeping.
|
|
87
|
+
*/
|
|
88
|
+
private _listProvisionedEntities;
|
|
41
89
|
}
|
|
42
90
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/sqlite/store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/sqlite/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,MAAM,EACN,YAAY,EACb,MAAM,mEAAmE,CAAC;AAO3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/C;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC5C;AAoCD,qBAAa,WAAY,YAAW,WAAW,CAAC,gBAAgB,CAAC;IAC/D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;gBAE9B,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc;IAezD,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB;IAmB/C,YAAY,CAChB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,MAAM,GAAG,eAAe,CAAC;IA0B9B,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BtD,KAAK,CACT,IAAI,EAAE,gBAAgB,EACtB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,EAAE,GAC/C,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAuE9B,IAAI,CAAC,CAAC,GAAG,YAAY,GAAG,SAAS,EAC/B,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAevB,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAsBvE,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAoB/B,YAAY,IAAI,iBAAiB;IAMjC,OAAO,CAAC,QAAQ;IA4BhB,OAAO,CAAC,GAAG;IA0EX,OAAO,CAAC,MAAM;IA0Bd;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAejC"}
|