@metagptx/web-sdk 0.0.2 → 0.0.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metagptx/web-sdk",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
6
6
  "description": "TypeScript SDK for interacting with FuncSea API",
7
7
  "author": "MetaGPTX",
package/dist/index.d.ts DELETED
@@ -1,108 +0,0 @@
1
- import * as axios0 from "axios";
2
- import { AxiosRequestConfig } from "axios";
3
-
4
- //#region src/utils/request.d.ts
5
- /**
6
- * Request instance configuration options
7
- */
8
- interface RequestConfig extends AxiosRequestConfig {
9
- baseURL?: string;
10
- timeout?: number;
11
- onUnauthorized?: () => void;
12
- }
13
- /**
14
- * Creates an axios request instance with default configuration
15
- * @param config - Optional configuration for the request instance
16
- * @returns Configured axios instance
17
- */
18
- //#endregion
19
- //#region src/client.d.ts
20
- interface ClientConfig extends RequestConfig {}
21
- declare const createClient: (config?: ClientConfig) => {
22
- auth: {
23
- me(): Promise<axios0.AxiosResponse<any, any, {}>>;
24
- logout(): Promise<axios0.AxiosResponse<any, any, {}>>;
25
- toLogin: () => void;
26
- };
27
- entities: Record<string, {
28
- query<T = any>(params?: {
29
- query?: Record<string, unknown>;
30
- sort?: string;
31
- limit?: number;
32
- skip?: number;
33
- fields?: string[];
34
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
35
- get<T = any>(params: {
36
- id: string;
37
- fields?: string[];
38
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
39
- create<T = any>(params: {
40
- data: Record<string, unknown>;
41
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
42
- update<T = any>(params: {
43
- id: string;
44
- data: Record<string, unknown>;
45
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
46
- delete<T = any>(params: {
47
- id: string;
48
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
49
- deleteBatch<T = any>(params: {
50
- ids: string[];
51
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
52
- createBatch<T = any>(params: {
53
- data: Record<string, unknown>[];
54
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
55
- updateBatch<T = any>(params: {
56
- data: Record<string, unknown>[];
57
- }): Promise<axios0.AxiosResponse<T, any, {}>>;
58
- }>;
59
- apiCall: {
60
- invoke<T = any>(params: ApiCallParams): Promise<axios0.AxiosResponse<T, any, {}>>;
61
- };
62
- integrations: Record<string, Record<string, IntegrationFunction>>;
63
- };
64
- //#endregion
65
- //#region src/types/index.d.ts
66
- /**
67
- * Common reusable types for the funcsea-websdk
68
- */
69
- type AnyType = any;
70
- //#endregion
71
- //#region src/modules/apiCall.d.ts
72
- /**
73
- * API call parameters interface
74
- */
75
- interface ApiCallParams {
76
- url: string;
77
- method?: string;
78
- data?: Record<string, AnyType>;
79
- options?: AxiosRequestConfig;
80
- }
81
- /**
82
- * Creates an API call module for making custom HTTP requests
83
- * @param params - Configuration object
84
- * @param params.requestInstance - Axios instance for making HTTP requests
85
- * @returns Object containing invoke method for API calls
86
- */
87
- //#endregion
88
- //#region src/modules/integrations.d.ts
89
- /**
90
- * Integration function parameters interface
91
- */
92
- interface IntegrationParams {
93
- payload?: Record<string, AnyType> | FormData;
94
- option?: Record<string, AnyType>;
95
- }
96
- /**
97
- * Integration function type
98
- */
99
- type IntegrationFunction = (params?: IntegrationParams) => Promise<AnyType>;
100
- /**
101
- * Creates an integrations module using proxy for dynamic package and function access
102
- * @param params - Configuration object
103
- * @param params.requestInstance - Axios instance for making HTTP requests
104
- * @returns Proxy object that dynamically creates integration calls
105
- */
106
-
107
- //#endregion
108
- export { type AnyType, type ApiCallParams, type ClientConfig, type IntegrationFunction, type IntegrationParams, type RequestConfig, createClient };
package/dist/index.js DELETED
@@ -1 +0,0 @@
1
- import e from"axios";import t from"qs";const n=(n={})=>{let{onUnauthorized:r,...i}=n,a={timeout:6e4,paramsSerializer:e=>t.stringify(e,{arrayFormat:`brackets`}),...i,headers:{"Content-Type":`application/json`,...i.headers}},o=e.create(a);return o.interceptors.request.use(e=>e,e=>Promise.reject(e)),o.interceptors.response.use(e=>e,e=>(e.response?.status===401&&r&&r(),Promise.reject(e))),o},r=e=>typeof e==`string`?e.startsWith(`_`)||e.startsWith(`$`)||e===`constructor`||e===`toString`||e===`valueOf`||e===`inspect`||e===`toJSON`:!0,i=()=>{let e=window.location.href,t=new URLSearchParams({from_url:e});window.location.href=`/api/v1/auth/login?${t.toString()}`},a=e=>{let{requestInstance:t}=e;return{async me(){return t.get(`/api/v1/auth/me`)},async logout(){return t.post(`/api/v1/auth/logout`)},toLogin:i}},o=e=>{let{requestInstance:t,entityName:n}=e,r=`/api/v1/entities/${n}`,i=e=>{if(!e)return;let t={...e};return e.fields&&Array.isArray(e.fields)&&(t.fields=e.fields.join(`,`)),e.query&&typeof e.query==`object`&&(t.query=JSON.stringify(e.query)),t};return{async query(e){let n=i(e);return t.get(r,{params:n})},async get(e){let{id:n,...a}=e,o=i(a);return t.get(`${r}/${n}`,{params:o})},async create(e){return t.post(r,e.data)},async update(e){return t.put(`${r}/${e.id}`,e.data)},async delete(e){return t.delete(`${r}/${e.id}`)},async deleteBatch(e){return t.delete(`${r}/batch`,{data:{ids:e.ids}})},async createBatch(e){return t.post(`${r}/batch`,e.data)},async updateBatch(e){return t.put(`${r}/batch`,e.data)}}},s=e=>{let{requestInstance:t}=e,n=new Map;return new Proxy({},{get(e,i){if(!r(i))return n.has(i)||n.set(i,o({requestInstance:t,entityName:i})),n.get(i)}})},c=e=>{let{requestInstance:t}=e;return{async invoke(e){let{url:n,method:r=`GET`,data:i,options:a={}}=e,o={method:r.toUpperCase(),url:n,...a};return i&&[`POST`,`PUT`,`PATCH`].includes(o.method)?o.data=i:i&&[`GET`,`DELETE`].includes(o.method)&&(o.params=i),t.request(o)}}},l=e=>{let{requestInstance:t}=e;return new Proxy({},{get(e,n){if(!r(n))return new Proxy({},{get(e,i){if(!r(i))return(e={})=>{let r=`/api/integrations/core/${i}`;n!==`core`&&(r=`/api/integrations/providers/${n}/${i}`);let{payload:a={},option:o={}}=e,s=a instanceof FormData?{...o,headers:{...o.headers,"Content-Type":void 0}}:o;return t.post(r,a,s)}}})}})},u=(e={})=>{let t=n({baseURL:`/`,...e,onUnauthorized:i}),r=a({requestInstance:t}),o=s({requestInstance:t}),u=c({requestInstance:t}),d=l({requestInstance:t});return{auth:r,entities:o,apiCall:u,integrations:d}};export{u as createClient};