@readyfor/api-client-base 0.243.0-pr985.545a27b → 0.243.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fetcher.mjs CHANGED
@@ -5,9 +5,9 @@ import {
5
5
  createVoidFetcher
6
6
  } from "./chunk-BNXKKSJH.mjs";
7
7
  import "./chunk-PY35XWDS.mjs";
8
+ import "./chunk-JCZWXJBU.mjs";
8
9
  import "./chunk-472P3XVV.mjs";
9
10
  import "./chunk-3SEO7S3Q.mjs";
10
- import "./chunk-JCZWXJBU.mjs";
11
11
  export {
12
12
  createBlobFetcher,
13
13
  createJsonFetcher,
package/dist/index.mjs CHANGED
@@ -10,6 +10,10 @@ import {
10
10
  errorTitle,
11
11
  getErrorStatus
12
12
  } from "./chunk-PY35XWDS.mjs";
13
+ import {
14
+ isZodError,
15
+ schemaForType
16
+ } from "./chunk-JCZWXJBU.mjs";
13
17
  import {
14
18
  __internal__requestUrl
15
19
  } from "./chunk-RGDL3AEX.mjs";
@@ -21,10 +25,6 @@ import {
21
25
  createStore
22
26
  } from "./chunk-3SEO7S3Q.mjs";
23
27
  import "./chunk-WBQAMGXK.mjs";
24
- import {
25
- isZodError,
26
- schemaForType
27
- } from "./chunk-JCZWXJBU.mjs";
28
28
  export {
29
29
  HTTPError,
30
30
  __internal__requestUrl,
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,171 @@
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
+ });
@@ -0,0 +1,114 @@
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
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readyfor/api-client-base",
3
- "version": "0.243.0-pr985.545a27b",
3
+ "version": "0.243.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,6 +27,9 @@
27
27
  ]
28
28
  }
29
29
  },
30
+ "scripts": {
31
+ "build": "tsup"
32
+ },
30
33
  "dependencies": {
31
34
  "qs": "6.14.0",
32
35
  "zod": "^3.24.1"
@@ -35,9 +38,9 @@
35
38
  "@types/qs": "6.9.18",
36
39
  "@types/react": "19.1.2",
37
40
  "@types/use-sync-external-store": "1.5.0",
38
- "react": "19.1.0",
39
- "swr": "2.3.3",
40
- "use-sync-external-store": "1.5.0"
41
+ "react": "catalog:react19",
42
+ "swr": "catalog:",
43
+ "use-sync-external-store": "catalog:use-sync-external-store"
41
44
  },
42
45
  "peerDependencies": {
43
46
  "react": ">=18.x <=19.x",
@@ -64,13 +67,8 @@
64
67
  "esm"
65
68
  ],
66
69
  "entry": [
67
- "src/**/*.ts",
68
- "src/**/*.tsx",
69
- "!src/**/*.test.ts",
70
- "!src/**/*.test.tsx"
70
+ "src"
71
71
  ]
72
72
  },
73
- "scripts": {
74
- "build": "tsup"
75
- }
76
- }
73
+ "gitHead": "1641f43f9c85279fb4d040f63593649642867329"
74
+ }