@deessejs/collections 0.0.51 → 0.2.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.
Files changed (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +204 -0
  3. package/dist/index.js +868 -22
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +821 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/next/index.js +421 -51
  8. package/dist/next/index.js.map +1 -0
  9. package/dist/next/index.mjs +377 -0
  10. package/dist/next/index.mjs.map +1 -0
  11. package/package.json +76 -72
  12. package/dist/collections/define.d.ts +0 -43
  13. package/dist/collections/define.js +0 -13
  14. package/dist/collections/extend-fields.d.ts +0 -3
  15. package/dist/collections/extend-fields.js +0 -13
  16. package/dist/collections/index.d.ts +0 -1
  17. package/dist/collections/index.js +0 -17
  18. package/dist/collections/types.d.ts +0 -29
  19. package/dist/collections/types.js +0 -2
  20. package/dist/config/index.d.ts +0 -2
  21. package/dist/config/index.js +0 -45
  22. package/dist/config/orchestrator.d.ts +0 -8
  23. package/dist/config/orchestrator.js +0 -70
  24. package/dist/config/types.d.ts +0 -14
  25. package/dist/config/types.js +0 -2
  26. package/dist/database/types.d.ts +0 -10
  27. package/dist/database/types.js +0 -2
  28. package/dist/drizzle/generate.d.ts +0 -2
  29. package/dist/drizzle/generate.js +0 -49
  30. package/dist/drizzle/index.d.ts +0 -31
  31. package/dist/drizzle/index.js +0 -24
  32. package/dist/drizzle/types.js +0 -1
  33. package/dist/dsl/collections.d.ts +0 -13
  34. package/dist/dsl/collections.js +0 -14
  35. package/dist/dsl/index.d.ts +0 -1
  36. package/dist/dsl/index.js +0 -17
  37. package/dist/dsl/types.d.ts +0 -1
  38. package/dist/dsl/types.js +0 -2
  39. package/dist/esm/collections/define.d.ts +0 -43
  40. package/dist/esm/collections/define.js +0 -9
  41. package/dist/esm/collections/extend-fields.d.ts +0 -3
  42. package/dist/esm/collections/extend-fields.js +0 -9
  43. package/dist/esm/collections/index.d.ts +0 -1
  44. package/dist/esm/collections/index.js +0 -1
  45. package/dist/esm/collections/types.d.ts +0 -29
  46. package/dist/esm/collections/types.js +0 -1
  47. package/dist/esm/config/index.d.ts +0 -5
  48. package/dist/esm/config/index.js +0 -13
  49. package/dist/esm/config/orchestrator.d.ts +0 -8
  50. package/dist/esm/config/orchestrator.js +0 -66
  51. package/dist/esm/config/types.d.ts +0 -14
  52. package/dist/esm/config/types.js +0 -1
  53. package/dist/esm/database/types.d.ts +0 -10
  54. package/dist/esm/database/types.js +0 -1
  55. package/dist/esm/drizzle/generate.d.ts +0 -2
  56. package/dist/esm/drizzle/generate.js +0 -30
  57. package/dist/esm/drizzle/index.d.ts +0 -31
  58. package/dist/esm/drizzle/index.js +0 -20
  59. package/dist/esm/drizzle/types.d.ts +0 -0
  60. package/dist/esm/drizzle/types.js +0 -1
  61. package/dist/esm/dsl/collections.d.ts +0 -13
  62. package/dist/esm/dsl/collections.js +0 -10
  63. package/dist/esm/dsl/index.d.ts +0 -1
  64. package/dist/esm/dsl/index.js +0 -1
  65. package/dist/esm/fields/constraints.d.ts +0 -6
  66. package/dist/esm/fields/constraints.js +0 -59
  67. package/dist/esm/fields/core.d.ts +0 -71
  68. package/dist/esm/fields/core.js +0 -27
  69. package/dist/esm/fields/field.d.ts +0 -24
  70. package/dist/esm/fields/field.js +0 -33
  71. package/dist/esm/fields/index.d.ts +0 -4
  72. package/dist/esm/fields/index.js +0 -4
  73. package/dist/esm/fields/types.d.ts +0 -48
  74. package/dist/esm/fields/types.js +0 -1
  75. package/dist/esm/index.d.ts +0 -8
  76. package/dist/esm/index.js +0 -8
  77. package/dist/esm/next/index.d.ts +0 -5
  78. package/dist/esm/next/index.js +0 -17
  79. package/dist/esm/plugins/index.d.ts +0 -2
  80. package/dist/esm/plugins/index.js +0 -3
  81. package/dist/esm/plugins/types.d.ts +0 -1
  82. package/dist/esm/plugins/types.js +0 -1
  83. package/dist/esm/providers/index.d.ts +0 -2
  84. package/dist/esm/providers/index.js +0 -53
  85. package/dist/esm/providers/types.d.ts +0 -8
  86. package/dist/esm/providers/types.js +0 -1
  87. package/dist/esm/utils/deep-partial.d.ts +0 -3
  88. package/dist/esm/utils/deep-partial.js +0 -1
  89. package/dist/esm/utils/exact.d.ts +0 -1
  90. package/dist/esm/utils/exact.js +0 -1
  91. package/dist/esm/utils/union-intersection.d.ts +0 -1
  92. package/dist/esm/utils/union-intersection.js +0 -1
  93. package/dist/esm/worker/index.d.ts +0 -2
  94. package/dist/esm/worker/index.js +0 -32
  95. package/dist/fields/constraints.d.ts +0 -6
  96. package/dist/fields/constraints.js +0 -67
  97. package/dist/fields/core.d.ts +0 -71
  98. package/dist/fields/core.js +0 -33
  99. package/dist/fields/field.d.ts +0 -24
  100. package/dist/fields/field.js +0 -38
  101. package/dist/fields/index.d.ts +0 -4
  102. package/dist/fields/index.js +0 -20
  103. package/dist/fields/types.d.ts +0 -48
  104. package/dist/fields/types.js +0 -2
  105. package/dist/index.d.ts +0 -8
  106. package/dist/next/index.d.ts +0 -5
  107. package/dist/plugins/index.d.ts +0 -2
  108. package/dist/plugins/index.js +0 -7
  109. package/dist/plugins/types.d.ts +0 -1
  110. package/dist/plugins/types.js +0 -2
  111. package/dist/providers/index.d.ts +0 -2
  112. package/dist/providers/index.js +0 -57
  113. package/dist/providers/types.d.ts +0 -8
  114. package/dist/providers/types.js +0 -2
  115. package/dist/utils/deep-partial.d.ts +0 -3
  116. package/dist/utils/deep-partial.js +0 -2
  117. package/dist/utils/exact.d.ts +0 -1
  118. package/dist/utils/exact.js +0 -1
  119. package/dist/utils/union-intersection.d.ts +0 -1
  120. package/dist/utils/union-intersection.js +0 -2
  121. package/dist/worker/index.d.ts +0 -1
  122. package/dist/worker/index.js +0 -101
  123. /package/{dist/drizzle/types.d.ts → public/.gitkeep} +0 -0
@@ -1,71 +0,0 @@
1
- export declare const number: (params?: {
2
- min?: number | undefined;
3
- max?: number | undefined;
4
- } | undefined) => {
5
- kind: import("./types").FieldKind;
6
- params: unknown;
7
- dsl: {
8
- kind: import("./types").FieldKind;
9
- isPrimary: boolean;
10
- isUnique: boolean;
11
- canBeNull: boolean;
12
- };
13
- admin: {
14
- component: any;
15
- };
16
- };
17
- export declare const text: (params?: {
18
- min?: number | undefined;
19
- max?: number | undefined;
20
- } | undefined) => {
21
- kind: import("./types").FieldKind;
22
- params: unknown;
23
- dsl: {
24
- kind: import("./types").FieldKind;
25
- isPrimary: boolean;
26
- isUnique: boolean;
27
- canBeNull: boolean;
28
- };
29
- admin: {
30
- component: any;
31
- };
32
- };
33
- export declare const uuid: (params?: void | undefined) => {
34
- kind: import("./types").FieldKind;
35
- params: unknown;
36
- dsl: {
37
- kind: import("./types").FieldKind;
38
- isPrimary: boolean;
39
- isUnique: boolean;
40
- canBeNull: boolean;
41
- };
42
- admin: {
43
- component: any;
44
- };
45
- };
46
- export declare const timestamp: (params?: void | undefined) => {
47
- kind: import("./types").FieldKind;
48
- params: unknown;
49
- dsl: {
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;
64
- isPrimary: boolean;
65
- isUnique: boolean;
66
- canBeNull: boolean;
67
- };
68
- admin: {
69
- component: any;
70
- };
71
- };
@@ -1,27 +0,0 @@
1
- import z from "zod";
2
- import { fieldType } from "./field";
3
- export const number = fieldType({
4
- schema: z.object({ min: z.number().optional(), max: z.number().optional() }),
5
- dsl: { kind: "numeric" },
6
- admin: { component: undefined },
7
- });
8
- export const text = fieldType({
9
- schema: z.object({ min: z.number().optional(), max: z.number().optional() }),
10
- dsl: { kind: "text" },
11
- admin: { component: undefined },
12
- });
13
- export const uuid = fieldType({
14
- schema: z.void(),
15
- dsl: { kind: "uuid" },
16
- admin: { component: undefined },
17
- });
18
- export const timestamp = fieldType({
19
- schema: z.void(),
20
- dsl: { kind: "timestamp" },
21
- admin: { component: undefined },
22
- });
23
- export const serial = fieldType({
24
- schema: z.void(),
25
- dsl: { kind: "serial" },
26
- admin: { component: undefined },
27
- });
@@ -1,24 +0,0 @@
1
- import z from "zod";
2
- import { FieldChain, FieldConfig, FieldKind, FieldTypeFinal } from "./types";
3
- export declare const fieldType: <TOutput, TParams extends z.ZodType | undefined>(config: {
4
- schema?: TParams;
5
- dsl: {
6
- kind: FieldKind;
7
- };
8
- admin: {
9
- component: any;
10
- };
11
- }) => (params?: TParams extends z.ZodType ? z.infer<TParams> : undefined) => {
12
- kind: FieldKind;
13
- params: unknown;
14
- dsl: {
15
- kind: FieldKind;
16
- isPrimary: boolean;
17
- isUnique: boolean;
18
- canBeNull: boolean;
19
- };
20
- admin: {
21
- component: any;
22
- };
23
- };
24
- export declare const field: <TType extends FieldTypeFinal>(config: FieldConfig<TType>) => FieldChain<TType>;
@@ -1,33 +0,0 @@
1
- import { attachChain } from "./constraints";
2
- export const fieldType = (config) => (params) => {
3
- const validated = config.schema && params !== undefined
4
- ? config.schema.parse(params)
5
- : params;
6
- return {
7
- kind: config.dsl.kind,
8
- params: validated,
9
- dsl: {
10
- kind: config.dsl.kind,
11
- isPrimary: false,
12
- isUnique: false,
13
- canBeNull: true,
14
- },
15
- admin: config.admin,
16
- };
17
- };
18
- const defaultPermissions = {
19
- create: async () => true,
20
- read: async () => true,
21
- update: async () => true,
22
- delete: async () => true,
23
- };
24
- export const field = (config) => {
25
- const base = {
26
- type: config.type,
27
- permissions: {
28
- ...defaultPermissions,
29
- ...config.permissions,
30
- },
31
- };
32
- return attachChain(base);
33
- };
@@ -1,4 +0,0 @@
1
- export * from './field';
2
- export * from './types';
3
- export * from './core';
4
- export * from './constraints';
@@ -1,4 +0,0 @@
1
- export * from './field';
2
- export * from './types';
3
- export * from './core';
4
- export * from './constraints';
@@ -1,48 +0,0 @@
1
- import { z } from "zod";
2
- export type FieldKind = "integer" | "serial" | "boolean" | "text" | "varchar" | "char" | "numeric" | "decimal" | "json" | "uuid" | "timestamp";
3
- export type FieldTypeConfig<TParams extends z.ZodType = z.ZodType> = {
4
- schema?: TParams;
5
- dsl: {
6
- kind: FieldKind;
7
- };
8
- admin: {
9
- component: any;
10
- };
11
- };
12
- export type FieldTypeFinal<TParams extends z.ZodType = z.ZodType, TOutput = any> = {
13
- kind: string;
14
- params: z.infer<TParams>;
15
- dsl: {
16
- kind: string;
17
- isPrimary: boolean;
18
- isUnique: boolean;
19
- canBeNull: boolean;
20
- };
21
- admin: {
22
- component: any;
23
- };
24
- _output?: TOutput;
25
- };
26
- export type FieldPermissions = {
27
- create: (ctx: any) => Promise<boolean>;
28
- read: (ctx: any) => Promise<boolean>;
29
- update: (ctx: any) => Promise<boolean>;
30
- delete: (ctx: any) => Promise<boolean>;
31
- };
32
- export type FieldConfig<TType extends FieldTypeFinal> = {
33
- type: TType;
34
- permissions?: Partial<FieldPermissions>;
35
- };
36
- export type Field<TType extends FieldTypeFinal = FieldTypeFinal> = {
37
- type: TType;
38
- permissions: FieldPermissions;
39
- };
40
- export type InferSchema<F extends Record<string, Field>> = {
41
- [K in keyof F]: F[K] extends Field<infer FT> ? FT extends FieldTypeFinal<any, infer TVal> ? TVal : never : never;
42
- };
43
- export type FieldChain<TType extends FieldTypeFinal> = Field<TType> & {
44
- unique(): FieldChain<TType>;
45
- required(): FieldChain<TType>;
46
- optional(): FieldChain<TType>;
47
- primary(): FieldChain<TType>;
48
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- export * from "./collections";
2
- export * from "./config";
3
- export * from "./drizzle";
4
- export * from "./dsl";
5
- export * from "./fields";
6
- export * from "./next";
7
- export * from "./plugins";
8
- export * from "./providers";
package/dist/esm/index.js DELETED
@@ -1,8 +0,0 @@
1
- export * from "./collections";
2
- export * from "./config";
3
- export * from "./drizzle";
4
- export * from "./dsl";
5
- export * from "./fields";
6
- export * from "./next";
7
- export * from "./plugins";
8
- export * from "./providers";
@@ -1,5 +0,0 @@
1
- import type { NextConfig } from "next";
2
- declare global {
3
- var __collections_worker_started: boolean | undefined;
4
- }
5
- export declare const withCollections: (phase: string, config: NextConfig) => NextConfig;
@@ -1,17 +0,0 @@
1
- import { spawn } from "child_process";
2
- import { PHASE_DEVELOPMENT_SERVER } from "next/constants";
3
- import path from "path";
4
- export const withCollections = (phase, config) => {
5
- const isDev = phase === PHASE_DEVELOPMENT_SERVER;
6
- if (isDev && !global.__collections_worker_started) {
7
- global.__collections_worker_started = true;
8
- const workerPath = path.join(__dirname, "../worker/index.js");
9
- console.log("[withCollections] Spawning background worker:", workerPath);
10
- spawn("node", [workerPath], {
11
- stdio: "inherit",
12
- });
13
- }
14
- return {
15
- ...config,
16
- };
17
- };
@@ -1,2 +0,0 @@
1
- import { Plugin } from "./types";
2
- export declare const plugin: () => Plugin;
@@ -1,3 +0,0 @@
1
- export const plugin = () => {
2
- return {};
3
- };
@@ -1 +0,0 @@
1
- export type Plugin = {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { Provider } from "./types";
2
- export declare const inAppProvider: () => Provider;
@@ -1,53 +0,0 @@
1
- export const inAppProvider = () => {
2
- // Stockage en mémoire : { "posts": { "id_1": { ...data }, "id_2": { ...data } } }
3
- const storage = {};
4
- return {
5
- // L'init reçoit maintenant la liste des collections pour préparer le "schéma"
6
- init: (collections) => {
7
- console.log("Initializing in-app provider");
8
- for (const col of collections) {
9
- // On initialise un "bucket" vide pour chaque collection si pas déjà fait
10
- if (!storage[col.slug]) {
11
- storage[col.slug] = {};
12
- }
13
- }
14
- },
15
- create: async (collectionSlug, data) => {
16
- // Simulation d'un ID (dans une vraie DB, c'est géré par le moteur ou UUID)
17
- const id = Math.random().toString(36).substring(2, 15);
18
- const record = { ...data, id };
19
- // Sécurité au cas où on écrit dans une collection non initialisée
20
- if (!storage[collectionSlug])
21
- storage[collectionSlug] = {};
22
- storage[collectionSlug][id] = record;
23
- return record;
24
- },
25
- read: async (collectionSlug, id) => {
26
- const record = storage[collectionSlug]?.[id];
27
- if (!record) {
28
- throw new Error(`Record with ID "${id}" not found in "${collectionSlug}".`);
29
- }
30
- return record;
31
- },
32
- update: async (collectionSlug, id, data) => {
33
- const existing = storage[collectionSlug]?.[id];
34
- if (!existing) {
35
- throw new Error(`Cannot update: Record with ID "${id}" not found in "${collectionSlug}".`);
36
- }
37
- // Fusion des données (Partial update)
38
- const updated = { ...existing, ...data };
39
- storage[collectionSlug][id] = updated;
40
- return updated;
41
- },
42
- delete: async (collectionSlug, id) => {
43
- if (storage[collectionSlug] && storage[collectionSlug][id]) {
44
- delete storage[collectionSlug][id];
45
- }
46
- else {
47
- // Optionnel : Throw une erreur si l'item n'existe pas,
48
- // ou juste ignorer comme le ferait une requête SQL "DELETE WHERE ID=..."
49
- console.warn(`Attempted to delete non-existent record "${id}" in "${collectionSlug}"`);
50
- }
51
- }
52
- };
53
- };
@@ -1,8 +0,0 @@
1
- import { Collection } from "../collections/types";
2
- export type Provider = {
3
- init: (collections: readonly Collection[]) => Promise<void> | void;
4
- create: (collectionSlug: string, data: any) => Promise<any>;
5
- read: (collectionSlug: string, id: string) => Promise<any>;
6
- update: (collectionSlug: string, id: string, data: any) => Promise<any>;
7
- delete: (collectionSlug: string, id: string) => Promise<void>;
8
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export type DeepPartial<T> = T extends (infer U)[] ? DeepPartial<U>[] : T extends object ? {
2
- [K in keyof T]?: DeepPartial<T[K]>;
3
- } : T;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- type Exact<A, B> = A extends B ? Exclude<keyof A, keyof B> extends never ? A : never : never;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { Collection } from "../collections/types";
2
- export declare const loadCollections: () => Promise<Collection[]>;
@@ -1,32 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { generateShadowSchema } from "../drizzle/generate";
4
- // Dossier des collections
5
- const collectionsDir = path.join(process.cwd(), "src", "collections");
6
- console.log(`[worker] Loading collections from ${collectionsDir}`);
7
- // Fonction pour importer toutes les collections
8
- export const loadCollections = async () => {
9
- const files = fs
10
- .readdirSync(collectionsDir)
11
- .filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
12
- const collections = [];
13
- for (const file of files) {
14
- const fullPath = path.join(collectionsDir, file);
15
- // Utilisation de import dynamique
16
- const module = await import(fullPath);
17
- // On suppose que la collection exporte toujours une const (ex: Posts)
18
- for (const exported of Object.values(module)) {
19
- const col = exported;
20
- if (col?.slug && col?.fields) {
21
- collections.push(col);
22
- }
23
- }
24
- }
25
- return collections;
26
- };
27
- // Exemple d'utilisation
28
- (async () => {
29
- const collections = await loadCollections();
30
- generateShadowSchema(collections);
31
- console.log(`[worker] Shadow schema generated for ${collections.length} collections.`);
32
- })();
@@ -1,6 +0,0 @@
1
- import { Field, FieldChain, FieldTypeFinal } from "./types";
2
- export declare const unique: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
3
- export declare const required: <TType extends FieldTypeFinal>(field: Field<TType>) => Field<TType>;
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>;
6
- export declare const attachChain: <TType extends FieldTypeFinal>(f: Field<TType>) => FieldChain<TType>;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attachChain = exports.primary = exports.optional = exports.required = exports.unique = void 0;
4
- const unique = (field) => {
5
- return {
6
- ...field,
7
- type: {
8
- ...field.type,
9
- dsl: {
10
- ...field.type.dsl,
11
- isUnique: true,
12
- },
13
- },
14
- };
15
- };
16
- exports.unique = unique;
17
- const required = (field) => ({
18
- ...field,
19
- type: {
20
- ...field.type,
21
- dsl: {
22
- ...field.type.dsl,
23
- canBeNull: false,
24
- },
25
- },
26
- });
27
- exports.required = required;
28
- const optional = (field) => ({
29
- ...field,
30
- type: {
31
- ...field.type,
32
- dsl: {
33
- ...field.type.dsl,
34
- canBeNull: true,
35
- },
36
- },
37
- });
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;
50
- const attachChain = (f) => {
51
- return {
52
- ...f,
53
- unique() {
54
- return (0, exports.attachChain)((0, exports.unique)(f));
55
- },
56
- required() {
57
- return (0, exports.attachChain)((0, exports.required)(f));
58
- },
59
- optional() {
60
- return (0, exports.attachChain)((0, exports.optional)(f));
61
- },
62
- primary() {
63
- return (0, exports.attachChain)((0, exports.primary)(f));
64
- },
65
- };
66
- };
67
- exports.attachChain = attachChain;
@@ -1,71 +0,0 @@
1
- export declare const number: (params?: {
2
- min?: number | undefined;
3
- max?: number | undefined;
4
- } | undefined) => {
5
- kind: import("./types").FieldKind;
6
- params: unknown;
7
- dsl: {
8
- kind: import("./types").FieldKind;
9
- isPrimary: boolean;
10
- isUnique: boolean;
11
- canBeNull: boolean;
12
- };
13
- admin: {
14
- component: any;
15
- };
16
- };
17
- export declare const text: (params?: {
18
- min?: number | undefined;
19
- max?: number | undefined;
20
- } | undefined) => {
21
- kind: import("./types").FieldKind;
22
- params: unknown;
23
- dsl: {
24
- kind: import("./types").FieldKind;
25
- isPrimary: boolean;
26
- isUnique: boolean;
27
- canBeNull: boolean;
28
- };
29
- admin: {
30
- component: any;
31
- };
32
- };
33
- export declare const uuid: (params?: void | undefined) => {
34
- kind: import("./types").FieldKind;
35
- params: unknown;
36
- dsl: {
37
- kind: import("./types").FieldKind;
38
- isPrimary: boolean;
39
- isUnique: boolean;
40
- canBeNull: boolean;
41
- };
42
- admin: {
43
- component: any;
44
- };
45
- };
46
- export declare const timestamp: (params?: void | undefined) => {
47
- kind: import("./types").FieldKind;
48
- params: unknown;
49
- dsl: {
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;
64
- isPrimary: boolean;
65
- isUnique: boolean;
66
- canBeNull: boolean;
67
- };
68
- admin: {
69
- component: any;
70
- };
71
- };
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.serial = exports.timestamp = exports.uuid = exports.text = exports.number = void 0;
7
- const zod_1 = __importDefault(require("zod"));
8
- const field_1 = require("./field");
9
- exports.number = (0, field_1.fieldType)({
10
- schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
11
- dsl: { kind: "numeric" },
12
- admin: { component: undefined },
13
- });
14
- exports.text = (0, field_1.fieldType)({
15
- schema: zod_1.default.object({ min: zod_1.default.number().optional(), max: zod_1.default.number().optional() }),
16
- dsl: { kind: "text" },
17
- admin: { component: undefined },
18
- });
19
- exports.uuid = (0, field_1.fieldType)({
20
- schema: zod_1.default.void(),
21
- dsl: { kind: "uuid" },
22
- admin: { component: undefined },
23
- });
24
- exports.timestamp = (0, field_1.fieldType)({
25
- schema: zod_1.default.void(),
26
- dsl: { kind: "timestamp" },
27
- admin: { component: undefined },
28
- });
29
- exports.serial = (0, field_1.fieldType)({
30
- schema: zod_1.default.void(),
31
- dsl: { kind: "serial" },
32
- admin: { component: undefined },
33
- });
@@ -1,24 +0,0 @@
1
- import z from "zod";
2
- import { FieldChain, FieldConfig, FieldKind, FieldTypeFinal } from "./types";
3
- export declare const fieldType: <TOutput, TParams extends z.ZodType | undefined>(config: {
4
- schema?: TParams;
5
- dsl: {
6
- kind: FieldKind;
7
- };
8
- admin: {
9
- component: any;
10
- };
11
- }) => (params?: TParams extends z.ZodType ? z.infer<TParams> : undefined) => {
12
- kind: FieldKind;
13
- params: unknown;
14
- dsl: {
15
- kind: FieldKind;
16
- isPrimary: boolean;
17
- isUnique: boolean;
18
- canBeNull: boolean;
19
- };
20
- admin: {
21
- component: any;
22
- };
23
- };
24
- export declare const field: <TType extends FieldTypeFinal>(config: FieldConfig<TType>) => FieldChain<TType>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.field = exports.fieldType = void 0;
4
- const constraints_1 = require("./constraints");
5
- const fieldType = (config) => (params) => {
6
- const validated = config.schema && params !== undefined
7
- ? config.schema.parse(params)
8
- : params;
9
- return {
10
- kind: config.dsl.kind,
11
- params: validated,
12
- dsl: {
13
- kind: config.dsl.kind,
14
- isPrimary: false,
15
- isUnique: false,
16
- canBeNull: true,
17
- },
18
- admin: config.admin,
19
- };
20
- };
21
- exports.fieldType = fieldType;
22
- const defaultPermissions = {
23
- create: async () => true,
24
- read: async () => true,
25
- update: async () => true,
26
- delete: async () => true,
27
- };
28
- const field = (config) => {
29
- const base = {
30
- type: config.type,
31
- permissions: {
32
- ...defaultPermissions,
33
- ...config.permissions,
34
- },
35
- };
36
- return (0, constraints_1.attachChain)(base);
37
- };
38
- exports.field = field;
@@ -1,4 +0,0 @@
1
- export * from './field';
2
- export * from './types';
3
- export * from './core';
4
- export * from './constraints';