@posty5/social-publisher-post 4.1.0 → 5.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 +273 -15
- package/dist/index.d.mts +833 -54
- package/dist/index.d.ts +833 -54
- package/dist/index.js +1552 -217
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1544 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -11747,6 +11747,12 @@ var require_follow_redirects = __commonJS({
|
|
|
11747
11747
|
RedirectableRequest.prototype._sanitizeOptions = function(options) {
|
|
11748
11748
|
if (!options.headers) {
|
|
11749
11749
|
options.headers = {};
|
|
11750
|
+
} else if (Array.isArray(options.headers)) {
|
|
11751
|
+
var headerList = options.headers;
|
|
11752
|
+
options.headers = {};
|
|
11753
|
+
for (var i = 0; i < headerList.length; i += 2) {
|
|
11754
|
+
options.headers[headerList[i]] = headerList[i + 1];
|
|
11755
|
+
}
|
|
11750
11756
|
}
|
|
11751
11757
|
if (!isArray2(options.sensitiveHeaders)) {
|
|
11752
11758
|
options.sensitiveHeaders = [];
|
|
@@ -12021,7 +12027,7 @@ var require_follow_redirects = __commonJS({
|
|
|
12021
12027
|
return URL2 && value instanceof URL2;
|
|
12022
12028
|
}
|
|
12023
12029
|
function escapeRegex(regex) {
|
|
12024
|
-
return regex.replace(/[\]\\/()
|
|
12030
|
+
return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
|
|
12025
12031
|
}
|
|
12026
12032
|
module.exports = wrap({ http: http3, https: https2 });
|
|
12027
12033
|
module.exports.wrap = wrap;
|
|
@@ -12080,22 +12086,82 @@ var { toString } = Object.prototype;
|
|
|
12080
12086
|
var { getPrototypeOf } = Object;
|
|
12081
12087
|
var { iterator, toStringTag } = Symbol;
|
|
12082
12088
|
var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
|
|
12089
|
+
var isUnsafeObjectKey = (prop) => typeof prop === "string" && (prop === "__proto__" || prop === "constructor" || prop === "prototype");
|
|
12090
|
+
var isPrototypeBoundary = (obj, prototype2, source) => obj === Object.prototype || !source && prototype2 === null;
|
|
12091
|
+
var isSafeAndFullyMutable = (obj) => {
|
|
12092
|
+
if (!Object.isExtensible(obj)) {
|
|
12093
|
+
return false;
|
|
12094
|
+
}
|
|
12095
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
12096
|
+
if (Object.getOwnPropertySymbols) {
|
|
12097
|
+
props.push(...Object.getOwnPropertySymbols(obj));
|
|
12098
|
+
}
|
|
12099
|
+
return props.every((prop) => {
|
|
12100
|
+
if (isUnsafeObjectKey(prop)) {
|
|
12101
|
+
return false;
|
|
12102
|
+
}
|
|
12103
|
+
const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
|
|
12104
|
+
return !!descriptor && descriptor.configurable && descriptor.writable === true;
|
|
12105
|
+
});
|
|
12106
|
+
};
|
|
12083
12107
|
var hasOwnInPrototypeChain = (thing, prop) => {
|
|
12084
12108
|
let obj = thing;
|
|
12085
12109
|
const seen = [];
|
|
12086
|
-
while (obj != null
|
|
12110
|
+
while (obj != null) {
|
|
12087
12111
|
if (seen.indexOf(obj) !== -1) {
|
|
12088
12112
|
return false;
|
|
12089
12113
|
}
|
|
12090
12114
|
seen.push(obj);
|
|
12115
|
+
const prototype2 = getPrototypeOf(obj);
|
|
12116
|
+
if (isPrototypeBoundary(obj, prototype2, obj === thing)) {
|
|
12117
|
+
return false;
|
|
12118
|
+
}
|
|
12091
12119
|
if (hasOwnProperty(obj, prop)) {
|
|
12092
12120
|
return true;
|
|
12093
12121
|
}
|
|
12094
|
-
obj =
|
|
12122
|
+
obj = prototype2;
|
|
12095
12123
|
}
|
|
12096
12124
|
return false;
|
|
12097
12125
|
};
|
|
12098
12126
|
var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
|
|
12127
|
+
var toSafeFlatObject = (thing) => {
|
|
12128
|
+
if (thing == null || typeof thing !== "object" && typeof thing !== "function") {
|
|
12129
|
+
return thing;
|
|
12130
|
+
}
|
|
12131
|
+
const sourcePrototype = getPrototypeOf(thing);
|
|
12132
|
+
if (sourcePrototype === null && isSafeAndFullyMutable(thing)) {
|
|
12133
|
+
return thing;
|
|
12134
|
+
}
|
|
12135
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
12136
|
+
const merged = /* @__PURE__ */ Object.create(null);
|
|
12137
|
+
const seen = [];
|
|
12138
|
+
let current = thing;
|
|
12139
|
+
while (current != null) {
|
|
12140
|
+
if (seen.indexOf(current) !== -1) {
|
|
12141
|
+
break;
|
|
12142
|
+
}
|
|
12143
|
+
seen.push(current);
|
|
12144
|
+
const prototype2 = current === thing ? sourcePrototype : getPrototypeOf(current);
|
|
12145
|
+
if (isPrototypeBoundary(current, prototype2, current === thing)) {
|
|
12146
|
+
break;
|
|
12147
|
+
}
|
|
12148
|
+
const props = Object.getOwnPropertyNames(current);
|
|
12149
|
+
if (Object.getOwnPropertySymbols) {
|
|
12150
|
+
props.push(...Object.getOwnPropertySymbols(current));
|
|
12151
|
+
}
|
|
12152
|
+
for (const prop of props) {
|
|
12153
|
+
if (isUnsafeObjectKey(prop)) {
|
|
12154
|
+
continue;
|
|
12155
|
+
}
|
|
12156
|
+
if (!hasOwnProperty(merged, prop)) {
|
|
12157
|
+
result[prop] = thing[prop];
|
|
12158
|
+
merged[prop] = true;
|
|
12159
|
+
}
|
|
12160
|
+
}
|
|
12161
|
+
current = prototype2;
|
|
12162
|
+
}
|
|
12163
|
+
return result;
|
|
12164
|
+
};
|
|
12099
12165
|
var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
|
|
12100
12166
|
const str = toString.call(thing);
|
|
12101
12167
|
return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
|
|
@@ -12130,9 +12196,9 @@ var isPlainObject = (val) => {
|
|
|
12130
12196
|
return false;
|
|
12131
12197
|
}
|
|
12132
12198
|
const prototype2 = getPrototypeOf(val);
|
|
12133
|
-
return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat
|
|
12134
|
-
//
|
|
12135
|
-
//
|
|
12199
|
+
return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat safe own/inherited Symbol.toStringTag or Symbol.iterator members as
|
|
12200
|
+
// evidence the value is tagged/iterable, while ignoring members reachable
|
|
12201
|
+
// only through shared or terminal prototype boundaries.
|
|
12136
12202
|
!hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
|
|
12137
12203
|
};
|
|
12138
12204
|
var isEmptyObject = (val) => {
|
|
@@ -12153,6 +12219,7 @@ var isReactNativeBlob = (value) => {
|
|
|
12153
12219
|
var isReactNative = (formData) => formData && typeof formData.getParts !== "undefined";
|
|
12154
12220
|
var isBlob = kindOfTest("Blob");
|
|
12155
12221
|
var isFileList = kindOfTest("FileList");
|
|
12222
|
+
var isSet = kindOfTest("Set");
|
|
12156
12223
|
var isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
12157
12224
|
function getGlobal() {
|
|
12158
12225
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
@@ -12448,11 +12515,20 @@ var toJSONObject = (obj) => {
|
|
|
12448
12515
|
}
|
|
12449
12516
|
if (!("toJSON" in source)) {
|
|
12450
12517
|
visited.add(source);
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
|
|
12518
|
+
let target;
|
|
12519
|
+
if (isSet(source)) {
|
|
12520
|
+
target = [];
|
|
12521
|
+
for (const value of source) {
|
|
12522
|
+
const reducedValue = visit(value);
|
|
12523
|
+
!isUndefined(reducedValue) && target.push(reducedValue);
|
|
12524
|
+
}
|
|
12525
|
+
} else {
|
|
12526
|
+
target = isArray(source) ? [] : {};
|
|
12527
|
+
forEach(source, (value, key) => {
|
|
12528
|
+
const reducedValue = visit(value);
|
|
12529
|
+
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
12530
|
+
});
|
|
12531
|
+
}
|
|
12456
12532
|
visited.delete(source);
|
|
12457
12533
|
return target;
|
|
12458
12534
|
}
|
|
@@ -12533,6 +12609,7 @@ var utils_default = {
|
|
|
12533
12609
|
// an alias to avoid ESLint no-prototype-builtins detection
|
|
12534
12610
|
hasOwnInPrototypeChain,
|
|
12535
12611
|
getSafeProp,
|
|
12612
|
+
toSafeFlatObject,
|
|
12536
12613
|
reduceDescriptors,
|
|
12537
12614
|
freezeMethods,
|
|
12538
12615
|
toObjectSet,
|
|
@@ -12581,17 +12658,18 @@ var parseHeaders_default = (rawHeaders) => {
|
|
|
12581
12658
|
i = line.indexOf(":");
|
|
12582
12659
|
key = line.substring(0, i).trim().toLowerCase();
|
|
12583
12660
|
val = line.substring(i + 1).trim();
|
|
12584
|
-
|
|
12661
|
+
const hasKey = utils_default.hasOwnProp(parsed, key);
|
|
12662
|
+
if (!key || hasKey && utils_default.hasOwnProp(ignoreDuplicateOf, key)) {
|
|
12585
12663
|
return;
|
|
12586
12664
|
}
|
|
12587
12665
|
if (key === "set-cookie") {
|
|
12588
|
-
if (
|
|
12666
|
+
if (hasKey) {
|
|
12589
12667
|
parsed[key].push(val);
|
|
12590
12668
|
} else {
|
|
12591
12669
|
parsed[key] = [val];
|
|
12592
12670
|
}
|
|
12593
12671
|
} else {
|
|
12594
|
-
parsed[key] =
|
|
12672
|
+
parsed[key] = hasKey ? parsed[key] + ", " + val : val;
|
|
12595
12673
|
}
|
|
12596
12674
|
});
|
|
12597
12675
|
return parsed;
|
|
@@ -12655,6 +12733,90 @@ function parseTokens(str) {
|
|
|
12655
12733
|
}
|
|
12656
12734
|
return tokens;
|
|
12657
12735
|
}
|
|
12736
|
+
var parameterNameRE = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
12737
|
+
function trimOWS(value) {
|
|
12738
|
+
let start = 0;
|
|
12739
|
+
let end = value.length;
|
|
12740
|
+
while (start < end) {
|
|
12741
|
+
const code = value.charCodeAt(start);
|
|
12742
|
+
if (code !== 9 && code !== 32) {
|
|
12743
|
+
break;
|
|
12744
|
+
}
|
|
12745
|
+
start += 1;
|
|
12746
|
+
}
|
|
12747
|
+
while (end > start) {
|
|
12748
|
+
const code = value.charCodeAt(end - 1);
|
|
12749
|
+
if (code !== 9 && code !== 32) {
|
|
12750
|
+
break;
|
|
12751
|
+
}
|
|
12752
|
+
end -= 1;
|
|
12753
|
+
}
|
|
12754
|
+
return start === 0 && end === value.length ? value : value.slice(start, end);
|
|
12755
|
+
}
|
|
12756
|
+
function decodeQuotedString(value) {
|
|
12757
|
+
const last = value.length - 1;
|
|
12758
|
+
if (last < 1 || value.charCodeAt(0) !== 34 || value.charCodeAt(last) !== 34) {
|
|
12759
|
+
return value;
|
|
12760
|
+
}
|
|
12761
|
+
let decoded = "";
|
|
12762
|
+
for (let i = 1; i < last; i++) {
|
|
12763
|
+
const code = value.charCodeAt(i);
|
|
12764
|
+
if (code === 34) {
|
|
12765
|
+
return value;
|
|
12766
|
+
}
|
|
12767
|
+
if (code === 92) {
|
|
12768
|
+
i += 1;
|
|
12769
|
+
if (i >= last) {
|
|
12770
|
+
return value;
|
|
12771
|
+
}
|
|
12772
|
+
}
|
|
12773
|
+
decoded += value[i];
|
|
12774
|
+
}
|
|
12775
|
+
return decoded;
|
|
12776
|
+
}
|
|
12777
|
+
function parseParameters(value) {
|
|
12778
|
+
const parameters = /* @__PURE__ */ Object.create(null);
|
|
12779
|
+
const str = String(value);
|
|
12780
|
+
let start = 0;
|
|
12781
|
+
let quoted = false;
|
|
12782
|
+
let escaped = false;
|
|
12783
|
+
function parseParameter(end) {
|
|
12784
|
+
const part = trimOWS(str.slice(start, end));
|
|
12785
|
+
const equals = part.indexOf("=");
|
|
12786
|
+
if (equals < 1) {
|
|
12787
|
+
return;
|
|
12788
|
+
}
|
|
12789
|
+
const name = trimOWS(part.slice(0, equals));
|
|
12790
|
+
if (!parameterNameRE.test(name)) {
|
|
12791
|
+
return;
|
|
12792
|
+
}
|
|
12793
|
+
const normalizedName = name.toLowerCase();
|
|
12794
|
+
if (normalizedName === "__proto__" || normalizedName === "constructor" || normalizedName === "prototype") {
|
|
12795
|
+
return;
|
|
12796
|
+
}
|
|
12797
|
+
const parameterValue = trimOWS(part.slice(equals + 1));
|
|
12798
|
+
parameters[normalizedName] = decodeQuotedString(parameterValue);
|
|
12799
|
+
}
|
|
12800
|
+
for (let i = 0; i < str.length; i++) {
|
|
12801
|
+
const code = str.charCodeAt(i);
|
|
12802
|
+
if (quoted) {
|
|
12803
|
+
if (escaped) {
|
|
12804
|
+
escaped = false;
|
|
12805
|
+
} else if (code === 92) {
|
|
12806
|
+
escaped = true;
|
|
12807
|
+
} else if (code === 34) {
|
|
12808
|
+
quoted = false;
|
|
12809
|
+
}
|
|
12810
|
+
} else if (code === 34) {
|
|
12811
|
+
quoted = true;
|
|
12812
|
+
} else if (code === 44 || code === 59) {
|
|
12813
|
+
parseParameter(i);
|
|
12814
|
+
start = i + 1;
|
|
12815
|
+
}
|
|
12816
|
+
}
|
|
12817
|
+
parseParameter(str.length);
|
|
12818
|
+
return parameters;
|
|
12819
|
+
}
|
|
12658
12820
|
var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
12659
12821
|
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
12660
12822
|
if (utils_default.isFunction(filter2)) {
|
|
@@ -12830,7 +12992,8 @@ var AxiosHeaders = class {
|
|
|
12830
12992
|
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
|
|
12831
12993
|
}
|
|
12832
12994
|
getSetCookie() {
|
|
12833
|
-
|
|
12995
|
+
const value = this.get("set-cookie");
|
|
12996
|
+
return utils_default.isArray(value) ? value : value == null || value === false ? [] : [value];
|
|
12834
12997
|
}
|
|
12835
12998
|
get [Symbol.toStringTag]() {
|
|
12836
12999
|
return "AxiosHeaders";
|
|
@@ -12838,6 +13001,9 @@ var AxiosHeaders = class {
|
|
|
12838
13001
|
static from(thing) {
|
|
12839
13002
|
return thing instanceof this ? thing : new this(thing);
|
|
12840
13003
|
}
|
|
13004
|
+
static parseParameters(value) {
|
|
13005
|
+
return parseParameters(value);
|
|
13006
|
+
}
|
|
12841
13007
|
static concat(first, ...targets) {
|
|
12842
13008
|
const computed = new this(first);
|
|
12843
13009
|
targets.forEach((target) => computed.set(target));
|
|
@@ -12933,9 +13099,30 @@ function redactConfig(config, redactKeys) {
|
|
|
12933
13099
|
};
|
|
12934
13100
|
return visit(config);
|
|
12935
13101
|
}
|
|
13102
|
+
function stringifySafely(value) {
|
|
13103
|
+
try {
|
|
13104
|
+
return String(value);
|
|
13105
|
+
} catch (err) {
|
|
13106
|
+
return "";
|
|
13107
|
+
}
|
|
13108
|
+
}
|
|
13109
|
+
function aggregateErrorMessage(error) {
|
|
13110
|
+
const message = error.errors.map((entry) => {
|
|
13111
|
+
try {
|
|
13112
|
+
return entry && entry.message ? stringifySafely(entry.message) : stringifySafely(entry);
|
|
13113
|
+
} catch (err) {
|
|
13114
|
+
return "";
|
|
13115
|
+
}
|
|
13116
|
+
}).filter(Boolean).join("; ");
|
|
13117
|
+
return message || error.name || "AggregateError";
|
|
13118
|
+
}
|
|
12936
13119
|
var AxiosError = class _AxiosError extends Error {
|
|
12937
13120
|
static from(error, code, config, request, response, customProps) {
|
|
12938
|
-
|
|
13121
|
+
let message = error.message;
|
|
13122
|
+
if (!message && utils_default.isArray(error.errors) && error.errors.length) {
|
|
13123
|
+
message = aggregateErrorMessage(error);
|
|
13124
|
+
}
|
|
13125
|
+
const axiosError = new _AxiosError(message, code || error.code, config, request, response);
|
|
12939
13126
|
Object.defineProperty(axiosError, "cause", {
|
|
12940
13127
|
__proto__: null,
|
|
12941
13128
|
value: error,
|
|
@@ -13025,6 +13212,16 @@ var AxiosError_default = AxiosError;
|
|
|
13025
13212
|
var import_form_data = __toESM(require_form_data());
|
|
13026
13213
|
var FormData_default = import_form_data.default;
|
|
13027
13214
|
|
|
13215
|
+
// ../node_modules/axios/lib/platform/node/classes/Buffer.js
|
|
13216
|
+
var Buffer_default = {
|
|
13217
|
+
isBufferAvailable() {
|
|
13218
|
+
return typeof Buffer !== "undefined";
|
|
13219
|
+
},
|
|
13220
|
+
from(value) {
|
|
13221
|
+
return Buffer.from(value);
|
|
13222
|
+
}
|
|
13223
|
+
};
|
|
13224
|
+
|
|
13028
13225
|
// ../node_modules/axios/lib/helpers/toFormData.js
|
|
13029
13226
|
var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
|
|
13030
13227
|
function isVisitable(thing) {
|
|
@@ -13051,24 +13248,16 @@ function toFormData(obj, formData, options) {
|
|
|
13051
13248
|
throw new TypeError("target must be an object");
|
|
13052
13249
|
}
|
|
13053
13250
|
formData = formData || new (FormData_default || FormData)();
|
|
13054
|
-
|
|
13055
|
-
options,
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13064
|
-
}
|
|
13065
|
-
);
|
|
13066
|
-
const metaTokens = options.metaTokens;
|
|
13067
|
-
const visitor = options.visitor || defaultVisitor;
|
|
13068
|
-
const dots = options.dots;
|
|
13069
|
-
const indexes = options.indexes;
|
|
13070
|
-
const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
|
|
13071
|
-
const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
|
|
13251
|
+
const option = (name, fallback) => {
|
|
13252
|
+
const value = utils_default.getSafeProp(options, name);
|
|
13253
|
+
return utils_default.isUndefined(value) ? fallback : value;
|
|
13254
|
+
};
|
|
13255
|
+
const metaTokens = option("metaTokens", true);
|
|
13256
|
+
const visitor = option("visitor") || defaultVisitor;
|
|
13257
|
+
const dots = option("dots", false);
|
|
13258
|
+
const indexes = option("indexes", false);
|
|
13259
|
+
const _Blob = option("Blob") || typeof Blob !== "undefined" && Blob;
|
|
13260
|
+
const maxDepth = option("maxDepth", DEFAULT_FORM_DATA_MAX_DEPTH);
|
|
13072
13261
|
const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
|
|
13073
13262
|
const stack = [];
|
|
13074
13263
|
if (!utils_default.isFunction(visitor)) {
|
|
@@ -13089,10 +13278,13 @@ function toFormData(obj, formData, options) {
|
|
|
13089
13278
|
if (useBlob && typeof _Blob === "function") {
|
|
13090
13279
|
return new _Blob([value]);
|
|
13091
13280
|
}
|
|
13092
|
-
if (
|
|
13093
|
-
return
|
|
13281
|
+
if (Buffer_default && Buffer_default.isBufferAvailable()) {
|
|
13282
|
+
return Buffer_default.from(value);
|
|
13094
13283
|
}
|
|
13095
|
-
throw new AxiosError_default(
|
|
13284
|
+
throw new AxiosError_default(
|
|
13285
|
+
"Blob is not supported. Use a Buffer instead.",
|
|
13286
|
+
AxiosError_default.ERR_NOT_SUPPORT
|
|
13287
|
+
);
|
|
13096
13288
|
}
|
|
13097
13289
|
return value;
|
|
13098
13290
|
}
|
|
@@ -13238,9 +13430,47 @@ function buildURL(url2, params, options) {
|
|
|
13238
13430
|
}
|
|
13239
13431
|
|
|
13240
13432
|
// ../node_modules/axios/lib/core/InterceptorManager.js
|
|
13433
|
+
var $internals2 = /* @__PURE__ */ Symbol("internals");
|
|
13434
|
+
function countHandlers(handlers) {
|
|
13435
|
+
return handlers ? handlers.length : 0;
|
|
13436
|
+
}
|
|
13437
|
+
function trimHandlers(handlers) {
|
|
13438
|
+
if (!handlers) {
|
|
13439
|
+
return;
|
|
13440
|
+
}
|
|
13441
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
13442
|
+
handlers.pop();
|
|
13443
|
+
}
|
|
13444
|
+
}
|
|
13445
|
+
function syncHandlerEntries(manager, internals) {
|
|
13446
|
+
const handlers = manager.handlers;
|
|
13447
|
+
const length = countHandlers(handlers);
|
|
13448
|
+
if (handlers !== internals.handlersRef) {
|
|
13449
|
+
internals.handlersRef = handlers;
|
|
13450
|
+
internals.handlerEntries.clear();
|
|
13451
|
+
} else if (length !== internals.handlersLength) {
|
|
13452
|
+
if (!length) {
|
|
13453
|
+
internals.handlerEntries.clear();
|
|
13454
|
+
} else {
|
|
13455
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
13456
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
13457
|
+
internals.handlerEntries.delete(id);
|
|
13458
|
+
}
|
|
13459
|
+
});
|
|
13460
|
+
}
|
|
13461
|
+
}
|
|
13462
|
+
internals.handlersLength = length;
|
|
13463
|
+
}
|
|
13241
13464
|
var InterceptorManager = class {
|
|
13242
13465
|
constructor() {
|
|
13243
13466
|
this.handlers = [];
|
|
13467
|
+
this[$internals2] = {
|
|
13468
|
+
handlersRef: this.handlers,
|
|
13469
|
+
handlersLength: this.handlers.length,
|
|
13470
|
+
handlerEntries: /* @__PURE__ */ new Map(),
|
|
13471
|
+
iterationDepth: 0,
|
|
13472
|
+
nextId: 0
|
|
13473
|
+
};
|
|
13244
13474
|
}
|
|
13245
13475
|
/**
|
|
13246
13476
|
* Add a new interceptor to the stack
|
|
@@ -13252,13 +13482,25 @@ var InterceptorManager = class {
|
|
|
13252
13482
|
* @return {Number} An ID used to remove interceptor later
|
|
13253
13483
|
*/
|
|
13254
13484
|
use(fulfilled, rejected, options) {
|
|
13255
|
-
|
|
13485
|
+
const handler = {
|
|
13256
13486
|
fulfilled,
|
|
13257
13487
|
rejected,
|
|
13258
13488
|
synchronous: options ? options.synchronous : false,
|
|
13259
13489
|
runWhen: options ? options.runWhen : null
|
|
13490
|
+
};
|
|
13491
|
+
const internals = this[$internals2];
|
|
13492
|
+
if (this.handlers == null) {
|
|
13493
|
+
this.handlers = [];
|
|
13494
|
+
}
|
|
13495
|
+
syncHandlerEntries(this, internals);
|
|
13496
|
+
const id = internals.nextId++;
|
|
13497
|
+
this.handlers.push(handler);
|
|
13498
|
+
internals.handlerEntries.set(id, {
|
|
13499
|
+
handler,
|
|
13500
|
+
index: this.handlers.length - 1
|
|
13260
13501
|
});
|
|
13261
|
-
|
|
13502
|
+
internals.handlersLength = this.handlers.length;
|
|
13503
|
+
return id;
|
|
13262
13504
|
}
|
|
13263
13505
|
/**
|
|
13264
13506
|
* Remove an interceptor from the stack
|
|
@@ -13268,8 +13510,19 @@ var InterceptorManager = class {
|
|
|
13268
13510
|
* @returns {void}
|
|
13269
13511
|
*/
|
|
13270
13512
|
eject(id) {
|
|
13271
|
-
|
|
13272
|
-
|
|
13513
|
+
const internals = this[$internals2];
|
|
13514
|
+
syncHandlerEntries(this, internals);
|
|
13515
|
+
const entry = internals.handlerEntries.get(id);
|
|
13516
|
+
if (entry) {
|
|
13517
|
+
internals.handlerEntries.delete(id);
|
|
13518
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
13519
|
+
return;
|
|
13520
|
+
}
|
|
13521
|
+
this.handlers[entry.index] = null;
|
|
13522
|
+
if (!internals.iterationDepth) {
|
|
13523
|
+
trimHandlers(this.handlers);
|
|
13524
|
+
internals.handlersLength = this.handlers.length;
|
|
13525
|
+
}
|
|
13273
13526
|
}
|
|
13274
13527
|
}
|
|
13275
13528
|
/**
|
|
@@ -13280,6 +13533,7 @@ var InterceptorManager = class {
|
|
|
13280
13533
|
clear() {
|
|
13281
13534
|
if (this.handlers) {
|
|
13282
13535
|
this.handlers = [];
|
|
13536
|
+
syncHandlerEntries(this, this[$internals2]);
|
|
13283
13537
|
}
|
|
13284
13538
|
}
|
|
13285
13539
|
/**
|
|
@@ -13293,11 +13547,22 @@ var InterceptorManager = class {
|
|
|
13293
13547
|
* @returns {void}
|
|
13294
13548
|
*/
|
|
13295
13549
|
forEach(fn) {
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13550
|
+
const internals = this[$internals2];
|
|
13551
|
+
syncHandlerEntries(this, internals);
|
|
13552
|
+
internals.iterationDepth++;
|
|
13553
|
+
try {
|
|
13554
|
+
utils_default.forEach(this.handlers, function forEachHandler(h) {
|
|
13555
|
+
if (h !== null) {
|
|
13556
|
+
fn(h);
|
|
13557
|
+
}
|
|
13558
|
+
});
|
|
13559
|
+
} finally {
|
|
13560
|
+
if (!--internals.iterationDepth) {
|
|
13561
|
+
syncHandlerEntries(this, internals);
|
|
13562
|
+
trimHandlers(this.handlers);
|
|
13563
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
13299
13564
|
}
|
|
13300
|
-
}
|
|
13565
|
+
}
|
|
13301
13566
|
}
|
|
13302
13567
|
};
|
|
13303
13568
|
var InterceptorManager_default = InterceptorManager;
|
|
@@ -13393,7 +13658,7 @@ function throwIfDepthExceeded(index) {
|
|
|
13393
13658
|
}
|
|
13394
13659
|
function parsePropPath(name) {
|
|
13395
13660
|
const path = [];
|
|
13396
|
-
const pattern =
|
|
13661
|
+
const pattern = /[^.[\]]+|\[([^.[\]]*)]/g;
|
|
13397
13662
|
let match;
|
|
13398
13663
|
while ((match = pattern.exec(name)) !== null) {
|
|
13399
13664
|
throwIfDepthExceeded(path.length);
|
|
@@ -13449,9 +13714,25 @@ function formDataToJSON(formData) {
|
|
|
13449
13714
|
}
|
|
13450
13715
|
var formDataToJSON_default = formDataToJSON;
|
|
13451
13716
|
|
|
13717
|
+
// ../node_modules/axios/lib/core/methodList.js
|
|
13718
|
+
var methodList = Object.freeze([
|
|
13719
|
+
"get",
|
|
13720
|
+
"delete",
|
|
13721
|
+
"head",
|
|
13722
|
+
"options",
|
|
13723
|
+
"post",
|
|
13724
|
+
"put",
|
|
13725
|
+
"patch",
|
|
13726
|
+
"purge",
|
|
13727
|
+
"link",
|
|
13728
|
+
"unlink",
|
|
13729
|
+
"query"
|
|
13730
|
+
]);
|
|
13731
|
+
var methodList_default = methodList;
|
|
13732
|
+
|
|
13452
13733
|
// ../node_modules/axios/lib/defaults/index.js
|
|
13453
13734
|
var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
|
|
13454
|
-
function
|
|
13735
|
+
function stringifySafely2(rawValue, parser, encoder) {
|
|
13455
13736
|
if (utils_default.isString(rawValue)) {
|
|
13456
13737
|
try {
|
|
13457
13738
|
(parser || JSON.parse)(rawValue);
|
|
@@ -13507,7 +13788,7 @@ var defaults = {
|
|
|
13507
13788
|
}
|
|
13508
13789
|
if (isObjectPayload || hasJSONContentType) {
|
|
13509
13790
|
headers.setContentType("application/json", false);
|
|
13510
|
-
return
|
|
13791
|
+
return stringifySafely2(data);
|
|
13511
13792
|
}
|
|
13512
13793
|
return data;
|
|
13513
13794
|
}
|
|
@@ -13561,7 +13842,7 @@ var defaults = {
|
|
|
13561
13842
|
}
|
|
13562
13843
|
}
|
|
13563
13844
|
};
|
|
13564
|
-
utils_default.forEach(
|
|
13845
|
+
utils_default.forEach(methodList_default, (method) => {
|
|
13565
13846
|
defaults.headers[method] = {};
|
|
13566
13847
|
});
|
|
13567
13848
|
var defaults_default = defaults;
|
|
@@ -13629,29 +13910,62 @@ function isAbsoluteURL(url2) {
|
|
|
13629
13910
|
|
|
13630
13911
|
// ../node_modules/axios/lib/helpers/combineURLs.js
|
|
13631
13912
|
function combineURLs(baseURL, relativeURL) {
|
|
13632
|
-
|
|
13913
|
+
if (!relativeURL) {
|
|
13914
|
+
return baseURL;
|
|
13915
|
+
}
|
|
13916
|
+
let end = baseURL.length;
|
|
13917
|
+
while (end > 0 && baseURL.charCodeAt(end - 1) === 47) {
|
|
13918
|
+
end--;
|
|
13919
|
+
}
|
|
13920
|
+
return baseURL.slice(0, end) + "/" + relativeURL.replace(/^\/+/, "");
|
|
13921
|
+
}
|
|
13922
|
+
|
|
13923
|
+
// ../node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js
|
|
13924
|
+
var urlParserControlCharacters = /[\t\n\r]/g;
|
|
13925
|
+
function normalizeURLForProtocolCheck(url2) {
|
|
13926
|
+
if (typeof url2 !== "string") {
|
|
13927
|
+
return url2;
|
|
13928
|
+
}
|
|
13929
|
+
let start = 0;
|
|
13930
|
+
while (start < url2.length && url2.charCodeAt(start) <= 32) {
|
|
13931
|
+
start++;
|
|
13932
|
+
}
|
|
13933
|
+
return url2.slice(start).replace(urlParserControlCharacters, "");
|
|
13633
13934
|
}
|
|
13634
13935
|
|
|
13635
13936
|
// ../node_modules/axios/lib/core/buildFullPath.js
|
|
13636
13937
|
var malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
while (i < url2.length && url2.charCodeAt(i) <= 32) {
|
|
13641
|
-
i++;
|
|
13938
|
+
function redactFragment(fragment) {
|
|
13939
|
+
if (!fragment) {
|
|
13940
|
+
return fragment;
|
|
13642
13941
|
}
|
|
13643
|
-
return
|
|
13942
|
+
return fragment.replace(/(^|&)([^=&]*=)?[^&]+/g, (match, separator, parameterName = "") => {
|
|
13943
|
+
return `${separator}${parameterName}${REDACTED}`;
|
|
13944
|
+
});
|
|
13644
13945
|
}
|
|
13645
|
-
function
|
|
13646
|
-
|
|
13946
|
+
function redactSensitiveURLParts(url2) {
|
|
13947
|
+
const redactedURL = url2.replace(/^(https?:\/{0,2})[^/?#]*@/i, `$1${REDACTED}@`);
|
|
13948
|
+
const fragmentIndex = redactedURL.indexOf("#");
|
|
13949
|
+
const urlWithoutFragment = fragmentIndex === -1 ? redactedURL : redactedURL.slice(0, fragmentIndex);
|
|
13950
|
+
const redactedURLWithoutFragment = urlWithoutFragment.replace(
|
|
13951
|
+
/([?&][^=&#]*=)[^&#]*/g,
|
|
13952
|
+
`$1${REDACTED}`
|
|
13953
|
+
);
|
|
13954
|
+
if (fragmentIndex === -1) {
|
|
13955
|
+
return redactedURLWithoutFragment;
|
|
13956
|
+
}
|
|
13957
|
+
return `${redactedURLWithoutFragment}#${redactFragment(redactedURL.slice(fragmentIndex + 1))}`;
|
|
13647
13958
|
}
|
|
13648
13959
|
function assertValidHttpProtocolURL(url2, config) {
|
|
13649
|
-
if (typeof url2 === "string"
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
AxiosError_default
|
|
13653
|
-
|
|
13654
|
-
|
|
13960
|
+
if (typeof url2 === "string") {
|
|
13961
|
+
const normalizedURL = normalizeURLForProtocolCheck(url2);
|
|
13962
|
+
if (malformedHttpProtocol.test(normalizedURL)) {
|
|
13963
|
+
throw new AxiosError_default(
|
|
13964
|
+
`Invalid URL ${JSON.stringify(redactSensitiveURLParts(normalizedURL))}: missing "//" after protocol`,
|
|
13965
|
+
AxiosError_default.ERR_INVALID_URL,
|
|
13966
|
+
config
|
|
13967
|
+
);
|
|
13968
|
+
}
|
|
13655
13969
|
}
|
|
13656
13970
|
}
|
|
13657
13971
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
|
|
@@ -13736,7 +14050,7 @@ var import_https_proxy_agent = __toESM(require_dist());
|
|
|
13736
14050
|
var import_follow_redirects = __toESM(require_follow_redirects());
|
|
13737
14051
|
|
|
13738
14052
|
// ../node_modules/axios/lib/env/data.js
|
|
13739
|
-
var VERSION = "1.
|
|
14053
|
+
var VERSION = "1.20.0";
|
|
13740
14054
|
|
|
13741
14055
|
// ../node_modules/axios/lib/helpers/parseProtocol.js
|
|
13742
14056
|
function parseProtocol(url2) {
|
|
@@ -13745,7 +14059,7 @@ function parseProtocol(url2) {
|
|
|
13745
14059
|
}
|
|
13746
14060
|
|
|
13747
14061
|
// ../node_modules/axios/lib/helpers/fromDataURI.js
|
|
13748
|
-
var DATA_URL_PATTERN = /^([
|
|
14062
|
+
var DATA_URL_PATTERN = /^([^,;/]+\/[^,;/]+)?((?:;[^,;=]+=[^,;]+)*)(;base64)?,([\s\S]*)$/;
|
|
13749
14063
|
function fromDataURI(uri, asBlob, options) {
|
|
13750
14064
|
const _Blob = options && options.Blob || platform_default.classes.Blob;
|
|
13751
14065
|
const protocol = parseProtocol(uri);
|
|
@@ -13779,6 +14093,20 @@ function fromDataURI(uri, asBlob, options) {
|
|
|
13779
14093
|
}
|
|
13780
14094
|
throw new AxiosError_default("Unsupported protocol " + protocol, AxiosError_default.ERR_NOT_SUPPORT);
|
|
13781
14095
|
}
|
|
14096
|
+
|
|
14097
|
+
// ../node_modules/axios/lib/core/setFormDataHeaders.js
|
|
14098
|
+
var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
|
|
14099
|
+
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
14100
|
+
if (policy !== "content-only") {
|
|
14101
|
+
headers.set(formHeaders);
|
|
14102
|
+
return;
|
|
14103
|
+
}
|
|
14104
|
+
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
14105
|
+
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
14106
|
+
headers.set(key, val);
|
|
14107
|
+
}
|
|
14108
|
+
});
|
|
14109
|
+
}
|
|
13782
14110
|
var kInternals = /* @__PURE__ */ Symbol("internals");
|
|
13783
14111
|
var AxiosTransformStream = class extends stream3__default.default.Transform {
|
|
13784
14112
|
constructor(options) {
|
|
@@ -14024,6 +14352,7 @@ var Http2Sessions = class {
|
|
|
14024
14352
|
}
|
|
14025
14353
|
getSession(authority, options) {
|
|
14026
14354
|
options = Object.assign(
|
|
14355
|
+
/* @__PURE__ */ Object.create(null),
|
|
14027
14356
|
{
|
|
14028
14357
|
sessionTimeout: 1e3
|
|
14029
14358
|
},
|
|
@@ -14089,6 +14418,7 @@ var Http2Sessions = class {
|
|
|
14089
14418
|
};
|
|
14090
14419
|
}
|
|
14091
14420
|
session.once("close", removeSession);
|
|
14421
|
+
session.once("error", removeSession);
|
|
14092
14422
|
let entry = [session, options];
|
|
14093
14423
|
authoritySessions ? authoritySessions.push(entry) : authoritySessions = this.sessions[authority] = [entry];
|
|
14094
14424
|
return session;
|
|
@@ -14113,12 +14443,73 @@ var callbackify_default = callbackify;
|
|
|
14113
14443
|
|
|
14114
14444
|
// ../node_modules/axios/lib/helpers/shouldBypassProxy.js
|
|
14115
14445
|
var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "0.0.0.0"]);
|
|
14446
|
+
var trimTrailingDots = (value) => {
|
|
14447
|
+
let end = value.length;
|
|
14448
|
+
while (end && value.charCodeAt(end - 1) === 46) {
|
|
14449
|
+
end--;
|
|
14450
|
+
}
|
|
14451
|
+
return end === value.length ? value : value.slice(0, end);
|
|
14452
|
+
};
|
|
14116
14453
|
var isIPv4Loopback = (host) => {
|
|
14117
14454
|
const parts = host.split(".");
|
|
14118
14455
|
if (parts.length !== 4) return false;
|
|
14119
14456
|
if (parts[0] !== "127") return false;
|
|
14120
14457
|
return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
|
|
14121
14458
|
};
|
|
14459
|
+
var parseIPv4Octet = (text) => {
|
|
14460
|
+
if (/^0[xX][0-9a-fA-F]+$/.test(text)) {
|
|
14461
|
+
const n = parseInt(text.slice(2), 16);
|
|
14462
|
+
return Number.isFinite(n) ? n : null;
|
|
14463
|
+
}
|
|
14464
|
+
if (text.length > 1 && /^0[0-7]+$/.test(text)) {
|
|
14465
|
+
const n = parseInt(text, 8);
|
|
14466
|
+
return Number.isFinite(n) ? n : null;
|
|
14467
|
+
}
|
|
14468
|
+
if (text.length > 1 && /^0[0-9]+$/.test(text)) {
|
|
14469
|
+
return null;
|
|
14470
|
+
}
|
|
14471
|
+
if (/^[0-9]+$/.test(text)) {
|
|
14472
|
+
const n = parseInt(text, 10);
|
|
14473
|
+
return Number.isFinite(n) ? n : null;
|
|
14474
|
+
}
|
|
14475
|
+
return null;
|
|
14476
|
+
};
|
|
14477
|
+
var normalizeIPAddress = (host) => {
|
|
14478
|
+
if (typeof host !== "string" || !host || host.indexOf(":") !== -1) {
|
|
14479
|
+
return host;
|
|
14480
|
+
}
|
|
14481
|
+
let h = host;
|
|
14482
|
+
if (h.charAt(0) === "[" && h.charAt(h.length - 1) === "]") {
|
|
14483
|
+
h = h.slice(1, -1);
|
|
14484
|
+
}
|
|
14485
|
+
h = trimTrailingDots(h);
|
|
14486
|
+
if (!/^[0-9.xXa-fA-F]+$/.test(h)) return host;
|
|
14487
|
+
const parts = h.split(".");
|
|
14488
|
+
if (parts.some((p) => p === "")) return host;
|
|
14489
|
+
if (parts.length === 4) {
|
|
14490
|
+
const octets = parts.map(parseIPv4Octet);
|
|
14491
|
+
if (octets.some((n) => n === null || n < 0 || n > 255)) return host;
|
|
14492
|
+
return octets.join(".");
|
|
14493
|
+
}
|
|
14494
|
+
if (parts.length > 4) {
|
|
14495
|
+
return host;
|
|
14496
|
+
}
|
|
14497
|
+
if (parts.length === 1) return host;
|
|
14498
|
+
const literalOctets = parts.slice(0, -1);
|
|
14499
|
+
const tail = parts[parts.length - 1];
|
|
14500
|
+
const tailSlots = 4 - literalOctets.length;
|
|
14501
|
+
const tailValue = parseIPv4Octet(tail);
|
|
14502
|
+
if (tailValue === null) return host;
|
|
14503
|
+
const maxTail = (1 << 8 * tailSlots) - 1;
|
|
14504
|
+
if (tailValue < 0 || tailValue > maxTail) return host;
|
|
14505
|
+
const tailOctets = new Array(tailSlots).fill(0);
|
|
14506
|
+
for (let i = tailSlots - 1, v = tailValue; i >= 0; i--, v >>= 8) {
|
|
14507
|
+
tailOctets[i] = v & 255;
|
|
14508
|
+
}
|
|
14509
|
+
const literal = literalOctets.map(parseIPv4Octet);
|
|
14510
|
+
if (literal.some((n) => n === null || n < 0 || n > 255)) return host;
|
|
14511
|
+
return [...literal, ...tailOctets].join(".");
|
|
14512
|
+
};
|
|
14122
14513
|
var isIPv6ZeroGroup = (group) => /^0{1,4}$/.test(group);
|
|
14123
14514
|
var isIPv6Unspecified = (host) => {
|
|
14124
14515
|
if (host === "::") return true;
|
|
@@ -14203,6 +14594,40 @@ var unmapIPv4MappedIPv6 = (host) => {
|
|
|
14203
14594
|
}
|
|
14204
14595
|
return host;
|
|
14205
14596
|
};
|
|
14597
|
+
var IPV4_OCTET_RE = /^(?:0|[1-9]\d{0,2})$/;
|
|
14598
|
+
var ipv4ToBytes = (host) => {
|
|
14599
|
+
const parts = host.split(".");
|
|
14600
|
+
return parts.length === 4 && parts.every((part) => IPV4_OCTET_RE.test(part) && Number(part) <= 255) ? parts.map(Number) : null;
|
|
14601
|
+
};
|
|
14602
|
+
var IPV6_GROUP_RE = /^[0-9a-f]{1,4}$/i;
|
|
14603
|
+
var ipv6ToBytes = (host) => {
|
|
14604
|
+
const halves = host.split("::");
|
|
14605
|
+
if (halves.length > 2) {
|
|
14606
|
+
return null;
|
|
14607
|
+
}
|
|
14608
|
+
const groups = halves[0] ? halves[0].split(":") : [];
|
|
14609
|
+
if (halves.length === 2) {
|
|
14610
|
+
const rear = halves[1] ? halves[1].split(":") : [];
|
|
14611
|
+
const missing = 8 - groups.length - rear.length;
|
|
14612
|
+
if (missing < 1) {
|
|
14613
|
+
return null;
|
|
14614
|
+
}
|
|
14615
|
+
groups.push(...new Array(missing).fill("0"), ...rear);
|
|
14616
|
+
}
|
|
14617
|
+
if (groups.length !== 8 || groups.some((group) => !IPV6_GROUP_RE.test(group))) {
|
|
14618
|
+
return null;
|
|
14619
|
+
}
|
|
14620
|
+
return groups.flatMap((group) => {
|
|
14621
|
+
const value = Number.parseInt(group, 16);
|
|
14622
|
+
return [value >> 8 & 255, value & 255];
|
|
14623
|
+
});
|
|
14624
|
+
};
|
|
14625
|
+
var ipToBytes = (host) => {
|
|
14626
|
+
if (typeof host !== "string" || !host) {
|
|
14627
|
+
return null;
|
|
14628
|
+
}
|
|
14629
|
+
return host.indexOf(":") !== -1 ? ipv6ToBytes(host) : ipv4ToBytes(host);
|
|
14630
|
+
};
|
|
14206
14631
|
var normalizeNoProxyHost = (hostname) => {
|
|
14207
14632
|
if (!hostname) {
|
|
14208
14633
|
return hostname;
|
|
@@ -14210,7 +14635,89 @@ var normalizeNoProxyHost = (hostname) => {
|
|
|
14210
14635
|
if (hostname.charAt(0) === "[" && hostname.charAt(hostname.length - 1) === "]") {
|
|
14211
14636
|
hostname = hostname.slice(1, -1);
|
|
14212
14637
|
}
|
|
14213
|
-
|
|
14638
|
+
const trimmed = trimTrailingDots(hostname);
|
|
14639
|
+
const ipv4 = normalizeIPAddress(trimmed);
|
|
14640
|
+
if (ipv4 !== trimmed) {
|
|
14641
|
+
return ipv4;
|
|
14642
|
+
}
|
|
14643
|
+
return unmapIPv4MappedIPv6(trimmed);
|
|
14644
|
+
};
|
|
14645
|
+
var normalizeCidrBase = (input) => {
|
|
14646
|
+
let base = input;
|
|
14647
|
+
const startsBracket = base.charAt(0) === "[";
|
|
14648
|
+
const endsBracket = base.charAt(base.length - 1) === "]";
|
|
14649
|
+
const hasBracket = base.includes("[") || base.includes("]");
|
|
14650
|
+
if (startsBracket || endsBracket) {
|
|
14651
|
+
if (!startsBracket || !endsBracket) {
|
|
14652
|
+
return null;
|
|
14653
|
+
}
|
|
14654
|
+
base = base.slice(1, -1);
|
|
14655
|
+
if (base.indexOf(":") === -1 || base.includes("[") || base.includes("]")) {
|
|
14656
|
+
return null;
|
|
14657
|
+
}
|
|
14658
|
+
} else if (hasBracket) {
|
|
14659
|
+
return null;
|
|
14660
|
+
}
|
|
14661
|
+
if (!base || base.charAt(base.length - 1) === ".") {
|
|
14662
|
+
return null;
|
|
14663
|
+
}
|
|
14664
|
+
const wasIPv6 = base.indexOf(":") !== -1;
|
|
14665
|
+
if (wasIPv6) {
|
|
14666
|
+
try {
|
|
14667
|
+
base = new URL(`http://[${base}]/`).hostname.slice(1, -1);
|
|
14668
|
+
} catch (_err) {
|
|
14669
|
+
return null;
|
|
14670
|
+
}
|
|
14671
|
+
} else {
|
|
14672
|
+
base = normalizeIPAddress(base);
|
|
14673
|
+
if (!ipv4ToBytes(base)) {
|
|
14674
|
+
return null;
|
|
14675
|
+
}
|
|
14676
|
+
}
|
|
14677
|
+
return { normalized: unmapIPv4MappedIPv6(base), wasIPv6 };
|
|
14678
|
+
};
|
|
14679
|
+
var CIDR_ENTRY_RE = /^(.+)\/(0|[1-9]\d{0,2})$/;
|
|
14680
|
+
var parseCidrEntry = (entry) => {
|
|
14681
|
+
if (entry.indexOf("/") === -1) {
|
|
14682
|
+
return void 0;
|
|
14683
|
+
}
|
|
14684
|
+
const match = CIDR_ENTRY_RE.exec(entry);
|
|
14685
|
+
if (!match) {
|
|
14686
|
+
return null;
|
|
14687
|
+
}
|
|
14688
|
+
let prefix = Number(match[2]);
|
|
14689
|
+
const parsedBase = normalizeCidrBase(match[1]);
|
|
14690
|
+
if (!parsedBase) {
|
|
14691
|
+
return null;
|
|
14692
|
+
}
|
|
14693
|
+
const { normalized, wasIPv6 } = parsedBase;
|
|
14694
|
+
if (wasIPv6 && normalized.indexOf(":") === -1) {
|
|
14695
|
+
if (prefix < 96) {
|
|
14696
|
+
return null;
|
|
14697
|
+
}
|
|
14698
|
+
prefix -= 96;
|
|
14699
|
+
}
|
|
14700
|
+
const bytes = ipToBytes(normalized);
|
|
14701
|
+
if (!bytes || prefix > bytes.length * 8) {
|
|
14702
|
+
return null;
|
|
14703
|
+
}
|
|
14704
|
+
return { bytes, prefix };
|
|
14705
|
+
};
|
|
14706
|
+
var isInSubnet = (addressBytes, networkBytes, prefix) => {
|
|
14707
|
+
const fullBytes = prefix >> 3;
|
|
14708
|
+
for (let i = 0; i < fullBytes; i++) {
|
|
14709
|
+
if (addressBytes[i] !== networkBytes[i]) {
|
|
14710
|
+
return false;
|
|
14711
|
+
}
|
|
14712
|
+
}
|
|
14713
|
+
const remainingBits = prefix & 7;
|
|
14714
|
+
if (remainingBits) {
|
|
14715
|
+
const mask = 255 << 8 - remainingBits & 255;
|
|
14716
|
+
if ((addressBytes[fullBytes] & mask) !== (networkBytes[fullBytes] & mask)) {
|
|
14717
|
+
return false;
|
|
14718
|
+
}
|
|
14719
|
+
}
|
|
14720
|
+
return true;
|
|
14214
14721
|
};
|
|
14215
14722
|
function shouldBypassProxy(location) {
|
|
14216
14723
|
let parsed;
|
|
@@ -14228,10 +14735,18 @@ function shouldBypassProxy(location) {
|
|
|
14228
14735
|
}
|
|
14229
14736
|
const port = Number.parseInt(parsed.port, 10) || DEFAULT_PORTS2[parsed.protocol.split(":", 1)[0]] || 0;
|
|
14230
14737
|
const hostname = normalizeNoProxyHost(parsed.hostname.toLowerCase());
|
|
14738
|
+
const hostnameBytes = ipToBytes(hostname);
|
|
14231
14739
|
return noProxy.split(/[\s,]+/).some((entry) => {
|
|
14232
14740
|
if (!entry) {
|
|
14233
14741
|
return false;
|
|
14234
14742
|
}
|
|
14743
|
+
if (entry === "*") {
|
|
14744
|
+
return true;
|
|
14745
|
+
}
|
|
14746
|
+
const cidr = parseCidrEntry(entry);
|
|
14747
|
+
if (cidr !== void 0) {
|
|
14748
|
+
return cidr !== null && !!hostnameBytes && hostnameBytes.length === cidr.bytes.length && isInSubnet(hostnameBytes, cidr.bytes, cidr.prefix);
|
|
14749
|
+
}
|
|
14235
14750
|
let [entryHost, entryPort] = parseNoProxyEntry(entry);
|
|
14236
14751
|
entryHost = normalizeNoProxyHost(entryHost);
|
|
14237
14752
|
if (!entryHost) {
|
|
@@ -14317,7 +14832,8 @@ function throttle(fn, freq) {
|
|
|
14317
14832
|
}
|
|
14318
14833
|
};
|
|
14319
14834
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
14320
|
-
|
|
14835
|
+
const flushWith = (...args) => invoke(args);
|
|
14836
|
+
return [throttled, flush, flushWith];
|
|
14321
14837
|
}
|
|
14322
14838
|
var throttle_default = throttle;
|
|
14323
14839
|
|
|
@@ -14326,12 +14842,12 @@ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
14326
14842
|
let bytesNotified = 0;
|
|
14327
14843
|
const _speedometer = speedometer_default(50, 250);
|
|
14328
14844
|
return throttle_default((e) => {
|
|
14329
|
-
if (!e ||
|
|
14845
|
+
if (!e || !utils_default.isNumber(e.loaded)) {
|
|
14330
14846
|
return;
|
|
14331
14847
|
}
|
|
14332
14848
|
const rawLoaded = e.loaded;
|
|
14333
14849
|
const total = e.lengthComputable ? e.total : void 0;
|
|
14334
|
-
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
14850
|
+
const loaded = Math.max(0, total != null ? Math.min(rawLoaded, total) : rawLoaded);
|
|
14335
14851
|
const progressBytes = Math.max(0, loaded - bytesNotified);
|
|
14336
14852
|
const rate = _speedometer(progressBytes);
|
|
14337
14853
|
bytesNotified = Math.max(bytesNotified, loaded);
|
|
@@ -14360,12 +14876,66 @@ var progressEventDecorator = (total, throttled) => {
|
|
|
14360
14876
|
throttled[1]
|
|
14361
14877
|
];
|
|
14362
14878
|
};
|
|
14363
|
-
var asyncDecorator = (fn) => (...args) =>
|
|
14879
|
+
var asyncDecorator = (fn, scheduler = utils_default.asap) => (...args) => scheduler(() => fn(...args));
|
|
14364
14880
|
|
|
14365
14881
|
// ../node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js
|
|
14366
14882
|
var isHexDigit = (charCode) => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
|
|
14367
14883
|
var isPercentEncodedByte = (str, i, len) => i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
|
|
14368
|
-
|
|
14884
|
+
var hexValue = (charCode) => charCode <= 57 ? charCode - 48 : (charCode & 223) - 55;
|
|
14885
|
+
var isBase64Char = (charCode) => charCode >= 65 && charCode <= 90 || // A-Z
|
|
14886
|
+
charCode >= 97 && charCode <= 122 || // a-z
|
|
14887
|
+
charCode >= 48 && charCode <= 57 || // 0-9
|
|
14888
|
+
charCode === 43 || // +
|
|
14889
|
+
charCode === 47 || // /
|
|
14890
|
+
charCode === 45 || // - (base64url)
|
|
14891
|
+
charCode === 95;
|
|
14892
|
+
var isBase64Whitespace = (charCode) => charCode === 9 || charCode === 10 || charCode === 12 || charCode === 13 || charCode === 32;
|
|
14893
|
+
var base64Bytes = (significant) => {
|
|
14894
|
+
const groups = Math.floor(significant / 4);
|
|
14895
|
+
const remainder = significant % 4;
|
|
14896
|
+
return groups * 3 + (remainder === 2 ? 1 : remainder === 3 ? 2 : 0);
|
|
14897
|
+
};
|
|
14898
|
+
var estimateBase64BufferAllocation = (body) => {
|
|
14899
|
+
const len = body.length;
|
|
14900
|
+
let padding = 0;
|
|
14901
|
+
if (len > 0 && body.charCodeAt(len - 1) === 61) {
|
|
14902
|
+
padding++;
|
|
14903
|
+
if (len > 1 && body.charCodeAt(len - 2) === 61) {
|
|
14904
|
+
padding++;
|
|
14905
|
+
}
|
|
14906
|
+
}
|
|
14907
|
+
return Math.floor((len - padding) * 3 / 4);
|
|
14908
|
+
};
|
|
14909
|
+
var estimatePercentDecodedBase64Bytes = (body) => {
|
|
14910
|
+
const len = body.length;
|
|
14911
|
+
let significant = 0;
|
|
14912
|
+
let padding = 0;
|
|
14913
|
+
let invalid = false;
|
|
14914
|
+
for (let i = 0; i < len; i++) {
|
|
14915
|
+
let code = body.charCodeAt(i);
|
|
14916
|
+
if (code === 37 && isPercentEncodedByte(body, i, len)) {
|
|
14917
|
+
code = hexValue(body.charCodeAt(i + 1)) * 16 + hexValue(body.charCodeAt(i + 2));
|
|
14918
|
+
i += 2;
|
|
14919
|
+
}
|
|
14920
|
+
if (isBase64Whitespace(code)) {
|
|
14921
|
+
continue;
|
|
14922
|
+
}
|
|
14923
|
+
if (code === 61) {
|
|
14924
|
+
padding++;
|
|
14925
|
+
continue;
|
|
14926
|
+
}
|
|
14927
|
+
if (!isBase64Char(code) || padding > 0) {
|
|
14928
|
+
invalid = true;
|
|
14929
|
+
continue;
|
|
14930
|
+
}
|
|
14931
|
+
significant++;
|
|
14932
|
+
}
|
|
14933
|
+
if (invalid || padding > 2 || padding > 0 && (significant + padding) % 4 !== 0 || significant % 4 === 1) {
|
|
14934
|
+
return estimateBase64BufferAllocation(body);
|
|
14935
|
+
}
|
|
14936
|
+
return base64Bytes(significant);
|
|
14937
|
+
};
|
|
14938
|
+
var estimateDataURLBytes = (url2, estimateBase64) => {
|
|
14369
14939
|
if (!url2 || typeof url2 !== "string") return 0;
|
|
14370
14940
|
if (!url2.startsWith("data:")) return 0;
|
|
14371
14941
|
const comma = url2.indexOf(",");
|
|
@@ -14374,43 +14944,7 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
14374
14944
|
const body = url2.slice(comma + 1);
|
|
14375
14945
|
const isBase64 = /;base64/i.test(meta);
|
|
14376
14946
|
if (isBase64) {
|
|
14377
|
-
|
|
14378
|
-
const len = body.length;
|
|
14379
|
-
for (let i = 0; i < len; i++) {
|
|
14380
|
-
if (body.charCodeAt(i) === 37 && i + 2 < len) {
|
|
14381
|
-
const a = body.charCodeAt(i + 1);
|
|
14382
|
-
const b = body.charCodeAt(i + 2);
|
|
14383
|
-
const isHex = isHexDigit(a) && isHexDigit(b);
|
|
14384
|
-
if (isHex) {
|
|
14385
|
-
effectiveLen -= 2;
|
|
14386
|
-
i += 2;
|
|
14387
|
-
}
|
|
14388
|
-
}
|
|
14389
|
-
}
|
|
14390
|
-
let pad = 0;
|
|
14391
|
-
let idx = len - 1;
|
|
14392
|
-
const tailIsPct3D = (j) => j >= 2 && body.charCodeAt(j - 2) === 37 && // '%'
|
|
14393
|
-
body.charCodeAt(j - 1) === 51 && // '3'
|
|
14394
|
-
(body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
|
|
14395
|
-
if (idx >= 0) {
|
|
14396
|
-
if (body.charCodeAt(idx) === 61) {
|
|
14397
|
-
pad++;
|
|
14398
|
-
idx--;
|
|
14399
|
-
} else if (tailIsPct3D(idx)) {
|
|
14400
|
-
pad++;
|
|
14401
|
-
idx -= 3;
|
|
14402
|
-
}
|
|
14403
|
-
}
|
|
14404
|
-
if (pad === 1 && idx >= 0) {
|
|
14405
|
-
if (body.charCodeAt(idx) === 61) {
|
|
14406
|
-
pad++;
|
|
14407
|
-
} else if (tailIsPct3D(idx)) {
|
|
14408
|
-
pad++;
|
|
14409
|
-
}
|
|
14410
|
-
}
|
|
14411
|
-
const groups = Math.floor(effectiveLen / 4);
|
|
14412
|
-
const bytes2 = groups * 3 - (pad || 0);
|
|
14413
|
-
return bytes2 > 0 ? bytes2 : 0;
|
|
14947
|
+
return estimateBase64(body);
|
|
14414
14948
|
}
|
|
14415
14949
|
let bytes = 0;
|
|
14416
14950
|
for (let i = 0, len = body.length; i < len; i++) {
|
|
@@ -14435,6 +14969,16 @@ function estimateDataURLDecodedBytes(url2) {
|
|
|
14435
14969
|
}
|
|
14436
14970
|
}
|
|
14437
14971
|
return bytes;
|
|
14972
|
+
};
|
|
14973
|
+
function estimateDataURLDecodedBytes(url2) {
|
|
14974
|
+
const fragmentIndex = typeof url2 === "string" ? url2.indexOf("#") : -1;
|
|
14975
|
+
return estimateDataURLBytes(
|
|
14976
|
+
fragmentIndex === -1 ? url2 : url2.slice(0, fragmentIndex),
|
|
14977
|
+
estimatePercentDecodedBase64Bytes
|
|
14978
|
+
);
|
|
14979
|
+
}
|
|
14980
|
+
function estimateDataURLBufferAllocation(url2) {
|
|
14981
|
+
return estimateDataURLBytes(url2, estimateBase64BufferAllocation);
|
|
14438
14982
|
}
|
|
14439
14983
|
|
|
14440
14984
|
// ../node_modules/axios/lib/adapters/http.js
|
|
@@ -14454,22 +14998,17 @@ var isBrotliSupported = utils_default.isFunction(zlib__default.default.createBro
|
|
|
14454
14998
|
var isZstdSupported = utils_default.isFunction(zlib__default.default.createZstdDecompress);
|
|
14455
14999
|
var ACCEPT_ENCODING = "gzip, compress, deflate" + (isBrotliSupported ? ", br" : "");
|
|
14456
15000
|
var ACCEPT_ENCODING_WITH_ZSTD = ACCEPT_ENCODING + (isZstdSupported ? ", zstd" : "");
|
|
15001
|
+
var scheduleProgress = typeof process !== "undefined" && process.nextTick ? process.nextTick.bind(process) : utils_default.asap;
|
|
14457
15002
|
var { http: httpFollow, https: httpsFollow } = import_follow_redirects.default;
|
|
14458
15003
|
var isHttps = /https:?/;
|
|
14459
|
-
var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
|
|
14460
|
-
function setFormDataHeaders(headers, formHeaders, policy) {
|
|
14461
|
-
if (policy !== "content-only") {
|
|
14462
|
-
headers.set(formHeaders);
|
|
14463
|
-
return;
|
|
14464
|
-
}
|
|
14465
|
-
Object.entries(formHeaders).forEach(([key, val]) => {
|
|
14466
|
-
if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
|
|
14467
|
-
headers.set(key, val);
|
|
14468
|
-
}
|
|
14469
|
-
});
|
|
14470
|
-
}
|
|
14471
15004
|
var kAxiosSocketListener = /* @__PURE__ */ Symbol("axios.http.socketListener");
|
|
14472
15005
|
var kAxiosCurrentReq = /* @__PURE__ */ Symbol("axios.http.currentReq");
|
|
15006
|
+
function handleSocketError(err) {
|
|
15007
|
+
const current = this[kAxiosCurrentReq];
|
|
15008
|
+
if (current && !current.destroyed) {
|
|
15009
|
+
current.destroy(err);
|
|
15010
|
+
}
|
|
15011
|
+
}
|
|
14473
15012
|
var kAxiosInstalledTunnel = /* @__PURE__ */ Symbol("axios.http.installedTunnel");
|
|
14474
15013
|
var tunnelingAgentCache = /* @__PURE__ */ new Map();
|
|
14475
15014
|
var tunnelingAgentCacheUser = /* @__PURE__ */ new WeakMap();
|
|
@@ -14572,10 +15111,10 @@ function isSameOriginRedirect(redirectOptions, requestDetails) {
|
|
|
14572
15111
|
return false;
|
|
14573
15112
|
}
|
|
14574
15113
|
}
|
|
14575
|
-
function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent) {
|
|
15114
|
+
function setProxy(options, configProxy, location, isRedirect, configHttpsAgent, configHttpAgent, allowEnvProxy = true) {
|
|
14576
15115
|
let proxy = configProxy;
|
|
14577
15116
|
const proxyEnvAgent = getProxyEnvAgent(options, configHttpAgent, configHttpsAgent);
|
|
14578
|
-
if (!proxy && proxy !== false && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
15117
|
+
if (!proxy && proxy !== false && allowEnvProxy && !isNodeEnvProxyEnabled(proxyEnvAgent)) {
|
|
14579
15118
|
const proxyUrl = getProxyForUrl(location);
|
|
14580
15119
|
if (proxyUrl) {
|
|
14581
15120
|
if (!shouldBypassProxy(location)) {
|
|
@@ -14672,9 +15211,13 @@ function setProxy(options, configProxy, location, isRedirect, configHttpsAgent,
|
|
|
14672
15211
|
redirectOptions.href,
|
|
14673
15212
|
true,
|
|
14674
15213
|
configHttpsAgent,
|
|
14675
|
-
configHttpAgent
|
|
15214
|
+
configHttpAgent,
|
|
15215
|
+
allowEnvProxy
|
|
14676
15216
|
);
|
|
14677
15217
|
};
|
|
15218
|
+
return Boolean(
|
|
15219
|
+
proxy || configProxy !== false && allowEnvProxy && isNodeEnvProxyEnabled(proxyEnvAgent)
|
|
15220
|
+
);
|
|
14678
15221
|
}
|
|
14679
15222
|
var isHttpAdapterSupported = typeof process !== "undefined" && utils_default.kindOf(process) === "process";
|
|
14680
15223
|
var wrapAsync = (asyncExecutor) => {
|
|
@@ -14699,7 +15242,7 @@ var wrapAsync = (asyncExecutor) => {
|
|
|
14699
15242
|
};
|
|
14700
15243
|
var resolveFamily = ({ address, family }) => {
|
|
14701
15244
|
if (!utils_default.isString(address)) {
|
|
14702
|
-
throw
|
|
15245
|
+
throw new AxiosError_default("address must be a string", AxiosError_default.ERR_BAD_OPTION_VALUE);
|
|
14703
15246
|
}
|
|
14704
15247
|
return {
|
|
14705
15248
|
address,
|
|
@@ -14707,12 +15250,36 @@ var resolveFamily = ({ address, family }) => {
|
|
|
14707
15250
|
};
|
|
14708
15251
|
};
|
|
14709
15252
|
var buildAddressEntry = (address, family) => resolveFamily(utils_default.isObject(address) ? address : { address, family });
|
|
14710
|
-
var
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
15253
|
+
var normalizedLookupCache = /* @__PURE__ */ new WeakMap();
|
|
15254
|
+
var normalizeLookup = (lookup) => {
|
|
15255
|
+
let normalized = normalizedLookupCache.get(lookup);
|
|
15256
|
+
if (normalized) {
|
|
15257
|
+
return normalized;
|
|
15258
|
+
}
|
|
15259
|
+
const callbackLookup = callbackify_default(lookup, (value) => utils_default.isArray(value) ? value : [value]);
|
|
15260
|
+
normalized = (hostname, opt, cb) => {
|
|
15261
|
+
callbackLookup(hostname, opt, (err, arg0, arg1) => {
|
|
15262
|
+
if (err) {
|
|
15263
|
+
return cb(err);
|
|
15264
|
+
}
|
|
15265
|
+
let addresses;
|
|
15266
|
+
try {
|
|
15267
|
+
addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
|
15268
|
+
} catch (error) {
|
|
15269
|
+
return cb(error);
|
|
15270
|
+
}
|
|
15271
|
+
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
|
15272
|
+
});
|
|
15273
|
+
};
|
|
15274
|
+
normalizedLookupCache.set(lookup, normalized);
|
|
15275
|
+
return normalized;
|
|
15276
|
+
};
|
|
15277
|
+
var http2Transport = {
|
|
15278
|
+
request(options, cb) {
|
|
15279
|
+
const authority = options.protocol + "//" + options.hostname + ":" + (options.port || (options.protocol === "https:" ? 443 : 80));
|
|
15280
|
+
const { http2Options, headers } = options;
|
|
15281
|
+
const session = http2Sessions.getSession(authority, http2Options);
|
|
15282
|
+
const { HTTP2_HEADER_SCHEME, HTTP2_HEADER_METHOD, HTTP2_HEADER_PATH, HTTP2_HEADER_STATUS } = http2__default.default.constants;
|
|
14716
15283
|
const http2Headers = {
|
|
14717
15284
|
[HTTP2_HEADER_SCHEME]: options.protocol.replace(":", ""),
|
|
14718
15285
|
[HTTP2_HEADER_METHOD]: options.method,
|
|
@@ -14743,6 +15310,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14743
15310
|
let family = own2("family");
|
|
14744
15311
|
let httpVersion = own2("httpVersion");
|
|
14745
15312
|
if (httpVersion === void 0) httpVersion = 1;
|
|
15313
|
+
const rawHttpVersion = httpVersion;
|
|
14746
15314
|
let http2Options = own2("http2Options");
|
|
14747
15315
|
const httpAgent = own2("httpAgent");
|
|
14748
15316
|
const httpsAgent = own2("httpsAgent");
|
|
@@ -14759,25 +15327,32 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14759
15327
|
let rejected = false;
|
|
14760
15328
|
let req;
|
|
14761
15329
|
let connectPhaseTimer;
|
|
14762
|
-
|
|
15330
|
+
try {
|
|
15331
|
+
httpVersion = +httpVersion;
|
|
15332
|
+
} catch (err) {
|
|
15333
|
+
throw new AxiosError_default(
|
|
15334
|
+
"Invalid protocol version: value is not a number",
|
|
15335
|
+
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
15336
|
+
config
|
|
15337
|
+
);
|
|
15338
|
+
}
|
|
14763
15339
|
if (Number.isNaN(httpVersion)) {
|
|
14764
|
-
throw
|
|
15340
|
+
throw new AxiosError_default(
|
|
15341
|
+
`Invalid protocol version: '${rawHttpVersion}' is not a number`,
|
|
15342
|
+
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
15343
|
+
config
|
|
15344
|
+
);
|
|
14765
15345
|
}
|
|
14766
15346
|
if (httpVersion !== 1 && httpVersion !== 2) {
|
|
14767
|
-
throw
|
|
15347
|
+
throw new AxiosError_default(
|
|
15348
|
+
`Unsupported protocol version '${httpVersion}'`,
|
|
15349
|
+
AxiosError_default.ERR_BAD_OPTION_VALUE,
|
|
15350
|
+
config
|
|
15351
|
+
);
|
|
14768
15352
|
}
|
|
14769
15353
|
const isHttp2 = httpVersion === 2;
|
|
14770
15354
|
if (lookup) {
|
|
14771
|
-
|
|
14772
|
-
lookup = (hostname, opt, cb) => {
|
|
14773
|
-
_lookup(hostname, opt, (err, arg0, arg1) => {
|
|
14774
|
-
if (err) {
|
|
14775
|
-
return cb(err);
|
|
14776
|
-
}
|
|
14777
|
-
const addresses = utils_default.isArray(arg0) ? arg0.map((addr) => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
|
|
14778
|
-
opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
|
|
14779
|
-
});
|
|
14780
|
-
};
|
|
15355
|
+
lookup = normalizeLookup(lookup);
|
|
14781
15356
|
}
|
|
14782
15357
|
const abortEmitter = new events.EventEmitter();
|
|
14783
15358
|
function abort(reason) {
|
|
@@ -14851,7 +15426,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14851
15426
|
if (protocol === "data:") {
|
|
14852
15427
|
if (maxContentLength > -1) {
|
|
14853
15428
|
const dataUrl = String(own2("url") || fullPath || "");
|
|
14854
|
-
const estimated =
|
|
15429
|
+
const estimated = estimateDataURLBufferAllocation(dataUrl);
|
|
14855
15430
|
if (estimated > maxContentLength) {
|
|
14856
15431
|
return reject(
|
|
14857
15432
|
new AxiosError_default(
|
|
@@ -14981,7 +15556,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
14981
15556
|
data,
|
|
14982
15557
|
progressEventDecorator(
|
|
14983
15558
|
contentLength,
|
|
14984
|
-
progressEventReducer(asyncDecorator(onUploadProgress), false, 3)
|
|
15559
|
+
progressEventReducer(asyncDecorator(onUploadProgress, scheduleProgress), false, 3)
|
|
14985
15560
|
)
|
|
14986
15561
|
)
|
|
14987
15562
|
);
|
|
@@ -15019,6 +15594,9 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15019
15594
|
utils_default.hasOwnProp(transitional2, "advertiseZstdAcceptEncoding") && transitional2.advertiseZstdAcceptEncoding === true ? ACCEPT_ENCODING_WITH_ZSTD : ACCEPT_ENCODING,
|
|
15020
15595
|
false
|
|
15021
15596
|
);
|
|
15597
|
+
if (isHttp2 && lookup) {
|
|
15598
|
+
http2Options = Object.assign(/* @__PURE__ */ Object.create(null), http2Options, { lookup });
|
|
15599
|
+
}
|
|
15022
15600
|
const options = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
15023
15601
|
path: path$1,
|
|
15024
15602
|
method,
|
|
@@ -15029,9 +15607,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15029
15607
|
family,
|
|
15030
15608
|
beforeRedirect: dispatchBeforeRedirect,
|
|
15031
15609
|
beforeRedirects: /* @__PURE__ */ Object.create(null),
|
|
15032
|
-
http2Options
|
|
15610
|
+
http2Options,
|
|
15611
|
+
createConnection: void 0
|
|
15033
15612
|
});
|
|
15034
15613
|
!utils_default.isUndefined(lookup) && (options.lookup = lookup);
|
|
15614
|
+
let proxyApplied = false;
|
|
15035
15615
|
if (socketPath) {
|
|
15036
15616
|
if (typeof socketPath !== "string") {
|
|
15037
15617
|
return reject(
|
|
@@ -15059,13 +15639,17 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15059
15639
|
} else {
|
|
15060
15640
|
options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
|
|
15061
15641
|
options.port = parsed.port;
|
|
15062
|
-
setProxy(
|
|
15642
|
+
proxyApplied = setProxy(
|
|
15063
15643
|
options,
|
|
15064
15644
|
configProxy,
|
|
15065
15645
|
protocol + "//" + parsed.hostname + (parsed.port ? ":" + parsed.port : "") + options.path,
|
|
15066
15646
|
false,
|
|
15067
15647
|
httpsAgent,
|
|
15068
|
-
httpAgent
|
|
15648
|
+
httpAgent,
|
|
15649
|
+
// The HTTP/2 transport connects independently of HTTP/1 agents, so it
|
|
15650
|
+
// cannot apply either axios-resolved or agent-local environment proxies.
|
|
15651
|
+
// Explicit proxy config is still processed and rejected below.
|
|
15652
|
+
!isHttp2
|
|
15069
15653
|
);
|
|
15070
15654
|
}
|
|
15071
15655
|
let transport;
|
|
@@ -15076,6 +15660,15 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15076
15660
|
options.agent = isHttpsRequest ? httpsAgent : httpAgent;
|
|
15077
15661
|
}
|
|
15078
15662
|
if (isHttp2) {
|
|
15663
|
+
if (proxyApplied) {
|
|
15664
|
+
return reject(
|
|
15665
|
+
new AxiosError_default(
|
|
15666
|
+
"HTTP/2 requests with a proxy are not supported",
|
|
15667
|
+
AxiosError_default.ERR_NOT_SUPPORT,
|
|
15668
|
+
config
|
|
15669
|
+
)
|
|
15670
|
+
);
|
|
15671
|
+
}
|
|
15079
15672
|
transport = http2Transport;
|
|
15080
15673
|
} else {
|
|
15081
15674
|
const configTransport = own2("transport");
|
|
@@ -15163,7 +15756,11 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15163
15756
|
transformStream,
|
|
15164
15757
|
progressEventDecorator(
|
|
15165
15758
|
responseLength,
|
|
15166
|
-
progressEventReducer(
|
|
15759
|
+
progressEventReducer(
|
|
15760
|
+
asyncDecorator(onDownloadProgress, scheduleProgress),
|
|
15761
|
+
true,
|
|
15762
|
+
3
|
|
15763
|
+
)
|
|
15167
15764
|
)
|
|
15168
15765
|
)
|
|
15169
15766
|
);
|
|
@@ -15312,12 +15909,7 @@ var http_default = isHttpAdapterSupported && function httpAdapter(config) {
|
|
|
15312
15909
|
socket.setKeepAlive(true, 1e3 * 60);
|
|
15313
15910
|
}
|
|
15314
15911
|
if (!socket[kAxiosSocketListener]) {
|
|
15315
|
-
socket.on("error",
|
|
15316
|
-
const current = socket[kAxiosCurrentReq];
|
|
15317
|
-
if (current && !current.destroyed) {
|
|
15318
|
-
current.destroy(err);
|
|
15319
|
-
}
|
|
15320
|
-
});
|
|
15912
|
+
socket.on("error", handleSocketError);
|
|
15321
15913
|
socket[kAxiosSocketListener] = true;
|
|
15322
15914
|
}
|
|
15323
15915
|
socket[kAxiosCurrentReq] = req;
|
|
@@ -15477,6 +16069,16 @@ var cookies_default = platform_default.hasStandardBrowserEnv ? (
|
|
|
15477
16069
|
|
|
15478
16070
|
// ../node_modules/axios/lib/core/mergeConfig.js
|
|
15479
16071
|
var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
|
|
16072
|
+
var ownEnumerableKeys = (thing) => {
|
|
16073
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
16074
|
+
return Object.keys(thing).concat(
|
|
16075
|
+
Object.getOwnPropertySymbols(thing).filter(
|
|
16076
|
+
(symbol) => Object.getOwnPropertyDescriptor(thing, symbol).enumerable
|
|
16077
|
+
)
|
|
16078
|
+
);
|
|
16079
|
+
}
|
|
16080
|
+
return Object.keys(thing);
|
|
16081
|
+
};
|
|
15480
16082
|
function mergeConfig(config1, config2) {
|
|
15481
16083
|
config1 = config1 || {};
|
|
15482
16084
|
config2 = config2 || {};
|
|
@@ -15552,7 +16154,7 @@ function mergeConfig(config1, config2) {
|
|
|
15552
16154
|
transformResponse: defaultToConfig2,
|
|
15553
16155
|
paramsSerializer: defaultToConfig2,
|
|
15554
16156
|
timeout: defaultToConfig2,
|
|
15555
|
-
|
|
16157
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
15556
16158
|
withCredentials: defaultToConfig2,
|
|
15557
16159
|
withXSRFToken: defaultToConfig2,
|
|
15558
16160
|
adapter: defaultToConfig2,
|
|
@@ -15575,7 +16177,7 @@ function mergeConfig(config1, config2) {
|
|
|
15575
16177
|
validateStatus: mergeDirectKeys,
|
|
15576
16178
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
15577
16179
|
};
|
|
15578
|
-
utils_default.forEach(
|
|
16180
|
+
utils_default.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
15579
16181
|
if (prop === "__proto__" || prop === "constructor" || prop === "prototype") return;
|
|
15580
16182
|
const merge2 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
15581
16183
|
const a = utils_default.hasOwnProp(config1, prop) ? config1[prop] : void 0;
|
|
@@ -15594,18 +16196,6 @@ function mergeConfig(config1, config2) {
|
|
|
15594
16196
|
}
|
|
15595
16197
|
|
|
15596
16198
|
// ../node_modules/axios/lib/helpers/resolveConfig.js
|
|
15597
|
-
var FORM_DATA_CONTENT_HEADERS2 = ["content-type", "content-length"];
|
|
15598
|
-
function setFormDataHeaders2(headers, formHeaders, policy) {
|
|
15599
|
-
if (policy !== "content-only") {
|
|
15600
|
-
headers.set(formHeaders);
|
|
15601
|
-
return;
|
|
15602
|
-
}
|
|
15603
|
-
Object.entries(formHeaders || {}).forEach(([key, val]) => {
|
|
15604
|
-
if (FORM_DATA_CONTENT_HEADERS2.includes(key.toLowerCase())) {
|
|
15605
|
-
headers.set(key, val);
|
|
15606
|
-
}
|
|
15607
|
-
});
|
|
15608
|
-
}
|
|
15609
16199
|
var encodeUTF8 = (str) => encodeURIComponent(str).replace(
|
|
15610
16200
|
/%([0-9A-F]{2})/gi,
|
|
15611
16201
|
(_, hex) => String.fromCharCode(parseInt(hex, 16))
|
|
@@ -15641,10 +16231,11 @@ function resolveConfig(config) {
|
|
|
15641
16231
|
}
|
|
15642
16232
|
}
|
|
15643
16233
|
if (utils_default.isFormData(data)) {
|
|
16234
|
+
const getHeaders = utils_default.getSafeProp(data, "getHeaders");
|
|
15644
16235
|
if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
|
|
15645
16236
|
headers.setContentType(void 0);
|
|
15646
|
-
} else if (utils_default.isFunction(
|
|
15647
|
-
|
|
16237
|
+
} else if (utils_default.isFunction(getHeaders)) {
|
|
16238
|
+
setFormDataHeaders(headers, getHeaders.call(data), own2("formDataHeaderPolicy"));
|
|
15648
16239
|
}
|
|
15649
16240
|
}
|
|
15650
16241
|
if (platform_default.hasStandardBrowserEnv) {
|
|
@@ -15673,7 +16264,7 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
15673
16264
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
15674
16265
|
let onCanceled;
|
|
15675
16266
|
let uploadThrottled, downloadThrottled;
|
|
15676
|
-
let flushUpload, flushDownload;
|
|
16267
|
+
let flushUpload, flushDownload, flushDownloadWithEvent;
|
|
15677
16268
|
function done() {
|
|
15678
16269
|
flushUpload && flushUpload();
|
|
15679
16270
|
flushDownload && flushDownload();
|
|
@@ -15683,7 +16274,27 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
15683
16274
|
let request = new XMLHttpRequest();
|
|
15684
16275
|
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
15685
16276
|
request.timeout = _config.timeout;
|
|
15686
|
-
function onloadend() {
|
|
16277
|
+
function onloadend(event) {
|
|
16278
|
+
if (!request) {
|
|
16279
|
+
return;
|
|
16280
|
+
}
|
|
16281
|
+
if (request.status === 0 && (parseProtocol(normalizeURLForProtocolCheck(_config.url)) || parseProtocol(platform_default.origin)) !== "file" && !(request.responseURL && request.responseURL.startsWith("file:"))) {
|
|
16282
|
+
reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
|
|
16283
|
+
done();
|
|
16284
|
+
request = null;
|
|
16285
|
+
return;
|
|
16286
|
+
}
|
|
16287
|
+
try {
|
|
16288
|
+
if (event) {
|
|
16289
|
+
flushDownloadWithEvent && flushDownloadWithEvent(event);
|
|
16290
|
+
} else {
|
|
16291
|
+
flushDownload && flushDownload();
|
|
16292
|
+
}
|
|
16293
|
+
} catch (err) {
|
|
16294
|
+
setTimeout(() => {
|
|
16295
|
+
throw err;
|
|
16296
|
+
});
|
|
16297
|
+
}
|
|
15687
16298
|
if (!request) {
|
|
15688
16299
|
return;
|
|
15689
16300
|
}
|
|
@@ -15771,7 +16382,10 @@ var xhr_default = isXHRAdapterSupported && function(config) {
|
|
|
15771
16382
|
request.responseType = _config.responseType;
|
|
15772
16383
|
}
|
|
15773
16384
|
if (onDownloadProgress) {
|
|
15774
|
-
[downloadThrottled, flushDownload] = progressEventReducer(
|
|
16385
|
+
[downloadThrottled, flushDownload, flushDownloadWithEvent] = progressEventReducer(
|
|
16386
|
+
onDownloadProgress,
|
|
16387
|
+
true
|
|
16388
|
+
);
|
|
15775
16389
|
request.addEventListener("progress", downloadThrottled);
|
|
15776
16390
|
}
|
|
15777
16391
|
if (onUploadProgress && request.upload) {
|
|
@@ -15843,7 +16457,16 @@ var composeSignals = (signals, timeout) => {
|
|
|
15843
16457
|
});
|
|
15844
16458
|
signals = null;
|
|
15845
16459
|
};
|
|
15846
|
-
signals.forEach((signal2) =>
|
|
16460
|
+
signals.forEach((signal2) => {
|
|
16461
|
+
if (aborted) {
|
|
16462
|
+
return;
|
|
16463
|
+
}
|
|
16464
|
+
if (signal2.aborted) {
|
|
16465
|
+
onabort.call(signal2);
|
|
16466
|
+
return;
|
|
16467
|
+
}
|
|
16468
|
+
signal2.addEventListener("abort", onabort, { once: true });
|
|
16469
|
+
});
|
|
15847
16470
|
const { signal } = controller;
|
|
15848
16471
|
signal.unsubscribe = () => utils_default.asap(unsubscribe);
|
|
15849
16472
|
return signal;
|
|
@@ -15932,6 +16555,17 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
|
|
|
15932
16555
|
|
|
15933
16556
|
// ../node_modules/axios/lib/adapters/fetch.js
|
|
15934
16557
|
var DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
16558
|
+
var DEFAULT_REQUEST_OPTIONS = {
|
|
16559
|
+
cache: "default",
|
|
16560
|
+
redirect: "follow",
|
|
16561
|
+
referrer: "about:client",
|
|
16562
|
+
referrerPolicy: "",
|
|
16563
|
+
mode: "cors",
|
|
16564
|
+
integrity: "",
|
|
16565
|
+
keepalive: false,
|
|
16566
|
+
priority: "auto",
|
|
16567
|
+
window: null
|
|
16568
|
+
};
|
|
15935
16569
|
var { isFunction: isFunction2 } = utils_default;
|
|
15936
16570
|
var encodeUTF82 = (str) => encodeURIComponent(str).replace(
|
|
15937
16571
|
/%([0-9A-F]{2})/gi,
|
|
@@ -16062,7 +16696,8 @@ var factory = (env) => {
|
|
|
16062
16696
|
withCredentials = "same-origin",
|
|
16063
16697
|
fetchOptions,
|
|
16064
16698
|
maxContentLength,
|
|
16065
|
-
maxBodyLength
|
|
16699
|
+
maxBodyLength,
|
|
16700
|
+
maxRedirects
|
|
16066
16701
|
} = resolveConfig_default(config);
|
|
16067
16702
|
const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
|
|
16068
16703
|
const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
|
|
@@ -16192,17 +16827,44 @@ var factory = (env) => {
|
|
|
16192
16827
|
}
|
|
16193
16828
|
}
|
|
16194
16829
|
headers.set("User-Agent", "axios/" + VERSION, false);
|
|
16195
|
-
const
|
|
16196
|
-
|
|
16830
|
+
const safeFetchOptions = fetchOptions == null ? fetchOptions : Object.assign(/* @__PURE__ */ Object.create(null), fetchOptions);
|
|
16831
|
+
if (safeFetchOptions) {
|
|
16832
|
+
delete safeFetchOptions.body;
|
|
16833
|
+
delete safeFetchOptions.headers;
|
|
16834
|
+
delete safeFetchOptions.method;
|
|
16835
|
+
delete safeFetchOptions.signal;
|
|
16836
|
+
delete safeFetchOptions.duplex;
|
|
16837
|
+
delete safeFetchOptions.credentials;
|
|
16838
|
+
}
|
|
16839
|
+
const resolvedOptions = Object.assign(/* @__PURE__ */ Object.create(null), safeFetchOptions, {
|
|
16197
16840
|
signal: composedSignal,
|
|
16198
16841
|
method: method.toUpperCase(),
|
|
16199
16842
|
headers: toByteStringHeaderObject(headers.normalize()),
|
|
16200
16843
|
body: data,
|
|
16201
16844
|
duplex: "half",
|
|
16202
16845
|
credentials: isCredentialsSupported ? withCredentials : void 0
|
|
16203
|
-
};
|
|
16846
|
+
});
|
|
16847
|
+
if (isRequestSupported) {
|
|
16848
|
+
utils_default.forEach(DEFAULT_REQUEST_OPTIONS, (value, key) => {
|
|
16849
|
+
if (resolvedOptions[key] === void 0) {
|
|
16850
|
+
resolvedOptions[key] = value;
|
|
16851
|
+
}
|
|
16852
|
+
});
|
|
16853
|
+
if (resolvedOptions.signal === void 0) {
|
|
16854
|
+
resolvedOptions.signal = null;
|
|
16855
|
+
}
|
|
16856
|
+
if (resolvedOptions.body === void 0) {
|
|
16857
|
+
resolvedOptions.body = null;
|
|
16858
|
+
}
|
|
16859
|
+
}
|
|
16860
|
+
if (maxRedirects === 0) {
|
|
16861
|
+
resolvedOptions.redirect = "manual";
|
|
16862
|
+
if (safeFetchOptions) {
|
|
16863
|
+
safeFetchOptions.redirect = "manual";
|
|
16864
|
+
}
|
|
16865
|
+
}
|
|
16204
16866
|
request = isRequestSupported && new Request(url2, resolvedOptions);
|
|
16205
|
-
let response = await (isRequestSupported ? _fetch(request,
|
|
16867
|
+
let response = await (isRequestSupported ? _fetch(request, safeFetchOptions) : _fetch(url2, resolvedOptions));
|
|
16206
16868
|
const responseHeaders = AxiosHeaders_default.from(response.headers);
|
|
16207
16869
|
if (hasMaxContentLength) {
|
|
16208
16870
|
const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
|
|
@@ -16421,9 +17083,10 @@ function throwIfCancellationRequested(config) {
|
|
|
16421
17083
|
throw new CanceledError_default(null, config);
|
|
16422
17084
|
}
|
|
16423
17085
|
}
|
|
16424
|
-
function dispatchRequest(
|
|
17086
|
+
function dispatchRequest(_config) {
|
|
17087
|
+
const config = utils_default.toSafeFlatObject(_config);
|
|
16425
17088
|
throwIfCancellationRequested(config);
|
|
16426
|
-
config.headers = AxiosHeaders_default.from(config
|
|
17089
|
+
config.headers = AxiosHeaders_default.from(utils_default.getSafeProp(config, "headers"));
|
|
16427
17090
|
config.data = transformData.call(config, config.transformRequest);
|
|
16428
17091
|
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
|
16429
17092
|
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
@@ -16553,16 +17216,15 @@ var Axios = class {
|
|
|
16553
17216
|
return await this._request(configOrUrl, config);
|
|
16554
17217
|
} catch (err) {
|
|
16555
17218
|
if (err instanceof Error) {
|
|
16556
|
-
let dummy = {};
|
|
16557
|
-
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
16558
|
-
const stack = (() => {
|
|
16559
|
-
if (!dummy.stack) {
|
|
16560
|
-
return "";
|
|
16561
|
-
}
|
|
16562
|
-
const firstNewlineIndex = dummy.stack.indexOf("\n");
|
|
16563
|
-
return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
|
|
16564
|
-
})();
|
|
16565
17219
|
try {
|
|
17220
|
+
let dummy = {};
|
|
17221
|
+
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
17222
|
+
const dummyStack = dummy.stack;
|
|
17223
|
+
let stack = "";
|
|
17224
|
+
if (typeof dummyStack === "string") {
|
|
17225
|
+
const firstNewlineIndex = dummyStack.indexOf("\n");
|
|
17226
|
+
stack = firstNewlineIndex === -1 ? "" : dummyStack.slice(firstNewlineIndex + 1);
|
|
17227
|
+
}
|
|
16566
17228
|
if (!err.stack) {
|
|
16567
17229
|
err.stack = stack;
|
|
16568
17230
|
} else if (stack) {
|
|
@@ -16631,9 +17293,9 @@ var Axios = class {
|
|
|
16631
17293
|
},
|
|
16632
17294
|
true
|
|
16633
17295
|
);
|
|
16634
|
-
config.method = (config
|
|
17296
|
+
config.method = (utils_default.getSafeProp(config, "method") || utils_default.getSafeProp(this.defaults, "method") || "get").toLowerCase();
|
|
16635
17297
|
let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
|
|
16636
|
-
headers && utils_default.forEach(
|
|
17298
|
+
headers && utils_default.forEach(methodList_default.concat("common"), (method) => {
|
|
16637
17299
|
delete headers[method];
|
|
16638
17300
|
});
|
|
16639
17301
|
config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
|
|
@@ -16676,16 +17338,31 @@ var Axios = class {
|
|
|
16676
17338
|
const onFulfilled = requestInterceptorChain[i++];
|
|
16677
17339
|
const onRejected = requestInterceptorChain[i++];
|
|
16678
17340
|
try {
|
|
16679
|
-
newConfig = onFulfilled(newConfig);
|
|
17341
|
+
newConfig = onFulfilled ? onFulfilled(newConfig) : newConfig;
|
|
16680
17342
|
} catch (error) {
|
|
16681
|
-
onRejected
|
|
17343
|
+
if (!onRejected) {
|
|
17344
|
+
promise = Promise.reject(error);
|
|
17345
|
+
break;
|
|
17346
|
+
}
|
|
17347
|
+
try {
|
|
17348
|
+
const rejectedResult = onRejected.call(this, error);
|
|
17349
|
+
if (utils_default.isThenable(rejectedResult)) {
|
|
17350
|
+
promise = Promise.resolve(rejectedResult).then(
|
|
17351
|
+
() => dispatchRequest.call(this, newConfig)
|
|
17352
|
+
);
|
|
17353
|
+
}
|
|
17354
|
+
} catch (rejectedError) {
|
|
17355
|
+
promise = Promise.reject(rejectedError);
|
|
17356
|
+
}
|
|
16682
17357
|
break;
|
|
16683
17358
|
}
|
|
16684
17359
|
}
|
|
16685
|
-
|
|
16686
|
-
|
|
16687
|
-
|
|
16688
|
-
|
|
17360
|
+
if (!promise) {
|
|
17361
|
+
try {
|
|
17362
|
+
promise = dispatchRequest.call(this, newConfig);
|
|
17363
|
+
} catch (error) {
|
|
17364
|
+
promise = Promise.reject(error);
|
|
17365
|
+
}
|
|
16689
17366
|
}
|
|
16690
17367
|
i = 0;
|
|
16691
17368
|
len = responseInterceptorChain.length;
|
|
@@ -16881,14 +17558,22 @@ var HttpStatusCode = {
|
|
|
16881
17558
|
Gone: 410,
|
|
16882
17559
|
LengthRequired: 411,
|
|
16883
17560
|
PreconditionFailed: 412,
|
|
17561
|
+
/**
|
|
17562
|
+
* @deprecated Use `ContentTooLarge` instead.
|
|
17563
|
+
*/
|
|
16884
17564
|
PayloadTooLarge: 413,
|
|
17565
|
+
ContentTooLarge: 413,
|
|
16885
17566
|
UriTooLong: 414,
|
|
16886
17567
|
UnsupportedMediaType: 415,
|
|
16887
17568
|
RangeNotSatisfiable: 416,
|
|
16888
17569
|
ExpectationFailed: 417,
|
|
16889
17570
|
ImATeapot: 418,
|
|
16890
17571
|
MisdirectedRequest: 421,
|
|
17572
|
+
/**
|
|
17573
|
+
* @deprecated Use `UnprocessableContent` instead.
|
|
17574
|
+
*/
|
|
16891
17575
|
UnprocessableEntity: 422,
|
|
17576
|
+
UnprocessableContent: 422,
|
|
16892
17577
|
Locked: 423,
|
|
16893
17578
|
FailedDependency: 424,
|
|
16894
17579
|
TooEarly: 425,
|
|
@@ -16908,6 +17593,7 @@ var HttpStatusCode = {
|
|
|
16908
17593
|
LoopDetected: 508,
|
|
16909
17594
|
NotExtended: 510,
|
|
16910
17595
|
NetworkAuthenticationRequired: 511,
|
|
17596
|
+
WebServerReturnsAnUnknownError: 520,
|
|
16911
17597
|
WebServerIsDown: 521,
|
|
16912
17598
|
ConnectionTimedOut: 522,
|
|
16913
17599
|
OriginIsUnreachable: 523,
|
|
@@ -16916,7 +17602,9 @@ var HttpStatusCode = {
|
|
|
16916
17602
|
InvalidSslCertificate: 526
|
|
16917
17603
|
};
|
|
16918
17604
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
16919
|
-
HttpStatusCode[value]
|
|
17605
|
+
if (HttpStatusCode[value] === void 0) {
|
|
17606
|
+
HttpStatusCode[value] = key;
|
|
17607
|
+
}
|
|
16920
17608
|
});
|
|
16921
17609
|
var HttpStatusCode_default = HttpStatusCode;
|
|
16922
17610
|
|
|
@@ -17212,6 +17900,20 @@ var ServerError = class extends Posty5Error {
|
|
|
17212
17900
|
this.name = "ServerError";
|
|
17213
17901
|
}
|
|
17214
17902
|
};
|
|
17903
|
+
var ConflictError = class extends Posty5Error {
|
|
17904
|
+
constructor(message = "The document was changed by someone else", currentVersion = -1, resourceId = "", details) {
|
|
17905
|
+
super(message, "VERSION_CONFLICT", 409, details);
|
|
17906
|
+
this.name = "ConflictError";
|
|
17907
|
+
this.currentVersion = currentVersion;
|
|
17908
|
+
this.resourceId = resourceId;
|
|
17909
|
+
}
|
|
17910
|
+
};
|
|
17911
|
+
var VersionRequiredError = class extends Posty5Error {
|
|
17912
|
+
constructor(message = "The document version is required", details) {
|
|
17913
|
+
super(message, "VERSION_REQUIRED", 428, details);
|
|
17914
|
+
this.name = "VersionRequiredError";
|
|
17915
|
+
}
|
|
17916
|
+
};
|
|
17215
17917
|
function transformError(error) {
|
|
17216
17918
|
if (error instanceof Posty5Error) {
|
|
17217
17919
|
return error;
|
|
@@ -17236,6 +17938,22 @@ function transformError(error) {
|
|
|
17236
17938
|
return new AuthorizationError(message, details);
|
|
17237
17939
|
case 404:
|
|
17238
17940
|
return new NotFoundError(message, details);
|
|
17941
|
+
case 409: {
|
|
17942
|
+
const body = data;
|
|
17943
|
+
if (body?.code === "VERSION_CONFLICT") {
|
|
17944
|
+
const result = body?.result ?? {};
|
|
17945
|
+
const current = Number(result.currentVersion ?? body?.currentVersion);
|
|
17946
|
+
return new ConflictError(
|
|
17947
|
+
message,
|
|
17948
|
+
Number.isFinite(current) ? current : -1,
|
|
17949
|
+
String(result._id ?? body?._id ?? ""),
|
|
17950
|
+
details
|
|
17951
|
+
);
|
|
17952
|
+
}
|
|
17953
|
+
return new Posty5Error(message, body?.code, status, details);
|
|
17954
|
+
}
|
|
17955
|
+
case 428:
|
|
17956
|
+
return new VersionRequiredError(message, details);
|
|
17239
17957
|
case 429:
|
|
17240
17958
|
const retryAfter2 = axiosError.response.headers["retry-after"];
|
|
17241
17959
|
return new RateLimitError(
|
|
@@ -17257,31 +17975,101 @@ function transformError(error) {
|
|
|
17257
17975
|
}
|
|
17258
17976
|
return new Posty5Error("An unknown error occurred", void 0, void 0, { originalError: error });
|
|
17259
17977
|
}
|
|
17978
|
+
var CORE_VERSION = "5.0.0";
|
|
17979
|
+
var DEFAULT_BASE_URL = "https://api.posty5.com";
|
|
17980
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
17981
|
+
var DEFAULT_MAX_RETRIES = 3;
|
|
17982
|
+
var DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
17983
|
+
var CLIENT_HEADER_NAME = "X-Posty5-Client";
|
|
17984
|
+
var SDK_CLIENT_NAME = "posty5-npm";
|
|
17985
|
+
var SDK_CLIENT_ID = `${SDK_CLIENT_NAME}/${CORE_VERSION}`;
|
|
17986
|
+
var DEFAULT_CREATED_FROM = "npmPackage";
|
|
17987
|
+
var IDEMPOTENT_METHODS = ["GET", "HEAD", "OPTIONS", "PUT", "DELETE"];
|
|
17988
|
+
var NEVER_CONNECTED_ERROR_CODES = ["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "ENETUNREACH", "EHOSTUNREACH"];
|
|
17989
|
+
var IF_MATCH_HEADER = "If-Match";
|
|
17990
|
+
var CONCURRENCY_REPORT_HEADER = "X-Posty5-Concurrency";
|
|
17991
|
+
var CONCURRENCY_REPORT_MISSING_VERSION = "missing-version";
|
|
17992
|
+
var NON_RETRYABLE_VERSION_STATUSES = [409, 428];
|
|
17993
|
+
function assertVersion(version, name = "version") {
|
|
17994
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version < 0) {
|
|
17995
|
+
throw new TypeError(`Posty5: \`${name}\` must be a non-negative integer (the document's __v), got ${String(version)}`);
|
|
17996
|
+
}
|
|
17997
|
+
}
|
|
17998
|
+
function ifMatchHeader(version) {
|
|
17999
|
+
assertVersion(version);
|
|
18000
|
+
return `"${version}"`;
|
|
18001
|
+
}
|
|
18002
|
+
function hasIfMatch(headers) {
|
|
18003
|
+
if (!headers) return false;
|
|
18004
|
+
if (typeof headers.get === "function") {
|
|
18005
|
+
const value = headers.get(IF_MATCH_HEADER);
|
|
18006
|
+
if (value !== void 0 && value !== null) return true;
|
|
18007
|
+
}
|
|
18008
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === IF_MATCH_HEADER.toLowerCase());
|
|
18009
|
+
}
|
|
18010
|
+
function withVersion(response, id) {
|
|
18011
|
+
const result = response.result && typeof response.result === "object" ? { ...response.result } : {};
|
|
18012
|
+
if (id !== void 0 && result._id === void 0) result._id = id;
|
|
18013
|
+
if (typeof response.version === "number") result.__v = response.version;
|
|
18014
|
+
return result;
|
|
18015
|
+
}
|
|
18016
|
+
var missingVersionWarned = false;
|
|
18017
|
+
function warnOnMissingVersion(headers, method, url2) {
|
|
18018
|
+
if (missingVersionWarned || !headers) return false;
|
|
18019
|
+
const value = typeof headers.get === "function" ? headers.get(CONCURRENCY_REPORT_HEADER) : headers[CONCURRENCY_REPORT_HEADER.toLowerCase()];
|
|
18020
|
+
if (String(value ?? "").toLowerCase() !== CONCURRENCY_REPORT_MISSING_VERSION) return false;
|
|
18021
|
+
missingVersionWarned = true;
|
|
18022
|
+
console.warn(
|
|
18023
|
+
`[Posty5 SDK] ${String(method || "").toUpperCase()} ${url2 ?? ""} was sent without a document version; the API will refuse it once versions are enforced. Please report this SDK bug.`
|
|
18024
|
+
);
|
|
18025
|
+
return true;
|
|
18026
|
+
}
|
|
18027
|
+
function shouldRetryRequest(error) {
|
|
18028
|
+
const method = String(error?.config?.method || "").toUpperCase();
|
|
18029
|
+
const idempotent = IDEMPOTENT_METHODS.includes(method);
|
|
18030
|
+
const status = error?.response?.status;
|
|
18031
|
+
if (hasIfMatch(error?.config?.headers)) return false;
|
|
18032
|
+
if (status !== void 0 && NON_RETRYABLE_VERSION_STATUSES.includes(status)) return false;
|
|
18033
|
+
if (status === void 0) {
|
|
18034
|
+
if (idempotent) return esm_default.isNetworkError(error);
|
|
18035
|
+
return NEVER_CONNECTED_ERROR_CODES.includes(String(error?.code || ""));
|
|
18036
|
+
}
|
|
18037
|
+
return idempotent && status >= 500;
|
|
18038
|
+
}
|
|
18039
|
+
function parseFileName(disposition) {
|
|
18040
|
+
if (!disposition) return void 0;
|
|
18041
|
+
const match = /filename\*?=(?:UTF-8'')?"?([^";]+)"?/i.exec(disposition);
|
|
18042
|
+
if (!match) return void 0;
|
|
18043
|
+
try {
|
|
18044
|
+
return decodeURIComponent(match[1]);
|
|
18045
|
+
} catch {
|
|
18046
|
+
return match[1];
|
|
18047
|
+
}
|
|
18048
|
+
}
|
|
17260
18049
|
var HttpClient = class {
|
|
17261
18050
|
constructor(config = {}) {
|
|
17262
18051
|
this.config = {
|
|
17263
|
-
timeout:
|
|
17264
|
-
maxRetries:
|
|
17265
|
-
retryDelay:
|
|
18052
|
+
timeout: DEFAULT_TIMEOUT_MS,
|
|
18053
|
+
maxRetries: DEFAULT_MAX_RETRIES,
|
|
18054
|
+
retryDelay: DEFAULT_RETRY_DELAY_MS,
|
|
17266
18055
|
...config,
|
|
17267
|
-
baseUrl: config.baseUrl || process.env.POSTY5_BASE_URL ||
|
|
18056
|
+
baseUrl: config.baseUrl || process.env.POSTY5_BASE_URL || DEFAULT_BASE_URL
|
|
17268
18057
|
};
|
|
17269
18058
|
this.axiosInstance = axios_default.create({
|
|
17270
18059
|
baseURL: this.config.baseUrl,
|
|
17271
18060
|
timeout: this.config.timeout,
|
|
17272
18061
|
headers: {
|
|
17273
18062
|
"Content-Type": "application/json",
|
|
18063
|
+
[CLIENT_HEADER_NAME]: SDK_CLIENT_ID,
|
|
17274
18064
|
...this.config.headers
|
|
17275
18065
|
}
|
|
17276
18066
|
});
|
|
17277
18067
|
esm_default(this.axiosInstance, {
|
|
17278
|
-
retries: this.config.maxRetries
|
|
18068
|
+
retries: this.config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
17279
18069
|
retryDelay: (retryCount) => {
|
|
17280
|
-
return retryCount * (this.config.retryDelay
|
|
18070
|
+
return retryCount * (this.config.retryDelay ?? DEFAULT_RETRY_DELAY_MS);
|
|
17281
18071
|
},
|
|
17282
|
-
retryCondition:
|
|
17283
|
-
return esm_default.isNetworkOrIdempotentRequestError(error) || error.response?.status !== void 0 && error.response.status >= 500;
|
|
17284
|
-
}
|
|
18072
|
+
retryCondition: shouldRetryRequest
|
|
17285
18073
|
});
|
|
17286
18074
|
this.axiosInstance.interceptors.request.use(
|
|
17287
18075
|
(config2) => {
|
|
@@ -17310,6 +18098,7 @@ var HttpClient = class {
|
|
|
17310
18098
|
);
|
|
17311
18099
|
this.axiosInstance.interceptors.response.use(
|
|
17312
18100
|
(response) => {
|
|
18101
|
+
warnOnMissingVersion(response.headers, response.config?.method, response.config?.url);
|
|
17313
18102
|
if (this.config.debug) {
|
|
17314
18103
|
console.log("[Posty5 SDK] Response:", {
|
|
17315
18104
|
status: response.status,
|
|
@@ -17326,6 +18115,10 @@ var HttpClient = class {
|
|
|
17326
18115
|
}
|
|
17327
18116
|
);
|
|
17328
18117
|
}
|
|
18118
|
+
/** The `createdFrom` label the clients stamp on records they create. */
|
|
18119
|
+
get createdFrom() {
|
|
18120
|
+
return this.config.createdFrom || DEFAULT_CREATED_FROM;
|
|
18121
|
+
}
|
|
17329
18122
|
/**
|
|
17330
18123
|
* Set or update the API key
|
|
17331
18124
|
*/
|
|
@@ -17399,6 +18192,28 @@ var HttpClient = class {
|
|
|
17399
18192
|
throw transformError(error);
|
|
17400
18193
|
}
|
|
17401
18194
|
}
|
|
18195
|
+
/**
|
|
18196
|
+
* Make a GET request for a file download.
|
|
18197
|
+
*
|
|
18198
|
+
* Separate from `get` rather than a flag on it: a download answers with the
|
|
18199
|
+
* file itself, not with the `{ message, result }` envelope every other
|
|
18200
|
+
* endpoint uses, so it cannot share the return type.
|
|
18201
|
+
*/
|
|
18202
|
+
async getBinary(url2, config) {
|
|
18203
|
+
try {
|
|
18204
|
+
const response = await this.axiosInstance.get(url2, {
|
|
18205
|
+
...this.buildConfig(config),
|
|
18206
|
+
responseType: "arraybuffer"
|
|
18207
|
+
});
|
|
18208
|
+
return {
|
|
18209
|
+
data: response.data,
|
|
18210
|
+
contentType: String(response.headers?.["content-type"] || "application/octet-stream"),
|
|
18211
|
+
fileName: parseFileName(response.headers?.["content-disposition"])
|
|
18212
|
+
};
|
|
18213
|
+
} catch (error) {
|
|
18214
|
+
throw transformError(error);
|
|
18215
|
+
}
|
|
18216
|
+
}
|
|
17402
18217
|
/**
|
|
17403
18218
|
* Build axios config from request config
|
|
17404
18219
|
*/
|
|
@@ -17408,11 +18223,18 @@ var HttpClient = class {
|
|
|
17408
18223
|
}
|
|
17409
18224
|
const axiosConfig = {};
|
|
17410
18225
|
if (config.headers) {
|
|
17411
|
-
axiosConfig.headers = config.headers;
|
|
18226
|
+
axiosConfig.headers = { ...config.headers };
|
|
18227
|
+
}
|
|
18228
|
+
if (config.version !== void 0) {
|
|
18229
|
+
axiosConfig.headers = { ...axiosConfig.headers || {}, [IF_MATCH_HEADER]: ifMatchHeader(config.version) };
|
|
18230
|
+
axiosConfig["axios-retry"] = { retries: 0 };
|
|
17412
18231
|
}
|
|
17413
18232
|
if (config.params) {
|
|
17414
18233
|
axiosConfig.params = config.params;
|
|
17415
18234
|
}
|
|
18235
|
+
if (config.data !== void 0) {
|
|
18236
|
+
axiosConfig.data = config.data;
|
|
18237
|
+
}
|
|
17416
18238
|
if (config.timeout) {
|
|
17417
18239
|
axiosConfig.timeout = config.timeout;
|
|
17418
18240
|
}
|
|
@@ -17473,6 +18295,169 @@ async function uploadToR2(presignedUrl, fileOrBlob, options = {}) {
|
|
|
17473
18295
|
}
|
|
17474
18296
|
}
|
|
17475
18297
|
|
|
18298
|
+
// src/resumable-upload.ts
|
|
18299
|
+
var TUS_VERSION = "1.0.0";
|
|
18300
|
+
var DEFAULT_CHUNK_SIZE2 = 8 * 1024 * 1024;
|
|
18301
|
+
var RETRY_DELAYS = [0, 1e3, 3e3, 5e3, 1e4];
|
|
18302
|
+
var MAX_CONSECUTIVE_STALLS = 3;
|
|
18303
|
+
function encodeMetadata(pairs) {
|
|
18304
|
+
return Object.entries(pairs).filter(([, value]) => value !== void 0 && value !== null && value !== "").map(([key, value]) => `${key} ${toBase64(value)}`).join(",");
|
|
18305
|
+
}
|
|
18306
|
+
function toBase64(value) {
|
|
18307
|
+
if (typeof btoa === "function") {
|
|
18308
|
+
return btoa(String.fromCharCode(...new TextEncoder().encode(value)));
|
|
18309
|
+
}
|
|
18310
|
+
return Buffer.from(value, "utf8").toString("base64");
|
|
18311
|
+
}
|
|
18312
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
18313
|
+
function isAborted(signal) {
|
|
18314
|
+
return !!signal?.aborted;
|
|
18315
|
+
}
|
|
18316
|
+
function abortError() {
|
|
18317
|
+
const error = new Error("Upload aborted");
|
|
18318
|
+
error.name = "AbortError";
|
|
18319
|
+
return error;
|
|
18320
|
+
}
|
|
18321
|
+
function supportsResumableUpload(target) {
|
|
18322
|
+
return !!target.tusEndpoint && !!target.ticket;
|
|
18323
|
+
}
|
|
18324
|
+
async function createUpload(target, size, filename, filetype, signal) {
|
|
18325
|
+
const response = await fetch(target.tusEndpoint, {
|
|
18326
|
+
method: "POST",
|
|
18327
|
+
headers: {
|
|
18328
|
+
"Tus-Resumable": TUS_VERSION,
|
|
18329
|
+
"Upload-Length": String(size),
|
|
18330
|
+
"Upload-Metadata": encodeMetadata({ ticket: target.ticket, filename, filetype })
|
|
18331
|
+
},
|
|
18332
|
+
signal
|
|
18333
|
+
});
|
|
18334
|
+
if (response.status !== 201) {
|
|
18335
|
+
throw new Error(`Could not start the upload (${response.status}): ${await safeText(response)}`);
|
|
18336
|
+
}
|
|
18337
|
+
const location = response.headers.get("Location");
|
|
18338
|
+
if (!location) {
|
|
18339
|
+
throw new Error("Upload was created but the server returned no Location header.");
|
|
18340
|
+
}
|
|
18341
|
+
return new URL(location, target.tusEndpoint).toString();
|
|
18342
|
+
}
|
|
18343
|
+
async function getOffset(uploadUrl, signal) {
|
|
18344
|
+
const response = await fetch(uploadUrl, {
|
|
18345
|
+
method: "HEAD",
|
|
18346
|
+
headers: { "Tus-Resumable": TUS_VERSION },
|
|
18347
|
+
signal
|
|
18348
|
+
});
|
|
18349
|
+
if (response.status === 404 || response.status === 410) {
|
|
18350
|
+
throw new Error("This upload has expired on the server and cannot be resumed.");
|
|
18351
|
+
}
|
|
18352
|
+
if (!response.ok) {
|
|
18353
|
+
throw new Error(`Could not read the upload's progress (${response.status}).`);
|
|
18354
|
+
}
|
|
18355
|
+
return Number(response.headers.get("Upload-Offset") ?? 0);
|
|
18356
|
+
}
|
|
18357
|
+
async function terminateUpload(uploadUrl) {
|
|
18358
|
+
try {
|
|
18359
|
+
const response = await fetch(uploadUrl, {
|
|
18360
|
+
method: "DELETE",
|
|
18361
|
+
headers: { "Tus-Resumable": TUS_VERSION }
|
|
18362
|
+
});
|
|
18363
|
+
return response.status === 204 || response.status === 404 || response.status === 410;
|
|
18364
|
+
} catch {
|
|
18365
|
+
return false;
|
|
18366
|
+
}
|
|
18367
|
+
}
|
|
18368
|
+
async function safeText(response) {
|
|
18369
|
+
try {
|
|
18370
|
+
return (await response.text()).slice(0, 300);
|
|
18371
|
+
} catch {
|
|
18372
|
+
return "";
|
|
18373
|
+
}
|
|
18374
|
+
}
|
|
18375
|
+
async function patchChunk(uploadUrl, chunk, offset, signal) {
|
|
18376
|
+
let lastError;
|
|
18377
|
+
for (let attempt = 0; attempt < RETRY_DELAYS.length; attempt++) {
|
|
18378
|
+
if (isAborted(signal)) throw abortError();
|
|
18379
|
+
if (RETRY_DELAYS[attempt]) await wait(RETRY_DELAYS[attempt]);
|
|
18380
|
+
try {
|
|
18381
|
+
const response = await fetch(uploadUrl, {
|
|
18382
|
+
method: "PATCH",
|
|
18383
|
+
headers: {
|
|
18384
|
+
"Tus-Resumable": TUS_VERSION,
|
|
18385
|
+
"Upload-Offset": String(offset),
|
|
18386
|
+
"Content-Type": "application/offset+octet-stream"
|
|
18387
|
+
},
|
|
18388
|
+
body: chunk,
|
|
18389
|
+
signal
|
|
18390
|
+
});
|
|
18391
|
+
if (response.status === 204) {
|
|
18392
|
+
return Number(response.headers.get("Upload-Offset") ?? offset + chunk.size);
|
|
18393
|
+
}
|
|
18394
|
+
if (response.status === 409) {
|
|
18395
|
+
return await getOffset(uploadUrl, signal);
|
|
18396
|
+
}
|
|
18397
|
+
if (response.status >= 400 && response.status < 500) {
|
|
18398
|
+
throw new Error(`Upload rejected (${response.status}): ${await safeText(response)}`);
|
|
18399
|
+
}
|
|
18400
|
+
lastError = new Error(`Upload failed (${response.status})`);
|
|
18401
|
+
} catch (error) {
|
|
18402
|
+
if (error?.name === "AbortError") throw error;
|
|
18403
|
+
if (/^Upload rejected/.test(error?.message || "")) throw error;
|
|
18404
|
+
lastError = error;
|
|
18405
|
+
}
|
|
18406
|
+
}
|
|
18407
|
+
throw lastError instanceof Error ? lastError : new Error("Upload failed");
|
|
18408
|
+
}
|
|
18409
|
+
async function uploadResumable(target, file, options = {}) {
|
|
18410
|
+
const { onProgress, onUploadUrl, chunkSize = DEFAULT_CHUNK_SIZE2, signal, fallbackType = "application/octet-stream", terminateOnAbort = false } = options;
|
|
18411
|
+
if (!supportsResumableUpload(target)) {
|
|
18412
|
+
throw new Error("This upload target does not support resumable uploads.");
|
|
18413
|
+
}
|
|
18414
|
+
if (target.maxSize && file.size > target.maxSize) {
|
|
18415
|
+
const limitMb = Math.round(target.maxSize / (1024 * 1024));
|
|
18416
|
+
throw new Error(`This file is larger than the ${limitMb}MB limit.`);
|
|
18417
|
+
}
|
|
18418
|
+
if (isAborted(signal)) throw abortError();
|
|
18419
|
+
const filename = file.name || "upload";
|
|
18420
|
+
const filetype = file.type || fallbackType;
|
|
18421
|
+
let uploadUrl = options.uploadUrl;
|
|
18422
|
+
let offset = 0;
|
|
18423
|
+
if (uploadUrl) {
|
|
18424
|
+
offset = await getOffset(uploadUrl, signal);
|
|
18425
|
+
} else {
|
|
18426
|
+
uploadUrl = await createUpload(target, file.size, filename, filetype, signal);
|
|
18427
|
+
onUploadUrl?.(uploadUrl);
|
|
18428
|
+
}
|
|
18429
|
+
const discardIfAsked = async () => {
|
|
18430
|
+
if (terminateOnAbort && uploadUrl) await terminateUpload(uploadUrl);
|
|
18431
|
+
};
|
|
18432
|
+
onProgress?.(file.size ? Math.round(offset / file.size * 100) : 0);
|
|
18433
|
+
let consecutiveStalls = 0;
|
|
18434
|
+
while (offset < file.size) {
|
|
18435
|
+
if (isAborted(signal)) {
|
|
18436
|
+
await discardIfAsked();
|
|
18437
|
+
throw abortError();
|
|
18438
|
+
}
|
|
18439
|
+
const end = Math.min(offset + chunkSize, file.size);
|
|
18440
|
+
let next;
|
|
18441
|
+
try {
|
|
18442
|
+
next = await patchChunk(uploadUrl, file.slice(offset, end), offset, signal);
|
|
18443
|
+
} catch (error) {
|
|
18444
|
+
if (error?.name === "AbortError") await discardIfAsked();
|
|
18445
|
+
throw error;
|
|
18446
|
+
}
|
|
18447
|
+
if (next <= offset) {
|
|
18448
|
+
if (++consecutiveStalls >= MAX_CONSECUTIVE_STALLS) {
|
|
18449
|
+
throw new Error("The upload stopped making progress and was abandoned.");
|
|
18450
|
+
}
|
|
18451
|
+
continue;
|
|
18452
|
+
}
|
|
18453
|
+
consecutiveStalls = 0;
|
|
18454
|
+
offset = next;
|
|
18455
|
+
onProgress?.(Math.round(offset / file.size * 100));
|
|
18456
|
+
}
|
|
18457
|
+
onProgress?.(100);
|
|
18458
|
+
return target.fileURL;
|
|
18459
|
+
}
|
|
18460
|
+
|
|
17476
18461
|
// src/social-publisher-post.client.ts
|
|
17477
18462
|
var SocialPublisherPostClient = class {
|
|
17478
18463
|
constructor(http3) {
|
|
@@ -17518,6 +18503,32 @@ var SocialPublisherPostClient = class {
|
|
|
17518
18503
|
const response = await this.http.post(`${this.basePath}/generate-upload-urls`, data);
|
|
17519
18504
|
return response.result;
|
|
17520
18505
|
}
|
|
18506
|
+
/**
|
|
18507
|
+
* Remove (delete) a post's published media directly from the connected
|
|
18508
|
+
* platform pages. Runs synchronously on the server — the media is deleted
|
|
18509
|
+
* from the platform immediately, not via a background job.
|
|
18510
|
+
*
|
|
18511
|
+
* Cost: 50 credits, charged ONLY when the removal succeeds (at least one
|
|
18512
|
+
* platform cleared and no delete-capable platform failed). Instagram and
|
|
18513
|
+
* TikTok expose no delete API, so a post published only to those platforms
|
|
18514
|
+
* cannot be removed programmatically and no credits are charged.
|
|
18515
|
+
*
|
|
18516
|
+
* @param id - Post ID
|
|
18517
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
18518
|
+
* @returns Per-platform removal results, `__v` set to the post's new version
|
|
18519
|
+
*
|
|
18520
|
+
* @example
|
|
18521
|
+
* ```ts
|
|
18522
|
+
* const post = await client.getStatus("post_123");
|
|
18523
|
+
* const { results } = await client.removePost("post_123", post.__v);
|
|
18524
|
+
* // results.youtube?.success === true
|
|
18525
|
+
* ```
|
|
18526
|
+
*/
|
|
18527
|
+
async removePost(id, version) {
|
|
18528
|
+
assertVersion(version);
|
|
18529
|
+
const response = await this.http.post(`${this.basePath}/${id}/remove`, {}, { version });
|
|
18530
|
+
return withVersion(response, id);
|
|
18531
|
+
}
|
|
17521
18532
|
/**
|
|
17522
18533
|
* Get next and previous post IDs
|
|
17523
18534
|
* @param id - Current Post ID
|
|
@@ -17535,7 +18546,7 @@ var SocialPublisherPostClient = class {
|
|
|
17535
18546
|
const url2 = id ? `${this.basePath}/short-video/workspace/by-file/${id}` : `${this.basePath}/short-video/workspace/by-file`;
|
|
17536
18547
|
const response = await this.http.post(url2, {
|
|
17537
18548
|
...data,
|
|
17538
|
-
createdFrom:
|
|
18549
|
+
createdFrom: this.http.createdFrom
|
|
17539
18550
|
});
|
|
17540
18551
|
return response.result?._id;
|
|
17541
18552
|
}
|
|
@@ -17548,7 +18559,7 @@ var SocialPublisherPostClient = class {
|
|
|
17548
18559
|
const url2 = id ? `${this.basePath}/short-video/workspace/by-url/${id}` : `${this.basePath}/short-video/workspace/by-url`;
|
|
17549
18560
|
const response = await this.http.post(url2, {
|
|
17550
18561
|
...data,
|
|
17551
|
-
createdFrom:
|
|
18562
|
+
createdFrom: this.http.createdFrom
|
|
17552
18563
|
});
|
|
17553
18564
|
return response.result?._id;
|
|
17554
18565
|
}
|
|
@@ -17561,7 +18572,7 @@ var SocialPublisherPostClient = class {
|
|
|
17561
18572
|
const url2 = id ? `${this.basePath}/short-video/account/by-file/${id}` : `${this.basePath}/short-video/account/by-file`;
|
|
17562
18573
|
const response = await this.http.post(url2, {
|
|
17563
18574
|
...data,
|
|
17564
|
-
createdFrom:
|
|
18575
|
+
createdFrom: this.http.createdFrom
|
|
17565
18576
|
});
|
|
17566
18577
|
return response.result?._id;
|
|
17567
18578
|
}
|
|
@@ -17574,7 +18585,7 @@ var SocialPublisherPostClient = class {
|
|
|
17574
18585
|
const url2 = id ? `${this.basePath}/short-video/account/by-url/${id}` : `${this.basePath}/short-video/account/by-url`;
|
|
17575
18586
|
const response = await this.http.post(url2, {
|
|
17576
18587
|
...data,
|
|
17577
|
-
createdFrom:
|
|
18588
|
+
createdFrom: this.http.createdFrom
|
|
17578
18589
|
});
|
|
17579
18590
|
return response.result?._id;
|
|
17580
18591
|
}
|
|
@@ -17598,7 +18609,7 @@ var SocialPublisherPostClient = class {
|
|
|
17598
18609
|
const url2 = id ? `${this.basePath}/image/workspace/${id}` : `${this.basePath}/image/workspace`;
|
|
17599
18610
|
const response = await this.http.post(url2, {
|
|
17600
18611
|
...data,
|
|
17601
|
-
createdFrom:
|
|
18612
|
+
createdFrom: this.http.createdFrom
|
|
17602
18613
|
});
|
|
17603
18614
|
return response.result?._id;
|
|
17604
18615
|
}
|
|
@@ -17611,10 +18622,50 @@ var SocialPublisherPostClient = class {
|
|
|
17611
18622
|
const url2 = id ? `${this.basePath}/image/account/${id}` : `${this.basePath}/image/account`;
|
|
17612
18623
|
const response = await this.http.post(url2, {
|
|
17613
18624
|
...data,
|
|
17614
|
-
createdFrom:
|
|
18625
|
+
createdFrom: this.http.createdFrom
|
|
17615
18626
|
});
|
|
17616
18627
|
return response.result?._id;
|
|
17617
18628
|
}
|
|
18629
|
+
/**
|
|
18630
|
+
* Publish a text-only post to every text-capable account in a workspace
|
|
18631
|
+
* (Facebook, Threads, X). Platforms that cannot take text are reported in
|
|
18632
|
+
* `skippedPlatforms`; X below the Pro plan is dropped into `refusedTargets`.
|
|
18633
|
+
*/
|
|
18634
|
+
async createTextPostToWorkspace(data) {
|
|
18635
|
+
const response = await this.http.post(`${this.basePath}/text/workspace`, {
|
|
18636
|
+
...data,
|
|
18637
|
+
createdFrom: this.http.createdFrom
|
|
18638
|
+
});
|
|
18639
|
+
return response.result;
|
|
18640
|
+
}
|
|
18641
|
+
/** Publish a text-only post to one account. */
|
|
18642
|
+
async createTextPostToAccount(data) {
|
|
18643
|
+
const response = await this.http.post(`${this.basePath}/text/account`, {
|
|
18644
|
+
...data,
|
|
18645
|
+
createdFrom: this.http.createdFrom
|
|
18646
|
+
});
|
|
18647
|
+
return response.result;
|
|
18648
|
+
}
|
|
18649
|
+
/**
|
|
18650
|
+
* Publish a story to every story-capable account in a workspace. Media by URL
|
|
18651
|
+
* only in this release: `image: { source: "image-url", externalUrl }`, or
|
|
18652
|
+
* `source: "video-url"` with `videoURL`.
|
|
18653
|
+
*/
|
|
18654
|
+
async createStoryPostToWorkspace(data) {
|
|
18655
|
+
const response = await this.http.post(`${this.basePath}/story/workspace`, {
|
|
18656
|
+
...data,
|
|
18657
|
+
createdFrom: this.http.createdFrom
|
|
18658
|
+
});
|
|
18659
|
+
return response.result;
|
|
18660
|
+
}
|
|
18661
|
+
/** Publish a story to one account. Media by URL only, as for the workspace form. */
|
|
18662
|
+
async createStoryPostToAccount(data) {
|
|
18663
|
+
const response = await this.http.post(`${this.basePath}/story/account`, {
|
|
18664
|
+
...data,
|
|
18665
|
+
createdFrom: this.http.createdFrom
|
|
18666
|
+
});
|
|
18667
|
+
return response.result;
|
|
18668
|
+
}
|
|
17618
18669
|
/**
|
|
17619
18670
|
* Handle thumbnail upload - accepts either File or URL string
|
|
17620
18671
|
* @param thumb - Thumbnail as File (will be uploaded) or URL string (will be passed directly)
|
|
@@ -17863,6 +18914,274 @@ var SocialPublisherPostClient = class {
|
|
|
17863
18914
|
async publishShortVideo(options) {
|
|
17864
18915
|
return this.publishShortVideoToWorkspace(options);
|
|
17865
18916
|
}
|
|
18917
|
+
// ─── Long video (up to 60 minutes) ───────────────────────────────────────
|
|
18918
|
+
/**
|
|
18919
|
+
* Price a long video before publishing it. Neither creates nor charges
|
|
18920
|
+
* anything.
|
|
18921
|
+
*
|
|
18922
|
+
* The server reads the video, measures its duration, and returns the exact
|
|
18923
|
+
* cost plus what each platform would do with a video that long. Show this
|
|
18924
|
+
* before the user commits — the units come from the same function the create
|
|
18925
|
+
* call charges with, so the quote and the bill cannot disagree.
|
|
18926
|
+
*
|
|
18927
|
+
* @param videoURL - URL of an uploaded or externally hosted video
|
|
18928
|
+
*
|
|
18929
|
+
* @example
|
|
18930
|
+
* ```ts
|
|
18931
|
+
* const quote = await client.getLongVideoQuote(fileURL);
|
|
18932
|
+
* if (!quote.withinLimit) throw new Error(quote.reason);
|
|
18933
|
+
* console.log(`${quote.durationSeconds}s costs ${quote.credits} credits`);
|
|
18934
|
+
* const blocked = quote.platforms.filter((p) => !p.accepted);
|
|
18935
|
+
* ```
|
|
18936
|
+
*/
|
|
18937
|
+
async getLongVideoQuote(videoURL) {
|
|
18938
|
+
if (!videoURL) {
|
|
18939
|
+
throw new Error("videoURL is required");
|
|
18940
|
+
}
|
|
18941
|
+
const response = await this.http.post(`${this.basePath}/long-video/quote`, { videoURL });
|
|
18942
|
+
return response.result;
|
|
18943
|
+
}
|
|
18944
|
+
/**
|
|
18945
|
+
* Publish a video of up to 60 minutes to every account connected to a
|
|
18946
|
+
* workspace.
|
|
18947
|
+
*
|
|
18948
|
+
* Handles the whole sequence for an uploaded file: request an upload
|
|
18949
|
+
* destination, push the bytes, then create the post. Pass a URL instead of a
|
|
18950
|
+
* `File` to publish something already hosted elsewhere.
|
|
18951
|
+
*
|
|
18952
|
+
* Cost is duration-based — 50 credits per started 5 minutes — so a 12-minute
|
|
18953
|
+
* video costs 150. Call {@link getLongVideoQuote} first if you need to show
|
|
18954
|
+
* the price. The duration is measured server-side; there is no duration
|
|
18955
|
+
* option here because a client-supplied one would be a client-supplied price.
|
|
18956
|
+
*
|
|
18957
|
+
* Platforms differ on what they accept: a 40-minute video publishes to
|
|
18958
|
+
* YouTube and Facebook but is refused by Instagram, whose Reels cap at 15
|
|
18959
|
+
* minutes. Those targets come back in `refusedTargets` — the post still
|
|
18960
|
+
* publishes to the rest.
|
|
18961
|
+
*
|
|
18962
|
+
* @example
|
|
18963
|
+
* ```ts
|
|
18964
|
+
* const result = await client.publishLongVideoToWorkspace({
|
|
18965
|
+
* workspaceId: "ws_123",
|
|
18966
|
+
* video: recordingFile,
|
|
18967
|
+
* youtube: { title: "Full session", description: "...", tags: ["workshop"] },
|
|
18968
|
+
* onProgress: (p) => console.log(`${p}%`),
|
|
18969
|
+
* });
|
|
18970
|
+
* console.log(`Charged ${result.credits} credits for ${result.durationSeconds}s`);
|
|
18971
|
+
* for (const t of result.refusedTargets) console.warn(t.reason);
|
|
18972
|
+
* ```
|
|
18973
|
+
*/
|
|
18974
|
+
async publishLongVideoToWorkspace(options) {
|
|
18975
|
+
if (!options.workspaceId) {
|
|
18976
|
+
throw new Error("workspaceId is required");
|
|
18977
|
+
}
|
|
18978
|
+
if (!options.video) {
|
|
18979
|
+
throw new Error("video is required");
|
|
18980
|
+
}
|
|
18981
|
+
if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
|
|
18982
|
+
throw new Error("Provide at least one platform configuration (youtube / tiktok / facebook / instagram)");
|
|
18983
|
+
}
|
|
18984
|
+
const isFile2 = this.detectVideoSource(options.video) === "file";
|
|
18985
|
+
const upload = isFile2 ? await this.uploadLongVideo(
|
|
18986
|
+
options.video,
|
|
18987
|
+
options.thumbnail,
|
|
18988
|
+
{
|
|
18989
|
+
onProgress: options.onProgress,
|
|
18990
|
+
onUploadUrl: options.onUploadUrl,
|
|
18991
|
+
resumeFrom: options.resumeFrom,
|
|
18992
|
+
signal: options.signal,
|
|
18993
|
+
terminateOnAbort: options.terminateOnAbort
|
|
18994
|
+
}
|
|
18995
|
+
) : void 0;
|
|
18996
|
+
const videoURL = upload ? upload.videoURL : options.video;
|
|
18997
|
+
const postId = upload?.postId;
|
|
18998
|
+
const thumb = await this.handleThumbnailUpload(options.thumbnail, upload?.uploadUrls);
|
|
18999
|
+
const body = {
|
|
19000
|
+
workspaceId: options.workspaceId,
|
|
19001
|
+
youtube: options.youtube,
|
|
19002
|
+
tiktok: options.tiktok,
|
|
19003
|
+
facebook: options.facebook,
|
|
19004
|
+
instagram: options.instagram,
|
|
19005
|
+
schedule: this.buildSchedule(options.schedule),
|
|
19006
|
+
source: isFile2 ? "video-file" : "video-url",
|
|
19007
|
+
videoURL,
|
|
19008
|
+
thumbURL: thumb?.thumbFileURL,
|
|
19009
|
+
tag: options.tag,
|
|
19010
|
+
refId: options.refId,
|
|
19011
|
+
comment: options.comment
|
|
19012
|
+
};
|
|
19013
|
+
const target = isFile2 ? "by-file" : "by-url";
|
|
19014
|
+
const id = postId ?? thumb?.postId;
|
|
19015
|
+
const url2 = id ? `${this.basePath}/long-video/workspace/${target}/${id}` : `${this.basePath}/long-video/workspace/${target}`;
|
|
19016
|
+
const response = await this.http.post(url2, { ...body, createdFrom: this.http.createdFrom });
|
|
19017
|
+
return this.normaliseLongVideoResult(response.result);
|
|
19018
|
+
}
|
|
19019
|
+
/**
|
|
19020
|
+
* Publish a video of up to 60 minutes to a single connected account.
|
|
19021
|
+
*
|
|
19022
|
+
* With one target there is no partial success: if that platform will not take
|
|
19023
|
+
* a video this long, the whole call is refused and nothing is charged. See
|
|
19024
|
+
* {@link publishLongVideoToWorkspace} for the cost model.
|
|
19025
|
+
*/
|
|
19026
|
+
async publishLongVideoToAccount(options) {
|
|
19027
|
+
if (!options.accountId) {
|
|
19028
|
+
throw new Error("accountId is required");
|
|
19029
|
+
}
|
|
19030
|
+
if (!options.video) {
|
|
19031
|
+
throw new Error("video is required");
|
|
19032
|
+
}
|
|
19033
|
+
if (!options.youtube && !options.tiktok && !options.facebook && !options.instagram) {
|
|
19034
|
+
throw new Error("Provide the platform configuration matching the account (youtube / tiktok / facebook / instagram)");
|
|
19035
|
+
}
|
|
19036
|
+
const isFile2 = this.detectVideoSource(options.video) === "file";
|
|
19037
|
+
const upload = isFile2 ? await this.uploadLongVideo(
|
|
19038
|
+
options.video,
|
|
19039
|
+
options.thumbnail,
|
|
19040
|
+
{
|
|
19041
|
+
onProgress: options.onProgress,
|
|
19042
|
+
onUploadUrl: options.onUploadUrl,
|
|
19043
|
+
resumeFrom: options.resumeFrom,
|
|
19044
|
+
signal: options.signal,
|
|
19045
|
+
terminateOnAbort: options.terminateOnAbort
|
|
19046
|
+
}
|
|
19047
|
+
) : void 0;
|
|
19048
|
+
const videoURL = upload ? upload.videoURL : options.video;
|
|
19049
|
+
const postId = upload?.postId;
|
|
19050
|
+
const thumb = await this.handleThumbnailUpload(options.thumbnail, upload?.uploadUrls);
|
|
19051
|
+
const body = {
|
|
19052
|
+
accountId: options.accountId,
|
|
19053
|
+
youtube: options.youtube,
|
|
19054
|
+
tiktok: options.tiktok,
|
|
19055
|
+
facebook: options.facebook,
|
|
19056
|
+
instagram: options.instagram,
|
|
19057
|
+
schedule: this.buildSchedule(options.schedule),
|
|
19058
|
+
source: isFile2 ? "video-file" : "video-url",
|
|
19059
|
+
videoURL,
|
|
19060
|
+
thumbURL: thumb?.thumbFileURL,
|
|
19061
|
+
tag: options.tag,
|
|
19062
|
+
refId: options.refId,
|
|
19063
|
+
comment: options.comment
|
|
19064
|
+
};
|
|
19065
|
+
const target = isFile2 ? "by-file" : "by-url";
|
|
19066
|
+
const id = postId ?? thumb?.postId;
|
|
19067
|
+
const url2 = id ? `${this.basePath}/long-video/account/${target}/${id}` : `${this.basePath}/long-video/account/${target}`;
|
|
19068
|
+
const response = await this.http.post(url2, { ...body, createdFrom: this.http.createdFrom });
|
|
19069
|
+
return this.normaliseLongVideoResult(response.result);
|
|
19070
|
+
}
|
|
19071
|
+
/**
|
|
19072
|
+
* Re-schedule a post that has not published yet, or send it out now.
|
|
19073
|
+
*
|
|
19074
|
+
* Free — this costs no credits. Only posts still pending with a future
|
|
19075
|
+
* publish time are eligible; anything that has started publishing is refused
|
|
19076
|
+
* by the server with a reason.
|
|
19077
|
+
*
|
|
19078
|
+
* @example
|
|
19079
|
+
* ```ts
|
|
19080
|
+
* const post = await client.getStatus("post_123");
|
|
19081
|
+
* const { __v } = await client.reschedulePost("post_123", { schedule: new Date("2026-09-01T09:00:00Z") }, post.__v);
|
|
19082
|
+
* await client.reschedulePost("post_123", { schedule: "now" }, __v);
|
|
19083
|
+
* ```
|
|
19084
|
+
*
|
|
19085
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
19086
|
+
* @returns `{ _id, __v }`, `__v` being the new version
|
|
19087
|
+
*/
|
|
19088
|
+
async reschedulePost(id, data, version) {
|
|
19089
|
+
if (!id) {
|
|
19090
|
+
throw new Error("id is required");
|
|
19091
|
+
}
|
|
19092
|
+
assertVersion(version);
|
|
19093
|
+
const response = await this.http.put(
|
|
19094
|
+
`${this.basePath}/${id}`,
|
|
19095
|
+
{
|
|
19096
|
+
...data.schedule === "now" ? { scheduleType: "now" } : { scheduleType: "schedule", scheduledAt: data.schedule.toISOString() },
|
|
19097
|
+
...data.caption !== void 0 ? { caption: data.caption } : {}
|
|
19098
|
+
},
|
|
19099
|
+
{ version }
|
|
19100
|
+
);
|
|
19101
|
+
const updated = withVersion(response, id);
|
|
19102
|
+
return { _id: updated._id, __v: updated.__v };
|
|
19103
|
+
}
|
|
19104
|
+
/**
|
|
19105
|
+
* Delete a post that has not published yet, releasing its uploaded media in
|
|
19106
|
+
* the same request.
|
|
19107
|
+
*
|
|
19108
|
+
* Free, and nothing is refunded — nothing was charged for a post that never
|
|
19109
|
+
* went out. A post that HAS published is refused; use {@link removePost} to
|
|
19110
|
+
* take down media that is already live.
|
|
19111
|
+
*
|
|
19112
|
+
* @example
|
|
19113
|
+
* ```ts
|
|
19114
|
+
* await client.deletePost("post_123", post.__v);
|
|
19115
|
+
* ```
|
|
19116
|
+
*
|
|
19117
|
+
* @param version - The post's `__v` as you read it. A stale one throws `ConflictError`.
|
|
19118
|
+
*/
|
|
19119
|
+
async deletePost(id, version) {
|
|
19120
|
+
if (!id) {
|
|
19121
|
+
throw new Error("id is required");
|
|
19122
|
+
}
|
|
19123
|
+
assertVersion(version);
|
|
19124
|
+
await this.http.delete(`${this.basePath}/${id}`, { version });
|
|
19125
|
+
}
|
|
19126
|
+
/**
|
|
19127
|
+
* Upload a long video and return the URL to publish from.
|
|
19128
|
+
*
|
|
19129
|
+
* Declares `postType: "longVideo"` so the server refuses now — on plan gating
|
|
19130
|
+
* or an empty balance — rather than after an hour of transfer.
|
|
19131
|
+
*/
|
|
19132
|
+
async uploadLongVideo(video, thumb, controls = {}) {
|
|
19133
|
+
const { onProgress, onUploadUrl, resumeFrom, signal, terminateOnAbort } = controls;
|
|
19134
|
+
if (video.size > this.maxVideoUploadSizeBytes) {
|
|
19135
|
+
throw new Error(`Video file size (${video.size} bytes) exceeds maximum allowed size (${this.maxVideoUploadSizeBytes} bytes)`);
|
|
19136
|
+
}
|
|
19137
|
+
const allowedVideoTypes = [".mp4", ".mov", ".avi", ".mkv", ".webm"];
|
|
19138
|
+
const videoExtension = "." + video.name.split(".").pop()?.toLowerCase();
|
|
19139
|
+
if (!allowedVideoTypes.includes(videoExtension)) {
|
|
19140
|
+
throw new Error(`Invalid video file type. Allowed types: ${allowedVideoTypes.join(", ")}`);
|
|
19141
|
+
}
|
|
19142
|
+
const uploadUrls = await this.generateUploadUrls({
|
|
19143
|
+
videoFileType: video.type,
|
|
19144
|
+
thumbFileType: thumb instanceof File ? thumb.type : void 0,
|
|
19145
|
+
postType: "longVideo"
|
|
19146
|
+
});
|
|
19147
|
+
if (supportsResumableUpload(uploadUrls.video)) {
|
|
19148
|
+
await uploadResumable(uploadUrls.video, video, {
|
|
19149
|
+
onProgress,
|
|
19150
|
+
onUploadUrl,
|
|
19151
|
+
uploadUrl: resumeFrom,
|
|
19152
|
+
signal,
|
|
19153
|
+
terminateOnAbort
|
|
19154
|
+
});
|
|
19155
|
+
} else {
|
|
19156
|
+
await uploadToR2(uploadUrls.video.uploadFileURL, video, {
|
|
19157
|
+
contentType: video.type,
|
|
19158
|
+
onProgress
|
|
19159
|
+
});
|
|
19160
|
+
}
|
|
19161
|
+
return { videoURL: uploadUrls.video.fileURL, postId: uploadUrls.postId, uploadUrls };
|
|
19162
|
+
}
|
|
19163
|
+
/** Translate the friendly `"now" | Date` form into the wire shape. */
|
|
19164
|
+
buildSchedule(schedule) {
|
|
19165
|
+
if (!schedule) return void 0;
|
|
19166
|
+
return {
|
|
19167
|
+
type: schedule === "now" ? "now" : "schedule",
|
|
19168
|
+
scheduledAt: schedule instanceof Date ? schedule : void 0
|
|
19169
|
+
};
|
|
19170
|
+
}
|
|
19171
|
+
/**
|
|
19172
|
+
* Guarantee the shape callers destructure. An older server that does not yet
|
|
19173
|
+
* return the duration fields would otherwise hand back `undefined` where the
|
|
19174
|
+
* types promise numbers.
|
|
19175
|
+
*/
|
|
19176
|
+
normaliseLongVideoResult(result) {
|
|
19177
|
+
return {
|
|
19178
|
+
_id: result?._id,
|
|
19179
|
+
durationSeconds: result?.durationSeconds ?? 0,
|
|
19180
|
+
creditUnits: result?.creditUnits ?? 0,
|
|
19181
|
+
credits: result?.credits ?? 0,
|
|
19182
|
+
refusedTargets: result?.refusedTargets ?? []
|
|
19183
|
+
};
|
|
19184
|
+
}
|
|
17866
19185
|
/**
|
|
17867
19186
|
* Auto-detect video source type.
|
|
17868
19187
|
*
|
|
@@ -17879,6 +19198,13 @@ var SocialPublisherPostClient = class {
|
|
|
17879
19198
|
throw new Error("Invalid video type. Must be File or string URL");
|
|
17880
19199
|
}
|
|
17881
19200
|
};
|
|
19201
|
+
|
|
19202
|
+
// src/interfaces/requests/index.ts
|
|
19203
|
+
var MAX_POST_COMMENTS = 5;
|
|
19204
|
+
var MAX_COMMENT_LENGTH = 2200;
|
|
19205
|
+
var MAX_COMMENT_DELAY_MINUTES = 24 * 60;
|
|
19206
|
+
var LONG_VIDEO_MAX_DURATION_SECONDS = 3600;
|
|
19207
|
+
var LONG_VIDEO_CREDIT_UNIT_SECONDS = 300;
|
|
17882
19208
|
/*! Bundled license information:
|
|
17883
19209
|
|
|
17884
19210
|
mime-db/index.js:
|
|
@@ -17898,8 +19224,17 @@ mime-types/index.js:
|
|
|
17898
19224
|
*)
|
|
17899
19225
|
*/
|
|
17900
19226
|
|
|
19227
|
+
exports.DEFAULT_CHUNK_SIZE = DEFAULT_CHUNK_SIZE2;
|
|
17901
19228
|
exports.HttpClient = HttpClient;
|
|
19229
|
+
exports.LONG_VIDEO_CREDIT_UNIT_SECONDS = LONG_VIDEO_CREDIT_UNIT_SECONDS;
|
|
19230
|
+
exports.LONG_VIDEO_MAX_DURATION_SECONDS = LONG_VIDEO_MAX_DURATION_SECONDS;
|
|
19231
|
+
exports.MAX_COMMENT_DELAY_MINUTES = MAX_COMMENT_DELAY_MINUTES;
|
|
19232
|
+
exports.MAX_COMMENT_LENGTH = MAX_COMMENT_LENGTH;
|
|
19233
|
+
exports.MAX_POST_COMMENTS = MAX_POST_COMMENTS;
|
|
17902
19234
|
exports.SocialPublisherPostClient = SocialPublisherPostClient;
|
|
19235
|
+
exports.supportsResumableUpload = supportsResumableUpload;
|
|
19236
|
+
exports.terminateUpload = terminateUpload;
|
|
19237
|
+
exports.uploadResumable = uploadResumable;
|
|
17903
19238
|
exports.uploadToR2 = uploadToR2;
|
|
17904
19239
|
//# sourceMappingURL=index.js.map
|
|
17905
19240
|
//# sourceMappingURL=index.js.map
|