@canva/error 0.0.1-rc.1 → 1.2.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/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @canva/error
2
+
3
+ A package for Canva's Apps SDK that exports a `CanvaError` class for handling errors.
4
+
5
+ ![](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
6
+
7
+ ## Table of contents
8
+
9
+ - [Introduction](#introduction)
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Related packages](#related-packages)
13
+ - [Contributing](#contributing)
14
+ - [License](#license)
15
+
16
+ ## Introduction
17
+
18
+ `@canva/error` is an npm package for Canva's [Apps SDK](https://www.canva.dev/docs/apps). It exports a `CanvaError` class that apps can use to catch and handle errors.
19
+
20
+ **Note:** To get up and running with the Apps SDK, check out [the quick start guide](https://www.canva.dev/docs/apps/quick-start).
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @canva/error
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ See the documentation for [Handling errors](https://www.canva.dev/docs/apps/handling-errors).
31
+
32
+ ## Related packages
33
+
34
+ The Apps SDK is made up of the following packages:
35
+
36
+ - [`@canva/app-ui-kit`](https://www.npmjs.com/package/@canva/app-ui-kit) - React-based component library for creating apps that mimic the look and feel of Canva.
37
+ - [`@canva/asset`](https://www.npmjs.com/package/@canva/asset) - Provides methods for working with assets, such as image and video files.
38
+ - [`@canva/design`](https://www.npmjs.com/package/@canva/design) - Provides methods for interacting with the user's design, such as creating elements.
39
+ - [`@canva/error`](https://www.npmjs.com/package/@canva/error) - Provides a `CanvaError` class for handling errors.
40
+ - [`@canva/platform`](https://www.npmjs.com/package/@canva/platform) - Provides utility methods, such as a method for opening external links.
41
+ - [`@canva/user`](https://www.npmjs.com/package/@canva/user) - Provides methods for accessing user data and authenticating users.
42
+
43
+ ## Contributing
44
+
45
+ We're actively developing this package but are not currently accepting third-party contributions. If you'd like to request any changes or additions to the package, submit a feature request via the [Canva Developers Community](https://community.canva.dev/).
46
+
47
+ ## License
48
+
49
+ See the `LICENSE.md` file.
package/index.d.ts CHANGED
@@ -53,6 +53,10 @@ export declare type ErrorCode =
53
53
  * The caller does not have sufficient permissions to execute the specified operation.
54
54
  */
55
55
  | "PERMISSION_DENIED"
56
+ /**
57
+ * The specified operation is not supported on the surface.
58
+ */
59
+ | "UNSUPPORTED_SURFACE"
56
60
  /**
57
61
  * The user is currently offline and cannot perform the requested operation.
58
62
  */
@@ -61,6 +65,10 @@ export declare type ErrorCode =
61
65
  * The specified resource was not found
62
66
  */
63
67
  | "NOT_FOUND"
68
+ /**
69
+ * The specified operation was not allowed
70
+ */
71
+ | "NOT_ALLOWED"
64
72
  /**
65
73
  * The operation exceeded the maximum allowed time to complete.
66
74
  */
@@ -1,19 +1,21 @@
1
+ // must use relative paths
1
2
  "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
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ _export_star(require("./public"), exports);
7
+ function _export_star(from, to) {
8
+ Object.keys(from).forEach(function(k) {
9
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
10
+ Object.defineProperty(to, k, {
11
+ enumerable: true,
12
+ get: function() {
13
+ return from[k];
14
+ }
15
+ });
16
+ }
17
+ });
18
+ return from;
19
+ }
20
+ // purposefully not exporting `BaseCanvaError` from '../.../api/error/api' since we want to export
21
+ // the actual CanvaError class, and not the interface, to allow apps to do instanceof checks
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CanvaError = void 0;
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
+ });
4
11
  const { canva } = window;
5
- /**
6
- * @public
7
- * Base Error thrown by Apps SDK methods
8
- */
9
- exports.CanvaError = canva.CanvaError;
12
+ const CanvaError = canva.CanvaError;
@@ -1,3 +1,3 @@
1
- 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
1
+ // must use relative paths
2
+ export * from './public'; // 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
@@ -2,5 +2,4 @@ const { canva } = window;
2
2
  /**
3
3
  * @public
4
4
  * Base Error thrown by Apps SDK methods
5
- */
6
- export const CanvaError = canva.CanvaError;
5
+ */ export const CanvaError = canva.CanvaError;
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "@canva/error",
3
- "version": "0.0.1-rc.1",
3
+ "version": "1.2.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"