@metagptx/web-sdk 0.0.1 → 0.0.2

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 (3) hide show
  1. package/README.md +15 -11
  2. package/dist/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -83,19 +83,21 @@ client.auth.toLogin();
83
83
 
84
84
  Provides dynamic CRUD operations for any entity type. Access entities using property syntax: `client.entities.{entityName}.{operation}()`.
85
85
 
86
+ **Note:** The `fields` parameter (array) will be automatically converted to a comma-separated string, and the `query` parameter (object) will be automatically converted to a JSON string before sending to the API.
87
+
86
88
  #### `entities[entityName].query(params?)`
87
89
 
88
90
  Query entities with filtering, sorting, and pagination.
89
91
 
90
92
  **HTTP Details:**
91
93
  - **Method:** `GET`
92
- - **Path:** `/api/entities/{entityName}`
94
+ - **Path:** `/api/v1/entities/{entityName}`
93
95
  - **Parameters:**
94
- - `query` (optional): Query conditions object
96
+ - `query` (optional): Query conditions object (will be converted to JSON string)
95
97
  - `sort` (optional): Sort field and order (e.g., `"-createdAt"`)
96
98
  - `limit` (optional): Maximum number of results
97
99
  - `skip` (optional): Number of results to skip
98
- - `fields` (optional): Array of fields to return
100
+ - `fields` (optional): Array of fields to return (will be converted to comma-separated string)
99
101
 
100
102
  **Example:**
101
103
  ```typescript
@@ -106,6 +108,7 @@ const response = await client.entities.users.query({
106
108
  skip: 0,
107
109
  fields: ['id', 'name', 'email'],
108
110
  });
111
+ // Actual API call: GET /api/v1/entities/users?query={"status":"active"}&sort=-createdAt&limit=10&skip=0&fields=id,name,email
109
112
  ```
110
113
 
111
114
  #### `entities[entityName].get(params)`
@@ -114,10 +117,10 @@ Get a single entity by ID.
114
117
 
115
118
  **HTTP Details:**
116
119
  - **Method:** `GET`
117
- - **Path:** `/api/entities/{entityName}/{id}`
120
+ - **Path:** `/api/v1/entities/{entityName}/{id}`
118
121
  - **Parameters:**
119
122
  - `id` (required): Entity ID
120
- - `fields` (optional): Array of fields to return
123
+ - `fields` (optional): Array of fields to return (will be converted to comma-separated string)
121
124
 
122
125
  **Example:**
123
126
  ```typescript
@@ -125,6 +128,7 @@ const response = await client.entities.users.get({
125
128
  id: '12345',
126
129
  fields: ['id', 'name', 'email'],
127
130
  });
131
+ // Actual API call: GET /api/v1/entities/users/12345?fields=id,name,email
128
132
  ```
129
133
 
130
134
  #### `entities[entityName].create(params)`
@@ -133,7 +137,7 @@ Create a new entity.
133
137
 
134
138
  **HTTP Details:**
135
139
  - **Method:** `POST`
136
- - **Path:** `/api/entities/{entityName}`
140
+ - **Path:** `/api/v1/entities/{entityName}`
137
141
  - **Body:**
138
142
  - `data` (required): Entity data object
139
143
 
@@ -154,7 +158,7 @@ Update an existing entity.
154
158
 
155
159
  **HTTP Details:**
156
160
  - **Method:** `PUT`
157
- - **Path:** `/api/entities/{entityName}/{id}`
161
+ - **Path:** `/api/v1/entities/{entityName}/{id}`
158
162
  - **Body:**
159
163
  - `id` (required): Entity ID
160
164
  - `data` (required): Updated entity data
@@ -176,7 +180,7 @@ Delete a single entity by ID.
176
180
 
177
181
  **HTTP Details:**
178
182
  - **Method:** `DELETE`
179
- - **Path:** `/api/entities/{entityName}/{id}`
183
+ - **Path:** `/api/v1/entities/{entityName}/{id}`
180
184
  - **Parameters:**
181
185
  - `id` (required): Entity ID
182
186
 
@@ -191,7 +195,7 @@ Create multiple entities in a single request.
191
195
 
192
196
  **HTTP Details:**
193
197
  - **Method:** `POST`
194
- - **Path:** `/api/entities/{entityName}/batch`
198
+ - **Path:** `/api/v1/entities/{entityName}/batch`
195
199
  - **Body:**
196
200
  - `data` (required): Array of entity data objects
197
201
 
@@ -211,7 +215,7 @@ Update multiple entities in a single request.
211
215
 
212
216
  **HTTP Details:**
213
217
  - **Method:** `PUT`
214
- - **Path:** `/api/entities/{entityName}/batch`
218
+ - **Path:** `/api/v1/entities/{entityName}/batch`
215
219
  - **Body:**
216
220
  - `data` (required): Array of entity data objects (must include `id` for each)
217
221
 
@@ -231,7 +235,7 @@ Delete multiple entities by their IDs.
231
235
 
232
236
  **HTTP Details:**
233
237
  - **Method:** `DELETE`
234
- - **Path:** `/api/entities/{entityName}/batch`
238
+ - **Path:** `/api/v1/entities/{entityName}/batch`
235
239
  - **Body:**
236
240
  - `ids` (required): Array of entity IDs
237
241
 
package/dist/index.js CHANGED
@@ -1 +1 @@
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/entities/${n}`;return{async query(e){return t.get(r,{params:e})},async get(e){let{id:n,...i}=e;return t.get(`${r}/${n}`,{params:i})},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};
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};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metagptx/web-sdk",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "packageManager": "pnpm@10.15.0+sha512.486ebc259d3e999a4e8691ce03b5cac4a71cbeca39372a9b762cb500cfdf0873e2cb16abe3d951b1ee2cf012503f027b98b6584e4df22524e0c7450d9ec7aa7b",
6
6
  "description": "TypeScript SDK for interacting with FuncSea API",
7
7
  "author": "MetaGPTX",