@spoosh/core 0.6.0 → 0.7.0
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/index.d.mts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +33 -4
- package/dist/index.mjs +33 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1360,14 +1360,21 @@ declare function objectToUrlEncoded(obj: Record<string, unknown>): string;
|
|
|
1360
1360
|
|
|
1361
1361
|
declare function sortObjectKeys(obj: unknown, seen?: WeakSet<object>): unknown;
|
|
1362
1362
|
|
|
1363
|
+
type TagMode = "all" | "self" | "none";
|
|
1364
|
+
type TagModeInArray = "all" | "self";
|
|
1363
1365
|
/**
|
|
1364
1366
|
* Common tag options used across plugins and operations.
|
|
1365
1367
|
*/
|
|
1366
1368
|
type TagOptions = {
|
|
1367
|
-
/**
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1369
|
+
/**
|
|
1370
|
+
* Unified tag option (follows invalidation pattern)
|
|
1371
|
+
* - String: mode only ('all' | 'self' | 'none')
|
|
1372
|
+
* - Array: custom tags only OR [mode keyword mixed with custom tags]
|
|
1373
|
+
* - If array contains 'all' or 'self', it's treated as mode + tags
|
|
1374
|
+
* - Otherwise, it's custom tags only (replaces auto-generated tags)
|
|
1375
|
+
* - 'none' keyword should NOT be used in arrays (use string 'none' instead)
|
|
1376
|
+
*/
|
|
1377
|
+
tags?: TagMode | (TagModeInArray | (string & {}))[];
|
|
1371
1378
|
};
|
|
1372
1379
|
declare function resolveTags(options: TagOptions | undefined, resolvedPath: string[]): string[];
|
|
1373
1380
|
declare function resolvePath(path: string[], params: Record<string, string | number> | undefined): string[];
|
|
@@ -1597,4 +1604,4 @@ type CreateInfiniteReadOptions<TData, TItem, TError, TRequest> = {
|
|
|
1597
1604
|
};
|
|
1598
1605
|
declare function createInfiniteReadController<TData, TItem, TError, TRequest extends InfiniteRequestOptions = InfiniteRequestOptions>(options: CreateInfiniteReadOptions<TData, TItem, TError, TRequest>): InfiniteReadController<TData, TItem, TError>;
|
|
1599
1606
|
|
|
1600
|
-
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type SpooshClientConfig as ClientConfig, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type EventEmitter, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type MiddlewareContext, type MiddlewareHandler, type MiddlewarePhase, type MutationSchemaHelper, type OperationController, type OperationState, type OperationType, type PageContext, type PluginAccessor, type PluginArray, type PluginContext, type PluginContextInput, type PluginExecutor, type PluginExportsRegistry, type PluginFactory, type PluginHandler, type PluginLifecycle, type PluginMiddleware, type PluginRegistry, type PluginResolvers, type PluginResponseHandler, type PluginResultResolvers, type PluginTypeConfig, type PluginUpdateHandler, type QuerySchemaHelper, type ReadClient, type RefetchEvent, type RequestOptions$1 as RequestOptions, type ResolveInstanceApi, type ResolveResultTypes, type ResolveSchemaTypes, type ResolveTypes, type ResolverContext, type RetryConfig, type RouteToPath, type SchemaPaths, type SelectedEndpoint, type SelectorFunction, type SelectorResult, Spoosh, type SpooshClient, type SpooshConfig, type SpooshInstance, type SpooshMiddleware, type SpooshOptions, type SpooshOptionsExtra, type SpooshPlugin, type SpooshResponse, type SpooshSchema, type StateManager, type TagOptions, type WriteClient, applyMiddlewares, buildUrl, composeMiddlewares, containsFile, createClient, createEventEmitter, createInfiniteReadController, createInitialState, createMiddleware, createOperationController, createPluginExecutor, createPluginRegistry, createProxyHandler, createSelectorProxy, createStateManager, executeFetch, extractMethodFromSelector, extractPathFromSelector, generateTags, getContentType, isJsonBody, mergeHeaders, objectToFormData, objectToUrlEncoded, resolveHeadersToRecord, resolvePath, resolveTags, setHeaders, sortObjectKeys };
|
|
1607
|
+
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type SpooshClientConfig as ClientConfig, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type EventEmitter, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type MiddlewareContext, type MiddlewareHandler, type MiddlewarePhase, type MutationSchemaHelper, type OperationController, type OperationState, type OperationType, type PageContext, type PluginAccessor, type PluginArray, type PluginContext, type PluginContextInput, type PluginExecutor, type PluginExportsRegistry, type PluginFactory, type PluginHandler, type PluginLifecycle, type PluginMiddleware, type PluginRegistry, type PluginResolvers, type PluginResponseHandler, type PluginResultResolvers, type PluginTypeConfig, type PluginUpdateHandler, type QuerySchemaHelper, type ReadClient, type RefetchEvent, type RequestOptions$1 as RequestOptions, type ResolveInstanceApi, type ResolveResultTypes, type ResolveSchemaTypes, type ResolveTypes, type ResolverContext, type RetryConfig, type RouteToPath, type SchemaPaths, type SelectedEndpoint, type SelectorFunction, type SelectorResult, Spoosh, type SpooshClient, type SpooshConfig, type SpooshInstance, type SpooshMiddleware, type SpooshOptions, type SpooshOptionsExtra, type SpooshPlugin, type SpooshResponse, type SpooshSchema, type StateManager, type TagMode, type TagOptions, type WriteClient, applyMiddlewares, buildUrl, composeMiddlewares, containsFile, createClient, createEventEmitter, createInfiniteReadController, createInitialState, createMiddleware, createOperationController, createPluginExecutor, createPluginRegistry, createProxyHandler, createSelectorProxy, createStateManager, executeFetch, extractMethodFromSelector, extractPathFromSelector, generateTags, getContentType, isJsonBody, mergeHeaders, objectToFormData, objectToUrlEncoded, resolveHeadersToRecord, resolvePath, resolveTags, setHeaders, sortObjectKeys };
|
package/dist/index.d.ts
CHANGED
|
@@ -1360,14 +1360,21 @@ declare function objectToUrlEncoded(obj: Record<string, unknown>): string;
|
|
|
1360
1360
|
|
|
1361
1361
|
declare function sortObjectKeys(obj: unknown, seen?: WeakSet<object>): unknown;
|
|
1362
1362
|
|
|
1363
|
+
type TagMode = "all" | "self" | "none";
|
|
1364
|
+
type TagModeInArray = "all" | "self";
|
|
1363
1365
|
/**
|
|
1364
1366
|
* Common tag options used across plugins and operations.
|
|
1365
1367
|
*/
|
|
1366
1368
|
type TagOptions = {
|
|
1367
|
-
/**
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1369
|
+
/**
|
|
1370
|
+
* Unified tag option (follows invalidation pattern)
|
|
1371
|
+
* - String: mode only ('all' | 'self' | 'none')
|
|
1372
|
+
* - Array: custom tags only OR [mode keyword mixed with custom tags]
|
|
1373
|
+
* - If array contains 'all' or 'self', it's treated as mode + tags
|
|
1374
|
+
* - Otherwise, it's custom tags only (replaces auto-generated tags)
|
|
1375
|
+
* - 'none' keyword should NOT be used in arrays (use string 'none' instead)
|
|
1376
|
+
*/
|
|
1377
|
+
tags?: TagMode | (TagModeInArray | (string & {}))[];
|
|
1371
1378
|
};
|
|
1372
1379
|
declare function resolveTags(options: TagOptions | undefined, resolvedPath: string[]): string[];
|
|
1373
1380
|
declare function resolvePath(path: string[], params: Record<string, string | number> | undefined): string[];
|
|
@@ -1597,4 +1604,4 @@ type CreateInfiniteReadOptions<TData, TItem, TError, TRequest> = {
|
|
|
1597
1604
|
};
|
|
1598
1605
|
declare function createInfiniteReadController<TData, TItem, TError, TRequest extends InfiniteRequestOptions = InfiniteRequestOptions>(options: CreateInfiniteReadOptions<TData, TItem, TError, TRequest>): InfiniteReadController<TData, TItem, TError>;
|
|
1599
1606
|
|
|
1600
|
-
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type SpooshClientConfig as ClientConfig, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type EventEmitter, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type MiddlewareContext, type MiddlewareHandler, type MiddlewarePhase, type MutationSchemaHelper, type OperationController, type OperationState, type OperationType, type PageContext, type PluginAccessor, type PluginArray, type PluginContext, type PluginContextInput, type PluginExecutor, type PluginExportsRegistry, type PluginFactory, type PluginHandler, type PluginLifecycle, type PluginMiddleware, type PluginRegistry, type PluginResolvers, type PluginResponseHandler, type PluginResultResolvers, type PluginTypeConfig, type PluginUpdateHandler, type QuerySchemaHelper, type ReadClient, type RefetchEvent, type RequestOptions$1 as RequestOptions, type ResolveInstanceApi, type ResolveResultTypes, type ResolveSchemaTypes, type ResolveTypes, type ResolverContext, type RetryConfig, type RouteToPath, type SchemaPaths, type SelectedEndpoint, type SelectorFunction, type SelectorResult, Spoosh, type SpooshClient, type SpooshConfig, type SpooshInstance, type SpooshMiddleware, type SpooshOptions, type SpooshOptionsExtra, type SpooshPlugin, type SpooshResponse, type SpooshSchema, type StateManager, type TagOptions, type WriteClient, applyMiddlewares, buildUrl, composeMiddlewares, containsFile, createClient, createEventEmitter, createInfiniteReadController, createInitialState, createMiddleware, createOperationController, createPluginExecutor, createPluginRegistry, createProxyHandler, createSelectorProxy, createStateManager, executeFetch, extractMethodFromSelector, extractPathFromSelector, generateTags, getContentType, isJsonBody, mergeHeaders, objectToFormData, objectToUrlEncoded, resolveHeadersToRecord, resolvePath, resolveTags, setHeaders, sortObjectKeys };
|
|
1607
|
+
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type SpooshClientConfig as ClientConfig, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type EventEmitter, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type MiddlewareContext, type MiddlewareHandler, type MiddlewarePhase, type MutationSchemaHelper, type OperationController, type OperationState, type OperationType, type PageContext, type PluginAccessor, type PluginArray, type PluginContext, type PluginContextInput, type PluginExecutor, type PluginExportsRegistry, type PluginFactory, type PluginHandler, type PluginLifecycle, type PluginMiddleware, type PluginRegistry, type PluginResolvers, type PluginResponseHandler, type PluginResultResolvers, type PluginTypeConfig, type PluginUpdateHandler, type QuerySchemaHelper, type ReadClient, type RefetchEvent, type RequestOptions$1 as RequestOptions, type ResolveInstanceApi, type ResolveResultTypes, type ResolveSchemaTypes, type ResolveTypes, type ResolverContext, type RetryConfig, type RouteToPath, type SchemaPaths, type SelectedEndpoint, type SelectorFunction, type SelectorResult, Spoosh, type SpooshClient, type SpooshConfig, type SpooshInstance, type SpooshMiddleware, type SpooshOptions, type SpooshOptionsExtra, type SpooshPlugin, type SpooshResponse, type SpooshSchema, type StateManager, type TagMode, type TagOptions, type WriteClient, applyMiddlewares, buildUrl, composeMiddlewares, containsFile, createClient, createEventEmitter, createInfiniteReadController, createInitialState, createMiddleware, createOperationController, createPluginExecutor, createPluginRegistry, createProxyHandler, createSelectorProxy, createStateManager, executeFetch, extractMethodFromSelector, extractPathFromSelector, generateTags, getContentType, isJsonBody, mergeHeaders, objectToFormData, objectToUrlEncoded, resolveHeadersToRecord, resolvePath, resolveTags, setHeaders, sortObjectKeys };
|
package/dist/index.js
CHANGED
|
@@ -247,11 +247,40 @@ function sortObjectKeys(obj, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// src/utils/path-utils.ts
|
|
250
|
+
function resolveTagMode(mode, path) {
|
|
251
|
+
switch (mode) {
|
|
252
|
+
case "all":
|
|
253
|
+
return generateTags(path);
|
|
254
|
+
case "self":
|
|
255
|
+
return [path.join("/")];
|
|
256
|
+
case "none":
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
250
260
|
function resolveTags(options, resolvedPath) {
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
261
|
+
const tagsOption = options?.tags;
|
|
262
|
+
if (!tagsOption) {
|
|
263
|
+
return generateTags(resolvedPath);
|
|
264
|
+
}
|
|
265
|
+
if (typeof tagsOption === "string") {
|
|
266
|
+
return resolveTagMode(tagsOption, resolvedPath);
|
|
267
|
+
}
|
|
268
|
+
if (Array.isArray(tagsOption)) {
|
|
269
|
+
const tags = [];
|
|
270
|
+
let mode = null;
|
|
271
|
+
for (const item of tagsOption) {
|
|
272
|
+
if (item === "all" || item === "self") {
|
|
273
|
+
mode = item;
|
|
274
|
+
} else if (typeof item === "string") {
|
|
275
|
+
tags.push(item);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (mode) {
|
|
279
|
+
tags.push(...resolveTagMode(mode, resolvedPath));
|
|
280
|
+
}
|
|
281
|
+
return [...new Set(tags)];
|
|
282
|
+
}
|
|
283
|
+
return generateTags(resolvedPath);
|
|
255
284
|
}
|
|
256
285
|
function resolvePath(path, params) {
|
|
257
286
|
if (!params) return path;
|
package/dist/index.mjs
CHANGED
|
@@ -191,11 +191,40 @@ function sortObjectKeys(obj, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
// src/utils/path-utils.ts
|
|
194
|
+
function resolveTagMode(mode, path) {
|
|
195
|
+
switch (mode) {
|
|
196
|
+
case "all":
|
|
197
|
+
return generateTags(path);
|
|
198
|
+
case "self":
|
|
199
|
+
return [path.join("/")];
|
|
200
|
+
case "none":
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
194
204
|
function resolveTags(options, resolvedPath) {
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
205
|
+
const tagsOption = options?.tags;
|
|
206
|
+
if (!tagsOption) {
|
|
207
|
+
return generateTags(resolvedPath);
|
|
208
|
+
}
|
|
209
|
+
if (typeof tagsOption === "string") {
|
|
210
|
+
return resolveTagMode(tagsOption, resolvedPath);
|
|
211
|
+
}
|
|
212
|
+
if (Array.isArray(tagsOption)) {
|
|
213
|
+
const tags = [];
|
|
214
|
+
let mode = null;
|
|
215
|
+
for (const item of tagsOption) {
|
|
216
|
+
if (item === "all" || item === "self") {
|
|
217
|
+
mode = item;
|
|
218
|
+
} else if (typeof item === "string") {
|
|
219
|
+
tags.push(item);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (mode) {
|
|
223
|
+
tags.push(...resolveTagMode(mode, resolvedPath));
|
|
224
|
+
}
|
|
225
|
+
return [...new Set(tags)];
|
|
226
|
+
}
|
|
227
|
+
return generateTags(resolvedPath);
|
|
199
228
|
}
|
|
200
229
|
function resolvePath(path, params) {
|
|
201
230
|
if (!params) return path;
|