@canva/error 0.0.1-rc.1

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/LICENSE.md ADDED
@@ -0,0 +1,48 @@
1
+ # A message from Canva
2
+
3
+ By making these software components available to you, our goal is to give you
4
+ the right to use the components to build your apps for Canva's ecosystem. See
5
+ below for the specific licence terms that apply to your use.
6
+
7
+ # Licence
8
+
9
+ Canva Pty Ltd (ACN 158 929 938) ("Canva") owns the copyright in the software and
10
+ associated documentation files to which this Licence relates (each a "Software
11
+ Component"). Canva reserves all of its rights.
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
14
+ the Software Components ("You"), to use the Software Components, but strictly
15
+ subject to the following restrictions and conditions:
16
+
17
+ 1. You must only use the Software Components and any Derivative on the Canva
18
+ Platform.
19
+
20
+ 2. You must only use the Software Components and any Derivative for the purpose
21
+ of building or updating Permitted Apps, and for no other purpose.
22
+
23
+ 3. You must include a copy of this Licence in all copies of any Software
24
+ Component and Derivative.
25
+
26
+ 4. To the fullest extent permitted by law, the Software Components are provided
27
+ "as is", without warranty of any kind, express or implied, including but not
28
+ limited to the warranties of merchantability, fitness for a particular
29
+ purpose and non-infringement. To the fullest extent permitted by law, in no
30
+ event shall the authors or copyright holders be liable for any claim,
31
+ damages or other liability, whether in an action of contract, tort or
32
+ otherwise, arising from, out of or in connection with the Software Components
33
+ or any Derivative, or the use of or other dealings in the Software Components
34
+ or any Derivative.
35
+
36
+ 5. In this Licence:
37
+
38
+ (a) "Canva Platform" means the visual communications platform owned and
39
+ operated by Canva that is made available on Canva.com (as well as any
40
+ sub-domains and international versions) and via mobile applications, desktop
41
+ applications, and in other forms provided or made available by Canva;
42
+
43
+ (b) "Derivative" means any software, document or other material that: (i)
44
+ contains any Software Component; and/or (ii) comprises or contains a
45
+ derivative, adaptation or substantial part of any Software Component; and
46
+
47
+ (c) "Permitted App" means a software application that is solely offered to
48
+ end-users on the Canva Platform.
package/index.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ /** @public */
2
+ declare interface BaseCanvaError extends Error {
3
+ code: ErrorCode;
4
+ }
5
+
6
+ /**
7
+ * @public
8
+ * Base Error thrown by Apps SDK methods
9
+ */
10
+ export declare const CanvaError: typeof CanvaErrorClass;
11
+
12
+ /**
13
+ * @public
14
+ * Base Error thrown by Apps SDK methods
15
+ */
16
+ declare class CanvaErrorClass extends Error implements BaseCanvaError {
17
+ readonly code: ErrorCode;
18
+
19
+ constructor(opts: { code: ErrorCode; message: string });
20
+ }
21
+
22
+ /**
23
+ * @public
24
+ * Error codes that could be thrown by Apps SDK methods
25
+ */
26
+ 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 operation exceeded the maximum allowed time to complete.
66
+ */
67
+ | "TIMEOUT";
68
+
69
+ export {};
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,9 @@
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;
@@ -0,0 +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
@@ -0,0 +1,6 @@
1
+ const { canva } = window;
2
+ /**
3
+ * @public
4
+ * Base Error thrown by Apps SDK methods
5
+ */
6
+ export const CanvaError = canva.CanvaError;
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@canva/error",
3
+ "version": "0.0.1-rc.1",
4
+ "description": "The Canva Apps SDK error library",
5
+ "author": "Canva Pty Ltd.",
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",
10
+ "exports": {
11
+ ".": {
12
+ "require": "./lib/cjs/sdk/error/index.js",
13
+ "import": "./lib/esm/sdk/error/index.js"
14
+ }
15
+ },
16
+ "typings": "./index.d.ts"
17
+ }