@uidev1116/acms-js-sdk 0.0.1 → 0.0.2
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.
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function V(c,y){for(var m=0;m<y.length;m++){const p=y[m];if(typeof p!="string"&&!Array.isArray(p)){for(const l in p)if(l!=="default"&&!(l in c)){const b=Object.getOwnPropertyDescriptor(p,l);b&&Object.defineProperty(c,l,b.get?b:{enumerable:!0,get:()=>p[l]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}var x=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function z(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var O={exports:{}};(function(c,y){var m=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof x<"u"&&x,p=function(){function b(){this.fetch=!1,this.DOMException=m.DOMException}return b.prototype=m,new b}();(function(b){(function(u){var a=typeof b<"u"&&b||typeof self<"u"&&self||typeof a<"u"&&a,f={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function j(e){return e&&DataView.prototype.isPrototypeOf(e)}if(f.arrayBuffer)var S=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],F=ArrayBuffer.isView||function(e){return e&&S.indexOf(Object.prototype.toString.call(e))>-1};function v(e){if(typeof e!="string"&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e==="")throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function A(e){return typeof e!="string"&&(e=String(e)),e}function E(e){var t={next:function(){var r=e.shift();return{done:r===void 0,value:r}}};return f.iterable&&(t[Symbol.iterator]=function(){return t}),t}function s(e){this.map={},e instanceof s?e.forEach(function(t,r){this.append(r,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}s.prototype.append=function(e,t){e=v(e),t=A(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},s.prototype.delete=function(e){delete this.map[v(e)]},s.prototype.get=function(e){return e=v(e),this.has(e)?this.map[e]:null},s.prototype.has=function(e){return this.map.hasOwnProperty(v(e))},s.prototype.set=function(e,t){this.map[v(e)]=A(t)},s.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},s.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),E(e)},s.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),E(e)},s.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),E(e)},f.iterable&&(s.prototype[Symbol.iterator]=s.prototype.entries);function T(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function P(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function M(e){var t=new FileReader,r=P(t);return t.readAsArrayBuffer(e),r}function I(e){var t=new FileReader,r=P(t);return t.readAsText(e),r}function H(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}function D(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function R(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e=="string"?this._bodyText=e:f.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:f.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():f.arrayBuffer&&f.blob&&j(e)?(this._bodyArrayBuffer=D(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||F(e))?this._bodyArrayBuffer=D(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||(typeof e=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var e=T(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=T(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var e=T(this);if(e)return e;if(this._bodyBlob)return I(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(H(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(C)}),this.json=function(){return this.text().then(JSON.parse)},this}var q=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function L(e){var t=e.toUpperCase();return q.indexOf(t)>-1?t:e}function w(e,t){if(!(this instanceof w))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t=t||{};var r=t.body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new s(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!r&&e._bodyInit!=null&&(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",(t.headers||!this.headers)&&(this.headers=new s(t.headers)),this.method=L(t.method||this.method||"GET"),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(t.cache==="no-store"||t.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var i=/\?/;this.url+=(i.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})};function C(e){var t=new FormData;return e.trim().split("&").forEach(function(r){if(r){var n=r.split("="),i=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(o))}}),t}function k(e){var t=new s,r=e.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
|
+
`)===0?n.substr(1,n.length):n}).forEach(function(n){var i=n.split(":"),o=i.shift().trim();if(o){var _=i.join(":").trim();t.append(o,_)}}),t}R.call(w.prototype);function d(e,t){if(!(this instanceof d))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=t.status===void 0?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?"":""+t.statusText,this.headers=new s(t.headers),this.url=t.url||"",this._initBody(e)}R.call(d.prototype),d.prototype.clone=function(){return new d(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new s(this.headers),url:this.url})},d.error=function(){var e=new d(null,{status:0,statusText:""});return e.type="error",e};var N=[301,302,303,307,308];d.redirect=function(e,t){if(N.indexOf(t)===-1)throw new RangeError("Invalid status code");return new d(null,{status:t,headers:{location:e}})},u.DOMException=a.DOMException;try{new u.DOMException}catch{u.DOMException=function(t,r){this.message=t,this.name=r;var n=Error(t);this.stack=n.stack},u.DOMException.prototype=Object.create(Error.prototype),u.DOMException.prototype.constructor=u.DOMException}function B(e,t){return new Promise(function(r,n){var i=new w(e,t);if(i.signal&&i.signal.aborted)return n(new u.DOMException("Aborted","AbortError"));var o=new XMLHttpRequest;function _(){o.abort()}o.onload=function(){var h={status:o.status,statusText:o.statusText,headers:k(o.getAllResponseHeaders()||"")};h.url="responseURL"in o?o.responseURL:h.headers.get("X-Request-URL");var g="response"in o?o.response:o.responseText;setTimeout(function(){r(new d(g,h))},0)},o.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},o.onabort=function(){setTimeout(function(){n(new u.DOMException("Aborted","AbortError"))},0)};function G(h){try{return h===""&&a.location.href?a.location.href:h}catch{return h}}o.open(i.method,G(i.url),!0),i.credentials==="include"?o.withCredentials=!0:i.credentials==="omit"&&(o.withCredentials=!1),"responseType"in o&&(f.blob?o.responseType="blob":f.arrayBuffer&&i.headers.get("Content-Type")&&i.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(o.responseType="arraybuffer")),t&&typeof t.headers=="object"&&!(t.headers instanceof s)?Object.getOwnPropertyNames(t.headers).forEach(function(h){o.setRequestHeader(h,A(t.headers[h]))}):i.headers.forEach(function(h,g){o.setRequestHeader(g,h)}),i.signal&&(i.signal.addEventListener("abort",_),o.onreadystatechange=function(){o.readyState===4&&i.signal.removeEventListener("abort",_)}),o.send(typeof i._bodyInit>"u"?null:i._bodyInit)})}return B.polyfill=!0,a.fetch||(a.fetch=B,a.Headers=s,a.Request=w,a.Response=d),u.Headers=s,u.Request=w,u.Response=d,u.fetch=B,u})({})})(p),p.fetch.ponyfill=!0,delete p.fetch.polyfill;var l=m.fetch?m:p;y=l.fetch,y.default=l.fetch,y.fetch=l.fetch,y.Headers=l.Headers,y.Request=l.Request,y.Response=l.Response,c.exports=y})(O,O.exports);var U=O.exports;const $=z(U),X=V({__proto__:null,default:$},[U]);exports.browserPonyfill=X;
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
function V(c, y) {
|
|
2
|
+
for (var m = 0; m < y.length; m++) {
|
|
3
|
+
const p = y[m];
|
|
4
|
+
if (typeof p != "string" && !Array.isArray(p)) {
|
|
5
|
+
for (const l in p)
|
|
6
|
+
if (l !== "default" && !(l in c)) {
|
|
7
|
+
const b = Object.getOwnPropertyDescriptor(p, l);
|
|
8
|
+
b && Object.defineProperty(c, l, b.get ? b : {
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
get: () => p[l]
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return Object.freeze(Object.defineProperty(c, Symbol.toStringTag, { value: "Module" }));
|
|
16
|
+
}
|
|
17
|
+
var R = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
18
|
+
function z(c) {
|
|
19
|
+
return c && c.__esModule && Object.prototype.hasOwnProperty.call(c, "default") ? c.default : c;
|
|
20
|
+
}
|
|
21
|
+
var O = { exports: {} };
|
|
22
|
+
(function(c, y) {
|
|
23
|
+
var m = typeof globalThis < "u" && globalThis || typeof self < "u" && self || typeof R < "u" && R, p = function() {
|
|
24
|
+
function b() {
|
|
25
|
+
this.fetch = !1, this.DOMException = m.DOMException;
|
|
26
|
+
}
|
|
27
|
+
return b.prototype = m, new b();
|
|
28
|
+
}();
|
|
29
|
+
(function(b) {
|
|
30
|
+
(function(u) {
|
|
31
|
+
var a = typeof b < "u" && b || typeof self < "u" && self || typeof a < "u" && a, f = {
|
|
32
|
+
searchParams: "URLSearchParams" in a,
|
|
33
|
+
iterable: "Symbol" in a && "iterator" in Symbol,
|
|
34
|
+
blob: "FileReader" in a && "Blob" in a && function() {
|
|
35
|
+
try {
|
|
36
|
+
return new Blob(), !0;
|
|
37
|
+
} catch {
|
|
38
|
+
return !1;
|
|
39
|
+
}
|
|
40
|
+
}(),
|
|
41
|
+
formData: "FormData" in a,
|
|
42
|
+
arrayBuffer: "ArrayBuffer" in a
|
|
43
|
+
};
|
|
44
|
+
function j(e) {
|
|
45
|
+
return e && DataView.prototype.isPrototypeOf(e);
|
|
46
|
+
}
|
|
47
|
+
if (f.arrayBuffer)
|
|
48
|
+
var S = [
|
|
49
|
+
"[object Int8Array]",
|
|
50
|
+
"[object Uint8Array]",
|
|
51
|
+
"[object Uint8ClampedArray]",
|
|
52
|
+
"[object Int16Array]",
|
|
53
|
+
"[object Uint16Array]",
|
|
54
|
+
"[object Int32Array]",
|
|
55
|
+
"[object Uint32Array]",
|
|
56
|
+
"[object Float32Array]",
|
|
57
|
+
"[object Float64Array]"
|
|
58
|
+
], F = ArrayBuffer.isView || function(e) {
|
|
59
|
+
return e && S.indexOf(Object.prototype.toString.call(e)) > -1;
|
|
60
|
+
};
|
|
61
|
+
function v(e) {
|
|
62
|
+
if (typeof e != "string" && (e = String(e)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e) || e === "")
|
|
63
|
+
throw new TypeError('Invalid character in header field name: "' + e + '"');
|
|
64
|
+
return e.toLowerCase();
|
|
65
|
+
}
|
|
66
|
+
function A(e) {
|
|
67
|
+
return typeof e != "string" && (e = String(e)), e;
|
|
68
|
+
}
|
|
69
|
+
function E(e) {
|
|
70
|
+
var t = {
|
|
71
|
+
next: function() {
|
|
72
|
+
var r = e.shift();
|
|
73
|
+
return { done: r === void 0, value: r };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return f.iterable && (t[Symbol.iterator] = function() {
|
|
77
|
+
return t;
|
|
78
|
+
}), t;
|
|
79
|
+
}
|
|
80
|
+
function s(e) {
|
|
81
|
+
this.map = {}, e instanceof s ? e.forEach(function(t, r) {
|
|
82
|
+
this.append(r, t);
|
|
83
|
+
}, this) : Array.isArray(e) ? e.forEach(function(t) {
|
|
84
|
+
this.append(t[0], t[1]);
|
|
85
|
+
}, this) : e && Object.getOwnPropertyNames(e).forEach(function(t) {
|
|
86
|
+
this.append(t, e[t]);
|
|
87
|
+
}, this);
|
|
88
|
+
}
|
|
89
|
+
s.prototype.append = function(e, t) {
|
|
90
|
+
e = v(e), t = A(t);
|
|
91
|
+
var r = this.map[e];
|
|
92
|
+
this.map[e] = r ? r + ", " + t : t;
|
|
93
|
+
}, s.prototype.delete = function(e) {
|
|
94
|
+
delete this.map[v(e)];
|
|
95
|
+
}, s.prototype.get = function(e) {
|
|
96
|
+
return e = v(e), this.has(e) ? this.map[e] : null;
|
|
97
|
+
}, s.prototype.has = function(e) {
|
|
98
|
+
return this.map.hasOwnProperty(v(e));
|
|
99
|
+
}, s.prototype.set = function(e, t) {
|
|
100
|
+
this.map[v(e)] = A(t);
|
|
101
|
+
}, s.prototype.forEach = function(e, t) {
|
|
102
|
+
for (var r in this.map)
|
|
103
|
+
this.map.hasOwnProperty(r) && e.call(t, this.map[r], r, this);
|
|
104
|
+
}, s.prototype.keys = function() {
|
|
105
|
+
var e = [];
|
|
106
|
+
return this.forEach(function(t, r) {
|
|
107
|
+
e.push(r);
|
|
108
|
+
}), E(e);
|
|
109
|
+
}, s.prototype.values = function() {
|
|
110
|
+
var e = [];
|
|
111
|
+
return this.forEach(function(t) {
|
|
112
|
+
e.push(t);
|
|
113
|
+
}), E(e);
|
|
114
|
+
}, s.prototype.entries = function() {
|
|
115
|
+
var e = [];
|
|
116
|
+
return this.forEach(function(t, r) {
|
|
117
|
+
e.push([r, t]);
|
|
118
|
+
}), E(e);
|
|
119
|
+
}, f.iterable && (s.prototype[Symbol.iterator] = s.prototype.entries);
|
|
120
|
+
function T(e) {
|
|
121
|
+
if (e.bodyUsed)
|
|
122
|
+
return Promise.reject(new TypeError("Already read"));
|
|
123
|
+
e.bodyUsed = !0;
|
|
124
|
+
}
|
|
125
|
+
function P(e) {
|
|
126
|
+
return new Promise(function(t, r) {
|
|
127
|
+
e.onload = function() {
|
|
128
|
+
t(e.result);
|
|
129
|
+
}, e.onerror = function() {
|
|
130
|
+
r(e.error);
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function M(e) {
|
|
135
|
+
var t = new FileReader(), r = P(t);
|
|
136
|
+
return t.readAsArrayBuffer(e), r;
|
|
137
|
+
}
|
|
138
|
+
function I(e) {
|
|
139
|
+
var t = new FileReader(), r = P(t);
|
|
140
|
+
return t.readAsText(e), r;
|
|
141
|
+
}
|
|
142
|
+
function H(e) {
|
|
143
|
+
for (var t = new Uint8Array(e), r = new Array(t.length), n = 0; n < t.length; n++)
|
|
144
|
+
r[n] = String.fromCharCode(t[n]);
|
|
145
|
+
return r.join("");
|
|
146
|
+
}
|
|
147
|
+
function D(e) {
|
|
148
|
+
if (e.slice)
|
|
149
|
+
return e.slice(0);
|
|
150
|
+
var t = new Uint8Array(e.byteLength);
|
|
151
|
+
return t.set(new Uint8Array(e)), t.buffer;
|
|
152
|
+
}
|
|
153
|
+
function x() {
|
|
154
|
+
return this.bodyUsed = !1, this._initBody = function(e) {
|
|
155
|
+
this.bodyUsed = this.bodyUsed, this._bodyInit = e, e ? typeof e == "string" ? this._bodyText = e : f.blob && Blob.prototype.isPrototypeOf(e) ? this._bodyBlob = e : f.formData && FormData.prototype.isPrototypeOf(e) ? this._bodyFormData = e : f.searchParams && URLSearchParams.prototype.isPrototypeOf(e) ? this._bodyText = e.toString() : f.arrayBuffer && f.blob && j(e) ? (this._bodyArrayBuffer = D(e.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : f.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(e) || F(e)) ? this._bodyArrayBuffer = D(e) : this._bodyText = e = Object.prototype.toString.call(e) : this._bodyText = "", this.headers.get("content-type") || (typeof e == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : f.searchParams && URLSearchParams.prototype.isPrototypeOf(e) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
|
|
156
|
+
}, f.blob && (this.blob = function() {
|
|
157
|
+
var e = T(this);
|
|
158
|
+
if (e)
|
|
159
|
+
return e;
|
|
160
|
+
if (this._bodyBlob)
|
|
161
|
+
return Promise.resolve(this._bodyBlob);
|
|
162
|
+
if (this._bodyArrayBuffer)
|
|
163
|
+
return Promise.resolve(new Blob([this._bodyArrayBuffer]));
|
|
164
|
+
if (this._bodyFormData)
|
|
165
|
+
throw new Error("could not read FormData body as blob");
|
|
166
|
+
return Promise.resolve(new Blob([this._bodyText]));
|
|
167
|
+
}, this.arrayBuffer = function() {
|
|
168
|
+
if (this._bodyArrayBuffer) {
|
|
169
|
+
var e = T(this);
|
|
170
|
+
return e || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(
|
|
171
|
+
this._bodyArrayBuffer.buffer.slice(
|
|
172
|
+
this._bodyArrayBuffer.byteOffset,
|
|
173
|
+
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
174
|
+
)
|
|
175
|
+
) : Promise.resolve(this._bodyArrayBuffer));
|
|
176
|
+
} else
|
|
177
|
+
return this.blob().then(M);
|
|
178
|
+
}), this.text = function() {
|
|
179
|
+
var e = T(this);
|
|
180
|
+
if (e)
|
|
181
|
+
return e;
|
|
182
|
+
if (this._bodyBlob)
|
|
183
|
+
return I(this._bodyBlob);
|
|
184
|
+
if (this._bodyArrayBuffer)
|
|
185
|
+
return Promise.resolve(H(this._bodyArrayBuffer));
|
|
186
|
+
if (this._bodyFormData)
|
|
187
|
+
throw new Error("could not read FormData body as text");
|
|
188
|
+
return Promise.resolve(this._bodyText);
|
|
189
|
+
}, f.formData && (this.formData = function() {
|
|
190
|
+
return this.text().then(C);
|
|
191
|
+
}), this.json = function() {
|
|
192
|
+
return this.text().then(JSON.parse);
|
|
193
|
+
}, this;
|
|
194
|
+
}
|
|
195
|
+
var q = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
|
|
196
|
+
function L(e) {
|
|
197
|
+
var t = e.toUpperCase();
|
|
198
|
+
return q.indexOf(t) > -1 ? t : e;
|
|
199
|
+
}
|
|
200
|
+
function w(e, t) {
|
|
201
|
+
if (!(this instanceof w))
|
|
202
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
203
|
+
t = t || {};
|
|
204
|
+
var r = t.body;
|
|
205
|
+
if (e instanceof w) {
|
|
206
|
+
if (e.bodyUsed)
|
|
207
|
+
throw new TypeError("Already read");
|
|
208
|
+
this.url = e.url, this.credentials = e.credentials, t.headers || (this.headers = new s(e.headers)), this.method = e.method, this.mode = e.mode, this.signal = e.signal, !r && e._bodyInit != null && (r = e._bodyInit, e.bodyUsed = !0);
|
|
209
|
+
} else
|
|
210
|
+
this.url = String(e);
|
|
211
|
+
if (this.credentials = t.credentials || this.credentials || "same-origin", (t.headers || !this.headers) && (this.headers = new s(t.headers)), this.method = L(t.method || this.method || "GET"), this.mode = t.mode || this.mode || null, this.signal = t.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && r)
|
|
212
|
+
throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
213
|
+
if (this._initBody(r), (this.method === "GET" || this.method === "HEAD") && (t.cache === "no-store" || t.cache === "no-cache")) {
|
|
214
|
+
var n = /([?&])_=[^&]*/;
|
|
215
|
+
if (n.test(this.url))
|
|
216
|
+
this.url = this.url.replace(n, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
|
|
217
|
+
else {
|
|
218
|
+
var i = /\?/;
|
|
219
|
+
this.url += (i.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
w.prototype.clone = function() {
|
|
224
|
+
return new w(this, { body: this._bodyInit });
|
|
225
|
+
};
|
|
226
|
+
function C(e) {
|
|
227
|
+
var t = new FormData();
|
|
228
|
+
return e.trim().split("&").forEach(function(r) {
|
|
229
|
+
if (r) {
|
|
230
|
+
var n = r.split("="), i = n.shift().replace(/\+/g, " "), o = n.join("=").replace(/\+/g, " ");
|
|
231
|
+
t.append(decodeURIComponent(i), decodeURIComponent(o));
|
|
232
|
+
}
|
|
233
|
+
}), t;
|
|
234
|
+
}
|
|
235
|
+
function k(e) {
|
|
236
|
+
var t = new s(), r = e.replace(/\r?\n[\t ]+/g, " ");
|
|
237
|
+
return r.split("\r").map(function(n) {
|
|
238
|
+
return n.indexOf(`
|
|
239
|
+
`) === 0 ? n.substr(1, n.length) : n;
|
|
240
|
+
}).forEach(function(n) {
|
|
241
|
+
var i = n.split(":"), o = i.shift().trim();
|
|
242
|
+
if (o) {
|
|
243
|
+
var _ = i.join(":").trim();
|
|
244
|
+
t.append(o, _);
|
|
245
|
+
}
|
|
246
|
+
}), t;
|
|
247
|
+
}
|
|
248
|
+
x.call(w.prototype);
|
|
249
|
+
function d(e, t) {
|
|
250
|
+
if (!(this instanceof d))
|
|
251
|
+
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
252
|
+
t || (t = {}), this.type = "default", this.status = t.status === void 0 ? 200 : t.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = t.statusText === void 0 ? "" : "" + t.statusText, this.headers = new s(t.headers), this.url = t.url || "", this._initBody(e);
|
|
253
|
+
}
|
|
254
|
+
x.call(d.prototype), d.prototype.clone = function() {
|
|
255
|
+
return new d(this._bodyInit, {
|
|
256
|
+
status: this.status,
|
|
257
|
+
statusText: this.statusText,
|
|
258
|
+
headers: new s(this.headers),
|
|
259
|
+
url: this.url
|
|
260
|
+
});
|
|
261
|
+
}, d.error = function() {
|
|
262
|
+
var e = new d(null, { status: 0, statusText: "" });
|
|
263
|
+
return e.type = "error", e;
|
|
264
|
+
};
|
|
265
|
+
var N = [301, 302, 303, 307, 308];
|
|
266
|
+
d.redirect = function(e, t) {
|
|
267
|
+
if (N.indexOf(t) === -1)
|
|
268
|
+
throw new RangeError("Invalid status code");
|
|
269
|
+
return new d(null, { status: t, headers: { location: e } });
|
|
270
|
+
}, u.DOMException = a.DOMException;
|
|
271
|
+
try {
|
|
272
|
+
new u.DOMException();
|
|
273
|
+
} catch {
|
|
274
|
+
u.DOMException = function(t, r) {
|
|
275
|
+
this.message = t, this.name = r;
|
|
276
|
+
var n = Error(t);
|
|
277
|
+
this.stack = n.stack;
|
|
278
|
+
}, u.DOMException.prototype = Object.create(Error.prototype), u.DOMException.prototype.constructor = u.DOMException;
|
|
279
|
+
}
|
|
280
|
+
function B(e, t) {
|
|
281
|
+
return new Promise(function(r, n) {
|
|
282
|
+
var i = new w(e, t);
|
|
283
|
+
if (i.signal && i.signal.aborted)
|
|
284
|
+
return n(new u.DOMException("Aborted", "AbortError"));
|
|
285
|
+
var o = new XMLHttpRequest();
|
|
286
|
+
function _() {
|
|
287
|
+
o.abort();
|
|
288
|
+
}
|
|
289
|
+
o.onload = function() {
|
|
290
|
+
var h = {
|
|
291
|
+
status: o.status,
|
|
292
|
+
statusText: o.statusText,
|
|
293
|
+
headers: k(o.getAllResponseHeaders() || "")
|
|
294
|
+
};
|
|
295
|
+
h.url = "responseURL" in o ? o.responseURL : h.headers.get("X-Request-URL");
|
|
296
|
+
var g = "response" in o ? o.response : o.responseText;
|
|
297
|
+
setTimeout(function() {
|
|
298
|
+
r(new d(g, h));
|
|
299
|
+
}, 0);
|
|
300
|
+
}, o.onerror = function() {
|
|
301
|
+
setTimeout(function() {
|
|
302
|
+
n(new TypeError("Network request failed"));
|
|
303
|
+
}, 0);
|
|
304
|
+
}, o.ontimeout = function() {
|
|
305
|
+
setTimeout(function() {
|
|
306
|
+
n(new TypeError("Network request failed"));
|
|
307
|
+
}, 0);
|
|
308
|
+
}, o.onabort = function() {
|
|
309
|
+
setTimeout(function() {
|
|
310
|
+
n(new u.DOMException("Aborted", "AbortError"));
|
|
311
|
+
}, 0);
|
|
312
|
+
};
|
|
313
|
+
function G(h) {
|
|
314
|
+
try {
|
|
315
|
+
return h === "" && a.location.href ? a.location.href : h;
|
|
316
|
+
} catch {
|
|
317
|
+
return h;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
o.open(i.method, G(i.url), !0), i.credentials === "include" ? o.withCredentials = !0 : i.credentials === "omit" && (o.withCredentials = !1), "responseType" in o && (f.blob ? o.responseType = "blob" : f.arrayBuffer && i.headers.get("Content-Type") && i.headers.get("Content-Type").indexOf("application/octet-stream") !== -1 && (o.responseType = "arraybuffer")), t && typeof t.headers == "object" && !(t.headers instanceof s) ? Object.getOwnPropertyNames(t.headers).forEach(function(h) {
|
|
321
|
+
o.setRequestHeader(h, A(t.headers[h]));
|
|
322
|
+
}) : i.headers.forEach(function(h, g) {
|
|
323
|
+
o.setRequestHeader(g, h);
|
|
324
|
+
}), i.signal && (i.signal.addEventListener("abort", _), o.onreadystatechange = function() {
|
|
325
|
+
o.readyState === 4 && i.signal.removeEventListener("abort", _);
|
|
326
|
+
}), o.send(typeof i._bodyInit > "u" ? null : i._bodyInit);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return B.polyfill = !0, a.fetch || (a.fetch = B, a.Headers = s, a.Request = w, a.Response = d), u.Headers = s, u.Request = w, u.Response = d, u.fetch = B, u;
|
|
330
|
+
})({});
|
|
331
|
+
})(p), p.fetch.ponyfill = !0, delete p.fetch.polyfill;
|
|
332
|
+
var l = m.fetch ? m : p;
|
|
333
|
+
y = l.fetch, y.default = l.fetch, y.fetch = l.fetch, y.Headers = l.Headers, y.Request = l.Request, y.Response = l.Response, c.exports = y;
|
|
334
|
+
})(O, O.exports);
|
|
335
|
+
var U = O.exports;
|
|
336
|
+
const $ = /* @__PURE__ */ z(U), X = /* @__PURE__ */ V({
|
|
337
|
+
__proto__: null,
|
|
338
|
+
default: $
|
|
339
|
+
}, [U]);
|
|
340
|
+
export {
|
|
341
|
+
X as b
|
|
342
|
+
};
|
package/dist/cjs/acms-js-sdk.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Details:
|
|
5
|
-
Details: Unknown Error`))}}createFetchOptions(r){const o=ee(r==null?void 0:r.headers);return o.has("X-API-KEY")||o.set("X-API-KEY",this.apiKey),{...r,headers:o}}createUrl(r){return U.isString(r)?new URL(r,this.baseUrl):r instanceof URL?new URL(r,this.baseUrl):new URL(H({...r}),this.baseUrl)}async get(r,o={}){return await this.request(r,{...o,requestInit:{...o.requestInit,method:"GET"}})}static isAcmsFetchError(r){return j.isAcmsFetchError(r)}}function ne(...f){return new re(...f)}exports.acmsPath=H;exports.isAcmsFetchError=j.isAcmsFetchError;exports.createClient=ne;
|
|
1
|
+
"use strict";var P=Object.defineProperty;var q=(t,e,r)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>(q(t,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./acms-path.cjs"),o=require("../typeGuard-eqTQ9U-x.cjs"),c=require("../index-x-5Zn68j.cjs");async function b(t){try{const{message:e}=await t.json();return e??null}catch{return null}}async function A(){if(typeof fetch>"u"){const{default:t}=await Promise.resolve().then(()=>require("../browser-ponyfill-fsIF2jNb.cjs")).then(e=>e.browserPonyfill);return t}return fetch}async function F(...t){if(typeof Headers>"u"){const{Headers:e}=await Promise.resolve().then(()=>require("../browser-ponyfill-fsIF2jNb.cjs")).then(r=>r.browserPonyfill);return new e(...t)}return new Headers(...t)}const U={responseType:"json"};class ${constructor({baseUrl:e,apiKey:r,...i}){n(this,"baseUrl");n(this,"apiKey");n(this,"config");if(e==null&&e==="")throw new Error("baseUrl is required.");if(r==null&&r==="")throw new Error("apiKey is required.");if(!o.isString(e))throw new Error("baseUrl must be string.");if(!o.isString(r))throw new Error("apiKey must be string.");this.baseUrl=e,this.apiKey=r,this.config={...U,...i}}async request(e,r={}){const i={...this.config,...r},{requestInit:l,responseType:d}=i,y=await A(),m=this.createUrl(e),p=await this.createFetchOptions(l);try{const s=await y(m,p),{ok:E,status:a,statusText:u,headers:g}=s,h={data:await s[d](),status:a,statusText:u,headers:g};if(!E){const f=await b(s);return await Promise.reject(new c.AcmsFetchError(`fetch API response status: ${a}${f!=null?`
|
|
2
|
+
message is \`${f}\``:""}`,`${a} ${u}`,h))}return h}catch(s){return s instanceof Error?await Promise.reject(new Error(`Network Error.
|
|
3
|
+
Details: ${s.message}`)):await Promise.reject(new Error(`Network Error.
|
|
4
|
+
Details: Unknown Error`))}}async createFetchOptions(e){const r=await F(e==null?void 0:e.headers);return r.has("X-API-KEY")||r.set("X-API-KEY",this.apiKey),{...e,headers:r}}createUrl(e){return o.isString(e)?new URL(e,this.baseUrl):e instanceof URL?new URL(e,this.baseUrl):new URL(w({...e}),this.baseUrl)}async get(e,r={}){return await this.request(e,{...r,requestInit:{...r.requestInit,method:"GET"}})}static isAcmsFetchError(e){return c.isAcmsFetchError(e)}}function j(...t){return new $(...t)}exports.acmsPath=w;exports.isAcmsFetchError=c.isAcmsFetchError;exports.createClient=j;
|
package/dist/es/acms-js-sdk.js
CHANGED
|
@@ -1,424 +1,109 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { a as
|
|
6
|
-
import { A
|
|
7
|
-
async function
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var g = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var n = (t, e, r) => (g(t, typeof e != "symbol" ? e + "" : e, r), r);
|
|
4
|
+
import b from "./acms-path.js";
|
|
5
|
+
import { a as i } from "../typeGuard-30fb1DDr.js";
|
|
6
|
+
import { A, i as q } from "../index-w7KUzF0v.js";
|
|
7
|
+
async function F(t) {
|
|
8
8
|
try {
|
|
9
|
-
const { message:
|
|
10
|
-
return
|
|
9
|
+
const { message: e } = await t.json();
|
|
10
|
+
return e ?? null;
|
|
11
11
|
} catch {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var s = typeof globalThis < "u" && globalThis || typeof self < "u" && self || typeof q < "u" && q, p = function() {
|
|
22
|
-
function m() {
|
|
23
|
-
this.fetch = !1, this.DOMException = s.DOMException;
|
|
24
|
-
}
|
|
25
|
-
return m.prototype = s, new m();
|
|
26
|
-
}();
|
|
27
|
-
(function(m) {
|
|
28
|
-
(function(l) {
|
|
29
|
-
var a = typeof m < "u" && m || typeof self < "u" && self || typeof a < "u" && a, h = {
|
|
30
|
-
searchParams: "URLSearchParams" in a,
|
|
31
|
-
iterable: "Symbol" in a && "iterator" in Symbol,
|
|
32
|
-
blob: "FileReader" in a && "Blob" in a && function() {
|
|
33
|
-
try {
|
|
34
|
-
return new Blob(), !0;
|
|
35
|
-
} catch {
|
|
36
|
-
return !1;
|
|
37
|
-
}
|
|
38
|
-
}(),
|
|
39
|
-
formData: "FormData" in a,
|
|
40
|
-
arrayBuffer: "ArrayBuffer" in a
|
|
41
|
-
};
|
|
42
|
-
function v(e) {
|
|
43
|
-
return e && DataView.prototype.isPrototypeOf(e);
|
|
44
|
-
}
|
|
45
|
-
if (h.arrayBuffer)
|
|
46
|
-
var _ = [
|
|
47
|
-
"[object Int8Array]",
|
|
48
|
-
"[object Uint8Array]",
|
|
49
|
-
"[object Uint8ClampedArray]",
|
|
50
|
-
"[object Int16Array]",
|
|
51
|
-
"[object Uint16Array]",
|
|
52
|
-
"[object Int32Array]",
|
|
53
|
-
"[object Uint32Array]",
|
|
54
|
-
"[object Float32Array]",
|
|
55
|
-
"[object Float64Array]"
|
|
56
|
-
], O = ArrayBuffer.isView || function(e) {
|
|
57
|
-
return e && _.indexOf(Object.prototype.toString.call(e)) > -1;
|
|
58
|
-
};
|
|
59
|
-
function E(e) {
|
|
60
|
-
if (typeof e != "string" && (e = String(e)), /[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e) || e === "")
|
|
61
|
-
throw new TypeError('Invalid character in header field name: "' + e + '"');
|
|
62
|
-
return e.toLowerCase();
|
|
63
|
-
}
|
|
64
|
-
function g(e) {
|
|
65
|
-
return typeof e != "string" && (e = String(e)), e;
|
|
66
|
-
}
|
|
67
|
-
function A(e) {
|
|
68
|
-
var t = {
|
|
69
|
-
next: function() {
|
|
70
|
-
var n = e.shift();
|
|
71
|
-
return { done: n === void 0, value: n };
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
return h.iterable && (t[Symbol.iterator] = function() {
|
|
75
|
-
return t;
|
|
76
|
-
}), t;
|
|
77
|
-
}
|
|
78
|
-
function c(e) {
|
|
79
|
-
this.map = {}, e instanceof c ? e.forEach(function(t, n) {
|
|
80
|
-
this.append(n, t);
|
|
81
|
-
}, this) : Array.isArray(e) ? e.forEach(function(t) {
|
|
82
|
-
this.append(t[0], t[1]);
|
|
83
|
-
}, this) : e && Object.getOwnPropertyNames(e).forEach(function(t) {
|
|
84
|
-
this.append(t, e[t]);
|
|
85
|
-
}, this);
|
|
86
|
-
}
|
|
87
|
-
c.prototype.append = function(e, t) {
|
|
88
|
-
e = E(e), t = g(t);
|
|
89
|
-
var n = this.map[e];
|
|
90
|
-
this.map[e] = n ? n + ", " + t : t;
|
|
91
|
-
}, c.prototype.delete = function(e) {
|
|
92
|
-
delete this.map[E(e)];
|
|
93
|
-
}, c.prototype.get = function(e) {
|
|
94
|
-
return e = E(e), this.has(e) ? this.map[e] : null;
|
|
95
|
-
}, c.prototype.has = function(e) {
|
|
96
|
-
return this.map.hasOwnProperty(E(e));
|
|
97
|
-
}, c.prototype.set = function(e, t) {
|
|
98
|
-
this.map[E(e)] = g(t);
|
|
99
|
-
}, c.prototype.forEach = function(e, t) {
|
|
100
|
-
for (var n in this.map)
|
|
101
|
-
this.map.hasOwnProperty(n) && e.call(t, this.map[n], n, this);
|
|
102
|
-
}, c.prototype.keys = function() {
|
|
103
|
-
var e = [];
|
|
104
|
-
return this.forEach(function(t, n) {
|
|
105
|
-
e.push(n);
|
|
106
|
-
}), A(e);
|
|
107
|
-
}, c.prototype.values = function() {
|
|
108
|
-
var e = [];
|
|
109
|
-
return this.forEach(function(t) {
|
|
110
|
-
e.push(t);
|
|
111
|
-
}), A(e);
|
|
112
|
-
}, c.prototype.entries = function() {
|
|
113
|
-
var e = [];
|
|
114
|
-
return this.forEach(function(t, n) {
|
|
115
|
-
e.push([n, t]);
|
|
116
|
-
}), A(e);
|
|
117
|
-
}, h.iterable && (c.prototype[Symbol.iterator] = c.prototype.entries);
|
|
118
|
-
function D(e) {
|
|
119
|
-
if (e.bodyUsed)
|
|
120
|
-
return Promise.reject(new TypeError("Already read"));
|
|
121
|
-
e.bodyUsed = !0;
|
|
122
|
-
}
|
|
123
|
-
function x(e) {
|
|
124
|
-
return new Promise(function(t, n) {
|
|
125
|
-
e.onload = function() {
|
|
126
|
-
t(e.result);
|
|
127
|
-
}, e.onerror = function() {
|
|
128
|
-
n(e.error);
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function S(e) {
|
|
133
|
-
var t = new FileReader(), n = x(t);
|
|
134
|
-
return t.readAsArrayBuffer(e), n;
|
|
135
|
-
}
|
|
136
|
-
function L(e) {
|
|
137
|
-
var t = new FileReader(), n = x(t);
|
|
138
|
-
return t.readAsText(e), n;
|
|
139
|
-
}
|
|
140
|
-
function M(e) {
|
|
141
|
-
for (var t = new Uint8Array(e), n = new Array(t.length), i = 0; i < t.length; i++)
|
|
142
|
-
n[i] = String.fromCharCode(t[i]);
|
|
143
|
-
return n.join("");
|
|
144
|
-
}
|
|
145
|
-
function F(e) {
|
|
146
|
-
if (e.slice)
|
|
147
|
-
return e.slice(0);
|
|
148
|
-
var t = new Uint8Array(e.byteLength);
|
|
149
|
-
return t.set(new Uint8Array(e)), t.buffer;
|
|
150
|
-
}
|
|
151
|
-
function I() {
|
|
152
|
-
return this.bodyUsed = !1, this._initBody = function(e) {
|
|
153
|
-
this.bodyUsed = this.bodyUsed, this._bodyInit = e, e ? typeof e == "string" ? this._bodyText = e : h.blob && Blob.prototype.isPrototypeOf(e) ? this._bodyBlob = e : h.formData && FormData.prototype.isPrototypeOf(e) ? this._bodyFormData = e : h.searchParams && URLSearchParams.prototype.isPrototypeOf(e) ? this._bodyText = e.toString() : h.arrayBuffer && h.blob && v(e) ? (this._bodyArrayBuffer = F(e.buffer), this._bodyInit = new Blob([this._bodyArrayBuffer])) : h.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(e) || O(e)) ? this._bodyArrayBuffer = F(e) : this._bodyText = e = Object.prototype.toString.call(e) : this._bodyText = "", this.headers.get("content-type") || (typeof e == "string" ? this.headers.set("content-type", "text/plain;charset=UTF-8") : this._bodyBlob && this._bodyBlob.type ? this.headers.set("content-type", this._bodyBlob.type) : h.searchParams && URLSearchParams.prototype.isPrototypeOf(e) && this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8"));
|
|
154
|
-
}, h.blob && (this.blob = function() {
|
|
155
|
-
var e = D(this);
|
|
156
|
-
if (e)
|
|
157
|
-
return e;
|
|
158
|
-
if (this._bodyBlob)
|
|
159
|
-
return Promise.resolve(this._bodyBlob);
|
|
160
|
-
if (this._bodyArrayBuffer)
|
|
161
|
-
return Promise.resolve(new Blob([this._bodyArrayBuffer]));
|
|
162
|
-
if (this._bodyFormData)
|
|
163
|
-
throw new Error("could not read FormData body as blob");
|
|
164
|
-
return Promise.resolve(new Blob([this._bodyText]));
|
|
165
|
-
}, this.arrayBuffer = function() {
|
|
166
|
-
if (this._bodyArrayBuffer) {
|
|
167
|
-
var e = D(this);
|
|
168
|
-
return e || (ArrayBuffer.isView(this._bodyArrayBuffer) ? Promise.resolve(
|
|
169
|
-
this._bodyArrayBuffer.buffer.slice(
|
|
170
|
-
this._bodyArrayBuffer.byteOffset,
|
|
171
|
-
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
|
172
|
-
)
|
|
173
|
-
) : Promise.resolve(this._bodyArrayBuffer));
|
|
174
|
-
} else
|
|
175
|
-
return this.blob().then(S);
|
|
176
|
-
}), this.text = function() {
|
|
177
|
-
var e = D(this);
|
|
178
|
-
if (e)
|
|
179
|
-
return e;
|
|
180
|
-
if (this._bodyBlob)
|
|
181
|
-
return L(this._bodyBlob);
|
|
182
|
-
if (this._bodyArrayBuffer)
|
|
183
|
-
return Promise.resolve(M(this._bodyArrayBuffer));
|
|
184
|
-
if (this._bodyFormData)
|
|
185
|
-
throw new Error("could not read FormData body as text");
|
|
186
|
-
return Promise.resolve(this._bodyText);
|
|
187
|
-
}, h.formData && (this.formData = function() {
|
|
188
|
-
return this.text().then(N);
|
|
189
|
-
}), this.json = function() {
|
|
190
|
-
return this.text().then(JSON.parse);
|
|
191
|
-
}, this;
|
|
192
|
-
}
|
|
193
|
-
var k = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
|
|
194
|
-
function C(e) {
|
|
195
|
-
var t = e.toUpperCase();
|
|
196
|
-
return k.indexOf(t) > -1 ? t : e;
|
|
197
|
-
}
|
|
198
|
-
function w(e, t) {
|
|
199
|
-
if (!(this instanceof w))
|
|
200
|
-
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
201
|
-
t = t || {};
|
|
202
|
-
var n = t.body;
|
|
203
|
-
if (e instanceof w) {
|
|
204
|
-
if (e.bodyUsed)
|
|
205
|
-
throw new TypeError("Already read");
|
|
206
|
-
this.url = e.url, this.credentials = e.credentials, t.headers || (this.headers = new c(e.headers)), this.method = e.method, this.mode = e.mode, this.signal = e.signal, !n && e._bodyInit != null && (n = e._bodyInit, e.bodyUsed = !0);
|
|
207
|
-
} else
|
|
208
|
-
this.url = String(e);
|
|
209
|
-
if (this.credentials = t.credentials || this.credentials || "same-origin", (t.headers || !this.headers) && (this.headers = new c(t.headers)), this.method = C(t.method || this.method || "GET"), this.mode = t.mode || this.mode || null, this.signal = t.signal || this.signal, this.referrer = null, (this.method === "GET" || this.method === "HEAD") && n)
|
|
210
|
-
throw new TypeError("Body not allowed for GET or HEAD requests");
|
|
211
|
-
if (this._initBody(n), (this.method === "GET" || this.method === "HEAD") && (t.cache === "no-store" || t.cache === "no-cache")) {
|
|
212
|
-
var i = /([?&])_=[^&]*/;
|
|
213
|
-
if (i.test(this.url))
|
|
214
|
-
this.url = this.url.replace(i, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
|
|
215
|
-
else {
|
|
216
|
-
var u = /\?/;
|
|
217
|
-
this.url += (u.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
w.prototype.clone = function() {
|
|
222
|
-
return new w(this, { body: this._bodyInit });
|
|
223
|
-
};
|
|
224
|
-
function N(e) {
|
|
225
|
-
var t = new FormData();
|
|
226
|
-
return e.trim().split("&").forEach(function(n) {
|
|
227
|
-
if (n) {
|
|
228
|
-
var i = n.split("="), u = i.shift().replace(/\+/g, " "), o = i.join("=").replace(/\+/g, " ");
|
|
229
|
-
t.append(decodeURIComponent(u), decodeURIComponent(o));
|
|
230
|
-
}
|
|
231
|
-
}), t;
|
|
232
|
-
}
|
|
233
|
-
function $(e) {
|
|
234
|
-
var t = new c(), n = e.replace(/\r?\n[\t ]+/g, " ");
|
|
235
|
-
return n.split("\r").map(function(i) {
|
|
236
|
-
return i.indexOf(`
|
|
237
|
-
`) === 0 ? i.substr(1, i.length) : i;
|
|
238
|
-
}).forEach(function(i) {
|
|
239
|
-
var u = i.split(":"), o = u.shift().trim();
|
|
240
|
-
if (o) {
|
|
241
|
-
var T = u.join(":").trim();
|
|
242
|
-
t.append(o, T);
|
|
243
|
-
}
|
|
244
|
-
}), t;
|
|
245
|
-
}
|
|
246
|
-
I.call(w.prototype);
|
|
247
|
-
function y(e, t) {
|
|
248
|
-
if (!(this instanceof y))
|
|
249
|
-
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
|
|
250
|
-
t || (t = {}), this.type = "default", this.status = t.status === void 0 ? 200 : t.status, this.ok = this.status >= 200 && this.status < 300, this.statusText = t.statusText === void 0 ? "" : "" + t.statusText, this.headers = new c(t.headers), this.url = t.url || "", this._initBody(e);
|
|
251
|
-
}
|
|
252
|
-
I.call(y.prototype), y.prototype.clone = function() {
|
|
253
|
-
return new y(this._bodyInit, {
|
|
254
|
-
status: this.status,
|
|
255
|
-
statusText: this.statusText,
|
|
256
|
-
headers: new c(this.headers),
|
|
257
|
-
url: this.url
|
|
258
|
-
});
|
|
259
|
-
}, y.error = function() {
|
|
260
|
-
var e = new y(null, { status: 0, statusText: "" });
|
|
261
|
-
return e.type = "error", e;
|
|
262
|
-
};
|
|
263
|
-
var G = [301, 302, 303, 307, 308];
|
|
264
|
-
y.redirect = function(e, t) {
|
|
265
|
-
if (G.indexOf(t) === -1)
|
|
266
|
-
throw new RangeError("Invalid status code");
|
|
267
|
-
return new y(null, { status: t, headers: { location: e } });
|
|
268
|
-
}, l.DOMException = a.DOMException;
|
|
269
|
-
try {
|
|
270
|
-
new l.DOMException();
|
|
271
|
-
} catch {
|
|
272
|
-
l.DOMException = function(t, n) {
|
|
273
|
-
this.message = t, this.name = n;
|
|
274
|
-
var i = Error(t);
|
|
275
|
-
this.stack = i.stack;
|
|
276
|
-
}, l.DOMException.prototype = Object.create(Error.prototype), l.DOMException.prototype.constructor = l.DOMException;
|
|
277
|
-
}
|
|
278
|
-
function R(e, t) {
|
|
279
|
-
return new Promise(function(n, i) {
|
|
280
|
-
var u = new w(e, t);
|
|
281
|
-
if (u.signal && u.signal.aborted)
|
|
282
|
-
return i(new l.DOMException("Aborted", "AbortError"));
|
|
283
|
-
var o = new XMLHttpRequest();
|
|
284
|
-
function T() {
|
|
285
|
-
o.abort();
|
|
286
|
-
}
|
|
287
|
-
o.onload = function() {
|
|
288
|
-
var d = {
|
|
289
|
-
status: o.status,
|
|
290
|
-
statusText: o.statusText,
|
|
291
|
-
headers: $(o.getAllResponseHeaders() || "")
|
|
292
|
-
};
|
|
293
|
-
d.url = "responseURL" in o ? o.responseURL : d.headers.get("X-Request-URL");
|
|
294
|
-
var B = "response" in o ? o.response : o.responseText;
|
|
295
|
-
setTimeout(function() {
|
|
296
|
-
n(new y(B, d));
|
|
297
|
-
}, 0);
|
|
298
|
-
}, o.onerror = function() {
|
|
299
|
-
setTimeout(function() {
|
|
300
|
-
i(new TypeError("Network request failed"));
|
|
301
|
-
}, 0);
|
|
302
|
-
}, o.ontimeout = function() {
|
|
303
|
-
setTimeout(function() {
|
|
304
|
-
i(new TypeError("Network request failed"));
|
|
305
|
-
}, 0);
|
|
306
|
-
}, o.onabort = function() {
|
|
307
|
-
setTimeout(function() {
|
|
308
|
-
i(new l.DOMException("Aborted", "AbortError"));
|
|
309
|
-
}, 0);
|
|
310
|
-
};
|
|
311
|
-
function V(d) {
|
|
312
|
-
try {
|
|
313
|
-
return d === "" && a.location.href ? a.location.href : d;
|
|
314
|
-
} catch {
|
|
315
|
-
return d;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
o.open(u.method, V(u.url), !0), u.credentials === "include" ? o.withCredentials = !0 : u.credentials === "omit" && (o.withCredentials = !1), "responseType" in o && (h.blob ? o.responseType = "blob" : h.arrayBuffer && u.headers.get("Content-Type") && u.headers.get("Content-Type").indexOf("application/octet-stream") !== -1 && (o.responseType = "arraybuffer")), t && typeof t.headers == "object" && !(t.headers instanceof c) ? Object.getOwnPropertyNames(t.headers).forEach(function(d) {
|
|
319
|
-
o.setRequestHeader(d, g(t.headers[d]));
|
|
320
|
-
}) : u.headers.forEach(function(d, B) {
|
|
321
|
-
o.setRequestHeader(B, d);
|
|
322
|
-
}), u.signal && (u.signal.addEventListener("abort", T), o.onreadystatechange = function() {
|
|
323
|
-
o.readyState === 4 && u.signal.removeEventListener("abort", T);
|
|
324
|
-
}), o.send(typeof u._bodyInit > "u" ? null : u._bodyInit);
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
return R.polyfill = !0, a.fetch || (a.fetch = R, a.Headers = c, a.Request = w, a.Response = y), l.Headers = c, l.Request = w, l.Response = y, l.fetch = R, l;
|
|
328
|
-
})({});
|
|
329
|
-
})(p), p.fetch.ponyfill = !0, delete p.fetch.polyfill;
|
|
330
|
-
var b = s.fetch ? s : p;
|
|
331
|
-
r = b.fetch, r.default = b.fetch, r.fetch = b.fetch, r.Headers = b.Headers, r.Request = b.Request, r.Response = b.Response, f.exports = r;
|
|
332
|
-
})(j, j.exports);
|
|
333
|
-
var H = j.exports;
|
|
334
|
-
const Z = /* @__PURE__ */ W(H);
|
|
335
|
-
function ee() {
|
|
336
|
-
return typeof fetch > "u" ? Z : fetch;
|
|
15
|
+
async function P() {
|
|
16
|
+
if (typeof fetch > "u") {
|
|
17
|
+
const { default: t } = await import("../browser-ponyfill-lYv-p29A.js").then((e) => e.b);
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
return fetch;
|
|
337
21
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
22
|
+
async function U(...t) {
|
|
23
|
+
if (typeof Headers > "u") {
|
|
24
|
+
const { Headers: e } = await import("../browser-ponyfill-lYv-p29A.js").then((r) => r.b);
|
|
25
|
+
return new e(...t);
|
|
26
|
+
}
|
|
27
|
+
return new Headers(...t);
|
|
340
28
|
}
|
|
341
|
-
const
|
|
29
|
+
const I = {
|
|
342
30
|
responseType: "json"
|
|
343
31
|
};
|
|
344
|
-
class
|
|
32
|
+
class R {
|
|
345
33
|
constructor({
|
|
346
|
-
baseUrl:
|
|
347
|
-
apiKey:
|
|
348
|
-
...
|
|
34
|
+
baseUrl: e,
|
|
35
|
+
apiKey: r,
|
|
36
|
+
...a
|
|
349
37
|
}) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
if (
|
|
38
|
+
n(this, "baseUrl");
|
|
39
|
+
n(this, "apiKey");
|
|
40
|
+
n(this, "config");
|
|
41
|
+
if (e == null && e === "")
|
|
354
42
|
throw new Error("baseUrl is required.");
|
|
355
|
-
if (
|
|
43
|
+
if (r == null && r === "")
|
|
356
44
|
throw new Error("apiKey is required.");
|
|
357
|
-
if (!
|
|
45
|
+
if (!i(e))
|
|
358
46
|
throw new Error("baseUrl must be string.");
|
|
359
|
-
if (!
|
|
47
|
+
if (!i(r))
|
|
360
48
|
throw new Error("apiKey must be string.");
|
|
361
|
-
this.baseUrl =
|
|
362
|
-
...
|
|
363
|
-
...
|
|
49
|
+
this.baseUrl = e, this.apiKey = r, this.config = {
|
|
50
|
+
...I,
|
|
51
|
+
...a
|
|
364
52
|
};
|
|
365
53
|
}
|
|
366
|
-
async request(
|
|
367
|
-
const
|
|
54
|
+
async request(e, r = {}) {
|
|
55
|
+
const a = { ...this.config, ...r }, { requestInit: f, responseType: w } = a, m = await P(), p = this.createUrl(e), l = await this.createFetchOptions(f);
|
|
368
56
|
try {
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
status: v,
|
|
375
|
-
statusText: _,
|
|
376
|
-
headers: O
|
|
57
|
+
const s = await m(p, l), { ok: d, status: o, statusText: c, headers: E } = s, u = {
|
|
58
|
+
data: await s[w](),
|
|
59
|
+
status: o,
|
|
60
|
+
statusText: c,
|
|
61
|
+
headers: E
|
|
377
62
|
};
|
|
378
|
-
if (!
|
|
379
|
-
const
|
|
63
|
+
if (!d) {
|
|
64
|
+
const h = await F(s);
|
|
380
65
|
return await Promise.reject(
|
|
381
|
-
new
|
|
382
|
-
`fetch API response status: ${
|
|
383
|
-
message is \`${
|
|
384
|
-
`${
|
|
385
|
-
|
|
66
|
+
new A(
|
|
67
|
+
`fetch API response status: ${o}${h != null ? `
|
|
68
|
+
message is \`${h}\`` : ""}`,
|
|
69
|
+
`${o} ${c}`,
|
|
70
|
+
u
|
|
386
71
|
)
|
|
387
72
|
);
|
|
388
73
|
}
|
|
389
|
-
return
|
|
390
|
-
} catch (
|
|
391
|
-
return
|
|
74
|
+
return u;
|
|
75
|
+
} catch (s) {
|
|
76
|
+
return s instanceof Error ? await Promise.reject(
|
|
392
77
|
new Error(`Network Error.
|
|
393
|
-
Details: ${
|
|
78
|
+
Details: ${s.message}`)
|
|
394
79
|
) : await Promise.reject(
|
|
395
80
|
new Error(`Network Error.
|
|
396
81
|
Details: Unknown Error`)
|
|
397
82
|
);
|
|
398
83
|
}
|
|
399
84
|
}
|
|
400
|
-
createFetchOptions(
|
|
401
|
-
const
|
|
402
|
-
return
|
|
85
|
+
async createFetchOptions(e) {
|
|
86
|
+
const r = await U(e == null ? void 0 : e.headers);
|
|
87
|
+
return r.has("X-API-KEY") || r.set("X-API-KEY", this.apiKey), { ...e, headers: r };
|
|
403
88
|
}
|
|
404
|
-
createUrl(
|
|
405
|
-
return
|
|
89
|
+
createUrl(e) {
|
|
90
|
+
return i(e) ? new URL(e, this.baseUrl) : e instanceof URL ? new URL(e, this.baseUrl) : new URL(b({ ...e }), this.baseUrl);
|
|
406
91
|
}
|
|
407
|
-
async get(
|
|
408
|
-
return await this.request(
|
|
409
|
-
...
|
|
410
|
-
requestInit: { ...
|
|
92
|
+
async get(e, r = {}) {
|
|
93
|
+
return await this.request(e, {
|
|
94
|
+
...r,
|
|
95
|
+
requestInit: { ...r.requestInit, method: "GET" }
|
|
411
96
|
});
|
|
412
97
|
}
|
|
413
|
-
static isAcmsFetchError(
|
|
414
|
-
return
|
|
98
|
+
static isAcmsFetchError(e) {
|
|
99
|
+
return q(e);
|
|
415
100
|
}
|
|
416
101
|
}
|
|
417
|
-
function
|
|
418
|
-
return new
|
|
102
|
+
function L(...t) {
|
|
103
|
+
return new R(...t);
|
|
419
104
|
}
|
|
420
105
|
export {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
106
|
+
b as acmsPath,
|
|
107
|
+
L as createClient,
|
|
108
|
+
q as isAcmsFetchError
|
|
424
109
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function createFetch(): typeof fetch
|
|
2
|
-
export declare function createHeaders(...args: ConstructorParameters<typeof Headers>): Headers
|
|
1
|
+
export default function createFetch(): Promise<typeof fetch>;
|
|
2
|
+
export declare function createHeaders(...args: ConstructorParameters<typeof Headers>): Promise<Headers>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uidev1116/acms-js-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "a-blog cms JavaScript SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"vitest": "^1.1.3"
|
|
70
70
|
},
|
|
71
71
|
"volta": {
|
|
72
|
-
"node": "20.
|
|
72
|
+
"node": "20.11.1"
|
|
73
73
|
},
|
|
74
74
|
"lint-staged": {
|
|
75
75
|
"*.{js,ts}": "prettier --write"
|