@deessejs/collections 0.0.27 → 0.0.29
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/collections/define.d.ts +7 -8
- package/dist/collections/define.js +4 -13
- package/dist/collections/extend-fields.d.ts +3 -0
- package/dist/collections/extend-fields.js +13 -0
- package/dist/dsl/collections.d.ts +13 -0
- package/dist/dsl/collections.js +14 -0
- package/dist/dsl/index.d.ts +1 -0
- package/dist/dsl/index.js +17 -0
- package/dist/fields/constraints.d.ts +1 -0
- package/dist/fields/constraints.js +15 -1
- package/dist/fields/core.d.ts +21 -8
- package/dist/fields/core.js +7 -2
- package/dist/fields/field.d.ts +4 -4
- package/dist/fields/types.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Field } from "../fields";
|
|
2
2
|
import { Collection } from "./types";
|
|
3
3
|
export declare const collection: <const Slug extends string, const Fields extends Record<string, Field>>(config: Collection<Slug, Fields>) => Collection<Slug, Fields & {
|
|
4
|
-
readonly id:
|
|
5
|
-
kind:
|
|
4
|
+
readonly id: Field<{
|
|
5
|
+
kind: import("../fields").FieldKind;
|
|
6
6
|
params: unknown;
|
|
7
7
|
dsl: {
|
|
8
|
-
kind:
|
|
8
|
+
kind: import("../fields").FieldKind;
|
|
9
9
|
isPrimary: boolean;
|
|
10
10
|
isUnique: boolean;
|
|
11
11
|
canBeNull: boolean;
|
|
@@ -15,10 +15,10 @@ export declare const collection: <const Slug extends string, const Fields extend
|
|
|
15
15
|
};
|
|
16
16
|
}>;
|
|
17
17
|
readonly createdAt: import("../fields").FieldChain<{
|
|
18
|
-
kind:
|
|
18
|
+
kind: import("../fields").FieldKind;
|
|
19
19
|
params: unknown;
|
|
20
20
|
dsl: {
|
|
21
|
-
kind:
|
|
21
|
+
kind: import("../fields").FieldKind;
|
|
22
22
|
isPrimary: boolean;
|
|
23
23
|
isUnique: boolean;
|
|
24
24
|
canBeNull: boolean;
|
|
@@ -28,10 +28,10 @@ export declare const collection: <const Slug extends string, const Fields extend
|
|
|
28
28
|
};
|
|
29
29
|
}>;
|
|
30
30
|
readonly updatedAt: import("../fields").FieldChain<{
|
|
31
|
-
kind:
|
|
31
|
+
kind: import("../fields").FieldKind;
|
|
32
32
|
params: unknown;
|
|
33
33
|
dsl: {
|
|
34
|
-
kind:
|
|
34
|
+
kind: import("../fields").FieldKind;
|
|
35
35
|
isPrimary: boolean;
|
|
36
36
|
isUnique: boolean;
|
|
37
37
|
canBeNull: boolean;
|
|
@@ -41,4 +41,3 @@ export declare const collection: <const Slug extends string, const Fields extend
|
|
|
41
41
|
};
|
|
42
42
|
}>;
|
|
43
43
|
}>;
|
|
44
|
-
export declare const extendFields: <const Slug extends string, const Fields extends Record<string, Field>, const NewFields extends Record<string, Field>>(base: Collection<Slug, Fields>, newFields: NewFields) => Collection<Slug, Fields & NewFields>;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.collection = void 0;
|
|
4
4
|
const fields_1 = require("../fields");
|
|
5
|
+
const extend_fields_1 = require("./extend-fields");
|
|
5
6
|
const collection = (config) => {
|
|
6
|
-
return (0,
|
|
7
|
-
id: (0, fields_1.field)({ type: (0, fields_1.
|
|
7
|
+
return (0, extend_fields_1.extendFields)(config, {
|
|
8
|
+
id: (0, fields_1.primary)((0, fields_1.field)({ type: (0, fields_1.serial)() })),
|
|
8
9
|
createdAt: (0, fields_1.field)({ type: (0, fields_1.timestamp)() }),
|
|
9
10
|
updatedAt: (0, fields_1.field)({ type: (0, fields_1.timestamp)() }),
|
|
10
11
|
});
|
|
11
12
|
};
|
|
12
13
|
exports.collection = collection;
|
|
13
|
-
const extendFields = (base, newFields) => {
|
|
14
|
-
return {
|
|
15
|
-
...base,
|
|
16
|
-
fields: {
|
|
17
|
-
...base.fields,
|
|
18
|
-
...newFields,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
exports.extendFields = extendFields;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Field } from "../fields";
|
|
2
|
+
import { Collection } from "./types";
|
|
3
|
+
export declare const extendFields: <const Slug extends string, const Fields extends Record<string, Field>, const NewFields extends Record<string, Field>>(base: Collection<Slug, Fields>, newFields: NewFields) => Collection<Slug, Fields & NewFields>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extendFields = void 0;
|
|
4
|
+
const extendFields = (base, newFields) => {
|
|
5
|
+
return {
|
|
6
|
+
...base,
|
|
7
|
+
fields: {
|
|
8
|
+
...base.fields,
|
|
9
|
+
...newFields,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.extendFields = extendFields;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Collection } from "../collections/types";
|
|
2
|
+
export declare const dsl: (collection: Collection) => {
|
|
3
|
+
slug: string;
|
|
4
|
+
fields: {
|
|
5
|
+
name: string;
|
|
6
|
+
dsl: {
|
|
7
|
+
kind: string;
|
|
8
|
+
isPrimary: boolean;
|
|
9
|
+
isUnique: boolean;
|
|
10
|
+
canBeNull: boolean;
|
|
11
|
+
};
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dsl = void 0;
|
|
4
|
+
const dsl = (collection) => {
|
|
5
|
+
const { slug, fields } = collection;
|
|
6
|
+
return {
|
|
7
|
+
slug,
|
|
8
|
+
fields: Object.entries(fields).map(([name, field]) => ({
|
|
9
|
+
name,
|
|
10
|
+
dsl: field.type.dsl,
|
|
11
|
+
})),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
exports.dsl = dsl;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './collections';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./collections"), exports);
|
|
@@ -2,4 +2,5 @@ import { Field, FieldChain, FieldTypeFinal } from "./types";
|
|
|
2
2
|
export declare const unique: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
3
3
|
export declare const required: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
4
4
|
export declare const optional: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
5
|
+
export declare const primary: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
|
|
5
6
|
export declare const attachChain: <TType extends FieldTypeFinal>(f: Field<TType>) => FieldChain<TType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.attachChain = exports.optional = exports.required = exports.unique = void 0;
|
|
3
|
+
exports.attachChain = exports.primary = exports.optional = exports.required = exports.unique = void 0;
|
|
4
4
|
const unique = (field) => {
|
|
5
5
|
return {
|
|
6
6
|
...field,
|
|
@@ -36,6 +36,17 @@ const optional = (field) => ({
|
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
38
|
exports.optional = optional;
|
|
39
|
+
const primary = (field) => ({
|
|
40
|
+
...field,
|
|
41
|
+
type: {
|
|
42
|
+
...field.type,
|
|
43
|
+
dsl: {
|
|
44
|
+
...field.type.dsl,
|
|
45
|
+
isPrimary: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
exports.primary = primary;
|
|
39
50
|
const attachChain = (f) => {
|
|
40
51
|
return {
|
|
41
52
|
...f,
|
|
@@ -48,6 +59,9 @@ const attachChain = (f) => {
|
|
|
48
59
|
optional() {
|
|
49
60
|
return (0, exports.attachChain)((0, exports.optional)(f));
|
|
50
61
|
},
|
|
62
|
+
primary() {
|
|
63
|
+
return (0, exports.attachChain)((0, exports.primary)(f));
|
|
64
|
+
},
|
|
51
65
|
};
|
|
52
66
|
};
|
|
53
67
|
exports.attachChain = attachChain;
|
package/dist/fields/core.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ export declare const number: (params?: {
|
|
|
2
2
|
min?: number | undefined;
|
|
3
3
|
max?: number | undefined;
|
|
4
4
|
} | undefined) => {
|
|
5
|
-
kind:
|
|
5
|
+
kind: import("./types").FieldKind;
|
|
6
6
|
params: unknown;
|
|
7
7
|
dsl: {
|
|
8
|
-
kind:
|
|
8
|
+
kind: import("./types").FieldKind;
|
|
9
9
|
isPrimary: boolean;
|
|
10
10
|
isUnique: boolean;
|
|
11
11
|
canBeNull: boolean;
|
|
@@ -18,10 +18,10 @@ export declare const text: (params?: {
|
|
|
18
18
|
min?: number | undefined;
|
|
19
19
|
max?: number | undefined;
|
|
20
20
|
} | undefined) => {
|
|
21
|
-
kind:
|
|
21
|
+
kind: import("./types").FieldKind;
|
|
22
22
|
params: unknown;
|
|
23
23
|
dsl: {
|
|
24
|
-
kind:
|
|
24
|
+
kind: import("./types").FieldKind;
|
|
25
25
|
isPrimary: boolean;
|
|
26
26
|
isUnique: boolean;
|
|
27
27
|
canBeNull: boolean;
|
|
@@ -31,10 +31,10 @@ export declare const text: (params?: {
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
export declare const uuid: (params?: void | undefined) => {
|
|
34
|
-
kind:
|
|
34
|
+
kind: import("./types").FieldKind;
|
|
35
35
|
params: unknown;
|
|
36
36
|
dsl: {
|
|
37
|
-
kind:
|
|
37
|
+
kind: import("./types").FieldKind;
|
|
38
38
|
isPrimary: boolean;
|
|
39
39
|
isUnique: boolean;
|
|
40
40
|
canBeNull: boolean;
|
|
@@ -44,10 +44,23 @@ export declare const uuid: (params?: void | undefined) => {
|
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
export declare const timestamp: (params?: void | undefined) => {
|
|
47
|
-
kind:
|
|
47
|
+
kind: import("./types").FieldKind;
|
|
48
48
|
params: unknown;
|
|
49
49
|
dsl: {
|
|
50
|
-
kind:
|
|
50
|
+
kind: import("./types").FieldKind;
|
|
51
|
+
isPrimary: boolean;
|
|
52
|
+
isUnique: boolean;
|
|
53
|
+
canBeNull: boolean;
|
|
54
|
+
};
|
|
55
|
+
admin: {
|
|
56
|
+
component: any;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export declare const serial: (params?: void | undefined) => {
|
|
60
|
+
kind: import("./types").FieldKind;
|
|
61
|
+
params: unknown;
|
|
62
|
+
dsl: {
|
|
63
|
+
kind: import("./types").FieldKind;
|
|
51
64
|
isPrimary: boolean;
|
|
52
65
|
isUnique: boolean;
|
|
53
66
|
canBeNull: boolean;
|
package/dist/fields/core.js
CHANGED
|
@@ -3,12 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.timestamp = exports.uuid = exports.text = exports.number = void 0;
|
|
6
|
+
exports.serial = exports.timestamp = exports.uuid = exports.text = exports.number = void 0;
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
|
8
8
|
const field_1 = require("./field");
|
|
9
9
|
exports.number = (0, field_1.fieldType)({
|
|
10
10
|
schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
|
|
11
|
-
dsl: { kind: "
|
|
11
|
+
dsl: { kind: "numeric" },
|
|
12
12
|
admin: { component: undefined },
|
|
13
13
|
});
|
|
14
14
|
exports.text = (0, field_1.fieldType)({
|
|
@@ -26,3 +26,8 @@ exports.timestamp = (0, field_1.fieldType)({
|
|
|
26
26
|
dsl: { kind: "timestamp" },
|
|
27
27
|
admin: { component: undefined },
|
|
28
28
|
});
|
|
29
|
+
exports.serial = (0, field_1.fieldType)({
|
|
30
|
+
schema: zod_1.default.void(),
|
|
31
|
+
dsl: { kind: "serial" },
|
|
32
|
+
admin: { component: undefined },
|
|
33
|
+
});
|
package/dist/fields/field.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
import { FieldChain, FieldConfig, FieldTypeFinal } from "./types";
|
|
2
|
+
import { FieldChain, FieldConfig, FieldKind, FieldTypeFinal } from "./types";
|
|
3
3
|
export declare const fieldType: <TOutput, TParams extends z.ZodType | undefined>(config: {
|
|
4
4
|
schema?: TParams;
|
|
5
5
|
dsl: {
|
|
6
|
-
kind:
|
|
6
|
+
kind: FieldKind;
|
|
7
7
|
};
|
|
8
8
|
admin: {
|
|
9
9
|
component: any;
|
|
10
10
|
};
|
|
11
11
|
}) => (params?: TParams extends z.ZodType ? z.infer<TParams> : undefined) => {
|
|
12
|
-
kind:
|
|
12
|
+
kind: FieldKind;
|
|
13
13
|
params: unknown;
|
|
14
14
|
dsl: {
|
|
15
|
-
kind:
|
|
15
|
+
kind: FieldKind;
|
|
16
16
|
isPrimary: boolean;
|
|
17
17
|
isUnique: boolean;
|
|
18
18
|
canBeNull: boolean;
|
package/dist/fields/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export type FieldKind = "integer" | "serial" | "boolean" | "text" | "varchar" | "char" | "numeric" | "decimal" | "json" | "uuid" | "timestamp";
|
|
2
3
|
export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
|
|
3
4
|
schema?: TParams;
|
|
4
5
|
dsl: {
|
|
5
|
-
kind:
|
|
6
|
+
kind: FieldKind;
|
|
6
7
|
};
|
|
7
8
|
admin: {
|
|
8
9
|
component: any;
|
|
@@ -43,4 +44,5 @@ export type FieldChain<TType extends FieldTypeFinal> = Field<TType> & {
|
|
|
43
44
|
unique(): FieldChain<TType>;
|
|
44
45
|
required(): FieldChain<TType>;
|
|
45
46
|
optional(): FieldChain<TType>;
|
|
47
|
+
primary(): FieldChain<TType>;
|
|
46
48
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED