@frontic/nuxt 0.8.0 → 0.8.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.
|
@@ -5,14 +5,20 @@ import type { FronticRequestOptions } from '../types/listing.js';
|
|
|
5
5
|
* Extracts the `items` array type from a tree response.
|
|
6
6
|
*
|
|
7
7
|
* When the user has a generated client, `Responses[T]` resolves to the concrete
|
|
8
|
-
* tree response shape (`{ items
|
|
8
|
+
* tree response shape (`{ items?: TreeNode[] }`) and this gives back the typed
|
|
9
9
|
* node array — so consumers get full IDE autocomplete on `node.$items`,
|
|
10
10
|
* `node.key`, and the block fields. Falls back to `unknown[]` against the
|
|
11
11
|
* ambient `Responses { [key: string]: unknown }` declaration.
|
|
12
|
+
*
|
|
13
|
+
* The generated `items` property is optional (the API may omit it), so the
|
|
14
|
+
* conditional matches `items?:` and strips `undefined` from the inferred type.
|
|
15
|
+
* The `unknown extends I` guard handles the ambient case where `TResponse` is
|
|
16
|
+
* `unknown` and `I` is inferred as `unknown`: without it, the branch would
|
|
17
|
+
* return bare `unknown` instead of the intended `unknown[]` array fallback.
|
|
12
18
|
*/
|
|
13
|
-
type TreeItems<TResponse> = TResponse extends {
|
|
14
|
-
items
|
|
15
|
-
} ? I : unknown[];
|
|
19
|
+
type TreeItems<TResponse> = [TResponse] extends [{
|
|
20
|
+
items?: infer I;
|
|
21
|
+
}] ? (unknown extends I ? unknown[] : Exclude<I, undefined>) : unknown[];
|
|
16
22
|
export interface UseFronticTreeOptions extends FronticRequestOptions {
|
|
17
23
|
/**
|
|
18
24
|
* Optional starting node key. When provided, the response contains the
|
|
@@ -52,6 +52,12 @@ declare module '@frontic/stack/generated-client' {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
declare module '@frontic/stack/generated-types' {
|
|
55
|
+
export interface RequestOptions {
|
|
56
|
+
requestUrl?: string
|
|
57
|
+
contextKey?: string
|
|
58
|
+
contextDomain?: string
|
|
59
|
+
proxyUrl?: string
|
|
60
|
+
}
|
|
55
61
|
export interface Blocks {}
|
|
56
62
|
export interface BlockData {}
|
|
57
63
|
export interface Pages {}
|
|
@@ -6,32 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { MaybeRef, Ref, ShallowRef } from 'vue';
|
|
8
8
|
import type { UseQueryReturn } from '@pinia/colada';
|
|
9
|
-
import type { Listings, ListingParameters, ListingQueryFilters, ListingQuerySorts, Responses } from '@frontic/stack/generated-types';
|
|
9
|
+
import type { Listings, ListingParameters, ListingQueryFilters, ListingQuerySorts, RequestOptions, Responses } from '@frontic/stack/generated-types';
|
|
10
10
|
export type { Listings, ListingParameters, ListingQueryFilters, ListingQuerySorts, Responses };
|
|
11
11
|
export type { Query, Sort, EqualsFilter, LogicalFilter, Filter, RangeFilter, ContainsFilter } from '@frontic/stack/query-types';
|
|
12
12
|
/**
|
|
13
|
-
* Shared request options for all Frontic composables
|
|
14
|
-
* These options match the client's RequestOptions interface
|
|
13
|
+
* Shared request options for all Frontic composables.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* Derived from the client's `RequestOptions` so new fields and renames flow
|
|
16
|
+
* through automatically. Each field is wrapped in `MaybeRef` so callers can
|
|
17
|
+
* pass reactive values, and the surface is narrowed to the options that make
|
|
18
|
+
* sense in a Nuxt composable context (proxyUrl is configured at module level).
|
|
18
19
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
contextKey?: MaybeRef<string | undefined>;
|
|
24
|
-
/**
|
|
25
|
-
* Context domain to override the global contextDomain for this request
|
|
26
|
-
* Used to indicate the requested region and locale
|
|
27
|
-
*/
|
|
28
|
-
contextDomain?: MaybeRef<string | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
* Request URL for analytics/tracking purposes
|
|
31
|
-
* URL to the current page, used by the Fetch API for tracking
|
|
32
|
-
*/
|
|
33
|
-
requestUrl?: MaybeRef<string | undefined>;
|
|
34
|
-
}
|
|
20
|
+
export type FronticRequestOptions = {
|
|
21
|
+
[K in 'contextKey' | 'contextDomain' | 'requestUrl']?: MaybeRef<RequestOptions[K] | undefined>;
|
|
22
|
+
};
|
|
35
23
|
/**
|
|
36
24
|
* Inclusion mode for configuring which fields to show
|
|
37
25
|
* - 'include': Only show specified keys
|
package/package.json
CHANGED