@danceroutine/tango-schema 1.11.0 → 1.11.2
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 +4 -4
- 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
|
@@ -0,0 +1,747 @@
|
|
|
1
|
+
import { E as Field, O as UpdateReferentialAction, S as ModelWriteHooks, T as IndexDef, a as PersistedModelOutput, c as DecoratedFieldKind, i as ModelKeyOf, k as DeleteReferentialAction, l as InternalDecoratedFieldKind, n as Model$1, o as RelationDecoratedSchema, s as ZodTypeAny, w as RelationDef } from "./index-Bhh0b304.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/model/decorators/domain/ModelRef.d.ts
|
|
5
|
+
declare const TANGO_TYPED_MODEL_REF_TARGET: unique symbol;
|
|
6
|
+
interface TypedModelRef<TModel extends Model$1 = Model$1> {
|
|
7
|
+
readonly key: ModelKeyOf<TModel>;
|
|
8
|
+
readonly [TANGO_TYPED_MODEL_REF_TARGET]?: TModel;
|
|
9
|
+
}
|
|
10
|
+
type ModelRef<TModel extends Model$1 = Model$1> = string | TModel | (() => TModel) | TypedModelRef<TModel>;
|
|
11
|
+
type ModelRefTarget<TRef> = TRef extends TypedModelRef<infer TModel> ? TModel : TRef extends (() => infer TModel) ? TModel extends Model$1 ? TModel : never : TRef extends Model$1 ? TRef : never;
|
|
12
|
+
declare function createTypedModelRef<TModel extends Model$1>(key: ModelKeyOf<TModel>): TypedModelRef<TModel>;
|
|
13
|
+
declare function isTypedModelRef(value: unknown): value is TypedModelRef;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/model/decorators/domain/TangoFieldMeta.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Options attached to a {@link TangoFieldMeta.references} block for foreign-key-style fields.
|
|
18
|
+
*/
|
|
19
|
+
interface ReferentialOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Column on the **referenced** model that this link targets. When omitted, the target model’s
|
|
22
|
+
* primary key is used.
|
|
23
|
+
*/
|
|
24
|
+
column?: string;
|
|
25
|
+
/** `ON DELETE` action for the underlying foreign key constraint. */
|
|
26
|
+
onDelete?: DeleteReferentialAction;
|
|
27
|
+
/** `ON UPDATE` action for the underlying foreign key constraint. */
|
|
28
|
+
onUpdate?: UpdateReferentialAction;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Field-level metadata attached to a Zod schema via decorators. Migrations and relation wiring
|
|
32
|
+
* read this shape when inferring columns, constraints, and graph edges.
|
|
33
|
+
*/
|
|
34
|
+
interface TangoFieldMeta {
|
|
35
|
+
/** Marks the backing column as the table primary key. */
|
|
36
|
+
primaryKey?: boolean;
|
|
37
|
+
/** Adds a uniqueness constraint at the database layer. */
|
|
38
|
+
unique?: boolean;
|
|
39
|
+
/** `NOT NULL` for the stored column when applicable. */
|
|
40
|
+
notNull?: boolean;
|
|
41
|
+
/** Creates a btree index on the stored column. */
|
|
42
|
+
dbIndex?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Database column name. When set, migrations and DDL use this instead of the object property
|
|
45
|
+
* name.
|
|
46
|
+
*/
|
|
47
|
+
dbColumn?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Application-level default used by schema inference and validation (`DEFAULT` clause is
|
|
50
|
+
* derived separately unless {@link dbDefault} is set).
|
|
51
|
+
*/
|
|
52
|
+
default?: string | {
|
|
53
|
+
now: true;
|
|
54
|
+
} | null;
|
|
55
|
+
/** Raw SQL expression for the column’s `DEFAULT` in generated DDL. */
|
|
56
|
+
dbDefault?: string;
|
|
57
|
+
/** Human-oriented description for forms, admin UIs, and generated docs. */
|
|
58
|
+
helpText?: string;
|
|
59
|
+
/** Enumerated allowed values when the field is presented as a choice list. */
|
|
60
|
+
choices?: readonly unknown[];
|
|
61
|
+
/** Runtime validators applied when coercing or checking incoming values. */
|
|
62
|
+
validators?: readonly ((value: unknown) => unknown)[];
|
|
63
|
+
/** Map of validator key to user-facing error message overrides. */
|
|
64
|
+
errorMessages?: Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Declares how this field relates to another model: plain FK (`target`), optional explicit
|
|
67
|
+
* many-to-many through model (`through`), and the through-side field names that pair the source
|
|
68
|
+
* and target endpoints.
|
|
69
|
+
*/
|
|
70
|
+
references?: {
|
|
71
|
+
/** Symbolic reference to the related model (same resolution rules as elsewhere in schema). */target: ModelRef;
|
|
72
|
+
options?: ReferentialOptions; /** Explicit join model for a many-to-many when not using an implicit through table. */
|
|
73
|
+
through?: ModelRef;
|
|
74
|
+
/**
|
|
75
|
+
* Schema field key on the through model that holds the foreign key **from** this model’s
|
|
76
|
+
* side of the association.
|
|
77
|
+
*/
|
|
78
|
+
throughSourceFieldName?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Schema field key on the through model that holds the foreign key **to** the related
|
|
81
|
+
* model’s side of the association.
|
|
82
|
+
*/
|
|
83
|
+
throughTargetFieldName?: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Classifies decorated relation endpoints (`foreignKey`, `oneToOne`, `manyToMany`) for
|
|
87
|
+
* normalization and graph construction.
|
|
88
|
+
*/
|
|
89
|
+
relationKind?: DecoratedFieldKind;
|
|
90
|
+
/**
|
|
91
|
+
* Preferred name for the forward edge from this model toward {@link references.target}
|
|
92
|
+
* (overrides inferred naming).
|
|
93
|
+
*/
|
|
94
|
+
forwardName?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Preferred name for the reverse edge back from the related model (overrides inferred naming).
|
|
97
|
+
*/
|
|
98
|
+
reverseName?: string;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/model/decorators/domain/RelationDecoratorConfig.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* Config object for `t.foreignKey(...)`.
|
|
104
|
+
*
|
|
105
|
+
* The config object is the preferred second-argument form for relation
|
|
106
|
+
* decorators. Omit `field` to keep Tango's default schema inference.
|
|
107
|
+
*/
|
|
108
|
+
interface ForeignKeyDecoratorConfig<TField extends ZodTypeAny = ZodTypeAny> extends ReferentialOptions {
|
|
109
|
+
field?: TField;
|
|
110
|
+
name?: string;
|
|
111
|
+
relatedName?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Config object for `t.oneToOne(...)`.
|
|
115
|
+
*
|
|
116
|
+
* The config object is the preferred second-argument form for relation
|
|
117
|
+
* decorators. Omit `field` to keep Tango's default schema inference.
|
|
118
|
+
*/
|
|
119
|
+
interface OneToOneDecoratorConfig<TField extends ZodTypeAny = ZodTypeAny> extends ReferentialOptions {
|
|
120
|
+
field?: TField;
|
|
121
|
+
name?: string;
|
|
122
|
+
relatedName?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Config object for `t.manyToMany(...)`.
|
|
126
|
+
*
|
|
127
|
+
* The config object is the preferred second-argument form for relation
|
|
128
|
+
* decorators. Omit `field` to keep Tango's default schema inference.
|
|
129
|
+
*/
|
|
130
|
+
interface ManyToManyDecoratorConfig<TField extends ZodTypeAny = ZodTypeAny> {
|
|
131
|
+
field?: TField;
|
|
132
|
+
name?: string;
|
|
133
|
+
relatedName?: never;
|
|
134
|
+
through?: ModelRef;
|
|
135
|
+
throughSourceFieldName?: string;
|
|
136
|
+
throughTargetFieldName?: string;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/model/decorators/Decorators.d.ts
|
|
140
|
+
interface FieldDecoratorBuilder<TField extends ZodTypeAny> {
|
|
141
|
+
defaultValue(value: string | {
|
|
142
|
+
now: true;
|
|
143
|
+
} | null): FieldDecoratorBuilder<TField>;
|
|
144
|
+
dbDefault(value: string): FieldDecoratorBuilder<TField>;
|
|
145
|
+
dbColumn(name: string): FieldDecoratorBuilder<TField>;
|
|
146
|
+
dbIndex(): FieldDecoratorBuilder<TField>;
|
|
147
|
+
choices(values: readonly unknown[]): FieldDecoratorBuilder<TField>;
|
|
148
|
+
validators(...values: readonly ((value: unknown) => unknown)[]): FieldDecoratorBuilder<TField>;
|
|
149
|
+
helpText(text: string): FieldDecoratorBuilder<TField>;
|
|
150
|
+
errorMessages(map: Record<string, string>): FieldDecoratorBuilder<TField>;
|
|
151
|
+
build(): TField;
|
|
152
|
+
}
|
|
153
|
+
type ConfigName<TConfig> = TConfig extends {
|
|
154
|
+
name: infer TName extends string;
|
|
155
|
+
} ? TName : undefined;
|
|
156
|
+
type ConfigRelatedName<TConfig> = TConfig extends {
|
|
157
|
+
relatedName: infer TRelatedName extends string;
|
|
158
|
+
} ? TRelatedName : undefined;
|
|
159
|
+
type UnaryFieldDecorator = {
|
|
160
|
+
<T extends ZodTypeAny>(schema: T): T;
|
|
161
|
+
<T extends ZodTypeAny>(): (input: T) => T;
|
|
162
|
+
};
|
|
163
|
+
type RelationshipDecorator = {
|
|
164
|
+
<TRef extends ModelRef, T extends ZodTypeAny, const TConfig extends ForeignKeyDecoratorConfig<T> & {
|
|
165
|
+
field: T;
|
|
166
|
+
}>(target: TRef, config: TConfig): RelationDecoratedSchema<T, 'foreignKey', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
167
|
+
<TRef extends ModelRef, const TConfig extends ForeignKeyDecoratorConfig<z.ZodNumber> | undefined>(target: TRef, config?: TConfig): RelationDecoratedSchema<z.ZodNumber, 'foreignKey', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Use `t.foreignKey(target, { field: schema, ...options })` instead.
|
|
170
|
+
*/
|
|
171
|
+
<T extends ZodTypeAny>(target: ModelRef, schema: T, options?: ReferentialOptions): RelationDecoratedSchema<T, 'foreignKey'>;
|
|
172
|
+
};
|
|
173
|
+
type OneToOneRelationshipDecorator = {
|
|
174
|
+
<TRef extends ModelRef, T extends ZodTypeAny, const TConfig extends OneToOneDecoratorConfig<T> & {
|
|
175
|
+
field: T;
|
|
176
|
+
}>(target: TRef, config: TConfig): RelationDecoratedSchema<T, 'oneToOne', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
177
|
+
<TRef extends ModelRef, const TConfig extends OneToOneDecoratorConfig<z.ZodNumber> | undefined>(target: TRef, config?: TConfig): RelationDecoratedSchema<z.ZodNumber, 'oneToOne', ModelRefTarget<TRef>, ConfigName<TConfig>, ConfigRelatedName<TConfig>>;
|
|
178
|
+
/**
|
|
179
|
+
* @deprecated Use `t.oneToOne(target, { field: schema, ...options })` instead.
|
|
180
|
+
*/
|
|
181
|
+
<T extends ZodTypeAny>(target: ModelRef, schema: T, options?: ReferentialOptions): RelationDecoratedSchema<T, 'oneToOne'>;
|
|
182
|
+
};
|
|
183
|
+
type ManyToManyDecorator = {
|
|
184
|
+
<TRef extends ModelRef, T extends ZodTypeAny, const TConfig extends ManyToManyDecoratorConfig<T> & {
|
|
185
|
+
field: T;
|
|
186
|
+
}>(target: TRef, config: TConfig): RelationDecoratedSchema<T, 'manyToMany', ModelRefTarget<TRef>, ConfigName<TConfig>, undefined>;
|
|
187
|
+
<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>;
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use `t.manyToMany(target, { field: schema, name })` instead.
|
|
190
|
+
*/
|
|
191
|
+
<T extends ZodTypeAny>(target: ModelRef, schema: T): RelationDecoratedSchema<T, 'manyToMany'>;
|
|
192
|
+
};
|
|
193
|
+
interface TangoDecorators {
|
|
194
|
+
field: <T extends ZodTypeAny>(schema: T) => FieldDecoratorBuilder<T>;
|
|
195
|
+
modelRef: <TModel extends Model$1>(key: ModelKeyOf<TModel>) => TypedModelRef<TModel>;
|
|
196
|
+
primaryKey: UnaryFieldDecorator;
|
|
197
|
+
unique: UnaryFieldDecorator;
|
|
198
|
+
null: UnaryFieldDecorator;
|
|
199
|
+
notNull: UnaryFieldDecorator;
|
|
200
|
+
default: <T extends ZodTypeAny>(schema: T, value: string | {
|
|
201
|
+
now: true;
|
|
202
|
+
} | null) => T;
|
|
203
|
+
dbDefault: <T extends ZodTypeAny>(schema: T, value: string) => T;
|
|
204
|
+
dbColumn: <T extends ZodTypeAny>(schema: T, name: string) => T;
|
|
205
|
+
dbIndex: <T extends ZodTypeAny>(schema: T) => T;
|
|
206
|
+
choices: <T extends ZodTypeAny>(schema: T, values: readonly unknown[]) => T;
|
|
207
|
+
validators: <T extends ZodTypeAny>(schema: T, ...values: readonly ((value: unknown) => unknown)[]) => T;
|
|
208
|
+
helpText: <T extends ZodTypeAny>(schema: T, text: string) => T;
|
|
209
|
+
errorMessages: <T extends ZodTypeAny>(schema: T, map: Record<string, string>) => T;
|
|
210
|
+
foreignKey: RelationshipDecorator;
|
|
211
|
+
oneToOne: OneToOneRelationshipDecorator;
|
|
212
|
+
manyToMany: ManyToManyDecorator;
|
|
213
|
+
}
|
|
214
|
+
declare const Decorators: TangoDecorators;
|
|
215
|
+
declare namespace index_d_exports$5 {
|
|
216
|
+
export { DecoratedFieldKind, Decorators, FieldDecoratorBuilder, ForeignKeyDecoratorConfig, InternalDecoratedFieldKind, ManyToManyDecoratorConfig, ModelRef, ModelRefTarget, OneToOneDecoratorConfig, ReferentialOptions, RelationDecoratedSchema, TangoDecorators, TangoFieldMeta, TypedModelRef, ZodTypeAny, createTypedModelRef, isTypedModelRef, Decorators as t };
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/model/meta/Meta.d.ts
|
|
220
|
+
type ModelConstraint = {
|
|
221
|
+
kind: string;
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
};
|
|
224
|
+
type ModelMetaFragment = {
|
|
225
|
+
ordering?: string[];
|
|
226
|
+
managed?: boolean;
|
|
227
|
+
defaultRelatedName?: string;
|
|
228
|
+
indexes?: IndexDef[];
|
|
229
|
+
constraints?: ModelConstraint[];
|
|
230
|
+
};
|
|
231
|
+
declare const Meta: {
|
|
232
|
+
ordering(...fields: string[]): ModelMetaFragment;
|
|
233
|
+
managed(value: boolean): ModelMetaFragment;
|
|
234
|
+
defaultRelatedName(value: string): ModelMetaFragment;
|
|
235
|
+
indexes(...indexes: IndexDef[]): ModelMetaFragment;
|
|
236
|
+
constraints(...constraints: ModelConstraint[]): ModelMetaFragment;
|
|
237
|
+
uniqueTogether(...sets: string[][]): ModelMetaFragment;
|
|
238
|
+
indexTogether(...sets: string[][]): ModelMetaFragment;
|
|
239
|
+
merge(...fragments: readonly ModelMetaFragment[]): ModelMetaFragment;
|
|
240
|
+
};
|
|
241
|
+
declare namespace index_d_exports$4 {
|
|
242
|
+
export { Meta, ModelConstraint, ModelMetaFragment, Meta as m };
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/model/constraints/Constraints.d.ts
|
|
246
|
+
type ConstraintDefinition = {
|
|
247
|
+
kind: string;
|
|
248
|
+
[key: string]: unknown;
|
|
249
|
+
};
|
|
250
|
+
declare const Constraints: {
|
|
251
|
+
unique(fields: string[], options?: {
|
|
252
|
+
name?: string;
|
|
253
|
+
where?: string;
|
|
254
|
+
}): ConstraintDefinition;
|
|
255
|
+
check(condition: string, options?: {
|
|
256
|
+
name?: string;
|
|
257
|
+
}): ConstraintDefinition;
|
|
258
|
+
exclusion(definition: {
|
|
259
|
+
using?: string;
|
|
260
|
+
elements: string[];
|
|
261
|
+
where?: string;
|
|
262
|
+
name?: string;
|
|
263
|
+
}): ConstraintDefinition;
|
|
264
|
+
};
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/model/constraints/Indexes.d.ts
|
|
267
|
+
declare const Indexes: {
|
|
268
|
+
index(on: string[], options?: Omit<IndexDef, "on">): IndexDef;
|
|
269
|
+
};
|
|
270
|
+
declare namespace index_d_exports$3 {
|
|
271
|
+
export { ConstraintDefinition, Constraints, Indexes, Constraints as c, Indexes as i };
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/model/fields/FinalizedStorageArtifacts.d.ts
|
|
275
|
+
interface FinalizedStorageModel {
|
|
276
|
+
key: string;
|
|
277
|
+
table: string;
|
|
278
|
+
fields: readonly Field[];
|
|
279
|
+
pk: string;
|
|
280
|
+
}
|
|
281
|
+
interface FinalizedStorageArtifacts {
|
|
282
|
+
version: number;
|
|
283
|
+
byModel: ReadonlyMap<string, FinalizedStorageModel>;
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/model/relations/RelationSpec.d.ts
|
|
287
|
+
declare const InternalRelationPublicKind: {
|
|
288
|
+
readonly BELONGS_TO: "belongsTo";
|
|
289
|
+
readonly HAS_ONE: "hasOne";
|
|
290
|
+
readonly HAS_MANY: "hasMany";
|
|
291
|
+
readonly MANY_TO_MANY: "manyToMany";
|
|
292
|
+
};
|
|
293
|
+
declare const InternalRelationStorageStrategy: {
|
|
294
|
+
readonly REFERENCE: "reference";
|
|
295
|
+
readonly REVERSE_REFERENCE: "reverse_reference";
|
|
296
|
+
readonly MANY_TO_MANY: "many_to_many";
|
|
297
|
+
};
|
|
298
|
+
declare const InternalRelationCardinality: {
|
|
299
|
+
readonly SINGLE: "single";
|
|
300
|
+
readonly MANY: "many";
|
|
301
|
+
};
|
|
302
|
+
declare const InternalRelationProvenance: {
|
|
303
|
+
readonly FIELD_DECORATOR: "field-decorator";
|
|
304
|
+
readonly RELATIONS_API: "relations-api";
|
|
305
|
+
readonly SYNTHESIZED_REVERSE: "synthesized-reverse";
|
|
306
|
+
};
|
|
307
|
+
type RelationPublicKind = (typeof InternalRelationPublicKind)[keyof typeof InternalRelationPublicKind];
|
|
308
|
+
type RelationStorageStrategy = (typeof InternalRelationStorageStrategy)[keyof typeof InternalRelationStorageStrategy];
|
|
309
|
+
type RelationCardinality = (typeof InternalRelationCardinality)[keyof typeof InternalRelationCardinality];
|
|
310
|
+
type RelationProvenance = (typeof InternalRelationProvenance)[keyof typeof InternalRelationProvenance];
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/model/relations/ResolvedRelationGraph.d.ts
|
|
313
|
+
/**
|
|
314
|
+
* Fully resolved relation edge published by the registry after storage
|
|
315
|
+
* artifacts are finalized.
|
|
316
|
+
*
|
|
317
|
+
* This is the resolution-stage shape consumed by ORM-facing relation metadata.
|
|
318
|
+
* Each descriptor has final naming, cardinality, key mapping, and capability
|
|
319
|
+
* flags that describe whether the edge is currently migratable, queryable, and
|
|
320
|
+
* hydratable.
|
|
321
|
+
*/
|
|
322
|
+
interface ResolvedRelationDescriptor {
|
|
323
|
+
edgeId: string;
|
|
324
|
+
sourceModelKey: string;
|
|
325
|
+
targetModelKey: string;
|
|
326
|
+
name: string;
|
|
327
|
+
inverseEdgeId?: string;
|
|
328
|
+
kind: RelationPublicKind;
|
|
329
|
+
storageStrategy: RelationStorageStrategy;
|
|
330
|
+
cardinality: RelationCardinality;
|
|
331
|
+
localFieldName?: string;
|
|
332
|
+
targetFieldName?: string;
|
|
333
|
+
throughModelKey?: string;
|
|
334
|
+
throughTable?: string;
|
|
335
|
+
throughSourceFieldName?: string;
|
|
336
|
+
throughTargetFieldName?: string;
|
|
337
|
+
throughSourceKey?: string;
|
|
338
|
+
throughTargetKey?: string;
|
|
339
|
+
capabilities: {
|
|
340
|
+
migratable: boolean;
|
|
341
|
+
queryable: boolean;
|
|
342
|
+
hydratable: boolean;
|
|
343
|
+
};
|
|
344
|
+
provenance: RelationProvenance;
|
|
345
|
+
alias: string;
|
|
346
|
+
ambiguity?: string;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Registry-scoped relation graph built from normalized relation descriptors,
|
|
350
|
+
* explicit relation names, and finalized storage artifacts.
|
|
351
|
+
*
|
|
352
|
+
* This is the canonical resolved relation view for query planning and future
|
|
353
|
+
* hydration work. It is versioned because relation resolution is scoped to a
|
|
354
|
+
* specific registry snapshot.
|
|
355
|
+
*/
|
|
356
|
+
interface ResolvedRelationGraph {
|
|
357
|
+
version: number;
|
|
358
|
+
byModel: ReadonlyMap<string, ReadonlyMap<string, ResolvedRelationDescriptor>>;
|
|
359
|
+
byEdgeId: ReadonlyMap<string, ResolvedRelationDescriptor>;
|
|
360
|
+
}
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/model/registry/ResolvedRelationGraphSnapshot.d.ts
|
|
363
|
+
/**
|
|
364
|
+
* Serializable snapshot of a single relation edge from the resolved relation
|
|
365
|
+
* graph. Snapshots are the stable, build-time wire format consumed by codegen
|
|
366
|
+
* and by tooling that compares the graph across runs.
|
|
367
|
+
*
|
|
368
|
+
* A snapshot row captures both the abstract edge identity (who connects to
|
|
369
|
+
* whom, under what public name) and the physical storage details (local
|
|
370
|
+
* fields, join columns, through-model coordinates) needed to translate the
|
|
371
|
+
* edge into SQL later.
|
|
372
|
+
*/
|
|
373
|
+
type ResolvedRelationGraphSnapshotRelation = {
|
|
374
|
+
/**
|
|
375
|
+
* Stable identifier for this edge within the graph. Used to cross-reference
|
|
376
|
+
* an edge with its inverse and to detect drift between snapshots.
|
|
377
|
+
*/
|
|
378
|
+
edgeId: string; /** Model key of the endpoint that owns this edge in the resolved graph. */
|
|
379
|
+
sourceModelKey: string; /** Model key of the endpoint this edge points at. */
|
|
380
|
+
targetModelKey: string;
|
|
381
|
+
/**
|
|
382
|
+
* Public relation name exposed to application code and query builders
|
|
383
|
+
* (for example `author` or `tags`).
|
|
384
|
+
*/
|
|
385
|
+
name: string;
|
|
386
|
+
/**
|
|
387
|
+
* Identifier of the paired edge on the opposite endpoint, when one exists.
|
|
388
|
+
* Bidirectional relations populate this; one-way edges leave it unset.
|
|
389
|
+
*/
|
|
390
|
+
inverseEdgeId?: string;
|
|
391
|
+
/**
|
|
392
|
+
* Public relation kind (`belongsTo`, `hasMany`, `manyToMany`, ...).
|
|
393
|
+
*/
|
|
394
|
+
kind: RelationPublicKind;
|
|
395
|
+
/**
|
|
396
|
+
* How the edge is physically stored. Distinguishes direct foreign-key
|
|
397
|
+
* references from reverse references and join-table backed relations.
|
|
398
|
+
*/
|
|
399
|
+
storageStrategy: RelationStorageStrategy; /** Whether the edge yields one target (`single`) or many (`many`). */
|
|
400
|
+
cardinality: RelationCardinality;
|
|
401
|
+
/**
|
|
402
|
+
* Owner-side column that stores the foreign key, when the edge is backed
|
|
403
|
+
* by a local reference column.
|
|
404
|
+
*/
|
|
405
|
+
localFieldName?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Target-side column the foreign key resolves against, when applicable.
|
|
408
|
+
*/
|
|
409
|
+
targetFieldName?: string;
|
|
410
|
+
/**
|
|
411
|
+
* Model key of the synthesized or user-provided through model for
|
|
412
|
+
* many-to-many edges.
|
|
413
|
+
*/
|
|
414
|
+
throughModelKey?: string; /** Physical join-table name for many-to-many edges. */
|
|
415
|
+
throughTable?: string; /** Through-model schema field on the source side, if resolved. */
|
|
416
|
+
throughSourceFieldName?: string; /** Through-model schema field on the target side, if resolved. */
|
|
417
|
+
throughTargetFieldName?: string;
|
|
418
|
+
/**
|
|
419
|
+
* Physical join-table column that stores the owner-side primary key for
|
|
420
|
+
* many-to-many edges.
|
|
421
|
+
*/
|
|
422
|
+
throughSourceKey?: string;
|
|
423
|
+
/**
|
|
424
|
+
* Physical join-table column that stores the target-side primary key for
|
|
425
|
+
* many-to-many edges.
|
|
426
|
+
*/
|
|
427
|
+
throughTargetKey?: string;
|
|
428
|
+
/**
|
|
429
|
+
* Alias used when the edge participates in SQL joins. Derived
|
|
430
|
+
* deterministically so compiled SQL is stable across runs.
|
|
431
|
+
*/
|
|
432
|
+
alias: string;
|
|
433
|
+
/**
|
|
434
|
+
* What this edge is allowed to participate in. The builder uses these
|
|
435
|
+
* flags to decide whether migrations emit DDL, queries can select over
|
|
436
|
+
* the edge, and hydration can populate the related attribute.
|
|
437
|
+
*/
|
|
438
|
+
capabilities: {
|
|
439
|
+
/** Whether migration tooling should emit DDL for this edge. */migratable: boolean; /** Whether the edge can appear as a hop in a query path. */
|
|
440
|
+
queryable: boolean; /** Whether hydrators can populate the related attribute on a row. */
|
|
441
|
+
hydratable: boolean;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
/**
|
|
445
|
+
* Snapshot of one model's relation edges. Grouping edges by source model
|
|
446
|
+
* lets codegen walk the graph model-by-model without having to re-index.
|
|
447
|
+
*/
|
|
448
|
+
type ResolvedRelationGraphSnapshotModel = {
|
|
449
|
+
/** Model key these relations source from. */key: string; /** Resolved outgoing relation edges in registration order. */
|
|
450
|
+
relations: ResolvedRelationGraphSnapshotRelation[];
|
|
451
|
+
};
|
|
452
|
+
/**
|
|
453
|
+
* Top-level serializable snapshot of the resolved relation graph for a
|
|
454
|
+
* registry. Written to disk by codegen and diffed across runs to detect
|
|
455
|
+
* registry drift.
|
|
456
|
+
*/
|
|
457
|
+
type ResolvedRelationGraphSnapshot = {
|
|
458
|
+
/** Per-model relation snapshots in registration order. */models: ResolvedRelationGraphSnapshotModel[];
|
|
459
|
+
};
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/model/registry/ModelRegistry.d.ts
|
|
462
|
+
/**
|
|
463
|
+
* Registry that resolves Tango models by stable identity.
|
|
464
|
+
*
|
|
465
|
+
* The default shared registry is convenient for application bootstrapping
|
|
466
|
+
* within one schema package instance, while dedicated instances are useful in
|
|
467
|
+
* tests and tooling. Explicit active-registry binding stays process-shared so
|
|
468
|
+
* tooling can construct models across separate schema package copies without
|
|
469
|
+
* relying on the ambient default registry.
|
|
470
|
+
*/
|
|
471
|
+
declare class ModelRegistry {
|
|
472
|
+
private static globalRegistry?;
|
|
473
|
+
private readonly models;
|
|
474
|
+
private version;
|
|
475
|
+
private storageCache?;
|
|
476
|
+
private relationGraphCache?;
|
|
477
|
+
private lastRelationRegistryDriftCheckVersion?;
|
|
478
|
+
/**
|
|
479
|
+
* Return the shared default registry used by `Model(...)` for this schema
|
|
480
|
+
* package instance.
|
|
481
|
+
*/
|
|
482
|
+
static global(): ModelRegistry;
|
|
483
|
+
/**
|
|
484
|
+
* Return the registry currently bound to model construction work.
|
|
485
|
+
*
|
|
486
|
+
* This explicit binding is process-shared so code that imports separate
|
|
487
|
+
* schema package copies can still participate in one construction flow.
|
|
488
|
+
*/
|
|
489
|
+
static active(): ModelRegistry;
|
|
490
|
+
/**
|
|
491
|
+
* Run work with a specific registry bound as the active construction target.
|
|
492
|
+
*/
|
|
493
|
+
static runWithRegistry<T>(registry: ModelRegistry, work: () => Promise<T> | T): Promise<T>;
|
|
494
|
+
/**
|
|
495
|
+
* Register a model on the shared global registry.
|
|
496
|
+
*/
|
|
497
|
+
static register(model: Model$1): void;
|
|
498
|
+
/**
|
|
499
|
+
* Register several models on the shared global registry.
|
|
500
|
+
*/
|
|
501
|
+
static registerMany(models: readonly Model$1[]): void;
|
|
502
|
+
/**
|
|
503
|
+
* Resolve a model from the shared registry by namespace and name.
|
|
504
|
+
*/
|
|
505
|
+
static get(namespace: string, name: string): Model$1 | undefined;
|
|
506
|
+
/**
|
|
507
|
+
* Resolve a model from the shared registry by its `namespace/name` key.
|
|
508
|
+
*/
|
|
509
|
+
static getByKey(key: string): Model$1 | undefined;
|
|
510
|
+
/**
|
|
511
|
+
* Resolve any supported model reference form against the shared registry.
|
|
512
|
+
*/
|
|
513
|
+
static resolveRef(ref: ModelRef): Model$1;
|
|
514
|
+
/**
|
|
515
|
+
* Clear the shared registry, which is mainly useful in tests.
|
|
516
|
+
*/
|
|
517
|
+
static clear(): void;
|
|
518
|
+
/**
|
|
519
|
+
* Return the owning registry for a model.
|
|
520
|
+
*/
|
|
521
|
+
static getOwner(model: {
|
|
522
|
+
metadata: {
|
|
523
|
+
key?: string;
|
|
524
|
+
};
|
|
525
|
+
} & object): ModelRegistry;
|
|
526
|
+
private static runtimeGlobal;
|
|
527
|
+
private static activeRegistryStorage;
|
|
528
|
+
/**
|
|
529
|
+
* Register a model on this registry instance.
|
|
530
|
+
*/
|
|
531
|
+
register(model: Model$1): void;
|
|
532
|
+
/**
|
|
533
|
+
* Register several models on this registry instance.
|
|
534
|
+
*/
|
|
535
|
+
registerMany(models: readonly Model$1[]): void;
|
|
536
|
+
/**
|
|
537
|
+
* Resolve a model from this registry instance by namespace and name.
|
|
538
|
+
*/
|
|
539
|
+
get(namespace: string, name: string): Model$1 | undefined;
|
|
540
|
+
/**
|
|
541
|
+
* Resolve a model from this registry instance by its `namespace/name` key.
|
|
542
|
+
*/
|
|
543
|
+
getByKey(key: string): Model$1 | undefined;
|
|
544
|
+
/**
|
|
545
|
+
* Resolve a string, callback, or direct model reference into a model object.
|
|
546
|
+
*/
|
|
547
|
+
resolveRef(ref: ModelRef): Model$1;
|
|
548
|
+
/**
|
|
549
|
+
* Finalize storage-only artifacts for all models in this registry.
|
|
550
|
+
*/
|
|
551
|
+
finalizeStorageArtifacts(): FinalizedStorageArtifacts;
|
|
552
|
+
/**
|
|
553
|
+
* Return finalized storage fields for a specific model.
|
|
554
|
+
*/
|
|
555
|
+
getFinalizedFields(model: Model$1 | string): readonly Field[];
|
|
556
|
+
/**
|
|
557
|
+
* Resolve the registry's relation graph from finalized storage artifacts.
|
|
558
|
+
*/
|
|
559
|
+
getResolvedRelationGraph(): ResolvedRelationGraph;
|
|
560
|
+
/**
|
|
561
|
+
* Return a canonical snapshot of the resolved relation graph.
|
|
562
|
+
*/
|
|
563
|
+
getResolvedRelationGraphSnapshot(): ResolvedRelationGraphSnapshot;
|
|
564
|
+
/**
|
|
565
|
+
* Return a deterministic fingerprint for the resolved relation graph.
|
|
566
|
+
*/
|
|
567
|
+
getResolvedRelationGraphFingerprint(): string;
|
|
568
|
+
/**
|
|
569
|
+
* Remove all registered models from this registry instance.
|
|
570
|
+
*/
|
|
571
|
+
clear(): void;
|
|
572
|
+
/**
|
|
573
|
+
* Return all registered models in insertion order.
|
|
574
|
+
*/
|
|
575
|
+
values(): readonly Model$1[];
|
|
576
|
+
private bumpVersion;
|
|
577
|
+
private stripImplicitManyToManyModels;
|
|
578
|
+
private freezeFields;
|
|
579
|
+
private inferPrimaryKeyName;
|
|
580
|
+
private mergeStorageFields;
|
|
581
|
+
private warnOnGeneratedRelationRegistryDrift;
|
|
582
|
+
private shouldCheckGeneratedRelationRegistry;
|
|
583
|
+
private readGeneratedRelationRegistryArtifact;
|
|
584
|
+
private isPartialRegistrySnapshot;
|
|
585
|
+
}
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/resolveSchemaModuleEntrypoint.d.ts
|
|
588
|
+
/**
|
|
589
|
+
* Resolve the current package root entrypoint for `@danceroutine/tango-schema`.
|
|
590
|
+
*
|
|
591
|
+
* Tooling loaders alias app-side `@danceroutine/tango-schema` imports back to
|
|
592
|
+
* this path so project modules reuse the same schema package instance across
|
|
593
|
+
* workspace-source and published-dist environments.
|
|
594
|
+
*/
|
|
595
|
+
declare function resolveSchemaModuleEntrypoint(): string;
|
|
596
|
+
/**
|
|
597
|
+
* Return explicit Jiti alias entries for the schema package root and its
|
|
598
|
+
* public subpaths so app modules always reuse the same schema package instance.
|
|
599
|
+
*
|
|
600
|
+
* @internal
|
|
601
|
+
* Exported for Tango tooling/framework consumption only. This helper exists so
|
|
602
|
+
* Tango loaders can force app modules to reuse the active schema package
|
|
603
|
+
* instance during module execution. It is not intended as a stable application
|
|
604
|
+
* API, and the alias map may be more permissive than the package exports
|
|
605
|
+
* surface by design.
|
|
606
|
+
*/
|
|
607
|
+
declare function createSchemaModuleAliases(): Record<string, string>;
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region src/model/registry/GeneratedRelationRegistryArtifact.d.ts
|
|
610
|
+
declare const GENERATED_RELATION_REGISTRY_DIRNAME = ".tango";
|
|
611
|
+
declare const GENERATED_RELATION_REGISTRY_TYPES_FILENAME = "relations.generated.d.ts";
|
|
612
|
+
declare const GENERATED_RELATION_REGISTRY_METADATA_FILENAME = "relations.generated.json";
|
|
613
|
+
declare const GENERATED_RELATION_REGISTRY_METADATA_VERSION = 1;
|
|
614
|
+
type GeneratedRelationRegistryArtifact = {
|
|
615
|
+
version: typeof GENERATED_RELATION_REGISTRY_METADATA_VERSION;
|
|
616
|
+
fingerprint: string;
|
|
617
|
+
snapshot: ResolvedRelationGraphSnapshot;
|
|
618
|
+
};
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/model/registry/ResolvedRelationGraphArtifactFactory.d.ts
|
|
621
|
+
/**
|
|
622
|
+
* Build canonical serialized artifacts from a resolved relation graph.
|
|
623
|
+
*
|
|
624
|
+
* Generation, drift detection, and related tooling all need the same stable
|
|
625
|
+
* snapshot shape and fingerprinting rules, so that work lives behind one class
|
|
626
|
+
* instead of a pair of free functions.
|
|
627
|
+
*/
|
|
628
|
+
declare class ResolvedRelationGraphArtifactFactory {
|
|
629
|
+
static createSnapshot(graph: ResolvedRelationGraph): ResolvedRelationGraphSnapshot;
|
|
630
|
+
static createFingerprint(value: ResolvedRelationGraph | ResolvedRelationGraphSnapshot): string;
|
|
631
|
+
}
|
|
632
|
+
declare namespace index_d_exports$2 {
|
|
633
|
+
export { GENERATED_RELATION_REGISTRY_DIRNAME, GENERATED_RELATION_REGISTRY_METADATA_FILENAME, GENERATED_RELATION_REGISTRY_METADATA_VERSION, GENERATED_RELATION_REGISTRY_TYPES_FILENAME, GeneratedRelationRegistryArtifact, ModelRegistry, ResolvedRelationGraphArtifactFactory, ResolvedRelationGraphSnapshot, ResolvedRelationGraphSnapshotModel, ResolvedRelationGraphSnapshotRelation, createSchemaModuleAliases, resolveSchemaModuleEntrypoint };
|
|
634
|
+
}
|
|
635
|
+
//#endregion
|
|
636
|
+
//#region src/model/relations/RelationBuilder.d.ts
|
|
637
|
+
/**
|
|
638
|
+
* Public authoring DSL for model-level named relations.
|
|
639
|
+
*
|
|
640
|
+
* This is the first stage of the relations subdomain. Application code uses it
|
|
641
|
+
* inside `relations: (r) => ({ ... })` to declare stable relation names and
|
|
642
|
+
* resolve ambiguity that field decorators alone cannot express.
|
|
643
|
+
*
|
|
644
|
+
* Later internal stages normalize these authored definitions and combine them
|
|
645
|
+
* with field-authored relation metadata to build the resolved relation graph.
|
|
646
|
+
*/
|
|
647
|
+
declare class RelationBuilder {
|
|
648
|
+
/** Declare a one-to-many relation from this model to `target`. */
|
|
649
|
+
hasMany(target: string, foreignKey: string): RelationDef;
|
|
650
|
+
/** Declare an owning relation to a parent model. */
|
|
651
|
+
belongsTo(target: string, foreignKey: string, localKey?: string): RelationDef;
|
|
652
|
+
/** Declare a one-to-one relation from this model to `target`. */
|
|
653
|
+
hasOne(target: string, foreignKey: string): RelationDef;
|
|
654
|
+
}
|
|
655
|
+
declare namespace index_d_exports$1 {
|
|
656
|
+
export { RelationBuilder };
|
|
657
|
+
}
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/model/ModelDefinition.d.ts
|
|
660
|
+
interface ModelDefinition<TSchema extends z.ZodObject<z.ZodRawShape>> {
|
|
661
|
+
namespace: string;
|
|
662
|
+
name: string;
|
|
663
|
+
table?: string;
|
|
664
|
+
schema: TSchema;
|
|
665
|
+
registry?: ModelRegistry;
|
|
666
|
+
fields?: Field[];
|
|
667
|
+
indexes?: IndexDef[];
|
|
668
|
+
relations?: (builder: RelationBuilder) => Record<string, RelationDef>;
|
|
669
|
+
ordering?: string[];
|
|
670
|
+
managed?: boolean;
|
|
671
|
+
defaultRelatedName?: string;
|
|
672
|
+
constraints?: unknown[];
|
|
673
|
+
/**
|
|
674
|
+
* Model-owned write lifecycle hooks that run inside `Model.objects`.
|
|
675
|
+
*/
|
|
676
|
+
hooks?: ModelWriteHooks<PersistedModelOutput<TSchema>>;
|
|
677
|
+
}
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/model/relations/ImplicitManyToManyIdentifier.d.ts
|
|
680
|
+
/**
|
|
681
|
+
* Single source of truth for identity of Tango-synthesized many-to-many
|
|
682
|
+
* through models. Other parts of the schema package interact with synthesized
|
|
683
|
+
* models exclusively through this class so they do not have to know the
|
|
684
|
+
* namespace or digest scheme those keys encode.
|
|
685
|
+
*/
|
|
686
|
+
declare class ImplicitManyToManyIdentifier {
|
|
687
|
+
private static readonly NAMESPACE;
|
|
688
|
+
/**
|
|
689
|
+
* Stable model key for the synthesized through model connecting
|
|
690
|
+
* `sourceModelKey` to `targetModelKey` via the schema field
|
|
691
|
+
* `sourceSchemaFieldKey`.
|
|
692
|
+
*
|
|
693
|
+
* The returned key is deterministic across runs so storage and hydration
|
|
694
|
+
* artifacts stay stable as long as the inputs match.
|
|
695
|
+
*/
|
|
696
|
+
static getModelKey(sourceModelKey: string, sourceSchemaFieldKey: string, targetModelKey: string): string;
|
|
697
|
+
/**
|
|
698
|
+
* Deterministic short digest used to derive the physical join-table name
|
|
699
|
+
* for a synthesized through model. Shorter than the model-key digest so
|
|
700
|
+
* table names stay within common SQL identifier limits.
|
|
701
|
+
*/
|
|
702
|
+
static getTableBaseDigest(sourceModelKey: string, sourceSchemaFieldKey: string, targetModelKey: string): string;
|
|
703
|
+
/**
|
|
704
|
+
* True when `modelKey` was produced by {@link getModelKey} and therefore
|
|
705
|
+
* identifies a synthesized through model. Callers use this instead of
|
|
706
|
+
* comparing namespace prefixes so the namespace remains an implementation
|
|
707
|
+
* detail of this class.
|
|
708
|
+
*/
|
|
709
|
+
static isImplicitManyToManyModel(modelKey: string): boolean;
|
|
710
|
+
/**
|
|
711
|
+
* Namespace under which synthesized through models are registered.
|
|
712
|
+
* Exposed so {@link ImplicitManyToManyThroughFactory} can construct the
|
|
713
|
+
* model with the correct namespace. External callers that want to ask
|
|
714
|
+
* "is this an implicit model" should prefer {@link isImplicitManyToManyModel}.
|
|
715
|
+
*/
|
|
716
|
+
static getNamespace(): string;
|
|
717
|
+
/**
|
|
718
|
+
* Extract the `m2m_<digest>` component of a synthesized model key so the
|
|
719
|
+
* factory can register the through model with a deterministic name while
|
|
720
|
+
* keeping the namespace owned by this class.
|
|
721
|
+
*/
|
|
722
|
+
static getModelName(modelKey: string): string;
|
|
723
|
+
private static digest;
|
|
724
|
+
}
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region src/model/Model.d.ts
|
|
727
|
+
/**
|
|
728
|
+
* Creates a model definition with metadata and schema validation.
|
|
729
|
+
* Automatically finalizes field types through the owning model registry.
|
|
730
|
+
*/
|
|
731
|
+
declare function Model<const TNamespace extends string, const TName extends string, TSchema extends z.ZodObject<z.ZodRawShape>>(definition: ModelDefinition<TSchema> & {
|
|
732
|
+
namespace: TNamespace;
|
|
733
|
+
name: TName;
|
|
734
|
+
}): Model$1<TSchema, `${TNamespace}/${TName}`>;
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/model/ModelAugmentorRegistry.d.ts
|
|
737
|
+
type ModelAugmentor = <TSchema extends z.ZodObject<z.ZodRawShape>, TKey extends string>(model: Model$1<TSchema, TKey>) => void;
|
|
738
|
+
/**
|
|
739
|
+
* Register a model augmentor that runs for existing and future models.
|
|
740
|
+
*/
|
|
741
|
+
declare function registerModelAugmentor(augmentor: ModelAugmentor): () => void;
|
|
742
|
+
declare namespace index_d_exports {
|
|
743
|
+
export { ConstraintDefinition, Constraints, DecoratedFieldKind, Decorators, FieldDecoratorBuilder, ForeignKeyDecoratorConfig, GENERATED_RELATION_REGISTRY_DIRNAME, GENERATED_RELATION_REGISTRY_METADATA_FILENAME, GENERATED_RELATION_REGISTRY_METADATA_VERSION, GENERATED_RELATION_REGISTRY_TYPES_FILENAME, GeneratedRelationRegistryArtifact, ImplicitManyToManyIdentifier, Indexes, InternalDecoratedFieldKind, ManyToManyDecoratorConfig, Meta, Model, ModelConstraint, ModelDefinition, ModelMetaFragment, ModelRef, ModelRefTarget, ModelRegistry, OneToOneDecoratorConfig, RelationBuilder, RelationDecoratedSchema, ResolvedRelationGraphArtifactFactory, ResolvedRelationGraphSnapshot, ResolvedRelationGraphSnapshotModel, ResolvedRelationGraphSnapshotRelation, TangoDecorators, TypedModelRef, Constraints as c, index_d_exports$3 as constraints, createSchemaModuleAliases, createTypedModelRef, index_d_exports$5 as decorators, Indexes as i, isTypedModelRef, Meta as m, index_d_exports$4 as meta, registerModelAugmentor, index_d_exports$2 as registry, index_d_exports$1 as relations, resolveSchemaModuleEntrypoint, Decorators as t };
|
|
744
|
+
}
|
|
745
|
+
//#endregion
|
|
746
|
+
export { Decorators as A, isTypedModelRef as B, ConstraintDefinition as C, ModelConstraint as D, Meta as E, OneToOneDecoratorConfig as F, ModelRef as I, ModelRefTarget as L, TangoDecorators as M, ForeignKeyDecoratorConfig as N, ModelMetaFragment as O, ManyToManyDecoratorConfig as P, TypedModelRef as R, Indexes as S, index_d_exports$4 as T, ModelRegistry as _, ModelDefinition as a, ResolvedRelationGraphSnapshotRelation as b, index_d_exports$2 as c, GENERATED_RELATION_REGISTRY_METADATA_FILENAME as d, GENERATED_RELATION_REGISTRY_METADATA_VERSION as f, resolveSchemaModuleEntrypoint as g, createSchemaModuleAliases as h, ImplicitManyToManyIdentifier as i, FieldDecoratorBuilder as j, index_d_exports$5 as k, ResolvedRelationGraphArtifactFactory as l, GeneratedRelationRegistryArtifact as m, registerModelAugmentor as n, index_d_exports$1 as o, GENERATED_RELATION_REGISTRY_TYPES_FILENAME as p, Model as r, RelationBuilder as s, index_d_exports as t, GENERATED_RELATION_REGISTRY_DIRNAME as u, ResolvedRelationGraphSnapshot as v, Constraints as w, index_d_exports$3 as x, ResolvedRelationGraphSnapshotModel as y, createTypedModelRef as z };
|
|
747
|
+
//# sourceMappingURL=index-DXFf5XNn.d.ts.map
|