quidproquo-actionprocessor-node 0.0.256 → 0.0.257
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/dynamicActionProcessor/file/getFileDeleteActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +81 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileExistsActionProcessor.js +72 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +41 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +44 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.js +25 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +98 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +77 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +74 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +70 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +70 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +69 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.d.ts +3 -0
- package/lib/commonjs/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +68 -0
- package/lib/commonjs/dynamicActionProcessor/file/index.d.ts +6 -0
- package/lib/commonjs/dynamicActionProcessor/file/index.js +48 -0
- package/lib/commonjs/dynamicActionProcessor/file/secureUrlUtils.d.ts +10 -0
- package/lib/commonjs/dynamicActionProcessor/file/secureUrlUtils.js +84 -0
- package/lib/commonjs/dynamicActionProcessor/file/types.d.ts +6 -0
- package/lib/commonjs/dynamicActionProcessor/file/types.js +2 -0
- package/lib/commonjs/dynamicActionProcessor/file/utils.d.ts +6 -0
- package/lib/commonjs/dynamicActionProcessor/file/utils.js +90 -0
- package/lib/commonjs/dynamicActionProcessor/index.d.ts +1 -0
- package/lib/commonjs/dynamicActionProcessor/index.js +17 -0
- package/lib/commonjs/index.d.ts +1 -0
- package/lib/commonjs/index.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileDeleteActionProcessor.js +33 -0
- package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileExistsActionProcessor.js +24 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js +26 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileGenerateTemporaryUploadSecureUrlActionProcessor.js +29 -0
- package/lib/esm/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileIsColdStorageActionProcessor.js +10 -0
- package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileListDirectoryActionProcessor.js +50 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadBinaryContentsActionProcessor.js +29 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadObjectJsonActionProcessor.js +26 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileReadTextContentsActionProcessor.js +22 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteBinaryContentsActionProcessor.js +22 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteObjectJsonActionProcessor.js +21 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.d.ts +3 -0
- package/lib/esm/dynamicActionProcessor/file/getFileWriteTextContentsActionProcessor.js +20 -0
- package/lib/esm/dynamicActionProcessor/file/index.d.ts +6 -0
- package/lib/esm/dynamicActionProcessor/file/index.js +32 -0
- package/lib/esm/dynamicActionProcessor/file/secureUrlUtils.d.ts +10 -0
- package/lib/esm/dynamicActionProcessor/file/secureUrlUtils.js +45 -0
- package/lib/esm/dynamicActionProcessor/file/types.d.ts +6 -0
- package/lib/esm/dynamicActionProcessor/file/types.js +1 -0
- package/lib/esm/dynamicActionProcessor/file/utils.d.ts +6 -0
- package/lib/esm/dynamicActionProcessor/file/utils.js +41 -0
- package/lib/esm/dynamicActionProcessor/index.d.ts +1 -0
- package/lib/esm/dynamicActionProcessor/index.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,81 @@
|
|
|
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.getFileDeleteActionProcessor = void 0;
|
|
46
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
const getProcessFileDelete = (qpqConfig, config) => {
|
|
50
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
51
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepaths }) {
|
|
52
|
+
const deletedFiles = [];
|
|
53
|
+
const errors = [];
|
|
54
|
+
for (const filepath of filepaths) {
|
|
55
|
+
try {
|
|
56
|
+
const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
|
|
57
|
+
yield fs.unlink(fullPath);
|
|
58
|
+
deletedFiles.push(filepath);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// If file doesn't exist, consider it successfully deleted
|
|
62
|
+
if (error.code === 'ENOENT') {
|
|
63
|
+
deletedFiles.push(filepath);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
errors.push(`Failed to delete ${filepath}: ${error.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (errors.length > 0 && deletedFiles.length === 0) {
|
|
71
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Failed to delete files: ${errors.join(', ')}`);
|
|
72
|
+
}
|
|
73
|
+
return (0, quidproquo_core_1.actionResult)(deletedFiles);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
const getFileDeleteActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
return ({
|
|
78
|
+
[quidproquo_core_1.FileActionType.Delete]: getProcessFileDelete(qpqConfig, config),
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
exports.getFileDeleteActionProcessor = getFileDeleteActionProcessor;
|
|
@@ -0,0 +1,72 @@
|
|
|
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.getFileExistsActionProcessor = void 0;
|
|
46
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
const getProcessFileExists = (qpqConfig, config) => {
|
|
50
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
51
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
|
|
52
|
+
try {
|
|
53
|
+
const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
|
|
54
|
+
try {
|
|
55
|
+
yield fs.access(fullPath);
|
|
56
|
+
return (0, quidproquo_core_1.actionResult)(true);
|
|
57
|
+
}
|
|
58
|
+
catch (_b) {
|
|
59
|
+
return (0, quidproquo_core_1.actionResult)(false);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error checking file existence: ${error.message}`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const getFileExistsActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
return ({
|
|
69
|
+
[quidproquo_core_1.FileActionType.Exists]: getProcessFileExists(qpqConfig, config),
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
exports.getFileExistsActionProcessor = getFileExistsActionProcessor;
|
package/lib/commonjs/dynamicActionProcessor/file/getFileGenerateTemporarySecureUrlActionProcessor.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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.getFileGenerateTemporarySecureUrlActionProcessor = void 0;
|
|
13
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
const secureUrlUtils_1 = require("./secureUrlUtils");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
const getProcessFileGenerateTemporarySecureUrl = (qpqConfig, config) => {
|
|
17
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
18
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs }) {
|
|
19
|
+
try {
|
|
20
|
+
// Create a token for download
|
|
21
|
+
const token = (0, secureUrlUtils_1.createSecureUrlToken)({
|
|
22
|
+
fullFilepath: (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath),
|
|
23
|
+
operation: 'download',
|
|
24
|
+
expiresAt: Date.now() + expirationMs,
|
|
25
|
+
}, config.secureUrlSecret);
|
|
26
|
+
// Build the secure URL
|
|
27
|
+
const baseUrl = (0, secureUrlUtils_1.getSecureUrlBaseUrl)(config);
|
|
28
|
+
const url = `${baseUrl}/secure-download?token=${token}`;
|
|
29
|
+
return (0, quidproquo_core_1.actionResult)(url);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Unable to generate temporary secure URL: ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const getFileGenerateTemporarySecureUrlActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
return ({
|
|
38
|
+
[quidproquo_core_1.FileActionType.GenerateTemporarySecureUrl]: getProcessFileGenerateTemporarySecureUrl(qpqConfig, config),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
exports.getFileGenerateTemporarySecureUrlActionProcessor = getFileGenerateTemporarySecureUrlActionProcessor;
|
|
@@ -0,0 +1,44 @@
|
|
|
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.getFileGenerateTemporaryUploadSecureUrlActionProcessor = void 0;
|
|
13
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
const secureUrlUtils_1 = require("./secureUrlUtils");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
const getProcessFileGenerateTemporaryUploadSecureUrl = (qpqConfig, config) => {
|
|
17
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
18
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath, expirationMs, contentType }) {
|
|
19
|
+
try {
|
|
20
|
+
const expiresAt = Date.now() + expirationMs;
|
|
21
|
+
// Create a token for upload
|
|
22
|
+
const token = (0, secureUrlUtils_1.createSecureUrlToken)({
|
|
23
|
+
fullFilepath: (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath),
|
|
24
|
+
operation: 'upload',
|
|
25
|
+
expiresAt,
|
|
26
|
+
contentType,
|
|
27
|
+
}, config.secureUrlSecret);
|
|
28
|
+
// Build the secure URL
|
|
29
|
+
const baseUrl = (0, secureUrlUtils_1.getSecureUrlBaseUrl)(config);
|
|
30
|
+
const url = `${baseUrl}/secure-upload?token=${token}`;
|
|
31
|
+
console.log(`Generated upload URL for ${filepath} in drive ${drive}, expires at ${new Date(expiresAt).toISOString()}`);
|
|
32
|
+
return (0, quidproquo_core_1.actionResult)(url);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Unable to generate temporary upload secure URL: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const getFileGenerateTemporaryUploadSecureUrlActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
return ({
|
|
41
|
+
[quidproquo_core_1.FileActionType.GenerateTemporaryUploadSecureUrl]: getProcessFileGenerateTemporaryUploadSecureUrl(qpqConfig, config),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
exports.getFileGenerateTemporaryUploadSecureUrlActionProcessor = getFileGenerateTemporaryUploadSecureUrlActionProcessor;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.getFileIsColdStorageActionProcessor = void 0;
|
|
13
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
14
|
+
const getProcessFileIsColdStorage = (config) => (qpqConfig) => {
|
|
15
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
|
|
16
|
+
// Local filesystem doesn't have cold storage, always return false
|
|
17
|
+
return (0, quidproquo_core_1.actionResult)(false);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const getFileIsColdStorageActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
return ({
|
|
22
|
+
[quidproquo_core_1.FileActionType.IsColdStorage]: getProcessFileIsColdStorage(config)(qpqConfig),
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
exports.getFileIsColdStorageActionProcessor = getFileIsColdStorageActionProcessor;
|
|
@@ -0,0 +1,98 @@
|
|
|
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.getFileListDirectoryActionProcessor = void 0;
|
|
46
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const utils_1 = require("./utils");
|
|
50
|
+
const getProcessFileListDirectory = (config) => (qpqConfig) => {
|
|
51
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
52
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, folderPath, maxFiles, pageToken }) {
|
|
53
|
+
try {
|
|
54
|
+
const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, folderPath || '');
|
|
55
|
+
// Read all entries in the directory
|
|
56
|
+
const entries = yield fs.readdir(fullPath, { withFileTypes: true });
|
|
57
|
+
// Build file info list
|
|
58
|
+
const allFiles = [];
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
allFiles.push({
|
|
61
|
+
filepath: path.join(folderPath || '', entry.name),
|
|
62
|
+
drive: drive,
|
|
63
|
+
isDir: entry.isDirectory(),
|
|
64
|
+
hashMd5: undefined,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Sort by filepath for consistent pagination
|
|
68
|
+
allFiles.sort((a, b) => a.filepath.localeCompare(b.filepath));
|
|
69
|
+
// Handle pagination
|
|
70
|
+
const startIndex = pageToken ? parseInt(pageToken, 10) : 0;
|
|
71
|
+
const endIndex = Math.min(startIndex + maxFiles, allFiles.length);
|
|
72
|
+
const paginatedFiles = allFiles.slice(startIndex, endIndex);
|
|
73
|
+
const result = {
|
|
74
|
+
fileInfos: paginatedFiles,
|
|
75
|
+
};
|
|
76
|
+
// Add page token if there are more files
|
|
77
|
+
if (endIndex < allFiles.length) {
|
|
78
|
+
result.pageToken = endIndex.toString();
|
|
79
|
+
}
|
|
80
|
+
return (0, quidproquo_core_1.actionResult)(result);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error.code === 'ENOENT') {
|
|
84
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `Directory not found: ${folderPath}`);
|
|
85
|
+
}
|
|
86
|
+
if (error.code === 'ENOTDIR') {
|
|
87
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Path is not a directory: ${folderPath}`);
|
|
88
|
+
}
|
|
89
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error listing directory: ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const getFileListDirectoryActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
return ({
|
|
95
|
+
[quidproquo_core_1.FileActionType.ListDirectory]: getProcessFileListDirectory(config)(qpqConfig),
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
exports.getFileListDirectoryActionProcessor = getFileListDirectoryActionProcessor;
|
|
@@ -0,0 +1,77 @@
|
|
|
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.getFileReadBinaryContentsActionProcessor = void 0;
|
|
46
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const path = __importStar(require("path"));
|
|
49
|
+
const utils_1 = require("./utils");
|
|
50
|
+
const getProcessFileReadBinaryContents = (config) => (qpqConfig) => {
|
|
51
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
52
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
|
|
53
|
+
try {
|
|
54
|
+
const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
|
|
55
|
+
const buffer = yield fs.readFile(fullPath);
|
|
56
|
+
// Convert Buffer to QPQBinaryData
|
|
57
|
+
const binaryData = {
|
|
58
|
+
base64Data: buffer.toString('base64'),
|
|
59
|
+
filename: path.basename(filepath),
|
|
60
|
+
mimetype: 'application/octet-stream', // Default mimetype for binary files
|
|
61
|
+
};
|
|
62
|
+
return (0, quidproquo_core_1.actionResult)(binaryData);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error.code === 'ENOENT') {
|
|
66
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
|
|
67
|
+
}
|
|
68
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error reading binary file: ${error.message}`);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const getFileReadBinaryContentsActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
return ({
|
|
74
|
+
[quidproquo_core_1.FileActionType.ReadBinaryContents]: getProcessFileReadBinaryContents(config)(qpqConfig),
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
exports.getFileReadBinaryContentsActionProcessor = getFileReadBinaryContentsActionProcessor;
|
|
@@ -0,0 +1,74 @@
|
|
|
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.getFileReadObjectJsonActionProcessor = void 0;
|
|
46
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
const getProcessFileReadObjectJson = (config) => (qpqConfig) => {
|
|
50
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
51
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
|
|
52
|
+
try {
|
|
53
|
+
const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
|
|
54
|
+
const content = yield fs.readFile(fullPath, 'utf8');
|
|
55
|
+
const jsonObject = JSON.parse(content);
|
|
56
|
+
return (0, quidproquo_core_1.actionResult)(jsonObject);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
if (error.code === 'ENOENT') {
|
|
60
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
|
|
61
|
+
}
|
|
62
|
+
if (error instanceof SyntaxError) {
|
|
63
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Invalid JSON in file: ${filepath}`);
|
|
64
|
+
}
|
|
65
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error reading JSON file: ${error.message}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
const getFileReadObjectJsonActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
return ({
|
|
71
|
+
[quidproquo_core_1.FileActionType.ReadObjectJson]: getProcessFileReadObjectJson(config)(qpqConfig),
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
exports.getFileReadObjectJsonActionProcessor = getFileReadObjectJsonActionProcessor;
|
|
@@ -0,0 +1,70 @@
|
|
|
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.getFileReadTextContentsActionProcessor = void 0;
|
|
46
|
+
const quidproquo_core_1 = require("quidproquo-core");
|
|
47
|
+
const fs = __importStar(require("fs/promises"));
|
|
48
|
+
const utils_1 = require("./utils");
|
|
49
|
+
const getProcessFileReadTextContents = (qpqConfig, config) => {
|
|
50
|
+
const serviceName = quidproquo_core_1.qpqCoreUtils.getApplicationModuleName(qpqConfig);
|
|
51
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ drive, filepath }) {
|
|
52
|
+
try {
|
|
53
|
+
const fullPath = (0, utils_1.resolveFilePath)(config, serviceName, drive, filepath);
|
|
54
|
+
const content = yield fs.readFile(fullPath, 'utf8');
|
|
55
|
+
return (0, quidproquo_core_1.actionResult)(content);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.code === 'ENOENT') {
|
|
59
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.NotFound, `File not found: ${filepath}`);
|
|
60
|
+
}
|
|
61
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.GenericError, `Error reading file: ${error.message}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
const getFileReadTextContentsActionProcessor = (config) => (qpqConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
+
return ({
|
|
67
|
+
[quidproquo_core_1.FileActionType.ReadTextContents]: getProcessFileReadTextContents(qpqConfig, config),
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
exports.getFileReadTextContentsActionProcessor = getFileReadTextContentsActionProcessor;
|