@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Ref, MaybeRef, ComputedRef } from 'vue';
|
|
2
|
-
import type {
|
|
3
|
-
import type { FronticRequestOptions } from '../types/listing.js';
|
|
2
|
+
import type { TreeName, ResponseOf } from '../types/registry.js';
|
|
3
|
+
import type { FronticRequestOptions, FronticQueryOptions } from '../types/listing.js';
|
|
4
4
|
/**
|
|
5
5
|
* Extracts the `items` array type from a tree response.
|
|
6
6
|
*
|
|
@@ -19,7 +19,7 @@ import type { FronticRequestOptions } from '../types/listing.js';
|
|
|
19
19
|
type TreeItems<TResponse> = [TResponse] extends [{
|
|
20
20
|
items?: infer I;
|
|
21
21
|
}] ? (unknown extends I ? unknown[] : Exclude<I, undefined>) : unknown[];
|
|
22
|
-
export interface UseFronticTreeOptions extends FronticRequestOptions {
|
|
22
|
+
export interface UseFronticTreeOptions extends FronticRequestOptions, FronticQueryOptions {
|
|
23
23
|
/**
|
|
24
24
|
* Optional starting node key. When provided, the response contains the
|
|
25
25
|
* subtree rooted at this node. When omitted, all root-level nodes are returned.
|
|
@@ -30,11 +30,6 @@ export interface UseFronticTreeOptions extends FronticRequestOptions {
|
|
|
30
30
|
* When omitted, all levels are returned (subject to the API's 250-node cap).
|
|
31
31
|
*/
|
|
32
32
|
depth?: MaybeRef<number | undefined>;
|
|
33
|
-
/**
|
|
34
|
-
* Cache stale time in milliseconds
|
|
35
|
-
* @default 300000 (5 minutes)
|
|
36
|
-
*/
|
|
37
|
-
staleTime?: number;
|
|
38
33
|
}
|
|
39
34
|
/**
|
|
40
35
|
* Fetch a Frontic tree by name
|
|
@@ -58,11 +53,11 @@ export interface UseFronticTreeOptions extends FronticRequestOptions {
|
|
|
58
53
|
* const { items } = useFronticTree('CategoryNavigation', { key: startKey })
|
|
59
54
|
* ```
|
|
60
55
|
*/
|
|
61
|
-
export declare function useFronticTree<T extends
|
|
56
|
+
export declare function useFronticTree<T extends TreeName>(name: T, options?: UseFronticTreeOptions): {
|
|
62
57
|
/**
|
|
63
58
|
* The full tree response, typed based on the tree name
|
|
64
59
|
*/
|
|
65
|
-
tree: Ref<
|
|
60
|
+
tree: Ref<ResponseOf<T> | undefined>;
|
|
66
61
|
/**
|
|
67
62
|
* The tree's top-level nodes (shortcut for `tree.value?.items`).
|
|
68
63
|
* Each node carries its children on `$items`.
|
|
@@ -71,18 +66,32 @@ export declare function useFronticTree<T extends keyof Trees>(name: T, options?:
|
|
|
71
66
|
* shape from their generated client — including the `$items` recursion
|
|
72
67
|
* and the fields produced by the tree's Detail Block.
|
|
73
68
|
*/
|
|
74
|
-
items: ComputedRef<TreeItems<
|
|
69
|
+
items: ComputedRef<TreeItems<ResponseOf<T>> | undefined>;
|
|
75
70
|
/**
|
|
76
|
-
*
|
|
71
|
+
* Data status: 'pending' | 'error' | 'success'
|
|
77
72
|
*/
|
|
78
73
|
status: import("vue").ShallowRef<import("@pinia/colada").DataStateStatus>;
|
|
74
|
+
/**
|
|
75
|
+
* Network status: 'idle' | 'loading'. Together with `status` this
|
|
76
|
+
* distinguishes a first load (`pending`) from a background refresh
|
|
77
|
+
* (`success` + 'loading').
|
|
78
|
+
*/
|
|
79
|
+
asyncStatus: ComputedRef<import("@pinia/colada").AsyncStatus>;
|
|
80
|
+
/**
|
|
81
|
+
* Whether a request is in flight (shortcut for `asyncStatus === 'loading'`)
|
|
82
|
+
*/
|
|
83
|
+
isLoading: import("vue").ShallowRef<boolean>;
|
|
84
|
+
/**
|
|
85
|
+
* Error of the last fetch, null while pending or after success
|
|
86
|
+
*/
|
|
87
|
+
error: import("vue").ShallowRef<Error | null>;
|
|
79
88
|
/**
|
|
80
89
|
* Manually refresh the tree data (uses cache if valid)
|
|
81
90
|
*/
|
|
82
|
-
refresh: (throwOnError?: boolean) => Promise<import("@pinia/colada").DataState<
|
|
91
|
+
refresh: (throwOnError?: boolean) => Promise<import("@pinia/colada").DataState<ResponseOf<T>, Error, undefined>>;
|
|
83
92
|
/**
|
|
84
93
|
* Force a fresh fetch of the tree data, bypassing cache
|
|
85
94
|
*/
|
|
86
|
-
refetch: (throwOnError?: boolean) => Promise<import("@pinia/colada").DataState<
|
|
95
|
+
refetch: (throwOnError?: boolean) => Promise<import("@pinia/colada").DataState<ResponseOf<T>, Error, undefined>>;
|
|
87
96
|
};
|
|
88
97
|
export {};
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
2
|
import { useQuery } from "@pinia/colada";
|
|
3
|
+
import { resolveContextDomain } from "../utils/resolve-context-domain.js";
|
|
3
4
|
import { fetchTreeQuery } from "./trees.js";
|
|
4
5
|
import { useFronticClient } from "./useFronticClient.js";
|
|
5
6
|
export function useFronticTree(name, options) {
|
|
6
|
-
const _client = useFronticClient();
|
|
7
|
+
const _client = useFronticClient({ contextDomain: false });
|
|
8
|
+
const autoContextDomain = resolveContextDomain();
|
|
9
|
+
const resolvedContextDomain = computed(() => toValue(options?.contextDomain) ?? autoContextDomain);
|
|
7
10
|
const treeQuery = fetchTreeQuery({
|
|
8
11
|
name,
|
|
9
12
|
key: options?.key,
|
|
10
13
|
depth: options?.depth,
|
|
11
14
|
contextKey: options?.contextKey,
|
|
12
|
-
contextDomain:
|
|
15
|
+
contextDomain: resolvedContextDomain,
|
|
13
16
|
requestUrl: options?.requestUrl,
|
|
14
17
|
staleTime: options?.staleTime,
|
|
18
|
+
gcTime: options?.gcTime,
|
|
19
|
+
enabled: options?.enabled,
|
|
20
|
+
keepPreviousData: options?.keepPreviousData,
|
|
15
21
|
_client
|
|
16
22
|
});
|
|
17
|
-
const { data, status, refresh, refetch } = useQuery(treeQuery);
|
|
23
|
+
const { data, status, asyncStatus, isLoading, error, refresh, refetch } = useQuery(treeQuery);
|
|
18
24
|
return {
|
|
19
25
|
/**
|
|
20
26
|
* The full tree response, typed based on the tree name
|
|
@@ -30,9 +36,23 @@ export function useFronticTree(name, options) {
|
|
|
30
36
|
*/
|
|
31
37
|
items: computed(() => data.value?.items),
|
|
32
38
|
/**
|
|
33
|
-
*
|
|
39
|
+
* Data status: 'pending' | 'error' | 'success'
|
|
34
40
|
*/
|
|
35
41
|
status,
|
|
42
|
+
/**
|
|
43
|
+
* Network status: 'idle' | 'loading'. Together with `status` this
|
|
44
|
+
* distinguishes a first load (`pending`) from a background refresh
|
|
45
|
+
* (`success` + 'loading').
|
|
46
|
+
*/
|
|
47
|
+
asyncStatus,
|
|
48
|
+
/**
|
|
49
|
+
* Whether a request is in flight (shortcut for `asyncStatus === 'loading'`)
|
|
50
|
+
*/
|
|
51
|
+
isLoading,
|
|
52
|
+
/**
|
|
53
|
+
* Error of the last fetch, null while pending or after success
|
|
54
|
+
*/
|
|
55
|
+
error,
|
|
36
56
|
/**
|
|
37
57
|
* Manually refresh the tree data (uses cache if valid)
|
|
38
58
|
*/
|
|
@@ -1,21 +1,59 @@
|
|
|
1
1
|
import { proxyRequest, getHeader, createError, defineEventHandler } from "h3";
|
|
2
|
-
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
|
+
import { useRuntimeConfig, useNitroApp } from "nitropack/runtime";
|
|
3
|
+
import { toFetchErrorDetail, isTimeoutError } from "../../../utils/describe-error.js";
|
|
4
|
+
import { FRONTIC_FETCH_ERROR_VERSION } from "../../../types/errors.js";
|
|
5
|
+
const DEFAULT_PROXY_TIMEOUT_MS = 1e4;
|
|
3
6
|
export default defineEventHandler(async (event) => {
|
|
4
7
|
const targetUrl = getHeader(event, "fs-target-url");
|
|
8
|
+
function report(error, status) {
|
|
9
|
+
const payload = {
|
|
10
|
+
operation: "proxy",
|
|
11
|
+
...targetUrl && { targetUrl },
|
|
12
|
+
...getHeader(event, "fs-context") && { contextKey: getHeader(event, "fs-context") },
|
|
13
|
+
...getHeader(event, "fs-domain") && { contextDomain: getHeader(event, "fs-domain") },
|
|
14
|
+
...getHeader(event, "fs-request-url") && { requestUrl: getHeader(event, "fs-request-url") },
|
|
15
|
+
...toFetchErrorDetail(error),
|
|
16
|
+
status,
|
|
17
|
+
version: FRONTIC_FETCH_ERROR_VERSION
|
|
18
|
+
};
|
|
19
|
+
const hooks = useNitroApp().hooks;
|
|
20
|
+
void Promise.resolve(hooks.callHook("frontic:fetch:error", payload)).catch(() => {
|
|
21
|
+
});
|
|
22
|
+
}
|
|
5
23
|
if (!targetUrl) {
|
|
6
|
-
|
|
24
|
+
const badRequest = createError({
|
|
7
25
|
statusCode: 400,
|
|
8
26
|
statusMessage: "Bad Request",
|
|
9
27
|
message: "Missing fs-target-url header"
|
|
10
28
|
});
|
|
29
|
+
report(badRequest, 400);
|
|
30
|
+
throw badRequest;
|
|
11
31
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
try {
|
|
33
|
+
if (event.node?.req?.headers) {
|
|
34
|
+
delete event.node.req.headers["fs-target-url"];
|
|
35
|
+
delete event.node.req.headers["cookie"];
|
|
36
|
+
delete event.node.req.headers["authorization"];
|
|
37
|
+
}
|
|
38
|
+
const config = useRuntimeConfig(event);
|
|
39
|
+
const fetchApiSecret = config.frontic?.fetchApiSecret;
|
|
40
|
+
if (fetchApiSecret && !getHeader(event, "fs-secret") && event.node?.req?.headers) {
|
|
41
|
+
event.node.req.headers["fs-secret"] = fetchApiSecret;
|
|
42
|
+
}
|
|
43
|
+
const configured = config.frontic?.proxyTimeout;
|
|
44
|
+
const timeout = typeof configured === "number" ? configured : DEFAULT_PROXY_TIMEOUT_MS;
|
|
45
|
+
const signal = timeout > 0 ? AbortSignal.timeout(timeout) : void 0;
|
|
46
|
+
return await proxyRequest(event, targetUrl, signal ? { fetchOptions: { signal } } : void 0);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const detail = toFetchErrorDetail(error);
|
|
49
|
+
const timedOut = isTimeoutError(error);
|
|
50
|
+
const status = timedOut ? 504 : detail.status ?? 500;
|
|
51
|
+
report(error, status);
|
|
52
|
+
throw createError({
|
|
53
|
+
statusCode: status,
|
|
54
|
+
statusMessage: timedOut ? "Gateway Timeout" : "Bad Gateway",
|
|
55
|
+
message: detail.message,
|
|
56
|
+
cause: error
|
|
57
|
+
});
|
|
19
58
|
}
|
|
20
|
-
return proxyRequest(event, targetUrl);
|
|
21
59
|
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineEventHandler, getHeader, getRequestHost, setResponseHeader, setResponseStatus, createError } from "h3";
|
|
2
|
+
import { useRuntimeConfig, defineCachedFunction } from "nitropack/runtime";
|
|
3
|
+
const SITEMAP_PATH = /^(\/.*)?\/sitemap(\d*)\.xml$/;
|
|
4
|
+
const DOMAIN_SHAPE = /^[a-z0-9.-]+(?::\d+)?(?:\/[a-z0-9._~%-]+)*$/;
|
|
5
|
+
const CACHE_MAX_AGE_SECONDS = 600;
|
|
6
|
+
const fetchSitemap = defineCachedFunction(
|
|
7
|
+
async (baseUrl, secret, domain, index) => {
|
|
8
|
+
const headers = { "fs-domain": domain };
|
|
9
|
+
if (secret) headers["fs-secret"] = secret;
|
|
10
|
+
const response = await fetch(`${baseUrl}/sitemap${index}.xml`, { headers });
|
|
11
|
+
if (response.status === 404) {
|
|
12
|
+
throw createError({ statusCode: 404, message: "Sitemap not found" });
|
|
13
|
+
}
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw createError({ statusCode: 502, message: `Sitemap upstream responded with ${response.status}` });
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
body: await response.text(),
|
|
19
|
+
etag: response.headers.get("etag") ?? void 0,
|
|
20
|
+
lastModified: response.headers.get("last-modified") ?? void 0
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "frontic-sitemap",
|
|
25
|
+
maxAge: CACHE_MAX_AGE_SECONDS,
|
|
26
|
+
swr: true,
|
|
27
|
+
getKey: (_baseUrl, _secret, domain, index) => `${domain}:${index || "0"}`,
|
|
28
|
+
shouldBypassCache: () => !!import.meta.dev
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
export default defineEventHandler(async (event) => {
|
|
32
|
+
const path = event.path.split("?")[0] ?? "";
|
|
33
|
+
const match = SITEMAP_PATH.exec(path);
|
|
34
|
+
if (!match) return;
|
|
35
|
+
const config = useRuntimeConfig(event);
|
|
36
|
+
const baseUrl = config.frontic?.sitemapBaseUrl;
|
|
37
|
+
if (!baseUrl) return;
|
|
38
|
+
const host = getRequestHost(event, { xForwardedHost: true });
|
|
39
|
+
const domain = `${host}${match[1] ?? ""}`.toLowerCase();
|
|
40
|
+
const index = match[2] ?? "";
|
|
41
|
+
const allowedDomains = config.frontic?.sitemapDomains ?? [];
|
|
42
|
+
if (domain.length > 255 || !DOMAIN_SHAPE.test(domain) || allowedDomains.length > 0 && !allowedDomains.includes(domain)) {
|
|
43
|
+
throw createError({ statusCode: 404, message: "Sitemap not found" });
|
|
44
|
+
}
|
|
45
|
+
const sitemap = await fetchSitemap(baseUrl, config.frontic?.fetchApiSecret ?? "", domain, index);
|
|
46
|
+
if (sitemap.etag && getHeader(event, "if-none-match") === sitemap.etag) {
|
|
47
|
+
setResponseStatus(event, 304);
|
|
48
|
+
return "";
|
|
49
|
+
}
|
|
50
|
+
setResponseHeader(event, "Content-Type", "text/xml; charset=utf-8");
|
|
51
|
+
setResponseHeader(event, "Cache-Control", `public, max-age=0, s-maxage=${CACHE_MAX_AGE_SECONDS}, stale-while-revalidate=3600`);
|
|
52
|
+
if (sitemap.etag) setResponseHeader(event, "ETag", sitemap.etag);
|
|
53
|
+
if (sitemap.lastModified) setResponseHeader(event, "Last-Modified", sitemap.lastModified);
|
|
54
|
+
return sitemap.body;
|
|
55
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineNitroPlugin, useRuntimeConfig } from "nitropack/runtime";
|
|
2
|
+
const PATCHED = Symbol.for("frontic.fetchSecret");
|
|
3
|
+
export default defineNitroPlugin(() => {
|
|
4
|
+
const config = useRuntimeConfig();
|
|
5
|
+
const secret = config.frontic?.fetchApiSecret;
|
|
6
|
+
if (!secret) return;
|
|
7
|
+
const upstream = globalThis.fetch;
|
|
8
|
+
if (upstream[PATCHED]) return;
|
|
9
|
+
const patched = async (input, init) => {
|
|
10
|
+
const source = init?.headers ?? (input instanceof Request ? input.headers : void 0);
|
|
11
|
+
const headers = new Headers(source);
|
|
12
|
+
if (!headers.has("fs-version") || headers.has("fs-secret") || headers.has("fs-target-url")) {
|
|
13
|
+
return upstream(input, init);
|
|
14
|
+
}
|
|
15
|
+
headers.set("fs-secret", secret);
|
|
16
|
+
return upstream(input, { ...init, headers });
|
|
17
|
+
};
|
|
18
|
+
patched[PATCHED] = true;
|
|
19
|
+
globalThis.fetch = patched;
|
|
20
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontic Client Interface
|
|
3
|
+
*
|
|
4
|
+
* Module-owned type of the client returned by `useFronticClient`. The generated
|
|
5
|
+
* runtime client (`.frontic/generated-client.ts`) implements this structurally;
|
|
6
|
+
* all name and response typing flows from the registry, so the module never
|
|
7
|
+
* depends on types exported by generated files.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
import type { BlockName, ListingName, TreeName, ListingParamsOf, ListingFiltersOf, ListingSortsOf, ResponseOf, RequestOptions, TreeQuery, Page, Context, ContextOption } from './registry.js';
|
|
11
|
+
import type { Query } from './query.js';
|
|
12
|
+
export interface FronticClient {
|
|
13
|
+
/** Fetch a block by name and key */
|
|
14
|
+
block<T extends BlockName>(name: T, key: string, config?: RequestOptions): Promise<ResponseOf<T>>;
|
|
15
|
+
/** Fetch a listing by name and parameters, with optional query options */
|
|
16
|
+
listing<T extends ListingName>(name: T, parameters: ListingParamsOf<T>, config?: {
|
|
17
|
+
query?: Query<ListingFiltersOf<T>, ListingSortsOf<T>>;
|
|
18
|
+
} & RequestOptions): Promise<ResponseOf<T>>;
|
|
19
|
+
/** Fetch a tree by name */
|
|
20
|
+
tree<T extends TreeName>(name: T, config?: {
|
|
21
|
+
query?: TreeQuery;
|
|
22
|
+
} & RequestOptions): Promise<ResponseOf<T>>;
|
|
23
|
+
/** Fetch a page by slug */
|
|
24
|
+
page(slug: string, config?: RequestOptions): Promise<Page>;
|
|
25
|
+
/** Fetch the context for a token */
|
|
26
|
+
context(token: string, config?: RequestOptions): Promise<Context>;
|
|
27
|
+
/** Fetch available context options; returns the options and the (possibly new) token */
|
|
28
|
+
contextList(token?: string, config?: RequestOptions): Promise<[ContextOption[], string]>;
|
|
29
|
+
/** Switch region/locale for the given token */
|
|
30
|
+
contextUpdate(context: {
|
|
31
|
+
region: string;
|
|
32
|
+
locale: string;
|
|
33
|
+
}, token: string, config?: RequestOptions): Promise<Context>;
|
|
34
|
+
/** Fetch the sitemap XML for a Frontic domain, optionally a sub-sitemap by index (starting at 1) */
|
|
35
|
+
sitemap(domain: string, index?: number | null, config?: RequestOptions): Promise<string>;
|
|
36
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload for the `frontic:fetch:error` hook.
|
|
3
|
+
*
|
|
4
|
+
* Fired wherever a Frontic call fails, so failures can be reported centrally
|
|
5
|
+
* instead of wired up per call site.
|
|
6
|
+
*
|
|
7
|
+
* Unlike the analytics hooks, this one fires on the server as well as the
|
|
8
|
+
* client: a request that dies during SSR is exactly the failure worth
|
|
9
|
+
* reporting, and suppressing it would hide the ones that matter most.
|
|
10
|
+
*/
|
|
11
|
+
/** Which client call failed. `contextList` and `contextUpdate` both report as `context`. */
|
|
12
|
+
export type FronticFetchOperation = 'block' | 'listing' | 'tree' | 'page' | 'context' | 'proxy' | 'sitemap';
|
|
13
|
+
export interface FronticFetchError {
|
|
14
|
+
operation: FronticFetchOperation;
|
|
15
|
+
/** Block, listing or tree name. Absent for `page`, `context`, `proxy` and `sitemap`. */
|
|
16
|
+
name?: string;
|
|
17
|
+
/** Page slug. Present for `page` only. */
|
|
18
|
+
slug?: string;
|
|
19
|
+
/** Frontic domain the sitemap was requested for. Present for `sitemap` only. */
|
|
20
|
+
domain?: string;
|
|
21
|
+
/** Resolved context domain the call was made under */
|
|
22
|
+
contextDomain?: string;
|
|
23
|
+
/** Context token the call was made under */
|
|
24
|
+
contextKey?: string;
|
|
25
|
+
/** The page URL the call originated from */
|
|
26
|
+
requestUrl?: string;
|
|
27
|
+
/** Proxy path in use, absent when the call went direct */
|
|
28
|
+
proxyUrl?: string;
|
|
29
|
+
/** Upstream URL, for proxy failures */
|
|
30
|
+
targetUrl?: string;
|
|
31
|
+
/** HTTP status. Absent when the failure never reached a response. */
|
|
32
|
+
status?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The `cause` chain, outermost first. `cause` is non-enumerable, so this is
|
|
35
|
+
* the only place the real reason — ECONNRESET, ETIMEDOUT, DNS, TLS — survives
|
|
36
|
+
* serialisation.
|
|
37
|
+
*/
|
|
38
|
+
chain: string[];
|
|
39
|
+
/** The chain as one line, for logs */
|
|
40
|
+
message: string;
|
|
41
|
+
/** The original error, for `captureException` */
|
|
42
|
+
error: unknown;
|
|
43
|
+
/** Bumped only on a breaking payload shape change, never on added fields. */
|
|
44
|
+
version: number;
|
|
45
|
+
}
|
|
46
|
+
/** Bumped only on a breaking payload shape change, never on added fields. */
|
|
47
|
+
export declare const FRONTIC_FETCH_ERROR_VERSION = 1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FRONTIC_FETCH_ERROR_VERSION = 1;
|
|
@@ -3,12 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Export all public types from this file.
|
|
5
5
|
*/
|
|
6
|
-
export type { FronticOptions, FronticComposable, FronticComposablesConfig } from '
|
|
7
|
-
export type {
|
|
6
|
+
export type { FronticOptions, FronticComposable, FronticComposablesConfig } from './options.js';
|
|
7
|
+
export type { Blocks, Listings, ListingParameters, ListingQueryFilters, ListingQuerySorts, Trees, Responses, ResponseOf, ListingParamsOf, ListingFiltersOf, ListingSortsOf, RequestOptions, TreeQuery, BlockName, ListingName, TreeName, Page, PageData, PageRoute, RouteMeta, AlternateRoute, Context, ContextOption, ApiError, InternalError, FronticApiError, DefaultApiError, DefaultInternalError, } from './registry.js';
|
|
8
|
+
export type { Query, Sort, Filter, EqualsFilter, LogicalFilter, RangeFilter, ContainsFilter } from './query.js';
|
|
9
|
+
export type { FronticClient } from './client.js';
|
|
10
|
+
export type { FronticRequestOptions, FronticQueryOptions, InclusionMode, FilterField, SortField, SortString, SortStringOf, ListingQuery, ListingEnvelope, ListingFieldConfig, FilterOption, UiFilter, UiSort, AggregationStats, Pagination, FilterData, AggregationData, FilterGroup, AggregationGroup, } from './listing.js';
|
|
8
11
|
export type { RangeFilterValue } from '../utils/filter-helpers.js';
|
|
12
|
+
export type { FronticAnalyticsItem, FronticListingTrigger, FronticListingResolved, FronticSearchCommitted, FronticPageResolved } from '../composables/analytics.js';
|
|
13
|
+
export type { FronticFetchError, FronticFetchOperation } from './errors.js';
|
|
9
14
|
export type { SearchState, UseFronticSearchOptions, UseSearchReturn } from './search.js';
|
|
10
15
|
export type { UseFronticClientOptions } from '../composables/useFronticClient.js';
|
|
11
16
|
export type { UseFronticBlockOptions } from '../composables/useFronticBlock.js';
|
|
12
17
|
export type { UseFronticPageOptions } from '../composables/useFronticPage.js';
|
|
13
|
-
export type { UseFronticContextOptions } from '../composables/useFronticContext.js';
|
|
18
|
+
export type { UseFronticContextOptions, FronticContext } from '../composables/useFronticContext.js';
|
|
14
19
|
export type { UseFronticListingOptions } from '../composables/useFronticListing.js';
|
|
20
|
+
export type { UseFronticTreeOptions } from '../composables/useFronticTree.js';
|