@atscript/db 0.1.39 → 0.1.41
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/README.md +18 -18
- package/dist/agg.cjs +8 -3
- package/dist/agg.d.cts +7 -0
- package/dist/agg.d.mts +7 -0
- package/dist/agg.mjs +7 -3
- package/dist/control-DRgryKeg.cjs +14 -0
- package/dist/{control_as-bjmwe24C.mjs → control-IANbnfjG.mjs} +6 -18
- package/dist/db-readable-BQQzfguJ.d.cts +1249 -0
- package/dist/db-readable-Bbr4CjMb.d.mts +1249 -0
- package/dist/db-space-BUrQ5BFm.d.mts +309 -0
- package/dist/db-space-Vxpcnyt5.d.cts +309 -0
- package/dist/db-validator-plugin-07kDiis2.d.cts +22 -0
- package/dist/db-validator-plugin-CiqsHTI_.d.mts +22 -0
- package/dist/db-view-CMI9TOo1.cjs +3096 -0
- package/dist/db-view-Esy2fDxw.mjs +2995 -0
- package/dist/index.cjs +95 -2801
- package/dist/index.d.cts +137 -0
- package/dist/index.d.mts +137 -0
- package/dist/index.mjs +55 -2761
- package/dist/{nested-writer-BkqL7cp3.cjs → nested-writer-BDXsDMPP.cjs} +196 -150
- package/dist/{nested-writer-NEN51mnR.mjs → nested-writer-Dmm1gbZV.mjs} +118 -70
- package/dist/ops-BdRAFLKY.d.mts +67 -0
- package/dist/ops-DXJ4Zw0P.d.cts +67 -0
- package/dist/ops.cjs +123 -0
- package/dist/ops.d.cts +2 -0
- package/dist/ops.d.mts +2 -0
- package/dist/ops.mjs +112 -0
- package/dist/plugin.cjs +90 -109
- package/dist/plugin.d.cts +6 -0
- package/dist/plugin.d.mts +6 -0
- package/dist/plugin.mjs +29 -49
- package/dist/rel.cjs +20 -20
- package/dist/rel.d.cts +119 -0
- package/dist/rel.d.mts +119 -0
- package/dist/rel.mjs +4 -5
- package/dist/{relation-helpers-guFL_oRf.cjs → relation-helpers-BYvsE1tR.cjs} +26 -22
- package/dist/{relation-helpers-DyBIlQnB.mjs → relation-helpers-CLasawQq.mjs} +11 -6
- package/dist/{relation-loader-Dv7qXYq7.mjs → relation-loader-BEOTXNcq.mjs} +63 -43
- package/dist/{relation-loader-CpnDRf9k.cjs → relation-loader-CRC5LcqM.cjs} +74 -49
- package/dist/shared.cjs +13 -13
- package/dist/{shared.d.ts → shared.d.cts} +14 -13
- package/dist/shared.d.mts +71 -0
- package/dist/shared.mjs +2 -3
- package/dist/sync.cjs +300 -252
- package/dist/sync.d.cts +369 -0
- package/dist/sync.d.mts +369 -0
- package/dist/sync.mjs +284 -233
- package/dist/{validation-utils-DEoCMmEb.cjs → validation-utils-DVJDijnB.cjs} +141 -109
- package/dist/{validation-utils-DhR_mtKa.mjs → validation-utils-DhjIjP1-.mjs} +71 -37
- package/package.json +30 -29
- package/LICENSE +0 -21
- package/dist/agg-BJFJ3dFQ.mjs +0 -8
- package/dist/agg-DnUWAOK8.cjs +0 -14
- package/dist/agg.d.ts +0 -13
- package/dist/chunk-CrpGerW8.cjs +0 -31
- package/dist/control_as-BFPERAF_.cjs +0 -28
- package/dist/index.d.ts +0 -1706
- package/dist/logger-B7oxCfLQ.mjs +0 -12
- package/dist/logger-Dt2v_-wb.cjs +0 -18
- package/dist/plugin.d.ts +0 -5
- package/dist/rel.d.ts +0 -1305
- package/dist/relation-loader-D4mTw6yH.cjs +0 -4
- package/dist/relation-loader-Ggy1ujwR.mjs +0 -4
- package/dist/sync.d.ts +0 -1878
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://atscript.
|
|
2
|
+
<img src="https://db.atscript.dev/logo.svg" alt="Atscript" width="120" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">@atscript/db</h1>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="https://atscript.
|
|
12
|
+
<a href="https://db.atscript.dev">Documentation</a> · <a href="https://db.atscript.dev/guide/">Database Guide</a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
---
|
|
@@ -39,25 +39,25 @@ interface User {
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
|
-
import { DbSpace } from
|
|
43
|
-
import { createAdapter } from
|
|
42
|
+
import { DbSpace } from "@atscript/db";
|
|
43
|
+
import { createAdapter } from "@atscript/db-sqlite";
|
|
44
44
|
|
|
45
|
-
const db = createAdapter(
|
|
46
|
-
const users = db.getTable(User)
|
|
45
|
+
const db = createAdapter("./myapp.db");
|
|
46
|
+
const users = db.getTable(User);
|
|
47
47
|
|
|
48
|
-
await users.insertOne({ name:
|
|
49
|
-
const all = await users.findMany({ filter: { name: { $eq:
|
|
48
|
+
await users.insertOne({ name: "John", email: "john@example.com" });
|
|
49
|
+
const all = await users.findMany({ filter: { name: { $eq: "John" } } });
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## Sub-entries
|
|
53
53
|
|
|
54
|
-
| Entry
|
|
55
|
-
|
|
56
|
-
| `@atscript/db/plugin` | `dbPlugin()` — registers all `@db.*` annotations
|
|
57
|
-
| `@atscript/db/rel`
|
|
58
|
-
| `@atscript/db/agg`
|
|
59
|
-
| `@atscript/db/sync`
|
|
60
|
-
| `@atscript/db/shared` | Annotation helpers for adapter plugins
|
|
54
|
+
| Entry | Purpose |
|
|
55
|
+
| --------------------- | -------------------------------------------------------- |
|
|
56
|
+
| `@atscript/db/plugin` | `dbPlugin()` — registers all `@db.*` annotations |
|
|
57
|
+
| `@atscript/db/rel` | Relation loading and nested writes |
|
|
58
|
+
| `@atscript/db/agg` | Aggregation query validation |
|
|
59
|
+
| `@atscript/db/sync` | Schema sync with drift detection and distributed locking |
|
|
60
|
+
| `@atscript/db/shared` | Annotation helpers for adapter plugins |
|
|
61
61
|
|
|
62
62
|
## Features
|
|
63
63
|
|
|
@@ -73,9 +73,9 @@ const all = await users.findMany({ filter: { name: { $eq: 'John' } } })
|
|
|
73
73
|
|
|
74
74
|
## Documentation
|
|
75
75
|
|
|
76
|
-
- [Database Guide](https://atscript.
|
|
77
|
-
- [API & Annotations](https://atscript.
|
|
78
|
-
- [Full Documentation](https://atscript.
|
|
76
|
+
- [Database Guide](https://db.atscript.dev/guide/)
|
|
77
|
+
- [API & Annotations](https://db.atscript.dev/api/tables)
|
|
78
|
+
- [Full Documentation](https://db.atscript.dev)
|
|
79
79
|
|
|
80
80
|
## License
|
|
81
81
|
|
package/dist/agg.cjs
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/agg.ts
|
|
3
|
+
/** Resolves output alias: $as if provided, otherwise `{fn}_{field}`. */
|
|
4
|
+
function resolveAlias(expr) {
|
|
5
|
+
return expr.$as ?? `${expr.$fn}_${expr.$field}`;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
exports.resolveAlias = resolveAlias;
|
package/dist/agg.d.cts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AggregateControls, AggregateExpr, AggregateExpr as AggregateExpr$1, AggregateFn, AggregateQuery, AggregateResult } from "@uniqu/core";
|
|
2
|
+
|
|
3
|
+
//#region src/agg.d.ts
|
|
4
|
+
/** Resolves output alias: $as if provided, otherwise `{fn}_{field}`. */
|
|
5
|
+
declare function resolveAlias(expr: AggregateExpr$1): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, resolveAlias };
|
package/dist/agg.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AggregateControls, AggregateExpr, AggregateExpr as AggregateExpr$1, AggregateFn, AggregateQuery, AggregateResult } from "@uniqu/core";
|
|
2
|
+
|
|
3
|
+
//#region src/agg.d.ts
|
|
4
|
+
/** Resolves output alias: $as if provided, otherwise `{fn}_{field}`. */
|
|
5
|
+
declare function resolveAlias(expr: AggregateExpr$1): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type AggregateControls, type AggregateExpr, type AggregateFn, type AggregateQuery, type AggregateResult, resolveAlias };
|
package/dist/agg.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/agg.ts
|
|
2
|
+
/** Resolves output alias: $as if provided, otherwise `{fn}_{field}`. */
|
|
3
|
+
function resolveAlias(expr) {
|
|
4
|
+
return expr.$as ?? `${expr.$fn}_${expr.$field}`;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { resolveAlias };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
let _atscript_typescript_utils = require("@atscript/typescript/utils");
|
|
2
|
+
//#region src/schema/control.as
|
|
3
|
+
var AtscriptControl = class {
|
|
4
|
+
static __is_atscript_annotated_type = true;
|
|
5
|
+
static type = {};
|
|
6
|
+
static metadata = /* @__PURE__ */ new Map();
|
|
7
|
+
static id = "AtscriptControl";
|
|
8
|
+
static toJsonSchema() {
|
|
9
|
+
(0, _atscript_typescript_utils.throwFeatureDisabled)("JSON Schema", "jsonSchema", "emit.jsonSchema");
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
(0, _atscript_typescript_utils.defineAnnotatedType)("object", AtscriptControl).prop("_id", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("string").tags("string").annotate("meta.id", true).$type).prop("value", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("string").tags("string").optional().$type).prop("lockedBy", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("string").tags("string").optional().$type).prop("lockedAt", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("number").tags("number").optional().$type).prop("expiresAt", (0, _atscript_typescript_utils.defineAnnotatedType)().designType("number").tags("number").optional().$type).annotate("db.table", "__atscript_control");
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.AtscriptControl = AtscriptControl;
|
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
import { defineAnnotatedType, throwFeatureDisabled } from "@atscript/typescript/utils";
|
|
2
|
-
|
|
3
|
-
//#region packages/db/src/schema/control.as.js
|
|
4
|
-
function _define_property(obj, key, value) {
|
|
5
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
6
|
-
value,
|
|
7
|
-
enumerable: true,
|
|
8
|
-
configurable: true,
|
|
9
|
-
writable: true
|
|
10
|
-
});
|
|
11
|
-
else obj[key] = value;
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
2
|
+
//#region src/schema/control.as
|
|
14
3
|
var AtscriptControl = class {
|
|
4
|
+
static __is_atscript_annotated_type = true;
|
|
5
|
+
static type = {};
|
|
6
|
+
static metadata = /* @__PURE__ */ new Map();
|
|
7
|
+
static id = "AtscriptControl";
|
|
15
8
|
static toJsonSchema() {
|
|
16
9
|
throwFeatureDisabled("JSON Schema", "jsonSchema", "emit.jsonSchema");
|
|
17
10
|
}
|
|
18
11
|
};
|
|
19
|
-
_define_property(AtscriptControl, "__is_atscript_annotated_type", true);
|
|
20
|
-
_define_property(AtscriptControl, "type", {});
|
|
21
|
-
_define_property(AtscriptControl, "metadata", new Map());
|
|
22
|
-
_define_property(AtscriptControl, "id", "AtscriptControl");
|
|
23
12
|
defineAnnotatedType("object", AtscriptControl).prop("_id", defineAnnotatedType().designType("string").tags("string").annotate("meta.id", true).$type).prop("value", defineAnnotatedType().designType("string").tags("string").optional().$type).prop("lockedBy", defineAnnotatedType().designType("string").tags("string").optional().$type).prop("lockedAt", defineAnnotatedType().designType("number").tags("number").optional().$type).prop("expiresAt", defineAnnotatedType().designType("number").tags("number").optional().$type).annotate("db.table", "__atscript_control");
|
|
24
|
-
|
|
25
13
|
//#endregion
|
|
26
|
-
export { AtscriptControl };
|
|
14
|
+
export { AtscriptControl };
|