@allthings/sdk 6.2.0-2 → 6.2.0-3
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/cli.js +343 -298
- package/dist/lib.cjs.js +394 -298
- package/dist/lib.esm.js +391 -299
- package/dist/lib.umd.min.js +43 -1
- package/dist/src/aws/index.d.ts +2 -2
- package/dist/src/index.d.ts +1 -0
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
require('@aws-sdk/client-ssm');
|
|
4
5
|
var querystring = require('query-string');
|
|
5
6
|
var fetch = require('cross-fetch');
|
|
6
7
|
var Bottleneck = require('bottleneck');
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
8
|
+
var require$$1 = require('util');
|
|
9
|
+
var require$$0$1 = require('stream');
|
|
10
|
+
var require$$1$1 = require('path');
|
|
11
|
+
var require$$3 = require('http');
|
|
12
|
+
var require$$4 = require('https');
|
|
13
|
+
var require$$5 = require('url');
|
|
14
|
+
var require$$6 = require('fs');
|
|
15
|
+
|
|
16
|
+
(undefined && undefined.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
({
|
|
28
|
+
clientConfig: DEFAULT_AWS_CONFIGURATION,
|
|
29
|
+
onlyDefault: false,
|
|
30
|
+
prefix: process.env.SSM_PARAM_PATH,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const DEFAULT_AWS_CONFIGURATION = {
|
|
34
|
+
region: 'eu-central-2',
|
|
35
|
+
};
|
|
14
36
|
|
|
15
37
|
function createTokenStore(initialToken) {
|
|
16
38
|
const token = new Map(Object.entries(initialToken || {}));
|
|
@@ -21,7 +43,7 @@ function createTokenStore(initialToken) {
|
|
|
21
43
|
};
|
|
22
44
|
}
|
|
23
45
|
|
|
24
|
-
const version = "6.2.0-
|
|
46
|
+
const version = "6.2.0-3";
|
|
25
47
|
|
|
26
48
|
const REST_API_URL = 'https://api.allthings.me';
|
|
27
49
|
const OAUTH_URL = 'https://accounts.allthings.me';
|
|
@@ -850,11 +872,15 @@ async function put(request, method, body, returnRawResultObject, headers) {
|
|
|
850
872
|
return request('put', method, { body, headers }, returnRawResultObject);
|
|
851
873
|
}
|
|
852
874
|
|
|
853
|
-
|
|
875
|
+
function getDefaultExportFromCjs (x) {
|
|
876
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
877
|
+
}
|
|
854
878
|
|
|
879
|
+
var Stream$2 = require$$0$1.Stream;
|
|
880
|
+
var util$2 = require$$1;
|
|
855
881
|
|
|
856
|
-
var delayed_stream = DelayedStream;
|
|
857
|
-
function DelayedStream() {
|
|
882
|
+
var delayed_stream = DelayedStream$1;
|
|
883
|
+
function DelayedStream$1() {
|
|
858
884
|
this.source = null;
|
|
859
885
|
this.dataSize = 0;
|
|
860
886
|
this.maxDataSize = 1024 * 1024;
|
|
@@ -864,9 +890,9 @@ function DelayedStream() {
|
|
|
864
890
|
this._released = false;
|
|
865
891
|
this._bufferedEvents = [];
|
|
866
892
|
}
|
|
867
|
-
util.inherits(DelayedStream, Stream$2);
|
|
893
|
+
util$2.inherits(DelayedStream$1, Stream$2);
|
|
868
894
|
|
|
869
|
-
DelayedStream.create = function(source, options) {
|
|
895
|
+
DelayedStream$1.create = function(source, options) {
|
|
870
896
|
var delayedStream = new this();
|
|
871
897
|
|
|
872
898
|
options = options || {};
|
|
@@ -890,7 +916,7 @@ DelayedStream.create = function(source, options) {
|
|
|
890
916
|
return delayedStream;
|
|
891
917
|
};
|
|
892
918
|
|
|
893
|
-
Object.defineProperty(DelayedStream.prototype, 'readable', {
|
|
919
|
+
Object.defineProperty(DelayedStream$1.prototype, 'readable', {
|
|
894
920
|
configurable: true,
|
|
895
921
|
enumerable: true,
|
|
896
922
|
get: function() {
|
|
@@ -898,11 +924,11 @@ Object.defineProperty(DelayedStream.prototype, 'readable', {
|
|
|
898
924
|
}
|
|
899
925
|
});
|
|
900
926
|
|
|
901
|
-
DelayedStream.prototype.setEncoding = function() {
|
|
927
|
+
DelayedStream$1.prototype.setEncoding = function() {
|
|
902
928
|
return this.source.setEncoding.apply(this.source, arguments);
|
|
903
929
|
};
|
|
904
930
|
|
|
905
|
-
DelayedStream.prototype.resume = function() {
|
|
931
|
+
DelayedStream$1.prototype.resume = function() {
|
|
906
932
|
if (!this._released) {
|
|
907
933
|
this.release();
|
|
908
934
|
}
|
|
@@ -910,11 +936,11 @@ DelayedStream.prototype.resume = function() {
|
|
|
910
936
|
this.source.resume();
|
|
911
937
|
};
|
|
912
938
|
|
|
913
|
-
DelayedStream.prototype.pause = function() {
|
|
939
|
+
DelayedStream$1.prototype.pause = function() {
|
|
914
940
|
this.source.pause();
|
|
915
941
|
};
|
|
916
942
|
|
|
917
|
-
DelayedStream.prototype.release = function() {
|
|
943
|
+
DelayedStream$1.prototype.release = function() {
|
|
918
944
|
this._released = true;
|
|
919
945
|
|
|
920
946
|
this._bufferedEvents.forEach(function(args) {
|
|
@@ -923,13 +949,13 @@ DelayedStream.prototype.release = function() {
|
|
|
923
949
|
this._bufferedEvents = [];
|
|
924
950
|
};
|
|
925
951
|
|
|
926
|
-
DelayedStream.prototype.pipe = function() {
|
|
952
|
+
DelayedStream$1.prototype.pipe = function() {
|
|
927
953
|
var r = Stream$2.prototype.pipe.apply(this, arguments);
|
|
928
954
|
this.resume();
|
|
929
955
|
return r;
|
|
930
956
|
};
|
|
931
957
|
|
|
932
|
-
DelayedStream.prototype._handleEmit = function(args) {
|
|
958
|
+
DelayedStream$1.prototype._handleEmit = function(args) {
|
|
933
959
|
if (this._released) {
|
|
934
960
|
this.emit.apply(this, args);
|
|
935
961
|
return;
|
|
@@ -943,7 +969,7 @@ DelayedStream.prototype._handleEmit = function(args) {
|
|
|
943
969
|
this._bufferedEvents.push(args);
|
|
944
970
|
};
|
|
945
971
|
|
|
946
|
-
DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
972
|
+
DelayedStream$1.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
947
973
|
if (this._maxDataSizeExceeded) {
|
|
948
974
|
return;
|
|
949
975
|
}
|
|
@@ -958,11 +984,12 @@ DelayedStream.prototype._checkIfMaxDataSizeExceeded = function() {
|
|
|
958
984
|
this.emit('error', new Error(message));
|
|
959
985
|
};
|
|
960
986
|
|
|
961
|
-
var
|
|
962
|
-
|
|
987
|
+
var util$1 = require$$1;
|
|
988
|
+
var Stream$1 = require$$0$1.Stream;
|
|
989
|
+
var DelayedStream = delayed_stream;
|
|
963
990
|
|
|
964
|
-
var combined_stream = CombinedStream;
|
|
965
|
-
function CombinedStream() {
|
|
991
|
+
var combined_stream = CombinedStream$1;
|
|
992
|
+
function CombinedStream$1() {
|
|
966
993
|
this.writable = false;
|
|
967
994
|
this.readable = true;
|
|
968
995
|
this.dataSize = 0;
|
|
@@ -975,9 +1002,9 @@ function CombinedStream() {
|
|
|
975
1002
|
this._insideLoop = false;
|
|
976
1003
|
this._pendingNext = false;
|
|
977
1004
|
}
|
|
978
|
-
util.inherits(CombinedStream, Stream$1);
|
|
1005
|
+
util$1.inherits(CombinedStream$1, Stream$1);
|
|
979
1006
|
|
|
980
|
-
CombinedStream.create = function(options) {
|
|
1007
|
+
CombinedStream$1.create = function(options) {
|
|
981
1008
|
var combinedStream = new this();
|
|
982
1009
|
|
|
983
1010
|
options = options || {};
|
|
@@ -988,7 +1015,7 @@ CombinedStream.create = function(options) {
|
|
|
988
1015
|
return combinedStream;
|
|
989
1016
|
};
|
|
990
1017
|
|
|
991
|
-
CombinedStream.isStreamLike = function(stream) {
|
|
1018
|
+
CombinedStream$1.isStreamLike = function(stream) {
|
|
992
1019
|
return (typeof stream !== 'function')
|
|
993
1020
|
&& (typeof stream !== 'string')
|
|
994
1021
|
&& (typeof stream !== 'boolean')
|
|
@@ -996,12 +1023,12 @@ CombinedStream.isStreamLike = function(stream) {
|
|
|
996
1023
|
&& (!Buffer.isBuffer(stream));
|
|
997
1024
|
};
|
|
998
1025
|
|
|
999
|
-
CombinedStream.prototype.append = function(stream) {
|
|
1000
|
-
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1026
|
+
CombinedStream$1.prototype.append = function(stream) {
|
|
1027
|
+
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1001
1028
|
|
|
1002
1029
|
if (isStreamLike) {
|
|
1003
|
-
if (!(stream instanceof
|
|
1004
|
-
var newStream =
|
|
1030
|
+
if (!(stream instanceof DelayedStream)) {
|
|
1031
|
+
var newStream = DelayedStream.create(stream, {
|
|
1005
1032
|
maxDataSize: Infinity,
|
|
1006
1033
|
pauseStream: this.pauseStreams,
|
|
1007
1034
|
});
|
|
@@ -1020,13 +1047,13 @@ CombinedStream.prototype.append = function(stream) {
|
|
|
1020
1047
|
return this;
|
|
1021
1048
|
};
|
|
1022
1049
|
|
|
1023
|
-
CombinedStream.prototype.pipe = function(dest, options) {
|
|
1050
|
+
CombinedStream$1.prototype.pipe = function(dest, options) {
|
|
1024
1051
|
Stream$1.prototype.pipe.call(this, dest, options);
|
|
1025
1052
|
this.resume();
|
|
1026
1053
|
return dest;
|
|
1027
1054
|
};
|
|
1028
1055
|
|
|
1029
|
-
CombinedStream.prototype._getNext = function() {
|
|
1056
|
+
CombinedStream$1.prototype._getNext = function() {
|
|
1030
1057
|
this._currentStream = null;
|
|
1031
1058
|
|
|
1032
1059
|
if (this._insideLoop) {
|
|
@@ -1045,7 +1072,7 @@ CombinedStream.prototype._getNext = function() {
|
|
|
1045
1072
|
}
|
|
1046
1073
|
};
|
|
1047
1074
|
|
|
1048
|
-
CombinedStream.prototype._realGetNext = function() {
|
|
1075
|
+
CombinedStream$1.prototype._realGetNext = function() {
|
|
1049
1076
|
var stream = this._streams.shift();
|
|
1050
1077
|
|
|
1051
1078
|
|
|
@@ -1061,7 +1088,7 @@ CombinedStream.prototype._realGetNext = function() {
|
|
|
1061
1088
|
|
|
1062
1089
|
var getStream = stream;
|
|
1063
1090
|
getStream(function(stream) {
|
|
1064
|
-
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1091
|
+
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1065
1092
|
if (isStreamLike) {
|
|
1066
1093
|
stream.on('data', this._checkDataSize.bind(this));
|
|
1067
1094
|
this._handleErrors(stream);
|
|
@@ -1071,10 +1098,10 @@ CombinedStream.prototype._realGetNext = function() {
|
|
|
1071
1098
|
}.bind(this));
|
|
1072
1099
|
};
|
|
1073
1100
|
|
|
1074
|
-
CombinedStream.prototype._pipeNext = function(stream) {
|
|
1101
|
+
CombinedStream$1.prototype._pipeNext = function(stream) {
|
|
1075
1102
|
this._currentStream = stream;
|
|
1076
1103
|
|
|
1077
|
-
var isStreamLike = CombinedStream.isStreamLike(stream);
|
|
1104
|
+
var isStreamLike = CombinedStream$1.isStreamLike(stream);
|
|
1078
1105
|
if (isStreamLike) {
|
|
1079
1106
|
stream.on('end', this._getNext.bind(this));
|
|
1080
1107
|
stream.pipe(this, {end: false});
|
|
@@ -1086,18 +1113,18 @@ CombinedStream.prototype._pipeNext = function(stream) {
|
|
|
1086
1113
|
this._getNext();
|
|
1087
1114
|
};
|
|
1088
1115
|
|
|
1089
|
-
CombinedStream.prototype._handleErrors = function(stream) {
|
|
1116
|
+
CombinedStream$1.prototype._handleErrors = function(stream) {
|
|
1090
1117
|
var self = this;
|
|
1091
1118
|
stream.on('error', function(err) {
|
|
1092
1119
|
self._emitError(err);
|
|
1093
1120
|
});
|
|
1094
1121
|
};
|
|
1095
1122
|
|
|
1096
|
-
CombinedStream.prototype.write = function(data) {
|
|
1123
|
+
CombinedStream$1.prototype.write = function(data) {
|
|
1097
1124
|
this.emit('data', data);
|
|
1098
1125
|
};
|
|
1099
1126
|
|
|
1100
|
-
CombinedStream.prototype.pause = function() {
|
|
1127
|
+
CombinedStream$1.prototype.pause = function() {
|
|
1101
1128
|
if (!this.pauseStreams) {
|
|
1102
1129
|
return;
|
|
1103
1130
|
}
|
|
@@ -1106,7 +1133,7 @@ CombinedStream.prototype.pause = function() {
|
|
|
1106
1133
|
this.emit('pause');
|
|
1107
1134
|
};
|
|
1108
1135
|
|
|
1109
|
-
CombinedStream.prototype.resume = function() {
|
|
1136
|
+
CombinedStream$1.prototype.resume = function() {
|
|
1110
1137
|
if (!this._released) {
|
|
1111
1138
|
this._released = true;
|
|
1112
1139
|
this.writable = true;
|
|
@@ -1117,23 +1144,23 @@ CombinedStream.prototype.resume = function() {
|
|
|
1117
1144
|
this.emit('resume');
|
|
1118
1145
|
};
|
|
1119
1146
|
|
|
1120
|
-
CombinedStream.prototype.end = function() {
|
|
1147
|
+
CombinedStream$1.prototype.end = function() {
|
|
1121
1148
|
this._reset();
|
|
1122
1149
|
this.emit('end');
|
|
1123
1150
|
};
|
|
1124
1151
|
|
|
1125
|
-
CombinedStream.prototype.destroy = function() {
|
|
1152
|
+
CombinedStream$1.prototype.destroy = function() {
|
|
1126
1153
|
this._reset();
|
|
1127
1154
|
this.emit('close');
|
|
1128
1155
|
};
|
|
1129
1156
|
|
|
1130
|
-
CombinedStream.prototype._reset = function() {
|
|
1157
|
+
CombinedStream$1.prototype._reset = function() {
|
|
1131
1158
|
this.writable = false;
|
|
1132
1159
|
this._streams = [];
|
|
1133
1160
|
this._currentStream = null;
|
|
1134
1161
|
};
|
|
1135
1162
|
|
|
1136
|
-
CombinedStream.prototype._checkDataSize = function() {
|
|
1163
|
+
CombinedStream$1.prototype._checkDataSize = function() {
|
|
1137
1164
|
this._updateDataSize();
|
|
1138
1165
|
if (this.dataSize <= this.maxDataSize) {
|
|
1139
1166
|
return;
|
|
@@ -1144,7 +1171,7 @@ CombinedStream.prototype._checkDataSize = function() {
|
|
|
1144
1171
|
this._emitError(new Error(message));
|
|
1145
1172
|
};
|
|
1146
1173
|
|
|
1147
|
-
CombinedStream.prototype._updateDataSize = function() {
|
|
1174
|
+
CombinedStream$1.prototype._updateDataSize = function() {
|
|
1148
1175
|
this.dataSize = 0;
|
|
1149
1176
|
|
|
1150
1177
|
var self = this;
|
|
@@ -1161,20 +1188,14 @@ CombinedStream.prototype._updateDataSize = function() {
|
|
|
1161
1188
|
}
|
|
1162
1189
|
};
|
|
1163
1190
|
|
|
1164
|
-
CombinedStream.prototype._emitError = function(err) {
|
|
1191
|
+
CombinedStream$1.prototype._emitError = function(err) {
|
|
1165
1192
|
this._reset();
|
|
1166
1193
|
this.emit('error', err);
|
|
1167
1194
|
};
|
|
1168
1195
|
|
|
1169
|
-
|
|
1170
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
function getCjsExportFromNamespace (n) {
|
|
1174
|
-
return n && n['default'] || n;
|
|
1175
|
-
}
|
|
1196
|
+
var mimeTypes = {};
|
|
1176
1197
|
|
|
1177
|
-
var
|
|
1198
|
+
var require$$0 = {
|
|
1178
1199
|
"application/1d-interleaved-parityfec": {
|
|
1179
1200
|
source: "iana"
|
|
1180
1201
|
},
|
|
@@ -10830,13 +10851,6 @@ var db = {
|
|
|
10830
10851
|
}
|
|
10831
10852
|
};
|
|
10832
10853
|
|
|
10833
|
-
var db$1 = /*#__PURE__*/Object.freeze({
|
|
10834
|
-
__proto__: null,
|
|
10835
|
-
default: db
|
|
10836
|
-
});
|
|
10837
|
-
|
|
10838
|
-
var require$$0 = getCjsExportFromNamespace(db$1);
|
|
10839
|
-
|
|
10840
10854
|
/*!
|
|
10841
10855
|
* mime-db
|
|
10842
10856
|
* Copyright(c) 2014 Jonathan Ong
|
|
@@ -10849,204 +10863,204 @@ var require$$0 = getCjsExportFromNamespace(db$1);
|
|
|
10849
10863
|
|
|
10850
10864
|
var mimeDb = require$$0;
|
|
10851
10865
|
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
*
|
|
10856
|
-
*
|
|
10857
|
-
*/
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
var extname = path.extname;
|
|
10861
|
-
|
|
10862
|
-
/**
|
|
10863
|
-
* Module variables.
|
|
10864
|
-
* @private
|
|
10865
|
-
*/
|
|
10866
|
-
|
|
10867
|
-
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
10868
|
-
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
10869
|
-
|
|
10870
|
-
/**
|
|
10871
|
-
* Module exports.
|
|
10872
|
-
* @public
|
|
10873
|
-
*/
|
|
10874
|
-
|
|
10875
|
-
exports.charset = charset;
|
|
10876
|
-
exports.charsets = { lookup: charset };
|
|
10877
|
-
exports.contentType = contentType;
|
|
10878
|
-
exports.extension = extension;
|
|
10879
|
-
exports.extensions = Object.create(null);
|
|
10880
|
-
exports.lookup = lookup;
|
|
10881
|
-
exports.types = Object.create(null);
|
|
10882
|
-
|
|
10883
|
-
// Populate the extensions/types maps
|
|
10884
|
-
populateMaps(exports.extensions, exports.types);
|
|
10885
|
-
|
|
10886
|
-
/**
|
|
10887
|
-
* Get the default charset for a MIME type.
|
|
10888
|
-
*
|
|
10889
|
-
* @param {string} type
|
|
10890
|
-
* @return {boolean|string}
|
|
10891
|
-
*/
|
|
10892
|
-
|
|
10893
|
-
function charset (type) {
|
|
10894
|
-
if (!type || typeof type !== 'string') {
|
|
10895
|
-
return false
|
|
10896
|
-
}
|
|
10897
|
-
|
|
10898
|
-
// TODO: use media-typer
|
|
10899
|
-
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
10900
|
-
var mime = match && mimeDb[match[1].toLowerCase()];
|
|
10901
|
-
|
|
10902
|
-
if (mime && mime.charset) {
|
|
10903
|
-
return mime.charset
|
|
10904
|
-
}
|
|
10905
|
-
|
|
10906
|
-
// default text/* to utf-8
|
|
10907
|
-
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
|
10908
|
-
return 'UTF-8'
|
|
10909
|
-
}
|
|
10910
|
-
|
|
10911
|
-
return false
|
|
10912
|
-
}
|
|
10913
|
-
|
|
10914
|
-
/**
|
|
10915
|
-
* Create a full Content-Type header given a MIME type or extension.
|
|
10916
|
-
*
|
|
10917
|
-
* @param {string} str
|
|
10918
|
-
* @return {boolean|string}
|
|
10919
|
-
*/
|
|
10920
|
-
|
|
10921
|
-
function contentType (str) {
|
|
10922
|
-
// TODO: should this even be in this module?
|
|
10923
|
-
if (!str || typeof str !== 'string') {
|
|
10924
|
-
return false
|
|
10925
|
-
}
|
|
10926
|
-
|
|
10927
|
-
var mime = str.indexOf('/') === -1
|
|
10928
|
-
? exports.lookup(str)
|
|
10929
|
-
: str;
|
|
10930
|
-
|
|
10931
|
-
if (!mime) {
|
|
10932
|
-
return false
|
|
10933
|
-
}
|
|
10934
|
-
|
|
10935
|
-
// TODO: use content-type or other module
|
|
10936
|
-
if (mime.indexOf('charset') === -1) {
|
|
10937
|
-
var charset = exports.charset(mime);
|
|
10938
|
-
if (charset) mime += '; charset=' + charset.toLowerCase();
|
|
10939
|
-
}
|
|
10940
|
-
|
|
10941
|
-
return mime
|
|
10942
|
-
}
|
|
10943
|
-
|
|
10944
|
-
/**
|
|
10945
|
-
* Get the default extension for a MIME type.
|
|
10946
|
-
*
|
|
10947
|
-
* @param {string} type
|
|
10948
|
-
* @return {boolean|string}
|
|
10949
|
-
*/
|
|
10950
|
-
|
|
10951
|
-
function extension (type) {
|
|
10952
|
-
if (!type || typeof type !== 'string') {
|
|
10953
|
-
return false
|
|
10954
|
-
}
|
|
10955
|
-
|
|
10956
|
-
// TODO: use media-typer
|
|
10957
|
-
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
10958
|
-
|
|
10959
|
-
// get extensions
|
|
10960
|
-
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
10961
|
-
|
|
10962
|
-
if (!exts || !exts.length) {
|
|
10963
|
-
return false
|
|
10964
|
-
}
|
|
10965
|
-
|
|
10966
|
-
return exts[0]
|
|
10967
|
-
}
|
|
10968
|
-
|
|
10969
|
-
/**
|
|
10970
|
-
* Lookup the MIME type for a file path/extension.
|
|
10971
|
-
*
|
|
10972
|
-
* @param {string} path
|
|
10973
|
-
* @return {boolean|string}
|
|
10974
|
-
*/
|
|
10975
|
-
|
|
10976
|
-
function lookup (path) {
|
|
10977
|
-
if (!path || typeof path !== 'string') {
|
|
10978
|
-
return false
|
|
10979
|
-
}
|
|
10980
|
-
|
|
10981
|
-
// get the extension ("ext" or ".ext" or full path)
|
|
10982
|
-
var extension = extname('x.' + path)
|
|
10983
|
-
.toLowerCase()
|
|
10984
|
-
.substr(1);
|
|
10985
|
-
|
|
10986
|
-
if (!extension) {
|
|
10987
|
-
return false
|
|
10988
|
-
}
|
|
10989
|
-
|
|
10990
|
-
return exports.types[extension] || false
|
|
10991
|
-
}
|
|
10992
|
-
|
|
10993
|
-
/**
|
|
10994
|
-
* Populate the extensions and types maps.
|
|
10995
|
-
* @private
|
|
10866
|
+
/*!
|
|
10867
|
+
* mime-types
|
|
10868
|
+
* Copyright(c) 2014 Jonathan Ong
|
|
10869
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
10870
|
+
* MIT Licensed
|
|
10996
10871
|
*/
|
|
10997
10872
|
|
|
10998
|
-
function
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11035
|
-
|
|
11036
|
-
|
|
11037
|
-
|
|
11038
|
-
|
|
11039
|
-
|
|
11040
|
-
|
|
11041
|
-
|
|
11042
|
-
|
|
10873
|
+
(function (exports) {
|
|
10874
|
+
|
|
10875
|
+
/**
|
|
10876
|
+
* Module dependencies.
|
|
10877
|
+
* @private
|
|
10878
|
+
*/
|
|
10879
|
+
|
|
10880
|
+
var db = mimeDb;
|
|
10881
|
+
var extname = require$$1$1.extname;
|
|
10882
|
+
|
|
10883
|
+
/**
|
|
10884
|
+
* Module variables.
|
|
10885
|
+
* @private
|
|
10886
|
+
*/
|
|
10887
|
+
|
|
10888
|
+
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
10889
|
+
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
10890
|
+
|
|
10891
|
+
/**
|
|
10892
|
+
* Module exports.
|
|
10893
|
+
* @public
|
|
10894
|
+
*/
|
|
10895
|
+
|
|
10896
|
+
exports.charset = charset;
|
|
10897
|
+
exports.charsets = { lookup: charset };
|
|
10898
|
+
exports.contentType = contentType;
|
|
10899
|
+
exports.extension = extension;
|
|
10900
|
+
exports.extensions = Object.create(null);
|
|
10901
|
+
exports.lookup = lookup;
|
|
10902
|
+
exports.types = Object.create(null);
|
|
10903
|
+
|
|
10904
|
+
// Populate the extensions/types maps
|
|
10905
|
+
populateMaps(exports.extensions, exports.types);
|
|
10906
|
+
|
|
10907
|
+
/**
|
|
10908
|
+
* Get the default charset for a MIME type.
|
|
10909
|
+
*
|
|
10910
|
+
* @param {string} type
|
|
10911
|
+
* @return {boolean|string}
|
|
10912
|
+
*/
|
|
10913
|
+
|
|
10914
|
+
function charset (type) {
|
|
10915
|
+
if (!type || typeof type !== 'string') {
|
|
10916
|
+
return false
|
|
10917
|
+
}
|
|
10918
|
+
|
|
10919
|
+
// TODO: use media-typer
|
|
10920
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
10921
|
+
var mime = match && db[match[1].toLowerCase()];
|
|
10922
|
+
|
|
10923
|
+
if (mime && mime.charset) {
|
|
10924
|
+
return mime.charset
|
|
10925
|
+
}
|
|
10926
|
+
|
|
10927
|
+
// default text/* to utf-8
|
|
10928
|
+
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
|
10929
|
+
return 'UTF-8'
|
|
10930
|
+
}
|
|
10931
|
+
|
|
10932
|
+
return false
|
|
10933
|
+
}
|
|
10934
|
+
|
|
10935
|
+
/**
|
|
10936
|
+
* Create a full Content-Type header given a MIME type or extension.
|
|
10937
|
+
*
|
|
10938
|
+
* @param {string} str
|
|
10939
|
+
* @return {boolean|string}
|
|
10940
|
+
*/
|
|
10941
|
+
|
|
10942
|
+
function contentType (str) {
|
|
10943
|
+
// TODO: should this even be in this module?
|
|
10944
|
+
if (!str || typeof str !== 'string') {
|
|
10945
|
+
return false
|
|
10946
|
+
}
|
|
10947
|
+
|
|
10948
|
+
var mime = str.indexOf('/') === -1
|
|
10949
|
+
? exports.lookup(str)
|
|
10950
|
+
: str;
|
|
10951
|
+
|
|
10952
|
+
if (!mime) {
|
|
10953
|
+
return false
|
|
10954
|
+
}
|
|
10955
|
+
|
|
10956
|
+
// TODO: use content-type or other module
|
|
10957
|
+
if (mime.indexOf('charset') === -1) {
|
|
10958
|
+
var charset = exports.charset(mime);
|
|
10959
|
+
if (charset) mime += '; charset=' + charset.toLowerCase();
|
|
10960
|
+
}
|
|
10961
|
+
|
|
10962
|
+
return mime
|
|
10963
|
+
}
|
|
10964
|
+
|
|
10965
|
+
/**
|
|
10966
|
+
* Get the default extension for a MIME type.
|
|
10967
|
+
*
|
|
10968
|
+
* @param {string} type
|
|
10969
|
+
* @return {boolean|string}
|
|
10970
|
+
*/
|
|
10971
|
+
|
|
10972
|
+
function extension (type) {
|
|
10973
|
+
if (!type || typeof type !== 'string') {
|
|
10974
|
+
return false
|
|
10975
|
+
}
|
|
10976
|
+
|
|
10977
|
+
// TODO: use media-typer
|
|
10978
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type);
|
|
10979
|
+
|
|
10980
|
+
// get extensions
|
|
10981
|
+
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
10982
|
+
|
|
10983
|
+
if (!exts || !exts.length) {
|
|
10984
|
+
return false
|
|
10985
|
+
}
|
|
10986
|
+
|
|
10987
|
+
return exts[0]
|
|
10988
|
+
}
|
|
10989
|
+
|
|
10990
|
+
/**
|
|
10991
|
+
* Lookup the MIME type for a file path/extension.
|
|
10992
|
+
*
|
|
10993
|
+
* @param {string} path
|
|
10994
|
+
* @return {boolean|string}
|
|
10995
|
+
*/
|
|
10996
|
+
|
|
10997
|
+
function lookup (path) {
|
|
10998
|
+
if (!path || typeof path !== 'string') {
|
|
10999
|
+
return false
|
|
11000
|
+
}
|
|
11001
|
+
|
|
11002
|
+
// get the extension ("ext" or ".ext" or full path)
|
|
11003
|
+
var extension = extname('x.' + path)
|
|
11004
|
+
.toLowerCase()
|
|
11005
|
+
.substr(1);
|
|
11006
|
+
|
|
11007
|
+
if (!extension) {
|
|
11008
|
+
return false
|
|
11009
|
+
}
|
|
11010
|
+
|
|
11011
|
+
return exports.types[extension] || false
|
|
11012
|
+
}
|
|
11013
|
+
|
|
11014
|
+
/**
|
|
11015
|
+
* Populate the extensions and types maps.
|
|
11016
|
+
* @private
|
|
11017
|
+
*/
|
|
11018
|
+
|
|
11019
|
+
function populateMaps (extensions, types) {
|
|
11020
|
+
// source preference (least -> most)
|
|
11021
|
+
var preference = ['nginx', 'apache', undefined, 'iana'];
|
|
11022
|
+
|
|
11023
|
+
Object.keys(db).forEach(function forEachMimeType (type) {
|
|
11024
|
+
var mime = db[type];
|
|
11025
|
+
var exts = mime.extensions;
|
|
11026
|
+
|
|
11027
|
+
if (!exts || !exts.length) {
|
|
11028
|
+
return
|
|
11029
|
+
}
|
|
11030
|
+
|
|
11031
|
+
// mime -> extensions
|
|
11032
|
+
extensions[type] = exts;
|
|
11033
|
+
|
|
11034
|
+
// extension -> mime
|
|
11035
|
+
for (var i = 0; i < exts.length; i++) {
|
|
11036
|
+
var extension = exts[i];
|
|
11037
|
+
|
|
11038
|
+
if (types[extension]) {
|
|
11039
|
+
var from = preference.indexOf(db[types[extension]].source);
|
|
11040
|
+
var to = preference.indexOf(mime.source);
|
|
11041
|
+
|
|
11042
|
+
if (types[extension] !== 'application/octet-stream' &&
|
|
11043
|
+
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
|
11044
|
+
// skip the remapping
|
|
11045
|
+
continue
|
|
11046
|
+
}
|
|
11047
|
+
}
|
|
11048
|
+
|
|
11049
|
+
// set the extension -> mime
|
|
11050
|
+
types[extension] = type;
|
|
11051
|
+
}
|
|
11052
|
+
});
|
|
11053
|
+
}
|
|
11054
|
+
} (mimeTypes));
|
|
11055
|
+
|
|
11056
|
+
var defer_1 = defer$1;
|
|
11043
11057
|
|
|
11044
11058
|
/**
|
|
11045
11059
|
* Runs provided function on next iteration of the event loop
|
|
11046
11060
|
*
|
|
11047
11061
|
* @param {function} fn - function to run
|
|
11048
11062
|
*/
|
|
11049
|
-
function defer(fn)
|
|
11063
|
+
function defer$1(fn)
|
|
11050
11064
|
{
|
|
11051
11065
|
var nextTick = typeof setImmediate == 'function'
|
|
11052
11066
|
? setImmediate
|
|
@@ -11066,8 +11080,10 @@ function defer(fn)
|
|
|
11066
11080
|
}
|
|
11067
11081
|
}
|
|
11068
11082
|
|
|
11083
|
+
var defer = defer_1;
|
|
11084
|
+
|
|
11069
11085
|
// API
|
|
11070
|
-
var async_1 = async;
|
|
11086
|
+
var async_1 = async$2;
|
|
11071
11087
|
|
|
11072
11088
|
/**
|
|
11073
11089
|
* Runs provided callback asynchronously
|
|
@@ -11076,12 +11092,12 @@ var async_1 = async;
|
|
|
11076
11092
|
* @param {function} callback - callback to invoke
|
|
11077
11093
|
* @returns {function} - augmented callback
|
|
11078
11094
|
*/
|
|
11079
|
-
function async(callback)
|
|
11095
|
+
function async$2(callback)
|
|
11080
11096
|
{
|
|
11081
11097
|
var isAsync = false;
|
|
11082
11098
|
|
|
11083
11099
|
// check if async happened
|
|
11084
|
-
|
|
11100
|
+
defer(function() { isAsync = true; });
|
|
11085
11101
|
|
|
11086
11102
|
return function async_callback(err, result)
|
|
11087
11103
|
{
|
|
@@ -11091,7 +11107,7 @@ function async(callback)
|
|
|
11091
11107
|
}
|
|
11092
11108
|
else
|
|
11093
11109
|
{
|
|
11094
|
-
|
|
11110
|
+
defer(function nextTick_callback()
|
|
11095
11111
|
{
|
|
11096
11112
|
callback(err, result);
|
|
11097
11113
|
});
|
|
@@ -11100,14 +11116,14 @@ function async(callback)
|
|
|
11100
11116
|
}
|
|
11101
11117
|
|
|
11102
11118
|
// API
|
|
11103
|
-
var abort_1 = abort;
|
|
11119
|
+
var abort_1 = abort$2;
|
|
11104
11120
|
|
|
11105
11121
|
/**
|
|
11106
11122
|
* Aborts leftover active jobs
|
|
11107
11123
|
*
|
|
11108
11124
|
* @param {object} state - current state object
|
|
11109
11125
|
*/
|
|
11110
|
-
function abort(state)
|
|
11126
|
+
function abort$2(state)
|
|
11111
11127
|
{
|
|
11112
11128
|
Object.keys(state.jobs).forEach(clean.bind(state));
|
|
11113
11129
|
|
|
@@ -11129,8 +11145,12 @@ function clean(key)
|
|
|
11129
11145
|
}
|
|
11130
11146
|
}
|
|
11131
11147
|
|
|
11148
|
+
var async$1 = async_1
|
|
11149
|
+
, abort$1 = abort_1
|
|
11150
|
+
;
|
|
11151
|
+
|
|
11132
11152
|
// API
|
|
11133
|
-
var iterate_1 = iterate;
|
|
11153
|
+
var iterate_1 = iterate$2;
|
|
11134
11154
|
|
|
11135
11155
|
/**
|
|
11136
11156
|
* Iterates over each job object
|
|
@@ -11140,7 +11160,7 @@ var iterate_1 = iterate;
|
|
|
11140
11160
|
* @param {object} state - current job status
|
|
11141
11161
|
* @param {function} callback - invoked when all elements processed
|
|
11142
11162
|
*/
|
|
11143
|
-
function iterate(list, iterator, state, callback)
|
|
11163
|
+
function iterate$2(list, iterator, state, callback)
|
|
11144
11164
|
{
|
|
11145
11165
|
// store current index
|
|
11146
11166
|
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
|
@@ -11162,7 +11182,7 @@ function iterate(list, iterator, state, callback)
|
|
|
11162
11182
|
// don't process rest of the results
|
|
11163
11183
|
// stop still active jobs
|
|
11164
11184
|
// and reset the list
|
|
11165
|
-
|
|
11185
|
+
abort$1(state);
|
|
11166
11186
|
}
|
|
11167
11187
|
else
|
|
11168
11188
|
{
|
|
@@ -11190,12 +11210,12 @@ function runJob(iterator, key, item, callback)
|
|
|
11190
11210
|
// allow shortcut if iterator expects only two arguments
|
|
11191
11211
|
if (iterator.length == 2)
|
|
11192
11212
|
{
|
|
11193
|
-
aborter = iterator(item,
|
|
11213
|
+
aborter = iterator(item, async$1(callback));
|
|
11194
11214
|
}
|
|
11195
11215
|
// otherwise go with full three arguments
|
|
11196
11216
|
else
|
|
11197
11217
|
{
|
|
11198
|
-
aborter = iterator(item, key,
|
|
11218
|
+
aborter = iterator(item, key, async$1(callback));
|
|
11199
11219
|
}
|
|
11200
11220
|
|
|
11201
11221
|
return aborter;
|
|
@@ -11239,8 +11259,12 @@ function state(list, sortMethod)
|
|
|
11239
11259
|
return initState;
|
|
11240
11260
|
}
|
|
11241
11261
|
|
|
11262
|
+
var abort = abort_1
|
|
11263
|
+
, async = async_1
|
|
11264
|
+
;
|
|
11265
|
+
|
|
11242
11266
|
// API
|
|
11243
|
-
var terminator_1 = terminator;
|
|
11267
|
+
var terminator_1 = terminator$2;
|
|
11244
11268
|
|
|
11245
11269
|
/**
|
|
11246
11270
|
* Terminates jobs in the attached state context
|
|
@@ -11248,7 +11272,7 @@ var terminator_1 = terminator;
|
|
|
11248
11272
|
* @this AsyncKitState#
|
|
11249
11273
|
* @param {function} callback - final callback to invoke after termination
|
|
11250
11274
|
*/
|
|
11251
|
-
function terminator(callback)
|
|
11275
|
+
function terminator$2(callback)
|
|
11252
11276
|
{
|
|
11253
11277
|
if (!Object.keys(this.jobs).length)
|
|
11254
11278
|
{
|
|
@@ -11259,12 +11283,17 @@ function terminator(callback)
|
|
|
11259
11283
|
this.index = this.size;
|
|
11260
11284
|
|
|
11261
11285
|
// abort jobs
|
|
11262
|
-
|
|
11286
|
+
abort(this);
|
|
11263
11287
|
|
|
11264
11288
|
// send back results we have so far
|
|
11265
|
-
|
|
11289
|
+
async(callback)(null, this.results);
|
|
11266
11290
|
}
|
|
11267
11291
|
|
|
11292
|
+
var iterate$1 = iterate_1
|
|
11293
|
+
, initState$1 = state_1
|
|
11294
|
+
, terminator$1 = terminator_1
|
|
11295
|
+
;
|
|
11296
|
+
|
|
11268
11297
|
// Public API
|
|
11269
11298
|
var parallel_1 = parallel;
|
|
11270
11299
|
|
|
@@ -11278,11 +11307,11 @@ var parallel_1 = parallel;
|
|
|
11278
11307
|
*/
|
|
11279
11308
|
function parallel(list, iterator, callback)
|
|
11280
11309
|
{
|
|
11281
|
-
var state =
|
|
11310
|
+
var state = initState$1(list);
|
|
11282
11311
|
|
|
11283
11312
|
while (state.index < (state['keyedList'] || list).length)
|
|
11284
11313
|
{
|
|
11285
|
-
|
|
11314
|
+
iterate$1(list, iterator, state, function(error, result)
|
|
11286
11315
|
{
|
|
11287
11316
|
if (error)
|
|
11288
11317
|
{
|
|
@@ -11301,14 +11330,21 @@ function parallel(list, iterator, callback)
|
|
|
11301
11330
|
state.index++;
|
|
11302
11331
|
}
|
|
11303
11332
|
|
|
11304
|
-
return
|
|
11333
|
+
return terminator$1.bind(state, callback);
|
|
11305
11334
|
}
|
|
11306
11335
|
|
|
11336
|
+
var serialOrdered$2 = {exports: {}};
|
|
11337
|
+
|
|
11338
|
+
var iterate = iterate_1
|
|
11339
|
+
, initState = state_1
|
|
11340
|
+
, terminator = terminator_1
|
|
11341
|
+
;
|
|
11342
|
+
|
|
11307
11343
|
// Public API
|
|
11308
|
-
|
|
11344
|
+
serialOrdered$2.exports = serialOrdered$1;
|
|
11309
11345
|
// sorting helpers
|
|
11310
|
-
|
|
11311
|
-
|
|
11346
|
+
serialOrdered$2.exports.ascending = ascending;
|
|
11347
|
+
serialOrdered$2.exports.descending = descending;
|
|
11312
11348
|
|
|
11313
11349
|
/**
|
|
11314
11350
|
* Runs iterator over provided sorted array elements in series
|
|
@@ -11319,11 +11355,11 @@ var descending_1 = descending;
|
|
|
11319
11355
|
* @param {function} callback - invoked when all elements processed
|
|
11320
11356
|
* @returns {function} - jobs terminator
|
|
11321
11357
|
*/
|
|
11322
|
-
function serialOrdered(list, iterator, sortMethod, callback)
|
|
11358
|
+
function serialOrdered$1(list, iterator, sortMethod, callback)
|
|
11323
11359
|
{
|
|
11324
|
-
var state =
|
|
11360
|
+
var state = initState(list, sortMethod);
|
|
11325
11361
|
|
|
11326
|
-
|
|
11362
|
+
iterate(list, iterator, state, function iteratorHandler(error, result)
|
|
11327
11363
|
{
|
|
11328
11364
|
if (error)
|
|
11329
11365
|
{
|
|
@@ -11336,7 +11372,7 @@ function serialOrdered(list, iterator, sortMethod, callback)
|
|
|
11336
11372
|
// are we there yet?
|
|
11337
11373
|
if (state.index < (state['keyedList'] || list).length)
|
|
11338
11374
|
{
|
|
11339
|
-
|
|
11375
|
+
iterate(list, iterator, state, iteratorHandler);
|
|
11340
11376
|
return;
|
|
11341
11377
|
}
|
|
11342
11378
|
|
|
@@ -11344,7 +11380,7 @@ function serialOrdered(list, iterator, sortMethod, callback)
|
|
|
11344
11380
|
callback(null, state.results);
|
|
11345
11381
|
});
|
|
11346
11382
|
|
|
11347
|
-
return
|
|
11383
|
+
return terminator.bind(state, callback);
|
|
11348
11384
|
}
|
|
11349
11385
|
|
|
11350
11386
|
/*
|
|
@@ -11374,8 +11410,10 @@ function descending(a, b)
|
|
|
11374
11410
|
{
|
|
11375
11411
|
return -1 * ascending(a, b);
|
|
11376
11412
|
}
|
|
11377
|
-
|
|
11378
|
-
|
|
11413
|
+
|
|
11414
|
+
var serialOrderedExports = serialOrdered$2.exports;
|
|
11415
|
+
|
|
11416
|
+
var serialOrdered = serialOrderedExports;
|
|
11379
11417
|
|
|
11380
11418
|
// Public API
|
|
11381
11419
|
var serial_1 = serial;
|
|
@@ -11390,18 +11428,18 @@ var serial_1 = serial;
|
|
|
11390
11428
|
*/
|
|
11391
11429
|
function serial(list, iterator, callback)
|
|
11392
11430
|
{
|
|
11393
|
-
return
|
|
11431
|
+
return serialOrdered(list, iterator, null, callback);
|
|
11394
11432
|
}
|
|
11395
11433
|
|
|
11396
|
-
var asynckit =
|
|
11434
|
+
var asynckit$1 =
|
|
11397
11435
|
{
|
|
11398
11436
|
parallel : parallel_1,
|
|
11399
11437
|
serial : serial_1,
|
|
11400
|
-
serialOrdered :
|
|
11438
|
+
serialOrdered : serialOrderedExports
|
|
11401
11439
|
};
|
|
11402
11440
|
|
|
11403
11441
|
// populates missing values
|
|
11404
|
-
var populate = function(dst, src) {
|
|
11442
|
+
var populate$1 = function(dst, src) {
|
|
11405
11443
|
|
|
11406
11444
|
Object.keys(src).forEach(function(prop)
|
|
11407
11445
|
{
|
|
@@ -11411,18 +11449,23 @@ var populate = function(dst, src) {
|
|
|
11411
11449
|
return dst;
|
|
11412
11450
|
};
|
|
11413
11451
|
|
|
11414
|
-
var
|
|
11415
|
-
|
|
11416
|
-
var
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11452
|
+
var CombinedStream = combined_stream;
|
|
11453
|
+
var util = require$$1;
|
|
11454
|
+
var path = require$$1$1;
|
|
11455
|
+
var http = require$$3;
|
|
11456
|
+
var https = require$$4;
|
|
11457
|
+
var parseUrl = require$$5.parse;
|
|
11458
|
+
var fs = require$$6;
|
|
11459
|
+
var Stream = require$$0$1.Stream;
|
|
11460
|
+
var mime = mimeTypes;
|
|
11461
|
+
var asynckit = asynckit$1;
|
|
11462
|
+
var populate = populate$1;
|
|
11420
11463
|
|
|
11421
11464
|
// Public API
|
|
11422
11465
|
var form_data = FormData;
|
|
11423
11466
|
|
|
11424
11467
|
// make it a Stream
|
|
11425
|
-
util.inherits(FormData,
|
|
11468
|
+
util.inherits(FormData, CombinedStream);
|
|
11426
11469
|
|
|
11427
11470
|
/**
|
|
11428
11471
|
* Create readable "multipart/form-data" streams.
|
|
@@ -11441,7 +11484,7 @@ function FormData(options) {
|
|
|
11441
11484
|
this._valueLength = 0;
|
|
11442
11485
|
this._valuesToMeasure = [];
|
|
11443
11486
|
|
|
11444
|
-
|
|
11487
|
+
CombinedStream.call(this);
|
|
11445
11488
|
|
|
11446
11489
|
options = options || {};
|
|
11447
11490
|
for (var option in options) {
|
|
@@ -11461,7 +11504,7 @@ FormData.prototype.append = function(field, value, options) {
|
|
|
11461
11504
|
options = {filename: options};
|
|
11462
11505
|
}
|
|
11463
11506
|
|
|
11464
|
-
var append =
|
|
11507
|
+
var append = CombinedStream.prototype.append.bind(this);
|
|
11465
11508
|
|
|
11466
11509
|
// all that streamy business can't handle numbers
|
|
11467
11510
|
if (typeof value == 'number') {
|
|
@@ -11656,12 +11699,12 @@ FormData.prototype._getContentType = function(value, options) {
|
|
|
11656
11699
|
|
|
11657
11700
|
// or try `name` from formidable, browser
|
|
11658
11701
|
if (!contentType && value.name) {
|
|
11659
|
-
contentType =
|
|
11702
|
+
contentType = mime.lookup(value.name);
|
|
11660
11703
|
}
|
|
11661
11704
|
|
|
11662
11705
|
// or try `path` from fs-, request- streams
|
|
11663
11706
|
if (!contentType && value.path) {
|
|
11664
|
-
contentType =
|
|
11707
|
+
contentType = mime.lookup(value.path);
|
|
11665
11708
|
}
|
|
11666
11709
|
|
|
11667
11710
|
// or if it's http-reponse
|
|
@@ -11671,7 +11714,7 @@ FormData.prototype._getContentType = function(value, options) {
|
|
|
11671
11714
|
|
|
11672
11715
|
// or guess it from the filepath or filename
|
|
11673
11716
|
if (!contentType && (options.filepath || options.filename)) {
|
|
11674
|
-
contentType =
|
|
11717
|
+
contentType = mime.lookup(options.filepath || options.filename);
|
|
11675
11718
|
}
|
|
11676
11719
|
|
|
11677
11720
|
// fallback to the default content type if `value` is not simple value
|
|
@@ -11908,6 +11951,8 @@ FormData.prototype.toString = function () {
|
|
|
11908
11951
|
return '[object FormData]';
|
|
11909
11952
|
};
|
|
11910
11953
|
|
|
11954
|
+
var FormDataModule = /*@__PURE__*/getDefaultExportFromCjs(form_data);
|
|
11955
|
+
|
|
11911
11956
|
const GRANT_TYPE$1 = 'client_credentials';
|
|
11912
11957
|
const castClientOptionsToRequestParams = (clientOptions) => {
|
|
11913
11958
|
const { scope, clientId, clientSecret } = clientOptions;
|
|
@@ -12101,7 +12146,7 @@ function makeApiRequest(oauthTokenStore, oauthTokenRequester, options, httpMetho
|
|
|
12101
12146
|
const formData = Object.entries(form).reduce((previous, [name, value]) => {
|
|
12102
12147
|
previous.append.apply(previous, [name].concat(value));
|
|
12103
12148
|
return previous;
|
|
12104
|
-
}, new
|
|
12149
|
+
}, new FormDataModule());
|
|
12105
12150
|
const headers = Object.assign(Object.assign(Object.assign(Object.assign({ accept: 'application/json', authorization: `Bearer ${oauthTokenStore.get('accessToken')}`, 'X-Allthings-Caller': `${options.serviceName
|
|
12106
12151
|
? options.serviceName
|
|
12107
12152
|
: process.env.SEVICE_NAME
|