serene-core-server 0.1.3 → 0.1.4

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 (69) hide show
  1. package/dist/src/index.d.ts +1 -0
  2. package/dist/src/index.js +1 -0
  3. package/package.json +4 -1
  4. package/prisma/schema.prisma +0 -572
  5. package/prisma.config.ts +0 -14
  6. package/src/apollo/README.md +0 -4
  7. package/src/apollo/resolvers/mutations/mailing-lists.ts +0 -30
  8. package/src/apollo/resolvers/mutations/user-preferences.ts +0 -33
  9. package/src/apollo/resolvers/mutations/users.ts +0 -61
  10. package/src/apollo/resolvers/queries/access.ts +0 -23
  11. package/src/apollo/resolvers/queries/profile.ts +0 -24
  12. package/src/apollo/resolvers/queries/quotas.ts +0 -25
  13. package/src/apollo/resolvers/queries/tech.ts +0 -42
  14. package/src/apollo/resolvers/queries/user-preferences.ts +0 -34
  15. package/src/apollo/resolvers/queries/users.ts +0 -33
  16. package/src/apollo/typedefs/typedefs.ts +0 -139
  17. package/src/db.ts +0 -19
  18. package/src/index.ts +0 -54
  19. package/src/models/chat/chat-message-created-model.ts +0 -126
  20. package/src/models/chat/chat-message-model.ts +0 -678
  21. package/src/models/chat/chat-participant-model.ts +0 -248
  22. package/src/models/chat/chat-session-model.ts +0 -397
  23. package/src/models/chat/chat-settings-model.ts +0 -336
  24. package/src/models/feature-flags/feature-flag-model.ts +0 -198
  25. package/src/models/instances/instance-model.ts +0 -673
  26. package/src/models/instances/instance-setting-model.ts +0 -235
  27. package/src/models/mailing-lists/mailing-list-model.ts +0 -177
  28. package/src/models/mailing-lists/mailing-list-subscriber-model.ts +0 -194
  29. package/src/models/quotas/resource-quota-total-model.ts +0 -243
  30. package/src/models/quotas/resource-quota-usage-model.ts +0 -219
  31. package/src/models/tech/rate-limited-api-event-model.ts +0 -190
  32. package/src/models/tech/rate-limited-api-model.ts +0 -171
  33. package/src/models/tech/tech-model.ts +0 -360
  34. package/src/models/tech/tech-provider-api-key-model.ts +0 -289
  35. package/src/models/tech/tech-provider-model.ts +0 -247
  36. package/src/models/users/external-user-integration-model.ts +0 -236
  37. package/src/models/users/user-error-model.ts +0 -219
  38. package/src/models/users/user-error-summary-model.ts +0 -216
  39. package/src/models/users/user-group-member-model.ts +0 -233
  40. package/src/models/users/user-group-model.ts +0 -174
  41. package/src/models/users/user-model.ts +0 -172
  42. package/src/models/users/user-preference-model.ts +0 -285
  43. package/src/models/users/user-profile-model.ts +0 -207
  44. package/src/services/access/access-service.ts +0 -36
  45. package/src/services/access/encrypt-service.ts +0 -122
  46. package/src/services/api-usage/api-usage-base-service.ts +0 -95
  47. package/src/services/console/service.ts +0 -24
  48. package/src/services/db/pg/pg-estimate-size-service.ts +0 -119
  49. package/src/services/files/types.ts +0 -7
  50. package/src/services/files/walk-dir-service.ts +0 -135
  51. package/src/services/locale/countries.ts +0 -483
  52. package/src/services/mailing-lists/mailing-list-subscriber-service.ts +0 -54
  53. package/src/services/process/sleep.ts +0 -7
  54. package/src/services/quotas/mutate-service.ts +0 -66
  55. package/src/services/quotas/query-service.ts +0 -197
  56. package/src/services/quotas/utils-service.ts +0 -29
  57. package/src/services/tech/tech-provider-mutate-service.ts +0 -136
  58. package/src/services/tech/tech-query-service.ts +0 -93
  59. package/src/services/user-preference/service.ts +0 -110
  60. package/src/services/users/external-user-integration-service.ts +0 -51
  61. package/src/services/users/profile-service.ts +0 -513
  62. package/src/services/users/service.ts +0 -293
  63. package/src/services/users/user-error-service.ts +0 -74
  64. package/src/services/users/users-group-service.ts +0 -85
  65. package/src/services/utils/field-naming-service.ts +0 -78
  66. package/src/services/utils/string-utils-service.ts +0 -48
  67. package/src/types/errors.ts +0 -18
  68. package/src/types/user-types.ts +0 -19
  69. package/tsconfig.json +0 -25
@@ -49,6 +49,7 @@ export * from './services/users/profile-service';
49
49
  export * from './services/users/service';
50
50
  export * from './services/users/user-error-service';
51
51
  export * from './services/users/users-group-service';
52
+ export * from './services/utils/field-naming-service';
52
53
  export * from './services/utils/string-utils-service';
53
54
  export * from './types/errors';
54
55
  export * from './types/user-types';
package/dist/src/index.js CHANGED
@@ -49,6 +49,7 @@ export * from './services/users/profile-service';
49
49
  export * from './services/users/service';
50
50
  export * from './services/users/user-error-service';
51
51
  export * from './services/users/users-group-service';
52
+ export * from './services/utils/field-naming-service';
52
53
  export * from './services/utils/string-utils-service';
53
54
  export * from './types/errors';
54
55
  export * from './types/user-types';
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "serene-core-server",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/src/index.js",
5
5
  "types": "./dist/src/index.d.ts",
6
6
  "exports": {
7
7
  ".": "./dist/src/index.js"
8
8
  },
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "dependencies": {
10
13
  "@inquirer/prompts": "^8.2.1",
11
14
  "@prisma/adapter-pg": "^7.5.0",
@@ -1,572 +0,0 @@
1
- // This is your Prisma schema file,
2
- // learn more about it in the docs: https://pris.ly/d/prisma-schema
3
-
4
- // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
5
- // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
6
-
7
- generator client {
8
- provider = "prisma-client-js"
9
- output = "../prisma/generated/prisma"
10
- }
11
-
12
- datasource db {
13
- provider = "postgresql"
14
- schemas = ["public"]
15
- }
16
-
17
- // NextAuth
18
- model Account {
19
- id String @id @default(cuid())
20
- userId String
21
- type String
22
- provider String
23
- providerAccountId String
24
- refresh_token String? @db.Text
25
- access_token String? @db.Text
26
- expires_at Int?
27
- token_type String?
28
- scope String?
29
- id_token String? @db.Text
30
- session_state String?
31
-
32
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
33
-
34
- @@unique([provider, providerAccountId])
35
- @@schema("public")
36
- }
37
-
38
- model Session {
39
- id String @id @default(cuid())
40
- sessionToken String @unique
41
- userId String
42
- expires DateTime
43
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
44
-
45
- @@schema("public")
46
- }
47
-
48
- model User {
49
- id String @id @default(cuid())
50
- name String?
51
- email String? @unique
52
- emailVerified DateTime?
53
- image String?
54
-
55
- accounts Account[]
56
- sessions Session[]
57
-
58
- // Link to UserProfile
59
- userProfiles UserProfile[]
60
-
61
- @@schema("public")
62
- }
63
-
64
- model VerificationToken {
65
- identifier String
66
- token String @unique
67
- expires DateTime
68
-
69
- @@unique([identifier, token])
70
- @@schema("public")
71
- }
72
-
73
- // Serene Core
74
-
75
- // User Management (non-NextAuth)
76
- model ExternalUserIntegration {
77
- id String @id @default(cuid())
78
- userProfileId String @map("user_profile_id")
79
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
80
- externalIntegrationUserId String @map("external_integration_user_id")
81
- externalIntegration String @map("external_integration")
82
-
83
- @@index([userProfileId])
84
- @@unique([externalIntegrationUserId, externalIntegration])
85
- @@map("external_user_integration")
86
- @@schema("public")
87
- }
88
-
89
- model UserGroup {
90
- id String @id @default(cuid())
91
- ownerUserProfileId String @map("owner_user_profile_id")
92
- ownerUserProfile UserProfile @relation(fields: [ownerUserProfileId], references: [id])
93
- name String @unique
94
- created DateTime @default(now())
95
- updated DateTime @updatedAt
96
-
97
- ofUserGroupMembers UserGroupMember[]
98
-
99
- @@unique([ownerUserProfileId, name], name: "user_group_uq")
100
- @@map("user_group")
101
- @@schema("public")
102
- }
103
-
104
- model UserGroupMember {
105
- id String @id @default(cuid())
106
- userGroupId String @map("user_group_id")
107
- userGroup UserGroup @relation(fields: [userGroupId], references: [id])
108
- userProfileId String @map("user_profile_id")
109
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
110
- isGroupAdmin Boolean @map("is_group_admin")
111
- created DateTime @default(now())
112
-
113
- @@unique([userProfileId, userGroupId], name: "user_group_member_uq")
114
- @@map("user_group_member")
115
- @@schema("public")
116
- }
117
-
118
- model UserPreference {
119
- id String @id @default(cuid())
120
- userProfileId String @map("user_profile_id")
121
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
122
- category String
123
- key String
124
- value String?
125
- values String[]
126
- created DateTime @default(now())
127
-
128
- @@unique([userProfileId, key], name: "user_preference_uq")
129
- @@map("user_preference")
130
- @@schema("public")
131
- }
132
-
133
- model UserProfile {
134
- id String @id @default(cuid())
135
- userId String? @map("user_id") @unique // Map to NextAuth's User model
136
- user User? @relation(fields: [userId], references: [id])
137
- isAdmin Boolean @map("is_admin")
138
- ownerType String? @map("owner_type")
139
- roles String[]
140
- created DateTime @default(now())
141
- updated DateTime @updatedAt
142
- deletePending DateTime? @map("delete_pending") // Start date/time of delete pending
143
-
144
- ofAgentUsers AgentUser[]
145
- ofChatMessagesCreated ChatMessageCreated[]
146
- ofChatParticipants ChatParticipant[]
147
- ofChatSessions ChatSession[]
148
- ofChatSettings ChatSettings[]
149
- ofExternalUserIntegrations ExternalUserIntegration[]
150
- ofFeatureFlags FeatureFlag[]
151
- ofInstances Instance[]
152
- ofRateLimitedApiEvents RateLimitedApiEvent[]
153
- ofResourceQuotaTotals ResourceQuotaTotal[]
154
- ofResourceQuotaUsages ResourceQuotaUsage[]
155
- ofTipGotIts TipGotIt[]
156
- ofUserGroups UserGroup[]
157
- ofUserGroupMembers UserGroupMember[]
158
- ofUserPreferences UserPreference[]
159
- ofUserErrors UserError[]
160
- ofEndUserErrors UserError[] @relation("end_user_profile")
161
- ofUserErrorSummaries UserErrorSummary[]
162
-
163
- @@map("user_profile")
164
- @@schema("public")
165
- }
166
-
167
- // Chat
168
-
169
- model AgentUser {
170
- id String @id @default(cuid())
171
- userProfileId String @map("user_profile_id") @unique
172
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
173
- uniqueRefId String? @map("unique_ref_id") @unique
174
- name String
175
- role String
176
- maxPrevMessages Int? @map("max_prev_messages") // The max previous messages in the session to include in the prompt
177
- defaultPrompt String? @map("default_prompt")
178
-
179
- ofChatSettings ChatSettings[]
180
-
181
- @@map("agent_user")
182
- @@schema("public")
183
- }
184
-
185
- model ChatMessage {
186
- // chatSessionId is optional to allow for direct messages.
187
- id String @id @default(cuid())
188
- chatSessionId String? @map("chat_session_id")
189
- chatSession ChatSession? @relation(fields: [chatSessionId], references: [id])
190
- replyToId String? @map("reply_to_id")
191
- fromChatParticipantId String @map("from_chat_participant_id")
192
- fromChatParticipant ChatParticipant @relation("fromChatParticipant", fields: [fromChatParticipantId], references: [id])
193
- toChatParticipantId String? @map("to_chat_participant_id")
194
- toChatParticipant ChatParticipant? @relation("toChatParticipant", fields: [toChatParticipantId], references: [id])
195
- externalId String? @map("external_id")
196
- sentByAi Boolean @map("sent_by_ai")
197
- message String
198
- created DateTime @default(now())
199
- updated DateTime @updatedAt
200
-
201
- @@index([chatSessionId])
202
- @@index([created])
203
- @@unique([chatSessionId, externalId])
204
- @@map("chat_message")
205
- @@schema("public")
206
- }
207
-
208
- model ChatMessageCreated {
209
- // Used for quotas and rate-limiting, as ChatMessage can be deleted from as
210
- // needed. Possibly add a FK from ChatMessage if costs per actual message
211
- // ever need to be tracked (when the ChatMessage is available).
212
- id String @id @default(cuid())
213
- userProfileId String @map("user_profile_id")
214
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
215
- instanceId String? @map("instance_id")
216
- instance Instance? @relation(fields: [instanceId], references: [id])
217
- techId String @map("tech_id")
218
- tech Tech @relation(fields: [techId], references: [id])
219
- sentByAi Boolean @map("sent_by_ai")
220
- inputTokens Int @map("input_tokens")
221
- outputTokens Int @map("output_tokens")
222
- costInCents Int @map("cost_in_cents")
223
- created DateTime @default(now())
224
-
225
- @@index([created])
226
- @@unique([userProfileId, created])
227
- @@map("chat_message_created")
228
- @@schema("public")
229
- }
230
-
231
- model ChatParticipant {
232
- // An optional projectId is available for use with inter-project chats.
233
- id String @id @default(cuid())
234
- chatSessionId String @map("chat_session_id")
235
- chatSession ChatSession @relation(fields: [chatSessionId], references: [id])
236
- userProfileId String @map("user_profile_id")
237
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
238
-
239
- ofChatMessagesFrom ChatMessage[] @relation("fromChatParticipant")
240
- ofChatMessagesTo ChatMessage[] @relation("toChatParticipant")
241
-
242
- @@index([chatSessionId])
243
- @@map("chat_participant")
244
- @@schema("public")
245
- }
246
-
247
- model ChatSession {
248
- id String @id @default(cuid())
249
- chatSettingsId String @map("chat_settings_id")
250
- chatSettings ChatSettings @relation(fields: [chatSettingsId], references: [id])
251
- instanceId String? @map("instance_id")
252
- instance Instance? @relation(fields: [instanceId], references: [id])
253
- status String @db.Char(1)
254
- isEncryptedAtRest Boolean @map("is_encrypted_at_rest")
255
- token String
256
- name String?
257
- externalIntegration String? @map("external_integration")
258
- externalId String? @map("external_id")
259
- createdById String @map("created_by_id")
260
- createdByUserProfile UserProfile @relation(fields: [createdById], references: [id])
261
- created DateTime @default(now())
262
- updated DateTime @updatedAt
263
-
264
- ofChatMessages ChatMessage[]
265
- ofChatParticipants ChatParticipant[]
266
-
267
- @@index([created])
268
- @@index([externalId])
269
- @@map("chat_session")
270
- @@schema("public")
271
- }
272
-
273
- model ChatSettings {
274
- id String @id @default(cuid())
275
- baseChatSettingsId String? @map("base_chat_settings_id")
276
- baseChatSettings ChatSettings? @relation("base", fields: [baseChatSettingsId], references: [id])
277
- status String @db.Char(1)
278
- isEncryptedAtRest Boolean @map("is_encrypted_at_rest")
279
- isJsonMode Boolean @map("is_json_mode")
280
- isPinned Boolean @map("is_pinned")
281
- name String? @unique // Only unique for baseChatSettingsId == null
282
- agentUserId String @map("agent_user_id")
283
- agentUser AgentUser @relation(fields: [agentUserId], references: [id])
284
- prompt String?
285
- agentRole String? @map("agent_role")
286
- appCustom Json? @map("app_custom") // For additional fields/values (app specific)
287
- createdById String @map("created_by_id")
288
- createdByUserProfile UserProfile @relation(fields: [createdById], references: [id])
289
- created DateTime @default(now())
290
- updated DateTime @updatedAt
291
-
292
- ofBaseChatSettings ChatSettings[] @relation("base")
293
- ofChatSessions ChatSession[]
294
-
295
- @@map("chat_settings")
296
- @@schema("public")
297
- }
298
-
299
- // Feature flags
300
-
301
- model FeatureFlag {
302
- id String @id @default(cuid())
303
- userProfileId String? @map("user_profile_id")
304
- userProfile UserProfile? @relation(fields: [userProfileId], references: [id])
305
- instanceId String? @map("instance_id")
306
- instance Instance? @relation(fields: [instanceId], references: [id])
307
- name String
308
- enabled Boolean
309
-
310
- @@map("feature_flag")
311
- @@schema("public")
312
- }
313
-
314
- // Instances
315
-
316
- model Instance {
317
- // An instance is a project
318
- id String @id @default(cuid())
319
- parentId String? @map("parent_id")
320
- parent Instance? @relation("parent", fields: [parentId], references: [id])
321
- userProfileId String @map("user_profile_id")
322
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
323
- status String @db.Char(1)
324
- key String
325
- name String
326
- created DateTime @default(now())
327
- updated DateTime @updatedAt
328
- // Additional fields (should be moved to InstanceSetting)
329
- instanceType String @map("instance_type") @db.Char(1) // P (project), E (environment)
330
- projectType String? @map("project_type")
331
- isDefault Boolean @map("is_default")
332
- isDemo Boolean @map("is_demo")
333
- publicAccess String? @map("public_access") @db.Char(1) // E.g. R/W
334
- // basePathDocNodeId String? @map("base_path_doc_node_id")
335
- // basePathDocNode DocNode? @relation("base_path", fields: [basePathDocNodeId], references: [id])
336
- // envVersionBranchId String? @map("env_version_branch_id")
337
- // envVersionBranch VersionBranch? @relation("env_version_branch", fields: [envVersionBranchId], references: [id])
338
-
339
- ofChatMessagesCreated ChatMessageCreated[]
340
- ofChatSessions ChatSession[]
341
- ofFeatureFlags FeatureFlag[]
342
- ofInstances Instance[] @relation("parent")
343
- ofInstanceSettings InstanceSetting[]
344
- ofUserErrors UserError[]
345
- ofUserErrorSummaries UserErrorSummary[]
346
-
347
- @@unique([userProfileId, parentId, key])
348
- @@unique([userProfileId, parentId, name])
349
- @@map("instance")
350
- @@schema("public")
351
- }
352
-
353
- model InstanceSetting {
354
- id String @id @default(cuid())
355
- instanceId String @map("instance_id")
356
- instance Instance @relation(fields: [instanceId], references: [id])
357
- name String
358
- value String
359
- created DateTime @default(now())
360
- updated DateTime @updatedAt
361
-
362
- @@unique([instanceId, name], name: "instance_setting_uq")
363
- @@map("instance_setting")
364
- @@schema("public")
365
- }
366
-
367
- // Generic tech
368
- model RateLimitedApi {
369
- id String @id @default(cuid())
370
- techId String? @map("tech_id")
371
- tech Tech? @relation(fields: [techId], references: [id])
372
- ratePerMinute Int @map("rate_per_minute")
373
-
374
- ofRateLimitedApiEvents RateLimitedApiEvent[]
375
-
376
- @@map("rate_limited_api")
377
- @@schema("public")
378
- }
379
-
380
- model RateLimitedApiEvent {
381
- // Using a separate table from ChatMessage, because ChatMessage is populated
382
- // after the LLM API returns, but the rate limited event should be tracked
383
- // from just before the API call is made.
384
- id String @id @default(cuid())
385
- rateLimitedApiId String @map("api_rate_limited_id")
386
- rateLimitedApi RateLimitedApi @relation(fields: [rateLimitedApiId], references: [id])
387
- userProfileId String @map("user_profile_id")
388
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
389
- created DateTime @default(now())
390
-
391
- @@index([created])
392
- @@map("rate_limited_api_event")
393
- @@schema("public")
394
- }
395
-
396
- model ResourceQuotaTotal {
397
- // TODO: set the total quota monthly by looking at the Serene Store payment
398
- // records for the past 31 days. Used quota is kept at a daily level.
399
- id String @id @default(cuid())
400
- userProfileId String @map("user_profile_id")
401
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
402
- resource String // E.g. LLMs
403
- fromDay DateTime @map("from_day") @db.Date
404
- toDay DateTime @map("to_day") @db.Date
405
- quota Float // In cents
406
-
407
- @@unique([userProfileId, resource, fromDay, toDay])
408
- @@map("resource_quota_total")
409
- @@schema("public")
410
- }
411
-
412
- model ResourceQuotaUsage {
413
- id String @id @default(cuid())
414
- userProfileId String @map("user_profile_id")
415
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
416
- resource String // E.g. LLMs
417
- day DateTime @db.Date
418
- usage Float // In cents
419
- created DateTime @default(now())
420
- updated DateTime @updatedAt
421
-
422
- @@unique([userProfileId, resource, day])
423
- @@map("resource_quota_usage")
424
- @@schema("public")
425
- }
426
-
427
- model Tech {
428
- id String @id @default(cuid())
429
- techProviderId String @map("tech_provider_id")
430
- techProvider TechProvider @relation(fields: [techProviderId], references: [id])
431
- status String @db.Char(1)
432
- variantName String @map("variant_name") @unique
433
- resource String
434
- model String?
435
- protocol String? // E.g. for LLMs 'OpenAI' or 'Gemini'
436
- pricingTier String @map("pricing_tier")
437
- isDefaultProvider Boolean @map("is_default_provider")
438
- isAdminOnly Boolean @map("is_admin_only")
439
-
440
- ofChatMessagesCreated ChatMessageCreated[]
441
- ofRateLimitedApis RateLimitedApi[]
442
-
443
- @@map("tech")
444
- @@schema("public")
445
- }
446
-
447
- model TechProvider {
448
- id String @id @default(cuid())
449
- status String @db.Char(1)
450
- name String @unique
451
- baseUrl String? @map("base_url")
452
- provides String[]
453
-
454
- ofTechs Tech[]
455
- ofTechProviderApiKeys TechProviderApiKey[]
456
-
457
- @@map("tech_provider")
458
- @@schema("public")
459
- }
460
-
461
- model TechProviderApiKey {
462
- id String @id @default(cuid())
463
- techProviderId String @map("tech_provider_id")
464
- techProvider TechProvider @relation(fields: [techProviderId], references: [id])
465
- status String @db.Char(1)
466
- name String
467
- accountEmail String? @map("account_email")
468
- apiKey String @map("api_key")
469
- pricingTier String? @map("pricing_tier")
470
-
471
- @@unique([techProviderId, name])
472
- @@unique([techProviderId, apiKey])
473
- @@map("tech_provider_api_key")
474
- @@schema("public")
475
- }
476
-
477
- // Mailing lists
478
-
479
- model MailingList {
480
- id String @id @default(cuid())
481
- name String @unique
482
- title String @unique
483
- created DateTime @default(now())
484
- updated DateTime @updatedAt
485
-
486
- ofMailingListSubscribers MailingListSubscriber[]
487
-
488
- @@map("mailing_list")
489
- @@schema("public")
490
- }
491
-
492
- model MailingListSubscriber {
493
- id String @id @default(cuid())
494
- mailingListId String @map("mailing_list_id")
495
- mailingList MailingList @relation(fields: [mailingListId], references: [id])
496
- email String
497
- firstName String?
498
- verificationCode String? @map("verification_code")
499
- verified DateTime?
500
- created DateTime @default(now())
501
- updated DateTime @updatedAt
502
-
503
- @@unique([mailingListId, email])
504
- @@map("mailing_list_subscriber")
505
- @@schema("public")
506
- }
507
-
508
- // Tips
509
-
510
- model Tip {
511
- id String @id @default(cuid())
512
- name String @unique
513
- tags String[]
514
-
515
- ofTipGotIts TipGotIt[]
516
-
517
- @@index([tags])
518
- @@map("tip")
519
- @@schema("public")
520
- }
521
-
522
- model TipGotIt {
523
- id String @id @default(cuid())
524
- tipId String @map("tip_id")
525
- tip Tip @relation(fields: [tipId], references: [id])
526
- userProfileId String @map("user_profile_id")
527
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
528
-
529
- @@unique([tipId, userProfileId], name: "tip_got_it_uq")
530
- @@index([userProfileId])
531
- @@map("tip_got_it")
532
- @@schema("public")
533
- }
534
-
535
- // User-specific
536
-
537
- model UserError {
538
- id String @id @default(cuid())
539
- userErrorSummaryId String @map("user_error_summary_id")
540
- userErrorSummary UserErrorSummary @relation(fields: [userErrorSummaryId], references: [id])
541
- userProfileId String @map("user_profile_id")
542
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
543
- endUserProfileId String? @map("end_user_profile_id")
544
- endUserProfile UserProfile? @relation("end_user_profile", fields: [endUserProfileId], references: [id])
545
- instanceId String? @map("instance_id")
546
- instance Instance? @relation(fields: [instanceId], references: [id])
547
- origin String
548
- message String
549
- techMessage String? @map("tech_message") // Meant for developers only
550
- created DateTime @default(now())
551
- updated DateTime @updatedAt
552
-
553
- @@map("user_error")
554
- @@schema("public")
555
- }
556
-
557
- model UserErrorSummary {
558
- id String @id @default(cuid())
559
- userProfileId String @map("user_profile_id")
560
- userProfile UserProfile @relation(fields: [userProfileId], references: [id])
561
- instanceId String? @map("instance_id")
562
- instance Instance? @relation(fields: [instanceId], references: [id])
563
- origin String?
564
- message String // Abstracts UserError.message (no user or time specific info)
565
- count Int
566
-
567
- ofUserErrors UserError[]
568
-
569
- @@unique([userProfileId, instanceId, origin, message])
570
- @@map("user_error_summary")
571
- @@schema("public")
572
- }
package/prisma.config.ts DELETED
@@ -1,14 +0,0 @@
1
- // This file was generated by Prisma, and assumes you have installed the following:
2
- // npm install --save-dev prisma dotenv
3
- import "dotenv/config";
4
- import { defineConfig } from "prisma/config";
5
-
6
- export default defineConfig({
7
- schema: "prisma",
8
- migrations: {
9
- path: "prisma/migrations",
10
- },
11
- datasource: {
12
- url: process.env["DATABASE_URL"],
13
- },
14
- });
@@ -1,4 +0,0 @@
1
- Note that the typedefs and resolvers listed here are for reference use. They
2
- should be copied and pasted to your project. This is because server-side Apollo
3
- GraphQL sometimes doesn't modularize very easily.
4
-
@@ -1,30 +0,0 @@
1
- import { MailingListSubscriberService } from '../../../services/mailing-lists/mailing-list-subscriber-service'
2
-
3
- // Services
4
- const mailingListSubscriberService = new MailingListSubscriberService()
5
-
6
- // Factory of resolvers
7
- // Note: prisma must be passed into the GraphQL server's context
8
- export function sereneCoreMailingListsMutationResolvers() {
9
- return {
10
- Mutation: {
11
- upsertUserPreference: async (
12
- parent: any,
13
- args: any,
14
- context: any,
15
- info: any
16
- ) => {
17
- try {
18
- return await
19
- mailingListSubscriberService.subscribe(
20
- context.prisma,
21
- args.mailingListName,
22
- args.email,
23
- args.firstName)
24
- } catch (error) {
25
- console.error(`upsertUserPreference: ${error}`)
26
- }
27
- },
28
- },
29
- }
30
- }