rip-lang 3.13.136 → 3.14.0
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 +46 -4
- package/docs/RIP-LANG.md +116 -11
- package/docs/RIP-SCHEMA.md +2390 -0
- package/docs/RIP-TYPES.md +21 -14
- package/docs/assets/rip-schema-logo-960w.png +0 -0
- package/docs/assets/rip-schema-social.png +0 -0
- package/docs/dist/rip.js +6817 -3670
- package/docs/dist/rip.min.js +1454 -211
- package/docs/dist/rip.min.js.br +0 -0
- package/package.json +10 -4
- package/src/AGENTS.md +130 -0
- package/src/compiler.js +65 -2
- package/src/components.js +19 -5
- package/src/grammar/grammar.rip +20 -1
- package/src/lexer.js +42 -0
- package/src/parser.js +222 -220
- package/src/schema.js +3298 -0
- package/src/sourcemap-utils.js +155 -0
- package/src/typecheck.js +395 -23
- package/src/types.js +25 -0
- package/src/ui.rip +203 -45
- package/CHANGELOG.md +0 -1500
package/docs/RIP-TYPES.md
CHANGED
|
@@ -721,26 +721,33 @@ export function getUser(id: number): User | undefined;
|
|
|
721
721
|
## Boundary Validation
|
|
722
722
|
|
|
723
723
|
Types are compile-time contracts. For data entering your system, validate
|
|
724
|
-
at boundaries
|
|
724
|
+
at boundaries — and in Rip, the `schema` keyword is the native way to do
|
|
725
|
+
it. Schemas are runtime validators AND a source of TypeScript types (via
|
|
726
|
+
shadow `.d.ts` emission), so one declaration gives you both the check
|
|
727
|
+
and the type.
|
|
725
728
|
|
|
726
729
|
```coffee
|
|
727
|
-
|
|
730
|
+
# Declare the wire shape — runtime validator + type source of truth
|
|
731
|
+
User = schema :input
|
|
732
|
+
id! integer
|
|
733
|
+
name! 1..50
|
|
734
|
+
email! email
|
|
728
735
|
|
|
729
|
-
#
|
|
730
|
-
UserSchema = z.object
|
|
731
|
-
id: z.number()
|
|
732
|
-
name: z.string()
|
|
733
|
-
email: z.string().email()
|
|
734
|
-
|
|
735
|
-
# Derive type from schema
|
|
736
|
-
type User = z.infer<typeof UserSchema>
|
|
737
|
-
|
|
738
|
-
# Validate at API boundary
|
|
736
|
+
# Validate at an API boundary
|
|
739
737
|
def createUser(req:: Request):: User
|
|
740
|
-
|
|
741
|
-
|
|
738
|
+
User.parse req.json! # throws SchemaError on invalid
|
|
739
|
+
|
|
740
|
+
# Or non-throwing for structured error responses
|
|
741
|
+
result = User.safe req.json!
|
|
742
|
+
# result: {ok: true, value: User} | {ok: false, errors: [...]}
|
|
742
743
|
```
|
|
743
744
|
|
|
745
|
+
The compiler emits the TypeScript `User` type from the schema definition
|
|
746
|
+
automatically. No `z.infer<>` step. See [RIP-SCHEMA.md](./RIP-SCHEMA.md)
|
|
747
|
+
for the full schema reference — field grammar, modifiers, constraints,
|
|
748
|
+
cross-field `@ensure` refinements, `:model` ORM surface, algebra
|
|
749
|
+
(`.pick/.omit/.partial/.extend`), and shadow TypeScript emission.
|
|
750
|
+
|
|
744
751
|
Once data passes boundary validation, trust the types internally — no need
|
|
745
752
|
to re-validate.
|
|
746
753
|
|
|
Binary file
|
|
Binary file
|