create-ec-app 0.0.10 → 0.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ec-app",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Unified CLI tool to create different types of EC applications: Webresource, Portal, Power Pages",
5
5
  "bin": {
6
6
  "create-ec-app": "./dist/index.js"
@@ -6,6 +6,7 @@
6
6
  "scripts": {
7
7
  "dev": "vite",
8
8
  "build": "tsc -b && vite build",
9
+ "build:dev": "tsc -b && vite build --mode development",
9
10
  "lint": "eslint .",
10
11
  "preview": "vite preview",
11
12
  "format": "biome format --write .",
@@ -1,38 +1,37 @@
1
-
2
1
  const getAuthToken = async (): Promise<string> => {
3
- const tokenModule = await import("../../token.json");
4
- const token = tokenModule.default.accessToken;
5
- return token;
2
+ const tokenModule = await import("../../token.json");
3
+ const token = tokenModule.default.accessToken;
4
+ return token;
6
5
  };
7
6
 
8
7
  export const getApiUrl = (): string => {
9
- if (window.parent && window.parent.Xrm) {
10
- const globalContext = window.Xrm.Utility.getGlobalContext();
11
- const clientUrl = globalContext.getClientUrl();
12
- return `${clientUrl}/api/data/v9.2`;
13
- }
8
+ if (window.top?.Xrm) {
9
+ const globalContext = window.top.Xrm.Utility.getGlobalContext();
10
+ const clientUrl = globalContext.getClientUrl();
11
+ return `${clientUrl}/api/data/v9.2`;
12
+ }
14
13
 
15
- return "https://DOMAIN.REGION.dynamics.com/api/data/v9.2";
14
+ return "https://DOMAIN.REGION.dynamics.com/api/data/v9.2";
16
15
  };
17
16
 
18
17
  export const getAuthHeaders = async (): Promise<HeadersInit> => {
19
- if (window.parent && window.parent.Xrm) {
20
- return {
21
- "Content-Type": "application/json",
22
- "OData-MaxVersion": "4.0",
23
- "OData-Version": "4.0",
24
- Prefer: 'odata.include-annotations="*"',
25
- };
26
- }
18
+ if (window.top?.Xrm) {
19
+ return {
20
+ "Content-Type": "application/json",
21
+ "OData-MaxVersion": "4.0",
22
+ "OData-Version": "4.0",
23
+ Prefer: 'odata.include-annotations="*"',
24
+ };
25
+ }
27
26
 
28
- const token = await getAuthToken();
29
- const headers: HeadersInit = {
30
- Authorization: `Bearer ${token}`,
31
- "Content-Type": "application/json",
32
- "OData-MaxVersion": "4.0",
33
- "OData-Version": "4.0",
34
- Prefer: 'odata.include-annotations="*"',
35
- };
27
+ const token = await getAuthToken();
28
+ const headers: HeadersInit = {
29
+ Authorization: `Bearer ${token}`,
30
+ "Content-Type": "application/json",
31
+ "OData-MaxVersion": "4.0",
32
+ "OData-Version": "4.0",
33
+ Prefer: 'odata.include-annotations="*"',
34
+ };
36
35
 
37
- return headers;
38
- };
36
+ return headers;
37
+ };