prisma-laravel-migrate 3.1.12 → 3.1.14

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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="MaterialThemeProjectNewConfig">
4
+ <option name="metadata">
5
+ <MTProjectMetadataState>
6
+ <option name="migrated" value="true" />
7
+ <option name="pristineConfig" value="false" />
8
+ <option name="userId" value="-21b54065:19ba513a2b7:-7ffe" />
9
+ </MTProjectMetadataState>
10
+ </option>
11
+ </component>
12
+ </project>
package/dist/cli/cli.js CHANGED
@@ -1444,7 +1444,7 @@ var StubModelPrinter = class {
1444
1444
 
1445
1445
  // src/generator/lib/relationship/types.ts
1446
1446
  var getModel = (dmmf, name) => dmmf.datamodel.models.find((m) => m.name === name);
1447
- var dbNameOf = (m) => decorate(m.dbName ?? m.name, { tablePrefix: getConfig("model")?.tablePrefix, tableSuffix: getConfig("model")?.tableSuffix });
1447
+ var dbNameOf = (m) => decorate(m.dbName ?? m.name, getConfig("model"));
1448
1448
  var conventionalPivotName = (a, b) => [a, b].map((s) => s.toLowerCase()).sort().join("_");
1449
1449
  var objRels = (m) => m.fields.filter((f) => f.kind === "object");
1450
1450
  var getPrimaryKeyFields = (m) => {
@@ -1814,10 +1814,7 @@ function buildRelationsForModel(dmmf, model) {
1814
1814
  type: "belongsToMany",
1815
1815
  mode: "explicit",
1816
1816
  modelClass: `${keys.target}::class`,
1817
- pivotTable: decorate(keys.pivotTable, {
1818
- tablePrefix: getConfig("model", "tablePrefix"),
1819
- tableSuffix: getConfig("model", "tableSuffix")
1820
- }),
1817
+ pivotTable: keys.pivotTable,
1821
1818
  pivotLocal: keys.pivotLocal,
1822
1819
  pivotForeign: keys.pivotForeign,
1823
1820
  pivotColumns: keys.pivotColumns,
@@ -1835,10 +1832,7 @@ function buildRelationsForModel(dmmf, model) {
1835
1832
  type: "belongsToMany",
1836
1833
  mode: "implicit",
1837
1834
  modelClass: `${keys.target}::class`,
1838
- pivotTable: decorate(keys.pivotTable, {
1839
- tablePrefix: getConfig("model", "tablePrefix"),
1840
- tableSuffix: getConfig("model", "tableSuffix")
1841
- }),
1835
+ pivotTable: keys.pivotTable,
1842
1836
  localKey: keys.local,
1843
1837
  foreignKey: keys.foreign,
1844
1838
  targetModelName: keys.target
@@ -1912,25 +1906,28 @@ function parseTypeDirective(doc) {
1912
1906
  }
1913
1907
  function parseAppendsDirective(doc) {
1914
1908
  if (!doc) return void 0;
1915
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
1909
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
1916
1910
  if (!m) return void 0;
1917
- let body = m[1].trim();
1911
+ let body = (m[1] ?? "").trim();
1918
1912
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
1919
1913
  body = body.slice(1, -1).trim();
1920
1914
  }
1915
+ if (body.startsWith(":")) body = body.slice(1).trim();
1921
1916
  if (!body) return void 0;
1922
1917
  const entries = [];
1923
1918
  for (const raw of body.split(",")) {
1924
1919
  const token = raw.trim();
1925
1920
  if (!token) continue;
1926
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
1927
- if (!nameRaw) continue;
1928
- const name = nameRaw;
1929
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
1930
- entries.push({ name, type });
1931
- }
1932
- if (!entries.length) return void 0;
1933
- return { entries };
1921
+ const idx = token.indexOf(":");
1922
+ const name = (idx === -1 ? token : token.slice(0, idx)).trim();
1923
+ const type = (idx === -1 ? "" : token.slice(idx + 1)).trim();
1924
+ if (!name) continue;
1925
+ entries.push({
1926
+ name,
1927
+ type: type.length ? type : void 0
1928
+ });
1929
+ }
1930
+ return entries.length ? { entries } : void 0;
1934
1931
  }
1935
1932
  function getModelTypeDirective(model) {
1936
1933
  return parseTypeDirective(model.documentation);
@@ -2003,7 +2000,7 @@ var PrismaToLaravelModelGenerator = class {
2003
2000
  type: field.type
2004
2001
  };
2005
2002
  });
2006
- const guarded = guardedSet.size || properties.some((p) => p.guarded) ? [...guardedSet, ...properties.filter((p) => p.guarded).map((p) => p.name)] : hasToken("guarded", modelDoc) ? [] : void 0;
2003
+ const guarded = guardedSet.size || properties.some((p) => p.guarded) ? Array.from(/* @__PURE__ */ new Set([...guardedSet, ...properties.filter((p) => p.guarded).map((p) => p.name)])) : hasToken("guarded", modelDoc) ? [] : void 0;
2007
2004
  const relations = this.extractRelationsFromModel(model);
2008
2005
  const interfaces = {};
2009
2006
  for (const prop of properties) {
@@ -2065,7 +2062,6 @@ var PrismaToLaravelModelGenerator = class {
2065
2062
  docblockProps.push(`@property ${type} $${p.name}`);
2066
2063
  }
2067
2064
  for (const rel of relations) {
2068
- if (rel.pivotTable) ;
2069
2065
  const type = rel.type === "hasMany" || rel.type === "belongsToMany" ? `\\Illuminate\\Support\\Collection<int, ${rel.modelClass}>` : rel.modelClass;
2070
2066
  docblockProps.push(`@property ${type} $${rel.name}`);
2071
2067
  }
@@ -284,7 +284,7 @@ var StubModelPrinter = class {
284
284
 
285
285
  // src/generator/lib/relationship/types.ts
286
286
  var getModel = (dmmf, name) => dmmf.datamodel.models.find((m) => m.name === name);
287
- var dbNameOf = (m) => decorate(m.dbName ?? m.name, { tablePrefix: getConfig("model")?.tablePrefix, tableSuffix: getConfig("model")?.tableSuffix });
287
+ var dbNameOf = (m) => decorate(m.dbName ?? m.name, getConfig("model"));
288
288
  var conventionalPivotName = (a, b) => [a, b].map((s) => s.toLowerCase()).sort().join("_");
289
289
  var objRels = (m) => m.fields.filter((f) => f.kind === "object");
290
290
  var getPrimaryKeyFields = (m) => {
@@ -654,10 +654,7 @@ function buildRelationsForModel(dmmf, model) {
654
654
  type: "belongsToMany",
655
655
  mode: "explicit",
656
656
  modelClass: `${keys.target}::class`,
657
- pivotTable: decorate(keys.pivotTable, {
658
- tablePrefix: getConfig("model", "tablePrefix"),
659
- tableSuffix: getConfig("model", "tableSuffix")
660
- }),
657
+ pivotTable: keys.pivotTable,
661
658
  pivotLocal: keys.pivotLocal,
662
659
  pivotForeign: keys.pivotForeign,
663
660
  pivotColumns: keys.pivotColumns,
@@ -675,10 +672,7 @@ function buildRelationsForModel(dmmf, model) {
675
672
  type: "belongsToMany",
676
673
  mode: "implicit",
677
674
  modelClass: `${keys.target}::class`,
678
- pivotTable: decorate(keys.pivotTable, {
679
- tablePrefix: getConfig("model", "tablePrefix"),
680
- tableSuffix: getConfig("model", "tableSuffix")
681
- }),
675
+ pivotTable: keys.pivotTable,
682
676
  localKey: keys.local,
683
677
  foreignKey: keys.foreign,
684
678
  targetModelName: keys.target
@@ -742,25 +736,28 @@ function buildRelationsForModel(dmmf, model) {
742
736
  // src/generator/ts/directives.ts
743
737
  function parseAppendsDirective(doc) {
744
738
  if (!doc) return void 0;
745
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
739
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
746
740
  if (!m) return void 0;
747
- let body = m[1].trim();
741
+ let body = (m[1] ?? "").trim();
748
742
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
749
743
  body = body.slice(1, -1).trim();
750
744
  }
745
+ if (body.startsWith(":")) body = body.slice(1).trim();
751
746
  if (!body) return void 0;
752
747
  const entries = [];
753
748
  for (const raw of body.split(",")) {
754
749
  const token = raw.trim();
755
750
  if (!token) continue;
756
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
757
- if (!nameRaw) continue;
758
- const name = nameRaw;
759
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
760
- entries.push({ name, type });
751
+ const idx = token.indexOf(":");
752
+ const name = (idx === -1 ? token : token.slice(0, idx)).trim();
753
+ const type = (idx === -1 ? "" : token.slice(idx + 1)).trim();
754
+ if (!name) continue;
755
+ entries.push({
756
+ name,
757
+ type: type.length ? type : void 0
758
+ });
761
759
  }
762
- if (!entries.length) return void 0;
763
- return { entries };
760
+ return entries.length ? { entries } : void 0;
764
761
  }
765
762
 
766
763
  // src/generator/modeler/generator.ts
@@ -824,7 +821,7 @@ var PrismaToLaravelModelGenerator = class {
824
821
  type: field.type
825
822
  };
826
823
  });
827
- const guarded = guardedSet.size || properties.some((p) => p.guarded) ? [...guardedSet, ...properties.filter((p) => p.guarded).map((p) => p.name)] : hasToken("guarded", modelDoc) ? [] : void 0;
824
+ const guarded = guardedSet.size || properties.some((p) => p.guarded) ? Array.from(/* @__PURE__ */ new Set([...guardedSet, ...properties.filter((p) => p.guarded).map((p) => p.name)])) : hasToken("guarded", modelDoc) ? [] : void 0;
828
825
  const relations = this.extractRelationsFromModel(model);
829
826
  const interfaces = {};
830
827
  for (const prop of properties) {
@@ -886,7 +883,6 @@ var PrismaToLaravelModelGenerator = class {
886
883
  docblockProps.push(`@property ${type} $${p.name}`);
887
884
  }
888
885
  for (const rel of relations) {
889
- if (rel.pivotTable) ;
890
886
  const type = rel.type === "hasMany" || rel.type === "belongsToMany" ? `\\Illuminate\\Support\\Collection<int, ${rel.modelClass}>` : rel.modelClass;
891
887
  docblockProps.push(`@property ${type} $${rel.name}`);
892
888
  }
@@ -96,25 +96,28 @@ function parseTypeDirective(doc) {
96
96
  }
97
97
  function parseAppendsDirective(doc) {
98
98
  if (!doc) return void 0;
99
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
99
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
100
100
  if (!m) return void 0;
101
- let body = m[1].trim();
101
+ let body = (m[1] ?? "").trim();
102
102
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
103
103
  body = body.slice(1, -1).trim();
104
104
  }
105
+ if (body.startsWith(":")) body = body.slice(1).trim();
105
106
  if (!body) return void 0;
106
107
  const entries = [];
107
108
  for (const raw of body.split(",")) {
108
109
  const token = raw.trim();
109
110
  if (!token) continue;
110
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
111
- if (!nameRaw) continue;
112
- const name = nameRaw;
113
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
114
- entries.push({ name, type });
115
- }
116
- if (!entries.length) return void 0;
117
- return { entries };
111
+ const idx = token.indexOf(":");
112
+ const name = (idx === -1 ? token : token.slice(0, idx)).trim();
113
+ const type = (idx === -1 ? "" : token.slice(idx + 1)).trim();
114
+ if (!name) continue;
115
+ entries.push({
116
+ name,
117
+ type: type.length ? type : void 0
118
+ });
119
+ }
120
+ return entries.length ? { entries } : void 0;
118
121
  }
119
122
  function getModelTypeDirective(model) {
120
123
  return parseTypeDirective(model.documentation);
@@ -225,7 +228,7 @@ function getStubPath(pathString, folder) {
225
228
 
226
229
  // src/generator/lib/relationship/types.ts
227
230
  var getModel = (dmmf, name) => dmmf.datamodel.models.find((m) => m.name === name);
228
- var dbNameOf = (m) => decorate(m.dbName ?? m.name, { tablePrefix: getConfig("model")?.tablePrefix, tableSuffix: getConfig("model")?.tableSuffix });
231
+ var dbNameOf = (m) => decorate(m.dbName ?? m.name, getConfig("model"));
229
232
  var conventionalPivotName = (a, b) => [a, b].map((s) => s.toLowerCase()).sort().join("_");
230
233
  var objRels = (m) => m.fields.filter((f) => f.kind === "object");
231
234
  var getPrimaryKeyFields = (m) => {
@@ -595,10 +598,7 @@ function buildRelationsForModel(dmmf, model) {
595
598
  type: "belongsToMany",
596
599
  mode: "explicit",
597
600
  modelClass: `${keys.target}::class`,
598
- pivotTable: decorate(keys.pivotTable, {
599
- tablePrefix: getConfig("model", "tablePrefix"),
600
- tableSuffix: getConfig("model", "tableSuffix")
601
- }),
601
+ pivotTable: keys.pivotTable,
602
602
  pivotLocal: keys.pivotLocal,
603
603
  pivotForeign: keys.pivotForeign,
604
604
  pivotColumns: keys.pivotColumns,
@@ -616,10 +616,7 @@ function buildRelationsForModel(dmmf, model) {
616
616
  type: "belongsToMany",
617
617
  mode: "implicit",
618
618
  modelClass: `${keys.target}::class`,
619
- pivotTable: decorate(keys.pivotTable, {
620
- tablePrefix: getConfig("model", "tablePrefix"),
621
- tableSuffix: getConfig("model", "tableSuffix")
622
- }),
619
+ pivotTable: keys.pivotTable,
623
620
  localKey: keys.local,
624
621
  foreignKey: keys.foreign,
625
622
  targetModelName: keys.target
package/dist/index.js CHANGED
@@ -1504,7 +1504,7 @@ var StubModelPrinter = class {
1504
1504
 
1505
1505
  // src/generator/lib/relationship/types.ts
1506
1506
  var getModel = (dmmf, name) => dmmf.datamodel.models.find((m) => m.name === name);
1507
- var dbNameOf = (m) => decorate(m.dbName ?? m.name, { tablePrefix: getConfig("model")?.tablePrefix, tableSuffix: getConfig("model")?.tableSuffix });
1507
+ var dbNameOf = (m) => decorate(m.dbName ?? m.name, getConfig("model"));
1508
1508
  var conventionalPivotName = (a, b) => [a, b].map((s) => s.toLowerCase()).sort().join("_");
1509
1509
  var objRels = (m) => m.fields.filter((f) => f.kind === "object");
1510
1510
  var getPrimaryKeyFields = (m) => {
@@ -1874,10 +1874,7 @@ function buildRelationsForModel(dmmf, model) {
1874
1874
  type: "belongsToMany",
1875
1875
  mode: "explicit",
1876
1876
  modelClass: `${keys.target}::class`,
1877
- pivotTable: decorate(keys.pivotTable, {
1878
- tablePrefix: getConfig("model", "tablePrefix"),
1879
- tableSuffix: getConfig("model", "tableSuffix")
1880
- }),
1877
+ pivotTable: keys.pivotTable,
1881
1878
  pivotLocal: keys.pivotLocal,
1882
1879
  pivotForeign: keys.pivotForeign,
1883
1880
  pivotColumns: keys.pivotColumns,
@@ -1895,10 +1892,7 @@ function buildRelationsForModel(dmmf, model) {
1895
1892
  type: "belongsToMany",
1896
1893
  mode: "implicit",
1897
1894
  modelClass: `${keys.target}::class`,
1898
- pivotTable: decorate(keys.pivotTable, {
1899
- tablePrefix: getConfig("model", "tablePrefix"),
1900
- tableSuffix: getConfig("model", "tableSuffix")
1901
- }),
1895
+ pivotTable: keys.pivotTable,
1902
1896
  localKey: keys.local,
1903
1897
  foreignKey: keys.foreign,
1904
1898
  targetModelName: keys.target
@@ -1972,25 +1966,28 @@ function parseTypeDirective(doc) {
1972
1966
  }
1973
1967
  function parseAppendsDirective(doc) {
1974
1968
  if (!doc) return void 0;
1975
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
1969
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
1976
1970
  if (!m) return void 0;
1977
- let body = m[1].trim();
1971
+ let body = (m[1] ?? "").trim();
1978
1972
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
1979
1973
  body = body.slice(1, -1).trim();
1980
1974
  }
1975
+ if (body.startsWith(":")) body = body.slice(1).trim();
1981
1976
  if (!body) return void 0;
1982
1977
  const entries = [];
1983
1978
  for (const raw of body.split(",")) {
1984
1979
  const token = raw.trim();
1985
1980
  if (!token) continue;
1986
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
1987
- if (!nameRaw) continue;
1988
- const name = nameRaw;
1989
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
1990
- entries.push({ name, type });
1991
- }
1992
- if (!entries.length) return void 0;
1993
- return { entries };
1981
+ const idx = token.indexOf(":");
1982
+ const name = (idx === -1 ? token : token.slice(0, idx)).trim();
1983
+ const type = (idx === -1 ? "" : token.slice(idx + 1)).trim();
1984
+ if (!name) continue;
1985
+ entries.push({
1986
+ name,
1987
+ type: type.length ? type : void 0
1988
+ });
1989
+ }
1990
+ return entries.length ? { entries } : void 0;
1994
1991
  }
1995
1992
  function getModelTypeDirective(model) {
1996
1993
  return parseTypeDirective(model.documentation);
@@ -2063,7 +2060,7 @@ var PrismaToLaravelModelGenerator = class {
2063
2060
  type: field.type
2064
2061
  };
2065
2062
  });
2066
- const guarded = guardedSet.size || properties.some((p) => p.guarded) ? [...guardedSet, ...properties.filter((p) => p.guarded).map((p) => p.name)] : hasToken("guarded", modelDoc) ? [] : void 0;
2063
+ const guarded = guardedSet.size || properties.some((p) => p.guarded) ? Array.from(/* @__PURE__ */ new Set([...guardedSet, ...properties.filter((p) => p.guarded).map((p) => p.name)])) : hasToken("guarded", modelDoc) ? [] : void 0;
2067
2064
  const relations = this.extractRelationsFromModel(model);
2068
2065
  const interfaces = {};
2069
2066
  for (const prop of properties) {
@@ -2125,7 +2122,6 @@ var PrismaToLaravelModelGenerator = class {
2125
2122
  docblockProps.push(`@property ${type} $${p.name}`);
2126
2123
  }
2127
2124
  for (const rel of relations) {
2128
- if (rel.pivotTable) ;
2129
2125
  const type = rel.type === "hasMany" || rel.type === "belongsToMany" ? `\\Illuminate\\Support\\Collection<int, ${rel.modelClass}>` : rel.modelClass;
2130
2126
  docblockProps.push(`@property ${type} $${rel.name}`);
2131
2127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-laravel-migrate",
3
- "version": "3.1.12",
3
+ "version": "3.1.14",
4
4
  "description": "Generate laravel migrations and/or models using prisma files",
5
5
  "bin": {
6
6
  "prisma-laravel-migrations": "./dist/cli/migrator.index.js",