suanpan_node_sdk 2.2.3 → 2.2.5-beta
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/api/index.d.ts +10 -10
- package/dist/api/index.js +56 -52
- package/dist/api/index.js.map +1 -1
- package/dist/core/common/constant.d.ts +6 -6
- package/dist/core/common/constant.js +50 -50
- package/dist/core/common/exec.d.ts +1 -1
- package/dist/core/common/exec.js +53 -53
- package/dist/core/common/log.d.ts +3 -3
- package/dist/core/common/log.js +15 -15
- package/dist/core/event/index.d.ts +6 -6
- package/dist/core/event/index.js +10 -10
- package/dist/core/logkit/index.d.ts +33 -33
- package/dist/core/logkit/index.js +125 -125
- package/dist/core/logkit/index.js.map +1 -1
- package/dist/core/message/channel.d.ts +7 -7
- package/dist/core/message/channel.js +2 -2
- package/dist/core/message/channelFactory.d.ts +4 -4
- package/dist/core/message/channelFactory.js +10 -10
- package/dist/core/message/index.d.ts +6 -6
- package/dist/core/message/index.js +22 -18
- package/dist/core/message/index.js.map +1 -1
- package/dist/core/message/message.d.ts +19 -19
- package/dist/core/message/message.js +59 -59
- package/dist/core/message/message.js.map +1 -1
- package/dist/core/message/messageBuilder.d.ts +12 -12
- package/dist/core/message/messageBuilder.js +50 -50
- package/dist/core/message/messageBuilder.js.map +1 -1
- package/dist/core/message/messageChain.d.ts +9 -9
- package/dist/core/message/messageChain.js +29 -29
- package/dist/core/message/messageListener.d.ts +4 -4
- package/dist/core/message/messageListener.js +11 -11
- package/dist/core/message/mq/index.d.ts +9 -9
- package/dist/core/message/mq/index.js +50 -50
- package/dist/core/message/mq/redis.d.ts +12 -12
- package/dist/core/message/mq/redis.js +101 -97
- package/dist/core/message/mq/redis.js.map +1 -1
- package/dist/core/parameter/commandArgs.d.ts +2 -2
- package/dist/core/parameter/commandArgs.js +22 -22
- package/dist/core/parameter/commandArgs.js.map +1 -1
- package/dist/core/parameter/environment.d.ts +86 -86
- package/dist/core/parameter/environment.js +103 -103
- package/dist/core/parameter/index.d.ts +7 -7
- package/dist/core/parameter/index.js +33 -33
- package/dist/core/script/script-babel/babel.d.ts +1 -1
- package/dist/core/script/script-babel/babel.js +23 -23
- package/dist/core/script/script-babel/plugin.d.ts +7 -7
- package/dist/core/script/script-babel/plugin.js +16 -16
- package/dist/core/script/script-constant.d.ts +36 -36
- package/dist/core/script/script-constant.js +70 -70
- package/dist/core/script/script-context.d.ts +1 -1
- package/dist/core/script/script-context.js +295 -295
- package/dist/core/script/script-front.d.ts +1 -1
- package/dist/core/script/script-front.js +201 -201
- package/dist/core/script/script-insert.d.ts +18 -18
- package/dist/core/script/script-insert.js +43 -43
- package/dist/core/script/script-manager.d.ts +74 -74
- package/dist/core/script/script-manager.js +261 -261
- package/dist/core/script/script-storage.d.ts +22 -22
- package/dist/core/script/script-storage.js +241 -241
- package/dist/core/script/script-support.d.ts +11 -11
- package/dist/core/script/script-support.js +140 -140
- package/dist/core/script/script-template.d.ts +1 -1
- package/dist/core/script/script-template.js +6 -6
- package/dist/core/service/port.d.ts +5 -5
- package/dist/core/service/port.js +53 -53
- package/dist/core/service/port.js.map +1 -1
- package/dist/core/storage/index.d.ts +5 -5
- package/dist/core/storage/index.js +21 -17
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/minioStorage.d.ts +31 -28
- package/dist/core/storage/minioStorage.js +224 -209
- package/dist/core/storage/minioStorage.js.map +1 -1
- package/dist/core/storage/objectStorage.d.ts +23 -19
- package/dist/core/storage/objectStorage.js +3 -3
- package/dist/core/storage/ossStorage.d.ts +29 -26
- package/dist/core/storage/ossStorage.js +215 -193
- package/dist/core/storage/ossStorage.js.map +1 -1
- package/dist/core/storage/storageFlusher.d.ts +14 -14
- package/dist/core/storage/storageFlusher.js +54 -54
- package/dist/core/storage/storageLogger.d.ts +16 -16
- package/dist/core/storage/storageLogger.js +100 -100
- package/dist/core/storage/storageLogger.js.map +1 -1
- package/dist/core/storage/storagePath.d.ts +16 -16
- package/dist/core/storage/storagePath.js +49 -49
- package/dist/core/storage/wrapperStorage.d.ts +17 -17
- package/dist/core/storage/wrapperStorage.js +47 -47
- package/dist/core/storage/wrapperStorage.js.map +1 -1
- package/dist/core/utils/flusher.d.ts +18 -18
- package/dist/core/utils/flusher.js +66 -62
- package/dist/core/utils/flusher.js.map +1 -1
- package/dist/core/utils/http.d.ts +3 -3
- package/dist/core/utils/http.js +35 -35
- package/dist/core/utils/http.js.map +1 -1
- package/dist/core/utils/index.d.ts +57 -56
- package/dist/core/utils/index.js +247 -243
- package/dist/core/utils/index.js.map +1 -1
- package/dist/core/utils/number.d.ts +2 -2
- package/dist/core/utils/number.js +19 -19
- package/dist/core/utils/retry.d.ts +1 -1
- package/dist/core/utils/retry.js +34 -34
- package/dist/core/utils/retry.js.map +1 -1
- package/dist/core/utils/suanpan.d.ts +21 -20
- package/dist/core/utils/suanpan.js +103 -92
- package/dist/core/utils/suanpan.js.map +1 -1
- package/dist/core/web/app.d.ts +2 -2
- package/dist/core/web/app.js +38 -38
- package/dist/core/web/app.js.map +1 -1
- package/dist/core/web/server.d.ts +3 -3
- package/dist/core/web/server.js +64 -60
- package/dist/core/web/server.js.map +1 -1
- package/dist/main.d.ts +5 -5
- package/dist/main.js +28 -24
- package/dist/main.js.map +1 -1
- package/dist/types/conmonTypes.d.ts +21 -21
- package/dist/types/conmonTypes.js +16 -16
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +19 -15
- package/dist/types/index.js.map +1 -1
- package/dist/types/storageTypes.d.ts +59 -58
- package/dist/types/storageTypes.js +9 -9
- package/dist/types/streamTypes.d.ts +21 -21
- package/dist/types/streamTypes.js +2 -2
- package/package.json +2 -1
|
@@ -1,141 +1,141 @@
|
|
|
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
|
-
const _ = require('lodash');
|
|
12
|
-
const uuidGen = require('uuid/v1');
|
|
13
|
-
const { POST_OUT, PORT_IN_REG, PORT_OUT_REG, SEND_MSG_TYPE } = require('./script-constant');
|
|
14
|
-
const { stringifyIfNecessary } = require('../utils');
|
|
15
|
-
function validate(when, targetNodeId, targetPortId) {
|
|
16
|
-
if (!_.isString(targetNodeId) || !_.isString(targetPortId)) {
|
|
17
|
-
throw new Error('targetNodeId or targetPortId must be string.');
|
|
18
|
-
}
|
|
19
|
-
if (when === POST_OUT && !targetPortId.match(PORT_IN_REG)) {
|
|
20
|
-
throw new Error(`error: can't send message to node's ${targetPortId}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function generateRequestDataId() {
|
|
24
|
-
return `${uuidGen().split('-').join('')}-ss`;
|
|
25
|
-
}
|
|
26
|
-
function getNodeQueueName(nodeId) {
|
|
27
|
-
return `mq-${nodeId}`;
|
|
28
|
-
}
|
|
29
|
-
function buildSendData(data, targetPortId, sendValue, dataType, extra) {
|
|
30
|
-
const dataWithoutPort = _.pickBy(data, (value, key) => {
|
|
31
|
-
return !key.match(PORT_IN_REG) && !key.match(PORT_OUT_REG);
|
|
32
|
-
});
|
|
33
|
-
return Object.assign(dataWithoutPort, dataType, {
|
|
34
|
-
id: generateRequestDataId(),
|
|
35
|
-
type: SEND_MSG_TYPE,
|
|
36
|
-
[targetPortId]: stringifyIfNecessary(sendValue),
|
|
37
|
-
extra: JSON.stringify(extra)
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
function buildDashBoardData(targetPortId, sendValue, dataType) {
|
|
41
|
-
return Object.assign({
|
|
42
|
-
id: generateRequestDataId(),
|
|
43
|
-
[targetPortId]: sendValue
|
|
44
|
-
}, dataType);
|
|
45
|
-
}
|
|
46
|
-
function hasOwnProperty(obj, key) {
|
|
47
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
48
|
-
}
|
|
49
|
-
function mergeDeep(...objects) {
|
|
50
|
-
const isObject = obj => obj && typeof obj === 'object';
|
|
51
|
-
return objects.reduce((prev, obj) => {
|
|
52
|
-
Object.keys(obj).forEach(key => {
|
|
53
|
-
const pVal = prev[key];
|
|
54
|
-
const oVal = obj[key];
|
|
55
|
-
if (Array.isArray(pVal) && Array.isArray(oVal)) {
|
|
56
|
-
prev[key] = pVal.concat(...oVal);
|
|
57
|
-
}
|
|
58
|
-
else if (isObject(pVal) && isObject(oVal)) {
|
|
59
|
-
prev[key] = mergeDeep(pVal, oVal);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
prev[key] = oVal;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return prev;
|
|
66
|
-
}, {});
|
|
67
|
-
}
|
|
68
|
-
const filterNotExistFileds = (ctx, required) => {
|
|
69
|
-
return required.filter(paramter => {
|
|
70
|
-
return !hasOwnProperty(ctx, paramter);
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
function asyncFunction(func) {
|
|
74
|
-
return func.constructor.name === 'AsyncFunction';
|
|
75
|
-
}
|
|
76
|
-
const generateWrapperInitializer = (initializerCallBack) => {
|
|
77
|
-
if (asyncFunction(initializerCallBack)) {
|
|
78
|
-
return function (ctx) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
initializerCallBack(ctx);
|
|
81
|
-
return ctx;
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return function (ctx) {
|
|
86
|
-
initializerCallBack(ctx);
|
|
87
|
-
return ctx;
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
const generateWrapperHandler = (cb) => {
|
|
91
|
-
if (asyncFunction(cb)) {
|
|
92
|
-
return function (data, ctx) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
const notExistParams = filterNotExistFileds(ctx, ['nodeId', 'portId', 'data', 'extra']);
|
|
95
|
-
if (notExistParams.length > 0) {
|
|
96
|
-
throw new Error(`error: missing ${notExistParams.join(', ')} filed`);
|
|
97
|
-
}
|
|
98
|
-
cb(data, ctx);
|
|
99
|
-
return ctx;
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
return function (data, ctx) {
|
|
104
|
-
const notExistParams = filterNotExistFileds(ctx, ['nodeId', 'portId', 'data', 'extra']);
|
|
105
|
-
if (notExistParams.length > 0) {
|
|
106
|
-
throw new Error(`error: missing ${notExistParams.join(', ')} filed`);
|
|
107
|
-
}
|
|
108
|
-
cb(data, ctx);
|
|
109
|
-
return ctx;
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
function assertString(propertyValue, propertyName) {
|
|
113
|
-
if (!propertyValue) {
|
|
114
|
-
throw new Error(`'${propertyName}' must be passed in`);
|
|
115
|
-
}
|
|
116
|
-
if (typeof propertyValue !== 'string') {
|
|
117
|
-
throw new Error(`'${propertyName}' must be a string, not ${typeof propertyValue}`);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function assertFunction(cb) {
|
|
121
|
-
if (!cb) {
|
|
122
|
-
throw new Error('callback must be passed in');
|
|
123
|
-
}
|
|
124
|
-
if (!_.isFunction(cb)) {
|
|
125
|
-
throw new Error(`'${cb}' must be a function, not ${typeof cb}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
module.exports = {
|
|
129
|
-
validate,
|
|
130
|
-
mergeDeep,
|
|
131
|
-
assertString,
|
|
132
|
-
assertFunction,
|
|
133
|
-
asyncFunction,
|
|
134
|
-
buildSendData,
|
|
135
|
-
getNodeQueueName,
|
|
136
|
-
buildDashBoardData,
|
|
137
|
-
filterNotExistFileds,
|
|
138
|
-
generateWrapperHandler,
|
|
139
|
-
generateWrapperInitializer
|
|
140
|
-
};
|
|
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
|
+
const _ = require('lodash');
|
|
12
|
+
const uuidGen = require('uuid/v1');
|
|
13
|
+
const { POST_OUT, PORT_IN_REG, PORT_OUT_REG, SEND_MSG_TYPE } = require('./script-constant');
|
|
14
|
+
const { stringifyIfNecessary } = require('../utils');
|
|
15
|
+
function validate(when, targetNodeId, targetPortId) {
|
|
16
|
+
if (!_.isString(targetNodeId) || !_.isString(targetPortId)) {
|
|
17
|
+
throw new Error('targetNodeId or targetPortId must be string.');
|
|
18
|
+
}
|
|
19
|
+
if (when === POST_OUT && !targetPortId.match(PORT_IN_REG)) {
|
|
20
|
+
throw new Error(`error: can't send message to node's ${targetPortId}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function generateRequestDataId() {
|
|
24
|
+
return `${uuidGen().split('-').join('')}-ss`;
|
|
25
|
+
}
|
|
26
|
+
function getNodeQueueName(nodeId) {
|
|
27
|
+
return `mq-${nodeId}`;
|
|
28
|
+
}
|
|
29
|
+
function buildSendData(data, targetPortId, sendValue, dataType, extra) {
|
|
30
|
+
const dataWithoutPort = _.pickBy(data, (value, key) => {
|
|
31
|
+
return !key.match(PORT_IN_REG) && !key.match(PORT_OUT_REG);
|
|
32
|
+
});
|
|
33
|
+
return Object.assign(dataWithoutPort, dataType, {
|
|
34
|
+
id: generateRequestDataId(),
|
|
35
|
+
type: SEND_MSG_TYPE,
|
|
36
|
+
[targetPortId]: stringifyIfNecessary(sendValue),
|
|
37
|
+
extra: JSON.stringify(extra)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function buildDashBoardData(targetPortId, sendValue, dataType) {
|
|
41
|
+
return Object.assign({
|
|
42
|
+
id: generateRequestDataId(),
|
|
43
|
+
[targetPortId]: sendValue
|
|
44
|
+
}, dataType);
|
|
45
|
+
}
|
|
46
|
+
function hasOwnProperty(obj, key) {
|
|
47
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
48
|
+
}
|
|
49
|
+
function mergeDeep(...objects) {
|
|
50
|
+
const isObject = obj => obj && typeof obj === 'object';
|
|
51
|
+
return objects.reduce((prev, obj) => {
|
|
52
|
+
Object.keys(obj).forEach(key => {
|
|
53
|
+
const pVal = prev[key];
|
|
54
|
+
const oVal = obj[key];
|
|
55
|
+
if (Array.isArray(pVal) && Array.isArray(oVal)) {
|
|
56
|
+
prev[key] = pVal.concat(...oVal);
|
|
57
|
+
}
|
|
58
|
+
else if (isObject(pVal) && isObject(oVal)) {
|
|
59
|
+
prev[key] = mergeDeep(pVal, oVal);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
prev[key] = oVal;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return prev;
|
|
66
|
+
}, {});
|
|
67
|
+
}
|
|
68
|
+
const filterNotExistFileds = (ctx, required) => {
|
|
69
|
+
return required.filter(paramter => {
|
|
70
|
+
return !hasOwnProperty(ctx, paramter);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
function asyncFunction(func) {
|
|
74
|
+
return func.constructor.name === 'AsyncFunction';
|
|
75
|
+
}
|
|
76
|
+
const generateWrapperInitializer = (initializerCallBack) => {
|
|
77
|
+
if (asyncFunction(initializerCallBack)) {
|
|
78
|
+
return function (ctx) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
initializerCallBack(ctx);
|
|
81
|
+
return ctx;
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return function (ctx) {
|
|
86
|
+
initializerCallBack(ctx);
|
|
87
|
+
return ctx;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
const generateWrapperHandler = (cb) => {
|
|
91
|
+
if (asyncFunction(cb)) {
|
|
92
|
+
return function (data, ctx) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const notExistParams = filterNotExistFileds(ctx, ['nodeId', 'portId', 'data', 'extra']);
|
|
95
|
+
if (notExistParams.length > 0) {
|
|
96
|
+
throw new Error(`error: missing ${notExistParams.join(', ')} filed`);
|
|
97
|
+
}
|
|
98
|
+
cb(data, ctx);
|
|
99
|
+
return ctx;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return function (data, ctx) {
|
|
104
|
+
const notExistParams = filterNotExistFileds(ctx, ['nodeId', 'portId', 'data', 'extra']);
|
|
105
|
+
if (notExistParams.length > 0) {
|
|
106
|
+
throw new Error(`error: missing ${notExistParams.join(', ')} filed`);
|
|
107
|
+
}
|
|
108
|
+
cb(data, ctx);
|
|
109
|
+
return ctx;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
function assertString(propertyValue, propertyName) {
|
|
113
|
+
if (!propertyValue) {
|
|
114
|
+
throw new Error(`'${propertyName}' must be passed in`);
|
|
115
|
+
}
|
|
116
|
+
if (typeof propertyValue !== 'string') {
|
|
117
|
+
throw new Error(`'${propertyName}' must be a string, not ${typeof propertyValue}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function assertFunction(cb) {
|
|
121
|
+
if (!cb) {
|
|
122
|
+
throw new Error('callback must be passed in');
|
|
123
|
+
}
|
|
124
|
+
if (!_.isFunction(cb)) {
|
|
125
|
+
throw new Error(`'${cb}' must be a function, not ${typeof cb}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
module.exports = {
|
|
129
|
+
validate,
|
|
130
|
+
mergeDeep,
|
|
131
|
+
assertString,
|
|
132
|
+
assertFunction,
|
|
133
|
+
asyncFunction,
|
|
134
|
+
buildSendData,
|
|
135
|
+
getNodeQueueName,
|
|
136
|
+
buildDashBoardData,
|
|
137
|
+
filterNotExistFileds,
|
|
138
|
+
generateWrapperHandler,
|
|
139
|
+
generateWrapperInitializer
|
|
140
|
+
};
|
|
141
141
|
//# sourceMappingURL=script-support.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function generateTemplate(script: any): string;
|
|
1
|
+
export function generateTemplate(script: any): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const { HANDLERS, INITIALIZEFN, SYSTEM_MESSAGE_HANDLERS, PRE_IN, POST_OUT } = require('./script-constant');
|
|
3
|
-
function generateTemplate(script) {
|
|
1
|
+
'use strict';
|
|
2
|
+
const { HANDLERS, INITIALIZEFN, SYSTEM_MESSAGE_HANDLERS, PRE_IN, POST_OUT } = require('./script-constant');
|
|
3
|
+
function generateTemplate(script) {
|
|
4
4
|
return `
|
|
5
5
|
'use strict'
|
|
6
6
|
|
|
@@ -64,7 +64,7 @@ function afterLeave (nodeId, port, cb) {
|
|
|
64
64
|
${HANDLERS} = processNode({ nodeId, port, pointcut: '${POST_OUT}', cb })
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
module.exports = ${script}`;
|
|
68
|
-
}
|
|
69
|
-
module.exports.generateTemplate = generateTemplate;
|
|
67
|
+
module.exports = ${script}`;
|
|
68
|
+
}
|
|
69
|
+
module.exports.generateTemplate = generateTemplate;
|
|
70
70
|
//# sourceMappingURL=script-template.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare class PortService {
|
|
2
|
-
private static readonly loopupRange;
|
|
3
|
-
static getHostFreePort(): Promise<number>;
|
|
4
|
-
static registerPortUntilSuccess(logicPort: number): Promise<number>;
|
|
5
|
-
}
|
|
1
|
+
export declare class PortService {
|
|
2
|
+
private static readonly loopupRange;
|
|
3
|
+
static getHostFreePort(): Promise<number>;
|
|
4
|
+
static registerPortUntilSuccess(logicPort: number): Promise<number>;
|
|
5
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PortService = void 0;
|
|
16
|
-
const log_1 = __importDefault(require("../common/log"));
|
|
17
|
-
const get_port_1 = __importDefault(require("get-port"));
|
|
18
|
-
const utils_1 = require("../utils");
|
|
19
|
-
const suanpan_1 = require("../utils/suanpan");
|
|
20
|
-
const lookupFrom = parseInt(process.env.SP_PORT_START || '50000');
|
|
21
|
-
const lookupTo = parseInt(process.env.SP_PORT_END || '60000');
|
|
22
|
-
class PortService {
|
|
23
|
-
static getHostFreePort() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
try {
|
|
26
|
-
return yield get_port_1.default({ port: this.loopupRange });
|
|
27
|
-
}
|
|
28
|
-
catch (ex) {
|
|
29
|
-
throw new Error(`Get host free port failed, ex: ${ex.message}`);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
static registerPortUntilSuccess(logicPort) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
for (;;) {
|
|
36
|
-
try {
|
|
37
|
-
const availableHostPort = yield PortService.getHostFreePort();
|
|
38
|
-
const response = yield suanpan_1.SuanpanWebApi.registerPort(logicPort, availableHostPort);
|
|
39
|
-
if (!response.success) {
|
|
40
|
-
throw new Error(response.msg);
|
|
41
|
-
}
|
|
42
|
-
return availableHostPort;
|
|
43
|
-
}
|
|
44
|
-
catch (e) {
|
|
45
|
-
log_1.default.error(e.message);
|
|
46
|
-
}
|
|
47
|
-
yield utils_1.sleep(200);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.PortService = PortService;
|
|
53
|
-
PortService.loopupRange = get_port_1.default.makeRange(lookupFrom, lookupTo);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PortService = void 0;
|
|
16
|
+
const log_1 = __importDefault(require("../common/log"));
|
|
17
|
+
const get_port_1 = __importDefault(require("get-port"));
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const suanpan_1 = require("../utils/suanpan");
|
|
20
|
+
const lookupFrom = parseInt(process.env.SP_PORT_START || '50000');
|
|
21
|
+
const lookupTo = parseInt(process.env.SP_PORT_END || '60000');
|
|
22
|
+
class PortService {
|
|
23
|
+
static getHostFreePort() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
return yield (0, get_port_1.default)({ port: this.loopupRange });
|
|
27
|
+
}
|
|
28
|
+
catch (ex) {
|
|
29
|
+
throw new Error(`Get host free port failed, ex: ${ex.message}`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
static registerPortUntilSuccess(logicPort) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
for (;;) {
|
|
36
|
+
try {
|
|
37
|
+
const availableHostPort = yield PortService.getHostFreePort();
|
|
38
|
+
const response = yield suanpan_1.SuanpanWebApi.registerPort(logicPort, availableHostPort);
|
|
39
|
+
if (!response.success) {
|
|
40
|
+
throw new Error(response.msg);
|
|
41
|
+
}
|
|
42
|
+
return availableHostPort;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
log_1.default.error(e.message);
|
|
46
|
+
}
|
|
47
|
+
yield (0, utils_1.sleep)(200);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.PortService = PortService;
|
|
53
|
+
PortService.loopupRange = get_port_1.default.makeRange(lookupFrom, lookupTo);
|
|
54
54
|
//# sourceMappingURL=port.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../../src/core/service/port.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAmC;AACnC,wDAAqC;AAErC,oCAAiC;AACjC,8CAAiD;AAEjD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,CAAC;AAClE,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,CAAC;AAC9D,MAAa,WAAW;IAItB,MAAM,CAAO,eAAe;;YAC1B,IAAI;gBACF,OAAO,MAAM,kBAAa,
|
|
1
|
+
{"version":3,"file":"port.js","sourceRoot":"","sources":["../../../src/core/service/port.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wDAAmC;AACnC,wDAAqC;AAErC,oCAAiC;AACjC,8CAAiD;AAEjD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,CAAC;AAClE,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,CAAC;AAC9D,MAAa,WAAW;IAItB,MAAM,CAAO,eAAe;;YAC1B,IAAI;gBACF,OAAO,MAAM,IAAA,kBAAa,EAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;aACxD;YAAC,OAAO,EAAO,EAAE;gBAChB,MAAM,IAAI,KAAK,CAAC,kCAAkC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;aACjE;QACH,CAAC;KAAA;IAED,MAAM,CAAO,wBAAwB,CAAC,SAAiB;;YACrD,SAAS;gBACP,IAAI;oBACF,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC,eAAe,EAAE,CAAC;oBAC9D,MAAM,QAAQ,GAAG,MAAM,uBAAa,CAAC,YAAY,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;oBAChF,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;wBACrB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;qBAC/B;oBACD,OAAO,iBAAiB,CAAC;iBAC1B;gBAAC,OAAO,CAAM,EAAE;oBACf,aAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;iBACzB;gBACD,MAAM,IAAA,aAAK,EAAC,GAAG,CAAC,CAAC;aAClB;QACH,CAAC;KAAA;;AA1BH,kCA2BC;AAzByB,uBAAW,GAAG,kBAAa,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './objectStorage';
|
|
2
|
-
export * from './storageFlusher';
|
|
3
|
-
export * from './storageLogger';
|
|
4
|
-
export * from './storagePath';
|
|
5
|
-
export * from './wrapperStorage';
|
|
1
|
+
export * from './objectStorage';
|
|
2
|
+
export * from './storageFlusher';
|
|
3
|
+
export * from './storageLogger';
|
|
4
|
+
export * from './storagePath';
|
|
5
|
+
export * from './wrapperStorage';
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
__exportStar(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
__exportStar(require("./
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./objectStorage"), exports);
|
|
18
|
+
__exportStar(require("./storageFlusher"), exports);
|
|
19
|
+
__exportStar(require("./storageLogger"), exports);
|
|
20
|
+
__exportStar(require("./storagePath"), exports);
|
|
21
|
+
__exportStar(require("./wrapperStorage"), exports);
|
|
18
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/storage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/storage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,mDAAiC;AACjC,kDAAgC;AAChC,gDAA8B;AAC9B,mDAAiC"}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { IObjectStorage } from './objectStorage';
|
|
4
|
+
import type { Readable as ReadableStream } from 'stream';
|
|
5
|
+
import type { ObjectData, ObjectItem, MinioConfig, ObjectMetadata } from '../../types';
|
|
6
|
+
export declare class MinioStorage implements IObjectStorage {
|
|
7
|
+
private config?;
|
|
8
|
+
private bucketName;
|
|
9
|
+
private minioClient;
|
|
10
|
+
constructor(config?: MinioConfig | undefined);
|
|
11
|
+
private buildMinioClient;
|
|
12
|
+
private getClient;
|
|
13
|
+
append(objectName: string, content: string): Promise<any>;
|
|
14
|
+
getObjectToBuffer(objectName: string): Promise<Buffer>;
|
|
15
|
+
getObjectToStream(objectName: string): Promise<ReadableStream>;
|
|
16
|
+
getObjectToString(objectName: string): Promise<string>;
|
|
17
|
+
getObjectToJSON(objectName: string): Promise<any>;
|
|
18
|
+
putObject(objectName: string, data: ObjectData, metaData?: ObjectMetadata): Promise<void>;
|
|
19
|
+
putObjectWithMetaData(objectName: string, data: ReadableStream | Buffer | string, metaData: object): Promise<void>;
|
|
20
|
+
fPutObject(objectName: string, filePath: string, metaData?: ObjectMetadata): Promise<void>;
|
|
21
|
+
fGetObject(objectName: string, filePath: string): Promise<void>;
|
|
22
|
+
presignedGetObject(objectName: string): Promise<string>;
|
|
23
|
+
presignedPutObject(objectName: string): Promise<string>;
|
|
24
|
+
presignedDeleteObject(objectName: string): Promise<string>;
|
|
25
|
+
listObjects(prefix: string, recursive?: boolean): Promise<ObjectItem[]>;
|
|
26
|
+
deleteObject(objectName: string): Promise<void>;
|
|
27
|
+
deleteMultiObjects(objectNames: string[]): Promise<void>;
|
|
28
|
+
checkObjectNameExist(objectName: string): Promise<boolean>;
|
|
29
|
+
getLastModified(objectName: string): Promise<Date>;
|
|
30
|
+
getSTSToken(): Promise<import("../../types").StsToken>;
|
|
31
|
+
}
|