n8n-core 1.89.0 → 1.90.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.
- package/dist/binary-data/object-store/object-store.config.d.ts +19 -0
- package/dist/binary-data/object-store/object-store.config.js +83 -0
- package/dist/binary-data/object-store/object-store.config.js.map +1 -0
- package/dist/binary-data/object-store/object-store.service.ee.d.ts +23 -11
- package/dist/binary-data/object-store/object-store.service.ee.js +172 -112
- package/dist/binary-data/object-store/object-store.service.ee.js.map +1 -1
- package/dist/binary-data/object-store/types.d.ts +4 -31
- package/dist/binary-data/utils.d.ts +1 -0
- package/dist/binary-data/utils.js +14 -9
- package/dist/binary-data/utils.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/execution-engine/node-execution-context/credentials-test-context.js +1 -1
- package/dist/execution-engine/node-execution-context/credentials-test-context.js.map +1 -1
- package/dist/execution-engine/node-execution-context/node-execution-context.js +1 -1
- package/dist/execution-engine/node-execution-context/node-execution-context.js.map +1 -1
- package/dist/execution-engine/partial-execution-utils/index.d.ts +2 -0
- package/dist/execution-engine/partial-execution-utils/index.js +5 -1
- package/dist/execution-engine/partial-execution-utils/index.js.map +1 -1
- package/dist/execution-engine/partial-execution-utils/is-tool.d.ts +2 -0
- package/dist/execution-engine/partial-execution-utils/is-tool.js +9 -0
- package/dist/execution-engine/partial-execution-utils/is-tool.js.map +1 -0
- package/dist/execution-engine/partial-execution-utils/rewire-graph.d.ts +3 -0
- package/dist/execution-engine/partial-execution-utils/rewire-graph.js +57 -0
- package/dist/execution-engine/partial-execution-utils/rewire-graph.js.map +1 -0
- package/dist/execution-engine/workflow-execute.js +40 -29
- package/dist/execution-engine/workflow-execute.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/instance-settings/instance-settings.js +1 -1
- package/dist/instance-settings/instance-settings.js.map +1 -1
- package/dist/nodes-loader/constants.d.ts +1 -0
- package/dist/nodes-loader/constants.js +77 -1
- package/dist/nodes-loader/constants.js.map +1 -1
- package/dist/nodes-loader/directory-loader.d.ts +1 -0
- package/dist/nodes-loader/directory-loader.js +42 -1
- package/dist/nodes-loader/directory-loader.js.map +1 -1
- package/package.json +6 -8
- package/dist/binary-data/object-store/utils.d.ts +0 -3
- package/dist/binary-data/object-store/utils.js +0 -19
- package/dist/binary-data/object-store/utils.js.map +0 -1
- package/dist/decorators/index.d.ts +0 -1
- package/dist/decorators/index.js +0 -6
- package/dist/decorators/index.js.map +0 -1
- package/dist/decorators/memoized.d.ts +0 -1
- package/dist/decorators/memoized.js +0 -23
- package/dist/decorators/memoized.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const protocolSchema: z.ZodEnum<["http", "https"]>;
|
|
3
|
+
export type Protocol = z.infer<typeof protocolSchema>;
|
|
4
|
+
declare class ObjectStoreBucketConfig {
|
|
5
|
+
name: string;
|
|
6
|
+
region: string;
|
|
7
|
+
}
|
|
8
|
+
declare class ObjectStoreCredentialsConfig {
|
|
9
|
+
accessKey: string;
|
|
10
|
+
accessSecret: string;
|
|
11
|
+
authAutoDetect: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class ObjectStoreConfig {
|
|
14
|
+
host: string;
|
|
15
|
+
protocol: Protocol;
|
|
16
|
+
bucket: ObjectStoreBucketConfig;
|
|
17
|
+
credentials: ObjectStoreCredentialsConfig;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ObjectStoreConfig = void 0;
|
|
13
|
+
const config_1 = require("@n8n/config");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const protocolSchema = zod_1.z.enum(['http', 'https']);
|
|
16
|
+
let ObjectStoreBucketConfig = class ObjectStoreBucketConfig {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.name = '';
|
|
19
|
+
this.region = '';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_BUCKET_NAME'),
|
|
24
|
+
__metadata("design:type", String)
|
|
25
|
+
], ObjectStoreBucketConfig.prototype, "name", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_BUCKET_REGION'),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], ObjectStoreBucketConfig.prototype, "region", void 0);
|
|
30
|
+
ObjectStoreBucketConfig = __decorate([
|
|
31
|
+
config_1.Config
|
|
32
|
+
], ObjectStoreBucketConfig);
|
|
33
|
+
let ObjectStoreCredentialsConfig = class ObjectStoreCredentialsConfig {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.accessKey = '';
|
|
36
|
+
this.accessSecret = '';
|
|
37
|
+
this.authAutoDetect = false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_ACCESS_KEY'),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], ObjectStoreCredentialsConfig.prototype, "accessKey", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_ACCESS_SECRET'),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], ObjectStoreCredentialsConfig.prototype, "accessSecret", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_AUTH_AUTO_DETECT'),
|
|
50
|
+
__metadata("design:type", Boolean)
|
|
51
|
+
], ObjectStoreCredentialsConfig.prototype, "authAutoDetect", void 0);
|
|
52
|
+
ObjectStoreCredentialsConfig = __decorate([
|
|
53
|
+
config_1.Config
|
|
54
|
+
], ObjectStoreCredentialsConfig);
|
|
55
|
+
let ObjectStoreConfig = class ObjectStoreConfig {
|
|
56
|
+
constructor() {
|
|
57
|
+
this.host = '';
|
|
58
|
+
this.protocol = 'https';
|
|
59
|
+
this.bucket = {};
|
|
60
|
+
this.credentials = {};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.ObjectStoreConfig = ObjectStoreConfig;
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_HOST'),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], ObjectStoreConfig.prototype, "host", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, config_1.Env)('N8N_EXTERNAL_STORAGE_S3_PROTOCOL', protocolSchema),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], ObjectStoreConfig.prototype, "protocol", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
config_1.Nested,
|
|
74
|
+
__metadata("design:type", ObjectStoreBucketConfig)
|
|
75
|
+
], ObjectStoreConfig.prototype, "bucket", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
config_1.Nested,
|
|
78
|
+
__metadata("design:type", ObjectStoreCredentialsConfig)
|
|
79
|
+
], ObjectStoreConfig.prototype, "credentials", void 0);
|
|
80
|
+
exports.ObjectStoreConfig = ObjectStoreConfig = __decorate([
|
|
81
|
+
config_1.Config
|
|
82
|
+
], ObjectStoreConfig);
|
|
83
|
+
//# sourceMappingURL=object-store.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-store.config.js","sourceRoot":"","sources":["../../../src/binary-data/object-store/object-store.config.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAkD;AAClD,6BAAwB;AAExB,MAAM,cAAc,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAKjD,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAA7B;QAGC,SAAI,GAAW,EAAE,CAAC;QAIlB,WAAM,GAAW,EAAE,CAAC;IACrB,CAAC;CAAA,CAAA;AALA;IADC,IAAA,YAAG,EAAC,qCAAqC,CAAC;;qDACzB;AAIlB;IADC,IAAA,YAAG,EAAC,uCAAuC,CAAC;;uDACzB;AAPf,uBAAuB;IAD5B,eAAM;GACD,uBAAuB,CAQ5B;AAGD,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;IAAlC;QAGC,cAAS,GAAW,EAAE,CAAC;QAIvB,iBAAY,GAAW,EAAE,CAAC;QAQ1B,mBAAc,GAAY,KAAK,CAAC;IACjC,CAAC;CAAA,CAAA;AAbA;IADC,IAAA,YAAG,EAAC,oCAAoC,CAAC;;+DACnB;AAIvB;IADC,IAAA,YAAG,EAAC,uCAAuC,CAAC;;kEACnB;AAQ1B;IADC,IAAA,YAAG,EAAC,0CAA0C,CAAC;;oEAChB;AAf3B,4BAA4B;IADjC,eAAM;GACD,4BAA4B,CAgBjC;AAGM,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QAMN,SAAI,GAAW,EAAE,CAAC;QAGlB,aAAQ,GAAa,OAAO,CAAC;QAG7B,WAAM,GAA4B,EAA6B,CAAC;QAGhE,gBAAW,GAAiC,EAAkC,CAAC;IAChF,CAAC;CAAA,CAAA;AAhBY,8CAAiB;AAM7B;IADC,IAAA,YAAG,EAAC,8BAA8B,CAAC;;+CAClB;AAGlB;IADC,IAAA,YAAG,EAAC,kCAAkC,EAAE,cAAc,CAAC;;mDAC3B;AAG7B;IADC,eAAM;8BACC,uBAAuB;iDAAiC;AAGhE;IADC,eAAM;8BACM,4BAA4B;sDAAsC;4BAfnE,iBAAiB;IAD7B,eAAM;GACM,iBAAiB,CAgB7B"}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type { S3ClientConfig } from '@aws-sdk/client-s3';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
3
|
import { Logger } from '../../logging/logger';
|
|
4
|
-
import
|
|
4
|
+
import { ObjectStoreConfig } from './object-store.config';
|
|
5
|
+
import type { MetadataResponseHeaders } from './types';
|
|
5
6
|
import type { BinaryData } from '../types';
|
|
6
7
|
export declare class ObjectStoreService {
|
|
7
8
|
private readonly logger;
|
|
8
9
|
private readonly s3Config;
|
|
9
|
-
private
|
|
10
|
+
private s3Client;
|
|
10
11
|
private isReady;
|
|
11
|
-
|
|
12
|
+
private bucket;
|
|
13
|
+
constructor(logger: Logger, s3Config: ObjectStoreConfig);
|
|
14
|
+
getClientConfig(): S3ClientConfig;
|
|
12
15
|
init(): Promise<void>;
|
|
13
16
|
setReady(newState: boolean): void;
|
|
14
|
-
checkConnection(): Promise<
|
|
15
|
-
put(filename: string, buffer: Buffer, metadata?: BinaryData.PreWriteMetadata): Promise<import("
|
|
17
|
+
checkConnection(): Promise<void>;
|
|
18
|
+
put(filename: string, buffer: Buffer, metadata?: BinaryData.PreWriteMetadata): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput>;
|
|
16
19
|
get(fileId: string, { mode }: {
|
|
17
20
|
mode: 'buffer';
|
|
18
21
|
}): Promise<Buffer>;
|
|
@@ -20,8 +23,8 @@ export declare class ObjectStoreService {
|
|
|
20
23
|
mode: 'stream';
|
|
21
24
|
}): Promise<Readable>;
|
|
22
25
|
getMetadata(fileId: string): Promise<MetadataResponseHeaders>;
|
|
23
|
-
deleteOne(fileId: string): Promise<import("
|
|
24
|
-
deleteMany(prefix: string): Promise<import("
|
|
26
|
+
deleteOne(fileId: string): Promise<import("@aws-sdk/client-s3").DeleteObjectCommandOutput>;
|
|
27
|
+
deleteMany(prefix: string): Promise<import("@aws-sdk/client-s3").DeleteObjectsCommandOutput | undefined>;
|
|
25
28
|
list(prefix: string): Promise<{
|
|
26
29
|
key: string;
|
|
27
30
|
lastModified: string;
|
|
@@ -29,6 +32,15 @@ export declare class ObjectStoreService {
|
|
|
29
32
|
size: number;
|
|
30
33
|
storageClass: string;
|
|
31
34
|
}[]>;
|
|
32
|
-
getListPage(prefix: string,
|
|
33
|
-
|
|
35
|
+
getListPage(prefix: string, continuationToken?: string): Promise<{
|
|
36
|
+
contents: {
|
|
37
|
+
key: string;
|
|
38
|
+
lastModified: string;
|
|
39
|
+
eTag: string;
|
|
40
|
+
size: number;
|
|
41
|
+
storageClass: string;
|
|
42
|
+
}[];
|
|
43
|
+
isTruncated: boolean;
|
|
44
|
+
nextContinuationToken: string | undefined;
|
|
45
|
+
}>;
|
|
34
46
|
}
|
|
@@ -8,32 +8,46 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.ObjectStoreService = void 0;
|
|
16
|
-
const
|
|
13
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
17
14
|
const di_1 = require("@n8n/di");
|
|
18
|
-
const aws4_1 = require("aws4");
|
|
19
|
-
const axios_1 = __importDefault(require("axios"));
|
|
20
15
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
21
16
|
const node_crypto_1 = require("node:crypto");
|
|
17
|
+
const node_stream_1 = require("node:stream");
|
|
22
18
|
const logger_1 = require("../../logging/logger");
|
|
23
|
-
const
|
|
19
|
+
const object_store_config_1 = require("./object-store.config");
|
|
20
|
+
const utils_1 = require("../utils");
|
|
24
21
|
let ObjectStoreService = class ObjectStoreService {
|
|
25
22
|
constructor(logger, s3Config) {
|
|
26
23
|
this.logger = logger;
|
|
27
24
|
this.s3Config = s3Config;
|
|
28
25
|
this.isReady = false;
|
|
29
|
-
const {
|
|
30
|
-
if (host === '') {
|
|
31
|
-
throw new n8n_workflow_1.ApplicationError('External storage host not configured. Please set `N8N_EXTERNAL_STORAGE_S3_HOST`.');
|
|
32
|
-
}
|
|
26
|
+
const { bucket } = s3Config;
|
|
33
27
|
if (bucket.name === '') {
|
|
34
|
-
throw new n8n_workflow_1.
|
|
28
|
+
throw new n8n_workflow_1.UnexpectedError('External storage bucket name not configured. Please set `N8N_EXTERNAL_STORAGE_S3_BUCKET_NAME`.');
|
|
29
|
+
}
|
|
30
|
+
this.bucket = bucket.name;
|
|
31
|
+
this.s3Client = new client_s3_1.S3Client(this.getClientConfig());
|
|
32
|
+
}
|
|
33
|
+
getClientConfig() {
|
|
34
|
+
const { host, bucket, protocol, credentials } = this.s3Config;
|
|
35
|
+
const clientConfig = {};
|
|
36
|
+
const endpoint = host ? `${protocol}://${host}` : undefined;
|
|
37
|
+
if (endpoint) {
|
|
38
|
+
clientConfig.endpoint = endpoint;
|
|
39
|
+
clientConfig.forcePathStyle = true;
|
|
40
|
+
}
|
|
41
|
+
if (bucket.region.length) {
|
|
42
|
+
clientConfig.region = bucket.region;
|
|
35
43
|
}
|
|
36
|
-
|
|
44
|
+
if (!credentials.authAutoDetect) {
|
|
45
|
+
clientConfig.credentials = {
|
|
46
|
+
accessKeyId: credentials.accessKey,
|
|
47
|
+
secretAccessKey: credentials.accessSecret,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return clientConfig;
|
|
37
51
|
}
|
|
38
52
|
async init() {
|
|
39
53
|
await this.checkConnection();
|
|
@@ -45,122 +59,168 @@ let ObjectStoreService = class ObjectStoreService {
|
|
|
45
59
|
async checkConnection() {
|
|
46
60
|
if (this.isReady)
|
|
47
61
|
return;
|
|
48
|
-
|
|
62
|
+
try {
|
|
63
|
+
this.logger.debug('Checking connection to S3 bucket', { bucket: this.bucket });
|
|
64
|
+
const command = new client_s3_1.HeadBucketCommand({ Bucket: this.bucket });
|
|
65
|
+
await this.s3Client.send(command);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
69
|
+
}
|
|
49
70
|
}
|
|
50
71
|
async put(filename, buffer, metadata = {}) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
try {
|
|
73
|
+
const params = {
|
|
74
|
+
Bucket: this.bucket,
|
|
75
|
+
Key: filename,
|
|
76
|
+
Body: buffer,
|
|
77
|
+
ContentLength: buffer.length,
|
|
78
|
+
ContentMD5: (0, node_crypto_1.createHash)('md5').update(buffer).digest('base64'),
|
|
79
|
+
};
|
|
80
|
+
if (metadata.fileName) {
|
|
81
|
+
params.Metadata = { filename: metadata.fileName };
|
|
82
|
+
}
|
|
83
|
+
if (metadata.mimeType) {
|
|
84
|
+
params.ContentType = metadata.mimeType;
|
|
85
|
+
}
|
|
86
|
+
this.logger.debug('Sending PUT request to S3', { params });
|
|
87
|
+
const command = new client_s3_1.PutObjectCommand(params);
|
|
88
|
+
return await this.s3Client.send(command);
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
92
|
+
}
|
|
60
93
|
}
|
|
61
94
|
async get(fileId, { mode }) {
|
|
62
|
-
|
|
63
|
-
|
|
95
|
+
this.logger.debug('Sending GET request to S3', { bucket: this.bucket, key: fileId });
|
|
96
|
+
const command = new client_s3_1.GetObjectCommand({
|
|
97
|
+
Bucket: this.bucket,
|
|
98
|
+
Key: fileId,
|
|
64
99
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
100
|
+
try {
|
|
101
|
+
const { Body: body } = await this.s3Client.send(command);
|
|
102
|
+
if (!body)
|
|
103
|
+
throw new n8n_workflow_1.UnexpectedError('Received empty response body');
|
|
104
|
+
if (mode === 'stream') {
|
|
105
|
+
if (body instanceof node_stream_1.Readable)
|
|
106
|
+
return body;
|
|
107
|
+
throw new n8n_workflow_1.UnexpectedError(`Expected stream but received ${typeof body}.`);
|
|
108
|
+
}
|
|
109
|
+
return await (0, utils_1.streamToBuffer)(body);
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
113
|
+
}
|
|
70
114
|
}
|
|
71
115
|
async getMetadata(fileId) {
|
|
72
|
-
|
|
73
|
-
|
|
116
|
+
try {
|
|
117
|
+
const command = new client_s3_1.HeadObjectCommand({
|
|
118
|
+
Bucket: this.bucket,
|
|
119
|
+
Key: fileId,
|
|
120
|
+
});
|
|
121
|
+
this.logger.debug('Sending HEAD request to S3', { bucket: this.bucket, key: fileId });
|
|
122
|
+
const response = await this.s3Client.send(command);
|
|
123
|
+
const headers = {};
|
|
124
|
+
if (response.ContentType)
|
|
125
|
+
headers['content-type'] = response.ContentType;
|
|
126
|
+
if (response.ContentLength)
|
|
127
|
+
headers['content-length'] = String(response.ContentLength);
|
|
128
|
+
if (response.ETag)
|
|
129
|
+
headers.etag = response.ETag;
|
|
130
|
+
if (response.LastModified)
|
|
131
|
+
headers['last-modified'] = response.LastModified.toUTCString();
|
|
132
|
+
if (response.Metadata) {
|
|
133
|
+
Object.entries(response.Metadata).forEach(([key, value]) => {
|
|
134
|
+
headers[`x-amz-meta-${key.toLowerCase()}`] = value;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return headers;
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
141
|
+
}
|
|
74
142
|
}
|
|
75
143
|
async deleteOne(fileId) {
|
|
76
|
-
|
|
144
|
+
try {
|
|
145
|
+
const command = new client_s3_1.DeleteObjectCommand({
|
|
146
|
+
Bucket: this.bucket,
|
|
147
|
+
Key: fileId,
|
|
148
|
+
});
|
|
149
|
+
this.logger.debug('Sending DELETE request to S3', { bucket: this.bucket, key: fileId });
|
|
150
|
+
return await this.s3Client.send(command);
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
154
|
+
}
|
|
77
155
|
}
|
|
78
156
|
async deleteMany(prefix) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
157
|
+
try {
|
|
158
|
+
const objects = await this.list(prefix);
|
|
159
|
+
if (objects.length === 0)
|
|
160
|
+
return;
|
|
161
|
+
const params = {
|
|
162
|
+
Bucket: this.bucket,
|
|
163
|
+
Delete: {
|
|
164
|
+
Objects: objects.map(({ key }) => ({ Key: key })),
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
this.logger.debug('Sending DELETE MANY request to S3', {
|
|
168
|
+
bucket: this.bucket,
|
|
169
|
+
objectCount: objects.length,
|
|
170
|
+
});
|
|
171
|
+
const command = new client_s3_1.DeleteObjectsCommand(params);
|
|
172
|
+
return await this.s3Client.send(command);
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
176
|
+
}
|
|
90
177
|
}
|
|
91
178
|
async list(prefix) {
|
|
92
179
|
const items = [];
|
|
93
|
-
let isTruncated;
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const qs = { 'list-type': 2, prefix };
|
|
106
|
-
if (nextPageToken)
|
|
107
|
-
qs['continuation-token'] = nextPageToken;
|
|
108
|
-
const { data } = await this.request('GET', '', { qs });
|
|
109
|
-
if (typeof data !== 'string') {
|
|
110
|
-
throw new TypeError(`Expected XML string but received ${typeof data}`);
|
|
111
|
-
}
|
|
112
|
-
const { listBucketResult: page } = await (0, utils_1.parseXml)(data);
|
|
113
|
-
if (!page.contents)
|
|
114
|
-
return { ...page, contents: [] };
|
|
115
|
-
if (!Array.isArray(page.contents))
|
|
116
|
-
page.contents = [page.contents];
|
|
117
|
-
page.contents.forEach((item) => {
|
|
118
|
-
Object.setPrototypeOf(item, Object.prototype);
|
|
119
|
-
});
|
|
120
|
-
return page;
|
|
121
|
-
}
|
|
122
|
-
async request(method, rawPath = '', { qs, headers, body, responseType } = {}) {
|
|
123
|
-
const url = new URL(this.baseUrl);
|
|
124
|
-
if (rawPath && rawPath !== '/') {
|
|
125
|
-
url.pathname = `${url.pathname}/${rawPath}`;
|
|
180
|
+
let isTruncated = true;
|
|
181
|
+
let continuationToken;
|
|
182
|
+
try {
|
|
183
|
+
while (isTruncated) {
|
|
184
|
+
const listPage = await this.getListPage(prefix, continuationToken);
|
|
185
|
+
if (listPage.contents?.length > 0) {
|
|
186
|
+
items.push(...listPage.contents);
|
|
187
|
+
}
|
|
188
|
+
isTruncated = listPage.isTruncated;
|
|
189
|
+
continuationToken = listPage.nextContinuationToken;
|
|
190
|
+
}
|
|
191
|
+
return items;
|
|
126
192
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
service: 's3',
|
|
133
|
-
region: this.s3Config.bucket.region,
|
|
134
|
-
host: this.s3Config.host,
|
|
135
|
-
path: `${url.pathname}${url.search}`,
|
|
136
|
-
};
|
|
137
|
-
if (headers)
|
|
138
|
-
optionsToSign.headers = headers;
|
|
139
|
-
if (body)
|
|
140
|
-
optionsToSign.body = body;
|
|
141
|
-
const { accessKey, accessSecret } = this.s3Config.credentials;
|
|
142
|
-
const signedOptions = (0, aws4_1.sign)(optionsToSign, {
|
|
143
|
-
accessKeyId: accessKey,
|
|
144
|
-
secretAccessKey: accessSecret,
|
|
145
|
-
});
|
|
146
|
-
const config = {
|
|
147
|
-
method,
|
|
148
|
-
url: url.toString(),
|
|
149
|
-
headers: signedOptions.headers,
|
|
150
|
-
};
|
|
151
|
-
if (body)
|
|
152
|
-
config.data = body;
|
|
153
|
-
if (responseType)
|
|
154
|
-
config.responseType = responseType;
|
|
193
|
+
catch (e) {
|
|
194
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
async getListPage(prefix, continuationToken) {
|
|
155
198
|
try {
|
|
156
|
-
|
|
157
|
-
|
|
199
|
+
const params = {
|
|
200
|
+
Bucket: this.bucket,
|
|
201
|
+
Prefix: prefix,
|
|
202
|
+
};
|
|
203
|
+
if (continuationToken) {
|
|
204
|
+
params.ContinuationToken = continuationToken;
|
|
205
|
+
}
|
|
206
|
+
this.logger.debug('Sending list request to S3', { bucket: this.bucket, prefix });
|
|
207
|
+
const command = new client_s3_1.ListObjectsV2Command(params);
|
|
208
|
+
const response = await this.s3Client.send(command);
|
|
209
|
+
const contents = response.Contents?.map((item) => ({
|
|
210
|
+
key: item.Key ?? '',
|
|
211
|
+
lastModified: item.LastModified?.toISOString() ?? '',
|
|
212
|
+
eTag: item.ETag ?? '',
|
|
213
|
+
size: item.Size ?? 0,
|
|
214
|
+
storageClass: item.StorageClass ?? '',
|
|
215
|
+
})) ?? [];
|
|
216
|
+
return {
|
|
217
|
+
contents,
|
|
218
|
+
isTruncated: response.IsTruncated ?? false,
|
|
219
|
+
nextContinuationToken: response.NextContinuationToken,
|
|
220
|
+
};
|
|
158
221
|
}
|
|
159
222
|
catch (e) {
|
|
160
|
-
|
|
161
|
-
const message = `Request to S3 failed: ${error.message}`;
|
|
162
|
-
this.logger.error(message, { config });
|
|
163
|
-
throw new n8n_workflow_1.ApplicationError(message, { cause: error, extra: { config } });
|
|
223
|
+
throw new n8n_workflow_1.UnexpectedError('Request to S3 failed', { cause: e });
|
|
164
224
|
}
|
|
165
225
|
}
|
|
166
226
|
};
|
|
@@ -168,6 +228,6 @@ exports.ObjectStoreService = ObjectStoreService;
|
|
|
168
228
|
exports.ObjectStoreService = ObjectStoreService = __decorate([
|
|
169
229
|
(0, di_1.Service)(),
|
|
170
230
|
__metadata("design:paramtypes", [logger_1.Logger,
|
|
171
|
-
|
|
231
|
+
object_store_config_1.ObjectStoreConfig])
|
|
172
232
|
], ObjectStoreService);
|
|
173
233
|
//# sourceMappingURL=object-store.service.ee.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-store.service.ee.js","sourceRoot":"","sources":["../../../src/binary-data/object-store/object-store.service.ee.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-store.service.ee.js","sourceRoot":"","sources":["../../../src/binary-data/object-store/object-store.service.ee.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA,kDAS4B;AAC5B,gCAAkC;AAClC,+CAA+C;AAC/C,6CAAyC;AACzC,6CAAuC;AAEvC,6CAA0C;AAE1C,+DAA0D;AAG1D,oCAA0C;AAGnC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAO9B,YACkB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|
2
1
|
import type { BinaryData } from '../types';
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
prefix: string;
|
|
7
|
-
keyCount: number;
|
|
8
|
-
maxKeys: number;
|
|
9
|
-
isTruncated: boolean;
|
|
10
|
-
nextContinuationToken?: string;
|
|
11
|
-
contents?: Item | Item[];
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
type Item = {
|
|
15
|
-
key: string;
|
|
16
|
-
lastModified: string;
|
|
17
|
-
eTag: string;
|
|
18
|
-
size: number;
|
|
19
|
-
storageClass: string;
|
|
20
|
-
};
|
|
21
|
-
export type ListPage = Omit<RawListPage['listBucketResult'], 'contents'> & {
|
|
22
|
-
contents: Item[];
|
|
23
|
-
};
|
|
24
|
-
export type RequestOptions = {
|
|
25
|
-
qs?: Record<string, string | number>;
|
|
26
|
-
headers?: Record<string, string | number>;
|
|
27
|
-
body?: string | Buffer;
|
|
28
|
-
responseType?: ResponseType;
|
|
29
|
-
};
|
|
30
|
-
export type MetadataResponseHeaders = AxiosResponseHeaders & {
|
|
31
|
-
'content-length': string;
|
|
2
|
+
export type MetadataResponseHeaders = Record<string, string> & {
|
|
3
|
+
'content-length'?: string;
|
|
32
4
|
'content-type'?: string;
|
|
33
5
|
'x-amz-meta-filename'?: string;
|
|
6
|
+
etag?: string;
|
|
7
|
+
'last-modified'?: string;
|
|
34
8
|
} & BinaryData.PreWriteMetadata;
|
|
35
|
-
export {};
|
|
@@ -5,4 +5,5 @@ export declare function areConfigModes(modes: string[]): modes is BinaryData.Con
|
|
|
5
5
|
export declare function isStoredMode(mode: string): mode is BinaryData.StoredMode;
|
|
6
6
|
export declare function assertDir(dir: string): Promise<void>;
|
|
7
7
|
export declare function doesNotExist(dir: string): Promise<boolean>;
|
|
8
|
+
export declare function streamToBuffer(stream: Readable): Promise<Buffer>;
|
|
8
9
|
export declare function binaryToBuffer(body: Buffer | Readable): Promise<Buffer>;
|
|
@@ -8,8 +8,9 @@ exports.areConfigModes = areConfigModes;
|
|
|
8
8
|
exports.isStoredMode = isStoredMode;
|
|
9
9
|
exports.assertDir = assertDir;
|
|
10
10
|
exports.doesNotExist = doesNotExist;
|
|
11
|
+
exports.streamToBuffer = streamToBuffer;
|
|
11
12
|
exports.binaryToBuffer = binaryToBuffer;
|
|
12
|
-
const
|
|
13
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
13
14
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
14
15
|
exports.CONFIG_MODES = ['default', 'filesystem', 's3'];
|
|
15
16
|
const STORED_MODES = ['filesystem', 'filesystem-v2', 's3'];
|
|
@@ -36,18 +37,22 @@ async function doesNotExist(dir) {
|
|
|
36
37
|
return true;
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
|
-
async function
|
|
40
|
-
if (Buffer.isBuffer(body))
|
|
41
|
-
return body;
|
|
40
|
+
async function streamToBuffer(stream) {
|
|
42
41
|
return await new Promise((resolve, reject) => {
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const chunks = [];
|
|
43
|
+
stream.on('data', (chunk) => chunks.push(chunk));
|
|
44
|
+
stream.on('end', () => resolve(Buffer.concat(chunks)));
|
|
45
|
+
stream.once('error', (cause) => {
|
|
45
46
|
if ('code' in cause && cause.code === 'Z_DATA_ERROR')
|
|
46
|
-
reject(new
|
|
47
|
+
reject(new n8n_workflow_1.UnexpectedError('Failed to decompress response', { cause }));
|
|
47
48
|
else
|
|
48
49
|
reject(cause);
|
|
49
|
-
})
|
|
50
|
-
.pipe((0, concat_stream_1.default)(resolve));
|
|
50
|
+
});
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
+
async function binaryToBuffer(body) {
|
|
54
|
+
if (Buffer.isBuffer(body))
|
|
55
|
+
return body;
|
|
56
|
+
return await streamToBuffer(body);
|
|
57
|
+
}
|
|
53
58
|
//# sourceMappingURL=utils.js.map
|