@sitecore-content-sdk/core 0.2.0-beta.2 → 0.2.0-beta.4

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.
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEdgeProxyFormsUrl = exports.getEdgeProxyContentUrl = void 0;
4
4
  const constants_1 = require("../constants");
5
- const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
5
+ const normalize_url_1 = require("../utils/normalize-url");
6
6
  /**
7
7
  * Generates a URL for accessing Sitecore Edge Platform Content using the provided endpoint and context ID.
8
8
  * @param {string} sitecoreEdgeContextId - The unique context id.
9
9
  * @param {string} [sitecoreEdgeUrl] - The base endpoint URL for the Edge Platform. Default is https://edge-platform.sitecorecloud.io
10
10
  * @returns {string} The complete URL for accessing content through the Edge Platform.
11
11
  */
12
- const getEdgeProxyContentUrl = (sitecoreEdgeContextId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => `${normalizeUrl(sitecoreEdgeUrl)}/v1/content/api/graphql/v1?sitecoreContextId=${sitecoreEdgeContextId}`;
12
+ const getEdgeProxyContentUrl = (sitecoreEdgeContextId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => `${(0, normalize_url_1.normalizeUrl)(sitecoreEdgeUrl)}/v1/content/api/graphql/v1?sitecoreContextId=${sitecoreEdgeContextId}`;
13
13
  exports.getEdgeProxyContentUrl = getEdgeProxyContentUrl;
14
14
  /**
15
15
  * Generates a URL for accessing Sitecore Edge Platform Forms using the provided form ID and context ID.
@@ -18,5 +18,5 @@ exports.getEdgeProxyContentUrl = getEdgeProxyContentUrl;
18
18
  * @param {string} [sitecoreEdgeUrl] - The base endpoint URL for the Edge Platform. Default is https://edge-platform.sitecorecloud.io
19
19
  * @returns {string} The complete URL for accessing forms through the Edge Platform.
20
20
  */
21
- const getEdgeProxyFormsUrl = (sitecoreEdgeContextId, formId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => `${normalizeUrl(sitecoreEdgeUrl)}/v1/forms/publisher/${formId}?sitecoreContextId=${sitecoreEdgeContextId}`;
21
+ const getEdgeProxyFormsUrl = (sitecoreEdgeContextId, formId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => `${(0, normalize_url_1.normalizeUrl)(sitecoreEdgeUrl)}/v1/forms/publisher/${formId}?sitecoreContextId=${sitecoreEdgeContextId}`;
22
22
  exports.getEdgeProxyFormsUrl = getEdgeProxyFormsUrl;
@@ -4,6 +4,7 @@ exports.updateComponentHandler = exports.addComponentUpdateHandler = exports.Des
4
4
  exports.getDesignLibraryStatusEvent = getDesignLibraryStatusEvent;
5
5
  exports.getDesignLibraryScriptLink = getDesignLibraryScriptLink;
6
6
  const constants_1 = require("../constants");
7
+ const normalize_url_1 = require("../utils/normalize-url");
7
8
  /**
8
9
  * Event to be sent when report status to design library
9
10
  */
@@ -110,5 +111,5 @@ function getDesignLibraryStatusEvent(status, uid) {
110
111
  * @returns The full URL to the design library script.
111
112
  */
112
113
  function getDesignLibraryScriptLink(sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) {
113
- return `${sitecoreEdgeUrl}/v1/files/designlibrary/lib/rh-lib-script.js`;
114
+ return `${(0, normalize_url_1.normalizeUrl)(sitecoreEdgeUrl)}/v1/files/designlibrary/lib/rh-lib-script.js`;
114
115
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.traverseComponent = exports.traverseField = exports.traversePlaceholder = exports.getContentStylesheetUrl = exports.getContentStylesheetLink = void 0;
4
4
  const constants_1 = require("../constants");
5
+ const normalize_url_1 = require("../utils/normalize-url");
5
6
  /**
6
7
  * Regular expression to check if the content styles are used in the field value
7
8
  */
@@ -26,7 +27,7 @@ const getContentStylesheetLink = (layoutData, sitecoreEdgeContextId, sitecoreEdg
26
27
  };
27
28
  };
28
29
  exports.getContentStylesheetLink = getContentStylesheetLink;
29
- const getContentStylesheetUrl = (sitecoreEdgeContextId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => `${sitecoreEdgeUrl}/v1/files/pages/styles/content-styles.css?sitecoreContextId=${sitecoreEdgeContextId}`;
30
+ const getContentStylesheetUrl = (sitecoreEdgeContextId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => `${(0, normalize_url_1.normalizeUrl)(sitecoreEdgeUrl)}/v1/files/pages/styles/content-styles.css?sitecoreContextId=${sitecoreEdgeContextId}`;
30
31
  exports.getContentStylesheetUrl = getContentStylesheetUrl;
31
32
  const traversePlaceholder = (components, config) => {
32
33
  if (config.loadStyles)
@@ -4,6 +4,7 @@ exports.getStylesheetUrl = void 0;
4
4
  exports.getDesignLibraryStylesheetLinks = getDesignLibraryStylesheetLinks;
5
5
  const _1 = require(".");
6
6
  const constants_1 = require("../constants");
7
+ const normalize_url_1 = require("../utils/normalize-url");
7
8
  /**
8
9
  * Pattern for library ids
9
10
  * @example -library--foo
@@ -27,7 +28,7 @@ function getDesignLibraryStylesheetLinks(layoutData, sitecoreEdgeContextId, site
27
28
  }));
28
29
  }
29
30
  const getStylesheetUrl = (id, sitecoreEdgeContextId, sitecoreEdgeUrl = constants_1.SITECORE_EDGE_URL_DEFAULT) => {
30
- return `${sitecoreEdgeUrl}/v1/files/components/styles/${id}.css?sitecoreContextId=${sitecoreEdgeContextId}`;
31
+ return `${(0, normalize_url_1.normalizeUrl)(sitecoreEdgeUrl)}/v1/files/components/styles/${id}.css?sitecoreContextId=${sitecoreEdgeContextId}`;
31
32
  };
32
33
  exports.getStylesheetUrl = getStylesheetUrl;
33
34
  /**
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeUrl = void 0;
4
+ const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
5
+ exports.normalizeUrl = normalizeUrl;
@@ -1,5 +1,5 @@
1
1
  import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
2
- const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
2
+ import { normalizeUrl } from '../utils/normalize-url';
3
3
  /**
4
4
  * Generates a URL for accessing Sitecore Edge Platform Content using the provided endpoint and context ID.
5
5
  * @param {string} sitecoreEdgeContextId - The unique context id.
@@ -1,4 +1,5 @@
1
1
  import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
2
+ import { normalizeUrl } from '../utils/normalize-url';
2
3
  /**
3
4
  * Event to be sent when report status to design library
4
5
  */
@@ -103,5 +104,5 @@ export function getDesignLibraryStatusEvent(status, uid) {
103
104
  * @returns The full URL to the design library script.
104
105
  */
105
106
  export function getDesignLibraryScriptLink(sitecoreEdgeUrl = SITECORE_EDGE_URL_DEFAULT) {
106
- return `${sitecoreEdgeUrl}/v1/files/designlibrary/lib/rh-lib-script.js`;
107
+ return `${normalizeUrl(sitecoreEdgeUrl)}/v1/files/designlibrary/lib/rh-lib-script.js`;
107
108
  }
@@ -1,4 +1,5 @@
1
1
  import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
2
+ import { normalizeUrl } from '../utils/normalize-url';
2
3
  /**
3
4
  * Regular expression to check if the content styles are used in the field value
4
5
  */
@@ -22,7 +23,7 @@ export const getContentStylesheetLink = (layoutData, sitecoreEdgeContextId, site
22
23
  rel: 'stylesheet',
23
24
  };
24
25
  };
25
- export const getContentStylesheetUrl = (sitecoreEdgeContextId, sitecoreEdgeUrl = SITECORE_EDGE_URL_DEFAULT) => `${sitecoreEdgeUrl}/v1/files/pages/styles/content-styles.css?sitecoreContextId=${sitecoreEdgeContextId}`;
26
+ export const getContentStylesheetUrl = (sitecoreEdgeContextId, sitecoreEdgeUrl = SITECORE_EDGE_URL_DEFAULT) => `${normalizeUrl(sitecoreEdgeUrl)}/v1/files/pages/styles/content-styles.css?sitecoreContextId=${sitecoreEdgeContextId}`;
26
27
  export const traversePlaceholder = (components, config) => {
27
28
  if (config.loadStyles)
28
29
  return;
@@ -1,5 +1,6 @@
1
1
  import { getFieldValue } from '.';
2
2
  import { SITECORE_EDGE_URL_DEFAULT } from '../constants';
3
+ import { normalizeUrl } from '../utils/normalize-url';
3
4
  /**
4
5
  * Pattern for library ids
5
6
  * @example -library--foo
@@ -23,7 +24,7 @@ export function getDesignLibraryStylesheetLinks(layoutData, sitecoreEdgeContextI
23
24
  }));
24
25
  }
25
26
  export const getStylesheetUrl = (id, sitecoreEdgeContextId, sitecoreEdgeUrl = SITECORE_EDGE_URL_DEFAULT) => {
26
- return `${sitecoreEdgeUrl}/v1/files/components/styles/${id}.css?sitecoreContextId=${sitecoreEdgeContextId}`;
27
+ return `${normalizeUrl(sitecoreEdgeUrl)}/v1/files/components/styles/${id}.css?sitecoreContextId=${sitecoreEdgeContextId}`;
27
28
  };
28
29
  /**
29
30
  * Traverse placeholder and components to add library ids
@@ -0,0 +1 @@
1
+ export const normalizeUrl = (url) => (url.endsWith('/') ? url.slice(0, -1) : url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/core",
3
- "version": "0.2.0-beta.2",
3
+ "version": "0.2.0-beta.4",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -77,7 +77,7 @@
77
77
  },
78
78
  "description": "",
79
79
  "types": "types/index.d.ts",
80
- "gitHead": "6414b2a03a72e9a7c96a4a20de79ede4bafb0290",
80
+ "gitHead": "750ea744c6ba45e5480c921acf549ec48c53b303",
81
81
  "files": [
82
82
  "dist",
83
83
  "types",
@@ -0,0 +1 @@
1
+ export declare const normalizeUrl: (url: string) => string;