@postxl/generator 0.6.0 → 0.6.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.
@@ -151,7 +151,9 @@ function generateFieldDataBoolean({}) {
151
151
  return faker_1.faker.datatype.boolean().toString();
152
152
  }
153
153
  function generateFieldDataDate({ field, model, index }) {
154
- return `new Date('${faker_1.faker.date.past(3)}')`;
154
+ const d = faker_1.faker.date.past(3);
155
+ d.setHours(0, 0, 0, 0);
156
+ return `new Date('${d.toISOString()}')`;
155
157
  }
156
158
  function generateFieldDataRelation({ field, model, index, itemCount, }) {
157
159
  const referenceId = faker_1.faker.datatype.number({ min: 1, max: itemCount });
@@ -2,7 +2,7 @@
2
2
  * Name of a Typescript type, e.g. "Aggregation".
3
3
  */
4
4
  export type TypeName = string & {
5
- readonly typeName: unique symbol;
5
+ readonly ___type: 'TypeName';
6
6
  };
7
7
  /**
8
8
  * Brands a raw string to a TypeScript Type identifier.
@@ -12,7 +12,7 @@ export declare const toTypeName: (t: string) => TypeName;
12
12
  * The name of a function (e.g. "toAggregation").
13
13
  */
14
14
  export type Function = string & {
15
- readonly functionName: unique symbol;
15
+ readonly ___type: 'FunctionName';
16
16
  };
17
17
  /**
18
18
  * Converts a string to a branded function name.
@@ -22,7 +22,7 @@ export declare const toFunction: (t: string) => Function;
22
22
  * The name of a class, e.g. "AggregationRepository".
23
23
  */
24
24
  export type ClassName = string & {
25
- readonly className: unique symbol;
25
+ readonly ___type: 'ClassName';
26
26
  };
27
27
  /**
28
28
  * Converts a raw string to a branded ClassName.
@@ -32,7 +32,7 @@ export declare const toClassName: (t: string) => ClassName;
32
32
  * The name of a variable or a property in the generated code.
33
33
  */
34
34
  export type VariableName = string & {
35
- readonly variableName: unique symbol;
35
+ readonly ___type: 'VariableName';
36
36
  };
37
37
  /**
38
38
  * Converts a string to a branded VariableName.
@@ -42,7 +42,7 @@ export declare const toVariableName: (t: string) => VariableName;
42
42
  * A name of the file without a file extension, e.g. "aggregation.type".
43
43
  */
44
44
  export type FileName = string & {
45
- readonly fileName: unique symbol;
45
+ readonly ___type: 'FileName';
46
46
  };
47
47
  /**
48
48
  * Lets you brand a string value as a name of the file.
@@ -54,7 +54,7 @@ export declare const toFileName: (t: string) => FileName;
54
54
  * A name of the folder without the trailing and leading slash (e.g. "aggregation").
55
55
  */
56
56
  export type FolderName = string & {
57
- readonly folderName: unique symbol;
57
+ readonly ___type: 'FolderName';
58
58
  };
59
59
  /**
60
60
  * Converts a string to a branded FolderName.
@@ -64,7 +64,7 @@ export declare const toFolderName: (t: string) => FolderName;
64
64
  * A relative or absolute path to a file or folder.
65
65
  */
66
66
  export type Path = string & {
67
- readonly fileName: unique symbol;
67
+ readonly ___type: 'FileName';
68
68
  };
69
69
  /**
70
70
  * Converts a string to a branded FileName.
@@ -33,6 +33,32 @@ const toPascalCase = (str) => {
33
33
  return s.charAt(0).toUpperCase() + s.slice(1);
34
34
  };
35
35
  exports.toPascalCase = toPascalCase;
36
+ const irregularPlurals = {
37
+ alumnus: 'alumni',
38
+ analysis: 'analyses',
39
+ appendix: 'appendices',
40
+ axis: 'axes',
41
+ basis: 'bases',
42
+ child: 'children',
43
+ crisis: 'crises',
44
+ criterion: 'criteria',
45
+ data: 'data',
46
+ datum: 'data',
47
+ diagnosis: 'diagnoses',
48
+ focus: 'foci',
49
+ hypothesis: 'hypotheses',
50
+ index: 'indices',
51
+ matrix: 'matrices',
52
+ medium: 'media',
53
+ parenthesis: 'parentheses',
54
+ phenomenon: 'phenomena',
55
+ prognosis: 'prognoses',
56
+ radius: 'radii',
57
+ suffix: 'suffixes',
58
+ syllabus: 'syllabi',
59
+ synopsis: 'synopses',
60
+ thesis: 'theses',
61
+ };
36
62
  /**
37
63
  * Returns a pluralized version of the given string based on the count.
38
64
  */
@@ -50,6 +76,13 @@ const pluralize = (s, count = 2) => {
50
76
  if (s.endsWith('s')) {
51
77
  return s;
52
78
  }
79
+ //check if word ends with any irregular plurals
80
+ const lower = s.toLowerCase();
81
+ for (const [irregularPlural, irregularSingular] of Object.entries(irregularPlurals)) {
82
+ if (lower.endsWith(irregularPlural)) {
83
+ return s.slice(0, -irregularPlural.length + 1) + irregularSingular.slice(1);
84
+ }
85
+ }
53
86
  return s + 's';
54
87
  };
55
88
  exports.pluralize = pluralize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "main": "./dist/generator.js",
5
5
  "typings": "./dist/generator.d.ts",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  "prettier": "^2.8.7",
22
22
  "remeda": "1.9.4",
23
23
  "zod": "3.21.4",
24
- "@postxl/lock": "0.1.0"
24
+ "@postxl/lock": "0.1.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@prisma/client": "4.12.0",
@@ -46,8 +46,10 @@
46
46
  "prepublish": "tsc -b",
47
47
  "dev": "tsc -b -w",
48
48
  "test": "jest",
49
+ "test:watch": "jest --watch",
49
50
  "test:types": "tsc --noEmit",
50
- "testgen:mca": "pnpm run build && prisma generate --schema ./tests/schemas/mca/mca.prisma",
51
- "testgen:la": "pnpm run build && prisma generate --schema ./tests/schemas/la/la.prisma"
51
+ "testgen:simple": "cd ./tests/schemas/simple/ && prisma generate",
52
+ "testgen:mca": "cd ./tests/schemas/mca/ && prisma generate",
53
+ "testgen:la": "cd ./tests/schemas/la/ && prisma generate"
52
54
  }
53
55
  }