@frontic/nuxt 0.8.3 → 1.0.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/README.md +30 -2
- package/dist/module.d.mts +2 -132
- package/dist/module.json +2 -2
- package/dist/module.mjs +63 -7
- package/dist/runtime/composables/analytics.d.ts +82 -0
- package/dist/runtime/composables/analytics.js +38 -0
- package/dist/runtime/composables/blocks.d.ts +24 -22
- package/dist/runtime/composables/blocks.js +16 -16
- package/dist/runtime/composables/index.d.ts +1 -1
- package/dist/runtime/composables/listings.d.ts +22 -13
- package/dist/runtime/composables/listings.js +24 -25
- package/dist/runtime/composables/pages.d.ts +21 -18
- package/dist/runtime/composables/pages.js +15 -16
- package/dist/runtime/composables/trees.d.ts +24 -22
- package/dist/runtime/composables/trees.js +15 -25
- package/dist/runtime/composables/useFronticBlock.d.ts +22 -13
- package/dist/runtime/composables/useFronticBlock.js +19 -2
- package/dist/runtime/composables/useFronticClient.d.ts +6 -3
- package/dist/runtime/composables/useFronticContext.d.ts +12 -0
- package/dist/runtime/composables/useFronticContext.js +71 -9
- package/dist/runtime/composables/useFronticListing.d.ts +23 -19
- package/dist/runtime/composables/useFronticListing.js +22 -3
- package/dist/runtime/composables/useFronticPage.d.ts +35 -16
- package/dist/runtime/composables/useFronticPage.js +36 -7
- package/dist/runtime/composables/useFronticSearch.d.ts +4 -96
- package/dist/runtime/composables/useFronticSearch.js +179 -51
- package/dist/runtime/composables/useFronticTree.d.ts +23 -14
- package/dist/runtime/composables/useFronticTree.js +19 -2
- package/dist/runtime/server/plugins/fetch-secret.d.ts +2 -0
- package/dist/runtime/server/plugins/fetch-secret.js +20 -0
- package/dist/runtime/types/client.d.ts +34 -0
- package/dist/runtime/types/client.js +0 -0
- package/dist/runtime/types/index.d.ts +8 -3
- package/dist/runtime/types/listing.d.ts +113 -251
- package/dist/runtime/types/options.d.ts +139 -0
- package/dist/runtime/types/options.js +0 -0
- package/dist/runtime/types/query.d.ts +88 -0
- package/dist/runtime/types/query.js +0 -0
- package/dist/runtime/types/registry.d.ts +272 -0
- package/dist/runtime/types/registry.js +0 -0
- package/dist/runtime/types/search.d.ts +56 -36
- package/dist/runtime/utils/errors.d.ts +22 -0
- package/dist/runtime/utils/errors.js +3 -0
- package/dist/runtime/utils/index.d.ts +2 -0
- package/dist/runtime/utils/index.js +2 -0
- package/dist/runtime/utils/query-keys.d.ts +27 -0
- package/dist/runtime/utils/query-keys.js +18 -0
- package/dist/runtime/utils/state-helpers.d.ts +3 -6
- package/dist/runtime/utils/state-helpers.js +7 -8
- package/dist/types.d.mts +2 -2
- package/package.json +15 -15
- package/dist/runtime/frontic-stack.d.ts +0 -168
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Functions for processing and transforming listing state for UI consumption.
|
|
5
5
|
*/
|
|
6
|
-
import type { ListingFieldConfig, UiFilter, UiSort,
|
|
6
|
+
import type { ListingFieldConfig, UiFilter, UiSort, FilterOption } from '../types/listing.js';
|
|
7
|
+
import type { AggregationData } from '../types/registry.js';
|
|
7
8
|
/**
|
|
8
9
|
* Frontic filter response structure
|
|
9
10
|
*/
|
|
@@ -14,11 +15,7 @@ interface FrontstackFilterResponse {
|
|
|
14
15
|
* Frontic aggregation response structure
|
|
15
16
|
* Matches the _aggregation schema from the Fetch API
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
[key: string]: {
|
|
19
|
-
total: AggregationTotal;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
18
|
+
type FrontstackAggregationResponse = AggregationData;
|
|
22
19
|
/**
|
|
23
20
|
* Extracts active (selected) filters from the API response
|
|
24
21
|
*
|
|
@@ -37,7 +37,8 @@ export function processAvailableFilters(rawFilters, rawAggregation, config = {})
|
|
|
37
37
|
const shouldInclude = select.length === 0 || (mode === "include" ? isInSelect : !isInSelect);
|
|
38
38
|
if (!shouldInclude) continue;
|
|
39
39
|
const filterOptions = rawFilters?.[key] || [];
|
|
40
|
-
const
|
|
40
|
+
const aggregationEntry = rawAggregation?.[key];
|
|
41
|
+
const aggregationData = aggregationEntry && "total" in aggregationEntry ? aggregationEntry : void 0;
|
|
41
42
|
if (filterOptions.length === 0 && !aggregationData) continue;
|
|
42
43
|
const filterLabel = labels[key] || key;
|
|
43
44
|
const filterType = typeConfig[key] || "default";
|
|
@@ -61,13 +62,11 @@ export function processAvailableSorts(config = {}, responseHasSort = true) {
|
|
|
61
62
|
if (select.length === 0) return true;
|
|
62
63
|
const isInSelect = select.includes(value);
|
|
63
64
|
return mode === "include" ? isInSelect : !isInSelect;
|
|
64
|
-
}).map(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
70
|
-
);
|
|
65
|
+
}).map(([value, sortLabel]) => ({
|
|
66
|
+
key: value,
|
|
67
|
+
label: sortLabel,
|
|
68
|
+
value
|
|
69
|
+
}));
|
|
71
70
|
return sortByOrder(availableSorts, sortOrder, (s) => s.key);
|
|
72
71
|
}
|
|
73
72
|
export function applyFilterConfig(filters, config = {}) {
|
package/dist/types.d.mts
CHANGED
|
@@ -4,6 +4,6 @@ import type { default as Module } from './module.mjs'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export { type FronticComposable, type FronticComposablesConfig, type FronticOptions } from '../dist/runtime/types/options.js'
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { default } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontic/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Nuxt module for Frontic - data fetching composables with smart caching, page routing, and context management",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontic",
|
|
@@ -55,25 +55,25 @@
|
|
|
55
55
|
"clean": "rm -rf dist .nuxt"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@nuxt/kit": "^4.
|
|
59
|
-
"@pinia/colada": "^1.
|
|
60
|
-
"@pinia/colada-nuxt": "^1.0.
|
|
61
|
-
"@pinia/nuxt": "^0.
|
|
62
|
-
"@vueuse/core": "^14.
|
|
63
|
-
"pinia": "^
|
|
58
|
+
"@nuxt/kit": "^4.5.2",
|
|
59
|
+
"@pinia/colada": "^1.4.2",
|
|
60
|
+
"@pinia/colada-nuxt": "^1.0.2",
|
|
61
|
+
"@pinia/nuxt": "^1.0.2",
|
|
62
|
+
"@vueuse/core": "^14.4.0",
|
|
63
|
+
"pinia": "^4.0.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@nuxt/module-builder": "^1.0.
|
|
67
|
-
"@nuxt/schema": "^4.
|
|
68
|
-
"@nuxt/test-utils": "^4.0
|
|
69
|
-
"@vitest/coverage-v8": "^4.1.
|
|
66
|
+
"@nuxt/module-builder": "^1.0.3",
|
|
67
|
+
"@nuxt/schema": "^4.5.2",
|
|
68
|
+
"@nuxt/test-utils": "^4.1.0",
|
|
69
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
70
70
|
"h3": "^1.15.11",
|
|
71
71
|
"nitropack": "^2.13.4",
|
|
72
|
-
"nuxt": "^4.
|
|
72
|
+
"nuxt": "^4.5.2",
|
|
73
73
|
"typescript": "^6.0.3",
|
|
74
|
-
"vitest": "^4.1.
|
|
75
|
-
"vue": "^3.5.
|
|
76
|
-
"vue-tsc": "^3.
|
|
74
|
+
"vitest": "^4.1.11",
|
|
75
|
+
"vue": "^3.5.41",
|
|
76
|
+
"vue-tsc": "^3.3.11"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"nuxt": ">=4.0.0"
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ambient type declarations for @frontic/stack/* virtual modules.
|
|
3
|
-
*
|
|
4
|
-
* At runtime, @frontic/stack/* resolves to the user's .frontic/ directory
|
|
5
|
-
* directory via aliases configured by the @frontic/nuxt module.
|
|
6
|
-
* These declarations provide fallback types so that:
|
|
7
|
-
* 1. The module builds with proper .d.ts output (mkdist can resolve imports)
|
|
8
|
-
* 2. vue-tsc can typecheck without the generated client being present
|
|
9
|
-
*
|
|
10
|
-
* When the user generates their client (npx @frontic/cli generate), the actual
|
|
11
|
-
* generated types take precedence via the path alias.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
declare module '@frontic/stack/generated-client' {
|
|
15
|
-
import type { Blocks, Listings, ListingParameters, ListingQueryFilters, ListingQuerySorts, Responses, Trees } from '@frontic/stack/generated-types'
|
|
16
|
-
import type { Query } from '@frontic/stack/query-types'
|
|
17
|
-
|
|
18
|
-
export interface RequestOptions {
|
|
19
|
-
requestUrl?: string
|
|
20
|
-
contextKey?: string
|
|
21
|
-
contextDomain?: string
|
|
22
|
-
proxyUrl?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface TreeQuery {
|
|
26
|
-
key?: string
|
|
27
|
-
depth?: number
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface ClientConfig {
|
|
31
|
-
proxyUrl?: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface FrontstackClient {
|
|
35
|
-
block: <T extends keyof Blocks>(name: T, key: string, config?: RequestOptions) => Promise<Responses[T]>
|
|
36
|
-
listing: <T extends keyof Listings>(
|
|
37
|
-
name: T,
|
|
38
|
-
parameters: T extends keyof ListingParameters ? ListingParameters[T] : Record<string, unknown>,
|
|
39
|
-
config?: {
|
|
40
|
-
query?: Query<T extends keyof ListingQueryFilters ? ListingQueryFilters[T] : unknown, T extends keyof ListingQuerySorts ? ListingQuerySorts[T] : unknown>
|
|
41
|
-
} & RequestOptions
|
|
42
|
-
) => Promise<Responses[T]>
|
|
43
|
-
tree: <T extends keyof Trees>(name: T, config?: { query?: TreeQuery } & RequestOptions) => Promise<Responses[T]>
|
|
44
|
-
page: (slug: string, config?: RequestOptions) => Promise<Page>
|
|
45
|
-
context: (token: string, config?: RequestOptions) => Promise<Context>
|
|
46
|
-
contextList: (token?: string, config?: RequestOptions) => Promise<[ContextOption[], string]>
|
|
47
|
-
contextUpdate: (context: { region: string; locale: string }, token: string, config?: RequestOptions) => Promise<Context>
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function createClient(config?: ClientConfig): FrontstackClient
|
|
51
|
-
export const client: FrontstackClient
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
declare module '@frontic/stack/generated-types' {
|
|
55
|
-
export interface RequestOptions {
|
|
56
|
-
requestUrl?: string
|
|
57
|
-
contextKey?: string
|
|
58
|
-
contextDomain?: string
|
|
59
|
-
proxyUrl?: string
|
|
60
|
-
}
|
|
61
|
-
export interface Blocks {}
|
|
62
|
-
export interface BlockData {}
|
|
63
|
-
export interface Pages {}
|
|
64
|
-
export interface PageData {}
|
|
65
|
-
export interface Contexts {}
|
|
66
|
-
export interface ContextData {}
|
|
67
|
-
export interface Listings {}
|
|
68
|
-
export interface ListingParameters {}
|
|
69
|
-
export interface ListingQueryFilters {}
|
|
70
|
-
export interface ListingQuerySorts {}
|
|
71
|
-
export interface Trees {}
|
|
72
|
-
export interface Responses {
|
|
73
|
-
[key: string]: unknown
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
declare module '@frontic/stack/query-types' {
|
|
78
|
-
export interface Query<TFilter = unknown, TSort = unknown> {
|
|
79
|
-
filter?: Filter[]
|
|
80
|
-
sort?: Sort | Sort[]
|
|
81
|
-
search?: string
|
|
82
|
-
limit?: number
|
|
83
|
-
page?: number
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface Sort {
|
|
87
|
-
field: string
|
|
88
|
-
order: 'asc' | 'desc'
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface EqualsFilter {
|
|
92
|
-
type: 'equals'
|
|
93
|
-
field: string
|
|
94
|
-
value: unknown | unknown[]
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface LogicalFilter {
|
|
98
|
-
type: 'and' | 'or' | 'not'
|
|
99
|
-
filter: Array<EqualsFilter | LogicalFilter>
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export type Filter = EqualsFilter | LogicalFilter | RangeFilter | ContainsFilter
|
|
103
|
-
|
|
104
|
-
export interface RangeFilter {
|
|
105
|
-
type: 'range'
|
|
106
|
-
field: string
|
|
107
|
-
from?: unknown
|
|
108
|
-
to?: unknown
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface ContainsFilter {
|
|
112
|
-
type: 'contains'
|
|
113
|
-
field: string
|
|
114
|
-
value: string
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Global types used by composables (Page, Context, etc.)
|
|
119
|
-
declare interface Page {
|
|
120
|
-
id?: string
|
|
121
|
-
slug?: string
|
|
122
|
-
title?: string
|
|
123
|
-
type?: string
|
|
124
|
-
block?: string
|
|
125
|
-
meta?: Record<string, unknown>
|
|
126
|
-
data?: Record<string, unknown>
|
|
127
|
-
route?: RouteMeta
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
declare interface PageRoute {
|
|
131
|
-
href: string
|
|
132
|
-
path: string
|
|
133
|
-
slug: string
|
|
134
|
-
url: string
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
declare interface AlternateRoute extends PageRoute {
|
|
138
|
-
locale: string
|
|
139
|
-
region: string
|
|
140
|
-
lang?: string
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
declare interface RouteMeta {
|
|
144
|
-
code: 200 | 301 | 404
|
|
145
|
-
redirect?: PageRoute
|
|
146
|
-
alternates?: AlternateRoute[]
|
|
147
|
-
context?: {
|
|
148
|
-
region: string
|
|
149
|
-
locale: string
|
|
150
|
-
suggested?: AlternateRoute
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
declare interface Context {
|
|
155
|
-
region: string
|
|
156
|
-
locale: string
|
|
157
|
-
scope: string
|
|
158
|
-
token: string
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
declare interface ContextOption {
|
|
162
|
-
region: string
|
|
163
|
-
currency: string
|
|
164
|
-
locales: Array<{
|
|
165
|
-
key: string
|
|
166
|
-
url: string
|
|
167
|
-
}>
|
|
168
|
-
}
|