@readyfor/api-client-base 0.243.0-pr986.3fe5563 → 0.244.0-pr981.aa1d2e5
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/apiClientConfigStore.d.mts +2 -1
- package/dist/apiClientConfigStore.d.ts +2 -1
- package/dist/apiClientConfigStore.js +30 -0
- package/dist/apiClientConfigStore.mjs +5 -1
- package/dist/chunk-2ORFVC4H.mjs +14 -0
- package/dist/{chunk-BNXKKSJH.mjs → chunk-E3EKMNYV.mjs} +32 -41
- package/dist/{chunk-RGDL3AEX.mjs → chunk-EYKOWAWU.mjs} +1 -1
- package/dist/{chunk-5ZI7SAUQ.mjs → chunk-T2LQ4KT5.mjs} +1 -1
- package/dist/chunk-X4CTIU5H.mjs +37 -0
- package/dist/chunk-Z2IX5DM2.mjs +21 -0
- package/dist/fetcher.js +52 -40
- package/dist/fetcher.mjs +5 -3
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +60 -40
- package/dist/index.mjs +14 -7
- package/dist/react/ApiClientConfigProvider.mjs +4 -2
- package/dist/react/index.js +26 -30
- package/dist/react/index.mjs +5 -3
- package/dist/react/useApiClientConfig.js +26 -30
- package/dist/react/useApiClientConfig.mjs +5 -3
- package/dist/requestUrl.mjs +4 -2
- package/dist/utils/requestInit.d.mts +9 -0
- package/dist/utils/requestInit.d.ts +9 -0
- package/dist/utils/requestInit.js +53 -0
- package/dist/utils/requestInit.mjs +7 -0
- package/package.json +5 -2
- package/dist/chunk-472P3XVV.mjs +0 -13
- package/dist/chunk-JOSDYCJN.mjs +0 -62
- package/dist/requestUrl.test.d.mts +0 -2
- package/dist/requestUrl.test.d.ts +0 -2
- package/dist/requestUrl.test.js +0 -171
- package/dist/requestUrl.test.mjs +0 -114
- package/dist/utils/headersInit.test.d.mts +0 -2
- package/dist/utils/headersInit.test.d.ts +0 -2
- package/dist/utils/headersInit.test.js +0 -81
- package/dist/utils/headersInit.test.mjs +0 -66
package/dist/requestUrl.test.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__internal__requestUrl
|
|
3
|
-
} from "./chunk-RGDL3AEX.mjs";
|
|
4
|
-
import {
|
|
5
|
-
store
|
|
6
|
-
} from "./chunk-472P3XVV.mjs";
|
|
7
|
-
import "./chunk-3SEO7S3Q.mjs";
|
|
8
|
-
|
|
9
|
-
// src/requestUrl.test.ts
|
|
10
|
-
var config = {
|
|
11
|
-
hostName: (url) => url.startsWith("/api/v1") ? "https://v1host.example.com" : "https://v2host.example.com"
|
|
12
|
-
};
|
|
13
|
-
describe("__internal_requestUrl", () => {
|
|
14
|
-
describe("path\u306E\u307F\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u6642", () => {
|
|
15
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u6642", () => {
|
|
16
|
-
test("path\u304C\u305D\u306E\u307E\u307E\u8FD4\u3055\u308C\u308B", () => {
|
|
17
|
-
store.setState(() => ({}));
|
|
18
|
-
expect(__internal__requestUrl("/api/v1/my/fundraising/header")).toEqual(
|
|
19
|
-
"/api/v1/my/fundraising/header"
|
|
20
|
-
);
|
|
21
|
-
expect(__internal__requestUrl("/api/v2/token")).toEqual(
|
|
22
|
-
"/api/v2/token"
|
|
23
|
-
);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u6642", () => {
|
|
27
|
-
test("hostUrl\u4ED8\u304D\u306EURL\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
28
|
-
store.setState(() => config);
|
|
29
|
-
expect(__internal__requestUrl("/api/v1/my/fundraising/header")).toEqual(
|
|
30
|
-
"https://v1host.example.com/api/v1/my/fundraising/header"
|
|
31
|
-
);
|
|
32
|
-
expect(__internal__requestUrl("/api/v2/token")).toEqual(
|
|
33
|
-
"https://v2host.example.com/api/v2/token"
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe("path\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3042\u308B\u6642", () => {
|
|
39
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u6642", () => {
|
|
40
|
-
test("path\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u7F6E\u304D\u63DB\u3048\u3089\u308C\u305Fpath\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
41
|
-
store.setState(() => ({}));
|
|
42
|
-
expect(
|
|
43
|
-
__internal__requestUrl(
|
|
44
|
-
"/api/v1/my/fundraising/projects/{project_id}",
|
|
45
|
-
{
|
|
46
|
-
project_id: 12345
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
).toEqual("/api/v1/my/fundraising/projects/12345");
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u6642", () => {
|
|
53
|
-
test("path\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u7F6E\u304D\u63DB\u3048\u3089\u308C\u305FURL\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
54
|
-
store.setState(() => config);
|
|
55
|
-
expect(
|
|
56
|
-
__internal__requestUrl(
|
|
57
|
-
"/api/v1/my/fundraising/projects/{project_id}",
|
|
58
|
-
{
|
|
59
|
-
project_id: 12345
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
).toEqual(
|
|
63
|
-
"https://v1host.example.com/api/v1/my/fundraising/projects/12345"
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
describe("query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3042\u308B\u6642", () => {
|
|
69
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u6642", () => {
|
|
70
|
-
test("query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3064\u3051\u3089\u308C\u305Fpath\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
71
|
-
store.setState(() => ({}));
|
|
72
|
-
expect(
|
|
73
|
-
__internal__requestUrl(
|
|
74
|
-
"/api/v1/my/messages/tree",
|
|
75
|
-
{},
|
|
76
|
-
{ follow_id: 12345 }
|
|
77
|
-
)
|
|
78
|
-
).toEqual("/api/v1/my/messages/tree?follow_id=12345");
|
|
79
|
-
expect(
|
|
80
|
-
__internal__requestUrl(
|
|
81
|
-
"/api/v2/contributions/project_info",
|
|
82
|
-
{},
|
|
83
|
-
{ project_id: "12345" }
|
|
84
|
-
)
|
|
85
|
-
).toEqual("/api/v2/contributions/project_info?project_id=12345");
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u6642", () => {
|
|
89
|
-
test("query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3064\u3051\u3089\u308C\u305FURL\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
90
|
-
store.setState(() => config);
|
|
91
|
-
expect(
|
|
92
|
-
__internal__requestUrl(
|
|
93
|
-
"/api/v1/my/messages/tree",
|
|
94
|
-
{},
|
|
95
|
-
{ follow_id: 12345 }
|
|
96
|
-
)
|
|
97
|
-
).toEqual(
|
|
98
|
-
"https://v1host.example.com/api/v1/my/messages/tree?follow_id=12345"
|
|
99
|
-
);
|
|
100
|
-
expect(
|
|
101
|
-
__internal__requestUrl(
|
|
102
|
-
"/api/v2/contributions/project_info",
|
|
103
|
-
{},
|
|
104
|
-
{ project_id: "12345" }
|
|
105
|
-
)
|
|
106
|
-
).toEqual(
|
|
107
|
-
"https://v2host.example.com/api/v2/contributions/project_info?project_id=12345"
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
describe("path\u30D1\u30E9\u30E1\u30FC\u30BF\u3068query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3042\u308B\u6642", () => {
|
|
113
|
-
});
|
|
114
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// src/utils/headersInit.ts
|
|
4
|
-
var mergeHeadersInit = (baseHeadersInit, overrideHeadersInit) => {
|
|
5
|
-
const base = new Headers(baseHeadersInit);
|
|
6
|
-
const override = new Headers(overrideHeadersInit);
|
|
7
|
-
const setCookies = base.getSetCookie().concat(override.getSetCookie());
|
|
8
|
-
base.delete("set-cookie");
|
|
9
|
-
override.delete("set-cookie");
|
|
10
|
-
const mergedHeaders = new Headers({
|
|
11
|
-
...Object.fromEntries(base),
|
|
12
|
-
...Object.fromEntries(override)
|
|
13
|
-
});
|
|
14
|
-
setCookies.forEach((cookie) => {
|
|
15
|
-
mergedHeaders.append("set-cookie", cookie);
|
|
16
|
-
});
|
|
17
|
-
return mergedHeaders;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// src/utils/headersInit.test.ts
|
|
21
|
-
describe("mergeHeadersInit", () => {
|
|
22
|
-
test("Set-Cookie\u4EE5\u5916\u306E\u30D8\u30C3\u30C0\u30FC\u306F\u5F15\u6570\u3067\u4E0A\u66F8\u304D\u3055\u308C\u3001Set-Cookie\u30D8\u30C3\u30C0\u30FC\u306F\u4E21\u65B9\u306E\u3082\u306E\u3092\u7D50\u5408\u3059\u308B", () => {
|
|
23
|
-
const base = {
|
|
24
|
-
"Content-Type": "application/json",
|
|
25
|
-
Authorization: "Basic token",
|
|
26
|
-
"Set-Cookie": "base=value",
|
|
27
|
-
"X-Test": "base value"
|
|
28
|
-
};
|
|
29
|
-
const override = {
|
|
30
|
-
Authorization: "Bearer token",
|
|
31
|
-
"X-Test": "override value",
|
|
32
|
-
"Set-Cookie": "override=value"
|
|
33
|
-
};
|
|
34
|
-
const result = new Headers(mergeHeadersInit(base, override));
|
|
35
|
-
expect([...result]).toEqual([
|
|
36
|
-
["authorization", "Bearer token"],
|
|
37
|
-
["content-type", "application/json"],
|
|
38
|
-
["set-cookie", "base=value"],
|
|
39
|
-
["set-cookie", "override=value"],
|
|
40
|
-
["x-test", "override value"]
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
describe("\u5185\u90E8\u3067\u5229\u7528\u3057\u3066\u3044\u308BHeaders\u306E\u56DE\u5E30\u30C6\u30B9\u30C8", () => {
|
|
44
|
-
test("Set-Cookie\u30D8\u30C3\u30C0\u30FC\u306F\u30AB\u30F3\u30DE\u3067\u7D50\u5408\u3055\u308C\u305A\u3001\u305D\u308C\u4EE5\u5916\u306E\u30D8\u30C3\u30C0\u30FC\u306F\u30AB\u30F3\u30DE\u3067\u7D50\u5408\u3055\u308C\u308B", () => {
|
|
45
|
-
expect([
|
|
46
|
-
...new Headers([
|
|
47
|
-
["X-Test", "test1"],
|
|
48
|
-
["X-Test", "test2"],
|
|
49
|
-
["X-Test", "test3"],
|
|
50
|
-
["Accept", "text/html"],
|
|
51
|
-
["Accept", "application/json"],
|
|
52
|
-
["Accept", "application/xml"],
|
|
53
|
-
["Set-Cookie", "a=1"],
|
|
54
|
-
["Set-Cookie", "b=2"],
|
|
55
|
-
["Set-Cookie", "c=3"]
|
|
56
|
-
])
|
|
57
|
-
]).toEqual([
|
|
58
|
-
["accept", "text/html, application/json, application/xml"],
|
|
59
|
-
["set-cookie", "a=1"],
|
|
60
|
-
["set-cookie", "b=2"],
|
|
61
|
-
["set-cookie", "c=3"],
|
|
62
|
-
["x-test", "test1, test2, test3"]
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
test("\u30D8\u30C3\u30C0\u30FC\u306F\u5C0F\u6587\u5B57\u306B\u6B63\u898F\u5316\u3055\u308C\u308B", () => {
|
|
66
|
-
expect([
|
|
67
|
-
...new Headers([
|
|
68
|
-
["ACCEPT", "text/html"],
|
|
69
|
-
["accept", "application/json"],
|
|
70
|
-
["Set-Cookie", "a=1"],
|
|
71
|
-
["aCcePT", "application/xml"],
|
|
72
|
-
["set-cookie", "b=2"]
|
|
73
|
-
])
|
|
74
|
-
]).toEqual([
|
|
75
|
-
["accept", "text/html, application/json, application/xml"],
|
|
76
|
-
["set-cookie", "a=1"],
|
|
77
|
-
["set-cookie", "b=2"]
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
mergeHeadersInit
|
|
3
|
-
} from "../chunk-GIFAQKW5.mjs";
|
|
4
|
-
|
|
5
|
-
// src/utils/headersInit.test.ts
|
|
6
|
-
describe("mergeHeadersInit", () => {
|
|
7
|
-
test("Set-Cookie\u4EE5\u5916\u306E\u30D8\u30C3\u30C0\u30FC\u306F\u5F15\u6570\u3067\u4E0A\u66F8\u304D\u3055\u308C\u3001Set-Cookie\u30D8\u30C3\u30C0\u30FC\u306F\u4E21\u65B9\u306E\u3082\u306E\u3092\u7D50\u5408\u3059\u308B", () => {
|
|
8
|
-
const base = {
|
|
9
|
-
"Content-Type": "application/json",
|
|
10
|
-
Authorization: "Basic token",
|
|
11
|
-
"Set-Cookie": "base=value",
|
|
12
|
-
"X-Test": "base value"
|
|
13
|
-
};
|
|
14
|
-
const override = {
|
|
15
|
-
Authorization: "Bearer token",
|
|
16
|
-
"X-Test": "override value",
|
|
17
|
-
"Set-Cookie": "override=value"
|
|
18
|
-
};
|
|
19
|
-
const result = new Headers(mergeHeadersInit(base, override));
|
|
20
|
-
expect([...result]).toEqual([
|
|
21
|
-
["authorization", "Bearer token"],
|
|
22
|
-
["content-type", "application/json"],
|
|
23
|
-
["set-cookie", "base=value"],
|
|
24
|
-
["set-cookie", "override=value"],
|
|
25
|
-
["x-test", "override value"]
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
28
|
-
describe("\u5185\u90E8\u3067\u5229\u7528\u3057\u3066\u3044\u308BHeaders\u306E\u56DE\u5E30\u30C6\u30B9\u30C8", () => {
|
|
29
|
-
test("Set-Cookie\u30D8\u30C3\u30C0\u30FC\u306F\u30AB\u30F3\u30DE\u3067\u7D50\u5408\u3055\u308C\u305A\u3001\u305D\u308C\u4EE5\u5916\u306E\u30D8\u30C3\u30C0\u30FC\u306F\u30AB\u30F3\u30DE\u3067\u7D50\u5408\u3055\u308C\u308B", () => {
|
|
30
|
-
expect([
|
|
31
|
-
...new Headers([
|
|
32
|
-
["X-Test", "test1"],
|
|
33
|
-
["X-Test", "test2"],
|
|
34
|
-
["X-Test", "test3"],
|
|
35
|
-
["Accept", "text/html"],
|
|
36
|
-
["Accept", "application/json"],
|
|
37
|
-
["Accept", "application/xml"],
|
|
38
|
-
["Set-Cookie", "a=1"],
|
|
39
|
-
["Set-Cookie", "b=2"],
|
|
40
|
-
["Set-Cookie", "c=3"]
|
|
41
|
-
])
|
|
42
|
-
]).toEqual([
|
|
43
|
-
["accept", "text/html, application/json, application/xml"],
|
|
44
|
-
["set-cookie", "a=1"],
|
|
45
|
-
["set-cookie", "b=2"],
|
|
46
|
-
["set-cookie", "c=3"],
|
|
47
|
-
["x-test", "test1, test2, test3"]
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
test("\u30D8\u30C3\u30C0\u30FC\u306F\u5C0F\u6587\u5B57\u306B\u6B63\u898F\u5316\u3055\u308C\u308B", () => {
|
|
51
|
-
expect([
|
|
52
|
-
...new Headers([
|
|
53
|
-
["ACCEPT", "text/html"],
|
|
54
|
-
["accept", "application/json"],
|
|
55
|
-
["Set-Cookie", "a=1"],
|
|
56
|
-
["aCcePT", "application/xml"],
|
|
57
|
-
["set-cookie", "b=2"]
|
|
58
|
-
])
|
|
59
|
-
]).toEqual([
|
|
60
|
-
["accept", "text/html, application/json, application/xml"],
|
|
61
|
-
["set-cookie", "a=1"],
|
|
62
|
-
["set-cookie", "b=2"]
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|