@webiny/wcp 5.29.0-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # `@webiny/wcp`
2
+ [![](https://img.shields.io/npm/dw/@webiny/wcp.svg)](https://www.npmjs.com/package/@webiny/wcp)
3
+ [![](https://img.shields.io/npm/v/@webiny/wcp.svg)](https://www.npmjs.com/package/@webiny/wcp)
4
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
+
7
+ A set of Webiny Control Panel (WCP)-related utilities.
8
+
9
+ ## Table of Contents
10
+
11
+ - [Installation](#installation)
12
+ - [Overview](#overview)
13
+ - [Examples](#examples)
14
+ - [Reference](#reference)
15
+ - [Functions](#functions)
16
+ - [`getWcpAppUrl`](#getWcpAppUrl)
17
+ - [`getWcpApiUrl`](#getWcpApiUrl)
18
+ - [`getWcpGqlApiUrl`](#getWcpGqlApiUrl)
19
+
20
+ ## Installation
21
+
22
+ ```
23
+ npm install --save @webiny/wcp
24
+ ```
25
+
26
+ Or if you prefer yarn:
27
+
28
+ ```
29
+ yarn add @webiny/wcp
30
+ ```
31
+
32
+
33
+ ## Overview
34
+
35
+ The `@webiny/wcp` package contains essential Webiny Control Panel (WCP)-related utilities.
36
+
37
+
38
+
39
+ ## Examples
40
+
41
+ | Example | Description |
42
+ | ------- | ----------- |
43
+ | [Retrieve WCP URLs](./docs/examples/retrievingWcpUrls.md) | Shows how to retrieve WCP API and app URLs. |
44
+
45
+ ## Reference
46
+
47
+ ### Functions
48
+
49
+ #### `getWcpAppUrl`
50
+
51
+ <details>
52
+ <summary>Type Declaration</summary>
53
+ <p>
54
+
55
+ ```ts
56
+ export declare const getWcpAppUrl: (path?: string | undefined) => string;
57
+ ```
58
+
59
+ </p>
60
+ </details>
61
+
62
+ Returns WCP app URL. The default URL can be overridden via the `WCP_APP_URL` environment variable.
63
+
64
+
65
+ ```ts
66
+ import { getWcpAppUrl } from "@webiny/wcp";
67
+
68
+ console.log(getWcpAppUrl()); // Returns "https://d3mudimnmgk2a9.cloudfront.net".
69
+ ```
70
+
71
+
72
+ #### `getWcpApiUrl`
73
+
74
+ <details>
75
+ <summary>Type Declaration</summary>
76
+ <p>
77
+
78
+ ```ts
79
+ export declare const getWcpApiUrl: (path?: string | undefined) => string;
80
+ ```
81
+
82
+ </p>
83
+ </details>
84
+
85
+ Returns WCP API URL. The default URL can be overridden via the `WCP_API_URL` environment variable.
86
+
87
+
88
+ ```ts
89
+ import { getWcpApiUrl } from "@webiny/wcp";
90
+
91
+ console.log(getWcpApiUrl()); // Returns "https://d3mudimnmgk2a9.cloudfront.net".
92
+ ```
93
+
94
+ #### `getWcpGqlApiUrl`
95
+
96
+ <details>
97
+ <summary>Type Declaration</summary>
98
+ <p>
99
+
100
+ ```ts
101
+ export declare const getWcpGqlApiUrl: (path?: string | undefined) => string;
102
+ ```
103
+
104
+ </p>
105
+ </details>
106
+
107
+ Returns WCP GraphQL API URL.
108
+
109
+
110
+ ```ts
111
+ import { getWcpGqlApiUrl } from "@webiny/wcp";
112
+
113
+ console.log(getWcpGqlApiUrl()); // Returns "https://d3mudimnmgk2a9.cloudfront.net/graphql".
114
+ ```
115
+
@@ -0,0 +1,6 @@
1
+ /**
2
+ * For now, we're not doing actual encryption, just simple base64 encoding/decoding.
3
+ * Potentially, we'll revisit this in the future and implement actual encryption.
4
+ */
5
+ export declare const encrypt: <T = Record<string, any>>(rawObject: T) => string;
6
+ export declare const decrypt: <T = Record<string, any>>(encryptedString: string) => T;
package/encryption.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.encrypt = exports.decrypt = void 0;
7
+
8
+ /**
9
+ * For now, we're not doing actual encryption, just simple base64 encoding/decoding.
10
+ * Potentially, we'll revisit this in the future and implement actual encryption.
11
+ */
12
+ const encrypt = rawObject => {
13
+ return Buffer.from(JSON.stringify(rawObject), "utf-8").toString("base64");
14
+ };
15
+
16
+ exports.encrypt = encrypt;
17
+
18
+ const decrypt = encryptedString => {
19
+ const decryptedString = Buffer.from(encryptedString, "base64").toString("utf-8");
20
+ return JSON.parse(decryptedString);
21
+ };
22
+
23
+ exports.decrypt = decrypt;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["encrypt","rawObject","Buffer","from","JSON","stringify","toString","decrypt","encryptedString","decryptedString","parse"],"sources":["encryption.ts"],"sourcesContent":["/**\n * For now, we're not doing actual encryption, just simple base64 encoding/decoding.\n * Potentially, we'll revisit this in the future and implement actual encryption.\n */\n\nexport const encrypt = <T = Record<string, any>>(rawObject: T): string => {\n return Buffer.from(JSON.stringify(rawObject), \"utf-8\").toString(\"base64\");\n};\n\nexport const decrypt = <T = Record<string, any>>(encryptedString: string): T => {\n const decryptedString = Buffer.from(encryptedString, \"base64\").toString(\"utf-8\");\n return JSON.parse(decryptedString) as T;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AAEO,MAAMA,OAAO,GAA6BC,SAA1B,IAAmD;EACtE,OAAOC,MAAM,CAACC,IAAP,CAAYC,IAAI,CAACC,SAAL,CAAeJ,SAAf,CAAZ,EAAuC,OAAvC,EAAgDK,QAAhD,CAAyD,QAAzD,CAAP;AACH,CAFM;;;;AAIA,MAAMC,OAAO,GAA6BC,eAA1B,IAAyD;EAC5E,MAAMC,eAAe,GAAGP,MAAM,CAACC,IAAP,CAAYK,eAAZ,EAA6B,QAA7B,EAAuCF,QAAvC,CAAgD,OAAhD,CAAxB;EACA,OAAOF,IAAI,CAACM,KAAL,CAAWD,eAAX,CAAP;AACH,CAHM"}
package/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export * from "./encryption";
2
+ export * from "./licenses";
3
+ export * from "./urls";
4
+ export declare const WCP_FEATURE_LABEL: {
5
+ seats: string;
6
+ multiTenancy: string;
7
+ advancedPublishingWorkflow: string;
8
+ advancedAccessControlLayer: string;
9
+ };
package/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ WCP_FEATURE_LABEL: true
8
+ };
9
+ exports.WCP_FEATURE_LABEL = void 0;
10
+
11
+ var _encryption = require("./encryption");
12
+
13
+ Object.keys(_encryption).forEach(function (key) {
14
+ if (key === "default" || key === "__esModule") return;
15
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
16
+ if (key in exports && exports[key] === _encryption[key]) return;
17
+ Object.defineProperty(exports, key, {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _encryption[key];
21
+ }
22
+ });
23
+ });
24
+
25
+ var _licenses = require("./licenses");
26
+
27
+ Object.keys(_licenses).forEach(function (key) {
28
+ if (key === "default" || key === "__esModule") return;
29
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
30
+ if (key in exports && exports[key] === _licenses[key]) return;
31
+ Object.defineProperty(exports, key, {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _licenses[key];
35
+ }
36
+ });
37
+ });
38
+
39
+ var _urls = require("./urls");
40
+
41
+ Object.keys(_urls).forEach(function (key) {
42
+ if (key === "default" || key === "__esModule") return;
43
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
44
+ if (key in exports && exports[key] === _urls[key]) return;
45
+ Object.defineProperty(exports, key, {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _urls[key];
49
+ }
50
+ });
51
+ });
52
+ const WCP_FEATURE_LABEL = {
53
+ seats: "User Seats",
54
+ multiTenancy: "Multi-tenancy",
55
+ advancedPublishingWorkflow: "Advanced Publishing Workflow (APW)",
56
+ advancedAccessControlLayer: "Advanced Access Control Layer (ACL)"
57
+ };
58
+ exports.WCP_FEATURE_LABEL = WCP_FEATURE_LABEL;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WCP_FEATURE_LABEL","seats","multiTenancy","advancedPublishingWorkflow","advancedAccessControlLayer"],"sources":["index.ts"],"sourcesContent":["export * from \"./encryption\";\nexport * from \"./licenses\";\nexport * from \"./urls\";\n\nexport const WCP_FEATURE_LABEL = {\n seats: \"User Seats\",\n multiTenancy: \"Multi-tenancy\",\n advancedPublishingWorkflow: \"Advanced Publishing Workflow (APW)\",\n advancedAccessControlLayer: \"Advanced Access Control Layer (ACL)\"\n};\n"],"mappings":";;;;;;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEO,MAAMA,iBAAiB,GAAG;EAC7BC,KAAK,EAAE,YADsB;EAE7BC,YAAY,EAAE,eAFe;EAG7BC,0BAA0B,EAAE,oCAHC;EAI7BC,0BAA0B,EAAE;AAJC,CAA1B"}
package/licenses.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { DecryptedWcpProjectLicense } from "./types";
2
+ interface GetWcpProjectLicenseParams {
3
+ orgId: string;
4
+ projectId: string;
5
+ projectEnvironmentApiKey: string;
6
+ }
7
+ export declare const getWcpProjectLicense: (params: GetWcpProjectLicenseParams) => Promise<DecryptedWcpProjectLicense | null>;
8
+ export {};
package/licenses.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getWcpProjectLicense = void 0;
9
+
10
+ var _nodeFetch = _interopRequireDefault(require("node-fetch"));
11
+
12
+ var _encryption = require("./encryption");
13
+
14
+ var _urls = require("./urls");
15
+
16
+ const fetchWcpProjectLicense = async ({
17
+ orgId,
18
+ projectId,
19
+ projectEnvironmentApiKey
20
+ }) => {
21
+ // Fetch and decrypt the license.
22
+ const getLicenseEndpoint = (0, _urls.getWcpApiUrl)(`/orgs/${orgId}/projects/${projectId}/license`);
23
+ const encryptedLicense = await (0, _nodeFetch.default)(getLicenseEndpoint, {
24
+ headers: {
25
+ authorization: projectEnvironmentApiKey
26
+ }
27
+ }).then(response => response.json()).catch(e => {
28
+ console.warn(`An error occurred while trying to retrieve the license for project "${orgId}/${projectId}": ${e.message}`);
29
+ return null;
30
+ });
31
+ return encryptedLicense;
32
+ };
33
+
34
+ const getWcpProjectLicense = async params => {
35
+ let encryptedLicense = process.env.WCP_PROJECT_LICENSE;
36
+
37
+ if (!encryptedLicense) {
38
+ const fetchedLicense = await fetchWcpProjectLicense(params);
39
+
40
+ if (fetchedLicense) {
41
+ encryptedLicense = fetchedLicense.license;
42
+ }
43
+ }
44
+
45
+ if (!encryptedLicense) {
46
+ return null;
47
+ }
48
+
49
+ try {
50
+ return (0, _encryption.decrypt)(encryptedLicense);
51
+ } catch (e) {
52
+ const projectId = `${params.orgId}/${params.projectId}`;
53
+ console.warn(`An error occurred while trying to decrypt the retrieved license for project "${projectId}": ${e.message}`);
54
+ return null;
55
+ }
56
+ };
57
+
58
+ exports.getWcpProjectLicense = getWcpProjectLicense;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fetchWcpProjectLicense","orgId","projectId","projectEnvironmentApiKey","getLicenseEndpoint","getWcpApiUrl","encryptedLicense","fetch","headers","authorization","then","response","json","catch","e","console","warn","message","getWcpProjectLicense","params","process","env","WCP_PROJECT_LICENSE","fetchedLicense","license","decrypt"],"sources":["licenses.ts"],"sourcesContent":["import fetch from \"node-fetch\";\nimport { DecryptedWcpProjectLicense, EncryptedWcpProjectLicense } from \"./types\";\nimport { decrypt } from \"./encryption\";\nimport { getWcpApiUrl } from \"./urls\";\n\ninterface GetWcpProjectLicenseParams {\n orgId: string;\n projectId: string;\n projectEnvironmentApiKey: string;\n}\n\nconst fetchWcpProjectLicense = async ({\n orgId,\n projectId,\n projectEnvironmentApiKey\n}: GetWcpProjectLicenseParams) => {\n // Fetch and decrypt the license.\n const getLicenseEndpoint = getWcpApiUrl(`/orgs/${orgId}/projects/${projectId}/license`);\n\n const encryptedLicense: { license: EncryptedWcpProjectLicense } | null = await fetch(\n getLicenseEndpoint,\n {\n headers: { authorization: projectEnvironmentApiKey }\n }\n )\n .then(response => response.json())\n .catch(e => {\n console.warn(\n `An error occurred while trying to retrieve the license for project \"${orgId}/${projectId}\": ${e.message}`\n );\n return null;\n });\n\n return encryptedLicense;\n};\n\nexport const getWcpProjectLicense = async (params: GetWcpProjectLicenseParams) => {\n let encryptedLicense = process.env.WCP_PROJECT_LICENSE;\n if (!encryptedLicense) {\n const fetchedLicense = await fetchWcpProjectLicense(params);\n if (fetchedLicense) {\n encryptedLicense = fetchedLicense.license;\n }\n }\n\n if (!encryptedLicense) {\n return null;\n }\n\n try {\n return decrypt<DecryptedWcpProjectLicense>(encryptedLicense);\n } catch (e) {\n const projectId = `${params.orgId}/${params.projectId}`;\n console.warn(\n `An error occurred while trying to decrypt the retrieved license for project \"${projectId}\": ${e.message}`\n );\n return null;\n }\n};\n"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AAQA,MAAMA,sBAAsB,GAAG,OAAO;EAClCC,KADkC;EAElCC,SAFkC;EAGlCC;AAHkC,CAAP,KAIG;EAC9B;EACA,MAAMC,kBAAkB,GAAG,IAAAC,kBAAA,EAAc,SAAQJ,KAAM,aAAYC,SAAU,UAAlD,CAA3B;EAEA,MAAMI,gBAAgE,GAAG,MAAM,IAAAC,kBAAA,EAC3EH,kBAD2E,EAE3E;IACII,OAAO,EAAE;MAAEC,aAAa,EAAEN;IAAjB;EADb,CAF2E,EAM1EO,IAN0E,CAMrEC,QAAQ,IAAIA,QAAQ,CAACC,IAAT,EANyD,EAO1EC,KAP0E,CAOpEC,CAAC,IAAI;IACRC,OAAO,CAACC,IAAR,CACK,uEAAsEf,KAAM,IAAGC,SAAU,MAAKY,CAAC,CAACG,OAAQ,EAD7G;IAGA,OAAO,IAAP;EACH,CAZ0E,CAA/E;EAcA,OAAOX,gBAAP;AACH,CAvBD;;AAyBO,MAAMY,oBAAoB,GAAG,MAAOC,MAAP,IAA8C;EAC9E,IAAIb,gBAAgB,GAAGc,OAAO,CAACC,GAAR,CAAYC,mBAAnC;;EACA,IAAI,CAAChB,gBAAL,EAAuB;IACnB,MAAMiB,cAAc,GAAG,MAAMvB,sBAAsB,CAACmB,MAAD,CAAnD;;IACA,IAAII,cAAJ,EAAoB;MAChBjB,gBAAgB,GAAGiB,cAAc,CAACC,OAAlC;IACH;EACJ;;EAED,IAAI,CAAClB,gBAAL,EAAuB;IACnB,OAAO,IAAP;EACH;;EAED,IAAI;IACA,OAAO,IAAAmB,mBAAA,EAAoCnB,gBAApC,CAAP;EACH,CAFD,CAEE,OAAOQ,CAAP,EAAU;IACR,MAAMZ,SAAS,GAAI,GAAEiB,MAAM,CAAClB,KAAM,IAAGkB,MAAM,CAACjB,SAAU,EAAtD;IACAa,OAAO,CAACC,IAAR,CACK,gFAA+Ed,SAAU,MAAKY,CAAC,CAACG,OAAQ,EAD7G;IAGA,OAAO,IAAP;EACH;AACJ,CAtBM"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@webiny/wcp",
3
+ "version": "5.29.0-beta.0",
4
+ "main": "index.js",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/webiny/webiny-js.git",
8
+ "directory": "packages/wcp"
9
+ },
10
+ "description": "A set of Webiny Control Panel (WCP)-related utilities.",
11
+ "author": "Webiny Ltd.",
12
+ "license": "MIT",
13
+ "dependencies": {
14
+ "@babel/runtime": "7.18.3",
15
+ "node-fetch": "2.6.7"
16
+ },
17
+ "devDependencies": {
18
+ "@babel/cli": "^7.16.0",
19
+ "@babel/core": "^7.16.0",
20
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
21
+ "@babel/plugin-transform-runtime": "^7.16.4",
22
+ "@babel/preset-env": "^7.16.4",
23
+ "@babel/preset-typescript": "^7.16.0",
24
+ "@webiny/cli": "^5.29.0-beta.0",
25
+ "@webiny/project-utils": "^5.29.0-beta.0",
26
+ "rimraf": "^3.0.2",
27
+ "ttypescript": "^1.5.12",
28
+ "typescript": "4.5.5"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "directory": "dist"
33
+ },
34
+ "scripts": {
35
+ "watch": "yarn webiny run watch",
36
+ "build": "yarn webiny run build"
37
+ },
38
+ "adio": {
39
+ "ignoreDirs": [
40
+ "__tests__"
41
+ ]
42
+ },
43
+ "gitHead": "e221dc575942c512548be142e20c5bd1231edcda"
44
+ }
package/types.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ export declare type WcpProjectEnvironment = {
2
+ id: string;
3
+ apiKey: string;
4
+ org: {
5
+ id: string;
6
+ };
7
+ project: {
8
+ id: string;
9
+ };
10
+ };
11
+ export declare type EncryptedWcpProjectLicense = string;
12
+ export interface DecryptedWcpProjectLicense {
13
+ orgId: string;
14
+ projectId: string;
15
+ package: {
16
+ features: {
17
+ seats: {
18
+ enabled: true;
19
+ options: {
20
+ maxCount: number;
21
+ };
22
+ };
23
+ multiTenancy: {
24
+ enabled: true;
25
+ };
26
+ advancedPublishingWorkflow: {
27
+ enabled: boolean;
28
+ };
29
+ advancedAccessControlLayer: {
30
+ enabled: boolean;
31
+ };
32
+ };
33
+ };
34
+ }
package/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export declare type WcpProjectEnvironment = {\n id: string;\n apiKey: string;\n org: {\n id: string;\n };\n project: {\n id: string;\n };\n};\n\nexport declare type EncryptedWcpProjectLicense = string;\n\nexport interface DecryptedWcpProjectLicense {\n orgId: string;\n projectId: string;\n package: {\n features: {\n seats: {\n // This is always true because WCP projects immediately get access to seats (by default 1 seat).\n enabled: true;\n options: {\n maxCount: number;\n };\n };\n multiTenancy: {\n // This is always true because WCP projects immediately get access to multi-tenancy.\n enabled: true;\n };\n advancedPublishingWorkflow: {\n enabled: boolean;\n };\n advancedAccessControlLayer: {\n enabled: boolean;\n };\n };\n };\n}\n"],"mappings":""}
package/urls.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare const getWcpApiUrl: (path?: string | undefined) => string;
2
+ export declare const getWcpGqlApiUrl: (path?: string | undefined) => string;
3
+ export declare const getWcpAppUrl: (path?: string | undefined) => string;
package/urls.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getWcpGqlApiUrl = exports.getWcpAppUrl = exports.getWcpApiUrl = void 0;
7
+ const DEFAULT_WCP_API_URL = "https://api.webiny.com";
8
+ const DEFAULT_WCP_APP_URL = "https://app.webiny.com";
9
+
10
+ const getWcpApiUrl = path => {
11
+ const apiUrl = process.env.WCP_API_URL || DEFAULT_WCP_API_URL;
12
+ return path ? apiUrl + path : apiUrl;
13
+ };
14
+
15
+ exports.getWcpApiUrl = getWcpApiUrl;
16
+
17
+ const getWcpGqlApiUrl = path => {
18
+ const graphqlApi = getWcpApiUrl("/graphql");
19
+ return path ? graphqlApi + path : graphqlApi;
20
+ };
21
+
22
+ exports.getWcpGqlApiUrl = getWcpGqlApiUrl;
23
+
24
+ const getWcpAppUrl = path => {
25
+ const appUrl = process.env.WCP_APP_URL || DEFAULT_WCP_APP_URL;
26
+ return path ? appUrl + path : appUrl;
27
+ };
28
+
29
+ exports.getWcpAppUrl = getWcpAppUrl;
package/urls.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DEFAULT_WCP_API_URL","DEFAULT_WCP_APP_URL","getWcpApiUrl","path","apiUrl","process","env","WCP_API_URL","getWcpGqlApiUrl","graphqlApi","getWcpAppUrl","appUrl","WCP_APP_URL"],"sources":["urls.ts"],"sourcesContent":["const DEFAULT_WCP_API_URL = \"https://api.webiny.com\";\nconst DEFAULT_WCP_APP_URL = \"https://app.webiny.com\";\n\nexport const getWcpApiUrl = (path?: string) => {\n const apiUrl = process.env.WCP_API_URL || DEFAULT_WCP_API_URL;\n return path ? apiUrl + path : apiUrl;\n};\n\nexport const getWcpGqlApiUrl = (path?: string) => {\n const graphqlApi = getWcpApiUrl(\"/graphql\");\n return path ? graphqlApi + path : graphqlApi;\n};\n\nexport const getWcpAppUrl = (path?: string) => {\n const appUrl = process.env.WCP_APP_URL || DEFAULT_WCP_APP_URL;\n return path ? appUrl + path : appUrl;\n};\n"],"mappings":";;;;;;AAAA,MAAMA,mBAAmB,GAAG,wBAA5B;AACA,MAAMC,mBAAmB,GAAG,wBAA5B;;AAEO,MAAMC,YAAY,GAAIC,IAAD,IAAmB;EAC3C,MAAMC,MAAM,GAAGC,OAAO,CAACC,GAAR,CAAYC,WAAZ,IAA2BP,mBAA1C;EACA,OAAOG,IAAI,GAAGC,MAAM,GAAGD,IAAZ,GAAmBC,MAA9B;AACH,CAHM;;;;AAKA,MAAMI,eAAe,GAAIL,IAAD,IAAmB;EAC9C,MAAMM,UAAU,GAAGP,YAAY,CAAC,UAAD,CAA/B;EACA,OAAOC,IAAI,GAAGM,UAAU,GAAGN,IAAhB,GAAuBM,UAAlC;AACH,CAHM;;;;AAKA,MAAMC,YAAY,GAAIP,IAAD,IAAmB;EAC3C,MAAMQ,MAAM,GAAGN,OAAO,CAACC,GAAR,CAAYM,WAAZ,IAA2BX,mBAA1C;EACA,OAAOE,IAAI,GAAGQ,MAAM,GAAGR,IAAZ,GAAmBQ,MAA9B;AACH,CAHM"}