artifact-engine 1.2.0 → 1.3.0
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/Engine/artifactEngine.d.ts +12 -12
- package/Engine/artifactEngine.js +166 -166
- package/Engine/artifactEngineOptions.d.ts +8 -8
- package/Engine/artifactEngineOptions.js +13 -15
- package/Engine/cilogger.d.ts +6 -6
- package/Engine/cilogger.js +44 -46
- package/Engine/index.d.ts +2 -2
- package/Engine/index.js +6 -8
- package/Engine/logger.d.ts +13 -13
- package/Engine/logger.js +109 -112
- package/Engine/worker.d.ts +10 -10
- package/Engine/worker.js +49 -51
- package/Models/artifactDownloadTicket.d.ts +11 -11
- package/Models/artifactDownloadTicket.js +5 -7
- package/Models/artifactItem.d.ts +12 -12
- package/Models/artifactItem.js +8 -10
- package/Models/artifactprovider.d.ts +10 -11
- package/Models/artifactprovider.js +2 -3
- package/Models/constants.d.ts +3 -3
- package/Models/constants.js +6 -8
- package/Models/index.d.ts +6 -6
- package/Models/index.js +12 -14
- package/Models/itemType.d.ts +5 -5
- package/Models/itemType.js +8 -10
- package/Models/ticketState.d.ts +7 -7
- package/Models/ticketState.js +10 -12
- package/Providers/filesystemProvider.d.ts +14 -15
- package/Providers/filesystemProvider.js +123 -123
- package/Providers/index.d.ts +4 -4
- package/Providers/index.js +10 -12
- package/Providers/stubProvider.d.ts +20 -21
- package/Providers/stubProvider.js +85 -88
- package/Providers/typed-rest-client/Handlers.d.ts +4 -4
- package/Providers/typed-rest-client/Handlers.js +10 -12
- package/Providers/typed-rest-client/HttpClient.d.ts +84 -77
- package/Providers/typed-rest-client/HttpClient.js +351 -328
- package/Providers/typed-rest-client/Index.d.ts +0 -1
- package/Providers/typed-rest-client/Index.js +2 -3
- package/Providers/typed-rest-client/Interfaces.d.ts +38 -38
- package/Providers/typed-rest-client/Interfaces.js +3 -4
- package/Providers/typed-rest-client/RestClient.d.ts +73 -27
- package/Providers/typed-rest-client/RestClient.js +186 -134
- package/Providers/typed-rest-client/Util.d.ts +7 -1
- package/Providers/typed-rest-client/Util.js +24 -18
- package/Providers/typed-rest-client/handlers/basiccreds.d.ts +9 -9
- package/Providers/typed-rest-client/handlers/basiccreds.js +23 -20
- package/Providers/typed-rest-client/handlers/bearertoken.d.ts +8 -8
- package/Providers/typed-rest-client/handlers/bearertoken.js +22 -19
- package/Providers/typed-rest-client/handlers/ntlm.d.ts +13 -13
- package/Providers/typed-rest-client/handlers/ntlm.js +115 -96
- package/Providers/typed-rest-client/handlers/personalaccesstoken.d.ts +8 -8
- package/Providers/typed-rest-client/handlers/personalaccesstoken.js +22 -19
- package/Providers/typed-rest-client/opensource/node-http-ntlm/readme.txt +6 -0
- package/Providers/webClient.d.ts +8 -8
- package/Providers/webClient.js +60 -60
- package/Providers/webClientFactory.d.ts +5 -5
- package/Providers/webClientFactory.js +59 -55
- package/Providers/webProvider.d.ts +21 -22
- package/Providers/webProvider.js +120 -116
- package/Providers/zipProvider.d.ts +15 -16
- package/Providers/zipProvider.js +53 -55
- package/Store/artifactItemStore.d.ts +18 -18
- package/Store/artifactItemStore.js +94 -96
- package/Store/index.d.ts +1 -1
- package/Store/index.js +4 -6
- package/Strings/resources.resjson/de-DE/resources.resjson +11 -11
- package/Strings/resources.resjson/en-US/resources.resjson +11 -11
- package/Strings/resources.resjson/es-ES/resources.resjson +11 -11
- package/Strings/resources.resjson/fr-FR/resources.resjson +11 -11
- package/Strings/resources.resjson/it-IT/resources.resjson +11 -11
- package/Strings/resources.resjson/ja-JP/resources.resjson +11 -11
- package/Strings/resources.resjson/ko-KR/resources.resjson +11 -11
- package/Strings/resources.resjson/ru-RU/resources.resjson +11 -11
- package/Strings/resources.resjson/zh-CN/resources.resjson +11 -11
- package/Strings/resources.resjson/zh-TW/resources.resjson +11 -11
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
|
@@ -1,55 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
options =
|
|
10
|
-
options
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!options.proxy || !options.proxy.proxyUrl) {
|
|
16
|
-
if (global['_vsts_task_lib_proxy']) {
|
|
17
|
-
let proxyFromEnv = {
|
|
18
|
-
proxyUrl: global['_vsts_task_lib_proxy_url'],
|
|
19
|
-
proxyUsername: global['_vsts_task_lib_proxy_username'],
|
|
20
|
-
proxyPassword: this._readTaskLibSecrets(global['_vsts_task_lib_proxy_password']),
|
|
21
|
-
proxyBypassHosts: JSON.parse(global['_vsts_task_lib_proxy_bypass'] || "[]"),
|
|
22
|
-
};
|
|
23
|
-
options.proxy = proxyFromEnv;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const crypto = require("crypto");
|
|
5
|
+
const webClient_1 = require("./webClient");
|
|
6
|
+
class WebClientFactory {
|
|
7
|
+
static getClient(handlers, options) {
|
|
8
|
+
options = options || {};
|
|
9
|
+
options.keepAlive = true;
|
|
10
|
+
this.initializeProxy(options);
|
|
11
|
+
return new webClient_1.WebClient(handlers, options);
|
|
12
|
+
}
|
|
13
|
+
static initializeProxy(options) {
|
|
14
|
+
// try get proxy setting from environment variable set by azure-pipelines-task-lib if there is no proxy setting in the options
|
|
15
|
+
if (!options.proxy || !options.proxy.proxyUrl) {
|
|
16
|
+
if (global['_vsts_task_lib_proxy']) {
|
|
17
|
+
let proxyFromEnv = {
|
|
18
|
+
proxyUrl: global['_vsts_task_lib_proxy_url'],
|
|
19
|
+
proxyUsername: global['_vsts_task_lib_proxy_username'],
|
|
20
|
+
proxyPassword: this._readTaskLibSecrets(global['_vsts_task_lib_proxy_password']),
|
|
21
|
+
proxyBypassHosts: JSON.parse(global['_vsts_task_lib_proxy_bypass'] || "[]"),
|
|
22
|
+
};
|
|
23
|
+
options.proxy = proxyFromEnv;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// try get cert setting from environment variable set by azure-pipelines-task-lib if there is no cert setting in the options
|
|
27
|
+
if (!options.cert) {
|
|
28
|
+
if (global['_vsts_task_lib_cert']) {
|
|
29
|
+
let certFromEnv = {
|
|
30
|
+
caFile: global['_vsts_task_lib_cert_ca'],
|
|
31
|
+
certFile: global['_vsts_task_lib_cert_clientcert'],
|
|
32
|
+
keyFile: global['_vsts_task_lib_cert_key'],
|
|
33
|
+
passphrase: this._readTaskLibSecrets(global['_vsts_task_lib_cert_passphrase']),
|
|
34
|
+
};
|
|
35
|
+
options.cert = certFromEnv;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// try get ignore SSL error setting from environment variable set by azure-pipelines-task-lib if there is no ignore SSL error setting in the options
|
|
39
|
+
if (!options.ignoreSslError) {
|
|
40
|
+
options.ignoreSslError = !!global['_vsts_task_lib_skip_cert_validation'];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
static _readTaskLibSecrets(lookupKey) {
|
|
44
|
+
// the lookupKey should has following format
|
|
45
|
+
// base64encoded<keyFilePath>:base64encoded<encryptedContent>
|
|
46
|
+
if (lookupKey && lookupKey.indexOf(':') > 0) {
|
|
47
|
+
let lookupInfo = lookupKey.split(':', 2);
|
|
48
|
+
// file contains encryption key
|
|
49
|
+
let keyFile = new Buffer(lookupInfo[0], 'base64').toString('utf8');
|
|
50
|
+
let encryptKey = new Buffer(fs.readFileSync(keyFile, 'utf8'), 'base64');
|
|
51
|
+
let encryptedContent = new Buffer(lookupInfo[1], 'base64').toString('utf8');
|
|
52
|
+
let decipher = crypto.createDecipher("aes-256-ctr", encryptKey);
|
|
53
|
+
let decryptedContent = decipher.update(encryptedContent, 'hex', 'utf8');
|
|
54
|
+
decryptedContent += decipher.final('utf8');
|
|
55
|
+
return decryptedContent;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.WebClientFactory = WebClientFactory;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
private
|
|
16
|
-
private
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
1
|
+
import * as stream from 'stream';
|
|
2
|
+
import { ArtifactItem, IArtifactProvider } from '../Models';
|
|
3
|
+
import { ArtifactItemStore } from '../Store/artifactItemStore';
|
|
4
|
+
import { WebClient } from './webClient';
|
|
5
|
+
import { IRequestHandler, IRequestOptions } from './typed-rest-client/Interfaces';
|
|
6
|
+
export declare class WebProvider implements IArtifactProvider {
|
|
7
|
+
artifactItemStore: ArtifactItemStore;
|
|
8
|
+
constructor(rootItemsLocation: any, templateFile: string, variables: any, handler: IRequestHandler, requestOptions?: IRequestOptions);
|
|
9
|
+
getRootItems(): Promise<ArtifactItem[]>;
|
|
10
|
+
getArtifactItems(artifactItem: ArtifactItem): Promise<ArtifactItem[]>;
|
|
11
|
+
getArtifactItem(artifactItem: ArtifactItem): Promise<NodeJS.ReadableStream>;
|
|
12
|
+
putArtifactItem(item: ArtifactItem, readStream: stream.Readable): Promise<ArtifactItem>;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
private getItems(itemsUrl, contentType);
|
|
15
|
+
private getTemplateFilePath();
|
|
16
|
+
private extend(target, source);
|
|
17
|
+
private rootItemsLocation;
|
|
18
|
+
private templateFile;
|
|
19
|
+
private variables;
|
|
20
|
+
webClient: WebClient;
|
|
21
|
+
}
|
package/Providers/webProvider.js
CHANGED
|
@@ -1,116 +1,120 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
rootItem.
|
|
22
|
-
rootItem.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1");
|
|
40
|
-
this.webClient.get(itemUrl, contentType ? { 'Accept': contentType } : undefined).then((res) => {
|
|
41
|
-
res.message.on('data', (chunk) => {
|
|
42
|
-
downloadSize += chunk.length;
|
|
43
|
-
});
|
|
44
|
-
res.message.on('end', () => {
|
|
45
|
-
this.artifactItemStore.updateDownloadSize(artifactItem, downloadSize);
|
|
46
|
-
});
|
|
47
|
-
res.message.on('error', (error) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const zlib = require("zlib");
|
|
6
|
+
const Models_1 = require("../Models");
|
|
7
|
+
const logger_1 = require("../Engine/logger");
|
|
8
|
+
const webClientFactory_1 = require("./webClientFactory");
|
|
9
|
+
var handlebars = require('handlebars');
|
|
10
|
+
var tl = require('azure-pipelines-task-lib/task');
|
|
11
|
+
class WebProvider {
|
|
12
|
+
constructor(rootItemsLocation, templateFile, variables, handler, requestOptions) {
|
|
13
|
+
this.rootItemsLocation = rootItemsLocation;
|
|
14
|
+
this.templateFile = templateFile;
|
|
15
|
+
this.webClient = webClientFactory_1.WebClientFactory.getClient([handler], requestOptions);
|
|
16
|
+
this.variables = variables;
|
|
17
|
+
}
|
|
18
|
+
getRootItems() {
|
|
19
|
+
var rootItem = new Models_1.ArtifactItem();
|
|
20
|
+
rootItem.metadata = { downloadUrl: this.rootItemsLocation };
|
|
21
|
+
rootItem.path = '';
|
|
22
|
+
rootItem.itemType = Models_1.ItemType.Folder;
|
|
23
|
+
return Promise.resolve([rootItem]);
|
|
24
|
+
}
|
|
25
|
+
getArtifactItems(artifactItem) {
|
|
26
|
+
var itemsUrl = artifactItem.metadata["downloadUrl"];
|
|
27
|
+
var contentType = artifactItem.contentType;
|
|
28
|
+
return this.getItems(itemsUrl, contentType);
|
|
29
|
+
}
|
|
30
|
+
getArtifactItem(artifactItem) {
|
|
31
|
+
var promise = new Promise((resolve, reject) => {
|
|
32
|
+
if (!artifactItem.metadata || !artifactItem.metadata['downloadUrl']) {
|
|
33
|
+
reject("No downloadUrl available to download the item.");
|
|
34
|
+
}
|
|
35
|
+
var downloadSize = 0;
|
|
36
|
+
var contentType = artifactItem.contentType;
|
|
37
|
+
var itemUrl = artifactItem.metadata['downloadUrl'];
|
|
38
|
+
var zipStream = null;
|
|
39
|
+
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1");
|
|
40
|
+
this.webClient.get(itemUrl, contentType ? { 'Accept': contentType } : undefined).then((res) => {
|
|
41
|
+
res.message.on('data', (chunk) => {
|
|
42
|
+
downloadSize += chunk.length;
|
|
43
|
+
});
|
|
44
|
+
res.message.on('end', () => {
|
|
45
|
+
this.artifactItemStore.updateDownloadSize(artifactItem, downloadSize);
|
|
46
|
+
});
|
|
47
|
+
res.message.on('error', (error) => {
|
|
48
|
+
if (zipStream) {
|
|
49
|
+
zipStream.destroy(error);
|
|
50
|
+
logger_1.Logger.logMessage(error);
|
|
51
|
+
}
|
|
52
|
+
reject(error);
|
|
53
|
+
});
|
|
54
|
+
if (res.message.headers['content-encoding'] === 'gzip') {
|
|
55
|
+
try {
|
|
56
|
+
zipStream = zlib.createUnzip();
|
|
57
|
+
resolve(res.message.pipe(zipStream));
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
reject(err);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
resolve(res.message);
|
|
65
|
+
}
|
|
66
|
+
}, (reason) => {
|
|
67
|
+
reject(reason);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
return promise;
|
|
71
|
+
}
|
|
72
|
+
putArtifactItem(item, readStream) {
|
|
73
|
+
throw new Error("Not implemented");
|
|
74
|
+
}
|
|
75
|
+
dispose() {
|
|
76
|
+
this.webClient.dispose();
|
|
77
|
+
}
|
|
78
|
+
getItems(itemsUrl, contentType) {
|
|
79
|
+
var promise = new Promise((resolve, reject) => {
|
|
80
|
+
itemsUrl = itemsUrl.replace(/([^:]\/)\/+/g, "$1");
|
|
81
|
+
this.webClient.get(itemsUrl, contentType ? { 'Accept': contentType } : { 'Accept': 'application/json' }).then((res) => {
|
|
82
|
+
res.readBody().then((body) => {
|
|
83
|
+
fs.readFile(this.getTemplateFilePath(), 'utf8', (err, templateFileContent) => {
|
|
84
|
+
if (err) {
|
|
85
|
+
logger_1.Logger.logMessage(err ? JSON.stringify(err) : "");
|
|
86
|
+
reject(err);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
var template = handlebars.compile(templateFileContent);
|
|
90
|
+
var response = JSON.parse(body);
|
|
91
|
+
var context = this.extend(response, this.variables);
|
|
92
|
+
var result = template(context);
|
|
93
|
+
var items = JSON.parse(result);
|
|
94
|
+
resolve(items);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
logger_1.Logger.logMessage(tl.loc("FailedToParseResponse", body, error));
|
|
98
|
+
reject(error);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}, (err) => {
|
|
102
|
+
reject(err);
|
|
103
|
+
});
|
|
104
|
+
}, (err) => {
|
|
105
|
+
reject(err);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
return promise;
|
|
109
|
+
}
|
|
110
|
+
getTemplateFilePath() {
|
|
111
|
+
return path.isAbsolute(this.templateFile) ? this.templateFile : path.join(__dirname, this.templateFile);
|
|
112
|
+
}
|
|
113
|
+
extend(target, source) {
|
|
114
|
+
for (var prop in source) {
|
|
115
|
+
target[prop] = source[prop];
|
|
116
|
+
}
|
|
117
|
+
return target;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.WebProvider = WebProvider;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
1
|
+
import { ArtifactItemStore } from '../Store/artifactItemStore';
|
|
2
|
+
import { ArtifactItem, IArtifactProvider } from '../Models';
|
|
3
|
+
import { WebClient } from './webClient';
|
|
4
|
+
import { IRequestHandler, IRequestOptions } from './typed-rest-client/Interfaces';
|
|
5
|
+
export declare class ZipProvider implements IArtifactProvider {
|
|
6
|
+
artifactItemStore: ArtifactItemStore;
|
|
7
|
+
constructor(zipLocation: any, handler: IRequestHandler, requestOptions?: IRequestOptions);
|
|
8
|
+
getRootItems(): Promise<ArtifactItem[]>;
|
|
9
|
+
getArtifactItems(artifactItem: ArtifactItem): Promise<ArtifactItem[]>;
|
|
10
|
+
getArtifactItem(artifactItem: ArtifactItem): Promise<NodeJS.ReadableStream>;
|
|
11
|
+
putArtifactItem(artifactItem: ArtifactItem, stream: NodeJS.ReadableStream): Promise<ArtifactItem>;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
private zipLocation;
|
|
14
|
+
webClient: WebClient;
|
|
15
|
+
}
|
package/Providers/zipProvider.js
CHANGED
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
rootItem.
|
|
14
|
-
rootItem.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
itemUrl
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
exports.ZipProvider = ZipProvider;
|
|
55
|
-
//# sourceMappingURL=zipProvider.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const Models_1 = require("../Models");
|
|
4
|
+
const factory = require("./webClientFactory");
|
|
5
|
+
class ZipProvider {
|
|
6
|
+
constructor(zipLocation, handler, requestOptions) {
|
|
7
|
+
this.zipLocation = zipLocation;
|
|
8
|
+
this.webClient = factory.WebClientFactory.getClient([handler], requestOptions);
|
|
9
|
+
}
|
|
10
|
+
getRootItems() {
|
|
11
|
+
var rootItem = new Models_1.ArtifactItem();
|
|
12
|
+
rootItem.metadata = { downloadUrl: this.zipLocation };
|
|
13
|
+
rootItem.path = '';
|
|
14
|
+
rootItem.itemType = Models_1.ItemType.File;
|
|
15
|
+
return Promise.resolve([rootItem]);
|
|
16
|
+
}
|
|
17
|
+
getArtifactItems(artifactItem) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
getArtifactItem(artifactItem) {
|
|
21
|
+
var promise = new Promise((resolve, reject) => {
|
|
22
|
+
if (!artifactItem.metadata || !artifactItem.metadata['downloadUrl']) {
|
|
23
|
+
reject("No downloadUrl available to download the item.");
|
|
24
|
+
}
|
|
25
|
+
var downloadSize = 0;
|
|
26
|
+
var itemUrl = artifactItem.metadata['downloadUrl'];
|
|
27
|
+
itemUrl = itemUrl.replace(/([^:]\/)\/+/g, "$1");
|
|
28
|
+
this.webClient.get(itemUrl).then((res) => {
|
|
29
|
+
res.message.on('data', (chunk) => {
|
|
30
|
+
if (chunk) {
|
|
31
|
+
downloadSize += chunk.length;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
res.message.on('end', () => {
|
|
35
|
+
this.artifactItemStore.updateDownloadSize(artifactItem, downloadSize);
|
|
36
|
+
});
|
|
37
|
+
res.message.on('error', (error) => {
|
|
38
|
+
reject(error);
|
|
39
|
+
});
|
|
40
|
+
resolve(res.message);
|
|
41
|
+
}, (reason) => {
|
|
42
|
+
reject(reason);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
return promise;
|
|
46
|
+
}
|
|
47
|
+
putArtifactItem(artifactItem, stream) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ZipProvider = ZipProvider;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as models from "../Models";
|
|
2
|
-
export declare class ArtifactItemStore {
|
|
3
|
-
_downloadTickets: models.ArtifactDownloadTicket[];
|
|
4
|
-
_hasDownloadFailed: boolean;
|
|
5
|
-
addItem(item: models.ArtifactItem): void;
|
|
6
|
-
addItems(items: models.ArtifactItem[]): void;
|
|
7
|
-
getTickets(): models.ArtifactDownloadTicket[];
|
|
8
|
-
itemsPendingProcessing(): boolean;
|
|
9
|
-
getNextItemToProcess(): models.ArtifactItem;
|
|
10
|
-
updateState(item: models.ArtifactItem, state: models.TicketState): void;
|
|
11
|
-
getRootLocation(): string;
|
|
12
|
-
increaseRetryCount(item: models.ArtifactItem): void;
|
|
13
|
-
updateDownloadSize(item: models.ArtifactItem, downloadSizeInBytes: number): void;
|
|
14
|
-
updateFileSize(item: models.ArtifactItem, fileSizeInBytes: number): void;
|
|
15
|
-
size(): number;
|
|
16
|
-
flush(): void;
|
|
17
|
-
hasDownloadFailed(): boolean;
|
|
18
|
-
}
|
|
1
|
+
import * as models from "../Models";
|
|
2
|
+
export declare class ArtifactItemStore {
|
|
3
|
+
_downloadTickets: models.ArtifactDownloadTicket[];
|
|
4
|
+
_hasDownloadFailed: boolean;
|
|
5
|
+
addItem(item: models.ArtifactItem): void;
|
|
6
|
+
addItems(items: models.ArtifactItem[]): void;
|
|
7
|
+
getTickets(): models.ArtifactDownloadTicket[];
|
|
8
|
+
itemsPendingProcessing(): boolean;
|
|
9
|
+
getNextItemToProcess(): models.ArtifactItem;
|
|
10
|
+
updateState(item: models.ArtifactItem, state: models.TicketState): void;
|
|
11
|
+
getRootLocation(): string;
|
|
12
|
+
increaseRetryCount(item: models.ArtifactItem): void;
|
|
13
|
+
updateDownloadSize(item: models.ArtifactItem, downloadSizeInBytes: number): void;
|
|
14
|
+
updateFileSize(item: models.ArtifactItem, fileSizeInBytes: number): void;
|
|
15
|
+
size(): number;
|
|
16
|
+
flush(): void;
|
|
17
|
+
hasDownloadFailed(): boolean;
|
|
18
|
+
}
|