@apso/cli 0.1.9 → 0.3.0
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/README.md +511 -0
- package/dist/commands/server/scaffold.js +1 -1
- package/dist/lib/controller.js +2 -2
- package/dist/lib/dto.js +1 -1
- package/dist/lib/entity.js +1 -1
- package/dist/lib/service.d.ts +1 -8
- package/dist/lib/service.js +28 -4
- package/dist/lib/templates/entities/entity-col-datetime.eta +4 -0
- package/dist/lib/templates/entities/entity-col-geography.eta +29 -0
- package/dist/lib/templates/entities/entity-col-geometry.eta +29 -0
- package/dist/lib/templates/entities/entity-col-geometrycollection.eta +29 -0
- package/dist/lib/templates/entities/entity-col-linestring.eta +37 -0
- package/dist/lib/templates/entities/entity-col-multilinestring.eta +44 -0
- package/dist/lib/templates/entities/entity-col-multipoint.eta +37 -0
- package/dist/lib/templates/entities/entity-col-multipolygon.eta +50 -0
- package/dist/lib/templates/entities/entity-col-polygon.eta +44 -0
- package/dist/lib/templates/graphql/dto/dto-col-decimal.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-geography.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-geometry.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-geometrycollection.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-linestring.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-multilinestring.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-multipoint.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-multipolygon.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-numeric.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-point.eta +4 -0
- package/dist/lib/templates/graphql/dto/dto-col-polygon.eta +4 -0
- package/dist/lib/templates/header.eta +8 -3
- package/dist/lib/templates/rest/dto-rest.eta +26 -1
- package/dist/lib/templates/rest/ormconfig.eta +2 -0
- package/dist/lib/templates/rest/service-rest-spec.eta +16 -7
- package/dist/lib/types/field.d.ts +3 -1
- package/dist/lib/utils/field.d.ts +1 -0
- package/dist/lib/utils/field.js +42 -9
- package/dist/lib/utils/file-system.d.ts +4 -0
- package/dist/lib/utils/file-system.js +9 -1
- package/dist/lib/utils/relationships/parse.js +1 -1
- package/dist/tests/templates/entities/types/decimal-field-validation.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/decimal-field-validation.spec.js +100 -0
- package/dist/tests/templates/entities/types/geometry-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/geometry-template.spec.js +58 -0
- package/dist/tests/templates/entities/types/polygon-template.spec.d.ts +1 -0
- package/dist/tests/templates/entities/types/polygon-template.spec.js +58 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const field_1 = require("../../../../lib/utils/field");
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
5
|
+
(0, globals_1.describe)('Decimal Field Validation Tests', () => {
|
|
6
|
+
(0, globals_1.it)('should accept valid decimal field with precision and scale', () => {
|
|
7
|
+
const field = {
|
|
8
|
+
name: 'price',
|
|
9
|
+
type: 'decimal',
|
|
10
|
+
precision: 10,
|
|
11
|
+
scale: 2,
|
|
12
|
+
nullable: false
|
|
13
|
+
};
|
|
14
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).not.toThrow();
|
|
15
|
+
});
|
|
16
|
+
(0, globals_1.it)('should accept valid numeric field with precision and scale', () => {
|
|
17
|
+
const field = {
|
|
18
|
+
name: 'amount',
|
|
19
|
+
type: 'numeric',
|
|
20
|
+
precision: 16,
|
|
21
|
+
scale: 6,
|
|
22
|
+
nullable: false
|
|
23
|
+
};
|
|
24
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).not.toThrow();
|
|
25
|
+
});
|
|
26
|
+
(0, globals_1.it)('should accept decimal field without precision and scale (uses defaults)', () => {
|
|
27
|
+
const field = {
|
|
28
|
+
name: 'value',
|
|
29
|
+
type: 'decimal',
|
|
30
|
+
nullable: false
|
|
31
|
+
};
|
|
32
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).not.toThrow();
|
|
33
|
+
});
|
|
34
|
+
(0, globals_1.it)('should throw error for invalid precision (too low)', () => {
|
|
35
|
+
const field = {
|
|
36
|
+
name: 'price',
|
|
37
|
+
type: 'decimal',
|
|
38
|
+
precision: 0,
|
|
39
|
+
scale: 2,
|
|
40
|
+
nullable: false
|
|
41
|
+
};
|
|
42
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).toThrow('price: Invalid precision value 0. Must be between 1 and 131072.');
|
|
43
|
+
});
|
|
44
|
+
(0, globals_1.it)('should throw error for invalid precision (too high)', () => {
|
|
45
|
+
const field = {
|
|
46
|
+
name: 'price',
|
|
47
|
+
type: 'decimal',
|
|
48
|
+
precision: 200000,
|
|
49
|
+
scale: 2,
|
|
50
|
+
nullable: false
|
|
51
|
+
};
|
|
52
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).toThrow('price: Invalid precision value 200000. Must be between 1 and 131072.');
|
|
53
|
+
});
|
|
54
|
+
(0, globals_1.it)('should throw error for invalid scale (too low)', () => {
|
|
55
|
+
const field = {
|
|
56
|
+
name: 'price',
|
|
57
|
+
type: 'decimal',
|
|
58
|
+
precision: 10,
|
|
59
|
+
scale: -1,
|
|
60
|
+
nullable: false
|
|
61
|
+
};
|
|
62
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).toThrow('price: Invalid scale value -1. Must be between 0 and 16383.');
|
|
63
|
+
});
|
|
64
|
+
(0, globals_1.it)('should throw error for invalid scale (too high)', () => {
|
|
65
|
+
const field = {
|
|
66
|
+
name: 'price',
|
|
67
|
+
type: 'decimal',
|
|
68
|
+
precision: 10,
|
|
69
|
+
scale: 20000,
|
|
70
|
+
nullable: false
|
|
71
|
+
};
|
|
72
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).toThrow('price: Invalid scale value 20000. Must be between 0 and 16383.');
|
|
73
|
+
});
|
|
74
|
+
(0, globals_1.it)('should throw error when scale exceeds precision', () => {
|
|
75
|
+
const field = {
|
|
76
|
+
name: 'price',
|
|
77
|
+
type: 'decimal',
|
|
78
|
+
precision: 5,
|
|
79
|
+
scale: 10,
|
|
80
|
+
nullable: false
|
|
81
|
+
};
|
|
82
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).toThrow('price: Scale (10) cannot be greater than precision (5).');
|
|
83
|
+
});
|
|
84
|
+
(0, globals_1.it)('should not validate non-decimal fields', () => {
|
|
85
|
+
const field = {
|
|
86
|
+
name: 'name',
|
|
87
|
+
type: 'text',
|
|
88
|
+
nullable: false
|
|
89
|
+
};
|
|
90
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).not.toThrow();
|
|
91
|
+
});
|
|
92
|
+
(0, globals_1.it)('should not validate non-numeric fields', () => {
|
|
93
|
+
const field = {
|
|
94
|
+
name: 'active',
|
|
95
|
+
type: 'boolean',
|
|
96
|
+
nullable: false
|
|
97
|
+
};
|
|
98
|
+
(0, globals_1.expect)(() => (0, field_1.validateDecimalField)(field)).not.toThrow();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const template_test_utils_1 = require("../utils/template-test-utils");
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
5
|
+
(0, globals_1.describe)('Geometry Entity Template Tests', () => {
|
|
6
|
+
// Setup Eta configuration once before all tests
|
|
7
|
+
(0, globals_1.beforeAll)(() => {
|
|
8
|
+
(0, template_test_utils_1.configureEta)();
|
|
9
|
+
});
|
|
10
|
+
const templatePath = './entities/entity-col-geometry';
|
|
11
|
+
const testCases = [
|
|
12
|
+
{
|
|
13
|
+
name: 'should render basic geometry field correctly',
|
|
14
|
+
field: {
|
|
15
|
+
name: 'shape',
|
|
16
|
+
dataType: 'any',
|
|
17
|
+
nullable: false
|
|
18
|
+
},
|
|
19
|
+
assertions: [
|
|
20
|
+
{ type: 'contains', text: '@Column({' },
|
|
21
|
+
{ type: 'contains', text: '"type": "geometry"' },
|
|
22
|
+
{ type: 'contains', text: 'transformer: {' },
|
|
23
|
+
{ type: 'contains', text: 'to: (geometry: any) => {' },
|
|
24
|
+
{ type: 'contains', text: 'from: (pgGeometry: any) => {' },
|
|
25
|
+
{ type: 'contains', text: 'shape: any;' },
|
|
26
|
+
{ type: 'notContains', text: 'nullable: true' }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'should render nullable geometry field correctly',
|
|
31
|
+
field: {
|
|
32
|
+
name: 'optionalShape',
|
|
33
|
+
dataType: 'any',
|
|
34
|
+
nullable: true
|
|
35
|
+
},
|
|
36
|
+
assertions: [
|
|
37
|
+
{ type: 'contains', text: '@Column({' },
|
|
38
|
+
{ type: 'contains', text: '"type": "geometry"' },
|
|
39
|
+
{ type: 'contains', text: 'nullable: true' },
|
|
40
|
+
{ type: 'contains', text: 'optionalShape: any;' }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'should render indexed geometry field correctly',
|
|
45
|
+
field: {
|
|
46
|
+
name: 'spatialData',
|
|
47
|
+
dataType: 'any',
|
|
48
|
+
nullable: false,
|
|
49
|
+
index: true
|
|
50
|
+
},
|
|
51
|
+
assertions: [
|
|
52
|
+
{ type: 'contains', text: '@Index()' },
|
|
53
|
+
{ type: 'contains', text: 'spatialData: any;' }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
(0, template_test_utils_1.runTemplateTests)(templatePath, testCases);
|
|
58
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const template_test_utils_1 = require("../utils/template-test-utils");
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
5
|
+
(0, globals_1.describe)('Polygon Entity Template Tests', () => {
|
|
6
|
+
// Setup Eta configuration once before all tests
|
|
7
|
+
(0, globals_1.beforeAll)(() => {
|
|
8
|
+
(0, template_test_utils_1.configureEta)();
|
|
9
|
+
});
|
|
10
|
+
const templatePath = './entities/entity-col-polygon';
|
|
11
|
+
const testCases = [
|
|
12
|
+
{
|
|
13
|
+
name: 'should render basic polygon field correctly',
|
|
14
|
+
field: {
|
|
15
|
+
name: 'boundary',
|
|
16
|
+
dataType: '{ coordinates: Array<Array<{ x: number, y: number }>> }',
|
|
17
|
+
nullable: false
|
|
18
|
+
},
|
|
19
|
+
assertions: [
|
|
20
|
+
{ type: 'contains', text: '@Column({' },
|
|
21
|
+
{ type: 'contains', text: '"type": "polygon"' },
|
|
22
|
+
{ type: 'contains', text: 'transformer: {' },
|
|
23
|
+
{ type: 'contains', text: 'to: (polygon: { coordinates: Array<Array<{x: number, y: number}>> } | null) => {' },
|
|
24
|
+
{ type: 'contains', text: 'from: (pgPolygon: string | null) => {' },
|
|
25
|
+
{ type: 'contains', text: 'boundary: { coordinates: Array<Array<{ x: number, y: number }>> };' },
|
|
26
|
+
{ type: 'notContains', text: 'nullable: true' }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'should render nullable polygon field correctly',
|
|
31
|
+
field: {
|
|
32
|
+
name: 'optionalBoundary',
|
|
33
|
+
dataType: '{ coordinates: Array<Array<{ x: number, y: number }>> }',
|
|
34
|
+
nullable: true
|
|
35
|
+
},
|
|
36
|
+
assertions: [
|
|
37
|
+
{ type: 'contains', text: '@Column({' },
|
|
38
|
+
{ type: 'contains', text: '"type": "polygon"' },
|
|
39
|
+
{ type: 'contains', text: 'nullable: true' },
|
|
40
|
+
{ type: 'contains', text: 'optionalBoundary: { coordinates: Array<Array<{ x: number, y: number }>> };' }
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'should render indexed polygon field correctly',
|
|
45
|
+
field: {
|
|
46
|
+
name: 'area',
|
|
47
|
+
dataType: '{ coordinates: Array<Array<{ x: number, y: number }>> }',
|
|
48
|
+
nullable: false,
|
|
49
|
+
index: true
|
|
50
|
+
},
|
|
51
|
+
assertions: [
|
|
52
|
+
{ type: 'contains', text: '@Index()' },
|
|
53
|
+
{ type: 'contains', text: 'area: { coordinates: Array<Array<{ x: number, y: number }>> };' }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
(0, template_test_utils_1.runTemplateTests)(templatePath, testCases);
|
|
58
|
+
});
|
package/oclif.manifest.json
CHANGED