serene-core-server 0.1.1

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 (315) hide show
  1. package/dist/apollo/resolvers/mutations/mailing-lists.d.ts +11 -0
  2. package/dist/apollo/resolvers/mutations/mailing-lists.js +30 -0
  3. package/dist/apollo/resolvers/mutations/user-preferences.d.ts +13 -0
  4. package/dist/apollo/resolvers/mutations/user-preferences.js +31 -0
  5. package/dist/apollo/resolvers/mutations/users.d.ts +28 -0
  6. package/dist/apollo/resolvers/mutations/users.js +44 -0
  7. package/dist/apollo/resolvers/queries/access.d.ts +11 -0
  8. package/dist/apollo/resolvers/queries/access.js +25 -0
  9. package/dist/apollo/resolvers/queries/profile.d.ts +11 -0
  10. package/dist/apollo/resolvers/queries/profile.js +25 -0
  11. package/dist/apollo/resolvers/queries/quotas.d.ts +21 -0
  12. package/dist/apollo/resolvers/queries/quotas.js +25 -0
  13. package/dist/apollo/resolvers/queries/tech.d.ts +5 -0
  14. package/dist/apollo/resolvers/queries/tech.js +35 -0
  15. package/dist/apollo/resolvers/queries/user-preferences.d.ts +5 -0
  16. package/dist/apollo/resolvers/queries/user-preferences.js +33 -0
  17. package/dist/apollo/resolvers/queries/users.d.ts +15 -0
  18. package/dist/apollo/resolvers/queries/users.js +28 -0
  19. package/dist/apollo/resolvers/resolvers.d.ts +20 -0
  20. package/dist/apollo/resolvers/resolvers.js +38 -0
  21. package/dist/apollo/typedefs/typedefs.d.ts +1 -0
  22. package/dist/apollo/typedefs/typedefs.js +142 -0
  23. package/dist/index.d.ts +52 -0
  24. package/dist/index.js +68 -0
  25. package/dist/models/chat/chat-message-created-model.d.ts +17 -0
  26. package/dist/models/chat/chat-message-created-model.js +113 -0
  27. package/dist/models/chat/chat-message-model.d.ts +44 -0
  28. package/dist/models/chat/chat-message-model.js +523 -0
  29. package/dist/models/chat/chat-participant-model.d.ts +39 -0
  30. package/dist/models/chat/chat-participant-model.js +211 -0
  31. package/dist/models/chat/chat-session-model.d.ts +92 -0
  32. package/dist/models/chat/chat-session-model.js +301 -0
  33. package/dist/models/chat/chat-settings-model.d.ts +87 -0
  34. package/dist/models/chat/chat-settings-model.js +261 -0
  35. package/dist/models/feature-flags/feature-flag-model.d.ts +40 -0
  36. package/dist/models/feature-flags/feature-flag-model.js +164 -0
  37. package/dist/models/instances/instance-model.d.ts +93 -0
  38. package/dist/models/instances/instance-model.js +432 -0
  39. package/dist/models/instances/instance-setting-model.d.ts +39 -0
  40. package/dist/models/instances/instance-setting-model.js +193 -0
  41. package/dist/models/mailing-lists/mailing-list-model.d.ts +34 -0
  42. package/dist/models/mailing-lists/mailing-list-model.js +154 -0
  43. package/dist/models/mailing-lists/mailing-list-subscriber-model.d.ts +36 -0
  44. package/dist/models/mailing-lists/mailing-list-subscriber-model.js +152 -0
  45. package/dist/models/quotas/resource-quota-total-model.d.ts +46 -0
  46. package/dist/models/quotas/resource-quota-total-model.js +200 -0
  47. package/dist/models/quotas/resource-quota-usage-model.d.ts +51 -0
  48. package/dist/models/quotas/resource-quota-usage-model.js +181 -0
  49. package/dist/models/tech/rate-limited-api-event-model.d.ts +25 -0
  50. package/dist/models/tech/rate-limited-api-event-model.js +161 -0
  51. package/dist/models/tech/rate-limited-api-model.d.ts +21 -0
  52. package/dist/models/tech/rate-limited-api-model.js +141 -0
  53. package/dist/models/tech/tech-model.d.ts +44 -0
  54. package/dist/models/tech/tech-model.js +268 -0
  55. package/dist/models/tech/tech-provider-api-key-model.d.ts +43 -0
  56. package/dist/models/tech/tech-provider-api-key-model.js +224 -0
  57. package/dist/models/tech/tech-provider-model.d.ts +28 -0
  58. package/dist/models/tech/tech-provider-model.js +197 -0
  59. package/dist/models/users/external-user-integration-model.d.ts +36 -0
  60. package/dist/models/users/external-user-integration-model.js +196 -0
  61. package/dist/models/users/user-error-model.d.ts +54 -0
  62. package/dist/models/users/user-error-model.js +173 -0
  63. package/dist/models/users/user-error-summary-model.d.ts +45 -0
  64. package/dist/models/users/user-error-summary-model.js +172 -0
  65. package/dist/models/users/user-group-member-model.d.ts +41 -0
  66. package/dist/models/users/user-group-member-model.js +193 -0
  67. package/dist/models/users/user-group-model.d.ts +27 -0
  68. package/dist/models/users/user-group-model.js +146 -0
  69. package/dist/models/users/user-model.d.ts +46 -0
  70. package/dist/models/users/user-model.js +153 -0
  71. package/dist/models/users/user-preference-model.d.ts +60 -0
  72. package/dist/models/users/user-preference-model.js +228 -0
  73. package/dist/models/users/user-profile-model.d.ts +58 -0
  74. package/dist/models/users/user-profile-model.js +173 -0
  75. package/dist/prisma.config.d.ts +3 -0
  76. package/dist/prisma.config.js +13 -0
  77. package/dist/services/access/access-service.d.ts +12 -0
  78. package/dist/services/access/access-service.js +44 -0
  79. package/dist/services/access/encrypt-service.d.ts +13 -0
  80. package/dist/services/access/encrypt-service.js +84 -0
  81. package/dist/services/api-usage/api-usage-base-service.d.ts +15 -0
  82. package/dist/services/api-usage/api-usage-base-service.js +75 -0
  83. package/dist/services/console/service.d.ts +7 -0
  84. package/dist/services/console/service.js +70 -0
  85. package/dist/services/db/pg/pg-estimate-size-service.d.ts +16 -0
  86. package/dist/services/db/pg/pg-estimate-size-service.js +90 -0
  87. package/dist/services/files/types.d.ts +6 -0
  88. package/dist/services/files/types.js +2 -0
  89. package/dist/services/files/walk-dir-service.d.ts +8 -0
  90. package/dist/services/files/walk-dir-service.js +94 -0
  91. package/dist/services/locale/countries.d.ts +6 -0
  92. package/dist/services/locale/countries.js +484 -0
  93. package/dist/services/mailing-lists/mailing-list-subscriber-service.d.ts +14 -0
  94. package/dist/services/mailing-lists/mailing-list-subscriber-service.js +45 -0
  95. package/dist/services/process/sleep.d.ts +2 -0
  96. package/dist/services/process/sleep.js +10 -0
  97. package/dist/services/quotas/mutate-service.d.ts +5 -0
  98. package/dist/services/quotas/mutate-service.js +54 -0
  99. package/dist/services/quotas/query-service.d.ts +27 -0
  100. package/dist/services/quotas/query-service.js +137 -0
  101. package/dist/services/quotas/utils-service.d.ts +4 -0
  102. package/dist/services/quotas/utils-service.js +28 -0
  103. package/dist/services/tech/tech-provider-mutate-service.d.ts +7 -0
  104. package/dist/services/tech/tech-provider-mutate-service.js +142 -0
  105. package/dist/services/tech/tech-query-service.d.ts +9 -0
  106. package/dist/services/tech/tech-query-service.js +77 -0
  107. package/dist/services/user-preference/service.d.ts +10 -0
  108. package/dist/services/user-preference/service.js +70 -0
  109. package/dist/services/users/external-user-integration-service.d.ts +9 -0
  110. package/dist/services/users/external-user-integration-service.js +42 -0
  111. package/dist/services/users/profile-service.d.ts +40 -0
  112. package/dist/services/users/profile-service.js +408 -0
  113. package/dist/services/users/service.d.ts +64 -0
  114. package/dist/services/users/service.js +187 -0
  115. package/dist/services/users/user-error-service.d.ts +4 -0
  116. package/dist/services/users/user-error-service.js +42 -0
  117. package/dist/services/users/users-group-service.d.ts +16 -0
  118. package/dist/services/users/users-group-service.js +68 -0
  119. package/dist/services/utils/string-utils-service.d.ts +5 -0
  120. package/dist/services/utils/string-utils-service.js +41 -0
  121. package/dist/src/apollo/resolvers/mutations/mailing-lists.d.ts +11 -0
  122. package/dist/src/apollo/resolvers/mutations/mailing-lists.js +19 -0
  123. package/dist/src/apollo/resolvers/mutations/user-preferences.d.ts +13 -0
  124. package/dist/src/apollo/resolvers/mutations/user-preferences.js +20 -0
  125. package/dist/src/apollo/resolvers/mutations/users.d.ts +28 -0
  126. package/dist/src/apollo/resolvers/mutations/users.js +33 -0
  127. package/dist/src/apollo/resolvers/queries/access.d.ts +11 -0
  128. package/dist/src/apollo/resolvers/queries/access.js +14 -0
  129. package/dist/src/apollo/resolvers/queries/profile.d.ts +11 -0
  130. package/dist/src/apollo/resolvers/queries/profile.js +14 -0
  131. package/dist/src/apollo/resolvers/queries/quotas.d.ts +21 -0
  132. package/dist/src/apollo/resolvers/queries/quotas.js +14 -0
  133. package/dist/src/apollo/resolvers/queries/tech.d.ts +5 -0
  134. package/dist/src/apollo/resolvers/queries/tech.js +24 -0
  135. package/dist/src/apollo/resolvers/queries/user-preferences.d.ts +5 -0
  136. package/dist/src/apollo/resolvers/queries/user-preferences.js +22 -0
  137. package/dist/src/apollo/resolvers/queries/users.d.ts +15 -0
  138. package/dist/src/apollo/resolvers/queries/users.js +17 -0
  139. package/dist/src/apollo/typedefs/typedefs.d.ts +1 -0
  140. package/dist/src/apollo/typedefs/typedefs.js +139 -0
  141. package/dist/src/db.d.ts +3 -0
  142. package/dist/src/db.js +11 -0
  143. package/dist/src/index.d.ts +52 -0
  144. package/dist/src/index.js +52 -0
  145. package/dist/src/models/chat/chat-message-created-model.d.ts +17 -0
  146. package/dist/src/models/chat/chat-message-created-model.js +92 -0
  147. package/dist/src/models/chat/chat-message-model.d.ts +44 -0
  148. package/dist/src/models/chat/chat-message-model.js +484 -0
  149. package/dist/src/models/chat/chat-participant-model.d.ts +39 -0
  150. package/dist/src/models/chat/chat-participant-model.js +178 -0
  151. package/dist/src/models/chat/chat-session-model.d.ts +92 -0
  152. package/dist/src/models/chat/chat-session-model.js +266 -0
  153. package/dist/src/models/chat/chat-settings-model.d.ts +87 -0
  154. package/dist/src/models/chat/chat-settings-model.js +230 -0
  155. package/dist/src/models/feature-flags/feature-flag-model.d.ts +40 -0
  156. package/dist/src/models/feature-flags/feature-flag-model.js +137 -0
  157. package/dist/src/models/instances/instance-model.d.ts +100 -0
  158. package/dist/src/models/instances/instance-model.js +466 -0
  159. package/dist/src/models/instances/instance-setting-model.d.ts +39 -0
  160. package/dist/src/models/instances/instance-setting-model.js +164 -0
  161. package/dist/src/models/mailing-lists/mailing-list-model.d.ts +34 -0
  162. package/dist/src/models/mailing-lists/mailing-list-model.js +127 -0
  163. package/dist/src/models/mailing-lists/mailing-list-subscriber-model.d.ts +36 -0
  164. package/dist/src/models/mailing-lists/mailing-list-subscriber-model.js +127 -0
  165. package/dist/src/models/quotas/resource-quota-total-model.d.ts +46 -0
  166. package/dist/src/models/quotas/resource-quota-total-model.js +170 -0
  167. package/dist/src/models/quotas/resource-quota-usage-model.d.ts +51 -0
  168. package/dist/src/models/quotas/resource-quota-usage-model.js +151 -0
  169. package/dist/src/models/tech/rate-limited-api-event-model.d.ts +25 -0
  170. package/dist/src/models/tech/rate-limited-api-event-model.js +134 -0
  171. package/dist/src/models/tech/rate-limited-api-model.d.ts +21 -0
  172. package/dist/src/models/tech/rate-limited-api-model.js +116 -0
  173. package/dist/src/models/tech/tech-model.d.ts +44 -0
  174. package/dist/src/models/tech/tech-model.js +239 -0
  175. package/dist/src/models/tech/tech-provider-api-key-model.d.ts +43 -0
  176. package/dist/src/models/tech/tech-provider-api-key-model.js +195 -0
  177. package/dist/src/models/tech/tech-provider-model.d.ts +28 -0
  178. package/dist/src/models/tech/tech-provider-model.js +170 -0
  179. package/dist/src/models/users/external-user-integration-model.d.ts +36 -0
  180. package/dist/src/models/users/external-user-integration-model.js +167 -0
  181. package/dist/src/models/users/user-error-model.d.ts +54 -0
  182. package/dist/src/models/users/user-error-model.js +146 -0
  183. package/dist/src/models/users/user-error-summary-model.d.ts +45 -0
  184. package/dist/src/models/users/user-error-summary-model.js +145 -0
  185. package/dist/src/models/users/user-group-member-model.d.ts +41 -0
  186. package/dist/src/models/users/user-group-member-model.js +164 -0
  187. package/dist/src/models/users/user-group-model.d.ts +27 -0
  188. package/dist/src/models/users/user-group-model.js +121 -0
  189. package/dist/src/models/users/user-model.d.ts +46 -0
  190. package/dist/src/models/users/user-model.js +126 -0
  191. package/dist/src/models/users/user-preference-model.d.ts +60 -0
  192. package/dist/src/models/users/user-preference-model.js +197 -0
  193. package/dist/src/models/users/user-profile-model.d.ts +58 -0
  194. package/dist/src/models/users/user-profile-model.js +146 -0
  195. package/dist/src/services/access/access-service.d.ts +12 -0
  196. package/dist/src/services/access/access-service.js +27 -0
  197. package/dist/src/services/access/encrypt-service.d.ts +13 -0
  198. package/dist/src/services/access/encrypt-service.js +79 -0
  199. package/dist/src/services/api-usage/api-usage-base-service.d.ts +15 -0
  200. package/dist/src/services/api-usage/api-usage-base-service.js +58 -0
  201. package/dist/src/services/console/service.d.ts +7 -0
  202. package/dist/src/services/console/service.js +18 -0
  203. package/dist/src/services/db/pg/pg-estimate-size-service.d.ts +16 -0
  204. package/dist/src/services/db/pg/pg-estimate-size-service.js +83 -0
  205. package/dist/src/services/files/types.d.ts +6 -0
  206. package/dist/src/services/files/types.js +1 -0
  207. package/dist/src/services/files/walk-dir-service.d.ts +8 -0
  208. package/dist/src/services/files/walk-dir-service.js +77 -0
  209. package/dist/src/services/locale/countries.d.ts +6 -0
  210. package/dist/src/services/locale/countries.js +481 -0
  211. package/dist/src/services/mailing-lists/mailing-list-subscriber-service.d.ts +14 -0
  212. package/dist/src/services/mailing-lists/mailing-list-subscriber-service.js +28 -0
  213. package/dist/src/services/process/sleep.d.ts +2 -0
  214. package/dist/src/services/process/sleep.js +6 -0
  215. package/dist/src/services/quotas/mutate-service.d.ts +5 -0
  216. package/dist/src/services/quotas/mutate-service.js +37 -0
  217. package/dist/src/services/quotas/query-service.d.ts +27 -0
  218. package/dist/src/services/quotas/query-service.js +116 -0
  219. package/dist/src/services/quotas/utils-service.d.ts +4 -0
  220. package/dist/src/services/quotas/utils-service.js +22 -0
  221. package/dist/src/services/tech/tech-provider-mutate-service.d.ts +7 -0
  222. package/dist/src/services/tech/tech-provider-mutate-service.js +85 -0
  223. package/dist/src/services/tech/tech-query-service.d.ts +9 -0
  224. package/dist/src/services/tech/tech-query-service.js +58 -0
  225. package/dist/src/services/user-preference/service.d.ts +10 -0
  226. package/dist/src/services/user-preference/service.js +49 -0
  227. package/dist/src/services/users/external-user-integration-service.d.ts +9 -0
  228. package/dist/src/services/users/external-user-integration-service.js +25 -0
  229. package/dist/src/services/users/profile-service.d.ts +40 -0
  230. package/dist/src/services/users/profile-service.js +385 -0
  231. package/dist/src/services/users/service.d.ts +64 -0
  232. package/dist/src/services/users/service.js +152 -0
  233. package/dist/src/services/users/user-error-service.d.ts +4 -0
  234. package/dist/src/services/users/user-error-service.js +27 -0
  235. package/dist/src/services/users/users-group-service.d.ts +16 -0
  236. package/dist/src/services/users/users-group-service.js +51 -0
  237. package/dist/src/services/utils/field-naming-service.d.ts +20 -0
  238. package/dist/src/services/utils/field-naming-service.js +59 -0
  239. package/dist/src/services/utils/string-utils-service.d.ts +5 -0
  240. package/dist/src/services/utils/string-utils-service.js +37 -0
  241. package/dist/src/types/errors.d.ts +9 -0
  242. package/dist/src/types/errors.js +15 -0
  243. package/dist/src/types/user-types.d.ts +11 -0
  244. package/dist/src/types/user-types.js +14 -0
  245. package/dist/types/errors.d.ts +9 -0
  246. package/dist/types/errors.js +20 -0
  247. package/dist/types/user-types.d.ts +11 -0
  248. package/dist/types/user-types.js +19 -0
  249. package/package.json +21 -0
  250. package/prisma/schema.prisma +572 -0
  251. package/prisma.config.ts +14 -0
  252. package/src/apollo/README.md +4 -0
  253. package/src/apollo/resolvers/mutations/mailing-lists.ts +30 -0
  254. package/src/apollo/resolvers/mutations/user-preferences.ts +33 -0
  255. package/src/apollo/resolvers/mutations/users.ts +61 -0
  256. package/src/apollo/resolvers/queries/access.ts +23 -0
  257. package/src/apollo/resolvers/queries/profile.ts +24 -0
  258. package/src/apollo/resolvers/queries/quotas.ts +25 -0
  259. package/src/apollo/resolvers/queries/tech.ts +42 -0
  260. package/src/apollo/resolvers/queries/user-preferences.ts +34 -0
  261. package/src/apollo/resolvers/queries/users.ts +33 -0
  262. package/src/apollo/typedefs/typedefs.ts +139 -0
  263. package/src/db.ts +19 -0
  264. package/src/index.ts +52 -0
  265. package/src/models/chat/chat-message-created-model.ts +126 -0
  266. package/src/models/chat/chat-message-model.ts +678 -0
  267. package/src/models/chat/chat-participant-model.ts +248 -0
  268. package/src/models/chat/chat-session-model.ts +397 -0
  269. package/src/models/chat/chat-settings-model.ts +336 -0
  270. package/src/models/feature-flags/feature-flag-model.ts +198 -0
  271. package/src/models/instances/instance-model.ts +673 -0
  272. package/src/models/instances/instance-setting-model.ts +235 -0
  273. package/src/models/mailing-lists/mailing-list-model.ts +177 -0
  274. package/src/models/mailing-lists/mailing-list-subscriber-model.ts +194 -0
  275. package/src/models/quotas/resource-quota-total-model.ts +243 -0
  276. package/src/models/quotas/resource-quota-usage-model.ts +219 -0
  277. package/src/models/tech/rate-limited-api-event-model.ts +190 -0
  278. package/src/models/tech/rate-limited-api-model.ts +171 -0
  279. package/src/models/tech/tech-model.ts +360 -0
  280. package/src/models/tech/tech-provider-api-key-model.ts +289 -0
  281. package/src/models/tech/tech-provider-model.ts +247 -0
  282. package/src/models/users/external-user-integration-model.ts +236 -0
  283. package/src/models/users/user-error-model.ts +219 -0
  284. package/src/models/users/user-error-summary-model.ts +216 -0
  285. package/src/models/users/user-group-member-model.ts +233 -0
  286. package/src/models/users/user-group-model.ts +174 -0
  287. package/src/models/users/user-model.ts +172 -0
  288. package/src/models/users/user-preference-model.ts +285 -0
  289. package/src/models/users/user-profile-model.ts +207 -0
  290. package/src/services/access/access-service.ts +36 -0
  291. package/src/services/access/encrypt-service.ts +122 -0
  292. package/src/services/api-usage/api-usage-base-service.ts +95 -0
  293. package/src/services/console/service.ts +24 -0
  294. package/src/services/db/pg/pg-estimate-size-service.ts +119 -0
  295. package/src/services/files/types.ts +7 -0
  296. package/src/services/files/walk-dir-service.ts +135 -0
  297. package/src/services/locale/countries.ts +483 -0
  298. package/src/services/mailing-lists/mailing-list-subscriber-service.ts +54 -0
  299. package/src/services/process/sleep.ts +7 -0
  300. package/src/services/quotas/mutate-service.ts +66 -0
  301. package/src/services/quotas/query-service.ts +197 -0
  302. package/src/services/quotas/utils-service.ts +29 -0
  303. package/src/services/tech/tech-provider-mutate-service.ts +136 -0
  304. package/src/services/tech/tech-query-service.ts +93 -0
  305. package/src/services/user-preference/service.ts +110 -0
  306. package/src/services/users/external-user-integration-service.ts +51 -0
  307. package/src/services/users/profile-service.ts +513 -0
  308. package/src/services/users/service.ts +293 -0
  309. package/src/services/users/user-error-service.ts +74 -0
  310. package/src/services/users/users-group-service.ts +85 -0
  311. package/src/services/utils/field-naming-service.ts +78 -0
  312. package/src/services/utils/string-utils-service.ts +48 -0
  313. package/src/types/errors.ts +18 -0
  314. package/src/types/user-types.ts +19 -0
  315. package/tsconfig.json +25 -0
@@ -0,0 +1,466 @@
1
+ export class InstanceModel {
2
+ // Consts
3
+ clName = 'InstanceModel';
4
+ // Code
5
+ async create(prisma, parentId, userProfileId, instanceType, projectType, isDemo, isDefault, status, publicAccess, key, name) {
6
+ // Debug
7
+ const fnName = `${this.clName}.create()`;
8
+ // Create record
9
+ try {
10
+ return await prisma.instance.create({
11
+ data: {
12
+ parent: parentId != null ? {
13
+ connect: {
14
+ id: parentId
15
+ }
16
+ } : undefined,
17
+ userProfile: {
18
+ connect: {
19
+ id: userProfileId
20
+ }
21
+ },
22
+ instanceType: instanceType,
23
+ projectType: projectType,
24
+ isDemo: isDemo,
25
+ isDefault: isDefault,
26
+ status: status,
27
+ publicAccess: publicAccess,
28
+ key: key,
29
+ name: name
30
+ }
31
+ });
32
+ }
33
+ catch (error) {
34
+ console.error(`${fnName}: error: ${error}`);
35
+ throw 'Prisma error';
36
+ }
37
+ }
38
+ async deleteById(prisma, id) {
39
+ // Debug
40
+ const fnName = `${this.clName}.deleteById()`;
41
+ // Delete
42
+ try {
43
+ return await prisma.instance.delete({
44
+ where: {
45
+ id: id
46
+ }
47
+ });
48
+ }
49
+ catch (error) {
50
+ if (!(error instanceof error.NotFound)) {
51
+ console.error(`${fnName}: error: ${error}`);
52
+ throw 'Prisma error';
53
+ }
54
+ }
55
+ }
56
+ async filter(prisma, parentId = undefined, userProfileId = undefined, instanceType = undefined, projectType = undefined, isDemo = undefined, isDefault = undefined, status = undefined, publicAccess = undefined, includeUserProfile = false, includeUser = false) {
57
+ // Debug
58
+ const fnName = `${this.clName}.filter()`;
59
+ // console.log(`${fnName}: starting with parentId: ${parentId} ` +
60
+ // `status: ${status} ` +
61
+ // `includeUserProfile: ${includeUserProfile} ` +
62
+ // `includeUser: ${includeUser}`)
63
+ // Query
64
+ try {
65
+ return await prisma.instance.findMany({
66
+ include: {
67
+ userProfile: includeUserProfile ? {
68
+ include: {
69
+ user: includeUser
70
+ }
71
+ } : false
72
+ },
73
+ where: {
74
+ parentId: parentId,
75
+ userProfileId: userProfileId,
76
+ instanceType: instanceType,
77
+ projectType: projectType,
78
+ isDemo: isDemo,
79
+ isDefault: isDefault,
80
+ status: status,
81
+ publicAccess: publicAccess
82
+ }
83
+ });
84
+ }
85
+ catch (error) {
86
+ console.error(`${fnName}: error: ${error}`);
87
+ throw 'Prisma error';
88
+ }
89
+ }
90
+ async getById(prisma, id, includeParent = false, includeUserProfile = false, includeUser = false) {
91
+ // Debug
92
+ const fnName = `${this.clName}.getById()`;
93
+ // Query
94
+ var instance = null;
95
+ try {
96
+ instance = await prisma.instance.findUnique({
97
+ include: {
98
+ parent: includeParent,
99
+ userProfile: includeUserProfile ? {
100
+ include: {
101
+ user: includeUser
102
+ }
103
+ } : false
104
+ },
105
+ where: {
106
+ id: id
107
+ }
108
+ });
109
+ }
110
+ catch (error) {
111
+ if (!(error instanceof error.NotFound)) {
112
+ console.error(`${fnName}: error: ${error}`);
113
+ throw 'Prisma error';
114
+ }
115
+ }
116
+ // Return
117
+ return instance;
118
+ }
119
+ async getByNameAndIsAdminUserProfile(prisma, name) {
120
+ // Debug
121
+ const fnName = `${this.clName}.getByName()`;
122
+ // Query
123
+ var instance;
124
+ try {
125
+ instance = await prisma.instance.findFirst({
126
+ where: {
127
+ userProfile: {
128
+ isAdmin: true
129
+ },
130
+ name: name
131
+ }
132
+ });
133
+ }
134
+ catch (error) {
135
+ console.error(`${fnName}: error: ${error}`);
136
+ throw 'Prisma error';
137
+ }
138
+ // Return
139
+ return instance;
140
+ }
141
+ async getByParentIdAndUserProfileIdAndIsDefault(prisma, parentId, userProfileId) {
142
+ // Debug
143
+ const fnName = `${this.clName}.getByParentIdAndUserProfileIdAndIsDefault()`;
144
+ // Query
145
+ var instance;
146
+ try {
147
+ instance = await prisma.instance.findFirst({
148
+ where: {
149
+ parentId: parentId,
150
+ userProfileId: userProfileId,
151
+ isDefault: true
152
+ }
153
+ });
154
+ }
155
+ catch (error) {
156
+ console.error(`${fnName}: error: ${error}`);
157
+ throw 'Prisma error';
158
+ }
159
+ // Return
160
+ return instance;
161
+ }
162
+ async getByParentIdAndKey(prisma, parentId, key) {
163
+ // Debug
164
+ const fnName = `${this.clName}.getByParentIdAndKey()`;
165
+ // console.log(`${fnName}: parentId: ${parentId} key: ${key} ` +
166
+ // `userProfileId: ${userProfileId}`)
167
+ // Validate
168
+ if (key == null) {
169
+ console.error(`${fnName}: key == null`);
170
+ throw 'Validation error';
171
+ }
172
+ // Query
173
+ var instance;
174
+ try {
175
+ instance = await prisma.instance.findFirst({
176
+ where: {
177
+ parentId: parentId,
178
+ key: key
179
+ }
180
+ });
181
+ }
182
+ catch (error) {
183
+ console.error(`${fnName}: error: ${error}`);
184
+ throw 'Prisma error';
185
+ }
186
+ // Return
187
+ return instance;
188
+ }
189
+ async getByParentIdAndName(prisma, parentId, name) {
190
+ // Debug
191
+ const fnName = `${this.clName}.getByParentIdAndName()`;
192
+ // console.log(`${fnName}: parentId: ${parentId} name: ${name} ` +
193
+ // `userProfileId: ${userProfileId}`)
194
+ // Validate
195
+ if (name == null) {
196
+ console.error(`${fnName}: name == null`);
197
+ throw 'Validation error';
198
+ }
199
+ // Query
200
+ var instance;
201
+ try {
202
+ instance = await prisma.instance.findFirst({
203
+ where: {
204
+ parentId: parentId,
205
+ name: name
206
+ }
207
+ });
208
+ }
209
+ catch (error) {
210
+ console.error(`${fnName}: error: ${error}`);
211
+ throw 'Prisma error';
212
+ }
213
+ // Return
214
+ return instance;
215
+ }
216
+ async getByParentIdAndKeyAndUserProfileId(prisma, parentId, key, userProfileId) {
217
+ // Debug
218
+ const fnName = `${this.clName}.getByParentIdAndKeyAndUserProfileId()`;
219
+ // console.log(`${fnName}: parentId: ${parentId} key: ${key} ` +
220
+ // `userProfileId: ${userProfileId}`)
221
+ // Validate
222
+ if (key == null) {
223
+ console.error(`${fnName}: key == null`);
224
+ throw 'Validation error';
225
+ }
226
+ if (userProfileId == null) {
227
+ console.error(`${fnName}: userProfileId == null`);
228
+ throw 'Validation error';
229
+ }
230
+ // Query
231
+ var instance;
232
+ try {
233
+ instance = await prisma.instance.findFirst({
234
+ where: {
235
+ parentId: parentId,
236
+ key: key,
237
+ userProfileId: userProfileId
238
+ }
239
+ });
240
+ }
241
+ catch (error) {
242
+ console.error(`${fnName}: error: ${error}`);
243
+ throw 'Prisma error';
244
+ }
245
+ // Return
246
+ return instance;
247
+ }
248
+ async getByParentIdAndNameAndUserProfileId(prisma, parentId, name, userProfileId) {
249
+ // Debug
250
+ const fnName = `${this.clName}.getByParentIdAndNameAndUserProfileId()`;
251
+ // console.log(`${fnName}: parentId: ${parentId} name: ${name} ` +
252
+ // `userProfileId: ${userProfileId}`)
253
+ // Validate
254
+ if (name == null) {
255
+ console.error(`${fnName}: name == null`);
256
+ throw 'Validation error';
257
+ }
258
+ if (userProfileId == null) {
259
+ console.error(`${fnName}: userProfileId == null`);
260
+ throw 'Validation error';
261
+ }
262
+ // Query
263
+ var instance;
264
+ try {
265
+ instance = await prisma.instance.findFirst({
266
+ where: {
267
+ parentId: parentId,
268
+ name: name,
269
+ userProfileId: userProfileId
270
+ }
271
+ });
272
+ }
273
+ catch (error) {
274
+ console.error(`${fnName}: error: ${error}`);
275
+ throw 'Prisma error';
276
+ }
277
+ // Return
278
+ return instance;
279
+ }
280
+ async getByUserProfileIdAndName(prisma, userProfileId, name) {
281
+ // Debug
282
+ const fnName = `${this.clName}.getByUserProfileIdAndName()`;
283
+ // Query
284
+ var instance;
285
+ try {
286
+ instance = await prisma.instance.findFirst({
287
+ where: {
288
+ userProfileId: userProfileId,
289
+ name: name
290
+ }
291
+ });
292
+ }
293
+ catch (error) {
294
+ console.error(`${fnName}: error: ${error}`);
295
+ throw 'Prisma error';
296
+ }
297
+ // Return
298
+ return instance;
299
+ }
300
+ async getByUserProfileIdAndParentNameAndName(prisma, userProfileId, parentName, name) {
301
+ // Debug
302
+ const fnName = `${this.clName}.getByUserProfileIdAndParentNameAndName()`;
303
+ // Validate
304
+ if (userProfileId == null) {
305
+ console.error(`${fnName}: userProfileId == null`);
306
+ throw 'Validation error';
307
+ }
308
+ if (parentName == null) {
309
+ console.error(`${fnName}: parentName == null`);
310
+ throw 'Validation error';
311
+ }
312
+ if (name == null) {
313
+ console.error(`${fnName}: name == null`);
314
+ throw 'Validation error';
315
+ }
316
+ // Query
317
+ var instance;
318
+ try {
319
+ instance = await prisma.instance.findFirst({
320
+ where: {
321
+ parent: {
322
+ userProfileId: userProfileId,
323
+ parentId: null,
324
+ name: parentName
325
+ },
326
+ userProfileId: userProfileId,
327
+ name: name
328
+ }
329
+ });
330
+ }
331
+ catch (error) {
332
+ console.error(`${fnName}: error: ${error}`);
333
+ throw 'Prisma error';
334
+ }
335
+ // Return
336
+ return instance;
337
+ }
338
+ async update(prisma, id, parentId, userProfileId, instanceType, projectType, isDemo, isDefault, status, publicAccess, key, name) {
339
+ // Debug
340
+ const fnName = `${this.clName}.update()`;
341
+ // Update record
342
+ try {
343
+ return await prisma.instance.update({
344
+ data: {
345
+ parentId: parentId,
346
+ userProfileId: userProfileId,
347
+ instanceType: instanceType,
348
+ projectType: projectType,
349
+ isDemo: isDemo,
350
+ isDefault: isDefault,
351
+ status: status,
352
+ publicAccess: publicAccess,
353
+ key: key,
354
+ name: name
355
+ },
356
+ where: {
357
+ id: id
358
+ }
359
+ });
360
+ }
361
+ catch (error) {
362
+ console.error(`${fnName}: error: ${error}`);
363
+ throw 'Prisma error';
364
+ }
365
+ }
366
+ async updateByParentId(prisma, parentId, userProfileId, instanceType, projectType, isDemo, isDefault, status, publicAccess, key, name) {
367
+ // Debug
368
+ const fnName = `${this.clName}.updateByParentId()`;
369
+ // Update record
370
+ try {
371
+ return await prisma.instance.updateMany({
372
+ data: {
373
+ userProfileId: userProfileId,
374
+ instanceType: instanceType,
375
+ projectType: projectType,
376
+ isDemo: isDemo,
377
+ isDefault: isDefault,
378
+ status: status,
379
+ publicAccess: publicAccess,
380
+ key: key,
381
+ name: name
382
+ },
383
+ where: {
384
+ parentId: parentId
385
+ }
386
+ });
387
+ }
388
+ catch (error) {
389
+ console.error(`${fnName}: error: ${error}`);
390
+ throw 'Prisma error';
391
+ }
392
+ }
393
+ async upsert(prisma, id, parentId, userProfileId, instanceType, projectType, isDemo, isDefault, status, publicAccess, key, name) {
394
+ // Debug
395
+ const fnName = `${this.clName}.upsert()`;
396
+ // If id isn't specified, try to get by a unique key
397
+ if (id == null &&
398
+ parentId !== undefined &&
399
+ key != null &&
400
+ userProfileId != null) {
401
+ const instance = await this.getByParentIdAndKeyAndUserProfileId(prisma, parentId, key, userProfileId);
402
+ if (instance != null) {
403
+ id = instance.id;
404
+ }
405
+ }
406
+ if (id == null &&
407
+ parentId !== undefined &&
408
+ name != null &&
409
+ userProfileId != null) {
410
+ const instance = await this.getByParentIdAndNameAndUserProfileId(prisma, parentId, name, userProfileId);
411
+ if (instance != null) {
412
+ id = instance.id;
413
+ }
414
+ }
415
+ // Upsert
416
+ if (id == null) {
417
+ // Validate for create (mainly for type validation of the create call)
418
+ if (parentId === undefined) {
419
+ console.error(`${fnName}: id is null and parentId is undefined`);
420
+ throw 'Prisma error';
421
+ }
422
+ if (userProfileId == null) {
423
+ console.error(`${fnName}: id is null and userProfileId is null`);
424
+ throw 'Prisma error';
425
+ }
426
+ if (instanceType == null) {
427
+ console.error(`${fnName}: id is null and instanceType is null`);
428
+ throw 'Prisma error';
429
+ }
430
+ if (projectType === undefined) {
431
+ console.error(`${fnName}: id is null and projectType is undefined`);
432
+ throw 'Prisma error';
433
+ }
434
+ if (isDemo == null) {
435
+ console.error(`${fnName}: id is null and isDemo is null`);
436
+ throw 'Prisma error';
437
+ }
438
+ if (isDefault == null) {
439
+ console.error(`${fnName}: id is null and isDefault is null`);
440
+ throw 'Prisma error';
441
+ }
442
+ if (status == null) {
443
+ console.error(`${fnName}: id is null and status is null`);
444
+ throw 'Prisma error';
445
+ }
446
+ if (publicAccess === undefined) {
447
+ console.error(`${fnName}: id is null and publicAccess is undefined`);
448
+ throw 'Prisma error';
449
+ }
450
+ if (key == null) {
451
+ console.error(`${fnName}: id is null and key is null`);
452
+ throw 'Prisma error';
453
+ }
454
+ if (name == null) {
455
+ console.error(`${fnName}: id is null and name is null`);
456
+ throw 'Prisma error';
457
+ }
458
+ // Create
459
+ return await this.create(prisma, parentId, userProfileId, instanceType, projectType, isDemo, isDefault, status, publicAccess, key, name);
460
+ }
461
+ else {
462
+ // Update
463
+ return await this.update(prisma, id, parentId, userProfileId, instanceType, projectType, isDemo, isDefault, status, publicAccess, key, name);
464
+ }
465
+ }
466
+ }
@@ -0,0 +1,39 @@
1
+ import { Prisma } from '@/prisma/client';
2
+ export declare class InstanceSettingModel {
3
+ clName: string;
4
+ create(prisma: Prisma.TransactionClient, instanceId: string, name: string, value: string): Promise<{
5
+ name: string;
6
+ id: string;
7
+ value: string;
8
+ created: Date;
9
+ updated: Date;
10
+ instanceId: string;
11
+ }>;
12
+ deleteByInstanceId(prisma: Prisma.TransactionClient, instanceId: string): Promise<Prisma.BatchPayload>;
13
+ filter(prisma: Prisma.TransactionClient, instanceId: string | undefined, name: string | undefined, value: string | undefined): Promise<{
14
+ name: string;
15
+ id: string;
16
+ value: string;
17
+ created: Date;
18
+ updated: Date;
19
+ instanceId: string;
20
+ }[]>;
21
+ getById(prisma: Prisma.TransactionClient, id: string): Promise<any>;
22
+ getByInstanceIdAndName(prisma: Prisma.TransactionClient, instanceId: string, name: string): Promise<any>;
23
+ update(prisma: Prisma.TransactionClient, id: string, instanceId: string | undefined, name: string | undefined, value: string | undefined): Promise<{
24
+ name: string;
25
+ id: string;
26
+ value: string;
27
+ created: Date;
28
+ updated: Date;
29
+ instanceId: string;
30
+ }>;
31
+ upsert(prisma: Prisma.TransactionClient, id: string | undefined, instanceId: string | undefined, name: string | undefined, value: string | undefined): Promise<{
32
+ name: string;
33
+ id: string;
34
+ value: string;
35
+ created: Date;
36
+ updated: Date;
37
+ instanceId: string;
38
+ }>;
39
+ }
@@ -0,0 +1,164 @@
1
+ export class InstanceSettingModel {
2
+ // Consts
3
+ clName = 'InstanceSettingModel';
4
+ // Code
5
+ async create(prisma, instanceId, name, value) {
6
+ // Debug
7
+ const fnName = `${this.clName}.create()`;
8
+ // Create record
9
+ try {
10
+ return await prisma.instanceSetting.create({
11
+ data: {
12
+ instanceId: instanceId,
13
+ name: name,
14
+ value: value
15
+ }
16
+ });
17
+ }
18
+ catch (error) {
19
+ console.error(`${fnName}: error: ${error}`);
20
+ throw 'Prisma error';
21
+ }
22
+ }
23
+ async deleteByInstanceId(prisma, instanceId) {
24
+ // Debug
25
+ const fnName = `${this.clName}.deleteByInstanceId()`;
26
+ // Delete records
27
+ try {
28
+ return await prisma.instanceSetting.deleteMany({
29
+ where: {
30
+ instanceId: instanceId
31
+ }
32
+ });
33
+ }
34
+ catch (error) {
35
+ console.error(`${fnName}: error: ${error}`);
36
+ throw 'Prisma error';
37
+ }
38
+ }
39
+ async filter(prisma, instanceId, name, value) {
40
+ // Debug
41
+ const fnName = `${this.clName}.filter()`;
42
+ // console.log(`${fnName}: starting..`)
43
+ // Query
44
+ try {
45
+ return await prisma.instanceSetting.findMany({
46
+ where: {
47
+ instanceId: instanceId,
48
+ name: name,
49
+ value: value
50
+ }
51
+ });
52
+ }
53
+ catch (error) {
54
+ console.error(`${fnName}: error: ${error}`);
55
+ throw 'Prisma error';
56
+ }
57
+ }
58
+ async getById(prisma, id) {
59
+ // Debug
60
+ const fnName = `${this.clName}.getById()`;
61
+ // Query
62
+ var instanceSetting = null;
63
+ try {
64
+ instanceSetting = await prisma.instanceSetting.findUnique({
65
+ where: {
66
+ id: id
67
+ }
68
+ });
69
+ }
70
+ catch (error) {
71
+ if (!(error instanceof error.NotFound)) {
72
+ console.error(`${fnName}: error: ${error}`);
73
+ throw 'Prisma error';
74
+ }
75
+ }
76
+ // Return
77
+ return instanceSetting;
78
+ }
79
+ async getByInstanceIdAndName(prisma, instanceId, name) {
80
+ // Debug
81
+ const fnName = `${this.clName}.getByInstanceIdAndName()`;
82
+ // Validate
83
+ if (instanceId == null) {
84
+ console.error(`${fnName}: instanceId == null`);
85
+ throw 'Validation error';
86
+ }
87
+ if (name == null) {
88
+ console.error(`${fnName}: name == null`);
89
+ throw 'Validation error';
90
+ }
91
+ // Query
92
+ var instanceSetting;
93
+ try {
94
+ instanceSetting = await prisma.instanceSetting.findFirst({
95
+ where: {
96
+ instanceId: instanceId,
97
+ name: name
98
+ }
99
+ });
100
+ }
101
+ catch (error) {
102
+ console.error(`${fnName}: error: ${error}`);
103
+ throw 'Prisma error';
104
+ }
105
+ // Return
106
+ return instanceSetting;
107
+ }
108
+ async update(prisma, id, instanceId, name, value) {
109
+ // Debug
110
+ const fnName = `${this.clName}.update()`;
111
+ // Update record
112
+ try {
113
+ return await prisma.instanceSetting.update({
114
+ data: {
115
+ instanceId: instanceId,
116
+ name: name,
117
+ value: value
118
+ },
119
+ where: {
120
+ id: id
121
+ }
122
+ });
123
+ }
124
+ catch (error) {
125
+ console.error(`${fnName}: error: ${error}`);
126
+ throw 'Prisma error';
127
+ }
128
+ }
129
+ async upsert(prisma, id, instanceId, name, value) {
130
+ // Debug
131
+ const fnName = `${this.clName}.upsert()`;
132
+ // If id isn't specified, try to get by the unique key
133
+ if (id == null &&
134
+ instanceId != null &&
135
+ name != null) {
136
+ const instanceSetting = await this.getByInstanceIdAndName(prisma, instanceId, name);
137
+ if (instanceSetting != null) {
138
+ id = instanceSetting.id;
139
+ }
140
+ }
141
+ // Upsert
142
+ if (id == null) {
143
+ // Validate for create (mainly for type validation of the create call)
144
+ if (instanceId == null) {
145
+ console.error(`${fnName}: id is null and instanceId is null`);
146
+ throw 'Prisma error';
147
+ }
148
+ if (name == null) {
149
+ console.error(`${fnName}: id is null and name is null`);
150
+ throw 'Prisma error';
151
+ }
152
+ if (value == null) {
153
+ console.error(`${fnName}: id is null and value is null`);
154
+ throw 'Prisma error';
155
+ }
156
+ // Create
157
+ return await this.create(prisma, instanceId, name, value);
158
+ }
159
+ else {
160
+ // Update
161
+ return await this.update(prisma, id, instanceId, name, value);
162
+ }
163
+ }
164
+ }
@@ -0,0 +1,34 @@
1
+ import { PrismaClient } from '@/prisma/client';
2
+ export declare class MailingListModel {
3
+ clName: string;
4
+ create(prisma: PrismaClient, name: string, title: string): Promise<{
5
+ name: string;
6
+ id: string;
7
+ title: string;
8
+ created: Date;
9
+ updated: Date;
10
+ }>;
11
+ getAll(prisma: PrismaClient): Promise<{
12
+ name: string;
13
+ id: string;
14
+ title: string;
15
+ created: Date;
16
+ updated: Date;
17
+ }[]>;
18
+ getById(prisma: PrismaClient, id: string): Promise<any>;
19
+ getByName(prisma: PrismaClient, name: string): Promise<any>;
20
+ update(prisma: PrismaClient, id: string, name: string, title: string): Promise<{
21
+ name: string;
22
+ id: string;
23
+ title: string;
24
+ created: Date;
25
+ updated: Date;
26
+ }>;
27
+ upsert(prisma: PrismaClient, id: string, name: string, title: string): Promise<{
28
+ name: string;
29
+ id: string;
30
+ title: string;
31
+ created: Date;
32
+ updated: Date;
33
+ }>;
34
+ }