@readyfor/api-client-base 0.0.1-pr889.422eb87

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.
Files changed (64) hide show
  1. package/LICENSE.md +1 -0
  2. package/dist/apiClientConfigStore.d.mts +17 -0
  3. package/dist/apiClientConfigStore.d.ts +17 -0
  4. package/dist/apiClientConfigStore.js +56 -0
  5. package/dist/apiClientConfigStore.mjs +9 -0
  6. package/dist/apiError.d.mts +30 -0
  7. package/dist/apiError.d.ts +30 -0
  8. package/dist/apiError.js +94 -0
  9. package/dist/apiError.mjs +13 -0
  10. package/dist/chunk-3SEO7S3Q.mjs +23 -0
  11. package/dist/chunk-472P3XVV.mjs +13 -0
  12. package/dist/chunk-C5P5R2CL.mjs +79 -0
  13. package/dist/chunk-DHYJM4DQ.mjs +19 -0
  14. package/dist/chunk-H3C7VSOJ.mjs +25 -0
  15. package/dist/chunk-JCZWXJBU.mjs +10 -0
  16. package/dist/chunk-PY35XWDS.mjs +66 -0
  17. package/dist/chunk-RGDL3AEX.mjs +22 -0
  18. package/dist/chunk-VVRQ7D57.mjs +25 -0
  19. package/dist/chunk-WBQAMGXK.mjs +0 -0
  20. package/dist/fetcher.d.mts +12 -0
  21. package/dist/fetcher.d.ts +12 -0
  22. package/dist/fetcher.js +170 -0
  23. package/dist/fetcher.mjs +16 -0
  24. package/dist/index.d.mts +8 -0
  25. package/dist/index.d.ts +8 -0
  26. package/dist/index.js +232 -0
  27. package/dist/index.mjs +43 -0
  28. package/dist/react/ApiClientConfigProvider.d.mts +17 -0
  29. package/dist/react/ApiClientConfigProvider.d.ts +17 -0
  30. package/dist/react/ApiClientConfigProvider.js +87 -0
  31. package/dist/react/ApiClientConfigProvider.mjs +11 -0
  32. package/dist/react/index.d.mts +8 -0
  33. package/dist/react/index.d.ts +8 -0
  34. package/dist/react/index.js +112 -0
  35. package/dist/react/index.mjs +20 -0
  36. package/dist/react/swr.d.mts +13 -0
  37. package/dist/react/swr.d.ts +13 -0
  38. package/dist/react/swr.js +43 -0
  39. package/dist/react/swr.mjs +6 -0
  40. package/dist/react/useApiClientConfig.d.mts +8 -0
  41. package/dist/react/useApiClientConfig.d.ts +8 -0
  42. package/dist/react/useApiClientConfig.js +86 -0
  43. package/dist/react/useApiClientConfig.mjs +12 -0
  44. package/dist/requestUrl.d.mts +6 -0
  45. package/dist/requestUrl.d.ts +6 -0
  46. package/dist/requestUrl.js +78 -0
  47. package/dist/requestUrl.mjs +8 -0
  48. package/dist/requestUrl.test.d.mts +2 -0
  49. package/dist/requestUrl.test.d.ts +2 -0
  50. package/dist/requestUrl.test.js +171 -0
  51. package/dist/requestUrl.test.mjs +114 -0
  52. package/dist/store.d.mts +13 -0
  53. package/dist/store.d.ts +13 -0
  54. package/dist/store.js +47 -0
  55. package/dist/store.mjs +6 -0
  56. package/dist/types.d.mts +12 -0
  57. package/dist/types.d.ts +12 -0
  58. package/dist/types.js +18 -0
  59. package/dist/types.mjs +1 -0
  60. package/dist/zod.d.mts +6 -0
  61. package/dist/zod.d.ts +6 -0
  62. package/dist/zod.js +35 -0
  63. package/dist/zod.mjs +8 -0
  64. package/package.json +66 -0
@@ -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
+ });
@@ -0,0 +1,13 @@
1
+ type Listener = () => void;
2
+ type GetState<T> = () => T;
3
+ type SetState<T> = (fn: (state: T) => T) => void;
4
+ type Subscribe = (listener: Listener) => Unsubscribe;
5
+ type Unsubscribe = () => void;
6
+ type Store<T> = {
7
+ getState: GetState<T>;
8
+ setState: SetState<T>;
9
+ subscribe: Subscribe;
10
+ };
11
+ declare const createStore: <T>(initialState: T) => Store<T>;
12
+
13
+ export { type Store, createStore };
@@ -0,0 +1,13 @@
1
+ type Listener = () => void;
2
+ type GetState<T> = () => T;
3
+ type SetState<T> = (fn: (state: T) => T) => void;
4
+ type Subscribe = (listener: Listener) => Unsubscribe;
5
+ type Unsubscribe = () => void;
6
+ type Store<T> = {
7
+ getState: GetState<T>;
8
+ setState: SetState<T>;
9
+ subscribe: Subscribe;
10
+ };
11
+ declare const createStore: <T>(initialState: T) => Store<T>;
12
+
13
+ export { type Store, createStore };
package/dist/store.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/store.ts
21
+ var store_exports = {};
22
+ __export(store_exports, {
23
+ createStore: () => createStore
24
+ });
25
+ module.exports = __toCommonJS(store_exports);
26
+ var createStore = (initialState) => {
27
+ let state = initialState;
28
+ const listeners = /* @__PURE__ */ new Set();
29
+ const getState = () => state;
30
+ const setState = (fn) => {
31
+ state = fn(state);
32
+ listeners.forEach((listener) => listener());
33
+ };
34
+ const subscribe = (listener) => {
35
+ listeners.add(listener);
36
+ return () => listeners.delete(listener);
37
+ };
38
+ return {
39
+ getState,
40
+ setState,
41
+ subscribe
42
+ };
43
+ };
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ createStore
47
+ });
package/dist/store.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import {
2
+ createStore
3
+ } from "./chunk-3SEO7S3Q.mjs";
4
+ export {
5
+ createStore
6
+ };
@@ -0,0 +1,12 @@
1
+ type ForceDig<T, K extends string[]> = K extends [
2
+ infer P extends string,
3
+ ...infer Rest extends string[]
4
+ ] ? T extends {
5
+ [key in P]?: infer S;
6
+ } ? ForceDig<Exclude<S, undefined>, Rest> : Record<string, never> : T;
7
+ type RemoveBracket<T> = T extends `${infer S}[]` ? S : T;
8
+ type QueryPropsFor<T extends Record<string, unknown>> = {
9
+ [K in keyof T as RemoveBracket<K>]: K extends `${string}[]` ? Exclude<T[K], undefined>[] : T[K];
10
+ };
11
+
12
+ export type { ForceDig, QueryPropsFor };
@@ -0,0 +1,12 @@
1
+ type ForceDig<T, K extends string[]> = K extends [
2
+ infer P extends string,
3
+ ...infer Rest extends string[]
4
+ ] ? T extends {
5
+ [key in P]?: infer S;
6
+ } ? ForceDig<Exclude<S, undefined>, Rest> : Record<string, never> : T;
7
+ type RemoveBracket<T> = T extends `${infer S}[]` ? S : T;
8
+ type QueryPropsFor<T extends Record<string, unknown>> = {
9
+ [K in keyof T as RemoveBracket<K>]: K extends `${string}[]` ? Exclude<T[K], undefined>[] : T[K];
10
+ };
11
+
12
+ export type { ForceDig, QueryPropsFor };
package/dist/types.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
package/dist/types.mjs ADDED
@@ -0,0 +1 @@
1
+ import "./chunk-WBQAMGXK.mjs";
package/dist/zod.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const schemaForType: <T>() => <S extends z.ZodType<T, any, any>>(arg: S) => S;
4
+ declare const isZodError: (obj: unknown) => obj is z.ZodError;
5
+
6
+ export { isZodError, schemaForType };
package/dist/zod.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const schemaForType: <T>() => <S extends z.ZodType<T, any, any>>(arg: S) => S;
4
+ declare const isZodError: (obj: unknown) => obj is z.ZodError;
5
+
6
+ export { isZodError, schemaForType };
package/dist/zod.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/zod.ts
21
+ var zod_exports = {};
22
+ __export(zod_exports, {
23
+ isZodError: () => isZodError,
24
+ schemaForType: () => schemaForType
25
+ });
26
+ module.exports = __toCommonJS(zod_exports);
27
+ var schemaForType = () => (arg) => {
28
+ return arg;
29
+ };
30
+ var isZodError = (obj) => obj !== null && typeof obj === "object" && obj.constructor.name === "ZodError";
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ isZodError,
34
+ schemaForType
35
+ });
package/dist/zod.mjs ADDED
@@ -0,0 +1,8 @@
1
+ import {
2
+ isZodError,
3
+ schemaForType
4
+ } from "./chunk-JCZWXJBU.mjs";
5
+ export {
6
+ isZodError,
7
+ schemaForType
8
+ };
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@readyfor/api-client-base",
3
+ "version": "0.0.1-pr889.422eb87",
4
+ "license": "SEE LICENSE IN LICENSE.md",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js"
16
+ },
17
+ "./react": {
18
+ "types": "./dist/react/index.d.ts",
19
+ "import": "./dist/react/index.mjs",
20
+ "require": "./dist/react/index.js"
21
+ }
22
+ },
23
+ "dependencies": {
24
+ "qs": "6.13.1",
25
+ "zod": "3.23.8"
26
+ },
27
+ "devDependencies": {
28
+ "@types/qs": "6.9.17",
29
+ "@types/react": "^18.3.12",
30
+ "@types/use-sync-external-store": "0.0.6",
31
+ "react": "^18.3.1",
32
+ "swr": "2.2.5",
33
+ "use-sync-external-store": "1.2.2"
34
+ },
35
+ "peerDependencies": {
36
+ "react": "^18.3.1",
37
+ "swr": "^2.2.5",
38
+ "use-sync-external-store": "1.2.2"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "react": {
42
+ "optional": true
43
+ },
44
+ "swr": {
45
+ "optional": true
46
+ },
47
+ "use-sync-external-store": {
48
+ "optional": true
49
+ }
50
+ },
51
+ "tsup": {
52
+ "clean": true,
53
+ "target": "esnext",
54
+ "dts": true,
55
+ "format": [
56
+ "cjs",
57
+ "esm"
58
+ ],
59
+ "entry": [
60
+ "src"
61
+ ]
62
+ },
63
+ "scripts": {
64
+ "build": "tsup"
65
+ }
66
+ }