joist-codegen 1.196.0 → 1.196.1

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":"scanEntityFiles.d.ts","sourceRoot":"","sources":["../src/scanEntityFiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,+GAA+G;AAC/G,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBvF"}
1
+ {"version":3,"file":"scanEntityFiles.d.ts","sourceRoot":"","sources":["../src/scanEntityFiles.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EAOX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKlC,+GAA+G;AAC/G,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvF"}
@@ -11,13 +11,7 @@ async function scanEntityFiles(config, dbMeta) {
11
11
  try {
12
12
  // load the entity.ts file (as a promise with fs/promises)
13
13
  const tsCode = (await (0, promises_1.readFile)((0, path_1.join)(config.entitiesDirectory, `${entity.name}.ts`))).toString();
14
- const defaultableFields = [
15
- ...entity.primitives,
16
- ...entity.enums,
17
- ...entity.pgEnums,
18
- ...entity.manyToOnes,
19
- ...entity.polymorphics,
20
- ];
14
+ const defaultableFields = recursiveDefaultableFields(dbMeta, entity);
21
15
  for (const match of tsCode.matchAll(regex)) {
22
16
  const field = defaultableFields.find((f) => f.fieldName === match[1]);
23
17
  if (field) {
@@ -30,4 +24,23 @@ async function scanEntityFiles(config, dbMeta) {
30
24
  }
31
25
  }));
32
26
  }
27
+ /**
28
+ * Traverse the entity inheritance tree to find all fields that can have defaults set on them.
29
+ *
30
+ * NOTE: I suspect here could be some edge cases here that will need to be ironed out, but should work
31
+ * for simple inheritence structures. In particular, there may be unexpected side effects if a base
32
+ * class field has a default set in one subtype, but not another.
33
+ */
34
+ function recursiveDefaultableFields(dbMeta, entity) {
35
+ if (!entity)
36
+ return [];
37
+ return [
38
+ ...entity.primitives,
39
+ ...entity.enums,
40
+ ...entity.pgEnums,
41
+ ...entity.manyToOnes,
42
+ ...entity.polymorphics,
43
+ ...(entity.baseClassName ? recursiveDefaultableFields(dbMeta, dbMeta.entitiesByName[entity.baseClassName]) : []),
44
+ ];
45
+ }
33
46
  //# sourceMappingURL=scanEntityFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scanEntityFiles.js","sourceRoot":"","sources":["../src/scanEntityFiles.ts"],"names":[],"mappings":";;AASA,0CAwBC;AAjCD,0CAAuC;AACvC,+BAA4B;AAI5B,mFAAmF;AACnF,MAAM,KAAK,GAAG,2CAA2C,CAAC;AAE1D,+GAA+G;AACxG,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,MAAkB;IACtE,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,CAAC;YACH,0DAA0D;YAC1D,MAAM,MAAM,GAAG,CAAC,MAAM,IAAA,mBAAQ,EAAC,IAAA,WAAI,EAAC,MAAM,CAAC,iBAAiB,EAAE,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YAChG,MAAM,iBAAiB,GAAG;gBACxB,GAAG,MAAM,CAAC,UAAU;gBACpB,GAAG,MAAM,CAAC,KAAK;gBACf,GAAG,MAAM,CAAC,OAAO;gBACjB,GAAG,MAAM,CAAC,UAAU;gBACpB,GAAG,MAAM,CAAC,YAAY;aACvB,CAAC;YACF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,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tE,IAAI,KAAK,EAAE,CAAC;oBACV,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,+BAA+B;QACjC,CAAC;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,0BAA0B,CACjC,MAAkB,EAClB,MAAoC;IAEpC,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,OAAO;QACL,GAAG,MAAM,CAAC,UAAU;QACpB,GAAG,MAAM,CAAC,KAAK;QACf,GAAG,MAAM,CAAC,OAAO;QACjB,GAAG,MAAM,CAAC,UAAU;QACpB,GAAG,MAAM,CAAC,YAAY;QACtB,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACjH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joist-codegen",
3
- "version": "1.196.0",
3
+ "version": "1.196.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "change-case": "^4.1.2",
26
26
  "fast-glob": "^3.3.2",
27
27
  "inquirer": "^9.3.0",
28
- "joist-utils": "1.196.0",
28
+ "joist-utils": "1.196.1",
29
29
  "jscodeshift": "^0.16.1",
30
30
  "knex": "^3.1.0",
31
31
  "pg": "^8.12.0",