typion 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +4 -2
- package/bin/typion.js +7 -0
- package/dist/auth/better-auth.d.ts +13 -0
- package/dist/auth/better-auth.js +11 -0
- package/dist/auth/better-auth.js.map +1 -0
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.js +883 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/column-kinds-Bkm4NJI2.js +47 -0
- package/dist/column-kinds-Bkm4NJI2.js.map +1 -0
- package/dist/context-B4e2eREP.d.ts +2100 -0
- package/dist/contract/index.d.ts +137 -0
- package/dist/contract/index.js +42 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/db/pglite.d.ts +12 -0
- package/dist/db/pglite.js +27 -0
- package/dist/db/pglite.js.map +1 -0
- package/dist/descriptor-Cc3mGp73.js +12 -0
- package/dist/descriptor-Cc3mGp73.js.map +1 -0
- package/dist/errors-ChDBxeS-.js +17 -0
- package/dist/errors-ChDBxeS-.js.map +1 -0
- package/dist/errors-D-CKO-px.js +114 -0
- package/dist/errors-D-CKO-px.js.map +1 -0
- package/dist/handler-BWVU8TCR.d.ts +23 -0
- package/dist/handler-_87bFkbP.js +565 -0
- package/dist/handler-_87bFkbP.js.map +1 -0
- package/dist/hono/index.d.ts +17 -0
- package/dist/hono/index.js +26 -0
- package/dist/hono/index.js.map +1 -0
- package/dist/http/index.d.ts +13 -0
- package/dist/http/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1324 -0
- package/dist/index.js.map +1 -0
- package/dist/issues-DLqCBQT1.js +42 -0
- package/dist/issues-DLqCBQT1.js.map +1 -0
- package/dist/next/index.d.ts +8 -0
- package/dist/next/index.js +18 -0
- package/dist/next/index.js.map +1 -0
- package/dist/operations-D3rOacLX.js +1811 -0
- package/dist/operations-D3rOacLX.js.map +1 -0
- package/dist/schema/index.d.ts +18 -0
- package/dist/schema/index.js +3 -0
- package/dist/schema-Rzzq97cK.js +68 -0
- package/dist/schema-Rzzq97cK.js.map +1 -0
- package/dist/seed/index.d.ts +19 -0
- package/dist/seed/index.js +85 -0
- package/dist/seed/index.js.map +1 -0
- package/dist/structural-BZnjFmCs.js +247 -0
- package/dist/structural-BZnjFmCs.js.map +1 -0
- package/dist/testing/index.d.ts +26 -0
- package/dist/testing/index.js +92 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/typion-Dh2BCSRz.js +1187 -0
- package/dist/typion-Dh2BCSRz.js.map +1 -0
- package/dist/validation/zod.d.ts +21 -0
- package/dist/validation/zod.js +84 -0
- package/dist/validation/zod.js.map +1 -0
- package/docs/README.md +145 -0
- package/docs/access.md +114 -0
- package/docs/auth.md +195 -0
- package/docs/collections.md +172 -0
- package/docs/database.md +76 -0
- package/docs/features/localization.md +112 -0
- package/docs/features/multi-tenant.md +166 -0
- package/docs/features/soft-delete.md +85 -0
- package/docs/features/versions.md +106 -0
- package/docs/hooks.md +106 -0
- package/docs/http.md +188 -0
- package/docs/queries.md +200 -0
- package/docs/testing.md +85 -0
- package/package.json +125 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simone Ergotino
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Typion
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Headless, type-safe application engine on top of Drizzle ORM: access control, hooks, drafts and versions, localization, soft delete, multi-tenancy, audit and a Fetch-based HTTP handler, with result types derived from the query you write.
|
|
4
|
+
|
|
5
|
+
[docs/README.md](docs/README.md) is the guide for applications: the model, the rules, and a page per task. It ships with the package, so an application finds it in `node_modules/typion/docs/`, and `typion init` points the application's agent notes at it.
|
package/bin/typion.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { main } from '../dist/cli/index.js'
|
|
3
|
+
|
|
4
|
+
const code = await main(process.argv.slice(2))
|
|
5
|
+
// A database driver can keep handles open (PGlite does), and a command that has said what it had to say
|
|
6
|
+
// should not hold the shell.
|
|
7
|
+
process.exit(code)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Gt as ContextFactoryInput, N as AnyDb, Wt as ContextFactory, a as MaybePromise } from "../context-B4e2eREP.js";
|
|
2
|
+
//#region src/auth/better-auth.d.ts
|
|
3
|
+
export type SessionProvider = {
|
|
4
|
+
api: {
|
|
5
|
+
getSession(options: {
|
|
6
|
+
headers: Headers;
|
|
7
|
+
}): Promise<unknown>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export type SessionOf<TAuth extends SessionProvider> = Awaited<ReturnType<TAuth['api']['getSession']>>;
|
|
11
|
+
export declare function betterAuthContext<TAuth extends SessionProvider, TCtx extends object>(auth: TAuth | ((db: AnyDb) => TAuth), map: (session: SessionOf<TAuth>, input: ContextFactoryInput) => MaybePromise<TCtx>): ContextFactory<TCtx>;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=better-auth.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/auth/better-auth.ts
|
|
2
|
+
function betterAuthContext(auth, map) {
|
|
3
|
+
return async (input) => {
|
|
4
|
+
const headers = input.headers ?? input.request?.headers ?? new Headers();
|
|
5
|
+
return map(await ("api" in auth ? auth : auth(input.db)).api.getSession({ headers }), input);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { betterAuthContext };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=better-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"better-auth.js","names":[],"sources":["../../src/auth/better-auth.ts"],"sourcesContent":["import type { MaybePromise } from '../types/context.js'\nimport type { ContextFactory, ContextFactoryInput } from '../types/collection.js'\nimport type { AnyDb } from '../types/runtime.js'\n\n// Structural on purpose: the engine never imports better-auth, so any auth library exposing the same\n// `api.getSession({ headers })` shape works, and better-auth stays an optional peer.\nexport type SessionProvider = {\n api: { getSession(options: { headers: Headers }): Promise<unknown> }\n}\n\nexport type SessionOf<TAuth extends SessionProvider> = Awaited<\n ReturnType<TAuth['api']['getSession']>\n>\n\n// The library says who signed in; `map` says who that is to the application. It gets the factory's input with\n// `system`, which crosses tenants, so it can look the caller up: their membership, their role (auth.md).\n// `auth` is the provider, or what builds it on the instance's connection: a provider per instance reads a test's\n// sessions from the test's database, and the config never has to reach the instance itself (ADR-092).\nexport function betterAuthContext<TAuth extends SessionProvider, TCtx extends object>(\n auth: TAuth | ((db: AnyDb) => TAuth),\n map: (session: SessionOf<TAuth>, input: ContextFactoryInput) => MaybePromise<TCtx>,\n): ContextFactory<TCtx> {\n return async (input) => {\n const headers = input.headers ?? input.request?.headers ?? new Headers()\n const provider = 'api' in auth ? (auth as TAuth) : auth(input.db)\n const session = (await provider.api.getSession({ headers })) as SessionOf<TAuth>\n return map(session, input)\n }\n}\n"],"mappings":";AAkBA,SAAgB,kBACd,MACA,KACsB;CACtB,OAAO,OAAO,UAAU;EACtB,MAAM,UAAU,MAAM,WAAW,MAAM,SAAS,WAAW,IAAI,QAAQ;EAGvE,OAAO,IAAI,OAFM,SAAS,OAAQ,OAAiB,KAAK,MAAM,EAAE,EAAA,CAChC,IAAI,WAAW,EAAE,QAAQ,CAAC,GACtC,KAAK;CAC3B;AACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/cli/output.d.ts
|
|
2
|
+
export declare class CliError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
type Io = {
|
|
6
|
+
out(line: string): void;
|
|
7
|
+
err(line: string): void;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/cli/index.d.ts
|
|
11
|
+
export declare function run(argv: readonly string[], io?: Io, cwd?: string): Promise<void>;
|
|
12
|
+
export declare function main(argv: readonly string[]): Promise<number>;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|