briyah 1.0.1 → 1.0.3
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/server/src/ai/LLM/deepseek.service.js +1 -1
- package/package.json +2 -2
- package/dist/ai/LLM/anthropic.module.d.ts +0 -2
- package/dist/ai/LLM/anthropic.module.js +0 -21
- package/dist/ai/LLM/anthropic.service.d.ts +0 -27
- package/dist/ai/LLM/anthropic.service.js +0 -329
- package/dist/ai/LLM/base-ai.service.d.ts +0 -45
- package/dist/ai/LLM/base-ai.service.js +0 -409
- package/dist/ai/LLM/deepseek.module.d.ts +0 -2
- package/dist/ai/LLM/deepseek.module.js +0 -21
- package/dist/ai/LLM/deepseek.service.d.ts +0 -15
- package/dist/ai/LLM/deepseek.service.js +0 -279
- package/dist/ai/LLM/fal.module.d.ts +0 -2
- package/dist/ai/LLM/fal.module.js +0 -21
- package/dist/ai/LLM/fal.service.d.ts +0 -17
- package/dist/ai/LLM/fal.service.js +0 -314
- package/dist/ai/LLM/googleai.module.d.ts +0 -2
- package/dist/ai/LLM/googleai.module.js +0 -21
- package/dist/ai/LLM/googleai.service.d.ts +0 -20
- package/dist/ai/LLM/googleai.service.js +0 -271
- package/dist/ai/LLM/grok.module.d.ts +0 -2
- package/dist/ai/LLM/grok.module.js +0 -21
- package/dist/ai/LLM/grok.service.d.ts +0 -14
- package/dist/ai/LLM/grok.service.js +0 -263
- package/dist/ai/LLM/mock.module.d.ts +0 -2
- package/dist/ai/LLM/mock.module.js +0 -21
- package/dist/ai/LLM/mock.service.d.ts +0 -13
- package/dist/ai/LLM/mock.service.js +0 -194
- package/dist/ai/LLM/openai.module.d.ts +0 -2
- package/dist/ai/LLM/openai.module.js +0 -21
- package/dist/ai/LLM/openai.service.d.ts +0 -21
- package/dist/ai/LLM/openai.service.js +0 -421
- package/dist/ai/LLM/together.module.d.ts +0 -2
- package/dist/ai/LLM/together.module.js +0 -21
- package/dist/ai/LLM/together.service.d.ts +0 -18
- package/dist/ai/LLM/together.service.js +0 -285
- package/dist/ai/LLM/vertexai.module.d.ts +0 -2
- package/dist/ai/LLM/vertexai.module.js +0 -21
- package/dist/ai/LLM/vertexai.service.d.ts +0 -17
- package/dist/ai/LLM/vertexai.service.js +0 -323
- package/dist/ai/agent-config.d.ts +0 -32
- package/dist/ai/agent-config.js +0 -2
- package/dist/ai/agent-factory.d.ts +0 -15
- package/dist/ai/agent-factory.js +0 -24
- package/dist/ai/agent-message.service.d.ts +0 -9
- package/dist/ai/agent-message.service.js +0 -56
- package/dist/ai/agent-store.module.d.ts +0 -2
- package/dist/ai/agent-store.module.js +0 -21
- package/dist/ai/agent-store.service.d.ts +0 -31
- package/dist/ai/agent-store.service.js +0 -352
- package/dist/ai/agent.d.ts +0 -75
- package/dist/ai/agent.js +0 -174
- package/dist/ai/ai-factory.module.d.ts +0 -2
- package/dist/ai/ai-factory.module.js +0 -40
- package/dist/ai/ai-factory.service.d.ts +0 -24
- package/dist/ai/ai-factory.service.js +0 -94
- package/dist/ai/artifact.module.d.ts +0 -2
- package/dist/ai/artifact.module.js +0 -22
- package/dist/ai/artifact.service.d.ts +0 -21
- package/dist/ai/artifact.service.js +0 -239
- package/dist/ai/attached-file.module.d.ts +0 -2
- package/dist/ai/attached-file.module.js +0 -22
- package/dist/ai/attached-file.service.d.ts +0 -35
- package/dist/ai/attached-file.service.js +0 -253
- package/dist/ai/model_prices.d.ts +0 -2
- package/dist/ai/model_prices.js +0 -54
- package/dist/ai/published-agents.service.d.ts +0 -13
- package/dist/ai/published-agents.service.js +0 -118
- package/dist/app/balance-message.service.d.ts +0 -8
- package/dist/app/balance-message.service.js +0 -45
- package/dist/app/balance.module.d.ts +0 -2
- package/dist/app/balance.module.js +0 -20
- package/dist/app/balance.service.d.ts +0 -18
- package/dist/app/balance.service.js +0 -158
- package/dist/app/stripe.controller.d.ts +0 -31
- package/dist/app/stripe.controller.js +0 -150
- package/dist/app/stripe.module.d.ts +0 -2
- package/dist/app/stripe.module.js +0 -22
- package/dist/app/stripe.service.d.ts +0 -28
- package/dist/app/stripe.service.js +0 -198
- package/dist/app/transaction.service.d.ts +0 -15
- package/dist/app/transaction.service.js +0 -139
- package/dist/app/user-service-factory.d.ts +0 -21
- package/dist/app/user-service-factory.js +0 -81
- package/dist/app/user-service-manager.d.ts +0 -28
- package/dist/app/user-service-manager.js +0 -102
- package/dist/app.controller.d.ts +0 -232
- package/dist/app.controller.js +0 -2536
- package/dist/app.module.d.ts +0 -2
- package/dist/app.module.js +0 -45
- package/dist/app.service.d.ts +0 -186
- package/dist/app.service.js +0 -1334
- package/dist/auth/agent-access.decorator.d.ts +0 -2
- package/dist/auth/agent-access.decorator.js +0 -10
- package/dist/auth/auth.controller.d.ts +0 -38
- package/dist/auth/auth.controller.js +0 -356
- package/dist/auth/auth.module.d.ts +0 -2
- package/dist/auth/auth.module.js +0 -55
- package/dist/auth/auth.service.d.ts +0 -14
- package/dist/auth/auth.service.js +0 -84
- package/dist/auth/dto/bot-login.dto.d.ts +0 -4
- package/dist/auth/dto/bot-login.dto.js +0 -2
- package/dist/auth/dto/password-reset.dto.d.ts +0 -11
- package/dist/auth/dto/password-reset.dto.js +0 -2
- package/dist/auth/dto/phone-login.dto.d.ts +0 -8
- package/dist/auth/dto/phone-login.dto.js +0 -2
- package/dist/auth/dto/phone-verification.dto.d.ts +0 -9
- package/dist/auth/dto/phone-verification.dto.js +0 -2
- package/dist/auth/jwt-auth.guard.d.ts +0 -13
- package/dist/auth/jwt-auth.guard.js +0 -143
- package/dist/auth/jwt.strategy.d.ts +0 -17
- package/dist/auth/jwt.strategy.js +0 -45
- package/dist/auth/phone-validation.service.d.ts +0 -7
- package/dist/auth/phone-validation.service.js +0 -50
- package/dist/auth/public.decorator.d.ts +0 -2
- package/dist/auth/public.decorator.js +0 -7
- package/dist/auth/rate-limit.service.d.ts +0 -16
- package/dist/auth/rate-limit.service.js +0 -84
- package/dist/auth/room-access.decorator.d.ts +0 -2
- package/dist/auth/room-access.decorator.js +0 -10
- package/dist/auth/scopes.decorator.d.ts +0 -2
- package/dist/auth/scopes.decorator.js +0 -7
- package/dist/auth/scopes.guard.d.ts +0 -9
- package/dist/auth/scopes.guard.js +0 -82
- package/dist/auth/session.guard.d.ts +0 -7
- package/dist/auth/session.guard.js +0 -55
- package/dist/auth/twilio.service.d.ts +0 -15
- package/dist/auth/twilio.service.js +0 -139
- package/dist/auth/users.service.d.ts +0 -24
- package/dist/auth/users.service.js +0 -149
- package/dist/common/errors.d.ts +0 -12
- package/dist/common/errors.js +0 -43
- package/dist/config/configuration.module.d.ts +0 -2
- package/dist/config/configuration.module.js +0 -20
- package/dist/config/configuration.service.d.ts +0 -26
- package/dist/config/configuration.service.js +0 -131
- package/dist/main.js +0 -15749
- package/dist/room/artifact-store.service.d.ts +0 -15
- package/dist/room/artifact-store.service.js +0 -226
- package/dist/room/artifact.d.ts +0 -6
- package/dist/room/artifact.js +0 -2
- package/dist/room/message.d.ts +0 -19
- package/dist/room/message.js +0 -70
- package/dist/room/published-rooms.service.d.ts +0 -12
- package/dist/room/published-rooms.service.js +0 -108
- package/dist/room/room-config.d.ts +0 -12
- package/dist/room/room-config.js +0 -2
- package/dist/room/room-factory.d.ts +0 -7
- package/dist/room/room-factory.js +0 -16
- package/dist/room/room-message.module.d.ts +0 -2
- package/dist/room/room-message.module.js +0 -21
- package/dist/room/room-message.service.d.ts +0 -8
- package/dist/room/room-message.service.js +0 -44
- package/dist/room/room-store.module.d.ts +0 -2
- package/dist/room/room-store.module.js +0 -25
- package/dist/room/room-store.service.d.ts +0 -38
- package/dist/room/room-store.service.js +0 -353
- package/dist/room/room.d.ts +0 -107
- package/dist/room/room.js +0 -833
- package/dist/sdk/briyah-config.d.ts +0 -13
- package/dist/sdk/briyah-config.js +0 -32
- package/dist/sdk/briyah.d.ts +0 -36
- package/dist/sdk/briyah.js +0 -122
- package/dist/sdk/index.d.ts +0 -6
- package/dist/sdk/index.js +0 -11
- package/dist/shared/shared.module.d.ts +0 -2
- package/dist/shared/shared.module.js +0 -46
- package/dist/story/story-message.service.d.ts +0 -10
- package/dist/story/story-message.service.js +0 -57
- package/dist/story/story-progress.service.d.ts +0 -8
- package/dist/story/story-progress.service.js +0 -44
- package/dist/story/story-store.module.d.ts +0 -2
- package/dist/story/story-store.module.js +0 -22
- package/dist/story/story-store.service.d.ts +0 -23
- package/dist/story/story-store.service.js +0 -392
- package/dist/story/story.service.d.ts +0 -94
- package/dist/story/story.service.js +0 -1797
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AiFactoryService = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const openai_service_1 = require("./LLM/openai.service");
|
|
15
|
-
const grok_service_1 = require("./LLM/grok.service");
|
|
16
|
-
const vertexai_service_1 = require("./LLM/vertexai.service");
|
|
17
|
-
const anthropic_service_1 = require("./LLM/anthropic.service");
|
|
18
|
-
const deepseek_service_1 = require("./LLM/deepseek.service");
|
|
19
|
-
const together_service_1 = require("./LLM/together.service");
|
|
20
|
-
const mock_service_1 = require("./LLM/mock.service");
|
|
21
|
-
const googleai_service_1 = require("./LLM/googleai.service");
|
|
22
|
-
const fal_service_1 = require("./LLM/fal.service");
|
|
23
|
-
let AiFactoryService = class AiFactoryService {
|
|
24
|
-
openAiService;
|
|
25
|
-
grokAiService;
|
|
26
|
-
vertexAiService;
|
|
27
|
-
anthropicAiService;
|
|
28
|
-
deepSeekAiService;
|
|
29
|
-
togetherAiService;
|
|
30
|
-
mockAiService;
|
|
31
|
-
googleAiService;
|
|
32
|
-
falAiService;
|
|
33
|
-
constructor(openAiService, grokAiService, vertexAiService, anthropicAiService, deepSeekAiService, togetherAiService, mockAiService, googleAiService, falAiService) {
|
|
34
|
-
this.openAiService = openAiService;
|
|
35
|
-
this.grokAiService = grokAiService;
|
|
36
|
-
this.vertexAiService = vertexAiService;
|
|
37
|
-
this.anthropicAiService = anthropicAiService;
|
|
38
|
-
this.deepSeekAiService = deepSeekAiService;
|
|
39
|
-
this.togetherAiService = togetherAiService;
|
|
40
|
-
this.mockAiService = mockAiService;
|
|
41
|
-
this.googleAiService = googleAiService;
|
|
42
|
-
this.falAiService = falAiService;
|
|
43
|
-
}
|
|
44
|
-
createAiService(serviceName) {
|
|
45
|
-
switch (serviceName) {
|
|
46
|
-
case this.openAiService.getServiceName():
|
|
47
|
-
return this.openAiService;
|
|
48
|
-
case this.grokAiService.getServiceName():
|
|
49
|
-
return this.grokAiService;
|
|
50
|
-
case this.vertexAiService.getServiceName():
|
|
51
|
-
return this.vertexAiService;
|
|
52
|
-
case this.anthropicAiService.getServiceName():
|
|
53
|
-
return this.anthropicAiService;
|
|
54
|
-
case this.deepSeekAiService.getServiceName():
|
|
55
|
-
return this.deepSeekAiService;
|
|
56
|
-
case this.togetherAiService.getServiceName():
|
|
57
|
-
return this.togetherAiService;
|
|
58
|
-
case this.mockAiService.getServiceName():
|
|
59
|
-
return this.mockAiService;
|
|
60
|
-
case this.googleAiService.getServiceName():
|
|
61
|
-
return this.googleAiService;
|
|
62
|
-
case this.falAiService.getServiceName():
|
|
63
|
-
return this.falAiService;
|
|
64
|
-
default:
|
|
65
|
-
throw new Error(`Unknown AI service: ${serviceName}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
getAllAiServices() {
|
|
69
|
-
return [
|
|
70
|
-
this.openAiService,
|
|
71
|
-
this.grokAiService,
|
|
72
|
-
this.vertexAiService,
|
|
73
|
-
this.anthropicAiService,
|
|
74
|
-
this.deepSeekAiService,
|
|
75
|
-
this.togetherAiService,
|
|
76
|
-
this.mockAiService,
|
|
77
|
-
this.googleAiService,
|
|
78
|
-
this.falAiService,
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
exports.AiFactoryService = AiFactoryService;
|
|
83
|
-
exports.AiFactoryService = AiFactoryService = __decorate([
|
|
84
|
-
(0, common_1.Injectable)(),
|
|
85
|
-
__metadata("design:paramtypes", [openai_service_1.OpenAiService,
|
|
86
|
-
grok_service_1.GrokAiService,
|
|
87
|
-
vertexai_service_1.VertexAiService,
|
|
88
|
-
anthropic_service_1.AnthropicAiService,
|
|
89
|
-
deepseek_service_1.DeepSeekAiService,
|
|
90
|
-
together_service_1.TogetherAiService,
|
|
91
|
-
mock_service_1.MockAiService,
|
|
92
|
-
googleai_service_1.GoogleAiService,
|
|
93
|
-
fal_service_1.FalAiService])
|
|
94
|
-
], AiFactoryService);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ArtifactModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const artifact_service_1 = require("./artifact.service");
|
|
12
|
-
const configuration_module_1 = require("../config/configuration.module");
|
|
13
|
-
let ArtifactModule = class ArtifactModule {
|
|
14
|
-
};
|
|
15
|
-
exports.ArtifactModule = ArtifactModule;
|
|
16
|
-
exports.ArtifactModule = ArtifactModule = __decorate([
|
|
17
|
-
(0, common_1.Module)({
|
|
18
|
-
imports: [configuration_module_1.ConfigurationModule],
|
|
19
|
-
providers: [artifact_service_1.ArtifactService],
|
|
20
|
-
exports: [artifact_service_1.ArtifactService],
|
|
21
|
-
})
|
|
22
|
-
], ArtifactModule);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ConfigurationService } from '../config/configuration.service';
|
|
2
|
-
import { ArtifactMetadata } from '../shared/types/app.types';
|
|
3
|
-
export declare class ArtifactService {
|
|
4
|
-
private readonly configService;
|
|
5
|
-
private readonly artifactsDir;
|
|
6
|
-
constructor(configService: ConfigurationService, storageDir?: string);
|
|
7
|
-
private getMetadataPath;
|
|
8
|
-
private loadMetadata;
|
|
9
|
-
private saveMetadata;
|
|
10
|
-
private getArtifactPath;
|
|
11
|
-
private getArtifactFilePath;
|
|
12
|
-
storeArtifact(name: string, content: string, description?: string): string;
|
|
13
|
-
getArtifact(artifactId: string): string | Buffer | null;
|
|
14
|
-
listArtifacts(): ArtifactMetadata[];
|
|
15
|
-
getArtifactMetadata(artifactId: string): ArtifactMetadata | null;
|
|
16
|
-
updateArtifact(artifactId: string, content: string): boolean;
|
|
17
|
-
renameArtifact(artifactId: string, newName: string): boolean;
|
|
18
|
-
updateArtifactDescription(artifactId: string, description: string): boolean;
|
|
19
|
-
deleteArtifact(artifactId: string): boolean;
|
|
20
|
-
storeImageArtifact(name: string, imageData: Buffer, mimeType: string, description?: string): string;
|
|
21
|
-
}
|
|
@@ -1,239 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.ArtifactService = void 0;
|
|
46
|
-
const common_1 = require("@nestjs/common");
|
|
47
|
-
const fs = __importStar(require("fs"));
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
|
-
const crypto_1 = require("crypto");
|
|
50
|
-
const configuration_service_1 = require("../config/configuration.service");
|
|
51
|
-
let ArtifactService = class ArtifactService {
|
|
52
|
-
configService;
|
|
53
|
-
artifactsDir;
|
|
54
|
-
constructor(configService, storageDir) {
|
|
55
|
-
this.configService = configService;
|
|
56
|
-
if (storageDir) {
|
|
57
|
-
this.artifactsDir = storageDir;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const userDataDir = this.configService.getUserDataDir();
|
|
61
|
-
this.artifactsDir = path.join(userDataDir, 'artifacts');
|
|
62
|
-
}
|
|
63
|
-
if (!fs.existsSync(this.artifactsDir)) {
|
|
64
|
-
fs.mkdirSync(this.artifactsDir, { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
getMetadataPath() {
|
|
68
|
-
return path.join(this.artifactsDir, 'metadata.json');
|
|
69
|
-
}
|
|
70
|
-
loadMetadata() {
|
|
71
|
-
const metadataPath = this.getMetadataPath();
|
|
72
|
-
if (!fs.existsSync(metadataPath)) {
|
|
73
|
-
return {};
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
const content = fs.readFileSync(metadataPath, 'utf8');
|
|
77
|
-
return JSON.parse(content);
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
console.error('Error loading artifact metadata:', error);
|
|
81
|
-
return {};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
saveMetadata(metadata) {
|
|
85
|
-
const metadataPath = this.getMetadataPath();
|
|
86
|
-
fs.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2), 'utf8');
|
|
87
|
-
}
|
|
88
|
-
getArtifactPath(artifactId) {
|
|
89
|
-
return path.join(this.artifactsDir, `${artifactId}.md`);
|
|
90
|
-
}
|
|
91
|
-
getArtifactFilePath(artifactId, metadata) {
|
|
92
|
-
if (metadata.mimeType?.startsWith('image/')) {
|
|
93
|
-
const extension = metadata.mimeType.split('/').pop();
|
|
94
|
-
return path.join(this.artifactsDir, `${artifactId}.${extension}`);
|
|
95
|
-
}
|
|
96
|
-
return path.join(this.artifactsDir, `${artifactId}.md`);
|
|
97
|
-
}
|
|
98
|
-
storeArtifact(name, content, description) {
|
|
99
|
-
const artifactId = (0, crypto_1.randomUUID)();
|
|
100
|
-
const filePath = this.getArtifactPath(artifactId);
|
|
101
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
102
|
-
const metadata = this.loadMetadata();
|
|
103
|
-
metadata[artifactId] = {
|
|
104
|
-
artifactId,
|
|
105
|
-
name,
|
|
106
|
-
fileName: `${name}.md`,
|
|
107
|
-
uploadDate: new Date().toISOString(),
|
|
108
|
-
size: Buffer.byteLength(content, 'utf8'),
|
|
109
|
-
mimeType: 'text/markdown',
|
|
110
|
-
...(description && { description }),
|
|
111
|
-
};
|
|
112
|
-
this.saveMetadata(metadata);
|
|
113
|
-
return artifactId;
|
|
114
|
-
}
|
|
115
|
-
getArtifact(artifactId) {
|
|
116
|
-
const metadata = this.getArtifactMetadata(artifactId);
|
|
117
|
-
if (!metadata) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
const filePath = this.getArtifactFilePath(artifactId, metadata);
|
|
121
|
-
if (!fs.existsSync(filePath)) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
if (metadata.mimeType?.startsWith('image/')) {
|
|
126
|
-
return fs.readFileSync(filePath);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
return fs.readFileSync(filePath, 'utf8');
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
console.error(`Error reading artifact ${artifactId}:`, error);
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
listArtifacts() {
|
|
138
|
-
const metadata = this.loadMetadata();
|
|
139
|
-
return Object.values(metadata);
|
|
140
|
-
}
|
|
141
|
-
getArtifactMetadata(artifactId) {
|
|
142
|
-
const metadata = this.loadMetadata();
|
|
143
|
-
return metadata[artifactId] || null;
|
|
144
|
-
}
|
|
145
|
-
updateArtifact(artifactId, content) {
|
|
146
|
-
const filePath = this.getArtifactPath(artifactId);
|
|
147
|
-
if (!fs.existsSync(filePath)) {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
try {
|
|
151
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
152
|
-
const metadata = this.loadMetadata();
|
|
153
|
-
if (metadata[artifactId]) {
|
|
154
|
-
metadata[artifactId].size = Buffer.byteLength(content, 'utf8');
|
|
155
|
-
this.saveMetadata(metadata);
|
|
156
|
-
}
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
console.error(`Error updating artifact ${artifactId}:`, error);
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
renameArtifact(artifactId, newName) {
|
|
165
|
-
const metadata = this.loadMetadata();
|
|
166
|
-
if (!metadata[artifactId]) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
try {
|
|
170
|
-
metadata[artifactId].name = newName;
|
|
171
|
-
this.saveMetadata(metadata);
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
console.error(`Error renaming artifact ${artifactId}:`, error);
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
updateArtifactDescription(artifactId, description) {
|
|
180
|
-
const metadata = this.loadMetadata();
|
|
181
|
-
if (!metadata[artifactId]) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
try {
|
|
185
|
-
metadata[artifactId].description = description;
|
|
186
|
-
this.saveMetadata(metadata);
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
console.error(`Error updating artifact description ${artifactId}:`, error);
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
deleteArtifact(artifactId) {
|
|
195
|
-
const metadata = this.getArtifactMetadata(artifactId);
|
|
196
|
-
if (!metadata) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
const filePath = this.getArtifactFilePath(artifactId, metadata);
|
|
200
|
-
if (!fs.existsSync(filePath)) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
try {
|
|
204
|
-
fs.unlinkSync(filePath);
|
|
205
|
-
const allMetadata = this.loadMetadata();
|
|
206
|
-
delete allMetadata[artifactId];
|
|
207
|
-
this.saveMetadata(allMetadata);
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
catch (error) {
|
|
211
|
-
console.error(`Error deleting artifact ${artifactId}:`, error);
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
storeImageArtifact(name, imageData, mimeType, description) {
|
|
216
|
-
const artifactId = (0, crypto_1.randomUUID)();
|
|
217
|
-
const extension = mimeType.split('/')[1];
|
|
218
|
-
const fileName = `${artifactId}.${extension}`;
|
|
219
|
-
const filePath = path.join(this.artifactsDir, fileName);
|
|
220
|
-
fs.writeFileSync(filePath, imageData);
|
|
221
|
-
const metadata = this.loadMetadata();
|
|
222
|
-
metadata[artifactId] = {
|
|
223
|
-
artifactId,
|
|
224
|
-
name,
|
|
225
|
-
fileName: fileName,
|
|
226
|
-
uploadDate: new Date().toISOString(),
|
|
227
|
-
size: imageData.length,
|
|
228
|
-
mimeType: mimeType,
|
|
229
|
-
...(description && { description }),
|
|
230
|
-
};
|
|
231
|
-
this.saveMetadata(metadata);
|
|
232
|
-
return artifactId;
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
exports.ArtifactService = ArtifactService;
|
|
236
|
-
exports.ArtifactService = ArtifactService = __decorate([
|
|
237
|
-
(0, common_1.Injectable)(),
|
|
238
|
-
__metadata("design:paramtypes", [configuration_service_1.ConfigurationService, String])
|
|
239
|
-
], ArtifactService);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.AttachedFileModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const attached_file_service_1 = require("./attached-file.service");
|
|
12
|
-
const configuration_module_1 = require("../config/configuration.module");
|
|
13
|
-
let AttachedFileModule = class AttachedFileModule {
|
|
14
|
-
};
|
|
15
|
-
exports.AttachedFileModule = AttachedFileModule;
|
|
16
|
-
exports.AttachedFileModule = AttachedFileModule = __decorate([
|
|
17
|
-
(0, common_1.Module)({
|
|
18
|
-
imports: [configuration_module_1.ConfigurationModule],
|
|
19
|
-
providers: [attached_file_service_1.AttachedFileService],
|
|
20
|
-
exports: [attached_file_service_1.AttachedFileService],
|
|
21
|
-
})
|
|
22
|
-
], AttachedFileModule);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ConfigurationService } from '../config/configuration.service';
|
|
2
|
-
export interface FileMetadata {
|
|
3
|
-
fileName: string;
|
|
4
|
-
fileId: string;
|
|
5
|
-
mimeType?: string;
|
|
6
|
-
size?: number;
|
|
7
|
-
uploadDate: string;
|
|
8
|
-
serviceMetadata?: {
|
|
9
|
-
serviceName: string;
|
|
10
|
-
resourceId?: string;
|
|
11
|
-
vectorStoreId?: string;
|
|
12
|
-
uri?: string;
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare class AttachedFileService {
|
|
17
|
-
private readonly configService;
|
|
18
|
-
private readonly attachedFilesDir;
|
|
19
|
-
constructor(configService: ConfigurationService);
|
|
20
|
-
private getMetadataPath;
|
|
21
|
-
storeFile(ownerId: string, fileName: string, fileData: Uint8Array, additionalMetadata?: Partial<FileMetadata>): string;
|
|
22
|
-
getFile(ownerId: string, fileId: string): Uint8Array | null;
|
|
23
|
-
getFileByName(ownerId: string, fileName: string): Uint8Array | null;
|
|
24
|
-
updateFileMetadata(ownerId: string, fileId: string, metadataUpdates: Partial<FileMetadata>): boolean;
|
|
25
|
-
getFileMetadata(ownerId: string, fileId: string): FileMetadata | null;
|
|
26
|
-
getFileMetadataByName(ownerId: string, fileName: string): FileMetadata | null;
|
|
27
|
-
getFileIdByName(ownerId: string, fileName: string): string | null;
|
|
28
|
-
listFileMetadata(ownerId: string): FileMetadata[];
|
|
29
|
-
listFiles(ownerId: string): string[];
|
|
30
|
-
deleteFile(ownerId: string, fileId: string): boolean;
|
|
31
|
-
deleteFileByName(ownerId: string, fileName: string): boolean;
|
|
32
|
-
deleteAllFiles(ownerId: string): boolean;
|
|
33
|
-
private getOwnerDirectory;
|
|
34
|
-
private deleteDirectory;
|
|
35
|
-
}
|