New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ronin/syntax

Package Overview
Dependencies
Maintainers
0
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ronin/syntax - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

287

dist/schema.d.ts

@@ -39,5 +39,2 @@ import { P as PublicModel, G as GetInstructions, W as WithInstruction, M as ModelIndex, a as ModelField, b as ModelTrigger } from './index.d-CMkIzj0q.js';

}
type SerializedField<Type> = Partial<Omit<Extract<ModelField, {
type: Type;
}>, 'slug' | 'type'>>;
type FieldsToTypes<F> = F extends Record<string, Primitives> ? {

@@ -83,7 +80,10 @@ [K in keyof F]: F[K] extends Record<string, Primitives> ? FieldsToTypes<F[K]> : F[K]['type'] extends 'string' ? string : F[K]['type'] extends 'number' ? number : F[K]['type'] extends 'boolean' ? boolean : F[K]['type'] extends 'link' ? string : F[K]['type'] extends 'json' ? object : F[K]['type'] extends 'blob' ? Blob : F[K]['type'] extends 'date' ? Date : never;

*
* @returns A field of type "string" with the specified or default attributes.
* @returns A field of type "string" with the specified attributes.
*/
declare const string: (attributes?: SerializedField<"string">) => {
unique?: boolean | undefined;
required?: boolean | undefined;
declare const string: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -95,11 +95,29 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
collation?: ("BINARY" | "NOCASE" | "RTRIM") | undefined;
name: string | undefined;
displayAs: string;
};
} & {
type: "string";
};
collation?: "BINARY" | "NOCASE" | "RTRIM";
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "string";
collation?: "BINARY" | "NOCASE" | "RTRIM";
}, "slug">;
/**

@@ -111,8 +129,10 @@ * Creates a number field definition returning an object that includes the field type

*
* @returns A field of type "number" with the specified or default attributes.
* @returns A field of type "number" with the specified attributes.
*/
declare const number: (attributes?: SerializedField<"number">) => {
displayAs?: string | undefined;
unique?: boolean | undefined;
required?: boolean | undefined;
declare const number: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -124,10 +144,29 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
increment?: boolean | undefined;
name: string | undefined;
};
} & {
type: "number";
};
increment?: boolean;
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "number";
increment?: boolean;
}, "slug">;
/**

@@ -139,8 +178,10 @@ * Creates a link field definition returning an object that includes the field type

*
* @returns A field of type "link" with the specified or default attributes.
* @returns A field of type "link" with the specified attributes.
*/
declare const link: (attributes?: SerializedField<"link">) => {
displayAs?: string | undefined;
unique?: boolean | undefined;
required?: boolean | undefined;
declare const link: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -152,15 +193,39 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
kind?: ("one" | "many") | undefined;
name: string | undefined;
};
} & {
type: "link";
target: string;
actions: {
kind?: "one" | "many";
actions?: {
onDelete?: "CASCADE" | "RESTRICT" | "SET NULL" | "SET DEFAULT" | "NO ACTION";
onUpdate?: "CASCADE" | "RESTRICT" | "SET NULL" | "SET DEFAULT" | "NO ACTION";
} | undefined;
};
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "link";
};
target: string;
kind?: "one" | "many";
actions?: {
onDelete?: "CASCADE" | "RESTRICT" | "SET NULL" | "SET DEFAULT" | "NO ACTION";
onUpdate?: "CASCADE" | "RESTRICT" | "SET NULL" | "SET DEFAULT" | "NO ACTION";
};
}, "slug">;
/**

@@ -172,7 +237,10 @@ * Creates a JSON field definition returning an object that includes the field type

*
* @returns A field of type "json" with the specified or default attributes.
* @returns A field of type "json" with the specified attributes.
*/
declare const json: (attributes?: SerializedField<"json">) => {
unique?: boolean | undefined;
required?: boolean | undefined;
declare const json: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -184,10 +252,27 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
name: string | undefined;
displayAs: string | undefined;
};
} & {
type: "json";
};
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "json";
}, "slug">;
/**

@@ -199,8 +284,10 @@ * Creates a date field definition returning an object that includes the field type

*
* @returns A field of type "date" with the specified or default attributes.
* @returns A field of type "date" with the specified attributes.
*/
declare const date: (attributes?: SerializedField<"date">) => {
displayAs?: string | undefined;
unique?: boolean | undefined;
required?: boolean | undefined;
declare const date: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -212,9 +299,27 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
name: string | undefined;
};
} & {
type: "date";
};
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "date";
}, "slug">;
/**

@@ -226,8 +331,10 @@ * Creates a boolean field definition returning an object that includes the field type

*
* @returns A field of type "boolean" with the specified or default attributes.
* @returns A field of type "boolean" with the specified attributes.
*/
declare const boolean: (attributes?: SerializedField<"boolean">) => {
displayAs?: string | undefined;
unique?: boolean | undefined;
required?: boolean | undefined;
declare const boolean: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -239,9 +346,27 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
name: string | undefined;
};
} & {
type: "boolean";
};
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "boolean";
}, "slug">;
/**

@@ -253,8 +378,10 @@ * Creates a blob field definition returning an object that includes the field type

*
* @returns A field of type "blob" with the specified or default attributes.
* @returns A field of type "blob" with the specified attributes.
*/
declare const blob: (attributes?: SerializedField<"blob">) => {
displayAs?: string | undefined;
unique?: boolean | undefined;
required?: boolean | undefined;
declare const blob: (attributes?: Partial<Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;

@@ -266,10 +393,28 @@ computedAs?: {

};
} | undefined;
};
check?: {
__RONIN_EXPRESSION: string;
} | undefined;
name: string | undefined;
};
} & {
type: "blob";
};
}, "slug" | "type">>) => Omit<{
name?: string;
slug: string;
displayAs?: string;
unique?: boolean;
required?: boolean;
defaultValue?: unknown;
computedAs?: {
kind: "VIRTUAL" | "STORED";
value: {
__RONIN_EXPRESSION: string;
};
};
check?: {
__RONIN_EXPRESSION: string;
};
} & {
type: "blob";
}, "slug">;
export { blob, boolean, date, json, link, model, number, string };

@@ -439,63 +439,14 @@ import {

// src/schema/primitives.ts
var string = (attributes = {}) => {
const { name, displayAs, ...rest } = attributes;
return {
name,
displayAs: displayAs ?? "single-line",
type: "string",
...rest
var primitive = (type) => {
return (attributes = {}) => {
return { type, ...attributes };
};
};
var number = (attributes = {}) => {
const { name, ...rest } = attributes;
return {
name,
type: "number",
...rest
};
};
var link = (attributes = {}) => {
const { name, target, actions, ...rest } = attributes;
if (!target) throw new Error("A model is required for a link field");
return {
name,
target,
actions,
type: "link",
...rest
};
};
var json = (attributes = {}) => {
const { name, displayAs, ...rest } = attributes;
return {
name,
displayAs,
type: "json",
...rest
};
};
var date = (attributes = {}) => {
const { name, ...rest } = attributes;
return {
name,
type: "date",
...rest
};
};
var boolean = (attributes = {}) => {
const { name, ...rest } = attributes;
return {
name,
type: "boolean",
...rest
};
};
var blob = (attributes = {}) => {
const { name, ...rest } = attributes;
return {
name,
type: "blob",
...rest
};
};
var string = primitive("string");
var number = primitive("number");
var link = primitive("link");
var json = primitive("json");
var date = primitive("date");
var boolean = primitive("boolean");
var blob = primitive("blob");
export {

@@ -502,0 +453,0 @@ blob,

{
"name": "@ronin/syntax",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",

@@ -5,0 +5,0 @@ "description": "Allows for defining RONIN queries and schemas in code.",

@@ -1,2 +0,2 @@

# RONIN Schema
# RONIN Syntax

@@ -7,3 +7,3 @@ [![tests](https://img.shields.io/github/actions/workflow/status/ronin-co/syntax/validate.yml?label=tests)](https://github.com/ronin-co/syntax/actions/workflows/validate.yml)

This package provides all primitives necessary for defining a [RONIN database schema](https://ronin.co/docs/platform/schemas-in-code) in code.
This package makes it possible to define [RONIN](https://ronin.co) queries and schemas in TypeScript code.

@@ -10,0 +10,0 @@ ## Setup

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc