@sitecore-content-sdk/core 0.2.0-canary.3 → 0.2.0-canary.30

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.
Files changed (55) hide show
  1. package/content.d.ts +1 -0
  2. package/content.js +1 -0
  3. package/dist/cjs/client/graphql-edge-proxy.js +3 -3
  4. package/dist/cjs/client/sitecore-client.js +25 -5
  5. package/dist/cjs/config/define-config.js +5 -5
  6. package/dist/cjs/constants.js +3 -1
  7. package/dist/cjs/content/content-client.js +87 -0
  8. package/dist/cjs/content/index.js +10 -0
  9. package/dist/cjs/content/locales.js +28 -0
  10. package/dist/cjs/content/utils.js +16 -0
  11. package/dist/cjs/debug.js +1 -0
  12. package/dist/cjs/editing/design-library.js +2 -1
  13. package/dist/cjs/index.js +3 -1
  14. package/dist/cjs/layout/content-styles.js +2 -1
  15. package/dist/cjs/layout/themes.js +2 -1
  16. package/dist/cjs/site/graphql-robots-service.js +2 -2
  17. package/dist/cjs/tools/auth/fetch-bearer-token.js +41 -0
  18. package/dist/cjs/tools/index.js +3 -1
  19. package/dist/cjs/utils/normalize-url.js +5 -0
  20. package/dist/cjs/utils/utils.js +5 -3
  21. package/dist/esm/client/graphql-edge-proxy.js +1 -1
  22. package/dist/esm/client/sitecore-client.js +25 -5
  23. package/dist/esm/config/define-config.js +5 -5
  24. package/dist/esm/constants.js +2 -0
  25. package/dist/esm/content/content-client.js +80 -0
  26. package/dist/esm/content/index.js +3 -0
  27. package/dist/esm/content/locales.js +25 -0
  28. package/dist/esm/content/utils.js +13 -0
  29. package/dist/esm/debug.js +1 -0
  30. package/dist/esm/editing/design-library.js +2 -1
  31. package/dist/esm/index.js +2 -0
  32. package/dist/esm/layout/content-styles.js +2 -1
  33. package/dist/esm/layout/themes.js +2 -1
  34. package/dist/esm/site/graphql-robots-service.js +2 -2
  35. package/dist/esm/tools/auth/fetch-bearer-token.js +34 -0
  36. package/dist/esm/tools/index.js +1 -0
  37. package/dist/esm/utils/normalize-url.js +1 -0
  38. package/dist/esm/utils/utils.js +5 -3
  39. package/package.json +18 -18
  40. package/types/client/sitecore-client.d.ts +43 -14
  41. package/types/config/index.d.ts +1 -1
  42. package/types/config/models.d.ts +7 -2
  43. package/types/constants.d.ts +2 -0
  44. package/types/content/content-client.d.ts +57 -0
  45. package/types/content/index.d.ts +3 -0
  46. package/types/content/locales.d.ts +32 -0
  47. package/types/content/utils.d.ts +15 -0
  48. package/types/debug.d.ts +1 -0
  49. package/types/index.d.ts +2 -0
  50. package/types/site/graphql-robots-service.d.ts +2 -2
  51. package/types/tools/auth/fetch-bearer-token.d.ts +13 -0
  52. package/types/tools/index.d.ts +1 -0
  53. package/types/utils/normalize-url.d.ts +1 -0
  54. package/form.d.ts +0 -1
  55. package/form.js +0 -1
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Represents the response structure for a query that retrieves a locale.
3
+ */
4
+ export interface LocaleQueryResponse {
5
+ locale: Locale | null;
6
+ }
7
+ /**
8
+ * Represents the response structure for a query that retrieves multiple locales.
9
+ */
10
+ export interface LocalesQueryResponse {
11
+ manyLocale: Locale[];
12
+ }
13
+ /**
14
+ * Represents a locale with an id and a label.
15
+ */
16
+ export type Locale = {
17
+ /** The unique identifier for the locale. */
18
+ id: string;
19
+ /** The display name or label for the locale. */
20
+ label: string;
21
+ };
22
+ /**
23
+ * GraphQL query to retrieve a specific locale by its ID.
24
+ *
25
+ * Variables:
26
+ * - id: The ID of the locale to retrieve.
27
+ */
28
+ export declare const GET_LOCALE_QUERY = "\n query GetLocaleById ($id: ID!) {\n locale(id: $id) {\n id\n label\n }\n }\n";
29
+ /**
30
+ * GraphQL query to retrieve all available locales.
31
+ */
32
+ export declare const GET_LOCALES_QUERY = "\n query GetAllLocales{\n manyLocale {\n id\n label\n }\n }\n";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Get the Content graphql endpoint url
3
+ * @param {object} params Parameters
4
+ * @param {string} [params.url] Content base graphql endpoint url
5
+ * @param {string} params.tenant Tenant name
6
+ * @param {string} params.environment Environment name
7
+ * @param {boolean} params.preview Indicates if preview mode is enabled
8
+ * @returns {string} Content graphql endpoint url
9
+ */
10
+ export declare function getContentUrl({ url, tenant, environment, preview, }: {
11
+ url?: string;
12
+ tenant: string;
13
+ environment: string;
14
+ preview: boolean;
15
+ }): string;
package/types/debug.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const enableDebug: (namespaces: string) => void;
11
11
  */
12
12
  declare const _default: {
13
13
  common: debug.Debugger;
14
+ content: debug.Debugger;
14
15
  form: debug.Debugger;
15
16
  http: debug.Debugger;
16
17
  layout: debug.Debugger;
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as constants from './constants';
2
+ import * as form from './form';
2
3
  export { default as debug, Debugger, enableDebug } from './debug';
3
4
  export { GraphQLClient, GraphQLRequestClient, GraphQLRequestClientConfig, GraphQLRequestClientFactory, GraphQLRequestClientFactoryConfig, } from './graphql-request-client';
4
5
  export { DefaultRetryStrategy } from './retries';
@@ -7,4 +8,5 @@ export { ClientError } from 'graphql-request';
7
8
  export { NativeDataFetcher, NativeDataFetcherConfig, NativeDataFetcherError, NativeDataFetcherResponse, } from './native-fetcher';
8
9
  export { HTMLLink, RetryStrategy, GenericGraphQLClientError, StaticPath } from './models';
9
10
  export { constants };
11
+ export { form };
10
12
  export { defineConfig } from './config';
@@ -1,4 +1,4 @@
1
- import { GraphQLClient } from '../client';
1
+ import { FetchOptions, GraphQLClient } from '../client';
2
2
  import { GraphQLRequestClientFactory } from '../graphql-request-client';
3
3
  export type GraphQLRobotsServiceConfig = {
4
4
  /**
@@ -38,7 +38,7 @@ export declare class GraphQLRobotsService {
38
38
  * @returns text of robots.txt
39
39
  * @throws {Error} if the siteName is empty.
40
40
  */
41
- fetchRobots(): Promise<string>;
41
+ fetchRobots(fetchOptions?: FetchOptions): Promise<string>;
42
42
  /**
43
43
  * Gets a GraphQL client that can make requests to the API. Uses graphql-request as the default
44
44
  * library for fetching graphql data (@see GraphQLRequestClient). Override this method if you
@@ -0,0 +1,13 @@
1
+ export type FetchBearerTokenOptions = {
2
+ clientId: string;
3
+ clientSecret: string;
4
+ audience?: string;
5
+ endpoint?: string;
6
+ };
7
+ /**
8
+ * Connects to M2M endpoint and fetches the bearer token
9
+ * Uses client_id and client_secret from environment variables
10
+ * @param {FetchBearerTokenOptions} options client id, secret, and other parameters for connection to m2m endpoint
11
+ * @returns {string} bearer token string
12
+ */
13
+ export declare const fetchBearerToken: (options: FetchBearerTokenOptions) => Promise<any>;
@@ -2,3 +2,4 @@ export { generateSites, GenerateSitesConfig } from './generateSites';
2
2
  export { generateMetadata } from './generateMetadata';
3
3
  export { scaffoldComponent } from './scaffold';
4
4
  export * from './templating';
5
+ export { fetchBearerToken } from './auth/fetch-bearer-token';
@@ -0,0 +1 @@
1
+ export declare const normalizeUrl: (url: string) => string;
package/form.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './types/form/index';
package/form.js DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./dist/cjs/form/index');