@xleddyl/nuxt-cms 0.4.0 → 0.4.2

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
3
  "configKey": "cms",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
package/dist/module.mjs CHANGED
@@ -1017,12 +1017,8 @@ function blockTypesTs(entryName, key, field) {
1017
1017
  members.push(name);
1018
1018
  const lines = [];
1019
1019
  for (const [blockFieldKey, blockField] of Object.entries(block.fields)) {
1020
- if (blockField.type === "media") {
1021
- lines.push(` ${blockFieldKey}: ${mediaTsType(blockField)} | null`);
1022
- continue;
1023
- }
1024
- const base = scalarTsType(blockField);
1025
- lines.push(` ${blockFieldKey}: ${blockField.required ? base : `${base} | null`}`);
1020
+ const base = blockField.type === "media" ? mediaTsType(blockField) : scalarTsType(blockField);
1021
+ lines.push(` ${blockFieldKey}: ${base} | null`);
1026
1022
  }
1027
1023
  defs.push(`export interface ${props} {
1028
1024
  ${lines.join("\n")}
@@ -1643,13 +1639,9 @@ const module$1 = defineNuxtModule({
1643
1639
  ` dialect: '${dialect}',`,
1644
1640
  ` schema: '${toPosix(schemaTemplate.dst)}',`,
1645
1641
  ` out: '${toPosix(relativeMigrationsDir)}',`,
1646
- driver === "postgres" ? ` dbCredentials: { url: process.env.NUXT_CMS_DATABASE_URL ?? ${JSON.stringify(
1647
- databaseUrl
1648
- )} },` : driver === "libsql" ? ` dbCredentials: { url: process.env.NUXT_CMS_DATABASE_URL ?? ${JSON.stringify(
1649
- databaseUrl || `file:${toPosix(resolvedDbPath)}`
1650
- )}, authToken: (process.env.NUXT_CMS_DATABASE_AUTH_TOKEN ?? ${JSON.stringify(
1651
- databaseAuthToken
1652
- )}) || undefined },` : driver === "d1" ? `` : ` dbCredentials: { url: ${JSON.stringify(toPosix(resolvedDbPath))} },`,
1642
+ driver === "postgres" ? ` dbCredentials: { url: process.env.NUXT_CMS_DATABASE_URL },` : driver === "libsql" ? databaseUrl ? ` dbCredentials: { url: process.env.NUXT_CMS_DATABASE_URL, authToken: process.env.NUXT_CMS_DATABASE_AUTH_TOKEN || undefined },` : ` dbCredentials: { url: ${JSON.stringify(
1643
+ `file:${toPosix(resolvedDbPath)}`
1644
+ )} },` : driver === "d1" ? `` : ` dbCredentials: { url: ${JSON.stringify(toPosix(resolvedDbPath))} },`,
1653
1645
  `}`,
1654
1646
  ``
1655
1647
  ].join("\n")
@@ -80,8 +80,7 @@ ${lines.join("\n")}
80
80
  }`;
81
81
  }
82
82
  function blockFieldSdl(field) {
83
- if (field.type === "media") return { base: "CmsMedia", nonNull: false };
84
- return { base: scalarFor(field), nonNull: !!field.required };
83
+ return field.type === "media" ? "CmsMedia" : scalarFor(field);
85
84
  }
86
85
  function sharedBlockFieldsSdl(field) {
87
86
  const blocks = Object.values(field.blocks ?? {});
@@ -92,9 +91,8 @@ function sharedBlockFieldsSdl(field) {
92
91
  const rendered = blocks.map((block) => block.fields[key]);
93
92
  if (rendered.some((blockField) => !blockField)) continue;
94
93
  const types = rendered.map((blockField) => blockFieldSdl(blockField));
95
- if (types.some((type) => type.base !== types[0].base)) continue;
96
- const nonNull = types.every((type) => type.nonNull);
97
- lines.push(` ${key}: ${types[0].base}${nonNull ? "!" : ""}`);
94
+ if (types.some((type) => type !== types[0])) continue;
95
+ lines.push(` ${key}: ${types[0]}`);
98
96
  }
99
97
  return lines;
100
98
  }
@@ -109,8 +107,7 @@ ${shared.join("\n")}
109
107
  for (const [blockName, block] of blocks) {
110
108
  const lines = [" type: String!"];
111
109
  for (const [blockFieldKey, blockField] of Object.entries(block.fields)) {
112
- const type = blockFieldSdl(blockField);
113
- lines.push(` ${blockFieldKey}: ${type.base}${type.nonNull ? "!" : ""}`);
110
+ lines.push(` ${blockFieldKey}: ${blockFieldSdl(blockField)}`);
114
111
  }
115
112
  const gqlType = blockTypeName(name, key, blockName);
116
113
  defs.push(`type ${gqlType} implements ${interfaceName} {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",