@spoosh/core 0.10.0 → 0.10.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @spoosh/core
2
2
 
3
- Core client and plugin system for Spoosh - a type-safe API client framework.
3
+ Core client and plugin system for Spoosh - a type-safe API toolkit.
4
4
 
5
5
  **[Documentation](https://spoosh.dev/docs/react)** · **Requirements:** TypeScript >= 5.0
6
6
 
@@ -188,7 +188,7 @@ Path parameters are defined using `:param` syntax in the path key (e.g., `"users
188
188
 
189
189
  ### createClient(config)
190
190
 
191
- Creates a lightweight type-safe API client.
191
+ Creates a lightweight type-safe API instance.
192
192
 
193
193
  | Option | Type | Description |
194
194
  | ---------------- | -------------------- | -------------------------------------------------- |
@@ -228,12 +228,12 @@ const { data } = await api("users").GET();
228
228
 
229
229
  **Properties:**
230
230
 
231
- | Property | Description |
232
- | ----------------- | ---------------------------------------- |
233
- | `.api` | Type-safe API client for making requests |
234
- | `.stateManager` | Cache and state management |
235
- | `.eventEmitter` | Event system for refetch/invalidation |
236
- | `.pluginExecutor` | Plugin lifecycle management |
231
+ | Property | Description |
232
+ | ----------------- | ------------------------------------------- |
233
+ | `.api` | Type-safe API interface for making requests |
234
+ | `.stateManager` | Cache and state management |
235
+ | `.eventEmitter` | Event system for refetch/invalidation |
236
+ | `.pluginExecutor` | Plugin lifecycle management |
237
237
 
238
238
  ## Creating Plugins
239
239
 
package/dist/index.d.mts CHANGED
@@ -1060,7 +1060,7 @@ type PathMethods<TSchema, TPath extends string, TDefaultError> = FindMatchingKey
1060
1060
  */
1061
1061
  type SchemaPaths<TSchema> = keyof TSchema & string;
1062
1062
  /**
1063
- * An API client that uses path strings instead of chained property access.
1063
+ * An API interface that uses path strings instead of chained property access.
1064
1064
  * Methods use HTTP names directly: GET, POST, PUT, PATCH, DELETE.
1065
1065
  *
1066
1066
  * @example
@@ -1091,7 +1091,7 @@ type ReadPathMethods<TSchema, TPath extends string, TDefaultError> = FindMatchin
1091
1091
  GET: MethodFn<TSchema[TKey]["GET"], TDefaultError, TPath>;
1092
1092
  }> : never : never : never;
1093
1093
  /**
1094
- * A read-only API client that only exposes GET methods.
1094
+ * A read-only API interface that only exposes GET methods.
1095
1095
  * Used by useRead and injectRead hooks.
1096
1096
  */
1097
1097
  type ReadClient<TSchema, TDefaultError = unknown> = <TPath extends ReadPaths<TSchema> | (string & {})>(path: TPath) => HasReadMethod<TSchema, TPath> extends true ? ReadPathMethods<TSchema, TPath, TDefaultError> : never;
@@ -1103,7 +1103,7 @@ type WritePathMethods<TSchema, TPath extends string, TDefaultError> = FindMatchi
1103
1103
  [M in WriteMethod as M extends keyof TSchema[TKey] ? M : never]: M extends keyof TSchema[TKey] ? MethodFn<TSchema[TKey][M], TDefaultError, TPath> : never;
1104
1104
  }> : never : never;
1105
1105
  /**
1106
- * A write-only API client that only exposes mutation methods (POST, PUT, PATCH, DELETE).
1106
+ * A write-only API interface that only exposes mutation methods (POST, PUT, PATCH, DELETE).
1107
1107
  * Used by useWrite and injectWrite hooks.
1108
1108
  */
1109
1109
  type WriteClient<TSchema, TDefaultError = unknown> = <TPath extends WritePaths<TSchema> | (string & {})>(path: TPath) => HasWriteMethod<TSchema, TPath> extends true ? WritePathMethods<TSchema, TPath, TDefaultError> : never;
@@ -1246,7 +1246,7 @@ declare class Spoosh<TSchema = unknown, TError = unknown, TPlugins extends Plugi
1246
1246
  */
1247
1247
  private getInstance;
1248
1248
  /**
1249
- * The type-safe API client for making requests.
1249
+ * The type-safe API interface for making requests.
1250
1250
  *
1251
1251
  * Provides a proxy-based interface for accessing endpoints defined in your schema.
1252
1252
  *
@@ -1352,13 +1352,13 @@ type SpooshClientConfig = {
1352
1352
  middlewares?: SpooshMiddleware[];
1353
1353
  };
1354
1354
  /**
1355
- * Creates a lightweight type-safe API client for vanilla JavaScript/TypeScript usage.
1355
+ * Creates a lightweight type-safe API instance for vanilla JavaScript/TypeScript usage.
1356
1356
  *
1357
1357
  * This is a simpler alternative to `Spoosh` for users who don't need
1358
1358
  * the full plugin system, state management, or React integration.
1359
1359
  *
1360
1360
  * @param config - Client configuration
1361
- * @returns Type-safe API client
1361
+ * @returns Type-safe API instance
1362
1362
  *
1363
1363
  * @example
1364
1364
  * ```ts
@@ -1456,7 +1456,7 @@ type ProxyHandlerConfig<TOptions = SpooshOptions> = {
1456
1456
  nextTags?: boolean;
1457
1457
  };
1458
1458
  /**
1459
- * Creates an API client proxy that uses path strings instead of chained property access.
1459
+ * Creates an API proxy that uses path strings instead of chained property access.
1460
1460
  * Methods use HTTP names directly: GET, POST, PUT, PATCH, DELETE.
1461
1461
  *
1462
1462
  * @param config - Proxy handler configuration
@@ -1474,7 +1474,7 @@ type ProxyHandlerConfig<TOptions = SpooshOptions> = {
1474
1474
  */
1475
1475
  declare function createProxyHandler<TSchema, TDefaultError = unknown, TOptions = SpooshOptions>(config: ProxyHandlerConfig<TOptions>): SpooshClient<TSchema, TDefaultError>;
1476
1476
 
1477
- /** All supported HTTP method keys used in the API client */
1477
+ /** All supported HTTP method keys used in the API toolkit */
1478
1478
  declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
1479
1479
  /** Union type of all HTTP method keys */
1480
1480
  type HttpMethodKey = (typeof HTTP_METHODS)[number];
package/dist/index.d.ts CHANGED
@@ -1060,7 +1060,7 @@ type PathMethods<TSchema, TPath extends string, TDefaultError> = FindMatchingKey
1060
1060
  */
1061
1061
  type SchemaPaths<TSchema> = keyof TSchema & string;
1062
1062
  /**
1063
- * An API client that uses path strings instead of chained property access.
1063
+ * An API interface that uses path strings instead of chained property access.
1064
1064
  * Methods use HTTP names directly: GET, POST, PUT, PATCH, DELETE.
1065
1065
  *
1066
1066
  * @example
@@ -1091,7 +1091,7 @@ type ReadPathMethods<TSchema, TPath extends string, TDefaultError> = FindMatchin
1091
1091
  GET: MethodFn<TSchema[TKey]["GET"], TDefaultError, TPath>;
1092
1092
  }> : never : never : never;
1093
1093
  /**
1094
- * A read-only API client that only exposes GET methods.
1094
+ * A read-only API interface that only exposes GET methods.
1095
1095
  * Used by useRead and injectRead hooks.
1096
1096
  */
1097
1097
  type ReadClient<TSchema, TDefaultError = unknown> = <TPath extends ReadPaths<TSchema> | (string & {})>(path: TPath) => HasReadMethod<TSchema, TPath> extends true ? ReadPathMethods<TSchema, TPath, TDefaultError> : never;
@@ -1103,7 +1103,7 @@ type WritePathMethods<TSchema, TPath extends string, TDefaultError> = FindMatchi
1103
1103
  [M in WriteMethod as M extends keyof TSchema[TKey] ? M : never]: M extends keyof TSchema[TKey] ? MethodFn<TSchema[TKey][M], TDefaultError, TPath> : never;
1104
1104
  }> : never : never;
1105
1105
  /**
1106
- * A write-only API client that only exposes mutation methods (POST, PUT, PATCH, DELETE).
1106
+ * A write-only API interface that only exposes mutation methods (POST, PUT, PATCH, DELETE).
1107
1107
  * Used by useWrite and injectWrite hooks.
1108
1108
  */
1109
1109
  type WriteClient<TSchema, TDefaultError = unknown> = <TPath extends WritePaths<TSchema> | (string & {})>(path: TPath) => HasWriteMethod<TSchema, TPath> extends true ? WritePathMethods<TSchema, TPath, TDefaultError> : never;
@@ -1246,7 +1246,7 @@ declare class Spoosh<TSchema = unknown, TError = unknown, TPlugins extends Plugi
1246
1246
  */
1247
1247
  private getInstance;
1248
1248
  /**
1249
- * The type-safe API client for making requests.
1249
+ * The type-safe API interface for making requests.
1250
1250
  *
1251
1251
  * Provides a proxy-based interface for accessing endpoints defined in your schema.
1252
1252
  *
@@ -1352,13 +1352,13 @@ type SpooshClientConfig = {
1352
1352
  middlewares?: SpooshMiddleware[];
1353
1353
  };
1354
1354
  /**
1355
- * Creates a lightweight type-safe API client for vanilla JavaScript/TypeScript usage.
1355
+ * Creates a lightweight type-safe API instance for vanilla JavaScript/TypeScript usage.
1356
1356
  *
1357
1357
  * This is a simpler alternative to `Spoosh` for users who don't need
1358
1358
  * the full plugin system, state management, or React integration.
1359
1359
  *
1360
1360
  * @param config - Client configuration
1361
- * @returns Type-safe API client
1361
+ * @returns Type-safe API instance
1362
1362
  *
1363
1363
  * @example
1364
1364
  * ```ts
@@ -1456,7 +1456,7 @@ type ProxyHandlerConfig<TOptions = SpooshOptions> = {
1456
1456
  nextTags?: boolean;
1457
1457
  };
1458
1458
  /**
1459
- * Creates an API client proxy that uses path strings instead of chained property access.
1459
+ * Creates an API proxy that uses path strings instead of chained property access.
1460
1460
  * Methods use HTTP names directly: GET, POST, PUT, PATCH, DELETE.
1461
1461
  *
1462
1462
  * @param config - Proxy handler configuration
@@ -1474,7 +1474,7 @@ type ProxyHandlerConfig<TOptions = SpooshOptions> = {
1474
1474
  */
1475
1475
  declare function createProxyHandler<TSchema, TDefaultError = unknown, TOptions = SpooshOptions>(config: ProxyHandlerConfig<TOptions>): SpooshClient<TSchema, TDefaultError>;
1476
1476
 
1477
- /** All supported HTTP method keys used in the API client */
1477
+ /** All supported HTTP method keys used in the API toolkit */
1478
1478
  declare const HTTP_METHODS: readonly ["GET", "POST", "PUT", "PATCH", "DELETE"];
1479
1479
  /** Union type of all HTTP method keys */
1480
1480
  type HttpMethodKey = (typeof HTTP_METHODS)[number];
package/dist/index.js CHANGED
@@ -1147,7 +1147,7 @@ var Spoosh = class _Spoosh {
1147
1147
  return this._instance;
1148
1148
  }
1149
1149
  /**
1150
- * The type-safe API client for making requests.
1150
+ * The type-safe API interface for making requests.
1151
1151
  *
1152
1152
  * Provides a proxy-based interface for accessing endpoints defined in your schema.
1153
1153
  *
@@ -1318,6 +1318,7 @@ function createOperationController(options) {
1318
1318
  if (cached) {
1319
1319
  stateManager.setCache(queryKey, {
1320
1320
  state: { ...cached.state, ...updater },
1321
+ tags,
1321
1322
  stale: false
1322
1323
  });
1323
1324
  } else {
package/dist/index.mjs CHANGED
@@ -1083,7 +1083,7 @@ var Spoosh = class _Spoosh {
1083
1083
  return this._instance;
1084
1084
  }
1085
1085
  /**
1086
- * The type-safe API client for making requests.
1086
+ * The type-safe API interface for making requests.
1087
1087
  *
1088
1088
  * Provides a proxy-based interface for accessing endpoints defined in your schema.
1089
1089
  *
@@ -1254,6 +1254,7 @@ function createOperationController(options) {
1254
1254
  if (cached) {
1255
1255
  stateManager.setCache(queryKey, {
1256
1256
  state: { ...cached.state, ...updater },
1257
+ tags,
1257
1258
  stale: false
1258
1259
  });
1259
1260
  } else {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@spoosh/core",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "license": "MIT",
5
- "description": "Type-safe API client with plugin middleware system",
5
+ "description": "Type-safe API toolkit with plugin middleware system",
6
6
  "keywords": [
7
7
  "spoosh",
8
- "api-client",
8
+ "api-toolkit",
9
9
  "fetch",
10
10
  "typescript",
11
11
  "middleware",