@allthings/sdk 6.6.0 → 7.0.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/README.md +20 -0
- package/dist/cli.js +1313 -1209
- package/dist/lib.cjs.js +1313 -1257
- package/dist/lib.esm.js +1314 -1256
- package/dist/lib.umd.min.js +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/rest/methods/conversation.d.ts +1 -0
- package/dist/src/rest/methods/file.d.ts +1 -0
- package/dist/src/rest/methods/group.d.ts +3 -2
- package/dist/src/rest/methods/property.d.ts +2 -1
- package/dist/src/rest/methods/registrationCode.d.ts +1 -0
- package/dist/src/rest/methods/ticket.d.ts +1 -0
- package/dist/src/rest/methods/unit.d.ts +1 -0
- package/dist/src/rest/methods/user.d.ts +8 -0
- package/dist/src/rest/methods/utilisationPeriod.d.ts +2 -1
- package/dist/src/utils/upload.d.ts +1 -0
- package/dist/test/helpers.d.ts +1 -0
- package/package.json +9 -11
- package/dist/src/aws/index.d.ts +0 -2
- package/dist/src/aws/parameterStore.d.ts +0 -16
- package/dist/src/aws/parameterStore.test.d.ts +0 -1
package/dist/lib.esm.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SSMClient, GetParametersCommand, GetParameterCommand } from '@aws-sdk/client-ssm';
|
|
2
1
|
import querystring from 'query-string';
|
|
3
2
|
import fetch from 'cross-fetch';
|
|
4
3
|
import Bottleneck from 'bottleneck';
|
|
@@ -10,7 +9,16 @@ import require$$4 from 'https';
|
|
|
10
9
|
import require$$5 from 'url';
|
|
11
10
|
import require$$6 from 'fs';
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
function createTokenStore(initialToken) {
|
|
13
|
+
const token = new Map(Object.entries(initialToken || {}));
|
|
14
|
+
return {
|
|
15
|
+
get: (key) => token.get(key),
|
|
16
|
+
reset: () => token.clear(),
|
|
17
|
+
set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const version = "7.0.0";
|
|
14
22
|
|
|
15
23
|
const REST_API_URL = 'https://api.allthings.me';
|
|
16
24
|
const OAUTH_URL = 'https://accounts.allthings.me';
|
|
@@ -32,81 +40,6 @@ const DEFAULT_API_WRAPPER_OPTIONS = {
|
|
|
32
40
|
username: process.env.ALLTHINGS_OAUTH_USERNAME,
|
|
33
41
|
};
|
|
34
42
|
const USER_AGENT = `Allthings Node SDK REST Client/${version}`;
|
|
35
|
-
const DEFAULT_AWS_CONFIGURATION = {
|
|
36
|
-
region: 'eu-central-2',
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
var __rest$5 = (undefined && undefined.__rest) || function (s, e) {
|
|
40
|
-
var t = {};
|
|
41
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
42
|
-
t[p] = s[p];
|
|
43
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
44
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
45
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
46
|
-
t[p[i]] = s[p[i]];
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
};
|
|
50
|
-
const DEFAULT_CLIENT_CONFIG = {
|
|
51
|
-
clientConfig: DEFAULT_AWS_CONFIGURATION,
|
|
52
|
-
onlyDefault: false,
|
|
53
|
-
prefix: process.env.SSM_PARAM_PATH,
|
|
54
|
-
};
|
|
55
|
-
const getSecrets = async (ssm, config, params, defaultValue) => {
|
|
56
|
-
var _a, _b;
|
|
57
|
-
if (config.onlyDefault) {
|
|
58
|
-
return [defaultValue];
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
const parameters = await ssm.send(new GetParametersCommand({
|
|
62
|
-
Names: params.map((param) => `${config.prefix ? config.prefix : ''}${param}`),
|
|
63
|
-
WithDecryption: true,
|
|
64
|
-
}));
|
|
65
|
-
return ((_b = (_a = parameters === null || parameters === void 0 ? void 0 : parameters.Parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => { var _a; return (_a = parameter.Value) !== null && _a !== void 0 ? _a : defaultValue; })) !== null && _b !== void 0 ? _b : [defaultValue]);
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
if (config.logger) {
|
|
69
|
-
config.logger(e);
|
|
70
|
-
}
|
|
71
|
-
return [defaultValue];
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const getSecret = async (ssm, config, param, defaultValue) => {
|
|
75
|
-
var _a, _b;
|
|
76
|
-
if (config.onlyDefault) {
|
|
77
|
-
return defaultValue;
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
const parameter = await ssm.send(new GetParameterCommand({
|
|
81
|
-
Name: `${config.prefix ? config.prefix : ''}${param}`,
|
|
82
|
-
WithDecryption: true,
|
|
83
|
-
}));
|
|
84
|
-
return (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.Parameter) === null || _a === void 0 ? void 0 : _a.Value) !== null && _b !== void 0 ? _b : defaultValue;
|
|
85
|
-
}
|
|
86
|
-
catch (e) {
|
|
87
|
-
if (config.logger) {
|
|
88
|
-
config.logger(e);
|
|
89
|
-
}
|
|
90
|
-
return defaultValue;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const parameterStore = (userConfig) => {
|
|
94
|
-
const _a = Object.assign(Object.assign({}, DEFAULT_CLIENT_CONFIG), userConfig), { clientConfig } = _a, config = __rest$5(_a, ["clientConfig"]);
|
|
95
|
-
const ssm = new SSMClient(clientConfig);
|
|
96
|
-
return {
|
|
97
|
-
getSecret: (param, defaultValue = '') => getSecret(ssm, config, param, defaultValue),
|
|
98
|
-
getSecrets: (params, defaultValue = '') => getSecrets(ssm, config, params, defaultValue),
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
function createTokenStore(initialToken) {
|
|
103
|
-
const token = new Map(Object.entries(initialToken || {}));
|
|
104
|
-
return {
|
|
105
|
-
get: (key) => token.get(key),
|
|
106
|
-
reset: () => token.clear(),
|
|
107
|
-
set: (update) => Object.entries(update).forEach(([key, value]) => token.set(key, value)),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
43
|
|
|
111
44
|
const RESPONSE_TYPE$1 = 'code';
|
|
112
45
|
const GRANT_TYPE$3 = 'authorization_code';
|
|
@@ -918,322 +851,338 @@ function getDefaultExportFromCjs (x) {
|
|
|
918
851
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
919
852
|
}
|
|
920
853
|
|
|
921
|
-
var
|
|
922
|
-
var
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
854
|
+
var delayed_stream;
|
|
855
|
+
var hasRequiredDelayed_stream;
|
|
856
|
+
|
|
857
|
+
function requireDelayed_stream () {
|
|
858
|
+
if (hasRequiredDelayed_stream) return delayed_stream;
|
|
859
|
+
hasRequiredDelayed_stream = 1;
|
|
860
|
+
var Stream = require$$0$1.Stream;
|
|
861
|
+
var util = require$$1;
|
|
862
|
+
|
|
863
|
+
delayed_stream = DelayedStream;
|
|
864
|
+
function DelayedStream() {
|
|
865
|
+
this.source = null;
|
|
866
|
+
this.dataSize = 0;
|
|
867
|
+
this.maxDataSize = 1024 * 1024;
|
|
868
|
+
this.pauseStream = true;
|
|
869
|
+
|
|
870
|
+
this._maxDataSizeExceeded = false;
|
|
871
|
+
this._released = false;
|
|
872
|
+
this._bufferedEvents = [];
|
|
873
|
+
}
|
|
874
|
+
util.inherits(DelayedStream, Stream);
|
|
936
875
|
|
|
937
|
-
DelayedStream
|
|
938
|
-
|
|
876
|
+
DelayedStream.create = function(source, options) {
|
|
877
|
+
var delayedStream = new this();
|
|
939
878
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
879
|
+
options = options || {};
|
|
880
|
+
for (var option in options) {
|
|
881
|
+
delayedStream[option] = options[option];
|
|
882
|
+
}
|
|
944
883
|
|
|
945
|
-
|
|
884
|
+
delayedStream.source = source;
|
|
946
885
|
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
886
|
+
var realEmit = source.emit;
|
|
887
|
+
source.emit = function() {
|
|
888
|
+
delayedStream._handleEmit(arguments);
|
|
889
|
+
return realEmit.apply(source, arguments);
|
|
890
|
+
};
|
|
952
891
|
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
892
|
+
source.on('error', function() {});
|
|
893
|
+
if (delayedStream.pauseStream) {
|
|
894
|
+
source.pause();
|
|
895
|
+
}
|
|
957
896
|
|
|
958
|
-
|
|
959
|
-
};
|
|
897
|
+
return delayedStream;
|
|
898
|
+
};
|
|
960
899
|
|
|
961
|
-
Object.defineProperty(DelayedStream
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
});
|
|
900
|
+
Object.defineProperty(DelayedStream.prototype, 'readable', {
|
|
901
|
+
configurable: true,
|
|
902
|
+
enumerable: true,
|
|
903
|
+
get: function() {
|
|
904
|
+
return this.source.readable;
|
|
905
|
+
}
|
|
906
|
+
});
|
|
968
907
|
|
|
969
|
-
DelayedStream
|
|
970
|
-
|
|
971
|
-
};
|
|
908
|
+
DelayedStream.prototype.setEncoding = function() {
|
|
909
|
+
return this.source.setEncoding.apply(this.source, arguments);
|
|
910
|
+
};
|
|
972
911
|
|
|
973
|
-
DelayedStream
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
912
|
+
DelayedStream.prototype.resume = function() {
|
|
913
|
+
if (!this._released) {
|
|
914
|
+
this.release();
|
|
915
|
+
}
|
|
977
916
|
|
|
978
|
-
|
|
979
|
-
};
|
|
917
|
+
this.source.resume();
|
|
918
|
+
};
|
|
980
919
|
|
|
981
|
-
DelayedStream
|
|
982
|
-
|
|
983
|
-
};
|
|
920
|
+
DelayedStream.prototype.pause = function() {
|
|
921
|
+
this.source.pause();
|
|
922
|
+
};
|
|
984
923
|
|
|
985
|
-
DelayedStream
|
|
986
|
-
|
|
924
|
+
DelayedStream.prototype.release = function() {
|
|
925
|
+
this._released = true;
|
|
987
926
|
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
};
|
|
927
|
+
this._bufferedEvents.forEach(function(args) {
|
|
928
|
+
this.emit.apply(this, args);
|
|
929
|
+
}.bind(this));
|
|
930
|
+
this._bufferedEvents = [];
|
|
931
|
+
};
|
|
993
932
|
|
|
994
|
-
DelayedStream
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
};
|
|
933
|
+
DelayedStream.prototype.pipe = function() {
|
|
934
|
+
var r = Stream.prototype.pipe.apply(this, arguments);
|
|
935
|
+
this.resume();
|
|
936
|
+
return r;
|
|
937
|
+
};
|
|
999
938
|
|
|
1000
|
-
DelayedStream
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
939
|
+
DelayedStream.prototype._handleEmit = function(args) {
|
|
940
|
+
if (this._released) {
|
|
941
|
+
this.emit.apply(this, args);
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
1005
944
|
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
945
|
+
if (args[0] === 'data') {
|
|
946
|
+
this.dataSize += args[1].length;
|
|
947
|
+
this._checkIfMaxDataSizeExceeded();
|
|
948
|
+
}
|
|
1010
949
|
|
|
1011
|
-
|
|
1012
|
-
};
|
|
950
|
+
this._bufferedEvents.push(args);
|
|
951
|
+
};
|
|
1013
952
|
|
|
1014
|
-
DelayedStream
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
if (this.dataSize <= this.maxDataSize) {
|
|
1020
|
-
return;
|
|
1021
|
-
}
|
|
953
|
+
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
954
|
+
if (this._maxDataSizeExceeded) {
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
1022
957
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
this.emit('error', new Error(message));
|
|
1027
|
-
};
|
|
958
|
+
if (this.dataSize <= this.maxDataSize) {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
1028
961
|
|
|
1029
|
-
|
|
1030
|
-
var
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
this.writable = false;
|
|
1036
|
-
this.readable = true;
|
|
1037
|
-
this.dataSize = 0;
|
|
1038
|
-
this.maxDataSize = 2 * 1024 * 1024;
|
|
1039
|
-
this.pauseStreams = true;
|
|
1040
|
-
|
|
1041
|
-
this._released = false;
|
|
1042
|
-
this._streams = [];
|
|
1043
|
-
this._currentStream = null;
|
|
1044
|
-
this._insideLoop = false;
|
|
1045
|
-
this._pendingNext = false;
|
|
962
|
+
this._maxDataSizeExceeded = true;
|
|
963
|
+
var message =
|
|
964
|
+
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.';
|
|
965
|
+
this.emit('error', new Error(message));
|
|
966
|
+
};
|
|
967
|
+
return delayed_stream;
|
|
1046
968
|
}
|
|
1047
|
-
util$1.inherits(CombinedStream$1, Stream$1);
|
|
1048
|
-
|
|
1049
|
-
CombinedStream$1.create = function(options) {
|
|
1050
|
-
var combinedStream = new this();
|
|
1051
969
|
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
970
|
+
var combined_stream;
|
|
971
|
+
var hasRequiredCombined_stream;
|
|
972
|
+
|
|
973
|
+
function requireCombined_stream () {
|
|
974
|
+
if (hasRequiredCombined_stream) return combined_stream;
|
|
975
|
+
hasRequiredCombined_stream = 1;
|
|
976
|
+
var util = require$$1;
|
|
977
|
+
var Stream = require$$0$1.Stream;
|
|
978
|
+
var DelayedStream = requireDelayed_stream();
|
|
979
|
+
|
|
980
|
+
combined_stream = CombinedStream;
|
|
981
|
+
function CombinedStream() {
|
|
982
|
+
this.writable = false;
|
|
983
|
+
this.readable = true;
|
|
984
|
+
this.dataSize = 0;
|
|
985
|
+
this.maxDataSize = 2 * 1024 * 1024;
|
|
986
|
+
this.pauseStreams = true;
|
|
987
|
+
|
|
988
|
+
this._released = false;
|
|
989
|
+
this._streams = [];
|
|
990
|
+
this._currentStream = null;
|
|
991
|
+
this._insideLoop = false;
|
|
992
|
+
this._pendingNext = false;
|
|
993
|
+
}
|
|
994
|
+
util.inherits(CombinedStream, Stream);
|
|
1056
995
|
|
|
1057
|
-
|
|
1058
|
-
|
|
996
|
+
CombinedStream.create = function(options) {
|
|
997
|
+
var combinedStream = new this();
|
|
1059
998
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
&& (typeof stream !== 'number')
|
|
1065
|
-
&& (!Buffer.isBuffer(stream));
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
CombinedStream$1.prototype.append = function(stream) {
|
|
1069
|
-
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1070
|
-
|
|
1071
|
-
if (isStreamLike) {
|
|
1072
|
-
if (!(stream instanceof DelayedStream)) {
|
|
1073
|
-
var newStream = DelayedStream.create(stream, {
|
|
1074
|
-
maxDataSize: Infinity,
|
|
1075
|
-
pauseStream: this.pauseStreams,
|
|
1076
|
-
});
|
|
1077
|
-
stream.on('data', this._checkDataSize.bind(this));
|
|
1078
|
-
stream = newStream;
|
|
1079
|
-
}
|
|
999
|
+
options = options || {};
|
|
1000
|
+
for (var option in options) {
|
|
1001
|
+
combinedStream[option] = options[option];
|
|
1002
|
+
}
|
|
1080
1003
|
|
|
1081
|
-
|
|
1004
|
+
return combinedStream;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
CombinedStream.isStreamLike = function(stream) {
|
|
1008
|
+
return (typeof stream !== 'function')
|
|
1009
|
+
&& (typeof stream !== 'string')
|
|
1010
|
+
&& (typeof stream !== 'boolean')
|
|
1011
|
+
&& (typeof stream !== 'number')
|
|
1012
|
+
&& (!Buffer.isBuffer(stream));
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
CombinedStream.prototype.append = function(stream) {
|
|
1016
|
+
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1017
|
+
|
|
1018
|
+
if (isStreamLike) {
|
|
1019
|
+
if (!(stream instanceof DelayedStream)) {
|
|
1020
|
+
var newStream = DelayedStream.create(stream, {
|
|
1021
|
+
maxDataSize: Infinity,
|
|
1022
|
+
pauseStream: this.pauseStreams,
|
|
1023
|
+
});
|
|
1024
|
+
stream.on('data', this._checkDataSize.bind(this));
|
|
1025
|
+
stream = newStream;
|
|
1026
|
+
}
|
|
1082
1027
|
|
|
1083
|
-
|
|
1084
|
-
stream.pause();
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1028
|
+
this._handleErrors(stream);
|
|
1087
1029
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
}
|
|
1030
|
+
if (this.pauseStreams) {
|
|
1031
|
+
stream.pause();
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1091
1034
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
return dest;
|
|
1096
|
-
};
|
|
1035
|
+
this._streams.push(stream);
|
|
1036
|
+
return this;
|
|
1037
|
+
};
|
|
1097
1038
|
|
|
1098
|
-
CombinedStream
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
return; // defer call
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
this._insideLoop = true;
|
|
1107
|
-
try {
|
|
1108
|
-
do {
|
|
1109
|
-
this._pendingNext = false;
|
|
1110
|
-
this._realGetNext();
|
|
1111
|
-
} while (this._pendingNext);
|
|
1112
|
-
} finally {
|
|
1113
|
-
this._insideLoop = false;
|
|
1114
|
-
}
|
|
1115
|
-
};
|
|
1039
|
+
CombinedStream.prototype.pipe = function(dest, options) {
|
|
1040
|
+
Stream.prototype.pipe.call(this, dest, options);
|
|
1041
|
+
this.resume();
|
|
1042
|
+
return dest;
|
|
1043
|
+
};
|
|
1116
1044
|
|
|
1117
|
-
CombinedStream
|
|
1118
|
-
|
|
1045
|
+
CombinedStream.prototype._getNext = function() {
|
|
1046
|
+
this._currentStream = null;
|
|
1119
1047
|
|
|
1048
|
+
if (this._insideLoop) {
|
|
1049
|
+
this._pendingNext = true;
|
|
1050
|
+
return; // defer call
|
|
1051
|
+
}
|
|
1120
1052
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1053
|
+
this._insideLoop = true;
|
|
1054
|
+
try {
|
|
1055
|
+
do {
|
|
1056
|
+
this._pendingNext = false;
|
|
1057
|
+
this._realGetNext();
|
|
1058
|
+
} while (this._pendingNext);
|
|
1059
|
+
} finally {
|
|
1060
|
+
this._insideLoop = false;
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1125
1063
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
return;
|
|
1129
|
-
}
|
|
1130
|
-
|
|
1131
|
-
var getStream = stream;
|
|
1132
|
-
getStream(function(stream) {
|
|
1133
|
-
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1134
|
-
if (isStreamLike) {
|
|
1135
|
-
stream.on('data', this._checkDataSize.bind(this));
|
|
1136
|
-
this._handleErrors(stream);
|
|
1137
|
-
}
|
|
1064
|
+
CombinedStream.prototype._realGetNext = function() {
|
|
1065
|
+
var stream = this._streams.shift();
|
|
1138
1066
|
|
|
1139
|
-
this._pipeNext(stream);
|
|
1140
|
-
}.bind(this));
|
|
1141
|
-
};
|
|
1142
1067
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1068
|
+
if (typeof stream == 'undefined') {
|
|
1069
|
+
this.end();
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1145
1072
|
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1073
|
+
if (typeof stream !== 'function') {
|
|
1074
|
+
this._pipeNext(stream);
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1152
1077
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1078
|
+
var getStream = stream;
|
|
1079
|
+
getStream(function(stream) {
|
|
1080
|
+
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1081
|
+
if (isStreamLike) {
|
|
1082
|
+
stream.on('data', this._checkDataSize.bind(this));
|
|
1083
|
+
this._handleErrors(stream);
|
|
1084
|
+
}
|
|
1157
1085
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
self._emitError(err);
|
|
1162
|
-
});
|
|
1163
|
-
};
|
|
1086
|
+
this._pipeNext(stream);
|
|
1087
|
+
}.bind(this));
|
|
1088
|
+
};
|
|
1164
1089
|
|
|
1165
|
-
CombinedStream
|
|
1166
|
-
|
|
1167
|
-
};
|
|
1090
|
+
CombinedStream.prototype._pipeNext = function(stream) {
|
|
1091
|
+
this._currentStream = stream;
|
|
1168
1092
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1093
|
+
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1094
|
+
if (isStreamLike) {
|
|
1095
|
+
stream.on('end', this._getNext.bind(this));
|
|
1096
|
+
stream.pipe(this, {end: false});
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1173
1099
|
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1100
|
+
var value = stream;
|
|
1101
|
+
this.write(value);
|
|
1102
|
+
this._getNext();
|
|
1103
|
+
};
|
|
1177
1104
|
|
|
1178
|
-
CombinedStream
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1105
|
+
CombinedStream.prototype._handleErrors = function(stream) {
|
|
1106
|
+
var self = this;
|
|
1107
|
+
stream.on('error', function(err) {
|
|
1108
|
+
self._emitError(err);
|
|
1109
|
+
});
|
|
1110
|
+
};
|
|
1184
1111
|
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
};
|
|
1112
|
+
CombinedStream.prototype.write = function(data) {
|
|
1113
|
+
this.emit('data', data);
|
|
1114
|
+
};
|
|
1188
1115
|
|
|
1189
|
-
CombinedStream
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
}
|
|
1116
|
+
CombinedStream.prototype.pause = function() {
|
|
1117
|
+
if (!this.pauseStreams) {
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1193
1120
|
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
};
|
|
1121
|
+
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause();
|
|
1122
|
+
this.emit('pause');
|
|
1123
|
+
};
|
|
1198
1124
|
|
|
1199
|
-
CombinedStream
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1125
|
+
CombinedStream.prototype.resume = function() {
|
|
1126
|
+
if (!this._released) {
|
|
1127
|
+
this._released = true;
|
|
1128
|
+
this.writable = true;
|
|
1129
|
+
this._getNext();
|
|
1130
|
+
}
|
|
1204
1131
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1132
|
+
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume();
|
|
1133
|
+
this.emit('resume');
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
CombinedStream.prototype.end = function() {
|
|
1137
|
+
this._reset();
|
|
1138
|
+
this.emit('end');
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
CombinedStream.prototype.destroy = function() {
|
|
1142
|
+
this._reset();
|
|
1143
|
+
this.emit('close');
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
CombinedStream.prototype._reset = function() {
|
|
1147
|
+
this.writable = false;
|
|
1148
|
+
this._streams = [];
|
|
1149
|
+
this._currentStream = null;
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
CombinedStream.prototype._checkDataSize = function() {
|
|
1153
|
+
this._updateDataSize();
|
|
1154
|
+
if (this.dataSize <= this.maxDataSize) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1210
1157
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
};
|
|
1158
|
+
var message =
|
|
1159
|
+
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.';
|
|
1160
|
+
this._emitError(new Error(message));
|
|
1161
|
+
};
|
|
1215
1162
|
|
|
1216
|
-
CombinedStream
|
|
1217
|
-
|
|
1163
|
+
CombinedStream.prototype._updateDataSize = function() {
|
|
1164
|
+
this.dataSize = 0;
|
|
1218
1165
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1166
|
+
var self = this;
|
|
1167
|
+
this._streams.forEach(function(stream) {
|
|
1168
|
+
if (!stream.dataSize) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1224
1171
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1172
|
+
self.dataSize += stream.dataSize;
|
|
1173
|
+
});
|
|
1227
1174
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
};
|
|
1175
|
+
if (this._currentStream && this._currentStream.dataSize) {
|
|
1176
|
+
this.dataSize += this._currentStream.dataSize;
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1232
1179
|
|
|
1233
|
-
CombinedStream
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
};
|
|
1180
|
+
CombinedStream.prototype._emitError = function(err) {
|
|
1181
|
+
this._reset();
|
|
1182
|
+
this.emit('error', err);
|
|
1183
|
+
};
|
|
1184
|
+
return combined_stream;
|
|
1185
|
+
}
|
|
1237
1186
|
|
|
1238
1187
|
var mimeTypes = {};
|
|
1239
1188
|
|
|
@@ -11947,11 +11896,19 @@ var require$$0 = {
|
|
|
11947
11896
|
* MIT Licensed
|
|
11948
11897
|
*/
|
|
11949
11898
|
|
|
11950
|
-
|
|
11951
|
-
|
|
11952
|
-
*/
|
|
11899
|
+
var mimeDb;
|
|
11900
|
+
var hasRequiredMimeDb;
|
|
11953
11901
|
|
|
11954
|
-
|
|
11902
|
+
function requireMimeDb () {
|
|
11903
|
+
if (hasRequiredMimeDb) return mimeDb;
|
|
11904
|
+
hasRequiredMimeDb = 1;
|
|
11905
|
+
/**
|
|
11906
|
+
* Module exports.
|
|
11907
|
+
*/
|
|
11908
|
+
|
|
11909
|
+
mimeDb = require$$0;
|
|
11910
|
+
return mimeDb;
|
|
11911
|
+
}
|
|
11955
11912
|
|
|
11956
11913
|
/*!
|
|
11957
11914
|
* mime-types
|
|
@@ -11960,1088 +11917,1189 @@ var mimeDb = require$$0;
|
|
|
11960
11917
|
* MIT Licensed
|
|
11961
11918
|
*/
|
|
11962
11919
|
|
|
11963
|
-
|
|
11920
|
+
var hasRequiredMimeTypes;
|
|
11921
|
+
|
|
11922
|
+
function requireMimeTypes () {
|
|
11923
|
+
if (hasRequiredMimeTypes) return mimeTypes;
|
|
11924
|
+
hasRequiredMimeTypes = 1;
|
|
11925
|
+
(function (exports) {
|
|
11926
|
+
|
|
11927
|
+
/**
|
|
11928
|
+
* Module dependencies.
|
|
11929
|
+
* @private
|
|
11930
|
+
*/
|
|
11931
|
+
|
|
11932
|
+
var db = requireMimeDb();
|
|
11933
|
+
var extname = require$$1$1.extname;
|
|
11934
|
+
|
|
11935
|
+
/**
|
|
11936
|
+
* Module variables.
|
|
11937
|
+
* @private
|
|
11938
|
+
*/
|
|
11939
|
+
|
|
11940
|
+
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
11941
|
+
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
11942
|
+
|
|
11943
|
+
/**
|
|
11944
|
+
* Module exports.
|
|
11945
|
+
* @public
|
|
11946
|
+
*/
|
|
11947
|
+
|
|
11948
|
+
exports.charset = charset;
|
|
11949
|
+
exports.charsets = { lookup: charset };
|
|
11950
|
+
exports.contentType = contentType;
|
|
11951
|
+
exports.extension = extension;
|
|
11952
|
+
exports.extensions = Object.create(null);
|
|
11953
|
+
exports.lookup = lookup;
|
|
11954
|
+
exports.types = Object.create(null);
|
|
11955
|
+
|
|
11956
|
+
// Populate the extensions/types maps
|
|
11957
|
+
populateMaps(exports.extensions, exports.types);
|
|
11958
|
+
|
|
11959
|
+
/**
|
|
11960
|
+
* Get the default charset for a MIME type.
|
|
11961
|
+
*
|
|
11962
|
+
* @param {string} type
|
|
11963
|
+
* @return {boolean|string}
|
|
11964
|
+
*/
|
|
11965
|
+
|
|
11966
|
+
function charset (type) {
|
|
11967
|
+
if (!type || typeof type !== 'string') {
|
|
11968
|
+
return false
|
|
11969
|
+
}
|
|
11970
|
+
|
|
11971
|
+
// TODO: use media-typer
|
|
11972
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
11973
|
+
var mime = match && db[match[1].toLowerCase()];
|
|
11974
|
+
|
|
11975
|
+
if (mime && mime.charset) {
|
|
11976
|
+
return mime.charset
|
|
11977
|
+
}
|
|
11978
|
+
|
|
11979
|
+
// default text/* to utf-8
|
|
11980
|
+
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
|
11981
|
+
return 'UTF-8'
|
|
11982
|
+
}
|
|
11983
|
+
|
|
11984
|
+
return false
|
|
11985
|
+
}
|
|
11986
|
+
|
|
11987
|
+
/**
|
|
11988
|
+
* Create a full Content-Type header given a MIME type or extension.
|
|
11989
|
+
*
|
|
11990
|
+
* @param {string} str
|
|
11991
|
+
* @return {boolean|string}
|
|
11992
|
+
*/
|
|
11993
|
+
|
|
11994
|
+
function contentType (str) {
|
|
11995
|
+
// TODO: should this even be in this module?
|
|
11996
|
+
if (!str || typeof str !== 'string') {
|
|
11997
|
+
return false
|
|
11998
|
+
}
|
|
11999
|
+
|
|
12000
|
+
var mime = str.indexOf('/') === -1
|
|
12001
|
+
? exports.lookup(str)
|
|
12002
|
+
: str;
|
|
12003
|
+
|
|
12004
|
+
if (!mime) {
|
|
12005
|
+
return false
|
|
12006
|
+
}
|
|
12007
|
+
|
|
12008
|
+
// TODO: use content-type or other module
|
|
12009
|
+
if (mime.indexOf('charset') === -1) {
|
|
12010
|
+
var charset = exports.charset(mime);
|
|
12011
|
+
if (charset) mime += '; charset=' + charset.toLowerCase();
|
|
12012
|
+
}
|
|
12013
|
+
|
|
12014
|
+
return mime
|
|
12015
|
+
}
|
|
12016
|
+
|
|
12017
|
+
/**
|
|
12018
|
+
* Get the default extension for a MIME type.
|
|
12019
|
+
*
|
|
12020
|
+
* @param {string} type
|
|
12021
|
+
* @return {boolean|string}
|
|
12022
|
+
*/
|
|
12023
|
+
|
|
12024
|
+
function extension (type) {
|
|
12025
|
+
if (!type || typeof type !== 'string') {
|
|
12026
|
+
return false
|
|
12027
|
+
}
|
|
12028
|
+
|
|
12029
|
+
// TODO: use media-typer
|
|
12030
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
12031
|
+
|
|
12032
|
+
// get extensions
|
|
12033
|
+
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
12034
|
+
|
|
12035
|
+
if (!exts || !exts.length) {
|
|
12036
|
+
return false
|
|
12037
|
+
}
|
|
12038
|
+
|
|
12039
|
+
return exts[0]
|
|
12040
|
+
}
|
|
12041
|
+
|
|
12042
|
+
/**
|
|
12043
|
+
* Lookup the MIME type for a file path/extension.
|
|
12044
|
+
*
|
|
12045
|
+
* @param {string} path
|
|
12046
|
+
* @return {boolean|string}
|
|
12047
|
+
*/
|
|
12048
|
+
|
|
12049
|
+
function lookup (path) {
|
|
12050
|
+
if (!path || typeof path !== 'string') {
|
|
12051
|
+
return false
|
|
12052
|
+
}
|
|
12053
|
+
|
|
12054
|
+
// get the extension ("ext" or ".ext" or full path)
|
|
12055
|
+
var extension = extname('x.' + path)
|
|
12056
|
+
.toLowerCase()
|
|
12057
|
+
.substr(1);
|
|
12058
|
+
|
|
12059
|
+
if (!extension) {
|
|
12060
|
+
return false
|
|
12061
|
+
}
|
|
12062
|
+
|
|
12063
|
+
return exports.types[extension] || false
|
|
12064
|
+
}
|
|
12065
|
+
|
|
12066
|
+
/**
|
|
12067
|
+
* Populate the extensions and types maps.
|
|
12068
|
+
* @private
|
|
12069
|
+
*/
|
|
12070
|
+
|
|
12071
|
+
function populateMaps (extensions, types) {
|
|
12072
|
+
// source preference (least -> most)
|
|
12073
|
+
var preference = ['nginx', 'apache', undefined, 'iana'];
|
|
12074
|
+
|
|
12075
|
+
Object.keys(db).forEach(function forEachMimeType (type) {
|
|
12076
|
+
var mime = db[type];
|
|
12077
|
+
var exts = mime.extensions;
|
|
12078
|
+
|
|
12079
|
+
if (!exts || !exts.length) {
|
|
12080
|
+
return
|
|
12081
|
+
}
|
|
12082
|
+
|
|
12083
|
+
// mime -> extensions
|
|
12084
|
+
extensions[type] = exts;
|
|
12085
|
+
|
|
12086
|
+
// extension -> mime
|
|
12087
|
+
for (var i = 0; i < exts.length; i++) {
|
|
12088
|
+
var extension = exts[i];
|
|
12089
|
+
|
|
12090
|
+
if (types[extension]) {
|
|
12091
|
+
var from = preference.indexOf(db[types[extension]].source);
|
|
12092
|
+
var to = preference.indexOf(mime.source);
|
|
12093
|
+
|
|
12094
|
+
if (types[extension] !== 'application/octet-stream' &&
|
|
12095
|
+
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
|
12096
|
+
// skip the remapping
|
|
12097
|
+
continue
|
|
12098
|
+
}
|
|
12099
|
+
}
|
|
12100
|
+
|
|
12101
|
+
// set the extension -> mime
|
|
12102
|
+
types[extension] = type;
|
|
12103
|
+
}
|
|
12104
|
+
});
|
|
12105
|
+
}
|
|
12106
|
+
} (mimeTypes));
|
|
12107
|
+
return mimeTypes;
|
|
12108
|
+
}
|
|
11964
12109
|
|
|
11965
|
-
|
|
11966
|
-
|
|
11967
|
-
* @private
|
|
11968
|
-
*/
|
|
12110
|
+
var defer_1;
|
|
12111
|
+
var hasRequiredDefer;
|
|
11969
12112
|
|
|
11970
|
-
|
|
11971
|
-
|
|
12113
|
+
function requireDefer () {
|
|
12114
|
+
if (hasRequiredDefer) return defer_1;
|
|
12115
|
+
hasRequiredDefer = 1;
|
|
12116
|
+
defer_1 = defer;
|
|
11972
12117
|
|
|
11973
12118
|
/**
|
|
11974
|
-
*
|
|
11975
|
-
*
|
|
12119
|
+
* Runs provided function on next iteration of the event loop
|
|
12120
|
+
*
|
|
12121
|
+
* @param {function} fn - function to run
|
|
11976
12122
|
*/
|
|
12123
|
+
function defer(fn)
|
|
12124
|
+
{
|
|
12125
|
+
var nextTick = typeof setImmediate == 'function'
|
|
12126
|
+
? setImmediate
|
|
12127
|
+
: (
|
|
12128
|
+
typeof process == 'object' && typeof process.nextTick == 'function'
|
|
12129
|
+
? process.nextTick
|
|
12130
|
+
: null
|
|
12131
|
+
);
|
|
12132
|
+
|
|
12133
|
+
if (nextTick)
|
|
12134
|
+
{
|
|
12135
|
+
nextTick(fn);
|
|
12136
|
+
}
|
|
12137
|
+
else
|
|
12138
|
+
{
|
|
12139
|
+
setTimeout(fn, 0);
|
|
12140
|
+
}
|
|
12141
|
+
}
|
|
12142
|
+
return defer_1;
|
|
12143
|
+
}
|
|
11977
12144
|
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
|
|
11981
|
-
/**
|
|
11982
|
-
* Module exports.
|
|
11983
|
-
* @public
|
|
11984
|
-
*/
|
|
12145
|
+
var async_1;
|
|
12146
|
+
var hasRequiredAsync;
|
|
11985
12147
|
|
|
11986
|
-
|
|
11987
|
-
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
exports.extensions = Object.create(null);
|
|
11991
|
-
exports.lookup = lookup;
|
|
11992
|
-
exports.types = Object.create(null);
|
|
12148
|
+
function requireAsync () {
|
|
12149
|
+
if (hasRequiredAsync) return async_1;
|
|
12150
|
+
hasRequiredAsync = 1;
|
|
12151
|
+
var defer = requireDefer();
|
|
11993
12152
|
|
|
11994
|
-
//
|
|
11995
|
-
|
|
12153
|
+
// API
|
|
12154
|
+
async_1 = async;
|
|
11996
12155
|
|
|
11997
12156
|
/**
|
|
11998
|
-
*
|
|
12157
|
+
* Runs provided callback asynchronously
|
|
12158
|
+
* even if callback itself is not
|
|
11999
12159
|
*
|
|
12000
|
-
* @param
|
|
12001
|
-
* @
|
|
12160
|
+
* @param {function} callback - callback to invoke
|
|
12161
|
+
* @returns {function} - augmented callback
|
|
12002
12162
|
*/
|
|
12163
|
+
function async(callback)
|
|
12164
|
+
{
|
|
12165
|
+
var isAsync = false;
|
|
12166
|
+
|
|
12167
|
+
// check if async happened
|
|
12168
|
+
defer(function() { isAsync = true; });
|
|
12169
|
+
|
|
12170
|
+
return function async_callback(err, result)
|
|
12171
|
+
{
|
|
12172
|
+
if (isAsync)
|
|
12173
|
+
{
|
|
12174
|
+
callback(err, result);
|
|
12175
|
+
}
|
|
12176
|
+
else
|
|
12177
|
+
{
|
|
12178
|
+
defer(function nextTick_callback()
|
|
12179
|
+
{
|
|
12180
|
+
callback(err, result);
|
|
12181
|
+
});
|
|
12182
|
+
}
|
|
12183
|
+
};
|
|
12184
|
+
}
|
|
12185
|
+
return async_1;
|
|
12186
|
+
}
|
|
12003
12187
|
|
|
12004
|
-
|
|
12005
|
-
|
|
12006
|
-
return false
|
|
12007
|
-
}
|
|
12008
|
-
|
|
12009
|
-
// TODO: use media-typer
|
|
12010
|
-
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
12011
|
-
var mime = match && db[match[1].toLowerCase()];
|
|
12188
|
+
var abort_1;
|
|
12189
|
+
var hasRequiredAbort;
|
|
12012
12190
|
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12191
|
+
function requireAbort () {
|
|
12192
|
+
if (hasRequiredAbort) return abort_1;
|
|
12193
|
+
hasRequiredAbort = 1;
|
|
12194
|
+
// API
|
|
12195
|
+
abort_1 = abort;
|
|
12016
12196
|
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12197
|
+
/**
|
|
12198
|
+
* Aborts leftover active jobs
|
|
12199
|
+
*
|
|
12200
|
+
* @param {object} state - current state object
|
|
12201
|
+
*/
|
|
12202
|
+
function abort(state)
|
|
12203
|
+
{
|
|
12204
|
+
Object.keys(state.jobs).forEach(clean.bind(state));
|
|
12021
12205
|
|
|
12022
|
-
|
|
12206
|
+
// reset leftover jobs
|
|
12207
|
+
state.jobs = {};
|
|
12023
12208
|
}
|
|
12024
12209
|
|
|
12025
12210
|
/**
|
|
12026
|
-
*
|
|
12211
|
+
* Cleans up leftover job by invoking abort function for the provided job id
|
|
12027
12212
|
*
|
|
12028
|
-
* @
|
|
12029
|
-
* @
|
|
12213
|
+
* @this state
|
|
12214
|
+
* @param {string|number} key - job id to abort
|
|
12030
12215
|
*/
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12216
|
+
function clean(key)
|
|
12217
|
+
{
|
|
12218
|
+
if (typeof this.jobs[key] == 'function')
|
|
12219
|
+
{
|
|
12220
|
+
this.jobs[key]();
|
|
12036
12221
|
}
|
|
12222
|
+
}
|
|
12223
|
+
return abort_1;
|
|
12224
|
+
}
|
|
12037
12225
|
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
: str;
|
|
12226
|
+
var iterate_1;
|
|
12227
|
+
var hasRequiredIterate;
|
|
12041
12228
|
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12229
|
+
function requireIterate () {
|
|
12230
|
+
if (hasRequiredIterate) return iterate_1;
|
|
12231
|
+
hasRequiredIterate = 1;
|
|
12232
|
+
var async = requireAsync()
|
|
12233
|
+
, abort = requireAbort()
|
|
12234
|
+
;
|
|
12045
12235
|
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
var charset = exports.charset(mime);
|
|
12049
|
-
if (charset) mime += '; charset=' + charset.toLowerCase();
|
|
12050
|
-
}
|
|
12051
|
-
|
|
12052
|
-
return mime
|
|
12053
|
-
}
|
|
12236
|
+
// API
|
|
12237
|
+
iterate_1 = iterate;
|
|
12054
12238
|
|
|
12055
12239
|
/**
|
|
12056
|
-
*
|
|
12240
|
+
* Iterates over each job object
|
|
12057
12241
|
*
|
|
12058
|
-
* @param {
|
|
12059
|
-
* @
|
|
12242
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12243
|
+
* @param {function} iterator - iterator to run
|
|
12244
|
+
* @param {object} state - current job status
|
|
12245
|
+
* @param {function} callback - invoked when all elements processed
|
|
12060
12246
|
*/
|
|
12247
|
+
function iterate(list, iterator, state, callback)
|
|
12248
|
+
{
|
|
12249
|
+
// store current index
|
|
12250
|
+
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
|
12251
|
+
|
|
12252
|
+
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
|
12253
|
+
{
|
|
12254
|
+
// don't repeat yourself
|
|
12255
|
+
// skip secondary callbacks
|
|
12256
|
+
if (!(key in state.jobs))
|
|
12257
|
+
{
|
|
12258
|
+
return;
|
|
12259
|
+
}
|
|
12061
12260
|
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
return false
|
|
12065
|
-
}
|
|
12066
|
-
|
|
12067
|
-
// TODO: use media-typer
|
|
12068
|
-
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
12069
|
-
|
|
12070
|
-
// get extensions
|
|
12071
|
-
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
12261
|
+
// clean up jobs
|
|
12262
|
+
delete state.jobs[key];
|
|
12072
12263
|
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12264
|
+
if (error)
|
|
12265
|
+
{
|
|
12266
|
+
// don't process rest of the results
|
|
12267
|
+
// stop still active jobs
|
|
12268
|
+
// and reset the list
|
|
12269
|
+
abort(state);
|
|
12270
|
+
}
|
|
12271
|
+
else
|
|
12272
|
+
{
|
|
12273
|
+
state.results[key] = output;
|
|
12274
|
+
}
|
|
12076
12275
|
|
|
12077
|
-
|
|
12276
|
+
// return salvaged results
|
|
12277
|
+
callback(error, state.results);
|
|
12278
|
+
});
|
|
12078
12279
|
}
|
|
12079
12280
|
|
|
12080
12281
|
/**
|
|
12081
|
-
*
|
|
12282
|
+
* Runs iterator over provided job element
|
|
12082
12283
|
*
|
|
12083
|
-
* @param
|
|
12084
|
-
* @
|
|
12284
|
+
* @param {function} iterator - iterator to invoke
|
|
12285
|
+
* @param {string|number} key - key/index of the element in the list of jobs
|
|
12286
|
+
* @param {mixed} item - job description
|
|
12287
|
+
* @param {function} callback - invoked after iterator is done with the job
|
|
12288
|
+
* @returns {function|mixed} - job abort function or something else
|
|
12085
12289
|
*/
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12290
|
+
function runJob(iterator, key, item, callback)
|
|
12291
|
+
{
|
|
12292
|
+
var aborter;
|
|
12293
|
+
|
|
12294
|
+
// allow shortcut if iterator expects only two arguments
|
|
12295
|
+
if (iterator.length == 2)
|
|
12296
|
+
{
|
|
12297
|
+
aborter = iterator(item, async(callback));
|
|
12090
12298
|
}
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
.substr(1);
|
|
12096
|
-
|
|
12097
|
-
if (!extension) {
|
|
12098
|
-
return false
|
|
12299
|
+
// otherwise go with full three arguments
|
|
12300
|
+
else
|
|
12301
|
+
{
|
|
12302
|
+
aborter = iterator(item, key, async(callback));
|
|
12099
12303
|
}
|
|
12100
12304
|
|
|
12101
|
-
return
|
|
12305
|
+
return aborter;
|
|
12102
12306
|
}
|
|
12307
|
+
return iterate_1;
|
|
12308
|
+
}
|
|
12103
12309
|
|
|
12104
|
-
|
|
12105
|
-
|
|
12106
|
-
* @private
|
|
12107
|
-
*/
|
|
12108
|
-
|
|
12109
|
-
function populateMaps (extensions, types) {
|
|
12110
|
-
// source preference (least -> most)
|
|
12111
|
-
var preference = ['nginx', 'apache', undefined, 'iana'];
|
|
12310
|
+
var state_1;
|
|
12311
|
+
var hasRequiredState;
|
|
12112
12312
|
|
|
12113
|
-
|
|
12114
|
-
|
|
12115
|
-
|
|
12313
|
+
function requireState () {
|
|
12314
|
+
if (hasRequiredState) return state_1;
|
|
12315
|
+
hasRequiredState = 1;
|
|
12316
|
+
// API
|
|
12317
|
+
state_1 = state;
|
|
12116
12318
|
|
|
12117
|
-
|
|
12118
|
-
|
|
12319
|
+
/**
|
|
12320
|
+
* Creates initial state object
|
|
12321
|
+
* for iteration over list
|
|
12322
|
+
*
|
|
12323
|
+
* @param {array|object} list - list to iterate over
|
|
12324
|
+
* @param {function|null} sortMethod - function to use for keys sort,
|
|
12325
|
+
* or `null` to keep them as is
|
|
12326
|
+
* @returns {object} - initial state object
|
|
12327
|
+
*/
|
|
12328
|
+
function state(list, sortMethod)
|
|
12329
|
+
{
|
|
12330
|
+
var isNamedList = !Array.isArray(list)
|
|
12331
|
+
, initState =
|
|
12332
|
+
{
|
|
12333
|
+
index : 0,
|
|
12334
|
+
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
|
|
12335
|
+
jobs : {},
|
|
12336
|
+
results : isNamedList ? {} : [],
|
|
12337
|
+
size : isNamedList ? Object.keys(list).length : list.length
|
|
12119
12338
|
}
|
|
12339
|
+
;
|
|
12340
|
+
|
|
12341
|
+
if (sortMethod)
|
|
12342
|
+
{
|
|
12343
|
+
// sort array keys based on it's values
|
|
12344
|
+
// sort object's keys just on own merit
|
|
12345
|
+
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
|
12346
|
+
{
|
|
12347
|
+
return sortMethod(list[a], list[b]);
|
|
12348
|
+
});
|
|
12349
|
+
}
|
|
12120
12350
|
|
|
12121
|
-
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
for (var i = 0; i < exts.length; i++) {
|
|
12126
|
-
var extension = exts[i];
|
|
12351
|
+
return initState;
|
|
12352
|
+
}
|
|
12353
|
+
return state_1;
|
|
12354
|
+
}
|
|
12127
12355
|
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
var to = preference.indexOf(mime.source);
|
|
12356
|
+
var terminator_1;
|
|
12357
|
+
var hasRequiredTerminator;
|
|
12131
12358
|
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
|
|
12137
|
-
|
|
12359
|
+
function requireTerminator () {
|
|
12360
|
+
if (hasRequiredTerminator) return terminator_1;
|
|
12361
|
+
hasRequiredTerminator = 1;
|
|
12362
|
+
var abort = requireAbort()
|
|
12363
|
+
, async = requireAsync()
|
|
12364
|
+
;
|
|
12138
12365
|
|
|
12139
|
-
|
|
12140
|
-
|
|
12141
|
-
}
|
|
12142
|
-
});
|
|
12143
|
-
}
|
|
12144
|
-
} (mimeTypes));
|
|
12145
|
-
|
|
12146
|
-
var defer_1 = defer$1;
|
|
12366
|
+
// API
|
|
12367
|
+
terminator_1 = terminator;
|
|
12147
12368
|
|
|
12148
|
-
/**
|
|
12149
|
-
|
|
12150
|
-
|
|
12151
|
-
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
: null
|
|
12161
|
-
);
|
|
12162
|
-
|
|
12163
|
-
if (nextTick)
|
|
12164
|
-
{
|
|
12165
|
-
nextTick(fn);
|
|
12166
|
-
}
|
|
12167
|
-
else
|
|
12168
|
-
{
|
|
12169
|
-
setTimeout(fn, 0);
|
|
12170
|
-
}
|
|
12171
|
-
}
|
|
12369
|
+
/**
|
|
12370
|
+
* Terminates jobs in the attached state context
|
|
12371
|
+
*
|
|
12372
|
+
* @this AsyncKitState#
|
|
12373
|
+
* @param {function} callback - final callback to invoke after termination
|
|
12374
|
+
*/
|
|
12375
|
+
function terminator(callback)
|
|
12376
|
+
{
|
|
12377
|
+
if (!Object.keys(this.jobs).length)
|
|
12378
|
+
{
|
|
12379
|
+
return;
|
|
12380
|
+
}
|
|
12172
12381
|
|
|
12173
|
-
|
|
12382
|
+
// fast forward iteration index
|
|
12383
|
+
this.index = this.size;
|
|
12174
12384
|
|
|
12175
|
-
//
|
|
12176
|
-
|
|
12385
|
+
// abort jobs
|
|
12386
|
+
abort(this);
|
|
12177
12387
|
|
|
12178
|
-
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
* @param {function} callback - callback to invoke
|
|
12183
|
-
* @returns {function} - augmented callback
|
|
12184
|
-
*/
|
|
12185
|
-
function async$2(callback)
|
|
12186
|
-
{
|
|
12187
|
-
var isAsync = false;
|
|
12188
|
-
|
|
12189
|
-
// check if async happened
|
|
12190
|
-
defer(function() { isAsync = true; });
|
|
12191
|
-
|
|
12192
|
-
return function async_callback(err, result)
|
|
12193
|
-
{
|
|
12194
|
-
if (isAsync)
|
|
12195
|
-
{
|
|
12196
|
-
callback(err, result);
|
|
12197
|
-
}
|
|
12198
|
-
else
|
|
12199
|
-
{
|
|
12200
|
-
defer(function nextTick_callback()
|
|
12201
|
-
{
|
|
12202
|
-
callback(err, result);
|
|
12203
|
-
});
|
|
12204
|
-
}
|
|
12205
|
-
};
|
|
12388
|
+
// send back results we have so far
|
|
12389
|
+
async(callback)(null, this.results);
|
|
12390
|
+
}
|
|
12391
|
+
return terminator_1;
|
|
12206
12392
|
}
|
|
12207
12393
|
|
|
12208
|
-
|
|
12209
|
-
var
|
|
12394
|
+
var parallel_1;
|
|
12395
|
+
var hasRequiredParallel;
|
|
12210
12396
|
|
|
12211
|
-
|
|
12212
|
-
|
|
12213
|
-
|
|
12214
|
-
|
|
12215
|
-
|
|
12216
|
-
|
|
12217
|
-
|
|
12218
|
-
Object.keys(state.jobs).forEach(clean.bind(state));
|
|
12397
|
+
function requireParallel () {
|
|
12398
|
+
if (hasRequiredParallel) return parallel_1;
|
|
12399
|
+
hasRequiredParallel = 1;
|
|
12400
|
+
var iterate = requireIterate()
|
|
12401
|
+
, initState = requireState()
|
|
12402
|
+
, terminator = requireTerminator()
|
|
12403
|
+
;
|
|
12219
12404
|
|
|
12220
|
-
|
|
12221
|
-
|
|
12222
|
-
}
|
|
12405
|
+
// Public API
|
|
12406
|
+
parallel_1 = parallel;
|
|
12223
12407
|
|
|
12224
|
-
/**
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
|
|
12229
|
-
|
|
12230
|
-
function
|
|
12231
|
-
|
|
12232
|
-
|
|
12233
|
-
|
|
12234
|
-
|
|
12235
|
-
|
|
12236
|
-
|
|
12408
|
+
/**
|
|
12409
|
+
* Runs iterator over provided array elements in parallel
|
|
12410
|
+
*
|
|
12411
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12412
|
+
* @param {function} iterator - iterator to run
|
|
12413
|
+
* @param {function} callback - invoked when all elements processed
|
|
12414
|
+
* @returns {function} - jobs terminator
|
|
12415
|
+
*/
|
|
12416
|
+
function parallel(list, iterator, callback)
|
|
12417
|
+
{
|
|
12418
|
+
var state = initState(list);
|
|
12419
|
+
|
|
12420
|
+
while (state.index < (state['keyedList'] || list).length)
|
|
12421
|
+
{
|
|
12422
|
+
iterate(list, iterator, state, function(error, result)
|
|
12423
|
+
{
|
|
12424
|
+
if (error)
|
|
12425
|
+
{
|
|
12426
|
+
callback(error, result);
|
|
12427
|
+
return;
|
|
12428
|
+
}
|
|
12237
12429
|
|
|
12238
|
-
|
|
12239
|
-
|
|
12240
|
-
|
|
12430
|
+
// looks like it's the last one
|
|
12431
|
+
if (Object.keys(state.jobs).length === 0)
|
|
12432
|
+
{
|
|
12433
|
+
callback(null, state.results);
|
|
12434
|
+
return;
|
|
12435
|
+
}
|
|
12436
|
+
});
|
|
12241
12437
|
|
|
12242
|
-
|
|
12243
|
-
|
|
12438
|
+
state.index++;
|
|
12439
|
+
}
|
|
12244
12440
|
|
|
12245
|
-
|
|
12246
|
-
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
* @param {function} iterator - iterator to run
|
|
12250
|
-
* @param {object} state - current job status
|
|
12251
|
-
* @param {function} callback - invoked when all elements processed
|
|
12252
|
-
*/
|
|
12253
|
-
function iterate$2(list, iterator, state, callback)
|
|
12254
|
-
{
|
|
12255
|
-
// store current index
|
|
12256
|
-
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
|
12257
|
-
|
|
12258
|
-
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
|
12259
|
-
{
|
|
12260
|
-
// don't repeat yourself
|
|
12261
|
-
// skip secondary callbacks
|
|
12262
|
-
if (!(key in state.jobs))
|
|
12263
|
-
{
|
|
12264
|
-
return;
|
|
12265
|
-
}
|
|
12441
|
+
return terminator.bind(state, callback);
|
|
12442
|
+
}
|
|
12443
|
+
return parallel_1;
|
|
12444
|
+
}
|
|
12266
12445
|
|
|
12267
|
-
|
|
12268
|
-
delete state.jobs[key];
|
|
12446
|
+
var serialOrdered = {exports: {}};
|
|
12269
12447
|
|
|
12270
|
-
|
|
12271
|
-
{
|
|
12272
|
-
// don't process rest of the results
|
|
12273
|
-
// stop still active jobs
|
|
12274
|
-
// and reset the list
|
|
12275
|
-
abort$1(state);
|
|
12276
|
-
}
|
|
12277
|
-
else
|
|
12278
|
-
{
|
|
12279
|
-
state.results[key] = output;
|
|
12280
|
-
}
|
|
12448
|
+
var hasRequiredSerialOrdered;
|
|
12281
12449
|
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
12450
|
+
function requireSerialOrdered () {
|
|
12451
|
+
if (hasRequiredSerialOrdered) return serialOrdered.exports;
|
|
12452
|
+
hasRequiredSerialOrdered = 1;
|
|
12453
|
+
var iterate = requireIterate()
|
|
12454
|
+
, initState = requireState()
|
|
12455
|
+
, terminator = requireTerminator()
|
|
12456
|
+
;
|
|
12286
12457
|
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12291
|
-
|
|
12292
|
-
* @param {mixed} item - job description
|
|
12293
|
-
* @param {function} callback - invoked after iterator is done with the job
|
|
12294
|
-
* @returns {function|mixed} - job abort function or something else
|
|
12295
|
-
*/
|
|
12296
|
-
function runJob(iterator, key, item, callback)
|
|
12297
|
-
{
|
|
12298
|
-
var aborter;
|
|
12299
|
-
|
|
12300
|
-
// allow shortcut if iterator expects only two arguments
|
|
12301
|
-
if (iterator.length == 2)
|
|
12302
|
-
{
|
|
12303
|
-
aborter = iterator(item, async$1(callback));
|
|
12304
|
-
}
|
|
12305
|
-
// otherwise go with full three arguments
|
|
12306
|
-
else
|
|
12307
|
-
{
|
|
12308
|
-
aborter = iterator(item, key, async$1(callback));
|
|
12309
|
-
}
|
|
12310
|
-
|
|
12311
|
-
return aborter;
|
|
12312
|
-
}
|
|
12458
|
+
// Public API
|
|
12459
|
+
serialOrdered.exports = serialOrdered$1;
|
|
12460
|
+
// sorting helpers
|
|
12461
|
+
serialOrdered.exports.ascending = ascending;
|
|
12462
|
+
serialOrdered.exports.descending = descending;
|
|
12313
12463
|
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
|
|
12318
|
-
|
|
12319
|
-
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12327
|
-
|
|
12328
|
-
|
|
12329
|
-
|
|
12330
|
-
|
|
12331
|
-
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
results : isNamedList ? {} : [],
|
|
12335
|
-
size : isNamedList ? Object.keys(list).length : list.length
|
|
12336
|
-
}
|
|
12337
|
-
;
|
|
12338
|
-
|
|
12339
|
-
if (sortMethod)
|
|
12340
|
-
{
|
|
12341
|
-
// sort array keys based on it's values
|
|
12342
|
-
// sort object's keys just on own merit
|
|
12343
|
-
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
|
12344
|
-
{
|
|
12345
|
-
return sortMethod(list[a], list[b]);
|
|
12346
|
-
});
|
|
12347
|
-
}
|
|
12464
|
+
/**
|
|
12465
|
+
* Runs iterator over provided sorted array elements in series
|
|
12466
|
+
*
|
|
12467
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12468
|
+
* @param {function} iterator - iterator to run
|
|
12469
|
+
* @param {function} sortMethod - custom sort function
|
|
12470
|
+
* @param {function} callback - invoked when all elements processed
|
|
12471
|
+
* @returns {function} - jobs terminator
|
|
12472
|
+
*/
|
|
12473
|
+
function serialOrdered$1(list, iterator, sortMethod, callback)
|
|
12474
|
+
{
|
|
12475
|
+
var state = initState(list, sortMethod);
|
|
12476
|
+
|
|
12477
|
+
iterate(list, iterator, state, function iteratorHandler(error, result)
|
|
12478
|
+
{
|
|
12479
|
+
if (error)
|
|
12480
|
+
{
|
|
12481
|
+
callback(error, result);
|
|
12482
|
+
return;
|
|
12483
|
+
}
|
|
12348
12484
|
|
|
12349
|
-
|
|
12350
|
-
}
|
|
12485
|
+
state.index++;
|
|
12351
12486
|
|
|
12352
|
-
|
|
12353
|
-
|
|
12354
|
-
|
|
12487
|
+
// are we there yet?
|
|
12488
|
+
if (state.index < (state['keyedList'] || list).length)
|
|
12489
|
+
{
|
|
12490
|
+
iterate(list, iterator, state, iteratorHandler);
|
|
12491
|
+
return;
|
|
12492
|
+
}
|
|
12355
12493
|
|
|
12356
|
-
//
|
|
12357
|
-
|
|
12494
|
+
// done here
|
|
12495
|
+
callback(null, state.results);
|
|
12496
|
+
});
|
|
12358
12497
|
|
|
12359
|
-
|
|
12360
|
-
|
|
12361
|
-
*
|
|
12362
|
-
* @this AsyncKitState#
|
|
12363
|
-
* @param {function} callback - final callback to invoke after termination
|
|
12364
|
-
*/
|
|
12365
|
-
function terminator$2(callback)
|
|
12366
|
-
{
|
|
12367
|
-
if (!Object.keys(this.jobs).length)
|
|
12368
|
-
{
|
|
12369
|
-
return;
|
|
12370
|
-
}
|
|
12498
|
+
return terminator.bind(state, callback);
|
|
12499
|
+
}
|
|
12371
12500
|
|
|
12372
|
-
|
|
12373
|
-
|
|
12501
|
+
/*
|
|
12502
|
+
* -- Sort methods
|
|
12503
|
+
*/
|
|
12374
12504
|
|
|
12375
|
-
|
|
12376
|
-
|
|
12505
|
+
/**
|
|
12506
|
+
* sort helper to sort array elements in ascending order
|
|
12507
|
+
*
|
|
12508
|
+
* @param {mixed} a - an item to compare
|
|
12509
|
+
* @param {mixed} b - an item to compare
|
|
12510
|
+
* @returns {number} - comparison result
|
|
12511
|
+
*/
|
|
12512
|
+
function ascending(a, b)
|
|
12513
|
+
{
|
|
12514
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
12515
|
+
}
|
|
12377
12516
|
|
|
12378
|
-
|
|
12379
|
-
|
|
12517
|
+
/**
|
|
12518
|
+
* sort helper to sort array elements in descending order
|
|
12519
|
+
*
|
|
12520
|
+
* @param {mixed} a - an item to compare
|
|
12521
|
+
* @param {mixed} b - an item to compare
|
|
12522
|
+
* @returns {number} - comparison result
|
|
12523
|
+
*/
|
|
12524
|
+
function descending(a, b)
|
|
12525
|
+
{
|
|
12526
|
+
return -1 * ascending(a, b);
|
|
12527
|
+
}
|
|
12528
|
+
return serialOrdered.exports;
|
|
12380
12529
|
}
|
|
12381
12530
|
|
|
12382
|
-
var
|
|
12383
|
-
|
|
12384
|
-
, terminator$1 = terminator_1
|
|
12385
|
-
;
|
|
12386
|
-
|
|
12387
|
-
// Public API
|
|
12388
|
-
var parallel_1 = parallel;
|
|
12389
|
-
|
|
12390
|
-
/**
|
|
12391
|
-
* Runs iterator over provided array elements in parallel
|
|
12392
|
-
*
|
|
12393
|
-
* @param {array|object} list - array or object (named list) to iterate over
|
|
12394
|
-
* @param {function} iterator - iterator to run
|
|
12395
|
-
* @param {function} callback - invoked when all elements processed
|
|
12396
|
-
* @returns {function} - jobs terminator
|
|
12397
|
-
*/
|
|
12398
|
-
function parallel(list, iterator, callback)
|
|
12399
|
-
{
|
|
12400
|
-
var state = initState$1(list);
|
|
12401
|
-
|
|
12402
|
-
while (state.index < (state['keyedList'] || list).length)
|
|
12403
|
-
{
|
|
12404
|
-
iterate$1(list, iterator, state, function(error, result)
|
|
12405
|
-
{
|
|
12406
|
-
if (error)
|
|
12407
|
-
{
|
|
12408
|
-
callback(error, result);
|
|
12409
|
-
return;
|
|
12410
|
-
}
|
|
12531
|
+
var serial_1;
|
|
12532
|
+
var hasRequiredSerial;
|
|
12411
12533
|
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
return;
|
|
12417
|
-
}
|
|
12418
|
-
});
|
|
12534
|
+
function requireSerial () {
|
|
12535
|
+
if (hasRequiredSerial) return serial_1;
|
|
12536
|
+
hasRequiredSerial = 1;
|
|
12537
|
+
var serialOrdered = requireSerialOrdered();
|
|
12419
12538
|
|
|
12420
|
-
|
|
12421
|
-
|
|
12539
|
+
// Public API
|
|
12540
|
+
serial_1 = serial;
|
|
12422
12541
|
|
|
12423
|
-
|
|
12542
|
+
/**
|
|
12543
|
+
* Runs iterator over provided array elements in series
|
|
12544
|
+
*
|
|
12545
|
+
* @param {array|object} list - array or object (named list) to iterate over
|
|
12546
|
+
* @param {function} iterator - iterator to run
|
|
12547
|
+
* @param {function} callback - invoked when all elements processed
|
|
12548
|
+
* @returns {function} - jobs terminator
|
|
12549
|
+
*/
|
|
12550
|
+
function serial(list, iterator, callback)
|
|
12551
|
+
{
|
|
12552
|
+
return serialOrdered(list, iterator, null, callback);
|
|
12553
|
+
}
|
|
12554
|
+
return serial_1;
|
|
12424
12555
|
}
|
|
12425
12556
|
|
|
12426
|
-
var
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
serialOrdered
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
* Runs iterator over provided sorted array elements in series
|
|
12441
|
-
*
|
|
12442
|
-
* @param {array|object} list - array or object (named list) to iterate over
|
|
12443
|
-
* @param {function} iterator - iterator to run
|
|
12444
|
-
* @param {function} sortMethod - custom sort function
|
|
12445
|
-
* @param {function} callback - invoked when all elements processed
|
|
12446
|
-
* @returns {function} - jobs terminator
|
|
12447
|
-
*/
|
|
12448
|
-
function serialOrdered$1(list, iterator, sortMethod, callback)
|
|
12449
|
-
{
|
|
12450
|
-
var state = initState(list, sortMethod);
|
|
12451
|
-
|
|
12452
|
-
iterate(list, iterator, state, function iteratorHandler(error, result)
|
|
12453
|
-
{
|
|
12454
|
-
if (error)
|
|
12455
|
-
{
|
|
12456
|
-
callback(error, result);
|
|
12457
|
-
return;
|
|
12458
|
-
}
|
|
12557
|
+
var asynckit;
|
|
12558
|
+
var hasRequiredAsynckit;
|
|
12559
|
+
|
|
12560
|
+
function requireAsynckit () {
|
|
12561
|
+
if (hasRequiredAsynckit) return asynckit;
|
|
12562
|
+
hasRequiredAsynckit = 1;
|
|
12563
|
+
asynckit =
|
|
12564
|
+
{
|
|
12565
|
+
parallel : requireParallel(),
|
|
12566
|
+
serial : requireSerial(),
|
|
12567
|
+
serialOrdered : requireSerialOrdered()
|
|
12568
|
+
};
|
|
12569
|
+
return asynckit;
|
|
12570
|
+
}
|
|
12459
12571
|
|
|
12460
|
-
|
|
12572
|
+
var populate;
|
|
12573
|
+
var hasRequiredPopulate;
|
|
12461
12574
|
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
}
|
|
12575
|
+
function requirePopulate () {
|
|
12576
|
+
if (hasRequiredPopulate) return populate;
|
|
12577
|
+
hasRequiredPopulate = 1;
|
|
12578
|
+
// populates missing values
|
|
12579
|
+
populate = function(dst, src) {
|
|
12468
12580
|
|
|
12469
|
-
|
|
12470
|
-
|
|
12471
|
-
|
|
12581
|
+
Object.keys(src).forEach(function(prop)
|
|
12582
|
+
{
|
|
12583
|
+
dst[prop] = dst[prop] || src[prop];
|
|
12584
|
+
});
|
|
12472
12585
|
|
|
12473
|
-
|
|
12586
|
+
return dst;
|
|
12587
|
+
};
|
|
12588
|
+
return populate;
|
|
12474
12589
|
}
|
|
12475
12590
|
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12591
|
+
var form_data;
|
|
12592
|
+
var hasRequiredForm_data;
|
|
12593
|
+
|
|
12594
|
+
function requireForm_data () {
|
|
12595
|
+
if (hasRequiredForm_data) return form_data;
|
|
12596
|
+
hasRequiredForm_data = 1;
|
|
12597
|
+
var CombinedStream = requireCombined_stream();
|
|
12598
|
+
var util = require$$1;
|
|
12599
|
+
var path = require$$1$1;
|
|
12600
|
+
var http = require$$3;
|
|
12601
|
+
var https = require$$4;
|
|
12602
|
+
var parseUrl = require$$5.parse;
|
|
12603
|
+
var fs = require$$6;
|
|
12604
|
+
var Stream = require$$0$1.Stream;
|
|
12605
|
+
var mime = requireMimeTypes();
|
|
12606
|
+
var asynckit = requireAsynckit();
|
|
12607
|
+
var populate = requirePopulate();
|
|
12608
|
+
|
|
12609
|
+
// Public API
|
|
12610
|
+
form_data = FormData;
|
|
12611
|
+
|
|
12612
|
+
// make it a Stream
|
|
12613
|
+
util.inherits(FormData, CombinedStream);
|
|
12479
12614
|
|
|
12480
|
-
/**
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
{
|
|
12489
|
-
|
|
12490
|
-
|
|
12615
|
+
/**
|
|
12616
|
+
* Create readable "multipart/form-data" streams.
|
|
12617
|
+
* Can be used to submit forms
|
|
12618
|
+
* and file uploads to other web applications.
|
|
12619
|
+
*
|
|
12620
|
+
* @constructor
|
|
12621
|
+
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
|
12622
|
+
*/
|
|
12623
|
+
function FormData(options) {
|
|
12624
|
+
if (!(this instanceof FormData)) {
|
|
12625
|
+
return new FormData(options);
|
|
12626
|
+
}
|
|
12491
12627
|
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
* @param {mixed} a - an item to compare
|
|
12496
|
-
* @param {mixed} b - an item to compare
|
|
12497
|
-
* @returns {number} - comparison result
|
|
12498
|
-
*/
|
|
12499
|
-
function descending(a, b)
|
|
12500
|
-
{
|
|
12501
|
-
return -1 * ascending(a, b);
|
|
12502
|
-
}
|
|
12628
|
+
this._overheadLength = 0;
|
|
12629
|
+
this._valueLength = 0;
|
|
12630
|
+
this._valuesToMeasure = [];
|
|
12503
12631
|
|
|
12504
|
-
|
|
12632
|
+
CombinedStream.call(this);
|
|
12505
12633
|
|
|
12506
|
-
|
|
12634
|
+
options = options || {};
|
|
12635
|
+
for (var option in options) {
|
|
12636
|
+
this[option] = options[option];
|
|
12637
|
+
}
|
|
12638
|
+
}
|
|
12507
12639
|
|
|
12508
|
-
|
|
12509
|
-
|
|
12640
|
+
FormData.LINE_BREAK = '\r\n';
|
|
12641
|
+
FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream';
|
|
12510
12642
|
|
|
12511
|
-
|
|
12512
|
-
* Runs iterator over provided array elements in series
|
|
12513
|
-
*
|
|
12514
|
-
* @param {array|object} list - array or object (named list) to iterate over
|
|
12515
|
-
* @param {function} iterator - iterator to run
|
|
12516
|
-
* @param {function} callback - invoked when all elements processed
|
|
12517
|
-
* @returns {function} - jobs terminator
|
|
12518
|
-
*/
|
|
12519
|
-
function serial(list, iterator, callback)
|
|
12520
|
-
{
|
|
12521
|
-
return serialOrdered(list, iterator, null, callback);
|
|
12522
|
-
}
|
|
12643
|
+
FormData.prototype.append = function(field, value, options) {
|
|
12523
12644
|
|
|
12524
|
-
|
|
12525
|
-
{
|
|
12526
|
-
parallel : parallel_1,
|
|
12527
|
-
serial : serial_1,
|
|
12528
|
-
serialOrdered : serialOrderedExports
|
|
12529
|
-
};
|
|
12645
|
+
options = options || {};
|
|
12530
12646
|
|
|
12531
|
-
//
|
|
12532
|
-
|
|
12647
|
+
// allow filename as single option
|
|
12648
|
+
if (typeof options == 'string') {
|
|
12649
|
+
options = {filename: options};
|
|
12650
|
+
}
|
|
12533
12651
|
|
|
12534
|
-
|
|
12535
|
-
{
|
|
12536
|
-
dst[prop] = dst[prop] || src[prop];
|
|
12537
|
-
});
|
|
12652
|
+
var append = CombinedStream.prototype.append.bind(this);
|
|
12538
12653
|
|
|
12539
|
-
|
|
12540
|
-
|
|
12654
|
+
// all that streamy business can't handle numbers
|
|
12655
|
+
if (typeof value == 'number') {
|
|
12656
|
+
value = '' + value;
|
|
12657
|
+
}
|
|
12541
12658
|
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
var Stream = require$$0$1.Stream;
|
|
12550
|
-
var mime = mimeTypes;
|
|
12551
|
-
var asynckit = asynckit$1;
|
|
12552
|
-
var populate = populate$1;
|
|
12553
|
-
|
|
12554
|
-
// Public API
|
|
12555
|
-
var form_data = FormData;
|
|
12556
|
-
|
|
12557
|
-
// make it a Stream
|
|
12558
|
-
util.inherits(FormData, CombinedStream);
|
|
12559
|
-
|
|
12560
|
-
/**
|
|
12561
|
-
* Create readable "multipart/form-data" streams.
|
|
12562
|
-
* Can be used to submit forms
|
|
12563
|
-
* and file uploads to other web applications.
|
|
12564
|
-
*
|
|
12565
|
-
* @constructor
|
|
12566
|
-
* @param {Object} options - Properties to be added/overriden for FormData and CombinedStream
|
|
12567
|
-
*/
|
|
12568
|
-
function FormData(options) {
|
|
12569
|
-
if (!(this instanceof FormData)) {
|
|
12570
|
-
return new FormData(options);
|
|
12571
|
-
}
|
|
12659
|
+
// https://github.com/felixge/node-form-data/issues/38
|
|
12660
|
+
if (Array.isArray(value)) {
|
|
12661
|
+
// Please convert your array into string
|
|
12662
|
+
// the way web server expects it
|
|
12663
|
+
this._error(new Error('Arrays are not supported.'));
|
|
12664
|
+
return;
|
|
12665
|
+
}
|
|
12572
12666
|
|
|
12573
|
-
|
|
12574
|
-
|
|
12575
|
-
|
|
12667
|
+
var header = this._multiPartHeader(field, value, options);
|
|
12668
|
+
var footer = this._multiPartFooter();
|
|
12669
|
+
|
|
12670
|
+
append(header);
|
|
12671
|
+
append(value);
|
|
12672
|
+
append(footer);
|
|
12673
|
+
|
|
12674
|
+
// pass along options.knownLength
|
|
12675
|
+
this._trackLength(header, value, options);
|
|
12676
|
+
};
|
|
12677
|
+
|
|
12678
|
+
FormData.prototype._trackLength = function(header, value, options) {
|
|
12679
|
+
var valueLength = 0;
|
|
12680
|
+
|
|
12681
|
+
// used w/ getLengthSync(), when length is known.
|
|
12682
|
+
// e.g. for streaming directly from a remote server,
|
|
12683
|
+
// w/ a known file a size, and not wanting to wait for
|
|
12684
|
+
// incoming file to finish to get its size.
|
|
12685
|
+
if (options.knownLength != null) {
|
|
12686
|
+
valueLength += +options.knownLength;
|
|
12687
|
+
} else if (Buffer.isBuffer(value)) {
|
|
12688
|
+
valueLength = value.length;
|
|
12689
|
+
} else if (typeof value === 'string') {
|
|
12690
|
+
valueLength = Buffer.byteLength(value);
|
|
12691
|
+
}
|
|
12576
12692
|
|
|
12577
|
-
|
|
12693
|
+
this._valueLength += valueLength;
|
|
12578
12694
|
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
|
|
12582
|
-
|
|
12583
|
-
}
|
|
12695
|
+
// @check why add CRLF? does this account for custom/multiple CRLFs?
|
|
12696
|
+
this._overheadLength +=
|
|
12697
|
+
Buffer.byteLength(header) +
|
|
12698
|
+
FormData.LINE_BREAK.length;
|
|
12584
12699
|
|
|
12585
|
-
|
|
12586
|
-
|
|
12700
|
+
// empty or either doesn't have path or not an http response or not a stream
|
|
12701
|
+
if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) {
|
|
12702
|
+
return;
|
|
12703
|
+
}
|
|
12587
12704
|
|
|
12588
|
-
|
|
12705
|
+
// no need to bother with the length
|
|
12706
|
+
if (!options.knownLength) {
|
|
12707
|
+
this._valuesToMeasure.push(value);
|
|
12708
|
+
}
|
|
12709
|
+
};
|
|
12589
12710
|
|
|
12590
|
-
|
|
12711
|
+
FormData.prototype._lengthRetriever = function(value, callback) {
|
|
12591
12712
|
|
|
12592
|
-
|
|
12593
|
-
if (typeof options == 'string') {
|
|
12594
|
-
options = {filename: options};
|
|
12595
|
-
}
|
|
12713
|
+
if (value.hasOwnProperty('fd')) {
|
|
12596
12714
|
|
|
12597
|
-
|
|
12715
|
+
// take read range into a account
|
|
12716
|
+
// `end` = Infinity –> read file till the end
|
|
12717
|
+
//
|
|
12718
|
+
// TODO: Looks like there is bug in Node fs.createReadStream
|
|
12719
|
+
// it doesn't respect `end` options without `start` options
|
|
12720
|
+
// Fix it when node fixes it.
|
|
12721
|
+
// https://github.com/joyent/node/issues/7819
|
|
12722
|
+
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
|
12598
12723
|
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12724
|
+
// when end specified
|
|
12725
|
+
// no need to calculate range
|
|
12726
|
+
// inclusive, starts with 0
|
|
12727
|
+
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
|
12603
12728
|
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
this._error(new Error('Arrays are not supported.'));
|
|
12609
|
-
return;
|
|
12610
|
-
}
|
|
12729
|
+
// not that fast snoopy
|
|
12730
|
+
} else {
|
|
12731
|
+
// still need to fetch file size from fs
|
|
12732
|
+
fs.stat(value.path, function(err, stat) {
|
|
12611
12733
|
|
|
12612
|
-
|
|
12613
|
-
var footer = this._multiPartFooter();
|
|
12734
|
+
var fileSize;
|
|
12614
12735
|
|
|
12615
|
-
|
|
12616
|
-
|
|
12617
|
-
|
|
12736
|
+
if (err) {
|
|
12737
|
+
callback(err);
|
|
12738
|
+
return;
|
|
12739
|
+
}
|
|
12618
12740
|
|
|
12619
|
-
|
|
12620
|
-
|
|
12621
|
-
|
|
12741
|
+
// update final size based on the range options
|
|
12742
|
+
fileSize = stat.size - (value.start ? value.start : 0);
|
|
12743
|
+
callback(null, fileSize);
|
|
12744
|
+
});
|
|
12745
|
+
}
|
|
12622
12746
|
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
|
|
12628
|
-
|
|
12629
|
-
|
|
12630
|
-
|
|
12631
|
-
|
|
12632
|
-
|
|
12633
|
-
|
|
12634
|
-
|
|
12635
|
-
|
|
12636
|
-
|
|
12637
|
-
|
|
12638
|
-
|
|
12639
|
-
|
|
12640
|
-
|
|
12641
|
-
|
|
12642
|
-
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12747
|
+
// or http response
|
|
12748
|
+
} else if (value.hasOwnProperty('httpVersion')) {
|
|
12749
|
+
callback(null, +value.headers['content-length']);
|
|
12750
|
+
|
|
12751
|
+
// or request stream http://github.com/mikeal/request
|
|
12752
|
+
} else if (value.hasOwnProperty('httpModule')) {
|
|
12753
|
+
// wait till response come back
|
|
12754
|
+
value.on('response', function(response) {
|
|
12755
|
+
value.pause();
|
|
12756
|
+
callback(null, +response.headers['content-length']);
|
|
12757
|
+
});
|
|
12758
|
+
value.resume();
|
|
12759
|
+
|
|
12760
|
+
// something else
|
|
12761
|
+
} else {
|
|
12762
|
+
callback('Unknown stream');
|
|
12763
|
+
}
|
|
12764
|
+
};
|
|
12765
|
+
|
|
12766
|
+
FormData.prototype._multiPartHeader = function(field, value, options) {
|
|
12767
|
+
// custom header specified (as string)?
|
|
12768
|
+
// it becomes responsible for boundary
|
|
12769
|
+
// (e.g. to handle extra CRLFs on .NET servers)
|
|
12770
|
+
if (typeof options.header == 'string') {
|
|
12771
|
+
return options.header;
|
|
12772
|
+
}
|
|
12649
12773
|
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
this._valuesToMeasure.push(value);
|
|
12653
|
-
}
|
|
12654
|
-
};
|
|
12774
|
+
var contentDisposition = this._getContentDisposition(value, options);
|
|
12775
|
+
var contentType = this._getContentType(value, options);
|
|
12655
12776
|
|
|
12656
|
-
|
|
12777
|
+
var contents = '';
|
|
12778
|
+
var headers = {
|
|
12779
|
+
// add custom disposition as third element or keep it two elements if not
|
|
12780
|
+
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
|
12781
|
+
// if no content type. allow it to be empty array
|
|
12782
|
+
'Content-Type': [].concat(contentType || [])
|
|
12783
|
+
};
|
|
12657
12784
|
|
|
12658
|
-
|
|
12785
|
+
// allow custom headers.
|
|
12786
|
+
if (typeof options.header == 'object') {
|
|
12787
|
+
populate(headers, options.header);
|
|
12788
|
+
}
|
|
12659
12789
|
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
// it doesn't respect `end` options without `start` options
|
|
12665
|
-
// Fix it when node fixes it.
|
|
12666
|
-
// https://github.com/joyent/node/issues/7819
|
|
12667
|
-
if (value.end != undefined && value.end != Infinity && value.start != undefined) {
|
|
12790
|
+
var header;
|
|
12791
|
+
for (var prop in headers) {
|
|
12792
|
+
if (!headers.hasOwnProperty(prop)) continue;
|
|
12793
|
+
header = headers[prop];
|
|
12668
12794
|
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12795
|
+
// skip nullish headers.
|
|
12796
|
+
if (header == null) {
|
|
12797
|
+
continue;
|
|
12798
|
+
}
|
|
12673
12799
|
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
|
|
12677
|
-
|
|
12800
|
+
// convert all headers to arrays.
|
|
12801
|
+
if (!Array.isArray(header)) {
|
|
12802
|
+
header = [header];
|
|
12803
|
+
}
|
|
12678
12804
|
|
|
12679
|
-
|
|
12805
|
+
// add non-empty headers.
|
|
12806
|
+
if (header.length) {
|
|
12807
|
+
contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK;
|
|
12808
|
+
}
|
|
12809
|
+
}
|
|
12680
12810
|
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12811
|
+
return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK;
|
|
12812
|
+
};
|
|
12813
|
+
|
|
12814
|
+
FormData.prototype._getContentDisposition = function(value, options) {
|
|
12815
|
+
|
|
12816
|
+
var filename
|
|
12817
|
+
, contentDisposition
|
|
12818
|
+
;
|
|
12819
|
+
|
|
12820
|
+
if (typeof options.filepath === 'string') {
|
|
12821
|
+
// custom filepath for relative paths
|
|
12822
|
+
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
12823
|
+
} else if (options.filename || value.name || value.path) {
|
|
12824
|
+
// custom filename take precedence
|
|
12825
|
+
// formidable and the browser add a name property
|
|
12826
|
+
// fs- and request- streams have path property
|
|
12827
|
+
filename = path.basename(options.filename || value.name || value.path);
|
|
12828
|
+
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
|
12829
|
+
// or try http response
|
|
12830
|
+
filename = path.basename(value.client._httpMessage.path || '');
|
|
12831
|
+
}
|
|
12685
12832
|
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
});
|
|
12690
|
-
}
|
|
12833
|
+
if (filename) {
|
|
12834
|
+
contentDisposition = 'filename="' + filename + '"';
|
|
12835
|
+
}
|
|
12691
12836
|
|
|
12692
|
-
|
|
12693
|
-
|
|
12694
|
-
callback(null, +value.headers['content-length']);
|
|
12837
|
+
return contentDisposition;
|
|
12838
|
+
};
|
|
12695
12839
|
|
|
12696
|
-
|
|
12697
|
-
} else if (value.hasOwnProperty('httpModule')) {
|
|
12698
|
-
// wait till response come back
|
|
12699
|
-
value.on('response', function(response) {
|
|
12700
|
-
value.pause();
|
|
12701
|
-
callback(null, +response.headers['content-length']);
|
|
12702
|
-
});
|
|
12703
|
-
value.resume();
|
|
12840
|
+
FormData.prototype._getContentType = function(value, options) {
|
|
12704
12841
|
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
callback('Unknown stream');
|
|
12708
|
-
}
|
|
12709
|
-
};
|
|
12842
|
+
// use custom content-type above all
|
|
12843
|
+
var contentType = options.contentType;
|
|
12710
12844
|
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
if (typeof options.header == 'string') {
|
|
12716
|
-
return options.header;
|
|
12717
|
-
}
|
|
12718
|
-
|
|
12719
|
-
var contentDisposition = this._getContentDisposition(value, options);
|
|
12720
|
-
var contentType = this._getContentType(value, options);
|
|
12721
|
-
|
|
12722
|
-
var contents = '';
|
|
12723
|
-
var headers = {
|
|
12724
|
-
// add custom disposition as third element or keep it two elements if not
|
|
12725
|
-
'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []),
|
|
12726
|
-
// if no content type. allow it to be empty array
|
|
12727
|
-
'Content-Type': [].concat(contentType || [])
|
|
12728
|
-
};
|
|
12729
|
-
|
|
12730
|
-
// allow custom headers.
|
|
12731
|
-
if (typeof options.header == 'object') {
|
|
12732
|
-
populate(headers, options.header);
|
|
12733
|
-
}
|
|
12734
|
-
|
|
12735
|
-
var header;
|
|
12736
|
-
for (var prop in headers) {
|
|
12737
|
-
if (!headers.hasOwnProperty(prop)) continue;
|
|
12738
|
-
header = headers[prop];
|
|
12739
|
-
|
|
12740
|
-
// skip nullish headers.
|
|
12741
|
-
if (header == null) {
|
|
12742
|
-
continue;
|
|
12743
|
-
}
|
|
12845
|
+
// or try `name` from formidable, browser
|
|
12846
|
+
if (!contentType && value.name) {
|
|
12847
|
+
contentType = mime.lookup(value.name);
|
|
12848
|
+
}
|
|
12744
12849
|
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12850
|
+
// or try `path` from fs-, request- streams
|
|
12851
|
+
if (!contentType && value.path) {
|
|
12852
|
+
contentType = mime.lookup(value.path);
|
|
12853
|
+
}
|
|
12749
12854
|
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
}
|
|
12855
|
+
// or if it's http-reponse
|
|
12856
|
+
if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) {
|
|
12857
|
+
contentType = value.headers['content-type'];
|
|
12858
|
+
}
|
|
12755
12859
|
|
|
12756
|
-
|
|
12757
|
-
|
|
12860
|
+
// or guess it from the filepath or filename
|
|
12861
|
+
if (!contentType && (options.filepath || options.filename)) {
|
|
12862
|
+
contentType = mime.lookup(options.filepath || options.filename);
|
|
12863
|
+
}
|
|
12758
12864
|
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
;
|
|
12764
|
-
|
|
12765
|
-
if (typeof options.filepath === 'string') {
|
|
12766
|
-
// custom filepath for relative paths
|
|
12767
|
-
filename = path.normalize(options.filepath).replace(/\\/g, '/');
|
|
12768
|
-
} else if (options.filename || value.name || value.path) {
|
|
12769
|
-
// custom filename take precedence
|
|
12770
|
-
// formidable and the browser add a name property
|
|
12771
|
-
// fs- and request- streams have path property
|
|
12772
|
-
filename = path.basename(options.filename || value.name || value.path);
|
|
12773
|
-
} else if (value.readable && value.hasOwnProperty('httpVersion')) {
|
|
12774
|
-
// or try http response
|
|
12775
|
-
filename = path.basename(value.client._httpMessage.path || '');
|
|
12776
|
-
}
|
|
12777
|
-
|
|
12778
|
-
if (filename) {
|
|
12779
|
-
contentDisposition = 'filename="' + filename + '"';
|
|
12780
|
-
}
|
|
12781
|
-
|
|
12782
|
-
return contentDisposition;
|
|
12783
|
-
};
|
|
12865
|
+
// fallback to the default content type if `value` is not simple value
|
|
12866
|
+
if (!contentType && typeof value == 'object') {
|
|
12867
|
+
contentType = FormData.DEFAULT_CONTENT_TYPE;
|
|
12868
|
+
}
|
|
12784
12869
|
|
|
12785
|
-
|
|
12870
|
+
return contentType;
|
|
12871
|
+
};
|
|
12786
12872
|
|
|
12787
|
-
|
|
12788
|
-
|
|
12873
|
+
FormData.prototype._multiPartFooter = function() {
|
|
12874
|
+
return function(next) {
|
|
12875
|
+
var footer = FormData.LINE_BREAK;
|
|
12789
12876
|
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12877
|
+
var lastPart = (this._streams.length === 0);
|
|
12878
|
+
if (lastPart) {
|
|
12879
|
+
footer += this._lastBoundary();
|
|
12880
|
+
}
|
|
12794
12881
|
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
}
|
|
12882
|
+
next(footer);
|
|
12883
|
+
}.bind(this);
|
|
12884
|
+
};
|
|
12799
12885
|
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
}
|
|
12886
|
+
FormData.prototype._lastBoundary = function() {
|
|
12887
|
+
return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK;
|
|
12888
|
+
};
|
|
12804
12889
|
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12890
|
+
FormData.prototype.getHeaders = function(userHeaders) {
|
|
12891
|
+
var header;
|
|
12892
|
+
var formHeaders = {
|
|
12893
|
+
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
|
12894
|
+
};
|
|
12809
12895
|
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12896
|
+
for (header in userHeaders) {
|
|
12897
|
+
if (userHeaders.hasOwnProperty(header)) {
|
|
12898
|
+
formHeaders[header.toLowerCase()] = userHeaders[header];
|
|
12899
|
+
}
|
|
12900
|
+
}
|
|
12814
12901
|
|
|
12815
|
-
|
|
12816
|
-
};
|
|
12902
|
+
return formHeaders;
|
|
12903
|
+
};
|
|
12817
12904
|
|
|
12818
|
-
FormData.prototype.
|
|
12819
|
-
|
|
12820
|
-
|
|
12905
|
+
FormData.prototype.setBoundary = function(boundary) {
|
|
12906
|
+
this._boundary = boundary;
|
|
12907
|
+
};
|
|
12821
12908
|
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12909
|
+
FormData.prototype.getBoundary = function() {
|
|
12910
|
+
if (!this._boundary) {
|
|
12911
|
+
this._generateBoundary();
|
|
12912
|
+
}
|
|
12826
12913
|
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
};
|
|
12914
|
+
return this._boundary;
|
|
12915
|
+
};
|
|
12830
12916
|
|
|
12831
|
-
FormData.prototype.
|
|
12832
|
-
|
|
12833
|
-
|
|
12917
|
+
FormData.prototype.getBuffer = function() {
|
|
12918
|
+
var dataBuffer = new Buffer.alloc( 0 );
|
|
12919
|
+
var boundary = this.getBoundary();
|
|
12834
12920
|
|
|
12835
|
-
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
'content-type': 'multipart/form-data; boundary=' + this.getBoundary()
|
|
12839
|
-
};
|
|
12921
|
+
// Create the form content. Add Line breaks to the end of data.
|
|
12922
|
+
for (var i = 0, len = this._streams.length; i < len; i++) {
|
|
12923
|
+
if (typeof this._streams[i] !== 'function') {
|
|
12840
12924
|
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12925
|
+
// Add content to the buffer.
|
|
12926
|
+
if(Buffer.isBuffer(this._streams[i])) {
|
|
12927
|
+
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
|
12928
|
+
}else {
|
|
12929
|
+
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
|
12930
|
+
}
|
|
12846
12931
|
|
|
12847
|
-
|
|
12848
|
-
|
|
12932
|
+
// Add break after content.
|
|
12933
|
+
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
|
12934
|
+
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
|
12935
|
+
}
|
|
12936
|
+
}
|
|
12937
|
+
}
|
|
12849
12938
|
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
};
|
|
12939
|
+
// Add the footer and return the Buffer object.
|
|
12940
|
+
return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] );
|
|
12941
|
+
};
|
|
12853
12942
|
|
|
12854
|
-
FormData.prototype.
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12943
|
+
FormData.prototype._generateBoundary = function() {
|
|
12944
|
+
// This generates a 50 character boundary similar to those used by Firefox.
|
|
12945
|
+
// They are optimized for boyer-moore parsing.
|
|
12946
|
+
var boundary = '--------------------------';
|
|
12947
|
+
for (var i = 0; i < 24; i++) {
|
|
12948
|
+
boundary += Math.floor(Math.random() * 10).toString(16);
|
|
12949
|
+
}
|
|
12858
12950
|
|
|
12859
|
-
|
|
12860
|
-
};
|
|
12951
|
+
this._boundary = boundary;
|
|
12952
|
+
};
|
|
12861
12953
|
|
|
12862
|
-
|
|
12863
|
-
|
|
12864
|
-
|
|
12865
|
-
|
|
12866
|
-
|
|
12867
|
-
for (var i = 0, len = this._streams.length; i < len; i++) {
|
|
12868
|
-
if (typeof this._streams[i] !== 'function') {
|
|
12869
|
-
|
|
12870
|
-
// Add content to the buffer.
|
|
12871
|
-
if(Buffer.isBuffer(this._streams[i])) {
|
|
12872
|
-
dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]);
|
|
12873
|
-
}else {
|
|
12874
|
-
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]);
|
|
12875
|
-
}
|
|
12876
|
-
|
|
12877
|
-
// Add break after content.
|
|
12878
|
-
if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) {
|
|
12879
|
-
dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] );
|
|
12880
|
-
}
|
|
12881
|
-
}
|
|
12882
|
-
}
|
|
12954
|
+
// Note: getLengthSync DOESN'T calculate streams length
|
|
12955
|
+
// As workaround one can calculate file size manually
|
|
12956
|
+
// and add it as knownLength option
|
|
12957
|
+
FormData.prototype.getLengthSync = function() {
|
|
12958
|
+
var knownLength = this._overheadLength + this._valueLength;
|
|
12883
12959
|
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12960
|
+
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
12961
|
+
// so it basically checks if there is any value added to the form
|
|
12962
|
+
if (this._streams.length) {
|
|
12963
|
+
knownLength += this._lastBoundary().length;
|
|
12964
|
+
}
|
|
12887
12965
|
|
|
12888
|
-
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12966
|
+
// https://github.com/form-data/form-data/issues/40
|
|
12967
|
+
if (!this.hasKnownLength()) {
|
|
12968
|
+
// Some async length retrievers are present
|
|
12969
|
+
// therefore synchronous length calculation is false.
|
|
12970
|
+
// Please use getLength(callback) to get proper length
|
|
12971
|
+
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
|
12972
|
+
}
|
|
12895
12973
|
|
|
12896
|
-
|
|
12897
|
-
};
|
|
12974
|
+
return knownLength;
|
|
12975
|
+
};
|
|
12898
12976
|
|
|
12899
|
-
//
|
|
12900
|
-
//
|
|
12901
|
-
//
|
|
12902
|
-
FormData.prototype.
|
|
12903
|
-
|
|
12904
|
-
|
|
12905
|
-
// Don't get confused, there are 3 "internal" streams for each keyval pair
|
|
12906
|
-
// so it basically checks if there is any value added to the form
|
|
12907
|
-
if (this._streams.length) {
|
|
12908
|
-
knownLength += this._lastBoundary().length;
|
|
12909
|
-
}
|
|
12910
|
-
|
|
12911
|
-
// https://github.com/form-data/form-data/issues/40
|
|
12912
|
-
if (!this.hasKnownLength()) {
|
|
12913
|
-
// Some async length retrievers are present
|
|
12914
|
-
// therefore synchronous length calculation is false.
|
|
12915
|
-
// Please use getLength(callback) to get proper length
|
|
12916
|
-
this._error(new Error('Cannot calculate proper length in synchronous way.'));
|
|
12917
|
-
}
|
|
12918
|
-
|
|
12919
|
-
return knownLength;
|
|
12920
|
-
};
|
|
12977
|
+
// Public API to check if length of added values is known
|
|
12978
|
+
// https://github.com/form-data/form-data/issues/196
|
|
12979
|
+
// https://github.com/form-data/form-data/issues/262
|
|
12980
|
+
FormData.prototype.hasKnownLength = function() {
|
|
12981
|
+
var hasKnownLength = true;
|
|
12921
12982
|
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
FormData.prototype.hasKnownLength = function() {
|
|
12926
|
-
var hasKnownLength = true;
|
|
12983
|
+
if (this._valuesToMeasure.length) {
|
|
12984
|
+
hasKnownLength = false;
|
|
12985
|
+
}
|
|
12927
12986
|
|
|
12928
|
-
|
|
12929
|
-
|
|
12930
|
-
}
|
|
12987
|
+
return hasKnownLength;
|
|
12988
|
+
};
|
|
12931
12989
|
|
|
12932
|
-
|
|
12933
|
-
|
|
12990
|
+
FormData.prototype.getLength = function(cb) {
|
|
12991
|
+
var knownLength = this._overheadLength + this._valueLength;
|
|
12934
12992
|
|
|
12935
|
-
|
|
12936
|
-
|
|
12993
|
+
if (this._streams.length) {
|
|
12994
|
+
knownLength += this._lastBoundary().length;
|
|
12995
|
+
}
|
|
12937
12996
|
|
|
12938
|
-
|
|
12939
|
-
|
|
12940
|
-
|
|
12997
|
+
if (!this._valuesToMeasure.length) {
|
|
12998
|
+
process.nextTick(cb.bind(this, null, knownLength));
|
|
12999
|
+
return;
|
|
13000
|
+
}
|
|
12941
13001
|
|
|
12942
|
-
|
|
12943
|
-
|
|
12944
|
-
|
|
12945
|
-
|
|
13002
|
+
asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) {
|
|
13003
|
+
if (err) {
|
|
13004
|
+
cb(err);
|
|
13005
|
+
return;
|
|
13006
|
+
}
|
|
12946
13007
|
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
return;
|
|
12951
|
-
}
|
|
13008
|
+
values.forEach(function(length) {
|
|
13009
|
+
knownLength += length;
|
|
13010
|
+
});
|
|
12952
13011
|
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
13012
|
+
cb(null, knownLength);
|
|
13013
|
+
});
|
|
13014
|
+
};
|
|
13015
|
+
|
|
13016
|
+
FormData.prototype.submit = function(params, cb) {
|
|
13017
|
+
var request
|
|
13018
|
+
, options
|
|
13019
|
+
, defaults = {method: 'post'}
|
|
13020
|
+
;
|
|
13021
|
+
|
|
13022
|
+
// parse provided url if it's string
|
|
13023
|
+
// or treat it as options object
|
|
13024
|
+
if (typeof params == 'string') {
|
|
13025
|
+
|
|
13026
|
+
params = parseUrl(params);
|
|
13027
|
+
options = populate({
|
|
13028
|
+
port: params.port,
|
|
13029
|
+
path: params.pathname,
|
|
13030
|
+
host: params.hostname,
|
|
13031
|
+
protocol: params.protocol
|
|
13032
|
+
}, defaults);
|
|
13033
|
+
|
|
13034
|
+
// use custom params
|
|
13035
|
+
} else {
|
|
13036
|
+
|
|
13037
|
+
options = populate(params, defaults);
|
|
13038
|
+
// if no port provided use default one
|
|
13039
|
+
if (!options.port) {
|
|
13040
|
+
options.port = options.protocol == 'https:' ? 443 : 80;
|
|
13041
|
+
}
|
|
13042
|
+
}
|
|
12956
13043
|
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
};
|
|
13044
|
+
// put that good code in getHeaders to some use
|
|
13045
|
+
options.headers = this.getHeaders(params.headers);
|
|
12960
13046
|
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
// parse provided url if it's string
|
|
12968
|
-
// or treat it as options object
|
|
12969
|
-
if (typeof params == 'string') {
|
|
12970
|
-
|
|
12971
|
-
params = parseUrl(params);
|
|
12972
|
-
options = populate({
|
|
12973
|
-
port: params.port,
|
|
12974
|
-
path: params.pathname,
|
|
12975
|
-
host: params.hostname,
|
|
12976
|
-
protocol: params.protocol
|
|
12977
|
-
}, defaults);
|
|
12978
|
-
|
|
12979
|
-
// use custom params
|
|
12980
|
-
} else {
|
|
12981
|
-
|
|
12982
|
-
options = populate(params, defaults);
|
|
12983
|
-
// if no port provided use default one
|
|
12984
|
-
if (!options.port) {
|
|
12985
|
-
options.port = options.protocol == 'https:' ? 443 : 80;
|
|
12986
|
-
}
|
|
12987
|
-
}
|
|
12988
|
-
|
|
12989
|
-
// put that good code in getHeaders to some use
|
|
12990
|
-
options.headers = this.getHeaders(params.headers);
|
|
12991
|
-
|
|
12992
|
-
// https if specified, fallback to http in any other case
|
|
12993
|
-
if (options.protocol == 'https:') {
|
|
12994
|
-
request = https.request(options);
|
|
12995
|
-
} else {
|
|
12996
|
-
request = http.request(options);
|
|
12997
|
-
}
|
|
12998
|
-
|
|
12999
|
-
// get content length and fire away
|
|
13000
|
-
this.getLength(function(err, length) {
|
|
13001
|
-
if (err && err !== 'Unknown stream') {
|
|
13002
|
-
this._error(err);
|
|
13003
|
-
return;
|
|
13004
|
-
}
|
|
13047
|
+
// https if specified, fallback to http in any other case
|
|
13048
|
+
if (options.protocol == 'https:') {
|
|
13049
|
+
request = https.request(options);
|
|
13050
|
+
} else {
|
|
13051
|
+
request = http.request(options);
|
|
13052
|
+
}
|
|
13005
13053
|
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
|
|
13054
|
+
// get content length and fire away
|
|
13055
|
+
this.getLength(function(err, length) {
|
|
13056
|
+
if (err && err !== 'Unknown stream') {
|
|
13057
|
+
this._error(err);
|
|
13058
|
+
return;
|
|
13059
|
+
}
|
|
13010
13060
|
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13061
|
+
// add content length
|
|
13062
|
+
if (length) {
|
|
13063
|
+
request.setHeader('Content-Length', length);
|
|
13064
|
+
}
|
|
13014
13065
|
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13066
|
+
this.pipe(request);
|
|
13067
|
+
if (cb) {
|
|
13068
|
+
var onResponse;
|
|
13018
13069
|
|
|
13019
|
-
|
|
13020
|
-
|
|
13070
|
+
var callback = function (error, responce) {
|
|
13071
|
+
request.removeListener('error', callback);
|
|
13072
|
+
request.removeListener('response', onResponse);
|
|
13021
13073
|
|
|
13022
|
-
|
|
13074
|
+
return cb.call(this, error, responce);
|
|
13075
|
+
};
|
|
13023
13076
|
|
|
13024
|
-
|
|
13025
|
-
request.on('response', onResponse);
|
|
13026
|
-
}
|
|
13027
|
-
}.bind(this));
|
|
13077
|
+
onResponse = callback.bind(this, null);
|
|
13028
13078
|
|
|
13029
|
-
|
|
13030
|
-
|
|
13079
|
+
request.on('error', callback);
|
|
13080
|
+
request.on('response', onResponse);
|
|
13081
|
+
}
|
|
13082
|
+
}.bind(this));
|
|
13031
13083
|
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
this.error = err;
|
|
13035
|
-
this.pause();
|
|
13036
|
-
this.emit('error', err);
|
|
13037
|
-
}
|
|
13038
|
-
};
|
|
13084
|
+
return request;
|
|
13085
|
+
};
|
|
13039
13086
|
|
|
13040
|
-
FormData.prototype.
|
|
13041
|
-
|
|
13042
|
-
|
|
13087
|
+
FormData.prototype._error = function(err) {
|
|
13088
|
+
if (!this.error) {
|
|
13089
|
+
this.error = err;
|
|
13090
|
+
this.pause();
|
|
13091
|
+
this.emit('error', err);
|
|
13092
|
+
}
|
|
13093
|
+
};
|
|
13094
|
+
|
|
13095
|
+
FormData.prototype.toString = function () {
|
|
13096
|
+
return '[object FormData]';
|
|
13097
|
+
};
|
|
13098
|
+
return form_data;
|
|
13099
|
+
}
|
|
13043
13100
|
|
|
13044
|
-
var
|
|
13101
|
+
var form_dataExports = requireForm_data();
|
|
13102
|
+
var FormDataModule = /*@__PURE__*/getDefaultExportFromCjs(form_dataExports);
|
|
13045
13103
|
|
|
13046
13104
|
const GRANT_TYPE$1 = 'client_credentials';
|
|
13047
13105
|
const castClientOptionsToRequestParams = (clientOptions) => {
|
|
@@ -13460,4 +13518,4 @@ var EnumLookupUserType;
|
|
|
13460
13518
|
EnumLookupUserType["tenant"] = "tenant";
|
|
13461
13519
|
})(EnumLookupUserType || (EnumLookupUserType = {}));
|
|
13462
13520
|
|
|
13463
|
-
export {
|
|
13521
|
+
export { EnumCommunicationMethodType, EnumCommunicationPreferenceChannel, EnumCountryCode, EnumInputChannel, EnumLocale, EnumLookupUserType, EnumResource, EnumServiceProviderType, EnumTimezone, EnumUnitObjectType, EnumUnitType, EnumUserPermissionObjectType, EnumUserPermissionRole, EnumUserRelationType, EnumUtilisationPeriodType, createTokenStore, restClient };
|