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