@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,174 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateStrategyId } from '../utils.js';
4
- import {
5
- AuthenticationFactorPayloadSchema,
6
- AuthenticationFactorsPayloadSchema,
7
- UpsertAuthenticationFactorsPayloadSchema,
8
- } from './schema.js';
9
-
10
- describe('Authentication - Factors', () => {
11
- describe('Schema', () => {
12
- test('should parse response payload successfully', async () => {
13
- expect(
14
- AuthenticationFactorsPayloadSchema({
15
- createdAt: new Date(),
16
- updatedAt: new Date(),
17
- factors: [
18
- {
19
- id: generateStrategyId(),
20
- },
21
- ],
22
- })
23
- ).not.toBeInstanceOf(type.errors);
24
-
25
- // Undefined factors
26
- expect(
27
- AuthenticationFactorsPayloadSchema({
28
- createdAt: new Date(),
29
- updatedAt: new Date(),
30
- factors: undefined,
31
- })
32
- ).not.toBeInstanceOf(type.errors);
33
- });
34
-
35
- test('should parse upsert payload successfully', async () => {
36
- expect(
37
- UpsertAuthenticationFactorsPayloadSchema({
38
- factors: [
39
- {
40
- id: generateStrategyId(),
41
- },
42
- ],
43
- })
44
- ).not.toBeInstanceOf(type.errors);
45
-
46
- // Null factors
47
- expect(
48
- UpsertAuthenticationFactorsPayloadSchema({
49
- factors: null,
50
- })
51
- ).not.toBeInstanceOf(type.errors);
52
-
53
- // Undefined factors
54
- expect(
55
- UpsertAuthenticationFactorsPayloadSchema({
56
- factors: undefined,
57
- })
58
- ).not.toBeInstanceOf(type.errors);
59
- });
60
-
61
- test('should throw error for invalid factors', async () => {
62
- // Factor object
63
- expect(
64
- AuthenticationFactorsPayloadSchema({
65
- createdAt: new Date(),
66
- updatedAt: new Date(),
67
- factors: { id: generateStrategyId() },
68
- })
69
- ).toBeInstanceOf(type.errors);
70
-
71
- // Factor array of string
72
- expect(
73
- AuthenticationFactorsPayloadSchema({
74
- createdAt: new Date(),
75
- updatedAt: new Date(),
76
- factors: [generateStrategyId()],
77
- })
78
- ).toBeInstanceOf(type.errors);
79
- });
80
-
81
- test('should accept various next factors types', async () => {
82
- // Undefined
83
- expect(
84
- AuthenticationFactorPayloadSchema({
85
- id: generateStrategyId(),
86
- nextFactors: undefined,
87
- })
88
- ).not.toBeInstanceOf(type.errors);
89
-
90
- // Array
91
- expect(
92
- AuthenticationFactorPayloadSchema({
93
- id: generateStrategyId(),
94
- nextFactors: [
95
- {
96
- id: generateStrategyId(),
97
- },
98
- ],
99
- })
100
- ).not.toBeInstanceOf(type.errors);
101
-
102
- // Deeply nested array
103
- expect(
104
- AuthenticationFactorPayloadSchema({
105
- id: generateStrategyId(),
106
- nextFactors: [
107
- {
108
- id: generateStrategyId(),
109
- nextFactors: [
110
- {
111
- id: generateStrategyId(),
112
- nextFactors: [
113
- {
114
- id: generateStrategyId(),
115
- },
116
- ],
117
- },
118
- ],
119
- },
120
- ],
121
- })
122
- ).not.toBeInstanceOf(type.errors);
123
- });
124
-
125
- test('should throw error for invalid factor id', async () => {
126
- // Number
127
- expect(
128
- AuthenticationFactorsPayloadSchema({
129
- id: generateStrategyId(),
130
- })
131
- ).toBeInstanceOf(type.errors);
132
-
133
- // Null
134
- expect(
135
- AuthenticationFactorsPayloadSchema({
136
- id: null,
137
- })
138
- ).toBeInstanceOf(type.errors);
139
-
140
- // Undefined
141
- expect(
142
- AuthenticationFactorsPayloadSchema({
143
- id: undefined,
144
- })
145
- ).toBeInstanceOf(type.errors);
146
- });
147
-
148
- test('should throw error for invalid next factors', async () => {
149
- // String
150
- expect(
151
- AuthenticationFactorsPayloadSchema({
152
- id: generateStrategyId(),
153
- nextFactors: generateStrategyId(),
154
- })
155
- ).toBeInstanceOf(type.errors);
156
-
157
- // Object
158
- expect(
159
- AuthenticationFactorsPayloadSchema({
160
- id: generateStrategyId(),
161
- nextFactors: { id: generateStrategyId() },
162
- })
163
- ).toBeInstanceOf(type.errors);
164
-
165
- // Array
166
- expect(
167
- AuthenticationFactorsPayloadSchema({
168
- id: generateStrategyId(),
169
- nextFactors: [generateStrategyId()],
170
- })
171
- ).toBeInstanceOf(type.errors);
172
- });
173
- });
174
- });
@@ -1,91 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import {
4
- SettingsSchema,
5
- SettingsPayloadSchema,
6
- UpsertSettingsPayloadSchema,
7
- } from './schema.js';
8
-
9
- describe('Authentication Settings - Schema', () => {
10
- describe('SettingsSchema', () => {
11
- test('should accept minimal settings object', () => {
12
- const settings = {
13
- createdAt: new Date(),
14
- updatedAt: new Date(),
15
- metadata: {},
16
- };
17
-
18
- const result = SettingsSchema(settings);
19
- expect(result).not.toBeInstanceOf(type.errors);
20
- });
21
-
22
- test('should reject missing required dates', () => {
23
- const settings = {
24
- metadata: {},
25
- // missing createdAt, updatedAt
26
- };
27
-
28
- const result = SettingsSchema(settings);
29
- expect(result).toBeInstanceOf(type.errors);
30
- });
31
- });
32
-
33
- describe('SettingsPayloadSchema', () => {
34
- test('should accept minimal payload', () => {
35
- const payload = {
36
- metadata: {},
37
- };
38
-
39
- const result = SettingsPayloadSchema(payload);
40
- expect(result).not.toBeInstanceOf(type.errors);
41
- expect(result).toEqual(payload);
42
- });
43
-
44
- test('should accept payload with optional dates', () => {
45
- const payload = {
46
- updatedAt: new Date().toISOString(),
47
- metadata: {},
48
- };
49
-
50
- const result = SettingsPayloadSchema(payload);
51
- expect(result).not.toBeInstanceOf(type.errors);
52
- });
53
-
54
- test('should accept empty payload', () => {
55
- const payload = {
56
- // Schema might have defaults for metadata
57
- };
58
-
59
- const result = SettingsPayloadSchema(payload);
60
- expect(result).not.toBeInstanceOf(type.errors);
61
- });
62
- });
63
-
64
- describe('UpsertSettingsPayloadSchema', () => {
65
- test('should accept empty upsert payload', () => {
66
- const payload = {};
67
-
68
- const result = UpsertSettingsPayloadSchema(payload);
69
- expect(result).not.toBeInstanceOf(type.errors);
70
- expect(result).toEqual(payload);
71
- });
72
-
73
- test('should accept upsert with only metadata', () => {
74
- const payload = {
75
- metadata: { configVersion: '2.0' },
76
- };
77
-
78
- const result = UpsertSettingsPayloadSchema(payload);
79
- expect(result).not.toBeInstanceOf(type.errors);
80
- });
81
-
82
- test('should reject invalid factors structure', () => {
83
- const payload = {
84
- factors: 'invalid-factors',
85
- };
86
-
87
- const result = UpsertSettingsPayloadSchema(payload);
88
- expect(result).toBeInstanceOf(type.errors);
89
- });
90
- });
91
- });
@@ -1,267 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateAppId } from '../../app/utils.js';
4
- import {
5
- PermissionIdSchema,
6
- generatePermissionId,
7
- generateRoleId,
8
- } from '../schema.js';
9
- import {
10
- type InsertPermissionPayload,
11
- InsertPermissionPayloadSchema,
12
- type PermissionAssociationReference,
13
- PermissionAssociationReferenceSchema,
14
- PermissionAssociationsSchema,
15
- PermissionIdPropertySchema,
16
- PermissionSchema,
17
- PermissionStatus,
18
- UpdatePermissionPayloadSchema,
19
- } from './schema.js';
20
-
21
- describe('Authorization Permissions - Schema', () => {
22
- describe('PermissionStatus constants', () => {
23
- test('should have correct status values', () => {
24
- expect(PermissionStatus.ENABLED).toBe('enabled');
25
- expect(PermissionStatus.DISABLED).toBe('disabled');
26
- });
27
- });
28
-
29
- describe('PermissionIdSchema', () => {
30
- test('should accept valid string ID', () => {
31
- const result = PermissionIdSchema(generatePermissionId());
32
- expect(result).not.toBeInstanceOf(type.errors);
33
- });
34
-
35
- test('should reject non-string values', () => {
36
- expect(PermissionIdSchema(123)).toBeInstanceOf(type.errors);
37
- expect(PermissionIdSchema(null)).toBeInstanceOf(type.errors);
38
- });
39
- });
40
-
41
- describe('PermissionIdPropertySchema', () => {
42
- test('should accept valid id property', () => {
43
- const payload = { id: generatePermissionId() };
44
- const result = PermissionIdPropertySchema(payload);
45
- expect(result).not.toBeInstanceOf(type.errors);
46
- expect(result).toEqual({ id: payload.id });
47
- });
48
-
49
- test('should reject missing id', () => {
50
- const result = PermissionIdPropertySchema({});
51
- expect(result).toBeInstanceOf(type.errors);
52
- });
53
- });
54
-
55
- describe('PermissionAssociationsSchema', () => {
56
- const payload = {
57
- apps: [generateAppId(), generateAppId()],
58
- roles: [generateRoleId(), generateRoleId()],
59
- };
60
- test('should accept valid associations', () => {
61
- const result = PermissionAssociationsSchema(payload);
62
- expect(result).not.toBeInstanceOf(type.errors);
63
- expect(result).toEqual({
64
- apps: payload.apps,
65
- roles: payload.roles,
66
- });
67
- });
68
-
69
- test('should accept optional associations', () => {
70
- const result = PermissionAssociationsSchema({});
71
- expect(result).not.toBeInstanceOf(type.errors);
72
- expect(result).toEqual({});
73
- });
74
-
75
- test('should accept undefined associations', () => {
76
- const result = PermissionAssociationsSchema({
77
- apps: undefined,
78
- roles: [generateRoleId()],
79
- });
80
- expect(result).not.toBeInstanceOf(type.errors);
81
- });
82
-
83
- test('should reject non-array associations', () => {
84
- const result = PermissionAssociationsSchema({
85
- apps: 'not-an-array',
86
- });
87
- expect(result).toBeInstanceOf(type.errors);
88
- });
89
- });
90
-
91
- describe('PermissionSchema', () => {
92
- test('should accept complete permission object', () => {
93
- const permission = {
94
- id: generatePermissionId(),
95
- name: 'read:users',
96
- status: 'enabled' as const,
97
- description: 'Read user data',
98
- apps: { ids: [generateAppId()], count: 1 },
99
- roles: { ids: [generateRoleId()], count: 1 },
100
- createdAt: new Date(),
101
- updatedAt: new Date(),
102
- metadata: { key: 'value' },
103
- };
104
-
105
- const result = PermissionSchema(permission);
106
- expect(result).not.toBeInstanceOf(type.errors);
107
- });
108
-
109
- test('should accept minimal permission object', () => {
110
- const permission = {
111
- id: generatePermissionId(),
112
- name: 'read:users',
113
- status: 'enabled' as const,
114
- createdAt: new Date(),
115
- updatedAt: new Date(),
116
- metadata: {},
117
- };
118
-
119
- const result = PermissionSchema(permission);
120
- expect(result).not.toBeInstanceOf(type.errors);
121
- });
122
-
123
- test('should reject invalid status', () => {
124
- const permission = {
125
- id: generatePermissionId(),
126
- name: 'read:users',
127
- status: 'invalid',
128
- createdAt: new Date(),
129
- updatedAt: new Date(),
130
- metadata: {},
131
- };
132
-
133
- const result = PermissionSchema(permission);
134
- expect(result).toBeInstanceOf(type.errors);
135
- });
136
-
137
- test('should reject missing required fields', () => {
138
- const permission = {
139
- id: generatePermissionId(),
140
- name: 'read:users',
141
- };
142
-
143
- const result = PermissionSchema(permission);
144
- expect(result).toBeInstanceOf(type.errors);
145
- });
146
- });
147
-
148
- describe('InsertPermissionPayloadSchema', () => {
149
- test('should accept complete insert payload', () => {
150
- const payload = {
151
- id: generatePermissionId(),
152
- name: 'read:users',
153
- status: 'enabled' as const,
154
- description: 'Read user data',
155
- apps: [generateAppId()],
156
- roles: [generateRoleId()],
157
- metadata: { key: 'value' },
158
- };
159
-
160
- const result = InsertPermissionPayloadSchema(payload);
161
- expect(result).not.toBeInstanceOf(type.errors);
162
- });
163
-
164
- test('should accept minimal insert payload', () => {
165
- const payload = {
166
- name: 'read:users',
167
- };
168
-
169
- const result = InsertPermissionPayloadSchema(payload);
170
- expect(result).not.toBeInstanceOf(type.errors);
171
- expect((result as InsertPermissionPayload).status).toBe('enabled'); // default value
172
- });
173
-
174
- test('should generate default ID when not provided', () => {
175
- const payload = { name: 'read:users' };
176
- const result = InsertPermissionPayloadSchema(payload);
177
-
178
- expect(result).not.toBeInstanceOf(type.errors);
179
- expect((result as InsertPermissionPayload).id).toMatch(/^per_/);
180
- });
181
-
182
- test('should reject missing name', () => {
183
- const result = InsertPermissionPayloadSchema({});
184
- expect(result).toBeInstanceOf(type.errors);
185
- });
186
- });
187
-
188
- describe('UpdatePermissionPayloadSchema', () => {
189
- test('should accept all optional fields', () => {
190
- const payload = {
191
- name: 'updated:permission',
192
- status: 'disabled' as const,
193
- description: 'Updated description',
194
- metadata: { updated: true },
195
- };
196
-
197
- const result = UpdatePermissionPayloadSchema(payload);
198
- expect(result).not.toBeInstanceOf(type.errors);
199
- expect(result).toEqual(payload);
200
- });
201
-
202
- test('should accept empty update payload', () => {
203
- const result = UpdatePermissionPayloadSchema({});
204
- expect(result).not.toBeInstanceOf(type.errors);
205
- expect(result).toEqual({});
206
- });
207
-
208
- test('should accept partial updates', () => {
209
- const payload = { name: 'new:name' };
210
- const result = UpdatePermissionPayloadSchema(payload);
211
- expect(result).not.toBeInstanceOf(type.errors);
212
- expect(result).toEqual(payload);
213
- });
214
-
215
- test('should reject invalid status', () => {
216
- const payload = { status: 'invalid-status' };
217
- const result = UpdatePermissionPayloadSchema(payload);
218
- expect(result).toBeInstanceOf(type.errors);
219
- });
220
- });
221
-
222
- describe('PermissionAssociationReferenceSchema', () => {
223
- test('should accept complete association reference', () => {
224
- const reference = {
225
- id: generatePermissionId(),
226
- name: 'read:users',
227
- status: 'enabled' as const,
228
- model: 'Permission' as const,
229
- };
230
-
231
- const result = PermissionAssociationReferenceSchema(reference);
232
- expect(result).not.toBeInstanceOf(type.errors);
233
- expect(result).toEqual(reference);
234
- });
235
-
236
- test('should use default status when not provided', () => {
237
- const reference = {
238
- id: generatePermissionId(),
239
- name: 'read:users',
240
- model: 'Permission' as const,
241
- };
242
-
243
- const result = PermissionAssociationReferenceSchema(reference);
244
- expect(result).not.toBeInstanceOf(type.errors);
245
- expect((result as PermissionAssociationReference).status).toBe(
246
- 'disabled'
247
- ); // default value
248
- });
249
-
250
- test('should reject missing required fields', () => {
251
- const reference = { id: generatePermissionId() };
252
- const result = PermissionAssociationReferenceSchema(reference);
253
- expect(result).toBeInstanceOf(type.errors);
254
- });
255
-
256
- test('should reject invalid model value', () => {
257
- const reference = {
258
- id: generatePermissionId(),
259
- name: 'read:users',
260
- model: 'InvalidModel',
261
- };
262
-
263
- const result = PermissionAssociationReferenceSchema(reference);
264
- expect(result).toBeInstanceOf(type.errors);
265
- });
266
- });
267
- });