@postxl/generator 0.27.3 → 0.27.4

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.
@@ -117,7 +117,8 @@ function parseModel({ dmmfModel, enums, models, config, }) {
117
117
  return Object.assign(Object.assign({ kind: 'relation' }, shared), { relatedModelBacklinkFieldName: refField.name, typeName: Types.toTypeName(dmmfField.type), unbrandedTypeName: getTsTypeForId(dmmfField), relationToModel: refModel });
118
118
  }
119
119
  if (dmmfField.isId) {
120
- return Object.assign(Object.assign({ kind: 'id' }, shared), { isUnique: isUniqueField(dmmfField), isGenerated: isAutoIncrementField(dmmfField) || isUUIDField(dmmfField), unbrandedTypeName: getTsTypeForId(dmmfField), model: core });
120
+ const isGeneratedField = isAutoIncrementField(dmmfField) || isUUIDField(dmmfField);
121
+ return Object.assign(Object.assign({ kind: 'id' }, shared), { isUnique: isUniqueField(dmmfField), isGenerated: isGeneratedField, unbrandedTypeName: getTsTypeForId(dmmfField), model: core });
121
122
  }
122
123
  if (dmmfField.kind === 'scalar') {
123
124
  let validation = undefined;
@@ -198,12 +199,28 @@ function validateFields({ fields, model: { name } }) {
198
199
  return { idField, defaultField, nameField };
199
200
  }
200
201
  function isAutoIncrementField(fieldDmmf) {
201
- const d = fieldDmmf.default;
202
- return d !== undefined && !!d.name && d.name === 'autoincrement';
202
+ if (fieldDmmf.default === undefined) {
203
+ return false;
204
+ }
205
+ if (Array.isArray(fieldDmmf.default)) {
206
+ return false;
207
+ }
208
+ if (typeof fieldDmmf.default === 'object') {
209
+ return fieldDmmf.default.name === 'autoincrement';
210
+ }
211
+ return false;
203
212
  }
204
213
  function isUUIDField(fieldDmmf) {
205
- const d = fieldDmmf.default;
206
- return d !== undefined && !!d.name && d.name === 'cuid';
214
+ if (fieldDmmf.default === undefined) {
215
+ return false;
216
+ }
217
+ if (Array.isArray(fieldDmmf.default)) {
218
+ return false;
219
+ }
220
+ if (typeof fieldDmmf.default === 'object') {
221
+ return fieldDmmf.default.name === 'uuid' || fieldDmmf.default.name === 'cuid';
222
+ }
223
+ return false;
207
224
  }
208
225
  function isUniqueField(fieldRaw) {
209
226
  return fieldRaw.isUnique && fieldRaw.type === 'String';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.27.3",
3
+ "version": "0.27.4",
4
4
  "main": "./dist/generator.js",
5
5
  "typings": "./dist/generator.d.ts",
6
6
  "bin": {