@taylordb/shared 0.16.5 → 0.18.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/dist/cjs/column-types.d.ts +5 -4
- package/dist/cjs/column-types.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/runtime-schema.d.ts +54 -0
- package/dist/cjs/runtime-schema.js +76 -0
- package/dist/cjs/runtime-schema.js.map +1 -0
- package/dist/esm/column-types.d.ts +5 -4
- package/dist/esm/column-types.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/runtime-schema.d.ts +54 -0
- package/dist/esm/runtime-schema.js +63 -0
- package/dist/esm/runtime-schema.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -34,6 +34,10 @@ export interface AttachmentColumnValue {
|
|
|
34
34
|
fileType: string;
|
|
35
35
|
size: number;
|
|
36
36
|
}
|
|
37
|
+
export interface AttachmentUpdateValue {
|
|
38
|
+
newAttachments: Attachment[];
|
|
39
|
+
deletedUrls: string[];
|
|
40
|
+
}
|
|
37
41
|
export declare class Attachment {
|
|
38
42
|
readonly collectionName: string;
|
|
39
43
|
readonly fileInformation: FileInformation;
|
|
@@ -182,10 +186,7 @@ export type LinkColumnType<T extends string, R extends boolean> = ALinkColumnTyp
|
|
|
182
186
|
newIds: number[];
|
|
183
187
|
deletedIds: number[];
|
|
184
188
|
}, number[], R>;
|
|
185
|
-
export type AttachmentColumnType<R extends boolean> = ColumnType<string[], Attachment[] |
|
|
186
|
-
newIds: number[];
|
|
187
|
-
deletedIds: number[];
|
|
188
|
-
} | number[], Attachment[] | number[], R, LinkFilters, LinkAggregations>;
|
|
189
|
+
export type AttachmentColumnType<R extends boolean> = ColumnType<string[], Attachment[] | AttachmentUpdateValue | number[], Attachment[] | number[], R, LinkFilters, LinkAggregations>;
|
|
189
190
|
export type SingleSelectColumnType<O extends readonly string[], R extends boolean> = ColumnType<O[number], O[number], O[number], R, SelectFilters<O>>;
|
|
190
191
|
export type MultiSelectColumnType<O extends readonly string[], R extends boolean> = ColumnType<O[number][], O[number][], O[number][], R, SelectFilters<O>>;
|
|
191
192
|
export type NumberColumnType<R extends boolean> = ColumnType<number, number, number, R, NumberFilters, NumberAggregations>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAwCH,MAAa,UAAU;IACL,cAAc,CAAS;IACvB,eAAe,CAAkB;IACjC,QAAQ,CAAsC;IAC9C,MAAM,CAAS;IACf,cAAc,CAAS;IACvB,GAAG,CAAS;IAE5B,YAAY,IAAoB;QAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,aAAa;QACX,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;YAC9B,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ;YACvC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;SAChC,CAAC;IACJ,CAAC;CACF;AAxBD,gCAwBC"}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./@types/index.js"), exports);
|
|
18
18
|
__exportStar(require("./column-types.js"), exports);
|
|
19
19
|
__exportStar(require("./constants/index.js"), exports);
|
|
20
|
+
__exportStar(require("./runtime-schema.js"), exports);
|
|
20
21
|
__exportStar(require("./utilities/index.js"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,oDAAkC;AAClC,uDAAqC;AACrC,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,oDAAkC;AAClC,uDAAqC;AACrC,sDAAoC;AACpC,uDAAqC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AttachmentColumnType, AutoGeneratedDateColumnType, AutoGeneratedNumberColumnType, CheckboxColumnType, DateColumnType, LinkColumnType, MultiSelectColumnType, NumberColumnType, SearchColumnType, SingleSelectColumnType, TextColumnType } from './column-types.js';
|
|
2
|
+
type RequiredOption<R extends boolean = boolean> = {
|
|
3
|
+
required: R;
|
|
4
|
+
};
|
|
5
|
+
type BaseFieldDescriptor<TType extends string, R extends boolean, TInsertable extends boolean, TUpdatable extends boolean> = {
|
|
6
|
+
type: TType;
|
|
7
|
+
required: R;
|
|
8
|
+
insertable: TInsertable;
|
|
9
|
+
updatable: TUpdatable;
|
|
10
|
+
};
|
|
11
|
+
export type TextFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'text', R, true, true>;
|
|
12
|
+
export type NumberFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'number', R, true, true>;
|
|
13
|
+
export type CheckboxFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'checkbox', R, true, true>;
|
|
14
|
+
export type DateFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'date', R, true, true>;
|
|
15
|
+
export type SearchFieldDescriptor = BaseFieldDescriptor<'search', false, true, true>;
|
|
16
|
+
export type LinkFieldDescriptor<TLinkedTo extends string = string, R extends boolean = boolean> = BaseFieldDescriptor<'link', R, true, true> & {
|
|
17
|
+
linkedTo: TLinkedTo;
|
|
18
|
+
};
|
|
19
|
+
export type AttachmentFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'attachment', R, true, true> & {
|
|
20
|
+
linkedTo: 'attachmentTable';
|
|
21
|
+
};
|
|
22
|
+
export type SelectFieldDescriptor<TOptions extends readonly string[] = readonly string[], R extends boolean = boolean, TMode extends 'single' | 'multi' = 'single' | 'multi'> = BaseFieldDescriptor<'select', R, true, true> & {
|
|
23
|
+
mode: TMode;
|
|
24
|
+
options: TOptions;
|
|
25
|
+
};
|
|
26
|
+
export type AutoNumberFieldDescriptor = BaseFieldDescriptor<'autoNumber', false, false, false>;
|
|
27
|
+
export type AutoDateFieldDescriptor = BaseFieldDescriptor<'autoDate', false, false, false>;
|
|
28
|
+
export type TaylorFieldDescriptor = TextFieldDescriptor | NumberFieldDescriptor | CheckboxFieldDescriptor | DateFieldDescriptor | SearchFieldDescriptor | LinkFieldDescriptor | AttachmentFieldDescriptor | SelectFieldDescriptor | AutoNumberFieldDescriptor | AutoDateFieldDescriptor;
|
|
29
|
+
export type TaylorTableSchema = Record<string, TaylorFieldDescriptor>;
|
|
30
|
+
export type TaylorRuntimeSchema = Record<string, TaylorTableSchema>;
|
|
31
|
+
export declare function defineTaylorSchema<const TSchema extends TaylorRuntimeSchema>(schema: TSchema): TSchema;
|
|
32
|
+
export declare function textField<const R extends boolean>({ required, }: RequiredOption<R>): TextFieldDescriptor<R>;
|
|
33
|
+
export declare function numberField<const R extends boolean>({ required, }: RequiredOption<R>): NumberFieldDescriptor<R>;
|
|
34
|
+
export declare function checkboxField<const R extends boolean>({ required, }: RequiredOption<R>): CheckboxFieldDescriptor<R>;
|
|
35
|
+
export declare function dateField<const R extends boolean>({ required, }: RequiredOption<R>): DateFieldDescriptor<R>;
|
|
36
|
+
export declare function searchField(): SearchFieldDescriptor;
|
|
37
|
+
export declare function linkField<const TLinkedTo extends string, const R extends boolean>({ required, linkedTo, }: RequiredOption<R> & {
|
|
38
|
+
linkedTo: TLinkedTo;
|
|
39
|
+
}): LinkFieldDescriptor<TLinkedTo, R>;
|
|
40
|
+
export declare function attachmentField<const R extends boolean>({ required, }: RequiredOption<R>): AttachmentFieldDescriptor<R>;
|
|
41
|
+
export declare function selectField<const TOptions extends readonly string[], const R extends boolean, const TMode extends 'single' | 'multi'>({ required, mode, options, }: RequiredOption<R> & {
|
|
42
|
+
mode: TMode;
|
|
43
|
+
options: TOptions;
|
|
44
|
+
}): SelectFieldDescriptor<TOptions, R, TMode>;
|
|
45
|
+
export declare function autoNumberField(): AutoNumberFieldDescriptor;
|
|
46
|
+
export declare function autoDateField(): AutoDateFieldDescriptor;
|
|
47
|
+
export type InferTaylorField<TField extends TaylorFieldDescriptor> = TField extends TextFieldDescriptor<infer R> ? TextColumnType<R> : TField extends NumberFieldDescriptor<infer R> ? NumberColumnType<R> : TField extends CheckboxFieldDescriptor<infer R> ? CheckboxColumnType<R> : TField extends DateFieldDescriptor<infer R> ? DateColumnType<R> : TField extends SearchFieldDescriptor ? SearchColumnType<false> : TField extends LinkFieldDescriptor<infer TLinkedTo, infer R> ? LinkColumnType<TLinkedTo, R> : TField extends AttachmentFieldDescriptor<infer R> ? AttachmentColumnType<R> : TField extends SelectFieldDescriptor<infer TOptions, infer R, infer TMode> ? TMode extends 'single' ? SingleSelectColumnType<TOptions, R> : MultiSelectColumnType<TOptions, R> : TField extends AutoNumberFieldDescriptor ? AutoGeneratedNumberColumnType : TField extends AutoDateFieldDescriptor ? AutoGeneratedDateColumnType : never;
|
|
48
|
+
export type InferTaylorTable<TTableSchema extends TaylorTableSchema> = {
|
|
49
|
+
[K in keyof TTableSchema]: InferTaylorField<TTableSchema[K]>;
|
|
50
|
+
};
|
|
51
|
+
export type InferTaylorDatabase<TSchema extends TaylorRuntimeSchema> = {
|
|
52
|
+
[K in keyof TSchema]: InferTaylorTable<TSchema[K]>;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineTaylorSchema = defineTaylorSchema;
|
|
4
|
+
exports.textField = textField;
|
|
5
|
+
exports.numberField = numberField;
|
|
6
|
+
exports.checkboxField = checkboxField;
|
|
7
|
+
exports.dateField = dateField;
|
|
8
|
+
exports.searchField = searchField;
|
|
9
|
+
exports.linkField = linkField;
|
|
10
|
+
exports.attachmentField = attachmentField;
|
|
11
|
+
exports.selectField = selectField;
|
|
12
|
+
exports.autoNumberField = autoNumberField;
|
|
13
|
+
exports.autoDateField = autoDateField;
|
|
14
|
+
function defineTaylorSchema(schema) {
|
|
15
|
+
return schema;
|
|
16
|
+
}
|
|
17
|
+
function textField({ required, }) {
|
|
18
|
+
return { type: 'text', required, insertable: true, updatable: true };
|
|
19
|
+
}
|
|
20
|
+
function numberField({ required, }) {
|
|
21
|
+
return { type: 'number', required, insertable: true, updatable: true };
|
|
22
|
+
}
|
|
23
|
+
function checkboxField({ required, }) {
|
|
24
|
+
return { type: 'checkbox', required, insertable: true, updatable: true };
|
|
25
|
+
}
|
|
26
|
+
function dateField({ required, }) {
|
|
27
|
+
return { type: 'date', required, insertable: true, updatable: true };
|
|
28
|
+
}
|
|
29
|
+
function searchField() {
|
|
30
|
+
return { type: 'search', required: false, insertable: true, updatable: true };
|
|
31
|
+
}
|
|
32
|
+
function linkField({ required, linkedTo, }) {
|
|
33
|
+
return {
|
|
34
|
+
type: 'link',
|
|
35
|
+
required,
|
|
36
|
+
linkedTo,
|
|
37
|
+
insertable: true,
|
|
38
|
+
updatable: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function attachmentField({ required, }) {
|
|
42
|
+
return {
|
|
43
|
+
type: 'attachment',
|
|
44
|
+
required,
|
|
45
|
+
linkedTo: 'attachmentTable',
|
|
46
|
+
insertable: true,
|
|
47
|
+
updatable: true,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function selectField({ required, mode, options, }) {
|
|
51
|
+
return {
|
|
52
|
+
type: 'select',
|
|
53
|
+
required,
|
|
54
|
+
mode,
|
|
55
|
+
options,
|
|
56
|
+
insertable: true,
|
|
57
|
+
updatable: true,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function autoNumberField() {
|
|
61
|
+
return {
|
|
62
|
+
type: 'autoNumber',
|
|
63
|
+
required: false,
|
|
64
|
+
insertable: false,
|
|
65
|
+
updatable: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function autoDateField() {
|
|
69
|
+
return {
|
|
70
|
+
type: 'autoDate',
|
|
71
|
+
required: false,
|
|
72
|
+
insertable: false,
|
|
73
|
+
updatable: false,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=runtime-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-schema.js","sourceRoot":"","sources":["../../src/runtime-schema.ts"],"names":[],"mappings":";;AAwFA,gDAIC;AAED,8BAIC;AAED,kCAIC;AAED,sCAIC;AAED,8BAIC;AAED,kCAEC;AAED,8BAiBC;AAED,0CAUC;AAED,kCAoBC;AAED,0CAOC;AAED,sCAOC;AAvGD,SAAgB,kBAAkB,CAChC,MAAe;IAEf,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,SAAS,CAA0B,EACjD,QAAQ,GACU;IAClB,OAAO,EAAE,IAAI,EAAE,MAAM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,IAAI;QACJ,OAAO;QACP,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -34,6 +34,10 @@ export interface AttachmentColumnValue {
|
|
|
34
34
|
fileType: string;
|
|
35
35
|
size: number;
|
|
36
36
|
}
|
|
37
|
+
export interface AttachmentUpdateValue {
|
|
38
|
+
newAttachments: Attachment[];
|
|
39
|
+
deletedUrls: string[];
|
|
40
|
+
}
|
|
37
41
|
export declare class Attachment {
|
|
38
42
|
readonly collectionName: string;
|
|
39
43
|
readonly fileInformation: FileInformation;
|
|
@@ -182,10 +186,7 @@ export type LinkColumnType<T extends string, R extends boolean> = ALinkColumnTyp
|
|
|
182
186
|
newIds: number[];
|
|
183
187
|
deletedIds: number[];
|
|
184
188
|
}, number[], R>;
|
|
185
|
-
export type AttachmentColumnType<R extends boolean> = ColumnType<string[], Attachment[] |
|
|
186
|
-
newIds: number[];
|
|
187
|
-
deletedIds: number[];
|
|
188
|
-
} | number[], Attachment[] | number[], R, LinkFilters, LinkAggregations>;
|
|
189
|
+
export type AttachmentColumnType<R extends boolean> = ColumnType<string[], Attachment[] | AttachmentUpdateValue | number[], Attachment[] | number[], R, LinkFilters, LinkAggregations>;
|
|
189
190
|
export type SingleSelectColumnType<O extends readonly string[], R extends boolean> = ColumnType<O[number], O[number], O[number], R, SelectFilters<O>>;
|
|
190
191
|
export type MultiSelectColumnType<O extends readonly string[], R extends boolean> = ColumnType<O[number][], O[number][], O[number][], R, SelectFilters<O>>;
|
|
191
192
|
export type NumberColumnType<R extends boolean> = ColumnType<number, number, number, R, NumberFilters, NumberAggregations>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwCH,MAAM,OAAO,UAAU;IACL,cAAc,CAAS;IACvB,eAAe,CAAkB;IACjC,QAAQ,CAAsC;IAC9C,MAAM,CAAS;IACf,cAAc,CAAS;IACvB,GAAG,CAAS;IAE5B,YAAY,IAAoB;QAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,aAAa;QACX,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;YAC9B,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ;YACvC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;SAChC,CAAC;IACJ,CAAC;CACF"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AttachmentColumnType, AutoGeneratedDateColumnType, AutoGeneratedNumberColumnType, CheckboxColumnType, DateColumnType, LinkColumnType, MultiSelectColumnType, NumberColumnType, SearchColumnType, SingleSelectColumnType, TextColumnType } from './column-types.js';
|
|
2
|
+
type RequiredOption<R extends boolean = boolean> = {
|
|
3
|
+
required: R;
|
|
4
|
+
};
|
|
5
|
+
type BaseFieldDescriptor<TType extends string, R extends boolean, TInsertable extends boolean, TUpdatable extends boolean> = {
|
|
6
|
+
type: TType;
|
|
7
|
+
required: R;
|
|
8
|
+
insertable: TInsertable;
|
|
9
|
+
updatable: TUpdatable;
|
|
10
|
+
};
|
|
11
|
+
export type TextFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'text', R, true, true>;
|
|
12
|
+
export type NumberFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'number', R, true, true>;
|
|
13
|
+
export type CheckboxFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'checkbox', R, true, true>;
|
|
14
|
+
export type DateFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'date', R, true, true>;
|
|
15
|
+
export type SearchFieldDescriptor = BaseFieldDescriptor<'search', false, true, true>;
|
|
16
|
+
export type LinkFieldDescriptor<TLinkedTo extends string = string, R extends boolean = boolean> = BaseFieldDescriptor<'link', R, true, true> & {
|
|
17
|
+
linkedTo: TLinkedTo;
|
|
18
|
+
};
|
|
19
|
+
export type AttachmentFieldDescriptor<R extends boolean = boolean> = BaseFieldDescriptor<'attachment', R, true, true> & {
|
|
20
|
+
linkedTo: 'attachmentTable';
|
|
21
|
+
};
|
|
22
|
+
export type SelectFieldDescriptor<TOptions extends readonly string[] = readonly string[], R extends boolean = boolean, TMode extends 'single' | 'multi' = 'single' | 'multi'> = BaseFieldDescriptor<'select', R, true, true> & {
|
|
23
|
+
mode: TMode;
|
|
24
|
+
options: TOptions;
|
|
25
|
+
};
|
|
26
|
+
export type AutoNumberFieldDescriptor = BaseFieldDescriptor<'autoNumber', false, false, false>;
|
|
27
|
+
export type AutoDateFieldDescriptor = BaseFieldDescriptor<'autoDate', false, false, false>;
|
|
28
|
+
export type TaylorFieldDescriptor = TextFieldDescriptor | NumberFieldDescriptor | CheckboxFieldDescriptor | DateFieldDescriptor | SearchFieldDescriptor | LinkFieldDescriptor | AttachmentFieldDescriptor | SelectFieldDescriptor | AutoNumberFieldDescriptor | AutoDateFieldDescriptor;
|
|
29
|
+
export type TaylorTableSchema = Record<string, TaylorFieldDescriptor>;
|
|
30
|
+
export type TaylorRuntimeSchema = Record<string, TaylorTableSchema>;
|
|
31
|
+
export declare function defineTaylorSchema<const TSchema extends TaylorRuntimeSchema>(schema: TSchema): TSchema;
|
|
32
|
+
export declare function textField<const R extends boolean>({ required, }: RequiredOption<R>): TextFieldDescriptor<R>;
|
|
33
|
+
export declare function numberField<const R extends boolean>({ required, }: RequiredOption<R>): NumberFieldDescriptor<R>;
|
|
34
|
+
export declare function checkboxField<const R extends boolean>({ required, }: RequiredOption<R>): CheckboxFieldDescriptor<R>;
|
|
35
|
+
export declare function dateField<const R extends boolean>({ required, }: RequiredOption<R>): DateFieldDescriptor<R>;
|
|
36
|
+
export declare function searchField(): SearchFieldDescriptor;
|
|
37
|
+
export declare function linkField<const TLinkedTo extends string, const R extends boolean>({ required, linkedTo, }: RequiredOption<R> & {
|
|
38
|
+
linkedTo: TLinkedTo;
|
|
39
|
+
}): LinkFieldDescriptor<TLinkedTo, R>;
|
|
40
|
+
export declare function attachmentField<const R extends boolean>({ required, }: RequiredOption<R>): AttachmentFieldDescriptor<R>;
|
|
41
|
+
export declare function selectField<const TOptions extends readonly string[], const R extends boolean, const TMode extends 'single' | 'multi'>({ required, mode, options, }: RequiredOption<R> & {
|
|
42
|
+
mode: TMode;
|
|
43
|
+
options: TOptions;
|
|
44
|
+
}): SelectFieldDescriptor<TOptions, R, TMode>;
|
|
45
|
+
export declare function autoNumberField(): AutoNumberFieldDescriptor;
|
|
46
|
+
export declare function autoDateField(): AutoDateFieldDescriptor;
|
|
47
|
+
export type InferTaylorField<TField extends TaylorFieldDescriptor> = TField extends TextFieldDescriptor<infer R> ? TextColumnType<R> : TField extends NumberFieldDescriptor<infer R> ? NumberColumnType<R> : TField extends CheckboxFieldDescriptor<infer R> ? CheckboxColumnType<R> : TField extends DateFieldDescriptor<infer R> ? DateColumnType<R> : TField extends SearchFieldDescriptor ? SearchColumnType<false> : TField extends LinkFieldDescriptor<infer TLinkedTo, infer R> ? LinkColumnType<TLinkedTo, R> : TField extends AttachmentFieldDescriptor<infer R> ? AttachmentColumnType<R> : TField extends SelectFieldDescriptor<infer TOptions, infer R, infer TMode> ? TMode extends 'single' ? SingleSelectColumnType<TOptions, R> : MultiSelectColumnType<TOptions, R> : TField extends AutoNumberFieldDescriptor ? AutoGeneratedNumberColumnType : TField extends AutoDateFieldDescriptor ? AutoGeneratedDateColumnType : never;
|
|
48
|
+
export type InferTaylorTable<TTableSchema extends TaylorTableSchema> = {
|
|
49
|
+
[K in keyof TTableSchema]: InferTaylorField<TTableSchema[K]>;
|
|
50
|
+
};
|
|
51
|
+
export type InferTaylorDatabase<TSchema extends TaylorRuntimeSchema> = {
|
|
52
|
+
[K in keyof TSchema]: InferTaylorTable<TSchema[K]>;
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export function defineTaylorSchema(schema) {
|
|
2
|
+
return schema;
|
|
3
|
+
}
|
|
4
|
+
export function textField({ required, }) {
|
|
5
|
+
return { type: 'text', required, insertable: true, updatable: true };
|
|
6
|
+
}
|
|
7
|
+
export function numberField({ required, }) {
|
|
8
|
+
return { type: 'number', required, insertable: true, updatable: true };
|
|
9
|
+
}
|
|
10
|
+
export function checkboxField({ required, }) {
|
|
11
|
+
return { type: 'checkbox', required, insertable: true, updatable: true };
|
|
12
|
+
}
|
|
13
|
+
export function dateField({ required, }) {
|
|
14
|
+
return { type: 'date', required, insertable: true, updatable: true };
|
|
15
|
+
}
|
|
16
|
+
export function searchField() {
|
|
17
|
+
return { type: 'search', required: false, insertable: true, updatable: true };
|
|
18
|
+
}
|
|
19
|
+
export function linkField({ required, linkedTo, }) {
|
|
20
|
+
return {
|
|
21
|
+
type: 'link',
|
|
22
|
+
required,
|
|
23
|
+
linkedTo,
|
|
24
|
+
insertable: true,
|
|
25
|
+
updatable: true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function attachmentField({ required, }) {
|
|
29
|
+
return {
|
|
30
|
+
type: 'attachment',
|
|
31
|
+
required,
|
|
32
|
+
linkedTo: 'attachmentTable',
|
|
33
|
+
insertable: true,
|
|
34
|
+
updatable: true,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function selectField({ required, mode, options, }) {
|
|
38
|
+
return {
|
|
39
|
+
type: 'select',
|
|
40
|
+
required,
|
|
41
|
+
mode,
|
|
42
|
+
options,
|
|
43
|
+
insertable: true,
|
|
44
|
+
updatable: true,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function autoNumberField() {
|
|
48
|
+
return {
|
|
49
|
+
type: 'autoNumber',
|
|
50
|
+
required: false,
|
|
51
|
+
insertable: false,
|
|
52
|
+
updatable: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function autoDateField() {
|
|
56
|
+
return {
|
|
57
|
+
type: 'autoDate',
|
|
58
|
+
required: false,
|
|
59
|
+
insertable: false,
|
|
60
|
+
updatable: false,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=runtime-schema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