@hed-hog/core 0.0.354 → 0.0.356
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/ai/ai.service.d.ts +3 -12
- package/dist/ai/ai.service.d.ts.map +1 -1
- package/dist/ai/ai.service.js +34 -125
- package/dist/ai/ai.service.js.map +1 -1
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +3 -3
- package/dist/core.module.js.map +1 -1
- package/dist/file/file.service.d.ts +1 -1
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +50 -64
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/provider/provider.enum.d.ts +2 -1
- package/dist/file/provider/provider.enum.d.ts.map +1 -1
- package/dist/file/provider/provider.enum.js +1 -0
- package/dist/file/provider/provider.enum.js.map +1 -1
- package/dist/file/provider/provider.factory.d.ts.map +1 -1
- package/dist/file/provider/provider.factory.js +3 -0
- package/dist/file/provider/provider.factory.js.map +1 -1
- package/dist/file/provider/spaces.provider.d.ts +27 -0
- package/dist/file/provider/spaces.provider.d.ts.map +1 -0
- package/dist/file/provider/spaces.provider.js +218 -0
- package/dist/file/provider/spaces.provider.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/integration-profile/dto/create.dto.d.ts +9 -0
- package/dist/integration-profile/dto/create.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/create.dto.js +54 -0
- package/dist/integration-profile/dto/create.dto.js.map +1 -0
- package/dist/integration-profile/dto/export.dto.d.ts +5 -0
- package/dist/integration-profile/dto/export.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/export.dto.js +29 -0
- package/dist/integration-profile/dto/export.dto.js.map +1 -0
- package/dist/integration-profile/dto/import-confirm.dto.d.ts +17 -0
- package/dist/integration-profile/dto/import-confirm.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/import-confirm.dto.js +77 -0
- package/dist/integration-profile/dto/import-confirm.dto.js.map +1 -0
- package/dist/integration-profile/dto/update.dto.d.ts +6 -0
- package/dist/integration-profile/dto/update.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/update.dto.js +9 -0
- package/dist/integration-profile/dto/update.dto.js.map +1 -0
- package/dist/integration-profile/integration-profile.controller.d.ts +142 -0
- package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.controller.js +165 -0
- package/dist/integration-profile/integration-profile.controller.js.map +1 -0
- package/dist/integration-profile/integration-profile.module.d.ts +3 -0
- package/dist/integration-profile/integration-profile.module.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.module.js +29 -0
- package/dist/integration-profile/integration-profile.module.js.map +1 -0
- package/dist/integration-profile/integration-profile.service.d.ts +160 -0
- package/dist/integration-profile/integration-profile.service.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.service.js +606 -0
- package/dist/integration-profile/integration-profile.service.js.map +1 -0
- package/dist/integration-profile/integration-profile.utils.d.ts +24 -0
- package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.utils.js +147 -0
- package/dist/integration-profile/integration-profile.utils.js.map +1 -0
- package/dist/mail/mail.module.d.ts.map +1 -1
- package/dist/mail/mail.module.js +27 -19
- package/dist/mail/mail.module.js.map +1 -1
- package/dist/mail/mail.service.d.ts +3 -2
- package/dist/mail/mail.service.d.ts.map +1 -1
- package/dist/mail/mail.service.js +25 -47
- package/dist/mail/mail.service.js.map +1 -1
- package/dist/mcp/mcp.module.js +2 -2
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +3 -15
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js +12 -94
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.js +17 -16
- package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +0 -2
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/webhook-integration/event-webhook.controller.d.ts +1 -0
- package/dist/webhook-integration/event-webhook.controller.d.ts.map +1 -1
- package/dist/webhook-integration/event-webhook.controller.js +10 -0
- package/dist/webhook-integration/event-webhook.controller.js.map +1 -1
- package/dist/webhook-integration/event-webhook.service.d.ts +2 -0
- package/dist/webhook-integration/event-webhook.service.d.ts.map +1 -1
- package/dist/webhook-integration/event-webhook.service.js +30 -0
- package/dist/webhook-integration/event-webhook.service.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.d.ts +1 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.js +10 -0
- package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts +2 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +62 -44
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/dist/whatsapp-profile/dto/create.dto.d.ts +11 -0
- package/dist/whatsapp-profile/dto/create.dto.d.ts.map +1 -0
- package/dist/whatsapp-profile/dto/create.dto.js +55 -0
- package/dist/whatsapp-profile/dto/create.dto.js.map +1 -0
- package/dist/whatsapp-profile/dto/update.dto.d.ts +6 -0
- package/dist/whatsapp-profile/dto/update.dto.d.ts.map +1 -0
- package/dist/whatsapp-profile/dto/update.dto.js +9 -0
- package/dist/whatsapp-profile/dto/update.dto.js.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts +54 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.js +85 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.js.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts +3 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.js +26 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.js.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts +63 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.js +138 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.js.map +1 -0
- package/hedhog/data/file_provider.yaml +9 -1
- package/hedhog/data/integration_provider.yaml +132 -0
- package/hedhog/data/integration_type.yaml +29 -0
- package/hedhog/data/menu.yaml +15 -14
- package/hedhog/data/role.yaml +8 -0
- package/hedhog/data/route.yaml +66 -15
- package/hedhog/data/setting_group.yaml +30 -191
- package/hedhog/data/setting_subgroup.yaml +5 -13
- package/hedhog/data/whatsapp_profile.yaml +6 -0
- package/hedhog/frontend/app/account/components/connected-accounts.tsx.ejs +25 -20
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +579 -204
- package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +1662 -0
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +233 -108
- package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +3 -822
- package/hedhog/frontend/app/users/permissions.tsx.ejs +79 -2
- package/hedhog/frontend/app/users/user-sheet.tsx.ejs +7 -2
- package/hedhog/frontend/messages/en.json +172 -0
- package/hedhog/frontend/messages/pt.json +172 -0
- package/hedhog/table/integration_profile.yaml +34 -0
- package/hedhog/table/integration_provider.yaml +23 -0
- package/hedhog/table/integration_type.yaml +19 -0
- package/hedhog/table/webhook_action.yaml +85 -85
- package/hedhog/table/whatsapp_profile.yaml +26 -0
- package/package.json +2 -2
- package/src/ai/ai.service.ts +35 -153
- package/src/core.module.ts +3 -3
- package/src/file/file.service.ts +60 -76
- package/src/file/provider/provider.enum.ts +1 -0
- package/src/file/provider/provider.factory.ts +3 -0
- package/src/file/provider/spaces.provider.ts +261 -0
- package/src/index.ts +6 -3
- package/src/integration-profile/dto/create.dto.ts +44 -0
- package/src/integration-profile/dto/export.dto.ts +15 -0
- package/src/integration-profile/dto/import-confirm.dto.ts +61 -0
- package/src/integration-profile/dto/update.dto.ts +4 -0
- package/src/integration-profile/integration-profile.controller.ts +129 -0
- package/src/integration-profile/integration-profile.module.ts +16 -0
- package/src/integration-profile/integration-profile.service.ts +788 -0
- package/src/integration-profile/integration-profile.utils.ts +156 -0
- package/src/mail/mail.module.ts +27 -18
- package/src/mail/mail.service.ts +31 -60
- package/src/mcp/mcp.module.ts +2 -2
- package/src/mcp/tools/core-mail-profile.mcp-tools.ts +10 -69
- package/src/mcp-chat/mcp-chat.service.ts +23 -20
- package/src/setting/setting.service.ts +0 -2
- package/src/webhook-integration/event-webhook.controller.ts +55 -50
- package/src/webhook-integration/event-webhook.service.ts +422 -384
- package/src/webhook-integration/webhook-integration.controller.ts +5 -0
- package/src/webhook-integration/webhook-integration.service.ts +74 -46
- package/src/whatsapp-profile/dto/create.dto.ts +36 -0
- package/src/whatsapp-profile/dto/update.dto.ts +4 -0
- package/src/whatsapp-profile/whatsapp-profile.controller.ts +51 -0
- package/src/whatsapp-profile/whatsapp-profile.module.ts +13 -0
- package/src/whatsapp-profile/whatsapp-profile.service.ts +160 -0
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.IntegrationProfileService = void 0;
|
|
49
|
+
const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
50
|
+
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
51
|
+
const common_1 = require("@nestjs/common");
|
|
52
|
+
const pako = __importStar(require("pako"));
|
|
53
|
+
const integration_profile_utils_1 = require("./integration-profile.utils");
|
|
54
|
+
let IntegrationProfileService = class IntegrationProfileService {
|
|
55
|
+
constructor(prismaService, paginationService) {
|
|
56
|
+
this.prismaService = prismaService;
|
|
57
|
+
this.paginationService = paginationService;
|
|
58
|
+
}
|
|
59
|
+
async listTypes() {
|
|
60
|
+
return this.prismaService.integration_type.findMany({
|
|
61
|
+
orderBy: { id: 'asc' },
|
|
62
|
+
select: {
|
|
63
|
+
id: true,
|
|
64
|
+
slug: true,
|
|
65
|
+
icon: true,
|
|
66
|
+
integration_type_locale: {
|
|
67
|
+
select: { name: true, locale: { select: { code: true } } },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
async listProviders(typeId, typeSlug) {
|
|
73
|
+
const normalizedTypeSlug = String(typeSlug !== null && typeSlug !== void 0 ? typeSlug : '').trim();
|
|
74
|
+
return this.prismaService.integration_provider.findMany({
|
|
75
|
+
where: Object.assign(Object.assign({}, (typeId ? { type_id: typeId } : {})), (normalizedTypeSlug
|
|
76
|
+
? { integration_type: { slug: normalizedTypeSlug } }
|
|
77
|
+
: {})),
|
|
78
|
+
orderBy: { id: 'asc' },
|
|
79
|
+
select: {
|
|
80
|
+
id: true,
|
|
81
|
+
slug: true,
|
|
82
|
+
type_id: true,
|
|
83
|
+
integration_provider_locale: {
|
|
84
|
+
select: { name: true, locale: { select: { code: true } } },
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async list(paginationParams, typeId, typeSlug) {
|
|
90
|
+
const fields = ['slug', 'name'];
|
|
91
|
+
const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
|
|
92
|
+
const normalizedTypeSlug = String(typeSlug !== null && typeSlug !== void 0 ? typeSlug : '').trim();
|
|
93
|
+
const result = await this.paginationService.paginate(this.prismaService.integration_profile, paginationParams, {
|
|
94
|
+
where: Object.assign(Object.assign(Object.assign({}, (OR.length > 0 ? { OR } : {})), (typeId ? { type_id: typeId } : {})), (normalizedTypeSlug
|
|
95
|
+
? { integration_type: { slug: normalizedTypeSlug } }
|
|
96
|
+
: {})),
|
|
97
|
+
select: {
|
|
98
|
+
id: true,
|
|
99
|
+
slug: true,
|
|
100
|
+
name: true,
|
|
101
|
+
config: true,
|
|
102
|
+
type_id: true,
|
|
103
|
+
provider_id: true,
|
|
104
|
+
is_active: true,
|
|
105
|
+
created_at: true,
|
|
106
|
+
updated_at: true,
|
|
107
|
+
integration_type: {
|
|
108
|
+
select: {
|
|
109
|
+
slug: true,
|
|
110
|
+
icon: true,
|
|
111
|
+
integration_type_locale: {
|
|
112
|
+
select: { name: true, locale: { select: { code: true } } },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
integration_provider: {
|
|
117
|
+
select: {
|
|
118
|
+
slug: true,
|
|
119
|
+
integration_provider_locale: {
|
|
120
|
+
select: { name: true, locale: { select: { code: true } } },
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
orderBy: [{ updated_at: 'desc' }, { id: 'desc' }],
|
|
126
|
+
});
|
|
127
|
+
const items = Array.isArray(result.data) ? result.data : [];
|
|
128
|
+
if (items.length > 0) {
|
|
129
|
+
const ids = items.map((p) => p.id);
|
|
130
|
+
const counts = await this.prismaService.$queryRaw `
|
|
131
|
+
SELECT
|
|
132
|
+
ip.id,
|
|
133
|
+
(
|
|
134
|
+
COALESCE((SELECT COUNT(*)::int FROM campaign WHERE mail_profile_id = ip.id), 0) +
|
|
135
|
+
COALESCE((SELECT COUNT(*)::int FROM webhook_action WHERE mail_profile_id = ip.id), 0)
|
|
136
|
+
) AS uses_count
|
|
137
|
+
FROM integration_profile ip
|
|
138
|
+
WHERE ip.id = ANY(${ids}::int[])
|
|
139
|
+
`;
|
|
140
|
+
const countMap = new Map(counts.map((r) => [r.id, Number(r.uses_count)]));
|
|
141
|
+
result.data = items.map((p) => {
|
|
142
|
+
var _a;
|
|
143
|
+
return (Object.assign(Object.assign({}, p), { uses_count: (_a = countMap.get(p.id)) !== null && _a !== void 0 ? _a : 0 }));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
async get(id) {
|
|
149
|
+
const profile = await this.prismaService.integration_profile.findUnique({
|
|
150
|
+
where: { id },
|
|
151
|
+
include: {
|
|
152
|
+
integration_type: {
|
|
153
|
+
select: {
|
|
154
|
+
slug: true,
|
|
155
|
+
icon: true,
|
|
156
|
+
integration_type_locale: {
|
|
157
|
+
select: { name: true, locale: { select: { code: true } } },
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
integration_provider: {
|
|
162
|
+
select: {
|
|
163
|
+
slug: true,
|
|
164
|
+
integration_provider_locale: {
|
|
165
|
+
select: { name: true, locale: { select: { code: true } } },
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
if (!profile) {
|
|
172
|
+
throw new common_1.NotFoundException(`Integration profile with id ${id} not found.`);
|
|
173
|
+
}
|
|
174
|
+
return profile;
|
|
175
|
+
}
|
|
176
|
+
async create(data) {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
await this.ensureSlugIsAvailable(data.slug);
|
|
179
|
+
await this.validateTypeAndProvider(data.type_id, data.provider_id);
|
|
180
|
+
return this.prismaService.integration_profile.create({
|
|
181
|
+
data: {
|
|
182
|
+
slug: data.slug.trim(),
|
|
183
|
+
name: data.name.trim(),
|
|
184
|
+
type_id: data.type_id,
|
|
185
|
+
provider_id: data.provider_id,
|
|
186
|
+
config: (_a = data.config) !== null && _a !== void 0 ? _a : null,
|
|
187
|
+
is_active: (_b = data.is_active) !== null && _b !== void 0 ? _b : true,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async update({ id, data }) {
|
|
192
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
193
|
+
const existing = await this.prismaService.integration_profile.findUnique({
|
|
194
|
+
where: { id },
|
|
195
|
+
});
|
|
196
|
+
if (!existing) {
|
|
197
|
+
throw new common_1.NotFoundException(`Integration profile with id ${id} not found.`);
|
|
198
|
+
}
|
|
199
|
+
if (data.slug && data.slug !== existing.slug) {
|
|
200
|
+
await this.ensureSlugIsAvailable(data.slug);
|
|
201
|
+
}
|
|
202
|
+
const type_id = (_a = data.type_id) !== null && _a !== void 0 ? _a : existing.type_id;
|
|
203
|
+
const provider_id = (_b = data.provider_id) !== null && _b !== void 0 ? _b : existing.provider_id;
|
|
204
|
+
await this.validateTypeAndProvider(type_id, provider_id);
|
|
205
|
+
return this.prismaService.integration_profile.update({
|
|
206
|
+
where: { id },
|
|
207
|
+
data: {
|
|
208
|
+
slug: (_d = (_c = data.slug) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : existing.slug,
|
|
209
|
+
name: (_f = (_e = data.name) === null || _e === void 0 ? void 0 : _e.trim()) !== null && _f !== void 0 ? _f : existing.name,
|
|
210
|
+
type_id,
|
|
211
|
+
provider_id,
|
|
212
|
+
config: data.config !== undefined
|
|
213
|
+
? ((_g = data.config) !== null && _g !== void 0 ? _g : null)
|
|
214
|
+
: existing.config,
|
|
215
|
+
is_active: (_h = data.is_active) !== null && _h !== void 0 ? _h : existing.is_active,
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
async delete({ ids }) {
|
|
220
|
+
if (!(ids === null || ids === void 0 ? void 0 : ids.length)) {
|
|
221
|
+
throw new common_1.BadRequestException('You must select at least one item to delete.');
|
|
222
|
+
}
|
|
223
|
+
return this.prismaService.integration_profile.deleteMany({
|
|
224
|
+
where: { id: { in: ids } },
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
async test(data) {
|
|
228
|
+
var _a, _b;
|
|
229
|
+
await this.validateTypeAndProvider(data.type_id, data.provider_id);
|
|
230
|
+
const provider = await this.prismaService.integration_provider.findUnique({
|
|
231
|
+
where: { id: data.provider_id },
|
|
232
|
+
select: {
|
|
233
|
+
slug: true,
|
|
234
|
+
integration_type: {
|
|
235
|
+
select: {
|
|
236
|
+
slug: true,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
if (!provider) {
|
|
242
|
+
throw new common_1.BadRequestException(`Provider with id ${data.provider_id} not found.`);
|
|
243
|
+
}
|
|
244
|
+
if (provider.integration_type.slug !== 'email') {
|
|
245
|
+
throw new common_1.BadRequestException('Integration profile test is only available for email type.');
|
|
246
|
+
}
|
|
247
|
+
(0, integration_profile_utils_1.buildMailConfigFromIntegration)(provider.slug, data.config);
|
|
248
|
+
const destination = String((_b = (_a = data.config) === null || _a === void 0 ? void 0 : _a.from_email) !== null && _b !== void 0 ? _b : '').trim();
|
|
249
|
+
if (!destination) {
|
|
250
|
+
throw new common_1.BadRequestException('Sender email is required.');
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
success: true,
|
|
254
|
+
destination,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
async exportProfiles({ ids, includeSecrets = false, }) {
|
|
258
|
+
const rows = await this.prismaService.integration_profile.findMany({
|
|
259
|
+
where: (ids === null || ids === void 0 ? void 0 : ids.length) ? { id: { in: ids } } : undefined,
|
|
260
|
+
select: {
|
|
261
|
+
slug: true,
|
|
262
|
+
name: true,
|
|
263
|
+
config: true,
|
|
264
|
+
is_active: true,
|
|
265
|
+
integration_type: {
|
|
266
|
+
select: { slug: true },
|
|
267
|
+
},
|
|
268
|
+
integration_provider: {
|
|
269
|
+
select: { slug: true },
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
orderBy: [{ slug: 'asc' }],
|
|
273
|
+
});
|
|
274
|
+
const payload = rows.map((row) => ({
|
|
275
|
+
slug: row.slug,
|
|
276
|
+
name: row.name,
|
|
277
|
+
type_slug: row.integration_type.slug,
|
|
278
|
+
provider_slug: row.integration_provider.slug,
|
|
279
|
+
config: this.sanitizeConfigForExport(row.integration_provider.slug, row.config, includeSecrets),
|
|
280
|
+
is_active: row.is_active,
|
|
281
|
+
}));
|
|
282
|
+
const envelope = {
|
|
283
|
+
type: 'integration-profile',
|
|
284
|
+
version: 1,
|
|
285
|
+
generated_at: new Date().toISOString(),
|
|
286
|
+
include_secrets: includeSecrets,
|
|
287
|
+
data: payload,
|
|
288
|
+
};
|
|
289
|
+
const compressed = pako.gzip(JSON.stringify(envelope));
|
|
290
|
+
return Buffer.from(compressed);
|
|
291
|
+
}
|
|
292
|
+
async validateImportFile(file) {
|
|
293
|
+
const envelope = this.parseImportEnvelope(file);
|
|
294
|
+
const typeMap = new Map((await this.prismaService.integration_type.findMany({
|
|
295
|
+
select: { id: true, slug: true },
|
|
296
|
+
})).map((row) => [row.slug.toLowerCase(), row]));
|
|
297
|
+
const providerMap = new Map((await this.prismaService.integration_provider.findMany({
|
|
298
|
+
select: { id: true, slug: true, type_id: true },
|
|
299
|
+
})).map((row) => [row.slug.toLowerCase(), row]));
|
|
300
|
+
const firstSlugIndex = new Map();
|
|
301
|
+
const validItems = [];
|
|
302
|
+
const invalidItems = [];
|
|
303
|
+
envelope.data.forEach((item, index) => {
|
|
304
|
+
var _a, _b, _c, _d, _e, _f;
|
|
305
|
+
const errors = [];
|
|
306
|
+
const slug = String((_a = item === null || item === void 0 ? void 0 : item.slug) !== null && _a !== void 0 ? _a : '').trim();
|
|
307
|
+
const name = String((_b = item === null || item === void 0 ? void 0 : item.name) !== null && _b !== void 0 ? _b : '').trim();
|
|
308
|
+
const typeSlug = String((_c = item === null || item === void 0 ? void 0 : item.type_slug) !== null && _c !== void 0 ? _c : '')
|
|
309
|
+
.trim()
|
|
310
|
+
.toLowerCase();
|
|
311
|
+
const providerSlug = String((_d = item === null || item === void 0 ? void 0 : item.provider_slug) !== null && _d !== void 0 ? _d : '')
|
|
312
|
+
.trim()
|
|
313
|
+
.toLowerCase();
|
|
314
|
+
if (!slug)
|
|
315
|
+
errors.push('Missing slug.');
|
|
316
|
+
if (!name)
|
|
317
|
+
errors.push(`Missing name for slug "${slug || index}".`);
|
|
318
|
+
if (!typeSlug)
|
|
319
|
+
errors.push(`Missing type_slug for slug "${slug || index}".`);
|
|
320
|
+
if (!providerSlug) {
|
|
321
|
+
errors.push(`Missing provider_slug for slug "${slug || index}".`);
|
|
322
|
+
}
|
|
323
|
+
if (slug) {
|
|
324
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)) {
|
|
325
|
+
errors.push(`Invalid slug format "${slug}".`);
|
|
326
|
+
}
|
|
327
|
+
if (firstSlugIndex.has(slug)) {
|
|
328
|
+
const originalIndex = firstSlugIndex.get(slug);
|
|
329
|
+
errors.push(`Duplicate slug "${slug}" in file (already used at index ${originalIndex}).`);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
firstSlugIndex.set(slug, index);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const type = typeMap.get(typeSlug);
|
|
336
|
+
if (!type && typeSlug) {
|
|
337
|
+
errors.push(`Unknown type_slug "${typeSlug}".`);
|
|
338
|
+
}
|
|
339
|
+
const provider = providerMap.get(providerSlug);
|
|
340
|
+
if (!provider && providerSlug) {
|
|
341
|
+
errors.push(`Unknown provider_slug "${providerSlug}".`);
|
|
342
|
+
}
|
|
343
|
+
if (type && provider && provider.type_id !== type.id) {
|
|
344
|
+
errors.push(`Provider "${providerSlug}" does not belong to type "${typeSlug}".`);
|
|
345
|
+
}
|
|
346
|
+
if ((item === null || item === void 0 ? void 0 : item.config) !== null &&
|
|
347
|
+
(item === null || item === void 0 ? void 0 : item.config) !== undefined &&
|
|
348
|
+
(typeof item.config !== 'object' || Array.isArray(item.config))) {
|
|
349
|
+
errors.push(`Invalid config for slug "${slug || index}".`);
|
|
350
|
+
}
|
|
351
|
+
if (errors.length > 0) {
|
|
352
|
+
invalidItems.push({ index, slug: slug || undefined, errors });
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
validItems.push({
|
|
356
|
+
index,
|
|
357
|
+
slug,
|
|
358
|
+
name,
|
|
359
|
+
type_slug: typeSlug,
|
|
360
|
+
provider_slug: providerSlug,
|
|
361
|
+
config: (_e = item.config) !== null && _e !== void 0 ? _e : null,
|
|
362
|
+
is_active: (_f = item.is_active) !== null && _f !== void 0 ? _f : true,
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
const existingSlugs = new Set((await this.prismaService.integration_profile.findMany({
|
|
366
|
+
where: {
|
|
367
|
+
slug: {
|
|
368
|
+
in: validItems.map((item) => item.slug),
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
select: { slug: true },
|
|
372
|
+
})).map((row) => row.slug));
|
|
373
|
+
const profiles = validItems.map((item) => (Object.assign(Object.assign({}, item), { has_conflict: existingSlugs.has(item.slug) })));
|
|
374
|
+
const conflictSlugs = profiles
|
|
375
|
+
.filter((item) => item.has_conflict)
|
|
376
|
+
.map((item) => item.slug);
|
|
377
|
+
return {
|
|
378
|
+
format: {
|
|
379
|
+
type: envelope.type,
|
|
380
|
+
version: envelope.version,
|
|
381
|
+
generated_at: envelope.generated_at,
|
|
382
|
+
include_secrets: envelope.include_secrets,
|
|
383
|
+
},
|
|
384
|
+
total_profiles: envelope.data.length,
|
|
385
|
+
valid_profiles: profiles.length,
|
|
386
|
+
invalid_profiles: invalidItems.length,
|
|
387
|
+
conflict_profiles: conflictSlugs.length,
|
|
388
|
+
importable_profiles: profiles.length - conflictSlugs.length,
|
|
389
|
+
conflict_slugs: conflictSlugs,
|
|
390
|
+
profiles,
|
|
391
|
+
invalid_items: invalidItems,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
async confirmImport({ profiles, conflictResolutions, }) {
|
|
395
|
+
var _a, _b, _c;
|
|
396
|
+
if (!(profiles === null || profiles === void 0 ? void 0 : profiles.length)) {
|
|
397
|
+
throw new common_1.BadRequestException('No profiles provided for import.');
|
|
398
|
+
}
|
|
399
|
+
const resolutionMap = new Map((conflictResolutions !== null && conflictResolutions !== void 0 ? conflictResolutions : []).map((resolution) => [
|
|
400
|
+
resolution.slug,
|
|
401
|
+
resolution.action,
|
|
402
|
+
]));
|
|
403
|
+
const typeMap = new Map((await this.prismaService.integration_type.findMany({
|
|
404
|
+
select: { id: true, slug: true },
|
|
405
|
+
})).map((row) => [row.slug.toLowerCase(), row]));
|
|
406
|
+
const providerMap = new Map((await this.prismaService.integration_provider.findMany({
|
|
407
|
+
select: { id: true, slug: true, type_id: true },
|
|
408
|
+
})).map((row) => [row.slug.toLowerCase(), row]));
|
|
409
|
+
const duplicatedSlugs = new Set();
|
|
410
|
+
const seenSlugs = new Set();
|
|
411
|
+
profiles.forEach((item) => {
|
|
412
|
+
const slug = item.slug.trim();
|
|
413
|
+
if (seenSlugs.has(slug)) {
|
|
414
|
+
duplicatedSlugs.add(slug);
|
|
415
|
+
}
|
|
416
|
+
seenSlugs.add(slug);
|
|
417
|
+
});
|
|
418
|
+
if (duplicatedSlugs.size > 0) {
|
|
419
|
+
throw new common_1.BadRequestException(`File has duplicated slugs: ${Array.from(duplicatedSlugs).join(', ')}`);
|
|
420
|
+
}
|
|
421
|
+
const existingBySlug = new Map((await this.prismaService.integration_profile.findMany({
|
|
422
|
+
where: { slug: { in: profiles.map((profile) => profile.slug.trim()) } },
|
|
423
|
+
select: { id: true, slug: true },
|
|
424
|
+
})).map((row) => [row.slug, row]));
|
|
425
|
+
let created = 0;
|
|
426
|
+
let replaced = 0;
|
|
427
|
+
let ignored = 0;
|
|
428
|
+
let renamed = 0;
|
|
429
|
+
for (const item of profiles) {
|
|
430
|
+
const slug = item.slug.trim();
|
|
431
|
+
const name = item.name.trim();
|
|
432
|
+
const typeSlug = item.type_slug.trim().toLowerCase();
|
|
433
|
+
const providerSlug = item.provider_slug.trim().toLowerCase();
|
|
434
|
+
if (!slug || !name || !typeSlug || !providerSlug) {
|
|
435
|
+
throw new common_1.BadRequestException(`Invalid profile payload for slug "${slug || '<empty>'}".`);
|
|
436
|
+
}
|
|
437
|
+
const type = typeMap.get(typeSlug);
|
|
438
|
+
if (!type) {
|
|
439
|
+
throw new common_1.BadRequestException(`Unknown type_slug "${typeSlug}".`);
|
|
440
|
+
}
|
|
441
|
+
const provider = providerMap.get(providerSlug);
|
|
442
|
+
if (!provider) {
|
|
443
|
+
throw new common_1.BadRequestException(`Unknown provider_slug "${providerSlug}".`);
|
|
444
|
+
}
|
|
445
|
+
if (provider.type_id !== type.id) {
|
|
446
|
+
throw new common_1.BadRequestException(`Provider "${providerSlug}" does not belong to type "${typeSlug}".`);
|
|
447
|
+
}
|
|
448
|
+
const existing = existingBySlug.get(slug);
|
|
449
|
+
const data = {
|
|
450
|
+
slug,
|
|
451
|
+
name,
|
|
452
|
+
type_id: type.id,
|
|
453
|
+
provider_id: provider.id,
|
|
454
|
+
config: (_a = item.config) !== null && _a !== void 0 ? _a : null,
|
|
455
|
+
is_active: (_b = item.is_active) !== null && _b !== void 0 ? _b : true,
|
|
456
|
+
};
|
|
457
|
+
if (!existing) {
|
|
458
|
+
await this.prismaService.integration_profile.create({ data });
|
|
459
|
+
created += 1;
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
const action = (_c = resolutionMap.get(slug)) !== null && _c !== void 0 ? _c : 'ignore';
|
|
463
|
+
if (action === 'ignore') {
|
|
464
|
+
ignored += 1;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (action === 'replace') {
|
|
468
|
+
await this.prismaService.integration_profile.update({
|
|
469
|
+
where: { id: existing.id },
|
|
470
|
+
data: {
|
|
471
|
+
name: data.name,
|
|
472
|
+
type_id: data.type_id,
|
|
473
|
+
provider_id: data.provider_id,
|
|
474
|
+
config: data.config,
|
|
475
|
+
is_active: data.is_active,
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
replaced += 1;
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
const newSlug = await this.generateUniqueSlug(slug);
|
|
482
|
+
await this.prismaService.integration_profile.create({
|
|
483
|
+
data: Object.assign(Object.assign({}, data), { slug: newSlug }),
|
|
484
|
+
});
|
|
485
|
+
renamed += 1;
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
success: true,
|
|
489
|
+
total_received: profiles.length,
|
|
490
|
+
created,
|
|
491
|
+
replaced,
|
|
492
|
+
renamed,
|
|
493
|
+
ignored,
|
|
494
|
+
imported: created + replaced + renamed,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
async ensureSlugIsAvailable(slug) {
|
|
498
|
+
const existing = await this.prismaService.integration_profile.findUnique({
|
|
499
|
+
where: { slug },
|
|
500
|
+
select: { id: true },
|
|
501
|
+
});
|
|
502
|
+
if (existing) {
|
|
503
|
+
throw new common_1.BadRequestException(`Integration profile with slug "${slug}" already exists.`);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async validateTypeAndProvider(type_id, provider_id) {
|
|
507
|
+
const provider = await this.prismaService.integration_provider.findUnique({
|
|
508
|
+
where: { id: provider_id },
|
|
509
|
+
select: { id: true, type_id: true },
|
|
510
|
+
});
|
|
511
|
+
if (!provider) {
|
|
512
|
+
throw new common_1.BadRequestException(`Provider with id ${provider_id} not found.`);
|
|
513
|
+
}
|
|
514
|
+
if (provider.type_id !== type_id) {
|
|
515
|
+
throw new common_1.BadRequestException(`Provider ${provider_id} does not belong to type ${type_id}.`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
parseImportEnvelope(file) {
|
|
519
|
+
var _a, _b;
|
|
520
|
+
let parsed;
|
|
521
|
+
try {
|
|
522
|
+
const decompressed = pako.ungzip(file.buffer, { to: 'string' });
|
|
523
|
+
parsed = JSON.parse(decompressed);
|
|
524
|
+
}
|
|
525
|
+
catch (_c) {
|
|
526
|
+
throw new common_1.BadRequestException('File is not a valid .hedhog archive or is corrupted.');
|
|
527
|
+
}
|
|
528
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
529
|
+
throw new common_1.BadRequestException('Invalid .hedhog payload format.');
|
|
530
|
+
}
|
|
531
|
+
const payload = parsed;
|
|
532
|
+
if (payload.type !== 'integration-profile') {
|
|
533
|
+
throw new common_1.BadRequestException(`Invalid .hedhog type "${String((_a = payload.type) !== null && _a !== void 0 ? _a : '')}".`);
|
|
534
|
+
}
|
|
535
|
+
if (payload.version !== 1) {
|
|
536
|
+
throw new common_1.BadRequestException(`Unsupported .hedhog version "${String((_b = payload.version) !== null && _b !== void 0 ? _b : '')}".`);
|
|
537
|
+
}
|
|
538
|
+
if (!Array.isArray(payload.data)) {
|
|
539
|
+
throw new common_1.BadRequestException('Invalid .hedhog data: expected an array.');
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
type: 'integration-profile',
|
|
543
|
+
version: 1,
|
|
544
|
+
generated_at: typeof payload.generated_at === 'string'
|
|
545
|
+
? payload.generated_at
|
|
546
|
+
: new Date().toISOString(),
|
|
547
|
+
include_secrets: payload.include_secrets === true,
|
|
548
|
+
data: payload.data,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
sanitizeConfigForExport(providerSlug, config, includeSecrets) {
|
|
552
|
+
if (!config || includeSecrets)
|
|
553
|
+
return config;
|
|
554
|
+
const hiddenKeys = this.getSensitiveConfigKeys(providerSlug);
|
|
555
|
+
if (hiddenKeys.length === 0)
|
|
556
|
+
return config;
|
|
557
|
+
const sanitized = Object.assign({}, config);
|
|
558
|
+
hiddenKeys.forEach((key) => {
|
|
559
|
+
delete sanitized[key];
|
|
560
|
+
});
|
|
561
|
+
return sanitized;
|
|
562
|
+
}
|
|
563
|
+
getSensitiveConfigKeys(providerSlug) {
|
|
564
|
+
var _a;
|
|
565
|
+
const map = {
|
|
566
|
+
smtp: ['password'],
|
|
567
|
+
gmail: ['client_secret', 'refresh_token'],
|
|
568
|
+
ses: ['secret_access_key'],
|
|
569
|
+
'evolution-api': ['token'],
|
|
570
|
+
'whatsapp-official': ['access_token'],
|
|
571
|
+
s3: ['secret_access_key'],
|
|
572
|
+
gcs: ['key_file_json'],
|
|
573
|
+
'azure-blob': ['key'],
|
|
574
|
+
's3-compatible': ['secret_access_key'],
|
|
575
|
+
openai: ['api_key'],
|
|
576
|
+
gemini: ['api_key'],
|
|
577
|
+
claude: ['api_key'],
|
|
578
|
+
'google-oauth': ['client_secret'],
|
|
579
|
+
'github-oauth': ['client_secret'],
|
|
580
|
+
'microsoft-oauth': ['client_secret'],
|
|
581
|
+
};
|
|
582
|
+
return (_a = map[providerSlug.toLowerCase()]) !== null && _a !== void 0 ? _a : [];
|
|
583
|
+
}
|
|
584
|
+
async generateUniqueSlug(baseSlug) {
|
|
585
|
+
let candidate = `${baseSlug}-copy`;
|
|
586
|
+
let suffix = 1;
|
|
587
|
+
// Gera slug único determinístico para imports com conflito e opção de renomear.
|
|
588
|
+
while (await this.prismaService.integration_profile.findUnique({
|
|
589
|
+
where: { slug: candidate },
|
|
590
|
+
select: { id: true },
|
|
591
|
+
})) {
|
|
592
|
+
candidate = `${baseSlug}-copy-${suffix}`;
|
|
593
|
+
suffix += 1;
|
|
594
|
+
}
|
|
595
|
+
return candidate;
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
exports.IntegrationProfileService = IntegrationProfileService;
|
|
599
|
+
exports.IntegrationProfileService = IntegrationProfileService = __decorate([
|
|
600
|
+
(0, common_1.Injectable)(),
|
|
601
|
+
__param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => api_prisma_1.PrismaService))),
|
|
602
|
+
__param(1, (0, common_1.Inject)((0, common_1.forwardRef)(() => api_pagination_1.PaginationService))),
|
|
603
|
+
__metadata("design:paramtypes", [api_prisma_1.PrismaService,
|
|
604
|
+
api_pagination_1.PaginationService])
|
|
605
|
+
], IntegrationProfileService);
|
|
606
|
+
//# sourceMappingURL=integration-profile.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-profile.service.js","sourceRoot":"","sources":["../../src/integration-profile/integration-profile.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAA2E;AAC3E,oDAAoD;AACpD,2CAMwB;AACxB,2CAA6B;AAC7B,2EAA6E;AA2CtE,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,YAEmB,aAA4B,EAE5B,iBAAoC;QAFpC,kBAAa,GAAb,aAAa,CAAe;QAE5B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACpD,CAAC;IAEJ,KAAK,CAAC,SAAS;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;YAClD,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE;YACtB,MAAM,EAAE;gBACN,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,IAAI;gBACV,uBAAuB,EAAE;oBACvB,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;iBAC3D;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAAe,EAAE,QAAiB;QACpD,MAAM,kBAAkB,GAAG,MAAM,CAAC,QAAQ,aAAR,QAAQ,cAA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ACjC,cAAc,EAAE,CAAC,eAAe,CAAC;YACjC,iBAAiB,EAAE,CAAC,eAAe,CAAC;SACrC,CAAC;QAEF,OAAO,MAAA,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,mCAAI,EAAE,CAAC;IAC/C,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,QAAgB;QAC/C,IAAI,SAAS,GAAG,GAAG,QAAQ,OAAO,CAAC;QACnC,IAAI,MAAM,GAAG,CAAC,CAAC;QAEf,gFAAgF;QAChF,OACE,MAAM,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,UAAU,CAAC;YACtD,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;YAC1B,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE;SACrB,CAAC,EACF,CAAC;YACD,SAAS,GAAG,GAAG,QAAQ,SAAS,MAAM,EAAE,CAAC;YACzC,MAAM,IAAI,CAAC,CAAC;QACd,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAA;AA7tBY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAC,CAAA;IAEvC,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,kCAAiB,CAAC,CAAC,CAAA;qCADZ,0BAAa;QAET,kCAAiB;GAL5C,yBAAyB,CA6tBrC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EnumProvider } from '../file/provider/provider.enum';
|
|
2
|
+
export declare function buildMailConfigFromIntegration(providerSlug: string, config: unknown): any;
|
|
3
|
+
export declare function getFromAddress(config: unknown): string;
|
|
4
|
+
export declare function getReplyToAddress(config: unknown): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Maps an integration_profile config JSON to the flat settings dict that the
|
|
7
|
+
* existing provider classes (S3Provider, AzureProvider, etc.) expect.
|
|
8
|
+
*
|
|
9
|
+
* integration_provider slugs → EnumProvider:
|
|
10
|
+
* local, s3, gcs → same
|
|
11
|
+
* azure-blob → abs
|
|
12
|
+
* s3-compatible → spaces
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildStorageConfigFromIntegration(providerSlug: string, config: unknown): Record<string, string>;
|
|
15
|
+
/** Maps integration_provider slug to EnumProvider. */
|
|
16
|
+
export declare function resolveStorageEnumProvider(providerSlug: string): EnumProvider;
|
|
17
|
+
/** Maps integration_provider slug to the slug used in the file_provider table. */
|
|
18
|
+
export declare function resolveFileProviderSlug(providerSlug: string): string;
|
|
19
|
+
/** Maps an integration_profile config JSON to the API key and optional org needed by AI providers. */
|
|
20
|
+
export declare function buildAiConfigFromIntegration(providerSlug: string, config: unknown): {
|
|
21
|
+
apiKey: string;
|
|
22
|
+
organization?: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=integration-profile.utils.d.ts.map
|