@contentstack/studio-client 1.3.0 → 1.4.0

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 (35) hide show
  1. package/dist/breakpoints/BreakpointManager.js +0 -1
  2. package/dist/breakpoints/BreakpointManager.js.map +1 -1
  3. package/dist/composable-studio/initializer-sdk.js +0 -1
  4. package/dist/composable-studio/initializer-sdk.js.map +1 -1
  5. package/dist/composable-studio/sdk.js +218 -50
  6. package/dist/composable-studio/sdk.js.map +1 -1
  7. package/dist/config/config.schema.js +1 -0
  8. package/dist/config/config.schema.js.map +1 -1
  9. package/dist/config/default-config.js +1 -0
  10. package/dist/config/default-config.js.map +1 -1
  11. package/dist/config/process-user-config.js +4 -1
  12. package/dist/config/process-user-config.js.map +1 -1
  13. package/dist/config/stack-sdk-wrapper.js +52 -12
  14. package/dist/config/stack-sdk-wrapper.js.map +1 -1
  15. package/dist/context-menu/context-menu.js +0 -1
  16. package/dist/context-menu/context-menu.js.map +1 -1
  17. package/dist/design/handle-active-style-change.js +0 -1
  18. package/dist/design/handle-active-style-change.js.map +1 -1
  19. package/dist/dnd/dnd-manager.js +2 -3
  20. package/dist/dnd/dnd-manager.js.map +1 -1
  21. package/dist/highlight-node/highlight-node-manager.js +0 -1
  22. package/dist/highlight-node/highlight-node-manager.js.map +1 -1
  23. package/dist/highlight-node/highlight-node.js +0 -1
  24. package/dist/highlight-node/highlight-node.js.map +1 -1
  25. package/dist/index.d.ts +64 -17
  26. package/dist/index.js +1 -1
  27. package/dist/utils/composable-studio-error.js +9 -7
  28. package/dist/utils/composable-studio-error.js.map +1 -1
  29. package/dist/utils/error-messages.default.js +141 -0
  30. package/dist/utils/error-messages.default.js.map +1 -0
  31. package/dist/utils/error-messages.js +47 -0
  32. package/dist/utils/error-messages.js.map +1 -0
  33. package/dist/utils/http-error.constants.js +96 -0
  34. package/dist/utils/http-error.constants.js.map +1 -0
  35. package/package.json +8 -7
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Keys for error message lookup. Use these constants instead of string literals.
3
+ * @internal
4
+ */
5
+ const ErrorMessageKey = {
6
+ AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR",
7
+ INVALID_CREDENTIALS_DEFAULT: "INVALID_CREDENTIALS_DEFAULT",
8
+ NETWORK_ERROR_EMPTY: "NETWORK_ERROR_EMPTY",
9
+ NETWORK_ERROR_GENERIC: "NETWORK_ERROR_GENERIC",
10
+ NETWORK_ERROR_DETAIL_DEFAULT: "NETWORK_ERROR_DETAIL_DEFAULT",
11
+ COMPOSITION_NOT_FOUND_404: "COMPOSITION_NOT_FOUND_404",
12
+ SERVER_ERROR: "SERVER_ERROR",
13
+ SERVER_ERROR_DETAIL_DEFAULT: "SERVER_ERROR_DETAIL_DEFAULT",
14
+ COMPOSITION_NOT_FOUND_API: "COMPOSITION_NOT_FOUND_API",
15
+ COMPOSITION_NOT_FOUND_API_DETAIL_DEFAULT: "COMPOSITION_NOT_FOUND_API_DETAIL_DEFAULT",
16
+ COMPOSITION_NOT_FOUND_DEFAULT: "COMPOSITION_NOT_FOUND_DEFAULT",
17
+ FETCHING_CONNECTED_DATA_FAILED: "FETCHING_CONNECTED_DATA_FAILED",
18
+ PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND",
19
+ STACK_SDK_NOT_AVAILABLE: "STACK_SDK_NOT_AVAILABLE",
20
+ UI_PARSING_ERROR: "UI_PARSING_ERROR",
21
+ COMPOSITION_NOT_FOUND_BY_URL: "COMPOSITION_NOT_FOUND_BY_URL",
22
+ MISSING_COMPOSITION_IDENTIFIER: "MISSING_COMPOSITION_IDENTIFIER",
23
+ };
24
+ /**
25
+ * Default (en) error message templates. Single source of truth for user-facing error messages.
26
+ * Use getErrorMessage() with ErrorMessageKey constants to resolve messages with placeholders.
27
+ * @internal
28
+ */
29
+ const defaultErrorMessages = {
30
+ [ErrorMessageKey.AUTHENTICATION_ERROR]: "Authentication failed: {detail}",
31
+ [ErrorMessageKey.INVALID_CREDENTIALS_DEFAULT]: "Invalid API key or delivery token. Please check your credentials.",
32
+ [ErrorMessageKey.NETWORK_ERROR_EMPTY]: "Network error: Unable to connect to Contentstack API. Please check your internet connection, API endpoint, and credentials.",
33
+ [ErrorMessageKey.NETWORK_ERROR_GENERIC]: "Network error: {detail}",
34
+ [ErrorMessageKey.NETWORK_ERROR_DETAIL_DEFAULT]: "Failed to connect to API",
35
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_404]: "Composition not found. The requested composition does not exist or has been deleted.",
36
+ [ErrorMessageKey.SERVER_ERROR]: "Server error ({statusCode}): {detail}",
37
+ [ErrorMessageKey.SERVER_ERROR_DETAIL_DEFAULT]: "The server encountered an error. Please try again later.",
38
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_API]: "API error ({statusCode}): {detail}",
39
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_API_DETAIL_DEFAULT]: "Failed to fetch composition",
40
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_DEFAULT]: "Composition not found. An unexpected error occurred while fetching the composition.",
41
+ [ErrorMessageKey.FETCHING_CONNECTED_DATA_FAILED]: "Failed to fetch connected data",
42
+ [ErrorMessageKey.PREVIEW_ENTRY_NOT_FOUND]: "Preview entry not found for content type: {contentType}. The connected content type does not have an entry matching the composition query.",
43
+ [ErrorMessageKey.STACK_SDK_NOT_AVAILABLE]: "Stack SDK not available to fetch composition.",
44
+ [ErrorMessageKey.UI_PARSING_ERROR]: "Failed to parse composition UI structure",
45
+ [ErrorMessageKey.COMPOSITION_NOT_FOUND_BY_URL]: "Composition not found for URL: {url}. No composition matches the provided URL pattern.",
46
+ [ErrorMessageKey.MISSING_COMPOSITION_IDENTIFIER]: "Please provide either composableUid or url to fetch the composition.",
47
+ };
48
+ /**
49
+ * Keys for troubleshooting info lookup. Use with getTroubleshootingInfo().
50
+ * @internal
51
+ */
52
+ const TroubleshootingInfoKey = {
53
+ NETWORK_ERROR: "NETWORK_ERROR",
54
+ AUTHENTICATION_ERROR: "AUTHENTICATION_ERROR",
55
+ COMPOSITION_NOT_FOUND_URL: "COMPOSITION_NOT_FOUND_URL",
56
+ COMPOSITION_NOT_FOUND_UID: "COMPOSITION_NOT_FOUND_UID",
57
+ PREVIEW_ENTRY_NOT_FOUND: "PREVIEW_ENTRY_NOT_FOUND",
58
+ };
59
+ /**
60
+ * Default (en) troubleshooting info by key. Single source of truth for cause/fix strings.
61
+ * @internal
62
+ */
63
+ const defaultTroubleshootingInfo = {
64
+ [TroubleshootingInfoKey.NETWORK_ERROR]: [
65
+ {
66
+ cause: "Network connectivity issue",
67
+ fix: "Check your internet connection and try again. Verify that the API endpoint is accessible.",
68
+ },
69
+ {
70
+ cause: "Invalid API credentials",
71
+ fix: "Verify your API key and delivery token are correct in the SDK configuration.",
72
+ },
73
+ {
74
+ cause: "Incorrect API endpoint",
75
+ fix: "Ensure the API endpoint URL is correct and points to the right Contentstack region.",
76
+ },
77
+ ],
78
+ [TroubleshootingInfoKey.AUTHENTICATION_ERROR]: [
79
+ {
80
+ cause: "Invalid API key",
81
+ fix: "Verify your API key is correct and has the necessary permissions. Check your Contentstack dashboard for the correct API key.",
82
+ },
83
+ {
84
+ cause: "Invalid delivery token",
85
+ fix: "Ensure your delivery token is valid and not expired. Generate a new token if needed.",
86
+ },
87
+ {
88
+ cause: "Missing permissions",
89
+ fix: "Check that your API credentials have the required permissions to access the content type and entries.",
90
+ },
91
+ ],
92
+ [TroubleshootingInfoKey.COMPOSITION_NOT_FOUND_URL]: [
93
+ {
94
+ cause: "No composition found for this URL",
95
+ fix: "Verify the URL is correct and matches an existing composition. Check that the composition is published and accessible.",
96
+ },
97
+ {
98
+ cause: "URL pattern does not match any composition",
99
+ fix: "Ensure the URL pattern in your composition matches the requested URL. Check the composition's URL field in Contentstack.",
100
+ },
101
+ {
102
+ cause: "Composition not published",
103
+ fix: "Publish the composition in Contentstack or use a preview/draft token to access unpublished content.",
104
+ },
105
+ ],
106
+ [TroubleshootingInfoKey.COMPOSITION_NOT_FOUND_UID]: [
107
+ {
108
+ cause: "Composition does not exist",
109
+ fix: "Verify the composition UID is correct. Check that the composition exists in your Contentstack stack.",
110
+ },
111
+ {
112
+ cause: "Composition UID is incorrect",
113
+ fix: "Double-check the composition UID you're using. You can find the correct UID on the composition listing page in studio",
114
+ },
115
+ {
116
+ cause: "Composition not published",
117
+ fix: "Publish the composition in Contentstack or use a preview/draft token to access unpublished content.",
118
+ },
119
+ ],
120
+ [TroubleshootingInfoKey.PREVIEW_ENTRY_NOT_FOUND]: [
121
+ {
122
+ cause: "No entry exists for the connected content type",
123
+ fix: "Create an entry for the connected content type in Contentstack, or verify the content type is correctly configured.",
124
+ },
125
+ {
126
+ cause: "URL pattern does not match any entry",
127
+ fix: "Ensure the URL in your composition query matches the URL field of an entry in the connected content type.",
128
+ },
129
+ {
130
+ cause: "Entry was deleted or unpublished",
131
+ fix: "Check if the entry exists and is published. Restore it from trash if deleted, or publish it if it's in draft state.",
132
+ },
133
+ {
134
+ cause: "Incorrect content type configuration",
135
+ fix: "Verify that the connected_content_type field in your composition is set to the correct content type UID.",
136
+ },
137
+ ],
138
+ };
139
+
140
+ export { ErrorMessageKey, TroubleshootingInfoKey, defaultErrorMessages, defaultTroubleshootingInfo };
141
+ //# sourceMappingURL=error-messages.default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-messages.default.js","sources":["../../src/utils/error-messages.default.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AACI,MAAM,eAAe,GAAG;AAC7B,IAAA,oBAAoB,EAAE,sBAAsB;AAC5C,IAAA,2BAA2B,EAAE,6BAA6B;AAC1D,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,4BAA4B,EAAE,8BAA8B;AAC5D,IAAA,yBAAyB,EAAE,2BAA2B;AACtD,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,2BAA2B,EAAE,6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G,EAAE,qGAAqG;AAC3G,SAAA;AACF,KAAA;AACD,IAAA,CAAC,sBAAsB,CAAC,yBAAyB,GAAG;AAClD,QAAA;AACE,YAAA,KAAK,EAAE,4BAA4B;AACnC,YAAA,GAAG,EAAE,sGAAsG;AAC5G,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,8BAA8B;AACrC,YAAA,GAAG,EAAE,uHAAuH;AAC7H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,2BAA2B;AAClC,YAAA,GAAG,EAAE,qGAAqG;AAC3G,SAAA;AACF,KAAA;AACD,IAAA,CAAC,sBAAsB,CAAC,uBAAuB,GAAG;AAChD,QAAA;AACE,YAAA,KAAK,EAAE,gDAAgD;AACvD,YAAA,GAAG,EAAE,qHAAqH;AAC3H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,sCAAsC;AAC7C,YAAA,GAAG,EAAE,2GAA2G;AACjH,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,kCAAkC;AACzC,YAAA,GAAG,EAAE,qHAAqH;AAC3H,SAAA;AACD,QAAA;AACE,YAAA,KAAK,EAAE,sCAAsC;AAC7C,YAAA,GAAG,EAAE,0GAA0G;AAChH,SAAA;AACF,KAAA;;;;;"}
@@ -0,0 +1,47 @@
1
+ import { defaultErrorMessages, defaultTroubleshootingInfo } from './error-messages.default.js';
2
+ export { ErrorMessageKey, TroubleshootingInfoKey } from './error-messages.default.js';
3
+
4
+ /**
5
+ * Error message lookup for studio-client. Messages are defined in error-messages.default.ts.
6
+ * Use getErrorMessage with ErrorMessageKey constants (no string literals).
7
+ * @internal
8
+ */
9
+ /**
10
+ * Returns the message string for the given key, substituting placeholders with params.
11
+ * Placeholders: {detail}, {statusCode}, {url}
12
+ * Use ErrorMessageKey constants for the key argument.
13
+ * @internal
14
+ */
15
+ function getErrorMessage(key, params) {
16
+ let template = defaultErrorMessages[key];
17
+ if (template == null) {
18
+ return String(key);
19
+ }
20
+ if (!params) {
21
+ return template;
22
+ }
23
+ if (params.detail !== undefined) {
24
+ template = template.replace(/\{detail\}/g, String(params.detail));
25
+ }
26
+ if (params.statusCode !== undefined) {
27
+ template = template.replace(/\{statusCode\}/g, String(params.statusCode));
28
+ }
29
+ if (params.url !== undefined) {
30
+ template = template.replace(/\{url\}/g, String(params.url));
31
+ }
32
+ if (params.contentType !== undefined) {
33
+ template = template.replace(/\{contentType\}/g, String(params.contentType));
34
+ }
35
+ return template;
36
+ }
37
+ /**
38
+ * Returns troubleshooting info (cause/fix pairs) for the given key.
39
+ * Use TroubleshootingInfoKey constants. Return type is compatible with TroubleshootingInfo[].
40
+ * @internal
41
+ */
42
+ function getTroubleshootingInfo(key) {
43
+ return defaultTroubleshootingInfo[key] ?? [];
44
+ }
45
+
46
+ export { getErrorMessage, getTroubleshootingInfo };
47
+ //# sourceMappingURL=error-messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-messages.js","sources":["../../src/utils/error-messages.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;AAIG;AAyBH;;;;;AAKG;AACG,SAAU,eAAe,CAC7B,GAAwB,EACxB,MAA2B,EAAA;AAE3B,IAAA,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC;AACxC,IAAA,IAAI,QAAQ,IAAI,IAAI,EAAE;AACpB,QAAA,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB;IACA,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;AAC/B,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACnE;AACA,IAAA,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE;AACnC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3E;AACA,IAAA,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE;AAC5B,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D;AACA,IAAA,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE;AACpC,QAAA,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7E;AACA,IAAA,OAAO,QAAQ;AACjB;AAEA;;;;AAIG;AACG,SAAU,sBAAsB,CACpC,GAA+B,EAAA;AAE/B,IAAA,OAAO,0BAA0B,CAAC,GAAG,CAAC,IAAI,EAAE;AAC9C;;;;"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * HTTP status code constants and helpers for error classification.
3
+ * @internal
4
+ */
5
+ const HttpStatus = {
6
+ UNAUTHORIZED: 401,
7
+ FORBIDDEN: 403,
8
+ NOT_FOUND: 404,
9
+ SERVER_ERROR_MIN: 500,
10
+ SERVER_ERROR_MAX: 599,
11
+ };
12
+ /**
13
+ * Contentstack API error codes (from Contentstack API responses).
14
+ * @internal
15
+ */
16
+ const ContentstackErrorCode = {
17
+ UNAUTHORIZED: 104,
18
+ INVALID_CREDENTIALS: 105,
19
+ ENTRY_NOT_FOUND: 141,
20
+ };
21
+ /**
22
+ * Node.js / network error codes that indicate connection failures.
23
+ * @internal
24
+ */
25
+ const NetworkErrorCode = {
26
+ ENOTFOUND: "ENOTFOUND",
27
+ ECONNREFUSED: "ECONNREFUSED",
28
+ ETIMEDOUT: "ETIMEDOUT",
29
+ };
30
+ const NETWORK_ERROR_CODES = [
31
+ NetworkErrorCode.ENOTFOUND,
32
+ NetworkErrorCode.ECONNREFUSED,
33
+ NetworkErrorCode.ETIMEDOUT,
34
+ ];
35
+ const NETWORK_ERROR_TYPE = "network";
36
+ /**
37
+ * Returns the HTTP status code from an error object (supports both status and statusCode).
38
+ * @internal
39
+ */
40
+ function getStatusCode(err) {
41
+ const code = err?.status ?? err?.statusCode;
42
+ return typeof code === "number" && Number.isFinite(code) ? code : undefined;
43
+ }
44
+ /**
45
+ * Returns true if the status code indicates an authentication/authorization error (401 or 403).
46
+ * @internal
47
+ */
48
+ function isAuthError(statusCode) {
49
+ return (statusCode === HttpStatus.UNAUTHORIZED ||
50
+ statusCode === HttpStatus.FORBIDDEN);
51
+ }
52
+ /**
53
+ * Returns true if the status code indicates a server error (5xx).
54
+ * @internal
55
+ */
56
+ function isServerError(statusCode) {
57
+ return (statusCode >= HttpStatus.SERVER_ERROR_MIN &&
58
+ statusCode <= HttpStatus.SERVER_ERROR_MAX);
59
+ }
60
+ /**
61
+ * Returns true if the error is a Contentstack auth error by error_code (104 or 105).
62
+ * @internal
63
+ */
64
+ function isContentstackAuthError(err) {
65
+ const code = err?.error_code;
66
+ return (code === ContentstackErrorCode.UNAUTHORIZED ||
67
+ code === ContentstackErrorCode.INVALID_CREDENTIALS);
68
+ }
69
+ /**
70
+ * Returns true if the error has Contentstack auth error shape (errors.api_key or errors.authorization)
71
+ * without necessarily having an HTTP status. Used when API returns auth failure in body only.
72
+ * @internal
73
+ */
74
+ function hasAuthErrorShape(err) {
75
+ if (!err || typeof err !== "object")
76
+ return false;
77
+ const apiKey = err?.errors?.api_key;
78
+ const auth = err?.errors?.authorization;
79
+ return ((Array.isArray(apiKey) && apiKey.length > 0) ||
80
+ (Array.isArray(auth) && auth.length > 0));
81
+ }
82
+ /**
83
+ * Returns true if the error indicates a network-level failure (no HTTP response).
84
+ * @internal
85
+ */
86
+ function isNetworkError(err) {
87
+ if (!err)
88
+ return false;
89
+ const code = err?.code;
90
+ const type = err?.type;
91
+ return ((typeof code === "string" && NETWORK_ERROR_CODES.includes(code)) ||
92
+ type === NETWORK_ERROR_TYPE);
93
+ }
94
+
95
+ export { ContentstackErrorCode, HttpStatus, NETWORK_ERROR_CODES, NETWORK_ERROR_TYPE, NetworkErrorCode, getStatusCode, hasAuthErrorShape, isAuthError, isContentstackAuthError, isNetworkError, isServerError };
96
+ //# sourceMappingURL=http-error.constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-error.constants.js","sources":["../../src/utils/http-error.constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;AAGG;AAEI,MAAM,UAAU,GAAG;AACxB,IAAA,YAAY,EAAE,GAAG;AACjB,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,SAAS,EAAE,GAAG;AACd,IAAA,gBAAgB,EAAE,GAAG;AACrB,IAAA,gBAAgB,EAAE,GAAG;;AAGvB;;;AAGG;AACI,MAAM,qBAAqB,GAAG;AACnC,IAAA,YAAY,EAAE,GAAG;AACjB,IAAA,mBAAmB,EAAE,GAAG;AACxB,IAAA,eAAe,EAAE,GAAG;;AAGtB;;;AAGG;AACI,MAAM,gBAAgB,GAAG;AAC9B,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,SAAS,EAAE,WAAW;;AAGjB,MAAM,mBAAmB,GAAG;AACjC,IAAA,gBAAgB,CAAC,SAAS;AAC1B,IAAA,gBAAgB,CAAC,YAAY;AAC7B,IAAA,gBAAgB,CAAC,SAAS;;AAGrB,MAAM,kBAAkB,GAAG;AAElC;;;AAGG;AACG,SAAU,aAAa,CAAC,GAAQ,EAAA;IACpC,MAAM,IAAI,GAAG,GAAG,EAAE,MAAM,IAAI,GAAG,EAAE,UAAU;AAC3C,IAAA,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS;AAC7E;AAEA;;;AAGG;AACG,SAAU,WAAW,CAAC,UAAkB,EAAA;AAC5C,IAAA,QACE,UAAU,KAAK,UAAU,CAAC,YAAY;AACtC,QAAA,UAAU,KAAK,UAAU,CAAC,SAAS;AAEvC;AAEA;;;A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"1.4.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "module": "dist/index.js",
@@ -30,15 +30,16 @@
30
30
  "url": "https://github.com/contentstack/composable-studio-sdk/issues"
31
31
  },
32
32
  "devDependencies": {
33
- "@contentstack/common-config": "^1.1.4",
33
+ "@contentstack/common-config": "^1.1.5",
34
34
  "@contentstack/delivery-sdk": "^4.5.0",
35
- "@contentstack/studio-internal": "^1.1.4",
35
+ "@contentstack/studio-internal": "^1.1.5",
36
36
  "@rollup/plugin-commonjs": "^28.0.6",
37
37
  "@rollup/plugin-node-resolve": "^16.0.1",
38
38
  "@rollup/plugin-terser": "^0.4.4",
39
39
  "@rollup/plugin-typescript": "^12.1.4",
40
40
  "contentstack": "^3.20.3",
41
41
  "happy-dom": "^20.0.1",
42
+ "msw": "^2.12.9",
42
43
  "rollup": "^4.46.2",
43
44
  "rollup-plugin-dts": "^6.2.1",
44
45
  "rollup-plugin-node-externals": "^8.0.1",
@@ -46,13 +47,13 @@
46
47
  "typescript": "^5.5.4"
47
48
  },
48
49
  "dependencies": {
49
- "@contentstack/studio-message-types": "^1.1.4",
50
- "@contentstack/studio-messenger": "^1.1.4",
51
- "@contentstack/studio-registry": "^1.2.1",
50
+ "@contentstack/studio-message-types": "^1.1.5",
51
+ "@contentstack/studio-messenger": "^1.2.0",
52
+ "@contentstack/studio-registry": "^1.3.0",
52
53
  "eventemitter3": "^5.0.1",
53
54
  "html2canvas": "^1.4.1",
54
55
  "lodash-es": "^4.17.23",
55
56
  "zod": "^3.23.8"
56
57
  },
57
- "gitHead": "a8df12b115d554e3c69b5fcd5972197d92b1f558"
58
+ "gitHead": "6739518a282ff9788218b0acd2e46e0be2a6fb68"
58
59
  }