@cwqt/refract
Advanced tools
Comparing version 1.0.9 to 1.0.10
import { Modifier } from '../types/modifiers'; | ||
export declare const modifier: <T extends keyof import("../types/types").TypeData>(type: T, modifier: Modifier<T, keyof import("../types/types").TypeData[T]>) => string; | ||
export declare const modifier: <T extends "BigInt" | "Int" | "Float" | "Bytes" | "Decimal" | "String" | "Boolean" | "DateTime" | "Json" | keyof { | ||
Enum: { | ||
id?: true; | ||
nullable?: true; | ||
default?: string; | ||
ignore?: true; | ||
enum: string; | ||
}; | ||
EnumKey: { | ||
map?: string; | ||
}; | ||
} | keyof { | ||
OneToMany: { | ||
model: string | import("../types/blocks").Model; | ||
nullable?: true; | ||
}; | ||
OneToOne: { | ||
model: string | import("../types/blocks").Model; | ||
nullable?: true; | ||
fields: string[]; | ||
references: string[]; | ||
}; | ||
ManyToOne: { | ||
nullable?: true; | ||
model: string | import("../types/blocks").Model; | ||
fields: string[]; | ||
references: string[]; | ||
}; | ||
} | "Raw">(type: T, modifier: Modifier<T, keyof import("../types/types").TypeData[T]>) => string; |
@@ -18,4 +18,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
return `@map("${modifier.value}")`; | ||
case 'raw': | ||
return modifier.value; | ||
} | ||
}; | ||
exports.modifier = modifier; |
import * as Types from '../types'; | ||
export declare const Int: <M extends "map" | "default" | "id" | "unique" | "nullable" | "ignore">(...modifiers: Types.Modifier<"Int", M>[]) => { | ||
export declare const Int: <M extends "raw" | "map" | "default" | "id" | "nullable" | "ignore" | "unique">(...modifiers: Types.Modifier<"Int", M>[]) => { | ||
type: "Int"; | ||
modifiers: Types.Modifier<"Int", M>[]; | ||
}; | ||
export declare const String: <M extends "map" | "default" | "unique" | "nullable" | "ignore" | "limit">(...modifiers: Types.Modifier<"String", M>[]) => { | ||
export declare const String: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "unique" | "limit">(...modifiers: Types.Modifier<"String", M>[]) => { | ||
type: "String"; | ||
modifiers: Types.Modifier<"String", M>[]; | ||
}; | ||
export declare const Float: <M extends "map" | "default" | "unique" | "nullable" | "ignore">(...modifiers: Types.Modifier<"Float", M>[]) => { | ||
export declare const Float: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "unique">(...modifiers: Types.Modifier<"Float", M>[]) => { | ||
type: "Float"; | ||
modifiers: Types.Modifier<"Float", M>[]; | ||
}; | ||
export declare const BigInt: <M extends "map" | "default" | "unique" | "nullable" | "ignore">(...modifiers: Types.Modifier<"BigInt", M>[]) => { | ||
export declare const BigInt: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "unique">(...modifiers: Types.Modifier<"BigInt", M>[]) => { | ||
type: "BigInt"; | ||
modifiers: Types.Modifier<"BigInt", M>[]; | ||
}; | ||
export declare const Bytes: <M extends "map" | "default" | "unique" | "nullable" | "ignore">(...modifiers: Types.Modifier<"Bytes", M>[]) => { | ||
export declare const Bytes: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "unique">(...modifiers: Types.Modifier<"Bytes", M>[]) => { | ||
type: "Bytes"; | ||
modifiers: Types.Modifier<"Bytes", M>[]; | ||
}; | ||
export declare const Boolean: <M extends "map" | "default" | "unique" | "nullable" | "ignore">(...modifiers: Types.Modifier<"Boolean", M>[]) => { | ||
export declare const Boolean: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "unique">(...modifiers: Types.Modifier<"Boolean", M>[]) => { | ||
type: "Boolean"; | ||
modifiers: Types.Modifier<"Boolean", M>[]; | ||
}; | ||
export declare const Json: <M extends "map" | "default" | "nullable" | "ignore">(...modifiers: Types.Modifier<"Json", M>[]) => { | ||
export declare const Json: <M extends "raw" | "map" | "default" | "nullable" | "ignore">(...modifiers: Types.Modifier<"Json", M>[]) => { | ||
type: "Json"; | ||
modifiers: Types.Modifier<"Json", M>[]; | ||
}; | ||
export declare const DateTime: <M extends "map" | "default" | "nullable" | "ignore" | "updatedAt">(...modifiers: Types.Modifier<"DateTime", M>[]) => Types.Fields.Field<'DateTime'>; | ||
export declare const DateTime: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "updatedAt">(...modifiers: Types.Modifier<"DateTime", M>[]) => { | ||
type: "DateTime"; | ||
modifiers: Types.Modifier<"DateTime", M>[]; | ||
}; | ||
export declare const Decimal: <M extends "raw" | "map" | "default" | "nullable" | "ignore" | "unique">(...modifiers: Types.Modifier<"Decimal", M>[]) => { | ||
type: "Decimal"; | ||
modifiers: Types.Modifier<"Decimal", M>[]; | ||
}; | ||
export declare const Enum: <E extends Types.Fields.EnumKey<string>[]>(name: string, ...keys: E) => (<M extends "default" | "id" | "enum" | "nullable" | "ignore">(initial?: E[number]["name"], ...modifiers: Types.Modifier<"Enum", M>[]) => Types.Fields.Field<"Enum", M>) & Types.Blocks.Enum; | ||
@@ -32,0 +39,0 @@ export declare const Key: <T extends string>(name: T, ...modifiers: Types.Modifier<'EnumKey'>[]) => Types.Fields.EnumKey<T>; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OneToOne = exports.ManyToOne = exports.Pk = exports.OneToMany = exports.Key = exports.Enum = exports.DateTime = exports.Json = exports.Boolean = exports.Bytes = exports.BigInt = exports.Float = exports.String = exports.Int = void 0; | ||
exports.OneToOne = exports.ManyToOne = exports.Pk = exports.OneToMany = exports.Key = exports.Enum = exports.Decimal = exports.DateTime = exports.Json = exports.Boolean = exports.Bytes = exports.BigInt = exports.Float = exports.String = exports.Int = void 0; | ||
const utils_1 = require("../types/utils"); | ||
const enum_1 = require("./enum"); | ||
const Int = (...modifiers) => ({ | ||
type: 'Int', | ||
const scalar = (type) => (...modifiers) => ({ | ||
type, | ||
modifiers, | ||
}); | ||
exports.Int = Int; | ||
const String = (...modifiers) => ({ | ||
type: 'String', | ||
modifiers, | ||
}); | ||
exports.String = String; | ||
const Float = (...modifiers) => ({ | ||
type: 'Float', | ||
modifiers, | ||
}); | ||
exports.Float = Float; | ||
const BigInt = (...modifiers) => ({ | ||
type: 'BigInt', | ||
modifiers, | ||
}); | ||
exports.BigInt = BigInt; | ||
const Bytes = (...modifiers) => ({ | ||
type: 'Bytes', | ||
modifiers, | ||
}); | ||
exports.Bytes = Bytes; | ||
const Boolean = (...modifiers) => ({ | ||
type: 'Boolean', | ||
modifiers, | ||
}); | ||
exports.Boolean = Boolean; | ||
const Json = (...modifiers) => ({ | ||
type: 'Json', | ||
modifiers, | ||
}); | ||
exports.Json = Json; | ||
const DateTime = (...modifiers) => ({ | ||
type: 'DateTime', | ||
modifiers, | ||
}); | ||
exports.DateTime = DateTime; | ||
exports.Int = scalar('Int'); | ||
exports.String = scalar('String'); | ||
exports.Float = scalar('Float'); | ||
exports.BigInt = scalar('BigInt'); | ||
exports.Bytes = scalar('Bytes'); | ||
exports.Boolean = scalar('Boolean'); | ||
exports.Json = scalar('Json'); | ||
exports.DateTime = scalar('DateTime'); | ||
exports.Decimal = scalar('Decimal'); | ||
const Enum = (name, ...keys) => new enum_1.Enum(name, keys); | ||
@@ -46,0 +19,0 @@ exports.Enum = Enum; |
@@ -24,2 +24,6 @@ import * as Types from '../types'; | ||
}; | ||
export declare const Raw: (value: string) => { | ||
type: "raw"; | ||
value: string; | ||
}; | ||
export declare const Limit: <K extends number>(value: K) => Types.Modifier<'String', 'limit'>; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Limit = exports.Ignore = exports.Id = exports.Nullable = exports.UpdatedAt = exports.Unique = exports.Map = exports.Default = void 0; | ||
exports.Limit = exports.Raw = exports.Ignore = exports.Id = exports.Nullable = exports.UpdatedAt = exports.Unique = exports.Map = exports.Default = void 0; | ||
const Default = (value) => ({ type: 'default', value }); | ||
@@ -27,3 +27,5 @@ exports.Default = Default; | ||
}; | ||
const Raw = (value) => ({ type: 'raw', value }); | ||
exports.Raw = Raw; | ||
const Limit = (value) => ({ type: 'limit', value }); | ||
exports.Limit = Limit; |
import { JsonValue } from '../codegen/lib/json'; | ||
import { Model } from './blocks'; | ||
export declare type TypeData = { | ||
declare type Append<T, K> = { | ||
[index in keyof T]: T[index] & K; | ||
}; | ||
declare type Scalars = Append<{ | ||
Int: { | ||
@@ -8,5 +11,2 @@ unique?: true; | ||
default?: 'cuid()' | 'autoincrement()' | 'uuid()' | number; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -16,5 +16,2 @@ Float: { | ||
default?: number; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -24,5 +21,2 @@ BigInt: { | ||
default?: BigInt; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -32,5 +26,2 @@ Bytes: { | ||
default?: never; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -40,13 +31,7 @@ Decimal: { | ||
default?: number; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
String: { | ||
unique?: true; | ||
default?: string; | ||
nullable?: true; | ||
default?: string | 'auto()'; | ||
limit?: number; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -56,19 +41,17 @@ Boolean: { | ||
default?: boolean; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
DateTime: { | ||
default?: 'now()'; | ||
nullable?: true; | ||
updatedAt?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
Json: { | ||
nullable?: true; | ||
default?: JsonValue; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
}, { | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
raw?: string; | ||
}>; | ||
declare type Enums = { | ||
Enum: { | ||
@@ -84,2 +67,4 @@ id?: true; | ||
}; | ||
}; | ||
declare type Relations = { | ||
OneToMany: { | ||
@@ -101,2 +86,4 @@ model: Model | string; | ||
}; | ||
}; | ||
export declare type TypeData = Scalars & Enums & Relations & { | ||
Raw: { | ||
@@ -107,1 +94,2 @@ value: string; | ||
export declare type Type = keyof TypeData; | ||
export {}; |
{ | ||
"name": "@cwqt/refract", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "A TypeScript SDK for Prisma", | ||
@@ -5,0 +5,0 @@ "author": "cwqt", |
73781
952