cogsbox-shape 0.5.79 → 0.5.81
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 +4 -4
- package/dist/schema.js +1 -1
- package/package.json +1 -1
package/dist/schema.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ type SQLToZodType<T extends SQLType, TDefault extends boolean> = T["pk"] extends
|
|
|
37
37
|
} ? TDefault extends true ? never : z.ZodDate : z.ZodDate : never;
|
|
38
38
|
type ZodTypeFromPrimitive<T> = T extends string ? z.ZodString : T extends number ? z.ZodNumber : T extends boolean ? z.ZodBoolean : T extends Date ? z.ZodDate : z.ZodAny;
|
|
39
39
|
type IsLiteralType<T> = T extends string ? string extends T ? false : true : T extends number ? number extends T ? false : true : T extends boolean ? boolean extends T ? false : true : false;
|
|
40
|
-
interface IBuilderMethods<T extends SQLType | RelationConfig<any>, TSql extends z.ZodTypeAny, TNew extends z.ZodTypeAny, TInitialValue, TClient extends z.ZodTypeAny, TValidation extends z.ZodTypeAny> {
|
|
40
|
+
export interface IBuilderMethods<T extends SQLType | RelationConfig<any>, TSql extends z.ZodTypeAny, TNew extends z.ZodTypeAny, TInitialValue, TClient extends z.ZodTypeAny, TValidation extends z.ZodTypeAny> {
|
|
41
41
|
initialState: {
|
|
42
42
|
<const TResult>(defaultValue: TResult): TResult extends () => infer R ? R extends z.ZodTypeAny ? Prettify<Builder<"new", T, TSql, R, z.infer<R>, InferSmartClientType<TSql, R>, InferSmartClientType<TSql, R>>> : Prettify<Builder<"new", T, TSql, z.ZodLiteral<R>, R, z.ZodUnion<[TSql, z.ZodLiteral<R>]>, z.ZodUnion<[TSql, z.ZodLiteral<R>]>>> : TResult extends z.ZodTypeAny ? Prettify<Builder<"new", T, TSql, TResult, z.infer<TResult>, InferSmartClientType<TSql, TResult>, InferSmartClientType<TSql, TResult>>> : TResult extends string | number | boolean ? Prettify<Builder<"new", T, TSql, z.ZodLiteral<TResult>, TResult, z.ZodUnion<[TSql, z.ZodLiteral<TResult>]>, z.ZodUnion<[TSql, z.ZodLiteral<TResult>]>>> : Prettify<Builder<"new", T, TSql, ZodTypeFromPrimitive<TResult>, TResult, InferSmartClientType<TSql, ZodTypeFromPrimitive<TResult>>, InferSmartClientType<TSql, ZodTypeFromPrimitive<TResult>>>>;
|
|
43
43
|
<TNewNext extends z.ZodTypeAny, const TDefaultNext>(schema: ((tools: {
|
|
@@ -139,17 +139,17 @@ interface ShapeAPI {
|
|
|
139
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>>>;
|
|
140
140
|
}
|
|
141
141
|
export declare const s: ShapeAPI;
|
|
142
|
-
type EnrichedField<K extends string, V, TSchema extends ShapeSchema> = V & {
|
|
142
|
+
export type EnrichedField<K extends string, V, TSchema extends ShapeSchema> = V & {
|
|
143
143
|
__meta: {
|
|
144
144
|
_key: K;
|
|
145
145
|
_fieldType: V;
|
|
146
146
|
};
|
|
147
147
|
__parentTableType: TSchema;
|
|
148
148
|
};
|
|
149
|
-
type EnrichFields<T extends ShapeSchema> = {
|
|
149
|
+
export type EnrichFields<T extends ShapeSchema> = {
|
|
150
150
|
[K in keyof T]: K extends string ? EnrichedField<K, T[K], T> : T[K];
|
|
151
151
|
};
|
|
152
|
-
declare const SchemaWrapperBrand: unique symbol;
|
|
152
|
+
export declare const SchemaWrapperBrand: unique symbol;
|
|
153
153
|
export declare function schema<T extends ShapeSchema>(schema: T): EnrichFields<T> & {
|
|
154
154
|
_tableName: T["_tableName"];
|
|
155
155
|
[SchemaWrapperBrand]: true;
|
package/dist/schema.js
CHANGED
|
@@ -269,7 +269,7 @@ function createBuilder(config) {
|
|
|
269
269
|
return builderObject;
|
|
270
270
|
}
|
|
271
271
|
// The table function that enriches fields with their key information
|
|
272
|
-
const SchemaWrapperBrand = Symbol("SchemaWrapper");
|
|
272
|
+
export const SchemaWrapperBrand = Symbol("SchemaWrapper");
|
|
273
273
|
// Update the schema function to use the symbol
|
|
274
274
|
export function schema(schema) {
|
|
275
275
|
const enrichedSchema = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogsbox-shape",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.81",
|
|
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",
|