cogsbox-shape 0.5.74 → 0.5.76

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/schema.d.ts CHANGED
@@ -30,25 +30,6 @@ export type SQLType = ({
30
30
  }) & {
31
31
  pk?: true;
32
32
  };
33
- type BaseConfig = {
34
- nullable?: boolean;
35
- pk?: true;
36
- field?: string;
37
- };
38
- type IntConfig = BaseConfig & {
39
- default?: number;
40
- };
41
- type BooleanConfig = BaseConfig & {
42
- default?: boolean;
43
- };
44
- type DateConfig = BaseConfig & {
45
- type?: "date" | "datetime";
46
- default?: Date;
47
- };
48
- type StringConfig = BaseConfig & {
49
- length?: number;
50
- default?: string;
51
- };
52
33
  type SQLToZodType<T extends SQLType, TDefault extends boolean> = T["pk"] extends true ? TDefault extends true ? z.ZodString : z.ZodNumber : T["nullable"] extends true ? T["type"] extends "varchar" | "char" | "text" | "longtext" ? z.ZodNullable<z.ZodString> : T["type"] extends "int" ? z.ZodNullable<z.ZodNumber> : T["type"] extends "boolean" ? z.ZodNullable<z.ZodBoolean> : T["type"] extends "date" | "datetime" ? T extends {
53
34
  default: "CURRENT_TIMESTAMP";
54
35
  } ? TDefault extends true ? never : z.ZodNullable<z.ZodDate> : z.ZodNullable<z.ZodDate> : never : T["type"] extends "varchar" | "char" | "text" | "longtext" ? z.ZodString : T["type"] extends "int" ? z.ZodNumber : T["type"] extends "boolean" ? z.ZodBoolean : T["type"] extends "date" | "datetime" ? T extends {
@@ -138,14 +119,6 @@ export type Builder<TStage extends Stage, T extends SQLType | RelationConfig<any
138
119
  };
139
120
  } & Pick<IBuilderMethods<T, TSql, TNew, TInitialValue, TClient, TValidation>, StageMethods[TStage]>;
140
121
  interface ShapeAPI {
141
- int: (config?: IntConfig) => ReturnType<typeof createBuilder>;
142
- varchar: (config?: Omit<StringConfig, "type">) => ReturnType<typeof createBuilder>;
143
- char: (config?: Omit<StringConfig, "type">) => ReturnType<typeof createBuilder>;
144
- text: (config?: Omit<StringConfig, "type" | "length">) => ReturnType<typeof createBuilder>;
145
- longtext: (config?: Omit<StringConfig, "type" | "length">) => ReturnType<typeof createBuilder>;
146
- boolean: (config?: BooleanConfig) => ReturnType<typeof createBuilder>;
147
- date: (config?: Omit<DateConfig, "type">) => ReturnType<typeof createBuilder>;
148
- datetime: (config?: Omit<DateConfig, "type">) => ReturnType<typeof createBuilder>;
149
122
  sql: <T extends SQLType>(sqlConfig: T) => Builder<"sql", T, SQLToZodType<T, false>, SQLToZodType<T, false>, z.infer<SQLToZodType<T, false>>, SQLToZodType<T, false>, SQLToZodType<T, false>>;
150
123
  hasMany: <T extends Schema<any>, CreateSchema extends ReturnType<typeof createSchema<T>>>(config: {
151
124
  fromKey: string;
@@ -166,18 +139,6 @@ interface ShapeAPI {
166
139
  }) => Builder<"relation", RelationConfig<T>, z.ZodOptional<z.ZodArray<z.ZodAny>>, z.ZodOptional<z.ZodArray<z.ZodAny>>, any[], z.ZodOptional<z.ZodArray<z.ZodAny>>, z.ZodOptional<z.ZodArray<z.ZodAny>>>;
167
140
  }
168
141
  export declare const s: ShapeAPI;
169
- declare function createBuilder<TStage extends "sql" | "relation" | "new" | "client" | "validation", T extends SQLType | RelationConfig<any>, TSql extends z.ZodTypeAny, TNew extends z.ZodTypeAny, TInitialValue, TClient extends z.ZodTypeAny, TValidation extends z.ZodTypeAny>(config: {
170
- stage: TStage;
171
- sqlConfig: T;
172
- sqlZod: TSql;
173
- newZod: TNew;
174
- initialValue: TInitialValue;
175
- clientZod: TClient;
176
- validationZod: TValidation;
177
- completedStages?: Set<string>;
178
- clientTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
179
- validationTransform?: (schema: z.ZodTypeAny) => z.ZodTypeAny;
180
- }): Builder<TStage, T, TSql, TNew, TInitialValue, TClient, TValidation>;
181
142
  type EnrichedField<K extends string, V, TSchema extends ShapeSchema> = V & {
182
143
  __meta: {
183
144
  _key: K;
package/dist/schema.js CHANGED
@@ -9,38 +9,46 @@ export function currentTimeStamp() {
9
9
  }
10
10
  // Now define the shape object with the explicit type annotation
11
11
  export const s = {
12
- int: (config = {}) => s.sql({
13
- type: "int",
14
- ...config,
15
- }),
16
- varchar: (config = {}) => s.sql({
17
- type: "varchar",
18
- ...config,
19
- }),
20
- char: (config = {}) => s.sql({
21
- type: "char",
22
- ...config,
23
- }),
24
- text: (config = {}) => s.sql({
25
- type: "text",
26
- ...config,
27
- }),
28
- longtext: (config = {}) => s.sql({
29
- type: "longtext",
30
- ...config,
31
- }),
32
- boolean: (config = {}) => s.sql({
33
- type: "boolean",
34
- ...config,
35
- }),
36
- date: (config = {}) => s.sql({
37
- type: "date",
38
- ...config,
39
- }),
40
- datetime: (config = {}) => s.sql({
41
- type: "datetime",
42
- ...config,
43
- }),
12
+ // int: (config: IntConfig = {}) =>
13
+ // s.sql({
14
+ // type: "int",
15
+ // ...config,
16
+ // }),
17
+ // varchar: (config: Omit<StringConfig, "type"> = {}) =>
18
+ // s.sql({
19
+ // type: "varchar",
20
+ // ...config,
21
+ // }),
22
+ // char: (config: Omit<StringConfig, "type"> = {}) =>
23
+ // s.sql({
24
+ // type: "char",
25
+ // ...config,
26
+ // }),
27
+ // text: (config: Omit<StringConfig, "type" | "length"> = {}) =>
28
+ // s.sql({
29
+ // type: "text",
30
+ // ...config,
31
+ // }),
32
+ // longtext: (config: Omit<StringConfig, "type" | "length"> = {}) =>
33
+ // s.sql({
34
+ // type: "longtext",
35
+ // ...config,
36
+ // }),
37
+ // boolean: (config: BooleanConfig = {}) =>
38
+ // s.sql({
39
+ // type: "boolean",
40
+ // ...config,
41
+ // }),
42
+ // date: (config: Omit<DateConfig, "type"> = {}) =>
43
+ // s.sql({
44
+ // type: "date",
45
+ // ...config,
46
+ // }),
47
+ // datetime: (config: Omit<DateConfig, "type"> = {}) =>
48
+ // s.sql({
49
+ // type: "datetime",
50
+ // ...config,
51
+ // }),
44
52
  sql: (sqlConfig) => {
45
53
  const sqlZodType = (() => {
46
54
  let baseType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.74",
3
+ "version": "0.5.76",
4
4
  "description": "A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for relationships and serialization.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",