@sitecore-jss/sitecore-jss 0.1.0-beta.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.
- package/LICENSE.txt +202 -0
- package/README.md +7 -0
- package/dist/cjs/cache-client.js +54 -0
- package/dist/cjs/constants.js +12 -0
- package/dist/cjs/debug.js +43 -0
- package/dist/cjs/graphql/app-root-query.js +73 -0
- package/dist/cjs/graphql/graphql-edge-proxy.js +12 -0
- package/dist/cjs/graphql/index.js +11 -0
- package/dist/cjs/graphql/search-service.js +60 -0
- package/dist/cjs/graphql-request-client.js +106 -0
- package/dist/cjs/i18n/dictionary-service.js +45 -0
- package/dist/cjs/i18n/graphql-dictionary-service.js +125 -0
- package/dist/cjs/i18n/index.js +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/layout/content-styles.js +73 -0
- package/dist/cjs/layout/graphql-layout-service.js +84 -0
- package/dist/cjs/layout/index.js +18 -0
- package/dist/cjs/layout/layout-service.js +9 -0
- package/dist/cjs/layout/models.js +27 -0
- package/dist/cjs/layout/themes.js +79 -0
- package/dist/cjs/layout/utils.js +44 -0
- package/dist/cjs/media/index.js +24 -0
- package/dist/cjs/media/media-api.js +128 -0
- package/dist/cjs/models.js +2 -0
- package/dist/cjs/native-fetcher.js +183 -0
- package/dist/cjs/personalize/graphql-personalize-service.js +114 -0
- package/dist/cjs/personalize/index.js +12 -0
- package/dist/cjs/personalize/layout-personalizer.js +75 -0
- package/dist/cjs/personalize/utils.js +92 -0
- package/dist/cjs/site/graphql-error-pages-service.js +86 -0
- package/dist/cjs/site/graphql-redirects-service.js +103 -0
- package/dist/cjs/site/graphql-robots-service.js +81 -0
- package/dist/cjs/site/graphql-siteinfo-service.js +128 -0
- package/dist/cjs/site/graphql-sitemap-service.js +91 -0
- package/dist/cjs/site/index.js +22 -0
- package/dist/cjs/site/site-resolver.js +79 -0
- package/dist/cjs/site/utils.js +43 -0
- package/dist/cjs/utils/edit-frame.js +138 -0
- package/dist/cjs/utils/editing.js +122 -0
- package/dist/cjs/utils/env.js +26 -0
- package/dist/cjs/utils/index.js +25 -0
- package/dist/cjs/utils/is-server.js +10 -0
- package/dist/cjs/utils/timeout-promise.js +31 -0
- package/dist/cjs/utils/utils.js +70 -0
- package/dist/esm/cache-client.js +50 -0
- package/dist/esm/constants.js +9 -0
- package/dist/esm/debug.js +36 -0
- package/dist/esm/graphql/app-root-query.js +69 -0
- package/dist/esm/graphql/graphql-edge-proxy.js +8 -0
- package/dist/esm/graphql/index.js +4 -0
- package/dist/esm/graphql/search-service.js +56 -0
- package/dist/esm/graphql-request-client.js +99 -0
- package/dist/esm/i18n/dictionary-service.js +41 -0
- package/dist/esm/i18n/graphql-dictionary-service.js +118 -0
- package/dist/esm/i18n/index.js +2 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/layout/content-styles.js +65 -0
- package/dist/esm/layout/graphql-layout-service.js +77 -0
- package/dist/esm/layout/index.js +6 -0
- package/dist/esm/layout/layout-service.js +5 -0
- package/dist/esm/layout/models.js +24 -0
- package/dist/esm/layout/themes.js +74 -0
- package/dist/esm/layout/utils.js +39 -0
- package/dist/esm/media/index.js +2 -0
- package/dist/esm/media/media-api.js +117 -0
- package/dist/esm/models.js +1 -0
- package/dist/esm/native-fetcher.js +176 -0
- package/dist/esm/personalize/graphql-personalize-service.js +107 -0
- package/dist/esm/personalize/index.js +3 -0
- package/dist/esm/personalize/layout-personalizer.js +69 -0
- package/dist/esm/personalize/utils.js +85 -0
- package/dist/esm/site/graphql-error-pages-service.js +79 -0
- package/dist/esm/site/graphql-redirects-service.js +96 -0
- package/dist/esm/site/graphql-robots-service.js +74 -0
- package/dist/esm/site/graphql-siteinfo-service.js +121 -0
- package/dist/esm/site/graphql-sitemap-service.js +84 -0
- package/dist/esm/site/index.js +7 -0
- package/dist/esm/site/site-resolver.js +75 -0
- package/dist/esm/site/utils.js +37 -0
- package/dist/esm/utils/edit-frame.js +133 -0
- package/dist/esm/utils/editing.js +111 -0
- package/dist/esm/utils/env.js +22 -0
- package/dist/esm/utils/index.js +5 -0
- package/dist/esm/utils/is-server.js +8 -0
- package/dist/esm/utils/timeout-promise.js +28 -0
- package/dist/esm/utils/utils.js +61 -0
- package/graphql.d.ts +1 -0
- package/graphql.js +1 -0
- package/i18n.d.ts +1 -0
- package/i18n.js +1 -0
- package/layout.d.ts +1 -0
- package/layout.js +1 -0
- package/media.d.ts +1 -0
- package/media.js +1 -0
- package/package.json +71 -0
- package/personalize.d.ts +1 -0
- package/personalize.js +1 -0
- package/site.d.ts +1 -0
- package/site.js +1 -0
- package/types/cache-client.d.ts +64 -0
- package/types/constants.d.ts +6 -0
- package/types/debug.d.ts +26 -0
- package/types/graphql/app-root-query.d.ts +32 -0
- package/types/graphql/graphql-edge-proxy.d.ts +7 -0
- package/types/graphql/index.d.ts +4 -0
- package/types/graphql/search-service.d.ts +92 -0
- package/types/graphql-request-client.d.ts +88 -0
- package/types/i18n/dictionary-service.d.ts +56 -0
- package/types/i18n/graphql-dictionary-service.d.ts +65 -0
- package/types/i18n/index.d.ts +2 -0
- package/types/index.d.ts +6 -0
- package/types/layout/content-styles.d.ts +18 -0
- package/types/layout/graphql-layout-service.d.ts +59 -0
- package/types/layout/index.d.ts +6 -0
- package/types/layout/layout-service.d.ts +20 -0
- package/types/layout/models.d.ts +140 -0
- package/types/layout/themes.d.ts +11 -0
- package/types/layout/utils.d.ts +17 -0
- package/types/media/index.d.ts +2 -0
- package/types/media/media-api.d.ts +69 -0
- package/types/models.d.ts +6 -0
- package/types/native-fetcher.d.ts +92 -0
- package/types/personalize/graphql-personalize-service.d.ts +77 -0
- package/types/personalize/index.d.ts +3 -0
- package/types/personalize/layout-personalizer.d.ts +25 -0
- package/types/personalize/utils.d.ts +53 -0
- package/types/site/graphql-error-pages-service.d.ts +55 -0
- package/types/site/graphql-redirects-service.d.ts +66 -0
- package/types/site/graphql-robots-service.d.ts +47 -0
- package/types/site/graphql-siteinfo-service.d.ts +69 -0
- package/types/site/graphql-sitemap-service.d.ts +53 -0
- package/types/site/index.d.ts +7 -0
- package/types/site/site-resolver.d.ts +27 -0
- package/types/site/utils.d.ts +24 -0
- package/types/utils/edit-frame.d.ts +76 -0
- package/types/utils/editing.d.ts +58 -0
- package/types/utils/env.d.ts +7 -0
- package/types/utils/index.d.ts +5 -0
- package/types/utils/is-server.d.ts +6 -0
- package/types/utils/timeout-promise.d.ts +18 -0
- package/types/utils/utils.d.ts +18 -0
- package/utils.d.ts +1 -0
- package/utils.js +1 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { GraphQLClient } from '../graphql';
|
|
2
|
+
import { CacheOptions, CacheClient } from '../cache-client';
|
|
3
|
+
import { GraphQLRequestClientFactory } from '../graphql-request-client';
|
|
4
|
+
export declare const REDIRECT_TYPE_301 = "REDIRECT_301";
|
|
5
|
+
export declare const REDIRECT_TYPE_302 = "REDIRECT_302";
|
|
6
|
+
export declare const REDIRECT_TYPE_SERVER_TRANSFER = "SERVER_TRANSFER";
|
|
7
|
+
export declare type RedirectInfo = {
|
|
8
|
+
pattern: string;
|
|
9
|
+
target: string;
|
|
10
|
+
redirectType: string;
|
|
11
|
+
isQueryStringPreserved: boolean;
|
|
12
|
+
locale: string;
|
|
13
|
+
};
|
|
14
|
+
export declare type GraphQLRedirectsServiceConfig = CacheOptions & {
|
|
15
|
+
/**
|
|
16
|
+
* Override fetch method. Uses 'GraphQLRequestClient' default otherwise.
|
|
17
|
+
*/
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
/**
|
|
20
|
+
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
21
|
+
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
22
|
+
*/
|
|
23
|
+
clientFactory: GraphQLRequestClientFactory;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The schema of data returned in response to redirects array request
|
|
27
|
+
*/
|
|
28
|
+
export declare type RedirectsQueryResult = {
|
|
29
|
+
site: {
|
|
30
|
+
siteInfo: {
|
|
31
|
+
redirects: RedirectInfo[];
|
|
32
|
+
} | null;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* The GraphQLRedirectsService class is used to query the JSS redirects using Graphql endpoint
|
|
37
|
+
*/
|
|
38
|
+
export declare class GraphQLRedirectsService {
|
|
39
|
+
private options;
|
|
40
|
+
private graphQLClient;
|
|
41
|
+
private cache;
|
|
42
|
+
protected get query(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Creates an instance of graphQL redirects service with the provided options
|
|
45
|
+
* @param {GraphQLRedirectsServiceConfig} options instance
|
|
46
|
+
*/
|
|
47
|
+
constructor(options: GraphQLRedirectsServiceConfig);
|
|
48
|
+
/**
|
|
49
|
+
* Fetch an array of redirects from API
|
|
50
|
+
* @param {string} siteName site name
|
|
51
|
+
* @returns Promise<RedirectInfo[]>
|
|
52
|
+
* @throws {Error} if the siteName is empty.
|
|
53
|
+
*/
|
|
54
|
+
fetchRedirects(siteName: string): Promise<RedirectInfo[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Gets a GraphQL client that can make requests to the API.
|
|
57
|
+
* @returns {GraphQLClient} implementation
|
|
58
|
+
*/
|
|
59
|
+
protected getGraphQLClient(): GraphQLClient;
|
|
60
|
+
/**
|
|
61
|
+
* Gets cache client implementation
|
|
62
|
+
* Override this method if custom cache needs to be used
|
|
63
|
+
* @returns CacheClient instance
|
|
64
|
+
*/
|
|
65
|
+
protected getCacheClient(): CacheClient<RedirectsQueryResult>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { GraphQLClient } from '../graphql';
|
|
2
|
+
import { GraphQLRequestClientFactory } from '../graphql-request-client';
|
|
3
|
+
export declare type GraphQLRobotsServiceConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* The JSS application name
|
|
6
|
+
*/
|
|
7
|
+
siteName: string;
|
|
8
|
+
/**
|
|
9
|
+
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
10
|
+
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
11
|
+
*/
|
|
12
|
+
clientFactory: GraphQLRequestClientFactory;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The schema of data returned in response to robots.txt request
|
|
16
|
+
*/
|
|
17
|
+
export declare type RobotsQueryResult = {
|
|
18
|
+
site: {
|
|
19
|
+
siteInfo: {
|
|
20
|
+
robots: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Service that fetch the robots.txt data using Sitecore's GraphQL API.
|
|
26
|
+
*/
|
|
27
|
+
export declare class GraphQLRobotsService {
|
|
28
|
+
options: GraphQLRobotsServiceConfig;
|
|
29
|
+
private graphQLClient;
|
|
30
|
+
protected get query(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Creates an instance of graphQL robots.txt service with the provided options
|
|
33
|
+
* @param {GraphQLRobotsServiceConfig} options instance
|
|
34
|
+
*/
|
|
35
|
+
constructor(options: GraphQLRobotsServiceConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Fetch a data of robots.txt from API
|
|
38
|
+
* @returns text of robots.txt
|
|
39
|
+
* @throws {Error} if the siteName is empty.
|
|
40
|
+
*/
|
|
41
|
+
fetchRobots(): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Gets a GraphQL client that can make requests to the API.
|
|
44
|
+
* @returns {GraphQLClient} implementation
|
|
45
|
+
*/
|
|
46
|
+
protected getGraphQLClient(): GraphQLClient;
|
|
47
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { GraphQLClient } from '../graphql';
|
|
2
|
+
import { CacheClient, CacheOptions } from '../cache-client';
|
|
3
|
+
import { GraphQLRequestClientFactory } from '../graphql-request-client';
|
|
4
|
+
export declare type SiteInfo = {
|
|
5
|
+
/**
|
|
6
|
+
* Additional user-defined properties
|
|
7
|
+
*/
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Site name
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Site host name. May include multiple values (separated by '|') and wildcards ('*')
|
|
15
|
+
*/
|
|
16
|
+
hostName: string;
|
|
17
|
+
/**
|
|
18
|
+
* Site default language
|
|
19
|
+
*/
|
|
20
|
+
language: string;
|
|
21
|
+
};
|
|
22
|
+
export declare type GraphQLSiteInfoServiceConfig = CacheOptions & {
|
|
23
|
+
/** common variable for all GraphQL queries
|
|
24
|
+
* it will be used for every type of query to regulate result batch size
|
|
25
|
+
* Optional. How many result items to fetch in each GraphQL call. This is needed for pagination.
|
|
26
|
+
* @default 10
|
|
27
|
+
*/
|
|
28
|
+
pageSize?: number;
|
|
29
|
+
/**
|
|
30
|
+
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
31
|
+
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
32
|
+
*/
|
|
33
|
+
clientFactory: GraphQLRequestClientFactory;
|
|
34
|
+
};
|
|
35
|
+
export declare type GraphQLSiteInfoResult = {
|
|
36
|
+
name: {
|
|
37
|
+
value: string;
|
|
38
|
+
};
|
|
39
|
+
hostName: {
|
|
40
|
+
value: string;
|
|
41
|
+
};
|
|
42
|
+
language: {
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare class GraphQLSiteInfoService {
|
|
47
|
+
private config;
|
|
48
|
+
private graphQLClient;
|
|
49
|
+
private cache;
|
|
50
|
+
protected get query(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Creates an instance of graphQL service to retrieve site configuration list from Sitecore
|
|
53
|
+
* @param {GraphQLSiteInfoServiceConfig} config instance
|
|
54
|
+
*/
|
|
55
|
+
constructor(config: GraphQLSiteInfoServiceConfig);
|
|
56
|
+
fetchSiteInfo(): Promise<SiteInfo[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets cache client implementation
|
|
59
|
+
* Override this method if custom cache needs to be used
|
|
60
|
+
* @returns CacheClient instance
|
|
61
|
+
*/
|
|
62
|
+
protected getCacheClient(): CacheClient<SiteInfo[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Gets a GraphQL client that can make requests to the API.
|
|
65
|
+
* @returns {GraphQLClient} implementation
|
|
66
|
+
*/
|
|
67
|
+
protected getGraphQLClient(): GraphQLClient;
|
|
68
|
+
private getCacheKey;
|
|
69
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { GraphQLClient } from '../graphql';
|
|
2
|
+
import { GraphQLRequestClientFactory } from '../graphql-request-client';
|
|
3
|
+
export declare type GraphQLSitemapXmlServiceConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* The JSS application name
|
|
6
|
+
*/
|
|
7
|
+
siteName: string;
|
|
8
|
+
/**
|
|
9
|
+
* A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
|
|
10
|
+
* This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
|
|
11
|
+
*/
|
|
12
|
+
clientFactory: GraphQLRequestClientFactory;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The schema of data returned in response to sitemaps request
|
|
16
|
+
*/
|
|
17
|
+
export declare type SitemapQueryResult = {
|
|
18
|
+
site: {
|
|
19
|
+
siteInfo: {
|
|
20
|
+
sitemap: string[];
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Service that fetch the sitemaps data using Sitecore's GraphQL API.
|
|
26
|
+
*/
|
|
27
|
+
export declare class GraphQLSitemapXmlService {
|
|
28
|
+
options: GraphQLSitemapXmlServiceConfig;
|
|
29
|
+
private graphQLClient;
|
|
30
|
+
protected get query(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Creates an instance of graphQL sitemaps service with the provided options
|
|
33
|
+
* @param {GraphQLSitemapXmlServiceConfig} options instance
|
|
34
|
+
*/
|
|
35
|
+
constructor(options: GraphQLSitemapXmlServiceConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Fetch list of sitemaps for the site
|
|
38
|
+
* @returns {string[]} list of sitemap paths
|
|
39
|
+
* @throws {Error} if the siteName is empty.
|
|
40
|
+
*/
|
|
41
|
+
fetchSitemaps(): Promise<string[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Get sitemap file path for sitemap id
|
|
44
|
+
* @param {string} id the sitemap id (can be empty for default 'sitemap.xml' file)
|
|
45
|
+
* @returns {string | undefined} the sitemap file path or undefined if one doesn't exist
|
|
46
|
+
*/
|
|
47
|
+
getSitemap(id: string): Promise<string | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Gets a GraphQL client that can make requests to the API.
|
|
50
|
+
* @returns {GraphQLClient} implementation
|
|
51
|
+
*/
|
|
52
|
+
protected getGraphQLClient(): GraphQLClient;
|
|
53
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { RobotsQueryResult, GraphQLRobotsService, GraphQLRobotsServiceConfig, } from './graphql-robots-service';
|
|
2
|
+
export { RedirectInfo, RedirectsQueryResult, REDIRECT_TYPE_301, REDIRECT_TYPE_302, REDIRECT_TYPE_SERVER_TRANSFER, GraphQLRedirectsService, GraphQLRedirectsServiceConfig, } from './graphql-redirects-service';
|
|
3
|
+
export { SitemapQueryResult, GraphQLSitemapXmlService, GraphQLSitemapXmlServiceConfig, } from './graphql-sitemap-service';
|
|
4
|
+
export { ErrorPages, GraphQLErrorPagesService, GraphQLErrorPagesServiceConfig, } from './graphql-error-pages-service';
|
|
5
|
+
export { SiteInfo, GraphQLSiteInfoService, GraphQLSiteInfoServiceConfig, } from './graphql-siteinfo-service';
|
|
6
|
+
export { getSiteRewrite, getSiteRewriteData, normalizeSiteRewrite, SiteRewriteData } from './utils';
|
|
7
|
+
export { SiteResolver } from './site-resolver';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SiteInfo } from './graphql-siteinfo-service';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves site based on the provided host or site name
|
|
4
|
+
*/
|
|
5
|
+
export declare class SiteResolver {
|
|
6
|
+
readonly sites: SiteInfo[];
|
|
7
|
+
/**
|
|
8
|
+
* @param {SiteInfo[]} sites Array of sites to be used in resolution
|
|
9
|
+
*/
|
|
10
|
+
constructor(sites: SiteInfo[]);
|
|
11
|
+
/**
|
|
12
|
+
* Resolve site by host name
|
|
13
|
+
* @param {string} hostName the host name
|
|
14
|
+
* @returns {SiteInfo} the resolved site
|
|
15
|
+
* @throws {Error} if a matching site is not found
|
|
16
|
+
*/
|
|
17
|
+
getByHost: (hostName: string) => SiteInfo;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve site by site name
|
|
20
|
+
* @param {string} siteName the site name
|
|
21
|
+
* @returns {SiteInfo} the resolved site
|
|
22
|
+
* @throws {Error} if a matching site is not found
|
|
23
|
+
*/
|
|
24
|
+
getByName: (siteName: string) => SiteInfo;
|
|
25
|
+
protected getHostMap: () => Map<string, SiteInfo>;
|
|
26
|
+
protected matchesPattern(hostname: string, pattern: string): boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const SITE_PREFIX = "_site_";
|
|
2
|
+
export declare type SiteRewriteData = {
|
|
3
|
+
siteName: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Get a site rewrite path for given pathname
|
|
7
|
+
* @param {string} pathname the pathname
|
|
8
|
+
* @param {SiteRewriteData} data the site data to include in the rewrite
|
|
9
|
+
* @returns {string} the rewrite path
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSiteRewrite(pathname: string, data: SiteRewriteData): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get site data from the rewrite path
|
|
14
|
+
* @param {string} pathname the pathname
|
|
15
|
+
* @param {string} defaultSiteName the default site name
|
|
16
|
+
* @returns {SiteRewriteData} the site data from the rewrite
|
|
17
|
+
*/
|
|
18
|
+
export declare function getSiteRewriteData(pathname: string, defaultSiteName: string): SiteRewriteData;
|
|
19
|
+
/**
|
|
20
|
+
* Normalize a site rewrite path (remove site data)
|
|
21
|
+
* @param {string} pathname the pathname
|
|
22
|
+
* @returns {string} the pathname with site data removed
|
|
23
|
+
*/
|
|
24
|
+
export declare function normalizeSiteRewrite(pathname: string): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export declare type ChromeCommand = {
|
|
2
|
+
isDivider: boolean;
|
|
3
|
+
click: string;
|
|
4
|
+
header: string;
|
|
5
|
+
icon: string;
|
|
6
|
+
tooltip: string | null;
|
|
7
|
+
type: string | null;
|
|
8
|
+
};
|
|
9
|
+
export declare const DefaultEditFrameButtonIds: {
|
|
10
|
+
edit: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const DefaultEditFrameButton: {
|
|
13
|
+
insert: {
|
|
14
|
+
header: string;
|
|
15
|
+
icon: string;
|
|
16
|
+
click: string;
|
|
17
|
+
tooltip: string;
|
|
18
|
+
};
|
|
19
|
+
editRelatedItem: {
|
|
20
|
+
header: string;
|
|
21
|
+
icon: string;
|
|
22
|
+
click: string;
|
|
23
|
+
tooltip: string;
|
|
24
|
+
};
|
|
25
|
+
edit: {
|
|
26
|
+
header: string;
|
|
27
|
+
icon: string;
|
|
28
|
+
fields: string[];
|
|
29
|
+
tooltip: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const DefaultEditFrameButtons: ({
|
|
33
|
+
header: string;
|
|
34
|
+
icon: string;
|
|
35
|
+
click: string;
|
|
36
|
+
tooltip: string;
|
|
37
|
+
} | {
|
|
38
|
+
header: string;
|
|
39
|
+
icon: string;
|
|
40
|
+
fields: string[];
|
|
41
|
+
tooltip: string;
|
|
42
|
+
})[];
|
|
43
|
+
export declare type EditFrameDataSource = {
|
|
44
|
+
itemId: string;
|
|
45
|
+
databaseName?: string;
|
|
46
|
+
language?: string;
|
|
47
|
+
};
|
|
48
|
+
export declare type BaseEditButton = {
|
|
49
|
+
isDivider?: boolean;
|
|
50
|
+
header?: string;
|
|
51
|
+
icon?: string;
|
|
52
|
+
tooltip?: string;
|
|
53
|
+
};
|
|
54
|
+
export declare type FieldEditButton = BaseEditButton & {
|
|
55
|
+
fields: string[];
|
|
56
|
+
};
|
|
57
|
+
export declare type WebEditButton = BaseEditButton & {
|
|
58
|
+
click: string;
|
|
59
|
+
parameters?: Record<string, string | number | boolean | undefined | null>;
|
|
60
|
+
type?: string;
|
|
61
|
+
};
|
|
62
|
+
export declare type EditButtonTypes = WebEditButton | FieldEditButton | '|';
|
|
63
|
+
/**
|
|
64
|
+
* Map the edit button types to chrome data
|
|
65
|
+
* @param {EditButtonTypes } button the edit button to build a ChromeCommand for
|
|
66
|
+
* @param {string} itemId the ID of the item the EditFrame is associated with
|
|
67
|
+
* @param {Record<string, string | number | boolean | undefined | null>} frameParameters additional parameters passed to the EditFrame
|
|
68
|
+
*/
|
|
69
|
+
export declare function mapButtonToCommand(button: EditButtonTypes, itemId?: string, frameParameters?: Record<string, string | number | boolean | undefined | null>): ChromeCommand;
|
|
70
|
+
/**
|
|
71
|
+
* Build a ChromeCommand from a web edit button. Merging the parameters from the button, frame and id
|
|
72
|
+
* @param {WebEditButton } button the web edit button to build a ChromeCommand for
|
|
73
|
+
* @param {string} itemId the ID of the item the EditFrame is associated with
|
|
74
|
+
* @param {Record<string, string>} frameParameters additional parameters passed to the EditFrame
|
|
75
|
+
*/
|
|
76
|
+
export declare function commandBuilder(button: WebEditButton, itemId?: string, frameParameters?: Record<string, string | number | boolean | undefined | null>): ChromeCommand;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application metadata
|
|
3
|
+
*/
|
|
4
|
+
export interface Metadata {
|
|
5
|
+
packages: {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Static utility class for Sitecore Experience Editor
|
|
11
|
+
*/
|
|
12
|
+
export declare class ExperienceEditor {
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether the current execution context is within a Experience Editor.
|
|
15
|
+
* Experience Editor environment can be identified only in the browser
|
|
16
|
+
* @returns true if executing within a Experience Editor
|
|
17
|
+
*/
|
|
18
|
+
static isActive(): boolean;
|
|
19
|
+
static resetChromes(): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Copy of chrome rediscovery contract from Horizon (chrome-rediscovery.contract.ts)
|
|
23
|
+
*/
|
|
24
|
+
export declare const ChromeRediscoveryGlobalFunctionName: {
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Static utility class for Sitecore Horizon Editor
|
|
29
|
+
*/
|
|
30
|
+
export declare class HorizonEditor {
|
|
31
|
+
/**
|
|
32
|
+
* Determines whether the current execution context is within a Horizon Editor.
|
|
33
|
+
* Horizon Editor environment can be identified only in the browser
|
|
34
|
+
* @returns true if executing within a Horizon Editor
|
|
35
|
+
*/
|
|
36
|
+
static isActive(): boolean;
|
|
37
|
+
static resetChromes(): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Determines whether the current execution context is within a Sitecore editor.
|
|
41
|
+
* Sitecore Editor environment can be identified only in the browser
|
|
42
|
+
* @returns true if executing within a Sitecore editor
|
|
43
|
+
*/
|
|
44
|
+
export declare const isEditorActive: () => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Resets Sitecore editor "chromes"
|
|
47
|
+
*/
|
|
48
|
+
export declare const resetEditorChromes: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* @description in Experience Editor, anchor tags
|
|
51
|
+
* with both onclick and href attributes will use the href, blocking the onclick from firing.
|
|
52
|
+
* This function makes it so the anchor tags function as intended in the sample when using Experience Editor
|
|
53
|
+
*
|
|
54
|
+
* The Mutation Observer API is used to observe changes to the body, then select all elements with href="#" and an onclick,
|
|
55
|
+
* and replaces the # value with javascript:void(0); which prevents the anchor tag from blocking the onclick event handler.
|
|
56
|
+
* @see Mutation Observer API: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/MutationObserver
|
|
57
|
+
*/
|
|
58
|
+
export declare const handleEditorAnchors: () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method to parse JSON-formatted environment variables
|
|
3
|
+
* @param {string} envValue - can be undefined when providing values via process.env
|
|
4
|
+
* @param {T} defaultValue - default value
|
|
5
|
+
* @returns {T | string} parsed value
|
|
6
|
+
*/
|
|
7
|
+
export declare const tryParseEnvValue: <T>(envValue: string | undefined, defaultValue: T) => T;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as isServer } from './is-server';
|
|
2
|
+
export { resolveUrl, isAbsoluteUrl, isTimeoutError } from './utils';
|
|
3
|
+
export { tryParseEnvValue } from './env';
|
|
4
|
+
export { ExperienceEditor, HorizonEditor, isEditorActive, resetEditorChromes, handleEditorAnchors, Metadata, } from './editing';
|
|
5
|
+
export { DefaultEditFrameButton, DefaultEditFrameButtons, DefaultEditFrameButtonIds, EditFrameDataSource, ChromeCommand, FieldEditButton, WebEditButton, EditButtonTypes, mapButtonToCommand, } from './edit-frame';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* A helper to assign timeouts to fetch or other promises
|
|
4
|
+
* Useful in nextjs middleware until fetch.signal is fully supported by Vercel edge functions
|
|
5
|
+
*/
|
|
6
|
+
export default class TimeoutPromise {
|
|
7
|
+
private timeout;
|
|
8
|
+
timeoutId: NodeJS.Timeout | undefined;
|
|
9
|
+
constructor(timeout: number);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a timeout promise
|
|
12
|
+
*/
|
|
13
|
+
get start(): Promise<unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Clears the timeout from timeout promise
|
|
16
|
+
*/
|
|
17
|
+
clear(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParsedUrlQueryInput } from 'querystring';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a base URL that may contain query string parameters and an additional set of query
|
|
5
|
+
* string parameters into a unified string representation.
|
|
6
|
+
* @param {string} urlBase the base URL that may contain query string parameters
|
|
7
|
+
* @param {ParsedUrlQueryInput} params query string parameters
|
|
8
|
+
* @returns a URL string
|
|
9
|
+
* @throws {RangeError} if the provided url is an empty string
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveUrl(urlBase: string, params?: ParsedUrlQueryInput): string;
|
|
12
|
+
export declare const isAbsoluteUrl: (url: string) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether the error is a timeout error
|
|
15
|
+
* @param {unknown} error error
|
|
16
|
+
* @returns {boolean} is timeout error
|
|
17
|
+
*/
|
|
18
|
+
export declare const isTimeoutError: (error: unknown) => boolean;
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types/utils/index';
|
package/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist/cjs/utils/index');
|