ntfy-reverse-proxy 0.0.0 → 2.0.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/README.md +48 -0
- package/build/src/cli/commands/config-io.d.ts +5 -0
- package/build/src/cli/commands/config-io.d.ts.map +1 -0
- package/build/src/cli/commands/config-io.js +19 -0
- package/build/src/cli/commands/config-io.js.map +1 -0
- package/build/src/cli/commands/context.d.ts +9 -0
- package/build/src/cli/commands/context.d.ts.map +1 -0
- package/build/src/cli/commands/context.js +108 -0
- package/build/src/cli/commands/context.js.map +1 -0
- package/build/src/cli/commands/deploy.d.ts +4 -0
- package/build/src/cli/commands/deploy.d.ts.map +1 -0
- package/build/src/cli/commands/deploy.js +496 -0
- package/build/src/cli/commands/deploy.js.map +1 -0
- package/build/src/cli/commands/generate.d.ts +4 -0
- package/build/src/cli/commands/generate.d.ts.map +1 -0
- package/build/src/cli/commands/generate.js +68 -0
- package/build/src/cli/commands/generate.js.map +1 -0
- package/build/src/cli/commands/server.d.ts +7 -0
- package/build/src/cli/commands/server.d.ts.map +1 -0
- package/build/src/cli/commands/server.js +43 -0
- package/build/src/cli/commands/server.js.map +1 -0
- package/build/src/cli/commands/settings.d.ts +5 -0
- package/build/src/cli/commands/settings.d.ts.map +1 -0
- package/build/src/cli/commands/settings.js +16 -0
- package/build/src/cli/commands/settings.js.map +1 -0
- package/build/src/cli/commands/validate.d.ts +4 -0
- package/build/src/cli/commands/validate.d.ts.map +1 -0
- package/build/src/cli/commands/validate.js +45 -0
- package/build/src/cli/commands/validate.js.map +1 -0
- package/build/src/cli/index.d.ts +5 -0
- package/build/src/cli/index.d.ts.map +1 -0
- package/build/src/cli/index.js +118 -0
- package/build/src/cli/index.js.map +1 -0
- package/build/src/cli/menu/interactive.d.ts +4 -0
- package/build/src/cli/menu/interactive.d.ts.map +1 -0
- package/build/src/cli/menu/interactive.js +902 -0
- package/build/src/cli/menu/interactive.js.map +1 -0
- package/build/src/lib/item.d.ts +3 -0
- package/build/src/lib/item.d.ts.map +1 -0
- package/build/src/lib/item.js +3 -0
- package/build/src/lib/item.js.map +1 -0
- package/build/src/lib/regex.d.ts +30 -0
- package/build/src/lib/regex.d.ts.map +1 -0
- package/build/src/lib/regex.js +30 -0
- package/build/src/lib/regex.js.map +1 -0
- package/build/src/lib/schema.d.ts +167 -0
- package/build/src/lib/schema.d.ts.map +1 -0
- package/build/src/lib/schema.js +70 -0
- package/build/src/lib/schema.js.map +1 -0
- package/build/src/lib/utility.d.ts +4 -0
- package/build/src/lib/utility.d.ts.map +1 -0
- package/build/src/lib/utility.js +14 -0
- package/build/src/lib/utility.js.map +1 -0
- package/build/src/types/cli/commands/config-io.d.ts +38 -0
- package/build/src/types/cli/commands/context.d.ts +131 -0
- package/build/src/types/cli/commands/deploy.d.ts +622 -0
- package/build/src/types/cli/commands/generate.d.ts +51 -0
- package/build/src/types/cli/commands/server.d.ts +65 -0
- package/build/src/types/cli/commands/settings.d.ts +25 -0
- package/build/src/types/cli/commands/validate.d.ts +37 -0
- package/build/src/types/cli/index.d.ts +55 -0
- package/build/src/types/cli/menu/interactive.d.ts +381 -0
- package/build/src/types/fetch-response.d.ts +11 -0
- package/build/src/types/lib/schema.d.ts +134 -0
- package/build/src/types/lib/utility.d.ts +8 -0
- package/build/src/types/tests/cli/commands/context.test.d.ts +57 -0
- package/build/src/types/tests/cli/commands/generate.test.d.ts +12 -0
- package/build/src/types/tests/cli/commands/server.test.d.ts +45 -0
- package/build/src/types/tests/cli/commands/settings.test.d.ts +40 -0
- package/build/src/types/tests/cli/commands/validate.test.d.ts +19 -0
- package/build/src/types/tests/cli/menu/interactive.test.d.ts +6 -0
- package/build/src/types/tests/lib/schema.test.d.ts +10 -0
- package/build/src/types/tests/type-declarations.test.d.ts +173 -0
- package/build/src/types/tests/worker/index.test.d.ts +20 -0
- package/build/src/types/tests/worker/interpreters/ntfy-json.test.d.ts +19 -0
- package/build/src/types/tests/worker/interpreters/pfsense.test.d.ts +10 -0
- package/build/src/types/tests/worker/interpreters/plain-text.test.d.ts +10 -0
- package/build/src/types/tests/worker/interpreters/seerr.test.d.ts +8 -0
- package/build/src/types/tests/worker/interpreters/statuspage.test.d.ts +58 -0
- package/build/src/types/tests/worker/interpreters/synology.test.d.ts +8 -0
- package/build/src/types/tests/worker/interpreters/unifi.test.d.ts +8 -0
- package/build/src/types/tests/worker/landing/page.test.d.ts +55 -0
- package/build/src/types/tests/worker/pipeline/accumulate.test.d.ts +28 -0
- package/build/src/types/tests/worker/pipeline/authenticate.test.d.ts +9 -0
- package/build/src/types/tests/worker/pipeline/email.test.d.ts +15 -0
- package/build/src/types/tests/worker/pipeline/format.test.d.ts +38 -0
- package/build/src/types/tests/worker/pipeline/interpret.test.d.ts +43 -0
- package/build/src/types/tests/worker/pipeline/parse.test.d.ts +17 -0
- package/build/src/types/tests/worker/pipeline/receive.test.d.ts +23 -0
- package/build/src/types/tests/worker/pipeline/respond.test.d.ts +20 -0
- package/build/src/types/tests/worker/pipeline/route.test.d.ts +80 -0
- package/build/src/types/tests/worker/pipeline/send.test.d.ts +37 -0
- package/build/src/types/tests/worker/pipeline/split.test.d.ts +17 -0
- package/build/src/types/worker/index.d.ts +232 -0
- package/build/src/types/worker/interpreters/ntfy-json.d.ts +28 -0
- package/build/src/types/worker/interpreters/pfsense.d.ts +97 -0
- package/build/src/types/worker/interpreters/plain-text.d.ts +24 -0
- package/build/src/types/worker/interpreters/seerr.d.ts +124 -0
- package/build/src/types/worker/interpreters/statuspage.d.ts +239 -0
- package/build/src/types/worker/interpreters/synology.d.ts +99 -0
- package/build/src/types/worker/interpreters/unifi.d.ts +111 -0
- package/build/src/types/worker/landing/page.d.ts +44 -0
- package/build/src/types/worker/pipeline/accumulate.d.ts +79 -0
- package/build/src/types/worker/pipeline/authenticate.d.ts +68 -0
- package/build/src/types/worker/pipeline/email.d.ts +108 -0
- package/build/src/types/worker/pipeline/format.d.ts +47 -0
- package/build/src/types/worker/pipeline/interpret.d.ts +63 -0
- package/build/src/types/worker/pipeline/parse.d.ts +39 -0
- package/build/src/types/worker/pipeline/receive.d.ts +64 -0
- package/build/src/types/worker/pipeline/respond.d.ts +113 -0
- package/build/src/types/worker/pipeline/route.d.ts +34 -0
- package/build/src/types/worker/pipeline/send.d.ts +143 -0
- package/build/src/types/worker/pipeline/shared.d.ts +85 -0
- package/build/src/types/worker/pipeline/split.d.ts +35 -0
- package/build/src/worker/handlers.d.ts +5 -0
- package/build/src/worker/handlers.d.ts.map +1 -0
- package/build/src/worker/handlers.js +360 -0
- package/build/src/worker/handlers.js.map +1 -0
- package/build/src/worker/index.d.ts +4 -0
- package/build/src/worker/index.d.ts.map +1 -0
- package/build/src/worker/index.js +52 -0
- package/build/src/worker/index.js.map +1 -0
- package/build/src/worker/interpreters/ntfy-json.d.ts +4 -0
- package/build/src/worker/interpreters/ntfy-json.d.ts.map +1 -0
- package/build/src/worker/interpreters/ntfy-json.js +49 -0
- package/build/src/worker/interpreters/ntfy-json.js.map +1 -0
- package/build/src/worker/interpreters/pfsense.d.ts +4 -0
- package/build/src/worker/interpreters/pfsense.d.ts.map +1 -0
- package/build/src/worker/interpreters/pfsense.js +150 -0
- package/build/src/worker/interpreters/pfsense.js.map +1 -0
- package/build/src/worker/interpreters/plain-text.d.ts +4 -0
- package/build/src/worker/interpreters/plain-text.d.ts.map +1 -0
- package/build/src/worker/interpreters/plain-text.js +18 -0
- package/build/src/worker/interpreters/plain-text.js.map +1 -0
- package/build/src/worker/interpreters/seerr.d.ts +4 -0
- package/build/src/worker/interpreters/seerr.d.ts.map +1 -0
- package/build/src/worker/interpreters/seerr.js +173 -0
- package/build/src/worker/interpreters/seerr.js.map +1 -0
- package/build/src/worker/interpreters/statuspage.d.ts +4 -0
- package/build/src/worker/interpreters/statuspage.d.ts.map +1 -0
- package/build/src/worker/interpreters/statuspage.js +266 -0
- package/build/src/worker/interpreters/statuspage.js.map +1 -0
- package/build/src/worker/interpreters/synology.d.ts +4 -0
- package/build/src/worker/interpreters/synology.d.ts.map +1 -0
- package/build/src/worker/interpreters/synology.js +177 -0
- package/build/src/worker/interpreters/synology.js.map +1 -0
- package/build/src/worker/interpreters/unifi.d.ts +4 -0
- package/build/src/worker/interpreters/unifi.d.ts.map +1 -0
- package/build/src/worker/interpreters/unifi.js +152 -0
- package/build/src/worker/interpreters/unifi.js.map +1 -0
- package/build/src/worker/landing/page.d.ts +4 -0
- package/build/src/worker/landing/page.d.ts.map +1 -0
- package/build/src/worker/landing/page.js +260 -0
- package/build/src/worker/landing/page.js.map +1 -0
- package/build/src/worker/pipeline/accumulate.d.ts +7 -0
- package/build/src/worker/pipeline/accumulate.d.ts.map +1 -0
- package/build/src/worker/pipeline/accumulate.js +53 -0
- package/build/src/worker/pipeline/accumulate.js.map +1 -0
- package/build/src/worker/pipeline/authenticate.d.ts +4 -0
- package/build/src/worker/pipeline/authenticate.d.ts.map +1 -0
- package/build/src/worker/pipeline/authenticate.js +53 -0
- package/build/src/worker/pipeline/authenticate.js.map +1 -0
- package/build/src/worker/pipeline/email.d.ts +4 -0
- package/build/src/worker/pipeline/email.d.ts.map +1 -0
- package/build/src/worker/pipeline/email.js +149 -0
- package/build/src/worker/pipeline/email.js.map +1 -0
- package/build/src/worker/pipeline/format.d.ts +5 -0
- package/build/src/worker/pipeline/format.d.ts.map +1 -0
- package/build/src/worker/pipeline/format.js +48 -0
- package/build/src/worker/pipeline/format.js.map +1 -0
- package/build/src/worker/pipeline/interpret.d.ts +4 -0
- package/build/src/worker/pipeline/interpret.d.ts.map +1 -0
- package/build/src/worker/pipeline/interpret.js +30 -0
- package/build/src/worker/pipeline/interpret.js.map +1 -0
- package/build/src/worker/pipeline/parse.d.ts +4 -0
- package/build/src/worker/pipeline/parse.d.ts.map +1 -0
- package/build/src/worker/pipeline/parse.js +59 -0
- package/build/src/worker/pipeline/parse.js.map +1 -0
- package/build/src/worker/pipeline/receive.d.ts +4 -0
- package/build/src/worker/pipeline/receive.d.ts.map +1 -0
- package/build/src/worker/pipeline/receive.js +52 -0
- package/build/src/worker/pipeline/receive.js.map +1 -0
- package/build/src/worker/pipeline/respond.d.ts +4 -0
- package/build/src/worker/pipeline/respond.d.ts.map +1 -0
- package/build/src/worker/pipeline/respond.js +48 -0
- package/build/src/worker/pipeline/respond.js.map +1 -0
- package/build/src/worker/pipeline/route.d.ts +5 -0
- package/build/src/worker/pipeline/route.d.ts.map +1 -0
- package/build/src/worker/pipeline/route.js +23 -0
- package/build/src/worker/pipeline/route.js.map +1 -0
- package/build/src/worker/pipeline/send.d.ts +4 -0
- package/build/src/worker/pipeline/send.d.ts.map +1 -0
- package/build/src/worker/pipeline/send.js +156 -0
- package/build/src/worker/pipeline/send.js.map +1 -0
- package/build/src/worker/pipeline/split.d.ts +4 -0
- package/build/src/worker/pipeline/split.d.ts.map +1 -0
- package/build/src/worker/pipeline/split.js +40 -0
- package/build/src/worker/pipeline/split.js.map +1 -0
- package/package.json +95 -2
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://nrp.cbnventures.io/">
|
|
3
|
+
<picture>
|
|
4
|
+
<img alt="Reverse Proxy for ntfy" src="https://nrp.cbnventures.io/images/logo.svg" height="128">
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
<h1>Reverse Proxy for ntfy</h1>
|
|
8
|
+
<a href="https://www.npmjs.com/package/ntfy-reverse-proxy">
|
|
9
|
+
<img alt="npm Package" src="https://img.shields.io/npm/v/ntfy-reverse-proxy?style=for-the-badge&logo=npm&logoColor=%23ffffff&color=%23b25da6">
|
|
10
|
+
</a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/ntfy-reverse-proxy">
|
|
12
|
+
<img alt="npm Downloads" src="https://img.shields.io/npm/dt/ntfy-reverse-proxy?style=for-the-badge&logo=npm&logoColor=%23ffffff&color=%236688c3">
|
|
13
|
+
</a>
|
|
14
|
+
<a href="https://github.com/cbnventures/ntfy-reverse-proxy/releases">
|
|
15
|
+
<img alt="GitHub Releases" src="https://img.shields.io/github/v/release/cbnventures/ntfy-reverse-proxy?style=for-the-badge&logo=github&logoColor=%23ffffff&color=%23b25da6">
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://github.com/cbnventures/ntfy-reverse-proxy">
|
|
18
|
+
<img alt="GitHub Top Languages" src="https://img.shields.io/github/languages/top/cbnventures/ntfy-reverse-proxy?style=for-the-badge&logo=github&logoColor=%23ffffff&color=%236688c3">
|
|
19
|
+
</a>
|
|
20
|
+
<a href="https://github.com/cbnventures/ntfy-reverse-proxy/blob/HEAD/LICENSE">
|
|
21
|
+
<img alt="GitHub License" src="https://img.shields.io/github/license/cbnventures/ntfy-reverse-proxy?style=for-the-badge&logo=googledocs&logoColor=%23ffffff&color=%2348a56a">
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://github.com/sponsors/cbnventures">
|
|
24
|
+
<img alt="Become a GitHub Sponsor" src="https://img.shields.io/badge/github-sponsor-gray?style=for-the-badge&logo=githubsponsors&logoColor=%23ffffff&color=%23eaaf41">
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://www.paypal.com/biz/profile/cbnventures">
|
|
27
|
+
<img alt="Donate via PayPal" src="https://img.shields.io/badge/paypal-donate-gray?style=for-the-badge&logo=paypal&logoColor=%23ffffff&color=%23ce4a4a">
|
|
28
|
+
</a>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
## Introduction
|
|
32
|
+
|
|
33
|
+
Webhook and email notification gateway with built-in interpreters (Statuspage.io, Synology DSM, Seerr, pfSense, UniFi, ntfy JSON, plain text), automatic primary/fallback server failover, and smart message splitting, powered by Cloudflare Workers and Cloudflare Email Routing. Interactive CLI for configuration, validation, and deployment.
|
|
34
|
+
|
|
35
|
+
## Documentation
|
|
36
|
+
|
|
37
|
+
To get started, visit [https://nrp.cbnventures.io/](https://nrp.cbnventures.io/) to view the full documentation.
|
|
38
|
+
|
|
39
|
+
## Credits and Appreciation
|
|
40
|
+
|
|
41
|
+
If you find value in the ongoing development of this project and wish to express your appreciation, you have the option to:
|
|
42
|
+
|
|
43
|
+
- Become our supporter on [GitHub Sponsors](https://github.com/sponsors/cbnventures)
|
|
44
|
+
- Make a one-time donation through [PayPal](https://www.paypal.com/biz/profile/cbnventures)
|
|
45
|
+
|
|
46
|
+
A special thanks to our contributors and supporters:
|
|
47
|
+
|
|
48
|
+
- [Jacky Liang](https://www.mrjackyliang.com/)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CliCommandsConfigIoLoadConfigConfigPath, CliCommandsConfigIoLoadConfigReturn, CliCommandsConfigIoSaveConfigConfig, CliCommandsConfigIoSaveConfigConfigPath, CliCommandsConfigIoSaveConfigReturns } from '../../types/cli/commands/config-io.d.ts';
|
|
2
|
+
declare function loadConfig(configPath: CliCommandsConfigIoLoadConfigConfigPath): CliCommandsConfigIoLoadConfigReturn;
|
|
3
|
+
declare function saveConfig(configPath: CliCommandsConfigIoSaveConfigConfigPath, config: CliCommandsConfigIoSaveConfigConfig): CliCommandsConfigIoSaveConfigReturns;
|
|
4
|
+
export { loadConfig, saveConfig, };
|
|
5
|
+
//# sourceMappingURL=config-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-io.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/config-io.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,uCAAuC,EACvC,mCAAmC,EAKnC,mCAAmC,EACnC,uCAAuC,EACvC,oCAAoC,EACrC,MAAM,yCAAyC,CAAC;AAWjD,iBAAS,UAAU,CAAC,UAAU,EAAE,uCAAuC,GAAG,mCAAmC,CAE5G;AAkCD,iBAAS,UAAU,CAAC,UAAU,EAAE,uCAAuC,EAAE,MAAM,EAAE,mCAAmC,GAAG,oCAAoC,CAI1J;AAED,OAAO,EACL,UAAU,EACV,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
function loadConfig(configPath) {
|
|
3
|
+
return JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
4
|
+
}
|
|
5
|
+
function normalizeConfig(config) {
|
|
6
|
+
const sortedServers = [...config['servers']].sort((a, b) => a['name'].localeCompare(b['name']));
|
|
7
|
+
const sortedContexts = [...config['contexts']].sort((a, b) => a['name'].localeCompare(b['name']));
|
|
8
|
+
return {
|
|
9
|
+
servers: sortedServers,
|
|
10
|
+
contexts: sortedContexts,
|
|
11
|
+
settings: config['settings'],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function saveConfig(configPath, config) {
|
|
15
|
+
writeFileSync(configPath, `${JSON.stringify(normalizeConfig(config), null, 2)}\n`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
export { loadConfig, saveConfig, };
|
|
19
|
+
//# sourceMappingURL=config-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-io.js","sourceRoot":"","sources":["../../../../src/cli/commands/config-io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAuBjD,SAAS,UAAU,CAAC,UAAmD;IACrE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AACvD,CAAC;AAUD,SAAS,eAAe,CAAC,MAAgD;IACvE,MAAM,aAAa,GAAoD,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAChG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAC7C,CAAC;IAEF,MAAM,cAAc,GAAqD,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACnG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAC7C,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,QAAQ,EAAE,cAAc;QACxB,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC;KAC7B,CAAC;AACJ,CAAC;AAUD,SAAS,UAAU,CAAC,UAAmD,EAAE,MAA2C;IAClH,aAAa,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAEnF,OAAO;AACT,CAAC;AAED,OAAO,EACL,UAAU,EACV,UAAU,GACX,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CliCommandsContextAddContextConfigPath, CliCommandsContextAddContextContext, CliCommandsContextAddContextReturn, CliCommandsContextEditContextConfigPath, CliCommandsContextEditContextName, CliCommandsContextEditContextReturn, CliCommandsContextEditContextUpdates, CliCommandsContextGenerateIdReturn, CliCommandsContextGenerateTokenReturn, CliCommandsContextListContextsConfigPath, CliCommandsContextListContextsReturn, CliCommandsContextRemoveContextConfigPath, CliCommandsContextRemoveContextName, CliCommandsContextRemoveContextReturn } from '../../types/cli/commands/context.d.ts';
|
|
2
|
+
declare function addContext(configPath: CliCommandsContextAddContextConfigPath, context: CliCommandsContextAddContextContext): CliCommandsContextAddContextReturn;
|
|
3
|
+
declare function listContexts(configPath: CliCommandsContextListContextsConfigPath): CliCommandsContextListContextsReturn;
|
|
4
|
+
declare function editContext(configPath: CliCommandsContextEditContextConfigPath, name: CliCommandsContextEditContextName, updates: CliCommandsContextEditContextUpdates): CliCommandsContextEditContextReturn;
|
|
5
|
+
declare function removeContext(configPath: CliCommandsContextRemoveContextConfigPath, name: CliCommandsContextRemoveContextName): CliCommandsContextRemoveContextReturn;
|
|
6
|
+
declare function generateId(): CliCommandsContextGenerateIdReturn;
|
|
7
|
+
declare function generateToken(): CliCommandsContextGenerateTokenReturn;
|
|
8
|
+
export { addContext, editContext, generateId, generateToken, listContexts, removeContext, };
|
|
9
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/context.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAEV,sCAAsC,EACtC,mCAAmC,EAOnC,kCAAkC,EAGlC,uCAAuC,EAIvC,iCAAiC,EAGjC,mCAAmC,EAEnC,oCAAoC,EACpC,kCAAkC,EAMlC,qCAAqC,EACrC,wCAAwC,EACxC,oCAAoC,EAQpC,yCAAyC,EAEzC,mCAAmC,EACnC,qCAAqC,EACtC,MAAM,uCAAuC,CAAC;AAU/C,iBAAS,UAAU,CAAC,UAAU,EAAE,sCAAsC,EAAE,OAAO,EAAE,mCAAmC,GAAG,kCAAkC,CA0CxJ;AAUD,iBAAS,YAAY,CAAC,UAAU,EAAE,wCAAwC,GAAG,oCAAoC,CAEhH;AAUD,iBAAS,WAAW,CAAC,UAAU,EAAE,uCAAuC,EAAE,IAAI,EAAE,iCAAiC,EAAE,OAAO,EAAE,oCAAoC,GAAG,mCAAmC,CA0CrM;AAUD,iBAAS,aAAa,CAAC,UAAU,EAAE,yCAAyC,EAAE,IAAI,EAAE,mCAAmC,GAAG,qCAAqC,CAS9J;AA0DD,iBAAS,UAAU,IAAI,kCAAkC,CAExD;AAUD,iBAAS,aAAa,IAAI,qCAAqC,CAE9D;AAED,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,GACd,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { randomBytes } from 'crypto';
|
|
2
|
+
import { LIB_REGEX_NON_ALPHANUMERIC } from '../../lib/regex.js';
|
|
3
|
+
import { configSchema } from '../../lib/schema.js';
|
|
4
|
+
import { loadConfig, saveConfig } from './config-io.js';
|
|
5
|
+
function addContext(configPath, context) {
|
|
6
|
+
const config = configSchema.parse(loadConfig(configPath));
|
|
7
|
+
const duplicateName = config['contexts'].some((existingContext) => existingContext['name'] === context['name']);
|
|
8
|
+
if (duplicateName === true) {
|
|
9
|
+
throw new Error(`Context with name "${context['name']}" already exists.`);
|
|
10
|
+
}
|
|
11
|
+
let currentContext = context;
|
|
12
|
+
const existingIds = new Set(config['contexts'].map((existingContext) => existingContext['id']));
|
|
13
|
+
if (existingIds.has(currentContext['id']) === true) {
|
|
14
|
+
let newId = generateId();
|
|
15
|
+
while (existingIds.has(newId) === true) {
|
|
16
|
+
newId = generateId();
|
|
17
|
+
}
|
|
18
|
+
currentContext = {
|
|
19
|
+
...currentContext,
|
|
20
|
+
id: newId,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const serverNames = config['servers'].map((server) => server['name']);
|
|
24
|
+
const missingServer = currentContext['servers'].find((serverName) => serverNames.includes(serverName) === false);
|
|
25
|
+
if (missingServer !== undefined) {
|
|
26
|
+
throw new Error(`Server "${missingServer}" does not exist.`);
|
|
27
|
+
}
|
|
28
|
+
if (serverNames.includes(currentContext['primary_server']) === false) {
|
|
29
|
+
throw new Error(`Server "${currentContext['primary_server']}" does not exist.`);
|
|
30
|
+
}
|
|
31
|
+
const ordered = orderContextKeys(currentContext);
|
|
32
|
+
config['contexts'].push(ordered);
|
|
33
|
+
saveConfig(configPath, config);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
function listContexts(configPath) {
|
|
37
|
+
return configSchema.parse(loadConfig(configPath))['contexts'];
|
|
38
|
+
}
|
|
39
|
+
function editContext(configPath, name, updates) {
|
|
40
|
+
const config = configSchema.parse(loadConfig(configPath));
|
|
41
|
+
const index = config['contexts'].findIndex((context) => context['name'] === name);
|
|
42
|
+
if (index === -1) {
|
|
43
|
+
throw new Error(`Context with name "${name}" not found.`);
|
|
44
|
+
}
|
|
45
|
+
let updatedUpdates = updates;
|
|
46
|
+
if (updatedUpdates['id'] !== undefined) {
|
|
47
|
+
let newId = updatedUpdates['id'];
|
|
48
|
+
const existingIds = new Set(config['contexts'].filter((_context, i) => i !== index).map((context) => context['id']));
|
|
49
|
+
if (existingIds.has(newId) === true) {
|
|
50
|
+
newId = generateId();
|
|
51
|
+
while (existingIds.has(newId) === true) {
|
|
52
|
+
newId = generateId();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
updatedUpdates = {
|
|
56
|
+
...updatedUpdates,
|
|
57
|
+
id: newId,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const merged = {
|
|
61
|
+
...config['contexts'][index],
|
|
62
|
+
...updatedUpdates,
|
|
63
|
+
};
|
|
64
|
+
const ordered = orderContextKeys(merged);
|
|
65
|
+
Reflect.set(config['contexts'], index, ordered);
|
|
66
|
+
saveConfig(configPath, config);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
function removeContext(configPath, name) {
|
|
70
|
+
const config = configSchema.parse(loadConfig(configPath));
|
|
71
|
+
const filtered = config['contexts'].filter((context) => context['name'] !== name);
|
|
72
|
+
Reflect.set(config, 'contexts', filtered);
|
|
73
|
+
saveConfig(configPath, config);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
function orderContextKeys(context) {
|
|
77
|
+
const type = context['type'];
|
|
78
|
+
const name = context['name'];
|
|
79
|
+
const id = context['id'];
|
|
80
|
+
const rest = {
|
|
81
|
+
...context,
|
|
82
|
+
};
|
|
83
|
+
Reflect.deleteProperty(rest, 'type');
|
|
84
|
+
Reflect.deleteProperty(rest, 'name');
|
|
85
|
+
Reflect.deleteProperty(rest, 'id');
|
|
86
|
+
return {
|
|
87
|
+
type,
|
|
88
|
+
name,
|
|
89
|
+
id,
|
|
90
|
+
...rest,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function generateRandomString(length, lowercase = false) {
|
|
94
|
+
let result = '';
|
|
95
|
+
while (result['length'] < length) {
|
|
96
|
+
const chunk = randomBytes(48).toString('base64').replace(new RegExp(LIB_REGEX_NON_ALPHANUMERIC, 'g'), '');
|
|
97
|
+
result += (lowercase === true) ? chunk.toLowerCase() : chunk;
|
|
98
|
+
}
|
|
99
|
+
return result.slice(0, length);
|
|
100
|
+
}
|
|
101
|
+
function generateId() {
|
|
102
|
+
return generateRandomString(20, true);
|
|
103
|
+
}
|
|
104
|
+
function generateToken() {
|
|
105
|
+
return generateRandomString(64);
|
|
106
|
+
}
|
|
107
|
+
export { addContext, editContext, generateId, generateToken, listContexts, removeContext, };
|
|
108
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/cli/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAuDxD,SAAS,UAAU,CAAC,UAAkD,EAAE,OAA4C;IAClH,MAAM,MAAM,GAAuC,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9F,MAAM,aAAa,GAA8C,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3J,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,sBAAsB,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,cAAc,GAA+C,OAAO,CAAC;IACzE,MAAM,WAAW,GAA4C,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC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,IAAI;QACJ,EAAE;QACF,GAAG,IAAI;KACoC,CAAC;AAChD,CAAC;AAUD,SAAS,oBAAoB,CAAC,MAAoD,EAAE,YAA6D,KAAK;IACpJ,IAAI,MAAM,GAAiD,EAAE,CAAC;IAE9D,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,EAAE,CAAC;QACjC,MAAM,KAAK,GAAgD,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,0BAA0B,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;QAEvJ,MAAM,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACjC,CAAC;AAUD,SAAS,UAAU;IACjB,OAAO,oBAAoB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACxC,CAAC;AAUD,SAAS,aAAa;IACpB,OAAO,oBAAoB,CAAC,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,OAAO,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,GACd,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CliCommandsDeployDeployConfigPath, CliCommandsDeployDeployInteractive, CliCommandsDeployDeployReturn } from '../../types/cli/commands/deploy.d.ts';
|
|
2
|
+
declare function deploy(configPath: CliCommandsDeployDeployConfigPath, interactive?: CliCommandsDeployDeployInteractive): CliCommandsDeployDeployReturn;
|
|
3
|
+
export { deploy, };
|
|
4
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAoBV,iCAAiC,EAGjC,kCAAkC,EAIlC,6BAA6B,EAyG9B,MAAM,sCAAsC,CAAC;AAe9C,iBAAe,MAAM,CAAC,UAAU,EAAE,iCAAiC,EAAE,WAAW,GAAE,kCAA0C,GAAG,6BAA6B,CA8F3J;AAyrBD,OAAO,EACL,MAAM,GACP,CAAC"}
|