@eventcatalog/generator-amazon-apigateway 1.0.2 → 1.0.3
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/dist/checkLicense.d.mts +3 -0
- package/dist/checkLicense.d.ts +3 -0
- package/dist/checkLicense.js +118 -0
- package/dist/checkLicense.js.map +1 -0
- package/dist/checkLicense.mjs +87 -0
- package/dist/checkLicense.mjs.map +1 -0
- package/dist/index.js +95 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/checkLicense.ts
|
|
31
|
+
var checkLicense_exports = {};
|
|
32
|
+
__export(checkLicense_exports, {
|
|
33
|
+
default: () => checkLicense_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(checkLicense_exports);
|
|
36
|
+
var import_chalk = __toESM(require("chalk"));
|
|
37
|
+
|
|
38
|
+
// package.json
|
|
39
|
+
var package_default = {
|
|
40
|
+
name: "@eventcatalog/generator-amazon-apigateway",
|
|
41
|
+
version: "1.0.3",
|
|
42
|
+
description: "Generator for Amazon API Gateway",
|
|
43
|
+
scripts: {
|
|
44
|
+
build: "tsup",
|
|
45
|
+
test: "vitest",
|
|
46
|
+
format: "prettier --write .",
|
|
47
|
+
"format:diff": "prettier --list-different .",
|
|
48
|
+
changeset: "changeset",
|
|
49
|
+
release: "changeset publish"
|
|
50
|
+
},
|
|
51
|
+
publishConfig: {
|
|
52
|
+
access: "public"
|
|
53
|
+
},
|
|
54
|
+
keywords: [],
|
|
55
|
+
author: "",
|
|
56
|
+
license: "ISC",
|
|
57
|
+
devDependencies: {
|
|
58
|
+
"@smithy/types": "^3.5.0",
|
|
59
|
+
"@types/node": "^20.16.1",
|
|
60
|
+
prettier: "^3.3.3",
|
|
61
|
+
tsup: "^8.1.0",
|
|
62
|
+
typescript: "^5.5.3",
|
|
63
|
+
vitest: "^2.0.2"
|
|
64
|
+
},
|
|
65
|
+
files: [
|
|
66
|
+
"dist",
|
|
67
|
+
"package.json"
|
|
68
|
+
],
|
|
69
|
+
main: "./dist/index.js",
|
|
70
|
+
module: "./dist/index.mjs",
|
|
71
|
+
types: "./dist/index.d.ts",
|
|
72
|
+
dependencies: {
|
|
73
|
+
"@aws-sdk/client-api-gateway": "^3.743.0",
|
|
74
|
+
"@aws-sdk/credential-provider-node": "^3.743.0",
|
|
75
|
+
"@changesets/cli": "^2.27.7",
|
|
76
|
+
chalk: "^4"
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// src/checkLicense.ts
|
|
81
|
+
var checkLicense_default = async (licenseKey) => {
|
|
82
|
+
const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;
|
|
83
|
+
if (!LICENSE_KEY) {
|
|
84
|
+
console.log(import_chalk.default.bgRed(`
|
|
85
|
+
This plugin requires a license key to use`));
|
|
86
|
+
console.log(import_chalk.default.redBright(`
|
|
87
|
+
Visit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const response = await fetch("https://api.eventcatalog.cloud/functions/v1/license", {
|
|
91
|
+
method: "POST",
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `Bearer ${LICENSE_KEY}`,
|
|
94
|
+
"Content-Type": "application/json"
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
if (response.status !== 200) {
|
|
98
|
+
console.log(import_chalk.default.bgRed(`
|
|
99
|
+
Invalid license key`));
|
|
100
|
+
console.log(import_chalk.default.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
if (response.status === 200) {
|
|
104
|
+
const data = await response.json();
|
|
105
|
+
if (package_default.name !== data.plugin) {
|
|
106
|
+
console.log(import_chalk.default.bgRed(`
|
|
107
|
+
Invalid license key for this plugin`));
|
|
108
|
+
console.log(import_chalk.default.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
if (data.is_trial) {
|
|
112
|
+
console.log(import_chalk.default.bgBlue(`
|
|
113
|
+
You are using a trial license for this plugin`));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return Promise.resolve();
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=checkLicense.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/checkLicense.ts","../package.json"],"sourcesContent":["import chalk from 'chalk';\nimport pkg from '../package.json';\n\ntype LicenseResponse = {\n is_trial: boolean;\n plugin: string;\n state: string;\n};\n\nexport default async (licenseKey?: string) => {\n const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;\n\n if (!LICENSE_KEY) {\n console.log(chalk.bgRed(`\\nThis plugin requires a license key to use`));\n console.log(chalk.redBright(`\\nVisit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));\n process.exit(1);\n }\n\n // Verify the license key\n const response = await fetch('https://api.eventcatalog.cloud/functions/v1/license', {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${LICENSE_KEY}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status !== 200) {\n console.log(chalk.bgRed(`\\nInvalid license key`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (response.status === 200) {\n const data = (await response.json()) as LicenseResponse;\n\n if (pkg.name !== data.plugin) {\n console.log(chalk.bgRed(`\\nInvalid license key for this plugin`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (data.is_trial) {\n console.log(chalk.bgBlue(`\\nYou are using a trial license for this plugin`));\n }\n }\n\n return Promise.resolve();\n};\n","{\n \"name\": \"@eventcatalog/generator-amazon-apigateway\",\n \"version\": \"1.0.3\",\n \"description\": \"Generator for Amazon API Gateway\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest\",\n \"format\": \"prettier --write .\",\n \"format:diff\": \"prettier --list-different .\",\n \"changeset\": \"changeset\",\n \"release\": \"changeset publish\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@smithy/types\": \"^3.5.0\",\n \"@types/node\": \"^20.16.1\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.5.3\",\n \"vitest\": \"^2.0.2\"\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"dependencies\": {\n \"@aws-sdk/client-api-gateway\": \"^3.743.0\",\n \"@aws-sdk/credential-provider-node\": \"^3.743.0\",\n \"@changesets/cli\": \"^2.27.7\",\n \"chalk\": \"^4\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;;;ACAlB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,SAAW;AAAA,IACT,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,eAAe;AAAA,IACf,WAAa;AAAA,IACb,SAAW;AAAA,EACb;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,UAAY,CAAC;AAAA,EACb,QAAU;AAAA,EACV,SAAW;AAAA,EACX,iBAAmB;AAAA,IACjB,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf,UAAY;AAAA,IACZ,MAAQ;AAAA,IACR,YAAc;AAAA,IACd,QAAU;AAAA,EACZ;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,EACF;AAAA,EACA,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,cAAgB;AAAA,IACd,+BAA+B;AAAA,IAC/B,qCAAqC;AAAA,IACrC,mBAAmB;AAAA,IACnB,OAAS;AAAA,EACX;AACF;;;AD9BA,IAAO,uBAAQ,OAAO,eAAwB;AAC5C,QAAM,cAAc,QAAQ,IAAI,8CAA8C,cAAc;AAE5F,MAAI,CAAC,aAAa;AAChB,YAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,0CAA6C,CAAC;AACtE,YAAQ,IAAI,aAAAA,QAAM,UAAU;AAAA,8EAAiF,CAAC;AAC9G,YAAQ,KAAK,CAAC;AAAA,EAChB;AAGA,QAAM,WAAW,MAAM,MAAM,uDAAuD;AAAA,IAClF,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,eAAe,UAAU,WAAW;AAAA,MACpC,gBAAgB;AAAA,IAClB;AAAA,EACF,CAAC;AAED,MAAI,SAAS,WAAW,KAAK;AAC3B,YAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,oBAAuB,CAAC;AAChD,YAAQ,IAAI,aAAAA,QAAM,UAAU,2FAA2F,CAAC;AACxH,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,SAAS,WAAW,KAAK;AAC3B,UAAM,OAAQ,MAAM,SAAS,KAAK;AAElC,QAAI,gBAAI,SAAS,KAAK,QAAQ;AAC5B,cAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,oCAAuC,CAAC;AAChE,cAAQ,IAAI,aAAAA,QAAM,UAAU,2FAA2F,CAAC;AACxH,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI,KAAK,UAAU;AACjB,cAAQ,IAAI,aAAAA,QAAM,OAAO;AAAA,8CAAiD,CAAC;AAAA,IAC7E;AAAA,EACF;AAEA,SAAO,QAAQ,QAAQ;AACzB;","names":["chalk"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/checkLicense.ts
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
// package.json
|
|
5
|
+
var package_default = {
|
|
6
|
+
name: "@eventcatalog/generator-amazon-apigateway",
|
|
7
|
+
version: "1.0.3",
|
|
8
|
+
description: "Generator for Amazon API Gateway",
|
|
9
|
+
scripts: {
|
|
10
|
+
build: "tsup",
|
|
11
|
+
test: "vitest",
|
|
12
|
+
format: "prettier --write .",
|
|
13
|
+
"format:diff": "prettier --list-different .",
|
|
14
|
+
changeset: "changeset",
|
|
15
|
+
release: "changeset publish"
|
|
16
|
+
},
|
|
17
|
+
publishConfig: {
|
|
18
|
+
access: "public"
|
|
19
|
+
},
|
|
20
|
+
keywords: [],
|
|
21
|
+
author: "",
|
|
22
|
+
license: "ISC",
|
|
23
|
+
devDependencies: {
|
|
24
|
+
"@smithy/types": "^3.5.0",
|
|
25
|
+
"@types/node": "^20.16.1",
|
|
26
|
+
prettier: "^3.3.3",
|
|
27
|
+
tsup: "^8.1.0",
|
|
28
|
+
typescript: "^5.5.3",
|
|
29
|
+
vitest: "^2.0.2"
|
|
30
|
+
},
|
|
31
|
+
files: [
|
|
32
|
+
"dist",
|
|
33
|
+
"package.json"
|
|
34
|
+
],
|
|
35
|
+
main: "./dist/index.js",
|
|
36
|
+
module: "./dist/index.mjs",
|
|
37
|
+
types: "./dist/index.d.ts",
|
|
38
|
+
dependencies: {
|
|
39
|
+
"@aws-sdk/client-api-gateway": "^3.743.0",
|
|
40
|
+
"@aws-sdk/credential-provider-node": "^3.743.0",
|
|
41
|
+
"@changesets/cli": "^2.27.7",
|
|
42
|
+
chalk: "^4"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/checkLicense.ts
|
|
47
|
+
var checkLicense_default = async (licenseKey) => {
|
|
48
|
+
const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;
|
|
49
|
+
if (!LICENSE_KEY) {
|
|
50
|
+
console.log(chalk.bgRed(`
|
|
51
|
+
This plugin requires a license key to use`));
|
|
52
|
+
console.log(chalk.redBright(`
|
|
53
|
+
Visit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const response = await fetch("https://api.eventcatalog.cloud/functions/v1/license", {
|
|
57
|
+
method: "POST",
|
|
58
|
+
headers: {
|
|
59
|
+
Authorization: `Bearer ${LICENSE_KEY}`,
|
|
60
|
+
"Content-Type": "application/json"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
if (response.status !== 200) {
|
|
64
|
+
console.log(chalk.bgRed(`
|
|
65
|
+
Invalid license key`));
|
|
66
|
+
console.log(chalk.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
if (response.status === 200) {
|
|
70
|
+
const data = await response.json();
|
|
71
|
+
if (package_default.name !== data.plugin) {
|
|
72
|
+
console.log(chalk.bgRed(`
|
|
73
|
+
Invalid license key for this plugin`));
|
|
74
|
+
console.log(chalk.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
if (data.is_trial) {
|
|
78
|
+
console.log(chalk.bgBlue(`
|
|
79
|
+
You are using a trial license for this plugin`));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Promise.resolve();
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
checkLicense_default as default
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=checkLicense.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/checkLicense.ts","../package.json"],"sourcesContent":["import chalk from 'chalk';\nimport pkg from '../package.json';\n\ntype LicenseResponse = {\n is_trial: boolean;\n plugin: string;\n state: string;\n};\n\nexport default async (licenseKey?: string) => {\n const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;\n\n if (!LICENSE_KEY) {\n console.log(chalk.bgRed(`\\nThis plugin requires a license key to use`));\n console.log(chalk.redBright(`\\nVisit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));\n process.exit(1);\n }\n\n // Verify the license key\n const response = await fetch('https://api.eventcatalog.cloud/functions/v1/license', {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${LICENSE_KEY}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status !== 200) {\n console.log(chalk.bgRed(`\\nInvalid license key`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (response.status === 200) {\n const data = (await response.json()) as LicenseResponse;\n\n if (pkg.name !== data.plugin) {\n console.log(chalk.bgRed(`\\nInvalid license key for this plugin`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (data.is_trial) {\n console.log(chalk.bgBlue(`\\nYou are using a trial license for this plugin`));\n }\n }\n\n return Promise.resolve();\n};\n","{\n \"name\": \"@eventcatalog/generator-amazon-apigateway\",\n \"version\": \"1.0.3\",\n \"description\": \"Generator for Amazon API Gateway\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest\",\n \"format\": \"prettier --write .\",\n \"format:diff\": \"prettier --list-different .\",\n \"changeset\": \"changeset\",\n \"release\": \"changeset publish\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@smithy/types\": \"^3.5.0\",\n \"@types/node\": \"^20.16.1\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.5.3\",\n \"vitest\": \"^2.0.2\"\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"dependencies\": {\n \"@aws-sdk/client-api-gateway\": \"^3.743.0\",\n \"@aws-sdk/credential-provider-node\": \"^3.743.0\",\n \"@changesets/cli\": \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2FAA2F,CAAC;AACxH,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,SAAS,WAAW,KAAK;AAC3B,UAAM,OAAQ,MAAM,SAAS,KAAK;AAElC,QAAI,gBAAI,SAAS,KAAK,QAAQ;AAC5B,cAAQ,IAAI,MAAM,MAAM;AAAA,oCAAuC,CAAC;AAChE,cAAQ,IAAI,MAAM,UAAU,2FAA2F,CAAC;AACxH,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI,KAAK,UAAU;AACjB,cAAQ,IAAI,MAAM,OAAO;AAAA,8CAAiD,CAAC;AAAA,IAC7E;AAAA,EACF;AAEA,SAAO,QAAQ,QAAQ;AACzB;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -127,8 +127,94 @@ async function hydrate(openApiSpec, routeConfig, version) {
|
|
|
127
127
|
// src/index.ts
|
|
128
128
|
var import_promises = require("fs/promises");
|
|
129
129
|
var import_node_path = require("path");
|
|
130
|
-
var
|
|
130
|
+
var import_chalk2 = __toESM(require("chalk"));
|
|
131
131
|
var import_promises2 = __toESM(require("fs/promises"));
|
|
132
|
+
|
|
133
|
+
// src/checkLicense.ts
|
|
134
|
+
var import_chalk = __toESM(require("chalk"));
|
|
135
|
+
|
|
136
|
+
// package.json
|
|
137
|
+
var package_default = {
|
|
138
|
+
name: "@eventcatalog/generator-amazon-apigateway",
|
|
139
|
+
version: "1.0.3",
|
|
140
|
+
description: "Generator for Amazon API Gateway",
|
|
141
|
+
scripts: {
|
|
142
|
+
build: "tsup",
|
|
143
|
+
test: "vitest",
|
|
144
|
+
format: "prettier --write .",
|
|
145
|
+
"format:diff": "prettier --list-different .",
|
|
146
|
+
changeset: "changeset",
|
|
147
|
+
release: "changeset publish"
|
|
148
|
+
},
|
|
149
|
+
publishConfig: {
|
|
150
|
+
access: "public"
|
|
151
|
+
},
|
|
152
|
+
keywords: [],
|
|
153
|
+
author: "",
|
|
154
|
+
license: "ISC",
|
|
155
|
+
devDependencies: {
|
|
156
|
+
"@smithy/types": "^3.5.0",
|
|
157
|
+
"@types/node": "^20.16.1",
|
|
158
|
+
prettier: "^3.3.3",
|
|
159
|
+
tsup: "^8.1.0",
|
|
160
|
+
typescript: "^5.5.3",
|
|
161
|
+
vitest: "^2.0.2"
|
|
162
|
+
},
|
|
163
|
+
files: [
|
|
164
|
+
"dist",
|
|
165
|
+
"package.json"
|
|
166
|
+
],
|
|
167
|
+
main: "./dist/index.js",
|
|
168
|
+
module: "./dist/index.mjs",
|
|
169
|
+
types: "./dist/index.d.ts",
|
|
170
|
+
dependencies: {
|
|
171
|
+
"@aws-sdk/client-api-gateway": "^3.743.0",
|
|
172
|
+
"@aws-sdk/credential-provider-node": "^3.743.0",
|
|
173
|
+
"@changesets/cli": "^2.27.7",
|
|
174
|
+
chalk: "^4"
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/checkLicense.ts
|
|
179
|
+
var checkLicense_default = async (licenseKey) => {
|
|
180
|
+
const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;
|
|
181
|
+
if (!LICENSE_KEY) {
|
|
182
|
+
console.log(import_chalk.default.bgRed(`
|
|
183
|
+
This plugin requires a license key to use`));
|
|
184
|
+
console.log(import_chalk.default.redBright(`
|
|
185
|
+
Visit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
const response = await fetch("https://api.eventcatalog.cloud/functions/v1/license", {
|
|
189
|
+
method: "POST",
|
|
190
|
+
headers: {
|
|
191
|
+
Authorization: `Bearer ${LICENSE_KEY}`,
|
|
192
|
+
"Content-Type": "application/json"
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (response.status !== 200) {
|
|
196
|
+
console.log(import_chalk.default.bgRed(`
|
|
197
|
+
Invalid license key`));
|
|
198
|
+
console.log(import_chalk.default.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
199
|
+
process.exit(1);
|
|
200
|
+
}
|
|
201
|
+
if (response.status === 200) {
|
|
202
|
+
const data = await response.json();
|
|
203
|
+
if (package_default.name !== data.plugin) {
|
|
204
|
+
console.log(import_chalk.default.bgRed(`
|
|
205
|
+
Invalid license key for this plugin`));
|
|
206
|
+
console.log(import_chalk.default.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
if (data.is_trial) {
|
|
210
|
+
console.log(import_chalk.default.bgBlue(`
|
|
211
|
+
You are using a trial license for this plugin`));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return Promise.resolve();
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/index.ts
|
|
132
218
|
var index_default = async (_, options) => {
|
|
133
219
|
if (!process.env.PROJECT_DIR) {
|
|
134
220
|
process.env.PROJECT_DIR = process.cwd();
|
|
@@ -136,27 +222,28 @@ var index_default = async (_, options) => {
|
|
|
136
222
|
if (!process.env.PROJECT_DIR) {
|
|
137
223
|
throw new Error("Please provide catalog url (env variable PROJECT_DIR)");
|
|
138
224
|
}
|
|
225
|
+
await checkLicense_default(options.licenseKey);
|
|
139
226
|
const outputDir = options.output ? (0, import_node_path.join)(process.env.PROJECT_DIR, options.output) : (0, import_node_path.join)(process.env.PROJECT_DIR, "amazon-apigateway-specs");
|
|
140
|
-
console.log(
|
|
227
|
+
console.log(import_chalk2.default.green(`Processing ${options.apis.length} apis with API Gateway`));
|
|
141
228
|
for (const api of options.apis) {
|
|
142
|
-
console.log(
|
|
229
|
+
console.log(import_chalk2.default.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));
|
|
143
230
|
const client = new import_client_api_gateway2.APIGatewayClient({ region: api.region, credentials: options.credentials });
|
|
144
231
|
const apiName = await getRestApiIdByName(client, api.name);
|
|
145
232
|
if (!apiName) {
|
|
146
|
-
console.log(
|
|
233
|
+
console.log(import_chalk2.default.yellow(` - API with name '${api.name}' not found, skipping import...`));
|
|
147
234
|
continue;
|
|
148
235
|
}
|
|
149
236
|
const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);
|
|
150
|
-
console.log(
|
|
237
|
+
console.log(import_chalk2.default.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));
|
|
151
238
|
const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);
|
|
152
239
|
const output = (0, import_node_path.join)(outputDir, `${api.name}.json`);
|
|
153
240
|
await import_promises2.default.mkdir(outputDir, { recursive: true });
|
|
154
|
-
console.log(
|
|
241
|
+
console.log(import_chalk2.default.cyan(` - Writing OpenAPI file to ${output}...`));
|
|
155
242
|
await (0, import_promises.writeFile)(output, JSON.stringify(hydratedSpec, null, 2));
|
|
156
243
|
}
|
|
157
|
-
console.log(
|
|
244
|
+
console.log(import_chalk2.default.green(`
|
|
158
245
|
Finished generating event catalog with Amazon API Gateway Apis.`));
|
|
159
|
-
console.log(
|
|
246
|
+
console.log(import_chalk2.default.green(`
|
|
160
247
|
Specifications have been written to ${outputDir}`));
|
|
161
248
|
};
|
|
162
249
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\n\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n\n // Add render false for empty schemas\n if (operationObj.requestBody?.content?.['application/json']?.schema?.title === 'Empty Schema') {\n operationObj.requestBody.content['application/json'].schema['x-eventcatalog-render'] = false;\n }\n }\n }\n }\n\n // Add render false for empty schemas in components\n if (modifiedSpec.components?.schemas?.Empty?.title === 'Empty Schema') {\n modifiedSpec.components.schemas.Empty['x-eventcatalog-render-schema-viewer'] = false;\n }\n\n return modifiedSpec;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,6BAAiC;;;ACAjC,gCAAuE;AAEvE,eAAsB,eAAe,QAA0B,WAAmB,WAAmB;AACnG,MAAI;AACF,UAAM,UAAU,IAAI,2CAAiB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,YAAY;AAAA;AAAA,MACZ,SAAS;AAAA,IACX,CAAC;AAED,UAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,QAAI;AAEJ,QAAI;AACF,oBAAc,IAAI,YAAY,EAAE,OAAO,SAAS,IAAI;AACpD,aAAO,KAAK,MAAM,WAAW;AAAA,IAC/B,SAAS,OAAO;AACd,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,yCAAyC,KAAK;AAC5D,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,mBAAmB,QAA0B,SAAiB;AAClF,MAAI;AACF,QAAI;AACJ,OAAG;AACD,YAAM,UAAU,IAAI,6CAAmB;AAAA,QACrC;AAAA;AAAA,MACF,CAAC;AACD,YAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,YAAM,MAAM,SAAS,OAAO,KAAK,CAACC,SAAQA,KAAI,SAAS,OAAO;AAC9D,UAAI,KAAK;AACP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ACF;AAEA,UAAM,cAAc,MAAM,eAAe,QAAQ,SAAS,IAAI,SAAS;AAEvE,YAAQ,IAAI,aAAAA,QAAM,KAAK,kEAAkE,CAAC;AAC1F,UAAM,eAAe,MAAM,QAAQ,aAAa,IAAI,QAAQ,IAAI,OAAO;AAEvE,UAAM,aAAS,uBAAK,WAAW,GAAG,IAAI,IAAI,OAAO;AAGjD,UAAM,iBAAAC,QAAG,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAE7C,YAAQ,IAAI,aAAAD,QAAM,KAAK,8BAA8B,MAAM,KAAK,CAAC;AACjE,cAAM,2BAAU,QAAQ,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,EAC/D;AAEA,UAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,gEAAmE,CAAC;AAC5F,UAAQ,IAAI,aAAAA,QAAM,MAAM;AAAA,sCAAyC,SAAS,EAAE,CAAC;AAC/E;","names":["import_client_api_gateway","api","import_promises","chalk","fs"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts","../src/checkLicense.ts","../package.json"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\nimport checkLicense from './checkLicense';\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n await checkLicense(options.licenseKey);\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n\n // Add render false for empty schemas\n if (operationObj.requestBody?.content?.['application/json']?.schema?.title === 'Empty Schema') {\n operationObj.requestBody.content['application/json'].schema['x-eventcatalog-render'] = false;\n }\n }\n }\n }\n\n // Add render false for empty schemas in components\n if (modifiedSpec.components?.schemas?.Empty?.title === 'Empty Schema') {\n modifiedSpec.components.schemas.Empty['x-eventcatalog-render-schema-viewer'] = false;\n }\n\n return modifiedSpec;\n}\n","import chalk from 'chalk';\nimport pkg from '../package.json';\n\ntype LicenseResponse = {\n is_trial: boolean;\n plugin: string;\n state: string;\n};\n\nexport default async (licenseKey?: string) => {\n const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;\n\n if (!LICENSE_KEY) {\n console.log(chalk.bgRed(`\\nThis plugin requires a license key to use`));\n console.log(chalk.redBright(`\\nVisit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));\n process.exit(1);\n }\n\n // Verify the license key\n const response = await fetch('https://api.eventcatalog.cloud/functions/v1/license', {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${LICENSE_KEY}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status !== 200) {\n console.log(chalk.bgRed(`\\nInvalid license key`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (response.status === 200) {\n const data = (await response.json()) as LicenseResponse;\n\n if (pkg.name !== data.plugin) {\n console.log(chalk.bgRed(`\\nInvalid license key for this plugin`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (data.is_trial) {\n console.log(chalk.bgBlue(`\\nYou are using a trial license for this plugin`));\n }\n }\n\n return Promise.resolve();\n};\n","{\n \"name\": \"@eventcatalog/generator-amazon-apigateway\",\n \"version\": \"1.0.3\",\n \"description\": \"Generator for Amazon API Gateway\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest\",\n \"format\": \"prettier --write .\",\n \"format:diff\": \"prettier --list-different .\",\n \"changeset\": \"changeset\",\n \"release\": \"changeset publish\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@smithy/types\": \"^3.5.0\",\n \"@types/node\": \"^20.16.1\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.5.3\",\n \"vitest\": \"^2.0.2\"\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"dependencies\": {\n \"@aws-sdk/client-api-gateway\": \"^3.743.0\",\n \"@aws-sdk/credential-provider-node\": \"^3.743.0\",\n \"@changesets/cli\": \"^2.27.7\",\n \"chalk\": \"^4\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,6BAAiC;;;ACAjC,gCAAuE;AAEvE,eAAsB,eAAe,QAA0B,WAAmB,WAAmB;AACnG,MAAI;AACF,UAAM,UAAU,IAAI,2CAAiB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,YAAY;AAAA;AAAA,MACZ,SAAS;AAAA,IACX,CAAC;AAED,UAAM,WAAW,MAAM,OAAO,KAAK,OAAO;AAE1C,QAAI;AAEJ,QAAI;AACF,oBAAc,IAAI,YAAY,EAAE,OAAO,SAAS,IAAI;AACpD,aAAO,KAAK,MAAM,WAAW;AAAA,IAC/B,SAAS,OAAO;AACd,aAAO,SAAS;AAAA,IAClB;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,MAAM,yCAAyC,KAAK;AAC5D,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,mBAAmB,QAA0B,SAAiB;AAClF,MAAI;AACF,QAAI;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,SAAS,EAAE,CAAC;AAC/E;","names":["import_client_api_gateway","api","import_chalk","import_promises","chalk","chalk","fs"]}
|
package/dist/index.mjs
CHANGED
|
@@ -93,8 +93,94 @@ async function hydrate(openApiSpec, routeConfig, version) {
|
|
|
93
93
|
// src/index.ts
|
|
94
94
|
import { writeFile } from "node:fs/promises";
|
|
95
95
|
import { join } from "node:path";
|
|
96
|
-
import
|
|
96
|
+
import chalk2 from "chalk";
|
|
97
97
|
import fs from "fs/promises";
|
|
98
|
+
|
|
99
|
+
// src/checkLicense.ts
|
|
100
|
+
import chalk from "chalk";
|
|
101
|
+
|
|
102
|
+
// package.json
|
|
103
|
+
var package_default = {
|
|
104
|
+
name: "@eventcatalog/generator-amazon-apigateway",
|
|
105
|
+
version: "1.0.3",
|
|
106
|
+
description: "Generator for Amazon API Gateway",
|
|
107
|
+
scripts: {
|
|
108
|
+
build: "tsup",
|
|
109
|
+
test: "vitest",
|
|
110
|
+
format: "prettier --write .",
|
|
111
|
+
"format:diff": "prettier --list-different .",
|
|
112
|
+
changeset: "changeset",
|
|
113
|
+
release: "changeset publish"
|
|
114
|
+
},
|
|
115
|
+
publishConfig: {
|
|
116
|
+
access: "public"
|
|
117
|
+
},
|
|
118
|
+
keywords: [],
|
|
119
|
+
author: "",
|
|
120
|
+
license: "ISC",
|
|
121
|
+
devDependencies: {
|
|
122
|
+
"@smithy/types": "^3.5.0",
|
|
123
|
+
"@types/node": "^20.16.1",
|
|
124
|
+
prettier: "^3.3.3",
|
|
125
|
+
tsup: "^8.1.0",
|
|
126
|
+
typescript: "^5.5.3",
|
|
127
|
+
vitest: "^2.0.2"
|
|
128
|
+
},
|
|
129
|
+
files: [
|
|
130
|
+
"dist",
|
|
131
|
+
"package.json"
|
|
132
|
+
],
|
|
133
|
+
main: "./dist/index.js",
|
|
134
|
+
module: "./dist/index.mjs",
|
|
135
|
+
types: "./dist/index.d.ts",
|
|
136
|
+
dependencies: {
|
|
137
|
+
"@aws-sdk/client-api-gateway": "^3.743.0",
|
|
138
|
+
"@aws-sdk/credential-provider-node": "^3.743.0",
|
|
139
|
+
"@changesets/cli": "^2.27.7",
|
|
140
|
+
chalk: "^4"
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/checkLicense.ts
|
|
145
|
+
var checkLicense_default = async (licenseKey) => {
|
|
146
|
+
const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;
|
|
147
|
+
if (!LICENSE_KEY) {
|
|
148
|
+
console.log(chalk.bgRed(`
|
|
149
|
+
This plugin requires a license key to use`));
|
|
150
|
+
console.log(chalk.redBright(`
|
|
151
|
+
Visit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
const response = await fetch("https://api.eventcatalog.cloud/functions/v1/license", {
|
|
155
|
+
method: "POST",
|
|
156
|
+
headers: {
|
|
157
|
+
Authorization: `Bearer ${LICENSE_KEY}`,
|
|
158
|
+
"Content-Type": "application/json"
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
if (response.status !== 200) {
|
|
162
|
+
console.log(chalk.bgRed(`
|
|
163
|
+
Invalid license key`));
|
|
164
|
+
console.log(chalk.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
if (response.status === 200) {
|
|
168
|
+
const data = await response.json();
|
|
169
|
+
if (package_default.name !== data.plugin) {
|
|
170
|
+
console.log(chalk.bgRed(`
|
|
171
|
+
Invalid license key for this plugin`));
|
|
172
|
+
console.log(chalk.redBright("Please check your plugin license key or purchase a license at https://eventcatalog.cloud/"));
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
if (data.is_trial) {
|
|
176
|
+
console.log(chalk.bgBlue(`
|
|
177
|
+
You are using a trial license for this plugin`));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return Promise.resolve();
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/index.ts
|
|
98
184
|
var index_default = async (_, options) => {
|
|
99
185
|
if (!process.env.PROJECT_DIR) {
|
|
100
186
|
process.env.PROJECT_DIR = process.cwd();
|
|
@@ -102,27 +188,28 @@ var index_default = async (_, options) => {
|
|
|
102
188
|
if (!process.env.PROJECT_DIR) {
|
|
103
189
|
throw new Error("Please provide catalog url (env variable PROJECT_DIR)");
|
|
104
190
|
}
|
|
191
|
+
await checkLicense_default(options.licenseKey);
|
|
105
192
|
const outputDir = options.output ? join(process.env.PROJECT_DIR, options.output) : join(process.env.PROJECT_DIR, "amazon-apigateway-specs");
|
|
106
|
-
console.log(
|
|
193
|
+
console.log(chalk2.green(`Processing ${options.apis.length} apis with API Gateway`));
|
|
107
194
|
for (const api of options.apis) {
|
|
108
|
-
console.log(
|
|
195
|
+
console.log(chalk2.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));
|
|
109
196
|
const client = new APIGatewayClient2({ region: api.region, credentials: options.credentials });
|
|
110
197
|
const apiName = await getRestApiIdByName(client, api.name);
|
|
111
198
|
if (!apiName) {
|
|
112
|
-
console.log(
|
|
199
|
+
console.log(chalk2.yellow(` - API with name '${api.name}' not found, skipping import...`));
|
|
113
200
|
continue;
|
|
114
201
|
}
|
|
115
202
|
const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);
|
|
116
|
-
console.log(
|
|
203
|
+
console.log(chalk2.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));
|
|
117
204
|
const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);
|
|
118
205
|
const output = join(outputDir, `${api.name}.json`);
|
|
119
206
|
await fs.mkdir(outputDir, { recursive: true });
|
|
120
|
-
console.log(
|
|
207
|
+
console.log(chalk2.cyan(` - Writing OpenAPI file to ${output}...`));
|
|
121
208
|
await writeFile(output, JSON.stringify(hydratedSpec, null, 2));
|
|
122
209
|
}
|
|
123
|
-
console.log(
|
|
210
|
+
console.log(chalk2.green(`
|
|
124
211
|
Finished generating event catalog with Amazon API Gateway Apis.`));
|
|
125
|
-
console.log(
|
|
212
|
+
console.log(chalk2.green(`
|
|
126
213
|
Specifications have been written to ${outputDir}`));
|
|
127
214
|
};
|
|
128
215
|
export {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\n\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n\n // Add render false for empty schemas\n if (operationObj.requestBody?.content?.['application/json']?.schema?.title === 'Empty Schema') {\n operationObj.requestBody.content['application/json'].schema['x-eventcatalog-render'] = false;\n }\n }\n }\n }\n\n // Add render false for empty schemas in components\n if (modifiedSpec.components?.schemas?.Empty?.title === 'Empty Schema') {\n modifiedSpec.components.schemas.Empty['x-eventcatalog-render-schema-viewer'] = false;\n }\n\n return modifiedSpec;\n}\n"],"mappings":";AAAA,SAAS,oBAAAA,yBAAwB;;;ACAjC,SAA2B,kBAAkB,0BAA0B;AAEvE,eAAsB,eAAe,QAA0B,WAAmB,WAAmB;AACnG,MAAI;AACF,UAAM,U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"sources":["../src/index.ts","../src/utils/apigateway.ts","../src/utils/hydrate-openapi-file.ts","../src/checkLicense.ts","../package.json"],"sourcesContent":["import { APIGatewayClient } from '@aws-sdk/client-api-gateway';\nimport { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@smithy/types';\nimport { getOpenApiSpec, getRestApiIdByName } from './utils/apigateway';\nimport { hydrate } from './utils/hydrate-openapi-file';\nimport { writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport chalk from 'chalk';\nimport fs from 'fs/promises';\nimport checkLicense from './checkLicense';\nexport type Route = {\n type: 'command' | 'query' | 'event';\n id?: string;\n name?: string;\n description?: string;\n};\n\nexport type API = {\n name: string;\n region: string;\n stageName: string;\n version?: number;\n routes: Record<string, Route>;\n};\n\ntype Props = {\n debug?: boolean;\n licenseKey?: string;\n apis: API[];\n output?: string;\n credentials?: AwsCredentialIdentity | AwsCredentialIdentityProvider;\n};\n\nexport default async (_: any, options: Props) => {\n if (!process.env.PROJECT_DIR) {\n process.env.PROJECT_DIR = process.cwd();\n }\n\n if (!process.env.PROJECT_DIR) {\n throw new Error('Please provide catalog url (env variable PROJECT_DIR)');\n }\n\n await checkLicense(options.licenseKey);\n\n const outputDir = options.output\n ? join(process.env.PROJECT_DIR, options.output)\n : join(process.env.PROJECT_DIR, 'amazon-apigateway-specs');\n\n console.log(chalk.green(`Processing ${options.apis.length} apis with API Gateway`));\n\n // Loop through all the APIS and hydrate the openapi spec\n for (const api of options.apis) {\n console.log(chalk.gray(`Processing ${api.name} in ${api.region} with Amazon API Gateway...`));\n\n const client = new APIGatewayClient({ region: api.region, credentials: options.credentials });\n\n const apiName = await getRestApiIdByName(client, api.name);\n\n if (!apiName) {\n console.log(chalk.yellow(` - API with name '${api.name}' not found, skipping import...`));\n continue;\n }\n\n const openApiSpec = await getOpenApiSpec(client, apiName, api.stageName);\n\n console.log(chalk.cyan(` - Found OpenAPI file, hydrating with EventCatalog extensions...`));\n const hydratedSpec = await hydrate(openApiSpec, api.routes, api.version);\n\n const output = join(outputDir, `${api.name}.json`);\n\n // ensure the directory exists\n await fs.mkdir(outputDir, { recursive: true });\n\n console.log(chalk.cyan(` - Writing OpenAPI file to ${output}...`));\n await writeFile(output, JSON.stringify(hydratedSpec, null, 2));\n }\n\n console.log(chalk.green(`\\nFinished generating event catalog with Amazon API Gateway Apis.`));\n console.log(chalk.green(`\\nSpecifications have been written to ${outputDir}`));\n};\n","import { APIGatewayClient, GetExportCommand, GetRestApisCommand } from '@aws-sdk/client-api-gateway';\n\nexport async function getOpenApiSpec(client: APIGatewayClient, restApiId: string, stageName: string) {\n try {\n const command = new GetExportCommand({\n restApiId: restApiId,\n stageName: stageName,\n exportType: 'oas30', // Use 'swagger' for Swagger/OpenAPI 2.0\n accepts: 'application/json',\n });\n\n const response = await client.send(command);\n\n let openAPISpec;\n\n try {\n openAPISpec = new TextDecoder().decode(response.body);\n return JSON.parse(openAPISpec);\n } catch (error) {\n return response.body;\n }\n } catch (error) {\n console.error('Error fetching OpenAPI specification:', error);\n throw error;\n }\n}\n\nexport async function getRestApiIdByName(client: APIGatewayClient, apiName: string) {\n try {\n let position: string | undefined;\n do {\n const command = new GetRestApisCommand({\n position: position, // Include the position token for pagination\n });\n const response = await client.send(command);\n\n const api = response.items?.find((api) => api.name === apiName);\n if (api) {\n return api.id; // Found the API, return its ID\n }\n\n position = response.position; // Get the next position token\n } while (position); // Continue while there are more APIs to fetch\n\n throw new Error(`API with name '${apiName}' not found`);\n } catch (error) {\n console.error('Error fetching REST API ID:', error);\n throw error;\n }\n}\n","export async function hydrate(openApiSpec: any, routeConfig: any, version?: number) {\n // Clone the spec to avoid modifying the original\n const modifiedSpec = JSON.parse(JSON.stringify(openApiSpec));\n\n // Default configuration - all routes are queries unless specified\n const defaultMessageType = 'query';\n\n // Set version from config or default to 1\n const specVersion = version || routeConfig.version || 1;\n modifiedSpec.info.version = `${specVersion}`;\n\n // Iterate through all paths and their methods\n for (const [path, pathItem] of Object.entries(modifiedSpec.paths)) {\n for (const [method, operation] of Object.entries(pathItem as Record<string, unknown>)) {\n if (operation && typeof operation === 'object' && !Array.isArray(operation)) {\n const operationObj = operation as {\n operationId?: string;\n description?: string;\n [key: string]: any;\n };\n\n const configKey = `${method.toLowerCase()} ${path}`;\n const config = routeConfig[configKey] || {};\n\n // Add message type extension\n const messageType = typeof config === 'string' ? config : config.type || defaultMessageType;\n operationObj['x-eventcatalog-message-type'] = messageType;\n\n // Set operationId\n if (typeof config === 'object' && config.id) {\n operationObj.operationId = config.id;\n } else if (!operationObj.operationId) {\n const normalizedPath = path.replace(/^\\//, '').replace(/\\//g, '_').replace(/[{}]/g, '');\n\n operationObj.operationId = `${method.toLowerCase()}_${normalizedPath}`;\n }\n\n // Add description if provided in config\n if (typeof config === 'object' && config.description) {\n operationObj.description = config.description;\n }\n\n // Add optional message ID and name if provided\n if (typeof config === 'object') {\n if (config.id) {\n operationObj['x-eventcatalog-message-id'] = config.id;\n }\n if (config.name) {\n operationObj['x-eventcatalog-message-name'] = config.name;\n }\n }\n\n // Add render false for empty schemas\n if (operationObj.requestBody?.content?.['application/json']?.schema?.title === 'Empty Schema') {\n operationObj.requestBody.content['application/json'].schema['x-eventcatalog-render'] = false;\n }\n }\n }\n }\n\n // Add render false for empty schemas in components\n if (modifiedSpec.components?.schemas?.Empty?.title === 'Empty Schema') {\n modifiedSpec.components.schemas.Empty['x-eventcatalog-render-schema-viewer'] = false;\n }\n\n return modifiedSpec;\n}\n","import chalk from 'chalk';\nimport pkg from '../package.json';\n\ntype LicenseResponse = {\n is_trial: boolean;\n plugin: string;\n state: string;\n};\n\nexport default async (licenseKey?: string) => {\n const LICENSE_KEY = process.env.EVENTCATALOG_LICENSE_KEY_AMAZON_APIGATEWAY || licenseKey || null;\n\n if (!LICENSE_KEY) {\n console.log(chalk.bgRed(`\\nThis plugin requires a license key to use`));\n console.log(chalk.redBright(`\\nVisit https://eventcatalog.cloud/ to get a 14 day trial or purchase a license`));\n process.exit(1);\n }\n\n // Verify the license key\n const response = await fetch('https://api.eventcatalog.cloud/functions/v1/license', {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${LICENSE_KEY}`,\n 'Content-Type': 'application/json',\n },\n });\n\n if (response.status !== 200) {\n console.log(chalk.bgRed(`\\nInvalid license key`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (response.status === 200) {\n const data = (await response.json()) as LicenseResponse;\n\n if (pkg.name !== data.plugin) {\n console.log(chalk.bgRed(`\\nInvalid license key for this plugin`));\n console.log(chalk.redBright('Please check your plugin license key or purchase a license at https://eventcatalog.cloud/'));\n process.exit(1);\n }\n\n if (data.is_trial) {\n console.log(chalk.bgBlue(`\\nYou are using a trial license for this plugin`));\n }\n }\n\n return Promise.resolve();\n};\n","{\n \"name\": \"@eventcatalog/generator-amazon-apigateway\",\n \"version\": \"1.0.3\",\n \"description\": \"Generator for Amazon API Gateway\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"test\": \"vitest\",\n \"format\": \"prettier --write .\",\n \"format:diff\": \"prettier --list-different .\",\n \"changeset\": \"changeset\",\n \"release\": \"changeset publish\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@smithy/types\": \"^3.5.0\",\n \"@types/node\": \"^20.16.1\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.1.0\",\n \"typescript\": \"^5.5.3\",\n \"vitest\": \"^2.0.2\"\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"dependencies\": {\n \"@aws-sdk/client-api-gateway\": \"^3.743.0\",\n \"@aws-sdk/credential-provider-node\": \"^3.743.0\",\n \"@changesets/cli\": \"^2.27.7\",\n \"chalk\": \"^4\"\n }\n}\n"],"mappings":";AAAA,SAAS,oBA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