@apso/cli 0.7.4 → 0.8.3
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/dist/autogen/index.d.ts +2 -0
- package/dist/autogen/index.js +3 -0
- package/dist/commands/server/new.d.ts +4 -1
- package/dist/commands/server/new.js +115 -22
- package/dist/commands/server/scaffold.d.ts +10 -0
- package/dist/commands/server/scaffold.js +200 -10
- package/dist/lib/api/client.d.ts +65 -0
- package/dist/lib/api/client.js +305 -0
- package/dist/lib/api/index.d.ts +8 -0
- package/dist/lib/api/index.js +22 -0
- package/dist/lib/api/services.d.ts +166 -0
- package/dist/lib/api/services.js +202 -0
- package/dist/lib/api/types.d.ts +212 -0
- package/dist/lib/api/types.js +7 -0
- package/dist/lib/apsorc-parser.d.ts +3 -0
- package/dist/lib/apsorc-parser.js +4 -0
- package/dist/lib/config/index.d.ts +8 -0
- package/dist/lib/config/index.js +17 -0
- package/dist/lib/config/manager.d.ts +127 -0
- package/dist/lib/config/manager.js +304 -0
- package/dist/lib/config/paths.d.ts +65 -0
- package/dist/lib/config/paths.js +127 -0
- package/dist/lib/config/types.d.ts +230 -0
- package/dist/lib/config/types.js +30 -0
- package/dist/lib/generators/base.d.ts +93 -0
- package/dist/lib/generators/base.js +90 -0
- package/dist/lib/generators/go.d.ts +37 -0
- package/dist/lib/generators/go.js +340 -0
- package/dist/lib/generators/index.d.ts +21 -0
- package/dist/lib/generators/index.js +51 -0
- package/dist/lib/generators/python.d.ts +21 -0
- package/dist/lib/generators/python.js +253 -0
- package/dist/lib/generators/typescript.d.ts +25 -0
- package/dist/lib/generators/typescript.js +373 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.js +9 -1
- package/dist/lib/templates/entities/entity-col-timestamp.eta +9 -2
- package/dist/lib/templates/entities/entity-col-timestamptz.eta +9 -2
- package/dist/lib/templates/entities/entity.eta +16 -3
- package/dist/lib/templates/go/dto/dto-col-array.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-boolean.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-date.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-decimal.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-enum.eta +8 -0
- package/dist/lib/templates/go/dto/dto-col-float.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-integer.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-json.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-jsonb.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-numeric.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-string.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-text.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-timestamp.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-timestamptz.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-uuid.eta +7 -0
- package/dist/lib/templates/go/dto/dto-col-varchar.eta +7 -0
- package/dist/lib/templates/go/dto/dto.eta +78 -0
- package/dist/lib/templates/go/enums.eta +44 -0
- package/dist/lib/templates/go/handlers/handler.eta +212 -0
- package/dist/lib/templates/go/header.eta +3 -0
- package/dist/lib/templates/go/index-module.eta +53 -0
- package/dist/lib/templates/go/middleware/auth.eta +101 -0
- package/dist/lib/templates/go/models/model-col-array.eta +1 -0
- package/dist/lib/templates/go/models/model-col-boolean.eta +1 -0
- package/dist/lib/templates/go/models/model-col-date.eta +1 -0
- package/dist/lib/templates/go/models/model-col-decimal.eta +1 -0
- package/dist/lib/templates/go/models/model-col-enum.eta +2 -0
- package/dist/lib/templates/go/models/model-col-float.eta +1 -0
- package/dist/lib/templates/go/models/model-col-integer.eta +1 -0
- package/dist/lib/templates/go/models/model-col-json.eta +1 -0
- package/dist/lib/templates/go/models/model-col-jsonb.eta +1 -0
- package/dist/lib/templates/go/models/model-col-numeric.eta +1 -0
- package/dist/lib/templates/go/models/model-col-string.eta +1 -0
- package/dist/lib/templates/go/models/model-col-text.eta +1 -0
- package/dist/lib/templates/go/models/model-col-timestamp.eta +1 -0
- package/dist/lib/templates/go/models/model-col-timestamptz.eta +1 -0
- package/dist/lib/templates/go/models/model-col-uuid.eta +1 -0
- package/dist/lib/templates/go/models/model-col-varchar.eta +1 -0
- package/dist/lib/templates/go/models/model.eta +53 -0
- package/dist/lib/templates/go/services/service.eta +190 -0
- package/dist/lib/templates/python/enums.eta +10 -0
- package/dist/lib/templates/python/header.eta +6 -0
- package/dist/lib/templates/python/index-module.eta +18 -0
- package/dist/lib/templates/python/models/model-col-array.eta +4 -0
- package/dist/lib/templates/python/models/model-col-boolean.eta +5 -0
- package/dist/lib/templates/python/models/model-col-date.eta +4 -0
- package/dist/lib/templates/python/models/model-col-decimal.eta +4 -0
- package/dist/lib/templates/python/models/model-col-enum.eta +16 -0
- package/dist/lib/templates/python/models/model-col-float.eta +5 -0
- package/dist/lib/templates/python/models/model-col-integer.eta +6 -0
- package/dist/lib/templates/python/models/model-col-json.eta +4 -0
- package/dist/lib/templates/python/models/model-col-jsonb.eta +4 -0
- package/dist/lib/templates/python/models/model-col-numeric.eta +4 -0
- package/dist/lib/templates/python/models/model-col-string.eta +6 -0
- package/dist/lib/templates/python/models/model-col-text.eta +6 -0
- package/dist/lib/templates/python/models/model-col-timestamp.eta +11 -0
- package/dist/lib/templates/python/models/model-col-timestamptz.eta +11 -0
- package/dist/lib/templates/python/models/model-col-uuid.eta +5 -0
- package/dist/lib/templates/python/models/model-col-varchar.eta +6 -0
- package/dist/lib/templates/python/models/model.eta +124 -0
- package/dist/lib/templates/python/routers/router.eta +206 -0
- package/dist/lib/templates/python/schemas/schema-col-array.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-boolean.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-date.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-decimal.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-enum.eta +6 -0
- package/dist/lib/templates/python/schemas/schema-col-float.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-integer.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-json.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-jsonb.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-numeric.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-string.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-text.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-timestamp.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-timestamptz.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-uuid.eta +1 -0
- package/dist/lib/templates/python/schemas/schema-col-varchar.eta +1 -0
- package/dist/lib/templates/python/schemas/schema.eta +87 -0
- package/dist/lib/templates/python/services/service.eta +163 -0
- package/dist/lib/templates/rest/controller-rest.eta +13 -12
- package/dist/lib/templates/rest/dto-rest.eta +173 -59
- package/dist/lib/types/generator.d.ts +241 -0
- package/dist/lib/types/generator.js +2 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/utils/casing.d.ts +1 -0
- package/dist/lib/utils/casing.js +11 -1
- package/oclif.manifest.json +32 -3
- package/package.json +4 -2
- package/dist/lib/utils/relationships/parse.spec.d.ts +0 -1
- package/dist/lib/utils/relationships/parse.spec.js +0 -402
- package/dist/tests/templates/entities/types/array-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/array-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/bigint-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/bigint-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/boolean-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/boolean-template.spec.js +0 -77
- package/dist/tests/templates/entities/types/bytea-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/bytea-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/char-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/char-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/date-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/date-template.spec.js +0 -56
- package/dist/tests/templates/entities/types/decimal-field-validation.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/decimal-field-validation.spec.js +0 -100
- package/dist/tests/templates/entities/types/decimal-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/decimal-template.spec.js +0 -86
- package/dist/tests/templates/entities/types/double-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/double-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/enum-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/enum-template.spec.js +0 -85
- package/dist/tests/templates/entities/types/float-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/float-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/geometry-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/geometry-template.spec.js +0 -58
- package/dist/tests/templates/entities/types/inet-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/inet-template.spec.js +0 -69
- package/dist/tests/templates/entities/types/int4range-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/int4range-template.spec.js +0 -72
- package/dist/tests/templates/entities/types/integer-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/integer-template.spec.js +0 -79
- package/dist/tests/templates/entities/types/interval-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/interval-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/json-plain-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/json-plain-template.spec.js +0 -54
- package/dist/tests/templates/entities/types/json-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/json-template.spec.js +0 -40
- package/dist/tests/templates/entities/types/jsonb-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/jsonb-template.spec.js +0 -40
- package/dist/tests/templates/entities/types/money-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/money-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/numeric-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/numeric-template.spec.js +0 -84
- package/dist/tests/templates/entities/types/point-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/point-template.spec.js +0 -64
- package/dist/tests/templates/entities/types/polygon-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/polygon-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/real-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/real-template.spec.js +0 -67
- package/dist/tests/templates/entities/types/serial-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/serial-template.spec.js +0 -113
- package/dist/tests/templates/entities/types/smallint-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/smallint-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/string-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/string-template.spec.js +0 -111
- package/dist/tests/templates/entities/types/text-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/text-template.spec.js +0 -70
- package/dist/tests/templates/entities/types/time-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/time-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/timestamp-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/timestamp-template.spec.js +0 -74
- package/dist/tests/templates/entities/types/timetz-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/timetz-template.spec.js +0 -68
- package/dist/tests/templates/entities/types/tsvector-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/tsvector-template.spec.js +0 -55
- package/dist/tests/templates/entities/types/uuid-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/uuid-template.spec.js +0 -82
- package/dist/tests/templates/entities/types/varchar-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/varchar-template.spec.js +0 -105
- package/dist/tests/templates/entities/types/xml-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/types/xml-template.spec.js +0 -55
- package/dist/tests/templates/entities/uuid-entity-template.spec.d.ts +0 -1
- package/dist/tests/templates/entities/uuid-entity-template.spec.js +0 -277
- package/dist/tests/utils/relationship-deduplication.spec.d.ts +0 -1
- package/dist/tests/utils/relationship-deduplication.spec.js +0 -98
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const globals_1 = require("@jest/globals");
|
|
4
|
-
const parse_1 = require("./parse");
|
|
5
|
-
(0, globals_1.describe)("parseRelationships", () => {
|
|
6
|
-
// Mock console.warn to prevent test output clutter
|
|
7
|
-
(0, globals_1.beforeEach)(() => {
|
|
8
|
-
globals_1.jest.spyOn(console, "warn").mockImplementation(() => {
|
|
9
|
-
/* No output */
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
(0, globals_1.afterEach)(() => {
|
|
13
|
-
globals_1.jest.restoreAllMocks();
|
|
14
|
-
});
|
|
15
|
-
(0, globals_1.describe)("ManyToMany Relationships", () => {
|
|
16
|
-
(0, globals_1.it)("should parse a single bidirectional ManyToMany definition", () => {
|
|
17
|
-
const relationships = [
|
|
18
|
-
{
|
|
19
|
-
from: "EntityA",
|
|
20
|
-
to: "EntityB",
|
|
21
|
-
type: "ManyToMany",
|
|
22
|
-
// eslint-disable-next-line camelcase
|
|
23
|
-
bi_directional: true,
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
const expected = {
|
|
27
|
-
EntityA: [
|
|
28
|
-
{
|
|
29
|
-
name: "EntityB",
|
|
30
|
-
type: "ManyToMany",
|
|
31
|
-
referenceName: "EntityB",
|
|
32
|
-
join: true,
|
|
33
|
-
biDirectional: true,
|
|
34
|
-
joinTableName: undefined,
|
|
35
|
-
joinColumnName: undefined,
|
|
36
|
-
inverseJoinColumnName: undefined,
|
|
37
|
-
inverseReferenceName: "EntityA", // PascalCase entity name
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
EntityB: [
|
|
41
|
-
{
|
|
42
|
-
name: "EntityA",
|
|
43
|
-
type: "ManyToMany",
|
|
44
|
-
referenceName: "EntityA",
|
|
45
|
-
join: false,
|
|
46
|
-
biDirectional: true,
|
|
47
|
-
joinTableName: undefined,
|
|
48
|
-
joinColumnName: undefined,
|
|
49
|
-
inverseJoinColumnName: undefined,
|
|
50
|
-
inverseReferenceName: "EntityB", // PascalCase entity name
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
const result = (0, parse_1.parseRelationships)(relationships);
|
|
55
|
-
(0, globals_1.expect)(result).toEqual(expected);
|
|
56
|
-
});
|
|
57
|
-
(0, globals_1.it)("should parse a single bidirectional ManyToMany with to_name", () => {
|
|
58
|
-
const relationships = [
|
|
59
|
-
{
|
|
60
|
-
from: "User",
|
|
61
|
-
to: "Group",
|
|
62
|
-
type: "ManyToMany",
|
|
63
|
-
// eslint-disable-next-line camelcase
|
|
64
|
-
bi_directional: true,
|
|
65
|
-
// eslint-disable-next-line camelcase
|
|
66
|
-
to_name: "userGroups",
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
const expected = {
|
|
70
|
-
User: [
|
|
71
|
-
{
|
|
72
|
-
name: "Group",
|
|
73
|
-
type: "ManyToMany",
|
|
74
|
-
referenceName: "userGroups",
|
|
75
|
-
join: true,
|
|
76
|
-
biDirectional: true,
|
|
77
|
-
joinTableName: undefined,
|
|
78
|
-
joinColumnName: undefined,
|
|
79
|
-
inverseJoinColumnName: undefined,
|
|
80
|
-
inverseReferenceName: "User", // PascalCase entity name
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
Group: [
|
|
84
|
-
{
|
|
85
|
-
name: "User",
|
|
86
|
-
type: "ManyToMany",
|
|
87
|
-
referenceName: "User",
|
|
88
|
-
join: false,
|
|
89
|
-
biDirectional: true,
|
|
90
|
-
joinTableName: undefined,
|
|
91
|
-
joinColumnName: undefined,
|
|
92
|
-
inverseJoinColumnName: undefined,
|
|
93
|
-
inverseReferenceName: "userGroups", // Preserved camelCase from to_name
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
};
|
|
97
|
-
const result = (0, parse_1.parseRelationships)(relationships);
|
|
98
|
-
(0, globals_1.expect)(result).toEqual(expected);
|
|
99
|
-
});
|
|
100
|
-
(0, globals_1.it)("should parse a unidirectional ManyToMany definition", () => {
|
|
101
|
-
const relationships = [
|
|
102
|
-
{
|
|
103
|
-
from: "Post",
|
|
104
|
-
to: "Tag",
|
|
105
|
-
type: "ManyToMany",
|
|
106
|
-
// bi_directional is false or omitted
|
|
107
|
-
},
|
|
108
|
-
];
|
|
109
|
-
const expected = {
|
|
110
|
-
Post: [
|
|
111
|
-
{
|
|
112
|
-
name: "Tag",
|
|
113
|
-
type: "ManyToMany",
|
|
114
|
-
referenceName: "Tag",
|
|
115
|
-
join: true,
|
|
116
|
-
biDirectional: false,
|
|
117
|
-
joinTableName: undefined,
|
|
118
|
-
joinColumnName: undefined,
|
|
119
|
-
inverseJoinColumnName: undefined,
|
|
120
|
-
inverseReferenceName: undefined, // Correct: No inverse name for unidirectional
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
// No entry expected for Tag
|
|
124
|
-
};
|
|
125
|
-
const result = (0, parse_1.parseRelationships)(relationships);
|
|
126
|
-
(0, globals_1.expect)(result).toEqual(expected);
|
|
127
|
-
});
|
|
128
|
-
(0, globals_1.it)("should handle join table details correctly", () => {
|
|
129
|
-
const relationships = [
|
|
130
|
-
{
|
|
131
|
-
from: "Student",
|
|
132
|
-
to: "Course",
|
|
133
|
-
type: "ManyToMany",
|
|
134
|
-
// eslint-disable-next-line camelcase
|
|
135
|
-
bi_directional: true,
|
|
136
|
-
// UNUSED: eslint-disable-next-line camelcase
|
|
137
|
-
joinTableName: "enrollments",
|
|
138
|
-
// UNUSED: eslint-disable-next-line camelcase
|
|
139
|
-
joinColumnName: "student_id",
|
|
140
|
-
// UNUSED: eslint-disable-next-line camelcase
|
|
141
|
-
inverseJoinColumnName: "course_id",
|
|
142
|
-
},
|
|
143
|
-
];
|
|
144
|
-
const expected = {
|
|
145
|
-
Student: [
|
|
146
|
-
{
|
|
147
|
-
name: "Course",
|
|
148
|
-
type: "ManyToMany",
|
|
149
|
-
referenceName: "Course",
|
|
150
|
-
join: true,
|
|
151
|
-
biDirectional: true,
|
|
152
|
-
joinTableName: "enrollments",
|
|
153
|
-
joinColumnName: "student_id",
|
|
154
|
-
inverseJoinColumnName: "course_id",
|
|
155
|
-
inverseReferenceName: "Student", // PascalCase entity name
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
Course: [
|
|
159
|
-
{
|
|
160
|
-
name: "Student",
|
|
161
|
-
type: "ManyToMany",
|
|
162
|
-
referenceName: "Student",
|
|
163
|
-
join: false,
|
|
164
|
-
biDirectional: true,
|
|
165
|
-
joinTableName: undefined,
|
|
166
|
-
joinColumnName: undefined,
|
|
167
|
-
inverseJoinColumnName: undefined,
|
|
168
|
-
inverseReferenceName: "Course", // PascalCase entity name
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
};
|
|
172
|
-
const result = (0, parse_1.parseRelationships)(relationships);
|
|
173
|
-
(0, globals_1.expect)(result).toEqual(expected);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
(0, globals_1.describe)("Mixed Relationship Types", () => {
|
|
177
|
-
(0, globals_1.it)("should correctly parse ManyToMany alongside other types", () => {
|
|
178
|
-
const relationships = [
|
|
179
|
-
{
|
|
180
|
-
from: "User",
|
|
181
|
-
to: "Profile",
|
|
182
|
-
type: "OneToOne",
|
|
183
|
-
// eslint-disable-next-line camelcase
|
|
184
|
-
bi_directional: true,
|
|
185
|
-
// eslint-disable-next-line camelcase
|
|
186
|
-
to_name: "userProfile",
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
from: "User",
|
|
190
|
-
to: "Post",
|
|
191
|
-
type: "OneToMany",
|
|
192
|
-
// eslint-disable-next-line camelcase
|
|
193
|
-
bi_directional: true, // Implies ManyToOne on Post
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
from: "Role",
|
|
197
|
-
to: "User",
|
|
198
|
-
type: "ManyToMany",
|
|
199
|
-
// eslint-disable-next-line camelcase
|
|
200
|
-
bi_directional: true,
|
|
201
|
-
},
|
|
202
|
-
];
|
|
203
|
-
const result = (0, parse_1.parseRelationships)(relationships);
|
|
204
|
-
// Check User relationships
|
|
205
|
-
(0, globals_1.expect)(result.User).toHaveLength(3);
|
|
206
|
-
(0, globals_1.expect)(result.User).toContainEqual(globals_1.expect.objectContaining({
|
|
207
|
-
name: "Profile",
|
|
208
|
-
type: "OneToOne",
|
|
209
|
-
referenceName: "userProfile",
|
|
210
|
-
biDirectional: true,
|
|
211
|
-
join: false,
|
|
212
|
-
})); // Expect preserved camelCase
|
|
213
|
-
(0, globals_1.expect)(result.User).toContainEqual(globals_1.expect.objectContaining({
|
|
214
|
-
name: "Post",
|
|
215
|
-
type: "OneToMany",
|
|
216
|
-
referenceName: "Post",
|
|
217
|
-
biDirectional: true,
|
|
218
|
-
})); // PascalCase entity name
|
|
219
|
-
(0, globals_1.expect)(result.User).toContainEqual(globals_1.expect.objectContaining({
|
|
220
|
-
name: "Role",
|
|
221
|
-
type: "ManyToMany",
|
|
222
|
-
referenceName: "Role",
|
|
223
|
-
biDirectional: true,
|
|
224
|
-
join: false,
|
|
225
|
-
})); // PascalCase entity name
|
|
226
|
-
// Check Profile relationship
|
|
227
|
-
(0, globals_1.expect)(result.Profile).toHaveLength(1);
|
|
228
|
-
(0, globals_1.expect)(result.Profile).toContainEqual(globals_1.expect.objectContaining({
|
|
229
|
-
name: "User",
|
|
230
|
-
type: "OneToOne",
|
|
231
|
-
referenceName: "User",
|
|
232
|
-
biDirectional: true,
|
|
233
|
-
join: true,
|
|
234
|
-
}));
|
|
235
|
-
// Check Post relationship
|
|
236
|
-
(0, globals_1.expect)(result.Post).toHaveLength(1);
|
|
237
|
-
(0, globals_1.expect)(result.Post).toContainEqual(globals_1.expect.objectContaining({
|
|
238
|
-
name: "User",
|
|
239
|
-
type: "ManyToOne",
|
|
240
|
-
referenceName: "User",
|
|
241
|
-
biDirectional: true,
|
|
242
|
-
}));
|
|
243
|
-
// Check Role relationship
|
|
244
|
-
(0, globals_1.expect)(result.Role).toHaveLength(1);
|
|
245
|
-
(0, globals_1.expect)(result.Role).toContainEqual(globals_1.expect.objectContaining({
|
|
246
|
-
name: "User",
|
|
247
|
-
type: "ManyToMany",
|
|
248
|
-
referenceName: "User",
|
|
249
|
-
biDirectional: true,
|
|
250
|
-
join: true,
|
|
251
|
-
})); // PascalCase entity name
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
(0, globals_1.describe)("getRelationshipForTemplate", () => {
|
|
256
|
-
// Mock console.warn to prevent test output clutter
|
|
257
|
-
(0, globals_1.beforeEach)(() => {
|
|
258
|
-
globals_1.jest.spyOn(console, "warn").mockImplementation(() => {
|
|
259
|
-
/* No output */
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
(0, globals_1.afterEach)(() => {
|
|
263
|
-
globals_1.jest.restoreAllMocks();
|
|
264
|
-
});
|
|
265
|
-
(0, globals_1.describe)("UUID Primary Key Support", () => {
|
|
266
|
-
(0, globals_1.it)("should populate referencedEntityPrimaryKeyType as uuid when referenced entity has uuid primary key", () => {
|
|
267
|
-
const entities = [
|
|
268
|
-
{ name: "User", primaryKeyType: "uuid" },
|
|
269
|
-
{ name: "Account", primaryKeyType: "serial" },
|
|
270
|
-
];
|
|
271
|
-
const relationships = [
|
|
272
|
-
{
|
|
273
|
-
name: "User",
|
|
274
|
-
type: "ManyToOne",
|
|
275
|
-
referenceName: null,
|
|
276
|
-
nullable: false,
|
|
277
|
-
index: false,
|
|
278
|
-
},
|
|
279
|
-
];
|
|
280
|
-
const result = (0, parse_1.getRelationshipForTemplate)("Account", relationships, entities);
|
|
281
|
-
(0, globals_1.expect)(result).toHaveLength(1);
|
|
282
|
-
(0, globals_1.expect)(result[0]).toMatchObject({
|
|
283
|
-
name: "User",
|
|
284
|
-
type: "ManyToOne",
|
|
285
|
-
referencedEntityPrimaryKeyType: "uuid",
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
(0, globals_1.it)("should populate referencedEntityPrimaryKeyType as serial when referenced entity has serial primary key", () => {
|
|
289
|
-
const entities = [
|
|
290
|
-
{ name: "User", primaryKeyType: "serial" },
|
|
291
|
-
{ name: "Post", primaryKeyType: "serial" },
|
|
292
|
-
];
|
|
293
|
-
const relationships = [
|
|
294
|
-
{
|
|
295
|
-
name: "User",
|
|
296
|
-
type: "ManyToOne",
|
|
297
|
-
referenceName: null,
|
|
298
|
-
nullable: false,
|
|
299
|
-
index: false,
|
|
300
|
-
},
|
|
301
|
-
];
|
|
302
|
-
const result = (0, parse_1.getRelationshipForTemplate)("Post", relationships, entities);
|
|
303
|
-
(0, globals_1.expect)(result).toHaveLength(1);
|
|
304
|
-
(0, globals_1.expect)(result[0]).toMatchObject({
|
|
305
|
-
name: "User",
|
|
306
|
-
type: "ManyToOne",
|
|
307
|
-
referencedEntityPrimaryKeyType: "serial",
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
(0, globals_1.it)("should default referencedEntityPrimaryKeyType to serial when entity does not specify primaryKeyType", () => {
|
|
311
|
-
const entities = [
|
|
312
|
-
{ name: "User" },
|
|
313
|
-
{ name: "Post", primaryKeyType: "serial" },
|
|
314
|
-
];
|
|
315
|
-
const relationships = [
|
|
316
|
-
{
|
|
317
|
-
name: "User",
|
|
318
|
-
type: "ManyToOne",
|
|
319
|
-
referenceName: null,
|
|
320
|
-
nullable: false,
|
|
321
|
-
index: false,
|
|
322
|
-
},
|
|
323
|
-
];
|
|
324
|
-
const result = (0, parse_1.getRelationshipForTemplate)("Post", relationships, entities);
|
|
325
|
-
(0, globals_1.expect)(result).toHaveLength(1);
|
|
326
|
-
(0, globals_1.expect)(result[0]).toMatchObject({
|
|
327
|
-
name: "User",
|
|
328
|
-
type: "ManyToOne",
|
|
329
|
-
referencedEntityPrimaryKeyType: "serial",
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
(0, globals_1.it)("should default referencedEntityPrimaryKeyType to serial when entities array is not provided", () => {
|
|
333
|
-
const relationships = [
|
|
334
|
-
{
|
|
335
|
-
name: "User",
|
|
336
|
-
type: "ManyToOne",
|
|
337
|
-
referenceName: null,
|
|
338
|
-
nullable: false,
|
|
339
|
-
index: false,
|
|
340
|
-
},
|
|
341
|
-
];
|
|
342
|
-
const result = (0, parse_1.getRelationshipForTemplate)("Post", relationships);
|
|
343
|
-
(0, globals_1.expect)(result).toHaveLength(1);
|
|
344
|
-
(0, globals_1.expect)(result[0]).toMatchObject({
|
|
345
|
-
name: "User",
|
|
346
|
-
type: "ManyToOne",
|
|
347
|
-
referencedEntityPrimaryKeyType: "serial",
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
(0, globals_1.it)("should handle multiple relationships with mixed primary key types", () => {
|
|
351
|
-
const entities = [
|
|
352
|
-
{ name: "User", primaryKeyType: "uuid" },
|
|
353
|
-
{ name: "Organization", primaryKeyType: "serial" },
|
|
354
|
-
{ name: "Team", primaryKeyType: "uuid" },
|
|
355
|
-
{ name: "Post", primaryKeyType: "serial" },
|
|
356
|
-
];
|
|
357
|
-
const relationships = [
|
|
358
|
-
{
|
|
359
|
-
name: "User",
|
|
360
|
-
type: "ManyToOne",
|
|
361
|
-
referenceName: null,
|
|
362
|
-
nullable: false,
|
|
363
|
-
index: true,
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
name: "Organization",
|
|
367
|
-
type: "ManyToOne",
|
|
368
|
-
referenceName: null,
|
|
369
|
-
nullable: false,
|
|
370
|
-
index: false,
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
name: "Team",
|
|
374
|
-
type: "ManyToOne",
|
|
375
|
-
referenceName: null,
|
|
376
|
-
nullable: true,
|
|
377
|
-
index: false,
|
|
378
|
-
},
|
|
379
|
-
];
|
|
380
|
-
const result = (0, parse_1.getRelationshipForTemplate)("Post", relationships, entities);
|
|
381
|
-
(0, globals_1.expect)(result).toHaveLength(3);
|
|
382
|
-
const userRel = result.find((r) => r.name === "User");
|
|
383
|
-
(0, globals_1.expect)(userRel).toMatchObject({
|
|
384
|
-
name: "User",
|
|
385
|
-
type: "ManyToOne",
|
|
386
|
-
referencedEntityPrimaryKeyType: "uuid",
|
|
387
|
-
});
|
|
388
|
-
const orgRel = result.find((r) => r.name === "Organization");
|
|
389
|
-
(0, globals_1.expect)(orgRel).toMatchObject({
|
|
390
|
-
name: "Organization",
|
|
391
|
-
type: "ManyToOne",
|
|
392
|
-
referencedEntityPrimaryKeyType: "serial",
|
|
393
|
-
});
|
|
394
|
-
const teamRel = result.find((r) => r.name === "Team");
|
|
395
|
-
(0, globals_1.expect)(teamRel).toMatchObject({
|
|
396
|
-
name: "Team",
|
|
397
|
-
type: "ManyToOne",
|
|
398
|
-
referencedEntityPrimaryKeyType: "uuid",
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
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)("Array 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-array";
|
|
11
|
-
const testCases = [
|
|
12
|
-
{
|
|
13
|
-
name: "should render basic text array field correctly",
|
|
14
|
-
field: {
|
|
15
|
-
name: "tags",
|
|
16
|
-
dataType: "string[]",
|
|
17
|
-
nullable: false,
|
|
18
|
-
},
|
|
19
|
-
assertions: [
|
|
20
|
-
{ type: "contains", text: "@Column({" },
|
|
21
|
-
{ type: "contains", text: 'type: "text"' },
|
|
22
|
-
{ type: "contains", text: "array: true" },
|
|
23
|
-
{ type: "contains", text: "tags: string[];" },
|
|
24
|
-
{ type: "notContains", text: "nullable: true" },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "should render nullable array field correctly",
|
|
29
|
-
field: {
|
|
30
|
-
name: "optionalTags",
|
|
31
|
-
dataType: "string[]",
|
|
32
|
-
nullable: true,
|
|
33
|
-
},
|
|
34
|
-
assertions: [
|
|
35
|
-
{ type: "contains", text: "nullable: true" },
|
|
36
|
-
{ type: "contains", text: "optionalTags: string[];" },
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "should render indexed array field correctly",
|
|
41
|
-
field: {
|
|
42
|
-
name: "categories",
|
|
43
|
-
dataType: "string[]",
|
|
44
|
-
nullable: false,
|
|
45
|
-
index: true,
|
|
46
|
-
},
|
|
47
|
-
assertions: [
|
|
48
|
-
{ type: "contains", text: "@Index()" },
|
|
49
|
-
{ type: "contains", text: "categories: string[];" },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: "should render integer array field correctly",
|
|
54
|
-
field: {
|
|
55
|
-
name: "scores",
|
|
56
|
-
dataType: "number[]",
|
|
57
|
-
elementType: "int",
|
|
58
|
-
nullable: false,
|
|
59
|
-
},
|
|
60
|
-
assertions: [
|
|
61
|
-
{ type: "contains", text: 'type: "int"' },
|
|
62
|
-
{ type: "contains", text: "array: true" },
|
|
63
|
-
{ type: "contains", text: "scores: number[];" },
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "should render decimal array field correctly",
|
|
68
|
-
field: {
|
|
69
|
-
name: "amounts",
|
|
70
|
-
dataType: "number[]",
|
|
71
|
-
elementType: "decimal",
|
|
72
|
-
nullable: false,
|
|
73
|
-
},
|
|
74
|
-
assertions: [
|
|
75
|
-
{ type: "contains", text: 'type: "decimal"' },
|
|
76
|
-
{ type: "contains", text: "array: true" },
|
|
77
|
-
{ type: "contains", text: "amounts: number[];" },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
];
|
|
81
|
-
(0, template_test_utils_1.runTemplateTests)(templatePath, testCases);
|
|
82
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
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)("BigInt 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-bigint";
|
|
11
|
-
const testCases = [
|
|
12
|
-
{
|
|
13
|
-
name: "should render basic bigint field correctly",
|
|
14
|
-
field: {
|
|
15
|
-
name: "largeCounter",
|
|
16
|
-
dataType: "number",
|
|
17
|
-
nullable: false,
|
|
18
|
-
},
|
|
19
|
-
assertions: [
|
|
20
|
-
{ type: "contains", text: '@Column({ "type": "bigint"' },
|
|
21
|
-
{ type: "contains", text: "largeCounter: string;" },
|
|
22
|
-
{ type: "notContains", text: "@Index()" },
|
|
23
|
-
{ type: "notContains", text: "@PrimaryColumn()" },
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: "should render nullable bigint field correctly",
|
|
28
|
-
field: {
|
|
29
|
-
name: "optionalCounter",
|
|
30
|
-
dataType: "number",
|
|
31
|
-
nullable: true,
|
|
32
|
-
},
|
|
33
|
-
assertions: [
|
|
34
|
-
{ type: "contains", text: '@Column({ "type": "bigint"' },
|
|
35
|
-
{ type: "contains", text: "optionalCounter: string;" },
|
|
36
|
-
],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: "should render bigint field with default value correctly",
|
|
40
|
-
field: {
|
|
41
|
-
name: "defaultCounter",
|
|
42
|
-
dataType: "number",
|
|
43
|
-
nullable: false,
|
|
44
|
-
default: 0,
|
|
45
|
-
},
|
|
46
|
-
assertions: [
|
|
47
|
-
{ type: "contains", text: '@Column({ "type": "bigint"' },
|
|
48
|
-
{ type: "contains", text: "default: 0" },
|
|
49
|
-
{ type: "contains", text: "defaultCounter: string;" },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
name: "should render indexed bigint field correctly",
|
|
54
|
-
field: {
|
|
55
|
-
name: "indexedCounter",
|
|
56
|
-
dataType: "number",
|
|
57
|
-
nullable: false,
|
|
58
|
-
index: true,
|
|
59
|
-
},
|
|
60
|
-
assertions: [
|
|
61
|
-
{ type: "contains", text: '@Column({ "type": "bigint"' },
|
|
62
|
-
{ type: "contains", text: "@Index()" },
|
|
63
|
-
{ type: "contains", text: "indexedCounter: string;" },
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
name: "should render primary key bigint field correctly",
|
|
68
|
-
field: {
|
|
69
|
-
name: "id",
|
|
70
|
-
dataType: "number",
|
|
71
|
-
nullable: false,
|
|
72
|
-
primary: true,
|
|
73
|
-
},
|
|
74
|
-
assertions: [
|
|
75
|
-
{ type: "contains", text: '@Column({ "type": "bigint"' },
|
|
76
|
-
{ type: "contains", text: "@PrimaryColumn()" },
|
|
77
|
-
{ type: "contains", text: "id: string;" },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
];
|
|
81
|
-
(0, template_test_utils_1.runTemplateTests)(templatePath, testCases);
|
|
82
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
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)("Boolean 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-boolean";
|
|
11
|
-
const testCases = [
|
|
12
|
-
{
|
|
13
|
-
name: "should render basic boolean field correctly",
|
|
14
|
-
field: {
|
|
15
|
-
name: "isActive",
|
|
16
|
-
dataType: "boolean",
|
|
17
|
-
nullable: false,
|
|
18
|
-
},
|
|
19
|
-
assertions: [
|
|
20
|
-
{ type: "contains", text: "@IsOptional({ groups: [CREATE, UPDATE] })" },
|
|
21
|
-
{ type: "contains", text: "@IsBoolean({ always: true })" },
|
|
22
|
-
{ type: "contains", text: "@Column({ type: 'boolean'" },
|
|
23
|
-
{ type: "contains", text: "default: false" },
|
|
24
|
-
{ type: "contains", text: "isActive!: boolean;" },
|
|
25
|
-
{ type: "notContains", text: "@Index()" },
|
|
26
|
-
{ type: "notContains", text: "@PrimaryColumn()" },
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "should render nullable boolean field correctly",
|
|
31
|
-
field: {
|
|
32
|
-
name: "optionalFlag",
|
|
33
|
-
dataType: "boolean",
|
|
34
|
-
nullable: true,
|
|
35
|
-
},
|
|
36
|
-
assertions: [
|
|
37
|
-
{ type: "contains", text: "@IsOptional({ groups: [CREATE, UPDATE] })" },
|
|
38
|
-
{ type: "contains", text: "@IsBoolean({ always: true })" },
|
|
39
|
-
{ type: "contains", text: "@Column({ type: 'boolean'" },
|
|
40
|
-
{ type: "contains", text: "optionalFlag!: boolean;" },
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "should render boolean field with default value correctly",
|
|
45
|
-
field: {
|
|
46
|
-
name: "defaultFlag",
|
|
47
|
-
dataType: "boolean",
|
|
48
|
-
nullable: false,
|
|
49
|
-
default: "true",
|
|
50
|
-
},
|
|
51
|
-
assertions: [
|
|
52
|
-
{ type: "contains", text: "@IsOptional({ groups: [CREATE, UPDATE] })" },
|
|
53
|
-
{ type: "contains", text: "@IsBoolean({ always: true })" },
|
|
54
|
-
{ type: "contains", text: "@Column({ type: 'boolean'" },
|
|
55
|
-
{ type: "contains", text: "default: true" },
|
|
56
|
-
{ type: "contains", text: "defaultFlag!: boolean;" },
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: "should render indexed boolean field correctly",
|
|
61
|
-
field: {
|
|
62
|
-
name: "indexedFlag",
|
|
63
|
-
dataType: "boolean",
|
|
64
|
-
nullable: false,
|
|
65
|
-
index: true,
|
|
66
|
-
},
|
|
67
|
-
assertions: [
|
|
68
|
-
{ type: "contains", text: "@IsOptional({ groups: [CREATE, UPDATE] })" },
|
|
69
|
-
{ type: "contains", text: "@IsBoolean({ always: true })" },
|
|
70
|
-
{ type: "contains", text: "@Column({ type: 'boolean'" },
|
|
71
|
-
{ type: "contains", text: "@Index()" },
|
|
72
|
-
{ type: "contains", text: "indexedFlag!: boolean;" },
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
(0, template_test_utils_1.runTemplateTests)(templatePath, testCases);
|
|
77
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|