@go-mondo/identity-sdk 0.0.2-beta.73 → 0.0.2-beta.75

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 (60) 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 +0 -9
  6. package/dist/cjs/app/authorization/schema.d.ts.map +1 -1
  7. package/dist/cjs/common/schema/jwt.d.ts +0 -6
  8. package/dist/cjs/common/schema/jwt.d.ts.map +1 -1
  9. package/dist/cjs/common/schema/jwt.js +0 -3
  10. package/dist/cjs/common/schema/jwt.test.js +0 -8
  11. package/dist/cjs/customer/users/schema.d.ts +4 -4
  12. package/dist/cjs/customer/users/schema.d.ts.map +1 -1
  13. package/dist/cjs/customer/users/schema.js +8 -4
  14. package/dist/cjs/customer/users/schema.test.js +4 -4
  15. package/dist/cjs/workspace/authorization/schema.d.ts +0 -9
  16. package/dist/cjs/workspace/authorization/schema.d.ts.map +1 -1
  17. package/dist/esm/app/authorization/schema.d.ts +0 -9
  18. package/dist/esm/app/authorization/schema.d.ts.map +1 -1
  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/customer/users/schema.d.ts +4 -4
  24. package/dist/esm/customer/users/schema.d.ts.map +1 -1
  25. package/dist/esm/customer/users/schema.js +8 -4
  26. package/dist/esm/customer/users/schema.test.js +4 -4
  27. package/dist/esm/workspace/authorization/schema.d.ts +0 -9
  28. package/dist/esm/workspace/authorization/schema.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/src/action/schema/operations/sign-up-verification.test.ts.bak +0 -163
  31. package/src/action/schema/operations/sign-up.test.ts.bak +0 -203
  32. package/src/action/schema/operations/user-attribute-verification.test.ts.bak +0 -148
  33. package/src/activity/schema/base.test.ts.bak +0 -291
  34. package/src/activity/schema/schema.test.ts.bak +0 -392
  35. package/src/activity/schema/types/authentication.test.ts.bak +0 -337
  36. package/src/activity/schema/types/authorization.test.ts.bak +0 -379
  37. package/src/activity/schema/types/note.test.ts.bak +0 -367
  38. package/src/activity/schema/types/operation.test.ts.bak +0 -379
  39. package/src/activity/schema/types/unknown.test.ts.bak +0 -304
  40. package/src/app/authorization/schema.test.ts.bak +0 -412
  41. package/src/app/oidc/schema.test.ts.bak +0 -117
  42. package/src/app/registration/schema.test.ts.bak +0 -308
  43. package/src/app/schema.test.ts.bak +0 -221
  44. package/src/association/schema.test.ts.bak +0 -148
  45. package/src/authentication/factors/schema.test.ts.bak +0 -174
  46. package/src/authentication/settings/schema.test.ts.bak +0 -91
  47. package/src/authorization/permissions/schema.test.ts.bak +0 -267
  48. package/src/authorization/roles/schema.test.ts.bak +0 -283
  49. package/src/common/schema/aggregate.test.ts.bak +0 -89
  50. package/src/common/schema/collection.test.ts.bak +0 -116
  51. package/src/common/schema/dates.test.ts.bak +0 -49
  52. package/src/common/schema/id.test.ts.bak +0 -149
  53. package/src/common/schema/jwt.test.ts.bak +0 -61
  54. package/src/common/schema/metadata.test.ts.bak +0 -141
  55. package/src/common/schema/pagination.test.ts.bak +0 -80
  56. package/src/common/schema/schema.test.ts.bak +0 -41
  57. package/src/customer/users/schema.test.ts.bak +0 -138
  58. package/src/identity/schema.test.ts.bak +0 -48
  59. package/src/oauth/token/schema/schema.test.ts.bak +0 -142
  60. package/src/workspace/settings/schema.test.ts.bak +0 -88
@@ -1,291 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateAppId } from '../../app/utils.js';
4
- import {
5
- ActivityIdPropertySchema,
6
- ActivityIdSchema,
7
- ActivityType,
8
- BaseInsertPayloadSchema,
9
- BaseSchema,
10
- BaseUpdatePayloadSchema,
11
- PerformedBySchema,
12
- PerformerType,
13
- SourceSchema,
14
- } from './base.js';
15
- import { generateActivityId } from './utils.js';
16
-
17
- describe('Activity Schema - Base', () => {
18
- describe('ActivityType constants', () => {
19
- test('should have correct activity type values', () => {
20
- expect(ActivityType.UNKNOWN).toBe('unknown');
21
- expect(ActivityType.NOTE).toBe('note');
22
- expect(ActivityType.OPERATION).toBe('operation');
23
- expect(ActivityType.AUTHORIZATION).toBe('authorization');
24
- expect(ActivityType.AUTHENTICATION).toBe('authentication');
25
- });
26
- });
27
-
28
- describe('PerformerType constants', () => {
29
- test('should have correct performer type values', () => {
30
- expect(PerformerType.SYSTEM).toBe('system');
31
- expect(PerformerType.GUEST).toBe('guest');
32
- expect(PerformerType.IDENTITY).toBe('identity');
33
- expect(PerformerType.AUTOMATION).toBe('automation');
34
- expect(PerformerType.INTEGRATION).toBe('integration');
35
- });
36
- });
37
-
38
- describe('ActivityIdSchema', () => {
39
- test('should accept valid activity ID', () => {
40
- const id = generateActivityId();
41
- const result = ActivityIdSchema(id);
42
- expect(result).not.toBeInstanceOf(type.errors);
43
- expect(result).toBe(id);
44
- });
45
-
46
- test('should reject invalid activity ID format', () => {
47
- expect(ActivityIdSchema('invalid_id')).toBeInstanceOf(type.errors);
48
- expect(ActivityIdSchema('wrong_prefix_123')).toBeInstanceOf(type.errors);
49
- });
50
-
51
- test('should reject non-string values', () => {
52
- expect(ActivityIdSchema(123)).toBeInstanceOf(type.errors);
53
- expect(ActivityIdSchema(null)).toBeInstanceOf(type.errors);
54
- });
55
- });
56
-
57
- describe('ActivityIdPropertySchema', () => {
58
- test('should accept valid id property', () => {
59
- const payload = { id: generateActivityId() };
60
- const result = ActivityIdPropertySchema(payload);
61
- expect(result).not.toBeInstanceOf(type.errors);
62
- expect(result).toEqual(payload);
63
- });
64
-
65
- test('should reject missing id', () => {
66
- const result = ActivityIdPropertySchema({});
67
- expect(result).toBeInstanceOf(type.errors);
68
- });
69
- });
70
-
71
- describe('SourceSchema', () => {
72
- test('should accept string source', () => {
73
- const result = SourceSchema('api-request');
74
- expect(result).not.toBeInstanceOf(type.errors);
75
- expect(result).toBe('api-request');
76
- });
77
-
78
- test('should reject non-string values', () => {
79
- expect(SourceSchema(123)).toBeInstanceOf(type.errors);
80
- expect(SourceSchema(null)).toBeInstanceOf(type.errors);
81
- });
82
- });
83
-
84
- describe('PerformedBySchema', () => {
85
- test('should accept valid performer with system type', () => {
86
- const performer = {
87
- type: 'system' as const,
88
- identifier: 'system-process',
89
- };
90
-
91
- const result = PerformedBySchema(performer);
92
- expect(result).not.toBeInstanceOf(type.errors);
93
- expect(result).toEqual(performer);
94
- });
95
-
96
- test('should accept valid performer with identity type', () => {
97
- const performer = {
98
- type: 'identity' as const,
99
- identifier: 'user@example.com',
100
- };
101
-
102
- const result = PerformedBySchema(performer);
103
- expect(result).not.toBeInstanceOf(type.errors);
104
- expect(result).toEqual(performer);
105
- });
106
-
107
- test('should accept all valid performer types', () => {
108
- const types = [
109
- 'system',
110
- 'guest',
111
- 'identity',
112
- 'automation',
113
- 'integration',
114
- ] as const;
115
-
116
- for (const performerType of types) {
117
- const performer = {
118
- type: performerType,
119
- identifier: `test-${performerType}`,
120
- };
121
- const result = PerformedBySchema(performer);
122
- expect(result).not.toBeInstanceOf(type.errors);
123
- }
124
- });
125
-
126
- test('should reject invalid performer type', () => {
127
- const performer = {
128
- type: 'invalid',
129
- identifier: 'test',
130
- };
131
-
132
- const result = PerformedBySchema(performer);
133
- expect(result).toBeInstanceOf(type.errors);
134
- });
135
-
136
- test('should reject missing fields', () => {
137
- expect(PerformedBySchema({ type: 'system' })).toBeInstanceOf(type.errors);
138
- expect(PerformedBySchema({ identifier: 'test' })).toBeInstanceOf(
139
- type.errors
140
- );
141
- });
142
- });
143
-
144
- describe('BaseSchema', () => {
145
- test('should accept complete base activity', () => {
146
- const activity = {
147
- id: generateActivityId(),
148
- performedBy: {
149
- type: 'identity' as const,
150
- identifier: 'user@example.com',
151
- },
152
- source: 'web-app',
153
- app: generateAppId(),
154
- isMutateable: true,
155
- createdAt: new Date(),
156
- updatedAt: new Date(),
157
- metadata: { key: 'value' },
158
- };
159
-
160
- const result = BaseSchema(activity);
161
- expect(result).not.toBeInstanceOf(type.errors);
162
- });
163
-
164
- test('should accept activity without app', () => {
165
- const activity = {
166
- id: generateActivityId(),
167
- performedBy: {
168
- type: 'system' as const,
169
- identifier: 'background-job',
170
- },
171
- source: 'cron',
172
- isMutateable: false,
173
- createdAt: new Date(),
174
- updatedAt: new Date(),
175
- metadata: {},
176
- };
177
-
178
- const result = BaseSchema(activity);
179
- expect(result).not.toBeInstanceOf(type.errors);
180
- });
181
-
182
- test('should accept activity with optional dates', () => {
183
- const activity = {
184
- id: generateActivityId(),
185
- performedBy: {
186
- type: 'guest' as const,
187
- identifier: 'anonymous',
188
- },
189
- source: 'public-api',
190
- isMutateable: true,
191
- createdAt: new Date(),
192
- updatedAt: new Date(),
193
- deletedAt: new Date(),
194
- deactivatedAt: new Date(),
195
- metadata: {},
196
- };
197
-
198
- const result = BaseSchema(activity);
199
- expect(result).not.toBeInstanceOf(type.errors);
200
- });
201
-
202
- test('should reject missing required fields', () => {
203
- const activity = {
204
- id: generateActivityId(),
205
- performedBy: {
206
- type: 'system' as const,
207
- identifier: 'test',
208
- },
209
- // missing source, isMutateable, dates, metadata
210
- };
211
-
212
- const result = BaseSchema(activity);
213
- expect(result).toBeInstanceOf(type.errors);
214
- });
215
- });
216
-
217
- describe('BaseInsertPayloadSchema', () => {
218
- test('should accept complete insert payload', () => {
219
- const payload = {
220
- id: generateActivityId(),
221
- performedBy: {
222
- type: 'identity' as const,
223
- identifier: 'user123',
224
- },
225
- metadata: { source: 'api' },
226
- };
227
-
228
- const result = BaseInsertPayloadSchema(payload);
229
- expect(result).not.toBeInstanceOf(type.errors);
230
- });
231
-
232
- test('should accept minimal insert payload', () => {
233
- const payload = {};
234
-
235
- const result = BaseInsertPayloadSchema(payload);
236
- expect(result).not.toBeInstanceOf(type.errors);
237
- // Should generate default ID
238
- expect((result as typeof BaseInsertPayloadSchema.inferOut).id).toMatch(
239
- /^act_/
240
- );
241
- });
242
-
243
- test('should generate default ID when not provided', () => {
244
- const payload = {
245
- performedBy: {
246
- type: 'system' as const,
247
- identifier: 'auto-process',
248
- },
249
- };
250
-
251
- const result = BaseInsertPayloadSchema(payload);
252
- expect(result).not.toBeInstanceOf(type.errors);
253
- expect((result as typeof BaseInsertPayloadSchema.inferOut).id).toMatch(
254
- /^act_/
255
- );
256
- });
257
- });
258
-
259
- describe('BaseUpdatePayloadSchema', () => {
260
- test('should accept update with performer', () => {
261
- const payload = {
262
- performedBy: {
263
- type: 'automation' as const,
264
- identifier: 'scheduled-task',
265
- },
266
- metadata: { updated: true },
267
- };
268
-
269
- const result = BaseUpdatePayloadSchema(payload);
270
- expect(result).not.toBeInstanceOf(type.errors);
271
- expect(result).toEqual(payload);
272
- });
273
-
274
- test('should accept empty update payload', () => {
275
- const payload = {};
276
-
277
- const result = BaseUpdatePayloadSchema(payload);
278
- expect(result).not.toBeInstanceOf(type.errors);
279
- expect(result).toEqual(payload);
280
- });
281
-
282
- test('should accept update with only metadata', () => {
283
- const payload = {
284
- metadata: { version: '2.0' },
285
- };
286
-
287
- const result = BaseUpdatePayloadSchema(payload);
288
- expect(result).not.toBeInstanceOf(type.errors);
289
- });
290
- });
291
- });
@@ -1,392 +0,0 @@
1
- import { type } from 'arktype';
2
- import { describe, expect, test } from 'vitest';
3
- import { generateUserId } from '../../customer/schema.js';
4
- import {
5
- ActivityPayloadSchema,
6
- ActivitySchema,
7
- type InsertActivityPayload,
8
- InsertActivityPayloadSchema,
9
- UpdateActivityPayloadSchema,
10
- } from './schema.js';
11
- import { generateActivityId } from './utils.js';
12
-
13
- describe('Activity Schema - Main', () => {
14
- describe('ActivitySchema', () => {
15
- test('should accept note activity', () => {
16
- const activity = {
17
- id: generateActivityId(),
18
- type: 'note' as const,
19
- message: 'Test note message',
20
- performedBy: {
21
- type: 'identity' as const,
22
- identifier: 'user@example.com',
23
- },
24
- source: 'web-app',
25
- isMutateable: true,
26
- createdAt: new Date(),
27
- updatedAt: new Date(),
28
- metadata: {},
29
- };
30
-
31
- const result = ActivitySchema(activity);
32
- expect(result).not.toBeInstanceOf(type.errors);
33
- });
34
-
35
- test('should accept authentication activity', () => {
36
- const activity = {
37
- id: generateActivityId(),
38
- type: 'authentication' as const,
39
- performedBy: {
40
- type: 'identity' as const,
41
- identifier: 'user@example.com',
42
- },
43
- message: 'string',
44
- identity: generateUserId(),
45
- status: 'success',
46
- source: 'login-form',
47
- isMutateable: false,
48
- createdAt: new Date(),
49
- updatedAt: new Date(),
50
- metadata: { method: 'email' },
51
- };
52
-
53
- const result = ActivitySchema(activity);
54
- expect(result).not.toBeInstanceOf(type.errors);
55
- });
56
-
57
- test('should accept authorization activity', () => {
58
- const activity = {
59
- id: generateActivityId(),
60
- type: 'authorization' as const,
61
- performedBy: {
62
- type: 'system' as const,
63
- identifier: 'auth-service',
64
- },
65
- message: 'string',
66
- status: 'success',
67
- source: 'rbac-check',
68
- isMutateable: false,
69
- createdAt: new Date(),
70
- updatedAt: new Date(),
71
- metadata: { resource: 'users' },
72
- };
73
-
74
- const result = ActivitySchema(activity);
75
- expect(result).not.toBeInstanceOf(type.errors);
76
- });
77
-
78
- test('should accept operation activity', () => {
79
- const activity = {
80
- id: generateActivityId(),
81
- type: 'operation' as const,
82
- performedBy: {
83
- type: 'automation' as const,
84
- identifier: 'data-sync',
85
- },
86
- message: 'string',
87
- operation: 'delete',
88
- target: generateUserId(),
89
- source: 'cron-job',
90
- isMutateable: true,
91
- createdAt: new Date(),
92
- updatedAt: new Date(),
93
- metadata: { operation: 'sync' },
94
- };
95
-
96
- const result = ActivitySchema(activity);
97
- expect(result).not.toBeInstanceOf(type.errors);
98
- });
99
-
100
- test('should accept unknown activity', () => {
101
- const activity = {
102
- id: generateActivityId(),
103
- type: 'unknown' as const,
104
- performedBy: {
105
- type: 'guest' as const,
106
- identifier: 'anonymous',
107
- },
108
- message: 'string',
109
- source: 'external-api',
110
- isMutateable: true,
111
- createdAt: new Date(),
112
- updatedAt: new Date(),
113
- metadata: {},
114
- };
115
-
116
- const result = ActivitySchema(activity);
117
- expect(result).not.toBeInstanceOf(type.errors);
118
- });
119
-
120
- test('should reject invalid activity type', () => {
121
- const activity = {
122
- id: generateActivityId(),
123
- type: 'invalid_type',
124
- performedBy: {
125
- type: 'system' as const,
126
- identifier: 'test',
127
- },
128
- source: 'test',
129
- isMutateable: true,
130
- createdAt: new Date(),
131
- updatedAt: new Date(),
132
- metadata: {},
133
- };
134
-
135
- const result = ActivitySchema(activity);
136
- expect(result).toBeInstanceOf(type.errors);
137
- });
138
- });
139
-
140
- describe('ActivityPayloadSchema', () => {
141
- test('should accept note activity payload', () => {
142
- const payload = {
143
- id: generateActivityId(),
144
- type: 'note' as const,
145
- message: 'Test note',
146
- performedBy: {
147
- type: 'identity' as const,
148
- identifier: 'user@example.com',
149
- },
150
- source: 'web-app',
151
- isMutateable: true,
152
- createdAt: new Date().toISOString(),
153
- updatedAt: new Date().toISOString(),
154
- metadata: { urgent: true },
155
- };
156
-
157
- const result = ActivityPayloadSchema(payload);
158
- expect(result).not.toBeInstanceOf(type.errors);
159
- expect(result).toEqual(payload);
160
- });
161
-
162
- test('should accept authentication activity payload', () => {
163
- const payload = {
164
- id: generateActivityId(),
165
- type: 'authentication' as const,
166
- performedBy: {
167
- type: 'identity' as const,
168
- identifier: 'user@example.com',
169
- },
170
- identity: generateUserId(),
171
- message: 'string',
172
- status: 'success',
173
- source: 'mobile-app',
174
- isMutateable: false,
175
- createdAt: new Date().toISOString(),
176
- updatedAt: new Date().toISOString(),
177
- metadata: { device: 'iPhone' },
178
- };
179
-
180
- const result = ActivityPayloadSchema(payload);
181
- expect(result).not.toBeInstanceOf(type.errors);
182
- });
183
-
184
- test('should accept authorization activity payload', () => {
185
- const payload = {
186
- id: generateActivityId(),
187
- type: 'authorization' as const,
188
- performedBy: {
189
- type: 'system' as const,
190
- identifier: 'permission-service',
191
- },
192
- message: 'string',
193
- status: 'success',
194
- source: 'api-gateway',
195
- isMutateable: false,
196
- createdAt: new Date().toISOString(),
197
- updatedAt: new Date().toISOString(),
198
- metadata: { action: 'read' },
199
- };
200
-
201
- const result = ActivityPayloadSchema(payload);
202
- expect(result).not.toBeInstanceOf(type.errors);
203
- });
204
-
205
- test('should accept operation activity payload', () => {
206
- const payload = {
207
- id: generateActivityId(),
208
- type: 'operation' as const,
209
- performedBy: {
210
- type: 'automation' as const,
211
- identifier: 'backup-service',
212
- },
213
- operation: 'create',
214
- target: 'target-id',
215
- message: 'string',
216
- source: 'scheduler',
217
- isMutateable: true,
218
- createdAt: new Date().toISOString(),
219
- updatedAt: new Date().toISOString(),
220
- metadata: { backup_type: 'full' },
221
- };
222
-
223
- const result = ActivityPayloadSchema(payload);
224
- expect(result).not.toBeInstanceOf(type.errors);
225
- });
226
-
227
- test('should accept unknown activity payload', () => {
228
- const payload = {
229
- id: generateActivityId(),
230
- type: 'unknown' as const,
231
- performedBy: {
232
- type: 'integration' as const,
233
- identifier: 'webhook-handler',
234
- },
235
- message: 'string',
236
- source: 'external-webhook',
237
- isMutateable: true,
238
- createdAt: new Date().toISOString(),
239
- updatedAt: new Date().toISOString(),
240
- metadata: { webhook_id: 'wh_123' },
241
- };
242
-
243
- const result = ActivityPayloadSchema(payload);
244
- expect(result).not.toBeInstanceOf(type.errors);
245
- });
246
-
247
- test('should reject invalid activity type in payload', () => {
248
- const payload = {
249
- id: generateActivityId(),
250
- type: 'invalid_type',
251
- performedBy: {
252
- type: 'system' as const,
253
- identifier: 'test',
254
- },
255
- source: 'test',
256
- isMutateable: true,
257
- createdAt: new Date().toISOString(),
258
- updatedAt: new Date().toISOString(),
259
- metadata: {},
260
- };
261
-
262
- const result = ActivityPayloadSchema(payload);
263
- expect(result).toBeInstanceOf(type.errors);
264
- });
265
-
266
- test('should reject payload with invalid date format', () => {
267
- const payload = {
268
- id: generateActivityId(),
269
- type: 'note' as const,
270
- message: 'Test note',
271
- performedBy: {
272
- type: 'identity' as const,
273
- identifier: 'user@example.com',
274
- },
275
- source: 'web-app',
276
- isMutateable: true,
277
- createdAt: 'invalid-date',
278
- updatedAt: new Date().toISOString(),
279
- metadata: {},
280
- };
281
-
282
- const result = ActivityPayloadSchema(payload);
283
- expect(result).toBeInstanceOf(type.errors);
284
- });
285
- });
286
-
287
- describe('InsertActivityPayloadSchema', () => {
288
- test('should accept valid insert payload', () => {
289
- const payload = {
290
- type: 'note' as const,
291
- message: 'New note',
292
- performedBy: {
293
- type: 'identity' as const,
294
- identifier: 'user@example.com',
295
- },
296
- metadata: { priority: 'high' },
297
- };
298
-
299
- const result = InsertActivityPayloadSchema(payload);
300
- expect(result).not.toBeInstanceOf(type.errors);
301
- });
302
-
303
- test('should accept minimal insert payload', () => {
304
- const payload = {
305
- type: 'note' as const,
306
- message: 'Simple note',
307
- };
308
-
309
- const result = InsertActivityPayloadSchema(payload);
310
- expect(result).not.toBeInstanceOf(type.errors);
311
- // Should generate ID automatically
312
- expect((result as InsertActivityPayload).id).toMatch(/^act_/);
313
- });
314
-
315
- test('should reject insert payload missing required fields', () => {
316
- const payload = {
317
- type: 'note' as const,
318
- // missing message
319
- };
320
-
321
- const result = InsertActivityPayloadSchema(payload);
322
- expect(result).toBeInstanceOf(type.errors);
323
- });
324
-
325
- test('should reject insert payload with invalid type', () => {
326
- const payload = {
327
- type: 'invalid_type',
328
- message: 'Test message',
329
- };
330
-
331
- const result = InsertActivityPayloadSchema(payload);
332
- expect(result).toBeInstanceOf(type.errors);
333
- });
334
- });
335
-
336
- describe('UpdateActivityPayloadSchema', () => {
337
- test('should accept update payload with message', () => {
338
- const payload = {
339
- type: 'note' as const,
340
- message: 'Updated message',
341
- metadata: { updated: true },
342
- };
343
-
344
- const result = UpdateActivityPayloadSchema(payload);
345
- expect(result).not.toBeInstanceOf(type.errors);
346
- expect(result).toEqual(payload);
347
- });
348
-
349
- test('should accept update payload without message', () => {
350
- const payload = {
351
- type: 'note' as const,
352
- performedBy: {
353
- type: 'automation' as const,
354
- identifier: 'update-service',
355
- },
356
- metadata: { auto_updated: true },
357
- };
358
-
359
- const result = UpdateActivityPayloadSchema(payload);
360
- expect(result).not.toBeInstanceOf(type.errors);
361
- });
362
-
363
- test('should accept minimal update payload', () => {
364
- const payload = {
365
- type: 'note' as const,
366
- };
367
-
368
- const result = UpdateActivityPayloadSchema(payload);
369
- expect(result).not.toBeInstanceOf(type.errors);
370
- });
371
-
372
- test('should reject update payload with invalid type', () => {
373
- const payload = {
374
- type: 'invalid_type',
375
- message: 'Updated message',
376
- };
377
-
378
- const result = UpdateActivityPayloadSchema(payload);
379
- expect(result).toBeInstanceOf(type.errors);
380
- });
381
-
382
- test('should accept update with only metadata', () => {
383
- const payload = {
384
- type: 'note' as const,
385
- metadata: { version: '2.0' },
386
- };
387
-
388
- const result = UpdateActivityPayloadSchema(payload);
389
- expect(result).not.toBeInstanceOf(type.errors);
390
- });
391
- });
392
- });