@danceroutine/tango-schema 1.11.1 → 1.11.3
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/chunk-D7D4PA-g.js +13 -0
- package/dist/domain/index.d.ts +2 -13
- package/dist/domain/index.js +7 -1
- package/dist/domain/index.js.map +1 -0
- package/dist/index-Bhh0b304.d.ts +246 -0
- package/dist/index-DXFf5XNn.d.ts +747 -0
- package/dist/index.d.ts +3 -9
- package/dist/index.js +3 -4
- package/dist/model/index.d.ts +3 -25
- package/dist/model/index.js +2 -3
- package/dist/{model-upj6jxaK.js → model-aRAusQPz.js} +199 -175
- package/dist/model-aRAusQPz.js.map +1 -0
- package/package.json +3 -3
- package/dist/domain/DeleteReferentialAction.d.ts +0 -1
- package/dist/domain/Field.d.ts +0 -20
- package/dist/domain/FieldType.d.ts +0 -2
- package/dist/domain/IndexDef.d.ts +0 -6
- package/dist/domain/Model.d.ts +0 -35
- package/dist/domain/ModelMetadata.d.ts +0 -16
- package/dist/domain/ModelWriteHooks.d.ts +0 -96
- package/dist/domain/RelationDef.d.ts +0 -7
- package/dist/domain/RelationType.d.ts +0 -2
- package/dist/domain/UpdateReferentialAction.d.ts +0 -1
- package/dist/domain/internal/InternalFieldType.d.ts +0 -10
- package/dist/domain/internal/InternalReferentialAction.d.ts +0 -6
- package/dist/domain/internal/InternalRelationType.d.ts +0 -5
- package/dist/domain/internal/zod/hasConstructorName.d.ts +0 -1
- package/dist/domain/internal/zod/index.d.ts +0 -13
- package/dist/domain/internal/zod/isDate.d.ts +0 -1
- package/dist/domain/internal/zod/isZodArray.d.ts +0 -2
- package/dist/domain/internal/zod/isZodBoolean.d.ts +0 -2
- package/dist/domain/internal/zod/isZodDate.d.ts +0 -2
- package/dist/domain/internal/zod/isZodDefault.d.ts +0 -2
- package/dist/domain/internal/zod/isZodNullable.d.ts +0 -2
- package/dist/domain/internal/zod/isZodNumber.d.ts +0 -2
- package/dist/domain/internal/zod/isZodObject.d.ts +0 -2
- package/dist/domain/internal/zod/isZodOptional.d.ts +0 -2
- package/dist/domain/internal/zod/isZodString.d.ts +0 -2
- package/dist/domain-Cufz6y1q.js +0 -7
- package/dist/domain-Cufz6y1q.js.map +0 -1
- package/dist/model/Model.d.ts +0 -11
- package/dist/model/ModelAugmentorRegistry.d.ts +0 -11
- package/dist/model/ModelDefinition.d.ts +0 -23
- package/dist/model/constraints/Constraints.d.ts +0 -19
- package/dist/model/constraints/Indexes.d.ts +0 -4
- package/dist/model/constraints/index.d.ts +0 -6
- package/dist/model/decorators/Decorators.d.ts +0 -83
- package/dist/model/decorators/domain/DecoratedFieldKind.d.ts +0 -6
- package/dist/model/decorators/domain/ModelRef.d.ts +0 -11
- package/dist/model/decorators/domain/RelationDecoratedSchema.d.ts +0 -24
- package/dist/model/decorators/domain/RelationDecoratorConfig.d.ts +0 -39
- package/dist/model/decorators/domain/TangoFieldMeta.d.ts +0 -89
- package/dist/model/decorators/domain/ZodTypeAny.d.ts +0 -2
- package/dist/model/decorators/index.d.ts +0 -13
- package/dist/model/fields/FieldMetadataStore.d.ts +0 -4
- package/dist/model/fields/FinalizedStorageArtifacts.d.ts +0 -11
- package/dist/model/fields/inferFieldsFromSchema.d.ts +0 -15
- package/dist/model/internal/InternalSchemaModel.d.ts +0 -29
- package/dist/model/meta/Meta.d.ts +0 -22
- package/dist/model/meta/index.d.ts +0 -5
- package/dist/model/registry/GeneratedRelationRegistryArtifact.d.ts +0 -10
- package/dist/model/registry/ModelRegistry.d.ts +0 -129
- package/dist/model/registry/ResolvedRelationGraphArtifactFactory.d.ts +0 -13
- package/dist/model/registry/ResolvedRelationGraphSnapshot.d.ts +0 -110
- package/dist/model/registry/index.d.ts +0 -8
- package/dist/model/relations/ImplicitManyToManyIdentifier.d.ts +0 -45
- package/dist/model/relations/ImplicitManyToManyThroughFactory.d.ts +0 -14
- package/dist/model/relations/NormalizedRelationStorageDescriptor.d.ts +0 -36
- package/dist/model/relations/RelationBuilder.d.ts +0 -19
- package/dist/model/relations/RelationDescriptorNormalizer.d.ts +0 -30
- package/dist/model/relations/RelationSpec.d.ts +0 -48
- package/dist/model/relations/ResolvedRelationGraph.d.ts +0 -49
- package/dist/model/relations/ResolvedRelationGraphBuilder.d.ts +0 -54
- package/dist/model/relations/SchemaNaming.d.ts +0 -12
- package/dist/model/relations/index.d.ts +0 -13
- package/dist/model-upj6jxaK.js.map +0 -1
- package/dist/resolveSchemaModuleEntrypoint.d.ts +0 -20
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain boundary barrel: centralizes this subdomain's public contract.
|
|
3
|
-
*/
|
|
4
|
-
export { isDate } from './isDate';
|
|
5
|
-
export { isZodArray } from './isZodArray';
|
|
6
|
-
export { isZodBoolean } from './isZodBoolean';
|
|
7
|
-
export { isZodDate } from './isZodDate';
|
|
8
|
-
export { isZodDefault } from './isZodDefault';
|
|
9
|
-
export { isZodNullable } from './isZodNullable';
|
|
10
|
-
export { isZodNumber } from './isZodNumber';
|
|
11
|
-
export { isZodObject } from './isZodObject';
|
|
12
|
-
export { isZodOptional } from './isZodOptional';
|
|
13
|
-
export { isZodString } from './isZodString';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isDate(value: unknown): value is Date;
|
package/dist/domain-Cufz6y1q.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domain-Cufz6y1q.js","names":[],"sources":["../src/domain/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport type { FieldType } from './FieldType';\nexport type { DeleteReferentialAction } from './DeleteReferentialAction';\nexport type { UpdateReferentialAction } from './UpdateReferentialAction';\nexport type { RelationType } from './RelationType';\nexport type { Field } from './Field';\nexport type { IndexDef } from './IndexDef';\nexport type { RelationDef } from './RelationDef';\nexport type { ModelMetadata } from './ModelMetadata';\nexport type { Model, ModelAugmentations, ModelKeyOf, PersistedModelOutput } from './Model';\nexport type {\n ModelHookModel,\n ModelWriteHookOnCommitOptions,\n ModelWriteHookManager,\n ModelWriteHookTransaction,\n ModelWriteHooks,\n BeforeCreateHookArgs,\n AfterCreateHookArgs,\n BeforeUpdateHookArgs,\n AfterUpdateHookArgs,\n BeforeDeleteHookArgs,\n AfterDeleteHookArgs,\n BeforeBulkCreateHookArgs,\n AfterBulkCreateHookArgs,\n} from './ModelWriteHooks';\n"],"mappings":""}
|
package/dist/model/Model.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Model as SchemaModel } from '../domain/Model';
|
|
3
|
-
import type { ModelDefinition } from './ModelDefinition';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a model definition with metadata and schema validation.
|
|
6
|
-
* Automatically finalizes field types through the owning model registry.
|
|
7
|
-
*/
|
|
8
|
-
export declare function Model<const TNamespace extends string, const TName extends string, TSchema extends z.ZodObject<z.ZodRawShape>>(definition: ModelDefinition<TSchema> & {
|
|
9
|
-
namespace: TNamespace;
|
|
10
|
-
name: TName;
|
|
11
|
-
}): SchemaModel<TSchema, `${TNamespace}/${TName}`>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { z } from 'zod';
|
|
2
|
-
import type { Model } from '../domain/Model';
|
|
3
|
-
export type ModelAugmentor = <TSchema extends z.ZodObject<z.ZodRawShape>, TKey extends string>(model: Model<TSchema, TKey>) => void;
|
|
4
|
-
/**
|
|
5
|
-
* Register a model augmentor that runs for existing and future models.
|
|
6
|
-
*/
|
|
7
|
-
export declare function registerModelAugmentor(augmentor: ModelAugmentor): () => void;
|
|
8
|
-
/**
|
|
9
|
-
* Apply all registered augmentors to a model before it is returned publicly.
|
|
10
|
-
*/
|
|
11
|
-
export declare function applyModelAugmentors<TSchema extends z.ZodObject<z.ZodRawShape>, TKey extends string>(model: Model<TSchema, TKey>): Model<TSchema, TKey>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Field, IndexDef, PersistedModelOutput, RelationDef } from '../domain/index';
|
|
3
|
-
import type { ModelWriteHooks } from '../domain/index';
|
|
4
|
-
import type { RelationBuilder } from './relations/RelationBuilder';
|
|
5
|
-
import type { ModelRegistry } from './registry/ModelRegistry';
|
|
6
|
-
export interface ModelDefinition<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
7
|
-
namespace: string;
|
|
8
|
-
name: string;
|
|
9
|
-
table?: string;
|
|
10
|
-
schema: TSchema;
|
|
11
|
-
registry?: ModelRegistry;
|
|
12
|
-
fields?: Field[];
|
|
13
|
-
indexes?: IndexDef[];
|
|
14
|
-
relations?: (builder: RelationBuilder) => Record<string, RelationDef>;
|
|
15
|
-
ordering?: string[];
|
|
16
|
-
managed?: boolean;
|
|
17
|
-
defaultRelatedName?: string;
|
|
18
|
-
constraints?: unknown[];
|
|
19
|
-
/**
|
|
20
|
-
* Model-owned write lifecycle hooks that run inside `Model.objects`.
|
|
21
|
-
*/
|
|
22
|
-
hooks?: ModelWriteHooks<PersistedModelOutput<TSchema>>;
|
|
23
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type ConstraintDefinition = {
|
|
2
|
-
kind: string;
|
|
3
|
-
[key: string]: unknown;
|
|
4
|
-
};
|
|
5
|
-
export declare const Constraints: {
|
|
6
|
-
unique(fields: string[], options?: {
|
|
7
|
-
name?: string;
|
|
8
|
-
where?: string;
|
|
9
|
-
}): ConstraintDefinition;
|
|
10
|
-
check(condition: string, options?: {
|
|
11
|
-
name?: string;
|
|
12
|
-
}): ConstraintDefinition;
|
|
13
|
-
exclusion(definition: {
|
|
14
|
-
using?: string;
|
|
15
|
-
elements: string[];
|
|
16
|
-
where?: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
}): ConstraintDefinition;
|
|
19
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { ZodTypeAny } from './domain/ZodTypeAny';
|
|
3
|
-
import { type ModelRef, type ModelRefTarget, type TypedModelRef } from './domain/ModelRef';
|
|
4
|
-
import type { ReferentialOptions } from './domain/TangoFieldMeta';
|
|
5
|
-
import type { Model, ModelKeyOf } from '../../domain';
|
|
6
|
-
import type { ForeignKeyDecoratorConfig, ManyToManyDecoratorConfig, OneToOneDecoratorConfig } from './domain/RelationDecoratorConfig';
|
|
7
|
-
import type { RelationDecoratedSchema } from './domain/RelationDecoratedSchema';
|
|
8
|
-
export interface FieldDecoratorBuilder<TField extends ZodTypeAny> {
|
|
9
|
-
defaultValue(value: string | {
|
|
10
|
-
now: true;
|
|
11
|
-
} | null): FieldDecoratorBuilder<TField>;
|
|
12
|
-
dbDefault(value: string): FieldDecoratorBuilder<TField>;
|
|
13
|
-
dbColumn(name: string): FieldDecoratorBuilder<TField>;
|
|
14
|
-
dbIndex(): FieldDecoratorBuilder<TField>;
|
|
15
|
-
choices(values: readonly unknown[]): FieldDecoratorBuilder<TField>;
|
|
16
|
-
validators(...values: readonly ((value: unknown) => unknown)[]): FieldDecoratorBuilder<TField>;
|
|
17
|
-
helpText(text: string): FieldDecoratorBuilder<TField>;
|
|
18
|
-
errorMessages(map: Record<string, string>): FieldDecoratorBuilder<TField>;
|
|
19
|
-
build(): TField;
|
|
20
|
-
}
|
|
21
|
-
type ConfigName<TConfig> = TConfig extends {
|
|
22
|
-
name: infer TName extends string;
|
|
23
|
-
} ? TName : undefined;
|
|
24
|
-
type ConfigRelatedName<TConfig> = TConfig extends {
|
|
25
|
-
relatedName: infer TRelatedName extends string;
|
|
26
|
-
} ? TRelatedName : undefined;
|
|
27
|
-
type UnaryFieldDecorator = {
|
|
28
|
-
<T extends ZodTypeAny>(schema: T): T;
|
|
29
|
-
<T extends ZodTypeAny>(): (input: T) => T;
|
|
30
|
-
};
|
|
31
|
-
type RelationshipDecorator = {
|
|
32
|
-
<TRef extends ModelRef, T extends ZodTypeAny, const TConfig extends ForeignKeyDecoratorConfig<T> & {
|
|
33
|
-
field: T;
|
|
34
|
-
}>(target: TRef, config: TConfig): RelationDecoratedSchema<T, 'foreignKey', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
35
|
-
<TRef extends ModelRef, const TConfig extends ForeignKeyDecoratorConfig<z.ZodNumber> | undefined>(target: TRef, config?: TConfig): RelationDecoratedSchema<z.ZodNumber, 'foreignKey', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Use `t.foreignKey(target, { field: schema, ...options })` instead.
|
|
38
|
-
*/
|
|
39
|
-
<T extends ZodTypeAny>(target: ModelRef, schema: T, options?: ReferentialOptions): RelationDecoratedSchema<T, 'foreignKey'>;
|
|
40
|
-
};
|
|
41
|
-
type OneToOneRelationshipDecorator = {
|
|
42
|
-
<TRef extends ModelRef, T extends ZodTypeAny, const TConfig extends OneToOneDecoratorConfig<T> & {
|
|
43
|
-
field: T;
|
|
44
|
-
}>(target: TRef, config: TConfig): RelationDecoratedSchema<T, 'oneToOne', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
45
|
-
<TRef extends ModelRef, const TConfig extends OneToOneDecoratorConfig<z.ZodNumber> | undefined>(target: TRef, config?: TConfig): RelationDecoratedSchema<z.ZodNumber, 'oneToOne', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Use `t.oneToOne(target, { field: schema, ...options })` instead.
|
|
48
|
-
*/
|
|
49
|
-
<T extends ZodTypeAny>(target: ModelRef, schema: T, options?: ReferentialOptions): RelationDecoratedSchema<T, 'oneToOne'>;
|
|
50
|
-
};
|
|
51
|
-
type ManyToManyDecorator = {
|
|
52
|
-
<TRef extends ModelRef, T extends ZodTypeAny, const TConfig extends ManyToManyDecoratorConfig<T> & {
|
|
53
|
-
field: T;
|
|
54
|
-
}>(target: TRef, config: TConfig): RelationDecoratedSchema<T, 'manyToMany', ModelRefTarget<TRef>, ConfigName<TConfig>, undefined>;
|
|
55
|
-
<TRef extends ModelRef, const TConfig extends ManyToManyDecoratorConfig<z.ZodArray<z.ZodNumber>> | undefined>(target: TRef, config?: TConfig): RelationDecoratedSchema<z.ZodArray<z.ZodNumber>, 'manyToMany', ModelRefTarget<TRef>, ConfigName<TConfig>, undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated Use `t.manyToMany(target, { field: schema, name })` instead.
|
|
58
|
-
*/
|
|
59
|
-
<T extends ZodTypeAny>(target: ModelRef, schema: T): RelationDecoratedSchema<T, 'manyToMany'>;
|
|
60
|
-
};
|
|
61
|
-
export interface TangoDecorators {
|
|
62
|
-
field: <T extends ZodTypeAny>(schema: T) => FieldDecoratorBuilder<T>;
|
|
63
|
-
modelRef: <TModel extends Model>(key: ModelKeyOf<TModel>) => TypedModelRef<TModel>;
|
|
64
|
-
primaryKey: UnaryFieldDecorator;
|
|
65
|
-
unique: UnaryFieldDecorator;
|
|
66
|
-
null: UnaryFieldDecorator;
|
|
67
|
-
notNull: UnaryFieldDecorator;
|
|
68
|
-
default: <T extends ZodTypeAny>(schema: T, value: string | {
|
|
69
|
-
now: true;
|
|
70
|
-
} | null) => T;
|
|
71
|
-
dbDefault: <T extends ZodTypeAny>(schema: T, value: string) => T;
|
|
72
|
-
dbColumn: <T extends ZodTypeAny>(schema: T, name: string) => T;
|
|
73
|
-
dbIndex: <T extends ZodTypeAny>(schema: T) => T;
|
|
74
|
-
choices: <T extends ZodTypeAny>(schema: T, values: readonly unknown[]) => T;
|
|
75
|
-
validators: <T extends ZodTypeAny>(schema: T, ...values: readonly ((value: unknown) => unknown)[]) => T;
|
|
76
|
-
helpText: <T extends ZodTypeAny>(schema: T, text: string) => T;
|
|
77
|
-
errorMessages: <T extends ZodTypeAny>(schema: T, map: Record<string, string>) => T;
|
|
78
|
-
foreignKey: RelationshipDecorator;
|
|
79
|
-
oneToOne: OneToOneRelationshipDecorator;
|
|
80
|
-
manyToMany: ManyToManyDecorator;
|
|
81
|
-
}
|
|
82
|
-
export declare const Decorators: TangoDecorators;
|
|
83
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const InternalDecoratedFieldKind: {
|
|
2
|
-
readonly FOREIGN_KEY: "foreignKey";
|
|
3
|
-
readonly ONE_TO_ONE: "oneToOne";
|
|
4
|
-
readonly MANY_TO_MANY: "manyToMany";
|
|
5
|
-
};
|
|
6
|
-
export type DecoratedFieldKind = (typeof InternalDecoratedFieldKind)[keyof typeof InternalDecoratedFieldKind];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Model, ModelKeyOf } from '../../../domain';
|
|
2
|
-
declare const TANGO_TYPED_MODEL_REF_TARGET: unique symbol;
|
|
3
|
-
export interface TypedModelRef<TModel extends Model = Model> {
|
|
4
|
-
readonly key: ModelKeyOf<TModel>;
|
|
5
|
-
readonly [TANGO_TYPED_MODEL_REF_TARGET]?: TModel;
|
|
6
|
-
}
|
|
7
|
-
export type ModelRef<TModel extends Model = Model> = string | TModel | (() => TModel) | TypedModelRef<TModel>;
|
|
8
|
-
export type ModelRefTarget<TRef> = TRef extends TypedModelRef<infer TModel> ? TModel : TRef extends () => infer TModel ? TModel extends Model ? TModel : never : TRef extends Model ? TRef : never;
|
|
9
|
-
export declare function createTypedModelRef<TModel extends Model>(key: ModelKeyOf<TModel>): TypedModelRef<TModel>;
|
|
10
|
-
export declare function isTypedModelRef(value: unknown): value is TypedModelRef;
|
|
11
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { DecoratedFieldKind } from './DecoratedFieldKind';
|
|
2
|
-
import type { Model } from '../../../domain';
|
|
3
|
-
import type { ZodTypeAny } from './ZodTypeAny';
|
|
4
|
-
declare const TANGO_DECORATED_FIELD_KIND: unique symbol;
|
|
5
|
-
export type RelationDecoratedSchema<TSchema extends ZodTypeAny, TKind extends DecoratedFieldKind, TTargetModel extends Model | never = never, TName extends string | undefined = undefined, TRelatedName extends string | undefined = undefined> = TSchema & {
|
|
6
|
-
readonly [TANGO_DECORATED_FIELD_KIND]: {
|
|
7
|
-
readonly relationKind: TKind;
|
|
8
|
-
readonly targetModel: TTargetModel;
|
|
9
|
-
readonly name: TName;
|
|
10
|
-
readonly relatedName: TRelatedName;
|
|
11
|
-
};
|
|
12
|
-
readonly __tangoRelationDecoratedSchema: {
|
|
13
|
-
readonly relationKind: TKind;
|
|
14
|
-
readonly targetModel: TTargetModel;
|
|
15
|
-
readonly name: TName;
|
|
16
|
-
readonly relatedName: TRelatedName;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export type RelationDecoratedSchemaKind<TField> = TField extends {
|
|
20
|
-
readonly __tangoRelationDecoratedSchema: {
|
|
21
|
-
readonly relationKind: infer TKind extends DecoratedFieldKind;
|
|
22
|
-
};
|
|
23
|
-
} ? TKind : never;
|
|
24
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ZodTypeAny } from './ZodTypeAny';
|
|
2
|
-
import type { ReferentialOptions } from './TangoFieldMeta';
|
|
3
|
-
import type { ModelRef } from './ModelRef';
|
|
4
|
-
/**
|
|
5
|
-
* Config object for `t.foreignKey(...)`.
|
|
6
|
-
*
|
|
7
|
-
* The config object is the preferred second-argument form for relation
|
|
8
|
-
* decorators. Omit `field` to keep Tango's default schema inference.
|
|
9
|
-
*/
|
|
10
|
-
export interface ForeignKeyDecoratorConfig<TField extends ZodTypeAny = ZodTypeAny> extends ReferentialOptions {
|
|
11
|
-
field?: TField;
|
|
12
|
-
name?: string;
|
|
13
|
-
relatedName?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Config object for `t.oneToOne(...)`.
|
|
17
|
-
*
|
|
18
|
-
* The config object is the preferred second-argument form for relation
|
|
19
|
-
* decorators. Omit `field` to keep Tango's default schema inference.
|
|
20
|
-
*/
|
|
21
|
-
export interface OneToOneDecoratorConfig<TField extends ZodTypeAny = ZodTypeAny> extends ReferentialOptions {
|
|
22
|
-
field?: TField;
|
|
23
|
-
name?: string;
|
|
24
|
-
relatedName?: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Config object for `t.manyToMany(...)`.
|
|
28
|
-
*
|
|
29
|
-
* The config object is the preferred second-argument form for relation
|
|
30
|
-
* decorators. Omit `field` to keep Tango's default schema inference.
|
|
31
|
-
*/
|
|
32
|
-
export interface ManyToManyDecoratorConfig<TField extends ZodTypeAny = ZodTypeAny> {
|
|
33
|
-
field?: TField;
|
|
34
|
-
name?: string;
|
|
35
|
-
relatedName?: never;
|
|
36
|
-
through?: ModelRef;
|
|
37
|
-
throughSourceFieldName?: string;
|
|
38
|
-
throughTargetFieldName?: string;
|
|
39
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import type { DeleteReferentialAction, UpdateReferentialAction } from '../../../domain';
|
|
2
|
-
import type { DecoratedFieldKind } from './DecoratedFieldKind';
|
|
3
|
-
import type { ModelRef } from './ModelRef';
|
|
4
|
-
/**
|
|
5
|
-
* Options attached to a {@link TangoFieldMeta.references} block for foreign-key-style fields.
|
|
6
|
-
*/
|
|
7
|
-
export interface ReferentialOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Column on the **referenced** model that this link targets. When omitted, the target model’s
|
|
10
|
-
* primary key is used.
|
|
11
|
-
*/
|
|
12
|
-
column?: string;
|
|
13
|
-
/** `ON DELETE` action for the underlying foreign key constraint. */
|
|
14
|
-
onDelete?: DeleteReferentialAction;
|
|
15
|
-
/** `ON UPDATE` action for the underlying foreign key constraint. */
|
|
16
|
-
onUpdate?: UpdateReferentialAction;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Field-level metadata attached to a Zod schema via decorators. Migrations and relation wiring
|
|
20
|
-
* read this shape when inferring columns, constraints, and graph edges.
|
|
21
|
-
*/
|
|
22
|
-
export interface TangoFieldMeta {
|
|
23
|
-
/** Marks the backing column as the table primary key. */
|
|
24
|
-
primaryKey?: boolean;
|
|
25
|
-
/** Adds a uniqueness constraint at the database layer. */
|
|
26
|
-
unique?: boolean;
|
|
27
|
-
/** `NOT NULL` for the stored column when applicable. */
|
|
28
|
-
notNull?: boolean;
|
|
29
|
-
/** Creates a btree index on the stored column. */
|
|
30
|
-
dbIndex?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Database column name. When set, migrations and DDL use this instead of the object property
|
|
33
|
-
* name.
|
|
34
|
-
*/
|
|
35
|
-
dbColumn?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Application-level default used by schema inference and validation (`DEFAULT` clause is
|
|
38
|
-
* derived separately unless {@link dbDefault} is set).
|
|
39
|
-
*/
|
|
40
|
-
default?: string | {
|
|
41
|
-
now: true;
|
|
42
|
-
} | null;
|
|
43
|
-
/** Raw SQL expression for the column’s `DEFAULT` in generated DDL. */
|
|
44
|
-
dbDefault?: string;
|
|
45
|
-
/** Human-oriented description for forms, admin UIs, and generated docs. */
|
|
46
|
-
helpText?: string;
|
|
47
|
-
/** Enumerated allowed values when the field is presented as a choice list. */
|
|
48
|
-
choices?: readonly unknown[];
|
|
49
|
-
/** Runtime validators applied when coercing or checking incoming values. */
|
|
50
|
-
validators?: readonly ((value: unknown) => unknown)[];
|
|
51
|
-
/** Map of validator key to user-facing error message overrides. */
|
|
52
|
-
errorMessages?: Record<string, string>;
|
|
53
|
-
/**
|
|
54
|
-
* Declares how this field relates to another model: plain FK (`target`), optional explicit
|
|
55
|
-
* many-to-many through model (`through`), and the through-side field names that pair the source
|
|
56
|
-
* and target endpoints.
|
|
57
|
-
*/
|
|
58
|
-
references?: {
|
|
59
|
-
/** Symbolic reference to the related model (same resolution rules as elsewhere in schema). */
|
|
60
|
-
target: ModelRef;
|
|
61
|
-
options?: ReferentialOptions;
|
|
62
|
-
/** Explicit join model for a many-to-many when not using an implicit through table. */
|
|
63
|
-
through?: ModelRef;
|
|
64
|
-
/**
|
|
65
|
-
* Schema field key on the through model that holds the foreign key **from** this model’s
|
|
66
|
-
* side of the association.
|
|
67
|
-
*/
|
|
68
|
-
throughSourceFieldName?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Schema field key on the through model that holds the foreign key **to** the related
|
|
71
|
-
* model’s side of the association.
|
|
72
|
-
*/
|
|
73
|
-
throughTargetFieldName?: string;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Classifies decorated relation endpoints (`foreignKey`, `oneToOne`, `manyToMany`) for
|
|
77
|
-
* normalization and graph construction.
|
|
78
|
-
*/
|
|
79
|
-
relationKind?: DecoratedFieldKind;
|
|
80
|
-
/**
|
|
81
|
-
* Preferred name for the forward edge from this model toward {@link references.target}
|
|
82
|
-
* (overrides inferred naming).
|
|
83
|
-
*/
|
|
84
|
-
forwardName?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Preferred name for the reverse edge back from the related model (overrides inferred naming).
|
|
87
|
-
*/
|
|
88
|
-
reverseName?: string;
|
|
89
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain boundary barrel: centralizes this subdomain's public contract.
|
|
3
|
-
*/
|
|
4
|
-
export { Decorators, Decorators as t } from './Decorators';
|
|
5
|
-
export type { FieldDecoratorBuilder, TangoDecorators } from './Decorators';
|
|
6
|
-
export type { ModelRef, ModelRefTarget, TypedModelRef } from './domain/ModelRef';
|
|
7
|
-
export { createTypedModelRef, isTypedModelRef } from './domain/ModelRef';
|
|
8
|
-
export type { RelationDecoratedSchema } from './domain/RelationDecoratedSchema';
|
|
9
|
-
export { InternalDecoratedFieldKind } from './domain/DecoratedFieldKind';
|
|
10
|
-
export type { DecoratedFieldKind } from './domain/DecoratedFieldKind';
|
|
11
|
-
export type { ForeignKeyDecoratorConfig, OneToOneDecoratorConfig, ManyToManyDecoratorConfig, } from './domain/RelationDecoratorConfig';
|
|
12
|
-
export type { ReferentialOptions, TangoFieldMeta } from './domain/TangoFieldMeta';
|
|
13
|
-
export type { ZodTypeAny } from './domain/ZodTypeAny';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ZodTypeAny } from '../decorators/domain/ZodTypeAny';
|
|
2
|
-
import type { TangoFieldMeta } from '../decorators/domain/TangoFieldMeta';
|
|
3
|
-
export declare function getFieldMetadata(schema: ZodTypeAny): TangoFieldMeta | undefined;
|
|
4
|
-
export declare function setFieldMetadata(schema: ZodTypeAny, meta: TangoFieldMeta): void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Field } from '../../domain/index';
|
|
2
|
-
export interface FinalizedStorageModel {
|
|
3
|
-
key: string;
|
|
4
|
-
table: string;
|
|
5
|
-
fields: readonly Field[];
|
|
6
|
-
pk: string;
|
|
7
|
-
}
|
|
8
|
-
export interface FinalizedStorageArtifacts {
|
|
9
|
-
version: number;
|
|
10
|
-
byModel: ReadonlyMap<string, FinalizedStorageModel>;
|
|
11
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Field } from '../../domain/index';
|
|
3
|
-
import type { ModelRef } from '../decorators/domain/ModelRef';
|
|
4
|
-
import { ModelRegistry } from '../registry/ModelRegistry';
|
|
5
|
-
export type InferFieldsOptions = {
|
|
6
|
-
registry?: ModelRegistry;
|
|
7
|
-
resolveReferenceTarget?: (target: ModelRef) => {
|
|
8
|
-
table: string;
|
|
9
|
-
pk: string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Infer Tango field metadata from a Zod object schema and any attached field decorators.
|
|
14
|
-
*/
|
|
15
|
-
export declare function inferFieldsFromSchema(schema: z.ZodObject<z.ZodRawShape>, options?: InferFieldsOptions): Field[];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Field, Model, ModelAugmentations, ModelMetadata, ModelWriteHooks, PersistedModelOutput, RelationDef } from '../../domain/index';
|
|
3
|
-
import type { ModelDefinition } from '../ModelDefinition';
|
|
4
|
-
import type { ModelRegistry } from '../registry/ModelRegistry';
|
|
5
|
-
import type { NormalizedRelationStorageDescriptor } from '../relations/NormalizedRelationStorageDescriptor';
|
|
6
|
-
type AnySchemaModel = Model<z.ZodObject<z.ZodRawShape>>;
|
|
7
|
-
type AnyInternalSchemaModel = InternalSchemaModel<z.ZodObject<z.ZodRawShape>>;
|
|
8
|
-
export declare class InternalSchemaModel<TSchema extends z.ZodObject<z.ZodRawShape>, TKey extends string = string> implements Model<TSchema, TKey> {
|
|
9
|
-
static readonly BRAND: "tango.schema.internal_schema_model";
|
|
10
|
-
readonly __tangoBrand: typeof InternalSchemaModel.BRAND;
|
|
11
|
-
readonly metadata: ModelMetadata;
|
|
12
|
-
readonly schema: TSchema;
|
|
13
|
-
readonly hooks?: ModelWriteHooks<PersistedModelOutput<TSchema>>;
|
|
14
|
-
readonly objects: ModelAugmentations<TSchema, TKey> extends {
|
|
15
|
-
readonly objects: infer TObject;
|
|
16
|
-
} ? TObject : never;
|
|
17
|
-
private constructor();
|
|
18
|
-
static create<TSchema extends z.ZodObject<z.ZodRawShape>>(definition: ModelDefinition<TSchema>, registry: ModelRegistry): InternalSchemaModel<TSchema>;
|
|
19
|
-
static isInternalSchemaModel(value: unknown): value is AnyInternalSchemaModel;
|
|
20
|
-
static getRegistryOwner(model: AnySchemaModel): ModelRegistry;
|
|
21
|
-
static getNormalizedRelations(model: AnySchemaModel): readonly NormalizedRelationStorageDescriptor[];
|
|
22
|
-
static getExplicitFields(model: AnySchemaModel): readonly Field[] | undefined;
|
|
23
|
-
static getExplicitRelations(model: AnySchemaModel): Readonly<Record<string, RelationDef>> | undefined;
|
|
24
|
-
private static validateDefinition;
|
|
25
|
-
private static require;
|
|
26
|
-
private static carrier;
|
|
27
|
-
private static attachInternals;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { IndexDef } from '../../domain/index';
|
|
2
|
-
export type ModelConstraint = {
|
|
3
|
-
kind: string;
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
export type ModelMetaFragment = {
|
|
7
|
-
ordering?: string[];
|
|
8
|
-
managed?: boolean;
|
|
9
|
-
defaultRelatedName?: string;
|
|
10
|
-
indexes?: IndexDef[];
|
|
11
|
-
constraints?: ModelConstraint[];
|
|
12
|
-
};
|
|
13
|
-
export declare const Meta: {
|
|
14
|
-
ordering(...fields: string[]): ModelMetaFragment;
|
|
15
|
-
managed(value: boolean): ModelMetaFragment;
|
|
16
|
-
defaultRelatedName(value: string): ModelMetaFragment;
|
|
17
|
-
indexes(...indexes: IndexDef[]): ModelMetaFragment;
|
|
18
|
-
constraints(...constraints: ModelConstraint[]): ModelMetaFragment;
|
|
19
|
-
uniqueTogether(...sets: string[][]): ModelMetaFragment;
|
|
20
|
-
indexTogether(...sets: string[][]): ModelMetaFragment;
|
|
21
|
-
merge(...fragments: readonly ModelMetaFragment[]): ModelMetaFragment;
|
|
22
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ResolvedRelationGraphSnapshot } from './ResolvedRelationGraphSnapshot';
|
|
2
|
-
export declare const GENERATED_RELATION_REGISTRY_DIRNAME = ".tango";
|
|
3
|
-
export declare const GENERATED_RELATION_REGISTRY_TYPES_FILENAME = "relations.generated.d.ts";
|
|
4
|
-
export declare const GENERATED_RELATION_REGISTRY_METADATA_FILENAME = "relations.generated.json";
|
|
5
|
-
export declare const GENERATED_RELATION_REGISTRY_METADATA_VERSION = 1;
|
|
6
|
-
export type GeneratedRelationRegistryArtifact = {
|
|
7
|
-
version: typeof GENERATED_RELATION_REGISTRY_METADATA_VERSION;
|
|
8
|
-
fingerprint: string;
|
|
9
|
-
snapshot: ResolvedRelationGraphSnapshot;
|
|
10
|
-
};
|