@sitecore-content-sdk/angular 0.1.0-canary.20260609132302
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 +33 -0
- package/cli-node/config-cli/define-cli-config.d.ts +11 -0
- package/cli-node/config-cli/define-cli-config.d.ts.map +1 -0
- package/cli-node/config-cli/define-cli-config.js +68 -0
- package/cli-node/config-cli/define-cli-config.spec.d.ts +2 -0
- package/cli-node/config-cli/define-cli-config.spec.d.ts.map +1 -0
- package/cli-node/config-cli/define-cli-config.spec.js +83 -0
- package/cli-node/config-cli/index.d.ts +2 -0
- package/cli-node/config-cli/index.d.ts.map +1 -0
- package/cli-node/config-cli/index.js +5 -0
- package/cli-node/tools/generate-map.d.ts +9 -0
- package/cli-node/tools/generate-map.d.ts.map +1 -0
- package/cli-node/tools/generate-map.js +90 -0
- package/cli-node/tools/generate-map.spec.d.ts +2 -0
- package/cli-node/tools/generate-map.spec.d.ts.map +1 -0
- package/cli-node/tools/generate-map.spec.js +207 -0
- package/cli-node/tools/index.d.ts +2 -0
- package/cli-node/tools/index.d.ts.map +1 -0
- package/cli-node/tools/index.js +5 -0
- package/dist/README.md +33 -0
- package/dist/fesm2022/sitecore-content-sdk-angular.mjs +2912 -0
- package/dist/fesm2022/sitecore-content-sdk-angular.mjs.map +1 -0
- package/dist/types/sitecore-content-sdk-angular.d.ts +1446 -0
- package/dist/types/sitecore-content-sdk-angular.d.ts.map +1 -0
- package/package.json +113 -0
|
@@ -0,0 +1,1446 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { EnvironmentProviders, InjectionToken, Provider, Signal, Type, ElementRef } from '@angular/core';
|
|
3
|
+
import { Params, ResolveFn, ActivatedRouteSnapshot, RouterStateSnapshot, NavigationError, RedirectCommand, Router, UrlMatcher, DefaultUrlSerializer, UrlTree } from '@angular/router';
|
|
4
|
+
import { SitecoreClient, Page } from '@sitecore-content-sdk/content/client';
|
|
5
|
+
export { DefaultRetryStrategy, ErrorPage, GraphQLClientError, GraphQLRequestClient, GraphQLRequestClientFactoryConfig, Page, PageMode, RetryStrategy, SitecoreClient } from '@sitecore-content-sdk/content/client';
|
|
6
|
+
import { SitecoreConfig, SitecoreConfigInput } from '@sitecore-content-sdk/content/config';
|
|
7
|
+
export { CacheClient, CacheOptions, ClientError, MemoryCacheClient, NativeDataFetcher, NativeDataFetcherConfig, NativeDataFetcherResponse, constants, enableDebug } from '@sitecore-content-sdk/core';
|
|
8
|
+
import * as _sitecore_content_sdk_content_layout from '@sitecore-content-sdk/content/layout';
|
|
9
|
+
import { ComponentRendering, RouteData, TextField, LinkField, LinkFieldValue } from '@sitecore-content-sdk/content/layout';
|
|
10
|
+
export { ComponentFields, ComponentParams, ComponentRendering, EditMode, Field, ImageField, ImageFieldValue, ImageSizeParameters, Item, LayoutService, LayoutServiceContext, LayoutServiceContextData, LayoutServiceData, LayoutServicePageState, LinkField, LinkFieldValue, RichTextField, RouteData, TextField, getChildPlaceholder, getContentStylesheetLink, getDesignLibraryStylesheetLinks, getFieldValue } from '@sitecore-content-sdk/content/layout';
|
|
11
|
+
import { Driver } from 'unstorage';
|
|
12
|
+
import * as _sitecore_content_sdk_angular from '@sitecore-content-sdk/angular';
|
|
13
|
+
import { SiteInfo } from '@sitecore-content-sdk/content/site';
|
|
14
|
+
export { SitePathService, SitePathServiceConfig } from '@sitecore-content-sdk/content/site';
|
|
15
|
+
import { DictionaryPhrases } from '@sitecore-content-sdk/content/i18n';
|
|
16
|
+
export { getLocaleRewrite } from '@sitecore-content-sdk/content/i18n';
|
|
17
|
+
import { TranslateLoader } from '@ngx-translate/core';
|
|
18
|
+
import { Observable } from 'rxjs';
|
|
19
|
+
export { isEditorActive, resetEditorChromes } from '@sitecore-content-sdk/content/editing';
|
|
20
|
+
export { mediaApi } from '@sitecore-content-sdk/content/media';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Sitecore configuration input for Angular apps. Extends the base
|
|
24
|
+
* {@link SitecoreConfigInput} with an `angular` section. `redirects.locales` is intentionally
|
|
25
|
+
* omitted from the input — it is derived from `angular.locales` so there is a single
|
|
26
|
+
* source of truth for the locale list.
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
interface AngularSitecoreConfigInput extends Omit<SitecoreConfigInput, 'redirects'> {
|
|
30
|
+
/**
|
|
31
|
+
* Settings for redirects functionality. `locales` is derived automatically from
|
|
32
|
+
* `angular.locales`; only `enabled` is configurable at this layer.
|
|
33
|
+
*/
|
|
34
|
+
redirects?: Omit<NonNullable<SitecoreConfigInput['redirects']>, 'locales'>;
|
|
35
|
+
/** Angular-specific configuration. */
|
|
36
|
+
angular?: {
|
|
37
|
+
/**
|
|
38
|
+
* Locales supported by the Angular app.
|
|
39
|
+
* `defaultLanguage` is prepended automatically when absent.
|
|
40
|
+
*/
|
|
41
|
+
locales?: string[];
|
|
42
|
+
/**
|
|
43
|
+
* Configuration for the ISR-like cache. Both fields default when omitted
|
|
44
|
+
* (`enabled: true`, `revalidate: 300`).
|
|
45
|
+
*/
|
|
46
|
+
loadersCache?: {
|
|
47
|
+
/** Whether the cache is enabled. */
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
/** The global revalidate time in seconds. */
|
|
50
|
+
revalidate?: number;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Resolved Sitecore configuration for Angular apps. Extends the fully-resolved
|
|
56
|
+
* {@link SitecoreConfig}; structurally still a `SitecoreConfig`, so existing callers that
|
|
57
|
+
* type the value as `SitecoreConfig` continue to work. `redirects.locales` is intentionally
|
|
58
|
+
* omitted at the type level — read the canonical locale list from `angular.locales`.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
interface AngularSitecoreConfig extends Omit<SitecoreConfig, 'redirects'> {
|
|
62
|
+
redirects: Omit<SitecoreConfig['redirects'], 'locales'>;
|
|
63
|
+
angular: {
|
|
64
|
+
/** Resolved locales for the Angular app. Always contains at least `defaultLanguage`. */
|
|
65
|
+
locales: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Resolved configuration for the ISR-like cache. Defaults are applied by
|
|
68
|
+
* `defineConfig`: `enabled: true`, `revalidate: 300`.
|
|
69
|
+
*/
|
|
70
|
+
loadersCache: {
|
|
71
|
+
enabled: boolean;
|
|
72
|
+
revalidate: number;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Merges `clientEnv` (browser-safe `environment*.ts`) with `process.env` for server-only variables,
|
|
78
|
+
* then delegates to the base content `defineConfig` and adds the Angular-specific config layer.
|
|
79
|
+
*
|
|
80
|
+
* - `angular.locales` is the single source of truth for the locale list; `defaultLanguage` is
|
|
81
|
+
* added when missing.
|
|
82
|
+
* - `redirects.locales` is overwritten from `angular.locales` so the redirects proxy stays in sync.
|
|
83
|
+
*
|
|
84
|
+
* On Node/SSR, load `.env` in the app entry before importing `sitecore.config` (see
|
|
85
|
+
* `load-env.ts` in the sample).
|
|
86
|
+
* @param {AngularSitecoreConfigInput} [config] - Base Sitecore configuration input.
|
|
87
|
+
* @param {Record<string, string | undefined>} [clientEnv] - Browser-safe env from `environment*.ts`.
|
|
88
|
+
* @returns {AngularSitecoreConfig} Fully merged Sitecore configuration for Angular.
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
declare function defineConfig(config?: AngularSitecoreConfigInput, clientEnv?: Record<string, string | undefined>): AngularSitecoreConfig;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Configuration for the Sitecore Angular SDK.
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
interface AngularCSDKAppInit {
|
|
98
|
+
/**
|
|
99
|
+
* Sitecore configuration (e.g. from sitecore.config.ts).
|
|
100
|
+
* When provided, {@link sitecoreClient} must also be set; both are registered for DI.
|
|
101
|
+
*/
|
|
102
|
+
sitecoreConfig?: AngularSitecoreConfig;
|
|
103
|
+
/**
|
|
104
|
+
* Application-owned {@link SitecoreClient} instance (e.g. from a module singleton).
|
|
105
|
+
* Required when {@link sitecoreConfig} is set; registered as {@link SITECORE_CLIENT_TOKEN}.
|
|
106
|
+
*/
|
|
107
|
+
sitecoreClient?: SitecoreClient;
|
|
108
|
+
notFoundRoute?: string;
|
|
109
|
+
errorRoute?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Provides Sitecore Angular SDK services to the application.
|
|
113
|
+
* Call this in your `app.config.ts` `providers` array.
|
|
114
|
+
* @param {AngularCSDKAppInit} init SDK configuration
|
|
115
|
+
* @param {AngularCSDKAppInit} init.sitecoreConfig - Sitecore configuration
|
|
116
|
+
* @param {AngularCSDKAppInit} init.sitecoreClient - Sitecore client
|
|
117
|
+
* @param {AngularCSDKAppInit} init.notFoundRoute - Not found route
|
|
118
|
+
* @param {AngularCSDKAppInit} init.errorRoute - Error route
|
|
119
|
+
* @returns {EnvironmentProviders} Angular environment providers
|
|
120
|
+
* @example
|
|
121
|
+
* // app.config.ts
|
|
122
|
+
* import scConfig from '../sitecore.config';
|
|
123
|
+
* import { getClient } from '../content-sdk/client/sitecore-client';
|
|
124
|
+
* export const appConfig: ApplicationConfig = {
|
|
125
|
+
* providers: [
|
|
126
|
+
* provideSitecoreAngular({ sitecoreConfig: scConfig, sitecoreClient: getClient() }),
|
|
127
|
+
* ],
|
|
128
|
+
* };
|
|
129
|
+
* @public
|
|
130
|
+
*/
|
|
131
|
+
declare function provideSitecoreAngular(init: AngularCSDKAppInit): EnvironmentProviders;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Injection token for the Sitecore configuration.
|
|
135
|
+
* Provided by `provideSitecoreAngular({ sitecoreConfig, sitecoreClient })`. Inject this to read config app-wide.
|
|
136
|
+
* `AngularSitecoreConfig` extends `SitecoreConfig`, so consumers that previously typed the
|
|
137
|
+
* value as `SitecoreConfig` remain structurally compatible.
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
declare const SITECORE_CONFIG_TOKEN: InjectionToken<AngularSitecoreConfig>;
|
|
141
|
+
/**
|
|
142
|
+
* Injection token for the SitecoreClient instance.
|
|
143
|
+
* Provided by `provideSitecoreAngular({ sitecoreConfig, sitecoreClient })` with the app-supplied client instance.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
declare const SITECORE_CLIENT_TOKEN: InjectionToken<SitecoreClient>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Resolves layout/page data for a route path using a {@link SitecoreClient} and Sitecore config.
|
|
150
|
+
* Import your `sitecore.config` default and shared client (e.g. `getClient()`) from the app;
|
|
151
|
+
* this stays usable from route loaders without Angular injection context.
|
|
152
|
+
*
|
|
153
|
+
* Future: add helpers for personalization and multisite alongside this call.
|
|
154
|
+
* @param {string} path - Route path (e.g. `'/'` or `'/about'`).
|
|
155
|
+
* @param {AngularSitecoreConfig} sitecoreConfig - Resolved Sitecore configuration (e.g. default export from `sitecore.config.ts`).
|
|
156
|
+
* @param {SitecoreClient} client - Sitecore client instance (e.g. from a module singleton).
|
|
157
|
+
* @param {{ locale?: string; site?: string }} [options] - Optional `locale` / `site` overrides.
|
|
158
|
+
* @param {string} [options.locale] - Optional locale override.
|
|
159
|
+
* @param {string} [options.site] - Optional site override.
|
|
160
|
+
* @returns {Promise<Page | null>} Page layout data, or `null` if not found.
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
declare function resolveSitecorePage(path: string, sitecoreConfig: AngularSitecoreConfig, client: SitecoreClient, options?: {
|
|
164
|
+
locale?: string;
|
|
165
|
+
site?: string;
|
|
166
|
+
}): Promise<Page | null>;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Request context containing information from the incoming HTTP request.
|
|
170
|
+
* Used for request-dependent operations in loaders.
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
interface RequestContext {
|
|
174
|
+
/**
|
|
175
|
+
* The hostname from the request (without port)
|
|
176
|
+
*/
|
|
177
|
+
hostname?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Cookies from the request
|
|
180
|
+
*/
|
|
181
|
+
cookies?: Record<string, string>;
|
|
182
|
+
/**
|
|
183
|
+
* Query parameters from the request
|
|
184
|
+
*/
|
|
185
|
+
query?: Record<string, string | string[] | undefined>;
|
|
186
|
+
/**
|
|
187
|
+
* Headers from the request
|
|
188
|
+
*/
|
|
189
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Context provided to loader functions.
|
|
193
|
+
* Contains information about the current request including URL, params, query, and request context.
|
|
194
|
+
* @public
|
|
195
|
+
*/
|
|
196
|
+
type LoaderContext = {
|
|
197
|
+
/**
|
|
198
|
+
* The current URL path
|
|
199
|
+
*/
|
|
200
|
+
url: string;
|
|
201
|
+
/**
|
|
202
|
+
* Route parameters from all matched segments.
|
|
203
|
+
*
|
|
204
|
+
* When locales are configured and the route tree uses `scLocaleMatcher`, the matched
|
|
205
|
+
* locale is exposed as `params.locale`. The resolver also defaults `params.locale` to
|
|
206
|
+
* `defaultLanguage` from `sitecore.config` when no locale segment was matched — loaders
|
|
207
|
+
* can rely on a concrete `params.locale` regardless of URL shape.
|
|
208
|
+
*/
|
|
209
|
+
params: Params;
|
|
210
|
+
/**
|
|
211
|
+
* Query string parameters
|
|
212
|
+
*/
|
|
213
|
+
query: Record<string, string | string[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Server-only: the incoming request
|
|
216
|
+
*/
|
|
217
|
+
req?: Request;
|
|
218
|
+
/**
|
|
219
|
+
* Server-only: the response object
|
|
220
|
+
*/
|
|
221
|
+
res?: Response;
|
|
222
|
+
/**
|
|
223
|
+
* Server-only: context from the incoming HTTP request.
|
|
224
|
+
* Contains hostname, cookies, query params, and headers.
|
|
225
|
+
* Use with createSiteResolver() to determine the current site.
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const resolveSite = createSiteResolver({ sites, defaultSite: config.defaultSite });
|
|
229
|
+
*
|
|
230
|
+
* export const pageLoader: LoaderFn = async (ctx) => {
|
|
231
|
+
* if (ctx.requestContext) {
|
|
232
|
+
* const { site } = resolveSite(ctx.requestContext);
|
|
233
|
+
* return client.getPage(ctx.url, { site: site.name });
|
|
234
|
+
* }
|
|
235
|
+
* return client.getPage(ctx.url);
|
|
236
|
+
* };
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
requestContext?: RequestContext;
|
|
240
|
+
};
|
|
241
|
+
type LoaderApiRequest = {
|
|
242
|
+
loaderId: string;
|
|
243
|
+
url: string;
|
|
244
|
+
params: Params;
|
|
245
|
+
query: Record<string, any>;
|
|
246
|
+
/**
|
|
247
|
+
* Server-derived request context (hostname, headers, cookies, query).
|
|
248
|
+
* Populated once at the request boundary (`/_data` middleware closure or the
|
|
249
|
+
* SSR resolver). Downstream code reads this directly; nobody re-extracts.
|
|
250
|
+
* Phase 2 of the refactor plan.
|
|
251
|
+
*/
|
|
252
|
+
angularRequestContext?: RequestContext;
|
|
253
|
+
/**
|
|
254
|
+
* Per-route cache overrides supplied at the `loaderResolver(id, cacheOptions)`
|
|
255
|
+
* call site. The browser includes them in the `/_data` POST body so the same
|
|
256
|
+
* per-route policy applies on CSR navigations. Phase 5 of the refactor plan.
|
|
257
|
+
*/
|
|
258
|
+
cacheOptions?: LoaderCacheConfig;
|
|
259
|
+
};
|
|
260
|
+
type LoaderRedirectResult = {
|
|
261
|
+
loaderRedirectTarget: string;
|
|
262
|
+
status?: number;
|
|
263
|
+
};
|
|
264
|
+
type LoaderApiResponse = {
|
|
265
|
+
kind: 'data';
|
|
266
|
+
data: any;
|
|
267
|
+
} | {
|
|
268
|
+
kind: 'redirect';
|
|
269
|
+
redirect: LoaderRedirectResult;
|
|
270
|
+
} | {
|
|
271
|
+
kind: 'error';
|
|
272
|
+
status: number;
|
|
273
|
+
message: string;
|
|
274
|
+
} | {
|
|
275
|
+
kind: 'notFound';
|
|
276
|
+
status: number;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Result returned by loader resolution on the server (SSR and `/_data` endpoint).
|
|
280
|
+
* Uses the shared cross-boundary loader registry; not a separate server loader set.
|
|
281
|
+
* @public
|
|
282
|
+
*/
|
|
283
|
+
type LoaderDataResult = {
|
|
284
|
+
kind: 'data';
|
|
285
|
+
data: unknown;
|
|
286
|
+
} | {
|
|
287
|
+
kind: 'redirect';
|
|
288
|
+
redirect: LoaderRedirectResult;
|
|
289
|
+
} | {
|
|
290
|
+
kind: 'error';
|
|
291
|
+
status: number;
|
|
292
|
+
message: string;
|
|
293
|
+
cause?: unknown;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Loader function type.
|
|
297
|
+
* A loader is an async function that receives context, can be applied in route resolvers and can return:
|
|
298
|
+
* - data - any data that can be serialized and stored in the transfer state
|
|
299
|
+
* - redirect - a redirect to be applied to the router
|
|
300
|
+
* - throw error - an error that occurred during the retrieval of the data
|
|
301
|
+
* @public
|
|
302
|
+
*/
|
|
303
|
+
type LoaderFn<T = unknown> = (ctx: LoaderContext) => Promise<T> | T | LoaderRedirectResult;
|
|
304
|
+
declare class NotFoundNavigationError extends Error {
|
|
305
|
+
constructor(message?: string);
|
|
306
|
+
}
|
|
307
|
+
declare class LoaderHttpError extends Error {
|
|
308
|
+
status: number;
|
|
309
|
+
constructor(status: number, message?: string);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Base browser-safe config type for loader cache.
|
|
313
|
+
*
|
|
314
|
+
* `revalidate` is in seconds. A positive value caches the entry for that many
|
|
315
|
+
* seconds; `0` or a negative value means "never expire" (rely on explicit
|
|
316
|
+
* invalidation). There is no `'infinite'` sentinel.
|
|
317
|
+
* @public
|
|
318
|
+
*/
|
|
319
|
+
interface LoaderCacheConfig extends PerRouteLoaderCacheConfig {
|
|
320
|
+
/** Default site name for tag helpers and admin tooling. Defaults to `'default'`. */
|
|
321
|
+
defaultSiteName?: string;
|
|
322
|
+
/**
|
|
323
|
+
* Site names used by revalidation middleware to fan out dictionary loader tags
|
|
324
|
+
* (`sc:loader:dictionary:<site>:<locale>`) on every webhook call.
|
|
325
|
+
*/
|
|
326
|
+
sites?: string[];
|
|
327
|
+
/** Fallback locale for tag helpers when a site entry has no `language`. Defaults to `'en'`. */
|
|
328
|
+
defaultLocale?: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Per-route cache configuration.
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
interface PerRouteLoaderCacheConfig {
|
|
335
|
+
/** TTL in seconds. Positive → expires after N seconds; `0` or negative → never expires. */
|
|
336
|
+
revalidate?: number;
|
|
337
|
+
/** Master switch — when false, every call falls through to the raw loader. */
|
|
338
|
+
enabled?: boolean;
|
|
339
|
+
/**
|
|
340
|
+
* Custom tags applied to every entry this loader writes. Merged with built-in
|
|
341
|
+
* OSR tags (self-key, `sc:site`, `sc:locale`, and `sc:item` for page loaders).
|
|
342
|
+
*/
|
|
343
|
+
tags?: string[];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Metadata returned by cache.entries() — sufficient for an admin UI without
|
|
347
|
+
* shipping the cached values themselves (which can be large).
|
|
348
|
+
* @public
|
|
349
|
+
*/
|
|
350
|
+
interface LoaderCacheEntryInfo {
|
|
351
|
+
key: string;
|
|
352
|
+
tags: string[];
|
|
353
|
+
storedAt: number;
|
|
354
|
+
expiresAt: number | null;
|
|
355
|
+
stale: boolean;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Three-outcome read result for stale-while-revalidate (Phase 3).
|
|
359
|
+
*
|
|
360
|
+
* - `hit` — entry is fresh; serve cached value without running the loader.
|
|
361
|
+
* - `stale` — entry expired or was invalidated; serve cached value and refresh in the background.
|
|
362
|
+
* - `miss` — no entry; run the loader synchronously.
|
|
363
|
+
* @public
|
|
364
|
+
*/
|
|
365
|
+
type LoaderCacheReadResult =
|
|
366
|
+
/** Fresh cache entry within TTL and not marked stale. */
|
|
367
|
+
{
|
|
368
|
+
kind: 'hit';
|
|
369
|
+
value: unknown;
|
|
370
|
+
cacheKey: string;
|
|
371
|
+
}
|
|
372
|
+
/** Expired or invalidated entry; value is served while a background refresh runs. */
|
|
373
|
+
| {
|
|
374
|
+
kind: 'stale';
|
|
375
|
+
value: unknown;
|
|
376
|
+
cacheKey: string;
|
|
377
|
+
}
|
|
378
|
+
/** No entry stored for the requested cache key. */
|
|
379
|
+
| {
|
|
380
|
+
kind: 'miss';
|
|
381
|
+
cacheKey: string;
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Tag-based invalidation input.
|
|
385
|
+
* Marks matching entries stale via the tag index; does not delete them (SWR semantics).
|
|
386
|
+
* @public
|
|
387
|
+
*/
|
|
388
|
+
interface InvalidateInput {
|
|
389
|
+
/** Non-empty list of OSR tags (for example `sc:item:…`, `sc:site:…`, or a cache key self-tag). */
|
|
390
|
+
tags?: string[];
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Server-only cache instance. Constructed once in `server.ts` via
|
|
394
|
+
* `createLoaderCache` (see `server/cache`) and passed by reference to middleware factories
|
|
395
|
+
* (`createLoaderDataServiceMiddleware`, `createCacheAdminMiddleware`,
|
|
396
|
+
* `createSitecoreRevalidateMiddleware`; see `server/middleware`) and to Angular SSR through
|
|
397
|
+
* `angularApp.handle(req, { cache })`.
|
|
398
|
+
*
|
|
399
|
+
* Implementations maintain a sidecar tag index so `LoaderCache.invalidate`
|
|
400
|
+
* can mark entries stale without scanning every key.
|
|
401
|
+
* @public
|
|
402
|
+
*/
|
|
403
|
+
interface LoaderCache {
|
|
404
|
+
/** Global default TTL in seconds from {@link LoaderCacheConfig.revalidate}. */
|
|
405
|
+
get ttl(): number;
|
|
406
|
+
/** Resolved configuration (useful for admin UI and diagnostics). */
|
|
407
|
+
get config(): Readonly<LoaderCacheConfig>;
|
|
408
|
+
/**
|
|
409
|
+
* Reads a cache entry and classifies it as hit, stale, or miss.
|
|
410
|
+
* @param key - OSR-aligned cache key (for example `sc:loader:page:demo:en:default:about`).
|
|
411
|
+
*/
|
|
412
|
+
get(key: string): Promise<LoaderCacheReadResult>;
|
|
413
|
+
/**
|
|
414
|
+
* Stores an entry and links it to the supplied tag set.
|
|
415
|
+
* @param key - Cache key to write.
|
|
416
|
+
* @param value - Loader payload to persist.
|
|
417
|
+
* @param ttlSeconds - TTL in seconds; `0` or negative means never expire.
|
|
418
|
+
* @param tags - Tag index pointers written alongside the entry (self-key, site, locale, item, etc.).
|
|
419
|
+
*/
|
|
420
|
+
set(key: string, value: unknown, ttlSeconds: number, tags: string[]): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* Marks every entry linked to any of the supplied tags as stale.
|
|
423
|
+
* @param filter - Tag list to resolve through the tag index.
|
|
424
|
+
* @returns Number of entries marked stale (includes entries already stale).
|
|
425
|
+
*/
|
|
426
|
+
invalidate(filter: InvalidateInput): Promise<number>;
|
|
427
|
+
/** Removes a single entry and unlinks it from the tag index. */
|
|
428
|
+
delete(key: string): Promise<boolean>;
|
|
429
|
+
/** Removes every entry and clears the tag index. */
|
|
430
|
+
flush(): Promise<void>;
|
|
431
|
+
/** Returns lightweight metadata for admin tooling (values are omitted). */
|
|
432
|
+
entries(): Promise<LoaderCacheEntryInfo[]>;
|
|
433
|
+
/** Whether caching is enabled globally. Per-route overrides may still opt in. */
|
|
434
|
+
enabled(): boolean;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Extension point for custom loader IDs. Augment this interface so that
|
|
439
|
+
* loaderResolver() accepts your loader ids when you add them via provideLoaderRegistry().
|
|
440
|
+
* @example
|
|
441
|
+
* // In your app (e.g. app.d.ts or a types file):
|
|
442
|
+
* declare module '@sitecore-content-sdk/angular' {
|
|
443
|
+
* interface LoaderIdMap {
|
|
444
|
+
* myCustomLoader: void;
|
|
445
|
+
* }
|
|
446
|
+
* }
|
|
447
|
+
* // Then provideLoaderRegistry({ myCustomLoader: myLoader }) and loaderResolver('myCustomLoader') are typed.
|
|
448
|
+
*/
|
|
449
|
+
interface LoaderIdMap {
|
|
450
|
+
}
|
|
451
|
+
/** Loader ID type. Use string keys that match the keys you pass to provideLoaderRegistry. */
|
|
452
|
+
type LoaderId = keyof LoaderIdMap extends never ? string : keyof LoaderIdMap;
|
|
453
|
+
/**
|
|
454
|
+
* Create a loader resolver function that resolver loader data with optional cache options on server or browser.
|
|
455
|
+
* @param {LoaderId} loaderId - The loader ID
|
|
456
|
+
* @param {PerRouteLoaderCacheConfig} [cacheOptions] - The cache options
|
|
457
|
+
* @returns {ResolveFn<unknown>} loader resolver function
|
|
458
|
+
*/
|
|
459
|
+
declare const loaderResolver: (loaderId: LoaderId, cacheOptions?: PerRouteLoaderCacheConfig) => ResolveFn<unknown>;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Optional endpoint path for loader data fetch (e.g. '/_data' or '/api/data').
|
|
463
|
+
* When null or undefined, LOADER_DATA_ENDPOINT is used.
|
|
464
|
+
* @public
|
|
465
|
+
*/
|
|
466
|
+
declare const FETCH_DATA_ENDPOINT: InjectionToken<string | null | undefined>;
|
|
467
|
+
/**
|
|
468
|
+
* Cross-boundary loader registry — maps loader IDs to loader functions.
|
|
469
|
+
* The same registry is used for SSR, CSR (`/_data`), and route resolvers.
|
|
470
|
+
* There is no separate server vs client loader set.
|
|
471
|
+
* @public
|
|
472
|
+
*/
|
|
473
|
+
type LoaderRegistry = Record<string, LoaderFn>;
|
|
474
|
+
declare const LOADER_REGISTRY: InjectionToken<LoaderRegistry>;
|
|
475
|
+
/**
|
|
476
|
+
* Registers the app's loader registry for DI. Pass the loaders your app uses
|
|
477
|
+
* (e.g. page, '404', '500'). Use the **same object** with
|
|
478
|
+
*createLoaderDataServiceMiddleware in `server.ts` so SSR and CSR
|
|
479
|
+
* navigations resolve the same loader functions.
|
|
480
|
+
* @param {LoaderRegistry} loaders - Map of loader id to loader function
|
|
481
|
+
* @public
|
|
482
|
+
*/
|
|
483
|
+
declare const provideLoaderRegistry: (loaders: LoaderRegistry) => Provider[];
|
|
484
|
+
/**
|
|
485
|
+
* Symbol used to tag resolver functions with their loader ID.
|
|
486
|
+
* This allows the prefetch service to identify loader resolvers in the route tree.
|
|
487
|
+
* @internal
|
|
488
|
+
*/
|
|
489
|
+
declare const LOADER_ID: unique symbol;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Request parameters for fetching loader data
|
|
493
|
+
* @public
|
|
494
|
+
*/
|
|
495
|
+
interface LoaderDataRequest {
|
|
496
|
+
url: string;
|
|
497
|
+
loaderId: string;
|
|
498
|
+
params?: Params;
|
|
499
|
+
query?: Record<string, string | string[]>;
|
|
500
|
+
/**
|
|
501
|
+
* Per-route cache overrides from `loaderResolver(id, cacheOptions)`. Sent
|
|
502
|
+
* to the server in the POST body so server-side cache policy matches the
|
|
503
|
+
* route's intent on CSR navigations. Phase 5 of the refactor plan.
|
|
504
|
+
*/
|
|
505
|
+
cacheOptions?: LoaderCacheConfig;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Loader data client for browser loader data resolution. POSTs to the `/_data` endpoint and holds
|
|
509
|
+
* short-lived prefetched responses for parallel navigation prefetching.
|
|
510
|
+
* Not aware of the server-side {@link LoaderCache}.
|
|
511
|
+
* @public
|
|
512
|
+
*/
|
|
513
|
+
declare class ClientLoaderDataService {
|
|
514
|
+
private readonly prefetchedResponses;
|
|
515
|
+
private readonly pending;
|
|
516
|
+
private readonly http;
|
|
517
|
+
private readonly platformId;
|
|
518
|
+
private readonly fetchDataEndpoint;
|
|
519
|
+
/**
|
|
520
|
+
* Prefetch loader data for the given request without consuming staged responses.
|
|
521
|
+
* If a response is already staged or a request is pending, does nothing.
|
|
522
|
+
* Otherwise starts a fetch and stores the result for a later getData() call.
|
|
523
|
+
* Used by PreLoaderDataService to warm responses for all loaders in a route in parallel.
|
|
524
|
+
* @param {LoaderDataRequest} loaderRequest - The loader data request
|
|
525
|
+
*/
|
|
526
|
+
prefetch(loaderRequest: LoaderDataRequest): void;
|
|
527
|
+
/**
|
|
528
|
+
* Get data for the given request, using staged prefetched responses or fetching if needed.
|
|
529
|
+
* If a request is already pending for this URL/loader combination,
|
|
530
|
+
* waits for it to complete instead of making a duplicate request.
|
|
531
|
+
* Consumes (removes) staged responses after retrieval.
|
|
532
|
+
* @param {LoaderDataRequest} request - The loader data request
|
|
533
|
+
* @returns {Promise<LoaderApiResponse>} Promise resolving to the API response
|
|
534
|
+
*/
|
|
535
|
+
getData(request: LoaderDataRequest): Promise<LoaderApiResponse>;
|
|
536
|
+
/**
|
|
537
|
+
* Fetch data from the configured data endpoint.
|
|
538
|
+
* Callers (getData, prefetch) add the returned promise to pending; it is removed
|
|
539
|
+
* in finally when the promise settles.
|
|
540
|
+
* @param {LoaderDataRequest} request - The loader data request
|
|
541
|
+
* @returns {Promise<LoaderApiResponse>} Promise resolving to the API response
|
|
542
|
+
*/
|
|
543
|
+
private fetchData;
|
|
544
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ClientLoaderDataService, never>;
|
|
545
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ClientLoaderDataService>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* ClientPreLoaderDataService kicks off loader data fetches for all loaders in the current route
|
|
550
|
+
* and its parent routes in parallel, so that when Angular runs resolvers sequentially,
|
|
551
|
+
* resolvers get staged prefetched responses or join already-pending requests instead of waiting.
|
|
552
|
+
*
|
|
553
|
+
* Subscribes to the router's ActivationStart event and prefetches for the
|
|
554
|
+
* ActivatedRouteSnapshot when it is the leaf route (browser only). Discovers all loader
|
|
555
|
+
* resolvers on that snapshot and its parents (via LOADER_ID on pathFromRoot), then
|
|
556
|
+
* calls ClientLoaderDataService.prefetch() for each (loaderId, url, params, query). Fetches
|
|
557
|
+
* run in parallel; results are stored in ClientLoaderDataService prefetchedResponses for getData() to consume.
|
|
558
|
+
* @public
|
|
559
|
+
*/
|
|
560
|
+
declare class ClientPreLoaderDataService {
|
|
561
|
+
private readonly loaderData;
|
|
562
|
+
private readonly platformId;
|
|
563
|
+
private readonly router;
|
|
564
|
+
private readonly destroyRef;
|
|
565
|
+
constructor();
|
|
566
|
+
/**
|
|
567
|
+
* Prefetch loader data for all loaders in the route tree.
|
|
568
|
+
* Call this at the start of browser resolver execution so all loaders for the route
|
|
569
|
+
* are kicked off in parallel before resolvers run sequentially.
|
|
570
|
+
* No-op on server.
|
|
571
|
+
* @param {ActivatedRouteSnapshot} route - Current route (pathFromRoot gives current and parent routes)
|
|
572
|
+
* @param {RouterStateSnapshot} state - Current router state (use state.url for the navigation URL)
|
|
573
|
+
*/
|
|
574
|
+
prefetchForRoute(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<void>;
|
|
575
|
+
/**
|
|
576
|
+
* Collect LoaderDataRequest for each resolver that has LOADER_ID on the current route
|
|
577
|
+
* and its parent routes (pathFromRoot). Deduplicates by (loaderId, url).
|
|
578
|
+
* @param {ActivatedRouteSnapshot} route - The current route
|
|
579
|
+
* @param {RouterStateSnapshot} state - The router state snapshot, used for url and params
|
|
580
|
+
*/
|
|
581
|
+
private collectLoaders;
|
|
582
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ClientPreLoaderDataService, never>;
|
|
583
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ClientPreLoaderDataService>;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* SSR injection port for cache-aware loader resolution.
|
|
588
|
+
* Implemented by `ServerLoaderRunner` and wired via
|
|
589
|
+
* `provideServerLoaderRunner` (see the `server/express` module).
|
|
590
|
+
* @public
|
|
591
|
+
*/
|
|
592
|
+
interface ServerLoaderRunnerPort {
|
|
593
|
+
/**
|
|
594
|
+
* Resolve loader data on the server (cache-aware) using the shared {@link LOADER_REGISTRY}.
|
|
595
|
+
* @param {LoaderApiRequest} request - Loader request payload
|
|
596
|
+
* @returns {Promise<LoaderDataResult>} Resolved loader result
|
|
597
|
+
*/
|
|
598
|
+
resolve(request: LoaderApiRequest): Promise<LoaderDataResult>;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Injection token for SSR loader data resolution.
|
|
602
|
+
* Must be provided via `provideServerLoaderRunner` in server application config.
|
|
603
|
+
* @public
|
|
604
|
+
*/
|
|
605
|
+
declare const SERVER_LOADER_RUNNER: InjectionToken<ServerLoaderRunnerPort>;
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Returns a navigation error handler for use with withNavigationErrorHandler.
|
|
609
|
+
* Delegates to {@link redirectOnNavigationError}.
|
|
610
|
+
* @returns A handler compatible with `provideRouter(routes, withNavigationErrorHandler(...))`
|
|
611
|
+
* @public
|
|
612
|
+
*/
|
|
613
|
+
declare function handleNavigationError(): (error: NavigationError) => RedirectCommand | void;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Apply a redirect: internal URLs → RedirectCommand; external URLs → full page navigation.
|
|
617
|
+
* Use in resolvers and in the navigation error handler (fallback) so redirect behavior is consistent.
|
|
618
|
+
* Redirects are not errors; this helper is the single place that defines how to perform them.
|
|
619
|
+
* @param {Router} router - Angular Router (for internal redirects)
|
|
620
|
+
* @param {string} location - Target URL (path or full URL)
|
|
621
|
+
* @returns RedirectCommand for internal, void after window.location.assign for external
|
|
622
|
+
* @public
|
|
623
|
+
*/
|
|
624
|
+
declare function applyRedirect(router: Router, location: string): RedirectCommand | void;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Default path for the data endpoint used by loaders.
|
|
628
|
+
* This path will be requested by the client-side loader resolver to fetch data for the current route.
|
|
629
|
+
* @public
|
|
630
|
+
*/
|
|
631
|
+
declare const LOADER_DATA_ENDPOINT = "/_data";
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Minimal Express Request interface for type safety without requiring Express as a dependency
|
|
635
|
+
* @public
|
|
636
|
+
*/
|
|
637
|
+
interface ExpressRequest {
|
|
638
|
+
method: string;
|
|
639
|
+
path: string;
|
|
640
|
+
url: string;
|
|
641
|
+
body: unknown;
|
|
642
|
+
query: Record<string, string | string[] | undefined>;
|
|
643
|
+
/**
|
|
644
|
+
* Cookies from the request (requires cookie-parser middleware)
|
|
645
|
+
*/
|
|
646
|
+
cookies?: Record<string, string>;
|
|
647
|
+
/**
|
|
648
|
+
* Headers from the request
|
|
649
|
+
*/
|
|
650
|
+
headers?: Record<string, string | string[] | undefined>;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Minimal Express Response interface for type safety without requiring Express as a dependency
|
|
654
|
+
* @public
|
|
655
|
+
*/
|
|
656
|
+
interface ExpressResponse {
|
|
657
|
+
status(code: number): ExpressResponse;
|
|
658
|
+
json(data: unknown): void;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Configuration for server-side data handlers
|
|
662
|
+
* @public
|
|
663
|
+
*/
|
|
664
|
+
interface DataHandlerConfig {
|
|
665
|
+
/**
|
|
666
|
+
* The endpoint path for the data handler.
|
|
667
|
+
* @default '/_data'
|
|
668
|
+
*/
|
|
669
|
+
endpoint?: string;
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Express next function type
|
|
673
|
+
* @public
|
|
674
|
+
*/
|
|
675
|
+
type ExpressNextFunction = (error?: unknown) => void;
|
|
676
|
+
/**
|
|
677
|
+
* Express-compatible middleware type
|
|
678
|
+
* @public
|
|
679
|
+
*/
|
|
680
|
+
type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void | Promise<void>;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Options for the Express data handler
|
|
684
|
+
* @public
|
|
685
|
+
*/
|
|
686
|
+
interface ExpressDataHandlerOptions extends DataHandlerConfig {
|
|
687
|
+
/**
|
|
688
|
+
* The shared loader registry (same object as provideLoaderRegistry).
|
|
689
|
+
*/
|
|
690
|
+
loaders: LoaderRegistry;
|
|
691
|
+
/**
|
|
692
|
+
* Optional loader cache. When supplied, /_data responses go through
|
|
693
|
+
* cache-aside; omit to run loaders directly on every request.
|
|
694
|
+
*/
|
|
695
|
+
cache?: LoaderCache;
|
|
696
|
+
/**
|
|
697
|
+
* Optional request context extractor (e.g. for testing via TestBed).
|
|
698
|
+
* If not provided, uses the default implementation from loaders/utils.
|
|
699
|
+
* @internal
|
|
700
|
+
*/
|
|
701
|
+
extractRequestContext?: (req: ExpressRequest) => RequestContext;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Server-side cache aware loader data resolver.
|
|
706
|
+
* LoaderResolver is exposed to both server and browser. This layer ensures browser safety and acts as connecting layer to cache.
|
|
707
|
+
*
|
|
708
|
+
* Resolution order when a {@link LoaderCache} is attached:
|
|
709
|
+
* 1. **hit** — return cached value immediately.
|
|
710
|
+
* 2. **stale** — return cached value immediately and schedule a background refresh
|
|
711
|
+
* (coalesced per cache key via `pendingCacheOps`).
|
|
712
|
+
* 3. **miss** — run the loader, persist the result with OSR tags, return data.
|
|
713
|
+
*
|
|
714
|
+
* Redirect responses are never cached. Per-route LoaderCacheConfig overrides
|
|
715
|
+
* from `loaderResolver(id, cacheOptions)` control TTL, tags, and opt-in caching when
|
|
716
|
+
* the global cache is disabled.
|
|
717
|
+
* @public
|
|
718
|
+
*/
|
|
719
|
+
declare class ServerLoaderRunner {
|
|
720
|
+
private readonly registry;
|
|
721
|
+
private readonly cache?;
|
|
722
|
+
/** Process-wide coalescing for stale-while-revalidate background refreshes. */
|
|
723
|
+
private static readonly pendingCacheOps;
|
|
724
|
+
/**
|
|
725
|
+
* @param {LoaderRegistry} registry - Same loader map as `provideLoaderRegistry` / `/_data` middleware.
|
|
726
|
+
* @param {LoaderCache | undefined} cache - Optional cache instance from createLoaderCache.
|
|
727
|
+
*/
|
|
728
|
+
constructor(registry: LoaderRegistry, cache?: LoaderCache | undefined);
|
|
729
|
+
/**
|
|
730
|
+
* Resolve loader data with optional cache read-through and SWR refresh.
|
|
731
|
+
* @param {LoaderApiRequest} request - Loader id, URL, params, optional request context and cache overrides.
|
|
732
|
+
* @returns {Promise<LoaderDataResult>} Data, redirect, or error result for the middleware / SSR resolver.
|
|
733
|
+
*/
|
|
734
|
+
resolve(request: LoaderApiRequest): Promise<LoaderDataResult>;
|
|
735
|
+
/**
|
|
736
|
+
* Fire-and-forget SWR refresh; skipped when a refresh is already in flight for the key.
|
|
737
|
+
* @param {LoaderApiRequest} request - The loader request
|
|
738
|
+
* @param {LoaderContext} ctx - The loader context
|
|
739
|
+
* @param {string} cacheKey - The cache key
|
|
740
|
+
* @param {LoaderApiRequest['cacheOptions']} cacheOptions - The cache options
|
|
741
|
+
*/
|
|
742
|
+
private scheduleBackgroundRefresh;
|
|
743
|
+
private runLoader;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Wires SSR {@link SERVER_LOADER_RUNNER} to ServerLoaderRunner
|
|
748
|
+
* using the shared {@link LOADER_REGISTRY}. Include in server application providers
|
|
749
|
+
* alongside provideLoaderRegistry.
|
|
750
|
+
* @returns Environment providers for SSR loader data resolution
|
|
751
|
+
* @public
|
|
752
|
+
*/
|
|
753
|
+
declare function provideServerLoaderRunner(): EnvironmentProviders;
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Create an Express middleware for the data endpoint.
|
|
757
|
+
* This middleware handles both GET and POST requests at the configured endpoint path.
|
|
758
|
+
*
|
|
759
|
+
* The endpoint path must match the client: provide the same value to the Angular app via
|
|
760
|
+
* FETCH_DATA_ENDPOINT (e.g. in app.config.ts). There is no Angular DI in Node/Express,
|
|
761
|
+
* so you pass the endpoint here when calling this function (e.g. from server.ts).
|
|
762
|
+
* @param {ExpressDataHandlerOptions} options - Handler options: loaders and optional endpoint (defaults to {@link LOADER_DATA_ENDPOINT})
|
|
763
|
+
* @returns Express middleware that handles the data endpoint
|
|
764
|
+
* @example
|
|
765
|
+
* ```typescript
|
|
766
|
+
* import { createExpressDataMiddleware, LOADER_DATA_ENDPOINT } from '@sitecore-content-sdk/angular';
|
|
767
|
+
*
|
|
768
|
+
* // Pass the same LOADERS object used with provideLoaderRegistry(LOADERS)
|
|
769
|
+
* app.use(createExpressDataMiddleware({ loaders: LOADERS }));
|
|
770
|
+
*
|
|
771
|
+
* // Or pass the same endpoint you provide to the Angular app (FETCH_DATA_ENDPOINT)
|
|
772
|
+
* const dataEndpoint = process.env.DATA_ENDPOINT ?? LOADER_DATA_ENDPOINT;
|
|
773
|
+
* app.use(createExpressDataMiddleware({ loaders: LOADERS, endpoint: dataEndpoint }));
|
|
774
|
+
* ```
|
|
775
|
+
* @public
|
|
776
|
+
*/
|
|
777
|
+
declare function createLoaderDataServiceMiddleware(options: ExpressDataHandlerOptions): ExpressMiddleware;
|
|
778
|
+
/** @public */
|
|
779
|
+
declare const createExpressDataMiddleware: typeof createLoaderDataServiceMiddleware;
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Returns a non-empty trimmed secret, or `undefined` when unset or whitespace-only.
|
|
783
|
+
* @param {string | undefined} secretOption - Explicit secret from handler options.
|
|
784
|
+
* @param {string | undefined} envValue - Secret from `process.env` (e.g. `SITECORE_REVALIDATE_SECRET`).
|
|
785
|
+
* @returns {string | undefined} The resolved secret
|
|
786
|
+
* @internal
|
|
787
|
+
*/
|
|
788
|
+
declare function resolveConfiguredRevalidateSecret(secretOption: string | undefined, envValue: string | undefined): string | undefined;
|
|
789
|
+
/**
|
|
790
|
+
* Options for {@link createSitecoreRevalidateMiddleware}.
|
|
791
|
+
* @public
|
|
792
|
+
*/
|
|
793
|
+
interface SitecoreRevalidateMiddlewareOptions {
|
|
794
|
+
/** Shared cache instance from createLoaderCache call */
|
|
795
|
+
cache: LoaderCache;
|
|
796
|
+
/** Default: `process.env.SITECORE_REVALIDATE_SECRET` */
|
|
797
|
+
secret?: string;
|
|
798
|
+
/** Locale fallback when an update has no `entity_culture`; default `'en'`. */
|
|
799
|
+
defaultLocale?: string;
|
|
800
|
+
/**
|
|
801
|
+
* When set, every webhook also marks stale one
|
|
802
|
+
* `sc:loader:dictionary:<site>:<locale>` entry per site (dictionary fan-out).
|
|
803
|
+
*/
|
|
804
|
+
sites?: SiteInfo[];
|
|
805
|
+
/** Endpoint path; default `/api/revalidate`. */
|
|
806
|
+
endpoint?: string;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Express middleware aligned with Next.js `createSitecoreRevalidateRouteHandler`.
|
|
810
|
+
*
|
|
811
|
+
* Handles `POST /api/revalidate` (configurable via `endpoint`):
|
|
812
|
+
* - Authenticates with `SITECORE_REVALIDATE_SECRET` / `x-revalidate-secret` when configured.
|
|
813
|
+
* - Parses Experience Edge webhook bodies via {@link collectSitecoreTagsFromEdgeRevalidateRequestBody}.
|
|
814
|
+
* - Optionally appends dictionary loader tags for each configured site.
|
|
815
|
+
* - Calls `LoaderCache.invalidate` (marks entries stale; does not delete).
|
|
816
|
+
*
|
|
817
|
+
* Response shape: `{ revalidated, tagsCount, marked, invocation_id, continues, durationMs }`.
|
|
818
|
+
* @param {SitecoreRevalidateMiddlewareOptions} options - The options for the middleware
|
|
819
|
+
* @returns {ExpressMiddleware} The middleware function
|
|
820
|
+
* @public
|
|
821
|
+
*/
|
|
822
|
+
declare function createSitecoreRevalidateMiddleware(options: SitecoreRevalidateMiddlewareOptions): ExpressMiddleware;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* One content change entry as commonly seen in Experience Edge / Content Operations payloads.
|
|
826
|
+
* @public
|
|
827
|
+
*/
|
|
828
|
+
type SitecoreEdgeRevalidateUpdate = {
|
|
829
|
+
identifier?: string;
|
|
830
|
+
entity_definition?: string;
|
|
831
|
+
operation?: string;
|
|
832
|
+
entity_culture?: string;
|
|
833
|
+
};
|
|
834
|
+
/**
|
|
835
|
+
* Request body shape for webhook-driven revalidation.
|
|
836
|
+
* @public
|
|
837
|
+
*/
|
|
838
|
+
type SitecoreEdgeRevalidateRequestBody = {
|
|
839
|
+
invocation_id?: string;
|
|
840
|
+
updates?: SitecoreEdgeRevalidateUpdate[];
|
|
841
|
+
continues?: boolean;
|
|
842
|
+
tags?: string[];
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* Strips Experience Edge style suffixes from an `identifier`.
|
|
846
|
+
* @param {string} identifier - Raw identifier from a webhook update row.
|
|
847
|
+
* @public
|
|
848
|
+
*/
|
|
849
|
+
declare function extractSitecoreEdgeContentId(identifier: string): string;
|
|
850
|
+
/**
|
|
851
|
+
* Options for {@link collectSitecoreTagsFromEdgeRevalidateRequestBody}.
|
|
852
|
+
* @public
|
|
853
|
+
*/
|
|
854
|
+
type CollectSitecoreTagsFromEdgeBodyOptions = {
|
|
855
|
+
defaultLocale: string;
|
|
856
|
+
};
|
|
857
|
+
/**
|
|
858
|
+
* Maps an Experience Edge webhook JSON body to Sitecore cache tag strings.
|
|
859
|
+
*
|
|
860
|
+
* Accepts fully qualified `sc:…` tags in `body.tags`, raw content identifiers
|
|
861
|
+
* (with optional `-media`/`-layout` suffixes), and `updates[]` rows with
|
|
862
|
+
* `identifier` + `entity_culture`.
|
|
863
|
+
* @param {SitecoreEdgeRevalidateRequestBody | null | undefined} body - Parsed webhook JSON body.
|
|
864
|
+
* @param {CollectSitecoreTagsFromEdgeBodyOptions} options - Locale fallback when an update omits `entity_culture`.
|
|
865
|
+
* @returns {string[]} Deduplicated Sitecore cache tags ready for `LoaderCache.invalidate`.
|
|
866
|
+
* @public
|
|
867
|
+
*/
|
|
868
|
+
declare function collectSitecoreTagsFromEdgeRevalidateRequestBody(body: SitecoreEdgeRevalidateRequestBody | null | undefined, options: CollectSitecoreTagsFromEdgeBodyOptions): string[];
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Global config for the loader cache. Consumed by `createLoaderCache()` in
|
|
872
|
+
* the app's `server.ts`.
|
|
873
|
+
*
|
|
874
|
+
* Moved to separate file to avoid accidental `unstorage` imports in browser-safe code.
|
|
875
|
+
*
|
|
876
|
+
* Drivers are imported and instantiated in the app (e.g.
|
|
877
|
+
* `fsDriver({ base: './.cache/loaders' })`) — the package does not own driver
|
|
878
|
+
* selection. When `driver` is omitted, the cache falls back to its built-in
|
|
879
|
+
* in-memory implementation.
|
|
880
|
+
* @public
|
|
881
|
+
*/
|
|
882
|
+
interface GlobalLoaderCacheConfig extends LoaderCacheConfig {
|
|
883
|
+
/**
|
|
884
|
+
* Unstorage `Driver` instance. Pass an imported driver — the cache wraps it
|
|
885
|
+
* with `createStorage({ driver })` internally. Omit for the in-memory default.
|
|
886
|
+
*/
|
|
887
|
+
driver?: Driver;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Public factory for the loader cache with unstorage backing.
|
|
892
|
+
* Uses the memory driver by default.
|
|
893
|
+
*
|
|
894
|
+
* Drivers are best imported and constructed in the app's `server.ts` and passed here as an instance.
|
|
895
|
+
* Callers depend on the {@link LoaderCache} interface; concrete classes are not exported.
|
|
896
|
+
* @param {GlobalLoaderCacheConfig} [config] - Global cache config and optional unstorage driver.
|
|
897
|
+
* @returns {LoaderCache} Cache implementation with Phase 3 SWR + tag semantics.
|
|
898
|
+
* @example
|
|
899
|
+
* ```ts
|
|
900
|
+
* const cache = createLoaderCache({
|
|
901
|
+
* revalidate: config.angular.loadersCache.revalidate,
|
|
902
|
+
* enabled: config.angular.loadersCache.enabled,
|
|
903
|
+
* defaultSiteName: config.defaultSite,
|
|
904
|
+
* driver: fsDriver({ base: './.cache/loaders' }),
|
|
905
|
+
* });
|
|
906
|
+
* ```
|
|
907
|
+
* @public
|
|
908
|
+
*/
|
|
909
|
+
declare function createLoaderCache(config?: GlobalLoaderCacheConfig): LoaderCache;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* This middleware is only used for testing and should be removed before release.
|
|
913
|
+
* TODO: Remove this middleware before release.
|
|
914
|
+
*/
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Options for the admin middleware.
|
|
918
|
+
* @public
|
|
919
|
+
*/
|
|
920
|
+
interface CacheAdminMiddlewareOptions {
|
|
921
|
+
/** The cache instance to expose. Capture once in `server.ts`. */
|
|
922
|
+
cache: LoaderCache;
|
|
923
|
+
/** Base path. Defaults to `/api/_cache`. */
|
|
924
|
+
endpoint?: string;
|
|
925
|
+
/**
|
|
926
|
+
* Optional auth gate. Return true to allow. Defaults to allowing everything,
|
|
927
|
+
* which is fine for local demos — *do not* leave that default in a deploy.
|
|
928
|
+
*/
|
|
929
|
+
auth?: (req: ExpressRequest) => boolean;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Lightweight admin surface for the loader cache:
|
|
933
|
+
* GET <endpoint>/entries → list entries (metadata only, no values)
|
|
934
|
+
* POST <endpoint>/invalidate → mark stale by tags (JSON body)
|
|
935
|
+
* POST <endpoint>/flush → flush every entry
|
|
936
|
+
* GET <endpoint>/config → resolved config (for the demo UI)
|
|
937
|
+
* @public
|
|
938
|
+
*/
|
|
939
|
+
declare function createCacheAdminMiddleware(options: CacheAdminMiddlewareOptions): ExpressMiddleware;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Request-scoped Sitecore context derived reactively from the Angular Router.
|
|
943
|
+
*
|
|
944
|
+
* - `page` / `dictionary` — from route resolve data (`loaderResolver('page'|'dictionary')`)
|
|
945
|
+
* - `urlLocale` — from current pathname (SSR REQUEST / window.location, then NavigationEnd)
|
|
946
|
+
* - `isEditing` / `effectiveLocale` — computed from page + urlLocale + config
|
|
947
|
+
*
|
|
948
|
+
* No manual `setPage` / `setDictionary` / `setLocale` wiring required in app components.
|
|
949
|
+
* @public
|
|
950
|
+
*/
|
|
951
|
+
declare class SitecoreContextService {
|
|
952
|
+
/** Current Sitecore page data (layout + mode). */
|
|
953
|
+
readonly page: Signal<Page | null>;
|
|
954
|
+
/** Current Sitecore dictionary data. */
|
|
955
|
+
readonly dictionary: Signal<DictionaryPhrases | null>;
|
|
956
|
+
/** Whether the current page is in editing mode. */
|
|
957
|
+
readonly isEditing: Signal<boolean>;
|
|
958
|
+
/**
|
|
959
|
+
* Locale extracted from the current URL; `null` when no configured-locale prefix
|
|
960
|
+
* or when locales are not configured.
|
|
961
|
+
*/
|
|
962
|
+
readonly urlLocale: Signal<string | null>;
|
|
963
|
+
/**
|
|
964
|
+
* Effective locale for data fetching: `page.locale ?? urlLocale ?? defaultLanguage`.
|
|
965
|
+
*/
|
|
966
|
+
readonly effectiveLocale: Signal<string>;
|
|
967
|
+
private readonly router;
|
|
968
|
+
private readonly config;
|
|
969
|
+
private readonly platformId;
|
|
970
|
+
private readonly req;
|
|
971
|
+
private readonly isBrowser;
|
|
972
|
+
private readonly locales;
|
|
973
|
+
private readonly defaultLanguage;
|
|
974
|
+
/** Merged resolve data; updates on every completed navigation. */
|
|
975
|
+
private readonly routeData;
|
|
976
|
+
/**
|
|
977
|
+
* Current pathname without query string.
|
|
978
|
+
* SSR/bootstrap: REQUEST or window.location; client: NavigationEnd.urlAfterRedirects.
|
|
979
|
+
*/
|
|
980
|
+
private readonly pathname;
|
|
981
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SitecoreContextService, never>;
|
|
982
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SitecoreContextService>;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* `ngx-translate` loader using Sitecore dictionary from {@link SitecoreContextService}.
|
|
987
|
+
* Requires a `dictionaryLoader` resolver on the active route — without it, `dictionary()`
|
|
988
|
+
* is `null` and translations resolve to `{}`.
|
|
989
|
+
* @public
|
|
990
|
+
*/
|
|
991
|
+
declare class SitecoreTranslateLoader implements TranslateLoader {
|
|
992
|
+
private readonly context;
|
|
993
|
+
/**
|
|
994
|
+
* Returns the translation based on the dictionary in the context from {@link SitecoreContextService}.
|
|
995
|
+
* @returns {Observable<Record<string, string>>} Observable of translation dictionary.
|
|
996
|
+
*/
|
|
997
|
+
getTranslation(): Observable<Record<string, string>>;
|
|
998
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SitecoreTranslateLoader, never>;
|
|
999
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<SitecoreTranslateLoader>;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Result of locale extraction from a URL path.
|
|
1004
|
+
* @public
|
|
1005
|
+
*/
|
|
1006
|
+
interface LocaleExtractionResult {
|
|
1007
|
+
/** Configured locale found at the start of the path, or `null` when absent. */
|
|
1008
|
+
locale: string | null;
|
|
1009
|
+
/** Remainder of the path after the locale segment (always starts with `/`). */
|
|
1010
|
+
nonLocalePath: string;
|
|
1011
|
+
/** Query or fragment string found at the end of the path, or `null` when absent. */
|
|
1012
|
+
queryFragment?: string;
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Extracts a configured locale from the first segment of a URL pathname.
|
|
1016
|
+
* Returns `{ locale: null, nonLocalePath: pathname, queryFragment: query or fragment string }` when the first segment is not a configured locale.
|
|
1017
|
+
* @param {string} pathname - URL pathname, with or without leading `/`.
|
|
1018
|
+
* @param {string[]} locales - Configured locales.
|
|
1019
|
+
* @returns {LocaleExtractionResult} Detected locale and the rest of the path.
|
|
1020
|
+
* @public
|
|
1021
|
+
*/
|
|
1022
|
+
declare function splitLocaleFromPath(pathname: string, locales: string[]): LocaleExtractionResult;
|
|
1023
|
+
/**
|
|
1024
|
+
* Creates an Angular {@link UrlMatcher} that consumes a configured-locale segment from
|
|
1025
|
+
* the start of a route. When the first URL segment matches one of scConfig's `locales`, it is consumed
|
|
1026
|
+
* and exposed as the `locale` route param. Otherwise zero segments are consumed and the
|
|
1027
|
+
* route still matches (so error routes and the catchall handle both prefixed and unprefixed
|
|
1028
|
+
* URLs from the same route tree).
|
|
1029
|
+
* @param {string[]} locales - Configured locales.
|
|
1030
|
+
* @returns {UrlMatcher} Angular URL matcher for locale-prefixed route trees.
|
|
1031
|
+
* @public
|
|
1032
|
+
*/
|
|
1033
|
+
declare function scLocaleMatcher(locales: string[]): UrlMatcher;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Locale-aware {@link UrlSerializer} replacement. Extends {@link DefaultUrlSerializer} and
|
|
1037
|
+
* prepends the current URL locale (from the request pathname) to every serialized
|
|
1038
|
+
* URL. Angular's built-in `[routerLink]` computes hrefs via `router.serializeUrl()`, which
|
|
1039
|
+
* delegates to the DI-injected `UrlSerializer.serialize()` — so replacing the binding makes
|
|
1040
|
+
* every routerLink href locale-aware with no directive changes.
|
|
1041
|
+
*
|
|
1042
|
+
* Behavior:
|
|
1043
|
+
* - When `currentLocale` is `null` (URL has no configured locale prefix), serialization is
|
|
1044
|
+
* unchanged.
|
|
1045
|
+
* - When the serialized URL already starts with a configured locale segment, serialization
|
|
1046
|
+
* is unchanged (mirrors ScLinkDirective idempotency under repeated cycles).
|
|
1047
|
+
* - Otherwise the locale segment is prepended to the serialized URL.
|
|
1048
|
+
*
|
|
1049
|
+
* Parsing is inherited from the default — this serializer does **not** strip locale on
|
|
1050
|
+
* parse. The locale matcher (`scLocaleMatcher`) consumes the locale segment from the
|
|
1051
|
+
* route tree instead.
|
|
1052
|
+
* @public
|
|
1053
|
+
*/
|
|
1054
|
+
declare class LocaleUrlSerializer extends DefaultUrlSerializer {
|
|
1055
|
+
private readonly locales;
|
|
1056
|
+
private readonly req;
|
|
1057
|
+
private readonly platformId;
|
|
1058
|
+
serialize(tree: UrlTree): string;
|
|
1059
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LocaleUrlSerializer, never>;
|
|
1060
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<LocaleUrlSerializer>;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* SXA uses a special export name to identify the "default" variant.
|
|
1065
|
+
* @public
|
|
1066
|
+
*/
|
|
1067
|
+
declare const DEFAULT_EXPORT_NAME = "Default";
|
|
1068
|
+
type AngularModule = {
|
|
1069
|
+
/** Named variant exports */
|
|
1070
|
+
[key: string]: Type<unknown> | undefined;
|
|
1071
|
+
/** Default component for this rendering */
|
|
1072
|
+
default?: Type<unknown>;
|
|
1073
|
+
/** SXA convention: uppercase Default */
|
|
1074
|
+
Default?: Type<unknown>;
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* An entry in the Angular component map. Maps Sitecore rendering names to Angular component types.
|
|
1078
|
+
* Supports SXA rendering variants via named exports alongside a default.
|
|
1079
|
+
* @public
|
|
1080
|
+
*/
|
|
1081
|
+
type AngularContentSdkComponent = Type<unknown> | AngularModule;
|
|
1082
|
+
/**
|
|
1083
|
+
* The Angular component map type: maps Sitecore rendering names to standalone component types or SXA variant groups.
|
|
1084
|
+
* @public
|
|
1085
|
+
*/
|
|
1086
|
+
type ComponentMap = Map<string, AngularContentSdkComponent>;
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Injection token for the Sitecore component map.
|
|
1090
|
+
* Provide this at the application level via `provideSitecoreAngular` or
|
|
1091
|
+
* directly as `{ provide: SITECORE_COMPONENT_MAP, useValue: yourMap }`.
|
|
1092
|
+
* @public
|
|
1093
|
+
*/
|
|
1094
|
+
declare const SITECORE_COMPONENT_MAP: InjectionToken<ComponentMap>;
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Result of resolving a component for a rendering definition.
|
|
1098
|
+
*/
|
|
1099
|
+
interface ComponentForRendering {
|
|
1100
|
+
component: Type<unknown> | null;
|
|
1101
|
+
isEmpty: boolean;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* Merged props passed to each child component rendered by a placeholder.
|
|
1105
|
+
* Matches React `getChildComponentProps`: merged `fields` / `params` props plus raw `rendering`.
|
|
1106
|
+
*/
|
|
1107
|
+
interface ChildComponentProps {
|
|
1108
|
+
fields: {
|
|
1109
|
+
[key: string]: unknown;
|
|
1110
|
+
};
|
|
1111
|
+
params: {
|
|
1112
|
+
[key: string]: string;
|
|
1113
|
+
};
|
|
1114
|
+
rendering: ComponentRendering;
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Get the renderings for the specified placeholder from the rendering layout data.
|
|
1118
|
+
* Includes dynamic placeholder handling aligned with React's implementation.
|
|
1119
|
+
* @param {ComponentRendering | RouteData} rendering - rendering data
|
|
1120
|
+
* @param {string} name - placeholder name
|
|
1121
|
+
* @param {boolean} isEditing - whether editing mode is active
|
|
1122
|
+
* @returns {ComponentRendering[]} Child renderings for the placeholder.
|
|
1123
|
+
*/
|
|
1124
|
+
declare const getPlaceholderRenderings: (rendering: ComponentRendering | RouteData, name: string, isEditing: boolean) => ComponentRendering[];
|
|
1125
|
+
/**
|
|
1126
|
+
* Extra inputs to set on each dynamically rendered component (in addition to `fields`, `params`, and `rendering`).
|
|
1127
|
+
* Keys are Angular `input()` names on the host component.
|
|
1128
|
+
* @public
|
|
1129
|
+
*/
|
|
1130
|
+
type PassThroughProps = Readonly<Record<string, unknown>>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Get SXA specific params from Sitecore rendering params.
|
|
1133
|
+
* @param {ComponentRendering} rendering - Rendering object.
|
|
1134
|
+
* @returns {{ Styles: string } | undefined} Converted SXA params, or `undefined` when none apply.
|
|
1135
|
+
*/
|
|
1136
|
+
declare const getSXAParams: (rendering: ComponentRendering) => {
|
|
1137
|
+
Styles: string;
|
|
1138
|
+
} | undefined;
|
|
1139
|
+
/**
|
|
1140
|
+
* Merge placeholder-level fields/params with per-component fields/params.
|
|
1141
|
+
* @param {{ [key: string]: unknown } | undefined} placeholderFields - Placeholder-level fields.
|
|
1142
|
+
* @param {{ [key: string]: string } | undefined} placeholderParams - Placeholder-level params.
|
|
1143
|
+
* @param {ComponentRendering} componentRendering - The component rendering data.
|
|
1144
|
+
* @returns {ChildComponentProps} Merged child component props.
|
|
1145
|
+
*/
|
|
1146
|
+
declare function getChildComponentProps(placeholderFields: {
|
|
1147
|
+
[key: string]: unknown;
|
|
1148
|
+
} | undefined, placeholderParams: {
|
|
1149
|
+
[key: string]: string;
|
|
1150
|
+
} | undefined, componentRendering: ComponentRendering): ChildComponentProps;
|
|
1151
|
+
/**
|
|
1152
|
+
* Resolve a component type for a rendering definition.
|
|
1153
|
+
* Handles hidden renderings, missing components, variant selection, and map lookup.
|
|
1154
|
+
* FEaaS/BYOC are intentionally not handled; they fall through to missingComponent.
|
|
1155
|
+
* @param {ComponentRendering} renderingDefinition - The rendering to resolve.
|
|
1156
|
+
* @param {string} placeholderName - Current placeholder name (for logging).
|
|
1157
|
+
* @param {ComponentMap | undefined} componentMap - The app component map.
|
|
1158
|
+
* @param {Type<unknown> | undefined} hiddenRenderingComponent - Optional override for hidden renderings.
|
|
1159
|
+
* @param {Type<unknown> | undefined} missingComponentComponent - Optional override for missing/unknown components.
|
|
1160
|
+
* @returns {ComponentForRendering} Resolved component info.
|
|
1161
|
+
*/
|
|
1162
|
+
declare const resolveComponentForRendering: (renderingDefinition: ComponentRendering, placeholderName: string, componentMap: ComponentMap, hiddenRenderingComponent?: Type<unknown>, missingComponentComponent?: Type<unknown>) => ComponentForRendering;
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* Angular placeholder component. Renders components from layout data for a given placeholder name.
|
|
1166
|
+
*
|
|
1167
|
+
* Usage:
|
|
1168
|
+
* ```html
|
|
1169
|
+
* <sc-placeholder name="headless-main" [rendering]="route"></sc-placeholder>
|
|
1170
|
+
* ```
|
|
1171
|
+
*
|
|
1172
|
+
* Optional `[passThroughProps]` sets extra `input()` values on each child (merged after `fields`, `params`, and `rendering`).
|
|
1173
|
+
* @public
|
|
1174
|
+
*/
|
|
1175
|
+
declare class ScPlaceholderComponent {
|
|
1176
|
+
/** Name of the placeholder to render. */
|
|
1177
|
+
readonly name: i0.InputSignal<string>;
|
|
1178
|
+
/** Rendering or route data containing placeholders. */
|
|
1179
|
+
readonly rendering: i0.InputSignal<RouteData<Record<string, _sitecore_content_sdk_angular.Field<_sitecore_content_sdk_content_layout.GenericFieldValue> | _sitecore_content_sdk_angular.Item | _sitecore_content_sdk_angular.Item[]>> | ComponentRendering<_sitecore_content_sdk_angular.ComponentFields>>;
|
|
1180
|
+
/** Optional placeholder-level fields merged into each child. */
|
|
1181
|
+
readonly fields: i0.InputSignal<{
|
|
1182
|
+
[key: string]: unknown;
|
|
1183
|
+
} | undefined>;
|
|
1184
|
+
/** Optional placeholder-level params merged into each child's `params` input. */
|
|
1185
|
+
readonly params: i0.InputSignal<{
|
|
1186
|
+
[key: string]: string;
|
|
1187
|
+
} | undefined>;
|
|
1188
|
+
/**
|
|
1189
|
+
* Extra inputs to set on each dynamically created component, after the standard `fields`, `params`, and `rendering` inputs.
|
|
1190
|
+
* Keys must match `input()` names on the target components.
|
|
1191
|
+
*/
|
|
1192
|
+
readonly passThroughProps: i0.InputSignal<Readonly<Record<string, unknown>>>;
|
|
1193
|
+
/** Override component map (defaults to injected SITECORE_COMPONENT_MAP). */
|
|
1194
|
+
readonly componentMap: i0.InputSignal<ComponentMap | undefined>;
|
|
1195
|
+
/** Override for missing component rendering. */
|
|
1196
|
+
readonly missingComponent: i0.InputSignal<Type<unknown> | undefined>;
|
|
1197
|
+
/** Override for hidden rendering component. */
|
|
1198
|
+
readonly hiddenRenderingComponent: i0.InputSignal<Type<unknown> | undefined>;
|
|
1199
|
+
private readonly context;
|
|
1200
|
+
private readonly contextComponentMap;
|
|
1201
|
+
private readonly injector;
|
|
1202
|
+
private readonly containerRef;
|
|
1203
|
+
private readonly isEditing;
|
|
1204
|
+
constructor();
|
|
1205
|
+
private trySetInput;
|
|
1206
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScPlaceholderComponent, never>;
|
|
1207
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScPlaceholderComponent, "sc-placeholder", never, { "name": { "alias": "name"; "required": true; "isSignal": true; }; "rendering": { "alias": "rendering"; "required": true; "isSignal": true; }; "fields": { "alias": "fields"; "required": false; "isSignal": true; }; "params": { "alias": "params"; "required": false; "isSignal": true; }; "passThroughProps": { "alias": "passThroughProps"; "required": false; "isSignal": true; }; "componentMap": { "alias": "componentMap"; "required": false; "isSignal": true; }; "missingComponent": { "alias": "missingComponent"; "required": false; "isSignal": true; }; "hiddenRenderingComponent": { "alias": "hiddenRenderingComponent"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Angular wrapper for Sitecore Forms.
|
|
1212
|
+
* Loads form HTML from Edge, executes embedded scripts, and subscribes to form events.
|
|
1213
|
+
*
|
|
1214
|
+
* Usage: register in the component map with the rendering name "Form".
|
|
1215
|
+
* @public
|
|
1216
|
+
*/
|
|
1217
|
+
declare class ScFormComponent {
|
|
1218
|
+
private formContainerRef;
|
|
1219
|
+
readonly rendering: i0.InputSignal<ComponentRendering<_sitecore_content_sdk_angular.ComponentFields> | undefined>;
|
|
1220
|
+
readonly params: i0.InputSignal<{
|
|
1221
|
+
[key: string]: string;
|
|
1222
|
+
}>;
|
|
1223
|
+
private readonly config;
|
|
1224
|
+
private readonly context;
|
|
1225
|
+
private readonly platformId;
|
|
1226
|
+
private readonly destroyRef;
|
|
1227
|
+
/**
|
|
1228
|
+
* Merges `rendering.params` with the `params` input: the component `params()` values override layout for the same key.
|
|
1229
|
+
*/
|
|
1230
|
+
private mergedFormParams;
|
|
1231
|
+
constructor();
|
|
1232
|
+
readonly styles: () => string;
|
|
1233
|
+
readonly renderingId: () => string | undefined;
|
|
1234
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScFormComponent, never>;
|
|
1235
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScFormComponent, "sc-form", never, { "rendering": { "alias": "rendering"; "required": false; "isSignal": true; }; "params": { "alias": "params"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/**
|
|
1239
|
+
* Default component rendered when a Sitecore rendering has no matching entry in the component map.
|
|
1240
|
+
* @public
|
|
1241
|
+
*/
|
|
1242
|
+
declare class ScMissingComponentComponent {
|
|
1243
|
+
readonly rendering: i0.InputSignal<ComponentRendering<_sitecore_content_sdk_angular.ComponentFields> | undefined>;
|
|
1244
|
+
readonly fields: i0.InputSignal<{
|
|
1245
|
+
[key: string]: unknown;
|
|
1246
|
+
} | undefined>;
|
|
1247
|
+
readonly params: i0.InputSignal<{
|
|
1248
|
+
[key: string]: string;
|
|
1249
|
+
} | undefined>;
|
|
1250
|
+
readonly componentName: () => string;
|
|
1251
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScMissingComponentComponent, never>;
|
|
1252
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScMissingComponentComponent, "sc-missing-component", never, { "rendering": { "alias": "rendering"; "required": false; "isSignal": true; }; "fields": { "alias": "fields"; "required": false; "isSignal": true; }; "params": { "alias": "params"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* Default component rendered for hidden Sitecore renderings.
|
|
1257
|
+
* @public
|
|
1258
|
+
*/
|
|
1259
|
+
declare class ScHiddenRenderingComponent {
|
|
1260
|
+
readonly rendering: i0.InputSignal<ComponentRendering<_sitecore_content_sdk_angular.ComponentFields> | undefined>;
|
|
1261
|
+
readonly fields: i0.InputSignal<{
|
|
1262
|
+
[key: string]: unknown;
|
|
1263
|
+
} | undefined>;
|
|
1264
|
+
readonly params: i0.InputSignal<{
|
|
1265
|
+
[key: string]: string;
|
|
1266
|
+
} | undefined>;
|
|
1267
|
+
readonly styles: {
|
|
1268
|
+
background: string;
|
|
1269
|
+
minHeight: string;
|
|
1270
|
+
border: string;
|
|
1271
|
+
padding: string;
|
|
1272
|
+
opacity: number;
|
|
1273
|
+
};
|
|
1274
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScHiddenRenderingComponent, never>;
|
|
1275
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ScHiddenRenderingComponent, "sc-hidden-rendering", never, { "rendering": { "alias": "rendering"; "required": false; "isSignal": true; }; "fields": { "alias": "fields"; "required": false; "isSignal": true; }; "params": { "alias": "params"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
/**
|
|
1279
|
+
* Renders a Sitecore text field value into the host element's text content.
|
|
1280
|
+
* For simple string/number fields in published mode.
|
|
1281
|
+
*
|
|
1282
|
+
* Usage:
|
|
1283
|
+
* ```html
|
|
1284
|
+
* <h1 [scText]="fields.Title"></h1>
|
|
1285
|
+
* <span [scText]="fields.Subtitle" scTextEncode="false"></span>
|
|
1286
|
+
* ```
|
|
1287
|
+
* @public
|
|
1288
|
+
*/
|
|
1289
|
+
declare class ScTextDirective {
|
|
1290
|
+
/** The Sitecore text field. */
|
|
1291
|
+
readonly scText: i0.InputSignal<TextField>;
|
|
1292
|
+
/** Whether to HTML-encode the value (default: true). When false, uses innerHTML. */
|
|
1293
|
+
readonly scTextEncode: i0.InputSignal<boolean>;
|
|
1294
|
+
private readonly el;
|
|
1295
|
+
private readonly renderer;
|
|
1296
|
+
constructor();
|
|
1297
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScTextDirective, never>;
|
|
1298
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScTextDirective, "[scText]", never, { "scText": { "alias": "scText"; "required": true; "isSignal": true; }; "scTextEncode": { "alias": "scTextEncode"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Image field value shape.
|
|
1303
|
+
*/
|
|
1304
|
+
interface ImageFieldValue {
|
|
1305
|
+
[attributeName: string]: unknown;
|
|
1306
|
+
src?: string;
|
|
1307
|
+
alt?: string;
|
|
1308
|
+
width?: number;
|
|
1309
|
+
height?: number;
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Image field shape (with optional value wrapper).
|
|
1313
|
+
*/
|
|
1314
|
+
interface ImageField {
|
|
1315
|
+
value?: ImageFieldValue;
|
|
1316
|
+
metadata?: {
|
|
1317
|
+
[key: string]: unknown;
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
/**
|
|
1321
|
+
* Renders a Sitecore image field onto a host `<img>` element.
|
|
1322
|
+
* Sets `src`, `alt`, and other attributes from the field data.
|
|
1323
|
+
*
|
|
1324
|
+
* Usage:
|
|
1325
|
+
* ```html
|
|
1326
|
+
* <img [scImage]="fields.Image" />
|
|
1327
|
+
* ```
|
|
1328
|
+
* @public
|
|
1329
|
+
*/
|
|
1330
|
+
declare class ScImageDirective {
|
|
1331
|
+
/** The Sitecore image field. */
|
|
1332
|
+
readonly scImage: i0.InputSignal<ImageFieldValue | ImageField | undefined>;
|
|
1333
|
+
/** Optional image params for media URL transformation. */
|
|
1334
|
+
readonly imageParams: i0.InputSignal<{
|
|
1335
|
+
[paramName: string]: string | number;
|
|
1336
|
+
} | undefined>;
|
|
1337
|
+
/** Optional media URL prefix regexp. */
|
|
1338
|
+
readonly mediaUrlPrefix: i0.InputSignal<RegExp | undefined>;
|
|
1339
|
+
private readonly el;
|
|
1340
|
+
private readonly renderer;
|
|
1341
|
+
constructor();
|
|
1342
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScImageDirective, never>;
|
|
1343
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScImageDirective, "img[scImage]", never, { "scImage": { "alias": "scImage"; "required": true; "isSignal": true; }; "imageParams": { "alias": "imageParams"; "required": false; "isSignal": true; }; "mediaUrlPrefix": { "alias": "mediaUrlPrefix"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* Renders a Sitecore link field onto a host `<a>` element.
|
|
1348
|
+
* Sets `href`, `title`, `target`, `class`, and text content from the field data.
|
|
1349
|
+
*
|
|
1350
|
+
* Locale-awareness: when a configured locale list is provided via `sitecore.config`,
|
|
1351
|
+
* internal hrefs are prefixed with the current URL locale (read from
|
|
1352
|
+
* {@link SitecoreContextService}). Hrefs that already contain a configured-locale segment
|
|
1353
|
+
* are written as-is, which respects author-intent cross-locale links and keeps the
|
|
1354
|
+
* directive idempotent under repeated change detection.
|
|
1355
|
+
*
|
|
1356
|
+
* Usage:
|
|
1357
|
+
* ```html
|
|
1358
|
+
* <a [scLink]="fields.Link">Optional child content</a>
|
|
1359
|
+
* ```
|
|
1360
|
+
* @public
|
|
1361
|
+
*/
|
|
1362
|
+
declare class ScLinkDirective {
|
|
1363
|
+
/** The Sitecore link field. */
|
|
1364
|
+
readonly scLink: i0.InputSignal<LinkField | LinkFieldValue>;
|
|
1365
|
+
/** Whether to show link text alongside existing child content. */
|
|
1366
|
+
readonly preferTextFromField: i0.InputSignal<boolean>;
|
|
1367
|
+
protected readonly el: ElementRef<any>;
|
|
1368
|
+
private readonly renderer;
|
|
1369
|
+
private readonly context;
|
|
1370
|
+
private readonly locales;
|
|
1371
|
+
private readonly originalClass;
|
|
1372
|
+
private readonly originalTitle;
|
|
1373
|
+
private readonly originalTarget;
|
|
1374
|
+
private readonly originalRel;
|
|
1375
|
+
constructor();
|
|
1376
|
+
/**
|
|
1377
|
+
* Returns a copy of the link with `href` prefixed by the current URL locale when applicable.
|
|
1378
|
+
* Internal hrefs are prefixed only when:
|
|
1379
|
+
* 1. There is a current URL locale (page itself has a locale prefix), and
|
|
1380
|
+
* 2. The href does not already start with a configured locale segment.
|
|
1381
|
+
* External, fragment-only, and locale-prefixed hrefs are returned unchanged.
|
|
1382
|
+
* @param {LinkFieldValue} link - Resolved link value from layout data.
|
|
1383
|
+
* @returns {LinkFieldValue} Link value with locale-aware href.
|
|
1384
|
+
*/
|
|
1385
|
+
private localizeLink;
|
|
1386
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScLinkDirective, never>;
|
|
1387
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScLinkDirective, "a[scLink]", never, { "scLink": { "alias": "scLink"; "required": true; "isSignal": true; }; "preferTextFromField": { "alias": "preferTextFromField"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/**
|
|
1391
|
+
* Renders a Sitecore link field onto a host `<a>` and calls `Router.navigateByUrl` on click
|
|
1392
|
+
* for in-app paths only. Clicks are left to the browser when `href` is missing/empty, when
|
|
1393
|
+
* `target="_blank"`, or when `href` uses http(s), mailto, tel, sms, javascript, data, ftp,
|
|
1394
|
+
* or protocol-relative (`//`) URLs.
|
|
1395
|
+
*
|
|
1396
|
+
* Usage:
|
|
1397
|
+
* ```html
|
|
1398
|
+
* <a [scRouterLink]="fields.Link">Optional child content</a>
|
|
1399
|
+
* ```
|
|
1400
|
+
* @public
|
|
1401
|
+
*/
|
|
1402
|
+
declare class ScRouterLinkDirective extends ScLinkDirective {
|
|
1403
|
+
/**
|
|
1404
|
+
* Sitecore link field; host attribute `[scRouterLink]` maps to the base {@link ScLinkDirective.scLink} input.
|
|
1405
|
+
*/
|
|
1406
|
+
readonly scLink: i0.InputSignal<LinkField | LinkFieldValue>;
|
|
1407
|
+
private readonly router;
|
|
1408
|
+
onClick(event: MouseEvent): void;
|
|
1409
|
+
/**
|
|
1410
|
+
* Returns true when the browser should handle navigation (no in-app Router navigation).
|
|
1411
|
+
* @param {string | null} hrefAttr - Raw `href` attribute from the anchor.
|
|
1412
|
+
* @param {string | null} targetAttr - Raw `target` attribute from the anchor.
|
|
1413
|
+
* @returns {boolean} Whether to skip `Router.navigateByUrl`.
|
|
1414
|
+
*/
|
|
1415
|
+
private shouldDeferNavigation;
|
|
1416
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScRouterLinkDirective, never>;
|
|
1417
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScRouterLinkDirective, "a[scRouterLink]", never, { "scLink": { "alias": "scRouterLink"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Renders a Sitecore rich text field value as innerHTML of the host element.
|
|
1422
|
+
* Content is marked trusted for Angular sanitization (typical for CMS-authored HTML).
|
|
1423
|
+
*
|
|
1424
|
+
* Usage:
|
|
1425
|
+
* ```html
|
|
1426
|
+
* <div [scRichText]="fields.Content"></div>
|
|
1427
|
+
* ```
|
|
1428
|
+
* @public
|
|
1429
|
+
*/
|
|
1430
|
+
declare class ScRichTextDirective {
|
|
1431
|
+
/** The Sitecore rich text field. */
|
|
1432
|
+
readonly scRichText: i0.InputSignal<TextField>;
|
|
1433
|
+
private readonly el;
|
|
1434
|
+
private readonly renderer;
|
|
1435
|
+
private readonly sanitizer;
|
|
1436
|
+
constructor();
|
|
1437
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ScRichTextDirective, never>;
|
|
1438
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ScRichTextDirective, "[scRichText]", never, { "scRichText": { "alias": "scRichText"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
declare const _coreVersionMarker: i0.Version;
|
|
1442
|
+
declare const _routerTokenMarker: typeof Router;
|
|
1443
|
+
|
|
1444
|
+
export { ClientLoaderDataService, ClientPreLoaderDataService, DEFAULT_EXPORT_NAME, FETCH_DATA_ENDPOINT, LOADER_DATA_ENDPOINT, LOADER_ID, LOADER_REGISTRY, LoaderHttpError, LocaleUrlSerializer, NotFoundNavigationError, SERVER_LOADER_RUNNER, SITECORE_CLIENT_TOKEN, SITECORE_COMPONENT_MAP, SITECORE_CONFIG_TOKEN, ScFormComponent, ScHiddenRenderingComponent, ScImageDirective, ScLinkDirective, ScMissingComponentComponent, ScPlaceholderComponent, ScRichTextDirective, ScRouterLinkDirective, ScTextDirective, ServerLoaderRunner, SitecoreContextService, SitecoreTranslateLoader, _coreVersionMarker, _routerTokenMarker, applyRedirect, collectSitecoreTagsFromEdgeRevalidateRequestBody, createCacheAdminMiddleware, createExpressDataMiddleware, createLoaderCache, createLoaderDataServiceMiddleware, createSitecoreRevalidateMiddleware, defineConfig, extractSitecoreEdgeContentId, getChildComponentProps, getPlaceholderRenderings, getSXAParams, handleNavigationError, loaderResolver, provideLoaderRegistry, provideServerLoaderRunner, provideSitecoreAngular, resolveComponentForRendering, resolveConfiguredRevalidateSecret, resolveSitecorePage, scLocaleMatcher, splitLocaleFromPath };
|
|
1445
|
+
export type { AngularCSDKAppInit, AngularContentSdkComponent, AngularSitecoreConfig, AngularSitecoreConfigInput, CacheAdminMiddlewareOptions, ChildComponentProps, CollectSitecoreTagsFromEdgeBodyOptions, ComponentForRendering, ComponentMap, DataHandlerConfig, ExpressDataHandlerOptions, ExpressMiddleware, ExpressNextFunction, ExpressRequest, ExpressResponse, GlobalLoaderCacheConfig, LoaderCacheConfig, LoaderContext, LoaderDataRequest, LoaderDataResult, LoaderFn, LoaderId, LoaderIdMap, LoaderRegistry, LocaleExtractionResult, PassThroughProps, PerRouteLoaderCacheConfig, ServerLoaderRunnerPort, SitecoreEdgeRevalidateRequestBody, SitecoreEdgeRevalidateUpdate, SitecoreRevalidateMiddlewareOptions };
|
|
1446
|
+
//# sourceMappingURL=sitecore-content-sdk-angular.d.ts.map
|