prisma-laravel-migrate 3.1.13 → 3.1.15

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
@@ -1195,7 +1195,7 @@ async function loadSharedConfig(schemaDir) {
1195
1195
  async function generateLaravelSchema(options) {
1196
1196
  const { dmmf, generator } = options;
1197
1197
  const raw = generator.config ?? {};
1198
- const schemaDir = path13.dirname(options.schemaPath);
1198
+ const schemaDir = path13.dirname(generator.sourceFilePath ?? path13.resolve(options.schemaPath));
1199
1199
  const shared = await loadSharedConfig(schemaDir);
1200
1200
  let groups = [];
1201
1201
  const loadGroups = async (p) => {
@@ -1906,25 +1906,28 @@ function parseTypeDirective(doc) {
1906
1906
  }
1907
1907
  function parseAppendsDirective(doc) {
1908
1908
  if (!doc) return void 0;
1909
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
1909
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
1910
1910
  if (!m) return void 0;
1911
- let body = m[1].trim();
1911
+ let body = (m[1] ?? "").trim();
1912
1912
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
1913
1913
  body = body.slice(1, -1).trim();
1914
1914
  }
1915
+ if (body.startsWith(":")) body = body.slice(1).trim();
1915
1916
  if (!body) return void 0;
1916
1917
  const entries = [];
1917
1918
  for (const raw of body.split(",")) {
1918
1919
  const token = raw.trim();
1919
1920
  if (!token) continue;
1920
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
1921
- if (!nameRaw) continue;
1922
- const name = nameRaw;
1923
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
1924
- entries.push({ name, type });
1925
- }
1926
- if (!entries.length) return void 0;
1927
- 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;
1928
1931
  }
1929
1932
  function getModelTypeDirective(model) {
1930
1933
  return parseTypeDirective(model.documentation);
@@ -1997,7 +2000,7 @@ var PrismaToLaravelModelGenerator = class {
1997
2000
  type: field.type
1998
2001
  };
1999
2002
  });
2000
- 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;
2001
2004
  const relations = this.extractRelationsFromModel(model);
2002
2005
  const interfaces = {};
2003
2006
  for (const prop of properties) {
@@ -2253,8 +2256,9 @@ function buildModelContent(model) {
2253
2256
  // src/generator/modeler/index.ts
2254
2257
  async function generateLaravelModels(options) {
2255
2258
  const { dmmf, generator } = options;
2259
+ generator.sourceFilePath;
2256
2260
  const raw = generator.config ?? {};
2257
- const schemaDir = path13.dirname(options.schemaPath);
2261
+ const schemaDir = path13.dirname(path13.resolve(options.schemaPath));
2258
2262
  const shared = await loadSharedConfig(schemaDir);
2259
2263
  let groups = [];
2260
2264
  if (raw["groups"]) {
@@ -1164,7 +1164,7 @@ async function loadSharedConfig(schemaDir) {
1164
1164
  async function generateLaravelSchema(options) {
1165
1165
  const { dmmf, generator } = options;
1166
1166
  const raw = generator.config ?? {};
1167
- const schemaDir = path7.dirname(options.schemaPath);
1167
+ const schemaDir = path7.dirname(generator.sourceFilePath ?? path7.resolve(options.schemaPath));
1168
1168
  const shared = await loadSharedConfig(schemaDir);
1169
1169
  let groups = [];
1170
1170
  const loadGroups = async (p) => {
@@ -736,25 +736,28 @@ function buildRelationsForModel(dmmf, model) {
736
736
  // src/generator/ts/directives.ts
737
737
  function parseAppendsDirective(doc) {
738
738
  if (!doc) return void 0;
739
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
739
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
740
740
  if (!m) return void 0;
741
- let body = m[1].trim();
741
+ let body = (m[1] ?? "").trim();
742
742
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
743
743
  body = body.slice(1, -1).trim();
744
744
  }
745
+ if (body.startsWith(":")) body = body.slice(1).trim();
745
746
  if (!body) return void 0;
746
747
  const entries = [];
747
748
  for (const raw of body.split(",")) {
748
749
  const token = raw.trim();
749
750
  if (!token) continue;
750
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
751
- if (!nameRaw) continue;
752
- const name = nameRaw;
753
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
754
- 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
+ });
755
759
  }
756
- if (!entries.length) return void 0;
757
- return { entries };
760
+ return entries.length ? { entries } : void 0;
758
761
  }
759
762
 
760
763
  // src/generator/modeler/generator.ts
@@ -818,7 +821,7 @@ var PrismaToLaravelModelGenerator = class {
818
821
  type: field.type
819
822
  };
820
823
  });
821
- 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;
822
825
  const relations = this.extractRelationsFromModel(model);
823
826
  const interfaces = {};
824
827
  for (const prop of properties) {
@@ -1259,8 +1262,9 @@ function buildModelContent(model) {
1259
1262
  // src/generator/modeler/index.ts
1260
1263
  async function generateLaravelModels(options) {
1261
1264
  const { dmmf, generator } = options;
1265
+ generator.sourceFilePath;
1262
1266
  const raw = generator.config ?? {};
1263
- const schemaDir = path7.dirname(options.schemaPath);
1267
+ const schemaDir = path7.dirname(path7.resolve(options.schemaPath));
1264
1268
  const shared = await loadSharedConfig(schemaDir);
1265
1269
  let groups = [];
1266
1270
  if (raw["groups"]) {
@@ -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);
package/dist/index.js CHANGED
@@ -1317,7 +1317,7 @@ async function loadSharedConfig(schemaDir) {
1317
1317
  async function generateLaravelSchema(options) {
1318
1318
  const { dmmf, generator } = options;
1319
1319
  const raw = generator.config ?? {};
1320
- const schemaDir = path9.dirname(options.schemaPath);
1320
+ const schemaDir = path9.dirname(generator.sourceFilePath ?? path9.resolve(options.schemaPath));
1321
1321
  const shared = await loadSharedConfig(schemaDir);
1322
1322
  let groups = [];
1323
1323
  const loadGroups = async (p) => {
@@ -1966,25 +1966,28 @@ function parseTypeDirective(doc) {
1966
1966
  }
1967
1967
  function parseAppendsDirective(doc) {
1968
1968
  if (!doc) return void 0;
1969
- const m = doc.match(/@appends\s*(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/);
1969
+ const m = doc.match(/@appends\s*(?::\s*)?(\{[^}]*\}|\([^)]*\)|[^\r\n]*)/i);
1970
1970
  if (!m) return void 0;
1971
- let body = m[1].trim();
1971
+ let body = (m[1] ?? "").trim();
1972
1972
  if (body.startsWith("{") && body.endsWith("}") || body.startsWith("(") && body.endsWith(")")) {
1973
1973
  body = body.slice(1, -1).trim();
1974
1974
  }
1975
+ if (body.startsWith(":")) body = body.slice(1).trim();
1975
1976
  if (!body) return void 0;
1976
1977
  const entries = [];
1977
1978
  for (const raw of body.split(",")) {
1978
1979
  const token = raw.trim();
1979
1980
  if (!token) continue;
1980
- const [nameRaw, typeRaw] = token.split(":").map((s) => s.trim());
1981
- if (!nameRaw) continue;
1982
- const name = nameRaw;
1983
- const type = typeRaw && typeRaw.length ? typeRaw : void 0;
1984
- entries.push({ name, type });
1985
- }
1986
- if (!entries.length) return void 0;
1987
- 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;
1988
1991
  }
1989
1992
  function getModelTypeDirective(model) {
1990
1993
  return parseTypeDirective(model.documentation);
@@ -2057,7 +2060,7 @@ var PrismaToLaravelModelGenerator = class {
2057
2060
  type: field.type
2058
2061
  };
2059
2062
  });
2060
- 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;
2061
2064
  const relations = this.extractRelationsFromModel(model);
2062
2065
  const interfaces = {};
2063
2066
  for (const prop of properties) {
@@ -2248,8 +2251,9 @@ var PrismaToLaravelModelGenerator = class {
2248
2251
  // src/generator/modeler/index.ts
2249
2252
  async function generateLaravelModels(options) {
2250
2253
  const { dmmf, generator } = options;
2254
+ generator.sourceFilePath;
2251
2255
  const raw = generator.config ?? {};
2252
- const schemaDir = path9.dirname(options.schemaPath);
2256
+ const schemaDir = path9.dirname(path9.resolve(options.schemaPath));
2253
2257
  const shared = await loadSharedConfig(schemaDir);
2254
2258
  let groups = [];
2255
2259
  if (raw["groups"]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-laravel-migrate",
3
- "version": "3.1.13",
3
+ "version": "3.1.15",
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",