@readyfor/api-client-base 0.242.1 → 0.243.0-pr981.418eff9
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-GIFAQKW5.mjs +20 -0
- 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/headersInit.d.mts +17 -0
- package/dist/utils/headersInit.d.ts +17 -0
- package/dist/utils/headersInit.js +44 -0
- package/dist/utils/headersInit.mjs +6 -0
- 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 +12 -10
- 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/requestUrl.test.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
|
|
25
|
-
// src/requestUrl.ts
|
|
26
|
-
var import_qs = __toESM(require("qs"));
|
|
27
|
-
|
|
28
|
-
// src/store.ts
|
|
29
|
-
var createStore = (initialState) => {
|
|
30
|
-
let state = initialState;
|
|
31
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
32
|
-
const getState = () => state;
|
|
33
|
-
const setState = (fn) => {
|
|
34
|
-
state = fn(state);
|
|
35
|
-
listeners.forEach((listener) => listener());
|
|
36
|
-
};
|
|
37
|
-
const subscribe = (listener) => {
|
|
38
|
-
listeners.add(listener);
|
|
39
|
-
return () => listeners.delete(listener);
|
|
40
|
-
};
|
|
41
|
-
return {
|
|
42
|
-
getState,
|
|
43
|
-
setState,
|
|
44
|
-
subscribe
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/apiClientConfigStore.ts
|
|
49
|
-
var defaultConfig = {};
|
|
50
|
-
var store = createStore(defaultConfig);
|
|
51
|
-
|
|
52
|
-
// src/requestUrl.ts
|
|
53
|
-
function __internal__requestUrl(...args) {
|
|
54
|
-
const config2 = store.getState();
|
|
55
|
-
const rawPath = args[0];
|
|
56
|
-
const params = args[1] || {};
|
|
57
|
-
const query = args[2];
|
|
58
|
-
const hostName = config2.hostName ? typeof config2.hostName === "string" ? config2.hostName : config2.hostName(rawPath) : "";
|
|
59
|
-
const path = hostName + Object.entries(params).reduce(
|
|
60
|
-
(path2, [key, value]) => path2.replace(`{${key}}`, String(value)),
|
|
61
|
-
rawPath
|
|
62
|
-
);
|
|
63
|
-
return query ? `${path}?${import_qs.default.stringify(query)}` : path;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// src/requestUrl.test.ts
|
|
67
|
-
var config = {
|
|
68
|
-
hostName: (url) => url.startsWith("/api/v1") ? "https://v1host.example.com" : "https://v2host.example.com"
|
|
69
|
-
};
|
|
70
|
-
describe("__internal_requestUrl", () => {
|
|
71
|
-
describe("path\u306E\u307F\u306E\u30D1\u30E9\u30E1\u30FC\u30BF\u306E\u6642", () => {
|
|
72
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u6642", () => {
|
|
73
|
-
test("path\u304C\u305D\u306E\u307E\u307E\u8FD4\u3055\u308C\u308B", () => {
|
|
74
|
-
store.setState(() => ({}));
|
|
75
|
-
expect(__internal__requestUrl("/api/v1/my/fundraising/header")).toEqual(
|
|
76
|
-
"/api/v1/my/fundraising/header"
|
|
77
|
-
);
|
|
78
|
-
expect(__internal__requestUrl("/api/v2/token")).toEqual(
|
|
79
|
-
"/api/v2/token"
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u6642", () => {
|
|
84
|
-
test("hostUrl\u4ED8\u304D\u306EURL\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
85
|
-
store.setState(() => config);
|
|
86
|
-
expect(__internal__requestUrl("/api/v1/my/fundraising/header")).toEqual(
|
|
87
|
-
"https://v1host.example.com/api/v1/my/fundraising/header"
|
|
88
|
-
);
|
|
89
|
-
expect(__internal__requestUrl("/api/v2/token")).toEqual(
|
|
90
|
-
"https://v2host.example.com/api/v2/token"
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe("path\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3042\u308B\u6642", () => {
|
|
96
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u6642", () => {
|
|
97
|
-
test("path\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u7F6E\u304D\u63DB\u3048\u3089\u308C\u305Fpath\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
98
|
-
store.setState(() => ({}));
|
|
99
|
-
expect(
|
|
100
|
-
__internal__requestUrl(
|
|
101
|
-
"/api/v1/my/fundraising/projects/{project_id}",
|
|
102
|
-
{
|
|
103
|
-
project_id: 12345
|
|
104
|
-
}
|
|
105
|
-
)
|
|
106
|
-
).toEqual("/api/v1/my/fundraising/projects/12345");
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u6642", () => {
|
|
110
|
-
test("path\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u7F6E\u304D\u63DB\u3048\u3089\u308C\u305FURL\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
111
|
-
store.setState(() => config);
|
|
112
|
-
expect(
|
|
113
|
-
__internal__requestUrl(
|
|
114
|
-
"/api/v1/my/fundraising/projects/{project_id}",
|
|
115
|
-
{
|
|
116
|
-
project_id: 12345
|
|
117
|
-
}
|
|
118
|
-
)
|
|
119
|
-
).toEqual(
|
|
120
|
-
"https://v1host.example.com/api/v1/my/fundraising/projects/12345"
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe("query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3042\u308B\u6642", () => {
|
|
126
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u306A\u3044\u6642", () => {
|
|
127
|
-
test("query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3064\u3051\u3089\u308C\u305Fpath\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
128
|
-
store.setState(() => ({}));
|
|
129
|
-
expect(
|
|
130
|
-
__internal__requestUrl(
|
|
131
|
-
"/api/v1/my/messages/tree",
|
|
132
|
-
{},
|
|
133
|
-
{ follow_id: 12345 }
|
|
134
|
-
)
|
|
135
|
-
).toEqual("/api/v1/my/messages/tree?follow_id=12345");
|
|
136
|
-
expect(
|
|
137
|
-
__internal__requestUrl(
|
|
138
|
-
"/api/v2/contributions/project_info",
|
|
139
|
-
{},
|
|
140
|
-
{ project_id: "12345" }
|
|
141
|
-
)
|
|
142
|
-
).toEqual("/api/v2/contributions/project_info?project_id=12345");
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe("url\u306Econfig\u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u6642", () => {
|
|
146
|
-
test("query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3064\u3051\u3089\u308C\u305FURL\u304C\u8FD4\u3055\u308C\u308B", () => {
|
|
147
|
-
store.setState(() => config);
|
|
148
|
-
expect(
|
|
149
|
-
__internal__requestUrl(
|
|
150
|
-
"/api/v1/my/messages/tree",
|
|
151
|
-
{},
|
|
152
|
-
{ follow_id: 12345 }
|
|
153
|
-
)
|
|
154
|
-
).toEqual(
|
|
155
|
-
"https://v1host.example.com/api/v1/my/messages/tree?follow_id=12345"
|
|
156
|
-
);
|
|
157
|
-
expect(
|
|
158
|
-
__internal__requestUrl(
|
|
159
|
-
"/api/v2/contributions/project_info",
|
|
160
|
-
{},
|
|
161
|
-
{ project_id: "12345" }
|
|
162
|
-
)
|
|
163
|
-
).toEqual(
|
|
164
|
-
"https://v2host.example.com/api/v2/contributions/project_info?project_id=12345"
|
|
165
|
-
);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
describe("path\u30D1\u30E9\u30E1\u30FC\u30BF\u3068query\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u3042\u308B\u6642", () => {
|
|
170
|
-
});
|
|
171
|
-
});
|
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
|
-
});
|