@danceroutine/tango-schema 1.1.3 → 1.3.0

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.
Files changed (38) hide show
  1. package/dist/domain/Model.d.ts +17 -4
  2. package/dist/domain/index.d.ts +1 -1
  3. package/dist/domain-Cufz6y1q.js.map +1 -1
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +1 -1
  6. package/dist/model/Model.d.ts +5 -2
  7. package/dist/model/ModelAugmentorRegistry.d.ts +2 -2
  8. package/dist/model/ModelDefinition.d.ts +5 -3
  9. package/dist/model/decorators/Decorators.d.ts +54 -6
  10. package/dist/model/decorators/domain/DecoratedFieldKind.d.ts +6 -0
  11. package/dist/model/decorators/domain/ModelRef.d.ts +11 -0
  12. package/dist/model/decorators/domain/RelationDecoratedSchema.d.ts +24 -0
  13. package/dist/model/decorators/domain/RelationDecoratorConfig.d.ts +35 -0
  14. package/dist/model/decorators/{types.d.ts → domain/TangoFieldMeta.d.ts} +6 -5
  15. package/dist/model/decorators/domain/ZodTypeAny.d.ts +2 -0
  16. package/dist/model/decorators/index.d.ts +9 -2
  17. package/dist/model/{internal → fields}/FieldMetadataStore.d.ts +2 -1
  18. package/dist/model/fields/FinalizedStorageArtifacts.d.ts +11 -0
  19. package/dist/model/{inferFields.d.ts → fields/inferFieldsFromSchema.d.ts} +7 -2
  20. package/dist/model/index.d.ts +13 -3
  21. package/dist/model/index.js +2 -2
  22. package/dist/model/internal/InternalSchemaModel.d.ts +31 -0
  23. package/dist/model/registry/ModelRegistry.d.ts +35 -2
  24. package/dist/model/registry/index.d.ts +4 -0
  25. package/dist/model/relations/NormalizedRelationStorageDescriptor.d.ts +36 -0
  26. package/dist/model/relations/RelationBuilder.d.ts +19 -0
  27. package/dist/model/relations/RelationDescriptorNormalizer.d.ts +30 -0
  28. package/dist/model/relations/RelationSpec.d.ts +48 -0
  29. package/dist/model/relations/ResolvedRelationGraph.d.ts +43 -0
  30. package/dist/model/relations/ResolvedRelationGraphBuilder.d.ts +48 -0
  31. package/dist/model/relations/SchemaNaming.d.ts +11 -0
  32. package/dist/model/relations/index.d.ts +13 -0
  33. package/dist/model-YLW1ydkV.js +1144 -0
  34. package/dist/model-YLW1ydkV.js.map +1 -0
  35. package/package.json +3 -2
  36. package/dist/model/RelationBuilder.d.ts +0 -12
  37. package/dist/model-DI8lQH1W.js +0 -585
  38. package/dist/model-DI8lQH1W.js.map +0 -1
@@ -0,0 +1,48 @@
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
+ }
@@ -0,0 +1,43 @@
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
+ capabilities: {
23
+ migratable: boolean;
24
+ queryable: boolean;
25
+ hydratable: boolean;
26
+ };
27
+ provenance: RelationProvenance;
28
+ alias: string;
29
+ ambiguity?: string;
30
+ }
31
+ /**
32
+ * Registry-scoped relation graph built from normalized relation descriptors,
33
+ * explicit relation names, and finalized storage artifacts.
34
+ *
35
+ * This is the canonical resolved relation view for query planning and future
36
+ * hydration work. It is versioned because relation resolution is scoped to a
37
+ * specific registry snapshot.
38
+ */
39
+ export interface ResolvedRelationGraph {
40
+ version: number;
41
+ byModel: ReadonlyMap<string, ReadonlyMap<string, ResolvedRelationDescriptor>>;
42
+ byEdgeId: ReadonlyMap<string, ResolvedRelationDescriptor>;
43
+ }
@@ -0,0 +1,48 @@
1
+ import type { Model } from '../../domain/index';
2
+ import type { FinalizedStorageArtifacts } from '../fields/FinalizedStorageArtifacts';
3
+ import type { NormalizedRelationStorageDescriptor } from './NormalizedRelationStorageDescriptor';
4
+ import type { ResolvedRelationGraph } from './ResolvedRelationGraph';
5
+ type GraphBuilderOptions = {
6
+ version: number;
7
+ models: readonly Model[];
8
+ storage: FinalizedStorageArtifacts;
9
+ resolveRef: (ref: NormalizedRelationStorageDescriptor['targetRef']) => Model;
10
+ };
11
+ /**
12
+ * Resolution-stage builder that turns normalized relation descriptors into the
13
+ * registry-scoped resolved relation graph.
14
+ *
15
+ * This is the final pipeline stage in the relations subdomain. It combines:
16
+ *
17
+ * - normalized field-authored relation descriptors
18
+ * - explicit model-level relation names from `RelationBuilder`
19
+ * - finalized storage artifacts from the registry
20
+ *
21
+ * The result is the canonical named relation graph used by ORM-facing
22
+ * consumers.
23
+ */
24
+ export declare class ResolvedRelationGraphBuilder {
25
+ private readonly options;
26
+ private readonly byModel;
27
+ private readonly byEdgeId;
28
+ private readonly matchedOverrides;
29
+ constructor(options: GraphBuilderOptions);
30
+ static build(options: GraphBuilderOptions): ResolvedRelationGraph;
31
+ /**
32
+ * Resolve every model's normalized relation descriptors into a single
33
+ * registry-scoped graph and fail when authoring ambiguity remains.
34
+ */
35
+ build(): ResolvedRelationGraph;
36
+ private addModelRelations;
37
+ private addReferenceRelations;
38
+ private findForwardOverride;
39
+ private findReverseOverride;
40
+ private assertAllOverridesMatched;
41
+ private addResolvedRelation;
42
+ private getPrimaryKey;
43
+ private markOverrideMatched;
44
+ private buildOverrideMarker;
45
+ private resolveRelationTargetKey;
46
+ private deriveReverseName;
47
+ }
48
+ export {};
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,13 @@
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';