mates 0.1.0-beta.13 → 0.1.0-beta.15
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/Fetch/Fetch.d.ts +11 -11
- package/dist/Utils/svgIcon.d.ts +1 -1
- package/dist/index.d.ts +14 -14
- package/dist/index.esm.js +38 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/socket/ws.d.ts +2 -2
- package/package.json +3 -4
package/dist/Fetch/Fetch.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export type FetchRequest = Omit<RequestInit, "body"> & {
|
|
|
8
8
|
* - If it starts with `http:` or `https:` it is used as-is (absolute URL),
|
|
9
9
|
* ignoring any `host` set on the client/base request.
|
|
10
10
|
* - Otherwise it is treated as a path and appended to `host`
|
|
11
|
-
* (e.g. `host = "https
|
|
12
|
-
* `"https
|
|
11
|
+
* (e.g. `host = "https://<host>"` + `url = "/users"` →
|
|
12
|
+
* `"https://<host>/users"`).
|
|
13
13
|
* - Dynamic segments (`:id`) are substituted from `params`.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
@@ -24,7 +24,7 @@ export type FetchRequest = Omit<RequestInit, "body"> & {
|
|
|
24
24
|
*/
|
|
25
25
|
path?: string;
|
|
26
26
|
/**
|
|
27
|
-
* Origin / base host, e.g. `"https
|
|
27
|
+
* Origin / base host, e.g. `"https://<your-api>"`.
|
|
28
28
|
* Used as a prefix when `url` is a relative path.
|
|
29
29
|
* Defaults to `""` (no host prefix).
|
|
30
30
|
*/
|
|
@@ -67,7 +67,7 @@ export declare const clearInterceptors: () => void;
|
|
|
67
67
|
* - All requests are logged to Mates DevTools when devtools is connected.
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
70
|
-
* const api = new FetchClient({ host: "https
|
|
70
|
+
* const api = new FetchClient({ host: "https://<your-api>" });
|
|
71
71
|
* api.interceptBefore((url, opts) => ({
|
|
72
72
|
* url,
|
|
73
73
|
* options: { ...opts, headers: { ...opts.headers, Authorization: `Bearer ${token}` } },
|
|
@@ -106,16 +106,16 @@ export declare class FetchClient {
|
|
|
106
106
|
* exactly as `buildRequestUrl` handles them.
|
|
107
107
|
*
|
|
108
108
|
* @example
|
|
109
|
-
* const loadUser = api.fetchAction({ host: "https
|
|
109
|
+
* const loadUser = api.fetchAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
110
110
|
* loadUser({ id: 7, expand: "posts" });
|
|
111
|
-
* // → GET https
|
|
111
|
+
* // → GET https://<your-api>/users/7?expand=posts
|
|
112
112
|
*/
|
|
113
113
|
fetchAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
114
114
|
/**
|
|
115
115
|
* Creates an asyncAction that always issues a GET request via this client.
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
|
-
* const loadUsers = api.getAction({ host: "https
|
|
118
|
+
* const loadUsers = api.getAction({ host: "https://<your-api>", url: "/users" });
|
|
119
119
|
* loadUsers({ page: 2, limit: 20 });
|
|
120
120
|
*/
|
|
121
121
|
getAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -123,7 +123,7 @@ export declare class FetchClient {
|
|
|
123
123
|
* Creates an asyncAction that always issues a POST request via this client.
|
|
124
124
|
*
|
|
125
125
|
* @example
|
|
126
|
-
* const createUser = api.postAction({ host: "https
|
|
126
|
+
* const createUser = api.postAction({ host: "https://<your-api>", url: "/users" });
|
|
127
127
|
* createUser({ name: "Alice" });
|
|
128
128
|
*/
|
|
129
129
|
postAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -131,7 +131,7 @@ export declare class FetchClient {
|
|
|
131
131
|
* Creates an asyncAction that always issues a PUT request via this client.
|
|
132
132
|
*
|
|
133
133
|
* @example
|
|
134
|
-
* const replaceUser = api.putAction({ host: "https
|
|
134
|
+
* const replaceUser = api.putAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
135
135
|
* replaceUser({ id: 7, name: "Bob" });
|
|
136
136
|
*/
|
|
137
137
|
putAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -139,7 +139,7 @@ export declare class FetchClient {
|
|
|
139
139
|
* Creates an asyncAction that always issues a PATCH request via this client.
|
|
140
140
|
*
|
|
141
141
|
* @example
|
|
142
|
-
* const patchUser = api.patchAction({ host: "https
|
|
142
|
+
* const patchUser = api.patchAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
143
143
|
* patchUser({ id: 7, status: "inactive" });
|
|
144
144
|
*/
|
|
145
145
|
patchAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -147,7 +147,7 @@ export declare class FetchClient {
|
|
|
147
147
|
* Creates an asyncAction that always issues a DELETE request via this client.
|
|
148
148
|
*
|
|
149
149
|
* @example
|
|
150
|
-
* const removeUser = api.deleteAction({ host: "https
|
|
150
|
+
* const removeUser = api.deleteAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
151
151
|
* removeUser({ id: 7 });
|
|
152
152
|
*/
|
|
153
153
|
deleteAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
package/dist/Utils/svgIcon.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ declare const svgIconDirective: (_markup: string, _config: SvgConfig) => import(
|
|
|
70
70
|
* import { safeSVG, html } from "mates";
|
|
71
71
|
*
|
|
72
72
|
* const heartIcon =
|
|
73
|
-
* `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
73
|
+
* `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <!-- standard SVG namespace -->
|
|
74
74
|
* <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5…"/>
|
|
75
75
|
* </svg>`;
|
|
76
76
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1120,8 +1120,8 @@ type FetchRequest = Omit<RequestInit, "body"> & {
|
|
|
1120
1120
|
* - If it starts with `http:` or `https:` it is used as-is (absolute URL),
|
|
1121
1121
|
* ignoring any `host` set on the client/base request.
|
|
1122
1122
|
* - Otherwise it is treated as a path and appended to `host`
|
|
1123
|
-
* (e.g. `host = "https
|
|
1124
|
-
* `"https
|
|
1123
|
+
* (e.g. `host = "https://<host>"` + `url = "/users"` →
|
|
1124
|
+
* `"https://<host>/users"`).
|
|
1125
1125
|
* - Dynamic segments (`:id`) are substituted from `params`.
|
|
1126
1126
|
*
|
|
1127
1127
|
* @example
|
|
@@ -1136,7 +1136,7 @@ type FetchRequest = Omit<RequestInit, "body"> & {
|
|
|
1136
1136
|
*/
|
|
1137
1137
|
path?: string;
|
|
1138
1138
|
/**
|
|
1139
|
-
* Origin / base host, e.g. `"https
|
|
1139
|
+
* Origin / base host, e.g. `"https://<your-api>"`.
|
|
1140
1140
|
* Used as a prefix when `url` is a relative path.
|
|
1141
1141
|
* Defaults to `""` (no host prefix).
|
|
1142
1142
|
*/
|
|
@@ -1179,7 +1179,7 @@ declare const clearInterceptors: () => void;
|
|
|
1179
1179
|
* - All requests are logged to Mates DevTools when devtools is connected.
|
|
1180
1180
|
*
|
|
1181
1181
|
* @example
|
|
1182
|
-
* const api = new FetchClient({ host: "https
|
|
1182
|
+
* const api = new FetchClient({ host: "https://<your-api>" });
|
|
1183
1183
|
* api.interceptBefore((url, opts) => ({
|
|
1184
1184
|
* url,
|
|
1185
1185
|
* options: { ...opts, headers: { ...opts.headers, Authorization: `Bearer ${token}` } },
|
|
@@ -1218,16 +1218,16 @@ declare class FetchClient {
|
|
|
1218
1218
|
* exactly as `buildRequestUrl` handles them.
|
|
1219
1219
|
*
|
|
1220
1220
|
* @example
|
|
1221
|
-
* const loadUser = api.fetchAction({ host: "https
|
|
1221
|
+
* const loadUser = api.fetchAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
1222
1222
|
* loadUser({ id: 7, expand: "posts" });
|
|
1223
|
-
* // → GET https
|
|
1223
|
+
* // → GET https://<your-api>/users/7?expand=posts
|
|
1224
1224
|
*/
|
|
1225
1225
|
fetchAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
1226
1226
|
/**
|
|
1227
1227
|
* Creates an asyncAction that always issues a GET request via this client.
|
|
1228
1228
|
*
|
|
1229
1229
|
* @example
|
|
1230
|
-
* const loadUsers = api.getAction({ host: "https
|
|
1230
|
+
* const loadUsers = api.getAction({ host: "https://<your-api>", url: "/users" });
|
|
1231
1231
|
* loadUsers({ page: 2, limit: 20 });
|
|
1232
1232
|
*/
|
|
1233
1233
|
getAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -1235,7 +1235,7 @@ declare class FetchClient {
|
|
|
1235
1235
|
* Creates an asyncAction that always issues a POST request via this client.
|
|
1236
1236
|
*
|
|
1237
1237
|
* @example
|
|
1238
|
-
* const createUser = api.postAction({ host: "https
|
|
1238
|
+
* const createUser = api.postAction({ host: "https://<your-api>", url: "/users" });
|
|
1239
1239
|
* createUser({ name: "Alice" });
|
|
1240
1240
|
*/
|
|
1241
1241
|
postAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -1243,7 +1243,7 @@ declare class FetchClient {
|
|
|
1243
1243
|
* Creates an asyncAction that always issues a PUT request via this client.
|
|
1244
1244
|
*
|
|
1245
1245
|
* @example
|
|
1246
|
-
* const replaceUser = api.putAction({ host: "https
|
|
1246
|
+
* const replaceUser = api.putAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
1247
1247
|
* replaceUser({ id: 7, name: "Bob" });
|
|
1248
1248
|
*/
|
|
1249
1249
|
putAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -1251,7 +1251,7 @@ declare class FetchClient {
|
|
|
1251
1251
|
* Creates an asyncAction that always issues a PATCH request via this client.
|
|
1252
1252
|
*
|
|
1253
1253
|
* @example
|
|
1254
|
-
* const patchUser = api.patchAction({ host: "https
|
|
1254
|
+
* const patchUser = api.patchAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
1255
1255
|
* patchUser({ id: 7, status: "inactive" });
|
|
1256
1256
|
*/
|
|
1257
1257
|
patchAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -1259,7 +1259,7 @@ declare class FetchClient {
|
|
|
1259
1259
|
* Creates an asyncAction that always issues a DELETE request via this client.
|
|
1260
1260
|
*
|
|
1261
1261
|
* @example
|
|
1262
|
-
* const removeUser = api.deleteAction({ host: "https
|
|
1262
|
+
* const removeUser = api.deleteAction({ host: "https://<your-api>", url: "/users/:id" });
|
|
1263
1263
|
* removeUser({ id: 7 });
|
|
1264
1264
|
*/
|
|
1265
1265
|
deleteAction<T = unknown>(config?: FetchActionConfig): AsyncActionReturnType<(params?: Record<string, any>) => Promise<T>>;
|
|
@@ -4724,7 +4724,7 @@ type WsConnection<T = unknown> = {
|
|
|
4724
4724
|
* ```ts
|
|
4725
4725
|
* // ✅ correct — inside a component's outer function
|
|
4726
4726
|
* const MyComponent = () => {
|
|
4727
|
-
* const sock = ws<ChatMessage>("wss
|
|
4727
|
+
* const sock = ws<ChatMessage>("wss://<your-server>/chat", {
|
|
4728
4728
|
* reconnect: true,
|
|
4729
4729
|
* });
|
|
4730
4730
|
* onSocket((msg) => { messages.update(d => { d.push(msg); }); }, [sock]);
|
|
@@ -4732,7 +4732,7 @@ type WsConnection<T = unknown> = {
|
|
|
4732
4732
|
* };
|
|
4733
4733
|
*
|
|
4734
4734
|
* // ❌ wrong — module level, no host, cleanup is never registered
|
|
4735
|
-
* const chatSocket = ws<ChatMessage>("wss
|
|
4735
|
+
* const chatSocket = ws<ChatMessage>("wss://<your-server>/chat");
|
|
4736
4736
|
*
|
|
4737
4737
|
* // ❌ wrong — inner function, outer function has already returned
|
|
4738
4738
|
* const MyComponent = () => {
|
|
@@ -5901,7 +5901,7 @@ declare const svgIconDirective: (_markup: string, _config: SvgConfig) => lit_htm
|
|
|
5901
5901
|
* import { safeSVG, html } from "mates";
|
|
5902
5902
|
*
|
|
5903
5903
|
* const heartIcon =
|
|
5904
|
-
* `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
5904
|
+
* `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> <!-- standard SVG namespace -->
|
|
5905
5905
|
* <path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5…"/>
|
|
5906
5906
|
* </svg>`;
|
|
5907
5907
|
*
|