@webiny/api-core 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.9f53ea597d
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/createApiCore.d.ts +1 -1
- package/createApiCore.js +8 -4
- package/createApiCore.js.map +1 -1
- package/exports/api/security/api-key.d.ts +1 -0
- package/exports/api/security/api-key.js +1 -0
- package/exports/api.d.ts +1 -1
- package/exports/api.js +1 -1
- package/features/ai/Ai.d.ts +3 -1
- package/features/ai/Ai.js +39 -4
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +8 -44
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/OpenAiSdkFactory.js +4 -168
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/TextExtractor/DefaultTextExtractor.d.ts +9 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js +28 -0
- package/features/ai/TextExtractor/DefaultTextExtractor.js.map +1 -0
- package/features/ai/TextExtractor/abstractions.d.ts +12 -0
- package/features/ai/TextExtractor/abstractions.js +5 -0
- package/features/ai/TextExtractor/abstractions.js.map +1 -0
- package/features/ai/TextExtractor/index.d.ts +3 -0
- package/features/ai/TextExtractor/index.js +2 -0
- package/features/ai/TextExtractor/parsers/docxParser.d.ts +1 -0
- package/features/ai/TextExtractor/parsers/docxParser.js +111 -0
- package/features/ai/TextExtractor/parsers/docxParser.js.map +1 -0
- package/features/ai/events.d.ts +59 -0
- package/features/ai/events.js +41 -0
- package/features/ai/events.js.map +1 -0
- package/features/ai/feature.js +6 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +6 -0
- package/features/ai/index.js +3 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.d.ts +11 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js +31 -0
- package/features/ai/toolPipeline/AiOutputToolRegistry.js.map +1 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.d.ts +10 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js +36 -0
- package/features/ai/toolPipeline/AiToolPipelineRunner.js.map +1 -0
- package/features/ai/toolPipeline/abstractions.d.ts +23 -0
- package/features/ai/toolPipeline/abstractions.js +7 -0
- package/features/ai/toolPipeline/abstractions.js.map +1 -0
- package/features/ai/toolPipeline/index.d.ts +2 -0
- package/features/ai/toolPipeline/index.js +1 -0
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/abstractions.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -3
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/abstractions.js.map +1 -1
- package/features/security/apiKeys/feature.js +7 -2
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeyProvider.d.ts +3 -5
- package/features/security/apiKeys/shared/ApiKeyProvider.js +6 -21
- package/features/security/apiKeys/shared/ApiKeyProvider.js.map +1 -1
- package/features/security/apiKeys/shared/ApiKeysRepository.d.ts +1 -0
- package/features/security/apiKeys/shared/ApiKeysRepository.js +19 -4
- package/features/security/apiKeys/shared/ApiKeysRepository.js.map +1 -1
- package/features/security/apiKeys/shared/generateToken.d.ts +1 -1
- package/features/security/apiKeys/shared/generateToken.js.map +1 -1
- package/features/security/apiKeys/shared/types.d.ts +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +1 -1
- package/features/security/utils/getPermissionsFromRoles.d.ts +1 -1
- package/features/serviceDiscovery/ServiceDiscovery.d.ts +17 -0
- package/features/serviceDiscovery/ServiceDiscovery.js +22 -0
- package/features/serviceDiscovery/ServiceDiscovery.js.map +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.d.ts +1 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js +111 -0
- package/features/serviceDiscovery/__tests__/ServiceDiscovery.test.js.map +1 -0
- package/features/serviceDiscovery/index.d.ts +3 -0
- package/features/serviceDiscovery/index.js +1 -0
- package/features/tenancy/CreateTenant/CreateTenantUseCase.d.ts +1 -1
- package/features/tenancy/InstallTenant/InstallTenantUseCase.d.ts +1 -1
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/tenancy/UpdateTenant/UpdateTenantUseCase.d.ts +2 -2
- package/features/users/CreateUser/decorators/CreateUserWithWcpIncrement.d.ts +1 -1
- package/features/wcp/WcpContext/WcpContext.d.ts +5 -0
- package/features/wcp/WcpContext/WcpContext.js +15 -0
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +21 -7
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +27 -2
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/graphql/wcp/graphql.js +1 -0
- package/graphql/wcp/graphql.js.map +1 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +1 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +1 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +1 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +5 -0
- package/legacy/wcp/LegacyWcpContext.js +15 -0
- package/legacy/wcp/LegacyWcpContext.js.map +1 -1
- package/package.json +20 -22
- package/types/security.d.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/TextExtractor/abstractions.js","sources":["../../../../src/features/ai/TextExtractor/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface TextExtractorResult {\n text: string;\n}\n\nexport interface ITextExtractor {\n canExtract(mimeType: string): boolean;\n extract(buffer: Buffer, mimeType: string): Promise<TextExtractorResult>;\n}\n\nexport const TextExtractor = createAbstraction<ITextExtractor>(\"TextExtractor\");\n\nexport namespace TextExtractor {\n export type Interface = ITextExtractor;\n export type Result = TextExtractorResult;\n}\n"],"names":["TextExtractor","createAbstraction"],"mappings":";AAWO,MAAMA,gBAAgBC,kBAAkC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function extractDocxText(buffer: Buffer): Promise<string>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { inflateRawSync } from "node:zlib";
|
|
2
|
+
async function extractDocxText(buffer) {
|
|
3
|
+
const xml = extractFileFromZip(buffer, "word/document.xml");
|
|
4
|
+
if (!xml) throw new Error("Invalid DOCX: word/document.xml not found.");
|
|
5
|
+
const stylesXml = extractFileFromZip(buffer, "word/styles.xml");
|
|
6
|
+
const styleMap = stylesXml ? buildStyleMap(stylesXml) : new Map();
|
|
7
|
+
return convertToMarkdown(xml, styleMap);
|
|
8
|
+
}
|
|
9
|
+
function buildStyleMap(stylesXml) {
|
|
10
|
+
const map = new Map();
|
|
11
|
+
const styleRegex = /<w:style\s[^>]*w:styleId="([^"]*)"[^>]*>[\s\S]*?<\/w:style>/g;
|
|
12
|
+
let match;
|
|
13
|
+
while(null !== (match = styleRegex.exec(stylesXml))){
|
|
14
|
+
const styleId = match[1];
|
|
15
|
+
const block = match[0];
|
|
16
|
+
const nameMatch = block.match(/<w:name\s+w:val="([^"]*)"/);
|
|
17
|
+
if (nameMatch) map.set(styleId, nameMatch[1]);
|
|
18
|
+
}
|
|
19
|
+
return map;
|
|
20
|
+
}
|
|
21
|
+
function getHeadingLevel(paragraphXml, styleMap) {
|
|
22
|
+
const styleMatch = paragraphXml.match(/<w:pStyle\s+w:val="([^"]*)"/);
|
|
23
|
+
if (!styleMatch) return 0;
|
|
24
|
+
const styleId = styleMatch[1];
|
|
25
|
+
const directMatch = styleId.match(/^[Hh]eading(\d)$/);
|
|
26
|
+
if (directMatch) return parseInt(directMatch[1], 10);
|
|
27
|
+
const styleName = styleMap.get(styleId) ?? "";
|
|
28
|
+
const nameMatch = styleName.match(/^[Hh]eading\s*(\d)$/);
|
|
29
|
+
if (nameMatch) return parseInt(nameMatch[1], 10);
|
|
30
|
+
if (/title/i.test(styleName) || /title/i.test(styleId)) return 1;
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
function isListItem(paragraphXml) {
|
|
34
|
+
return /<w:numId\s/.test(paragraphXml);
|
|
35
|
+
}
|
|
36
|
+
function extractRunMarkdown(runXml) {
|
|
37
|
+
const textRegex = /<w:t(?:\s[^>]*)?>([^<]*)<\/w:t>/g;
|
|
38
|
+
const texts = [];
|
|
39
|
+
let match;
|
|
40
|
+
while(null !== (match = textRegex.exec(runXml)))texts.push(match[1]);
|
|
41
|
+
if (0 === texts.length) return "";
|
|
42
|
+
const text = texts.join("");
|
|
43
|
+
const isBold = /<w:b[\s/>]/.test(runXml) && !/<w:b\s+w:val="(false|0)"/.test(runXml);
|
|
44
|
+
const isItalic = /<w:i[\s/>]/.test(runXml) && !/<w:i\s+w:val="(false|0)"/.test(runXml);
|
|
45
|
+
if (isBold && isItalic) return `***${text}***`;
|
|
46
|
+
if (isBold) return `**${text}**`;
|
|
47
|
+
if (isItalic) return `*${text}*`;
|
|
48
|
+
return text;
|
|
49
|
+
}
|
|
50
|
+
function convertToMarkdown(xml, styleMap) {
|
|
51
|
+
const paragraphs = [];
|
|
52
|
+
const paragraphRegex = /<w:p[\s>][\s\S]*?<\/w:p>/g;
|
|
53
|
+
let paragraphMatch;
|
|
54
|
+
while(null !== (paragraphMatch = paragraphRegex.exec(xml))){
|
|
55
|
+
const paragraphXml = paragraphMatch[0];
|
|
56
|
+
const runRegex = /<w:r[\s>][\s\S]*?<\/w:r>/g;
|
|
57
|
+
const runs = [];
|
|
58
|
+
let runMatch;
|
|
59
|
+
while(null !== (runMatch = runRegex.exec(paragraphXml))){
|
|
60
|
+
const md = extractRunMarkdown(runMatch[0]);
|
|
61
|
+
if (md) runs.push(md);
|
|
62
|
+
}
|
|
63
|
+
if (0 === runs.length) continue;
|
|
64
|
+
let line = runs.join("");
|
|
65
|
+
const headingLevel = getHeadingLevel(paragraphXml, styleMap);
|
|
66
|
+
if (headingLevel > 0 && headingLevel <= 6) line = `${"#".repeat(headingLevel)} ${line}`;
|
|
67
|
+
else if (isListItem(paragraphXml)) line = `- ${line}`;
|
|
68
|
+
paragraphs.push(line);
|
|
69
|
+
}
|
|
70
|
+
return paragraphs.join("\n\n");
|
|
71
|
+
}
|
|
72
|
+
function extractFileFromZip(buffer, targetPath) {
|
|
73
|
+
const eocdOffset = findEocd(buffer);
|
|
74
|
+
if (-1 === eocdOffset) throw new Error("Invalid ZIP: End of Central Directory not found.");
|
|
75
|
+
const cdOffset = buffer.readUInt32LE(eocdOffset + 16);
|
|
76
|
+
const cdSize = buffer.readUInt32LE(eocdOffset + 12);
|
|
77
|
+
const cdEnd = cdOffset + cdSize;
|
|
78
|
+
let offset = cdOffset;
|
|
79
|
+
while(offset < cdEnd){
|
|
80
|
+
const sig = buffer.readUInt32LE(offset);
|
|
81
|
+
if (0x02014b50 !== sig) break;
|
|
82
|
+
const compressionMethod = buffer.readUInt16LE(offset + 10);
|
|
83
|
+
const compressedSize = buffer.readUInt32LE(offset + 20);
|
|
84
|
+
const fileNameLen = buffer.readUInt16LE(offset + 28);
|
|
85
|
+
const extraLen = buffer.readUInt16LE(offset + 30);
|
|
86
|
+
const commentLen = buffer.readUInt16LE(offset + 32);
|
|
87
|
+
const localHeaderOffset = buffer.readUInt32LE(offset + 42);
|
|
88
|
+
const fileName = buffer.toString("utf-8", offset + 46, offset + 46 + fileNameLen);
|
|
89
|
+
if (fileName === targetPath) return readLocalFile(buffer, localHeaderOffset, compressionMethod, compressedSize);
|
|
90
|
+
offset += 46 + fileNameLen + extraLen + commentLen;
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
function readLocalFile(buffer, offset, compressionMethod, compressedSize) {
|
|
95
|
+
const sig = buffer.readUInt32LE(offset);
|
|
96
|
+
if (0x04034b50 !== sig) throw new Error("Invalid ZIP: bad local file header.");
|
|
97
|
+
const localFileNameLen = buffer.readUInt16LE(offset + 26);
|
|
98
|
+
const localExtraLen = buffer.readUInt16LE(offset + 28);
|
|
99
|
+
const dataOffset = offset + 30 + localFileNameLen + localExtraLen;
|
|
100
|
+
const raw = buffer.subarray(dataOffset, dataOffset + compressedSize);
|
|
101
|
+
if (0 === compressionMethod) return raw.toString("utf-8");
|
|
102
|
+
if (8 === compressionMethod) return inflateRawSync(raw).toString("utf-8");
|
|
103
|
+
throw new Error(`Unsupported ZIP compression method: ${compressionMethod}`);
|
|
104
|
+
}
|
|
105
|
+
function findEocd(buffer) {
|
|
106
|
+
for(let i = buffer.length - 22; i >= Math.max(0, buffer.length - 65557); i--)if (0x06054b50 === buffer.readUInt32LE(i)) return i;
|
|
107
|
+
return -1;
|
|
108
|
+
}
|
|
109
|
+
export { extractDocxText };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=docxParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/TextExtractor/parsers/docxParser.js","sources":["../../../../../src/features/ai/TextExtractor/parsers/docxParser.ts"],"sourcesContent":["import { inflateRawSync } from \"node:zlib\";\n\nexport async function extractDocxText(buffer: Buffer): Promise<string> {\n const xml = extractFileFromZip(buffer, \"word/document.xml\");\n if (!xml) {\n throw new Error(\"Invalid DOCX: word/document.xml not found.\");\n }\n\n const stylesXml = extractFileFromZip(buffer, \"word/styles.xml\");\n const styleMap = stylesXml ? buildStyleMap(stylesXml) : new Map<string, string>();\n\n return convertToMarkdown(xml, styleMap);\n}\n\nfunction buildStyleMap(stylesXml: string): Map<string, string> {\n const map = new Map<string, string>();\n const styleRegex = /<w:style\\s[^>]*w:styleId=\"([^\"]*)\"[^>]*>[\\s\\S]*?<\\/w:style>/g;\n let match: RegExpExecArray | null;\n\n while ((match = styleRegex.exec(stylesXml)) !== null) {\n const styleId = match[1];\n const block = match[0];\n const nameMatch = block.match(/<w:name\\s+w:val=\"([^\"]*)\"/);\n if (nameMatch) {\n map.set(styleId, nameMatch[1]);\n }\n }\n\n return map;\n}\n\nfunction getHeadingLevel(paragraphXml: string, styleMap: Map<string, string>): number {\n const styleMatch = paragraphXml.match(/<w:pStyle\\s+w:val=\"([^\"]*)\"/);\n if (!styleMatch) {\n return 0;\n }\n\n const styleId = styleMatch[1];\n\n const directMatch = styleId.match(/^[Hh]eading(\\d)$/);\n if (directMatch) {\n return parseInt(directMatch[1], 10);\n }\n\n const styleName = styleMap.get(styleId) ?? \"\";\n const nameMatch = styleName.match(/^[Hh]eading\\s*(\\d)$/);\n if (nameMatch) {\n return parseInt(nameMatch[1], 10);\n }\n\n if (/title/i.test(styleName) || /title/i.test(styleId)) {\n return 1;\n }\n\n return 0;\n}\n\nfunction isListItem(paragraphXml: string): boolean {\n return /<w:numId\\s/.test(paragraphXml);\n}\n\nfunction extractRunMarkdown(runXml: string): string {\n const textRegex = /<w:t(?:\\s[^>]*)?>([^<]*)<\\/w:t>/g;\n const texts: string[] = [];\n let match: RegExpExecArray | null;\n while ((match = textRegex.exec(runXml)) !== null) {\n texts.push(match[1]);\n }\n if (texts.length === 0) {\n return \"\";\n }\n\n const text = texts.join(\"\");\n const isBold = /<w:b[\\s/>]/.test(runXml) && !/<w:b\\s+w:val=\"(false|0)\"/.test(runXml);\n const isItalic = /<w:i[\\s/>]/.test(runXml) && !/<w:i\\s+w:val=\"(false|0)\"/.test(runXml);\n\n if (isBold && isItalic) {\n return `***${text}***`;\n }\n if (isBold) {\n return `**${text}**`;\n }\n if (isItalic) {\n return `*${text}*`;\n }\n return text;\n}\n\nfunction convertToMarkdown(xml: string, styleMap: Map<string, string>): string {\n const paragraphs: string[] = [];\n const paragraphRegex = /<w:p[\\s>][\\s\\S]*?<\\/w:p>/g;\n let paragraphMatch: RegExpExecArray | null;\n\n while ((paragraphMatch = paragraphRegex.exec(xml)) !== null) {\n const paragraphXml = paragraphMatch[0];\n\n const runRegex = /<w:r[\\s>][\\s\\S]*?<\\/w:r>/g;\n const runs: string[] = [];\n let runMatch: RegExpExecArray | null;\n while ((runMatch = runRegex.exec(paragraphXml)) !== null) {\n const md = extractRunMarkdown(runMatch[0]);\n if (md) {\n runs.push(md);\n }\n }\n\n if (runs.length === 0) {\n continue;\n }\n\n let line = runs.join(\"\");\n const headingLevel = getHeadingLevel(paragraphXml, styleMap);\n\n if (headingLevel > 0 && headingLevel <= 6) {\n line = `${\"#\".repeat(headingLevel)} ${line}`;\n } else if (isListItem(paragraphXml)) {\n line = `- ${line}`;\n }\n\n paragraphs.push(line);\n }\n\n return paragraphs.join(\"\\n\\n\");\n}\n\n// --- ZIP utilities (unchanged) ---\n\nfunction extractFileFromZip(buffer: Buffer, targetPath: string): string | null {\n const eocdOffset = findEocd(buffer);\n if (eocdOffset === -1) {\n throw new Error(\"Invalid ZIP: End of Central Directory not found.\");\n }\n\n const cdOffset = buffer.readUInt32LE(eocdOffset + 16);\n const cdSize = buffer.readUInt32LE(eocdOffset + 12);\n const cdEnd = cdOffset + cdSize;\n let offset = cdOffset;\n\n while (offset < cdEnd) {\n const sig = buffer.readUInt32LE(offset);\n if (sig !== 0x02014b50) {\n break;\n }\n\n const compressionMethod = buffer.readUInt16LE(offset + 10);\n const compressedSize = buffer.readUInt32LE(offset + 20);\n const fileNameLen = buffer.readUInt16LE(offset + 28);\n const extraLen = buffer.readUInt16LE(offset + 30);\n const commentLen = buffer.readUInt16LE(offset + 32);\n const localHeaderOffset = buffer.readUInt32LE(offset + 42);\n const fileName = buffer.toString(\"utf-8\", offset + 46, offset + 46 + fileNameLen);\n\n if (fileName === targetPath) {\n return readLocalFile(buffer, localHeaderOffset, compressionMethod, compressedSize);\n }\n\n offset += 46 + fileNameLen + extraLen + commentLen;\n }\n\n return null;\n}\n\nfunction readLocalFile(\n buffer: Buffer,\n offset: number,\n compressionMethod: number,\n compressedSize: number\n): string {\n const sig = buffer.readUInt32LE(offset);\n if (sig !== 0x04034b50) {\n throw new Error(\"Invalid ZIP: bad local file header.\");\n }\n\n const localFileNameLen = buffer.readUInt16LE(offset + 26);\n const localExtraLen = buffer.readUInt16LE(offset + 28);\n const dataOffset = offset + 30 + localFileNameLen + localExtraLen;\n\n const raw = buffer.subarray(dataOffset, dataOffset + compressedSize);\n\n if (compressionMethod === 0) {\n return raw.toString(\"utf-8\");\n }\n\n if (compressionMethod === 8) {\n return inflateRawSync(raw).toString(\"utf-8\");\n }\n\n throw new Error(`Unsupported ZIP compression method: ${compressionMethod}`);\n}\n\nfunction findEocd(buffer: Buffer): number {\n for (let i = buffer.length - 22; i >= Math.max(0, buffer.length - 65557); i--) {\n if (buffer.readUInt32LE(i) === 0x06054b50) {\n return i;\n }\n }\n return -1;\n}\n"],"names":["extractDocxText","buffer","xml","extractFileFromZip","Error","stylesXml","styleMap","buildStyleMap","Map","convertToMarkdown","map","styleRegex","match","styleId","block","nameMatch","getHeadingLevel","paragraphXml","styleMatch","directMatch","parseInt","styleName","isListItem","extractRunMarkdown","runXml","textRegex","texts","text","isBold","isItalic","paragraphs","paragraphRegex","paragraphMatch","runRegex","runs","runMatch","md","line","headingLevel","targetPath","eocdOffset","findEocd","cdOffset","cdSize","cdEnd","offset","sig","compressionMethod","compressedSize","fileNameLen","extraLen","commentLen","localHeaderOffset","fileName","readLocalFile","localFileNameLen","localExtraLen","dataOffset","raw","inflateRawSync","i","Math"],"mappings":"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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DomainEvent } from "../../features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "../../features/eventPublisher/index.js";
|
|
3
|
+
import type { AiGenerateTextParams, AiStreamTextParams } from "./abstractions.js";
|
|
4
|
+
import type { generateText } from "ai";
|
|
5
|
+
export interface AiBeforeGenerateTextPayload {
|
|
6
|
+
requestId: string;
|
|
7
|
+
params: AiGenerateTextParams;
|
|
8
|
+
}
|
|
9
|
+
export declare class AiBeforeGenerateTextEvent extends DomainEvent<AiBeforeGenerateTextPayload> {
|
|
10
|
+
eventType: "ai.beforeGenerateText";
|
|
11
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiBeforeGenerateTextEvent>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const AiBeforeGenerateTextEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiBeforeGenerateTextEvent>>;
|
|
14
|
+
export declare namespace AiBeforeGenerateTextEventHandler {
|
|
15
|
+
type Interface = IEventHandler<AiBeforeGenerateTextEvent>;
|
|
16
|
+
type Event = AiBeforeGenerateTextEvent;
|
|
17
|
+
}
|
|
18
|
+
export interface AiAfterGenerateTextPayload {
|
|
19
|
+
requestId: string;
|
|
20
|
+
params: AiGenerateTextParams;
|
|
21
|
+
result: Awaited<ReturnType<typeof generateText>>;
|
|
22
|
+
duration: number;
|
|
23
|
+
}
|
|
24
|
+
export declare class AiAfterGenerateTextEvent extends DomainEvent<AiAfterGenerateTextPayload> {
|
|
25
|
+
eventType: "ai.afterGenerateText";
|
|
26
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiAfterGenerateTextEvent>>;
|
|
27
|
+
}
|
|
28
|
+
export declare const AiAfterGenerateTextEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiAfterGenerateTextEvent>>;
|
|
29
|
+
export declare namespace AiAfterGenerateTextEventHandler {
|
|
30
|
+
type Interface = IEventHandler<AiAfterGenerateTextEvent>;
|
|
31
|
+
type Event = AiAfterGenerateTextEvent;
|
|
32
|
+
}
|
|
33
|
+
export interface AiGenerateTextErrorPayload {
|
|
34
|
+
requestId: string;
|
|
35
|
+
params: AiGenerateTextParams;
|
|
36
|
+
error: Error;
|
|
37
|
+
duration: number;
|
|
38
|
+
}
|
|
39
|
+
export declare class AiGenerateTextErrorEvent extends DomainEvent<AiGenerateTextErrorPayload> {
|
|
40
|
+
eventType: "ai.generateTextError";
|
|
41
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiGenerateTextErrorEvent>>;
|
|
42
|
+
}
|
|
43
|
+
export declare const AiGenerateTextErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiGenerateTextErrorEvent>>;
|
|
44
|
+
export declare namespace AiGenerateTextErrorEventHandler {
|
|
45
|
+
type Interface = IEventHandler<AiGenerateTextErrorEvent>;
|
|
46
|
+
type Event = AiGenerateTextErrorEvent;
|
|
47
|
+
}
|
|
48
|
+
export interface AiBeforeStreamTextPayload {
|
|
49
|
+
params: AiStreamTextParams;
|
|
50
|
+
}
|
|
51
|
+
export declare class AiBeforeStreamTextEvent extends DomainEvent<AiBeforeStreamTextPayload> {
|
|
52
|
+
eventType: "ai.beforeStreamText";
|
|
53
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<AiBeforeStreamTextEvent>>;
|
|
54
|
+
}
|
|
55
|
+
export declare const AiBeforeStreamTextEventHandler: import("@webiny/di").Abstraction<IEventHandler<AiBeforeStreamTextEvent>>;
|
|
56
|
+
export declare namespace AiBeforeStreamTextEventHandler {
|
|
57
|
+
type Interface = IEventHandler<AiBeforeStreamTextEvent>;
|
|
58
|
+
type Event = AiBeforeStreamTextEvent;
|
|
59
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
import { DomainEvent } from "../eventPublisher/index.js";
|
|
3
|
+
class AiBeforeGenerateTextEvent extends DomainEvent {
|
|
4
|
+
getHandlerAbstraction() {
|
|
5
|
+
return AiBeforeGenerateTextEventHandler;
|
|
6
|
+
}
|
|
7
|
+
constructor(...args){
|
|
8
|
+
super(...args), this.eventType = "ai.beforeGenerateText";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const AiBeforeGenerateTextEventHandler = createAbstraction("AiBeforeGenerateTextEventHandler");
|
|
12
|
+
class AiAfterGenerateTextEvent extends DomainEvent {
|
|
13
|
+
getHandlerAbstraction() {
|
|
14
|
+
return AiAfterGenerateTextEventHandler;
|
|
15
|
+
}
|
|
16
|
+
constructor(...args){
|
|
17
|
+
super(...args), this.eventType = "ai.afterGenerateText";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const AiAfterGenerateTextEventHandler = createAbstraction("AiAfterGenerateTextEventHandler");
|
|
21
|
+
class AiGenerateTextErrorEvent extends DomainEvent {
|
|
22
|
+
getHandlerAbstraction() {
|
|
23
|
+
return AiGenerateTextErrorEventHandler;
|
|
24
|
+
}
|
|
25
|
+
constructor(...args){
|
|
26
|
+
super(...args), this.eventType = "ai.generateTextError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const AiGenerateTextErrorEventHandler = createAbstraction("AiGenerateTextErrorEventHandler");
|
|
30
|
+
class AiBeforeStreamTextEvent extends DomainEvent {
|
|
31
|
+
getHandlerAbstraction() {
|
|
32
|
+
return AiBeforeStreamTextEventHandler;
|
|
33
|
+
}
|
|
34
|
+
constructor(...args){
|
|
35
|
+
super(...args), this.eventType = "ai.beforeStreamText";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const AiBeforeStreamTextEventHandler = createAbstraction("AiBeforeStreamTextEventHandler");
|
|
39
|
+
export { AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/events.js","sources":["../../../src/features/ai/events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"~/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"~/features/eventPublisher/index.js\";\nimport type { AiGenerateTextParams, AiStreamTextParams } from \"./abstractions.js\";\nimport type { generateText } from \"ai\";\n\n// ============================================================================\n// BeforeGenerateText\n// ============================================================================\n\nexport interface AiBeforeGenerateTextPayload {\n requestId: string;\n params: AiGenerateTextParams;\n}\n\nexport class AiBeforeGenerateTextEvent extends DomainEvent<AiBeforeGenerateTextPayload> {\n eventType = \"ai.beforeGenerateText\" as const;\n\n getHandlerAbstraction() {\n return AiBeforeGenerateTextEventHandler;\n }\n}\n\nexport const AiBeforeGenerateTextEventHandler = createAbstraction<\n IEventHandler<AiBeforeGenerateTextEvent>\n>(\"AiBeforeGenerateTextEventHandler\");\n\nexport namespace AiBeforeGenerateTextEventHandler {\n export type Interface = IEventHandler<AiBeforeGenerateTextEvent>;\n export type Event = AiBeforeGenerateTextEvent;\n}\n\n// ============================================================================\n// AfterGenerateText\n// ============================================================================\n\nexport interface AiAfterGenerateTextPayload {\n requestId: string;\n params: AiGenerateTextParams;\n result: Awaited<ReturnType<typeof generateText>>;\n duration: number;\n}\n\nexport class AiAfterGenerateTextEvent extends DomainEvent<AiAfterGenerateTextPayload> {\n eventType = \"ai.afterGenerateText\" as const;\n\n getHandlerAbstraction() {\n return AiAfterGenerateTextEventHandler;\n }\n}\n\nexport const AiAfterGenerateTextEventHandler = createAbstraction<\n IEventHandler<AiAfterGenerateTextEvent>\n>(\"AiAfterGenerateTextEventHandler\");\n\nexport namespace AiAfterGenerateTextEventHandler {\n export type Interface = IEventHandler<AiAfterGenerateTextEvent>;\n export type Event = AiAfterGenerateTextEvent;\n}\n\n// ============================================================================\n// GenerateTextError\n// ============================================================================\n\nexport interface AiGenerateTextErrorPayload {\n requestId: string;\n params: AiGenerateTextParams;\n error: Error;\n duration: number;\n}\n\nexport class AiGenerateTextErrorEvent extends DomainEvent<AiGenerateTextErrorPayload> {\n eventType = \"ai.generateTextError\" as const;\n\n getHandlerAbstraction() {\n return AiGenerateTextErrorEventHandler;\n }\n}\n\nexport const AiGenerateTextErrorEventHandler = createAbstraction<\n IEventHandler<AiGenerateTextErrorEvent>\n>(\"AiGenerateTextErrorEventHandler\");\n\nexport namespace AiGenerateTextErrorEventHandler {\n export type Interface = IEventHandler<AiGenerateTextErrorEvent>;\n export type Event = AiGenerateTextErrorEvent;\n}\n\n// ============================================================================\n// BeforeStreamText\n// ============================================================================\n\nexport interface AiBeforeStreamTextPayload {\n params: AiStreamTextParams;\n}\n\nexport class AiBeforeStreamTextEvent extends DomainEvent<AiBeforeStreamTextPayload> {\n eventType = \"ai.beforeStreamText\" as const;\n\n getHandlerAbstraction() {\n return AiBeforeStreamTextEventHandler;\n }\n}\n\nexport const AiBeforeStreamTextEventHandler = createAbstraction<\n IEventHandler<AiBeforeStreamTextEvent>\n>(\"AiBeforeStreamTextEventHandler\");\n\nexport namespace AiBeforeStreamTextEventHandler {\n export type Interface = IEventHandler<AiBeforeStreamTextEvent>;\n export type Event = AiBeforeStreamTextEvent;\n}\n"],"names":["AiBeforeGenerateTextEvent","DomainEvent","AiBeforeGenerateTextEventHandler","createAbstraction","AiAfterGenerateTextEvent","AiAfterGenerateTextEventHandler","AiGenerateTextErrorEvent","AiGenerateTextErrorEventHandler","AiBeforeStreamTextEvent","AiBeforeStreamTextEventHandler"],"mappings":";;AAeO,MAAMA,kCAAkCC;IAG3C,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,mCAAmCC,kBAE9C;AAkBK,MAAMC,iCAAiCH;IAG1C,wBAAwB;QACpB,OAAOI;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,kCAAkCF,kBAE7C;AAkBK,MAAMG,iCAAiCL;IAG1C,wBAAwB;QACpB,OAAOM;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,kCAAkCJ,kBAE7C;AAeK,MAAMK,gCAAgCP;IAGzC,wBAAwB;QACpB,OAAOQ;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,iCAAiCN,kBAE5C"}
|
package/features/ai/feature.js
CHANGED
|
@@ -3,6 +3,9 @@ import { OpenAiSdkFactory } from "./OpenAiSdkFactory.js";
|
|
|
3
3
|
import { AnthropicSdkFactory } from "./AnthropicSdkFactory.js";
|
|
4
4
|
import { Ai } from "./Ai.js";
|
|
5
5
|
import { AiSdkTools } from "./AiSdkTools.js";
|
|
6
|
+
import { AiOutputToolRegistry } from "./toolPipeline/AiOutputToolRegistry.js";
|
|
7
|
+
import { AiToolPipelineRunner } from "./toolPipeline/AiToolPipelineRunner.js";
|
|
8
|
+
import { DefaultTextExtractor } from "./TextExtractor/DefaultTextExtractor.js";
|
|
6
9
|
const AiFeature = createFeature({
|
|
7
10
|
name: "AiFeature",
|
|
8
11
|
register (container) {
|
|
@@ -10,6 +13,9 @@ const AiFeature = createFeature({
|
|
|
10
13
|
container.register(AnthropicSdkFactory);
|
|
11
14
|
container.register(Ai);
|
|
12
15
|
container.register(AiSdkTools);
|
|
16
|
+
container.register(AiOutputToolRegistry);
|
|
17
|
+
container.register(AiToolPipelineRunner);
|
|
18
|
+
container.register(DefaultTextExtractor);
|
|
13
19
|
}
|
|
14
20
|
});
|
|
15
21
|
export { AiFeature };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { OpenAiSdkFactory } from \"./OpenAiSdkFactory.js\";\nimport { AnthropicSdkFactory } from \"./AnthropicSdkFactory.js\";\nimport { Ai } from \"./Ai.js\";\nimport { AiSdkTools } from \"./AiSdkTools.js\";\n\nexport const AiFeature = createFeature({\n name: \"AiFeature\",\n register(container) {\n container.register(OpenAiSdkFactory);\n container.register(AnthropicSdkFactory);\n container.register(Ai);\n container.register(AiSdkTools);\n }\n});\n"],"names":["AiFeature","createFeature","container","OpenAiSdkFactory","AnthropicSdkFactory","Ai","AiSdkTools"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/ai/feature.js","sources":["../../../src/features/ai/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { OpenAiSdkFactory } from \"./OpenAiSdkFactory.js\";\nimport { AnthropicSdkFactory } from \"./AnthropicSdkFactory.js\";\nimport { Ai } from \"./Ai.js\";\nimport { AiSdkTools } from \"./AiSdkTools.js\";\nimport { AiOutputToolRegistry } from \"./toolPipeline/AiOutputToolRegistry.js\";\nimport { AiToolPipelineRunner } from \"./toolPipeline/AiToolPipelineRunner.js\";\nimport { DefaultTextExtractor } from \"./TextExtractor/DefaultTextExtractor.js\";\n\nexport const AiFeature = createFeature({\n name: \"AiFeature\",\n register(container) {\n container.register(OpenAiSdkFactory);\n container.register(AnthropicSdkFactory);\n container.register(Ai);\n container.register(AiSdkTools);\n container.register(AiOutputToolRegistry);\n container.register(AiToolPipelineRunner);\n container.register(DefaultTextExtractor);\n }\n});\n"],"names":["AiFeature","createFeature","container","OpenAiSdkFactory","AnthropicSdkFactory","Ai","AiSdkTools","AiOutputToolRegistry","AiToolPipelineRunner","DefaultTextExtractor"],"mappings":";;;;;;;;AASO,MAAMA,YAAYC,cAAc;IACnC,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;IACvB;AACJ"}
|
package/features/ai/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export { AiSdk, AiSdkFactory, AiConnectionFactory, Ai, AiSdkTool, AiSdkTools } from "./abstractions.js";
|
|
2
2
|
export type { IAiConnection, IAiConnectionInline, AiModel, IAiSdkModel, IAiSdkTool, IAiSdkTools } from "./abstractions.js";
|
|
3
|
+
export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./toolPipeline/index.js";
|
|
4
|
+
export type { IAiOutputTool, IAiOutputToolRegistry, IAiToolPipelineRunner } from "./toolPipeline/index.js";
|
|
5
|
+
export { TextExtractor, DefaultTextExtractor } from "./TextExtractor/index.js";
|
|
6
|
+
export type { ITextExtractor, TextExtractorResult } from "./TextExtractor/index.js";
|
|
7
|
+
export { AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler } from "./events.js";
|
|
8
|
+
export type { AiBeforeGenerateTextPayload, AiAfterGenerateTextPayload, AiGenerateTextErrorPayload, AiBeforeStreamTextPayload } from "./events.js";
|
|
3
9
|
export { AiFeature } from "./feature.js";
|
package/features/ai/index.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { Ai, AiConnectionFactory, AiSdk, AiSdkFactory, AiSdkTool, AiSdkTools } from "./abstractions.js";
|
|
2
|
+
export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./toolPipeline/index.js";
|
|
3
|
+
export { DefaultTextExtractor, TextExtractor } from "./TextExtractor/index.js";
|
|
4
|
+
export { AiAfterGenerateTextEvent, AiAfterGenerateTextEventHandler, AiBeforeGenerateTextEvent, AiBeforeGenerateTextEventHandler, AiBeforeStreamTextEvent, AiBeforeStreamTextEventHandler, AiGenerateTextErrorEvent, AiGenerateTextErrorEventHandler } from "./events.js";
|
|
2
5
|
export { AiFeature } from "./feature.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IAiOutputTool, type IAiOutputToolRegistry } from "./abstractions.js";
|
|
2
|
+
declare class AiOutputToolRegistryImpl implements IAiOutputToolRegistry {
|
|
3
|
+
private toolMap;
|
|
4
|
+
constructor(tools: IAiOutputTool[]);
|
|
5
|
+
has(name: string): boolean;
|
|
6
|
+
invoke(name: string, params: Record<string, unknown>): Promise<unknown>;
|
|
7
|
+
}
|
|
8
|
+
export declare const AiOutputToolRegistry: typeof AiOutputToolRegistryImpl & {
|
|
9
|
+
__abstraction: import("@webiny/di").Abstraction<IAiOutputToolRegistry>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AiOutputTool, AiOutputToolRegistry } from "./abstractions.js";
|
|
2
|
+
class AiOutputToolRegistryImpl {
|
|
3
|
+
constructor(tools){
|
|
4
|
+
this.toolMap = new Map(tools.map((t)=>[
|
|
5
|
+
t.name,
|
|
6
|
+
t
|
|
7
|
+
]));
|
|
8
|
+
}
|
|
9
|
+
has(name) {
|
|
10
|
+
return this.toolMap.has(name);
|
|
11
|
+
}
|
|
12
|
+
async invoke(name, params) {
|
|
13
|
+
const tool = this.toolMap.get(name);
|
|
14
|
+
if (!tool) return;
|
|
15
|
+
return tool.execute(params);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const AiOutputToolRegistry_AiOutputToolRegistry = AiOutputToolRegistry.createImplementation({
|
|
19
|
+
implementation: AiOutputToolRegistryImpl,
|
|
20
|
+
dependencies: [
|
|
21
|
+
[
|
|
22
|
+
AiOutputTool,
|
|
23
|
+
{
|
|
24
|
+
multiple: true
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { AiOutputToolRegistry_AiOutputToolRegistry as AiOutputToolRegistry };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=AiOutputToolRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/toolPipeline/AiOutputToolRegistry.js","sources":["../../../../src/features/ai/toolPipeline/AiOutputToolRegistry.ts"],"sourcesContent":["import {\n AiOutputTool,\n AiOutputToolRegistry as Abstraction,\n type IAiOutputTool,\n type IAiOutputToolRegistry\n} from \"./abstractions.js\";\n\nclass AiOutputToolRegistryImpl implements IAiOutputToolRegistry {\n private toolMap: Map<string, IAiOutputTool>;\n\n constructor(tools: IAiOutputTool[]) {\n this.toolMap = new Map(tools.map(t => [t.name, t]));\n }\n\n has(name: string): boolean {\n return this.toolMap.has(name);\n }\n\n async invoke(name: string, params: Record<string, unknown>): Promise<unknown> {\n const tool = this.toolMap.get(name);\n if (!tool) {\n return undefined;\n }\n return tool.execute(params);\n }\n}\n\nexport const AiOutputToolRegistry = Abstraction.createImplementation({\n implementation: AiOutputToolRegistryImpl,\n dependencies: [[AiOutputTool, { multiple: true }]]\n});\n"],"names":["AiOutputToolRegistryImpl","tools","Map","t","name","params","tool","AiOutputToolRegistry","Abstraction","AiOutputTool"],"mappings":";AAOA,MAAMA;IAGF,YAAYC,KAAsB,CAAE;QAChC,IAAI,CAAC,OAAO,GAAG,IAAIC,IAAID,MAAM,GAAG,CAACE,CAAAA,IAAK;gBAACA,EAAE,IAAI;gBAAEA;aAAE;IACrD;IAEA,IAAIC,IAAY,EAAW;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAACA;IAC5B;IAEA,MAAM,OAAOA,IAAY,EAAEC,MAA+B,EAAoB;QAC1E,MAAMC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAACF;QAC9B,IAAI,CAACE,MACD;QAEJ,OAAOA,KAAK,OAAO,CAACD;IACxB;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBR;IAChB,cAAc;QAAC;YAACS;YAAc;gBAAE,UAAU;YAAK;SAAE;KAAC;AACtD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IAiOutputToolRegistry, type IAiToolPipelineRunner } from "./abstractions.js";
|
|
2
|
+
declare class AiToolPipelineRunnerImpl implements IAiToolPipelineRunner {
|
|
3
|
+
private registry;
|
|
4
|
+
constructor(registry: IAiOutputToolRegistry);
|
|
5
|
+
resolve(data: unknown): Promise<unknown>;
|
|
6
|
+
}
|
|
7
|
+
export declare const AiToolPipelineRunner: typeof AiToolPipelineRunnerImpl & {
|
|
8
|
+
__abstraction: import("@webiny/di").Abstraction<IAiToolPipelineRunner>;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AiOutputToolRegistry, AiToolPipelineRunner } from "./abstractions.js";
|
|
2
|
+
function isToolEnvelope(value) {
|
|
3
|
+
return "object" == typeof value && null !== value && "tool" in value && "string" == typeof value.tool && "params" in value && "object" == typeof value.params;
|
|
4
|
+
}
|
|
5
|
+
class AiToolPipelineRunnerImpl {
|
|
6
|
+
constructor(registry){
|
|
7
|
+
this.registry = registry;
|
|
8
|
+
}
|
|
9
|
+
async resolve(data) {
|
|
10
|
+
if (null == data) return data;
|
|
11
|
+
if (isToolEnvelope(data)) {
|
|
12
|
+
if (!this.registry.has(data.tool)) return data;
|
|
13
|
+
const result = await this.registry.invoke(data.tool, data.params);
|
|
14
|
+
return this.resolve(result);
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(data)) return Promise.all(data.map((item)=>this.resolve(item)));
|
|
17
|
+
if ("object" == typeof data) {
|
|
18
|
+
const entries = Object.entries(data);
|
|
19
|
+
const resolvedValues = await Promise.all(entries.map(([, value])=>this.resolve(value)));
|
|
20
|
+
return Object.fromEntries(entries.map(([key], i)=>[
|
|
21
|
+
key,
|
|
22
|
+
resolvedValues[i]
|
|
23
|
+
]));
|
|
24
|
+
}
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const AiToolPipelineRunner_AiToolPipelineRunner = AiToolPipelineRunner.createImplementation({
|
|
29
|
+
implementation: AiToolPipelineRunnerImpl,
|
|
30
|
+
dependencies: [
|
|
31
|
+
AiOutputToolRegistry
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
export { AiToolPipelineRunner_AiToolPipelineRunner as AiToolPipelineRunner };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=AiToolPipelineRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/toolPipeline/AiToolPipelineRunner.js","sources":["../../../../src/features/ai/toolPipeline/AiToolPipelineRunner.ts"],"sourcesContent":["import {\n AiOutputToolRegistry,\n AiToolPipelineRunner as Abstraction,\n type IAiOutputToolRegistry,\n type IAiToolPipelineRunner\n} from \"./abstractions.js\";\n\nfunction isToolEnvelope(\n value: unknown\n): value is { tool: string; params: Record<string, unknown> } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"tool\" in value &&\n typeof (value as Record<string, unknown>).tool === \"string\" &&\n \"params\" in value &&\n typeof (value as Record<string, unknown>).params === \"object\"\n );\n}\n\nclass AiToolPipelineRunnerImpl implements IAiToolPipelineRunner {\n constructor(private registry: IAiOutputToolRegistry) {}\n\n async resolve(data: unknown): Promise<unknown> {\n if (data === null || data === undefined) {\n return data;\n }\n\n if (isToolEnvelope(data)) {\n if (!this.registry.has(data.tool)) {\n return data;\n }\n const result = await this.registry.invoke(data.tool, data.params);\n return this.resolve(result);\n }\n\n if (Array.isArray(data)) {\n return Promise.all(data.map(item => this.resolve(item)));\n }\n\n if (typeof data === \"object\") {\n const entries = Object.entries(data as Record<string, unknown>);\n const resolvedValues = await Promise.all(\n entries.map(([, value]) => this.resolve(value))\n );\n return Object.fromEntries(entries.map(([key], i) => [key, resolvedValues[i]]));\n }\n\n return data;\n }\n}\n\nexport const AiToolPipelineRunner = Abstraction.createImplementation({\n implementation: AiToolPipelineRunnerImpl,\n dependencies: [AiOutputToolRegistry]\n});\n"],"names":["isToolEnvelope","value","AiToolPipelineRunnerImpl","registry","data","result","Array","Promise","item","entries","Object","resolvedValues","key","i","AiToolPipelineRunner","Abstraction","AiOutputToolRegistry"],"mappings":";AAOA,SAASA,eACLC,KAAc;IAEd,OACI,AAAiB,YAAjB,OAAOA,SACPA,AAAU,SAAVA,SACA,UAAUA,SACV,AAAmD,YAAnD,OAAQA,MAAkC,IAAI,IAC9C,YAAYA,SACZ,AAAqD,YAArD,OAAQA,MAAkC,MAAM;AAExD;AAEA,MAAMC;IACF,YAAoBC,QAA+B,CAAE;aAAjCA,QAAQ,GAARA;IAAkC;IAEtD,MAAM,QAAQC,IAAa,EAAoB;QAC3C,IAAIA,QAAAA,MACA,OAAOA;QAGX,IAAIJ,eAAeI,OAAO;YACtB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAACA,KAAK,IAAI,GAC5B,OAAOA;YAEX,MAAMC,SAAS,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAACD,KAAK,IAAI,EAAEA,KAAK,MAAM;YAChE,OAAO,IAAI,CAAC,OAAO,CAACC;QACxB;QAEA,IAAIC,MAAM,OAAO,CAACF,OACd,OAAOG,QAAQ,GAAG,CAACH,KAAK,GAAG,CAACI,CAAAA,OAAQ,IAAI,CAAC,OAAO,CAACA;QAGrD,IAAI,AAAgB,YAAhB,OAAOJ,MAAmB;YAC1B,MAAMK,UAAUC,OAAO,OAAO,CAACN;YAC/B,MAAMO,iBAAiB,MAAMJ,QAAQ,GAAG,CACpCE,QAAQ,GAAG,CAAC,CAAC,GAAGR,MAAM,GAAK,IAAI,CAAC,OAAO,CAACA;YAE5C,OAAOS,OAAO,WAAW,CAACD,QAAQ,GAAG,CAAC,CAAC,CAACG,IAAI,EAAEC,IAAM;oBAACD;oBAAKD,cAAc,CAACE,EAAE;iBAAC;QAChF;QAEA,OAAOT;IACX;AACJ;AAEO,MAAMU,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBb;IAChB,cAAc;QAACc;KAAqB;AACxC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface IAiOutputTool {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
execute(params: Record<string, unknown>): Promise<unknown>;
|
|
4
|
+
}
|
|
5
|
+
export declare const AiOutputTool: import("@webiny/di").Abstraction<IAiOutputTool>;
|
|
6
|
+
export declare namespace AiOutputTool {
|
|
7
|
+
type Interface = IAiOutputTool;
|
|
8
|
+
}
|
|
9
|
+
export interface IAiOutputToolRegistry {
|
|
10
|
+
has(name: string): boolean;
|
|
11
|
+
invoke(name: string, params: Record<string, unknown>): Promise<unknown>;
|
|
12
|
+
}
|
|
13
|
+
export declare const AiOutputToolRegistry: import("@webiny/di").Abstraction<IAiOutputToolRegistry>;
|
|
14
|
+
export declare namespace AiOutputToolRegistry {
|
|
15
|
+
type Interface = IAiOutputToolRegistry;
|
|
16
|
+
}
|
|
17
|
+
export interface IAiToolPipelineRunner {
|
|
18
|
+
resolve(data: unknown): Promise<unknown>;
|
|
19
|
+
}
|
|
20
|
+
export declare const AiToolPipelineRunner: import("@webiny/di").Abstraction<IAiToolPipelineRunner>;
|
|
21
|
+
export declare namespace AiToolPipelineRunner {
|
|
22
|
+
type Interface = IAiToolPipelineRunner;
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const AiOutputTool = createAbstraction("AiOutputTool");
|
|
3
|
+
const AiOutputToolRegistry = createAbstraction("AiOutputToolRegistry");
|
|
4
|
+
const AiToolPipelineRunner = createAbstraction("AiToolPipelineRunner");
|
|
5
|
+
export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/ai/toolPipeline/abstractions.js","sources":["../../../../src/features/ai/toolPipeline/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IAiOutputTool {\n readonly name: string;\n execute(params: Record<string, unknown>): Promise<unknown>;\n}\n\nexport const AiOutputTool = createAbstraction<IAiOutputTool>(\"AiOutputTool\");\n\nexport namespace AiOutputTool {\n export type Interface = IAiOutputTool;\n}\n\nexport interface IAiOutputToolRegistry {\n has(name: string): boolean;\n invoke(name: string, params: Record<string, unknown>): Promise<unknown>;\n}\n\nexport const AiOutputToolRegistry =\n createAbstraction<IAiOutputToolRegistry>(\"AiOutputToolRegistry\");\n\nexport namespace AiOutputToolRegistry {\n export type Interface = IAiOutputToolRegistry;\n}\n\nexport interface IAiToolPipelineRunner {\n resolve(data: unknown): Promise<unknown>;\n}\n\nexport const AiToolPipelineRunner =\n createAbstraction<IAiToolPipelineRunner>(\"AiToolPipelineRunner\");\n\nexport namespace AiToolPipelineRunner {\n export type Interface = IAiToolPipelineRunner;\n}\n"],"names":["AiOutputTool","createAbstraction","AiOutputToolRegistry","AiToolPipelineRunner"],"mappings":";AAOO,MAAMA,eAAeC,kBAAiC;AAWtD,MAAMC,uBACTD,kBAAyC;AAUtC,MAAME,uBACTF,kBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AiOutputTool, AiOutputToolRegistry, AiToolPipelineRunner } from "./abstractions.js";
|
|
@@ -7,7 +7,7 @@ declare class GetApiKeyUseCaseImpl implements GetApiKeyUseCaseAbstraction.Interf
|
|
|
7
7
|
private repository;
|
|
8
8
|
private identityContext;
|
|
9
9
|
constructor(repository: ApiKeysRepository.Interface, identityContext: IdentityContext.Interface);
|
|
10
|
-
execute(id: string): Promise<Result<ApiKey
|
|
10
|
+
execute(id: string): Promise<Result<ApiKey, GetApiKeyUseCaseAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const GetApiKeyUseCase: typeof GetApiKeyUseCaseImpl & {
|
|
13
13
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetApiKey>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js","sources":["../../../../../src/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetApiKeyUseCase as GetApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport type { ApiKey } from \"../shared/types.js\";\nimport { ApiKeyNotAuthorizedError } from \"~/features/security/apiKeys/shared/errors.js\";\n\nclass GetApiKeyUseCaseImpl implements GetApiKeyUseCaseAbstraction.Interface {\n private repository: ApiKeysRepository.Interface;\n private identityContext: IdentityContext.Interface;\n\n constructor(\n repository: ApiKeysRepository.Interface,\n identityContext: IdentityContext.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n }\n\n async execute(id: string): Promise<Result<ApiKey
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/GetApiKey/GetApiKeyUseCase.js","sources":["../../../../../src/features/security/apiKeys/GetApiKey/GetApiKeyUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetApiKeyUseCase as GetApiKeyUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\nimport { IdentityContext } from \"../../IdentityContext/abstractions.js\";\nimport type { ApiKey } from \"../shared/types.js\";\nimport { ApiKeyNotAuthorizedError } from \"~/features/security/apiKeys/shared/errors.js\";\n\nclass GetApiKeyUseCaseImpl implements GetApiKeyUseCaseAbstraction.Interface {\n private repository: ApiKeysRepository.Interface;\n private identityContext: IdentityContext.Interface;\n\n constructor(\n repository: ApiKeysRepository.Interface,\n identityContext: IdentityContext.Interface\n ) {\n this.repository = repository;\n this.identityContext = identityContext;\n }\n\n async execute(id: string): Promise<Result<ApiKey, GetApiKeyUseCaseAbstraction.Error>> {\n const hasPermission = await this.identityContext.getPermission(\"security.apiKey\");\n if (!hasPermission) {\n return Result.fail(new ApiKeyNotAuthorizedError());\n }\n\n return this.repository.get(id);\n }\n}\n\nexport const GetApiKeyUseCase = GetApiKeyUseCaseAbstraction.createImplementation({\n implementation: GetApiKeyUseCaseImpl,\n dependencies: [ApiKeysRepository, IdentityContext]\n});\n"],"names":["GetApiKeyUseCaseImpl","repository","identityContext","id","hasPermission","Result","ApiKeyNotAuthorizedError","GetApiKeyUseCase","GetApiKeyUseCaseAbstraction","ApiKeysRepository","IdentityContext"],"mappings":";;;;;AAOA,MAAMA;IAIF,YACIC,UAAuC,EACvCC,eAA0C,CAC5C;QACE,IAAI,CAAC,UAAU,GAAGD;QAClB,IAAI,CAAC,eAAe,GAAGC;IAC3B;IAEA,MAAM,QAAQC,EAAU,EAA8D;QAClF,MAAMC,gBAAgB,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC;QAC/D,IAAI,CAACA,eACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;QAG3B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAACH;IAC/B;AACJ;AAEO,MAAMI,oCAAmBC,iBAAAA,oBAAgD,CAAC;IAC7E,gBAAgBR;IAChB,cAAc;QAACS;QAAmBC;KAAgB;AACtD"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { Result } from "@webiny/feature/api";
|
|
2
1
|
import { GetApiKeyBySlugUseCase as GetApiKeyBySlugUseCaseAbstraction } from "./abstractions.js";
|
|
3
2
|
import { ApiKeysRepository } from "../shared/abstractions.js";
|
|
4
|
-
import type { ApiKey } from "../shared/types.js";
|
|
5
3
|
declare class GetApiKeyBySlugUseCaseImpl implements GetApiKeyBySlugUseCaseAbstraction.Interface {
|
|
6
4
|
private repository;
|
|
7
5
|
constructor(repository: ApiKeysRepository.Interface);
|
|
8
|
-
execute(slug: string): Promise<Result<ApiKey |
|
|
6
|
+
execute(slug: string): Promise<import("@webiny/feature/api").Result<import("../shared/types.js").ApiKey, import("../shared/errors.js").ApiKeyNotFoundError | import("../shared/errors.js").ApiKeyPersistenceError | import("../shared/errors.js").ApiKeyValidationError>>;
|
|
9
7
|
}
|
|
10
8
|
export declare const GetApiKeyBySlugUseCase: typeof GetApiKeyBySlugUseCaseImpl & {
|
|
11
9
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetApiKeyBySlug>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.ts"],"sourcesContent":["import { GetApiKeyBySlugUseCase as GetApiKeyBySlugUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\n\nclass GetApiKeyBySlugUseCaseImpl implements GetApiKeyBySlugUseCaseAbstraction.Interface {\n constructor(private repository: ApiKeysRepository.Interface) {}\n\n async execute(slug: string) {\n return this.repository.getBySlug(slug);\n }\n}\n\nexport const GetApiKeyBySlugUseCase = GetApiKeyBySlugUseCaseAbstraction.createImplementation({\n implementation: GetApiKeyBySlugUseCaseImpl,\n dependencies: [ApiKeysRepository]\n});\n"],"names":["GetApiKeyBySlugUseCaseImpl","repository","slug","GetApiKeyBySlugUseCase","GetApiKeyBySlugUseCaseAbstraction","ApiKeysRepository"],"mappings":";;AAGA,MAAMA;IACF,YAAoBC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAE9D,MAAM,QAAQC,IAAY,EAAE;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAACA;IACrC;AACJ;AAEO,MAAMC,gDAAyBC,uBAAAA,oBAAsD,CAAC;IACzF,gBAAgBJ;IAChB,cAAc;QAACK;KAAkB;AACrC"}
|
|
@@ -5,7 +5,7 @@ export interface IGetApiKeyBySlugErrors {
|
|
|
5
5
|
}
|
|
6
6
|
type GetApiKeyBySlugError = IGetApiKeyBySlugErrors[keyof IGetApiKeyBySlugErrors] | ApiKeysRepository.Error;
|
|
7
7
|
export interface IGetApiKeyBySlug {
|
|
8
|
-
execute(slug: string): Promise<Result<ApiKey
|
|
8
|
+
execute(slug: string): Promise<Result<ApiKey, GetApiKeyBySlugError>>;
|
|
9
9
|
}
|
|
10
10
|
/** Retrieve an API key by its slug. */
|
|
11
11
|
export declare const GetApiKeyBySlugUseCase: import("@webiny/di").Abstraction<IGetApiKeyBySlug>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/apiKeys/GetApiKeyBySlug/abstractions.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyBySlug/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey } from \"../shared/types.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\n\nexport interface IGetApiKeyBySlugErrors {\n // No use-case specific errors - only repository errors can occur\n}\n\ntype GetApiKeyBySlugError =\n | IGetApiKeyBySlugErrors[keyof IGetApiKeyBySlugErrors]\n | ApiKeysRepository.Error;\n\nexport interface IGetApiKeyBySlug {\n execute(slug: string): Promise<Result<ApiKey
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/GetApiKeyBySlug/abstractions.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyBySlug/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey } from \"../shared/types.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\n\nexport interface IGetApiKeyBySlugErrors {\n // No use-case specific errors - only repository errors can occur\n}\n\ntype GetApiKeyBySlugError =\n | IGetApiKeyBySlugErrors[keyof IGetApiKeyBySlugErrors]\n | ApiKeysRepository.Error;\n\nexport interface IGetApiKeyBySlug {\n execute(slug: string): Promise<Result<ApiKey, GetApiKeyBySlugError>>;\n}\n\n/** Retrieve an API key by its slug. */\nexport const GetApiKeyBySlugUseCase = createAbstraction<IGetApiKeyBySlug>(\"GetApiKeyBySlugUseCase\");\n\nexport namespace GetApiKeyBySlugUseCase {\n export type Interface = IGetApiKeyBySlug;\n export type Error = GetApiKeyBySlugError;\n}\n"],"names":["GetApiKeyBySlugUseCase","createAbstraction"],"mappings":";AAkBO,MAAMA,yBAAyBC,kBAAoC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { Result } from "@webiny/feature/api";
|
|
2
1
|
import { GetApiKeyByTokenUseCase as GetApiKeyByTokenUseCaseAbstraction } from "./abstractions.js";
|
|
3
2
|
import { ApiKeysRepository } from "../shared/abstractions.js";
|
|
4
|
-
import type { ApiKey } from "../shared/types.js";
|
|
5
3
|
declare class GetApiKeyByTokenUseCaseImpl implements GetApiKeyByTokenUseCaseAbstraction.Interface {
|
|
6
4
|
private repository;
|
|
7
5
|
constructor(repository: ApiKeysRepository.Interface);
|
|
8
|
-
execute(token: string): Promise<Result<ApiKey |
|
|
6
|
+
execute(token: string): Promise<import("@webiny/feature/api").Result<import("../shared/types.js").ApiKey, import("../shared/errors.js").ApiKeyNotFoundError | import("../shared/errors.js").ApiKeyPersistenceError | import("../shared/errors.js").ApiKeyValidationError>>;
|
|
9
7
|
}
|
|
10
8
|
export declare const GetApiKeyByTokenUseCase: typeof GetApiKeyByTokenUseCaseImpl & {
|
|
11
9
|
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetApiKeyByToken>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.ts"],"sourcesContent":["import { GetApiKeyByTokenUseCase as GetApiKeyByTokenUseCaseAbstraction } from \"./abstractions.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\n\nclass GetApiKeyByTokenUseCaseImpl implements GetApiKeyByTokenUseCaseAbstraction.Interface {\n constructor(private repository: ApiKeysRepository.Interface) {}\n\n async execute(token: string) {\n return this.repository.getByToken(token);\n }\n}\n\nexport const GetApiKeyByTokenUseCase = GetApiKeyByTokenUseCaseAbstraction.createImplementation({\n implementation: GetApiKeyByTokenUseCaseImpl,\n dependencies: [ApiKeysRepository]\n});\n"],"names":["GetApiKeyByTokenUseCaseImpl","repository","token","GetApiKeyByTokenUseCase","GetApiKeyByTokenUseCaseAbstraction","ApiKeysRepository"],"mappings":";;AAGA,MAAMA;IACF,YAAoBC,UAAuC,CAAE;aAAzCA,UAAU,GAAVA;IAA0C;IAE9D,MAAM,QAAQC,KAAa,EAAE;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAACA;IACtC;AACJ;AAEO,MAAMC,kDAA0BC,wBAAAA,oBAAuD,CAAC;IAC3F,gBAAgBJ;IAChB,cAAc;QAACK;KAAkB;AACrC"}
|
|
@@ -5,7 +5,7 @@ export interface IGetApiKeyByTokenErrors {
|
|
|
5
5
|
}
|
|
6
6
|
type GetApiKeyByTokenError = IGetApiKeyByTokenErrors[keyof IGetApiKeyByTokenErrors] | ApiKeysRepository.Error;
|
|
7
7
|
export interface IGetApiKeyByToken {
|
|
8
|
-
execute(token: string): Promise<Result<ApiKey
|
|
8
|
+
execute(token: string): Promise<Result<ApiKey, GetApiKeyByTokenError>>;
|
|
9
9
|
}
|
|
10
10
|
/** Retrieve an API key by its token value. */
|
|
11
11
|
export declare const GetApiKeyByTokenUseCase: import("@webiny/di").Abstraction<IGetApiKeyByToken>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/security/apiKeys/GetApiKeyByToken/abstractions.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyByToken/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey } from \"../shared/types.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\n\nexport interface IGetApiKeyByTokenErrors {\n // No use-case specific errors - only repository errors can occur\n}\n\ntype GetApiKeyByTokenError =\n | IGetApiKeyByTokenErrors[keyof IGetApiKeyByTokenErrors]\n | ApiKeysRepository.Error;\n\nexport interface IGetApiKeyByToken {\n execute(token: string): Promise<Result<ApiKey
|
|
1
|
+
{"version":3,"file":"features/security/apiKeys/GetApiKeyByToken/abstractions.js","sources":["../../../../../src/features/security/apiKeys/GetApiKeyByToken/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ApiKey } from \"../shared/types.js\";\nimport { ApiKeysRepository } from \"../shared/abstractions.js\";\n\nexport interface IGetApiKeyByTokenErrors {\n // No use-case specific errors - only repository errors can occur\n}\n\ntype GetApiKeyByTokenError =\n | IGetApiKeyByTokenErrors[keyof IGetApiKeyByTokenErrors]\n | ApiKeysRepository.Error;\n\nexport interface IGetApiKeyByToken {\n execute(token: string): Promise<Result<ApiKey, GetApiKeyByTokenError>>;\n}\n\n/** Retrieve an API key by its token value. */\nexport const GetApiKeyByTokenUseCase =\n createAbstraction<IGetApiKeyByToken>(\"GetApiKeyByTokenUseCase\");\n\nexport namespace GetApiKeyByTokenUseCase {\n export type Interface = IGetApiKeyByToken;\n export type Error = GetApiKeyByTokenError;\n}\n"],"names":["GetApiKeyByTokenUseCase","createAbstraction"],"mappings":";AAkBO,MAAMA,0BACTC,kBAAqC"}
|