@orchestr-sh/orchestr 1.5.10 → 1.6.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.
- package/README.md +433 -936
- package/dist/Console/Command.d.ts +59 -0
- package/dist/Console/Command.d.ts.map +1 -0
- package/dist/Console/Command.js +68 -0
- package/dist/Console/Command.js.map +1 -0
- package/dist/Console/Commands/MakeMigrationCommand.d.ts +15 -0
- package/dist/Console/Commands/MakeMigrationCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MakeMigrationCommand.js +41 -0
- package/dist/Console/Commands/MakeMigrationCommand.js.map +1 -0
- package/dist/Console/Commands/MakeSeederCommand.d.ts +23 -0
- package/dist/Console/Commands/MakeSeederCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MakeSeederCommand.js +109 -0
- package/dist/Console/Commands/MakeSeederCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateCommand.js +48 -0
- package/dist/Console/Commands/MigrateCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateFreshCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateFreshCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateFreshCommand.js +54 -0
- package/dist/Console/Commands/MigrateFreshCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateRefreshCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateRefreshCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateRefreshCommand.js +52 -0
- package/dist/Console/Commands/MigrateRefreshCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateResetCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateResetCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateResetCommand.js +46 -0
- package/dist/Console/Commands/MigrateResetCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateRollbackCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateRollbackCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateRollbackCommand.js +49 -0
- package/dist/Console/Commands/MigrateRollbackCommand.js.map +1 -0
- package/dist/Console/Commands/MigrateStatusCommand.d.ts +15 -0
- package/dist/Console/Commands/MigrateStatusCommand.d.ts.map +1 -0
- package/dist/Console/Commands/MigrateStatusCommand.js +58 -0
- package/dist/Console/Commands/MigrateStatusCommand.js.map +1 -0
- package/dist/Console/Commands/SeedCommand.d.ts +15 -0
- package/dist/Console/Commands/SeedCommand.d.ts.map +1 -0
- package/dist/Console/Commands/SeedCommand.js +44 -0
- package/dist/Console/Commands/SeedCommand.js.map +1 -0
- package/dist/Console/ConsoleKernel.d.ts +45 -0
- package/dist/Console/ConsoleKernel.d.ts.map +1 -0
- package/dist/Console/ConsoleKernel.js +109 -0
- package/dist/Console/ConsoleKernel.js.map +1 -0
- package/dist/Console/orchestr.d.ts +8 -0
- package/dist/Console/orchestr.d.ts.map +1 -0
- package/dist/Console/orchestr.js +45 -0
- package/dist/Console/orchestr.js.map +1 -0
- package/dist/Database/Ensemble/Concerns/HasDynamicRelations.d.ts +5 -0
- package/dist/Database/Ensemble/Concerns/HasDynamicRelations.d.ts.map +1 -1
- package/dist/Database/Ensemble/Concerns/HasDynamicRelations.js.map +1 -1
- package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts +20 -0
- package/dist/Database/Ensemble/Concerns/HasRelationships.d.ts.map +1 -1
- package/dist/Database/Ensemble/Concerns/HasRelationships.js +57 -0
- package/dist/Database/Ensemble/Concerns/HasRelationships.js.map +1 -1
- package/dist/Database/Ensemble/Relations/MorphMany.d.ts +97 -0
- package/dist/Database/Ensemble/Relations/MorphMany.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphMany.js +189 -0
- package/dist/Database/Ensemble/Relations/MorphMany.js.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphMap.d.ts +59 -0
- package/dist/Database/Ensemble/Relations/MorphMap.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphMap.js +84 -0
- package/dist/Database/Ensemble/Relations/MorphMap.js.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphOne.d.ts +93 -0
- package/dist/Database/Ensemble/Relations/MorphOne.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphOne.js +179 -0
- package/dist/Database/Ensemble/Relations/MorphOne.js.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphTo.d.ts +98 -0
- package/dist/Database/Ensemble/Relations/MorphTo.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphTo.js +214 -0
- package/dist/Database/Ensemble/Relations/MorphTo.js.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphToMany.d.ts +73 -0
- package/dist/Database/Ensemble/Relations/MorphToMany.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphToMany.js +164 -0
- package/dist/Database/Ensemble/Relations/MorphToMany.js.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphedByMany.d.ts +29 -0
- package/dist/Database/Ensemble/Relations/MorphedByMany.d.ts.map +1 -0
- package/dist/Database/Ensemble/Relations/MorphedByMany.js +58 -0
- package/dist/Database/Ensemble/Relations/MorphedByMany.js.map +1 -0
- package/dist/Database/Ensemble/Relations/index.d.ts +6 -0
- package/dist/Database/Ensemble/Relations/index.d.ts.map +1 -1
- package/dist/Database/Ensemble/Relations/index.js +14 -1
- package/dist/Database/Ensemble/Relations/index.js.map +1 -1
- package/dist/Database/Migrations/Blueprint.d.ts +166 -0
- package/dist/Database/Migrations/Blueprint.d.ts.map +1 -0
- package/dist/Database/Migrations/Blueprint.js +318 -0
- package/dist/Database/Migrations/Blueprint.js.map +1 -0
- package/dist/Database/Migrations/ColumnDefinition.d.ts +62 -0
- package/dist/Database/Migrations/ColumnDefinition.d.ts.map +1 -0
- package/dist/Database/Migrations/ColumnDefinition.js +95 -0
- package/dist/Database/Migrations/ColumnDefinition.js.map +1 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.d.ts +32 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.d.ts.map +1 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.js +50 -0
- package/dist/Database/Migrations/ForeignKeyDefinition.js.map +1 -0
- package/dist/Database/Migrations/Migration.d.ts +17 -0
- package/dist/Database/Migrations/Migration.d.ts.map +1 -0
- package/dist/Database/Migrations/Migration.js +12 -0
- package/dist/Database/Migrations/Migration.js.map +1 -0
- package/dist/Database/Migrations/MigrationCreator.d.ts +42 -0
- package/dist/Database/Migrations/MigrationCreator.d.ts.map +1 -0
- package/dist/Database/Migrations/MigrationCreator.js +184 -0
- package/dist/Database/Migrations/MigrationCreator.js.map +1 -0
- package/dist/Database/Migrations/MigrationRepository.d.ts +65 -0
- package/dist/Database/Migrations/MigrationRepository.d.ts.map +1 -0
- package/dist/Database/Migrations/MigrationRepository.js +135 -0
- package/dist/Database/Migrations/MigrationRepository.js.map +1 -0
- package/dist/Database/Migrations/Migrator.d.ts +84 -0
- package/dist/Database/Migrations/Migrator.d.ts.map +1 -0
- package/dist/Database/Migrations/Migrator.js +239 -0
- package/dist/Database/Migrations/Migrator.js.map +1 -0
- package/dist/Database/Migrations/SchemaBuilder.d.ts +136 -0
- package/dist/Database/Migrations/SchemaBuilder.d.ts.map +1 -0
- package/dist/Database/Migrations/SchemaBuilder.js +515 -0
- package/dist/Database/Migrations/SchemaBuilder.js.map +1 -0
- package/dist/Database/Seeders/Seeder.d.ts +29 -0
- package/dist/Database/Seeders/Seeder.d.ts.map +1 -0
- package/dist/Database/Seeders/Seeder.js +41 -0
- package/dist/Database/Seeders/Seeder.js.map +1 -0
- package/dist/Database/Seeders/SeederRunner.d.ts +41 -0
- package/dist/Database/Seeders/SeederRunner.d.ts.map +1 -0
- package/dist/Database/Seeders/SeederRunner.js +134 -0
- package/dist/Database/Seeders/SeederRunner.js.map +1 -0
- package/dist/index.d.ts +27 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MorphToMany Relationship
|
|
4
|
+
*
|
|
5
|
+
* Represents a polymorphic many-to-many relationship from the parent side
|
|
6
|
+
* Example: Post has many Tags (where Tag can belong to many types via taggables table)
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MorphToMany = void 0;
|
|
10
|
+
const BelongsToMany_1 = require("./BelongsToMany");
|
|
11
|
+
const MorphMap_1 = require("./MorphMap");
|
|
12
|
+
class MorphToMany extends BelongsToMany_1.BelongsToMany {
|
|
13
|
+
/**
|
|
14
|
+
* The morph type column (e.g., 'taggable_type')
|
|
15
|
+
*/
|
|
16
|
+
morphType;
|
|
17
|
+
/**
|
|
18
|
+
* The morph class name or alias
|
|
19
|
+
*/
|
|
20
|
+
morphClass;
|
|
21
|
+
/**
|
|
22
|
+
* Whether this is the inverse of the relation
|
|
23
|
+
*/
|
|
24
|
+
inverse;
|
|
25
|
+
/**
|
|
26
|
+
* Create a new morph to many relationship instance
|
|
27
|
+
*/
|
|
28
|
+
constructor(query, parent, name, table, foreignPivotKey, relatedPivotKey, morphType, parentKey, relatedKey, relationName, inverse = false) {
|
|
29
|
+
super(query, parent, table, foreignPivotKey, relatedPivotKey, parentKey, relatedKey, relationName);
|
|
30
|
+
this.morphType = morphType;
|
|
31
|
+
this.morphClass = this.getMorphClass();
|
|
32
|
+
this.inverse = inverse;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Set the join clause for the relation query
|
|
36
|
+
* Adds the morph type constraint
|
|
37
|
+
*/
|
|
38
|
+
performJoin(query) {
|
|
39
|
+
query = query || this.query;
|
|
40
|
+
// Join the pivot table with morph type constraint
|
|
41
|
+
query
|
|
42
|
+
.join(this.table, `${this.getQualifiedRelatedKeyName()}`, '=', `${this.getQualifiedRelatedPivotKeyName()}`)
|
|
43
|
+
.where(`${this.table}.${this.morphType}`, '=', this.morphClass);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Set the where clause for eager loading
|
|
47
|
+
*/
|
|
48
|
+
addWhereConstraints() {
|
|
49
|
+
const parentKeyValue = this.parent.getAttribute(this.parentKey);
|
|
50
|
+
// Only add constraint if parent key value exists
|
|
51
|
+
if (parentKeyValue !== null && parentKeyValue !== undefined) {
|
|
52
|
+
this.query.where(this.getQualifiedForeignPivotKeyName(), '=', parentKeyValue);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the morph class for the parent during initialization
|
|
57
|
+
*/
|
|
58
|
+
getMorphClass() {
|
|
59
|
+
if (this.inverse) {
|
|
60
|
+
// For inverse relations, we don't set the morph class on parent
|
|
61
|
+
// It will be set per attach/sync operation
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
return MorphMap_1.MorphMap.getMorphedModel(this.parent);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the morph type name
|
|
68
|
+
*/
|
|
69
|
+
getMorphType() {
|
|
70
|
+
return this.morphType;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the morph class value
|
|
74
|
+
*/
|
|
75
|
+
getMorphClassValue() {
|
|
76
|
+
return this.morphClass;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Set the morph class (used for inverse relations)
|
|
80
|
+
*/
|
|
81
|
+
setMorphClass(morphClass) {
|
|
82
|
+
this.morphClass = morphClass;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Attach models to the parent with morph type
|
|
87
|
+
*/
|
|
88
|
+
async attach(ids, attributes = {}, touch = true) {
|
|
89
|
+
const idsArray = Array.isArray(ids) ? ids : [ids];
|
|
90
|
+
const parentKey = this.parent.getAttribute(this.parentKey);
|
|
91
|
+
if (!parentKey) {
|
|
92
|
+
throw new Error('Parent key must be set before attaching');
|
|
93
|
+
}
|
|
94
|
+
const records = idsArray.map((id) => ({
|
|
95
|
+
[this.foreignPivotKey]: parentKey,
|
|
96
|
+
[this.relatedPivotKey]: id,
|
|
97
|
+
[this.morphType]: this.morphClass,
|
|
98
|
+
...attributes,
|
|
99
|
+
}));
|
|
100
|
+
const connection = this.parent.getConnection();
|
|
101
|
+
await connection.table(this.table).insert(records);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Detach models from the parent with morph type constraint
|
|
105
|
+
*/
|
|
106
|
+
async detach(ids) {
|
|
107
|
+
const query = this.newPivotQuery();
|
|
108
|
+
const parentKey = this.parent.getAttribute(this.parentKey);
|
|
109
|
+
if (!parentKey) {
|
|
110
|
+
return 0;
|
|
111
|
+
}
|
|
112
|
+
query
|
|
113
|
+
.where(this.foreignPivotKey, '=', parentKey)
|
|
114
|
+
.where(this.morphType, '=', this.morphClass);
|
|
115
|
+
if (ids) {
|
|
116
|
+
const idsArray = Array.isArray(ids) ? ids : [ids];
|
|
117
|
+
query.whereIn(this.relatedPivotKey, idsArray);
|
|
118
|
+
}
|
|
119
|
+
return query.delete();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Sync the intermediate tables with morph type
|
|
123
|
+
*/
|
|
124
|
+
async sync(ids, detaching = true) {
|
|
125
|
+
const changes = {
|
|
126
|
+
attached: [],
|
|
127
|
+
detached: [],
|
|
128
|
+
updated: [],
|
|
129
|
+
};
|
|
130
|
+
const parentKey = this.parent.getAttribute(this.parentKey);
|
|
131
|
+
if (!parentKey) {
|
|
132
|
+
return changes;
|
|
133
|
+
}
|
|
134
|
+
// Get current IDs
|
|
135
|
+
const current = await this.newPivotQuery()
|
|
136
|
+
.where(this.foreignPivotKey, '=', parentKey)
|
|
137
|
+
.where(this.morphType, '=', this.morphClass)
|
|
138
|
+
.select(this.relatedPivotKey)
|
|
139
|
+
.get();
|
|
140
|
+
const currentIds = current.map((record) => record[this.relatedPivotKey]);
|
|
141
|
+
const idsToAttach = ids.filter((id) => !currentIds.includes(id));
|
|
142
|
+
const idsToDetach = detaching ? currentIds.filter((id) => !ids.includes(id)) : [];
|
|
143
|
+
// Detach old records
|
|
144
|
+
if (idsToDetach.length > 0) {
|
|
145
|
+
await this.detach(idsToDetach);
|
|
146
|
+
changes.detached = idsToDetach;
|
|
147
|
+
}
|
|
148
|
+
// Attach new records
|
|
149
|
+
if (idsToAttach.length > 0) {
|
|
150
|
+
await this.attach(idsToAttach);
|
|
151
|
+
changes.attached = idsToAttach;
|
|
152
|
+
}
|
|
153
|
+
return changes;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Create a new pivot query
|
|
157
|
+
*/
|
|
158
|
+
newPivotQuery() {
|
|
159
|
+
const connection = this.parent.getConnection();
|
|
160
|
+
return connection.table(this.table);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
exports.MorphToMany = MorphToMany;
|
|
164
|
+
//# sourceMappingURL=MorphToMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MorphToMany.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/MorphToMany.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,mDAAgD;AAChD,yCAAsC;AAEtC,MAAa,WAAiE,SAAQ,6BAAgC;IACpH;;OAEG;IACO,SAAS,CAAS;IAE5B;;OAEG;IACO,UAAU,CAAS;IAE7B;;OAEG;IACO,OAAO,CAAU;IAE3B;;OAEG;IACH,YACE,KAAgC,EAChC,MAAe,EACf,IAAY,EACZ,KAAa,EACb,eAAuB,EACvB,eAAuB,EACvB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,YAAqB,EACrB,UAAmB,KAAK;QAExB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;QAEnG,IAAI,CAAC,SAAS,GAAG,SAA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AAE,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAEvF,qBAAqB;QACrB,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/B,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;QACjC,CAAC;QAED,qBAAqB;QACrB,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;YAC/B,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC;QACjC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACO,aAAa;QACrB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;QAC/C,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAQ,CAAC;IAC7C,CAAC;CACF;AApND,kCAoNC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MorphedByMany Relationship
|
|
3
|
+
*
|
|
4
|
+
* Represents the inverse of a polymorphic many-to-many relationship
|
|
5
|
+
* Example: Tag has many Posts (where Post morphs to many Tags)
|
|
6
|
+
*/
|
|
7
|
+
import { Ensemble } from '../Ensemble';
|
|
8
|
+
import { EnsembleBuilder } from '../EnsembleBuilder';
|
|
9
|
+
import { MorphToMany } from './MorphToMany';
|
|
10
|
+
export declare class MorphedByMany<TRelated extends Ensemble, TParent extends Ensemble> extends MorphToMany<TRelated, TParent> {
|
|
11
|
+
/**
|
|
12
|
+
* Create a new morphed by many relationship instance
|
|
13
|
+
*/
|
|
14
|
+
constructor(query: EnsembleBuilder<TRelated>, parent: TParent, name: string, table: string, foreignPivotKey: string, relatedPivotKey: string, morphType: string, parentKey: string, relatedKey: string, relationName?: string);
|
|
15
|
+
/**
|
|
16
|
+
* Get the morph class for the related model
|
|
17
|
+
*/
|
|
18
|
+
protected getMorphClassForRelated(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Set the join clause for the relation query
|
|
21
|
+
* For inverse relations, we need to adjust the constraints
|
|
22
|
+
*/
|
|
23
|
+
protected performJoin(query?: EnsembleBuilder<TRelated>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set the where clause for the relation query
|
|
26
|
+
*/
|
|
27
|
+
protected addWhereConstraints(): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=MorphedByMany.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MorphedByMany.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/MorphedByMany.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,qBAAa,aAAa,CAAC,QAAQ,SAAS,QAAQ,EAAE,OAAO,SAAS,QAAQ,CAAE,SAAQ,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC;IACpH;;OAEG;gBAED,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM;IAqBvB;;OAEG;IACH,SAAS,CAAC,uBAAuB,IAAI,MAAM;IAO3C;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,GAAG,IAAI;IAmB9D;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;CAYtC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MorphedByMany Relationship
|
|
4
|
+
*
|
|
5
|
+
* Represents the inverse of a polymorphic many-to-many relationship
|
|
6
|
+
* Example: Tag has many Posts (where Post morphs to many Tags)
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MorphedByMany = void 0;
|
|
10
|
+
const MorphToMany_1 = require("./MorphToMany");
|
|
11
|
+
const MorphMap_1 = require("./MorphMap");
|
|
12
|
+
class MorphedByMany extends MorphToMany_1.MorphToMany {
|
|
13
|
+
/**
|
|
14
|
+
* Create a new morphed by many relationship instance
|
|
15
|
+
*/
|
|
16
|
+
constructor(query, parent, name, table, foreignPivotKey, relatedPivotKey, morphType, parentKey, relatedKey, relationName) {
|
|
17
|
+
// Call parent with inverse flag set to true
|
|
18
|
+
super(query, parent, name, table, foreignPivotKey, relatedPivotKey, morphType, parentKey, relatedKey, relationName, true // inverse
|
|
19
|
+
);
|
|
20
|
+
// Set the morph class based on the related model
|
|
21
|
+
this.morphClass = this.getMorphClassForRelated();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get the morph class for the related model
|
|
25
|
+
*/
|
|
26
|
+
getMorphClassForRelated() {
|
|
27
|
+
// The morph class is based on the related model's type
|
|
28
|
+
// This will be the type stored in the pivot table
|
|
29
|
+
const instance = new this.related.constructor();
|
|
30
|
+
return MorphMap_1.MorphMap.getMorphedModel(instance);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set the join clause for the relation query
|
|
34
|
+
* For inverse relations, we need to adjust the constraints
|
|
35
|
+
*/
|
|
36
|
+
performJoin(query) {
|
|
37
|
+
query = query || this.query;
|
|
38
|
+
// Join the pivot table with morph type constraint
|
|
39
|
+
// The difference from MorphToMany is that we're joining from the related side
|
|
40
|
+
query
|
|
41
|
+
.join(this.table, `${this.getQualifiedRelatedKeyName()}`, '=', `${this.getQualifiedForeignPivotKeyName()}` // Swapped for inverse
|
|
42
|
+
)
|
|
43
|
+
.where(`${this.table}.${this.morphType}`, '=', this.morphClass);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Set the where clause for the relation query
|
|
47
|
+
*/
|
|
48
|
+
addWhereConstraints() {
|
|
49
|
+
const parentKeyValue = this.parent.getAttribute(this.parentKey);
|
|
50
|
+
// Only add constraint if parent key value exists
|
|
51
|
+
if (parentKeyValue !== null && parentKeyValue !== undefined) {
|
|
52
|
+
this.query.where(this.getQualifiedRelatedPivotKeyName(), // Swapped for inverse
|
|
53
|
+
'=', parentKeyValue);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.MorphedByMany = MorphedByMany;
|
|
58
|
+
//# sourceMappingURL=MorphedByMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MorphedByMany.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/MorphedByMany.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH,+CAA4C;AAC5C,yCAAsC;AAEtC,MAAa,aAAmE,SAAQ,yBAA8B;IACpH;;OAEG;IACH,YACE,KAAgC,EAChC,MAAe,EACf,IAAY,EACZ,KAAa,EACb,eAAuB,EACvB,eAAuB,EACvB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,YAAqB;QAErB,4CAA4C;QAC5C,KAAK,CACH,KAAK,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,eAAe,EACf,eAAe,EACf,SAAS,EACT,SAAS,EACT,UAAU,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10
|
export { BelongsToMany } from './BelongsToMany';
|
|
11
|
+
export { MorphMap } from './MorphMap';
|
|
12
|
+
export { MorphOne } from './MorphOne';
|
|
13
|
+
export { MorphMany } from './MorphMany';
|
|
14
|
+
export { MorphTo } from './MorphTo';
|
|
15
|
+
export { MorphToMany } from './MorphToMany';
|
|
16
|
+
export { MorphedByMany } from './MorphedByMany';
|
|
11
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Export all relationship classes
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.BelongsToMany = exports.BelongsTo = exports.HasMany = exports.HasOne = exports.Relation = void 0;
|
|
8
|
+
exports.MorphedByMany = exports.MorphToMany = exports.MorphTo = exports.MorphMany = exports.MorphOne = exports.MorphMap = exports.BelongsToMany = exports.BelongsTo = exports.HasMany = exports.HasOne = exports.Relation = void 0;
|
|
9
9
|
var Relation_1 = require("./Relation");
|
|
10
10
|
Object.defineProperty(exports, "Relation", { enumerable: true, get: function () { return Relation_1.Relation; } });
|
|
11
11
|
var HasOne_1 = require("./HasOne");
|
|
@@ -16,4 +16,17 @@ var BelongsTo_1 = require("./BelongsTo");
|
|
|
16
16
|
Object.defineProperty(exports, "BelongsTo", { enumerable: true, get: function () { return BelongsTo_1.BelongsTo; } });
|
|
17
17
|
var BelongsToMany_1 = require("./BelongsToMany");
|
|
18
18
|
Object.defineProperty(exports, "BelongsToMany", { enumerable: true, get: function () { return BelongsToMany_1.BelongsToMany; } });
|
|
19
|
+
// Polymorphic Relations
|
|
20
|
+
var MorphMap_1 = require("./MorphMap");
|
|
21
|
+
Object.defineProperty(exports, "MorphMap", { enumerable: true, get: function () { return MorphMap_1.MorphMap; } });
|
|
22
|
+
var MorphOne_1 = require("./MorphOne");
|
|
23
|
+
Object.defineProperty(exports, "MorphOne", { enumerable: true, get: function () { return MorphOne_1.MorphOne; } });
|
|
24
|
+
var MorphMany_1 = require("./MorphMany");
|
|
25
|
+
Object.defineProperty(exports, "MorphMany", { enumerable: true, get: function () { return MorphMany_1.MorphMany; } });
|
|
26
|
+
var MorphTo_1 = require("./MorphTo");
|
|
27
|
+
Object.defineProperty(exports, "MorphTo", { enumerable: true, get: function () { return MorphTo_1.MorphTo; } });
|
|
28
|
+
var MorphToMany_1 = require("./MorphToMany");
|
|
29
|
+
Object.defineProperty(exports, "MorphToMany", { enumerable: true, get: function () { return MorphToMany_1.MorphToMany; } });
|
|
30
|
+
var MorphedByMany_1 = require("./MorphedByMany");
|
|
31
|
+
Object.defineProperty(exports, "MorphedByMany", { enumerable: true, get: function () { return MorphedByMany_1.MorphedByMany; } });
|
|
19
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/Database/Ensemble/Relations/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AAEtB,wBAAwB;AACxB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blueprint
|
|
3
|
+
*
|
|
4
|
+
* Defines a table schema in a migration
|
|
5
|
+
*/
|
|
6
|
+
import { Blueprint as IBlueprint } from '../Contracts/Schema';
|
|
7
|
+
import { ColumnDefinition } from './ColumnDefinition';
|
|
8
|
+
import { ForeignKeyDefinition } from './ForeignKeyDefinition';
|
|
9
|
+
export interface IndexDefinition {
|
|
10
|
+
columns: string[];
|
|
11
|
+
name?: string;
|
|
12
|
+
type: 'index' | 'unique' | 'primary';
|
|
13
|
+
}
|
|
14
|
+
export interface DropCommand {
|
|
15
|
+
type: 'dropColumn' | 'dropIndex' | 'dropForeign' | 'renameColumn';
|
|
16
|
+
name?: string;
|
|
17
|
+
columns?: string[];
|
|
18
|
+
from?: string;
|
|
19
|
+
to?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class Blueprint implements IBlueprint {
|
|
22
|
+
table: string;
|
|
23
|
+
columns: ColumnDefinition[];
|
|
24
|
+
indexes: IndexDefinition[];
|
|
25
|
+
foreignKeys: ForeignKeyDefinition[];
|
|
26
|
+
commands: DropCommand[];
|
|
27
|
+
isCreate: boolean;
|
|
28
|
+
constructor(table: string);
|
|
29
|
+
/**
|
|
30
|
+
* Add an auto-incrementing ID column
|
|
31
|
+
*/
|
|
32
|
+
id(column?: string): ColumnDefinition;
|
|
33
|
+
/**
|
|
34
|
+
* Add a big auto-incrementing ID column
|
|
35
|
+
*/
|
|
36
|
+
bigIncrements(column: string): ColumnDefinition;
|
|
37
|
+
/**
|
|
38
|
+
* Add an auto-incrementing column
|
|
39
|
+
*/
|
|
40
|
+
increments(column: string): ColumnDefinition;
|
|
41
|
+
/**
|
|
42
|
+
* Add a UUID column
|
|
43
|
+
*/
|
|
44
|
+
uuid(column: string): ColumnDefinition;
|
|
45
|
+
/**
|
|
46
|
+
* Add a string column
|
|
47
|
+
*/
|
|
48
|
+
string(column: string, length?: number): ColumnDefinition;
|
|
49
|
+
/**
|
|
50
|
+
* Add a text column
|
|
51
|
+
*/
|
|
52
|
+
text(column: string): ColumnDefinition;
|
|
53
|
+
/**
|
|
54
|
+
* Add a medium text column
|
|
55
|
+
*/
|
|
56
|
+
mediumText(column: string): ColumnDefinition;
|
|
57
|
+
/**
|
|
58
|
+
* Add a long text column
|
|
59
|
+
*/
|
|
60
|
+
longText(column: string): ColumnDefinition;
|
|
61
|
+
/**
|
|
62
|
+
* Add an integer column
|
|
63
|
+
*/
|
|
64
|
+
integer(column: string): ColumnDefinition;
|
|
65
|
+
/**
|
|
66
|
+
* Add a big integer column
|
|
67
|
+
*/
|
|
68
|
+
bigInteger(column: string): ColumnDefinition;
|
|
69
|
+
/**
|
|
70
|
+
* Add a small integer column
|
|
71
|
+
*/
|
|
72
|
+
smallInteger(column: string): ColumnDefinition;
|
|
73
|
+
/**
|
|
74
|
+
* Add a tiny integer column
|
|
75
|
+
*/
|
|
76
|
+
tinyInteger(column: string): ColumnDefinition;
|
|
77
|
+
/**
|
|
78
|
+
* Add a decimal column
|
|
79
|
+
*/
|
|
80
|
+
decimal(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
81
|
+
/**
|
|
82
|
+
* Add a float column
|
|
83
|
+
*/
|
|
84
|
+
float(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
85
|
+
/**
|
|
86
|
+
* Add a double column
|
|
87
|
+
*/
|
|
88
|
+
double(column: string, precision?: number, scale?: number): ColumnDefinition;
|
|
89
|
+
/**
|
|
90
|
+
* Add a boolean column
|
|
91
|
+
*/
|
|
92
|
+
boolean(column: string): ColumnDefinition;
|
|
93
|
+
/**
|
|
94
|
+
* Add a date column
|
|
95
|
+
*/
|
|
96
|
+
date(column: string): ColumnDefinition;
|
|
97
|
+
/**
|
|
98
|
+
* Add a datetime column
|
|
99
|
+
*/
|
|
100
|
+
datetime(column: string, precision?: number): ColumnDefinition;
|
|
101
|
+
/**
|
|
102
|
+
* Add a timestamp column
|
|
103
|
+
*/
|
|
104
|
+
timestamp(column: string, precision?: number): ColumnDefinition;
|
|
105
|
+
/**
|
|
106
|
+
* Add created_at and updated_at timestamp columns
|
|
107
|
+
*/
|
|
108
|
+
timestamps(precision?: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Add a JSON column
|
|
111
|
+
*/
|
|
112
|
+
json(column: string): ColumnDefinition;
|
|
113
|
+
/**
|
|
114
|
+
* Add a JSONB column
|
|
115
|
+
*/
|
|
116
|
+
jsonb(column: string): ColumnDefinition;
|
|
117
|
+
/**
|
|
118
|
+
* Add a binary column
|
|
119
|
+
*/
|
|
120
|
+
binary(column: string): ColumnDefinition;
|
|
121
|
+
/**
|
|
122
|
+
* Add an enum column
|
|
123
|
+
*/
|
|
124
|
+
enum(column: string, values: string[]): ColumnDefinition;
|
|
125
|
+
/**
|
|
126
|
+
* Add a remember token column
|
|
127
|
+
*/
|
|
128
|
+
rememberToken(): ColumnDefinition;
|
|
129
|
+
/**
|
|
130
|
+
* Add soft delete columns
|
|
131
|
+
*/
|
|
132
|
+
softDeletes(column?: string): ColumnDefinition;
|
|
133
|
+
/**
|
|
134
|
+
* Add an index
|
|
135
|
+
*/
|
|
136
|
+
index(columns: string | string[], indexName?: string): void;
|
|
137
|
+
/**
|
|
138
|
+
* Add a unique index
|
|
139
|
+
*/
|
|
140
|
+
unique(columns: string | string[], indexName?: string): void;
|
|
141
|
+
/**
|
|
142
|
+
* Add a primary key
|
|
143
|
+
*/
|
|
144
|
+
primary(columns: string | string[]): void;
|
|
145
|
+
/**
|
|
146
|
+
* Add a foreign key
|
|
147
|
+
*/
|
|
148
|
+
foreign(columns: string | string[], indexName?: string): ForeignKeyDefinition;
|
|
149
|
+
/**
|
|
150
|
+
* Drop a column
|
|
151
|
+
*/
|
|
152
|
+
dropColumn(column: string | string[]): void;
|
|
153
|
+
/**
|
|
154
|
+
* Drop an index
|
|
155
|
+
*/
|
|
156
|
+
dropIndex(indexName: string): void;
|
|
157
|
+
/**
|
|
158
|
+
* Drop a foreign key
|
|
159
|
+
*/
|
|
160
|
+
dropForeign(indexName: string): void;
|
|
161
|
+
/**
|
|
162
|
+
* Rename a column
|
|
163
|
+
*/
|
|
164
|
+
renameColumn(from: string, to: string): void;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=Blueprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Blueprint.d.ts","sourceRoot":"","sources":["../../../src/Database/Migrations/Blueprint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,cAAc,CAAC;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,SAAU,YAAW,UAAU;IAOvB,KAAK,EAAE,MAAM;IANzB,OAAO,EAAE,gBAAgB,EAAE,CAAM;IACjC,OAAO,EAAE,eAAe,EAAE,CAAM;IAChC,WAAW,EAAE,oBAAoB,EAAE,CAAM;IACzC,QAAQ,EAAE,WAAW,EAAE,CAAM;IAC7B,QAAQ,EAAE,OAAO,CAAS;gBAEd,KAAK,EAAE,MAAM;IAEhC;;OAEG;IACH,EAAE,CAAC,MAAM,GAAE,MAAa,GAAG,gBAAgB;IAS3C;;OAEG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB;IAQ/C;;OAEG;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