@friggframework/schemas 2.0.0-next.30

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.
@@ -0,0 +1,445 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://schemas.friggframework.org/core-models.schema.json",
4
+ "title": "Frigg Core Data Models",
5
+ "description": "Schema definitions for core Frigg data models including User, Entity, and Credential.",
6
+ "definitions": {
7
+ "objectId": {
8
+ "type": "string",
9
+ "description": "MongoDB ObjectId",
10
+ "pattern": "^[a-f0-9]{24}$"
11
+ },
12
+ "timestamp": {
13
+ "type": "string",
14
+ "description": "ISO 8601 timestamp",
15
+ "format": "date-time"
16
+ },
17
+ "userModel": {
18
+ "type": "object",
19
+ "description": "Frigg User model schema",
20
+ "required": ["_id"],
21
+ "properties": {
22
+ "_id": {
23
+ "$ref": "#/definitions/objectId",
24
+ "description": "Unique user identifier"
25
+ },
26
+ "email": {
27
+ "type": "string",
28
+ "description": "User email address",
29
+ "format": "email",
30
+ "maxLength": 255
31
+ },
32
+ "firstName": {
33
+ "type": "string",
34
+ "description": "User first name",
35
+ "maxLength": 100
36
+ },
37
+ "lastName": {
38
+ "type": "string",
39
+ "description": "User last name",
40
+ "maxLength": 100
41
+ },
42
+ "organization": {
43
+ "type": "string",
44
+ "description": "User organization",
45
+ "maxLength": 200
46
+ },
47
+ "role": {
48
+ "type": "string",
49
+ "description": "User role",
50
+ "enum": ["admin", "user", "developer", "viewer"],
51
+ "default": "user"
52
+ },
53
+ "permissions": {
54
+ "type": "array",
55
+ "description": "User permissions",
56
+ "items": {
57
+ "type": "string",
58
+ "enum": [
59
+ "integrations:read", "integrations:write", "integrations:delete",
60
+ "entities:read", "entities:write", "entities:delete",
61
+ "credentials:read", "credentials:write", "credentials:delete",
62
+ "users:read", "users:write", "users:delete",
63
+ "admin:all"
64
+ ]
65
+ },
66
+ "uniqueItems": true
67
+ },
68
+ "preferences": {
69
+ "type": "object",
70
+ "description": "User preferences and settings",
71
+ "properties": {
72
+ "theme": {
73
+ "type": "string",
74
+ "enum": ["light", "dark", "auto"],
75
+ "default": "light"
76
+ },
77
+ "language": {
78
+ "type": "string",
79
+ "pattern": "^[a-z]{2}(-[A-Z]{2})?$",
80
+ "default": "en"
81
+ },
82
+ "timezone": {
83
+ "type": "string",
84
+ "description": "User timezone",
85
+ "default": "UTC"
86
+ },
87
+ "notifications": {
88
+ "type": "object",
89
+ "properties": {
90
+ "email": {
91
+ "type": "boolean",
92
+ "default": true
93
+ },
94
+ "push": {
95
+ "type": "boolean",
96
+ "default": false
97
+ },
98
+ "integration_errors": {
99
+ "type": "boolean",
100
+ "default": true
101
+ }
102
+ },
103
+ "additionalProperties": false
104
+ }
105
+ },
106
+ "additionalProperties": false
107
+ },
108
+ "isActive": {
109
+ "type": "boolean",
110
+ "description": "Whether user account is active",
111
+ "default": true
112
+ },
113
+ "lastLogin": {
114
+ "$ref": "#/definitions/timestamp",
115
+ "description": "Last login timestamp"
116
+ },
117
+ "createdAt": {
118
+ "$ref": "#/definitions/timestamp",
119
+ "description": "User creation timestamp"
120
+ },
121
+ "updatedAt": {
122
+ "$ref": "#/definitions/timestamp",
123
+ "description": "Last update timestamp"
124
+ }
125
+ },
126
+ "additionalProperties": false
127
+ },
128
+ "credentialModel": {
129
+ "type": "object",
130
+ "description": "Frigg Credential model schema",
131
+ "required": ["_id", "userId", "subType"],
132
+ "properties": {
133
+ "_id": {
134
+ "$ref": "#/definitions/objectId",
135
+ "description": "Unique credential identifier"
136
+ },
137
+ "userId": {
138
+ "$ref": "#/definitions/objectId",
139
+ "description": "Associated user ID"
140
+ },
141
+ "subType": {
142
+ "type": "string",
143
+ "description": "Integration type for this credential",
144
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$",
145
+ "maxLength": 100
146
+ },
147
+ "externalId": {
148
+ "type": "string",
149
+ "description": "External system identifier",
150
+ "maxLength": 255
151
+ },
152
+ "auth_is_valid": {
153
+ "type": "boolean",
154
+ "description": "Whether authentication is currently valid",
155
+ "default": false
156
+ },
157
+ "authData": {
158
+ "type": "object",
159
+ "description": "Encrypted authentication data",
160
+ "properties": {
161
+ "access_token": {
162
+ "type": "string",
163
+ "description": "Encrypted access token"
164
+ },
165
+ "refresh_token": {
166
+ "type": "string",
167
+ "description": "Encrypted refresh token"
168
+ },
169
+ "token_type": {
170
+ "type": "string",
171
+ "description": "Token type",
172
+ "enum": ["Bearer", "Basic", "API-Key"],
173
+ "default": "Bearer"
174
+ },
175
+ "expires_at": {
176
+ "$ref": "#/definitions/timestamp",
177
+ "description": "Token expiration time"
178
+ },
179
+ "scope": {
180
+ "type": "string",
181
+ "description": "OAuth scope granted"
182
+ }
183
+ },
184
+ "additionalProperties": true
185
+ },
186
+ "metadata": {
187
+ "type": "object",
188
+ "description": "Additional credential metadata",
189
+ "properties": {
190
+ "integration_version": {
191
+ "type": "string",
192
+ "description": "Version of integration used"
193
+ },
194
+ "last_validated": {
195
+ "$ref": "#/definitions/timestamp",
196
+ "description": "Last validation timestamp"
197
+ },
198
+ "validation_errors": {
199
+ "type": "array",
200
+ "description": "Recent validation errors",
201
+ "items": {
202
+ "type": "object",
203
+ "properties": {
204
+ "error": {
205
+ "type": "string",
206
+ "description": "Error message"
207
+ },
208
+ "timestamp": {
209
+ "$ref": "#/definitions/timestamp",
210
+ "description": "Error timestamp"
211
+ },
212
+ "code": {
213
+ "type": "string",
214
+ "description": "Error code"
215
+ }
216
+ },
217
+ "required": ["error", "timestamp"]
218
+ }
219
+ }
220
+ },
221
+ "additionalProperties": true
222
+ },
223
+ "isActive": {
224
+ "type": "boolean",
225
+ "description": "Whether credential is active",
226
+ "default": true
227
+ },
228
+ "createdAt": {
229
+ "$ref": "#/definitions/timestamp",
230
+ "description": "Credential creation timestamp"
231
+ },
232
+ "updatedAt": {
233
+ "$ref": "#/definitions/timestamp",
234
+ "description": "Last update timestamp"
235
+ }
236
+ },
237
+ "additionalProperties": false
238
+ },
239
+ "entityModel": {
240
+ "type": "object",
241
+ "description": "Frigg Entity model schema",
242
+ "required": ["_id", "credentialId", "userId", "subType"],
243
+ "properties": {
244
+ "_id": {
245
+ "$ref": "#/definitions/objectId",
246
+ "description": "Unique entity identifier"
247
+ },
248
+ "credentialId": {
249
+ "$ref": "#/definitions/objectId",
250
+ "description": "Associated credential ID"
251
+ },
252
+ "userId": {
253
+ "$ref": "#/definitions/objectId",
254
+ "description": "Associated user ID"
255
+ },
256
+ "subType": {
257
+ "type": "string",
258
+ "description": "Entity subtype or category",
259
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_-]*$",
260
+ "maxLength": 100
261
+ },
262
+ "name": {
263
+ "type": "string",
264
+ "description": "Entity display name",
265
+ "maxLength": 255
266
+ },
267
+ "externalId": {
268
+ "type": "string",
269
+ "description": "External system identifier",
270
+ "maxLength": 255
271
+ },
272
+ "data": {
273
+ "type": "object",
274
+ "description": "Entity-specific data",
275
+ "additionalProperties": true
276
+ },
277
+ "config": {
278
+ "type": "object",
279
+ "description": "Entity configuration settings",
280
+ "properties": {
281
+ "sync_enabled": {
282
+ "type": "boolean",
283
+ "description": "Whether synchronization is enabled",
284
+ "default": true
285
+ },
286
+ "sync_direction": {
287
+ "type": "string",
288
+ "description": "Synchronization direction",
289
+ "enum": ["incoming", "outgoing", "bidirectional"],
290
+ "default": "bidirectional"
291
+ },
292
+ "sync_frequency": {
293
+ "type": "string",
294
+ "description": "Synchronization frequency",
295
+ "enum": ["real-time", "hourly", "daily", "weekly", "manual"],
296
+ "default": "hourly"
297
+ },
298
+ "field_mappings": {
299
+ "type": "object",
300
+ "description": "Field mapping configuration",
301
+ "patternProperties": {
302
+ "^[a-zA-Z][a-zA-Z0-9_]*$": {
303
+ "type": "string",
304
+ "description": "Target field mapping"
305
+ }
306
+ }
307
+ }
308
+ },
309
+ "additionalProperties": false
310
+ },
311
+ "status": {
312
+ "type": "string",
313
+ "description": "Entity status",
314
+ "enum": ["active", "inactive", "error", "syncing", "pending"],
315
+ "default": "active"
316
+ },
317
+ "lastSync": {
318
+ "$ref": "#/definitions/timestamp",
319
+ "description": "Last synchronization timestamp"
320
+ },
321
+ "syncErrors": {
322
+ "type": "array",
323
+ "description": "Recent synchronization errors",
324
+ "items": {
325
+ "type": "object",
326
+ "properties": {
327
+ "error": {
328
+ "type": "string",
329
+ "description": "Error message"
330
+ },
331
+ "timestamp": {
332
+ "$ref": "#/definitions/timestamp",
333
+ "description": "Error timestamp"
334
+ },
335
+ "code": {
336
+ "type": "string",
337
+ "description": "Error code"
338
+ },
339
+ "retryable": {
340
+ "type": "boolean",
341
+ "description": "Whether error is retryable",
342
+ "default": true
343
+ }
344
+ },
345
+ "required": ["error", "timestamp"]
346
+ }
347
+ },
348
+ "isActive": {
349
+ "type": "boolean",
350
+ "description": "Whether entity is active",
351
+ "default": true
352
+ },
353
+ "createdAt": {
354
+ "$ref": "#/definitions/timestamp",
355
+ "description": "Entity creation timestamp"
356
+ },
357
+ "updatedAt": {
358
+ "$ref": "#/definitions/timestamp",
359
+ "description": "Last update timestamp"
360
+ }
361
+ },
362
+ "additionalProperties": false
363
+ }
364
+ },
365
+ "type": "object",
366
+ "properties": {
367
+ "user": {
368
+ "$ref": "#/definitions/userModel"
369
+ },
370
+ "credential": {
371
+ "$ref": "#/definitions/credentialModel"
372
+ },
373
+ "entity": {
374
+ "$ref": "#/definitions/entityModel"
375
+ }
376
+ },
377
+ "examples": [
378
+ {
379
+ "user": {
380
+ "_id": "507f1f77bcf86cd799439011",
381
+ "email": "user@example.com",
382
+ "firstName": "John",
383
+ "lastName": "Doe",
384
+ "organization": "Example Corp",
385
+ "role": "user",
386
+ "permissions": ["integrations:read", "integrations:write"],
387
+ "preferences": {
388
+ "theme": "dark",
389
+ "language": "en",
390
+ "notifications": {
391
+ "email": true,
392
+ "integration_errors": true
393
+ }
394
+ },
395
+ "isActive": true,
396
+ "createdAt": "2023-01-01T00:00:00Z",
397
+ "updatedAt": "2023-01-01T00:00:00Z"
398
+ },
399
+ "credential": {
400
+ "_id": "507f1f77bcf86cd799439012",
401
+ "userId": "507f1f77bcf86cd799439011",
402
+ "subType": "hubspot",
403
+ "externalId": "12345",
404
+ "auth_is_valid": true,
405
+ "authData": {
406
+ "access_token": "encrypted_access_token",
407
+ "refresh_token": "encrypted_refresh_token",
408
+ "token_type": "Bearer",
409
+ "expires_at": "2023-12-31T23:59:59Z",
410
+ "scope": "contacts companies deals"
411
+ },
412
+ "metadata": {
413
+ "integration_version": "2.0.0",
414
+ "last_validated": "2023-01-01T00:00:00Z"
415
+ },
416
+ "isActive": true,
417
+ "createdAt": "2023-01-01T00:00:00Z",
418
+ "updatedAt": "2023-01-01T00:00:00Z"
419
+ },
420
+ "entity": {
421
+ "_id": "507f1f77bcf86cd799439013",
422
+ "credentialId": "507f1f77bcf86cd799439012",
423
+ "userId": "507f1f77bcf86cd799439011",
424
+ "subType": "contact",
425
+ "name": "HubSpot Contacts",
426
+ "externalId": "hubspot_contacts_12345",
427
+ "config": {
428
+ "sync_enabled": true,
429
+ "sync_direction": "bidirectional",
430
+ "sync_frequency": "hourly",
431
+ "field_mappings": {
432
+ "email": "email",
433
+ "firstname": "first_name",
434
+ "lastname": "last_name"
435
+ }
436
+ },
437
+ "status": "active",
438
+ "lastSync": "2023-01-01T00:00:00Z",
439
+ "isActive": true,
440
+ "createdAt": "2023-01-01T00:00:00Z",
441
+ "updatedAt": "2023-01-01T00:00:00Z"
442
+ }
443
+ }
444
+ ]
445
+ }