@cwqt/refract
Advanced tools
Comparing version 1.0.8 to 1.0.9
import * as Types from '../types'; | ||
export declare const column: (column: Types.Column) => string; | ||
export declare const enumeration: (column: Types.Column<'Enum'>) => string; |
@@ -25,3 +25,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.column = void 0; | ||
exports.enumeration = exports.column = void 0; | ||
const modifiers_1 = require("./modifiers"); | ||
@@ -34,3 +34,5 @@ const Types = __importStar(require("../types")); | ||
if (Types.Fields.isEnum(column)) | ||
return enumeration(column); | ||
return (0, exports.enumeration)(column); | ||
if (Types.Fields.isEnumKey(column)) | ||
return enumKey(column); | ||
if (Types.Fields.isPrimitive(column)) | ||
@@ -43,5 +45,8 @@ return primitive(column); | ||
exports.column = column; | ||
const enumKey = (column) => `\t${column.name} ${column.modifiers | ||
.map(m => (0, modifiers_1.modifier)(column.type, m)) | ||
.join(' ')}`.trimEnd(); | ||
const enumeration = (column) => { | ||
const [type, ...modifiers] = column.modifiers; | ||
const isNullable = column.modifiers.find(({ type }) => type == 'nullable'); | ||
const isNullable = modifiers.find(({ type }) => type == 'nullable'); | ||
return `\t${column.name} ${type.value}${isNullable ? '?' : ''} ${modifiers | ||
@@ -51,9 +56,6 @@ .map(m => (0, modifiers_1.modifier)(column.type, m)) | ||
}; | ||
exports.enumeration = enumeration; | ||
const primitive = (column) => { | ||
const isNullable = column.modifiers.find(({ type }) => type == 'nullable'); | ||
return `\t${column.name} ${column.type == 'Varchar' | ||
? 'String' | ||
: column.type}${isNullable ? '?' : ''} ${column.modifiers | ||
.map(m => (0, modifiers_1.modifier)(column.type, m)) | ||
.join(' ')}`.trimEnd(); | ||
return `\t${column.name} ${column.type}${isNullable ? '?' : ''} ${column.modifiers.map(m => (0, modifiers_1.modifier)(column.type, m)).join(' ')}`.trimEnd(); | ||
}; | ||
@@ -75,3 +77,2 @@ const relationship = (column) => { | ||
} | ||
return ''; | ||
}; |
@@ -46,3 +46,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
group((0, block_1.header)('generators'), generators.map(generator => (0, block_1.block)(`generator ${generator.name}`, (0, align_1.align)((0, transform_1.kv)((0, utils_1.del)(generator, 'name')), '=')))), | ||
group((0, block_1.header)('enums'), enums.map(e => (0, block_1.block)(`enum ${e.name}`, e.columns.map(c => `\t${c.name}`).join('\n')))), | ||
group((0, block_1.header)('enums'), enums.map(e => (0, block_1.block)(`enum ${e.name}`, e.columns.map(e => (0, column_1.column)(e)).join('\n')))), | ||
group((0, block_1.header)('models'), models.map(model => (0, block_1.block)(`model ${model.name}`, (0, align_1.align)(model.columns.map(column_1.column).join('\n'))))), | ||
@@ -49,0 +49,0 @@ ] |
import { Modifier } from '../types/modifiers'; | ||
import { Type } from '../types/types'; | ||
export declare const modifier: (type: Type, modifier: Modifier) => string; | ||
export declare const modifier: <T extends keyof import("../types/types").TypeData>(type: T, modifier: Modifier<T, keyof import("../types/types").TypeData[T]>) => string; |
@@ -14,4 +14,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
return '@updatedAt'; | ||
case 'ignore': | ||
return '@ignore'; | ||
case 'map': | ||
return `@map("${modifier.value}")`; | ||
} | ||
}; | ||
exports.modifier = modifier; |
import { Column } from '../types/columns'; | ||
declare type Primitive = Date | boolean | number | string; | ||
import { JsonValue } from './lib/json'; | ||
declare type Primitive = Date | boolean | number | string | true | false | BigInt | JsonValue; | ||
declare type Properties = Record<string, Primitive | Array<Primitive> | Column>; | ||
@@ -4,0 +5,0 @@ export declare const kv: (properties: Properties) => string; |
@@ -5,4 +5,5 @@ export * from './public/modifiers'; | ||
export * from './public/mixin'; | ||
export * as Types from './types'; | ||
import * as Types from './types'; | ||
declare const _default: (config: Types.Config) => Promise<void>; | ||
export default _default; |
@@ -12,5 +12,17 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -20,2 +32,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Types = void 0; | ||
__exportStar(require("./public/modifiers"), exports); | ||
@@ -25,4 +38,5 @@ __exportStar(require("./public/fields"), exports); | ||
__exportStar(require("./public/mixin"), exports); | ||
exports.Types = __importStar(require("./types")); | ||
const promises_1 = require("fs/promises"); | ||
const codegen_1 = __importDefault(require("./codegen")); | ||
exports.default = (config) => (({ schema, output, time }) => (0, promises_1.writeFile)(output, schema, 'utf8').then(() => console.log(`Created schema at: ${output} (${time} ms)`)))((0, codegen_1.default)(config)); |
import * as Types from '../types'; | ||
export declare class Enum<K extends readonly string[]> extends Function implements Types.Blocks.Block<'enum'> { | ||
export declare class Enum<K extends Types.Fields.EnumKey[]> extends Function implements Types.Blocks.Block<'enum'> { | ||
name: string; | ||
type: 'enum'; | ||
columns: Types.Blocks.Model['columns']; | ||
columns: Types.Column<'EnumKey'>[]; | ||
constructor(name: string, keys: K); | ||
_call(initial?: K[number] | null, ...modifiers: Types.Modifier<'Enum'>[]): Types.Fields.Field<'Enum'>; | ||
} |
@@ -12,5 +12,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
this.columns = keys.map(k => ({ | ||
name: k, | ||
type: 'Enum', | ||
modifiers: [], | ||
name: k.name, | ||
type: 'EnumKey', | ||
modifiers: k.modifiers, | ||
})); | ||
@@ -17,0 +17,0 @@ return new Proxy(this, { |
import * as Types from '../types'; | ||
import { Model } from './model'; | ||
export declare const Enum: <K extends readonly string[]>(name: string, keys: K) => ((initial?: K[number], ...modifiers: Types.Modifier<'Enum'>[]) => Types.Fields.Field<'Enum'>) & Types.Blocks.Enum; | ||
export declare const Int: (...modifiers: Types.Modifier<'Int'>[]) => Types.Fields.Field<"Int">; | ||
export declare const Varchar: (...modifiers: Types.Modifier<'Varchar'>[]) => Types.Fields.Field<"Varchar">; | ||
export declare const Boolean: (...modifiers: Types.Modifier<'Boolean'>[]) => Types.Fields.Field<"Boolean">; | ||
export declare const Json: (...modifiers: Types.Modifier<'Json'>[]) => Types.Fields.Field<"Json">; | ||
export declare const DateTime: (...modifiers: Types.Modifier<'DateTime'>[]) => Types.Fields.Field<'DateTime'>; | ||
export declare const OneToMany: <M extends Types.Blocks.Model>(model: M, ...modifiers: Types.Modifier<'OneToMany'>[]) => Types.Fields.Field<"OneToMany">; | ||
export declare const Int: <M extends "map" | "default" | "id" | "unique" | "nullable" | "ignore">(...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>[]) => { | ||
type: "String"; | ||
modifiers: Types.Modifier<"String", M>[]; | ||
}; | ||
export declare const Float: <M extends "map" | "default" | "unique" | "nullable" | "ignore">(...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>[]) => { | ||
type: "BigInt"; | ||
modifiers: Types.Modifier<"BigInt", M>[]; | ||
}; | ||
export declare const Bytes: <M extends "map" | "default" | "unique" | "nullable" | "ignore">(...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>[]) => { | ||
type: "Boolean"; | ||
modifiers: Types.Modifier<"Boolean", M>[]; | ||
}; | ||
export declare const Json: <M extends "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 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; | ||
export declare const Key: <T extends string>(name: T, ...modifiers: Types.Modifier<'EnumKey'>[]) => Types.Fields.EnumKey<T>; | ||
export declare const OneToMany: <M extends Types.Blocks.Model>(model: M, ...modifiers: Types.Modifier<'OneToMany'>[]) => Types.Fields.Field<"OneToMany", "model" | "nullable">; | ||
declare type RelationFn<T extends Types.Blocks.Model> = (m: T | string) => Relation; | ||
@@ -18,4 +42,4 @@ export declare type Relation = { | ||
}; | ||
export declare const ManyToOne: <M extends Types.Blocks.Model>(model: string | M, relation: RelationFn<M>, ...modifiers: Types.Modifier<'ManyToOne'>[]) => Types.Fields.Field<"ManyToOne">; | ||
export declare const OneToOne: <M extends Types.Blocks.Model>(model: M, ...modifiers: [RelationFn<M>, ...Types.Modifier<"OneToOne", "model" | "nullable" | "fields" | "references">[]] | Types.Modifier<"OneToOne", "model" | "nullable" | "fields" | "references">[]) => Types.Fields.Field<"OneToOne">; | ||
export declare const ManyToOne: <M extends Types.Blocks.Model>(model: string | M, relation: RelationFn<M>, ...modifiers: Types.Modifier<'ManyToOne'>[]) => Types.Fields.Field<"ManyToOne", "model" | "nullable" | "fields" | "references">; | ||
export declare const OneToOne: <M extends Types.Blocks.Model>(model: M, ...modifiers: [RelationFn<M>, ...Types.Modifier<"OneToOne", "model" | "nullable" | "fields" | "references">[]] | Types.Modifier<"OneToOne", "model" | "nullable" | "fields" | "references">[]) => Types.Fields.Field<"OneToOne", "model" | "nullable" | "fields" | "references">; | ||
export {}; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OneToOne = exports.ManyToOne = exports.Pk = exports.OneToMany = exports.DateTime = exports.Json = exports.Boolean = exports.Varchar = exports.Int = exports.Enum = void 0; | ||
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; | ||
const utils_1 = require("../types/utils"); | ||
const enum_1 = require("./enum"); | ||
const Enum = (name, keys) => new enum_1.Enum(name, keys); | ||
exports.Enum = Enum; | ||
const Int = (...modifiers) => ({ type: 'Int', modifiers }); | ||
const Int = (...modifiers) => ({ | ||
type: 'Int', | ||
modifiers, | ||
}); | ||
exports.Int = Int; | ||
const Varchar = (...modifiers) => ({ type: 'Varchar', modifiers }); | ||
exports.Varchar = Varchar; | ||
const Boolean = (...modifiers) => ({ type: 'Boolean', modifiers }); | ||
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 }); | ||
const Json = (...modifiers) => ({ | ||
type: 'Json', | ||
modifiers, | ||
}); | ||
exports.Json = Json; | ||
const DateTime = (...modifiers) => ({ type: 'DateTime', modifiers }); | ||
const DateTime = (...modifiers) => ({ | ||
type: 'DateTime', | ||
modifiers, | ||
}); | ||
exports.DateTime = DateTime; | ||
const Enum = (name, ...keys) => new enum_1.Enum(name, keys); | ||
exports.Enum = Enum; | ||
const Key = (name, ...modifiers) => ({ name, modifiers }); | ||
exports.Key = Key; | ||
const OneToMany = (model, ...modifiers) => ({ | ||
@@ -18,0 +50,0 @@ type: 'OneToMany', |
import * as Types from '../types'; | ||
export declare const Mixin: () => { | ||
Field: (name: string, type: Types.Fields.Field<Types.Fields.Primitive>) => { | ||
Field: <T extends Types.Fields.Scalar>(name: string, type: Types.Fields.Field<T, keyof Types.TypeData[T]>) => { | ||
Field: any; | ||
columns: Types.Column<keyof Types.TypeData>[]; | ||
columns: Types.Column<Types.Fields.Scalar>[]; | ||
}; | ||
columns: Types.Column<keyof Types.TypeData>[]; | ||
columns: Types.Column<Types.Fields.Scalar>[]; | ||
}; |
@@ -6,3 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Field = (name, type) => { | ||
columns.push({ name, ...type }); | ||
columns.push({ | ||
name, | ||
...type, | ||
}); | ||
return { Field, columns }; | ||
@@ -9,0 +12,0 @@ }; |
@@ -5,4 +5,4 @@ import * as Types from '../types'; | ||
Raw: (value: string) => Model; | ||
Relation: (name: string, type: Types.Fields.Field<Types.Fields.Relation>) => Model; | ||
Field: (name: string, type: Types.Fields.Field<Types.Fields.Primitive>) => Model; | ||
Relation: <T extends Types.Fields.Relation>(name: string, type: Types.Fields.Field<T>) => Model; | ||
Field: <T extends Types.Fields.Scalar | 'Enum'>(name: string, type: Types.Fields.Field<T>) => Model; | ||
} & Types.Blocks.Model; | ||
@@ -13,9 +13,9 @@ export declare const Model: (name: string) => Model; | ||
type: 'model'; | ||
columns: Types.Column<keyof Types.TypeData>[]; | ||
columns: Types.Column<Types.Type>[]; | ||
constructor(name: string); | ||
Mixin(mixin: Types.Mixin): this; | ||
Raw(value: string): this; | ||
Relation(name: string, type: Types.Fields.Field<Types.Fields.Relation>): this; | ||
Field(name: string, type: Types.Fields.Field<Types.Fields.Primitive>): this; | ||
Relation<T extends Types.Fields.Relation>(name: string, type: Types.Fields.Field<T>): this; | ||
Field<T extends Types.Fields.Scalar | 'Enum'>(name: string, type: Types.Fields.Field<T>): this; | ||
} | ||
export {}; |
@@ -28,4 +28,2 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
if (type.type == 'ManyToOne') { | ||
const references = type.modifiers[2]; | ||
const missing = references.value.filter(f => !this.columns.map(c => c.name).includes(f)); | ||
} | ||
@@ -32,0 +30,0 @@ this.columns.push({ name, ...type }); |
import * as Types from '../types'; | ||
export declare const Default: <T extends Types.Fields.Primitive, K extends Types.TypeData[T]["default"]>(value: K) => Types.Modifier<T, "default">; | ||
export declare const Default: <T extends Types.Fields.Scalar, K extends Types.TypeData[T]["default"]>(value: K) => Types.Modifier<T, "default">; | ||
export declare const Map: <T extends "EnumKey" | Types.Fields.Scalar, K extends Types.TypeData[T]["map"]>(value: K) => Types.Modifier<T, "map">; | ||
export declare const Unique: { | ||
@@ -15,6 +16,10 @@ readonly type: "unique"; | ||
}; | ||
export declare const Index: { | ||
readonly type: "index"; | ||
export declare const Id: { | ||
readonly type: "id"; | ||
readonly value: true; | ||
}; | ||
export declare const Limit: <K extends number>(value: K) => Types.Modifier<'Varchar', 'limit'>; | ||
export declare const Ignore: { | ||
readonly type: "ignore"; | ||
readonly value: true; | ||
}; | ||
export declare const Limit: <K extends number>(value: K) => Types.Modifier<'String', 'limit'>; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Limit = exports.Index = exports.Nullable = exports.UpdatedAt = exports.Unique = exports.Default = void 0; | ||
exports.Limit = exports.Ignore = exports.Id = exports.Nullable = exports.UpdatedAt = exports.Unique = exports.Map = exports.Default = void 0; | ||
const Default = (value) => ({ type: 'default', value }); | ||
exports.Default = Default; | ||
const Map = (value) => ({ type: 'map', value }); | ||
exports.Map = Map; | ||
exports.Unique = { | ||
@@ -17,7 +19,11 @@ type: 'unique', | ||
}; | ||
exports.Index = { | ||
type: 'index', | ||
exports.Id = { | ||
type: 'id', | ||
value: true, | ||
}; | ||
exports.Ignore = { | ||
type: 'ignore', | ||
value: true, | ||
}; | ||
const Limit = (value) => ({ type: 'limit', value }); | ||
exports.Limit = Limit; |
import { Column } from './columns'; | ||
export declare type BlockType = 'model' | 'enum' | 'datasource' | 'db'; | ||
export declare type BlockType = 'model' | 'enum'; | ||
export declare type Block<T extends BlockType = BlockType> = { | ||
name: string; | ||
type: T; | ||
columns: Column[]; | ||
columns: T extends 'enum' ? Column<'EnumKey'>[] : Column[]; | ||
}; | ||
@@ -8,0 +8,0 @@ export declare type Model = Block<'model'>; |
@@ -1,5 +0,7 @@ | ||
import { Type, TypeData } from './types'; | ||
import { Field } from './fields'; | ||
export declare type Column<T extends Type = keyof TypeData> = { | ||
import { Modifier } from './modifiers'; | ||
import { Type } from './types'; | ||
export declare type Column<T extends Type = Type> = { | ||
name: string; | ||
} & Field<T>; | ||
type: T; | ||
modifiers: Modifier<T>[]; | ||
}; |
import { Column } from './columns'; | ||
import { Modifier } from './modifiers'; | ||
import { Modifier, Modifiers } from './modifiers'; | ||
import { Type, TypeData } from './types'; | ||
export declare type Field<T extends Type = keyof TypeData> = { | ||
import { UnionToIntersection } from './utils'; | ||
export declare type Field<T extends Type, M extends Modifiers<T> = Modifiers<T>> = { | ||
type: T; | ||
modifiers: Array<Modifier>; | ||
modifiers: Modifier<T, M>[]; | ||
}; | ||
export declare type Primitive = 'Int' | 'Varchar' | 'Boolean' | 'DateTime' | 'Enum' | 'Json'; | ||
export declare type EnumKey<T extends string = string> = { | ||
name: T; | ||
modifiers: Modifier<'EnumKey'>[]; | ||
}; | ||
export declare type Scalar = 'Int' | 'Float' | 'BigInt' | 'Bytes' | 'Decimal' | 'String' | 'Boolean' | 'DateTime' | 'Json'; | ||
export declare type Enum = 'Enum' | 'EnumKey'; | ||
export declare type Relation = 'OneToMany' | 'OneToOne' | 'ManyToOne'; | ||
export declare type Any = Primitive | Relation | 'Raw'; | ||
export declare function isRaw(column: Column<Any>): column is Column<'Raw'>; | ||
export declare function isEnum(column: Column<Any>): column is Column<'Enum'>; | ||
export declare function isRelation(column: Column<Any>): column is Column<Relation>; | ||
export declare function isPrimitive(column: Column<Any>): column is Column<Primitive>; | ||
export declare type Any = Scalar | Relation | Enum | 'Raw'; | ||
declare type TopColumn = { | ||
name: string; | ||
type: Type; | ||
modifiers: Array<{ | ||
type: keyof UnionToIntersection<{ | ||
[type in Type]: TypeData[type]; | ||
}[Type]>; | ||
value: any; | ||
}>; | ||
}; | ||
export declare function isRaw(column: TopColumn): column is Column<'Raw'>; | ||
export declare function isEnumKey(column: TopColumn): column is Column<'EnumKey'>; | ||
export declare function isEnum(column: TopColumn): column is Column<'Enum'>; | ||
export declare function isRelation(column: TopColumn): column is Column<Relation>; | ||
export declare function isPrimitive(column: TopColumn): column is Column<Scalar>; | ||
export {}; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPrimitive = exports.isRelation = exports.isEnum = exports.isRaw = void 0; | ||
exports.isPrimitive = exports.isRelation = exports.isEnum = exports.isEnumKey = exports.isRaw = void 0; | ||
function isRaw(column) { | ||
@@ -7,2 +7,6 @@ return column.type == 'Raw'; | ||
exports.isRaw = isRaw; | ||
function isEnumKey(column) { | ||
return column.type == 'EnumKey'; | ||
} | ||
exports.isEnumKey = isEnumKey; | ||
function isEnum(column) { | ||
@@ -17,4 +21,4 @@ return column.type == 'Enum'; | ||
function isPrimitive(column) { | ||
return [isRelation(column), isEnum(column)].every(v => v == false); | ||
return [isRelation(column), isEnumKey(column), isEnum(column)].every(v => v == false); | ||
} | ||
exports.isPrimitive = isPrimitive; |
@@ -0,4 +1,5 @@ | ||
import { Fields } from '.'; | ||
import { Column } from './columns'; | ||
export declare type Mixin = { | ||
columns: Column[]; | ||
columns: Column<Fields.Scalar>[]; | ||
}; |
import { Type, TypeData } from './types'; | ||
export declare type Modifier<T extends Type = Type, Property extends keyof TypeData[T] = keyof TypeData[T]> = { | ||
export declare type Modifier<T extends Type = Type, Property extends Modifiers<T> = Modifiers<T>> = { | ||
type: Property; | ||
value: TypeData[T][Property]; | ||
}; | ||
export declare type Modifiers<T extends Type> = keyof TypeData[T]; |
@@ -6,17 +6,50 @@ import { JsonValue } from '../codegen/lib/json'; | ||
unique?: true; | ||
index?: true; | ||
default?: 'autoincrement()' | number; | ||
id?: true; | ||
default?: 'cuid()' | 'autoincrement()' | 'uuid()' | number; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
Varchar: { | ||
Float: { | ||
unique?: true; | ||
default?: number; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
BigInt: { | ||
unique?: true; | ||
default?: BigInt; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
Bytes: { | ||
unique?: true; | ||
default?: never; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
Decimal: { | ||
unique?: true; | ||
default?: number; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
String: { | ||
unique?: true; | ||
default?: string; | ||
nullable?: true; | ||
limit?: number; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
Boolean: { | ||
unique?: true; | ||
index?: true; | ||
default?: boolean; | ||
nullable?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -27,2 +60,4 @@ DateTime: { | ||
updatedAt?: true; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
@@ -32,11 +67,15 @@ Json: { | ||
default?: JsonValue; | ||
map?: string; | ||
ignore?: true; | ||
}; | ||
Raw: { | ||
value: string; | ||
}; | ||
Enum: { | ||
id?: true; | ||
nullable?: true; | ||
default?: string; | ||
ignore?: true; | ||
enum: string; | ||
}; | ||
EnumKey: { | ||
map?: string; | ||
}; | ||
OneToMany: { | ||
@@ -58,3 +97,6 @@ model: Model | string; | ||
}; | ||
Raw: { | ||
value: string; | ||
}; | ||
}; | ||
export declare type Type = keyof TypeData; |
{ | ||
"name": "@cwqt/refract", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "A TypeScript SDK for Prisma", | ||
@@ -5,0 +5,0 @@ "author": "cwqt", |
@@ -6,3 +6,3 @@ # refract | ||
<div align="center"> | ||
<img src="https://ftp.cass.si/70c~4vjp4.png" width="75%" /> | ||
<img src="https://ftp.cass.si/9888e=mw7.png" width="75%" /> | ||
</div> | ||
@@ -9,0 +9,0 @@ |
73248
948