qstd 0.3.26 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +218 -0
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +217 -1
- package/dist/server/index.cjs +220 -2
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +219 -3
- package/dist/shared/api/domain.d.ts +181 -0
- package/dist/shared/api/domain.d.ts.map +1 -0
- package/dist/shared/api/fns.d.ts +140 -0
- package/dist/shared/api/fns.d.ts.map +1 -0
- package/dist/shared/api/index.d.ts +56 -0
- package/dist/shared/api/index.d.ts.map +1 -0
- package/dist/shared/api/types.d.ts +102 -0
- package/dist/shared/api/types.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/client/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var dateFns = require('date-fns');
|
|
4
4
|
|
|
5
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
5
6
|
var __defProp = Object.defineProperty;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
8
|
for (var name in all)
|
|
@@ -626,6 +627,222 @@ var label = (name) => ({
|
|
|
626
627
|
}
|
|
627
628
|
});
|
|
628
629
|
|
|
630
|
+
// src/shared/api/index.ts
|
|
631
|
+
var api_exports = {};
|
|
632
|
+
__export(api_exports, {
|
|
633
|
+
RestError: () => RestError,
|
|
634
|
+
configure: () => configure,
|
|
635
|
+
get: () => get,
|
|
636
|
+
patch: () => patch,
|
|
637
|
+
post: () => post,
|
|
638
|
+
put: () => put,
|
|
639
|
+
remove: () => remove
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// src/shared/api/types.ts
|
|
643
|
+
var RestError = class extends Error {
|
|
644
|
+
status;
|
|
645
|
+
body;
|
|
646
|
+
constructor(props) {
|
|
647
|
+
super(`REST ${props.status}: ${props.body}`);
|
|
648
|
+
this.name = "RestError";
|
|
649
|
+
this.status = props.status;
|
|
650
|
+
this.body = props.body;
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
// src/shared/api/fns.ts
|
|
655
|
+
var isDev = () => {
|
|
656
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV) {
|
|
657
|
+
return process.env.NODE_ENV !== "production";
|
|
658
|
+
}
|
|
659
|
+
if (typeof ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) }) !== "undefined" && undefined?.DEV !== void 0) {
|
|
660
|
+
return undefined.DEV;
|
|
661
|
+
}
|
|
662
|
+
return false;
|
|
663
|
+
};
|
|
664
|
+
var isAbsolute = (path) => path.startsWith("http");
|
|
665
|
+
var prepareUrl = (path, props) => {
|
|
666
|
+
if (isDev() && !isAbsolute(path) && path.includes("?") && path.split("?")[1]?.split("#")[0]) {
|
|
667
|
+
console.warn(
|
|
668
|
+
`[api] Query params detected in path string. Prefer using the 'params' option instead: Api.get("/path", { params: { ... } }). Path: ${path}`
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
const base = isAbsolute(path) ? "" : props.baseUrl;
|
|
672
|
+
let url = `${base}${path}`;
|
|
673
|
+
if (props.params) {
|
|
674
|
+
const searchParams = new URLSearchParams();
|
|
675
|
+
for (const [key, value] of Object.entries(props.params)) {
|
|
676
|
+
if (value != null) searchParams.set(key, String(value));
|
|
677
|
+
}
|
|
678
|
+
const qs = searchParams.toString();
|
|
679
|
+
if (qs) url += (url.includes("?") ? "&" : "?") + qs;
|
|
680
|
+
}
|
|
681
|
+
return url;
|
|
682
|
+
};
|
|
683
|
+
var prepareHeaders = async (props) => {
|
|
684
|
+
const { defaults, headersOption, input, body } = props;
|
|
685
|
+
if (headersOption === false) return void 0;
|
|
686
|
+
const headers = { ...defaults };
|
|
687
|
+
if (body instanceof FormData) ; else if (body instanceof Blob && body.type) {
|
|
688
|
+
headers["Content-Type"] = body.type;
|
|
689
|
+
} else if (input === "json") {
|
|
690
|
+
headers["Content-Type"] = "application/json";
|
|
691
|
+
} else if (input === "text") {
|
|
692
|
+
headers["Content-Type"] = "text/plain";
|
|
693
|
+
}
|
|
694
|
+
if (headersOption === void 0 || headersOption === true) {
|
|
695
|
+
return headers;
|
|
696
|
+
}
|
|
697
|
+
return await headersOption(headers);
|
|
698
|
+
};
|
|
699
|
+
var prepareBody = (body, input) => {
|
|
700
|
+
if (body === void 0) return void 0;
|
|
701
|
+
if (body instanceof FormData) return body;
|
|
702
|
+
if (body instanceof Blob) return body;
|
|
703
|
+
if (input === "json") return JSON.stringify(body);
|
|
704
|
+
if (input === "text") {
|
|
705
|
+
if (typeof body === "string") return body;
|
|
706
|
+
throw new Error("[api] input: 'text' requires a string body");
|
|
707
|
+
}
|
|
708
|
+
if (input === "form") {
|
|
709
|
+
const fd = new FormData();
|
|
710
|
+
for (const [k, v] of Object.entries(body)) {
|
|
711
|
+
fd.append(k, v);
|
|
712
|
+
}
|
|
713
|
+
return fd;
|
|
714
|
+
}
|
|
715
|
+
return body;
|
|
716
|
+
};
|
|
717
|
+
var parseResponse = async (response, output, onProgress) => {
|
|
718
|
+
const out = output ?? "json";
|
|
719
|
+
if (out === "stream") {
|
|
720
|
+
return response.body;
|
|
721
|
+
}
|
|
722
|
+
if (onProgress && response.body) {
|
|
723
|
+
const total = Number(response.headers.get("Content-Length")) || 0;
|
|
724
|
+
let loaded = 0;
|
|
725
|
+
const reader = response.body.getReader();
|
|
726
|
+
const chunks = [];
|
|
727
|
+
while (true) {
|
|
728
|
+
const { done, value } = await reader.read();
|
|
729
|
+
if (done) break;
|
|
730
|
+
chunks.push(value);
|
|
731
|
+
loaded += value.length;
|
|
732
|
+
onProgress({
|
|
733
|
+
loaded,
|
|
734
|
+
total,
|
|
735
|
+
percent: total ? Math.round(loaded / total * 100) : 0
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
const blob = new Blob(chunks);
|
|
739
|
+
if (out === "blob") return blob;
|
|
740
|
+
if (out === "arrayBuffer")
|
|
741
|
+
return await blob.arrayBuffer();
|
|
742
|
+
if (out === "text") return await blob.text();
|
|
743
|
+
const text2 = await blob.text();
|
|
744
|
+
return text2 ? JSON.parse(text2) : null;
|
|
745
|
+
}
|
|
746
|
+
if (out === "blob")
|
|
747
|
+
return await response.blob();
|
|
748
|
+
if (out === "arrayBuffer")
|
|
749
|
+
return await response.arrayBuffer();
|
|
750
|
+
if (out === "text")
|
|
751
|
+
return await response.text();
|
|
752
|
+
const text = await response.text();
|
|
753
|
+
return text ? JSON.parse(text) : null;
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
// src/shared/api/domain.ts
|
|
757
|
+
var config = { baseUrl: "" };
|
|
758
|
+
var configure = (c) => {
|
|
759
|
+
config = c;
|
|
760
|
+
};
|
|
761
|
+
var configHeaders = async () => {
|
|
762
|
+
if (!config.headers) return {};
|
|
763
|
+
return typeof config.headers === "function" ? await config.headers() : config.headers;
|
|
764
|
+
};
|
|
765
|
+
var request = async (method, path, options, defaultInput) => {
|
|
766
|
+
const opts = options;
|
|
767
|
+
const url = prepareUrl(path, {
|
|
768
|
+
baseUrl: config.baseUrl,
|
|
769
|
+
...opts?.params ? { params: opts.params } : {}
|
|
770
|
+
});
|
|
771
|
+
const rawBody = opts?.body;
|
|
772
|
+
const isAutoDetect = rawBody instanceof FormData || rawBody instanceof Blob;
|
|
773
|
+
const input = opts && "input" in opts && opts.input !== void 0 ? opts.input : isAutoDetect ? void 0 : defaultInput;
|
|
774
|
+
const headersOption = opts?.headers;
|
|
775
|
+
const isExternal = isAbsolute(path);
|
|
776
|
+
const defaults = headersOption !== false && !isExternal ? await configHeaders() : {};
|
|
777
|
+
const headers = await prepareHeaders({
|
|
778
|
+
defaults,
|
|
779
|
+
headersOption,
|
|
780
|
+
input,
|
|
781
|
+
body: rawBody
|
|
782
|
+
});
|
|
783
|
+
const body = prepareBody(rawBody, input);
|
|
784
|
+
const response = await fetch(url, {
|
|
785
|
+
method,
|
|
786
|
+
...headers && { headers },
|
|
787
|
+
...body !== void 0 && { body },
|
|
788
|
+
...opts?.signal && { signal: opts.signal }
|
|
789
|
+
});
|
|
790
|
+
if (!response.ok) {
|
|
791
|
+
const error3 = new RestError({
|
|
792
|
+
status: response.status,
|
|
793
|
+
body: await response.text()
|
|
794
|
+
});
|
|
795
|
+
if (opts?.onError) return opts.onError(error3);
|
|
796
|
+
throw error3;
|
|
797
|
+
}
|
|
798
|
+
const data = await parseResponse(
|
|
799
|
+
response,
|
|
800
|
+
opts?.output,
|
|
801
|
+
opts?.onProgress
|
|
802
|
+
);
|
|
803
|
+
return opts?.onSuccess ? opts.onSuccess(data) : data;
|
|
804
|
+
};
|
|
805
|
+
function get(path, opts) {
|
|
806
|
+
return request(
|
|
807
|
+
"GET",
|
|
808
|
+
path,
|
|
809
|
+
opts
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
function post(path, body, opts) {
|
|
813
|
+
return request(
|
|
814
|
+
"POST",
|
|
815
|
+
path,
|
|
816
|
+
{ ...opts, body },
|
|
817
|
+
"json"
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
function put(path, body, opts) {
|
|
821
|
+
return request(
|
|
822
|
+
"PUT",
|
|
823
|
+
path,
|
|
824
|
+
{ ...opts, body },
|
|
825
|
+
"json"
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
function patch(path, body, opts) {
|
|
829
|
+
return request(
|
|
830
|
+
"PATCH",
|
|
831
|
+
path,
|
|
832
|
+
{ ...opts, body },
|
|
833
|
+
"json"
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
function remove(path, body, opts) {
|
|
837
|
+
const defaultInput = body !== void 0 ? "json" : void 0;
|
|
838
|
+
return request(
|
|
839
|
+
"DELETE",
|
|
840
|
+
path,
|
|
841
|
+
{ ...opts, body },
|
|
842
|
+
defaultInput
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
|
|
629
846
|
// src/client/haptics.ts
|
|
630
847
|
var haptics_exports = {};
|
|
631
848
|
__export(haptics_exports, {
|
|
@@ -718,6 +935,7 @@ var copy = async (text) => {
|
|
|
718
935
|
}
|
|
719
936
|
};
|
|
720
937
|
|
|
938
|
+
exports.Api = api_exports;
|
|
721
939
|
exports.Dict = dict_exports;
|
|
722
940
|
exports.Dom = dom_exports;
|
|
723
941
|
exports.Flow = flow_exports;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * as Time from "../shared/time";
|
|
|
7
7
|
export * as Flow from "../shared/flow";
|
|
8
8
|
export * as Random from "../shared/random";
|
|
9
9
|
export * as Log from "../shared/log";
|
|
10
|
+
export * as Api from "../shared/api";
|
|
10
11
|
export * as Haptics from "./haptics";
|
|
11
12
|
export * as Dom from "./dom";
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAGrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAGrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC"}
|
package/dist/client/index.js
CHANGED
|
@@ -624,6 +624,222 @@ var label = (name) => ({
|
|
|
624
624
|
}
|
|
625
625
|
});
|
|
626
626
|
|
|
627
|
+
// src/shared/api/index.ts
|
|
628
|
+
var api_exports = {};
|
|
629
|
+
__export(api_exports, {
|
|
630
|
+
RestError: () => RestError,
|
|
631
|
+
configure: () => configure,
|
|
632
|
+
get: () => get,
|
|
633
|
+
patch: () => patch,
|
|
634
|
+
post: () => post,
|
|
635
|
+
put: () => put,
|
|
636
|
+
remove: () => remove
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// src/shared/api/types.ts
|
|
640
|
+
var RestError = class extends Error {
|
|
641
|
+
status;
|
|
642
|
+
body;
|
|
643
|
+
constructor(props) {
|
|
644
|
+
super(`REST ${props.status}: ${props.body}`);
|
|
645
|
+
this.name = "RestError";
|
|
646
|
+
this.status = props.status;
|
|
647
|
+
this.body = props.body;
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
// src/shared/api/fns.ts
|
|
652
|
+
var isDev = () => {
|
|
653
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV) {
|
|
654
|
+
return process.env.NODE_ENV !== "production";
|
|
655
|
+
}
|
|
656
|
+
if (typeof import.meta !== "undefined" && import.meta.env?.DEV !== void 0) {
|
|
657
|
+
return import.meta.env.DEV;
|
|
658
|
+
}
|
|
659
|
+
return false;
|
|
660
|
+
};
|
|
661
|
+
var isAbsolute = (path) => path.startsWith("http");
|
|
662
|
+
var prepareUrl = (path, props) => {
|
|
663
|
+
if (isDev() && !isAbsolute(path) && path.includes("?") && path.split("?")[1]?.split("#")[0]) {
|
|
664
|
+
console.warn(
|
|
665
|
+
`[api] Query params detected in path string. Prefer using the 'params' option instead: Api.get("/path", { params: { ... } }). Path: ${path}`
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
const base = isAbsolute(path) ? "" : props.baseUrl;
|
|
669
|
+
let url = `${base}${path}`;
|
|
670
|
+
if (props.params) {
|
|
671
|
+
const searchParams = new URLSearchParams();
|
|
672
|
+
for (const [key, value] of Object.entries(props.params)) {
|
|
673
|
+
if (value != null) searchParams.set(key, String(value));
|
|
674
|
+
}
|
|
675
|
+
const qs = searchParams.toString();
|
|
676
|
+
if (qs) url += (url.includes("?") ? "&" : "?") + qs;
|
|
677
|
+
}
|
|
678
|
+
return url;
|
|
679
|
+
};
|
|
680
|
+
var prepareHeaders = async (props) => {
|
|
681
|
+
const { defaults, headersOption, input, body } = props;
|
|
682
|
+
if (headersOption === false) return void 0;
|
|
683
|
+
const headers = { ...defaults };
|
|
684
|
+
if (body instanceof FormData) ; else if (body instanceof Blob && body.type) {
|
|
685
|
+
headers["Content-Type"] = body.type;
|
|
686
|
+
} else if (input === "json") {
|
|
687
|
+
headers["Content-Type"] = "application/json";
|
|
688
|
+
} else if (input === "text") {
|
|
689
|
+
headers["Content-Type"] = "text/plain";
|
|
690
|
+
}
|
|
691
|
+
if (headersOption === void 0 || headersOption === true) {
|
|
692
|
+
return headers;
|
|
693
|
+
}
|
|
694
|
+
return await headersOption(headers);
|
|
695
|
+
};
|
|
696
|
+
var prepareBody = (body, input) => {
|
|
697
|
+
if (body === void 0) return void 0;
|
|
698
|
+
if (body instanceof FormData) return body;
|
|
699
|
+
if (body instanceof Blob) return body;
|
|
700
|
+
if (input === "json") return JSON.stringify(body);
|
|
701
|
+
if (input === "text") {
|
|
702
|
+
if (typeof body === "string") return body;
|
|
703
|
+
throw new Error("[api] input: 'text' requires a string body");
|
|
704
|
+
}
|
|
705
|
+
if (input === "form") {
|
|
706
|
+
const fd = new FormData();
|
|
707
|
+
for (const [k, v] of Object.entries(body)) {
|
|
708
|
+
fd.append(k, v);
|
|
709
|
+
}
|
|
710
|
+
return fd;
|
|
711
|
+
}
|
|
712
|
+
return body;
|
|
713
|
+
};
|
|
714
|
+
var parseResponse = async (response, output, onProgress) => {
|
|
715
|
+
const out = output ?? "json";
|
|
716
|
+
if (out === "stream") {
|
|
717
|
+
return response.body;
|
|
718
|
+
}
|
|
719
|
+
if (onProgress && response.body) {
|
|
720
|
+
const total = Number(response.headers.get("Content-Length")) || 0;
|
|
721
|
+
let loaded = 0;
|
|
722
|
+
const reader = response.body.getReader();
|
|
723
|
+
const chunks = [];
|
|
724
|
+
while (true) {
|
|
725
|
+
const { done, value } = await reader.read();
|
|
726
|
+
if (done) break;
|
|
727
|
+
chunks.push(value);
|
|
728
|
+
loaded += value.length;
|
|
729
|
+
onProgress({
|
|
730
|
+
loaded,
|
|
731
|
+
total,
|
|
732
|
+
percent: total ? Math.round(loaded / total * 100) : 0
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
const blob = new Blob(chunks);
|
|
736
|
+
if (out === "blob") return blob;
|
|
737
|
+
if (out === "arrayBuffer")
|
|
738
|
+
return await blob.arrayBuffer();
|
|
739
|
+
if (out === "text") return await blob.text();
|
|
740
|
+
const text2 = await blob.text();
|
|
741
|
+
return text2 ? JSON.parse(text2) : null;
|
|
742
|
+
}
|
|
743
|
+
if (out === "blob")
|
|
744
|
+
return await response.blob();
|
|
745
|
+
if (out === "arrayBuffer")
|
|
746
|
+
return await response.arrayBuffer();
|
|
747
|
+
if (out === "text")
|
|
748
|
+
return await response.text();
|
|
749
|
+
const text = await response.text();
|
|
750
|
+
return text ? JSON.parse(text) : null;
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// src/shared/api/domain.ts
|
|
754
|
+
var config = { baseUrl: "" };
|
|
755
|
+
var configure = (c) => {
|
|
756
|
+
config = c;
|
|
757
|
+
};
|
|
758
|
+
var configHeaders = async () => {
|
|
759
|
+
if (!config.headers) return {};
|
|
760
|
+
return typeof config.headers === "function" ? await config.headers() : config.headers;
|
|
761
|
+
};
|
|
762
|
+
var request = async (method, path, options, defaultInput) => {
|
|
763
|
+
const opts = options;
|
|
764
|
+
const url = prepareUrl(path, {
|
|
765
|
+
baseUrl: config.baseUrl,
|
|
766
|
+
...opts?.params ? { params: opts.params } : {}
|
|
767
|
+
});
|
|
768
|
+
const rawBody = opts?.body;
|
|
769
|
+
const isAutoDetect = rawBody instanceof FormData || rawBody instanceof Blob;
|
|
770
|
+
const input = opts && "input" in opts && opts.input !== void 0 ? opts.input : isAutoDetect ? void 0 : defaultInput;
|
|
771
|
+
const headersOption = opts?.headers;
|
|
772
|
+
const isExternal = isAbsolute(path);
|
|
773
|
+
const defaults = headersOption !== false && !isExternal ? await configHeaders() : {};
|
|
774
|
+
const headers = await prepareHeaders({
|
|
775
|
+
defaults,
|
|
776
|
+
headersOption,
|
|
777
|
+
input,
|
|
778
|
+
body: rawBody
|
|
779
|
+
});
|
|
780
|
+
const body = prepareBody(rawBody, input);
|
|
781
|
+
const response = await fetch(url, {
|
|
782
|
+
method,
|
|
783
|
+
...headers && { headers },
|
|
784
|
+
...body !== void 0 && { body },
|
|
785
|
+
...opts?.signal && { signal: opts.signal }
|
|
786
|
+
});
|
|
787
|
+
if (!response.ok) {
|
|
788
|
+
const error3 = new RestError({
|
|
789
|
+
status: response.status,
|
|
790
|
+
body: await response.text()
|
|
791
|
+
});
|
|
792
|
+
if (opts?.onError) return opts.onError(error3);
|
|
793
|
+
throw error3;
|
|
794
|
+
}
|
|
795
|
+
const data = await parseResponse(
|
|
796
|
+
response,
|
|
797
|
+
opts?.output,
|
|
798
|
+
opts?.onProgress
|
|
799
|
+
);
|
|
800
|
+
return opts?.onSuccess ? opts.onSuccess(data) : data;
|
|
801
|
+
};
|
|
802
|
+
function get(path, opts) {
|
|
803
|
+
return request(
|
|
804
|
+
"GET",
|
|
805
|
+
path,
|
|
806
|
+
opts
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
function post(path, body, opts) {
|
|
810
|
+
return request(
|
|
811
|
+
"POST",
|
|
812
|
+
path,
|
|
813
|
+
{ ...opts, body },
|
|
814
|
+
"json"
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
function put(path, body, opts) {
|
|
818
|
+
return request(
|
|
819
|
+
"PUT",
|
|
820
|
+
path,
|
|
821
|
+
{ ...opts, body },
|
|
822
|
+
"json"
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
function patch(path, body, opts) {
|
|
826
|
+
return request(
|
|
827
|
+
"PATCH",
|
|
828
|
+
path,
|
|
829
|
+
{ ...opts, body },
|
|
830
|
+
"json"
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
function remove(path, body, opts) {
|
|
834
|
+
const defaultInput = body !== void 0 ? "json" : void 0;
|
|
835
|
+
return request(
|
|
836
|
+
"DELETE",
|
|
837
|
+
path,
|
|
838
|
+
{ ...opts, body },
|
|
839
|
+
defaultInput
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
|
|
627
843
|
// src/client/haptics.ts
|
|
628
844
|
var haptics_exports = {};
|
|
629
845
|
__export(haptics_exports, {
|
|
@@ -716,4 +932,4 @@ var copy = async (text) => {
|
|
|
716
932
|
}
|
|
717
933
|
};
|
|
718
934
|
|
|
719
|
-
export { dict_exports as Dict, dom_exports as Dom, flow_exports as Flow, haptics_exports as Haptics, int_exports as Int, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
|
|
935
|
+
export { api_exports as Api, dict_exports as Dict, dom_exports as Dom, flow_exports as Flow, haptics_exports as Haptics, int_exports as Int, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, str_exports as Str, time_exports as Time };
|