@postxl/generator 0.0.21 → 0.0.23

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/package.json CHANGED
@@ -1,8 +1,14 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "main": "./dist/src/generator.js",
5
- "bin": "./dist/src/generator.js",
5
+ "typings": "./dist/src/generator.d.ts",
6
+ "bin": {
7
+ "@postxl/generator": "./dist/src/generator.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
6
12
  "repository": {
7
13
  "type": "git",
8
14
  "url": "https://github.com/postxl/postxl"
@@ -11,7 +17,6 @@
11
17
  "@faker-js/faker": "7.6.0",
12
18
  "@prisma/generator-helper": "4.12.0",
13
19
  "@prisma/internals": "^4.12.0",
14
- "assert-never": "^1.2.1",
15
20
  "fast-glob": "^3.2.12",
16
21
  "remeda": "1.9.4",
17
22
  "zod": "3.21.4"
@@ -39,6 +44,7 @@
39
44
  "prepublish": "tsc -b",
40
45
  "dev": "tsc -b -w",
41
46
  "test": "jest",
47
+ "test:types": "tsc --noEmit",
42
48
  "testgen:mca": "pnpm run build && prisma generate --schema ./tests/schemas/mca/mca.prisma",
43
49
  "testgen:la": "pnpm run build && prisma generate --schema ./tests/schemas/la/la.prisma"
44
50
  }
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # @postxl/generator
2
-
3
- ## 0.0.21
4
-
5
- ### Patch Changes
6
-
7
- - [`fc22c09`](https://github.com/PostXL/PostXL/commit/fc22c09bea23c00c69dcd8725ebdb1f0c400d924) Thanks [@maticzav](https://github.com/maticzav)! - This is the first release of the generator package using Changesets.
package/changelog.md DELETED
@@ -1,115 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.0.20
4
-
5
- ### Fixes
6
-
7
- - Adjust pluralization of `ModelMetaData.reactQueryMethod`
8
-
9
- ## 0.0.19
10
-
11
- ### Changes
12
-
13
- - Use pluralized model name for TRPC routers
14
-
15
- ## 0.0.18
16
-
17
- ### Fixes
18
-
19
- - change hardcorde model name in repository error message to model's name
20
- - Convert `isEmpty` to sync
21
-
22
- ### Chores
23
-
24
- - Bump Prisma to 4.12.0
25
-
26
- ## 0.0.15
27
-
28
- ### Added
29
-
30
- - Add `dataService.isEmpty` function
31
-
32
- ## 0.0.14
33
-
34
- ### Fixes
35
-
36
- - Clear unique Ids in repos upon reInit
37
-
38
- ### Fixes
39
-
40
- # 0.0.13
41
-
42
- ### Fixes
43
-
44
- - Generated branded types now use `readonly ___type: 'ModelName'` instead of `readonly isModelName: unique symbol` to re-enable type inference
45
-
46
- ## 0.0.12
47
-
48
- ### Added
49
-
50
- - Remove remaining unbranded types from other repo functions
51
-
52
- ## 0.0.11
53
-
54
- ### Added
55
-
56
- - Add skipping of generators by remove path in generator config
57
-
58
- ## 0.0.10
59
-
60
- ### Fixes
61
-
62
- - Generated files now do not cause linting errors from Prettier as newline is added at the end of the file
63
- - Moved data service and module to root of data module
64
-
65
- ## 0.0.9
66
-
67
- ### Fixes
68
-
69
- - Fixed `isDefault` and `isLabel` field attributes
70
-
71
- ## 0.0.8
72
-
73
- ### Added
74
-
75
- - `repositories` array added to repository generator
76
-
77
- ## 0.0.7
78
-
79
- ### Fixed
80
-
81
- - Replace static project references with configured schema project
82
-
83
- ## 0.0.6
84
-
85
- ### Fixed
86
-
87
- - Use local paths when importin repositories in dataService
88
-
89
- ## 0.0.4/0.0.5
90
-
91
- ### Removed
92
-
93
- - `delete` method of repositories does not accept unbranded ids anymore
94
-
95
- ## 0.0.3
96
-
97
- ### Removed
98
-
99
- - 🔇 Removed debug output attribute parser
100
-
101
- ## 0.0.2
102
-
103
- ### Added
104
-
105
- - Field attribute: maxLength attribute - this is now enforced in the repository
106
- - `createMany` generated by repository generator
107
- - Internal: added sample schemas for testing
108
-
109
- ### Removed
110
-
111
- - `get` method of repositories does not accept unbranded ids anymore
112
-
113
- ### Fixed
114
-
115
- - `unique` field attribute is now generated correctly
package/jest.config.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { Config } from 'jest'
2
- // import { pathsToModuleNameMapper } from 'ts-jest'
3
- // import { compilerOptions } from './tsconfig.json'
4
-
5
- const config: Config = {
6
- verbose: true,
7
- // roots: ['<rootDir>/tests', '<rootDir>/src'],
8
- testEnvironment: 'node',
9
- transform: {
10
- '^.+\\.tsx?$': 'ts-jest',
11
- },
12
- testRegex: '(\\.|/)test\\.tsx?$',
13
- testPathIgnorePatterns: ['/node_modules/', '/__fixtures__/'],
14
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
15
- // moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src/' }),
16
- }
17
-
18
- export default config
@@ -1,91 +0,0 @@
1
- import {
2
- getFieldAttributes,
3
- getModelAttributes,
4
- parseArgumentToStringOrStringArray,
5
- parseAttributesFromDocumentation,
6
- } from '../src/prisma/attributes'
7
-
8
- describe('argument parser', () => {
9
- test('Blank argument should return blank string', () => {
10
- expect(parseArgumentToStringOrStringArray('')).toEqual('')
11
- })
12
-
13
- test('Argument without quotes should return as is', () => {
14
- expect(parseArgumentToStringOrStringArray('example')).toEqual('example')
15
- })
16
-
17
- test('Argument with quotes should return without quotes', () => {
18
- expect(parseArgumentToStringOrStringArray('"example"')).toEqual('example')
19
- })
20
-
21
- test('Argument with escaped quotes should return without quotes', () => {
22
- expect(parseArgumentToStringOrStringArray('"example \\"with quotes\\""')).toEqual('example "with quotes"')
23
- })
24
-
25
- test('Argument with array of strings should convert to array', () => {
26
- expect(parseArgumentToStringOrStringArray('["example1", "example2"]')).toEqual(['example1', 'example2'])
27
- })
28
- })
29
-
30
- describe('attribute parser', () => {
31
- test('Missing documentation should return blank object', () => {
32
- expect(parseAttributesFromDocumentation({})).toEqual({})
33
- })
34
-
35
- test('Entries without "@@" should be ignored', () => {
36
- expect(parseAttributesFromDocumentation({ documentation: 'Some documentation' })).toEqual({})
37
- })
38
-
39
- test('Entries with "@@" should be parsed', () => {
40
- expect(parseAttributesFromDocumentation({ documentation: '@@ignore()' })).toEqual({ ignore: '' })
41
- })
42
-
43
- test('Attributes should be converted to camelCase', () => {
44
- expect(parseAttributesFromDocumentation({ documentation: '@@IGNORE()' })).toEqual({ iGNORE: '' })
45
- })
46
- })
47
-
48
- describe('model attribute: ignore', () => {
49
- test('should default to false', () => {
50
- expect(getModelAttributes({} as any).ignore).toBe(false)
51
- expect(getModelAttributes({ documentation: '' } as any).ignore).toBe(false)
52
- expect(getModelAttributes({ documentation: '@@test()' } as any).ignore).toBe(false)
53
- })
54
- test('should be true if @@ignore attribute is provided', () => {
55
- expect(getModelAttributes({ documentation: '@@ignore()' } as any).ignore).toBe(true)
56
- })
57
- })
58
-
59
- describe('field attribute: ignore', () => {
60
- test('should default to false', () => {
61
- expect(getFieldAttributes({} as any).ignore).toBe(false)
62
- expect(getFieldAttributes({ documentation: '' } as any).ignore).toBe(false)
63
- expect(getFieldAttributes({ documentation: '@@test()' } as any).ignore).toBe(false)
64
- })
65
- test('should be true if @@ignore attribute is provided', () => {
66
- expect(getFieldAttributes({ documentation: '@@ignore()' } as any).ignore).toBe(true)
67
- })
68
- test('should be true if Prisma field has isIgnored flag set to true', () => {
69
- expect(getFieldAttributes({ isIgnored: true } as any).ignore).toBe(true)
70
- })
71
- })
72
-
73
- describe('field attributes: example and examples', () => {
74
- test('should default to undefined', () => {
75
- expect(getFieldAttributes({} as any).examples).toBe(undefined)
76
- })
77
- test('should parse "@@examples" attribute', () => {
78
- expect(getFieldAttributes({ documentation: '@@examples("test")' } as any).examples).toStrictEqual(['test'])
79
- })
80
- test('should parse "@@example" attribute', () => {
81
- expect(getFieldAttributes({ documentation: '@@example("test")' } as any).examples).toStrictEqual(['test'])
82
- })
83
- test('should give precedence to "@@examples" over "@@example" attribute', () => {
84
- expect(getFieldAttributes({ documentation: '@@example("B")\n@@examples("A")' } as any).examples).toStrictEqual([
85
- 'A',
86
- ])
87
- })
88
- test('should parse "@@example" attribute with an array of examples', () => {
89
- expect(getFieldAttributes({ documentation: '@@example("A", "B")' } as any).examples).toStrictEqual(['A', 'B'])
90
- })
91
- })
@@ -1,32 +0,0 @@
1
- import { getRelativePath } from '../src/lib/utils/file'
2
-
3
- describe('virtual file system', () => {
4
- test('correctly resolves path to the same file', () => {
5
- expect(getRelativePath({ from: 'a/b/c', to: 'a/b/c' })).toEqual('./c')
6
- })
7
-
8
- test('correctly resolves path to a file in the same folder', () => {
9
- expect(getRelativePath({ from: 'a/b/c', to: 'a/b/d' })).toEqual('./d')
10
- })
11
-
12
- test('correclty, resolves path to a file in a parent folder', () => {
13
- expect(getRelativePath({ from: 'a/b/c', to: 'a/d' })).toEqual('../d')
14
- })
15
-
16
- test('correctly resolves completely different paths', () => {
17
- expect(getRelativePath({ from: 'a/b/c', to: 'd/e/f' })).toEqual('../../d/e/f')
18
- })
19
-
20
- test('correctly resolves path to a package', () => {
21
- expect(getRelativePath({ from: 'a/b/c', to: '@lib/package' })).toEqual('@lib/package')
22
- })
23
-
24
- test('correctly resolves relative paths', () => {
25
- expect(
26
- getRelativePath({
27
- from: './backend/libs/data/src/services/data.module',
28
- to: './backend/libs/data/src/repositories/country.repository',
29
- }),
30
- ).toEqual('../repositories/country.repository')
31
- })
32
- })