@polardbx/pxbaas 0.0.0-stage → 0.1.0-beta.2

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.
Files changed (267) hide show
  1. package/README.md +107 -2
  2. package/bin/pxbaas.js +13 -0
  3. package/dist/app/preflight.d.ts +38 -0
  4. package/dist/app/preflight.d.ts.map +1 -0
  5. package/dist/app/preflight.js +79 -0
  6. package/dist/app/preflight.js.map +1 -0
  7. package/dist/app/spec-lint.d.ts +45 -0
  8. package/dist/app/spec-lint.d.ts.map +1 -0
  9. package/dist/app/spec-lint.js +407 -0
  10. package/dist/app/spec-lint.js.map +1 -0
  11. package/dist/app/templates.d.ts +143 -0
  12. package/dist/app/templates.d.ts.map +1 -0
  13. package/dist/app/templates.js +151 -0
  14. package/dist/app/templates.js.map +1 -0
  15. package/dist/cli/root.d.ts +3 -0
  16. package/dist/cli/root.d.ts.map +1 -0
  17. package/dist/cli/root.js +69 -0
  18. package/dist/cli/root.js.map +1 -0
  19. package/dist/commands/app/index.d.ts +8 -0
  20. package/dist/commands/app/index.d.ts.map +1 -0
  21. package/dist/commands/app/index.js +1476 -0
  22. package/dist/commands/app/index.js.map +1 -0
  23. package/dist/commands/auth/index.d.ts +3 -0
  24. package/dist/commands/auth/index.d.ts.map +1 -0
  25. package/dist/commands/auth/index.js +198 -0
  26. package/dist/commands/auth/index.js.map +1 -0
  27. package/dist/commands/completion/index.d.ts +3 -0
  28. package/dist/commands/completion/index.d.ts.map +1 -0
  29. package/dist/commands/completion/index.js +10 -0
  30. package/dist/commands/completion/index.js.map +1 -0
  31. package/dist/commands/data/index.d.ts +3 -0
  32. package/dist/commands/data/index.d.ts.map +1 -0
  33. package/dist/commands/data/index.js +245 -0
  34. package/dist/commands/data/index.js.map +1 -0
  35. package/dist/commands/db/index.d.ts +15 -0
  36. package/dist/commands/db/index.d.ts.map +1 -0
  37. package/dist/commands/db/index.js +389 -0
  38. package/dist/commands/db/index.js.map +1 -0
  39. package/dist/commands/doctor/index.d.ts +3 -0
  40. package/dist/commands/doctor/index.d.ts.map +1 -0
  41. package/dist/commands/doctor/index.js +305 -0
  42. package/dist/commands/doctor/index.js.map +1 -0
  43. package/dist/commands/functions/delete.d.ts +3 -0
  44. package/dist/commands/functions/delete.d.ts.map +1 -0
  45. package/dist/commands/functions/delete.js +55 -0
  46. package/dist/commands/functions/delete.js.map +1 -0
  47. package/dist/commands/functions/deploy.d.ts +3 -0
  48. package/dist/commands/functions/deploy.d.ts.map +1 -0
  49. package/dist/commands/functions/deploy.js +118 -0
  50. package/dist/commands/functions/deploy.js.map +1 -0
  51. package/dist/commands/functions/index.d.ts +3 -0
  52. package/dist/commands/functions/index.d.ts.map +1 -0
  53. package/dist/commands/functions/index.js +15 -0
  54. package/dist/commands/functions/index.js.map +1 -0
  55. package/dist/commands/functions/list.d.ts +6 -0
  56. package/dist/commands/functions/list.d.ts.map +1 -0
  57. package/dist/commands/functions/list.js +63 -0
  58. package/dist/commands/functions/list.js.map +1 -0
  59. package/dist/commands/functions/new.d.ts +3 -0
  60. package/dist/commands/functions/new.d.ts.map +1 -0
  61. package/dist/commands/functions/new.js +57 -0
  62. package/dist/commands/functions/new.js.map +1 -0
  63. package/dist/commands/gen/index.d.ts +3 -0
  64. package/dist/commands/gen/index.d.ts.map +1 -0
  65. package/dist/commands/gen/index.js +320 -0
  66. package/dist/commands/gen/index.js.map +1 -0
  67. package/dist/commands/instance/index.d.ts +8 -0
  68. package/dist/commands/instance/index.d.ts.map +1 -0
  69. package/dist/commands/instance/index.js +361 -0
  70. package/dist/commands/instance/index.js.map +1 -0
  71. package/dist/commands/login/index.d.ts +3 -0
  72. package/dist/commands/login/index.d.ts.map +1 -0
  73. package/dist/commands/login/index.js +160 -0
  74. package/dist/commands/login/index.js.map +1 -0
  75. package/dist/commands/login/login.d.ts +3 -0
  76. package/dist/commands/login/login.d.ts.map +1 -0
  77. package/dist/commands/login/login.js +185 -0
  78. package/dist/commands/login/login.js.map +1 -0
  79. package/dist/commands/logout/index.d.ts +3 -0
  80. package/dist/commands/logout/index.d.ts.map +1 -0
  81. package/dist/commands/logout/index.js +41 -0
  82. package/dist/commands/logout/index.js.map +1 -0
  83. package/dist/commands/profile/import-env.d.ts +13 -0
  84. package/dist/commands/profile/import-env.d.ts.map +1 -0
  85. package/dist/commands/profile/import-env.js +81 -0
  86. package/dist/commands/profile/import-env.js.map +1 -0
  87. package/dist/commands/profile/index.d.ts +3 -0
  88. package/dist/commands/profile/index.d.ts.map +1 -0
  89. package/dist/commands/profile/index.js +112 -0
  90. package/dist/commands/profile/index.js.map +1 -0
  91. package/dist/commands/rest/index.d.ts +3 -0
  92. package/dist/commands/rest/index.d.ts.map +1 -0
  93. package/dist/commands/rest/index.js +102 -0
  94. package/dist/commands/rest/index.js.map +1 -0
  95. package/dist/commands/skill/index.d.ts +11 -0
  96. package/dist/commands/skill/index.d.ts.map +1 -0
  97. package/dist/commands/skill/index.js +153 -0
  98. package/dist/commands/skill/index.js.map +1 -0
  99. package/dist/commands/status/index.d.ts +3 -0
  100. package/dist/commands/status/index.d.ts.map +1 -0
  101. package/dist/commands/status/index.js +59 -0
  102. package/dist/commands/status/index.js.map +1 -0
  103. package/dist/commands/storage/index.d.ts +3 -0
  104. package/dist/commands/storage/index.d.ts.map +1 -0
  105. package/dist/commands/storage/index.js +198 -0
  106. package/dist/commands/storage/index.js.map +1 -0
  107. package/dist/commands/whoami/index.d.ts +3 -0
  108. package/dist/commands/whoami/index.d.ts.map +1 -0
  109. package/dist/commands/whoami/index.js +82 -0
  110. package/dist/commands/whoami/index.js.map +1 -0
  111. package/dist/credentials/commit.d.ts +38 -0
  112. package/dist/credentials/commit.d.ts.map +1 -0
  113. package/dist/credentials/commit.js +57 -0
  114. package/dist/credentials/commit.js.map +1 -0
  115. package/dist/credentials/credential-store.d.ts +57 -0
  116. package/dist/credentials/credential-store.d.ts.map +1 -0
  117. package/dist/credentials/credential-store.js +180 -0
  118. package/dist/credentials/credential-store.js.map +1 -0
  119. package/dist/credentials/env-file.d.ts +44 -0
  120. package/dist/credentials/env-file.d.ts.map +1 -0
  121. package/dist/credentials/env-file.js +118 -0
  122. package/dist/credentials/env-file.js.map +1 -0
  123. package/dist/credentials/formatter.d.ts +39 -0
  124. package/dist/credentials/formatter.d.ts.map +1 -0
  125. package/dist/credentials/formatter.js +79 -0
  126. package/dist/credentials/formatter.js.map +1 -0
  127. package/dist/credentials/index.d.ts +13 -0
  128. package/dist/credentials/index.d.ts.map +1 -0
  129. package/dist/credentials/index.js +13 -0
  130. package/dist/credentials/index.js.map +1 -0
  131. package/dist/credentials/jwt-introspect.d.ts +32 -0
  132. package/dist/credentials/jwt-introspect.d.ts.map +1 -0
  133. package/dist/credentials/jwt-introspect.js +64 -0
  134. package/dist/credentials/jwt-introspect.js.map +1 -0
  135. package/dist/credentials/masker.d.ts +20 -0
  136. package/dist/credentials/masker.d.ts.map +1 -0
  137. package/dist/credentials/masker.js +37 -0
  138. package/dist/credentials/masker.js.map +1 -0
  139. package/dist/credentials/profile.d.ts +83 -0
  140. package/dist/credentials/profile.d.ts.map +1 -0
  141. package/dist/credentials/profile.js +184 -0
  142. package/dist/credentials/profile.js.map +1 -0
  143. package/dist/credentials/tenant-guard.d.ts +16 -0
  144. package/dist/credentials/tenant-guard.d.ts.map +1 -0
  145. package/dist/credentials/tenant-guard.js +53 -0
  146. package/dist/credentials/tenant-guard.js.map +1 -0
  147. package/dist/credentials/tty-guard.d.ts +19 -0
  148. package/dist/credentials/tty-guard.d.ts.map +1 -0
  149. package/dist/credentials/tty-guard.js +47 -0
  150. package/dist/credentials/tty-guard.js.map +1 -0
  151. package/dist/db/apply-schema.d.ts +144 -0
  152. package/dist/db/apply-schema.d.ts.map +1 -0
  153. package/dist/db/apply-schema.js +359 -0
  154. package/dist/db/apply-schema.js.map +1 -0
  155. package/dist/db/sql-file.d.ts +104 -0
  156. package/dist/db/sql-file.d.ts.map +1 -0
  157. package/dist/db/sql-file.js +584 -0
  158. package/dist/db/sql-file.js.map +1 -0
  159. package/dist/instance/provision.d.ts +89 -0
  160. package/dist/instance/provision.d.ts.map +1 -0
  161. package/dist/instance/provision.js +139 -0
  162. package/dist/instance/provision.js.map +1 -0
  163. package/dist/instance/zero-store.d.ts +47 -0
  164. package/dist/instance/zero-store.d.ts.map +1 -0
  165. package/dist/instance/zero-store.js +91 -0
  166. package/dist/instance/zero-store.js.map +1 -0
  167. package/dist/main.d.ts +3 -0
  168. package/dist/main.d.ts.map +1 -0
  169. package/dist/main.js +46 -0
  170. package/dist/main.js.map +1 -0
  171. package/dist/skill/assets.d.ts +38 -0
  172. package/dist/skill/assets.d.ts.map +1 -0
  173. package/dist/skill/assets.js +111 -0
  174. package/dist/skill/assets.js.map +1 -0
  175. package/dist/skill/hint.d.ts +39 -0
  176. package/dist/skill/hint.d.ts.map +1 -0
  177. package/dist/skill/hint.js +109 -0
  178. package/dist/skill/hint.js.map +1 -0
  179. package/dist/skill/hosts.d.ts +21 -0
  180. package/dist/skill/hosts.d.ts.map +1 -0
  181. package/dist/skill/hosts.js +38 -0
  182. package/dist/skill/hosts.js.map +1 -0
  183. package/dist/skill/installer.d.ts +88 -0
  184. package/dist/skill/installer.d.ts.map +1 -0
  185. package/dist/skill/installer.js +203 -0
  186. package/dist/skill/installer.js.map +1 -0
  187. package/dist/skill/ownership.d.ts +35 -0
  188. package/dist/skill/ownership.d.ts.map +1 -0
  189. package/dist/skill/ownership.js +52 -0
  190. package/dist/skill/ownership.js.map +1 -0
  191. package/package.json +63 -3
  192. package/skills/pxbaas-app-spec/SKILL.md +163 -0
  193. package/skills/pxbaas-app-spec/references/deploy-options.md +157 -0
  194. package/skills/pxbaas-app-spec/references/guardrails-pitfalls.md +89 -0
  195. package/skills/pxbaas-app-spec/references/runtime-contract.md +151 -0
  196. package/skills/pxbaas-app-spec/references/ssr-session.md +121 -0
  197. package/skills/pxbaas-app-spec/references/templates-examples.md +311 -0
  198. package/skills/pxbaas-cli/SKILL.md +171 -0
  199. package/skills/pxbaas-cli/references/api-reference.md +68 -0
  200. package/skills/pxbaas-cli/references/app-deploy.md +170 -0
  201. package/skills/pxbaas-cli/references/auth-and-credentials.md +100 -0
  202. package/skills/pxbaas-cli/references/data-postgrest.md +85 -0
  203. package/skills/pxbaas-cli/references/db-and-meta.md +97 -0
  204. package/skills/pxbaas-cli/references/edge-functions.md +71 -0
  205. package/skills/pxbaas-cli/references/multi-tenant-apps.md +138 -0
  206. package/skills/pxbaas-cli/references/provision.md +86 -0
  207. package/skills/pxbaas-cli/references/safety-and-two-phase.md +49 -0
  208. package/skills/pxbaas-cli/references/storage.md +61 -0
  209. package/skills/pxbaas-cli/references/troubleshooting.md +73 -0
  210. package/templates/webapp/api/index.ts +55 -0
  211. package/templates/webapp/csr-bff/README.md +81 -0
  212. package/templates/webapp/csr-bff/backend/index.ts +168 -0
  213. package/templates/webapp/csr-bff/db/rls.json +13 -0
  214. package/templates/webapp/csr-bff/db/schema.sql +49 -0
  215. package/templates/webapp/csr-bff/frontend/dist/admin.html +101 -0
  216. package/templates/webapp/csr-bff/frontend/dist/article.html +44 -0
  217. package/templates/webapp/csr-bff/frontend/dist/blog.js +206 -0
  218. package/templates/webapp/csr-bff/frontend/dist/blogger.html +53 -0
  219. package/templates/webapp/csr-bff/frontend/dist/index.html +70 -0
  220. package/templates/webapp/csr-bff/frontend/dist/login.html +56 -0
  221. package/templates/webapp/csr-bff/frontend/dist/profile.html +59 -0
  222. package/templates/webapp/csr-bff/frontend/dist/signup.html +78 -0
  223. package/templates/webapp/csr-bff/frontend/dist/style.css +27 -0
  224. package/templates/webapp/manifest.json +299 -0
  225. package/templates/webapp/mpa/about.html +29 -0
  226. package/templates/webapp/mpa/app.js +42 -0
  227. package/templates/webapp/mpa/index.html +42 -0
  228. package/templates/webapp/mpa/index.ts +60 -0
  229. package/templates/webapp/mpa/style.css +42 -0
  230. package/templates/webapp/react-vite/frontend/index.html +12 -0
  231. package/templates/webapp/react-vite/frontend/package-lock.json +1826 -0
  232. package/templates/webapp/react-vite/frontend/package.json +23 -0
  233. package/templates/webapp/react-vite/frontend/src/App.tsx +34 -0
  234. package/templates/webapp/react-vite/frontend/src/main.tsx +13 -0
  235. package/templates/webapp/react-vite/frontend/src/style.css +46 -0
  236. package/templates/webapp/react-vite/frontend/tsconfig.json +20 -0
  237. package/templates/webapp/react-vite/frontend/vite.config.ts +10 -0
  238. package/templates/webapp/react-vite-hono/backend/index.ts +21 -0
  239. package/templates/webapp/react-vite-hono/frontend/index.html +12 -0
  240. package/templates/webapp/react-vite-hono/frontend/package-lock.json +1826 -0
  241. package/templates/webapp/react-vite-hono/frontend/package.json +23 -0
  242. package/templates/webapp/react-vite-hono/frontend/src/App.tsx +47 -0
  243. package/templates/webapp/react-vite-hono/frontend/src/main.tsx +13 -0
  244. package/templates/webapp/react-vite-hono/frontend/src/style.css +66 -0
  245. package/templates/webapp/react-vite-hono/frontend/tsconfig.json +20 -0
  246. package/templates/webapp/react-vite-hono/frontend/vite.config.ts +10 -0
  247. package/templates/webapp/spa/index.ts +119 -0
  248. package/templates/webapp/ssr-auth/backend/index.ts +133 -0
  249. package/templates/webapp/ssr-auth/frontend/dist/index.html +15 -0
  250. package/templates/webapp/ssr-blog/README.md +111 -0
  251. package/templates/webapp/ssr-blog/backend/index.ts +764 -0
  252. package/templates/webapp/ssr-blog/db/rls.json +13 -0
  253. package/templates/webapp/ssr-blog/db/schema.sql +51 -0
  254. package/templates/webapp/ssr-blog/frontend/dist/index.html +39 -0
  255. package/templates/webapp/ssr-frameworks/README.md +64 -0
  256. package/templates/webapp/ssr-frameworks/backend/index.ts +241 -0
  257. package/templates/webapp/ssr-frameworks/frontend/dist/index.html +31 -0
  258. package/templates/webapp/ssr-hono/backend/index.ts +92 -0
  259. package/templates/webapp/ssr-hono/frontend/dist/index.html +12 -0
  260. package/templates/webapp/ssr-shop/README.md +80 -0
  261. package/templates/webapp/ssr-shop/backend/index.ts +491 -0
  262. package/templates/webapp/ssr-shop/db/rls.json +16 -0
  263. package/templates/webapp/ssr-shop/db/schema.sql +90 -0
  264. package/templates/webapp/ssr-shop/frontend/dist/index.html +12 -0
  265. package/templates/webapp/vanilla-static/frontend/app.js +6 -0
  266. package/templates/webapp/vanilla-static/frontend/index.html +19 -0
  267. package/templates/webapp/vanilla-static/frontend/style.css +43 -0
@@ -0,0 +1,185 @@
1
+ import inquirer from 'inquirer';
2
+ import { CredentialStore, ProfileManager, introspectJwt, validateTenantConsistency, assertTty, assertNoKeyArgs, formatSuccess, formatError, computeFingerprint, } from '../../credentials/index.js';
3
+ /**
4
+ * 从 stdin 读取一行(用于 --anon-key-stdin / --service-key-stdin)
5
+ */
6
+ async function readFromStdin() {
7
+ return new Promise((resolve, reject) => {
8
+ let data = '';
9
+ process.stdin.setEncoding('utf8');
10
+ process.stdin.on('readable', () => {
11
+ let chunk;
12
+ while ((chunk = process.stdin.read()) !== null) {
13
+ data += chunk;
14
+ }
15
+ });
16
+ process.stdin.on('end', () => {
17
+ resolve(data.trim());
18
+ });
19
+ process.stdin.on('error', reject);
20
+ });
21
+ }
22
+ export function registerLoginCommand(program) {
23
+ program
24
+ .command('login')
25
+ .description('Authenticate with PolarDB-X BaaS (interactive TTY only)')
26
+ .option('--endpoint <url>', 'BaaS endpoint URL')
27
+ .option('--tenant-id <id>', 'Tenant ID (for multi-tenant mode)')
28
+ .option('--anon-key-stdin', 'Read anon key from stdin')
29
+ .option('--service-key-stdin', 'Read service role key from stdin')
30
+ .option('--profile <name>', 'Profile name to use')
31
+ .action(async (options) => {
32
+ try {
33
+ await handleLogin(options, program);
34
+ }
35
+ catch (error) {
36
+ const message = error instanceof Error ? error.message : String(error);
37
+ console.error(formatError(message));
38
+ process.exit(1);
39
+ }
40
+ });
41
+ }
42
+ async function handleLogin(options, program) {
43
+ // 检查 argv 中是否有密钥参数(安全守卫)
44
+ assertNoKeyArgs(process.argv);
45
+ const isStdinMode = options.anonKeyStdin || options.serviceKeyStdin;
46
+ // 如果不是 stdin 模式,必须是 TTY
47
+ if (!isStdinMode) {
48
+ assertTty();
49
+ }
50
+ let endpoint;
51
+ let tenantId;
52
+ let anonKey;
53
+ let serviceRoleKey;
54
+ if (isStdinMode) {
55
+ // stdin 模式:从命令行参数或 stdin 获取
56
+ endpoint = options.endpoint || '';
57
+ tenantId = options.tenantId;
58
+ if (!endpoint) {
59
+ throw new Error('--endpoint is required when using --anon-key-stdin or --service-key-stdin');
60
+ }
61
+ if (options.anonKeyStdin && options.serviceKeyStdin) {
62
+ // 两个都从 stdin 读取(每行一个)
63
+ const lines = (await readFromStdin()).split('\n');
64
+ if (lines.length < 2) {
65
+ throw new Error('Expected two lines from stdin: anon key on first line, service role key on second line');
66
+ }
67
+ anonKey = lines[0].trim();
68
+ serviceRoleKey = lines[1].trim();
69
+ }
70
+ else if (options.anonKeyStdin) {
71
+ anonKey = (await readFromStdin()).trim();
72
+ throw new Error('--service-key-stdin is required when using --anon-key-stdin');
73
+ }
74
+ else {
75
+ serviceRoleKey = (await readFromStdin()).trim();
76
+ throw new Error('--anon-key-stdin is required when using --service-key-stdin');
77
+ }
78
+ }
79
+ else {
80
+ // TTY 交互模式:使用 inquirer 提示
81
+ const answers = await inquirer.prompt([
82
+ {
83
+ type: 'input',
84
+ name: 'endpoint',
85
+ message: 'BaaS endpoint URL:',
86
+ default: options.endpoint || 'http://localhost:8000',
87
+ validate: (input) => {
88
+ if (!input.trim())
89
+ return 'Endpoint is required';
90
+ if (!input.startsWith('http://') && !input.startsWith('https://')) {
91
+ return 'Endpoint must start with http:// or https://';
92
+ }
93
+ return true;
94
+ },
95
+ },
96
+ {
97
+ type: 'input',
98
+ name: 'tenantId',
99
+ message: 'Tenant ID (leave empty for single-tenant mode):',
100
+ default: options.tenantId || '',
101
+ },
102
+ {
103
+ type: 'password',
104
+ name: 'anonKey',
105
+ message: 'Anon Key:',
106
+ mask: '*',
107
+ validate: (input) => {
108
+ if (!input.trim())
109
+ return 'Anon key is required';
110
+ return true;
111
+ },
112
+ },
113
+ {
114
+ type: 'password',
115
+ name: 'serviceRoleKey',
116
+ message: 'Service Role Key:',
117
+ mask: '*',
118
+ validate: (input) => {
119
+ if (!input.trim())
120
+ return 'Service role key is required';
121
+ return true;
122
+ },
123
+ },
124
+ ]);
125
+ endpoint = answers.endpoint;
126
+ tenantId = answers.tenantId || undefined;
127
+ anonKey = answers.anonKey;
128
+ serviceRoleKey = answers.serviceRoleKey;
129
+ }
130
+ // 解析 JWT
131
+ const anonJwt = await introspectJwt(anonKey);
132
+ const serviceJwt = await introspectJwt(serviceRoleKey);
133
+ // 检查 JWT 是否过期
134
+ if (anonJwt.isExpired) {
135
+ console.warn(formatError('Warning: Anon key is expired'));
136
+ }
137
+ if (serviceJwt.isExpired) {
138
+ console.warn(formatError('Warning: Service role key is expired'));
139
+ }
140
+ // 创建 profile
141
+ const mode = tenantId ? 'multi-tenant' : 'single-tenant';
142
+ const profileName = options.profile || 'default';
143
+ const profile = {
144
+ name: profileName,
145
+ endpoint,
146
+ tenantId,
147
+ mode,
148
+ createdAt: new Date().toISOString(),
149
+ updatedAt: new Date().toISOString(),
150
+ };
151
+ // 验证租户一致性
152
+ validateTenantConsistency(profile, anonJwt, serviceJwt);
153
+ // 保存 profile
154
+ const profileManager = new ProfileManager();
155
+ await profileManager.setProfile(profile);
156
+ await profileManager.useProfile(profileName);
157
+ // 保存凭据
158
+ const credentialStore = new CredentialStore();
159
+ await credentialStore.setCredentials(profileName, {
160
+ anonKey,
161
+ serviceRoleKey,
162
+ storedAt: new Date().toISOString(),
163
+ });
164
+ // 输出成功消息
165
+ const output = {
166
+ profile: profileName,
167
+ endpoint,
168
+ tenantId: tenantId || '(single-tenant)',
169
+ mode,
170
+ anonKeyFingerprint: computeFingerprint(anonKey),
171
+ serviceKeyFingerprint: computeFingerprint(serviceRoleKey),
172
+ };
173
+ if (options.json || program.opts().json) {
174
+ console.log(JSON.stringify(output, null, 2));
175
+ }
176
+ else {
177
+ console.log(formatSuccess(`Login successful for profile: ${profileName}`));
178
+ console.log(` Endpoint: ${endpoint}`);
179
+ console.log(` Tenant ID: ${tenantId || '(single-tenant)'}`);
180
+ console.log(` Mode: ${mode}`);
181
+ console.log(` Anon Key: ${output.anonKeyFingerprint}`);
182
+ console.log(` Service Key: ${output.serviceKeyFingerprint}`);
183
+ }
184
+ }
185
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/login/login.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,eAAe,EACf,cAAc,EACd,aAAa,EACb,yBAAyB,EACzB,SAAS,EACT,eAAe,EACf,aAAa,EACb,WAAW,EACX,kBAAkB,GAEnB,MAAM,4BAA4B,CAAC;AAWpC;;GAEG;AACH,KAAK,UAAU,aAAa;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;YAChC,IAAI,KAAa,CAAC;YAClB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC/C,IAAI,IAAI,KAAK,CAAC;YAChB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO;S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AqB,EAAE,kBAAkB,CAAC,cAAc,CAAC;KAC1D,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,iCAAiC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC3E,OAAO,CAAC,GAAG,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,kBAAkB,QAAQ,IAAI,iBAAiB,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;QACtC,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerLogoutCommand(program: Command): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/logout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAa5D"}
@@ -0,0 +1,41 @@
1
+ import { CredentialStore, ProfileManager, formatSuccess, formatError, } from '../../credentials/index.js';
2
+ export function registerLogoutCommand(program) {
3
+ program
4
+ .command('logout')
5
+ .description('Clear credentials for current profile')
6
+ .action(async () => {
7
+ try {
8
+ await handleLogout(program);
9
+ }
10
+ catch (error) {
11
+ const message = error instanceof Error ? error.message : String(error);
12
+ console.error(formatError(message));
13
+ process.exit(1);
14
+ }
15
+ });
16
+ }
17
+ async function handleLogout(program) {
18
+ const profileManager = new ProfileManager();
19
+ const currentProfile = await profileManager.getCurrentProfile();
20
+ if (!currentProfile) {
21
+ throw new Error('No active profile. Use "pxbaas login" to authenticate first.');
22
+ }
23
+ const credentialStore = new CredentialStore();
24
+ const deleted = await credentialStore.deleteCredentials(currentProfile.name);
25
+ if (deleted) {
26
+ const output = {
27
+ profile: currentProfile.name,
28
+ status: 'logged out',
29
+ };
30
+ if (program.opts().json) {
31
+ console.log(JSON.stringify(output, null, 2));
32
+ }
33
+ else {
34
+ console.log(formatSuccess(`Logged out from profile: ${currentProfile.name}`));
35
+ }
36
+ }
37
+ else {
38
+ throw new Error(`No credentials found for profile: ${currentProfile.name}`);
39
+ }
40
+ }
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/logout/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,4BAA4B,CAAC;AAEpC,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,uCAAuC,CAAC;SACpD,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,OAAgB;IAC1C,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,iBAAiB,EAAE,CAAC;IAEhE,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAE7E,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,MAAM,GAAG;YACb,OAAO,EAAE,cAAc,CAAC,IAAI;YAC5B,MAAM,EAAE,YAAY;SACrB,CAAC;QAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,4BAA4B,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * pxbaas profile import <env-file>
3
+ *
4
+ * 直接从一个 Supabase/BaaS 惯例的 .env 文件导入单租户实例凭据并落库为 profile,
5
+ * 免去把 URL / anon key / service key 拆出来再拼 stdin 登录命令。
6
+ *
7
+ * 与 login 共用 commitProfileCredentials(JWT 过期校验 + 租户一致性校验 + keyring 存储)。
8
+ * 密钥来自文件而非 argv/shell history,因此该命令可被 agent 非交互执行。
9
+ * 多租户实例暂不支持(env 文件只有 global keys)——见 resolveLoginFromEnv 的显式报错。
10
+ */
11
+ import type { Command } from 'commander';
12
+ export declare function registerProfileImportCommand(profileCmd: Command, program: Command): void;
13
+ //# sourceMappingURL=import-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-env.d.ts","sourceRoot":"","sources":["../../../src/commands/profile/import-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAezC,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAoBxF"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * pxbaas profile import <env-file>
3
+ *
4
+ * 直接从一个 Supabase/BaaS 惯例的 .env 文件导入单租户实例凭据并落库为 profile,
5
+ * 免去把 URL / anon key / service key 拆出来再拼 stdin 登录命令。
6
+ *
7
+ * 与 login 共用 commitProfileCredentials(JWT 过期校验 + 租户一致性校验 + keyring 存储)。
8
+ * 密钥来自文件而非 argv/shell history,因此该命令可被 agent 非交互执行。
9
+ * 多租户实例暂不支持(env 文件只有 global keys)——见 resolveLoginFromEnv 的显式报错。
10
+ */
11
+ import { readFile } from 'node:fs/promises';
12
+ import { parseEnvText, resolveLoginFromEnv, commitProfileCredentials, formatSuccess, formatError, } from '../../credentials/index.js';
13
+ export function registerProfileImportCommand(profileCmd, program) {
14
+ profileCmd
15
+ .command('import <env-file>')
16
+ .description('Import a single-tenant instance profile from a .env file (non-interactive)')
17
+ .option('--name <profile>', 'Profile name to create/overwrite (default: --profile or "default")')
18
+ .option('--intranet', 'Prefer SUPABASE_INTRANET_URL over the public endpoint')
19
+ .option('--json', 'Output in JSON format')
20
+ .action(async (envFile, options) => {
21
+ try {
22
+ await handleProfileImport(envFile, options, program);
23
+ }
24
+ catch (error) {
25
+ const message = error instanceof Error ? error.message : String(error);
26
+ if (options.json || program.opts().json) {
27
+ console.log(JSON.stringify({ status: 'error', message }, null, 2));
28
+ }
29
+ else {
30
+ console.error(formatError(message));
31
+ }
32
+ process.exit(1);
33
+ }
34
+ });
35
+ }
36
+ async function handleProfileImport(envFile, options, program) {
37
+ let text;
38
+ try {
39
+ text = await readFile(envFile, 'utf-8');
40
+ }
41
+ catch (err) {
42
+ const reason = err instanceof Error ? err.message : String(err);
43
+ throw new Error(`Failed to read env file '${envFile}': ${reason}`);
44
+ }
45
+ const env = parseEnvText(text);
46
+ const fields = resolveLoginFromEnv(env, { intranet: options.intranet });
47
+ // profile 名优先级:--name > 全局 --profile > 'default'
48
+ const profileName = options.name || program.opts().profile || 'default';
49
+ const result = await commitProfileCredentials({
50
+ profileName,
51
+ endpoint: fields.endpoint,
52
+ tenantId: fields.tenantId,
53
+ anonKey: fields.anonKey,
54
+ serviceRoleKey: fields.serviceRoleKey,
55
+ });
56
+ if (options.json || program.opts().json) {
57
+ const output = {
58
+ status: 'success',
59
+ message: `Imported profile from env file: ${profileName}`,
60
+ profile: profileName,
61
+ envFile,
62
+ endpoint: result.endpoint,
63
+ tenantId: result.tenantId || '(single-tenant)',
64
+ mode: result.mode,
65
+ sources: fields.sources,
66
+ anonKeyFingerprint: result.anonKeyFingerprint,
67
+ serviceKeyFingerprint: result.serviceKeyFingerprint,
68
+ };
69
+ console.log(JSON.stringify(output, null, 2));
70
+ }
71
+ else {
72
+ console.log(formatSuccess(`Imported profile from env file: ${profileName}`));
73
+ console.log(` Env file: ${envFile}`);
74
+ console.log(` Endpoint: ${result.endpoint} (from ${fields.sources.endpoint})`);
75
+ console.log(` Tenant ID: ${result.tenantId || '(single-tenant)'}`);
76
+ console.log(` Mode: ${result.mode}`);
77
+ console.log(` Anon Key: ${result.anonKeyFingerprint} (from ${fields.sources.anonKey})`);
78
+ console.log(` Service Key: ${result.serviceKeyFingerprint} (from ${fields.sources.serviceRoleKey})`);
79
+ }
80
+ }
81
+ //# sourceMappingUR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Q,EAAE,MAAM,CAAC,QAAQ,IAAI,iBAAiB;YAC9C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;SACpD,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAmC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,QAAQ,WAAW,MAAM,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACpF,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,QAAQ,IAAI,iBAAiB,EAAE,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,kBAAkB,WAAW,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC;QAC7F,OAAO,CAAC,GAAG,CAAC,kBAAkB,MAAM,CAAC,qBAAqB,WAAW,MAAM,CAAC,OAAO,CAAC,cAAc,GAAG,CAAC,CAAC;IACzG,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerProfileCommand(program: Command): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/profile/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiD7D"}
@@ -0,0 +1,112 @@
1
+ import { ProfileManager, formatSuccess, formatError, } from '../../credentials/index.js';
2
+ import { registerProfileImportCommand } from './import-env.js';
3
+ export function registerProfileCommand(program) {
4
+ const profileCmd = program
5
+ .command('profile')
6
+ .description('Manage multiple environment profiles');
7
+ // profile ls
8
+ profileCmd
9
+ .command('ls')
10
+ .description('List all profiles')
11
+ .action(async () => {
12
+ try {
13
+ await handleProfileLs(program);
14
+ }
15
+ catch (error) {
16
+ const message = error instanceof Error ? error.message : String(error);
17
+ console.error(formatError(message));
18
+ process.exit(1);
19
+ }
20
+ });
21
+ // profile use <name>
22
+ profileCmd
23
+ .command('use <name>')
24
+ .description('Switch to a different profile')
25
+ .action(async (name) => {
26
+ try {
27
+ await handleProfileUse(name, program);
28
+ }
29
+ catch (error) {
30
+ const message = error instanceof Error ? error.message : String(error);
31
+ console.error(formatError(message));
32
+ process.exit(1);
33
+ }
34
+ });
35
+ // profile rm <name>
36
+ profileCmd
37
+ .command('rm <name>')
38
+ .description('Remove a profile')
39
+ .action(async (name) => {
40
+ try {
41
+ await handleProfileRm(name, program);
42
+ }
43
+ catch (error) {
44
+ const message = error instanceof Error ? error.message : String(error);
45
+ console.error(formatError(message));
46
+ process.exit(1);
47
+ }
48
+ });
49
+ // profile import <env-file>
50
+ registerProfileImportCommand(profileCmd, program);
51
+ }
52
+ async function handleProfileLs(program) {
53
+ const profileManager = new ProfileManager();
54
+ const profiles = await profileManager.listProfiles();
55
+ const currentProfile = await profileManager.getCurrentProfile();
56
+ if (profiles.length === 0) {
57
+ console.log('No profiles found. Use "pxbaas login" to create a profile.');
58
+ return;
59
+ }
60
+ const output = profiles.map(p => ({
61
+ name: p.name,
62
+ endpoint: p.endpoint,
63
+ tenantId: p.tenantId || '(single-tenant)',
64
+ mode: p.mode,
65
+ current: currentProfile?.name === p.name,
66
+ }));
67
+ if (program.opts().json) {
68
+ console.log(JSON.stringify(output, null, 2));
69
+ }
70
+ else {
71
+ for (const p of output) {
72
+ const marker = p.current ? '* ' : ' ';
73
+ console.log(`${marker}${p.name}`);
74
+ console.log(` Endpoint: ${p.endpoint}`);
75
+ console.log(` Tenant ID: ${p.tenantId}`);
76
+ console.log(` Mode: ${p.mode}`);
77
+ console.log();
78
+ }
79
+ }
80
+ }
81
+ async function handleProfileUse(name, program) {
82
+ const profileManager = new ProfileManager();
83
+ await profileManager.useProfile(name);
84
+ const output = {
85
+ profile: name,
86
+ status: 'active',
87
+ };
88
+ if (program.opts().json) {
89
+ console.log(JSON.stringify(output, null, 2));
90
+ }
91
+ else {
92
+ console.log(formatSuccess(`Switched to profile: ${name}`));
93
+ }
94
+ }
95
+ async function handleProfileRm(name, program) {
96
+ const profileManager = new ProfileManager();
97
+ const deleted = await profileManager.removeProfile(name);
98
+ if (!deleted) {
99
+ throw new Error(`Profile not found: ${name}`);
100
+ }
101
+ const output = {
102
+ profile: name,
103
+ status: 'removed',
104
+ };
105
+ if (program.opts().json) {
106
+ console.log(JSON.stringify(output, null, 2));
107
+ }
108
+ else {
109
+ console.log(formatSuccess(`Removed profile: ${name}`));
110
+ }
111
+ }
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/profile/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE/D,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,UAAU,GAAG,OAAO;SACvB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,sCAAsC,CAAC,CAAC;IAEvD,aAAa;IACb,UAAU;SACP,OAAO,CAAC,IAAI,CAAC;SACb,WAAW,CAAC,mBAAmB,CAAC;SACh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sB,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;KAClB,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function registerRestCommand(program: Command): void;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/rest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoB1D"}
@@ -0,0 +1,102 @@
1
+ import axios from 'axios';
2
+ import { CredentialStore, ProfileManager, formatSuccess, formatError, } from '../../credentials/index.js';
3
+ export function registerRestCommand(program) {
4
+ program
5
+ .command('rest <method> <path>')
6
+ .description('Raw HTTP passthrough to /rest/v1/* (for debugging)')
7
+ .option('--data <json>', 'Request body (JSON)')
8
+ .option('--role <role>', 'Role to use (anon or service_role)', 'anon')
9
+ .option('--json', 'Output in JSON format')
10
+ .action(async (method, path, options) => {
11
+ try {
12
+ await handleRest(method, path, { ...options, json: options.json || program.opts().json });
13
+ }
14
+ catch (error) {
15
+ const message = error instanceof Error ? error.message : String(error);
16
+ console.error(formatError(message));
17
+ process.exit(1);
18
+ }
19
+ });
20
+ }
21
+ async function handleRest(method, path, options) {
22
+ // Get current profile
23
+ const profileManager = new ProfileManager();
24
+ const currentProfile = await profileManager.getCurrentProfile();
25
+ if (!currentProfile) {
26
+ throw new Error('No active profile. Use "pxbaas login" to authenticate first.');
27
+ }
28
+ // Get credentials
29
+ const credentialStore = new CredentialStore();
30
+ const credentials = await credentialStore.getCredentials(currentProfile.name);
31
+ if (!credentials) {
32
+ throw new Error(`No credentials found for profile: ${currentProfile.name}. Use "pxbaas login" to authenticate.`);
33
+ }
34
+ // Validate method
35
+ const httpMethod = method.toUpperCase();
36
+ const validMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'];
37
+ if (!validMethods.includes(httpMethod)) {
38
+ throw new Error(`Invalid HTTP method: ${method}. Valid methods: ${validMethods.join(', ')}`);
39
+ }
40
+ // Build URL
41
+ const url = path.startsWith('/rest/v1/')
42
+ ? `${currentProfile.endpoint}${path}`
43
+ : `${currentProfile.endpoint}/rest/v1/${path}`;
44
+ // Select key based on role
45
+ const apiKey = options.role === 'service_role' ? credentials.serviceRoleKey : credentials.anonKey;
46
+ // Parse data if provided
47
+ let data = undefined;
48
+ if (options.data) {
49
+ try {
50
+ data = JSON.parse(options.data);
51
+ }
52
+ catch {
53
+ throw new Error('Invalid JSON in --data');
54
+ }
55
+ }
56
+ // Make request
57
+ try {
58
+ const headers = {
59
+ 'apikey': apiKey,
60
+ 'Authorization': `Bearer ${apiKey}`,
61
+ 'Content-Type': 'application/json',
62
+ };
63
+ if (currentProfile.tenantId) {
64
+ headers['X-Tenant-Id'] = currentProfile.tenantId;
65
+ }
66
+ const response = await axios({
67
+ method: httpMethod,
68
+ url,
69
+ headers,
70
+ data,
71
+ validateStatus: () => true, // Don't throw on non-2xx status codes
72
+ });
73
+ const output = {
74
+ status: response.status,
75
+ statusText: response.statusText,
76
+ headers: response.headers,
77
+ data: response.data,
78
+ };
79
+ if (options.json) {
80
+ console.log(JSON.stringify(output, null, 2));
81
+ }
82
+ else {
83
+ console.log(formatSuccess(`${httpMethod} ${path}`));
84
+ console.log(` Status: ${response.status} ${response.statusText}`);
85
+ console.log('');
86
+ if (response.data) {
87
+ console.log('Response:');
88
+ console.log(JSON.stringify(response.data, null, 2));
89
+ }
90
+ }
91
+ }
92
+ catch (error) {
93
+ if (axios.isAxiosError(error)) {
94
+ const status = error.response?.status ?? 'unknown';
95
+ const statusText = error.response?.statusText ?? 'Unknown';
96
+ const data = error.response?.data;
97
+ throw new Error(`HTTP ${status} ${statusText}: ${data ? JSON.stringify(data) : error.message}`);
98
+ }
99
+ throw error;
100
+ }
101
+ }
102
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/rest/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAiB,MAAM,OAAO,CAAC;AACtC,OAAO,EACL,eAAe,EACf,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,4BAA4B,CAAC;AAEpC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,sBAAsB,CAAC;SAC/B,WAAW,CAAC,oDAAoD,CAAC;SACjE,MAAM,CAAC,eAAe,EAAE,qBAAqB,CAAC;SAC9C,MAAM,CAAC,eAAe,EAAE,oCAAoC,EAAE,MAAM,CAAC;SACrE,MAAM,CAAC,QAAQ,EAAE,uBAAuB,CAAC;SACzC,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAY,EAAE,OAI5C,EAAE,EAAE;QACH,IAAI,CAAC;YACH,MAAM,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC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.claude,
5
+ * ~/.cursor, ~/.qwen, ~/.hermes). Each skill lands in `<host>/skills/<skill>/`
6
+ * with its own fail-closed owner marker.
7
+ *
8
+ * Offline and credential-free: never requires `pxbaas login`.
9
+ */
10
+ export declare function registerSkillCommands(program: Command): void;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/skill/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuD5D"}