@canva/error 1.1.0 → 2.0.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.
package/index.d.ts CHANGED
@@ -5,15 +5,18 @@ declare interface BaseCanvaError extends Error {
5
5
 
6
6
  /**
7
7
  * @public
8
- * Base Error thrown by Apps SDK methods
8
+ * An error thrown by the Apps SDK.
9
9
  */
10
10
  export declare const CanvaError: typeof CanvaErrorClass;
11
11
 
12
12
  /**
13
13
  * @public
14
- * Base Error thrown by Apps SDK methods
14
+ * An error thrown by the Apps SDK.
15
15
  */
16
16
  declare class CanvaErrorClass extends Error implements BaseCanvaError {
17
+ /**
18
+ * A code that identifies why the error was thrown.
19
+ */
17
20
  readonly code: ErrorCode;
18
21
 
19
22
  constructor(opts: { code: ErrorCode; message: string });
@@ -21,53 +24,38 @@ declare class CanvaErrorClass extends Error implements BaseCanvaError {
21
24
 
22
25
  /**
23
26
  * @public
24
- * Error codes that could be thrown by Apps SDK methods
27
+ * An error code that identifies why an error was thrown by the Apps SDK.
28
+ *
29
+ * @remarks
30
+ * The possible error codes include:
31
+ *
32
+ * - `"bad_external_service_response"` - A response from an external service is invalid or malformed.
33
+ * - `"bad_request"` - The app made a request with invalid or malformed inputs.
34
+ * - `"failed_precondition"` - The requested operation can't be performed because a precondition hasn't been met.
35
+ * - `"internal_error"` - An error occurred within the Apps SDK's internal implementation.
36
+ * - `"not_found"` - The specified resource couldn't be found.
37
+ * - `"not_allowed"` - The app isn't allowed to perform the requested operation.
38
+ * - `"permission_denied"` - The app isn't allowed perform the requested operation because the appropriate permissions aren't set.
39
+ * - `"quota_exceeded"` - The app or user has exceeded their allocated quota for a resource or service.
40
+ * - `"rate_limited"` - The app attempted too many operations within a certain period of time.
41
+ * - `"timeout"` - The requested operation took too long to complete.
42
+ * - `"unsupported_surface"` - The requested operation isn't supported on the current surface.
43
+ * - `"unsupported_page_type"` - The requested operation isn't supported on the current page.
44
+ * - `"user_offline"` - The requested operation can't be performed because the user is offline.
25
45
  */
26
46
  export declare type ErrorCode =
27
- /**
28
- * The system is currently unable to perform the requested operation because it is not in the necessary state.
29
- * Refer to the error message for more information on how to satisfy the failed precondition.
30
- */
31
- | "FAILED_PRECONDITION"
32
- /**
33
- * The response received from an external service is invalid or malformed.
34
- */
35
- | "BAD_EXTERNAL_SERVICE_RESPONSE"
36
- /**
37
- * The request received from the client is invalid or malformed.
38
- */
39
- | "BAD_REQUEST"
40
- /**
41
- * An error occurred within the SDK's internal implementation.
42
- */
43
- | "INTERNAL_ERROR"
44
- /**
45
- * The allocated quota for the resource or service has been exceeded.
46
- */
47
- | "QUOTA_EXCEEDED"
48
- /**
49
- * The system has received too many requests in a short period of time.
50
- */
51
- | "RATE_LIMITED"
52
- /**
53
- * The caller does not have sufficient permissions to execute the specified operation.
54
- */
55
- | "PERMISSION_DENIED"
56
- /**
57
- * The user is currently offline and cannot perform the requested operation.
58
- */
59
- | "USER_OFFLINE"
60
- /**
61
- * The specified resource was not found
62
- */
63
- | "NOT_FOUND"
64
- /**
65
- * The specified operation was not allowed
66
- */
67
- | "NOT_ALLOWED"
68
- /**
69
- * The operation exceeded the maximum allowed time to complete.
70
- */
71
- | "TIMEOUT";
47
+ | "bad_external_service_response"
48
+ | "bad_request"
49
+ | "failed_precondition"
50
+ | "internal_error"
51
+ | "not_found"
52
+ | "not_allowed"
53
+ | "permission_denied"
54
+ | "quota_exceeded"
55
+ | "rate_limited"
56
+ | "timeout"
57
+ | "unsupported_surface"
58
+ | "unsupported_page_type"
59
+ | "user_offline";
72
60
 
73
61
  export {};
@@ -1,19 +1,21 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./public"), exports);
18
- // purposefully not exporting `BaseCanvaError` from '../.../api/error/api' since we want to export
19
- // the actual CanvaError class, and not the interface, to allow apps to do instanceof checks
1
+ "use strict"
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ _export_star(require("./public"), exports);
6
+ function _export_star(from, to) {
7
+ Object.keys(from).forEach(function(k) {
8
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
9
+ Object.defineProperty(to, k, {
10
+ enumerable: true,
11
+ get: function() {
12
+ return from[k];
13
+ }
14
+ });
15
+ }
16
+ });
17
+ return from;
18
+ }
19
+ var _window___canva___sdkRegistration, _window___canva__;
20
+ (_window___canva__ =
21
+ window.__canva__) === null || _window___canva__ === void 0 ? void 0 : (_window___canva___sdkRegistration = _window___canva__.sdkRegistration) === null || _window___canva___sdkRegistration === void 0 ? void 0 : _window___canva___sdkRegistration.registerPackageVersion('error', '2.0.0', 'ga');
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CanvaError = void 0;
4
- const { canva } = window;
5
- /**
6
- * @public
7
- * Base Error thrown by Apps SDK methods
8
- */
9
- exports.CanvaError = canva.CanvaError;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "CanvaError", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return CanvaError;
9
+ }
10
+ });
11
+ const { canva_sdk } = window;
12
+ const CanvaError = canva_sdk.error.v2.CanvaError;
@@ -1,3 +1,4 @@
1
+ var _window___canva___sdkRegistration, _window___canva__;
1
2
  export * from './public';
2
- // purposefully not exporting `BaseCanvaError` from '../.../api/error/api' since we want to export
3
- // the actual CanvaError class, and not the interface, to allow apps to do instanceof checks
3
+ (_window___canva__ =
4
+ window.__canva__) === null || _window___canva__ === void 0 ? void 0 : (_window___canva___sdkRegistration = _window___canva__.sdkRegistration) === null || _window___canva___sdkRegistration === void 0 ? void 0 : _window___canva___sdkRegistration.registerPackageVersion('error', '2.0.0', 'ga');
@@ -1,6 +1,2 @@
1
- const { canva } = window;
2
- /**
3
- * @public
4
- * Base Error thrown by Apps SDK methods
5
- */
6
- export const CanvaError = canva.CanvaError;
1
+ const { canva_sdk } = window;
2
+ export const CanvaError = canva_sdk.error.v2.CanvaError;
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "@canva/error",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "The Canva Apps SDK error library",
5
5
  "author": "Canva Pty Ltd.",
6
6
  "license": "SEE LICENSE IN LICENSE.md FILE",
7
- "private": false,
8
- "main": "lib/cjs/sdk/error/index.js",
9
- "module": "lib/esm/sdk/error/index.js",
7
+ "main": "./lib/cjs/sdk/error/index.js",
8
+ "module": "./lib/esm/sdk/error/index.js",
10
9
  "exports": {
11
10
  ".": {
12
- "require": "./lib/cjs/sdk/error/index.js",
13
- "import": "./lib/esm/sdk/error/index.js"
11
+ "require": {
12
+ "types": "./index.d.ts",
13
+ "default": "./lib/cjs/sdk/error/index.js"
14
+ },
15
+ "import": {
16
+ "types": "./index.d.ts",
17
+ "default": "./lib/esm/sdk/error/index.js"
18
+ }
14
19
  }
15
20
  },
16
21
  "typings": "./index.d.ts"