@apso/cli 0.19.0 → 0.20.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.
@@ -37,9 +37,11 @@ import { <%= it.authConfig.accountUserEntity %> } from '../<%= it.authConfig.acc
37
37
  *
38
38
  * Usage:
39
39
  * 1. Import GuardsModule in your AppModule
40
- * 2. Guards are NOT enabled globally by default (for backward compatibility)
41
- * 3. To enable guards globally, uncomment the APP_GUARD providers below
42
- * 4. Or apply guards selectively using @UseGuards(AuthGuard, ScopeGuard) on controllers
40
+ * 2. Guards are ENABLED GLOBALLY BY DEFAULT (secure by default) because this
41
+ * schema declares an auth model / scoped entities. Requests are authenticated
42
+ * and tenant-scoped unless a route opts out with @Public().
43
+ * 3. Services with no auth model generate no guards and rely on the API Gateway
44
+ * API key at the edge.
43
45
  *
44
46
  <% if (it.authConfig) { %>
45
47
  * AuthGuard:
@@ -88,18 +90,22 @@ import { <%= it.authConfig.accountUserEntity %> } from '../<%= it.authConfig.acc
88
90
  <% if (it.scopedEntities && it.scopedEntities.length > 0) { %>
89
91
  ScopeGuard,
90
92
  <% } %>
91
- // UNCOMMENT BELOW TO ENABLE GLOBAL GUARDS
93
+ // Global guards are ENABLED BY DEFAULT (secure by default) whenever the
94
+ // schema declares an auth model / scoped entities. Services with NO auth
95
+ // config generate no guards at all and are protected at the edge by the
96
+ // API Gateway API key — so this does not conflict with that setup. Use the
97
+ // @Public() decorator to opt an individual route out of authentication.
92
98
  <% if (it.authConfig) { %>
93
- // {
94
- // provide: APP_GUARD,
95
- // useClass: AuthGuard,
96
- // },
99
+ {
100
+ provide: APP_GUARD,
101
+ useClass: AuthGuard,
102
+ },
97
103
  <% } %>
98
104
  <% if (it.scopedEntities && it.scopedEntities.length > 0) { %>
99
- // {
100
- // provide: APP_GUARD,
101
- // useClass: ScopeGuard,
102
- // },
105
+ {
106
+ provide: APP_GUARD,
107
+ useClass: ScopeGuard,
108
+ },
103
109
  <% } %>
104
110
  ],
105
111
  exports: [
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Upgrade-on-limit flow.
3
+ *
4
+ * When the platform rejects an action because the workspace hit a plan limit
5
+ * (e.g. the free-tier service cap), we surface a friendly prompt that opens the
6
+ * upgrade page in the browser and retries once the user is done — mirroring the
7
+ * "you've hit a limit, upgrade?" flow developers expect from modern CLIs.
8
+ */
9
+ import { ApiClientError } from "./api/client";
10
+ /**
11
+ * Prompt the user to upgrade after a limit error, open the upgrade page, and
12
+ * wait for them to finish. Returns true if the caller should retry the action.
13
+ */
14
+ export declare function promptUpgrade(error: ApiClientError): Promise<boolean>;
15
+ /**
16
+ * Run an action; if it fails with an upgradeable plan-limit error, offer to
17
+ * upgrade and retry once.
18
+ */
19
+ export declare function withUpgradeRetry<T>(action: () => Promise<T>): Promise<T>;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * Upgrade-on-limit flow.
4
+ *
5
+ * When the platform rejects an action because the workspace hit a plan limit
6
+ * (e.g. the free-tier service cap), we surface a friendly prompt that opens the
7
+ * upgrade page in the browser and retries once the user is done — mirroring the
8
+ * "you've hit a limit, upgrade?" flow developers expect from modern CLIs.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.withUpgradeRetry = exports.promptUpgrade = void 0;
12
+ const tslib_1 = require("tslib");
13
+ const child_process_1 = require("child_process");
14
+ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
15
+ const client_1 = require("./api/client");
16
+ const config_1 = require("./config");
17
+ /**
18
+ * Open a URL in the default browser (best-effort).
19
+ */
20
+ function openBrowser(url) {
21
+ return new Promise((resolve) => {
22
+ const platform = process.platform;
23
+ const command = platform === "darwin"
24
+ ? `open "${url}"`
25
+ : platform === "win32"
26
+ ? `start "" "${url}"`
27
+ : `xdg-open "${url}"`;
28
+ (0, child_process_1.exec)(command, () => resolve());
29
+ });
30
+ }
31
+ /**
32
+ * Prompt the user to upgrade after a limit error, open the upgrade page, and
33
+ * wait for them to finish. Returns true if the caller should retry the action.
34
+ */
35
+ async function promptUpgrade(error) {
36
+ const config = config_1.globalConfig.read();
37
+ const upgradeUrl = `${config.webUrl}${error.upgradeUrl || "/billing/upgrade"}`;
38
+ console.log("");
39
+ console.log(` ⚠ ${error.message || "You've reached a plan limit."}`);
40
+ console.log("");
41
+ const { proceed } = await inquirer_1.default.prompt([
42
+ {
43
+ type: "confirm",
44
+ name: "proceed",
45
+ message: "Open the upgrade page in your browser?",
46
+ default: true,
47
+ },
48
+ ]);
49
+ if (!proceed) {
50
+ console.log(` You can upgrade any time at: ${upgradeUrl}`);
51
+ return false;
52
+ }
53
+ console.log("");
54
+ console.log(` Opening ${upgradeUrl}`);
55
+ console.log(" If the browser doesn't open, visit the URL above.");
56
+ await openBrowser(upgradeUrl);
57
+ const { done } = await inquirer_1.default.prompt([
58
+ {
59
+ type: "confirm",
60
+ name: "done",
61
+ message: "Press enter once your upgrade is complete to retry",
62
+ default: true,
63
+ },
64
+ ]);
65
+ return done;
66
+ }
67
+ exports.promptUpgrade = promptUpgrade;
68
+ /**
69
+ * Run an action; if it fails with an upgradeable plan-limit error, offer to
70
+ * upgrade and retry once.
71
+ */
72
+ async function withUpgradeRetry(action) {
73
+ try {
74
+ return await action();
75
+ }
76
+ catch (error) {
77
+ if (error instanceof client_1.ApiClientError && error.isLimitError()) {
78
+ const retry = await promptUpgrade(error);
79
+ if (retry) {
80
+ return action();
81
+ }
82
+ }
83
+ throw error;
84
+ }
85
+ }
86
+ exports.withUpgradeRetry = withUpgradeRetry;
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@apso/cli",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@apso/cli",
9
- "version": "0.19.0",
9
+ "version": "0.20.0",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
+ "@biomejs/biome": "^1.9.4",
12
13
  "@electric-sql/pglite": "^0.2.17",
13
14
  "@modelcontextprotocol/sdk": "^1.29.0",
14
15
  "@oclif/core": "^2",
@@ -706,6 +707,161 @@
706
707
  "dev": true,
707
708
  "peer": true
708
709
  },
710
+ "node_modules/@biomejs/biome": {
711
+ "version": "1.9.4",
712
+ "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz",
713
+ "integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==",
714
+ "hasInstallScript": true,
715
+ "license": "MIT OR Apache-2.0",
716
+ "bin": {
717
+ "biome": "bin/biome"
718
+ },
719
+ "engines": {
720
+ "node": ">=14.21.3"
721
+ },
722
+ "funding": {
723
+ "type": "opencollective",
724
+ "url": "https://opencollective.com/biome"
725
+ },
726
+ "optionalDependencies": {
727
+ "@biomejs/cli-darwin-arm64": "1.9.4",
728
+ "@biomejs/cli-darwin-x64": "1.9.4",
729
+ "@biomejs/cli-linux-arm64": "1.9.4",
730
+ "@biomejs/cli-linux-arm64-musl": "1.9.4",
731
+ "@biomejs/cli-linux-x64": "1.9.4",
732
+ "@biomejs/cli-linux-x64-musl": "1.9.4",
733
+ "@biomejs/cli-win32-arm64": "1.9.4",
734
+ "@biomejs/cli-win32-x64": "1.9.4"
735
+ }
736
+ },
737
+ "node_modules/@biomejs/cli-darwin-arm64": {
738
+ "version": "1.9.4",
739
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz",
740
+ "integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==",
741
+ "cpu": [
742
+ "arm64"
743
+ ],
744
+ "license": "MIT OR Apache-2.0",
745
+ "optional": true,
746
+ "os": [
747
+ "darwin"
748
+ ],
749
+ "engines": {
750
+ "node": ">=14.21.3"
751
+ }
752
+ },
753
+ "node_modules/@biomejs/cli-darwin-x64": {
754
+ "version": "1.9.4",
755
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz",
756
+ "integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==",
757
+ "cpu": [
758
+ "x64"
759
+ ],
760
+ "license": "MIT OR Apache-2.0",
761
+ "optional": true,
762
+ "os": [
763
+ "darwin"
764
+ ],
765
+ "engines": {
766
+ "node": ">=14.21.3"
767
+ }
768
+ },
769
+ "node_modules/@biomejs/cli-linux-arm64": {
770
+ "version": "1.9.4",
771
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz",
772
+ "integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==",
773
+ "cpu": [
774
+ "arm64"
775
+ ],
776
+ "license": "MIT OR Apache-2.0",
777
+ "optional": true,
778
+ "os": [
779
+ "linux"
780
+ ],
781
+ "engines": {
782
+ "node": ">=14.21.3"
783
+ }
784
+ },
785
+ "node_modules/@biomejs/cli-linux-arm64-musl": {
786
+ "version": "1.9.4",
787
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz",
788
+ "integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==",
789
+ "cpu": [
790
+ "arm64"
791
+ ],
792
+ "license": "MIT OR Apache-2.0",
793
+ "optional": true,
794
+ "os": [
795
+ "linux"
796
+ ],
797
+ "engines": {
798
+ "node": ">=14.21.3"
799
+ }
800
+ },
801
+ "node_modules/@biomejs/cli-linux-x64": {
802
+ "version": "1.9.4",
803
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz",
804
+ "integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==",
805
+ "cpu": [
806
+ "x64"
807
+ ],
808
+ "license": "MIT OR Apache-2.0",
809
+ "optional": true,
810
+ "os": [
811
+ "linux"
812
+ ],
813
+ "engines": {
814
+ "node": ">=14.21.3"
815
+ }
816
+ },
817
+ "node_modules/@biomejs/cli-linux-x64-musl": {
818
+ "version": "1.9.4",
819
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz",
820
+ "integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==",
821
+ "cpu": [
822
+ "x64"
823
+ ],
824
+ "license": "MIT OR Apache-2.0",
825
+ "optional": true,
826
+ "os": [
827
+ "linux"
828
+ ],
829
+ "engines": {
830
+ "node": ">=14.21.3"
831
+ }
832
+ },
833
+ "node_modules/@biomejs/cli-win32-arm64": {
834
+ "version": "1.9.4",
835
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz",
836
+ "integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==",
837
+ "cpu": [
838
+ "arm64"
839
+ ],
840
+ "license": "MIT OR Apache-2.0",
841
+ "optional": true,
842
+ "os": [
843
+ "win32"
844
+ ],
845
+ "engines": {
846
+ "node": ">=14.21.3"
847
+ }
848
+ },
849
+ "node_modules/@biomejs/cli-win32-x64": {
850
+ "version": "1.9.4",
851
+ "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz",
852
+ "integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==",
853
+ "cpu": [
854
+ "x64"
855
+ ],
856
+ "license": "MIT OR Apache-2.0",
857
+ "optional": true,
858
+ "os": [
859
+ "win32"
860
+ ],
861
+ "engines": {
862
+ "node": ">=14.21.3"
863
+ }
864
+ },
709
865
  "node_modules/@cspotcode/source-map-support": {
710
866
  "version": "0.8.1",
711
867
  "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.19.0",
2
+ "version": "0.20.0",
3
3
  "commands": {
4
4
  "config": {
5
5
  "id": "config",
@@ -69,6 +69,25 @@
69
69
  "type": "boolean",
70
70
  "description": "Skip local migration validation",
71
71
  "allowNo": false
72
+ },
73
+ "skip-push": {
74
+ "name": "skip-push",
75
+ "type": "boolean",
76
+ "description": "Skip uploading + pushing code (redeploy current code)",
77
+ "allowNo": false
78
+ },
79
+ "repo": {
80
+ "name": "repo",
81
+ "type": "option",
82
+ "description": "GitHub repo (owner/name) to connect when none is linked yet",
83
+ "multiple": false
84
+ },
85
+ "branch": {
86
+ "name": "branch",
87
+ "type": "option",
88
+ "description": "Branch to push to",
89
+ "multiple": false,
90
+ "default": "main"
72
91
  }
73
92
  },
74
93
  "args": {}
@@ -512,6 +531,42 @@
512
531
  },
513
532
  "args": {}
514
533
  },
534
+ "github:connect": {
535
+ "id": "github:connect",
536
+ "description": "Connect a GitHub account to push generated code to a repo",
537
+ "strict": true,
538
+ "pluginName": "@apso/cli",
539
+ "pluginAlias": "@apso/cli",
540
+ "pluginType": "core",
541
+ "aliases": [],
542
+ "hiddenAliases": [],
543
+ "examples": [
544
+ "$ apso github connect"
545
+ ],
546
+ "flags": {
547
+ "help": {
548
+ "name": "help",
549
+ "type": "boolean",
550
+ "char": "h",
551
+ "description": "Show CLI help.",
552
+ "allowNo": false
553
+ },
554
+ "workspace-id": {
555
+ "name": "workspace-id",
556
+ "type": "option",
557
+ "description": "Workspace id to connect (defaults to the linked project)",
558
+ "multiple": false
559
+ },
560
+ "timeout": {
561
+ "name": "timeout",
562
+ "type": "option",
563
+ "description": "Seconds to wait for the connection",
564
+ "multiple": false,
565
+ "default": 300
566
+ }
567
+ },
568
+ "args": {}
569
+ },
515
570
  "mcp:serve": {
516
571
  "id": "mcp:serve",
517
572
  "description": "Start an MCP server exposing Apso tools over stdio. Used by AI coding agents (Claude Code, Cursor, etc.) to design schemas, generate APIs, and deploy backends.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apso/cli",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "mcpName": "io.github.apsoai/apso",
5
5
  "description": "Apso CLI",
6
6
  "author": "Apso by Mavric - @mavric",
@@ -24,6 +24,7 @@
24
24
  "/oclif.manifest.json"
25
25
  ],
26
26
  "dependencies": {
27
+ "@biomejs/biome": "^1.9.4",
27
28
  "@electric-sql/pglite": "^0.2.17",
28
29
  "@modelcontextprotocol/sdk": "^1.29.0",
29
30
  "@oclif/core": "^2",
@@ -107,7 +108,7 @@
107
108
  }
108
109
  },
109
110
  "scripts": {
110
- "post-build": "copyfiles -u 1 src/**/*.eta dist/",
111
+ "post-build": "copyfiles -u 1 \"src/**/*.eta\" \"src/lib/biome/*.json\" dist/",
111
112
  "build": "shx rm -rf dist && tsc -b && npm run post-build",
112
113
  "lint": "eslint . --ext .ts --config .eslintrc",
113
114
  "format": "prettier \"{src,test}/**/*.ts\" --write",