quidproquo-actionprocessor-awslambda 0.0.261 → 0.0.263
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/lib/commonjs/getActionProcessor/core/ai/aiModelMap.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/aiModelMap.js +15 -0
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptActionProcessor.js +75 -0
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js +126 -0
- package/lib/commonjs/getActionProcessor/core/ai/index.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/ai/index.js +18 -0
- package/lib/commonjs/getActionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.js +39 -0
- package/lib/commonjs/getActionProcessor/core/apiKeyValidation/index.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/apiKeyValidation/index.js +17 -0
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/getEventAutoRespondActionProcessor.js +2 -34
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/api/getEventGetStorySessionActionProcessor.js +2 -31
- package/lib/commonjs/getActionProcessor/core/event/apiGatwayEvent/websocket/getEventTransformResponseResultActionProcessor.js +2 -2
- package/lib/commonjs/getActionProcessor/core/eventBus/getEventBusSendMessagesActionProcessor.js +2 -2
- package/lib/commonjs/getActionProcessor/core/file/getFileStreamOpenActionProcessor.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/file/getFileStreamOpenActionProcessor.js +100 -0
- package/lib/commonjs/getActionProcessor/core/file/index.js +2 -1
- package/lib/commonjs/getActionProcessor/core/index.d.ts +2 -0
- package/lib/commonjs/getActionProcessor/core/index.js +6 -1
- package/lib/commonjs/getActionProcessor/core/queue/getQueueSendMessageActionProcessor.js +2 -2
- package/lib/commonjs/getActionProcessor/core/userDirectory/getUserDirectoryCreateUserActionProcessor.js +6 -1
- package/lib/commonjs/getActionProcessor/webserver/serviceFunction/getServiceFunctionExecuteActionProcessor.js +2 -2
- package/lib/esm/getActionProcessor/core/ai/aiModelMap.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/aiModelMap.js +12 -0
- package/lib/esm/getActionProcessor/core/ai/getAiPromptActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/getAiPromptActionProcessor.js +60 -0
- package/lib/esm/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/getAiPromptStreamActionProcessor.js +75 -0
- package/lib/esm/getActionProcessor/core/ai/index.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/ai/index.js +6 -0
- package/lib/esm/getActionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/apiKeyValidation/getApiKeyValidationValidateActionProcessor.js +24 -0
- package/lib/esm/getActionProcessor/core/apiKeyValidation/index.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/apiKeyValidation/index.js +4 -0
- package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/api/getEventAutoRespondActionProcessor.js +3 -32
- package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/api/getEventGetStorySessionActionProcessor.js +3 -35
- package/lib/esm/getActionProcessor/core/event/apiGatwayEvent/websocket/getEventTransformResponseResultActionProcessor.js +2 -2
- package/lib/esm/getActionProcessor/core/eventBus/getEventBusSendMessagesActionProcessor.js +2 -5
- package/lib/esm/getActionProcessor/core/file/getFileStreamOpenActionProcessor.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/file/getFileStreamOpenActionProcessor.js +50 -0
- package/lib/esm/getActionProcessor/core/file/index.js +2 -0
- package/lib/esm/getActionProcessor/core/index.d.ts +2 -0
- package/lib/esm/getActionProcessor/core/index.js +8 -0
- package/lib/esm/getActionProcessor/core/queue/getQueueSendMessageActionProcessor.js +2 -5
- package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryCreateUserActionProcessor.js +7 -2
- package/lib/esm/getActionProcessor/webserver/serviceFunction/getServiceFunctionExecuteActionProcessor.js +2 -5
- package/package.json +7 -5
- package/lib/commonjs/getActionProcessor/core/event/utils/isAuthValid.d.ts +0 -3
- package/lib/commonjs/getActionProcessor/core/event/utils/isAuthValid.js +0 -68
- package/lib/esm/getActionProcessor/core/event/utils/isAuthValid.d.ts +0 -3
- package/lib/esm/getActionProcessor/core/event/utils/isAuthValid.js +0 -55
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bedrockModelMap = void 0;
|
|
4
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
5
|
+
exports.bedrockModelMap = {
|
|
6
|
+
[quidproquo_core_1.AiModel.ClaudeHaiku35]: 'us.anthropic.claude-3-5-haiku-20241022-v1:0',
|
|
7
|
+
[quidproquo_core_1.AiModel.ClaudeSonnet35]: 'us.anthropic.claude-3-5-sonnet-20241022-v2:0',
|
|
8
|
+
[quidproquo_core_1.AiModel.ClaudeSonnet4]: 'us.anthropic.claude-sonnet-4-20250514-v1:0',
|
|
9
|
+
[quidproquo_core_1.AiModel.ClaudeOpus4]: 'us.anthropic.claude-opus-4-20250514-v1:0',
|
|
10
|
+
[quidproquo_core_1.AiModel.ClaudeHaiku45]: 'us.anthropic.claude-haiku-4-5-20251001-v1:0',
|
|
11
|
+
[quidproquo_core_1.AiModel.ClaudeSonnet45]: 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',
|
|
12
|
+
[quidproquo_core_1.AiModel.ClaudeOpus45]: 'us.anthropic.claude-opus-4-5-20251101-v1:0',
|
|
13
|
+
[quidproquo_core_1.AiModel.ClaudeSonnet46]: 'us.anthropic.claude-sonnet-4-6',
|
|
14
|
+
[quidproquo_core_1.AiModel.ClaudeOpus46]: 'us.anthropic.claude-opus-4-6-v1',
|
|
15
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAiPromptActionProcessor = void 0;
|
|
13
|
+
const quidproquo_config_aws_1 = require("quidproquo-config-aws");
|
|
14
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
15
|
+
const ai_1 = require("ai");
|
|
16
|
+
const amazon_bedrock_1 = require("@ai-sdk/amazon-bedrock");
|
|
17
|
+
const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
|
|
18
|
+
const aiModelMap_1 = require("./aiModelMap");
|
|
19
|
+
const getProcessAiPrompt = (qpqConfig) => {
|
|
20
|
+
return (payload, session, actionProcessorList, logger, updateSession, dynamicModuleLoader, streamRegistry) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
22
|
+
const bedrock = (0, amazon_bedrock_1.createAmazonBedrock)({ region });
|
|
23
|
+
const bedrockModelId = aiModelMap_1.bedrockModelMap[payload.model];
|
|
24
|
+
if (!bedrockModelId) {
|
|
25
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotImplemented, `Unsupported AI model: ${payload.model}`);
|
|
26
|
+
}
|
|
27
|
+
// Build tools from defineAi config if aiName is provided
|
|
28
|
+
const aiTools = {};
|
|
29
|
+
if (payload.aiName) {
|
|
30
|
+
const aiConfigs = quidproquo_core_1.qpqCoreUtils.getAllAiConfigs(qpqConfig);
|
|
31
|
+
const aiConfig = aiConfigs.find((c) => c.aiName === payload.aiName);
|
|
32
|
+
if (!aiConfig) {
|
|
33
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `AI config not found: ${payload.aiName}`);
|
|
34
|
+
}
|
|
35
|
+
for (const toolDef of aiConfig.tools) {
|
|
36
|
+
aiTools[toolDef.name] = {
|
|
37
|
+
description: toolDef.description,
|
|
38
|
+
inputSchema: (0, ai_1.jsonSchema)(toolDef.inputSchema),
|
|
39
|
+
execute: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const resolveStory = (0, quidproquo_core_1.createImplementationRuntime)(qpqConfig, [`AI Tool: ${toolDef.name}`], () => new Date().toISOString(), awsLambdaUtils_1.randomGuid, session, actionProcessorList, logger, dynamicModuleLoader, streamRegistry);
|
|
41
|
+
const storyResult = yield resolveStory(function* () {
|
|
42
|
+
return yield* (0, quidproquo_core_1.askInlineFunctionExecute)(toolDef.executor, args);
|
|
43
|
+
}, []);
|
|
44
|
+
if (storyResult.error) {
|
|
45
|
+
throw new Error(storyResult.error.errorText);
|
|
46
|
+
}
|
|
47
|
+
return storyResult.result;
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const result = yield (0, ai_1.generateText)({
|
|
54
|
+
model: bedrock(bedrockModelId),
|
|
55
|
+
system: payload.system,
|
|
56
|
+
prompt: payload.prompt,
|
|
57
|
+
tools: Object.keys(aiTools).length > 0 ? aiTools : undefined,
|
|
58
|
+
stopWhen: (0, ai_1.stepCountIs)(10),
|
|
59
|
+
});
|
|
60
|
+
return (0, quidproquo_core_1.actionResult)({ text: result.text });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, error.message);
|
|
65
|
+
}
|
|
66
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, 'An error occurred during AI prompt execution.');
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const getAiPromptActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
return ({
|
|
72
|
+
[quidproquo_core_1.AiActionType.Prompt]: getProcessAiPrompt(qpqConfig),
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
exports.getAiPromptActionProcessor = getAiPromptActionProcessor;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
24
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
25
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
26
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
27
|
+
function fulfill(value) { resume("next", value); }
|
|
28
|
+
function reject(value) { resume("throw", value); }
|
|
29
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.getAiPromptStreamActionProcessor = void 0;
|
|
33
|
+
const quidproquo_config_aws_1 = require("quidproquo-config-aws");
|
|
34
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
35
|
+
const ai_1 = require("ai");
|
|
36
|
+
const amazon_bedrock_1 = require("@ai-sdk/amazon-bedrock");
|
|
37
|
+
const awsLambdaUtils_1 = require("../../../awsLambdaUtils");
|
|
38
|
+
const aiModelMap_1 = require("./aiModelMap");
|
|
39
|
+
const getProcessAiPromptStream = (qpqConfig) => {
|
|
40
|
+
return (payload, session, actionProcessorList, logger, updateSession, dynamicModuleLoader, streamRegistry) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
var _a;
|
|
42
|
+
const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
43
|
+
const bedrock = (0, amazon_bedrock_1.createAmazonBedrock)({ region });
|
|
44
|
+
const bedrockModelId = aiModelMap_1.bedrockModelMap[payload.model];
|
|
45
|
+
if (!bedrockModelId) {
|
|
46
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotImplemented, `Unsupported AI model: ${payload.model}`);
|
|
47
|
+
}
|
|
48
|
+
// Build tools from defineAi config if aiName is provided
|
|
49
|
+
const aiTools = {};
|
|
50
|
+
if (payload.aiName) {
|
|
51
|
+
const aiConfigs = quidproquo_core_1.qpqCoreUtils.getAllAiConfigs(qpqConfig);
|
|
52
|
+
const aiConfig = aiConfigs.find((c) => c.aiName === payload.aiName);
|
|
53
|
+
if (!aiConfig) {
|
|
54
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `AI config not found: ${payload.aiName}`);
|
|
55
|
+
}
|
|
56
|
+
for (const toolDef of aiConfig.tools) {
|
|
57
|
+
aiTools[toolDef.name] = {
|
|
58
|
+
description: toolDef.description,
|
|
59
|
+
inputSchema: (0, ai_1.jsonSchema)(toolDef.inputSchema),
|
|
60
|
+
execute: (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const resolveStory = (0, quidproquo_core_1.createImplementationRuntime)(qpqConfig, [`AI Tool: ${toolDef.name}`], () => new Date().toISOString(), awsLambdaUtils_1.randomGuid, session, actionProcessorList, logger, dynamicModuleLoader, streamRegistry);
|
|
62
|
+
const storyResult = yield resolveStory(function* () {
|
|
63
|
+
return yield* (0, quidproquo_core_1.askInlineFunctionExecute)(toolDef.executor, args);
|
|
64
|
+
}, []);
|
|
65
|
+
if (storyResult.error) {
|
|
66
|
+
throw new Error(storyResult.error.errorText);
|
|
67
|
+
}
|
|
68
|
+
return storyResult.result;
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const { fullStream } = (0, ai_1.streamText)({
|
|
75
|
+
model: bedrock(bedrockModelId),
|
|
76
|
+
system: payload.system,
|
|
77
|
+
prompt: (_a = payload.messages) !== null && _a !== void 0 ? _a : payload.prompt,
|
|
78
|
+
tools: Object.keys(aiTools).length > 0 ? aiTools : undefined,
|
|
79
|
+
stopWhen: (0, ai_1.stepCountIs)(10),
|
|
80
|
+
});
|
|
81
|
+
const streamId = `ai-prompt-${Date.now()}-${(0, awsLambdaUtils_1.randomGuid)()}`;
|
|
82
|
+
function aiStreamIterator() {
|
|
83
|
+
return __asyncGenerator(this, arguments, function* aiStreamIterator_1() {
|
|
84
|
+
var _a, e_1, _b, _c;
|
|
85
|
+
try {
|
|
86
|
+
for (var _d = true, fullStream_1 = __asyncValues(fullStream), fullStream_1_1; fullStream_1_1 = yield __await(fullStream_1.next()), _a = fullStream_1_1.done, !_a; _d = true) {
|
|
87
|
+
_c = fullStream_1_1.value;
|
|
88
|
+
_d = false;
|
|
89
|
+
const part = _c;
|
|
90
|
+
if (part.type === 'text-delta') {
|
|
91
|
+
yield yield __await(JSON.stringify({ type: 'text-delta', text: part.text }));
|
|
92
|
+
}
|
|
93
|
+
else if (part.type === 'tool-call') {
|
|
94
|
+
yield yield __await(JSON.stringify({ type: 'tool-call', toolName: part.toolName, input: part.input }));
|
|
95
|
+
}
|
|
96
|
+
else if (part.type === 'tool-result') {
|
|
97
|
+
yield yield __await(JSON.stringify({ type: 'tool-result', toolName: part.toolName, output: part.output }));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
102
|
+
finally {
|
|
103
|
+
try {
|
|
104
|
+
if (!_d && !_a && (_b = fullStream_1.return)) yield __await(_b.call(fullStream_1));
|
|
105
|
+
}
|
|
106
|
+
finally { if (e_1) throw e_1.error; }
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
streamRegistry.register(streamId, aiStreamIterator());
|
|
111
|
+
return (0, quidproquo_core_1.actionResult)({ id: streamId, encoding: 'json' });
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (error instanceof Error) {
|
|
115
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, error.message);
|
|
116
|
+
}
|
|
117
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, 'An error occurred during AI prompt stream.');
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
const getAiPromptStreamActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
return ({
|
|
123
|
+
[quidproquo_core_1.AiActionType.PromptStream]: getProcessAiPromptStream(qpqConfig),
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
exports.getAiPromptStreamActionProcessor = getAiPromptStreamActionProcessor;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getAiActionProcessor = void 0;
|
|
13
|
+
const getAiPromptActionProcessor_1 = require("./getAiPromptActionProcessor");
|
|
14
|
+
const getAiPromptStreamActionProcessor_1 = require("./getAiPromptStreamActionProcessor");
|
|
15
|
+
const getAiActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
return (Object.assign(Object.assign({}, (yield (0, getAiPromptActionProcessor_1.getAiPromptActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getAiPromptStreamActionProcessor_1.getAiPromptStreamActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
17
|
+
});
|
|
18
|
+
exports.getAiActionProcessor = getAiActionProcessor;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getApiKeyValidationValidateActionProcessor = void 0;
|
|
13
|
+
const quidproquo_config_aws_1 = require("quidproquo-config-aws");
|
|
14
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
15
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
16
|
+
const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
17
|
+
const getApiKeys_1 = require("../../../logic/apiGateway/getApiKeys");
|
|
18
|
+
const getProcessApiKeyValidationValidate = (qpqConfig) => {
|
|
19
|
+
const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
20
|
+
const application = quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig);
|
|
21
|
+
const service = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
22
|
+
const environment = quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig);
|
|
23
|
+
const feature = quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig);
|
|
24
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKeyValue, apiKeyReferences }) {
|
|
25
|
+
const realApiKeys = yield (0, getApiKeys_1.getApiKeys)(region, ...apiKeyReferences.map((apiKey) => {
|
|
26
|
+
const apiKeyApplication = apiKey.applicationName || application;
|
|
27
|
+
const apiKeyService = apiKey.serviceName || service;
|
|
28
|
+
return (0, awsNamingUtils_1.getConfigRuntimeResourceName)(apiKey.name, apiKeyApplication, apiKeyService, environment, feature);
|
|
29
|
+
}));
|
|
30
|
+
const index = realApiKeys.findIndex((apiKey) => apiKey.value === apiKeyValue);
|
|
31
|
+
return (0, quidproquo_core_1.actionResult)(index >= 0);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const getApiKeyValidationValidateActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
return ({
|
|
36
|
+
[quidproquo_webserver_1.ApiKeyValidationActionType.Validate]: getProcessApiKeyValidationValidate(qpqConfig),
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
exports.getApiKeyValidationValidateActionProcessor = getApiKeyValidationValidateActionProcessor;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getApiKeyValidationActionProcessor = void 0;
|
|
13
|
+
const getApiKeyValidationValidateActionProcessor_1 = require("./getApiKeyValidationValidateActionProcessor");
|
|
14
|
+
const getApiKeyValidationActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, getApiKeyValidationValidateActionProcessor_1.getApiKeyValidationValidateActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
16
|
+
});
|
|
17
|
+
exports.getApiKeyValidationActionProcessor = getApiKeyValidationActionProcessor;
|
|
@@ -10,40 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getEventAutoRespondActionProcessor = void 0;
|
|
13
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
13
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ qpqEventRecord, matchResult }) {
|
|
18
|
-
var _b;
|
|
19
|
-
// Just auto respond for options requests
|
|
20
|
-
if (qpqEventRecord.method === 'OPTIONS') {
|
|
21
|
-
return (0, quidproquo_core_1.actionResult)({
|
|
22
|
-
status: 200,
|
|
23
|
-
isBase64Encoded: false,
|
|
24
|
-
body: '',
|
|
25
|
-
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, matchResult.config || {}, qpqEventRecord.headers),
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
// TODO: We can pull out the jwt from the session if thats a better way?
|
|
29
|
-
// Think about that when you dont have covid.
|
|
30
|
-
const authValid = yield (0, isAuthValid_1.isAuthValid)(qpqConfig, quidproquo_webserver_1.qpqWebServerUtils.getHeaderValue('Authorization', qpqEventRecord.headers), quidproquo_webserver_1.qpqWebServerUtils.getHeaderValue('x-api-key', qpqEventRecord.headers), (_b = matchResult.config) === null || _b === void 0 ? void 0 : _b.routeAuthSettings);
|
|
31
|
-
if (!authValid) {
|
|
32
|
-
return (0, quidproquo_core_1.actionResult)({
|
|
33
|
-
status: 401,
|
|
34
|
-
isBase64Encoded: false,
|
|
35
|
-
body: JSON.stringify({
|
|
36
|
-
message: 'You are unauthorized to access this resource',
|
|
37
|
-
}),
|
|
38
|
-
headers: quidproquo_webserver_1.qpqWebServerUtils.getCorsHeaders(qpqConfig, matchResult.config || {}, qpqEventRecord.headers),
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return (0, quidproquo_core_1.actionResult)(null);
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
const getEventAutoRespondActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
return ({
|
|
46
|
-
[quidproquo_core_1.EventActionType.AutoRespond]: getProcessAutoRespond(qpqConfig),
|
|
47
|
-
});
|
|
14
|
+
const getEventAutoRespondActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, quidproquo_webserver_1.getHttpApiEventAutoRespondActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
48
16
|
});
|
|
49
17
|
exports.getEventAutoRespondActionProcessor = getEventAutoRespondActionProcessor;
|
|
@@ -10,37 +10,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getEventGetStorySessionActionProcessor = void 0;
|
|
13
|
-
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
13
|
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ matchStoryResult, qpqEventRecord }, session) {
|
|
18
|
-
var _b, _c;
|
|
19
|
-
const accessToken = quidproquo_webserver_1.qpqWebServerUtils.getAccessTokenFromHeaders(qpqEventRecord.headers);
|
|
20
|
-
if (!accessToken) {
|
|
21
|
-
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
22
|
-
}
|
|
23
|
-
// if this endpoint has no auth settings, BUT we do have an access token
|
|
24
|
-
// then we want to just attempt to extract info for logs, but we will say that its
|
|
25
|
-
// wasValid = false
|
|
26
|
-
if (!((_c = (_b = matchStoryResult.config) === null || _b === void 0 ? void 0 : _b.routeAuthSettings) === null || _c === void 0 ? void 0 : _c.userDirectoryName)) {
|
|
27
|
-
// If this endpoint is unauthenticated, then we will just decode it, and say it wasnt valid, for logs
|
|
28
|
-
const info = quidproquo_webserver_1.qpqWebServerUtils.decodeJWT(accessToken);
|
|
29
|
-
return (0, quidproquo_core_1.actionResult)(Object.assign(Object.assign({}, session), { decodedAccessToken: {
|
|
30
|
-
exp: (info === null || info === void 0 ? void 0 : info.exp) || 0,
|
|
31
|
-
userDirectory: '',
|
|
32
|
-
userId: (info === null || info === void 0 ? void 0 : info.sub) || (info === null || info === void 0 ? void 0 : info.id) || (info === null || info === void 0 ? void 0 : info.userId) || (info === null || info === void 0 ? void 0 : info.username) || '',
|
|
33
|
-
username: (info === null || info === void 0 ? void 0 : info.username) || (info === null || info === void 0 ? void 0 : info.userId) || (info === null || info === void 0 ? void 0 : info.sub) || (info === null || info === void 0 ? void 0 : info.id) || '',
|
|
34
|
-
wasValid: false,
|
|
35
|
-
} }));
|
|
36
|
-
}
|
|
37
|
-
const decodedAccessToken = yield (0, cognito_1.decodeAccessToken)(matchStoryResult.config.routeAuthSettings.userDirectoryName, qpqConfig, accessToken, true);
|
|
38
|
-
return (0, quidproquo_core_1.actionResult)(Object.assign(Object.assign({}, session), { decodedAccessToken }));
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
const getEventGetStorySessionActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
return ({
|
|
43
|
-
[quidproquo_core_1.EventActionType.GetStorySession]: getProcessGetStorySession(qpqConfig),
|
|
44
|
-
});
|
|
14
|
+
const getEventGetStorySessionActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
return (Object.assign({}, (yield (0, quidproquo_webserver_1.getHttpApiEventGetStorySessionActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
45
16
|
});
|
|
46
17
|
exports.getEventGetStorySessionActionProcessor = getEventGetStorySessionActionProcessor;
|
|
@@ -24,10 +24,10 @@ function* askTransformResponseStory({ eventParams, qpqEventRecordResponses: [rec
|
|
|
24
24
|
const getProcessTransformResponseResult = (qpqConfig) => {
|
|
25
25
|
// Create a custom runtime for errored responses so we can log them out
|
|
26
26
|
const errorCustomImplementation = (0, quidproquo_core_1.getProcessCustomImplementation)(qpqConfig, askTransformResponseStory, 'Transform Errored Websocket Response', null, () => new Date().toISOString(), awsLambdaUtils_1.randomGuid);
|
|
27
|
-
return (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
return (payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
if (payload.qpqEventRecordResponses.some((r) => !r.success)) {
|
|
29
29
|
// We only wan't to run this for errors, because a custom imp is slower then a regular imp
|
|
30
|
-
return yield errorCustomImplementation(payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader);
|
|
30
|
+
return yield errorCustomImplementation(payload, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry);
|
|
31
31
|
}
|
|
32
32
|
return (0, quidproquo_core_1.actionResult)({
|
|
33
33
|
statusCode: 200,
|
package/lib/commonjs/getActionProcessor/core/eventBus/getEventBusSendMessagesActionProcessor.js
CHANGED
|
@@ -15,7 +15,7 @@ const quidproquo_core_1 = require("quidproquo-core");
|
|
|
15
15
|
const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
16
16
|
const publishMessage_1 = require("../../../logic/sns/publishMessage");
|
|
17
17
|
const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
18
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ eventBusName, eventBusMessages,
|
|
18
|
+
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ eventBusName, eventBusMessages, }, session) {
|
|
19
19
|
var _b, _c, _d, _e, _f;
|
|
20
20
|
const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
21
21
|
const eventBusConfig = quidproquo_core_1.qpqCoreUtils.getEventBusConfigByName(eventBusName, qpqConfig);
|
|
@@ -24,7 +24,7 @@ const getProcessEventBusSendMessage = (qpqConfig) => {
|
|
|
24
24
|
}
|
|
25
25
|
const topicArn = (0, awsNamingUtils_1.getEventBusSnsTopicArn)(((_b = eventBusConfig.owner) === null || _b === void 0 ? void 0 : _b.resourceNameOverride) || eventBusName, qpqConfig, ((_c = eventBusConfig.owner) === null || _c === void 0 ? void 0 : _c.module) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig), ((_d = eventBusConfig.owner) === null || _d === void 0 ? void 0 : _d.environment) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig), ((_e = eventBusConfig.owner) === null || _e === void 0 ? void 0 : _e.application) || quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig), ((_f = eventBusConfig.owner) === null || _f === void 0 ? void 0 : _f.feature) || quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig));
|
|
26
26
|
yield (0, publishMessage_1.publishMessage)(topicArn, region, eventBusMessages.map((message) => {
|
|
27
|
-
const eventBusMessageWithSession = Object.assign(Object.assign({}, message), { storySession:
|
|
27
|
+
const eventBusMessageWithSession = Object.assign(Object.assign({}, message), { storySession: session });
|
|
28
28
|
return JSON.stringify(eventBusMessageWithSession);
|
|
29
29
|
}));
|
|
30
30
|
return (0, quidproquo_core_1.actionResult)(void 0);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
24
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
25
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
26
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
27
|
+
function fulfill(value) { resume("next", value); }
|
|
28
|
+
function reject(value) { resume("throw", value); }
|
|
29
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.getFileStreamOpenActionProcessor = void 0;
|
|
33
|
+
const quidproquo_config_aws_1 = require("quidproquo-config-aws");
|
|
34
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
35
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
36
|
+
const createAwsClient_1 = require("../../../logic/createAwsClient");
|
|
37
|
+
const utils_1 = require("./utils");
|
|
38
|
+
function chunkedReadableIterator(stream, chunkSize, transform) {
|
|
39
|
+
return __asyncGenerator(this, arguments, function* chunkedReadableIterator_1() {
|
|
40
|
+
var _a, e_1, _b, _c;
|
|
41
|
+
let buffer = Buffer.alloc(0);
|
|
42
|
+
try {
|
|
43
|
+
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
|
|
44
|
+
_c = stream_1_1.value;
|
|
45
|
+
_d = false;
|
|
46
|
+
const chunk = _c;
|
|
47
|
+
const incoming = typeof chunk === 'string' ? Buffer.from(chunk, 'utf8') : chunk;
|
|
48
|
+
buffer = Buffer.concat([buffer, incoming]);
|
|
49
|
+
while (buffer.length >= chunkSize) {
|
|
50
|
+
yield yield __await(transform(buffer.subarray(0, chunkSize)));
|
|
51
|
+
buffer = buffer.subarray(chunkSize);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
|
|
59
|
+
}
|
|
60
|
+
finally { if (e_1) throw e_1.error; }
|
|
61
|
+
}
|
|
62
|
+
if (buffer.length > 0) {
|
|
63
|
+
yield yield __await(transform(buffer));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const getProcessFileStreamOpen = (qpqConfig) => {
|
|
68
|
+
return (_a, session_1, actionProcessors_1, logger_1, updateSession_1, dynamicModuleLoader_1, streamRegistry_1) => __awaiter(void 0, [_a, session_1, actionProcessors_1, logger_1, updateSession_1, dynamicModuleLoader_1, streamRegistry_1], void 0, function* ({ drive, filepath, encoding, chunkSize }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) {
|
|
69
|
+
try {
|
|
70
|
+
const s3BucketName = (0, utils_1.resolveStorageDriveBucketName)(drive, qpqConfig);
|
|
71
|
+
const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
72
|
+
const s3Client = (0, createAwsClient_1.createAwsClient)(client_s3_1.S3Client, { region });
|
|
73
|
+
const response = yield s3Client.send(new client_s3_1.GetObjectCommand({
|
|
74
|
+
Key: filepath,
|
|
75
|
+
Bucket: s3BucketName,
|
|
76
|
+
}));
|
|
77
|
+
if (!response.Body) {
|
|
78
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Empty response body for: ${filepath}`);
|
|
79
|
+
}
|
|
80
|
+
const streamId = `s3-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
81
|
+
const isText = encoding === 'text';
|
|
82
|
+
const size = chunkSize !== null && chunkSize !== void 0 ? chunkSize : 65536;
|
|
83
|
+
const transform = isText
|
|
84
|
+
? (buf) => buf.toString('utf8')
|
|
85
|
+
: (buf) => buf.toString('base64');
|
|
86
|
+
const iterator = chunkedReadableIterator(response.Body, size, transform);
|
|
87
|
+
streamRegistry.register(streamId, iterator);
|
|
88
|
+
return (0, quidproquo_core_1.actionResult)({ id: streamId, encoding });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return (0, quidproquo_core_1.actionResultErrorFromCaughtError)(error, {});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
const getFileStreamOpenActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
return ({
|
|
97
|
+
[quidproquo_core_1.FileActionType.StreamOpen]: getProcessFileStreamOpen(qpqConfig),
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
exports.getFileStreamOpenActionProcessor = getFileStreamOpenActionProcessor;
|
|
@@ -19,10 +19,11 @@ const getFileListDirectoryActionProcessor_1 = require("./getFileListDirectoryAct
|
|
|
19
19
|
const getFileReadBinaryContentsActionProcessor_1 = require("./getFileReadBinaryContentsActionProcessor");
|
|
20
20
|
const getFileReadObjectJsonActionProcessor_1 = require("./getFileReadObjectJsonActionProcessor");
|
|
21
21
|
const getFileReadTextContentsActionProcessor_1 = require("./getFileReadTextContentsActionProcessor");
|
|
22
|
+
const getFileStreamOpenActionProcessor_1 = require("./getFileStreamOpenActionProcessor");
|
|
22
23
|
const getFileWriteBinaryContentsActionProcessor_1 = require("./getFileWriteBinaryContentsActionProcessor");
|
|
23
24
|
const getFileWriteObjectJsonActionProcessor_1 = require("./getFileWriteObjectJsonActionProcessor");
|
|
24
25
|
const getFileWriteTextContentsActionProcessor_1 = require("./getFileWriteTextContentsActionProcessor");
|
|
25
26
|
const getFileActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, getFileDeleteActionProcessor_1.getFileDeleteActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileExistsActionProcessor_1.getFileExistsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileGenerateTemporarySecureUrlActionProcessor_1.getFileGenerateTemporarySecureUrlActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileGenerateTemporaryUploadSecureUrlActionProcessor_1.getFileGenerateTemporaryUploadSecureUrlActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileIsColdStorageActionProcessor_1.getFileIsColdStorageActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileListDirectoryActionProcessor_1.getFileListDirectoryActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileReadTextContentsActionProcessor_1.getFileReadTextContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileReadObjectJsonActionProcessor_1.getFileReadObjectJsonActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileWriteTextContentsActionProcessor_1.getFileWriteTextContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileReadBinaryContentsActionProcessor_1.getFileReadBinaryContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileWriteObjectJsonActionProcessor_1.getFileWriteObjectJsonActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileWriteBinaryContentsActionProcessor_1.getFileWriteBinaryContentsActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
27
|
+
return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, getFileDeleteActionProcessor_1.getFileDeleteActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileExistsActionProcessor_1.getFileExistsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileGenerateTemporarySecureUrlActionProcessor_1.getFileGenerateTemporarySecureUrlActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileGenerateTemporaryUploadSecureUrlActionProcessor_1.getFileGenerateTemporaryUploadSecureUrlActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileIsColdStorageActionProcessor_1.getFileIsColdStorageActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileListDirectoryActionProcessor_1.getFileListDirectoryActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileReadTextContentsActionProcessor_1.getFileReadTextContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileReadObjectJsonActionProcessor_1.getFileReadObjectJsonActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileWriteTextContentsActionProcessor_1.getFileWriteTextContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileReadBinaryContentsActionProcessor_1.getFileReadBinaryContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileWriteObjectJsonActionProcessor_1.getFileWriteObjectJsonActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileWriteBinaryContentsActionProcessor_1.getFileWriteBinaryContentsActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getFileStreamOpenActionProcessor_1.getFileStreamOpenActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
27
28
|
});
|
|
28
29
|
exports.getFileActionProcessor = getFileActionProcessor;
|
|
@@ -24,6 +24,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getCoreActionProcessor = void 0;
|
|
27
|
+
__exportStar(require("./ai"), exports);
|
|
28
|
+
__exportStar(require("./apiKeyValidation"), exports);
|
|
27
29
|
__exportStar(require("./config"), exports);
|
|
28
30
|
__exportStar(require("./event"), exports);
|
|
29
31
|
__exportStar(require("./eventBus"), exports);
|
|
@@ -33,6 +35,9 @@ __exportStar(require("./keyValueStore"), exports);
|
|
|
33
35
|
__exportStar(require("./queue"), exports);
|
|
34
36
|
__exportStar(require("./system"), exports);
|
|
35
37
|
__exportStar(require("./userDirectory"), exports);
|
|
38
|
+
const quidproquo_webserver_1 = require("quidproquo-webserver");
|
|
39
|
+
const ai_1 = require("./ai");
|
|
40
|
+
const apiKeyValidation_1 = require("./apiKeyValidation");
|
|
36
41
|
const config_1 = require("./config");
|
|
37
42
|
const event_1 = require("./event");
|
|
38
43
|
const eventBus_1 = require("./eventBus");
|
|
@@ -43,6 +48,6 @@ const queue_1 = require("./queue");
|
|
|
43
48
|
const system_1 = require("./system");
|
|
44
49
|
const userDirectory_1 = require("./userDirectory");
|
|
45
50
|
const getCoreActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
-
return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, file_1.getFileActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, keyValueStore_1.getKeyValueStoreActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, queue_1.getQueueActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, userDirectory_1.getUserDirectoryActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, eventBus_1.getEventBusActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, system_1.getSystemActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, config_1.getConfigActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, event_1.getApiGatewayApiEventEventProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, graphDatabase_1.getGraphDatabaseActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
51
|
+
return (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (yield (0, ai_1.getAiActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, apiKeyValidation_1.getApiKeyValidationActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, file_1.getFileActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, keyValueStore_1.getKeyValueStoreActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, queue_1.getQueueActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, userDirectory_1.getUserDirectoryActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, eventBus_1.getEventBusActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, system_1.getSystemActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, config_1.getConfigActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, event_1.getApiGatewayApiEventEventProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, graphDatabase_1.getGraphDatabaseActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, quidproquo_webserver_1.getRouteAuthValidationActionProcessor)(qpqConfig, dynamicModuleLoader))));
|
|
47
52
|
});
|
|
48
53
|
exports.getCoreActionProcessor = getCoreActionProcessor;
|
|
@@ -15,12 +15,12 @@ const quidproquo_core_1 = require("quidproquo-core");
|
|
|
15
15
|
const sendMessages_1 = require("../../../logic/sqs/sendMessages");
|
|
16
16
|
const qpqAwsLambdaRuntimeConfigUtils_1 = require("../../../runtimeConfig/qpqAwsLambdaRuntimeConfigUtils");
|
|
17
17
|
const getProcessQueueSendMessage = (qpqConfig) => {
|
|
18
|
-
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ queueName, queueMessages
|
|
18
|
+
return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ queueName, queueMessages }, session) {
|
|
19
19
|
// While we have some uuids
|
|
20
20
|
const sqsQueueName = (0, qpqAwsLambdaRuntimeConfigUtils_1.resolveResourceName)(queueName, qpqConfig);
|
|
21
21
|
yield (0, sendMessages_1.sendMessages)(sqsQueueName, quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig), queueMessages.map((message) => {
|
|
22
22
|
// Add the session info to the message
|
|
23
|
-
const queueMessageWithSession = Object.assign(Object.assign({}, message), { storySession:
|
|
23
|
+
const queueMessageWithSession = Object.assign(Object.assign({}, message), { storySession: session });
|
|
24
24
|
return JSON.stringify(queueMessageWithSession);
|
|
25
25
|
}));
|
|
26
26
|
return (0, quidproquo_core_1.actionResult)(void 0);
|