@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,129 +0,0 @@
|
|
|
1
|
-
import type { Field, Model } from '../../domain/index';
|
|
2
|
-
import { type ModelRef } from '../decorators/domain/ModelRef';
|
|
3
|
-
import type { FinalizedStorageArtifacts } from '../fields/FinalizedStorageArtifacts';
|
|
4
|
-
import type { ResolvedRelationGraph } from '../relations/ResolvedRelationGraph';
|
|
5
|
-
import type { ResolvedRelationGraphSnapshot } from './ResolvedRelationGraphSnapshot';
|
|
6
|
-
/**
|
|
7
|
-
* Registry that resolves Tango models by stable identity.
|
|
8
|
-
*
|
|
9
|
-
* The default shared registry is convenient for application bootstrapping
|
|
10
|
-
* within one schema package instance, while dedicated instances are useful in
|
|
11
|
-
* tests and tooling. Explicit active-registry binding stays process-shared so
|
|
12
|
-
* tooling can construct models across separate schema package copies without
|
|
13
|
-
* relying on the ambient default registry.
|
|
14
|
-
*/
|
|
15
|
-
export declare class ModelRegistry {
|
|
16
|
-
private static globalRegistry?;
|
|
17
|
-
private readonly models;
|
|
18
|
-
private version;
|
|
19
|
-
private storageCache?;
|
|
20
|
-
private relationGraphCache?;
|
|
21
|
-
private lastRelationRegistryDriftCheckVersion?;
|
|
22
|
-
/**
|
|
23
|
-
* Return the shared default registry used by `Model(...)` for this schema
|
|
24
|
-
* package instance.
|
|
25
|
-
*/
|
|
26
|
-
static global(): ModelRegistry;
|
|
27
|
-
/**
|
|
28
|
-
* Return the registry currently bound to model construction work.
|
|
29
|
-
*
|
|
30
|
-
* This explicit binding is process-shared so code that imports separate
|
|
31
|
-
* schema package copies can still participate in one construction flow.
|
|
32
|
-
*/
|
|
33
|
-
static active(): ModelRegistry;
|
|
34
|
-
/**
|
|
35
|
-
* Run work with a specific registry bound as the active construction target.
|
|
36
|
-
*/
|
|
37
|
-
static runWithRegistry<T>(registry: ModelRegistry, work: () => Promise<T> | T): Promise<T>;
|
|
38
|
-
/**
|
|
39
|
-
* Register a model on the shared global registry.
|
|
40
|
-
*/
|
|
41
|
-
static register(model: Model): void;
|
|
42
|
-
/**
|
|
43
|
-
* Register several models on the shared global registry.
|
|
44
|
-
*/
|
|
45
|
-
static registerMany(models: readonly Model[]): void;
|
|
46
|
-
/**
|
|
47
|
-
* Resolve a model from the shared registry by namespace and name.
|
|
48
|
-
*/
|
|
49
|
-
static get(namespace: string, name: string): Model | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Resolve a model from the shared registry by its `namespace/name` key.
|
|
52
|
-
*/
|
|
53
|
-
static getByKey(key: string): Model | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Resolve any supported model reference form against the shared registry.
|
|
56
|
-
*/
|
|
57
|
-
static resolveRef(ref: ModelRef): Model;
|
|
58
|
-
/**
|
|
59
|
-
* Clear the shared registry, which is mainly useful in tests.
|
|
60
|
-
*/
|
|
61
|
-
static clear(): void;
|
|
62
|
-
/**
|
|
63
|
-
* Return the owning registry for a model.
|
|
64
|
-
*/
|
|
65
|
-
static getOwner(model: {
|
|
66
|
-
metadata: {
|
|
67
|
-
key?: string;
|
|
68
|
-
};
|
|
69
|
-
} & object): ModelRegistry;
|
|
70
|
-
private static runtimeGlobal;
|
|
71
|
-
private static activeRegistryStorage;
|
|
72
|
-
/**
|
|
73
|
-
* Register a model on this registry instance.
|
|
74
|
-
*/
|
|
75
|
-
register(model: Model): void;
|
|
76
|
-
/**
|
|
77
|
-
* Register several models on this registry instance.
|
|
78
|
-
*/
|
|
79
|
-
registerMany(models: readonly Model[]): void;
|
|
80
|
-
/**
|
|
81
|
-
* Resolve a model from this registry instance by namespace and name.
|
|
82
|
-
*/
|
|
83
|
-
get(namespace: string, name: string): Model | undefined;
|
|
84
|
-
/**
|
|
85
|
-
* Resolve a model from this registry instance by its `namespace/name` key.
|
|
86
|
-
*/
|
|
87
|
-
getByKey(key: string): Model | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* Resolve a string, callback, or direct model reference into a model object.
|
|
90
|
-
*/
|
|
91
|
-
resolveRef(ref: ModelRef): Model;
|
|
92
|
-
/**
|
|
93
|
-
* Finalize storage-only artifacts for all models in this registry.
|
|
94
|
-
*/
|
|
95
|
-
finalizeStorageArtifacts(): FinalizedStorageArtifacts;
|
|
96
|
-
/**
|
|
97
|
-
* Return finalized storage fields for a specific model.
|
|
98
|
-
*/
|
|
99
|
-
getFinalizedFields(model: Model | string): readonly Field[];
|
|
100
|
-
/**
|
|
101
|
-
* Resolve the registry's relation graph from finalized storage artifacts.
|
|
102
|
-
*/
|
|
103
|
-
getResolvedRelationGraph(): ResolvedRelationGraph;
|
|
104
|
-
/**
|
|
105
|
-
* Return a canonical snapshot of the resolved relation graph.
|
|
106
|
-
*/
|
|
107
|
-
getResolvedRelationGraphSnapshot(): ResolvedRelationGraphSnapshot;
|
|
108
|
-
/**
|
|
109
|
-
* Return a deterministic fingerprint for the resolved relation graph.
|
|
110
|
-
*/
|
|
111
|
-
getResolvedRelationGraphFingerprint(): string;
|
|
112
|
-
/**
|
|
113
|
-
* Remove all registered models from this registry instance.
|
|
114
|
-
*/
|
|
115
|
-
clear(): void;
|
|
116
|
-
/**
|
|
117
|
-
* Return all registered models in insertion order.
|
|
118
|
-
*/
|
|
119
|
-
values(): readonly Model[];
|
|
120
|
-
private bumpVersion;
|
|
121
|
-
private stripImplicitManyToManyModels;
|
|
122
|
-
private freezeFields;
|
|
123
|
-
private inferPrimaryKeyName;
|
|
124
|
-
private mergeStorageFields;
|
|
125
|
-
private warnOnGeneratedRelationRegistryDrift;
|
|
126
|
-
private shouldCheckGeneratedRelationRegistry;
|
|
127
|
-
private readGeneratedRelationRegistryArtifact;
|
|
128
|
-
private isPartialRegistrySnapshot;
|
|
129
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ResolvedRelationGraph } from '../relations/ResolvedRelationGraph';
|
|
2
|
-
import type { ResolvedRelationGraphSnapshot } from './ResolvedRelationGraphSnapshot';
|
|
3
|
-
/**
|
|
4
|
-
* Build canonical serialized artifacts from a resolved relation graph.
|
|
5
|
-
*
|
|
6
|
-
* Generation, drift detection, and related tooling all need the same stable
|
|
7
|
-
* snapshot shape and fingerprinting rules, so that work lives behind one class
|
|
8
|
-
* instead of a pair of free functions.
|
|
9
|
-
*/
|
|
10
|
-
export declare class ResolvedRelationGraphArtifactFactory {
|
|
11
|
-
static createSnapshot(graph: ResolvedRelationGraph): ResolvedRelationGraphSnapshot;
|
|
12
|
-
static createFingerprint(value: ResolvedRelationGraph | ResolvedRelationGraphSnapshot): string;
|
|
13
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import type { RelationCardinality, RelationPublicKind, RelationStorageStrategy } from '../relations/RelationSpec';
|
|
2
|
-
/**
|
|
3
|
-
* Serializable snapshot of a single relation edge from the resolved relation
|
|
4
|
-
* graph. Snapshots are the stable, build-time wire format consumed by codegen
|
|
5
|
-
* and by tooling that compares the graph across runs.
|
|
6
|
-
*
|
|
7
|
-
* A snapshot row captures both the abstract edge identity (who connects to
|
|
8
|
-
* whom, under what public name) and the physical storage details (local
|
|
9
|
-
* fields, join columns, through-model coordinates) needed to translate the
|
|
10
|
-
* edge into SQL later.
|
|
11
|
-
*/
|
|
12
|
-
export type ResolvedRelationGraphSnapshotRelation = {
|
|
13
|
-
/**
|
|
14
|
-
* Stable identifier for this edge within the graph. Used to cross-reference
|
|
15
|
-
* an edge with its inverse and to detect drift between snapshots.
|
|
16
|
-
*/
|
|
17
|
-
edgeId: string;
|
|
18
|
-
/** Model key of the endpoint that owns this edge in the resolved graph. */
|
|
19
|
-
sourceModelKey: string;
|
|
20
|
-
/** Model key of the endpoint this edge points at. */
|
|
21
|
-
targetModelKey: string;
|
|
22
|
-
/**
|
|
23
|
-
* Public relation name exposed to application code and query builders
|
|
24
|
-
* (for example `author` or `tags`).
|
|
25
|
-
*/
|
|
26
|
-
name: string;
|
|
27
|
-
/**
|
|
28
|
-
* Identifier of the paired edge on the opposite endpoint, when one exists.
|
|
29
|
-
* Bidirectional relations populate this; one-way edges leave it unset.
|
|
30
|
-
*/
|
|
31
|
-
inverseEdgeId?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Public relation kind (`belongsTo`, `hasMany`, `manyToMany`, ...).
|
|
34
|
-
*/
|
|
35
|
-
kind: RelationPublicKind;
|
|
36
|
-
/**
|
|
37
|
-
* How the edge is physically stored. Distinguishes direct foreign-key
|
|
38
|
-
* references from reverse references and join-table backed relations.
|
|
39
|
-
*/
|
|
40
|
-
storageStrategy: RelationStorageStrategy;
|
|
41
|
-
/** Whether the edge yields one target (`single`) or many (`many`). */
|
|
42
|
-
cardinality: RelationCardinality;
|
|
43
|
-
/**
|
|
44
|
-
* Owner-side column that stores the foreign key, when the edge is backed
|
|
45
|
-
* by a local reference column.
|
|
46
|
-
*/
|
|
47
|
-
localFieldName?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Target-side column the foreign key resolves against, when applicable.
|
|
50
|
-
*/
|
|
51
|
-
targetFieldName?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Model key of the synthesized or user-provided through model for
|
|
54
|
-
* many-to-many edges.
|
|
55
|
-
*/
|
|
56
|
-
throughModelKey?: string;
|
|
57
|
-
/** Physical join-table name for many-to-many edges. */
|
|
58
|
-
throughTable?: string;
|
|
59
|
-
/** Through-model schema field on the source side, if resolved. */
|
|
60
|
-
throughSourceFieldName?: string;
|
|
61
|
-
/** Through-model schema field on the target side, if resolved. */
|
|
62
|
-
throughTargetFieldName?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Physical join-table column that stores the owner-side primary key for
|
|
65
|
-
* many-to-many edges.
|
|
66
|
-
*/
|
|
67
|
-
throughSourceKey?: string;
|
|
68
|
-
/**
|
|
69
|
-
* Physical join-table column that stores the target-side primary key for
|
|
70
|
-
* many-to-many edges.
|
|
71
|
-
*/
|
|
72
|
-
throughTargetKey?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Alias used when the edge participates in SQL joins. Derived
|
|
75
|
-
* deterministically so compiled SQL is stable across runs.
|
|
76
|
-
*/
|
|
77
|
-
alias: string;
|
|
78
|
-
/**
|
|
79
|
-
* What this edge is allowed to participate in. The builder uses these
|
|
80
|
-
* flags to decide whether migrations emit DDL, queries can select over
|
|
81
|
-
* the edge, and hydration can populate the related attribute.
|
|
82
|
-
*/
|
|
83
|
-
capabilities: {
|
|
84
|
-
/** Whether migration tooling should emit DDL for this edge. */
|
|
85
|
-
migratable: boolean;
|
|
86
|
-
/** Whether the edge can appear as a hop in a query path. */
|
|
87
|
-
queryable: boolean;
|
|
88
|
-
/** Whether hydrators can populate the related attribute on a row. */
|
|
89
|
-
hydratable: boolean;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* Snapshot of one model's relation edges. Grouping edges by source model
|
|
94
|
-
* lets codegen walk the graph model-by-model without having to re-index.
|
|
95
|
-
*/
|
|
96
|
-
export type ResolvedRelationGraphSnapshotModel = {
|
|
97
|
-
/** Model key these relations source from. */
|
|
98
|
-
key: string;
|
|
99
|
-
/** Resolved outgoing relation edges in registration order. */
|
|
100
|
-
relations: ResolvedRelationGraphSnapshotRelation[];
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Top-level serializable snapshot of the resolved relation graph for a
|
|
104
|
-
* registry. Written to disk by codegen and diffed across runs to detect
|
|
105
|
-
* registry drift.
|
|
106
|
-
*/
|
|
107
|
-
export type ResolvedRelationGraphSnapshot = {
|
|
108
|
-
/** Per-model relation snapshots in registration order. */
|
|
109
|
-
models: ResolvedRelationGraphSnapshotModel[];
|
|
110
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain boundary barrel: centralizes this subdomain's public contract.
|
|
3
|
-
*/
|
|
4
|
-
export { ModelRegistry } from './ModelRegistry';
|
|
5
|
-
export { createSchemaModuleAliases, resolveSchemaModuleEntrypoint } from '../../resolveSchemaModuleEntrypoint';
|
|
6
|
-
export { GENERATED_RELATION_REGISTRY_DIRNAME, GENERATED_RELATION_REGISTRY_METADATA_FILENAME, GENERATED_RELATION_REGISTRY_METADATA_VERSION, GENERATED_RELATION_REGISTRY_TYPES_FILENAME, type GeneratedRelationRegistryArtifact, } from './GeneratedRelationRegistryArtifact';
|
|
7
|
-
export { ResolvedRelationGraphArtifactFactory } from './ResolvedRelationGraphArtifactFactory';
|
|
8
|
-
export { type ResolvedRelationGraphSnapshot, type ResolvedRelationGraphSnapshotModel, type ResolvedRelationGraphSnapshotRelation, } from './ResolvedRelationGraphSnapshot';
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Single source of truth for identity of Tango-synthesized many-to-many
|
|
3
|
-
* through models. Other parts of the schema package interact with synthesized
|
|
4
|
-
* models exclusively through this class so they do not have to know the
|
|
5
|
-
* namespace or digest scheme those keys encode.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ImplicitManyToManyIdentifier {
|
|
8
|
-
private static readonly NAMESPACE;
|
|
9
|
-
/**
|
|
10
|
-
* Stable model key for the synthesized through model connecting
|
|
11
|
-
* `sourceModelKey` to `targetModelKey` via the schema field
|
|
12
|
-
* `sourceSchemaFieldKey`.
|
|
13
|
-
*
|
|
14
|
-
* The returned key is deterministic across runs so storage and hydration
|
|
15
|
-
* artifacts stay stable as long as the inputs match.
|
|
16
|
-
*/
|
|
17
|
-
static getModelKey(sourceModelKey: string, sourceSchemaFieldKey: string, targetModelKey: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Deterministic short digest used to derive the physical join-table name
|
|
20
|
-
* for a synthesized through model. Shorter than the model-key digest so
|
|
21
|
-
* table names stay within common SQL identifier limits.
|
|
22
|
-
*/
|
|
23
|
-
static getTableBaseDigest(sourceModelKey: string, sourceSchemaFieldKey: string, targetModelKey: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* True when `modelKey` was produced by {@link getModelKey} and therefore
|
|
26
|
-
* identifies a synthesized through model. Callers use this instead of
|
|
27
|
-
* comparing namespace prefixes so the namespace remains an implementation
|
|
28
|
-
* detail of this class.
|
|
29
|
-
*/
|
|
30
|
-
static isImplicitManyToManyModel(modelKey: string): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Namespace under which synthesized through models are registered.
|
|
33
|
-
* Exposed so {@link ImplicitManyToManyThroughFactory} can construct the
|
|
34
|
-
* model with the correct namespace. External callers that want to ask
|
|
35
|
-
* "is this an implicit model" should prefer {@link isImplicitManyToManyModel}.
|
|
36
|
-
*/
|
|
37
|
-
static getNamespace(): string;
|
|
38
|
-
/**
|
|
39
|
-
* Extract the `m2m_<digest>` component of a synthesized model key so the
|
|
40
|
-
* factory can register the through model with a deterministic name while
|
|
41
|
-
* keeping the namespace owned by this class.
|
|
42
|
-
*/
|
|
43
|
-
static getModelName(modelKey: string): string;
|
|
44
|
-
private static digest;
|
|
45
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Model } from '../../domain/index';
|
|
2
|
-
import type { ModelRegistry } from '../registry/ModelRegistry';
|
|
3
|
-
export declare class ImplicitManyToManyThroughFactory {
|
|
4
|
-
static throughFieldNames(sourceModel: Model, targetModel: Model): {
|
|
5
|
-
throughSourceFieldName: string;
|
|
6
|
-
throughTargetFieldName: string;
|
|
7
|
-
};
|
|
8
|
-
static buildModels(registry: ModelRegistry): Model[];
|
|
9
|
-
private static unwrapForForeignKeyField;
|
|
10
|
-
private static clonePrimaryKeySchemaForForeignKey;
|
|
11
|
-
private static readSinglePrimaryKey;
|
|
12
|
-
private static collectImplicitDescriptors;
|
|
13
|
-
private static allocateTableName;
|
|
14
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { DeleteReferentialAction, UpdateReferentialAction } from '../../domain/index';
|
|
2
|
-
import type { ModelRef } from '../decorators/domain/ModelRef';
|
|
3
|
-
export declare const InternalNormalizedRelationOrigin: {
|
|
4
|
-
readonly FOREIGN_KEY: "foreignKey";
|
|
5
|
-
readonly ONE_TO_ONE: "oneToOne";
|
|
6
|
-
readonly MANY_TO_MANY: "manyToMany";
|
|
7
|
-
};
|
|
8
|
-
export type NormalizedRelationOrigin = (typeof InternalNormalizedRelationOrigin)[keyof typeof InternalNormalizedRelationOrigin];
|
|
9
|
-
/**
|
|
10
|
-
* Registry-independent relation descriptor produced immediately after model
|
|
11
|
-
* construction.
|
|
12
|
-
*
|
|
13
|
-
* This is the handoff object between relation authoring and relation
|
|
14
|
-
* resolution. It preserves field-authored relation intent in a normalized form
|
|
15
|
-
* without yet assigning public reverse names or resolved graph edges.
|
|
16
|
-
*/
|
|
17
|
-
export interface NormalizedRelationStorageDescriptor {
|
|
18
|
-
edgeId: string;
|
|
19
|
-
sourceModelKey: string;
|
|
20
|
-
sourceSchemaFieldKey: string;
|
|
21
|
-
targetRef: ModelRef;
|
|
22
|
-
origin: NormalizedRelationOrigin;
|
|
23
|
-
localFieldName: string;
|
|
24
|
-
dbColumnName: string;
|
|
25
|
-
referencedTargetColumn?: string;
|
|
26
|
-
onDelete?: DeleteReferentialAction;
|
|
27
|
-
onUpdate?: UpdateReferentialAction;
|
|
28
|
-
unique?: boolean;
|
|
29
|
-
explicitForwardName?: string;
|
|
30
|
-
explicitReverseName?: string;
|
|
31
|
-
namingHint: string;
|
|
32
|
-
throughModelRef?: ModelRef;
|
|
33
|
-
throughSourceFieldName?: string;
|
|
34
|
-
throughTargetFieldName?: string;
|
|
35
|
-
provenance: 'field-decorator';
|
|
36
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { RelationDef } from '../../domain/index';
|
|
2
|
-
/**
|
|
3
|
-
* Public authoring DSL for model-level named relations.
|
|
4
|
-
*
|
|
5
|
-
* This is the first stage of the relations subdomain. Application code uses it
|
|
6
|
-
* inside `relations: (r) => ({ ... })` to declare stable relation names and
|
|
7
|
-
* resolve ambiguity that field decorators alone cannot express.
|
|
8
|
-
*
|
|
9
|
-
* Later internal stages normalize these authored definitions and combine them
|
|
10
|
-
* with field-authored relation metadata to build the resolved relation graph.
|
|
11
|
-
*/
|
|
12
|
-
export declare class RelationBuilder {
|
|
13
|
-
/** Declare a one-to-many relation from this model to `target`. */
|
|
14
|
-
hasMany(target: string, foreignKey: string): RelationDef;
|
|
15
|
-
/** Declare an owning relation to a parent model. */
|
|
16
|
-
belongsTo(target: string, foreignKey: string, localKey?: string): RelationDef;
|
|
17
|
-
/** Declare a one-to-one relation from this model to `target`. */
|
|
18
|
-
hasOne(target: string, foreignKey: string): RelationDef;
|
|
19
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { NormalizedRelationStorageDescriptor } from './NormalizedRelationStorageDescriptor';
|
|
3
|
-
/**
|
|
4
|
-
* Normalizes field-authored relation declarations from a model schema into the
|
|
5
|
-
* shared descriptor shape consumed by storage and relation finalization.
|
|
6
|
-
*
|
|
7
|
-
* This is the normalization stage of the relations subdomain. It sits between
|
|
8
|
-
* authoring and resolution:
|
|
9
|
-
*
|
|
10
|
-
* - authoring: decorators attach relation intent to schema fields
|
|
11
|
-
* - normalization: this class converts that intent into a registry-independent
|
|
12
|
-
* descriptor shape
|
|
13
|
-
* - resolution: the graph builder combines those descriptors with finalized
|
|
14
|
-
* storage artifacts and explicit relation names
|
|
15
|
-
*/
|
|
16
|
-
export declare class RelationDescriptorNormalizer {
|
|
17
|
-
private readonly sourceModelKey;
|
|
18
|
-
private readonly schema;
|
|
19
|
-
constructor(sourceModelKey: string, schema: z.ZodObject<z.ZodRawShape>);
|
|
20
|
-
static normalize(sourceModelKey: string, schema: z.ZodObject<z.ZodRawShape>): readonly NormalizedRelationStorageDescriptor[];
|
|
21
|
-
/**
|
|
22
|
-
* Run the field-authored relation normalization pipeline for one model
|
|
23
|
-
* schema and emit descriptors that later relation stages can resolve.
|
|
24
|
-
*/
|
|
25
|
-
normalize(): readonly NormalizedRelationStorageDescriptor[];
|
|
26
|
-
private collectRelationCandidates;
|
|
27
|
-
private normalizeCandidate;
|
|
28
|
-
private buildEdgeId;
|
|
29
|
-
private deriveNamingHint;
|
|
30
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export declare const InternalRelationPublicKind: {
|
|
2
|
-
readonly BELONGS_TO: "belongsTo";
|
|
3
|
-
readonly HAS_ONE: "hasOne";
|
|
4
|
-
readonly HAS_MANY: "hasMany";
|
|
5
|
-
readonly MANY_TO_MANY: "manyToMany";
|
|
6
|
-
};
|
|
7
|
-
export declare const InternalRelationStorageStrategy: {
|
|
8
|
-
readonly REFERENCE: "reference";
|
|
9
|
-
readonly REVERSE_REFERENCE: "reverse_reference";
|
|
10
|
-
readonly MANY_TO_MANY: "many_to_many";
|
|
11
|
-
};
|
|
12
|
-
export declare const InternalRelationCardinality: {
|
|
13
|
-
readonly SINGLE: "single";
|
|
14
|
-
readonly MANY: "many";
|
|
15
|
-
};
|
|
16
|
-
export declare const InternalRelationProvenance: {
|
|
17
|
-
readonly FIELD_DECORATOR: "field-decorator";
|
|
18
|
-
readonly RELATIONS_API: "relations-api";
|
|
19
|
-
readonly SYNTHESIZED_REVERSE: "synthesized-reverse";
|
|
20
|
-
};
|
|
21
|
-
export type RelationPublicKind = (typeof InternalRelationPublicKind)[keyof typeof InternalRelationPublicKind];
|
|
22
|
-
export type RelationStorageStrategy = (typeof InternalRelationStorageStrategy)[keyof typeof InternalRelationStorageStrategy];
|
|
23
|
-
export type RelationCardinality = (typeof InternalRelationCardinality)[keyof typeof InternalRelationCardinality];
|
|
24
|
-
export type RelationProvenance = (typeof InternalRelationProvenance)[keyof typeof InternalRelationProvenance];
|
|
25
|
-
/**
|
|
26
|
-
* Author-time relation intent after target resolution but before full graph
|
|
27
|
-
* pairing and naming.
|
|
28
|
-
*
|
|
29
|
-
* This type is the conceptual bridge between normalized descriptors and the
|
|
30
|
-
* fully resolved graph. It exists so the relations subdomain has a stable
|
|
31
|
-
* vocabulary for relation kinds, storage strategies, and provenance as the
|
|
32
|
-
* pipeline becomes more sophisticated.
|
|
33
|
-
*/
|
|
34
|
-
export interface RelationSpec {
|
|
35
|
-
edgeId: string;
|
|
36
|
-
sourceModelKey: string;
|
|
37
|
-
sourceSchemaFieldKey?: string;
|
|
38
|
-
targetModelKey: string;
|
|
39
|
-
kind: RelationPublicKind;
|
|
40
|
-
storageStrategy: RelationStorageStrategy;
|
|
41
|
-
localFieldName?: string;
|
|
42
|
-
targetFieldName?: string;
|
|
43
|
-
nameHint?: string;
|
|
44
|
-
throughModelKey?: string;
|
|
45
|
-
throughSourceFieldName?: string;
|
|
46
|
-
throughTargetFieldName?: string;
|
|
47
|
-
provenance: RelationProvenance;
|
|
48
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { RelationCardinality, RelationProvenance, RelationStorageStrategy, RelationPublicKind } from './RelationSpec';
|
|
2
|
-
/**
|
|
3
|
-
* Fully resolved relation edge published by the registry after storage
|
|
4
|
-
* artifacts are finalized.
|
|
5
|
-
*
|
|
6
|
-
* This is the resolution-stage shape consumed by ORM-facing relation metadata.
|
|
7
|
-
* Each descriptor has final naming, cardinality, key mapping, and capability
|
|
8
|
-
* flags that describe whether the edge is currently migratable, queryable, and
|
|
9
|
-
* hydratable.
|
|
10
|
-
*/
|
|
11
|
-
export interface ResolvedRelationDescriptor {
|
|
12
|
-
edgeId: string;
|
|
13
|
-
sourceModelKey: string;
|
|
14
|
-
targetModelKey: string;
|
|
15
|
-
name: string;
|
|
16
|
-
inverseEdgeId?: string;
|
|
17
|
-
kind: RelationPublicKind;
|
|
18
|
-
storageStrategy: RelationStorageStrategy;
|
|
19
|
-
cardinality: RelationCardinality;
|
|
20
|
-
localFieldName?: string;
|
|
21
|
-
targetFieldName?: string;
|
|
22
|
-
throughModelKey?: string;
|
|
23
|
-
throughTable?: string;
|
|
24
|
-
throughSourceFieldName?: string;
|
|
25
|
-
throughTargetFieldName?: string;
|
|
26
|
-
throughSourceKey?: string;
|
|
27
|
-
throughTargetKey?: string;
|
|
28
|
-
capabilities: {
|
|
29
|
-
migratable: boolean;
|
|
30
|
-
queryable: boolean;
|
|
31
|
-
hydratable: boolean;
|
|
32
|
-
};
|
|
33
|
-
provenance: RelationProvenance;
|
|
34
|
-
alias: string;
|
|
35
|
-
ambiguity?: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Registry-scoped relation graph built from normalized relation descriptors,
|
|
39
|
-
* explicit relation names, and finalized storage artifacts.
|
|
40
|
-
*
|
|
41
|
-
* This is the canonical resolved relation view for query planning and future
|
|
42
|
-
* hydration work. It is versioned because relation resolution is scoped to a
|
|
43
|
-
* specific registry snapshot.
|
|
44
|
-
*/
|
|
45
|
-
export interface ResolvedRelationGraph {
|
|
46
|
-
version: number;
|
|
47
|
-
byModel: ReadonlyMap<string, ReadonlyMap<string, ResolvedRelationDescriptor>>;
|
|
48
|
-
byEdgeId: ReadonlyMap<string, ResolvedRelationDescriptor>;
|
|
49
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { Model } from '../../domain/index';
|
|
2
|
-
import type { FinalizedStorageArtifacts } from '../fields/FinalizedStorageArtifacts';
|
|
3
|
-
import type { ResolvedRelationGraphSnapshot } from '../registry/ResolvedRelationGraphSnapshot';
|
|
4
|
-
import { type NormalizedRelationStorageDescriptor } from './NormalizedRelationStorageDescriptor';
|
|
5
|
-
import type { ResolvedRelationGraph } from './ResolvedRelationGraph';
|
|
6
|
-
type GraphBuilderOptions = {
|
|
7
|
-
version: number;
|
|
8
|
-
models: readonly Model[];
|
|
9
|
-
storage: FinalizedStorageArtifacts;
|
|
10
|
-
resolveRef: (ref: NormalizedRelationStorageDescriptor['targetRef']) => Model;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Resolution-stage builder that turns normalized relation descriptors into the
|
|
14
|
-
* registry-scoped resolved relation graph.
|
|
15
|
-
*
|
|
16
|
-
* This is the final pipeline stage in the relations subdomain. It combines:
|
|
17
|
-
*
|
|
18
|
-
* - normalized field-authored relation descriptors
|
|
19
|
-
* - explicit model-level relation names from `RelationBuilder`
|
|
20
|
-
* - finalized storage artifacts from the registry
|
|
21
|
-
*
|
|
22
|
-
* The result is the canonical named relation graph used by ORM-facing
|
|
23
|
-
* consumers.
|
|
24
|
-
*/
|
|
25
|
-
export declare class ResolvedRelationGraphBuilder {
|
|
26
|
-
private readonly options;
|
|
27
|
-
private readonly byModel;
|
|
28
|
-
private readonly byEdgeId;
|
|
29
|
-
private readonly matchedOverrides;
|
|
30
|
-
constructor(options: GraphBuilderOptions);
|
|
31
|
-
static build(options: GraphBuilderOptions): ResolvedRelationGraph;
|
|
32
|
-
/**
|
|
33
|
-
* Serialize a resolved graph into the canonical snapshot shape used by
|
|
34
|
-
* relation-registry code generation and fingerprinting.
|
|
35
|
-
*/
|
|
36
|
-
static createSnapshot(graph: ResolvedRelationGraph): ResolvedRelationGraphSnapshot;
|
|
37
|
-
/**
|
|
38
|
-
* Resolve every model's normalized relation descriptors into a single
|
|
39
|
-
* registry-scoped graph and fail when authoring ambiguity remains.
|
|
40
|
-
*/
|
|
41
|
-
build(): ResolvedRelationGraph;
|
|
42
|
-
private addModelRelations;
|
|
43
|
-
private addReferenceRelations;
|
|
44
|
-
private findForwardOverride;
|
|
45
|
-
private findReverseOverride;
|
|
46
|
-
private assertAllOverridesMatched;
|
|
47
|
-
private addResolvedRelation;
|
|
48
|
-
private getPrimaryKey;
|
|
49
|
-
private markOverrideMatched;
|
|
50
|
-
private buildOverrideMarker;
|
|
51
|
-
private resolveRelationTargetKey;
|
|
52
|
-
private deriveReverseName;
|
|
53
|
-
}
|
|
54
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared naming policy for the model and relations subdomains.
|
|
3
|
-
*
|
|
4
|
-
* These helpers are not an authoring or graph stage on their own. They are the
|
|
5
|
-
* cross-cutting policy layer used by both model construction and relation
|
|
6
|
-
* resolution when Tango derives table names, aliases, and synthesized relation
|
|
7
|
-
* names in a Django-style shape.
|
|
8
|
-
*/
|
|
9
|
-
export declare function toSnakeCase(value: string): string;
|
|
10
|
-
export declare function pluralize(value: string): string;
|
|
11
|
-
export declare function deriveTableName(name: string): string;
|
|
12
|
-
export declare function decapitalizeModelName(name: string): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Domain boundary barrel for relation authoring.
|
|
3
|
-
*
|
|
4
|
-
* The relations subdomain has three internal layers:
|
|
5
|
-
*
|
|
6
|
-
* - authoring: `RelationBuilder`
|
|
7
|
-
* - normalization: field-authored relations become normalized descriptors
|
|
8
|
-
* - resolution: normalized descriptors become the registry-scoped relation graph
|
|
9
|
-
*
|
|
10
|
-
* Only the authoring surface is exported here. The later pipeline stages stay
|
|
11
|
-
* internal until Tango intentionally publishes them as supported contracts.
|
|
12
|
-
*/
|
|
13
|
-
export { RelationBuilder } from './RelationBuilder';
|