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.
- package/dist/apollo/resolvers/mutations/mailing-lists.d.ts +11 -0
- package/dist/apollo/resolvers/mutations/mailing-lists.js +30 -0
- package/dist/apollo/resolvers/mutations/user-preferences.d.ts +13 -0
- package/dist/apollo/resolvers/mutations/user-preferences.js +31 -0
- package/dist/apollo/resolvers/mutations/users.d.ts +28 -0
- package/dist/apollo/resolvers/mutations/users.js +44 -0
- package/dist/apollo/resolvers/queries/access.d.ts +11 -0
- package/dist/apollo/resolvers/queries/access.js +25 -0
- package/dist/apollo/resolvers/queries/profile.d.ts +11 -0
- package/dist/apollo/resolvers/queries/profile.js +25 -0
- package/dist/apollo/resolvers/queries/quotas.d.ts +21 -0
- package/dist/apollo/resolvers/queries/quotas.js +25 -0
- package/dist/apollo/resolvers/queries/tech.d.ts +5 -0
- package/dist/apollo/resolvers/queries/tech.js +35 -0
- package/dist/apollo/resolvers/queries/user-preferences.d.ts +5 -0
- package/dist/apollo/resolvers/queries/user-preferences.js +33 -0
- package/dist/apollo/resolvers/queries/users.d.ts +15 -0
- package/dist/apollo/resolvers/queries/users.js +28 -0
- package/dist/apollo/resolvers/resolvers.d.ts +20 -0
- package/dist/apollo/resolvers/resolvers.js +38 -0
- package/dist/apollo/typedefs/typedefs.d.ts +1 -0
- package/dist/apollo/typedefs/typedefs.js +142 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +68 -0
- package/dist/models/chat/chat-message-created-model.d.ts +17 -0
- package/dist/models/chat/chat-message-created-model.js +113 -0
- package/dist/models/chat/chat-message-model.d.ts +44 -0
- package/dist/models/chat/chat-message-model.js +523 -0
- package/dist/models/chat/chat-participant-model.d.ts +39 -0
- package/dist/models/chat/chat-participant-model.js +211 -0
- package/dist/models/chat/chat-session-model.d.ts +92 -0
- package/dist/models/chat/chat-session-model.js +301 -0
- package/dist/models/chat/chat-settings-model.d.ts +87 -0
- package/dist/models/chat/chat-settings-model.js +261 -0
- package/dist/models/feature-flags/feature-flag-model.d.ts +40 -0
- package/dist/models/feature-flags/feature-flag-model.js +164 -0
- package/dist/models/instances/instance-model.d.ts +93 -0
- package/dist/models/instances/instance-model.js +432 -0
- package/dist/models/instances/instance-setting-model.d.ts +39 -0
- package/dist/models/instances/instance-setting-model.js +193 -0
- package/dist/models/mailing-lists/mailing-list-model.d.ts +34 -0
- package/dist/models/mailing-lists/mailing-list-model.js +154 -0
- package/dist/models/mailing-lists/mailing-list-subscriber-model.d.ts +36 -0
- package/dist/models/mailing-lists/mailing-list-subscriber-model.js +152 -0
- package/dist/models/quotas/resource-quota-total-model.d.ts +46 -0
- package/dist/models/quotas/resource-quota-total-model.js +200 -0
- package/dist/models/quotas/resource-quota-usage-model.d.ts +51 -0
- package/dist/models/quotas/resource-quota-usage-model.js +181 -0
- package/dist/models/tech/rate-limited-api-event-model.d.ts +25 -0
- package/dist/models/tech/rate-limited-api-event-model.js +161 -0
- package/dist/models/tech/rate-limited-api-model.d.ts +21 -0
- package/dist/models/tech/rate-limited-api-model.js +141 -0
- package/dist/models/tech/tech-model.d.ts +44 -0
- package/dist/models/tech/tech-model.js +268 -0
- package/dist/models/tech/tech-provider-api-key-model.d.ts +43 -0
- package/dist/models/tech/tech-provider-api-key-model.js +224 -0
- package/dist/models/tech/tech-provider-model.d.ts +28 -0
- package/dist/models/tech/tech-provider-model.js +197 -0
- package/dist/models/users/external-user-integration-model.d.ts +36 -0
- package/dist/models/users/external-user-integration-model.js +196 -0
- package/dist/models/users/user-error-model.d.ts +54 -0
- package/dist/models/users/user-error-model.js +173 -0
- package/dist/models/users/user-error-summary-model.d.ts +45 -0
- package/dist/models/users/user-error-summary-model.js +172 -0
- package/dist/models/users/user-group-member-model.d.ts +41 -0
- package/dist/models/users/user-group-member-model.js +193 -0
- package/dist/models/users/user-group-model.d.ts +27 -0
- package/dist/models/users/user-group-model.js +146 -0
- package/dist/models/users/user-model.d.ts +46 -0
- package/dist/models/users/user-model.js +153 -0
- package/dist/models/users/user-preference-model.d.ts +60 -0
- package/dist/models/users/user-preference-model.js +228 -0
- package/dist/models/users/user-profile-model.d.ts +58 -0
- package/dist/models/users/user-profile-model.js +173 -0
- package/dist/prisma.config.d.ts +3 -0
- package/dist/prisma.config.js +13 -0
- package/dist/services/access/access-service.d.ts +12 -0
- package/dist/services/access/access-service.js +44 -0
- package/dist/services/access/encrypt-service.d.ts +13 -0
- package/dist/services/access/encrypt-service.js +84 -0
- package/dist/services/api-usage/api-usage-base-service.d.ts +15 -0
- package/dist/services/api-usage/api-usage-base-service.js +75 -0
- package/dist/services/console/service.d.ts +7 -0
- package/dist/services/console/service.js +70 -0
- package/dist/services/db/pg/pg-estimate-size-service.d.ts +16 -0
- package/dist/services/db/pg/pg-estimate-size-service.js +90 -0
- package/dist/services/files/types.d.ts +6 -0
- package/dist/services/files/types.js +2 -0
- package/dist/services/files/walk-dir-service.d.ts +8 -0
- package/dist/services/files/walk-dir-service.js +94 -0
- package/dist/services/locale/countries.d.ts +6 -0
- package/dist/services/locale/countries.js +484 -0
- package/dist/services/mailing-lists/mailing-list-subscriber-service.d.ts +14 -0
- package/dist/services/mailing-lists/mailing-list-subscriber-service.js +45 -0
- package/dist/services/process/sleep.d.ts +2 -0
- package/dist/services/process/sleep.js +10 -0
- package/dist/services/quotas/mutate-service.d.ts +5 -0
- package/dist/services/quotas/mutate-service.js +54 -0
- package/dist/services/quotas/query-service.d.ts +27 -0
- package/dist/services/quotas/query-service.js +137 -0
- package/dist/services/quotas/utils-service.d.ts +4 -0
- package/dist/services/quotas/utils-service.js +28 -0
- package/dist/services/tech/tech-provider-mutate-service.d.ts +7 -0
- package/dist/services/tech/tech-provider-mutate-service.js +142 -0
- package/dist/services/tech/tech-query-service.d.ts +9 -0
- package/dist/services/tech/tech-query-service.js +77 -0
- package/dist/services/user-preference/service.d.ts +10 -0
- package/dist/services/user-preference/service.js +70 -0
- package/dist/services/users/external-user-integration-service.d.ts +9 -0
- package/dist/services/users/external-user-integration-service.js +42 -0
- package/dist/services/users/profile-service.d.ts +40 -0
- package/dist/services/users/profile-service.js +408 -0
- package/dist/services/users/service.d.ts +64 -0
- package/dist/services/users/service.js +187 -0
- package/dist/services/users/user-error-service.d.ts +4 -0
- package/dist/services/users/user-error-service.js +42 -0
- package/dist/services/users/users-group-service.d.ts +16 -0
- package/dist/services/users/users-group-service.js +68 -0
- package/dist/services/utils/string-utils-service.d.ts +5 -0
- package/dist/services/utils/string-utils-service.js +41 -0
- package/dist/src/apollo/resolvers/mutations/mailing-lists.d.ts +11 -0
- package/dist/src/apollo/resolvers/mutations/mailing-lists.js +19 -0
- package/dist/src/apollo/resolvers/mutations/user-preferences.d.ts +13 -0
- package/dist/src/apollo/resolvers/mutations/user-preferences.js +20 -0
- package/dist/src/apollo/resolvers/mutations/users.d.ts +28 -0
- package/dist/src/apollo/resolvers/mutations/users.js +33 -0
- package/dist/src/apollo/resolvers/queries/access.d.ts +11 -0
- package/dist/src/apollo/resolvers/queries/access.js +14 -0
- package/dist/src/apollo/resolvers/queries/profile.d.ts +11 -0
- package/dist/src/apollo/resolvers/queries/profile.js +14 -0
- package/dist/src/apollo/resolvers/queries/quotas.d.ts +21 -0
- package/dist/src/apollo/resolvers/queries/quotas.js +14 -0
- package/dist/src/apollo/resolvers/queries/tech.d.ts +5 -0
- package/dist/src/apollo/resolvers/queries/tech.js +24 -0
- package/dist/src/apollo/resolvers/queries/user-preferences.d.ts +5 -0
- package/dist/src/apollo/resolvers/queries/user-preferences.js +22 -0
- package/dist/src/apollo/resolvers/queries/users.d.ts +15 -0
- package/dist/src/apollo/resolvers/queries/users.js +17 -0
- package/dist/src/apollo/typedefs/typedefs.d.ts +1 -0
- package/dist/src/apollo/typedefs/typedefs.js +139 -0
- package/dist/src/db.d.ts +3 -0
- package/dist/src/db.js +11 -0
- package/dist/src/index.d.ts +52 -0
- package/dist/src/index.js +52 -0
- package/dist/src/models/chat/chat-message-created-model.d.ts +17 -0
- package/dist/src/models/chat/chat-message-created-model.js +92 -0
- package/dist/src/models/chat/chat-message-model.d.ts +44 -0
- package/dist/src/models/chat/chat-message-model.js +484 -0
- package/dist/src/models/chat/chat-participant-model.d.ts +39 -0
- package/dist/src/models/chat/chat-participant-model.js +178 -0
- package/dist/src/models/chat/chat-session-model.d.ts +92 -0
- package/dist/src/models/chat/chat-session-model.js +266 -0
- package/dist/src/models/chat/chat-settings-model.d.ts +87 -0
- package/dist/src/models/chat/chat-settings-model.js +230 -0
- package/dist/src/models/feature-flags/feature-flag-model.d.ts +40 -0
- package/dist/src/models/feature-flags/feature-flag-model.js +137 -0
- package/dist/src/models/instances/instance-model.d.ts +100 -0
- package/dist/src/models/instances/instance-model.js +466 -0
- package/dist/src/models/instances/instance-setting-model.d.ts +39 -0
- package/dist/src/models/instances/instance-setting-model.js +164 -0
- package/dist/src/models/mailing-lists/mailing-list-model.d.ts +34 -0
- package/dist/src/models/mailing-lists/mailing-list-model.js +127 -0
- package/dist/src/models/mailing-lists/mailing-list-subscriber-model.d.ts +36 -0
- package/dist/src/models/mailing-lists/mailing-list-subscriber-model.js +127 -0
- package/dist/src/models/quotas/resource-quota-total-model.d.ts +46 -0
- package/dist/src/models/quotas/resource-quota-total-model.js +170 -0
- package/dist/src/models/quotas/resource-quota-usage-model.d.ts +51 -0
- package/dist/src/models/quotas/resource-quota-usage-model.js +151 -0
- package/dist/src/models/tech/rate-limited-api-event-model.d.ts +25 -0
- package/dist/src/models/tech/rate-limited-api-event-model.js +134 -0
- package/dist/src/models/tech/rate-limited-api-model.d.ts +21 -0
- package/dist/src/models/tech/rate-limited-api-model.js +116 -0
- package/dist/src/models/tech/tech-model.d.ts +44 -0
- package/dist/src/models/tech/tech-model.js +239 -0
- package/dist/src/models/tech/tech-provider-api-key-model.d.ts +43 -0
- package/dist/src/models/tech/tech-provider-api-key-model.js +195 -0
- package/dist/src/models/tech/tech-provider-model.d.ts +28 -0
- package/dist/src/models/tech/tech-provider-model.js +170 -0
- package/dist/src/models/users/external-user-integration-model.d.ts +36 -0
- package/dist/src/models/users/external-user-integration-model.js +167 -0
- package/dist/src/models/users/user-error-model.d.ts +54 -0
- package/dist/src/models/users/user-error-model.js +146 -0
- package/dist/src/models/users/user-error-summary-model.d.ts +45 -0
- package/dist/src/models/users/user-error-summary-model.js +145 -0
- package/dist/src/models/users/user-group-member-model.d.ts +41 -0
- package/dist/src/models/users/user-group-member-model.js +164 -0
- package/dist/src/models/users/user-group-model.d.ts +27 -0
- package/dist/src/models/users/user-group-model.js +121 -0
- package/dist/src/models/users/user-model.d.ts +46 -0
- package/dist/src/models/users/user-model.js +126 -0
- package/dist/src/models/users/user-preference-model.d.ts +60 -0
- package/dist/src/models/users/user-preference-model.js +197 -0
- package/dist/src/models/users/user-profile-model.d.ts +58 -0
- package/dist/src/models/users/user-profile-model.js +146 -0
- package/dist/src/services/access/access-service.d.ts +12 -0
- package/dist/src/services/access/access-service.js +27 -0
- package/dist/src/services/access/encrypt-service.d.ts +13 -0
- package/dist/src/services/access/encrypt-service.js +79 -0
- package/dist/src/services/api-usage/api-usage-base-service.d.ts +15 -0
- package/dist/src/services/api-usage/api-usage-base-service.js +58 -0
- package/dist/src/services/console/service.d.ts +7 -0
- package/dist/src/services/console/service.js +18 -0
- package/dist/src/services/db/pg/pg-estimate-size-service.d.ts +16 -0
- package/dist/src/services/db/pg/pg-estimate-size-service.js +83 -0
- package/dist/src/services/files/types.d.ts +6 -0
- package/dist/src/services/files/types.js +1 -0
- package/dist/src/services/files/walk-dir-service.d.ts +8 -0
- package/dist/src/services/files/walk-dir-service.js +77 -0
- package/dist/src/services/locale/countries.d.ts +6 -0
- package/dist/src/services/locale/countries.js +481 -0
- package/dist/src/services/mailing-lists/mailing-list-subscriber-service.d.ts +14 -0
- package/dist/src/services/mailing-lists/mailing-list-subscriber-service.js +28 -0
- package/dist/src/services/process/sleep.d.ts +2 -0
- package/dist/src/services/process/sleep.js +6 -0
- package/dist/src/services/quotas/mutate-service.d.ts +5 -0
- package/dist/src/services/quotas/mutate-service.js +37 -0
- package/dist/src/services/quotas/query-service.d.ts +27 -0
- package/dist/src/services/quotas/query-service.js +116 -0
- package/dist/src/services/quotas/utils-service.d.ts +4 -0
- package/dist/src/services/quotas/utils-service.js +22 -0
- package/dist/src/services/tech/tech-provider-mutate-service.d.ts +7 -0
- package/dist/src/services/tech/tech-provider-mutate-service.js +85 -0
- package/dist/src/services/tech/tech-query-service.d.ts +9 -0
- package/dist/src/services/tech/tech-query-service.js +58 -0
- package/dist/src/services/user-preference/service.d.ts +10 -0
- package/dist/src/services/user-preference/service.js +49 -0
- package/dist/src/services/users/external-user-integration-service.d.ts +9 -0
- package/dist/src/services/users/external-user-integration-service.js +25 -0
- package/dist/src/services/users/profile-service.d.ts +40 -0
- package/dist/src/services/users/profile-service.js +385 -0
- package/dist/src/services/users/service.d.ts +64 -0
- package/dist/src/services/users/service.js +152 -0
- package/dist/src/services/users/user-error-service.d.ts +4 -0
- package/dist/src/services/users/user-error-service.js +27 -0
- package/dist/src/services/users/users-group-service.d.ts +16 -0
- package/dist/src/services/users/users-group-service.js +51 -0
- package/dist/src/services/utils/field-naming-service.d.ts +20 -0
- package/dist/src/services/utils/field-naming-service.js +59 -0
- package/dist/src/services/utils/string-utils-service.d.ts +5 -0
- package/dist/src/services/utils/string-utils-service.js +37 -0
- package/dist/src/types/errors.d.ts +9 -0
- package/dist/src/types/errors.js +15 -0
- package/dist/src/types/user-types.d.ts +11 -0
- package/dist/src/types/user-types.js +14 -0
- package/dist/types/errors.d.ts +9 -0
- package/dist/types/errors.js +20 -0
- package/dist/types/user-types.d.ts +11 -0
- package/dist/types/user-types.js +19 -0
- package/package.json +21 -0
- package/prisma/schema.prisma +572 -0
- package/prisma.config.ts +14 -0
- package/src/apollo/README.md +4 -0
- package/src/apollo/resolvers/mutations/mailing-lists.ts +30 -0
- package/src/apollo/resolvers/mutations/user-preferences.ts +33 -0
- package/src/apollo/resolvers/mutations/users.ts +61 -0
- package/src/apollo/resolvers/queries/access.ts +23 -0
- package/src/apollo/resolvers/queries/profile.ts +24 -0
- package/src/apollo/resolvers/queries/quotas.ts +25 -0
- package/src/apollo/resolvers/queries/tech.ts +42 -0
- package/src/apollo/resolvers/queries/user-preferences.ts +34 -0
- package/src/apollo/resolvers/queries/users.ts +33 -0
- package/src/apollo/typedefs/typedefs.ts +139 -0
- package/src/db.ts +19 -0
- package/src/index.ts +52 -0
- package/src/models/chat/chat-message-created-model.ts +126 -0
- package/src/models/chat/chat-message-model.ts +678 -0
- package/src/models/chat/chat-participant-model.ts +248 -0
- package/src/models/chat/chat-session-model.ts +397 -0
- package/src/models/chat/chat-settings-model.ts +336 -0
- package/src/models/feature-flags/feature-flag-model.ts +198 -0
- package/src/models/instances/instance-model.ts +673 -0
- package/src/models/instances/instance-setting-model.ts +235 -0
- package/src/models/mailing-lists/mailing-list-model.ts +177 -0
- package/src/models/mailing-lists/mailing-list-subscriber-model.ts +194 -0
- package/src/models/quotas/resource-quota-total-model.ts +243 -0
- package/src/models/quotas/resource-quota-usage-model.ts +219 -0
- package/src/models/tech/rate-limited-api-event-model.ts +190 -0
- package/src/models/tech/rate-limited-api-model.ts +171 -0
- package/src/models/tech/tech-model.ts +360 -0
- package/src/models/tech/tech-provider-api-key-model.ts +289 -0
- package/src/models/tech/tech-provider-model.ts +247 -0
- package/src/models/users/external-user-integration-model.ts +236 -0
- package/src/models/users/user-error-model.ts +219 -0
- package/src/models/users/user-error-summary-model.ts +216 -0
- package/src/models/users/user-group-member-model.ts +233 -0
- package/src/models/users/user-group-model.ts +174 -0
- package/src/models/users/user-model.ts +172 -0
- package/src/models/users/user-preference-model.ts +285 -0
- package/src/models/users/user-profile-model.ts +207 -0
- package/src/services/access/access-service.ts +36 -0
- package/src/services/access/encrypt-service.ts +122 -0
- package/src/services/api-usage/api-usage-base-service.ts +95 -0
- package/src/services/console/service.ts +24 -0
- package/src/services/db/pg/pg-estimate-size-service.ts +119 -0
- package/src/services/files/types.ts +7 -0
- package/src/services/files/walk-dir-service.ts +135 -0
- package/src/services/locale/countries.ts +483 -0
- package/src/services/mailing-lists/mailing-list-subscriber-service.ts +54 -0
- package/src/services/process/sleep.ts +7 -0
- package/src/services/quotas/mutate-service.ts +66 -0
- package/src/services/quotas/query-service.ts +197 -0
- package/src/services/quotas/utils-service.ts +29 -0
- package/src/services/tech/tech-provider-mutate-service.ts +136 -0
- package/src/services/tech/tech-query-service.ts +93 -0
- package/src/services/user-preference/service.ts +110 -0
- package/src/services/users/external-user-integration-service.ts +51 -0
- package/src/services/users/profile-service.ts +513 -0
- package/src/services/users/service.ts +293 -0
- package/src/services/users/user-error-service.ts +74 -0
- package/src/services/users/users-group-service.ts +85 -0
- package/src/services/utils/field-naming-service.ts +78 -0
- package/src/services/utils/string-utils-service.ts +48 -0
- package/src/types/errors.ts +18 -0
- package/src/types/user-types.ts +19 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChatParticipantModel = void 0;
|
|
13
|
+
const errors_1 = require("../../types/errors");
|
|
14
|
+
const service_1 = require("../../services/users/service");
|
|
15
|
+
class ChatParticipantModel {
|
|
16
|
+
constructor() {
|
|
17
|
+
// Consts
|
|
18
|
+
this.clName = 'ChatParticipantModel';
|
|
19
|
+
// Services
|
|
20
|
+
this.usersService = new service_1.UsersService();
|
|
21
|
+
}
|
|
22
|
+
// Code
|
|
23
|
+
create(prisma, id, chatSessionId, userProfileId) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
// Debug
|
|
26
|
+
const fnName = `${this.clName}.create()`;
|
|
27
|
+
// Validate
|
|
28
|
+
if (userProfileId == null) {
|
|
29
|
+
console.error(`${fnName}: userProfileId not specified`);
|
|
30
|
+
throw `Validation error`;
|
|
31
|
+
}
|
|
32
|
+
// Create record
|
|
33
|
+
try {
|
|
34
|
+
return yield prisma.chatParticipant.create({
|
|
35
|
+
data: {
|
|
36
|
+
id: id,
|
|
37
|
+
chatSessionId: chatSessionId,
|
|
38
|
+
userProfileId: userProfileId
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error(`${fnName}: error: ${error}`);
|
|
44
|
+
throw 'Prisma error';
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
deleteByChatSessionId(prisma, chatSessionId) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
// Debug
|
|
51
|
+
const fnName = `${this.clName}.deleteByChatSessionId()`;
|
|
52
|
+
// Delete records
|
|
53
|
+
try {
|
|
54
|
+
yield prisma.chatParticipant.deleteMany({
|
|
55
|
+
where: {
|
|
56
|
+
chatSessionId: chatSessionId
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
console.error(`${fnName}: error: ${error}`);
|
|
62
|
+
throw 'Prisma error';
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getById(prisma, id) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
// Debug
|
|
69
|
+
const fnName = `${this.clName}.getById()`;
|
|
70
|
+
// Query record
|
|
71
|
+
var chatParticipant = undefined;
|
|
72
|
+
try {
|
|
73
|
+
chatParticipant = yield prisma.chatParticipant.findUnique({
|
|
74
|
+
where: {
|
|
75
|
+
id: id
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!(error instanceof error.NotFound)) {
|
|
81
|
+
console.error(`${fnName}: error: ${error}`);
|
|
82
|
+
throw 'Prisma error';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Return OK
|
|
86
|
+
return chatParticipant;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getByChatSessionId(prisma, chatSessionId) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
// Debug
|
|
92
|
+
const fnName = `${this.clName}.getByChatSessionId()`;
|
|
93
|
+
// Get by chatSessionId
|
|
94
|
+
// Query records
|
|
95
|
+
try {
|
|
96
|
+
return yield prisma.chatParticipant.findMany({
|
|
97
|
+
where: {
|
|
98
|
+
chatSessionId: chatSessionId
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
if (!(error instanceof error.NotFound)) {
|
|
104
|
+
console.error(`${fnName}: error: ${error}`);
|
|
105
|
+
throw 'Prisma error';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getByChatSessionIdAndOwnerType(prisma, chatSessionId, ownerType) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
// Debug
|
|
113
|
+
const fnName = `${this.clName}.getByChatSessionId()`;
|
|
114
|
+
// Query record
|
|
115
|
+
try {
|
|
116
|
+
return yield prisma.chatParticipant.findFirst({
|
|
117
|
+
where: {
|
|
118
|
+
chatSessionId: chatSessionId,
|
|
119
|
+
userProfile: {
|
|
120
|
+
ownerType: ownerType
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (!(error instanceof error.NotFound)) {
|
|
127
|
+
console.error(`${fnName}: error: ${error}`);
|
|
128
|
+
throw 'Prisma error';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
getByChatSessionIdAndUserProfileId(prisma, chatSessionId, userProfileId) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
// Debug
|
|
136
|
+
const fnName = `${this.clName}.getByChatSessionId()`;
|
|
137
|
+
// Query record
|
|
138
|
+
try {
|
|
139
|
+
return yield prisma.chatParticipant.findFirst({
|
|
140
|
+
where: {
|
|
141
|
+
chatSessionId: chatSessionId,
|
|
142
|
+
userProfileId: userProfileId
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (!(error instanceof error.NotFound)) {
|
|
148
|
+
console.error(`${fnName}: error: ${error}`);
|
|
149
|
+
throw 'Prisma error';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
getParticipantTypeByUserProfileId(prisma, userProfileId) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
// Debug
|
|
157
|
+
const fnName = `${this.clName}.getParticipantTypeByUserProfileId()`;
|
|
158
|
+
// Query record
|
|
159
|
+
const userProfile = yield this.usersService.getById(prisma, userProfileId);
|
|
160
|
+
// Validate
|
|
161
|
+
if (userProfile == null) {
|
|
162
|
+
throw new errors_1.CustomError(`${fnName}: userProfile == null`);
|
|
163
|
+
}
|
|
164
|
+
// Return OK
|
|
165
|
+
return userProfile.ownerType;
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
update(prisma, id, chatSessionId, userProfileId) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
// Debug
|
|
171
|
+
const fnName = `${this.clName}.update()`;
|
|
172
|
+
// Create record
|
|
173
|
+
try {
|
|
174
|
+
return yield prisma.chatParticipant.update({
|
|
175
|
+
data: {
|
|
176
|
+
chatSessionId: chatSessionId,
|
|
177
|
+
userProfileId: userProfileId
|
|
178
|
+
},
|
|
179
|
+
where: {
|
|
180
|
+
id: id
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
console.error(`${fnName}: error: ${error}`);
|
|
186
|
+
throw 'Prisma error';
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
upsert(prisma, id, chatSessionId, userProfileId) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
// Debug
|
|
193
|
+
const fnName = `${this.clName}.upsert()`;
|
|
194
|
+
// If the id is specified, try to get it
|
|
195
|
+
if (id != null) {
|
|
196
|
+
const chatParticipant = yield this.getById(prisma, id);
|
|
197
|
+
if (chatParticipant != null) {
|
|
198
|
+
id = chatParticipant.id;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Upsert
|
|
202
|
+
if (id == null) {
|
|
203
|
+
return yield this.create(prisma, id, chatSessionId, userProfileId);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
return yield this.update(prisma, id, chatSessionId, userProfileId);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.ChatParticipantModel = ChatParticipantModel;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
export declare class ChatSessionModel {
|
|
3
|
+
clName: string;
|
|
4
|
+
create(prisma: PrismaClient, id: string | undefined, chatSettingsId: string, instanceId: string | null, status: string, isEncryptedAtRest: boolean, name: string | null, externalIntegration: string | null, externalId: string | null, createdById: string): Promise<{
|
|
5
|
+
name: string | null;
|
|
6
|
+
id: string;
|
|
7
|
+
status: string;
|
|
8
|
+
token: string;
|
|
9
|
+
externalIntegration: string | null;
|
|
10
|
+
created: Date;
|
|
11
|
+
updated: Date;
|
|
12
|
+
externalId: string | null;
|
|
13
|
+
instanceId: string | null;
|
|
14
|
+
chatSettingsId: string;
|
|
15
|
+
isEncryptedAtRest: boolean;
|
|
16
|
+
createdById: string;
|
|
17
|
+
}>;
|
|
18
|
+
deleteById(prisma: PrismaClient, id: string): Promise<{
|
|
19
|
+
name: string | null;
|
|
20
|
+
id: string;
|
|
21
|
+
status: string;
|
|
22
|
+
token: string;
|
|
23
|
+
externalIntegration: string | null;
|
|
24
|
+
created: Date;
|
|
25
|
+
updated: Date;
|
|
26
|
+
externalId: string | null;
|
|
27
|
+
instanceId: string | null;
|
|
28
|
+
chatSettingsId: string;
|
|
29
|
+
isEncryptedAtRest: boolean;
|
|
30
|
+
createdById: string;
|
|
31
|
+
}>;
|
|
32
|
+
deleteByIdCascade(prisma: PrismaClient, id: string): Promise<void>;
|
|
33
|
+
deleteByInstanceId(prisma: PrismaClient, instanceId: string): Promise<void>;
|
|
34
|
+
filter(prisma: PrismaClient, instanceId: string | null | undefined, status: string | undefined, isEncryptedAtRest: boolean | undefined, externalIntegration: string | null | undefined, createdById: string | undefined): Promise<{
|
|
35
|
+
name: string | null;
|
|
36
|
+
id: string;
|
|
37
|
+
status: string;
|
|
38
|
+
token: string;
|
|
39
|
+
externalIntegration: string | null;
|
|
40
|
+
created: Date;
|
|
41
|
+
updated: Date;
|
|
42
|
+
externalId: string | null;
|
|
43
|
+
instanceId: string | null;
|
|
44
|
+
chatSettingsId: string;
|
|
45
|
+
isEncryptedAtRest: boolean;
|
|
46
|
+
createdById: string;
|
|
47
|
+
}[] | undefined>;
|
|
48
|
+
getByDaysAgo(prisma: PrismaClient, daysAgo: number, status?: string | undefined): Promise<{
|
|
49
|
+
name: string | null;
|
|
50
|
+
id: string;
|
|
51
|
+
status: string;
|
|
52
|
+
token: string;
|
|
53
|
+
externalIntegration: string | null;
|
|
54
|
+
created: Date;
|
|
55
|
+
updated: Date;
|
|
56
|
+
externalId: string | null;
|
|
57
|
+
instanceId: string | null;
|
|
58
|
+
chatSettingsId: string;
|
|
59
|
+
isEncryptedAtRest: boolean;
|
|
60
|
+
createdById: string;
|
|
61
|
+
}[] | undefined>;
|
|
62
|
+
getByExternalIntegrationAndExternalId(prisma: PrismaClient, externalIntegration: string, externalId: string, includeChatSettings?: boolean): Promise<any>;
|
|
63
|
+
getById(prisma: PrismaClient, id: string, includeChatSettings?: boolean): Promise<any>;
|
|
64
|
+
update(prisma: PrismaClient, id: string, chatSettingsId: string | undefined, instanceId: string | null | undefined, status: string | undefined, isEncryptedAtRest: boolean | undefined, name: string | null | undefined, externalIntegration: string | null | undefined, externalId: string | null | undefined, createdById: string | undefined): Promise<{
|
|
65
|
+
name: string | null;
|
|
66
|
+
id: string;
|
|
67
|
+
status: string;
|
|
68
|
+
token: string;
|
|
69
|
+
externalIntegration: string | null;
|
|
70
|
+
created: Date;
|
|
71
|
+
updated: Date;
|
|
72
|
+
externalId: string | null;
|
|
73
|
+
instanceId: string | null;
|
|
74
|
+
chatSettingsId: string;
|
|
75
|
+
isEncryptedAtRest: boolean;
|
|
76
|
+
createdById: string;
|
|
77
|
+
}>;
|
|
78
|
+
upsert(prisma: PrismaClient, id: string, chatSettingsId: string | undefined, instanceId: string | null | undefined, status: string | undefined, isEncryptedAtRest: boolean | undefined, name: string | null | undefined, externalIntegration: string | null | undefined, externalId: string | null | undefined, createdById: string): Promise<{
|
|
79
|
+
name: string | null;
|
|
80
|
+
id: string;
|
|
81
|
+
status: string;
|
|
82
|
+
token: string;
|
|
83
|
+
externalIntegration: string | null;
|
|
84
|
+
created: Date;
|
|
85
|
+
updated: Date;
|
|
86
|
+
externalId: string | null;
|
|
87
|
+
instanceId: string | null;
|
|
88
|
+
chatSettingsId: string;
|
|
89
|
+
isEncryptedAtRest: boolean;
|
|
90
|
+
createdById: string;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChatSessionModel = void 0;
|
|
13
|
+
const { v4: uuidv4 } = require('uuid');
|
|
14
|
+
const errors_1 = require("../../types/errors");
|
|
15
|
+
const chat_participant_model_1 = require("./chat-participant-model");
|
|
16
|
+
// Models
|
|
17
|
+
const chatParticipantModel = new chat_participant_model_1.ChatParticipantModel();
|
|
18
|
+
// Class
|
|
19
|
+
class ChatSessionModel {
|
|
20
|
+
constructor() {
|
|
21
|
+
// Consts
|
|
22
|
+
this.clName = 'ChatSessionModel';
|
|
23
|
+
}
|
|
24
|
+
// Code
|
|
25
|
+
create(prisma, id, chatSettingsId, instanceId, status, isEncryptedAtRest, name, externalIntegration, externalId, createdById) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
// Debug
|
|
28
|
+
const fnName = `${this.clName}.create()`;
|
|
29
|
+
// Generate a token
|
|
30
|
+
const token = uuidv4();
|
|
31
|
+
// Create record
|
|
32
|
+
try {
|
|
33
|
+
return yield prisma.chatSession.create({
|
|
34
|
+
data: {
|
|
35
|
+
id: id,
|
|
36
|
+
chatSettingsId: chatSettingsId,
|
|
37
|
+
instanceId: instanceId,
|
|
38
|
+
status: status,
|
|
39
|
+
isEncryptedAtRest: isEncryptedAtRest,
|
|
40
|
+
token: token,
|
|
41
|
+
name: name,
|
|
42
|
+
externalIntegration: externalIntegration,
|
|
43
|
+
externalId: externalId,
|
|
44
|
+
createdById: createdById
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(`${fnName}: error: ${error}`);
|
|
50
|
+
throw 'Prisma error';
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
deleteById(prisma, id) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
// Debug
|
|
57
|
+
const fnName = `${this.clName}.deleteById()`;
|
|
58
|
+
// Delete chat session
|
|
59
|
+
try {
|
|
60
|
+
return yield prisma.chatSession.delete({
|
|
61
|
+
where: {
|
|
62
|
+
id: id
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(`${fnName}: error: ${error}`);
|
|
68
|
+
throw 'Prisma error';
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
deleteByIdCascade(prisma, id) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
// Debug
|
|
75
|
+
const fnName = `${this.clName}.deleteByIdCascade()`;
|
|
76
|
+
// Delete chat messages (code copied directly from chat-message-model.ts
|
|
77
|
+
// to avoid setting the encryption key via the constructor).
|
|
78
|
+
try {
|
|
79
|
+
yield prisma.chatMessage.deleteMany({
|
|
80
|
+
where: {
|
|
81
|
+
chatSessionId: id
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error(`${fnName}: error: ${error}`);
|
|
87
|
+
throw 'Prisma error';
|
|
88
|
+
}
|
|
89
|
+
// Delete chat participants
|
|
90
|
+
yield chatParticipantModel.deleteByChatSessionId(prisma, id);
|
|
91
|
+
// Delete chat session
|
|
92
|
+
yield this.deleteById(prisma, id);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
deleteByInstanceId(prisma, instanceId) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
// Debug
|
|
98
|
+
const fnName = `${this.clName}.deleteByInstanceId()`;
|
|
99
|
+
// Get records for the instanceId
|
|
100
|
+
const chatSessions = yield this.filter(prisma, instanceId, undefined, undefined, undefined, undefined);
|
|
101
|
+
// Validate
|
|
102
|
+
if (chatSessions == null) {
|
|
103
|
+
throw new errors_1.CustomError(`${fnName}: chatSessions == null`);
|
|
104
|
+
}
|
|
105
|
+
// Delete cascade each chat session
|
|
106
|
+
for (const chatSession of chatSessions) {
|
|
107
|
+
yield this.deleteByIdCascade(prisma, chatSession.id);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
filter(prisma, instanceId, status, isEncryptedAtRest, externalIntegration, createdById) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
// Debug
|
|
114
|
+
const fnName = `${this.clName}.filter()`;
|
|
115
|
+
// Query records
|
|
116
|
+
try {
|
|
117
|
+
return yield prisma.chatSession.findMany({
|
|
118
|
+
where: {
|
|
119
|
+
instanceId: instanceId,
|
|
120
|
+
status: status,
|
|
121
|
+
isEncryptedAtRest: isEncryptedAtRest,
|
|
122
|
+
externalIntegration: externalIntegration,
|
|
123
|
+
createdById: createdById
|
|
124
|
+
},
|
|
125
|
+
orderBy: [
|
|
126
|
+
{
|
|
127
|
+
created: 'desc'
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
if (!(error instanceof error.NotFound)) {
|
|
134
|
+
console.error(`${fnName}: error: ${error}`);
|
|
135
|
+
throw 'Prisma error';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
getByDaysAgo(prisma_1, daysAgo_1) {
|
|
141
|
+
return __awaiter(this, arguments, void 0, function* (prisma, daysAgo, status = undefined) {
|
|
142
|
+
// Debug
|
|
143
|
+
const fnName = `${this.clName}.getByDaysAgo()`;
|
|
144
|
+
// Days ago
|
|
145
|
+
const day = 1000 * 60 * 60 * 24;
|
|
146
|
+
const daysAgoTime = day * daysAgo;
|
|
147
|
+
const daysAgoDate = new Date(new Date().getTime() - daysAgoTime);
|
|
148
|
+
// Query records
|
|
149
|
+
try {
|
|
150
|
+
return yield prisma.chatSession.findMany({
|
|
151
|
+
where: {
|
|
152
|
+
status: status,
|
|
153
|
+
created: {
|
|
154
|
+
lt: daysAgoDate
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (!(error instanceof error.NotFound)) {
|
|
161
|
+
console.error(`${fnName}: error: ${error}`);
|
|
162
|
+
throw 'Prisma error';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
getByExternalIntegrationAndExternalId(prisma_1, externalIntegration_1, externalId_1) {
|
|
168
|
+
return __awaiter(this, arguments, void 0, function* (prisma, externalIntegration, externalId, includeChatSettings = false) {
|
|
169
|
+
// Debug
|
|
170
|
+
const fnName = `${this.clName}.getByExternalIntegrationAndExternalId()`;
|
|
171
|
+
// Query record
|
|
172
|
+
var chatSession = undefined;
|
|
173
|
+
try {
|
|
174
|
+
chatSession = yield prisma.chatSession.findFirst({
|
|
175
|
+
include: {
|
|
176
|
+
chatSettings: includeChatSettings
|
|
177
|
+
},
|
|
178
|
+
where: {
|
|
179
|
+
externalIntegration: externalIntegration,
|
|
180
|
+
externalId: externalId
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
if (!(error instanceof error.NotFound)) {
|
|
186
|
+
console.error(`${fnName}: error: ${error}`);
|
|
187
|
+
throw 'Prisma error';
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Return OK
|
|
191
|
+
return chatSession;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
getById(prisma_1, id_1) {
|
|
195
|
+
return __awaiter(this, arguments, void 0, function* (prisma, id, includeChatSettings = false) {
|
|
196
|
+
// Debug
|
|
197
|
+
const fnName = `${this.clName}.getById()`;
|
|
198
|
+
// Query record
|
|
199
|
+
var chatSession = undefined;
|
|
200
|
+
try {
|
|
201
|
+
chatSession = yield prisma.chatSession.findUnique({
|
|
202
|
+
include: {
|
|
203
|
+
chatSettings: includeChatSettings
|
|
204
|
+
},
|
|
205
|
+
where: {
|
|
206
|
+
id: id
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (!(error instanceof error.NotFound)) {
|
|
212
|
+
console.error(`${fnName}: error: ${error}`);
|
|
213
|
+
throw 'Prisma error';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Return OK
|
|
217
|
+
return chatSession;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
update(prisma, id, chatSettingsId, instanceId, status, isEncryptedAtRest, name, externalIntegration, externalId, createdById) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
// Debug
|
|
223
|
+
const fnName = `${this.clName}.update()`;
|
|
224
|
+
// Update record
|
|
225
|
+
try {
|
|
226
|
+
return yield prisma.chatSession.update({
|
|
227
|
+
data: {
|
|
228
|
+
chatSettingsId: chatSettingsId,
|
|
229
|
+
instanceId: instanceId,
|
|
230
|
+
status: status,
|
|
231
|
+
isEncryptedAtRest: isEncryptedAtRest,
|
|
232
|
+
name: name,
|
|
233
|
+
externalIntegration: externalIntegration,
|
|
234
|
+
externalId: externalId,
|
|
235
|
+
createdById: createdById
|
|
236
|
+
},
|
|
237
|
+
where: {
|
|
238
|
+
id: id
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
console.error(`${fnName}: error: ${error}`);
|
|
244
|
+
throw 'Prisma error';
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
upsert(prisma, id, chatSettingsId, instanceId, status, isEncryptedAtRest, name, externalIntegration, externalId, createdById) {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
// Debug
|
|
251
|
+
const fnName = `${this.clName}.upsert()`;
|
|
252
|
+
// If the id is specified, try to get it
|
|
253
|
+
if (id != null) {
|
|
254
|
+
const chatSession = yield this.getById(prisma, id);
|
|
255
|
+
if (chatSession != null) {
|
|
256
|
+
id = chatSession.id;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// Upsert
|
|
260
|
+
if (id == null) {
|
|
261
|
+
// Validate for create (mainly for type validation of the create call)
|
|
262
|
+
if (chatSettingsId == null) {
|
|
263
|
+
console.error(`${fnName}: id is null and chatSettingsId is null`);
|
|
264
|
+
throw 'Prisma error';
|
|
265
|
+
}
|
|
266
|
+
if (instanceId === undefined) {
|
|
267
|
+
console.error(`${fnName}: id is null and instanceId is undefined`);
|
|
268
|
+
throw 'Prisma error';
|
|
269
|
+
}
|
|
270
|
+
if (status == null) {
|
|
271
|
+
console.error(`${fnName}: id is null and status is null`);
|
|
272
|
+
throw 'Prisma error';
|
|
273
|
+
}
|
|
274
|
+
if (name === undefined) {
|
|
275
|
+
console.error(`${fnName}: id is null and name is undefined`);
|
|
276
|
+
throw 'Prisma error';
|
|
277
|
+
}
|
|
278
|
+
if (externalIntegration === undefined) {
|
|
279
|
+
console.error(`${fnName}: id is null and externalIntegration is undefined`);
|
|
280
|
+
throw 'Prisma error';
|
|
281
|
+
}
|
|
282
|
+
if (externalId === undefined) {
|
|
283
|
+
console.error(`${fnName}: id is null and externalId is undefined`);
|
|
284
|
+
throw 'Prisma error';
|
|
285
|
+
}
|
|
286
|
+
if (isEncryptedAtRest == null) {
|
|
287
|
+
console.error(`${fnName}: id is null and isEncryptedAtRest is null`);
|
|
288
|
+
throw 'Prisma error';
|
|
289
|
+
}
|
|
290
|
+
// Create
|
|
291
|
+
return yield this.create(prisma, undefined, // id
|
|
292
|
+
chatSettingsId, instanceId, status, isEncryptedAtRest, name, externalIntegration, externalId, createdById);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
// Update
|
|
296
|
+
return yield this.update(prisma, id, chatSettingsId, instanceId, status, isEncryptedAtRest, name, externalIntegration, externalId, createdById);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.ChatSessionModel = ChatSessionModel;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PrismaClient } from '@prisma/client';
|
|
2
|
+
export declare class ChatSettingsModel {
|
|
3
|
+
clName: string;
|
|
4
|
+
create(prisma: PrismaClient, baseChatSettingsId: string | null, status: string, isEncryptedAtRest: boolean, isJsonMode: boolean, isPinned: boolean, name: string | null, agentUserId: string, prompt: string | null, appCustom: any | null, createdById: string): Promise<{
|
|
5
|
+
name: string | null;
|
|
6
|
+
id: string;
|
|
7
|
+
prompt: string | null;
|
|
8
|
+
status: string;
|
|
9
|
+
created: Date;
|
|
10
|
+
updated: Date;
|
|
11
|
+
isEncryptedAtRest: boolean;
|
|
12
|
+
createdById: string;
|
|
13
|
+
baseChatSettingsId: string | null;
|
|
14
|
+
isJsonMode: boolean;
|
|
15
|
+
isPinned: boolean;
|
|
16
|
+
agentUserId: string;
|
|
17
|
+
agentRole: string | null;
|
|
18
|
+
appCustom: import("@prisma/client/runtime/library").JsonValue | null;
|
|
19
|
+
}>;
|
|
20
|
+
deleteById(prisma: PrismaClient, id: string): Promise<void>;
|
|
21
|
+
getById(prisma: PrismaClient, id: string): Promise<any>;
|
|
22
|
+
getByName(prisma: PrismaClient, name: string): Promise<any>;
|
|
23
|
+
getByBaseChatSettingsId(prisma: PrismaClient, baseChatSettingsId: string | null | undefined): Promise<{
|
|
24
|
+
name: string | null;
|
|
25
|
+
id: string;
|
|
26
|
+
prompt: string | null;
|
|
27
|
+
status: string;
|
|
28
|
+
created: Date;
|
|
29
|
+
updated: Date;
|
|
30
|
+
isEncryptedAtRest: boolean;
|
|
31
|
+
createdById: string;
|
|
32
|
+
baseChatSettingsId: string | null;
|
|
33
|
+
isJsonMode: boolean;
|
|
34
|
+
isPinned: boolean;
|
|
35
|
+
agentUserId: string;
|
|
36
|
+
agentRole: string | null;
|
|
37
|
+
appCustom: import("@prisma/client/runtime/library").JsonValue | null;
|
|
38
|
+
}[]>;
|
|
39
|
+
getUnused(prisma: PrismaClient): Promise<{
|
|
40
|
+
name: string | null;
|
|
41
|
+
id: string;
|
|
42
|
+
prompt: string | null;
|
|
43
|
+
status: string;
|
|
44
|
+
created: Date;
|
|
45
|
+
updated: Date;
|
|
46
|
+
isEncryptedAtRest: boolean;
|
|
47
|
+
createdById: string;
|
|
48
|
+
baseChatSettingsId: string | null;
|
|
49
|
+
isJsonMode: boolean;
|
|
50
|
+
isPinned: boolean;
|
|
51
|
+
agentUserId: string;
|
|
52
|
+
agentRole: string | null;
|
|
53
|
+
appCustom: import("@prisma/client/runtime/library").JsonValue | null;
|
|
54
|
+
}[]>;
|
|
55
|
+
update(prisma: PrismaClient, id: string, baseChatSettingsId: string | null | undefined, status: string | undefined, isEncryptedAtRest: boolean | undefined, isJsonMode: boolean | undefined, isPinned: boolean | undefined, name: string | null | undefined, agentUserId: string | undefined, prompt: string | null | undefined, appCustom: any | null | undefined, createdById: string | undefined): Promise<{
|
|
56
|
+
name: string | null;
|
|
57
|
+
id: string;
|
|
58
|
+
prompt: string | null;
|
|
59
|
+
status: string;
|
|
60
|
+
created: Date;
|
|
61
|
+
updated: Date;
|
|
62
|
+
isEncryptedAtRest: boolean;
|
|
63
|
+
createdById: string;
|
|
64
|
+
baseChatSettingsId: string | null;
|
|
65
|
+
isJsonMode: boolean;
|
|
66
|
+
isPinned: boolean;
|
|
67
|
+
agentUserId: string;
|
|
68
|
+
agentRole: string | null;
|
|
69
|
+
appCustom: import("@prisma/client/runtime/library").JsonValue | null;
|
|
70
|
+
}>;
|
|
71
|
+
upsert(prisma: PrismaClient, id: string | undefined, baseChatSettingsId: string | null | undefined, status: string | undefined, isEncryptedAtRest: boolean | undefined, isJsonMode: boolean | undefined, isPinned: boolean | undefined, name: string | null | undefined, agentUserId: string | undefined, prompt: string | null | undefined, appCustom: any | null | undefined, createdById: string | undefined): Promise<{
|
|
72
|
+
name: string | null;
|
|
73
|
+
id: string;
|
|
74
|
+
prompt: string | null;
|
|
75
|
+
status: string;
|
|
76
|
+
created: Date;
|
|
77
|
+
updated: Date;
|
|
78
|
+
isEncryptedAtRest: boolean;
|
|
79
|
+
createdById: string;
|
|
80
|
+
baseChatSettingsId: string | null;
|
|
81
|
+
isJsonMode: boolean;
|
|
82
|
+
isPinned: boolean;
|
|
83
|
+
agentUserId: string;
|
|
84
|
+
agentRole: string | null;
|
|
85
|
+
appCustom: import("@prisma/client/runtime/library").JsonValue | null;
|
|
86
|
+
}>;
|
|
87
|
+
}
|