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