@ronin/syntax
Advanced tools
Comparing version 0.1.9-leo-ron-1097-experimental-43 to 0.1.9-leo-ron-1097-experimental-44
@@ -42,4 +42,4 @@ import { AsyncLocalStorage } from 'node:async_hooks'; | ||
*/ | ||
interface QueryItem { | ||
structure: Query; | ||
interface SyntaxItem<Structure = unknown> { | ||
structure: Structure; | ||
options?: Record<string, unknown>; | ||
@@ -103,4 +103,4 @@ } | ||
*/ | ||
declare const getBatchProxy: <T extends [Promise<any> | any, ...Array<Promise<any> | any>] | (Promise<any> | any)[]>(operations: () => T, options: QueryOptions | undefined, queriesHandler: (queries: Array<QueryItem>, options?: QueryOptions) => Promise<any> | any) => Promise<PromiseTuple<T>> | T; | ||
declare const getBatchProxy: <T extends [Promise<any> | any, ...Array<Promise<any> | any>] | (Promise<any> | any)[]>(operations: () => T, options: QueryOptions | undefined, queriesHandler: (queries: Array<SyntaxItem<Query>>, options?: QueryOptions) => Promise<any> | any) => Promise<PromiseTuple<T>> | T; | ||
export { type PromiseTuple, type QueryItem, getBatchProxy, getProperty, getSyntaxProxy, setProperty }; | ||
export { type PromiseTuple, type SyntaxItem, getBatchProxy, getProperty, getSyntaxProxy, setProperty }; |
@@ -13,4 +13,4 @@ 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 Primitives = ReturnType<typeof link> | ReturnType<typeof string> | ReturnType<typeof boolean> | ReturnType<typeof number> | ReturnType<typeof json> | ReturnType<typeof date> | ReturnType<typeof blob> | NestedFields; | ||
interface NestedFields { | ||
type Primitives = ReturnType<typeof link> | ReturnType<typeof string> | ReturnType<typeof boolean> | ReturnType<typeof number> | ReturnType<typeof json> | ReturnType<typeof date> | ReturnType<typeof blob> | NestedFieldsPrimitives; | ||
interface NestedFieldsPrimitives { | ||
[key: string]: Primitives; | ||
@@ -74,3 +74,22 @@ } | ||
/** A utility type that maps an attribute's type to a function signature. */ | ||
type AttributeSignature<T> = T extends boolean ? () => any : T extends boolean ? never : (value: string) => any; | ||
/** | ||
* Represents a chain of field attributes in the form of a function chain. | ||
* | ||
* - `Attrs`: The interface describing your attributes (e.g., { required: boolean; }). | ||
* - `Used`: A union of the keys already used in the chain. | ||
* | ||
* For each attribute key `K` not in `Used`, create a method using the signature derived | ||
* from that attribute's type. Calling it returns a new `Chain` marking `K` as used. | ||
*/ | ||
type Chain<Attrs, Used extends keyof Attrs = never> = { | ||
[K in Exclude<keyof Attrs, Used | 'type'>]: (...args: Parameters<AttributeSignature<Attrs[K]>>) => Chain<Attrs, Used | K>; | ||
} & ('type' extends keyof Attrs ? { | ||
readonly type: Attrs['type']; | ||
} : {}); | ||
type FieldOutput<T extends ModelField['type']> = Omit<Extract<ModelField, { | ||
type: T; | ||
}>, 'slug'>; | ||
/** | ||
* Creates a string field definition returning an object that includes the field type | ||
@@ -102,3 +121,3 @@ * ("string") and attributes. | ||
collation?: "BINARY" | "NOCASE" | "RTRIM"; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"string">, never>; | ||
/** | ||
@@ -131,3 +150,3 @@ * Creates a number field definition returning an object that includes the field type | ||
increment?: boolean; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"number">, never>; | ||
/** | ||
@@ -165,3 +184,3 @@ * Creates a link field definition returning an object that includes the field type | ||
}; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"link">, never>; | ||
/** | ||
@@ -193,3 +212,3 @@ * Creates a JSON field definition returning an object that includes the field type | ||
type: "json"; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"json">, never>; | ||
/** | ||
@@ -221,3 +240,3 @@ * Creates a date field definition returning an object that includes the field type | ||
type: "date"; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"date">, never>; | ||
/** | ||
@@ -249,3 +268,3 @@ * Creates a boolean field definition returning an object that includes the field type | ||
type: "boolean"; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"boolean">, never>; | ||
/** | ||
@@ -277,4 +296,4 @@ * Creates a blob field definition returning an object that includes the field type | ||
type: "blob"; | ||
}, "slug" | "type">>) => any; | ||
}, "slug" | "type">>) => Chain<FieldOutput<"blob">, never>; | ||
export { blob, boolean, date, json, link, model, number, string }; | ||
export { type FieldOutput, blob, boolean, date, json, link, model, number, string }; |
@@ -71,13 +71,5 @@ import { | ||
} | ||
const { type, unique, defaultValue, required, name } = value; | ||
const { actions, target } = value; | ||
return { | ||
slug: key, | ||
name, | ||
unique: unique ?? false, | ||
required: required ?? false, | ||
defaultValue, | ||
type, | ||
target, | ||
actions | ||
...value | ||
}; | ||
@@ -84,0 +76,0 @@ } |
{ | ||
"name": "@ronin/syntax", | ||
"version": "0.1.9-leo-ron-1097-experimental-43", | ||
"version": "0.1.9-leo-ron-1097-experimental-44", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Allows for defining RONIN queries and schemas in code.", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
51223
1142
0