@mx-space/cli 0.1.0 → 0.1.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.
Files changed (110) hide show
  1. package/README.md +5 -1
  2. package/dist/{auth-DIFZzoMm.mjs → auth-OeKZZ_2x.mjs} +2 -2
  3. package/dist/{auth-DIFZzoMm.mjs.map → auth-OeKZZ_2x.mjs.map} +1 -1
  4. package/dist/bin/mxs.d.mts +1 -0
  5. package/dist/bin/mxs.mjs +39 -39
  6. package/dist/bin/mxs.mjs.map +1 -1
  7. package/dist/config-store-WL7dNMS6.mjs +226 -0
  8. package/dist/config-store-WL7dNMS6.mjs.map +1 -0
  9. package/dist/{create-Dz6rJJSS.mjs → create-BVHnXtIH.mjs} +2 -2
  10. package/dist/{create-Dz6rJJSS.mjs.map → create-BVHnXtIH.mjs.map} +1 -1
  11. package/dist/{create-DT1l2hue.mjs → create-BWA2WGrW.mjs} +2 -2
  12. package/dist/{create-DT1l2hue.mjs.map → create-BWA2WGrW.mjs.map} +1 -1
  13. package/dist/{create-B2AOQL1e.mjs → create-C85MSrtt.mjs} +2 -2
  14. package/dist/{create-B2AOQL1e.mjs.map → create-C85MSrtt.mjs.map} +1 -1
  15. package/dist/{create-DjlRHPXy.mjs → create-Cxnqt_Wt.mjs} +2 -2
  16. package/dist/{create-DjlRHPXy.mjs.map → create-Cxnqt_Wt.mjs.map} +1 -1
  17. package/dist/{create-CwjGcv2n.mjs → create-DUOSAqBm.mjs} +2 -2
  18. package/dist/{create-CwjGcv2n.mjs.map → create-DUOSAqBm.mjs.map} +1 -1
  19. package/dist/{delete-YzRliRn8.mjs → delete-BEXOOFAJ.mjs} +2 -2
  20. package/dist/{delete-YzRliRn8.mjs.map → delete-BEXOOFAJ.mjs.map} +1 -1
  21. package/dist/{delete-B4dGrrus.mjs → delete-CGy-cV6k.mjs} +2 -2
  22. package/dist/{delete-B4dGrrus.mjs.map → delete-CGy-cV6k.mjs.map} +1 -1
  23. package/dist/{delete-BH6ZngTz.mjs → delete-CKqlAUT8.mjs} +2 -2
  24. package/dist/{delete-BH6ZngTz.mjs.map → delete-CKqlAUT8.mjs.map} +1 -1
  25. package/dist/{delete-CaG2d_xt.mjs → delete-CcyrLNZv.mjs} +2 -2
  26. package/dist/{delete-CaG2d_xt.mjs.map → delete-CcyrLNZv.mjs.map} +1 -1
  27. package/dist/{delete-BrY5zJ6S.mjs → delete-Cjxehwj7.mjs} +2 -2
  28. package/dist/{delete-BrY5zJ6S.mjs.map → delete-Cjxehwj7.mjs.map} +1 -1
  29. package/dist/{document-output-BVB8emLt.mjs → document-output-C5PWbz2p.mjs} +57 -2
  30. package/dist/document-output-C5PWbz2p.mjs.map +1 -0
  31. package/dist/{edit-Bb0Ze4w6.mjs → edit-BRaZ6GGg.mjs} +2 -2
  32. package/dist/{edit-Bb0Ze4w6.mjs.map → edit-BRaZ6GGg.mjs.map} +1 -1
  33. package/dist/{edit-z55ofr1S.mjs → edit-BuKMUNVC.mjs} +2 -2
  34. package/dist/{edit-z55ofr1S.mjs.map → edit-BuKMUNVC.mjs.map} +1 -1
  35. package/dist/{edit-BeFmC3XD.mjs → edit-DFnOnk4i.mjs} +2 -2
  36. package/dist/{edit-BeFmC3XD.mjs.map → edit-DFnOnk4i.mjs.map} +1 -1
  37. package/dist/{edit-DLDw_ZWX.mjs → edit-t108N11Q.mjs} +2 -2
  38. package/dist/{edit-DLDw_ZWX.mjs.map → edit-t108N11Q.mjs.map} +1 -1
  39. package/dist/{get-ClkpDBTL.mjs → get-BYoAlJwB.mjs} +3 -3
  40. package/dist/get-BYoAlJwB.mjs.map +1 -0
  41. package/dist/{get-DJfUJ3sP.mjs → get-CwcNFb39.mjs} +3 -3
  42. package/dist/get-CwcNFb39.mjs.map +1 -0
  43. package/dist/{get-DiqaQvoS.mjs → get-DnDvLa9S.mjs} +4 -4
  44. package/dist/get-DnDvLa9S.mjs.map +1 -0
  45. package/dist/{get-2qjq0wgG.mjs → get-Doi-NKAh.mjs} +6 -6
  46. package/dist/get-Doi-NKAh.mjs.map +1 -0
  47. package/dist/{get-CRR13lgj.mjs → get-DxTU7Nom.mjs} +2 -2
  48. package/dist/{get-CRR13lgj.mjs.map → get-DxTU7Nom.mjs.map} +1 -1
  49. package/dist/{get-BGAk1Zmv.mjs → get-GdRz82RW.mjs} +4 -4
  50. package/dist/get-GdRz82RW.mjs.map +1 -0
  51. package/dist/index.d.mts +15 -3
  52. package/dist/index.mjs +5 -5
  53. package/dist/{list-Fp4nKfQb.mjs → list-CLAcZYZ4.mjs} +3 -3
  54. package/dist/list-CLAcZYZ4.mjs.map +1 -0
  55. package/dist/{list-DY-tPNG-.mjs → list-CtME3aDw.mjs} +2 -2
  56. package/dist/{list-DY-tPNG-.mjs.map → list-CtME3aDw.mjs.map} +1 -1
  57. package/dist/{list-DlQSkbqx.mjs → list-DHG-MzOM.mjs} +3 -3
  58. package/dist/list-DHG-MzOM.mjs.map +1 -0
  59. package/dist/{list-BYzhflDg.mjs → list-DN81zVDA.mjs} +4 -4
  60. package/dist/list-DN81zVDA.mjs.map +1 -0
  61. package/dist/list-DVunNsXr.mjs +10 -0
  62. package/dist/list-DVunNsXr.mjs.map +1 -0
  63. package/dist/list-DbNCVZbz.mjs +15 -0
  64. package/dist/list-DbNCVZbz.mjs.map +1 -0
  65. package/dist/{login-CLOJ-fTJ.mjs → login-mjliJn8U.mjs} +4 -4
  66. package/dist/{login-CLOJ-fTJ.mjs.map → login-mjliJn8U.mjs.map} +1 -1
  67. package/dist/{logout-v8ihxsim.mjs → logout-Bslt_ZJ4.mjs} +2 -2
  68. package/dist/{logout-v8ihxsim.mjs.map → logout-Bslt_ZJ4.mjs.map} +1 -1
  69. package/dist/{onboarding-640IldLz.mjs → onboarding-C1t1yoay.mjs} +3 -3
  70. package/dist/{onboarding-640IldLz.mjs.map → onboarding-C1t1yoay.mjs.map} +1 -1
  71. package/dist/output-BM7aBFwt.mjs.map +1 -1
  72. package/dist/{publish-pRBfTJfe.mjs → publish-CN3NTJ_r.mjs} +2 -2
  73. package/dist/{publish-pRBfTJfe.mjs.map → publish-CN3NTJ_r.mjs.map} +1 -1
  74. package/dist/{publish-DkTYB-eK.mjs → publish-akQWYsnL.mjs} +2 -2
  75. package/dist/{publish-DkTYB-eK.mjs.map → publish-akQWYsnL.mjs.map} +1 -1
  76. package/dist/{set-BEGQz2si.mjs → set-ClbrGFGv.mjs} +2 -2
  77. package/dist/{set-BEGQz2si.mjs.map → set-ClbrGFGv.mjs.map} +1 -1
  78. package/dist/{shared-D0HVBDHI.mjs → shared-C2EAn5h_.mjs} +11 -4
  79. package/dist/shared-C2EAn5h_.mjs.map +1 -0
  80. package/dist/{status-LXrN9fI-.mjs → status-Cvyrrx-J.mjs} +3 -3
  81. package/dist/{status-LXrN9fI-.mjs.map → status-Cvyrrx-J.mjs.map} +1 -1
  82. package/dist/{update-BMZQPOvR.mjs → update-CHmckeo8.mjs} +2 -2
  83. package/dist/{update-BMZQPOvR.mjs.map → update-CHmckeo8.mjs.map} +1 -1
  84. package/dist/{update-q66TLS38.mjs → update-CJjwg09n.mjs} +2 -2
  85. package/dist/{update-q66TLS38.mjs.map → update-CJjwg09n.mjs.map} +1 -1
  86. package/dist/{update-Dx6AF8tf.mjs → update-Duh-iVOZ.mjs} +2 -2
  87. package/dist/{update-Dx6AF8tf.mjs.map → update-Duh-iVOZ.mjs.map} +1 -1
  88. package/dist/{update-B9ynFCdZ.mjs → update-dc-72pUN.mjs} +2 -2
  89. package/dist/{update-B9ynFCdZ.mjs.map → update-dc-72pUN.mjs.map} +1 -1
  90. package/dist/{update-BXz0l7Lz.mjs → update-qfiC-9Og.mjs} +2 -2
  91. package/dist/{update-BXz0l7Lz.mjs.map → update-qfiC-9Og.mjs.map} +1 -1
  92. package/dist/{whoami-CTkctOEd.mjs → whoami-UwcdRchK.mjs} +3 -3
  93. package/dist/{whoami-CTkctOEd.mjs.map → whoami-UwcdRchK.mjs.map} +1 -1
  94. package/package.json +1 -1
  95. package/dist/config-store-DIu7x0ao.mjs +0 -121
  96. package/dist/config-store-DIu7x0ao.mjs.map +0 -1
  97. package/dist/document-output-BVB8emLt.mjs.map +0 -1
  98. package/dist/get-2qjq0wgG.mjs.map +0 -1
  99. package/dist/get-BGAk1Zmv.mjs.map +0 -1
  100. package/dist/get-ClkpDBTL.mjs.map +0 -1
  101. package/dist/get-DJfUJ3sP.mjs.map +0 -1
  102. package/dist/get-DiqaQvoS.mjs.map +0 -1
  103. package/dist/list-BYzhflDg.mjs.map +0 -1
  104. package/dist/list-DlQSkbqx.mjs.map +0 -1
  105. package/dist/list-DsrA5wIz.mjs +0 -15
  106. package/dist/list-DsrA5wIz.mjs.map +0 -1
  107. package/dist/list-Fp4nKfQb.mjs.map +0 -1
  108. package/dist/list-s_tloiEX.mjs +0 -10
  109. package/dist/list-s_tloiEX.mjs.map +0 -1
  110. package/dist/shared-D0HVBDHI.mjs.map +0 -1
@@ -0,0 +1,226 @@
1
+ import { s as MxsError } from "./output-BM7aBFwt.mjs";
2
+ import path from "node:path";
3
+ import { promises } from "node:fs";
4
+ import os from "node:os";
5
+ //#region src/core/config-dir.ts
6
+ function getConfigDir() {
7
+ const xdg = process.env.XDG_CONFIG_HOME;
8
+ const base = xdg && xdg.length > 0 ? xdg : path.join(os.homedir(), ".config");
9
+ return path.join(base, "mxs");
10
+ }
11
+ //#endregion
12
+ //#region src/core/profile.ts
13
+ function getProfilesDir() {
14
+ return path.join(getConfigDir(), "profiles");
15
+ }
16
+ function getCurrentPath() {
17
+ return path.join(getConfigDir(), "current");
18
+ }
19
+ function getProfileDir(name) {
20
+ return path.join(getProfilesDir(), name);
21
+ }
22
+ function getProfileConfigPath(name) {
23
+ return path.join(getProfileDir(name), "config.json");
24
+ }
25
+ function getProfileCredentialsPath(name) {
26
+ return path.join(getProfileDir(name), "credentials.json");
27
+ }
28
+ async function getCurrentProfile() {
29
+ const p = getCurrentPath();
30
+ try {
31
+ const name = (await promises.readFile(p, "utf8")).trim();
32
+ return name.length > 0 ? name : null;
33
+ } catch (err) {
34
+ if (err?.code === "ENOENT") return null;
35
+ throw err;
36
+ }
37
+ }
38
+ async function readJsonIfExists$1(p) {
39
+ try {
40
+ const raw = await promises.readFile(p, "utf8");
41
+ return JSON.parse(raw);
42
+ } catch (err) {
43
+ if (err?.code === "ENOENT") return null;
44
+ if (err instanceof SyntaxError) throw new MxsError({
45
+ code: "generic",
46
+ message: `failed to parse ${p}: ${err.message}`
47
+ });
48
+ throw err;
49
+ }
50
+ }
51
+ async function readProfileConfig(name) {
52
+ return await readJsonIfExists$1(getProfileConfigPath(name)) ?? {};
53
+ }
54
+ async function readProfileCredentials(name) {
55
+ const p = getProfileCredentialsPath(name);
56
+ const data = await readJsonIfExists$1(p);
57
+ if (data) await enforceProfileCredentialsMode(p);
58
+ return data;
59
+ }
60
+ async function enforceProfileCredentialsMode(p) {
61
+ let stats;
62
+ try {
63
+ stats = await promises.stat(p);
64
+ } catch (err) {
65
+ if (err?.code === "ENOENT") return false;
66
+ throw err;
67
+ }
68
+ const mode = stats.mode & 511;
69
+ if (mode !== 384) {
70
+ process.stderr.write(`mxs: credentials file ${p} had mode ${mode.toString(8)}; chmod 600\n`);
71
+ await promises.chmod(p, 384);
72
+ return true;
73
+ }
74
+ return false;
75
+ }
76
+ //#endregion
77
+ //#region src/core/config-store.ts
78
+ const DEFAULT_CLIENT_ID = "mxs-cli";
79
+ function getLegacyConfigPath() {
80
+ return path.join(getConfigDir(), "config.json");
81
+ }
82
+ function getLegacyCredentialsPath() {
83
+ return path.join(getConfigDir(), "credentials.json");
84
+ }
85
+ /** @deprecated Use getLegacyConfigPath for migration logic only */
86
+ function getConfigPath() {
87
+ return getLegacyConfigPath();
88
+ }
89
+ /** @deprecated Use getLegacyCredentialsPath for migration logic only */
90
+ function getCredentialsPath() {
91
+ return getLegacyCredentialsPath();
92
+ }
93
+ async function readJsonIfExists(p) {
94
+ try {
95
+ const raw = await promises.readFile(p, "utf8");
96
+ return JSON.parse(raw);
97
+ } catch (err) {
98
+ if (err?.code === "ENOENT") return null;
99
+ if (err instanceof SyntaxError) throw new MxsError({
100
+ code: "generic",
101
+ message: `failed to parse ${p}: ${err.message}`
102
+ });
103
+ throw err;
104
+ }
105
+ }
106
+ async function readConfig() {
107
+ return await readJsonIfExists(getLegacyConfigPath()) ?? {};
108
+ }
109
+ async function writeConfig(cfg) {
110
+ const dir = getConfigDir();
111
+ await promises.mkdir(dir, { recursive: true });
112
+ await promises.writeFile(getLegacyConfigPath(), JSON.stringify(cfg, null, 2), { mode: 420 });
113
+ try {
114
+ await promises.chmod(getLegacyConfigPath(), 420);
115
+ } catch {}
116
+ }
117
+ async function readCredentials() {
118
+ const p = getLegacyCredentialsPath();
119
+ const data = await readJsonIfExists(p);
120
+ if (data) await enforceCredentialsMode(p);
121
+ return data;
122
+ }
123
+ async function writeCredentials(cred) {
124
+ const dir = getConfigDir();
125
+ await promises.mkdir(dir, { recursive: true });
126
+ const p = getLegacyCredentialsPath();
127
+ await promises.writeFile(p, JSON.stringify(cred, null, 2), { mode: 384 });
128
+ await promises.chmod(p, 384);
129
+ }
130
+ async function deleteCredentials() {
131
+ const p = getLegacyCredentialsPath();
132
+ try {
133
+ await promises.unlink(p);
134
+ } catch (err) {
135
+ if (err?.code !== "ENOENT") throw err;
136
+ }
137
+ }
138
+ async function enforceCredentialsMode(p = getLegacyCredentialsPath()) {
139
+ let stats;
140
+ try {
141
+ stats = await promises.stat(p);
142
+ } catch (err) {
143
+ if (err?.code === "ENOENT") return false;
144
+ throw err;
145
+ }
146
+ const mode = stats.mode & 511;
147
+ if (mode !== 384) {
148
+ process.stderr.write(`mxs: credentials file ${p} had mode ${mode.toString(8)}; chmod 600\n`);
149
+ await promises.chmod(p, 384);
150
+ return true;
151
+ }
152
+ return false;
153
+ }
154
+ function normalizeApiUrl(input) {
155
+ let url = input.trim();
156
+ if (!url) throw new MxsError({
157
+ code: "config.missing.api_url",
158
+ message: "API URL is empty"
159
+ });
160
+ if (!/^https?:\/\//i.test(url)) url = /^(?:localhost|127\.0\.0\.1|::1)(?::\d+)?$/i.test(url) ? `http://${url}` : `https://${url}`;
161
+ return url.replace(/\/+$/, "");
162
+ }
163
+ async function resolveConfig(overrides = {}) {
164
+ const envApiUrl = process.env.MXS_API_URL?.trim();
165
+ const envToken = process.env.MXS_TOKEN?.trim();
166
+ const envApiKey = process.env.MXS_API_KEY?.trim();
167
+ const envProfile = process.env.MXS_PROFILE?.trim();
168
+ const urlOverridden = Boolean(overrides.apiUrl || envApiUrl);
169
+ const profileExplicit = Boolean(overrides.profile || envProfile);
170
+ const profileName = overrides.profile?.trim() || envProfile || await getCurrentProfile() || null;
171
+ if (profileName && !urlOverridden) try {
172
+ if (!(await promises.stat(getProfileDir(profileName))).isDirectory()) throw new MxsError({
173
+ code: "profile.not_found",
174
+ message: `profile '${profileName}' does not exist`,
175
+ hint: "run `mxs profile ls` to see configured profiles, or `mxs auth login --profile <name>` to create one"
176
+ });
177
+ } catch (err) {
178
+ if (err instanceof MxsError) throw err;
179
+ if (err?.code === "ENOENT") throw new MxsError({
180
+ code: "profile.not_found",
181
+ message: `profile '${profileName}' does not exist`,
182
+ hint: "run `mxs profile ls` to see configured profiles, or `mxs auth login --profile <name>` to create one"
183
+ });
184
+ throw err;
185
+ }
186
+ let profileConfig = {};
187
+ if (profileName) profileConfig = await readProfileConfig(profileName);
188
+ const rawApiUrl = overrides.apiUrl || envApiUrl || profileConfig.api_url;
189
+ if (!rawApiUrl) throw new MxsError({
190
+ code: "config.missing.api_url",
191
+ message: "API URL is not configured",
192
+ hint: "set MXS_API_URL or pass --api-url <url>, or run `mxs auth login` in an interactive shell"
193
+ });
194
+ const apiUrl = normalizeApiUrl(rawApiUrl);
195
+ const apiVersion = profileConfig.api_version ?? 2;
196
+ const apiBase = urlOverridden ? `${apiUrl}/api/v${apiVersion}` : profileConfig.api_base || `${apiUrl}/api/v${apiVersion}`;
197
+ const authBase = urlOverridden ? `${apiBase}/auth` : profileConfig.auth_base || `${apiBase}/auth`;
198
+ let token;
199
+ if (urlOverridden) token = overrides.token || envToken || void 0;
200
+ else {
201
+ let profileCreds = null;
202
+ if (profileName) profileCreds = await readProfileCredentials(profileName);
203
+ token = overrides.token || envToken || profileCreds?.access_token;
204
+ }
205
+ const apiKey = overrides.apiKey || envApiKey;
206
+ const isProduction = urlOverridden ? false : profileName ? Boolean(profileConfig.production) : false;
207
+ return {
208
+ apiUrl,
209
+ apiBase,
210
+ authBase,
211
+ apiVersion,
212
+ clientId: profileConfig.client_id || DEFAULT_CLIENT_ID,
213
+ token,
214
+ apiKey,
215
+ configPath: profileName ? getProfileConfigPath(profileName) : getLegacyConfigPath(),
216
+ credentialsPath: profileName ? getProfileCredentialsPath(profileName) : getLegacyCredentialsPath(),
217
+ profileName,
218
+ isProduction,
219
+ profileExplicit,
220
+ urlOverridden
221
+ };
222
+ }
223
+ //#endregion
224
+ export { normalizeApiUrl as a, resolveConfig as c, getConfigDir as d, getCredentialsPath as i, writeConfig as l, enforceCredentialsMode as n, readConfig as o, getConfigPath as r, readCredentials as s, deleteCredentials as t, writeCredentials as u };
225
+
226
+ //# sourceMappingURL=config-store-WL7dNMS6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-store-WL7dNMS6.mjs","names":["fs","readJsonIfExists","fs"],"sources":["../src/core/config-dir.ts","../src/core/profile.ts","../src/core/config-store.ts"],"sourcesContent":["import os from 'node:os'\nimport path from 'node:path'\n\nexport function getConfigDir(): string {\n const xdg = process.env.XDG_CONFIG_HOME\n const base = xdg && xdg.length > 0 ? xdg : path.join(os.homedir(), '.config')\n return path.join(base, 'mxs')\n}\n","import { type Dirent, promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport { getConfigDir } from './config-dir'\nimport type { ConfigShape, CredentialsShape } from './config-store'\nimport { MxsError } from './errors'\n\nexport { getConfigDir }\n\nexport const PROFILE_NAME_RE = /^[\\d_a-z-]{1,32}$/\n\nexport const RESERVED_PROFILE_NAMES = new Set(['current'])\n\nexport function validateProfileName(name: string): void {\n if (!name || name.length === 0) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'profile name must not be empty',\n })\n }\n if (RESERVED_PROFILE_NAMES.has(name)) {\n throw new MxsError({\n code: 'validation.failed',\n message: `profile name '${name}' is reserved`,\n })\n }\n if (!PROFILE_NAME_RE.test(name)) {\n throw new MxsError({\n code: 'validation.failed',\n message: `profile name '${name}' is invalid; must match ^[a-z0-9_-]{1,32}$`,\n })\n }\n}\n\nexport function getProfilesDir(): string {\n return path.join(getConfigDir(), 'profiles')\n}\n\nexport function getCurrentPath(): string {\n return path.join(getConfigDir(), 'current')\n}\n\nexport function getProfileDir(name: string): string {\n return path.join(getProfilesDir(), name)\n}\n\nexport function getProfileConfigPath(name: string): string {\n return path.join(getProfileDir(name), 'config.json')\n}\n\nexport function getProfileCredentialsPath(name: string): string {\n return path.join(getProfileDir(name), 'credentials.json')\n}\n\nexport async function listProfiles(): Promise<string[]> {\n const dir = getProfilesDir()\n let entries: Dirent[]\n try {\n entries = await fs.readdir(dir, { withFileTypes: true })\n } catch (err: any) {\n if (err?.code === 'ENOENT') return []\n throw err\n }\n return entries\n .filter((e) => e.isDirectory() && !e.name.startsWith('.'))\n .map((e) => e.name)\n .sort()\n}\n\nexport async function getCurrentProfile(): Promise<string | null> {\n const p = getCurrentPath()\n try {\n const raw = await fs.readFile(p, 'utf8')\n const name = raw.trim()\n return name.length > 0 ? name : null\n } catch (err: any) {\n if (err?.code === 'ENOENT') return null\n throw err\n }\n}\n\nexport async function setCurrentProfile(name: string): Promise<void> {\n validateProfileName(name)\n const dir = getProfileDir(name)\n try {\n const stat = await fs.stat(dir)\n if (!stat.isDirectory()) {\n throw new MxsError({\n code: 'validation.failed',\n message: `profile '${name}' does not exist`,\n })\n }\n } catch (err: any) {\n if (err instanceof MxsError) throw err\n if (err?.code === 'ENOENT') {\n throw new MxsError({\n code: 'validation.failed',\n message: `profile '${name}' does not exist`,\n })\n }\n throw err\n }\n await fs.writeFile(getCurrentPath(), `${name}\\n`, { encoding: 'utf8' })\n}\n\nasync function readJsonIfExists<T>(p: string): Promise<T | null> {\n try {\n const raw = await fs.readFile(p, 'utf8')\n return JSON.parse(raw) as T\n } catch (err: any) {\n if (err?.code === 'ENOENT') return null\n if (err instanceof SyntaxError) {\n throw new MxsError({\n code: 'generic',\n message: `failed to parse ${p}: ${err.message}`,\n })\n }\n throw err\n }\n}\n\nasync function ensureProfileDir(name: string): Promise<void> {\n const dir = getProfileDir(name)\n await fs.mkdir(dir, { recursive: true, mode: 0o700 })\n try {\n await fs.chmod(dir, 0o700)\n } catch {}\n}\n\nexport type ProfileConfigShape = ConfigShape\nexport type ProfileCredentialsShape = CredentialsShape\n\nexport async function readProfileConfig(\n name: string,\n): Promise<ProfileConfigShape> {\n const data = await readJsonIfExists<ProfileConfigShape>(\n getProfileConfigPath(name),\n )\n return data ?? {}\n}\n\nexport async function writeProfileConfig(\n name: string,\n cfg: ProfileConfigShape,\n): Promise<void> {\n await ensureProfileDir(name)\n const p = getProfileConfigPath(name)\n await fs.writeFile(p, JSON.stringify(cfg, null, 2), { mode: 0o644 })\n try {\n await fs.chmod(p, 0o644)\n } catch {}\n}\n\nexport async function readProfileCredentials(\n name: string,\n): Promise<ProfileCredentialsShape | null> {\n const p = getProfileCredentialsPath(name)\n const data = await readJsonIfExists<ProfileCredentialsShape>(p)\n if (data) {\n await enforceProfileCredentialsMode(p)\n }\n return data\n}\n\nexport async function writeProfileCredentials(\n name: string,\n creds: ProfileCredentialsShape,\n): Promise<void> {\n await ensureProfileDir(name)\n const p = getProfileCredentialsPath(name)\n await fs.writeFile(p, JSON.stringify(creds, null, 2), { mode: 0o600 })\n await fs.chmod(p, 0o600)\n}\n\nexport async function removeProfile(name: string): Promise<void> {\n const dir = getProfileDir(name)\n try {\n await fs.stat(dir)\n } catch (err: any) {\n if (err?.code === 'ENOENT') {\n throw new MxsError({\n code: 'resource.not_found',\n message: `profile '${name}' does not exist`,\n })\n }\n throw err\n }\n await fs.rm(dir, { recursive: true, force: true })\n}\n\nexport async function enforceProfileCredentialsMode(\n p: string,\n): Promise<boolean> {\n let stats\n try {\n stats = await fs.stat(p)\n } catch (err: any) {\n if (err?.code === 'ENOENT') return false\n throw err\n }\n const mode = stats.mode & 0o777\n if (mode !== 0o600) {\n process.stderr.write(\n `mxs: credentials file ${p} had mode ${mode.toString(8)}; chmod 600\\n`,\n )\n await fs.chmod(p, 0o600)\n return true\n }\n return false\n}\n","import { promises as fs } from 'node:fs'\nimport path from 'node:path'\n\nimport { getConfigDir } from './config-dir'\nimport { MxsError } from './errors'\nimport {\n getCurrentProfile,\n getProfileConfigPath,\n getProfileCredentialsPath,\n getProfileDir,\n readProfileConfig,\n readProfileCredentials,\n} from './profile'\n\nexport { getConfigDir }\n\nexport interface ConfigShape {\n api_url?: string\n api_base?: string\n auth_base?: string\n api_version?: number\n client_id?: string\n production?: boolean\n}\n\nexport interface CredentialsShape {\n access_token: string\n refresh_token?: string\n expires_at: number\n user?: {\n id?: string\n email?: string\n name?: string\n }\n}\n\nexport interface ResolvedConfig {\n apiUrl: string\n apiBase: string\n authBase: string\n apiVersion: number\n clientId: string\n token?: string\n apiKey?: string\n configPath: string\n credentialsPath: string\n profileName: string | null\n isProduction: boolean\n profileExplicit: boolean\n urlOverridden: boolean\n}\n\nexport interface StoreOverrides {\n apiUrl?: string\n token?: string\n apiKey?: string\n profile?: string\n}\n\nconst DEFAULT_CLIENT_ID = 'mxs-cli'\n\nexport function getLegacyConfigPath(): string {\n return path.join(getConfigDir(), 'config.json')\n}\n\nexport function getLegacyCredentialsPath(): string {\n return path.join(getConfigDir(), 'credentials.json')\n}\n\n/** @deprecated Use getLegacyConfigPath for migration logic only */\nexport function getConfigPath(): string {\n return getLegacyConfigPath()\n}\n\n/** @deprecated Use getLegacyCredentialsPath for migration logic only */\nexport function getCredentialsPath(): string {\n return getLegacyCredentialsPath()\n}\n\nasync function readJsonIfExists<T>(p: string): Promise<T | null> {\n try {\n const raw = await fs.readFile(p, 'utf8')\n return JSON.parse(raw) as T\n } catch (err: any) {\n if (err?.code === 'ENOENT') return null\n if (err instanceof SyntaxError) {\n throw new MxsError({\n code: 'generic',\n message: `failed to parse ${p}: ${err.message}`,\n })\n }\n throw err\n }\n}\n\nexport async function readConfig(): Promise<ConfigShape> {\n const data = await readJsonIfExists<ConfigShape>(getLegacyConfigPath())\n return data ?? {}\n}\n\nexport async function writeConfig(cfg: ConfigShape): Promise<void> {\n const dir = getConfigDir()\n await fs.mkdir(dir, { recursive: true })\n await fs.writeFile(getLegacyConfigPath(), JSON.stringify(cfg, null, 2), {\n mode: 0o644,\n })\n try {\n await fs.chmod(getLegacyConfigPath(), 0o644)\n } catch {}\n}\n\nexport async function readCredentials(): Promise<CredentialsShape | null> {\n const p = getLegacyCredentialsPath()\n const data = await readJsonIfExists<CredentialsShape>(p)\n if (data) {\n await enforceCredentialsMode(p)\n }\n return data\n}\n\nexport async function writeCredentials(cred: CredentialsShape): Promise<void> {\n const dir = getConfigDir()\n await fs.mkdir(dir, { recursive: true })\n const p = getLegacyCredentialsPath()\n await fs.writeFile(p, JSON.stringify(cred, null, 2), { mode: 0o600 })\n await fs.chmod(p, 0o600)\n}\n\nexport async function deleteCredentials(): Promise<void> {\n const p = getLegacyCredentialsPath()\n try {\n await fs.unlink(p)\n } catch (err: any) {\n if (err?.code !== 'ENOENT') throw err\n }\n}\n\nexport async function enforceCredentialsMode(\n p = getLegacyCredentialsPath(),\n): Promise<boolean> {\n let stats\n try {\n stats = await fs.stat(p)\n } catch (err: any) {\n if (err?.code === 'ENOENT') return false\n throw err\n }\n const mode = stats.mode & 0o777\n if (mode !== 0o600) {\n process.stderr.write(\n `mxs: credentials file ${p} had mode ${mode.toString(8)}; chmod 600\\n`,\n )\n await fs.chmod(p, 0o600)\n return true\n }\n return false\n}\n\nexport function normalizeApiUrl(input: string): string {\n let url = input.trim()\n if (!url) {\n throw new MxsError({\n code: 'config.missing.api_url',\n message: 'API URL is empty',\n })\n }\n if (!/^https?:\\/\\//i.test(url)) {\n const isLocal = /^(?:localhost|127\\.0\\.0\\.1|::1)(?::\\d+)?$/i.test(url)\n url = isLocal ? `http://${url}` : `https://${url}`\n }\n return url.replace(/\\/+$/, '')\n}\n\nexport async function resolveConfig(\n overrides: StoreOverrides = {},\n): Promise<ResolvedConfig> {\n const envApiUrl = process.env.MXS_API_URL?.trim()\n const envToken = process.env.MXS_TOKEN?.trim()\n const envApiKey = process.env.MXS_API_KEY?.trim()\n const envProfile = process.env.MXS_PROFILE?.trim()\n\n const urlOverridden = Boolean(overrides.apiUrl || envApiUrl)\n const profileExplicit = Boolean(overrides.profile || envProfile)\n\n const profileName: string | null =\n overrides.profile?.trim() ||\n envProfile ||\n (await getCurrentProfile()) ||\n null\n\n if (profileName && !urlOverridden) {\n try {\n const stat = await fs.stat(getProfileDir(profileName))\n if (!stat.isDirectory()) {\n throw new MxsError({\n code: 'profile.not_found',\n message: `profile '${profileName}' does not exist`,\n hint: 'run `mxs profile ls` to see configured profiles, or `mxs auth login --profile <name>` to create one',\n })\n }\n } catch (err: any) {\n if (err instanceof MxsError) throw err\n if (err?.code === 'ENOENT') {\n throw new MxsError({\n code: 'profile.not_found',\n message: `profile '${profileName}' does not exist`,\n hint: 'run `mxs profile ls` to see configured profiles, or `mxs auth login --profile <name>` to create one',\n })\n }\n throw err\n }\n }\n\n let profileConfig: ConfigShape = {}\n if (profileName) {\n profileConfig = await readProfileConfig(profileName)\n }\n\n const rawApiUrl = overrides.apiUrl || envApiUrl || profileConfig.api_url\n if (!rawApiUrl) {\n throw new MxsError({\n code: 'config.missing.api_url',\n message: 'API URL is not configured',\n hint: 'set MXS_API_URL or pass --api-url <url>, or run `mxs auth login` in an interactive shell',\n })\n }\n const apiUrl = normalizeApiUrl(rawApiUrl)\n const apiVersion = profileConfig.api_version ?? 2\n const apiBase = urlOverridden\n ? `${apiUrl}/api/v${apiVersion}`\n : profileConfig.api_base || `${apiUrl}/api/v${apiVersion}`\n const authBase = urlOverridden\n ? `${apiBase}/auth`\n : profileConfig.auth_base || `${apiBase}/auth`\n\n let token: string | undefined\n if (urlOverridden) {\n token = overrides.token || envToken || undefined\n } else {\n let profileCreds: Awaited<ReturnType<typeof readProfileCredentials>> = null\n if (profileName) {\n profileCreds = await readProfileCredentials(profileName)\n }\n token = overrides.token || envToken || profileCreds?.access_token\n }\n\n const apiKey = overrides.apiKey || envApiKey\n\n const isProduction = urlOverridden\n ? false\n : profileName\n ? Boolean(profileConfig.production)\n : false\n\n return {\n apiUrl,\n apiBase,\n authBase,\n apiVersion,\n clientId: profileConfig.client_id || DEFAULT_CLIENT_ID,\n token,\n apiKey,\n configPath: profileName\n ? getProfileConfigPath(profileName)\n : getLegacyConfigPath(),\n credentialsPath: profileName\n ? getProfileCredentialsPath(profileName)\n : getLegacyCredentialsPath(),\n profileName,\n isProduction,\n profileExplicit,\n urlOverridden,\n }\n}\n"],"mappings":"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"}
@@ -1,6 +1,6 @@
1
1
  import { i as emitSuccess } from "./output-BM7aBFwt.mjs";
2
2
  import { n as buildPagePayload } from "./payload-CN11pUto.mjs";
3
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
3
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
4
4
  //#region src/commands/page/create.ts
5
5
  async function run(_id, opts, flags, out) {
6
6
  const built = await buildPagePayload(opts);
@@ -16,4 +16,4 @@ async function run(_id, opts, flags, out) {
16
16
  //#endregion
17
17
  export { run };
18
18
 
19
- //# sourceMappingURL=create-Dz6rJJSS.mjs.map
19
+ //# sourceMappingURL=create-BVHnXtIH.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-Dz6rJJSS.mjs","names":[],"sources":["../src/commands/page/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildPagePayload, type PageFlagInputs } from '../../core/payload'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n _id: unknown,\n opts: PageFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildPagePayload(opts)\n if (flags.dryRun) {\n emitSuccess(built.payload, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request('/pages', {\n method: 'POST',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;AAIA,eAAsB,IACpB,KACA,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAOA,aAAY,MALG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,UAAU;EACzC,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
1
+ {"version":3,"file":"create-BVHnXtIH.mjs","names":[],"sources":["../src/commands/page/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildPagePayload, type PageFlagInputs } from '../../core/payload'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n _id: unknown,\n opts: PageFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildPagePayload(opts)\n if (flags.dryRun) {\n emitSuccess(built.payload, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request('/pages', {\n method: 'POST',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;AAIA,eAAsB,IACpB,KACA,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAOA,aAAY,MALG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,UAAU;EACzC,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
@@ -1,5 +1,5 @@
1
1
  import { i as emitSuccess } from "./output-BM7aBFwt.mjs";
2
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
2
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
3
3
  //#region src/commands/topic/create.ts
4
4
  async function run(opts, flags, out) {
5
5
  const body = {
@@ -20,4 +20,4 @@ async function run(opts, flags, out) {
20
20
  //#endregion
21
21
  export { run };
22
22
 
23
- //# sourceMappingURL=create-DT1l2hue.mjs.map
23
+ //# sourceMappingURL=create-BWA2WGrW.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-DT1l2hue.mjs","names":[],"sources":["../src/commands/topic/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport interface TopicCreateFlags {\n name: string\n slug: string\n description?: string\n icon?: string\n}\n\nexport async function run(\n opts: TopicCreateFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const body: Record<string, unknown> = {\n name: opts.name,\n slug: opts.slug,\n }\n if (opts.description) body.description = opts.description\n if (opts.icon) body.icon = opts.icon\n if (flags.dryRun) {\n emitSuccess(body, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request('/topics', { method: 'POST', body })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;AAUA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,OAAgC;EACpC,MAAM,KAAK;EACX,MAAM,KAAK;CACb;CACA,IAAI,KAAK,aAAa,KAAK,cAAc,KAAK;CAC9C,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,GAAG;EACrB;CACF;CAIA,aAAY,MAFG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,WAAW;EAAE,QAAQ;EAAQ;CAAK,CAAC,GACpD,MAAM,GAAG;AAC3B"}
1
+ {"version":3,"file":"create-BWA2WGrW.mjs","names":[],"sources":["../src/commands/topic/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport interface TopicCreateFlags {\n name: string\n slug: string\n description?: string\n icon?: string\n}\n\nexport async function run(\n opts: TopicCreateFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const body: Record<string, unknown> = {\n name: opts.name,\n slug: opts.slug,\n }\n if (opts.description) body.description = opts.description\n if (opts.icon) body.icon = opts.icon\n if (flags.dryRun) {\n emitSuccess(body, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request('/topics', { method: 'POST', body })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;AAUA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,OAAgC;EACpC,MAAM,KAAK;EACX,MAAM,KAAK;CACb;CACA,IAAI,KAAK,aAAa,KAAK,cAAc,KAAK;CAC9C,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,GAAG;EACrB;CACF;CAIA,aAAY,MAFG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,WAAW;EAAE,QAAQ;EAAQ;CAAK,CAAC,GACpD,MAAM,GAAG;AAC3B"}
@@ -1,6 +1,6 @@
1
1
  import { i as emitSuccess, r as emitInfo } from "./output-BM7aBFwt.mjs";
2
2
  import { r as buildPostPayload } from "./payload-CN11pUto.mjs";
3
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
3
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
4
4
  import { n as resolveCategoryRefs, t as buildResolver } from "./resolve-helpers-CahPoJ0Y.mjs";
5
5
  //#region src/commands/post/create.ts
6
6
  async function run(opts, flags, out) {
@@ -21,4 +21,4 @@ async function run(opts, flags, out) {
21
21
  //#endregion
22
22
  export { run };
23
23
 
24
- //# sourceMappingURL=create-B2AOQL1e.mjs.map
24
+ //# sourceMappingURL=create-C85MSrtt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-B2AOQL1e.mjs","names":[],"sources":["../src/commands/post/create.ts"],"sourcesContent":["import { emitInfo, emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildPostPayload, type PostFlagInputs } from '../../core/payload'\nimport { buildResolver, resolveCategoryRefs } from '../internal/resolve-helpers'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n opts: PostFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildPostPayload(opts)\n if (flags.dryRun) {\n emitInfo('dry-run — payload below', out)\n emitSuccess(built.payload, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const resolver = buildResolver(client)\n await resolveCategoryRefs(built.payload, resolver)\n const res = await client.request('/posts', {\n method: 'POST',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;;AAKA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,MAAM,QAAQ;EAChB,SAAS,2BAA2B,GAAG;EACvC,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,WAAW,cAAc,MAAM;CACrC,MAAM,oBAAoB,MAAM,SAAS,QAAQ;CAKjD,aAAY,MAJM,OAAO,QAAQ,UAAU;EACzC,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
1
+ {"version":3,"file":"create-C85MSrtt.mjs","names":[],"sources":["../src/commands/post/create.ts"],"sourcesContent":["import { emitInfo, emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildPostPayload, type PostFlagInputs } from '../../core/payload'\nimport { buildResolver, resolveCategoryRefs } from '../internal/resolve-helpers'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n opts: PostFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildPostPayload(opts)\n if (flags.dryRun) {\n emitInfo('dry-run — payload below', out)\n emitSuccess(built.payload, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const resolver = buildResolver(client)\n await resolveCategoryRefs(built.payload, resolver)\n const res = await client.request('/posts', {\n method: 'POST',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;;AAKA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,MAAM,QAAQ;EAChB,SAAS,2BAA2B,GAAG;EACvC,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,WAAW,cAAc,MAAM;CACrC,MAAM,oBAAoB,MAAM,SAAS,QAAQ;CAKjD,aAAY,MAJM,OAAO,QAAQ,UAAU;EACzC,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
@@ -1,6 +1,6 @@
1
1
  import { i as emitSuccess } from "./output-BM7aBFwt.mjs";
2
2
  import { t as buildNotePayload } from "./payload-CN11pUto.mjs";
3
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
3
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
4
4
  import { r as resolveTopicRefs, t as buildResolver } from "./resolve-helpers-CahPoJ0Y.mjs";
5
5
  //#region src/commands/note/create.ts
6
6
  async function run(opts, flags, out) {
@@ -20,4 +20,4 @@ async function run(opts, flags, out) {
20
20
  //#endregion
21
21
  export { run };
22
22
 
23
- //# sourceMappingURL=create-DjlRHPXy.mjs.map
23
+ //# sourceMappingURL=create-Cxnqt_Wt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-DjlRHPXy.mjs","names":[],"sources":["../src/commands/note/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildNotePayload, type NoteFlagInputs } from '../../core/payload'\nimport { buildResolver, resolveTopicRefs } from '../internal/resolve-helpers'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n opts: NoteFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildNotePayload(opts)\n if (flags.dryRun) {\n emitSuccess(built.payload, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const resolver = buildResolver(client)\n await resolveTopicRefs(built.payload, resolver)\n const res = await client.request('/notes', {\n method: 'POST',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;;AAKA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,WAAW,cAAc,MAAM;CACrC,MAAM,iBAAiB,MAAM,SAAS,QAAQ;CAK9C,aAAY,MAJM,OAAO,QAAQ,UAAU;EACzC,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
1
+ {"version":3,"file":"create-Cxnqt_Wt.mjs","names":[],"sources":["../src/commands/note/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildNotePayload, type NoteFlagInputs } from '../../core/payload'\nimport { buildResolver, resolveTopicRefs } from '../internal/resolve-helpers'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n opts: NoteFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildNotePayload(opts)\n if (flags.dryRun) {\n emitSuccess(built.payload, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const resolver = buildResolver(client)\n await resolveTopicRefs(built.payload, resolver)\n const res = await client.request('/notes', {\n method: 'POST',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;;AAKA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,WAAW,cAAc,MAAM;CACrC,MAAM,iBAAiB,MAAM,SAAS,QAAQ;CAK9C,aAAY,MAJM,OAAO,QAAQ,UAAU;EACzC,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
@@ -1,5 +1,5 @@
1
1
  import { i as emitSuccess } from "./output-BM7aBFwt.mjs";
2
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
2
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
3
3
  //#region src/commands/category/create.ts
4
4
  async function run(opts, flags, out) {
5
5
  const body = {
@@ -20,4 +20,4 @@ async function run(opts, flags, out) {
20
20
  //#endregion
21
21
  export { run };
22
22
 
23
- //# sourceMappingURL=create-CwjGcv2n.mjs.map
23
+ //# sourceMappingURL=create-DUOSAqBm.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-CwjGcv2n.mjs","names":[],"sources":["../src/commands/category/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport interface CategoryCreateFlags {\n name: string\n slug: string\n type?: 'category' | 'tag'\n icon?: string\n}\n\nexport async function run(\n opts: CategoryCreateFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const body: Record<string, unknown> = {\n name: opts.name,\n slug: opts.slug,\n }\n if (opts.type) body.type = opts.type === 'tag' ? 1 : 0\n if (opts.icon) body.icon = opts.icon\n if (flags.dryRun) {\n emitSuccess(body, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request('/categories', {\n method: 'POST',\n body,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;AAUA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,OAAgC;EACpC,MAAM,KAAK;EACX,MAAM,KAAK;CACb;CACA,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,SAAS,QAAQ,IAAI;CACrD,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,GAAG;EACrB;CACF;CAOA,aAAY,MALG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,eAAe;EAC9C,QAAQ;EACR;CACF,CAAC,GACe,MAAM,GAAG;AAC3B"}
1
+ {"version":3,"file":"create-DUOSAqBm.mjs","names":[],"sources":["../src/commands/category/create.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport interface CategoryCreateFlags {\n name: string\n slug: string\n type?: 'category' | 'tag'\n icon?: string\n}\n\nexport async function run(\n opts: CategoryCreateFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const body: Record<string, unknown> = {\n name: opts.name,\n slug: opts.slug,\n }\n if (opts.type) body.type = opts.type === 'tag' ? 1 : 0\n if (opts.icon) body.icon = opts.icon\n if (flags.dryRun) {\n emitSuccess(body, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request('/categories', {\n method: 'POST',\n body,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;AAUA,eAAsB,IACpB,MACA,OACA,KACA;CACA,MAAM,OAAgC;EACpC,MAAM,KAAK;EACX,MAAM,KAAK;CACb;CACA,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,SAAS,QAAQ,IAAI;CACrD,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,GAAG;EACrB;CACF;CAOA,aAAY,MALG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,eAAe;EAC9C,QAAQ;EACR;CACF,CAAC,GACe,MAAM,GAAG;AAC3B"}
@@ -1,6 +1,6 @@
1
1
  import { i as emitSuccess, s as MxsError } from "./output-BM7aBFwt.mjs";
2
2
  import { r as isSnowflakeId } from "./resolve-BogJOR7R.mjs";
3
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
3
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
4
4
  //#region src/commands/topic/delete.ts
5
5
  async function run(slugOrId, opts, flags, out) {
6
6
  if (!opts.force && !flags.dryRun && !process.stdin.isTTY) throw new MxsError({
@@ -28,4 +28,4 @@ async function resolveId(client, slugOrId) {
28
28
  //#endregion
29
29
  export { run };
30
30
 
31
- //# sourceMappingURL=delete-YzRliRn8.mjs.map
31
+ //# sourceMappingURL=delete-BEXOOFAJ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-YzRliRn8.mjs","names":[],"sources":["../src/commands/topic/delete.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { isSnowflakeId } from '../../core/resolve'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveId(client, slugOrId)\n await client.request(`/topics/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n\nasync function resolveId(client: ApiClient, slugOrId: string): Promise<string> {\n if (isSnowflakeId(slugOrId)) return slugOrId\n const res = await client.request<{ id?: string }>(`/topics/slug/${slugOrId}`)\n if (!res.data?.id)\n throw new MxsError({\n code: 'resource.not_found',\n message: `topic not found: ${slugOrId}`,\n })\n return res.data.id\n}\n"],"mappings":";;;;AAMA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,UAAU,QAAQ,QAAQ;CAC3C,MAAM,OAAO,QAAQ,WAAW,MAAM,EAAE,QAAQ,SAAS,CAAC;CAC1D,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC;AAEA,eAAe,UAAU,QAAmB,UAAmC;CAC7E,IAAI,cAAc,QAAQ,GAAG,OAAO;CACpC,MAAM,MAAM,MAAM,OAAO,QAAyB,gBAAgB,UAAU;CAC5E,IAAI,CAAC,IAAI,MAAM,IACb,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,oBAAoB;CAC/B,CAAC;CACH,OAAO,IAAI,KAAK;AAClB"}
1
+ {"version":3,"file":"delete-BEXOOFAJ.mjs","names":[],"sources":["../src/commands/topic/delete.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { isSnowflakeId } from '../../core/resolve'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveId(client, slugOrId)\n await client.request(`/topics/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n\nasync function resolveId(client: ApiClient, slugOrId: string): Promise<string> {\n if (isSnowflakeId(slugOrId)) return slugOrId\n const res = await client.request<{ id?: string }>(`/topics/slug/${slugOrId}`)\n if (!res.data?.id)\n throw new MxsError({\n code: 'resource.not_found',\n message: `topic not found: ${slugOrId}`,\n })\n return res.data.id\n}\n"],"mappings":";;;;AAMA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,UAAU,QAAQ,QAAQ;CAC3C,MAAM,OAAO,QAAQ,WAAW,MAAM,EAAE,QAAQ,SAAS,CAAC;CAC1D,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC;AAEA,eAAe,UAAU,QAAmB,UAAmC;CAC7E,IAAI,cAAc,QAAQ,GAAG,OAAO;CACpC,MAAM,MAAM,MAAM,OAAO,QAAyB,gBAAgB,UAAU;CAC5E,IAAI,CAAC,IAAI,MAAM,IACb,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,oBAAoB;CAC/B,CAAC;CACH,OAAO,IAAI,KAAK;AAClB"}
@@ -1,5 +1,5 @@
1
1
  import { i as emitSuccess, s as MxsError } from "./output-BM7aBFwt.mjs";
2
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
2
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
3
3
  import { t as resolvePostId } from "./resolve-Bp1AfBmM.mjs";
4
4
  //#region src/commands/post/delete.ts
5
5
  async function run(slugOrId, opts, flags, out) {
@@ -19,4 +19,4 @@ async function run(slugOrId, opts, flags, out) {
19
19
  //#endregion
20
20
  export { run };
21
21
 
22
- //# sourceMappingURL=delete-B4dGrrus.mjs.map
22
+ //# sourceMappingURL=delete-CGy-cV6k.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-B4dGrrus.mjs","names":[],"sources":["../src/commands/post/delete.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\nimport { resolvePostId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolvePostId(client, slugOrId)\n await client.request(`/posts/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n"],"mappings":";;;;AAKA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,cAAc,QAAQ,QAAQ;CAC/C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,QAAQ,SAAS,CAAC;CACzD,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC"}
1
+ {"version":3,"file":"delete-CGy-cV6k.mjs","names":[],"sources":["../src/commands/post/delete.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\nimport { resolvePostId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolvePostId(client, slugOrId)\n await client.request(`/posts/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n"],"mappings":";;;;AAKA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,cAAc,QAAQ,QAAQ;CAC/C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,QAAQ,SAAS,CAAC;CACzD,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC"}
@@ -1,5 +1,5 @@
1
1
  import { i as emitSuccess, s as MxsError } from "./output-BM7aBFwt.mjs";
2
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
2
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
3
3
  import { t as resolveNoteId } from "./resolve-CyjMlaoJ.mjs";
4
4
  //#region src/commands/note/delete.ts
5
5
  async function run(slugOrId, opts, flags, out) {
@@ -19,4 +19,4 @@ async function run(slugOrId, opts, flags, out) {
19
19
  //#endregion
20
20
  export { run };
21
21
 
22
- //# sourceMappingURL=delete-BH6ZngTz.mjs.map
22
+ //# sourceMappingURL=delete-CKqlAUT8.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-BH6ZngTz.mjs","names":[],"sources":["../src/commands/note/delete.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport {\n buildApiClient,\n type GlobalFlags,\n resolveContext,\n} from '../internal/shared'\nimport { resolveNoteId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveNoteId(client, slugOrId)\n await client.request(`/notes/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n"],"mappings":";;;;AASA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,cAAc,QAAQ,QAAQ;CAC/C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,QAAQ,SAAS,CAAC;CACzD,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC"}
1
+ {"version":3,"file":"delete-CKqlAUT8.mjs","names":[],"sources":["../src/commands/note/delete.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport {\n buildApiClient,\n type GlobalFlags,\n resolveContext,\n} from '../internal/shared'\nimport { resolveNoteId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveNoteId(client, slugOrId)\n await client.request(`/notes/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n"],"mappings":";;;;AASA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,cAAc,QAAQ,QAAQ;CAC/C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,QAAQ,SAAS,CAAC;CACzD,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC"}
@@ -1,6 +1,6 @@
1
1
  import { i as emitSuccess, s as MxsError } from "./output-BM7aBFwt.mjs";
2
2
  import { r as isSnowflakeId } from "./resolve-BogJOR7R.mjs";
3
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
3
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
4
4
  //#region src/commands/page/delete.ts
5
5
  async function run(slugOrId, opts, flags, out) {
6
6
  if (!opts.force && !flags.dryRun && !process.stdin.isTTY) throw new MxsError({
@@ -28,4 +28,4 @@ async function resolveId(client, slugOrId) {
28
28
  //#endregion
29
29
  export { run };
30
30
 
31
- //# sourceMappingURL=delete-CaG2d_xt.mjs.map
31
+ //# sourceMappingURL=delete-CcyrLNZv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-CaG2d_xt.mjs","names":[],"sources":["../src/commands/page/delete.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { isSnowflakeId } from '../../core/resolve'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveId(client, slugOrId)\n await client.request(`/pages/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n\nasync function resolveId(client: ApiClient, slugOrId: string): Promise<string> {\n if (isSnowflakeId(slugOrId)) return slugOrId\n const res = await client.request<{ id: string }>(`/pages/slug/${slugOrId}`)\n if (!res.data?.id)\n throw new MxsError({\n code: 'resource.not_found',\n message: `page not found: ${slugOrId}`,\n })\n return res.data.id\n}\n"],"mappings":";;;;AAMA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,UAAU,QAAQ,QAAQ;CAC3C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,QAAQ,SAAS,CAAC;CACzD,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC;AAEA,eAAe,UAAU,QAAmB,UAAmC;CAC7E,IAAI,cAAc,QAAQ,GAAG,OAAO;CACpC,MAAM,MAAM,MAAM,OAAO,QAAwB,eAAe,UAAU;CAC1E,IAAI,CAAC,IAAI,MAAM,IACb,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,mBAAmB;CAC9B,CAAC;CACH,OAAO,IAAI,KAAK;AAClB"}
1
+ {"version":3,"file":"delete-CcyrLNZv.mjs","names":[],"sources":["../src/commands/page/delete.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { isSnowflakeId } from '../../core/resolve'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveId(client, slugOrId)\n await client.request(`/pages/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n\nasync function resolveId(client: ApiClient, slugOrId: string): Promise<string> {\n if (isSnowflakeId(slugOrId)) return slugOrId\n const res = await client.request<{ id: string }>(`/pages/slug/${slugOrId}`)\n if (!res.data?.id)\n throw new MxsError({\n code: 'resource.not_found',\n message: `page not found: ${slugOrId}`,\n })\n return res.data.id\n}\n"],"mappings":";;;;AAMA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,UAAU,QAAQ,QAAQ;CAC3C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,QAAQ,SAAS,CAAC;CACzD,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC;AAEA,eAAe,UAAU,QAAmB,UAAmC;CAC7E,IAAI,cAAc,QAAQ,GAAG,OAAO;CACpC,MAAM,MAAM,MAAM,OAAO,QAAwB,eAAe,UAAU;CAC1E,IAAI,CAAC,IAAI,MAAM,IACb,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,mBAAmB;CAC9B,CAAC;CACH,OAAO,IAAI,KAAK;AAClB"}
@@ -1,5 +1,5 @@
1
1
  import { i as emitSuccess, s as MxsError } from "./output-BM7aBFwt.mjs";
2
- import { n as resolveContext, t as buildApiClient } from "./shared-D0HVBDHI.mjs";
2
+ import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
3
3
  import { t as resolveCategoryId } from "./resolve-Bw5Po9yK.mjs";
4
4
  //#region src/commands/category/delete.ts
5
5
  async function run(slugOrId, opts, flags, out) {
@@ -19,4 +19,4 @@ async function run(slugOrId, opts, flags, out) {
19
19
  //#endregion
20
20
  export { run };
21
21
 
22
- //# sourceMappingURL=delete-BrY5zJ6S.mjs.map
22
+ //# sourceMappingURL=delete-Cjxehwj7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-BrY5zJ6S.mjs","names":[],"sources":["../src/commands/category/delete.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport {\n buildApiClient,\n type GlobalFlags,\n resolveContext,\n} from '../internal/shared'\nimport { resolveCategoryId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveCategoryId(client, slugOrId)\n await client.request(`/categories/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n"],"mappings":";;;;AASA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,kBAAkB,QAAQ,QAAQ;CACnD,MAAM,OAAO,QAAQ,eAAe,MAAM,EAAE,QAAQ,SAAS,CAAC;CAC9D,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC"}
1
+ {"version":3,"file":"delete-Cjxehwj7.mjs","names":[],"sources":["../src/commands/category/delete.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport {\n buildApiClient,\n type GlobalFlags,\n resolveContext,\n} from '../internal/shared'\nimport { resolveCategoryId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: { force?: boolean },\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n if (!opts.force && !flags.dryRun && !process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: 'refusing to delete without --force in non-TTY context',\n })\n }\n if (flags.dryRun) {\n emitSuccess({ would_delete: slugOrId }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const id = await resolveCategoryId(client, slugOrId)\n await client.request(`/categories/${id}`, { method: 'DELETE' })\n emitSuccess({ deleted: id }, out)\n}\n"],"mappings":";;;;AASA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,UAAU,CAAC,QAAQ,MAAM,OACjD,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;CACX,CAAC;CAEH,IAAI,MAAM,QAAQ;EAChB,YAAY,EAAE,cAAc,SAAS,GAAG,GAAG;EAC3C;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,kBAAkB,QAAQ,QAAQ;CACnD,MAAM,OAAO,QAAQ,eAAe,MAAM,EAAE,QAAQ,SAAS,CAAC;CAC9D,YAAY,EAAE,SAAS,GAAG,GAAG,GAAG;AAClC"}
@@ -1,6 +1,12 @@
1
1
  import { i as emitSuccess, s as MxsError } from "./output-BM7aBFwt.mjs";
2
2
  import { i as serializeFromLexical } from "./litexml-codec-CDoRloiR.mjs";
3
3
  //#region src/core/document-output.ts
4
+ const POST_LIST_OUTPUT_MODES = new Set([
5
+ "pretty-json",
6
+ "json",
7
+ "readable",
8
+ "llm"
9
+ ]);
4
10
  const DOCUMENT_OUTPUT_MODES = new Set([
5
11
  "pretty-json",
6
12
  "json",
@@ -23,6 +29,19 @@ function emitDocument(kind, data, opts) {
23
29
  const rendered = mode === "envelope" ? renderDocumentEnvelope(kind, doc) : renderReadableDocument(kind, doc);
24
30
  process.stdout.write(`${rendered}\n`);
25
31
  }
32
+ function emitPostList(data, opts) {
33
+ const mode = opts.output ?? "pretty-json";
34
+ if (!POST_LIST_OUTPUT_MODES.has(mode)) throw new MxsError({
35
+ code: "validation.failed",
36
+ message: `unsupported --output value for post list: ${mode}`,
37
+ hint: "use --output pretty-json, json, readable, or llm"
38
+ });
39
+ if (opts.json || mode === "json" || mode === "pretty-json") {
40
+ emitSuccess(data, opts);
41
+ return;
42
+ }
43
+ process.stdout.write(`${renderPostList(data)}\n`);
44
+ }
26
45
  function renderReadableDocument(kind, data) {
27
46
  const doc = asRecord(data);
28
47
  const lines = [kind];
@@ -37,6 +56,42 @@ function renderReadableDocument(kind, data) {
37
56
  if (content.body) lines.push("", `content_format: ${content.format}`, "", "content:", content.body);
38
57
  return lines.join("\n");
39
58
  }
59
+ function renderPostList(data) {
60
+ const payload = asRecord(data);
61
+ const rows = Array.isArray(payload.data) ? payload.data : Array.isArray(data) ? data : [];
62
+ const pagination = asRecord(first(payload, "pagination"));
63
+ const lines = ["posts"];
64
+ if (rows.length > 0) lines.push(`count: ${rows.length}`);
65
+ else lines.push("count: 0");
66
+ const page = first(pagination, "page", "currentPage");
67
+ const size = first(pagination, "size", "pageSize");
68
+ const total = first(pagination, "total", "totalCount");
69
+ if (page !== void 0) lines.push(`page: ${formatScalar(page)}`);
70
+ if (size !== void 0) lines.push(`size: ${formatScalar(size)}`);
71
+ if (total !== void 0) lines.push(`total: ${formatScalar(total)}`);
72
+ rows.forEach((row, index) => {
73
+ const doc = asRecord(row);
74
+ lines.push("", `post ${index + 1}:`);
75
+ const fields = [
76
+ ["id", first(doc, "id")],
77
+ ["title", first(doc, "title")],
78
+ ["slug", first(doc, "slug")],
79
+ ["state", publishState(doc)],
80
+ ["category", relationLabel(first(doc, "category"))],
81
+ ["tags", first(doc, "tags")],
82
+ ["summary", first(doc, "summary")],
83
+ ["created_at", first(doc, "created_at", "createdAt")],
84
+ ["modified_at", first(doc, "modified_at", "modifiedAt")],
85
+ ["source_lang", first(doc, "source_lang", "sourceLang")],
86
+ ["translated", first(doc, "is_translated", "isTranslated")]
87
+ ];
88
+ for (const [key, value] of fields) {
89
+ if (value === void 0 || value === null || value === "") continue;
90
+ lines.push(`${key}: ${formatScalar(value)}`);
91
+ }
92
+ });
93
+ return lines.join("\n");
94
+ }
40
95
  function renderDocumentEnvelope(kind, data) {
41
96
  const doc = asRecord(data);
42
97
  const root = kind === "note" ? "mxnote" : "mxpost";
@@ -140,6 +195,6 @@ function escapeXml(value) {
140
195
  return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
141
196
  }
142
197
  //#endregion
143
- export { renderDocumentEnvelope as n, renderReadableDocument as r, emitDocument as t };
198
+ export { renderReadableDocument as a, renderPostList as i, emitPostList as n, renderDocumentEnvelope as r, emitDocument as t };
144
199
 
145
- //# sourceMappingURL=document-output-BVB8emLt.mjs.map
200
+ //# sourceMappingURL=document-output-C5PWbz2p.mjs.map