@isaijs/core 0.1.0 → 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/dist/adapters/cache/cloudflare-kv/index.d.ts +1 -1
- package/dist/adapters/database/d1/index.d.ts +1 -1
- package/dist/adapters/database/durable-object/index.d.ts +1 -1
- package/dist/adapters/database/sqlite-node/index.d.ts +1 -1
- package/dist/adapters/mail/gmail/index.d.ts +1 -1
- package/dist/adapters/pdf/cloudflare-browser/index.d.ts +1 -1
- package/dist/adapters/queue/cloudflare/index.d.ts +1 -1
- package/dist/adapters/ratelimit/cloudflare/index.d.ts +1 -1
- package/dist/adapters/ratelimit/memory/index.d.ts +1 -1
- package/dist/adapters/runtime/cloudflare/index.d.ts +1 -1
- package/dist/adapters/runtime/cloudflare/index.js +1 -1
- package/dist/adapters/storage/disk/index.d.ts +1 -1
- package/dist/adapters/storage/memory/index.d.ts +1 -1
- package/dist/adapters/storage/r2/index.d.ts +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +2 -2
- package/dist/{base64url-DwWPqoOT.js → base64url-K_wCmvxR.js} +23 -9
- package/dist/cli/index.js +12 -12
- package/dist/client/index.d.ts +5 -5
- package/dist/client/index.js +3 -3
- package/dist/{config-D6PexpSC.js → config-0PGFbJh6.js} +13 -6
- package/dist/{create-auth-Byf1-VJw.js → create-auth-y8E8cxkn.js} +5 -5
- package/dist/{data-layer-BNtz40PV.js → data-layer-D9UPOK6L.js} +9 -7
- package/dist/{data-layer-BMviRJaW.d.ts → data-layer-ubPfZvFV.d.ts} +20 -11
- package/dist/db/index.d.ts +3 -3
- package/dist/db/index.js +5 -5
- package/dist/{index-CBWFoL3s.d.ts → index-B6ipokoP.d.ts} +35 -25
- package/dist/{index-BVCrbMav.d.ts → index-C-WmIKxT.d.ts} +5 -6
- package/dist/{index-BKwTOLop.d.ts → index-Ce5p2-EB.d.ts} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +47 -30
- package/dist/{issues-Bxq4JExX.d.ts → issues-CKto95IW.d.ts} +3 -1
- package/dist/{make-DKzPd2b_.js → make-WQpkYW8N.js} +17 -2
- package/dist/{migrator-C65RM_K-.js → migrator-6oWUefLA.js} +68 -9
- package/dist/{policies-yVzFCjxU.js → policies-pFzslmSB.js} +3 -3
- package/dist/ports/index.d.ts +1 -1
- package/dist/{resource-9fjxJgmz.js → resource-C17NvNa3.js} +42 -15
- package/dist/{tables-C3Uza4qK.js → tables-C4ipMFjg.js} +4 -4
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +6 -6
- package/dist/{types-BFc_NEx8.d.ts → types-DpOcIuDl.d.ts} +15 -12
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +1 -1
- package/dist/{validation-l5JG-PFn.js → validation-FyOpSZqE.js} +2 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DatabaseDriver, f as Row } from "../../../index-
|
|
1
|
+
import { a as DatabaseDriver, f as Row } from "../../../index-Ce5p2-EB.js";
|
|
2
2
|
//#region src/adapters/database/d1/index.d.ts
|
|
3
3
|
/** The parts of a D1 prepared statement this driver uses. */
|
|
4
4
|
export interface D1Statement {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as DatabaseDriver, b as TenantDatabases, f as Row } from "../../../index-
|
|
1
|
+
import { a as DatabaseDriver, b as TenantDatabases, f as Row } from "../../../index-Ce5p2-EB.js";
|
|
2
2
|
//#region src/adapters/database/durable-object/index.d.ts
|
|
3
3
|
/** The parts of `ctx.storage` this driver uses (structurally compatible with `wrangler types`). */
|
|
4
4
|
export interface DurableObjectStorageBinding {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as PdfRenderer } from "../../../index-
|
|
1
|
+
import { l as PdfRenderer } from "../../../index-Ce5p2-EB.js";
|
|
2
2
|
//#region src/adapters/pdf/cloudflare-browser/index.d.ts
|
|
3
3
|
/** A Browser Rendering binding (opaque here; used through @cloudflare/puppeteer). */
|
|
4
4
|
export type BrowserBinding = object;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as RateLimiter } from "../../../index-
|
|
1
|
+
import { d as RateLimiter } from "../../../index-Ce5p2-EB.js";
|
|
2
2
|
//#region src/adapters/ratelimit/cloudflare/index.d.ts
|
|
3
3
|
/** The part of a Rate Limiting binding this uses. */
|
|
4
4
|
export interface RateLimitBinding {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as Row, m as ServiceRef, p as Runtime, v as TaskMessage } from "../../../index-
|
|
1
|
+
import { f as Row, m as ServiceRef, p as Runtime, v as TaskMessage } from "../../../index-Ce5p2-EB.js";
|
|
2
2
|
import { DurableObject } from "cloudflare:workers";
|
|
3
3
|
//#region src/adapters/runtime/cloudflare/index.d.ts
|
|
4
4
|
/** The parts of the Workers platform this runtime uses (structurally compatible with `wrangler types`). */
|
|
@@ -11,7 +11,7 @@ import { DurableObject } from "cloudflare:workers";
|
|
|
11
11
|
*
|
|
12
12
|
* With isolated tenancy, `Tenant` is the Durable Object class each tenant lives in: it opens the
|
|
13
13
|
* tenant from its own storage, migrates it before any request (`blockConcurrencyWhile`), and
|
|
14
|
-
* handles what the front door forwards to it over RPC
|
|
14
|
+
* handles what the front door forwards to it over RPC.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
17
|
* One failing task never holds back the rest of its batch: each message is acked on
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as Storage } from "../../../index-
|
|
1
|
+
import { g as Storage } from "../../../index-Ce5p2-EB.js";
|
|
2
2
|
//#region src/adapters/storage/memory/index.d.ts
|
|
3
3
|
export interface MemoryStorageOptions {
|
|
4
4
|
/** Where its files would be served from, to make it a public storage. */
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as AuthTablesOptions } from "../data-layer-
|
|
2
|
-
import { A as Permissions, F as DefinePolicy, I as Perms, L as Policy, N as AnyPolicy, P as Bound, R as Rules, a as OAuthMethod, c as Roles, i as Methods, l as SignInMethod, n as AuthConfig, o as Provider, r as AuthDefinition, s as RoleDefinition, t as Auth, u as createAuth, z as StandardAction } from "../index-
|
|
1
|
+
import { r as AuthTablesOptions } from "../data-layer-ubPfZvFV.js";
|
|
2
|
+
import { A as Permissions, F as DefinePolicy, I as Perms, L as Policy, N as AnyPolicy, P as Bound, R as Rules, a as OAuthMethod, c as Roles, i as Methods, l as SignInMethod, n as AuthConfig, o as Provider, r as AuthDefinition, s as RoleDefinition, t as Auth, u as createAuth, z as StandardAction } from "../index-B6ipokoP.js";
|
|
3
3
|
export { type AnyPolicy, Auth, type AuthConfig, type AuthDefinition, type AuthTablesOptions, type Bound, type DefinePolicy, type Methods, type OAuthMethod, type Permissions, type Perms, Policy, type Provider, type RoleDefinition, type Roles, type Rules, type SignInMethod, type StandardAction, createAuth };
|
package/dist/auth/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as Policy } from "../policies-
|
|
2
|
-
import { a as createAuth, t as Auth } from "../create-auth-
|
|
1
|
+
import { t as Policy } from "../policies-pFzslmSB.js";
|
|
2
|
+
import { a as createAuth, t as Auth } from "../create-auth-y8E8cxkn.js";
|
|
3
3
|
export { Auth, Policy, createAuth };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as flag, C as textKind, D as date, E as choice, F as sequence, L as list, M as int, N as money, O as datetime, P as quantity, S as text, T as url, U as kind, _ as personName, b as slugify, c as images, d as urls, f as email, g as newToken, h as markdown, i as file, j as id, k as fakeUlid, l as define, m as line, n as phoneKind, o as files, s as image, u as json, v as secret, w as token, x as subdomain, y as slug } from "./validation-
|
|
1
|
+
import { A as flag, C as textKind, D as date, E as choice, F as sequence, L as list, M as int, N as money, O as datetime, P as quantity, S as text, T as url, U as kind, _ as personName, b as slugify, c as images, d as urls, f as email, g as newToken, h as markdown, i as file, j as id, k as fakeUlid, l as define, m as line, n as phoneKind, o as files, s as image, u as json, v as secret, w as token, x as subdomain, y as slug } from "./validation-FyOpSZqE.js";
|
|
2
2
|
import { n as snakeCase } from "./case-BnpcvhdW.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
//#region src/internal/scope.ts
|
|
@@ -73,9 +73,20 @@ const ulid = monotonicUlid();
|
|
|
73
73
|
//#endregion
|
|
74
74
|
//#region src/db/orm/audit.ts
|
|
75
75
|
/**
|
|
76
|
-
* The audit log in the ORM's write path
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* The audit log in the ORM's write path: which writes are recorded, who makes them, and the
|
|
77
|
+
* statements placed around each one in its batch, so a change and its entries commit together (or
|
|
78
|
+
* neither does).
|
|
79
|
+
*
|
|
80
|
+
* Recorded: every ORM write (`…One`, `…Many`, upserts, inside `atomic` too), from routes,
|
|
81
|
+
* resources and services alike; a custom action's entry beside the writes it made (one request id
|
|
82
|
+
* ties them); sign-ins and sign-outs. Not recorded: data steps and the roles synced from `app.ts`
|
|
83
|
+
* (upkeep, nobody edited them), `db.raw`, `reorder` (positions are maintained), rows the database
|
|
84
|
+
* changes itself (cascades, counts, copies follow from a recorded write), reads, and the tables
|
|
85
|
+
* marked `unaudited` (Session, Verification, Upload, the log itself).
|
|
86
|
+
*
|
|
87
|
+
* Why in the batch, not from the post-commit write stream: a second write after commit can be lost
|
|
88
|
+
* while the change stays, and once committed the before values are gone. Why not triggers: a
|
|
89
|
+
* trigger can't see who wrote, and would record the database's own count and copy updates as noise.
|
|
79
90
|
*/
|
|
80
91
|
const actors = new Scope();
|
|
81
92
|
/** Runs `fn` with `actor` as the one every write inside it is recorded as made by. */
|
|
@@ -263,8 +274,11 @@ var Field = class Field {
|
|
|
263
274
|
}
|
|
264
275
|
/**
|
|
265
276
|
* A copy of a related row's value (`.from((s) => s.criterion.maxScore)`), so the row's checks and
|
|
266
|
-
* uniques can use it. The database writes it on create and keeps it equal to its source
|
|
267
|
-
* never written. The path's
|
|
277
|
+
* uniques can use it. The database writes it on create and keeps it equal to its source (triggers
|
|
278
|
+
* on each table along the path, so raw SQL writes are seen too); it's never written. The path's
|
|
279
|
+
* first ref must be `.fixed()`; when every step and the final field are fixed, it's written once
|
|
280
|
+
* and no trigger is made. A plain path to one column only: a derived value is `.computed()`, and a
|
|
281
|
+
* value frozen as it was is a snapshot, not a copy.
|
|
268
282
|
*/
|
|
269
283
|
from(build) {
|
|
270
284
|
if (this.spec.maintained || this.spec.computed || this.spec.generate) throw new TypeError("isai: .from() is for a plain field (not one the database or the framework makes)");
|
|
@@ -331,7 +345,7 @@ function sensitivity(spec) {
|
|
|
331
345
|
//#region src/db/fields/kinds.ts
|
|
332
346
|
/**
|
|
333
347
|
* The built-in field kinds: each is a kind from `isai/validation` with its storage. Kinds own
|
|
334
|
-
* their limits and rules; columns never repeat them
|
|
348
|
+
* their limits and rules; columns never repeat them.
|
|
335
349
|
*/
|
|
336
350
|
function fieldSpec(kind, storage, options) {
|
|
337
351
|
return {
|
|
@@ -429,7 +443,7 @@ function fieldKinds(defaults) {
|
|
|
429
443
|
json: (options) => field(json(options.shape), "json"),
|
|
430
444
|
/** A list, for shapes (`f.json({ shape: f.list(...) })`, route inputs). Not a column itself. */
|
|
431
445
|
list,
|
|
432
|
-
/** A file; `{ storage }` names a storage other than `default
|
|
446
|
+
/** A file; `{ storage }` names a storage other than `default`. */
|
|
433
447
|
file: (options = {}) => field(file(options), "json"),
|
|
434
448
|
image: (options = {}) => field(image(options), "json"),
|
|
435
449
|
files: (options = {}) => field(files(options), "json"),
|
|
@@ -1067,7 +1081,7 @@ var Model = class Model {
|
|
|
1067
1081
|
}
|
|
1068
1082
|
/**
|
|
1069
1083
|
* A rule over the row, written as a condition. It runs in JS on every write; when it reads
|
|
1070
|
-
* more than one field it is also a database guard
|
|
1084
|
+
* more than one field it is also a database guard.
|
|
1071
1085
|
*/
|
|
1072
1086
|
check(name, build) {
|
|
1073
1087
|
assertIdentifier("a check name", name);
|
package/dist/cli/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { B as toKind, R as object } from "../validation-
|
|
3
|
-
import { M as dialectFor, m as emptySnapshot, r as sync, t as migrate, y as MigrationError } from "../migrator-
|
|
4
|
-
import { a as lookupsOf, i as filterableOf, n as isRequired, t as Resource, u as Route } from "../resource-
|
|
5
|
-
import { F as sensitivity, c as fieldOf, r as Model } from "../base64url-
|
|
2
|
+
import { B as toKind, R as object } from "../validation-FyOpSZqE.js";
|
|
3
|
+
import { M as dialectFor, m as emptySnapshot, r as sync, t as migrate, y as MigrationError } from "../migrator-6oWUefLA.js";
|
|
4
|
+
import { a as lookupsOf, i as filterableOf, n as isRequired, t as Resource, u as Route } from "../resource-C17NvNa3.js";
|
|
5
|
+
import { F as sensitivity, c as fieldOf, r as Model } from "../base64url-K_wCmvxR.js";
|
|
6
6
|
import { t as kebabCase } from "../case-BnpcvhdW.js";
|
|
7
|
-
import { i as makeMigrations, n as checkSteps, t as checkMigrations } from "../make-
|
|
7
|
+
import { i as makeMigrations, n as checkSteps, t as checkMigrations } from "../make-WQpkYW8N.js";
|
|
8
8
|
import { d1 } from "../adapters/database/d1/index.js";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
10
|
import { parseArgs } from "node:util";
|
|
@@ -325,7 +325,7 @@ function json(text, side) {
|
|
|
325
325
|
/**
|
|
326
326
|
* The app's models: every export of every file in `db/schema/` that is a model, plus the built-in
|
|
327
327
|
* tables `db/index.ts` switches on (`use`) that the app doesn't extend. `db/schema/` holds models
|
|
328
|
-
* only
|
|
328
|
+
* only, so there's no list to keep. A model's database is its folder:
|
|
329
329
|
* `db/schema/<database>/` (`tenant/` and `platform/` with tenancy, `main/` or any one name without).
|
|
330
330
|
*/
|
|
331
331
|
const SCHEMA_DIR = "db/schema";
|
|
@@ -385,7 +385,7 @@ function databasesOf(models) {
|
|
|
385
385
|
//#endregion
|
|
386
386
|
//#region src/cli/outputs.ts
|
|
387
387
|
/**
|
|
388
|
-
* What handlers return, for the typed client
|
|
388
|
+
* What handlers return, for the typed client: each route's and custom
|
|
389
389
|
* action's TypeScript return type, read with the compiler over the app's own tsconfig, and printed
|
|
390
390
|
* as the JSON the output layer sends: dates (anything with `toJSON`) as what `toJSON` returns,
|
|
391
391
|
* files as `FileJSON`, functions and symbol keys left out, `undefined` keys optional.
|
|
@@ -534,7 +534,7 @@ const key = (name) => IDENTIFIER.test(name) ? name : JSON.stringify(name);
|
|
|
534
534
|
//#region src/cli/client.ts
|
|
535
535
|
/**
|
|
536
536
|
* `isai client` (and `isai dev`, on start and on each change): writes `.isai/client.ts`, the app's
|
|
537
|
-
* typed client
|
|
537
|
+
* typed client; `isai check` fails on a stale one. The app modules (`apps/**`)
|
|
538
538
|
* are loaded as the app loads them, for the exact endpoints, inputs and rows; what their handlers
|
|
539
539
|
* return is read with the TypeScript compiler.
|
|
540
540
|
*/
|
|
@@ -762,7 +762,7 @@ function printPlan(plan, log) {
|
|
|
762
762
|
}
|
|
763
763
|
/**
|
|
764
764
|
* Applies every pending step to the local databases at once: structure, rules, then data steps.
|
|
765
|
-
* No older code is running locally, so nothing waits for a release
|
|
765
|
+
* No older code is running locally, so nothing waits for a release.
|
|
766
766
|
* Returns the steps applied, as `<database>/<step>`.
|
|
767
767
|
*/
|
|
768
768
|
async function migrateLocal(project, databaseFor, log) {
|
|
@@ -792,7 +792,7 @@ async function migrateLocal(project, databaseFor, log) {
|
|
|
792
792
|
//#region src/cli/project.ts
|
|
793
793
|
/**
|
|
794
794
|
* The app the CLI works on: its root, and how its TypeScript is imported: models (`db/schema/`),
|
|
795
|
-
* migration manifests, and the app modules for the typed client
|
|
795
|
+
* migration manifests, and the app modules for the typed client.
|
|
796
796
|
*/
|
|
797
797
|
/** The nearest directory upward from `from` with a `package.json`. */
|
|
798
798
|
function findRoot(from) {
|
|
@@ -838,7 +838,7 @@ const PLATFORM_STUB = [
|
|
|
838
838
|
].join("\n");
|
|
839
839
|
//#endregion
|
|
840
840
|
//#region src/cli/prompt.ts
|
|
841
|
-
/** Asks `makemigrations`' questions in a terminal
|
|
841
|
+
/** Asks `makemigrations`' questions in a terminal. */
|
|
842
842
|
/** A value typed at the prompt: JSON when it reads as JSON (`3`, `true`), the text otherwise. */
|
|
843
843
|
function typedValue(text) {
|
|
844
844
|
try {
|
|
@@ -898,7 +898,7 @@ async function answer(question, prompt) {
|
|
|
898
898
|
/**
|
|
899
899
|
* The `workers` target, from the CLI: the app's `wrangler.jsonc`, its local D1 (the database
|
|
900
900
|
* `wrangler dev` uses), and `wrangler dev` itself. The CLI never imports `app.ts`: the database
|
|
901
|
-
* is the D1 binding whose `migrations_dir` is `migrations/<database
|
|
901
|
+
* is the D1 binding whose `migrations_dir` is `migrations/<database>`.
|
|
902
902
|
*/
|
|
903
903
|
const CONFIG_FILES = ["wrangler.jsonc", "wrangler.json"];
|
|
904
904
|
function configPath(root) {
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as Issue } from "../issues-
|
|
1
|
+
import { t as Issue } from "../issues-CKto95IW.js";
|
|
2
2
|
//#region src/client/types.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* The types a generated client (`.isai/client.ts`) is written in: pages, list queries with the
|
|
5
5
|
* lookups each kind takes, files as JSON, and the auth module's endpoints. Values are their JSON
|
|
6
6
|
* forms: dates are ISO strings, money integer minor units, refs ids.
|
|
7
7
|
*/
|
|
8
|
-
/** A list's page
|
|
8
|
+
/** A list's page; `page`, `pages` and `count` when asked. */
|
|
9
9
|
interface Page<T> {
|
|
10
10
|
readonly data: T[];
|
|
11
11
|
readonly next: string | null;
|
|
@@ -62,7 +62,7 @@ interface HistoryQuery {
|
|
|
62
62
|
readonly after?: string;
|
|
63
63
|
readonly before?: string;
|
|
64
64
|
}
|
|
65
|
-
/** One audit entry on a row
|
|
65
|
+
/** One audit entry on a row. */
|
|
66
66
|
interface HistoryEntry {
|
|
67
67
|
readonly id: string;
|
|
68
68
|
readonly createdAt: string;
|
|
@@ -151,7 +151,7 @@ interface ResourceEndpoint {
|
|
|
151
151
|
/** `read`, `create`, `update`, `delete`, trait actions (`publish`, `reorder`), `history`. */
|
|
152
152
|
readonly actions: readonly string[];
|
|
153
153
|
readonly custom?: readonly string[];
|
|
154
|
-
/** Its writable file fields: `upload(field, file)` sends a file to attach by id
|
|
154
|
+
/** Its writable file fields: `upload(field, file)` sends a file to attach by id. */
|
|
155
155
|
readonly uploads?: readonly string[];
|
|
156
156
|
}
|
|
157
157
|
/** A route in the endpoint table. */
|
|
@@ -181,7 +181,7 @@ export declare function listQuery(query: ListQuery<Readonly<Record<string, unkno
|
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/client/errors.d.ts
|
|
183
183
|
/**
|
|
184
|
-
* A failed call: the API's one error shape
|
|
184
|
+
* A failed call: the API's one error shape,
|
|
185
185
|
* `{ error: { code, message, … }, requestId }`, with its status.
|
|
186
186
|
*/
|
|
187
187
|
export declare class ApiError extends Error {
|
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as kebabCase } from "../case-BnpcvhdW.js";
|
|
2
2
|
//#region src/client/errors.ts
|
|
3
3
|
/**
|
|
4
|
-
* A failed call: the API's one error shape
|
|
4
|
+
* A failed call: the API's one error shape,
|
|
5
5
|
* `{ error: { code, message, … }, requestId }`, with its status.
|
|
6
6
|
*/
|
|
7
7
|
var ApiError = class extends Error {
|
|
@@ -35,7 +35,7 @@ async function errorOf(response) {
|
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/client/client.ts
|
|
37
37
|
/**
|
|
38
|
-
* The client's runtime
|
|
38
|
+
* The client's runtime: plain async calls over `fetch`, built from the endpoint
|
|
39
39
|
* table a generated client (`.isai/client.ts`) hands it. It holds no cache: a frontend wraps the
|
|
40
40
|
* calls in what it uses (TanStack Query, nanostores).
|
|
41
41
|
*
|
|
@@ -179,7 +179,7 @@ function pageQuery(query) {
|
|
|
179
179
|
...query.before === void 0 ? {} : { before: query.before }
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
/** The auth module's endpoints
|
|
182
|
+
/** The auth module's endpoints. */
|
|
183
183
|
function authApi(call, base) {
|
|
184
184
|
const person = (id) => `/auth/users/${segment(id)}`;
|
|
185
185
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as Fake, K as fakeValue } from "./validation-
|
|
2
|
-
import { D as planInsert, E as recordAction, S as clockOf, T as forUpkeep, V as CheckFailed } from "./migrator-
|
|
3
|
-
import { j as IMPLICIT_FIELDS, n as toBase64url, r as Model, t as fromBase64url } from "./base64url-
|
|
1
|
+
import { G as Fake, K as fakeValue } from "./validation-FyOpSZqE.js";
|
|
2
|
+
import { D as planInsert, E as recordAction, S as clockOf, T as forUpkeep, V as CheckFailed } from "./migrator-6oWUefLA.js";
|
|
3
|
+
import { j as IMPLICIT_FIELDS, n as toBase64url, r as Model, t as fromBase64url } from "./base64url-K_wCmvxR.js";
|
|
4
4
|
//#region src/auth/roles.ts
|
|
5
5
|
const same = (a, b) => a.length === b.length && a.every((value, i) => value === b[i]);
|
|
6
6
|
/** What a role in `app.ts` is stored as. */
|
|
@@ -329,8 +329,15 @@ function authOf(models) {
|
|
|
329
329
|
//#endregion
|
|
330
330
|
//#region src/db/seeds/makers.ts
|
|
331
331
|
/**
|
|
332
|
-
* `make` and `many`: a row from the values given, the rest faked from each field's kind
|
|
333
|
-
*
|
|
332
|
+
* `make` and `many`: a row from the values given, the rest faked from each field's kind. Models
|
|
333
|
+
* carry no factory code; values that matter to a story go in the seed.
|
|
334
|
+
*
|
|
335
|
+
* For a field it isn't given, `make` writes its default if it has one; nothing for what the
|
|
336
|
+
* framework or the database makes (id, timestamps, generated, maintained); a new parent for a
|
|
337
|
+
* required ref; `null` for an optional field (refs too), so rows are minimal; else the kind's
|
|
338
|
+
* fake, numbered for a unique field so fakes don't collide. A faked row failing a check is drawn
|
|
339
|
+
* again a few times, then `make` fails naming the check. Writes go through `createOne`, so
|
|
340
|
+
* validation, guards and the write stream all run.
|
|
334
341
|
*/
|
|
335
342
|
/** Fake rows that fail a check are drawn again, this many times in all. */
|
|
336
343
|
const ATTEMPTS = 20;
|
|
@@ -406,7 +413,7 @@ function failedCheck(model, input, now) {
|
|
|
406
413
|
//#region src/tenancy/config.ts
|
|
407
414
|
/**
|
|
408
415
|
* The two database names that mean something, and only with tenancy: each tenant's own database,
|
|
409
|
-
* and the platform's
|
|
416
|
+
* and the platform's. Every other name is just a name.
|
|
410
417
|
*/
|
|
411
418
|
const TENANT = "tenant";
|
|
412
419
|
const PLATFORM = "platform";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as fromBase64url } from "./base64url-
|
|
2
|
-
import { n as PROVIDERS } from "./tables-
|
|
3
|
-
import { a as byRole, c as tenant, i as anyone, l as user, n as PolicyRegistry, o as owner, s as readsTenant } from "./policies-
|
|
1
|
+
import { t as fromBase64url } from "./base64url-K_wCmvxR.js";
|
|
2
|
+
import { n as PROVIDERS } from "./tables-C4ipMFjg.js";
|
|
3
|
+
import { a as byRole, c as tenant, i as anyone, l as user, n as PolicyRegistry, o as owner, s as readsTenant } from "./policies-pFzslmSB.js";
|
|
4
4
|
//#region src/auth/create-auth.ts
|
|
5
5
|
const methods = { oauth: (provider, options) => ({
|
|
6
6
|
kind: "oauth",
|
|
@@ -15,7 +15,7 @@ const authPerms = {
|
|
|
15
15
|
invite: "auth.invite",
|
|
16
16
|
/** See the people with accounts, give and take their roles, suspend them. */
|
|
17
17
|
manageUsers: "auth.manageUsers",
|
|
18
|
-
/** Read the whole audit log (`GET /api/audit`), with the log on
|
|
18
|
+
/** Read the whole audit log (`GET /api/audit`), with the log on. */
|
|
19
19
|
readAudit: "audit.read"
|
|
20
20
|
};
|
|
21
21
|
var Auth = class {
|
|
@@ -31,7 +31,7 @@ var Auth = class {
|
|
|
31
31
|
/**
|
|
32
32
|
* Gives `email` a role from `app.ts`, from code (a tenant's setup service, a seed): now, if it has
|
|
33
33
|
* an account in the current database, else when it first signs in. Safe to repeat.
|
|
34
|
-
* `held: "platform"` puts the assignment beyond the tenant's reach
|
|
34
|
+
* `held: "platform"` puts the assignment beyond the tenant's reach.
|
|
35
35
|
*/
|
|
36
36
|
invite(input) {
|
|
37
37
|
if (!this.invites) return Promise.reject(/* @__PURE__ */ new Error("isai: auth.invite is used before the runtime started the app"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { O as datetime, P as quantity, p as host, r as isPhoneRegion } from "./validation-
|
|
2
|
-
import { C as not, M as field, N as fieldKinds, S as count, s as defineModel, u as rowOf, v as all, w as now, y as any } from "./base64url-
|
|
3
|
-
import { a as TableSet, i as platformAuthDefinitions, o as defineBuiltins, r as authTables } from "./tables-
|
|
1
|
+
import { O as datetime, P as quantity, p as host, r as isPhoneRegion } from "./validation-FyOpSZqE.js";
|
|
2
|
+
import { C as not, M as field, N as fieldKinds, S as count, s as defineModel, u as rowOf, v as all, w as now, y as any } from "./base64url-K_wCmvxR.js";
|
|
3
|
+
import { a as TableSet, i as platformAuthDefinitions, o as defineBuiltins, r as authTables } from "./tables-C4ipMFjg.js";
|
|
4
4
|
import { n as seed } from "./seed-BObmdKdP.js";
|
|
5
5
|
//#region src/db/fields/slot.ts
|
|
6
6
|
var Slot = class {
|
|
@@ -89,13 +89,13 @@ function uploadTables(f, options) {
|
|
|
89
89
|
//#endregion
|
|
90
90
|
//#region src/tenancy/tables.ts
|
|
91
91
|
/**
|
|
92
|
-
* The platform's built-in tables
|
|
92
|
+
* The platform's built-in tables, switched on with
|
|
93
93
|
* `use: [base.tenancy({ database: "platform" })]` in `db/index.ts`:
|
|
94
94
|
*
|
|
95
95
|
* Tenant the registry: what the front door finds behind a host, and whether it may answer
|
|
96
96
|
* Domain every host a tenant answers on (its subdomain and custom domains alike)
|
|
97
97
|
* PlatformUser, PlatformSession… the platform's own people (the auth tables, prefixed): who
|
|
98
|
-
* signs in on the platform's host
|
|
98
|
+
* signs in on the platform's host
|
|
99
99
|
*
|
|
100
100
|
* Feature switches are the app's own columns: `builtins.Tenant.extend({ coupons: f.flag() })`.
|
|
101
101
|
*/
|
|
@@ -171,8 +171,10 @@ var ModelRegistry = class {
|
|
|
171
171
|
//#region src/db/schema/traits.ts
|
|
172
172
|
/**
|
|
173
173
|
* Traits: behaviour a model takes whole, written before its fields (`model(name, ...traits,
|
|
174
|
-
* fields)
|
|
175
|
-
*
|
|
174
|
+
* fields)`), Laravel's traits typed. A trait adds fields (so the model's own fields already see
|
|
175
|
+
* them; declaring one of them again is an error), computed fields, and a name the framework reads
|
|
176
|
+
* (`singleton`). Always written `traits.x()`, never imported bare: a bare `publishable()` reads like
|
|
177
|
+
* an action.
|
|
176
178
|
*/
|
|
177
179
|
var Trait = class {
|
|
178
180
|
spec;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as DatabaseDriver, o as DialectName } from "./index-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as DatabaseDriver, o as DialectName } from "./index-Ce5p2-EB.js";
|
|
2
|
+
import { t as Issue } from "./issues-CKto95IW.js";
|
|
3
|
+
import { M as IdInput, q as StoredFile } from "./index-C-WmIKxT.js";
|
|
4
|
+
import { A as Dialect, G as Model, H as Columns, I as Clock, K as ModelSpec, M as RetiredSnapshot, N as SchemaSnapshot, U as ComputedFields, V as AnyModel, W as Fields, X as Condition, at as count, b as RowOf, dt as Kinds, et as Now, f as seed, ft as SchemaDefaults, ht as Field, i as Row, it as any, mt as AnyField, n as Patch, ot as not, p as Database, q as ModelRegistry, rt as all, yt as Slot } from "./types-DpOcIuDl.js";
|
|
4
5
|
//#region src/db/schema/traits.d.ts
|
|
5
6
|
type ComputedDefinitions = Record<string, (row: any) => Condition>;
|
|
6
7
|
interface TraitSpec {
|
|
@@ -79,12 +80,20 @@ declare class CheckFailed extends DatabaseError {
|
|
|
79
80
|
readonly name = "CheckFailed";
|
|
80
81
|
constructor(model: string, check: string, options?: ErrorOptions);
|
|
81
82
|
}
|
|
82
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* A unique field (or combination) already has this value. `fields` are the unique's own; `issues`
|
|
85
|
+
* put one on each for a form, except that a field made from another (a slug from its title) puts
|
|
86
|
+
* it on that one, the field a person typed.
|
|
87
|
+
*/
|
|
83
88
|
declare class UniqueFailed extends DatabaseError {
|
|
84
89
|
readonly model: string;
|
|
85
90
|
readonly fields: readonly string[];
|
|
86
91
|
readonly name = "UniqueFailed";
|
|
87
|
-
|
|
92
|
+
readonly issues: readonly Issue[];
|
|
93
|
+
constructor(model: string, fields: readonly string[], options?: ErrorOptions & {
|
|
94
|
+
/** The field each generated one is made from: `{ slug: "title" }`. */
|
|
95
|
+
readonly from?: Readonly<Record<string, string>>;
|
|
96
|
+
});
|
|
88
97
|
}
|
|
89
98
|
/** A ref points at a row that doesn't exist, or a delete is restricted by rows that reference it. */
|
|
90
99
|
declare class ReferenceFailed extends DatabaseError {
|
|
@@ -268,7 +277,7 @@ declare class UnsafeMigration extends Error {
|
|
|
268
277
|
//#region src/db/migrations/errors.d.ts
|
|
269
278
|
/**
|
|
270
279
|
* The migrator's errors: one type with a code, a message and a hint, so the CLI prints the same
|
|
271
|
-
* shape for each and picks its exit code from the code
|
|
280
|
+
* shape for each and picks its exit code from the code.
|
|
272
281
|
*/
|
|
273
282
|
type MigrationErrorCode = "migrations.conflict" | "migrations.tampered" | "database.ahead" | "cleanup.notLive" | "migrations.todo" | "migrations.missing" | "migrations.question" | "migrations.rename" | "migrations.uniqueFill" | "data.loops" | "lock.held" | "deploy.held" | "rollback.unknownRelease" | "rollback.beyondCleanup";
|
|
274
283
|
declare class MigrationError extends Error {
|
|
@@ -708,7 +717,7 @@ declare function authTables(f: Kinds, options: AuthTablesOptions): TableSet<{
|
|
|
708
717
|
};
|
|
709
718
|
}>;
|
|
710
719
|
/**
|
|
711
|
-
* Held by the platform
|
|
720
|
+
* Held by the platform: the tenant's people, the owner
|
|
712
721
|
* included, can't take it away or suspend its holder.
|
|
713
722
|
*/
|
|
714
723
|
held: Field<"platform", "platform", true, false, {}>;
|
|
@@ -922,13 +931,13 @@ interface DataLayerDefinition<P extends Record<string, ProjectKind>, U extends r
|
|
|
922
931
|
}
|
|
923
932
|
/** What `define` gets: the built-in kinds, and the built-in table sets it may `use`. */
|
|
924
933
|
type Base = Kinds & {
|
|
925
|
-
/** User, Session, Account, Verification, Invite, Role and UserRole, in the app's data database
|
|
934
|
+
/** User, Session, Account, Verification, Invite, Role and UserRole, in the app's data database. */
|
|
926
935
|
readonly authTables: (options: AuthTablesOptions) => ReturnType<typeof authTables>;
|
|
927
|
-
/** `Tenant` and `Domain`, in the platform's database
|
|
936
|
+
/** `Tenant` and `Domain`, in the platform's database. */
|
|
928
937
|
readonly tenancy: (options: TenancyOptions) => ReturnType<typeof tenancyTables>;
|
|
929
|
-
/** `Upload` (files uploaded and not yet attached), in the app's data database
|
|
938
|
+
/** `Upload` (files uploaded and not yet attached), in the app's data database. */
|
|
930
939
|
readonly uploads: (options: UploadTablesOptions) => ReturnType<typeof uploadTables>;
|
|
931
|
-
/** `AuditEntry` (the audit log), in the database whose writes it records
|
|
940
|
+
/** `AuditEntry` (the audit log), in the database whose writes it records. */
|
|
932
941
|
readonly audit: (options: AuditTablesOptions) => AuditTables;
|
|
933
942
|
};
|
|
934
943
|
type ProjectKinds<P> = { readonly [K in keyof P]: P[K] extends AnyField ? () => P[K] : P[K]; };
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ValidationError } from "../issues-
|
|
2
|
-
import { $ as Expr, A as Dialect, B as newSecretKey, F as snapshotOf, G as Model, I as Clock, J as Models, K as ModelSpec, L as FixedClock, M as RetiredSnapshot, N as SchemaSnapshot, O as Write, P as emptySnapshot, R as fixedClock, V as AnyModel, X as Condition, Y as Column, _ as database, _t as Storage, a as Visible, at as count, bt as slot, c as Many, d as SeedContext, dt as Kinds, et as Now, ft as SchemaDefaults, g as Transaction, gt as FieldSpec, h as RawValue, ht as Field, i as Row, it as any, j as Rule, k as WriteListener, l as Overrides, lt as ConditionNode, m as DatabaseOptions, n as Patch, nt as Total, o as Make, ot as not, p as Database, pt as fieldKinds, r as Planned, rt as all, st as now, t as Insert, tt as Relation, u as Seed, v as OrderKey, vt as sensitivity, y as Query, yt as Slot, z as systemClock } from "../types-
|
|
3
|
-
import { A as MigrateOptions, B as NotFound, C as MigrationErrorCode, D as Cleanup, E as UnsafeMigration, F as DataStep, H as UniqueFailed, I as TODO, L as dataStep, M as migrate, N as migrateFresh, O as cleanupMigration, P as sync, R as CheckFailed, S as MigrationError, T as UnsafeChange, U as dialectFor, V as ReferenceFailed, W as sqlite, _ as Generated, b as manifest, c as acquireLock, d as setReleaseStatus, f as startRelease, g as makeMigrations, h as makeCleanup, j as Migration, k as Manifest, l as releaseLock, m as checkMigrations, n as row, o as Release, p as applyRules, s as ReleaseStatus, t as createDataLayer, u as rollback, v as generateMigration, w as SuspectedRename, x as structureStep, y as cleanupStep, z as DatabaseError } from "../data-layer-
|
|
1
|
+
import { a as ValidationError } from "../issues-CKto95IW.js";
|
|
2
|
+
import { $ as Expr, A as Dialect, B as newSecretKey, F as snapshotOf, G as Model, I as Clock, J as Models, K as ModelSpec, L as FixedClock, M as RetiredSnapshot, N as SchemaSnapshot, O as Write, P as emptySnapshot, R as fixedClock, V as AnyModel, X as Condition, Y as Column, _ as database, _t as Storage, a as Visible, at as count, bt as slot, c as Many, d as SeedContext, dt as Kinds, et as Now, ft as SchemaDefaults, g as Transaction, gt as FieldSpec, h as RawValue, ht as Field, i as Row, it as any, j as Rule, k as WriteListener, l as Overrides, lt as ConditionNode, m as DatabaseOptions, n as Patch, nt as Total, o as Make, ot as not, p as Database, pt as fieldKinds, r as Planned, rt as all, st as now, t as Insert, tt as Relation, u as Seed, v as OrderKey, vt as sensitivity, y as Query, yt as Slot, z as systemClock } from "../types-DpOcIuDl.js";
|
|
3
|
+
import { A as MigrateOptions, B as NotFound, C as MigrationErrorCode, D as Cleanup, E as UnsafeMigration, F as DataStep, H as UniqueFailed, I as TODO, L as dataStep, M as migrate, N as migrateFresh, O as cleanupMigration, P as sync, R as CheckFailed, S as MigrationError, T as UnsafeChange, U as dialectFor, V as ReferenceFailed, W as sqlite, _ as Generated, b as manifest, c as acquireLock, d as setReleaseStatus, f as startRelease, g as makeMigrations, h as makeCleanup, j as Migration, k as Manifest, l as releaseLock, m as checkMigrations, n as row, o as Release, p as applyRules, s as ReleaseStatus, t as createDataLayer, u as rollback, v as generateMigration, w as SuspectedRename, x as structureStep, y as cleanupStep, z as DatabaseError } from "../data-layer-ubPfZvFV.js";
|
|
4
4
|
export { type AnyModel, CheckFailed, type Cleanup, type Clock, Column, Condition, type ConditionNode, type DataStep, Database, DatabaseError, type DatabaseOptions, type Dialect, Expr, Field, type FieldSpec, type FixedClock, type Generated, type Insert, type Kinds, type Make, type Manifest, type Many, type MigrateOptions, type Migration, MigrationError, type MigrationErrorCode, Model, type ModelSpec, type Models, NotFound, Now, type OrderKey, type Overrides, type Patch, type Planned, Query, type RawValue, ReferenceFailed, Relation, type Release, type ReleaseStatus, type RetiredSnapshot, type Row, type Rule, type SchemaDefaults, type SchemaSnapshot, Seed, type SeedContext, Slot, type Storage, type SuspectedRename, TODO, Total, Transaction, UniqueFailed, type UnsafeChange, UnsafeMigration, ValidationError, type Visible, type Write, type WriteListener, acquireLock, all, any, applyRules, checkMigrations, cleanupMigration, cleanupStep, count, createDataLayer, dataStep, database, dialectFor, emptySnapshot, fieldKinds, fixedClock, generateMigration, makeCleanup, makeMigrations, manifest, migrate, migrateFresh, newSecretKey, not, now, releaseLock, rollback, row, sensitivity, setReleaseStatus, slot, snapshotOf, sqlite, startRelease, structureStep, sync, systemClock };
|
package/dist/db/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { W as ValidationError } from "../validation-
|
|
2
|
-
import { A as Query, C as database, F as systemClock, G as UniqueFailed, H as DatabaseError, I as newSecretKey, M as dialectFor, N as sqlite, P as fixedClock, U as NotFound, V as CheckFailed, W as ReferenceFailed, _ as TODO, b as Database, c as rollback, d as applyRules, g as UnsafeMigration, h as snapshotOf, i as acquireLock, l as setReleaseStatus, m as emptySnapshot, n as migrateFresh, p as generateMigration, r as sync, s as releaseLock, t as migrate, u as startRelease, v as dataStep, x as Transaction, y as MigrationError } from "../migrator-
|
|
3
|
-
import { C as not, F as sensitivity, N as fieldKinds, P as Field, S as count, _ as Total, d as Column, f as Condition, g as Relation, h as Now, m as Expr, r as Model, v as all, w as now, y as any } from "../base64url-
|
|
4
|
-
import { i as slot, n as row, r as Slot, t as createDataLayer } from "../data-layer-
|
|
1
|
+
import { W as ValidationError } from "../validation-FyOpSZqE.js";
|
|
2
|
+
import { A as Query, C as database, F as systemClock, G as UniqueFailed, H as DatabaseError, I as newSecretKey, M as dialectFor, N as sqlite, P as fixedClock, U as NotFound, V as CheckFailed, W as ReferenceFailed, _ as TODO, b as Database, c as rollback, d as applyRules, g as UnsafeMigration, h as snapshotOf, i as acquireLock, l as setReleaseStatus, m as emptySnapshot, n as migrateFresh, p as generateMigration, r as sync, s as releaseLock, t as migrate, u as startRelease, v as dataStep, x as Transaction, y as MigrationError } from "../migrator-6oWUefLA.js";
|
|
3
|
+
import { C as not, F as sensitivity, N as fieldKinds, P as Field, S as count, _ as Total, d as Column, f as Condition, g as Relation, h as Now, m as Expr, r as Model, v as all, w as now, y as any } from "../base64url-K_wCmvxR.js";
|
|
4
|
+
import { i as slot, n as row, r as Slot, t as createDataLayer } from "../data-layer-D9UPOK6L.js";
|
|
5
5
|
import { t as Seed } from "../seed-BObmdKdP.js";
|
|
6
|
-
import { a as cleanupMigration, i as makeMigrations, r as makeCleanup, t as checkMigrations } from "../make-
|
|
6
|
+
import { a as cleanupMigration, i as makeMigrations, r as makeCleanup, t as checkMigrations } from "../make-WQpkYW8N.js";
|
|
7
7
|
//#region src/db/migrations/files.ts
|
|
8
8
|
/** A structure step file: adds tables and columns. Applied once, never edited. */
|
|
9
9
|
function structureStep(options) {
|