@frontic/nuxt 0.8.4 → 1.1.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 +65 -4
- package/dist/module.d.mts +2 -132
- package/dist/module.json +2 -2
- package/dist/module.mjs +130 -15
- 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 +25 -4
- package/dist/runtime/composables/useFronticClient.d.ts +9 -28
- package/dist/runtime/composables/useFronticClient.js +59 -48
- 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 +28 -5
- package/dist/runtime/composables/useFronticPage.d.ts +35 -16
- package/dist/runtime/composables/useFronticPage.js +42 -20
- package/dist/runtime/composables/useFronticSearch.d.ts +4 -96
- package/dist/runtime/composables/useFronticSearch.js +193 -60
- package/dist/runtime/composables/useFronticTree.d.ts +23 -14
- package/dist/runtime/composables/useFronticTree.js +25 -5
- package/dist/runtime/server/api/frontic/[...path].js +48 -10
- package/dist/runtime/server/middleware/sitemap.d.ts +2 -0
- package/dist/runtime/server/middleware/sitemap.js +55 -0
- 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 +36 -0
- package/dist/runtime/types/client.js +0 -0
- package/dist/runtime/types/errors.d.ts +47 -0
- package/dist/runtime/types/errors.js +1 -0
- package/dist/runtime/types/index.d.ts +9 -3
- package/dist/runtime/types/listing.d.ts +113 -251
- package/dist/runtime/types/options.d.ts +169 -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 +90 -38
- package/dist/runtime/utils/describe-error.d.ts +38 -0
- package/dist/runtime/utils/describe-error.js +38 -0
- package/dist/runtime/utils/errors.d.ts +22 -0
- package/dist/runtime/utils/errors.js +3 -0
- package/dist/runtime/utils/filter-helpers.d.ts +13 -0
- package/dist/runtime/utils/filter-helpers.js +14 -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/resolve-context-domain.d.ts +14 -0
- package/dist/runtime/utils/resolve-context-domain.js +9 -1
- 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
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const MAX_CAUSE_DEPTH = 5;
|
|
2
|
+
export function describeErrorChain(error) {
|
|
3
|
+
const chain = [];
|
|
4
|
+
let current = error;
|
|
5
|
+
for (let depth = 0; current instanceof Error && depth < MAX_CAUSE_DEPTH; depth++) {
|
|
6
|
+
const code = current.code;
|
|
7
|
+
chain.push(`${current.name}${code ? `(${code})` : ""}: ${current.message}`);
|
|
8
|
+
current = current.cause;
|
|
9
|
+
}
|
|
10
|
+
return chain.length > 0 ? chain : [String(error)];
|
|
11
|
+
}
|
|
12
|
+
export function isTimeoutError(error) {
|
|
13
|
+
let current = error;
|
|
14
|
+
for (let depth = 0; current instanceof Error && depth < MAX_CAUSE_DEPTH; depth++) {
|
|
15
|
+
const code = current.code;
|
|
16
|
+
if (current.name === "TimeoutError" || current.name === "AbortError" || code === "ETIMEDOUT" || code === "ABORT_ERR") {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
current = current.cause;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
function statusOf(error) {
|
|
24
|
+
const e = error;
|
|
25
|
+
for (const candidate of [e?.statusCode, e?.status, e?.response?.status]) {
|
|
26
|
+
if (typeof candidate === "number") return candidate;
|
|
27
|
+
}
|
|
28
|
+
return void 0;
|
|
29
|
+
}
|
|
30
|
+
export function toFetchErrorDetail(error) {
|
|
31
|
+
const chain = describeErrorChain(error);
|
|
32
|
+
return {
|
|
33
|
+
error,
|
|
34
|
+
chain,
|
|
35
|
+
message: chain.join(" <- "),
|
|
36
|
+
...statusOf(error) !== void 0 && { status: statusOf(error) }
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Helper Utilities
|
|
3
|
+
*
|
|
4
|
+
* The Fetch API returns two error bodies, told apart by `code`: it is present
|
|
5
|
+
* exactly when the failure was raised deliberately, so a 500 never carries
|
|
6
|
+
* one. The body arrives on the thrown fetch error's `data`, not as a resolved
|
|
7
|
+
* response.
|
|
8
|
+
*/
|
|
9
|
+
import type { ApiError } from '../types/registry.js';
|
|
10
|
+
/**
|
|
11
|
+
* Narrow an unknown error body to the deliberately-raised shape.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const { error } = useFronticBlock('ProductCard', key)
|
|
16
|
+
* const body = (error.value as { data?: unknown } | null)?.data
|
|
17
|
+
* if (isApiError(body) && body.code === 'KEY_NOT_FOUND') {
|
|
18
|
+
* // `code` and `correlationId` are typed here
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function isApiError(value: unknown): value is ApiError;
|
|
@@ -146,3 +146,16 @@ export declare function hasFilter<T = Record<string, unknown>>(filterList: Equal
|
|
|
146
146
|
* @returns Array of current filter values, or empty array if no filter exists
|
|
147
147
|
*/
|
|
148
148
|
export declare function getFilterValues<T = Record<string, unknown>>(filterList: EqualsFilter<T>[], field: keyof T & string): T[keyof T][];
|
|
149
|
+
/**
|
|
150
|
+
* Split a field -> value map into the three lists the query is built from.
|
|
151
|
+
*
|
|
152
|
+
* Routes each field exactly as the mutators would: range values by shape, and
|
|
153
|
+
* everything else into the or- or and-list depending on `orFields`. Seeded
|
|
154
|
+
* state therefore produces the same query an interaction would, rather than a
|
|
155
|
+
* second parallel notion of what a filter means.
|
|
156
|
+
*/
|
|
157
|
+
export declare function seedFilterLists<T = Record<string, unknown>>(initial: Partial<Record<keyof T & string, unknown>> | undefined, orFields: Array<keyof T & string>): {
|
|
158
|
+
or: EqualsFilter<T>[];
|
|
159
|
+
and: EqualsFilter<T>[];
|
|
160
|
+
range: RangeFilter[];
|
|
161
|
+
};
|
|
@@ -70,3 +70,17 @@ export function getFilterValues(filterList, field) {
|
|
|
70
70
|
if (!filter) return [];
|
|
71
71
|
return Array.isArray(filter.value) ? filter.value : [filter.value];
|
|
72
72
|
}
|
|
73
|
+
export function seedFilterLists(initial, orFields) {
|
|
74
|
+
const lists = { or: [], and: [], range: [] };
|
|
75
|
+
if (!initial) return lists;
|
|
76
|
+
for (const [field, value] of Object.entries(initial)) {
|
|
77
|
+
if (value === void 0 || value === null) continue;
|
|
78
|
+
if (isRangeFilterValue(value)) {
|
|
79
|
+
lists.range = manageRangeFilter(lists.range, field, value);
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const target = orFields.includes(field) ? "or" : "and";
|
|
83
|
+
lists[target] = manageFilter(lists[target], field, value);
|
|
84
|
+
}
|
|
85
|
+
return lists;
|
|
86
|
+
}
|
|
@@ -5,3 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export { makeEqualsFilter, makeLogicalFilter, manageFilter, removeFilter, hasFilter, getFilterValues, type EqualsFilter, type LogicalFilter } from './filter-helpers.js';
|
|
7
7
|
export { makeFilterState, processAvailableFilters, processAvailableSorts, applyFilterConfig, countActiveFilters, parseSortString, isSortAllowed } from './state-helpers.js';
|
|
8
|
+
export { DEFAULT_STALE_TIME, requestContextSlot, toKeyPart } from './query-keys.js';
|
|
9
|
+
export { isApiError } from './errors.js';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { makeEqualsFilter, makeLogicalFilter, manageFilter, removeFilter, hasFilter, getFilterValues } from "./filter-helpers.js";
|
|
2
2
|
export { makeFilterState, processAvailableFilters, processAvailableSorts, applyFilterConfig, countActiveFilters, parseSortString, isSortAllowed } from "./state-helpers.js";
|
|
3
|
+
export { DEFAULT_STALE_TIME, requestContextSlot, toKeyPart } from "./query-keys.js";
|
|
4
|
+
export { isApiError } from "./errors.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Key Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared building blocks for the per-entity query key factories.
|
|
5
|
+
*/
|
|
6
|
+
/** Default stale time for all Frontic queries (5 minutes) */
|
|
7
|
+
export declare const DEFAULT_STALE_TIME: number;
|
|
8
|
+
/**
|
|
9
|
+
* Request context slot appended to every detail key, so responses fetched
|
|
10
|
+
* under different contexts (personalization token) or context domains
|
|
11
|
+
* (locale/region domain) never share a cache entry. `null` marks "not set" —
|
|
12
|
+
* Pinia Colada forbids `undefined` inside keys.
|
|
13
|
+
*
|
|
14
|
+
* `requestUrl` is deliberately absent: it is per-route request metadata
|
|
15
|
+
* (attribution/tracking), not content identity — keying on it would fragment
|
|
16
|
+
* the cache into one entry per visited URL.
|
|
17
|
+
*/
|
|
18
|
+
export declare function requestContextSlot(contextKey?: string, contextDomain?: string): {
|
|
19
|
+
readonly context: string | null;
|
|
20
|
+
readonly domain: string | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Makes an object usable inside a query key: Pinia Colada keys must be JSON
|
|
24
|
+
* values, so `undefined` entries are dropped recursively. Property order does
|
|
25
|
+
* not matter — the cache normalises objects order-insensitively.
|
|
26
|
+
*/
|
|
27
|
+
export declare function toKeyPart(value: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const DEFAULT_STALE_TIME = 1e3 * 60 * 5;
|
|
2
|
+
export function requestContextSlot(contextKey, contextDomain) {
|
|
3
|
+
return { context: contextKey ?? null, domain: contextDomain ?? null };
|
|
4
|
+
}
|
|
5
|
+
export function toKeyPart(value) {
|
|
6
|
+
return stripUndefined(value);
|
|
7
|
+
}
|
|
8
|
+
function stripUndefined(value) {
|
|
9
|
+
if (Array.isArray(value)) return value.map(stripUndefined);
|
|
10
|
+
if (value && typeof value === "object") {
|
|
11
|
+
const result = {};
|
|
12
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
13
|
+
if (entry !== void 0) result[key] = stripUndefined(entry);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
@@ -1 +1,15 @@
|
|
|
1
1
|
export declare function resolveI18nContextDomain(): string | undefined;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the contextDomain a request will actually carry.
|
|
4
|
+
*
|
|
5
|
+
* The client injects this into every request; the composables key on it, so
|
|
6
|
+
* that responses fetched under different domains never share a cache entry.
|
|
7
|
+
* Both sides must call this — deriving the request from one value and the
|
|
8
|
+
* query key from another is what FSC-4523 was.
|
|
9
|
+
*
|
|
10
|
+
* Reads `useNuxtApp()` when the module config is `true`, so call it during
|
|
11
|
+
* setup rather than from a lazily evaluated query key.
|
|
12
|
+
*
|
|
13
|
+
* @param override - A per-call domain, or `false` to send none.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveContextDomain(override?: false | string): string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useNuxtApp } from "nuxt/app";
|
|
1
|
+
import { useNuxtApp, useRuntimeConfig } from "nuxt/app";
|
|
2
2
|
export function resolveI18nContextDomain() {
|
|
3
3
|
try {
|
|
4
4
|
const app = useNuxtApp();
|
|
@@ -15,3 +15,11 @@ export function resolveI18nContextDomain() {
|
|
|
15
15
|
}
|
|
16
16
|
return void 0;
|
|
17
17
|
}
|
|
18
|
+
export function resolveContextDomain(override) {
|
|
19
|
+
if (override === false) return void 0;
|
|
20
|
+
if (typeof override === "string") return override;
|
|
21
|
+
const configDomain = useRuntimeConfig().public.frontic?.contextDomain;
|
|
22
|
+
if (typeof configDomain === "string") return configDomain;
|
|
23
|
+
if (configDomain === true) return resolveI18nContextDomain();
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
@@ -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": "
|
|
3
|
+
"version": "1.1.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.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
|
-
}
|