@go-mondo/identity-sdk 0.0.2-beta.74 → 0.0.2-beta.76

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 (56) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/.tsbuildinfo/cjs.json +1 -1
  3. package/.tsbuildinfo/esm.json +1 -1
  4. package/CHANGELOG.md +14 -0
  5. package/dist/cjs/app/authorization/schema.d.ts +14 -23
  6. package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
  7. package/dist/cjs/app/authorization/schema.js +5 -3
  8. package/dist/cjs/app/authorization/schema.test.js +26 -0
  9. package/dist/cjs/common/schema/jwt.d.ts +0 -6
  10. package/dist/cjs/common/schema/jwt.d.ts.map +1 -1
  11. package/dist/cjs/common/schema/jwt.js +0 -3
  12. package/dist/cjs/common/schema/jwt.test.js +0 -8
  13. package/dist/cjs/workspace/authorization/schema.d.ts +0 -9
  14. package/dist/cjs/workspace/authorization/schema.d.ts.map +1 -1
  15. package/dist/esm/app/authorization/schema.d.ts +14 -23
  16. package/dist/esm/app/authorization/schema.d.ts.map +1 -1
  17. package/dist/esm/app/authorization/schema.js +5 -3
  18. package/dist/esm/app/authorization/schema.test.js +26 -0
  19. package/dist/esm/common/schema/jwt.d.ts +0 -6
  20. package/dist/esm/common/schema/jwt.d.ts.map +1 -1
  21. package/dist/esm/common/schema/jwt.js +0 -3
  22. package/dist/esm/common/schema/jwt.test.js +0 -8
  23. package/dist/esm/workspace/authorization/schema.d.ts +0 -9
  24. package/dist/esm/workspace/authorization/schema.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/action/schema/operations/sign-up-verification.test.ts.bak +0 -163
  27. package/src/action/schema/operations/sign-up.test.ts.bak +0 -203
  28. package/src/action/schema/operations/user-attribute-verification.test.ts.bak +0 -148
  29. package/src/activity/schema/base.test.ts.bak +0 -291
  30. package/src/activity/schema/schema.test.ts.bak +0 -392
  31. package/src/activity/schema/types/authentication.test.ts.bak +0 -337
  32. package/src/activity/schema/types/authorization.test.ts.bak +0 -379
  33. package/src/activity/schema/types/note.test.ts.bak +0 -367
  34. package/src/activity/schema/types/operation.test.ts.bak +0 -379
  35. package/src/activity/schema/types/unknown.test.ts.bak +0 -304
  36. package/src/app/authorization/schema.test.ts.bak +0 -412
  37. package/src/app/oidc/schema.test.ts.bak +0 -117
  38. package/src/app/registration/schema.test.ts.bak +0 -308
  39. package/src/app/schema.test.ts.bak +0 -221
  40. package/src/association/schema.test.ts.bak +0 -148
  41. package/src/authentication/factors/schema.test.ts.bak +0 -174
  42. package/src/authentication/settings/schema.test.ts.bak +0 -91
  43. package/src/authorization/permissions/schema.test.ts.bak +0 -267
  44. package/src/authorization/roles/schema.test.ts.bak +0 -283
  45. package/src/common/schema/aggregate.test.ts.bak +0 -89
  46. package/src/common/schema/collection.test.ts.bak +0 -116
  47. package/src/common/schema/dates.test.ts.bak +0 -49
  48. package/src/common/schema/id.test.ts.bak +0 -149
  49. package/src/common/schema/jwt.test.ts.bak +0 -61
  50. package/src/common/schema/metadata.test.ts.bak +0 -141
  51. package/src/common/schema/pagination.test.ts.bak +0 -80
  52. package/src/common/schema/schema.test.ts.bak +0 -41
  53. package/src/customer/users/schema.test.ts.bak +0 -138
  54. package/src/identity/schema.test.ts.bak +0 -48
  55. package/src/oauth/token/schema/schema.test.ts.bak +0 -142
  56. package/src/workspace/settings/schema.test.ts.bak +0 -88
@@ -1,308 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import {
4
- type Registration,
5
- type RegistrationPayload,
6
- RegistrationPayloadSchema,
7
- RegistrationSchema,
8
- UpsertRegistrationPayloadSchema,
9
- } from './schema.js';
10
-
11
- describe('App Registration - Schema', () => {
12
- describe('RegistrationSchema', () => {
13
- test('should accept complete registration object', () => {
14
- const registration = {
15
- allowSelfRegistration: true,
16
- updatedAt: new Date(),
17
- deletedAt: new Date(),
18
- deactivatedAt: new Date(),
19
- metadata: {
20
- approval_required: false,
21
- email_verification: true,
22
- default_role: 'user',
23
- },
24
- };
25
-
26
- const result = RegistrationSchema(registration);
27
- expect(result).not.toBeInstanceOf(type.errors);
28
- });
29
-
30
- test('should accept minimal registration object', () => {
31
- const registration = {
32
- metadata: {},
33
- };
34
-
35
- const result = RegistrationSchema(registration);
36
- expect(result).not.toBeInstanceOf(type.errors);
37
- // Should have default allowSelfRegistration value
38
- expect((result as Registration).allowSelfRegistration).toBe(false);
39
- });
40
-
41
- test('should accept registration with allowSelfRegistration false', () => {
42
- const registration = {
43
- allowSelfRegistration: false,
44
- metadata: {
45
- registration_flow: 'invite_only',
46
- admin_approval: true,
47
- },
48
- };
49
-
50
- const result = RegistrationSchema(registration);
51
- expect(result).not.toBeInstanceOf(type.errors);
52
- expect((result as Registration).allowSelfRegistration).toBe(false);
53
- });
54
-
55
- test('should accept registration with allowSelfRegistration true', () => {
56
- const registration = {
57
- allowSelfRegistration: true,
58
- updatedAt: new Date(),
59
- metadata: {
60
- registration_flow: 'open',
61
- email_domains: ['example.com', 'company.org'],
62
- require_email_verification: true,
63
- },
64
- };
65
-
66
- const result = RegistrationSchema(registration);
67
- expect(result).not.toBeInstanceOf(type.errors);
68
- expect((result as Registration).allowSelfRegistration).toBe(true);
69
- });
70
-
71
- test('should accept registration with optional dates', () => {
72
- const registration = {
73
- allowSelfRegistration: true,
74
- updatedAt: new Date(),
75
- metadata: {
76
- last_config_change: new Date().toISOString(),
77
- configured_by: 'admin@example.com',
78
- },
79
- };
80
-
81
- const result = RegistrationSchema(registration);
82
- expect(result).not.toBeInstanceOf(type.errors);
83
- });
84
-
85
- test('should accept registration with complex metadata', () => {
86
- const registration = {
87
- allowSelfRegistration: true,
88
- updatedAt: new Date(),
89
- deletedAt: new Date(),
90
- metadata: {
91
- settings: {
92
- email_verification_required: true,
93
- phone_verification_required: false,
94
- captcha_required: true,
95
- password_policy: {
96
- min_length: 8,
97
- require_uppercase: true,
98
- require_lowercase: true,
99
- require_numbers: true,
100
- require_symbols: false,
101
- },
102
- },
103
- restrictions: {
104
- allowed_domains: ['company.com', 'partner.org'],
105
- blocked_domains: ['tempmail.com', 'guerrillamail.info'],
106
- max_registrations_per_day: 100,
107
- rate_limit_per_ip: 5,
108
- },
109
- workflow: {
110
- approval_workflow: false,
111
- auto_assign_role: 'member',
112
- welcome_email: true,
113
- onboarding_flow: 'standard',
114
- },
115
- },
116
- };
117
-
118
- const result = RegistrationSchema(registration);
119
- expect(result).not.toBeInstanceOf(type.errors);
120
- });
121
-
122
- test('should reject invalid allowSelfRegistration type', () => {
123
- const registration = {
124
- allowSelfRegistration: 'yes', // should be boolean
125
- metadata: {},
126
- };
127
-
128
- const result = RegistrationSchema(registration);
129
- expect(result).toBeInstanceOf(type.errors);
130
- });
131
-
132
- test('should reject invalid date types', () => {
133
- const registration = {
134
- allowSelfRegistration: true,
135
- updatedAt: 'invalid-date',
136
- metadata: {},
137
- };
138
-
139
- const result = RegistrationSchema(registration);
140
- expect(result).toBeInstanceOf(type.errors);
141
- });
142
- });
143
-
144
- describe('RegistrationPayloadSchema', () => {
145
- test('should accept complete payload', () => {
146
- const payload = {
147
- allowSelfRegistration: true,
148
- updatedAt: new Date().toISOString(),
149
- deletedAt: new Date().toISOString(),
150
- deactivatedAt: new Date().toISOString(),
151
- metadata: {
152
- configuration: 'open_registration',
153
- updated_by: 'admin@example.com',
154
- },
155
- };
156
-
157
- const result = RegistrationPayloadSchema(payload);
158
- expect(result).not.toBeInstanceOf(type.errors);
159
- expect(result).toEqual(payload);
160
- });
161
-
162
- test('should accept minimal payload', () => {
163
- const payload = {
164
- metadata: {},
165
- };
166
-
167
- const result = RegistrationPayloadSchema(payload);
168
- expect(result).not.toBeInstanceOf(type.errors);
169
- expect((result as RegistrationPayload).allowSelfRegistration).toBe(false);
170
- });
171
-
172
- test('should accept payload with allowSelfRegistration', () => {
173
- const payload = {
174
- allowSelfRegistration: true,
175
- metadata: {
176
- feature_enabled: true,
177
- enabled_at: new Date().toISOString(),
178
- },
179
- };
180
-
181
- const result = RegistrationPayloadSchema(payload);
182
- expect(result).not.toBeInstanceOf(type.errors);
183
- });
184
-
185
- test('should accept payload with optional dates', () => {
186
- const payload = {
187
- allowSelfRegistration: false,
188
- updatedAt: new Date().toISOString(),
189
- metadata: {
190
- disabled_reason: 'maintenance',
191
- re_enable_at: new Date().toISOString(),
192
- },
193
- };
194
-
195
- const result = RegistrationPayloadSchema(payload);
196
- expect(result).not.toBeInstanceOf(type.errors);
197
- });
198
-
199
- test('should accept payload with comprehensive registration settings', () => {
200
- const payload = {
201
- allowSelfRegistration: true,
202
- updatedAt: new Date().toISOString(),
203
- metadata: {
204
- email_format: 'strict',
205
- name_min_length: 2,
206
- phone_format: 'international',
207
- },
208
- };
209
-
210
- const result = RegistrationPayloadSchema(payload);
211
- expect(result).not.toBeInstanceOf(type.errors);
212
- });
213
-
214
- test('should reject invalid date format', () => {
215
- const payload = {
216
- allowSelfRegistration: true,
217
- updatedAt: 'invalid-date',
218
- metadata: {},
219
- };
220
-
221
- const result = RegistrationPayloadSchema(payload);
222
- expect(result).toBeInstanceOf(type.errors);
223
- });
224
-
225
- test('should reject invalid allowSelfRegistration type', () => {
226
- const payload = {
227
- allowSelfRegistration: 'true', // should be boolean
228
- metadata: {},
229
- };
230
-
231
- const result = RegistrationPayloadSchema(payload);
232
- expect(result).toBeInstanceOf(type.errors);
233
- });
234
- });
235
-
236
- describe('UpsertRegistrationPayloadSchema', () => {
237
- test('should accept upsert with allowSelfRegistration', () => {
238
- const payload = {
239
- allowSelfRegistration: true,
240
- metadata: {
241
- operation: 'enable_self_registration',
242
- reason: 'open_beta_launch',
243
- },
244
- };
245
-
246
- const result = UpsertRegistrationPayloadSchema(payload);
247
- expect(result).not.toBeInstanceOf(type.errors);
248
- expect(result).toEqual(payload);
249
- });
250
-
251
- test('should accept upsert without allowSelfRegistration', () => {
252
- const payload = {
253
- metadata: {
254
- operation: 'enable_self_registration',
255
- reason: 'open_beta_launch',
256
- },
257
- };
258
-
259
- const result = UpsertRegistrationPayloadSchema(payload);
260
- expect(result).not.toBeInstanceOf(type.errors);
261
- });
262
-
263
- test('should accept upsert with undefined allowSelfRegistration', () => {
264
- const payload = {
265
- allowSelfRegistration: undefined,
266
- metadata: {
267
- partial_update: true,
268
- },
269
- };
270
-
271
- const result = UpsertRegistrationPayloadSchema(payload);
272
- expect(result).not.toBeInstanceOf(type.errors);
273
- });
274
-
275
- test('should accept empty metadata', () => {
276
- const payload = {
277
- allowSelfRegistration: false,
278
- metadata: {},
279
- };
280
-
281
- const result = UpsertRegistrationPayloadSchema(payload);
282
- expect(result).not.toBeInstanceOf(type.errors);
283
- });
284
-
285
- test('should accept comprehensive upsert payload', () => {
286
- const payload = {
287
- allowSelfRegistration: true,
288
- metadata: {
289
- updated_by: 'admin@example.com',
290
- change_reason: 'platform_upgrade',
291
- },
292
- };
293
-
294
- const result = UpsertRegistrationPayloadSchema(payload);
295
- expect(result).not.toBeInstanceOf(type.errors);
296
- });
297
-
298
- test('should reject invalid allowSelfRegistration type', () => {
299
- const payload = {
300
- allowSelfRegistration: 'maybe', // should be boolean or undefined
301
- metadata: {},
302
- };
303
-
304
- const result = UpsertRegistrationPayloadSchema(payload);
305
- expect(result).toBeInstanceOf(type.errors);
306
- });
307
- });
308
- });
@@ -1,221 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import {
4
- type AppAssociationReference,
5
- AppAssociationReferenceSchema,
6
- AppIdPropertySchema,
7
- AppIdSchema,
8
- AppSchema,
9
- AppStatus,
10
- UpdateAppPayloadSchema,
11
- } from './schema.js';
12
- import { generateAppId } from './utils.js';
13
-
14
- describe('App - Schema', () => {
15
- describe('AppStatus constants', () => {
16
- test('should have correct status values', () => {
17
- expect(AppStatus.ENABLED).toBe('enabled');
18
- expect(AppStatus.DISABLED).toBe('disabled');
19
- });
20
- });
21
-
22
- describe('AppIdSchema', () => {
23
- test('should accept valid app ID', () => {
24
- const id = generateAppId();
25
- const result = AppIdSchema(id);
26
- expect(result).not.toBeInstanceOf(type.errors);
27
- expect(result).toBe(id);
28
- });
29
-
30
- test('should reject invalid app ID format', () => {
31
- expect(AppIdSchema('invalid_id')).toBeInstanceOf(type.errors);
32
- expect(AppIdSchema('wrong_prefix_123')).toBeInstanceOf(type.errors);
33
- });
34
-
35
- test('should reject non-string values', () => {
36
- expect(AppIdSchema(123)).toBeInstanceOf(type.errors);
37
- expect(AppIdSchema(null)).toBeInstanceOf(type.errors);
38
- });
39
- });
40
-
41
- describe('AppIdPropertySchema', () => {
42
- test('should accept valid id property', () => {
43
- const payload = { id: generateAppId() };
44
- const result = AppIdPropertySchema(payload);
45
- expect(result).not.toBeInstanceOf(type.errors);
46
- expect(result).toEqual(payload);
47
- });
48
-
49
- test('should reject missing id', () => {
50
- const result = AppIdPropertySchema({});
51
- expect(result).toBeInstanceOf(type.errors);
52
- });
53
-
54
- test('should reject invalid id format', () => {
55
- const result = AppIdPropertySchema({ id: 'invalid_id' });
56
- expect(result).toBeInstanceOf(type.errors);
57
- });
58
- });
59
-
60
- describe('AppSchema', () => {
61
- test('should accept complete app object', () => {
62
- const app = {
63
- id: generateAppId(),
64
- status: 'enabled' as const,
65
- label: 'My Application',
66
- description: 'Application description',
67
- createdAt: new Date(),
68
- updatedAt: new Date(),
69
- metadata: { key: 'value' },
70
- };
71
-
72
- const result = AppSchema(app);
73
- expect(result).not.toBeInstanceOf(type.errors);
74
- });
75
-
76
- test('should accept minimal app object', () => {
77
- const app = {
78
- id: generateAppId(),
79
- status: 'enabled' as const,
80
- label: 'Simple App',
81
- createdAt: new Date(),
82
- updatedAt: new Date(),
83
- metadata: {},
84
- };
85
-
86
- const result = AppSchema(app);
87
- expect(result).not.toBeInstanceOf(type.errors);
88
- });
89
-
90
- test('should accept app with optional dates', () => {
91
- const app = {
92
- id: generateAppId(),
93
- status: 'disabled' as const,
94
- label: 'Disabled App',
95
- description: 'This app is disabled',
96
- createdAt: new Date(),
97
- updatedAt: new Date(),
98
- deletedAt: new Date(),
99
- deactivatedAt: new Date(),
100
- metadata: {},
101
- };
102
-
103
- const result = AppSchema(app);
104
- expect(result).not.toBeInstanceOf(type.errors);
105
- });
106
-
107
- test('should reject invalid status', () => {
108
- const app = {
109
- id: generateAppId(),
110
- status: 'invalid-status',
111
- label: 'My App',
112
- createdAt: new Date(),
113
- updatedAt: new Date(),
114
- metadata: {},
115
- };
116
-
117
- const result = AppSchema(app);
118
- expect(result).toBeInstanceOf(type.errors);
119
- });
120
-
121
- test('should reject missing required fields', () => {
122
- const app = {
123
- id: generateAppId(),
124
- status: 'enabled' as const,
125
- // missing label, createdAt, updatedAt, metadata
126
- };
127
-
128
- const result = AppSchema(app);
129
- expect(result).toBeInstanceOf(type.errors);
130
- });
131
- });
132
-
133
- describe('UpdateAppPayloadSchema', () => {
134
- test('should accept all optional fields', () => {
135
- const payload = {
136
- status: 'disabled' as const,
137
- label: 'Updated App',
138
- description: 'Updated description',
139
- metadata: { updated: true },
140
- };
141
-
142
- const result = UpdateAppPayloadSchema(payload);
143
- expect(result).not.toBeInstanceOf(type.errors);
144
- expect(result).toEqual(payload);
145
- });
146
-
147
- test('should accept empty update payload', () => {
148
- const result = UpdateAppPayloadSchema({});
149
- expect(result).not.toBeInstanceOf(type.errors);
150
- expect(result).toEqual({});
151
- });
152
-
153
- test('should accept partial updates', () => {
154
- const payload = { label: 'New Label' };
155
- const result = UpdateAppPayloadSchema(payload);
156
- expect(result).not.toBeInstanceOf(type.errors);
157
- expect(result).toEqual(payload);
158
- });
159
-
160
- test('should accept null values for nullable fields', () => {
161
- const payload = {
162
- label: null,
163
- description: null,
164
- };
165
-
166
- const result = UpdateAppPayloadSchema(payload);
167
- expect(result).not.toBeInstanceOf(type.errors);
168
- expect(result).toEqual(payload);
169
- });
170
-
171
- test('should reject invalid status', () => {
172
- const payload = { status: 'invalid-status' };
173
- const result = UpdateAppPayloadSchema(payload);
174
- expect(result).toBeInstanceOf(type.errors);
175
- });
176
- });
177
-
178
- describe('AppAssociationReferenceSchema', () => {
179
- test('should accept complete association reference', () => {
180
- const reference = {
181
- id: generateAppId(),
182
- status: 'enabled' as const,
183
- label: 'Associated App',
184
- model: 'App' as const,
185
- };
186
-
187
- const result = AppAssociationReferenceSchema(reference);
188
- expect(result).not.toBeInstanceOf(type.errors);
189
- expect(result).toEqual(reference);
190
- });
191
-
192
- test('should use default status when not provided', () => {
193
- const reference = {
194
- id: generateAppId(),
195
- label: 'Test App',
196
- model: 'App' as const,
197
- };
198
-
199
- const result = AppAssociationReferenceSchema(reference);
200
- expect(result).not.toBeInstanceOf(type.errors);
201
- expect((result as AppAssociationReference).status).toBe('disabled'); // default value
202
- });
203
-
204
- test('should reject missing required fields', () => {
205
- const reference = { id: generateAppId() };
206
- const result = AppAssociationReferenceSchema(reference);
207
- expect(result).toBeInstanceOf(type.errors);
208
- });
209
-
210
- test('should reject invalid model value', () => {
211
- const reference = {
212
- id: generateAppId(),
213
- label: 'Test App',
214
- model: 'InvalidModel',
215
- };
216
-
217
- const result = AppAssociationReferenceSchema(reference);
218
- expect(result).toBeInstanceOf(type.errors);
219
- });
220
- });
221
- });
@@ -1,148 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateAppId } from '../app/utils.js';
4
- import {
5
- generatePermissionId,
6
- generateRoleId,
7
- } from '../authorization/schema.js';
8
- import { generateUserId } from '../customer/schema.js';
9
- import {
10
- AssociationObjectType,
11
- AssociationIdReferenceSchema,
12
- AssociationAttributesReferenceSchema,
13
- AssociationObjectSchema,
14
- } from './schema.js';
15
-
16
- describe('Association - Schema', () => {
17
- describe('AssociationObjectType constants', () => {
18
- test('should have correct object type values', () => {
19
- expect(AssociationObjectType.USER).toBe('User');
20
- expect(AssociationObjectType.ORGANIZATION).toBe('Organization');
21
- expect(AssociationObjectType.ROLE).toBe('Role');
22
- expect(AssociationObjectType.APP).toBe('App');
23
- expect(AssociationObjectType.PERMISSION).toBe('Permission');
24
- });
25
- });
26
-
27
- describe('AssociationIdReferenceSchema', () => {
28
- test('should accept valid id reference', () => {
29
- const reference = { id: 'any_string_id' };
30
- const result = AssociationIdReferenceSchema(reference);
31
- expect(result).not.toBeInstanceOf(type.errors);
32
- expect(result).toEqual(reference);
33
- });
34
-
35
- test('should reject missing id', () => {
36
- const result = AssociationIdReferenceSchema({});
37
- expect(result).toBeInstanceOf(type.errors);
38
- });
39
-
40
- test('should reject non-string id', () => {
41
- const reference = { id: 123 };
42
- const result = AssociationIdReferenceSchema(reference);
43
- expect(result).toBeInstanceOf(type.errors);
44
- });
45
- });
46
-
47
- describe('AssociationAttributesReferenceSchema', () => {
48
- test('should accept id with additional attributes', () => {
49
- const reference = {
50
- id: 'test_id',
51
- name: 'Test Name',
52
- status: 'active',
53
- metadata: { key: 'value' },
54
- };
55
-
56
- const result = AssociationAttributesReferenceSchema(reference);
57
- expect(result).not.toBeInstanceOf(type.errors);
58
- expect(result).toEqual(reference);
59
- });
60
-
61
- test('should accept minimal reference with just id', () => {
62
- const reference = { id: 'minimal_id' };
63
- const result = AssociationAttributesReferenceSchema(reference);
64
- expect(result).not.toBeInstanceOf(type.errors);
65
- expect(result).toEqual(reference);
66
- });
67
-
68
- test('should reject missing id', () => {
69
- const reference = { name: 'Test', status: 'active' };
70
- const result = AssociationAttributesReferenceSchema(reference);
71
- expect(result).toBeInstanceOf(type.errors);
72
- });
73
- });
74
-
75
- describe('AssociationObjectSchema', () => {
76
- // Note: User association reference has complex requirements
77
- // that depend on UserNamePropertiesSchema and EmailOrPhonePropertiesSchema
78
-
79
- test('should accept App association reference', () => {
80
- const appAssociation = {
81
- id: generateAppId(),
82
- status: 'enabled' as const,
83
- label: 'Test App',
84
- model: 'App' as const,
85
- };
86
-
87
- const result = AssociationObjectSchema(appAssociation);
88
- expect(result).not.toBeInstanceOf(type.errors);
89
- });
90
-
91
- test('should accept Role association reference', () => {
92
- const roleAssociation = {
93
- id: generateRoleId(),
94
- name: 'admin',
95
- status: 'enabled' as const,
96
- model: 'Role' as const,
97
- };
98
-
99
- const result = AssociationObjectSchema(roleAssociation);
100
- expect(result).not.toBeInstanceOf(type.errors);
101
- });
102
-
103
- test('should accept Permission association reference', () => {
104
- const permissionAssociation = {
105
- id: generatePermissionId(),
106
- name: 'read:users',
107
- status: 'enabled' as const,
108
- model: 'Permission' as const,
109
- };
110
-
111
- const result = AssociationObjectSchema(permissionAssociation);
112
- expect(result).not.toBeInstanceOf(type.errors);
113
- });
114
-
115
- test('should reject invalid association object', () => {
116
- const invalidAssociation = {
117
- id: 'test_id',
118
- name: 'Test',
119
- model: 'InvalidModel',
120
- };
121
-
122
- const result = AssociationObjectSchema(invalidAssociation);
123
- expect(result).toBeInstanceOf(type.errors);
124
- });
125
-
126
- test('should reject association missing required fields', () => {
127
- const incompleteAssociation = {
128
- id: generateUserId(),
129
- // missing required fields for any valid association type
130
- };
131
-
132
- const result = AssociationObjectSchema(incompleteAssociation);
133
- expect(result).toBeInstanceOf(type.errors);
134
- });
135
-
136
- test('should reject association with mismatched model and data', () => {
137
- const mismatchedAssociation = {
138
- id: generateUserId(),
139
- name: 'admin', // role field
140
- status: 'enabled' as const,
141
- model: 'User' as const, // but missing user fields
142
- };
143
-
144
- const result = AssociationObjectSchema(mismatchedAssociation);
145
- expect(result).toBeInstanceOf(type.errors);
146
- });
147
- });
148
- });