@cmssy/core 9.10.0 → 10.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/dist/csp-Blh6P15m.d.ts +189 -0
- package/dist/csp-DlAEXYjA.d.cts +189 -0
- package/dist/index.cjs +43 -1409
- package/dist/index.d.cts +6 -401
- package/dist/index.d.ts +6 -401
- package/dist/index.js +44 -1331
- package/dist/internal/locale.cjs +279 -0
- package/dist/internal/locale.d.cts +28 -0
- package/dist/internal/locale.d.ts +28 -0
- package/dist/internal/locale.js +267 -0
- package/dist/internal.cjs +955 -0
- package/dist/internal.d.cts +65 -0
- package/dist/internal.d.ts +65 -0
- package/dist/internal.js +913 -0
- package/dist/locale-XintNd0n.d.ts +52 -0
- package/dist/locale-rhYcXU5z.d.cts +52 -0
- package/package.json +12 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
|
|
2
|
+
import { CmssyClientConfig, CmssyLocaleContext } from '@cmssy/types';
|
|
3
|
+
|
|
4
|
+
interface GraphqlRequestOptions {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Route through the org-scoped public delivery path instead of the base
|
|
10
|
+
* `/graphql` endpoint. Set for unauthenticated public queries so the backend
|
|
11
|
+
* resolves the workspace from the URL rather than a global slug lookup.
|
|
12
|
+
*/
|
|
13
|
+
public?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Retry transient HTTP failures (429/503, honoring Retry-After). Off by
|
|
16
|
+
* default: this function also carries mutations (auth, cart, checkout),
|
|
17
|
+
* which must never be blind-retried. Read-only callers opt in with `{}`.
|
|
18
|
+
*/
|
|
19
|
+
retry?: RetryPolicy | false;
|
|
20
|
+
}
|
|
21
|
+
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Rewrites an internal href to carry the active locale as a path prefix.
|
|
25
|
+
* External hrefs, fragments and relative paths are returned untouched. Already
|
|
26
|
+
* prefixed hrefs are normalized so the prefix never doubles.
|
|
27
|
+
*/
|
|
28
|
+
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the href that switches the current `pathname` to `target` locale,
|
|
31
|
+
* preserving the rest of the path. Used by a language switcher.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
|
|
34
|
+
/**
|
|
35
|
+
* Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
|
|
36
|
+
* For rich-text content stored in CMS blocks where links are raw markup.
|
|
37
|
+
*/
|
|
38
|
+
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
39
|
+
|
|
40
|
+
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
41
|
+
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
42
|
+
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
43
|
+
locale: string;
|
|
44
|
+
path: string[] | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the locale a path asks for. The prefix IS the language, so a routed
|
|
48
|
+
* path is all it takes - no request, no headers, static-safe.
|
|
49
|
+
*/
|
|
50
|
+
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
51
|
+
|
|
52
|
+
export { CMSSY_LOCALE_HEADER as C, type GraphqlRequestOptions as G, localeForPath as a, buildLocaleSwitchHref as b, localeForPathname as c, localizeHtmlLinks as d, graphqlRequest as g, localizeHref as l, splitCmssyLocale as s };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.cjs';
|
|
2
|
+
import { CmssyClientConfig, CmssyLocaleContext } from '@cmssy/types';
|
|
3
|
+
|
|
4
|
+
interface GraphqlRequestOptions {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Route through the org-scoped public delivery path instead of the base
|
|
10
|
+
* `/graphql` endpoint. Set for unauthenticated public queries so the backend
|
|
11
|
+
* resolves the workspace from the URL rather than a global slug lookup.
|
|
12
|
+
*/
|
|
13
|
+
public?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Retry transient HTTP failures (429/503, honoring Retry-After). Off by
|
|
16
|
+
* default: this function also carries mutations (auth, cart, checkout),
|
|
17
|
+
* which must never be blind-retried. Read-only callers opt in with `{}`.
|
|
18
|
+
*/
|
|
19
|
+
retry?: RetryPolicy | false;
|
|
20
|
+
}
|
|
21
|
+
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Rewrites an internal href to carry the active locale as a path prefix.
|
|
25
|
+
* External hrefs, fragments and relative paths are returned untouched. Already
|
|
26
|
+
* prefixed hrefs are normalized so the prefix never doubles.
|
|
27
|
+
*/
|
|
28
|
+
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the href that switches the current `pathname` to `target` locale,
|
|
31
|
+
* preserving the rest of the path. Used by a language switcher.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
|
|
34
|
+
/**
|
|
35
|
+
* Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
|
|
36
|
+
* For rich-text content stored in CMS blocks where links are raw markup.
|
|
37
|
+
*/
|
|
38
|
+
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
39
|
+
|
|
40
|
+
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
41
|
+
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
42
|
+
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
43
|
+
locale: string;
|
|
44
|
+
path: string[] | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the locale a path asks for. The prefix IS the language, so a routed
|
|
48
|
+
* path is all it takes - no request, no headers, static-safe.
|
|
49
|
+
*/
|
|
50
|
+
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
51
|
+
|
|
52
|
+
export { CMSSY_LOCALE_HEADER as C, type GraphqlRequestOptions as G, localeForPath as a, buildLocaleSwitchHref as b, localeForPathname as c, localizeHtmlLinks as d, graphqlRequest as g, localizeHref as l, splitCmssyLocale as s };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Framework-agnostic cmssy
|
|
3
|
+
"version": "10.1.0",
|
|
4
|
+
"description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
7
7
|
"cms",
|
|
@@ -27,6 +27,16 @@
|
|
|
27
27
|
"import": "./dist/index.js",
|
|
28
28
|
"require": "./dist/index.cjs"
|
|
29
29
|
},
|
|
30
|
+
"./internal": {
|
|
31
|
+
"types": "./dist/internal.d.ts",
|
|
32
|
+
"import": "./dist/internal.js",
|
|
33
|
+
"require": "./dist/internal.cjs"
|
|
34
|
+
},
|
|
35
|
+
"./internal/locale": {
|
|
36
|
+
"types": "./dist/internal/locale.d.ts",
|
|
37
|
+
"import": "./dist/internal/locale.js",
|
|
38
|
+
"require": "./dist/internal/locale.cjs"
|
|
39
|
+
},
|
|
30
40
|
"./testing": {
|
|
31
41
|
"types": "./dist/testing.d.ts",
|
|
32
42
|
"import": "./dist/testing.js",
|