@isaijs/core 0.1.4 → 0.1.6

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.
@@ -1,4 +1,4 @@
1
- import { D as nodesOf, U as isRecorded, a as columnName, f as Condition, m as Expr, u as rowOf, x as conditionNode } from "./base64url-C5GTYIL5.js";
1
+ import { G as isRecorded, _ as Expr, c as rowOf, h as Condition, j as nodesOf, r as columnName, w as conditionNode } from "./model-Dc3HunKb.js";
2
2
  //#region src/auth/enforce.ts
3
3
  /**
4
4
  * Checking a policy: its action's condition, with the
@@ -1,7 +1,7 @@
1
1
  import { G as ValidationError, H as validate, V as toKind, z as object } from "./validation-Cppmd0RV.js";
2
- import { J as UniqueFailed, K as NotFound, W as CheckFailed, q as ReferenceFailed } from "./migrator-BU3_PHk8.js";
3
- import { a as columnName, b as asCondition, j as IMPLICIT_FIELDS, l as computedFieldOf, m as Expr, p as Embed } from "./base64url-C5GTYIL5.js";
4
- import { r as actionsOf } from "./policies-D_G5Rmxv.js";
2
+ import { J as NotFound, K as CheckFailed, X as UniqueFailed, Y as ReferenceFailed } from "./migrator-B25prc9n.js";
3
+ import { C as asCondition, _ as Expr, g as Embed, l as IMPLICIT_FIELDS, r as columnName, s as computedFieldOf } from "./model-Dc3HunKb.js";
4
+ import { r as actionsOf } from "./policies-KsqmlX67.js";
5
5
  import { n as RESERVED, t as LOOKUPS } from "./syntax-CrUZFrS7.js";
6
6
  //#region src/api/fail.ts
7
7
  /**
@@ -38,8 +38,10 @@ function fail(code, message) {
38
38
  * 405 MethodNotAllowed a known path with another method (`Allow`)
39
39
  * 409 UniqueFailed (`fields`, and `issues` for a form), CheckFailed, ReferenceFailed, or the
40
40
  * app's own code from `fail`
41
+ * 409 InProgress a write whose `Idempotency-Key` is still running (`./idempotency`)
41
42
  * 411/413/415 uploads without a size, too large, of a refused type; a body over
42
43
  * the JSON limit (413) or not JSON (415)
44
+ * 422 IdempotencyKeyReused a key sent again with another route, user or body
43
45
  * 429 TooManyRequests anonymous writes past the per-IP limit (`Retry-After`)
44
46
  * 503 TenantSuspended a suspended tenant
45
47
  * 500 InternalError anything else: logged with its stack as one JSON line, nothing sent
@@ -1,4 +1,4 @@
1
- import { r as Model, s as defineModel } from "./base64url-C5GTYIL5.js";
1
+ import { a as defineModel, t as Model } from "./model-Dc3HunKb.js";
2
2
  //#region src/db/schema/builtins.ts
3
3
  /**
4
4
  * Built-in tables: sets of models a part of isai owns, switched on
@@ -1,5 +1,5 @@
1
1
  import { a as DatabaseDriver, g as Storage } from "../index-Ce5p2-EB.js";
2
- import { I as Clock, L as FixedClock, R as fixedClock, V as AnyModel, i as Row, l as Overrides, p as Database, s as Makers, u as Seed } from "../types-S6zF5IXV.js";
2
+ import { I as Clock, L as FixedClock, R as fixedClock, V as AnyModel, i as Row, l as Overrides, p as Database, s as Makers, u as Seed } from "../types-BgOkJy5d.js";
3
3
  //#region src/testing/conformance/database.d.ts
4
4
  /**
5
5
  * Makes the driver under test. Every call must return a driver on an **empty** database:
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.js";
2
- import { H as utc, L as PLATFORM, M as dialectFor, P as fixedClock, R as TENANT, a as currentRelease, b as Database, c as rollback, i as acquireLock, k as keyCondition, l as setReleaseStatus, m as emptySnapshot, n as migrateFresh, o as holdOf, p as generateMigration, r as sync, s as releaseLock, t as migrate, u as startRelease, v as dataStep, y as MigrationError } from "../migrator-BU3_PHk8.js";
3
- import { n as toBase64url, r as Model } from "../base64url-C5GTYIL5.js";
4
- import { t as createDataLayer } from "../data-layer-_TZtuy-F.js";
5
- import { d as forgetGoogleKeys, r as authOf, s as GOOGLE, t as makers, y as seedAs } from "../makers-DeSNM0Nd.js";
2
+ import { F as dialectFor, H as fixedClock, L as PLATFORM, R as TENANT, W as utc, a as currentRelease, b as Database, c as rollback, i as acquireLock, j as keyCondition, l as setReleaseStatus, m as emptySnapshot, n as migrateFresh, o as holdOf, p as generateMigration, r as sync, s as releaseLock, t as migrate, u as startRelease, v as dataStep, y as MigrationError } from "../migrator-B25prc9n.js";
3
+ import { L as toBase64url, t as Model } from "../model-Dc3HunKb.js";
4
+ import { t as createDataLayer } from "../data-layer-C5oJZ8V1.js";
5
+ import { d as forgetGoogleKeys, r as authOf, s as GOOGLE, t as makers, y as seedAs } from "../makers-P9kg68C8.js";
6
6
  import { describe, expect, it } from "vitest";
7
7
  //#region src/testing/conformance/database.ts
8
8
  /**
@@ -372,15 +372,18 @@ interface CoalesceNode {
372
372
  readonly t: "coalesce";
373
373
  readonly items: readonly Operand[];
374
374
  }
375
- /** The rows of another table that reference a row (`fest.events`: events whose `fest_id` is the fest). */
375
+ /**
376
+ * The rows of another table that reference a row (`fest.events`: events whose `fest_id` is the
377
+ * fest), or, without an owner, every row of a table (`rows(Product)`).
378
+ */
376
379
  interface RelationNode {
377
380
  /** The row that owns the relation: its scope, and the refs followed to reach it. */
378
- readonly owner: {
381
+ readonly owner?: {
379
382
  readonly scope: ScopeId;
380
383
  readonly path: readonly RefStep[];
381
384
  };
382
385
  readonly table: string;
383
- /** The related table's column holding the owner's id. */
386
+ /** The related table's column holding the owner's id (unused without an owner). */
384
387
  readonly column: string;
385
388
  /** The scope of the related rows inside the callback. */
386
389
  readonly scope: ScopeId;
@@ -1112,6 +1115,11 @@ interface Dialect {
1112
1115
  totals(model: ModelSpec, query: TotalsQuery, context: SqlContext): Sql;
1113
1116
  /** A totals row's values, decoded by what each one is. */
1114
1117
  decodeTotals(query: TotalsQuery, row: Row$1): Record<string, unknown>;
1118
+ /**
1119
+ * `SELECT <node> AS "value"`: a value that needs no row of `model`, such as a count over a whole
1120
+ * table (`rows(Product).count()`), for a create's rule. `model` only names the statement's table.
1121
+ */
1122
+ value(model: ModelSpec, node: Operand, context: SqlContext): Sql;
1115
1123
  /** One row (`"found"`) when any row matches. */
1116
1124
  exists(model: ModelSpec, where: readonly ConditionNode[], context: SqlContext): Sql;
1117
1125
  update(model: ModelSpec, assignments: Assignments, where: readonly ConditionNode[], context: SqlContext, returning: Returning): Sql;
@@ -1482,6 +1490,8 @@ declare class Transaction {
1482
1490
  type WriteOnly<T> = T extends PromiseLike<unknown> ? never : T;
1483
1491
  declare const UPKEEP: unique symbol;
1484
1492
  declare const CLOCK: unique symbol;
1493
+ declare const DRIVER: unique symbol;
1494
+ declare const TOTALS: unique symbol;
1485
1495
  declare const RECORD: unique symbol;
1486
1496
  declare const DECODE: unique symbol;
1487
1497
  declare class Database {
@@ -1495,6 +1505,10 @@ declare class Database {
1495
1505
  [DECODE](model: ModelSpec, row: Row$1): Record<string, unknown>;
1496
1506
  /** See `clockOf`. */
1497
1507
  [CLOCK](): Clock;
1508
+ /** See `withTableTotals`. */
1509
+ [TOTALS](model: ModelSpec, node: ConditionNode): Promise<ConditionNode>;
1510
+ /** See `driverOf`. */
1511
+ [DRIVER](): DatabaseDriver;
1498
1512
  /**
1499
1513
  * The post-commit write stream: `listener` is called after every committed write with what it
1500
1514
  * created, changed and deleted (an `atomic`'s writes in one call). Returns the unsubscribe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isaijs/core",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "A batteries-included, type-safe TypeScript backend framework. Cloudflare first, no lock-in.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,11 +0,0 @@
1
- //#region src/internal/case.ts
2
- /** `manageProducts` → `manage-products`, `markPaid` → `mark-paid`: path segments. */
3
- function kebabCase(name) {
4
- return snakeCase(name).replace(/_/g, "-");
5
- }
6
- /** `RegistrationMember` → `registration_member`, `startsAt` → `starts_at`. */
7
- function snakeCase(name) {
8
- return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase();
9
- }
10
- //#endregion
11
- export { snakeCase as n, kebabCase as t };