@nixxie-cms/core 1.0.1 → 1.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../../../../src/fields/types/timestamp","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gCAAsB;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAGvB,gCAAsB;AAMvB,MAAM,MAAM,oBAAoB,CAAC,YAAY,SAAS,gBAAgB,IAAI,iBAAiB,CACzF,YAAY,EACZ,mBAAmB,CAAC,UAAU,GAAG,QAAQ,CAAC,CAC3C,GAAG;IACF,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC9B,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,YAAY,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAA;IACvC,EAAE,CAAC,EAAE;QAEH,SAAS,CAAC,EAAE,OAAO,CAAA;QACnB,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;KAC/C,CAAA;CACF,CAAA;AAED,wBAAgB,SAAS,CAAC,YAAY,SAAS,gBAAgB,EAC7D,MAAM,GAAE,oBAAoB,CAAC,YAAY,CAAM,GAC9C,aAAa,CAAC,YAAY,CAAC,CAkF7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../../../../src/fields/types/timestamp","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,gCAAsB;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAGvB,gCAAsB;AAMvB,MAAM,MAAM,oBAAoB,CAAC,YAAY,SAAS,gBAAgB,IAAI,iBAAiB,CACzF,YAAY,EACZ,mBAAmB,CAAC,UAAU,GAAG,QAAQ,CAAC,CAC3C,GAAG;IACF,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC9B,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,YAAY,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAA;IACvC,EAAE,CAAC,EAAE;QAEH,SAAS,CAAC,EAAE,OAAO,CAAA;QACnB,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;KAC/C,CAAA;CACF,CAAA;AAED,wBAAgB,SAAS,CAAC,YAAY,SAAS,gBAAgB,EAC7D,MAAM,GAAE,oBAAoB,CAAC,YAAY,CAAM,GAC9C,aAAa,CAAC,YAAY,CAAC,CAuF7B"}
@@ -88,7 +88,7 @@ function timestamp(config = {}) {
88
88
  validation
89
89
  } = config;
90
90
  return meta => {
91
- var _config$db, _config$db2, _config$db3, _validation$isRequire;
91
+ var _config$db, _config$db2, _config$db3, _config$db4, _validation$isRequire;
92
92
  if (typeof defaultValue === 'string') {
93
93
  try {
94
94
  g.DateTime.parseValue(defaultValue);
@@ -97,10 +97,15 @@ function timestamp(config = {}) {
97
97
  }
98
98
  }
99
99
  const parsedDefaultValue = typeof defaultValue === 'string' ? g.DateTime.parseValue(defaultValue) : defaultValue;
100
+ // `db.updatedAt` (Prisma `@updatedAt`) and a `defaultValue` are both filled by the database, so
101
+ // the value is not "required" on create even when the column is non-nullable — otherwise
102
+ // `timestamp({ db: { updatedAt: true, isNullable: false } })` (e.g. via withTimestamps) would
103
+ // fail create validation with "missing value".
104
+ const hasPrismaDefaultValue = defaultValue !== undefined || Boolean((_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.updatedAt);
100
105
  const {
101
106
  mode,
102
107
  validate
103
- } = makeValidateHook(meta, config);
108
+ } = makeValidateHook(meta, config, undefined, hasPrismaDefaultValue);
104
109
  return fieldType({
105
110
  kind: 'scalar',
106
111
  mode,
@@ -112,9 +117,9 @@ function timestamp(config = {}) {
112
117
  } : defaultValue === undefined ? undefined : {
113
118
  kind: 'now'
114
119
  },
115
- updatedAt: (_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.updatedAt,
116
- map: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.map,
117
- extendPrismaSchema: (_config$db3 = config.db) === null || _config$db3 === void 0 ? void 0 : _config$db3.extendPrismaSchema
120
+ updatedAt: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.updatedAt,
121
+ map: (_config$db3 = config.db) === null || _config$db3 === void 0 ? void 0 : _config$db3.map,
122
+ extendPrismaSchema: (_config$db4 = config.db) === null || _config$db4 === void 0 ? void 0 : _config$db4.extendPrismaSchema
118
123
  })({
119
124
  ...config,
120
125
  ...defaultIsRequired(config, (_validation$isRequire = validation === null || validation === void 0 ? void 0 : validation.isRequired) !== null && _validation$isRequire !== void 0 ? _validation$isRequire : false),
@@ -142,8 +147,8 @@ function timestamp(config = {}) {
142
147
  }),
143
148
  resolve(val) {
144
149
  if (val === undefined) {
145
- var _config$db4;
146
- if (parsedDefaultValue === undefined && (_config$db4 = config.db) !== null && _config$db4 !== void 0 && _config$db4.updatedAt) return undefined;
150
+ var _config$db5;
151
+ if (parsedDefaultValue === undefined && (_config$db5 = config.db) !== null && _config$db5 !== void 0 && _config$db5.updatedAt) return undefined;
147
152
  if (parsedDefaultValue instanceof Date || parsedDefaultValue === undefined) {
148
153
  return parsedDefaultValue !== null && parsedDefaultValue !== void 0 ? parsedDefaultValue : null;
149
154
  }
@@ -169,10 +174,10 @@ function timestamp(config = {}) {
169
174
  __nxTelemetryFieldTypeName: '@nixxie-cms/timestamp',
170
175
  views: '@nixxie-cms/core/fields/types/timestamp/views',
171
176
  getAdminMeta() {
172
- var _config$db$updatedAt, _config$db5;
177
+ var _config$db$updatedAt, _config$db6;
173
178
  return {
174
179
  defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : null,
175
- updatedAt: (_config$db$updatedAt = (_config$db5 = config.db) === null || _config$db5 === void 0 ? void 0 : _config$db5.updatedAt) !== null && _config$db$updatedAt !== void 0 ? _config$db$updatedAt : false
180
+ updatedAt: (_config$db$updatedAt = (_config$db6 = config.db) === null || _config$db6 === void 0 ? void 0 : _config$db6.updatedAt) !== null && _config$db$updatedAt !== void 0 ? _config$db$updatedAt : false
176
181
  };
177
182
  }
178
183
  });
@@ -90,7 +90,7 @@ function timestamp(config = {}) {
90
90
  validation
91
91
  } = config;
92
92
  return meta => {
93
- var _config$db, _config$db2, _config$db3, _validation$isRequire;
93
+ var _config$db, _config$db2, _config$db3, _config$db4, _validation$isRequire;
94
94
  if (typeof defaultValue === 'string') {
95
95
  try {
96
96
  nextFields.g.DateTime.parseValue(defaultValue);
@@ -99,10 +99,15 @@ function timestamp(config = {}) {
99
99
  }
100
100
  }
101
101
  const parsedDefaultValue = typeof defaultValue === 'string' ? nextFields.g.DateTime.parseValue(defaultValue) : defaultValue;
102
+ // `db.updatedAt` (Prisma `@updatedAt`) and a `defaultValue` are both filled by the database, so
103
+ // the value is not "required" on create even when the column is non-nullable — otherwise
104
+ // `timestamp({ db: { updatedAt: true, isNullable: false } })` (e.g. via withTimestamps) would
105
+ // fail create validation with "missing value".
106
+ const hasPrismaDefaultValue = defaultValue !== undefined || Boolean((_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.updatedAt);
102
107
  const {
103
108
  mode,
104
109
  validate
105
- } = nonNullGraphql.makeValidateHook(meta, config);
110
+ } = nonNullGraphql.makeValidateHook(meta, config, undefined, hasPrismaDefaultValue);
106
111
  return nextFields.fieldType({
107
112
  kind: 'scalar',
108
113
  mode,
@@ -114,9 +119,9 @@ function timestamp(config = {}) {
114
119
  } : defaultValue === undefined ? undefined : {
115
120
  kind: 'now'
116
121
  },
117
- updatedAt: (_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.updatedAt,
118
- map: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.map,
119
- extendPrismaSchema: (_config$db3 = config.db) === null || _config$db3 === void 0 ? void 0 : _config$db3.extendPrismaSchema
122
+ updatedAt: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.updatedAt,
123
+ map: (_config$db3 = config.db) === null || _config$db3 === void 0 ? void 0 : _config$db3.map,
124
+ extendPrismaSchema: (_config$db4 = config.db) === null || _config$db4 === void 0 ? void 0 : _config$db4.extendPrismaSchema
120
125
  })({
121
126
  ...config,
122
127
  ...nonNullGraphql.defaultIsRequired(config, (_validation$isRequire = validation === null || validation === void 0 ? void 0 : validation.isRequired) !== null && _validation$isRequire !== void 0 ? _validation$isRequire : false),
@@ -144,8 +149,8 @@ function timestamp(config = {}) {
144
149
  }),
145
150
  resolve(val) {
146
151
  if (val === undefined) {
147
- var _config$db4;
148
- if (parsedDefaultValue === undefined && (_config$db4 = config.db) !== null && _config$db4 !== void 0 && _config$db4.updatedAt) return undefined;
152
+ var _config$db5;
153
+ if (parsedDefaultValue === undefined && (_config$db5 = config.db) !== null && _config$db5 !== void 0 && _config$db5.updatedAt) return undefined;
149
154
  if (parsedDefaultValue instanceof Date || parsedDefaultValue === undefined) {
150
155
  return parsedDefaultValue !== null && parsedDefaultValue !== void 0 ? parsedDefaultValue : null;
151
156
  }
@@ -171,10 +176,10 @@ function timestamp(config = {}) {
171
176
  __nxTelemetryFieldTypeName: '@nixxie-cms/timestamp',
172
177
  views: '@nixxie-cms/core/fields/types/timestamp/views',
173
178
  getAdminMeta() {
174
- var _config$db$updatedAt, _config$db5;
179
+ var _config$db$updatedAt, _config$db6;
175
180
  return {
176
181
  defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : null,
177
- updatedAt: (_config$db$updatedAt = (_config$db5 = config.db) === null || _config$db5 === void 0 ? void 0 : _config$db5.updatedAt) !== null && _config$db$updatedAt !== void 0 ? _config$db$updatedAt : false
182
+ updatedAt: (_config$db$updatedAt = (_config$db6 = config.db) === null || _config$db6 === void 0 ? void 0 : _config$db6.updatedAt) !== null && _config$db$updatedAt !== void 0 ? _config$db$updatedAt : false
178
183
  };
179
184
  }
180
185
  });
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var resolveHooks = require('./resolve-hooks-165a9ce2.cjs.js');
6
- var index = require('./index-89635494.cjs.js');
6
+ var index = require('./index-42045902.cjs.js');
7
7
  var nextFields = require('./next-fields-49c025ef.cjs.js');
8
8
  require('pluralize');
9
9
  require('@graphql-ts/schema');
@@ -1,5 +1,5 @@
1
1
  import { i as idFieldType, m as merge } from './resolve-hooks-6813a045.esm.js';
2
- import { t as timestamp, r as relationship } from './index-baa799e0.esm.js';
2
+ import { t as timestamp, r as relationship } from './index-15c8f81e.esm.js';
3
3
  export { g, a as gWithContext, g as graphql } from './next-fields-9bf04ed8.esm.js';
4
4
  import 'pluralize';
5
5
  import '@graphql-ts/schema';
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var resolveHooks = require('../../dist/resolve-hooks-165a9ce2.cjs.js');
6
6
  require('pluralize');
7
7
  var nextFields = require('../../dist/next-fields-49c025ef.cjs.js');
8
- var index = require('../../dist/index-89635494.cjs.js');
8
+ var index = require('../../dist/index-42045902.cjs.js');
9
9
  var nonNullGraphql = require('../../dist/non-null-graphql-add6bb3d.cjs.js');
10
10
  require('node:path');
11
11
  var schema = require('@graphql-ts/schema');
@@ -1,8 +1,8 @@
1
1
  import { u as userInputError, m as merge } from '../../dist/resolve-hooks-6813a045.esm.js';
2
2
  import 'pluralize';
3
3
  import { f as fieldType, g, o as orderDirectionEnum } from '../../dist/next-fields-9bf04ed8.esm.js';
4
- import { f as filters, a as resolveCommon, b as resolveString } from '../../dist/index-baa799e0.esm.js';
5
- export { r as relationship, t as timestamp } from '../../dist/index-baa799e0.esm.js';
4
+ import { f as filters, a as resolveCommon, b as resolveString } from '../../dist/index-15c8f81e.esm.js';
5
+ export { r as relationship, t as timestamp } from '../../dist/index-15c8f81e.esm.js';
6
6
  import { a as assertReadIsNonNullAllowed, m as makeValidateHook, d as defaultIsRequired, r as resolveDbNullable } from '../../dist/non-null-graphql-a84ed64d.esm.js';
7
7
  import 'node:path';
8
8
  import { GNonNull } from '@graphql-ts/schema';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixxie-cms/core",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nixxiecms/nixxie/tree/main/packages/core"
@@ -302,7 +302,7 @@
302
302
  "@types/react-dom": "^19.2.3",
303
303
  "@types/resolve": "^1.20.2",
304
304
  "@types/uuid": "^11.0.0",
305
- "@nixxie-cms/core": "^1.0.1"
305
+ "@nixxie-cms/core": "^1.0.3"
306
306
  },
307
307
  "preconstruct": {
308
308
  "entrypoints": [
@@ -154,6 +154,35 @@ const nextConfigTemplate = basePath => `const nextConfig = {
154
154
  // as they import ts files into nextjs
155
155
  transpilePackages: ['../../admin'],
156
156
  ${basePath ? `basePath: '${basePath}',` : ''}
157
+ webpack: (config, { webpack, isServer }) => {
158
+ // The Admin UI bundle pulls in isomorphic helpers (e.g. the GraphQL schema builder) from
159
+ // server packages whose modules also import Node built-ins via the "node:" scheme. Webpack
160
+ // cannot resolve "node:"-scheme imports for the browser, so on the client we strip the prefix
161
+ // and stub the built-ins to empty modules. The server-only code paths that actually use them
162
+ // are never executed in the browser.
163
+ if (!isServer) {
164
+ config.plugins.push(
165
+ new webpack.NormalModuleReplacementPlugin(/^node:/, resource => {
166
+ resource.request = resource.request.replace(/^node:/, '')
167
+ })
168
+ )
169
+ config.resolve.fallback = {
170
+ ...config.resolve.fallback,
171
+ crypto: false,
172
+ fs: false,
173
+ 'fs/promises': false,
174
+ http: false,
175
+ https: false,
176
+ module: false,
177
+ net: false,
178
+ os: false,
179
+ path: false,
180
+ stream: false,
181
+ util: false,
182
+ }
183
+ }
184
+ return config
185
+ },
157
186
  }
158
187
 
159
188
  module.exports = nextConfig`;
@@ -133,6 +133,35 @@ const nextConfigTemplate = basePath => `const nextConfig = {
133
133
  // as they import ts files into nextjs
134
134
  transpilePackages: ['../../admin'],
135
135
  ${basePath ? `basePath: '${basePath}',` : ''}
136
+ webpack: (config, { webpack, isServer }) => {
137
+ // The Admin UI bundle pulls in isomorphic helpers (e.g. the GraphQL schema builder) from
138
+ // server packages whose modules also import Node built-ins via the "node:" scheme. Webpack
139
+ // cannot resolve "node:"-scheme imports for the browser, so on the client we strip the prefix
140
+ // and stub the built-ins to empty modules. The server-only code paths that actually use them
141
+ // are never executed in the browser.
142
+ if (!isServer) {
143
+ config.plugins.push(
144
+ new webpack.NormalModuleReplacementPlugin(/^node:/, resource => {
145
+ resource.request = resource.request.replace(/^node:/, '')
146
+ })
147
+ )
148
+ config.resolve.fallback = {
149
+ ...config.resolve.fallback,
150
+ crypto: false,
151
+ fs: false,
152
+ 'fs/promises': false,
153
+ http: false,
154
+ https: false,
155
+ module: false,
156
+ net: false,
157
+ os: false,
158
+ path: false,
159
+ stream: false,
160
+ util: false,
161
+ }
162
+ }
163
+ return config
164
+ },
136
165
  }
137
166
 
138
167
  module.exports = nextConfig`;
@@ -11,6 +11,35 @@ export const nextConfigTemplate = (basePath?: string) =>
11
11
  // as they import ts files into nextjs
12
12
  transpilePackages: ['../../admin'],
13
13
  ${basePath ? `basePath: '${basePath}',` : ''}
14
+ webpack: (config, { webpack, isServer }) => {
15
+ // The Admin UI bundle pulls in isomorphic helpers (e.g. the GraphQL schema builder) from
16
+ // server packages whose modules also import Node built-ins via the "node:" scheme. Webpack
17
+ // cannot resolve "node:"-scheme imports for the browser, so on the client we strip the prefix
18
+ // and stub the built-ins to empty modules. The server-only code paths that actually use them
19
+ // are never executed in the browser.
20
+ if (!isServer) {
21
+ config.plugins.push(
22
+ new webpack.NormalModuleReplacementPlugin(/^node:/, resource => {
23
+ resource.request = resource.request.replace(/^node:/, '')
24
+ })
25
+ )
26
+ config.resolve.fallback = {
27
+ ...config.resolve.fallback,
28
+ crypto: false,
29
+ fs: false,
30
+ 'fs/promises': false,
31
+ http: false,
32
+ https: false,
33
+ module: false,
34
+ net: false,
35
+ os: false,
36
+ path: false,
37
+ stream: false,
38
+ util: false,
39
+ }
40
+ }
41
+ return config
42
+ },
14
43
  }
15
44
 
16
45
  module.exports = nextConfig`
@@ -49,7 +49,12 @@ export function timestamp<ListTypeInfo extends BaseListTypeInfo>(
49
49
  typeof defaultValue === 'string'
50
50
  ? (g.DateTime.parseValue(defaultValue) as Date)
51
51
  : defaultValue
52
- const { mode, validate } = makeValidateHook(meta, config)
52
+ // `db.updatedAt` (Prisma `@updatedAt`) and a `defaultValue` are both filled by the database, so
53
+ // the value is not "required" on create even when the column is non-nullable — otherwise
54
+ // `timestamp({ db: { updatedAt: true, isNullable: false } })` (e.g. via withTimestamps) would
55
+ // fail create validation with "missing value".
56
+ const hasPrismaDefaultValue = defaultValue !== undefined || Boolean(config.db?.updatedAt)
57
+ const { mode, validate } = makeValidateHook(meta, config, undefined, hasPrismaDefaultValue)
53
58
 
54
59
  return fieldType({
55
60
  kind: 'scalar',