better-schemic 0.1.0-beta.7 → 0.1.0-beta.8
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 +42 -1
- package/lib/aot.js +6 -3557
- package/lib/authoring.js +17 -212
- package/lib/chunk-00apd4ns.js +62 -0
- package/lib/chunk-0avev9qc.js +7 -0
- package/lib/chunk-0xecyh0f.js +1060 -0
- package/lib/chunk-14s9y00s.js +31 -0
- package/lib/chunk-2nz25g5r.js +27 -0
- package/lib/chunk-58rf0smz.js +332 -0
- package/lib/chunk-7mav5k1w.js +3 -0
- package/lib/chunk-855b9bex.js +240 -0
- package/lib/chunk-8akck8xw.js +17 -0
- package/lib/chunk-963xgz1s.js +2852 -0
- package/lib/chunk-ap8jd774.js +232 -0
- package/lib/chunk-cvsxxbcx.js +477 -0
- package/lib/chunk-gcmqdtdc.js +23 -0
- package/lib/chunk-h6nk8mve.js +15 -0
- package/lib/chunk-hmbm9mgx.js +54 -0
- package/lib/chunk-jh0sq69g.js +374 -0
- package/lib/chunk-k0k2tyw7.js +19 -0
- package/lib/chunk-k8qpfr1z.js +167 -0
- package/lib/chunk-nr8c9y3r.js +340 -0
- package/lib/chunk-nwxy0jc2.js +79 -0
- package/lib/chunk-pt1ejnc2.js +4839 -0
- package/lib/chunk-qx9yrabp.js +201 -0
- package/lib/chunk-r96r37ts.js +20 -0
- package/lib/chunk-srnezxwj.js +11 -0
- package/lib/chunk-tpkbpbr7.js +9 -0
- package/lib/chunk-v7tc7wtb.js +111 -0
- package/lib/chunk-wnrwcrwb.js +423 -0
- package/lib/chunk-x2enykdk.js +873 -0
- package/lib/chunk-ysdrf8d2.js +8909 -0
- package/lib/chunk-zabx1bky.js +19 -0
- package/lib/cli/action.d.ts +3 -0
- package/lib/cli/constants.d.ts +6 -0
- package/lib/cli/index.js +393 -10149
- package/lib/config.js +7 -15443
- package/lib/connection.js +5 -15442
- package/lib/core/cli-kit/json.d.ts +2 -0
- package/lib/core/client-base.d.ts +14 -0
- package/lib/core/client.d.ts +3 -10
- package/lib/core/driver/sdk.js +46 -464
- package/lib/core/index.js +149 -1656
- package/lib/driver.js +46 -9818
- package/lib/index.js +123 -3623
- package/lib/logger.js +7 -1081
- package/lib/orm/index.js +140 -15674
- package/lib/otel/index.js +5 -56
- package/lib/plugins/create-only.js +36 -4466
- package/lib/plugins/hard-delete.js +5 -339
- package/lib/plugins/policy.js +19 -545
- package/lib/plugins/rules.js +9 -343
- package/lib/plugins/soft-delete.js +13 -4073
- package/lib/plugins/tenant.js +58 -4492
- package/lib/plugins/timestamps.js +18 -4103
- package/lib/plugins/zod.js +39 -3954
- package/lib/query.js +33 -3721
- package/lib/surreal/fn.d.ts +9 -0
- package/lib/surreal/index.d.ts +2 -49
- package/lib/surreal/orm/ai/context.d.ts +3 -0
- package/lib/surreal/orm/ai/index.d.ts +13 -0
- package/lib/surreal/orm/ai/policy.d.ts +8 -0
- package/lib/surreal/orm/ai/query.d.ts +25 -0
- package/lib/surreal/orm/ai/tool.d.ts +15 -0
- package/lib/surreal/orm/ai/types.d.ts +160 -0
- package/lib/surreal/orm/api.d.ts +2 -0
- package/lib/surreal/orm/batch.d.ts +8 -0
- package/lib/surreal/orm/client.d.ts +19 -1
- package/lib/surreal/orm/compiler/aggregate-split.d.ts +1 -1
- package/lib/surreal/orm/compiler/aggregate.d.ts +7 -0
- package/lib/surreal/orm/compiler/graph.d.ts +1 -3
- package/lib/surreal/orm/compiler/include/index.d.ts +1 -1
- package/lib/surreal/orm/compiler/include/specs.d.ts +2 -0
- package/lib/surreal/orm/compiler/reserved.d.ts +3 -0
- package/lib/surreal/orm/compiler/shared.d.ts +10 -2
- package/lib/surreal/orm/compiler/write-shared.d.ts +9 -0
- package/lib/surreal/orm/delegate.d.ts +18 -14
- package/lib/surreal/orm/errors.d.ts +11 -0
- package/lib/surreal/orm/execute.d.ts +16 -2
- package/lib/surreal/orm/graph.d.ts +6 -0
- package/lib/surreal/orm/hooks.d.ts +1 -19
- package/lib/surreal/orm/index.d.ts +17 -7
- package/lib/surreal/orm/logger/colors.d.ts +0 -1
- package/lib/surreal/orm/operations.d.ts +65 -0
- package/lib/surreal/orm/reads.d.ts +49 -1
- package/lib/surreal/orm/results.d.ts +67 -0
- package/lib/surreal/orm/search.d.ts +29 -0
- package/lib/surreal/orm/sql-statement.d.ts +5 -0
- package/lib/surreal/orm/types/api.d.ts +23 -1
- package/lib/surreal/orm/types/client.d.ts +9 -2
- package/lib/surreal/orm/types/fn.d.ts +5 -1
- package/lib/surreal/orm/types/hooks.d.ts +2 -12
- package/lib/surreal/orm/types/include.d.ts +7 -3
- package/lib/surreal/orm/types/search.d.ts +60 -0
- package/lib/surreal/orm/types/select.d.ts +86 -31
- package/lib/surreal/orm/types/where.d.ts +14 -3
- package/lib/surreal/orm/types/write.d.ts +22 -2
- package/lib/surreal/orm/validate.d.ts +41 -0
- package/lib/surreal/orm/writes.d.ts +24 -1
- package/lib/surreal/pure.d.ts +20 -1
- package/lib/surreal/surql/predicate.d.ts +4 -0
- package/lib/surreal/surql-tag.d.ts +54 -0
- package/lib/testing.js +11 -345
- package/package.json +7 -5
- package/src/cli/action.ts +3 -3
- package/src/cli/constants.ts +9 -0
- package/src/cli/driver-commands.ts +6 -5
- package/src/cli/generate-orm.ts +3 -0
- package/src/cli/generate.ts +3 -2
- package/src/cli/index.ts +9 -17
- package/src/cli/init.ts +1 -3
- package/src/cli/inspect.ts +1 -3
- package/src/cli/migrate.ts +2 -2
- package/src/core/cli-kit/generated.ts +2 -2
- package/src/core/cli-kit/json.ts +2 -0
- package/src/core/cli-kit/merge.ts +0 -3
- package/src/core/cli-kit/meta.ts +2 -2
- package/src/core/client-base.ts +19 -0
- package/src/core/client.ts +4 -14
- package/src/core/kind/plan.ts +0 -3
- package/src/otel/logger.ts +1 -5
- package/src/surreal/cli/format.ts +1 -4
- package/src/surreal/cli/pull.ts +4 -7
- package/src/surreal/cli/struct.ts +3 -6
- package/src/surreal/cli/structure.ts +0 -3
- package/src/surreal/cli/surreal-diff.ts +0 -4
- package/src/surreal/ddl.ts +0 -2
- package/src/surreal/fn.ts +14 -6
- package/src/surreal/index.ts +3 -136
- package/src/surreal/orm/ai/context.ts +158 -0
- package/src/surreal/orm/ai/index.ts +34 -0
- package/src/surreal/orm/ai/policy.ts +47 -0
- package/src/surreal/orm/ai/query.ts +295 -0
- package/src/surreal/orm/ai/tool.ts +161 -0
- package/src/surreal/orm/ai/types.ts +160 -0
- package/src/surreal/orm/api.ts +56 -1
- package/src/surreal/orm/batch.ts +67 -0
- package/src/surreal/orm/client.ts +37 -1
- package/src/surreal/orm/compiler/adjustment.ts +1 -6
- package/src/surreal/orm/compiler/aggregate-entries.ts +27 -2
- package/src/surreal/orm/compiler/aggregate-operand.ts +0 -2
- package/src/surreal/orm/compiler/aggregate-split.ts +25 -13
- package/src/surreal/orm/compiler/aggregate.ts +16 -8
- package/src/surreal/orm/compiler/graph.ts +1 -10
- package/src/surreal/orm/compiler/include/index.ts +7 -1
- package/src/surreal/orm/compiler/include/links.ts +38 -12
- package/src/surreal/orm/compiler/include/projection.ts +34 -16
- package/src/surreal/orm/compiler/include/specs.ts +2 -0
- package/src/surreal/orm/compiler/keyset.ts +2 -4
- package/src/surreal/orm/compiler/mutate.ts +12 -9
- package/src/surreal/orm/compiler/projection.ts +16 -17
- package/src/surreal/orm/compiler/reserved.ts +3 -0
- package/src/surreal/orm/compiler/select.ts +143 -41
- package/src/surreal/orm/compiler/shared.ts +16 -5
- package/src/surreal/orm/compiler/where.ts +6 -11
- package/src/surreal/orm/compiler/write-shared.ts +10 -0
- package/src/surreal/orm/decode.ts +5 -2
- package/src/surreal/orm/delegate.ts +24 -40
- package/src/surreal/orm/errors.ts +14 -8
- package/src/surreal/orm/execute.ts +91 -17
- package/src/surreal/orm/fn.ts +35 -1
- package/src/surreal/orm/graph.ts +33 -55
- package/src/surreal/orm/hooks.ts +7 -49
- package/src/surreal/orm/index.ts +72 -1
- package/src/surreal/orm/logger/colors.ts +0 -4
- package/src/surreal/orm/logger/logger.ts +19 -15
- package/src/surreal/orm/operations.ts +81 -0
- package/src/surreal/orm/raw.ts +5 -4
- package/src/surreal/orm/reads.ts +97 -28
- package/src/surreal/orm/results.ts +111 -1
- package/src/surreal/orm/search.ts +320 -0
- package/src/surreal/orm/sql-statement.ts +12 -0
- package/src/surreal/orm/types/api.ts +42 -1
- package/src/surreal/orm/types/client.ts +17 -1
- package/src/surreal/orm/types/fn.ts +5 -1
- package/src/surreal/orm/types/hooks.ts +17 -28
- package/src/surreal/orm/types/include.ts +16 -12
- package/src/surreal/orm/types/search.ts +74 -0
- package/src/surreal/orm/types/select.ts +132 -39
- package/src/surreal/orm/types/where.ts +16 -2
- package/src/surreal/orm/types/write.ts +24 -2
- package/src/surreal/orm/validate.ts +84 -0
- package/src/surreal/orm/writes.ts +91 -7
- package/src/surreal/plugins/zod.ts +29 -9
- package/src/surreal/pure.ts +74 -10
- package/src/surreal/surql/predicate.ts +10 -0
- package/src/surreal/surql-tag.ts +142 -0
- package/src/surreal/wire.ts +0 -3
- package/lib/aot.js.map +0 -20
- package/lib/authoring.js.map +0 -12
- package/lib/cli/index.js.map +0 -63
- package/lib/config.js.map +0 -99
- package/lib/connection.js.map +0 -98
- package/lib/core/driver/sdk.js.map +0 -15
- package/lib/core/index.js.map +0 -25
- package/lib/driver.js.map +0 -49
- package/lib/index.js.map +0 -22
- package/lib/logger.js.map +0 -18
- package/lib/orm/index.js.map +0 -99
- package/lib/otel/index.js.map +0 -12
- package/lib/plugin.js.map +0 -10
- package/lib/plugins/create-only.js.map +0 -27
- package/lib/plugins/hard-delete.js.map +0 -13
- package/lib/plugins/policy.js.map +0 -15
- package/lib/plugins/rules.js.map +0 -13
- package/lib/plugins/soft-delete.js.map +0 -24
- package/lib/plugins/tenant.js.map +0 -29
- package/lib/plugins/timestamps.js.map +0 -25
- package/lib/plugins/zod.js.map +0 -23
- package/lib/query.js.map +0 -22
- package/lib/testing.js.map +0 -12
- package/lib/zod-core.js.map +0 -10
- package/lib/zod.js.map +0 -10
package/README.md
CHANGED
|
@@ -817,12 +817,53 @@ await Bun.build({
|
|
|
817
817
|
});
|
|
818
818
|
```
|
|
819
819
|
|
|
820
|
+
## ORM API highlights (typed callbacks, prepared reads, hybrid search)
|
|
821
|
+
|
|
822
|
+
```ts
|
|
823
|
+
import { defineSearch, orm, param } from "better-schemic/orm";
|
|
824
|
+
import { defineFn, s, table } from "better-schemic";
|
|
825
|
+
|
|
826
|
+
const client = orm(conn, { schema: { users: User } });
|
|
827
|
+
|
|
828
|
+
// Callbacks run at COMPILE time and emit the same SQL as the object form.
|
|
829
|
+
const adults = await client.users.findMany({
|
|
830
|
+
where: (u) => u.age.gte(18),
|
|
831
|
+
select: (u) => ({ id: u.id, name: u.name }),
|
|
832
|
+
orderBy: (u) => u.age.desc(),
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
// Compile once, replay with fresh named values.
|
|
836
|
+
const byName = client.users
|
|
837
|
+
.findMany({ where: { name: param<string>("name") } })
|
|
838
|
+
.prepare("users.by-name");
|
|
839
|
+
await byName.execute({ name: "Ada" });
|
|
840
|
+
|
|
841
|
+
// Several operations, ONE atomic round-trip, typed tuple result.
|
|
842
|
+
const [rows, total] = await client.batch(
|
|
843
|
+
client.users.findMany({ limit: 10 }),
|
|
844
|
+
client.users.count({ where: { active: true } }),
|
|
845
|
+
);
|
|
846
|
+
|
|
847
|
+
// BM25 + ANN + a custom scorer, fused with SurrealDB's search::rrf.
|
|
848
|
+
const jw = defineFn("jw", { a: s.string(), b: s.string() }, s.string());
|
|
849
|
+
const searchUsers = defineSearch(User, {
|
|
850
|
+
select: ["id", "name"],
|
|
851
|
+
sources: {
|
|
852
|
+
bm25: { kind: "bm25", field: "name" },
|
|
853
|
+
ann: { kind: "ann", field: "embedding", k: 5 },
|
|
854
|
+
fuzzy: { kind: "fuzzy", field: "name", fn: "jw" },
|
|
855
|
+
},
|
|
856
|
+
fuse: { method: "rrf", k: 60 },
|
|
857
|
+
});
|
|
858
|
+
const hits = await searchUsers(client, { query: "Ada", embedding: [0.1, 0.2, 0.3] });
|
|
859
|
+
```
|
|
860
|
+
|
|
820
861
|
## Docs
|
|
821
862
|
|
|
822
863
|
Full guides, concepts, and reference live at
|
|
823
864
|
[docs](https://github.com/NONSTANDARDCODE/better-schemic). Feature maps:
|
|
824
865
|
[docs/COVERAGE.md](docs/COVERAGE.md) (schema/DDL) and
|
|
825
|
-
[docs/ORM-COVERAGE.md](docs/ORM-COVERAGE.md) (runtime ORM surface); the live-verified SurrealQL the
|
|
866
|
+
[docs/ORM-COVERAGE.md](docs/ORM-COVERAGE.md) (runtime ORM surface), [docs/AI-API.md](docs/AI-API.md) (AI context, guarded queries and tools); the live-verified SurrealQL the
|
|
826
867
|
ORM emits is [docs/orm-syntax-map.md](docs/orm-syntax-map.md), and the milestone plan is
|
|
827
868
|
[ROADMAP.md](../../ROADMAP.md). This package is part of the
|
|
828
869
|
[Better-schemic](https://github.com/NONSTANDARDCODE/better-schemic) toolkit.
|