quidproquo-actionprocessor-node 0.0.263 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/lib/commonjs/actionProcessor/core/index.d.ts +0 -12
  2. package/lib/commonjs/actionProcessor/core/index.js +6 -25
  3. package/lib/commonjs/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +1 -0
  4. package/lib/commonjs/actionProcessor/webserver/index.js +4 -2
  5. package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +7 -4
  6. package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js +10 -4
  7. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +1 -2
  8. package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +1 -2
  9. package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +6 -9
  10. package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +4 -6
  11. package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +5 -9
  12. package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +4 -6
  13. package/lib/commonjs/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +6 -7
  14. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +10 -3
  15. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +4 -3
  16. package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +4 -3
  17. package/lib/commonjs/dynamicActionProcessor/file/utils.d.ts +2 -1
  18. package/lib/commonjs/dynamicActionProcessor/file/utils.js +11 -1
  19. package/lib/esm/actionProcessor/core/index.d.ts +0 -12
  20. package/lib/esm/actionProcessor/core/index.js +6 -35
  21. package/lib/esm/actionProcessor/core/inlineFunction/getInlineFunctionExecuteActionProcessor.js +1 -0
  22. package/lib/esm/actionProcessor/webserver/index.js +4 -2
  23. package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +8 -5
  24. package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js +11 -5
  25. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +2 -3
  26. package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +2 -3
  27. package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +7 -10
  28. package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +5 -7
  29. package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +6 -10
  30. package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +5 -7
  31. package/lib/esm/dynamicActionProcessor/file/getFileStreamOpenActionProcessor.js +7 -8
  32. package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +11 -4
  33. package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +5 -4
  34. package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +5 -4
  35. package/lib/esm/dynamicActionProcessor/file/utils.d.ts +2 -1
  36. package/lib/esm/dynamicActionProcessor/file/utils.js +9 -1
  37. package/package.json +5 -9
  38. package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +0 -2
  39. package/lib/commonjs/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -74
  40. package/lib/commonjs/actionProcessor/core/claudeAi/index.d.ts +0 -2
  41. package/lib/commonjs/actionProcessor/core/claudeAi/index.js +0 -17
  42. package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +0 -2
  43. package/lib/commonjs/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +0 -30
  44. package/lib/commonjs/actionProcessor/core/config/index.d.ts +0 -2
  45. package/lib/commonjs/actionProcessor/core/config/index.js +0 -17
  46. package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.d.ts +0 -2
  47. package/lib/commonjs/actionProcessor/core/context/getContextListActionProcessor.js +0 -24
  48. package/lib/commonjs/actionProcessor/core/context/getContextReadActionProcessor.d.ts +0 -2
  49. package/lib/commonjs/actionProcessor/core/context/getContextReadActionProcessor.js +0 -27
  50. package/lib/commonjs/actionProcessor/core/context/index.d.ts +0 -2
  51. package/lib/commonjs/actionProcessor/core/context/index.js +0 -18
  52. package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +0 -2
  53. package/lib/commonjs/actionProcessor/core/customActions/getCustomActionActionProcessor.js +0 -58
  54. package/lib/commonjs/actionProcessor/core/customActions/index.d.ts +0 -1
  55. package/lib/commonjs/actionProcessor/core/customActions/index.js +0 -18
  56. package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.d.ts +0 -2
  57. package/lib/commonjs/actionProcessor/core/date/getDateNowActionProcessor.js +0 -24
  58. package/lib/commonjs/actionProcessor/core/date/index.d.ts +0 -2
  59. package/lib/commonjs/actionProcessor/core/date/index.js +0 -17
  60. package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +0 -2
  61. package/lib/commonjs/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +0 -24
  62. package/lib/commonjs/actionProcessor/core/error/index.d.ts +0 -2
  63. package/lib/commonjs/actionProcessor/core/error/index.js +0 -17
  64. package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +0 -2
  65. package/lib/commonjs/actionProcessor/core/guid/getGuidNewActionProcessor.js +0 -25
  66. package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +0 -2
  67. package/lib/commonjs/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +0 -25
  68. package/lib/commonjs/actionProcessor/core/guid/index.d.ts +0 -2
  69. package/lib/commonjs/actionProcessor/core/guid/index.js +0 -18
  70. package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +0 -2
  71. package/lib/commonjs/actionProcessor/core/log/getLogCreateActionProcessor.js +0 -30
  72. package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +0 -2
  73. package/lib/commonjs/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +0 -25
  74. package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +0 -2
  75. package/lib/commonjs/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +0 -26
  76. package/lib/commonjs/actionProcessor/core/log/index.d.ts +0 -2
  77. package/lib/commonjs/actionProcessor/core/log/index.js +0 -19
  78. package/lib/commonjs/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +0 -2
  79. package/lib/commonjs/actionProcessor/core/math/getMathRandomNumberActionProcessor.js +0 -24
  80. package/lib/commonjs/actionProcessor/core/math/index.d.ts +0 -2
  81. package/lib/commonjs/actionProcessor/core/math/index.js +0 -17
  82. package/lib/commonjs/actionProcessor/core/network/getNetworkRequestActionProcessor.d.ts +0 -2
  83. package/lib/commonjs/actionProcessor/core/network/getNetworkRequestActionProcessor.js +0 -153
  84. package/lib/commonjs/actionProcessor/core/network/index.d.ts +0 -2
  85. package/lib/commonjs/actionProcessor/core/network/index.js +0 -17
  86. package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +0 -2
  87. package/lib/commonjs/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +0 -24
  88. package/lib/commonjs/actionProcessor/core/platform/index.d.ts +0 -2
  89. package/lib/commonjs/actionProcessor/core/platform/index.js +0 -17
  90. package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +0 -2
  91. package/lib/commonjs/actionProcessor/core/system/getSystemBatchActionProcessor.js +0 -51
  92. package/lib/commonjs/actionProcessor/core/system/index.d.ts +0 -2
  93. package/lib/commonjs/actionProcessor/core/system/index.js +0 -17
  94. package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +0 -2
  95. package/lib/commonjs/actionProcessor/webserver/dns/getDnsListActionProcessor.js +0 -26
  96. package/lib/commonjs/actionProcessor/webserver/dns/index.d.ts +0 -2
  97. package/lib/commonjs/actionProcessor/webserver/dns/index.js +0 -17
  98. package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.d.ts +0 -2
  99. package/lib/esm/actionProcessor/core/claudeAi/getClaudeAiMessagesApiActionProcessor.js +0 -26
  100. package/lib/esm/actionProcessor/core/claudeAi/index.d.ts +0 -2
  101. package/lib/esm/actionProcessor/core/claudeAi/index.js +0 -4
  102. package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.d.ts +0 -2
  103. package/lib/esm/actionProcessor/core/config/getConfigGetApplicationInfoActionProcessor.js +0 -15
  104. package/lib/esm/actionProcessor/core/config/index.d.ts +0 -2
  105. package/lib/esm/actionProcessor/core/config/index.js +0 -4
  106. package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.d.ts +0 -2
  107. package/lib/esm/actionProcessor/core/context/getContextListActionProcessor.js +0 -9
  108. package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.d.ts +0 -2
  109. package/lib/esm/actionProcessor/core/context/getContextReadActionProcessor.js +0 -12
  110. package/lib/esm/actionProcessor/core/context/index.d.ts +0 -2
  111. package/lib/esm/actionProcessor/core/context/index.js +0 -6
  112. package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.d.ts +0 -2
  113. package/lib/esm/actionProcessor/core/customActions/getCustomActionActionProcessor.js +0 -43
  114. package/lib/esm/actionProcessor/core/customActions/index.d.ts +0 -1
  115. package/lib/esm/actionProcessor/core/customActions/index.js +0 -2
  116. package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.d.ts +0 -2
  117. package/lib/esm/actionProcessor/core/date/getDateNowActionProcessor.js +0 -9
  118. package/lib/esm/actionProcessor/core/date/index.d.ts +0 -2
  119. package/lib/esm/actionProcessor/core/date/index.js +0 -4
  120. package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.d.ts +0 -2
  121. package/lib/esm/actionProcessor/core/error/getErrorThrowErrorActionProcessor.js +0 -9
  122. package/lib/esm/actionProcessor/core/error/index.d.ts +0 -2
  123. package/lib/esm/actionProcessor/core/error/index.js +0 -4
  124. package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.d.ts +0 -2
  125. package/lib/esm/actionProcessor/core/guid/getGuidNewActionProcessor.js +0 -10
  126. package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.d.ts +0 -2
  127. package/lib/esm/actionProcessor/core/guid/getGuidNewSortableActionProcessor.js +0 -10
  128. package/lib/esm/actionProcessor/core/guid/index.d.ts +0 -2
  129. package/lib/esm/actionProcessor/core/guid/index.js +0 -6
  130. package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.d.ts +0 -2
  131. package/lib/esm/actionProcessor/core/log/getLogCreateActionProcessor.js +0 -15
  132. package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.d.ts +0 -2
  133. package/lib/esm/actionProcessor/core/log/getLogDisableEventHistoryActionProcessor.js +0 -10
  134. package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.d.ts +0 -2
  135. package/lib/esm/actionProcessor/core/log/getLogTemplateLiteralActionProcessor.js +0 -11
  136. package/lib/esm/actionProcessor/core/log/index.d.ts +0 -2
  137. package/lib/esm/actionProcessor/core/log/index.js +0 -8
  138. package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.d.ts +0 -2
  139. package/lib/esm/actionProcessor/core/math/getMathRandomNumberActionProcessor.js +0 -9
  140. package/lib/esm/actionProcessor/core/math/index.d.ts +0 -2
  141. package/lib/esm/actionProcessor/core/math/index.js +0 -4
  142. package/lib/esm/actionProcessor/core/network/getNetworkRequestActionProcessor.d.ts +0 -2
  143. package/lib/esm/actionProcessor/core/network/getNetworkRequestActionProcessor.js +0 -137
  144. package/lib/esm/actionProcessor/core/network/index.d.ts +0 -2
  145. package/lib/esm/actionProcessor/core/network/index.js +0 -4
  146. package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.d.ts +0 -2
  147. package/lib/esm/actionProcessor/core/platform/getPlatformDelayActionProcessor.js +0 -9
  148. package/lib/esm/actionProcessor/core/platform/index.d.ts +0 -2
  149. package/lib/esm/actionProcessor/core/platform/index.js +0 -4
  150. package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.d.ts +0 -2
  151. package/lib/esm/actionProcessor/core/system/getSystemBatchActionProcessor.js +0 -36
  152. package/lib/esm/actionProcessor/core/system/index.d.ts +0 -2
  153. package/lib/esm/actionProcessor/core/system/index.js +0 -4
  154. package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.d.ts +0 -2
  155. package/lib/esm/actionProcessor/webserver/dns/getDnsListActionProcessor.js +0 -11
  156. package/lib/esm/actionProcessor/webserver/dns/index.d.ts +0 -2
  157. package/lib/esm/actionProcessor/webserver/dns/index.js +0 -4
@@ -1,14 +1,13 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, } from 'quidproquo-core';
2
2
  import { createSecureUrlToken, getSecureUrlBaseUrl } from './secureUrlUtils';
3
3
  import { resolveFilePath } from './utils';
4
4
  const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig, config) => {
5
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
5
  return async ({ drive, filepath, expirationMs, contentType }) => {
7
6
  try {
8
7
  const expiresAt = Date.now() + expirationMs;
9
8
  // Create a token for upload
10
9
  const token = createSecureUrlToken({
11
- fullFilepath: resolveFilePath(config, serviceName, drive, filepath),
10
+ fullFilepath: resolveFilePath(config, qpqConfig, drive, filepath),
12
11
  operation: 'upload',
13
12
  expiresAt,
14
13
  contentType,
@@ -1,12 +1,11 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileListDirectoryErrorTypeEnum, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import * as path from 'path';
4
4
  import { resolveFilePath } from './utils';
5
5
  const getProcessFileListDirectory = (config) => (qpqConfig) => {
6
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
7
6
  return async ({ drive, folderPath, maxFiles, pageToken }) => {
8
7
  try {
9
- const fullPath = resolveFilePath(config, serviceName, drive, folderPath || '');
8
+ const fullPath = resolveFilePath(config, qpqConfig, drive, folderPath || '');
10
9
  // Read all entries in the directory
11
10
  const entries = await fs.readdir(fullPath, { withFileTypes: true });
12
11
  // Build file info list
@@ -35,13 +34,11 @@ const getProcessFileListDirectory = (config) => (qpqConfig) => {
35
34
  return actionResult(result);
36
35
  }
37
36
  catch (error) {
38
- if (error.code === 'ENOENT') {
39
- return actionResultError(ErrorTypeEnum.NotFound, `Directory not found: ${folderPath}`);
40
- }
41
- if (error.code === 'ENOTDIR') {
42
- return actionResultError(ErrorTypeEnum.GenericError, `Path is not a directory: ${folderPath}`);
43
- }
44
- return actionResultError(ErrorTypeEnum.GenericError, `Error listing directory: ${error.message}`);
37
+ return actionResultErrorFromCaughtError(error, {
38
+ ENOENT: () => actionResultError(FileListDirectoryErrorTypeEnum.DirectoryNotFound, `Directory not found: ${folderPath}`), // node fs code
39
+ ENOTDIR: () => actionResultError(FileListDirectoryErrorTypeEnum.NotADirectory, `Path is not a directory: ${folderPath}`), // node fs code
40
+ EACCES: () => actionResultError(FileListDirectoryErrorTypeEnum.AccessDenied, `Access denied listing directory: ${folderPath}`), // node fs code
41
+ });
45
42
  }
46
43
  };
47
44
  };
@@ -1,12 +1,11 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileReadBinaryContentsErrorTypeEnum, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import * as path from 'path';
4
4
  import { resolveFilePath } from './utils';
5
5
  const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
6
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
7
6
  return async ({ drive, filepath }) => {
8
7
  try {
9
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
8
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
10
9
  const buffer = await fs.readFile(fullPath);
11
10
  // Convert Buffer to QPQBinaryData
12
11
  const binaryData = {
@@ -17,10 +16,9 @@ const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
17
16
  return actionResult(binaryData);
18
17
  }
19
18
  catch (error) {
20
- if (error.code === 'ENOENT') {
21
- return actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
22
- }
23
- return actionResultError(ErrorTypeEnum.GenericError, `Error reading binary file: ${error.message}`);
19
+ return actionResultErrorFromCaughtError(error, {
20
+ ENOENT: () => actionResultError(FileReadBinaryContentsErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
21
+ });
24
22
  }
25
23
  };
26
24
  };
@@ -1,23 +1,19 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, ErrorTypeEnum, FileActionType, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import { resolveFilePath } from './utils';
4
4
  const getProcessFileReadObjectJson = (config) => (qpqConfig) => {
5
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
5
  return async ({ drive, filepath }) => {
7
6
  try {
8
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
7
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
9
8
  const content = await fs.readFile(fullPath, 'utf8');
10
9
  const jsonObject = JSON.parse(content);
11
10
  return actionResult(jsonObject);
12
11
  }
13
12
  catch (error) {
14
- if (error.code === 'ENOENT') {
15
- return actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
16
- }
17
- if (error instanceof SyntaxError) {
18
- return actionResultError(ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`);
19
- }
20
- return actionResultError(ErrorTypeEnum.GenericError, `Error reading JSON file: ${error.message}`);
13
+ return actionResultErrorFromCaughtError(error, {
14
+ ENOENT: () => actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code
15
+ SyntaxError: () => actionResultError(ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`), // JSON.parse failure
16
+ });
21
17
  }
22
18
  };
23
19
  };
@@ -1,19 +1,17 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, ErrorTypeEnum, FileActionType, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import { resolveFilePath } from './utils';
4
4
  const getProcessFileReadTextContents = (qpqConfig, config) => {
5
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
5
  return async ({ drive, filepath }) => {
7
6
  try {
8
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
7
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
9
8
  const content = await fs.readFile(fullPath, 'utf8');
10
9
  return actionResult(content);
11
10
  }
12
11
  catch (error) {
13
- if (error.code === 'ENOENT') {
14
- return actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
15
- }
16
- return actionResultError(ErrorTypeEnum.GenericError, `Error reading file: ${error.message}`);
12
+ return actionResultErrorFromCaughtError(error, {
13
+ ENOENT: () => actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`), // node fs code
14
+ });
17
15
  }
18
16
  };
19
17
  };
@@ -1,4 +1,5 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileStreamOpenErrorTypeEnum, } from 'quidproquo-core';
2
+ import { randomUUID } from 'crypto';
2
3
  import * as fs from 'fs';
3
4
  import { resolveFilePath } from './utils';
4
5
  async function* textStreamIterator(stream) {
@@ -13,23 +14,21 @@ async function* binaryStreamIterator(stream) {
13
14
  }
14
15
  }
15
16
  const getProcessFileStreamOpen = (qpqConfig, config) => {
16
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
17
17
  return async ({ drive, filepath, encoding, chunkSize }, session, actionProcessors, logger, updateSession, dynamicModuleLoader, streamRegistry) => {
18
18
  try {
19
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
19
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
20
20
  const isText = encoding === 'text';
21
21
  const highWaterMark = chunkSize ?? 65536;
22
22
  const readStream = fs.createReadStream(fullPath, isText ? { encoding: 'utf8', highWaterMark } : { highWaterMark });
23
- const streamId = `file-${Date.now()}-${Math.random().toString(36).slice(2)}`;
23
+ const streamId = `file-${randomUUID()}`;
24
24
  const iterator = isText ? textStreamIterator(readStream) : binaryStreamIterator(readStream);
25
25
  streamRegistry.register(streamId, iterator);
26
26
  return actionResult({ id: streamId, encoding });
27
27
  }
28
28
  catch (error) {
29
- if (error.code === 'ENOENT') {
30
- return actionResultError(ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
31
- }
32
- return actionResultError(ErrorTypeEnum.GenericError, `Error opening file stream: ${error.message}`);
29
+ return actionResultErrorFromCaughtError(error, {
30
+ ENOENT: () => actionResultError(FileStreamOpenErrorTypeEnum.FileNotFound, `File not found: ${filepath}`), // node fs code
31
+ });
33
32
  }
34
33
  };
35
34
  };
@@ -1,19 +1,26 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileWriteBinaryContentsErrorTypeEnum, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import { ensureParentDirectoryExists, resolveFilePath } from './utils';
4
4
  const getProcessFileWriteBinaryContents = (config) => (qpqConfig) => {
5
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
5
  return async ({ drive, filepath, data }) => {
7
6
  try {
8
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
7
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
9
8
  await ensureParentDirectoryExists(fullPath);
10
9
  // Convert QPQBinaryData to Buffer
11
10
  const buffer = Buffer.from(data.base64Data, 'base64');
12
11
  await fs.writeFile(fullPath, buffer);
12
+ if (data.mimetype || data.contentDisposition) {
13
+ await fs.writeFile(`${fullPath}.qpqmeta.json`, JSON.stringify({
14
+ mimetype: data.mimetype,
15
+ contentDisposition: data.contentDisposition,
16
+ }));
17
+ }
13
18
  return actionResult(void 0);
14
19
  }
15
20
  catch (error) {
16
- return actionResultError(ErrorTypeEnum.GenericError, `Error writing binary file: ${error.message}`);
21
+ return actionResultErrorFromCaughtError(error, {
22
+ EACCES: () => actionResultError(FileWriteBinaryContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
23
+ });
17
24
  }
18
25
  };
19
26
  };
@@ -1,18 +1,19 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileWriteObjectJsonErrorTypeEnum, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import { ensureParentDirectoryExists, resolveFilePath } from './utils';
4
4
  const getProcessFileWriteObjectJson = (config) => (qpqConfig) => {
5
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
5
  return async ({ drive, filepath, data }) => {
7
6
  try {
8
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
7
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
9
8
  await ensureParentDirectoryExists(fullPath);
10
9
  const jsonString = JSON.stringify(data, null, 2);
11
10
  await fs.writeFile(fullPath, jsonString, 'utf8');
12
11
  return actionResult(void 0);
13
12
  }
14
13
  catch (error) {
15
- return actionResultError(ErrorTypeEnum.GenericError, `Error writing JSON file: ${error.message}`);
14
+ return actionResultErrorFromCaughtError(error, {
15
+ EACCES: () => actionResultError(FileWriteObjectJsonErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
16
+ });
16
17
  }
17
18
  };
18
19
  };
@@ -1,17 +1,18 @@
1
- import { actionResult, actionResultError, ErrorTypeEnum, FileActionType, qpqCoreUtils, } from 'quidproquo-core';
1
+ import { actionResult, actionResultError, actionResultErrorFromCaughtError, FileActionType, FileWriteTextContentsErrorTypeEnum, } from 'quidproquo-core';
2
2
  import * as fs from 'fs/promises';
3
3
  import { ensureParentDirectoryExists, resolveFilePath } from './utils';
4
4
  const getProcessFileWriteTextContents = (qpqConfig, config) => {
5
- const serviceName = qpqCoreUtils.getApplicationModuleName(qpqConfig);
6
5
  return async ({ drive, filepath, data }) => {
7
6
  try {
8
- const fullPath = resolveFilePath(config, serviceName, drive, filepath);
7
+ const fullPath = resolveFilePath(config, qpqConfig, drive, filepath);
9
8
  await ensureParentDirectoryExists(fullPath);
10
9
  await fs.writeFile(fullPath, data, 'utf8');
11
10
  return actionResult(void 0);
12
11
  }
13
12
  catch (error) {
14
- return actionResultError(ErrorTypeEnum.GenericError, `Error writing file: ${error.message}`);
13
+ return actionResultErrorFromCaughtError(error, {
14
+ EACCES: () => actionResultError(FileWriteTextContentsErrorTypeEnum.AccessDenied, `Access denied writing file: ${filepath}`), // node fs code
15
+ });
15
16
  }
16
17
  };
17
18
  };
@@ -1,6 +1,7 @@
1
1
  import { QPQConfig } from 'quidproquo-core';
2
2
  import { FileStorageConfig } from './types';
3
3
  export declare const isStorageDriveNameValid: (drive: string, qpqConfig: QPQConfig) => boolean;
4
- export declare function resolveFilePath(fileStorageConfig: FileStorageConfig, service: string, drive: string, filepath: string): string;
4
+ export declare function resolveDriveServiceName(drive: string, qpqConfig: QPQConfig): string;
5
+ export declare function resolveFilePath(fileStorageConfig: FileStorageConfig, qpqConfig: QPQConfig, drive: string, filepath: string): string;
5
6
  export declare const ensureDirectoryExists: (dirPath: string) => Promise<void>;
6
7
  export declare const ensureParentDirectoryExists: (filePath: string) => Promise<void>;
@@ -9,7 +9,15 @@ export const isStorageDriveNameValid = (drive, qpqConfig) => {
9
9
  }
10
10
  return true;
11
11
  };
12
- export function resolveFilePath(fileStorageConfig, service, drive, filepath) {
12
+ // Resolve the service that owns a drive's on-disk location. Drives declared with
13
+ // `owner.module` are shared across services, so every caller reads and writes
14
+ // under the owner's folder — mirroring how AWS resolves the bucket by owner.
15
+ export function resolveDriveServiceName(drive, qpqConfig) {
16
+ const storageDrive = qpqCoreUtils.getStorageDriveByName(drive, qpqConfig);
17
+ return storageDrive?.owner?.module ?? qpqCoreUtils.getApplicationModuleName(qpqConfig);
18
+ }
19
+ export function resolveFilePath(fileStorageConfig, qpqConfig, drive, filepath) {
20
+ const service = resolveDriveServiceName(drive, qpqConfig);
13
21
  const root = path.resolve(fileStorageConfig.storagePath, service, drive);
14
22
  // Block absolute paths and null bytes outright
15
23
  if (path.isAbsolute(filepath)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quidproquo-actionprocessor-node",
3
- "version": "0.0.263",
3
+ "version": "0.1.1",
4
4
  "description": "",
5
5
  "main": "./lib/commonjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -33,17 +33,13 @@
33
33
  "homepage": "https://github.com/joe-coady/quidproquo#readme",
34
34
  "dependencies": {
35
35
  "@anthropic-ai/sdk": "^0.19.1",
36
- "axios": "^1.2.1",
37
- "mime-types": "^2.1.35",
38
- "quidproquo-core": "0.0.263",
39
- "quidproquo-webserver": "0.0.263",
40
- "uuid": "^9.0.0",
36
+ "quidproquo-actionprocessor-js": "0.1.1",
37
+ "quidproquo-core": "0.1.1",
38
+ "quidproquo-webserver": "0.1.1",
41
39
  "uuidv7": "^1.0.1"
42
40
  },
43
41
  "devDependencies": {
44
- "@types/mime-types": "^2.1.1",
45
- "@types/uuid": "^9.0.0",
46
- "quidproquo-tsconfig": "0.0.263",
42
+ "quidproquo-tsconfig": "0.1.1",
47
43
  "typescript": "^5.8.2"
48
44
  }
49
45
  }
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getClaudeAiMessagesApiActionProcessor: ActionProcessorListResolver;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.getClaudeAiMessagesApiActionProcessor = void 0;
46
- const quidproquo_core_1 = require("quidproquo-core");
47
- const sdk_1 = __importStar(require("@anthropic-ai/sdk"));
48
- const getProcessMessagesApi = (qpqConfig) => {
49
- return (_a) => __awaiter(void 0, [_a], void 0, function* ({ body, apiKey }) {
50
- const anthropic = new sdk_1.default({ apiKey });
51
- try {
52
- const msg = yield anthropic.messages.create(body);
53
- return (0, quidproquo_core_1.actionResult)(msg);
54
- }
55
- catch (error) {
56
- console.log(error);
57
- if (error instanceof sdk_1.AuthenticationError) {
58
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Unauthorized, 'Invalid API key.');
59
- }
60
- else if (error instanceof Error) {
61
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, error.message);
62
- }
63
- else {
64
- return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, 'An error occurred while processing your request.');
65
- }
66
- }
67
- });
68
- };
69
- const getClaudeAiMessagesApiActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
70
- return ({
71
- [quidproquo_core_1.ClaudeAiActionType.MessagesApi]: getProcessMessagesApi(qpqConfig),
72
- });
73
- });
74
- exports.getClaudeAiMessagesApiActionProcessor = getClaudeAiMessagesApiActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getClaudeAiActionProcessor: ActionProcessorListResolver;
@@ -1,17 +0,0 @@
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.getClaudeAiActionProcessor = void 0;
13
- const getClaudeAiMessagesApiActionProcessor_1 = require("./getClaudeAiMessagesApiActionProcessor");
14
- const getClaudeAiActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (Object.assign({}, (yield (0, getClaudeAiMessagesApiActionProcessor_1.getClaudeAiMessagesApiActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
- });
17
- exports.getClaudeAiActionProcessor = getClaudeAiActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getConfigGetApplicationInfoActionProcessor: ActionProcessorListResolver;
@@ -1,30 +0,0 @@
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.getConfigGetApplicationInfoActionProcessor = void 0;
13
- const quidproquo_core_1 = require("quidproquo-core");
14
- const getProcessConfigGetApplicationConfig = (qpqConfig) => {
15
- return () => __awaiter(void 0, void 0, void 0, function* () {
16
- const appInfo = {
17
- environment: quidproquo_core_1.qpqCoreUtils.getApplicationModuleEnvironment(qpqConfig),
18
- feature: quidproquo_core_1.qpqCoreUtils.getApplicationModuleFeature(qpqConfig),
19
- module: quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig),
20
- name: quidproquo_core_1.qpqCoreUtils.getApplicationName(qpqConfig),
21
- };
22
- return (0, quidproquo_core_1.actionResult)(appInfo);
23
- });
24
- };
25
- const getConfigGetApplicationInfoActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
26
- return ({
27
- [quidproquo_core_1.ConfigActionType.GetApplicationInfo]: getProcessConfigGetApplicationConfig(qpqConfig),
28
- });
29
- });
30
- exports.getConfigGetApplicationInfoActionProcessor = getConfigGetApplicationInfoActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getConfigActionProcessor: ActionProcessorListResolver;
@@ -1,17 +0,0 @@
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.getConfigActionProcessor = void 0;
13
- const getConfigGetApplicationInfoActionProcessor_1 = require("./getConfigGetApplicationInfoActionProcessor");
14
- const getConfigActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
15
- return (Object.assign({}, (yield (0, getConfigGetApplicationInfoActionProcessor_1.getConfigGetApplicationInfoActionProcessor)(qpqConfig, dynamicModuleLoader))));
16
- });
17
- exports.getConfigActionProcessor = getConfigActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getContextListActionProcessor: ActionProcessorListResolver;
@@ -1,24 +0,0 @@
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.getContextListActionProcessor = void 0;
13
- const quidproquo_core_1 = require("quidproquo-core");
14
- const getProcessContextList = (qpqConfig) => {
15
- return (payload, session) => __awaiter(void 0, void 0, void 0, function* () {
16
- return (0, quidproquo_core_1.actionResult)(session.context);
17
- });
18
- };
19
- const getContextListActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
20
- return ({
21
- [quidproquo_core_1.ContextActionType.List]: getProcessContextList(qpqConfig),
22
- });
23
- });
24
- exports.getContextListActionProcessor = getContextListActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getContextReadActionProcessor: ActionProcessorListResolver;
@@ -1,27 +0,0 @@
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.getContextReadActionProcessor = void 0;
13
- const quidproquo_core_1 = require("quidproquo-core");
14
- const getContextValue = (context, contextIdentifier) => {
15
- return contextIdentifier.uniqueName in context ? context[contextIdentifier.uniqueName] : contextIdentifier.defaultValue;
16
- };
17
- const getProcessContextRead = (qpqConfig) => {
18
- return (_a, session_1) => __awaiter(void 0, [_a, session_1], void 0, function* ({ contextIdentifier }, session) {
19
- return (0, quidproquo_core_1.actionResult)(getContextValue(session.context, contextIdentifier));
20
- });
21
- };
22
- const getContextReadActionProcessor = (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
23
- return ({
24
- [quidproquo_core_1.ContextActionType.Read]: getProcessContextRead(qpqConfig),
25
- });
26
- });
27
- exports.getContextReadActionProcessor = getContextReadActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getContextActionProcessor: ActionProcessorListResolver;
@@ -1,18 +0,0 @@
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.getContextActionProcessor = void 0;
13
- const getContextListActionProcessor_1 = require("./getContextListActionProcessor");
14
- const getContextReadActionProcessor_1 = require("./getContextReadActionProcessor");
15
- const getContextActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
16
- return (Object.assign(Object.assign({}, (yield (0, getContextListActionProcessor_1.getContextListActionProcessor)(qpqConfig, dynamicModuleLoader))), (yield (0, getContextReadActionProcessor_1.getContextReadActionProcessor)(qpqConfig, dynamicModuleLoader))));
17
- });
18
- exports.getContextActionProcessor = getContextActionProcessor;
@@ -1,2 +0,0 @@
1
- import { ActionProcessorListResolver } from 'quidproquo-core';
2
- export declare const getCustomActionActionProcessor: ActionProcessorListResolver;
@@ -1,58 +0,0 @@
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.getCustomActionActionProcessor = void 0;
13
- const quidproquo_core_1 = require("quidproquo-core");
14
- function getActionProcessorListLoader(dynamicModuleLoader, qpqConfig) {
15
- return function loadModule(qpqFunctionRuntime) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- try {
18
- const possibleModule = yield dynamicModuleLoader(qpqFunctionRuntime);
19
- if (typeof possibleModule !== 'function') {
20
- throw new Error(`Expected module to be a function, but got ${typeof possibleModule}`);
21
- }
22
- const apl = yield possibleModule(qpqConfig, dynamicModuleLoader);
23
- if (typeof apl !== 'object') {
24
- throw new Error(`Expected action processor list to be an object, but got ${typeof apl}`);
25
- }
26
- if (Object.values(apl).find((aplv) => typeof aplv !== 'function')) {
27
- throw new Error('Expected all action processors to be functions');
28
- }
29
- return apl;
30
- }
31
- catch (e) {
32
- console.log(`Unable to dynamically load action processors: [${e}] ${JSON.stringify(qpqFunctionRuntime)}`);
33
- throw e;
34
- }
35
- });
36
- };
37
- }
38
- const getProcessCustomAction = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
39
- try {
40
- const actionProcessorListLoader = getActionProcessorListLoader(dynamicModuleLoader, qpqConfig);
41
- const getCustomActionProcessors = quidproquo_core_1.qpqCoreUtils.getActionProcessorSources(qpqConfig);
42
- const possibleModuleResults = yield Promise.allSettled(getCustomActionProcessors.map(actionProcessorListLoader));
43
- // Filter out successfully loaded modules that are functions
44
- const actionProcessorLists = possibleModuleResults
45
- .filter((result) => result.status === 'fulfilled')
46
- .map((result) => result.value);
47
- return actionProcessorLists.reduce((acc, cur) => (Object.assign(Object.assign({}, acc), cur)), {});
48
- }
49
- catch (e) {
50
- // This should never get hit, but just in case
51
- console.log(`Unable to dynamically load action processors: [${e}]`);
52
- return {};
53
- }
54
- });
55
- const getCustomActionActionProcessor = (qpqConfig, dynamicModuleLoader) => __awaiter(void 0, void 0, void 0, function* () {
56
- return (Object.assign({}, (yield getProcessCustomAction(qpqConfig, dynamicModuleLoader))));
57
- });
58
- exports.getCustomActionActionProcessor = getCustomActionActionProcessor;