rip-lang 3.15.0 → 3.15.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/README.md +2 -2
- package/bin/rip +1 -1
- package/docs/RIP-SCHEMA.md +4 -4
- package/docs/dist/rip.js +6 -6
- package/docs/dist/rip.min.js +83 -83
- package/docs/dist/rip.min.js.br +0 -0
- package/docs/extensions/duckdb/manifest.json +1 -1
- package/docs/extensions/duckdb/v1.5.2/linux_amd64/ripdb.duckdb_extension.gz +0 -0
- package/docs/extensions/duckdb/v1.5.2/osx_arm64/ripdb.duckdb_extension.gz +0 -0
- package/package.json +4 -7
- package/src/AGENTS.md +27 -25
- package/src/browser.js +1 -1
- package/src/compiler.js +1 -1
- package/src/grammar/grammar.rip +1 -1
- package/src/lexer.js +1 -1
- package/src/schema/dts-emit.js +329 -0
- package/src/schema/loader-browser.js +55 -0
- package/src/schema/loader-server.js +65 -0
- package/src/schema/runtime-browser-stubs.js +51 -0
- package/src/schema/runtime-db-naming.js +34 -0
- package/src/schema/runtime-ddl.js +124 -0
- package/src/schema/runtime-orm.js +294 -0
- package/src/schema/runtime-validate.js +816 -0
- package/src/schema/runtime.generated.js +1315 -0
- package/src/schema/schema.js +1805 -0
- package/src/typecheck.js +2 -2
- package/src/types-emit.js +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="https://github.com/shreeve/rip-lang/commits/main"><img src="https://img.shields.io/badge/version-3.15.
|
|
12
|
+
<a href="https://github.com/shreeve/rip-lang/commits/main"><img src="https://img.shields.io/badge/version-3.15.1-blue.svg" alt="Version"></a>
|
|
13
13
|
<a href="#zero-dependencies"><img src="https://img.shields.io/badge/dependencies-ZERO-brightgreen.svg" alt="Dependencies"></a>
|
|
14
14
|
<a href="#"><img src="https://img.shields.io/badge/tests-1%2C436%2F1%2C436-brightgreen.svg" alt="Tests"></a>
|
|
15
15
|
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a>
|
|
@@ -351,7 +351,7 @@ The **body syntax is declarative**, not general Rip code. Five line forms are le
|
|
|
351
351
|
|
|
352
352
|
**`:model` is where the pieces converge.** One declaration gives you a validator, a class with fields as enumerable own properties and methods/getters on the prototype, a chainable async query builder (`User.where(active: true).order("last_name").all!`), migration DDL that works standalone (`User.toSQL()` never touches the database), belongs-to/has-many accessors that resolve cross-module through the registry, and full shadow TypeScript with `ModelSchema<Instance, Data>` typing that propagates through schema algebra. Hydrated instances carry both snake_case and camelCase aliases on DB-derived columns (`order.user_id` and `order.userId` read the same slot), so raw SQL helpers and ORM access coexist cleanly. A single-function adapter interface (`adapter.query(sql, params)`) routes all database I/O, so tests use in-memory mocks and production uses rip-db without the ORM caring.
|
|
353
353
|
|
|
354
|
-
**Schema algebra** — `.pick`, `.omit`, `.partial`, `.required`, `.extend` — always returns a new `:shape`. Field semantics (type, literal unions, constraints, inline transforms) carry through to the derived shape; instance behavior (methods, computed `~>`, eager-derived `!>`, hooks, and `@ensure` refinements) does not. `User.omit "password"` produces a validator for `User` minus the password field; it won't have `.find()` or the `beforeSave` hook, but field-level transforms (`email, -> it.email.toLowerCase()`) continue to fire on the derived shape exactly as they did on the original. This invariant is enforced both at runtime (ORM methods throw on derived shapes with a targeted diagnostic pointing at query projection) and at the TypeScript level (algebra generics are parameterized over `Data`, not `Instance`, so the derived types correctly omit methods and ORM surface). Internally, the whole feature is a compiler sidecar — 54% of the implementation lives in `
|
|
354
|
+
**Schema algebra** — `.pick`, `.omit`, `.partial`, `.required`, `.extend` — always returns a new `:shape`. Field semantics (type, literal unions, constraints, inline transforms) carry through to the derived shape; instance behavior (methods, computed `~>`, eager-derived `!>`, hooks, and `@ensure` refinements) does not. `User.omit "password"` produces a validator for `User` minus the password field; it won't have `.find()` or the `beforeSave` hook, but field-level transforms (`email, -> it.email.toLowerCase()`) continue to fire on the derived shape exactly as they did on the original. This invariant is enforced both at runtime (ORM methods throw on derived shapes with a targeted diagnostic pointing at query projection) and at the TypeScript level (algebra generics are parameterized over `Data`, not `Instance`, so the derived types correctly omit methods and ORM surface). Internally, the whole feature is a compiler sidecar — 54% of the implementation lives in `src/schema/schema.js` and touches the core compiler in under 100 lines of wiring. A four-layer lazy runtime (raw descriptor → normalized metadata → validator plan → ORM plan / DDL plan) means module load is cheap, migration scripts never build the ORM plan, and validator-only consumers never build the class machinery. The full reference is in [docs/RIP-SCHEMA.md](docs/RIP-SCHEMA.md).
|
|
355
355
|
|
|
356
356
|
---
|
|
357
357
|
|
package/bin/rip
CHANGED
|
@@ -9,7 +9,7 @@ import { Compiler, formatError } from '../src/compiler.js';
|
|
|
9
9
|
// bundle imports a different schema loader so server-only fragments
|
|
10
10
|
// (db-naming/orm/ddl) tree-shake out of docs/dist/rip.min.js.
|
|
11
11
|
import '../src/types-emit.js'; // registers emitTypes for .d.ts output
|
|
12
|
-
import '
|
|
12
|
+
import '../src/schema/loader-server.js'; // registers full schema runtime
|
|
13
13
|
import packageJson from '../package.json' with { type: 'json' };
|
|
14
14
|
|
|
15
15
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
package/docs/RIP-SCHEMA.md
CHANGED
|
@@ -2324,7 +2324,7 @@ through this interface.
|
|
|
2324
2324
|
## 24. Compiler integration
|
|
2325
2325
|
|
|
2326
2326
|
The schema keyword is implemented as a compiler sidecar in
|
|
2327
|
-
`
|
|
2327
|
+
`src/schema/schema.js`, alongside the existing type and component sidecars.
|
|
2328
2328
|
This isolates the feature from the rest of the compiler: the main Rip
|
|
2329
2329
|
grammar has two productions for the schema keyword (not hundreds), and
|
|
2330
2330
|
the schema-specific body syntax never reaches the main parser.
|
|
@@ -2373,7 +2373,7 @@ binds to the instance correctly without special codegen.
|
|
|
2373
2373
|
|
|
2374
2374
|
| File | Role |
|
|
2375
2375
|
| -------------------- | ------------------------------------------------------------------ |
|
|
2376
|
-
| `
|
|
2376
|
+
| `src/schema/schema.js` | Sub-parser, `emitSchema`, Layer 1-4 runtime, shadow TS walker, `installSchemaSupport` |
|
|
2377
2377
|
| `src/lexer.js` | Hook point — calls `rewriteSchema()`; comment-token fix for `#` modifier |
|
|
2378
2378
|
| `src/grammar/grammar.rip` | The one `Schema` production |
|
|
2379
2379
|
| `src/compiler.js` | Dispatch for the `schema` s-expression head; preamble injection |
|
|
@@ -2381,7 +2381,7 @@ binds to the instance correctly without special codegen.
|
|
|
2381
2381
|
| `src/typecheck.js` | `hasSchemas()` probe so schema-only files aren't `@ts-nocheck`d |
|
|
2382
2382
|
| `test/rip/schema.rip` | The test suite |
|
|
2383
2383
|
|
|
2384
|
-
The total wiring in the core compiler (outside `
|
|
2384
|
+
The total wiring in the core compiler (outside `src/schema/schema.js`) is under
|
|
2385
2385
|
100 lines. That's the sidecar pattern working — the feature is big, but
|
|
2386
2386
|
its footprint in the main compiler is small.
|
|
2387
2387
|
|
|
@@ -2405,7 +2405,7 @@ transactions, eager loading, scopes, and soft deletes — not yet; see
|
|
|
2405
2405
|
|
|
2406
2406
|
**Does the runtime belong to `schema.js` or is it loaded separately?**
|
|
2407
2407
|
It's inlined. When a file uses `schema`, the compiler injects a small
|
|
2408
|
-
preamble (under `SCHEMA_RUNTIME` in `
|
|
2408
|
+
preamble (under `SCHEMA_RUNTIME` in `src/schema/schema.js`) that defines
|
|
2409
2409
|
`SchemaError`, `__SchemaDef`, `__SchemaRegistry`, `Query`, and the
|
|
2410
2410
|
helpers. No import statement, no package dependency, no bootstrap call.
|
|
2411
2411
|
|
package/docs/dist/rip.js
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
BUILD_DATE: () => BUILD_DATE
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
//
|
|
63
|
+
// src/schema/runtime.generated.js
|
|
64
64
|
var SCHEMA_RUNTIME_WRAPPER_HEAD = `
|
|
65
65
|
// ---- Rip Schema Runtime ----------------------------------------------------
|
|
66
66
|
// Four layers, lazy compilation:
|
|
@@ -1786,7 +1786,7 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
1786
1786
|
var parser = /* @__PURE__ */ createParser();
|
|
1787
1787
|
var parse = parser.parse.bind(parser);
|
|
1788
1788
|
|
|
1789
|
-
//
|
|
1789
|
+
// src/schema/schema.js
|
|
1790
1790
|
var _schemaRuntimeProvider = null;
|
|
1791
1791
|
function setSchemaRuntimeProvider(fn) {
|
|
1792
1792
|
_schemaRuntimeProvider = fn;
|
|
@@ -3082,12 +3082,12 @@ Expecting ${expected.join(", ")}, got '${this.tokenNames[symbol] || symbol}'`;
|
|
|
3082
3082
|
}
|
|
3083
3083
|
function getSchemaRuntime(opts = {}) {
|
|
3084
3084
|
if (!_schemaRuntimeProvider) {
|
|
3085
|
-
throw new Error("schema runtime provider not registered. Side-effect-import either " + "'
|
|
3085
|
+
throw new Error("schema runtime provider not registered. Side-effect-import either " + "'./schema/loader-server.js' (CLI / server / tests) or " + "'./schema/loader-browser.js' (browser bundle) before calling " + "any compileToJS that emits schemas.");
|
|
3086
3086
|
}
|
|
3087
3087
|
return _schemaRuntimeProvider(opts);
|
|
3088
3088
|
}
|
|
3089
3089
|
|
|
3090
|
-
//
|
|
3090
|
+
// src/schema/loader-browser.js
|
|
3091
3091
|
function provider({ mode = "browser" } = {}) {
|
|
3092
3092
|
let body;
|
|
3093
3093
|
switch (mode) {
|
|
@@ -12453,8 +12453,8 @@ globalThis.zip ??= (...a) => a[0].map((_, i) => a.map(b => b[i]));
|
|
|
12453
12453
|
return new CodeEmitter({}).getComponentRuntime();
|
|
12454
12454
|
}
|
|
12455
12455
|
// src/browser.js
|
|
12456
|
-
var VERSION = "3.15.
|
|
12457
|
-
var BUILD_DATE = "2026-04-27@
|
|
12456
|
+
var VERSION = "3.15.1";
|
|
12457
|
+
var BUILD_DATE = "2026-04-27@06:14:13GMT";
|
|
12458
12458
|
if (typeof globalThis !== "undefined") {
|
|
12459
12459
|
if (!globalThis.__rip)
|
|
12460
12460
|
new Function(getReactiveRuntime())();
|