@mx-space/cli 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -28
- package/ROADMAP.md +4 -3
- package/dist/{auth-OeKZZ_2x.mjs → auth-Duj8jJn9.mjs} +3 -3
- package/dist/{auth-OeKZZ_2x.mjs.map → auth-Duj8jJn9.mjs.map} +1 -1
- package/dist/bin/mxs.d.mts +2 -1
- package/dist/bin/mxs.mjs +250 -48
- package/dist/bin/mxs.mjs.map +1 -1
- package/dist/{config-store-WL7dNMS6.mjs → config-store-DmwX2iZU.mjs} +15 -76
- package/dist/config-store-DmwX2iZU.mjs.map +1 -0
- package/dist/{create-Cxnqt_Wt.mjs → create-Cqt1rrSZ.mjs} +5 -5
- package/dist/{create-Cxnqt_Wt.mjs.map → create-Cqt1rrSZ.mjs.map} +1 -1
- package/dist/{create-BWA2WGrW.mjs → create-D7cR9xcN.mjs} +3 -3
- package/dist/{create-BWA2WGrW.mjs.map → create-D7cR9xcN.mjs.map} +1 -1
- package/dist/{create-C85MSrtt.mjs → create-DAt3FXLf.mjs} +5 -5
- package/dist/{create-C85MSrtt.mjs.map → create-DAt3FXLf.mjs.map} +1 -1
- package/dist/{create-DUOSAqBm.mjs → create-_H8YO7ze.mjs} +3 -3
- package/dist/{create-DUOSAqBm.mjs.map → create-_H8YO7ze.mjs.map} +1 -1
- package/dist/{create-BVHnXtIH.mjs → create-kYlrs4d6.mjs} +4 -4
- package/dist/{create-BVHnXtIH.mjs.map → create-kYlrs4d6.mjs.map} +1 -1
- package/dist/{delete-Cjxehwj7.mjs → delete-DVNebWqO.mjs} +4 -4
- package/dist/{delete-Cjxehwj7.mjs.map → delete-DVNebWqO.mjs.map} +1 -1
- package/dist/{delete-CGy-cV6k.mjs → delete-D_NRteuq.mjs} +4 -4
- package/dist/{delete-CGy-cV6k.mjs.map → delete-D_NRteuq.mjs.map} +1 -1
- package/dist/{delete-CKqlAUT8.mjs → delete-DmKPzzsQ.mjs} +4 -4
- package/dist/{delete-CKqlAUT8.mjs.map → delete-DmKPzzsQ.mjs.map} +1 -1
- package/dist/{delete-CcyrLNZv.mjs → delete-ZIjkquZj.mjs} +4 -4
- package/dist/{delete-CcyrLNZv.mjs.map → delete-ZIjkquZj.mjs.map} +1 -1
- package/dist/{delete-BEXOOFAJ.mjs → delete-aCVSWuKi.mjs} +4 -4
- package/dist/{delete-BEXOOFAJ.mjs.map → delete-aCVSWuKi.mjs.map} +1 -1
- package/dist/{onboarding-C1t1yoay.mjs → dist-DJF1Ntdn.mjs} +95 -173
- package/dist/dist-DJF1Ntdn.mjs.map +1 -0
- package/dist/{document-output-C5PWbz2p.mjs → document-output-BtY8T7eY.mjs} +3 -3
- package/dist/{document-output-C5PWbz2p.mjs.map → document-output-BtY8T7eY.mjs.map} +1 -1
- package/dist/{edit-t108N11Q.mjs → edit-BWX7X4sy.mjs} +8 -8
- package/dist/{edit-t108N11Q.mjs.map → edit-BWX7X4sy.mjs.map} +1 -1
- package/dist/{edit-BRaZ6GGg.mjs → edit-CHCuoiWT.mjs} +9 -9
- package/dist/{edit-BRaZ6GGg.mjs.map → edit-CHCuoiWT.mjs.map} +1 -1
- package/dist/{edit-BuKMUNVC.mjs → edit-DjRE8Gk-.mjs} +4 -4
- package/dist/{edit-BuKMUNVC.mjs.map → edit-DjRE8Gk-.mjs.map} +1 -1
- package/dist/{edit-DFnOnk4i.mjs → edit-R6H5RtWd.mjs} +8 -8
- package/dist/{edit-DFnOnk4i.mjs.map → edit-R6H5RtWd.mjs.map} +1 -1
- package/dist/{editor-xrF-j3UE.mjs → editor-Dywlo4-8.mjs} +2 -2
- package/dist/{editor-xrF-j3UE.mjs.map → editor-Dywlo4-8.mjs.map} +1 -1
- package/dist/{envelope-overlays-DPAlMNW1.mjs → envelope-overlays-D1gmGVe5.mjs} +2 -2
- package/dist/{envelope-overlays-DPAlMNW1.mjs.map → envelope-overlays-D1gmGVe5.mjs.map} +1 -1
- package/dist/{get-GdRz82RW.mjs → get-CiLnUGHw.mjs} +4 -4
- package/dist/{get-GdRz82RW.mjs.map → get-CiLnUGHw.mjs.map} +1 -1
- package/dist/{get-Doi-NKAh.mjs → get-CkBqVyGi.mjs} +5 -5
- package/dist/{get-Doi-NKAh.mjs.map → get-CkBqVyGi.mjs.map} +1 -1
- package/dist/{get-DxTU7Nom.mjs → get-DNdde54z.mjs} +3 -3
- package/dist/{get-DxTU7Nom.mjs.map → get-DNdde54z.mjs.map} +1 -1
- package/dist/{get-DnDvLa9S.mjs → get-DbH58EkF.mjs} +4 -4
- package/dist/{get-DnDvLa9S.mjs.map → get-DbH58EkF.mjs.map} +1 -1
- package/dist/{get-CwcNFb39.mjs → get-IQQv4_rP.mjs} +3 -3
- package/dist/{get-CwcNFb39.mjs.map → get-IQQv4_rP.mjs.map} +1 -1
- package/dist/{get-BYoAlJwB.mjs → get-xtByxURm.mjs} +4 -4
- package/dist/{get-BYoAlJwB.mjs.map → get-xtByxURm.mjs.map} +1 -1
- package/dist/index.d.mts +19 -2
- package/dist/index.mjs +9 -9
- package/dist/{list-DVunNsXr.mjs → list-Bnlg9SfR.mjs} +3 -3
- package/dist/{list-DVunNsXr.mjs.map → list-Bnlg9SfR.mjs.map} +1 -1
- package/dist/{list-CtME3aDw.mjs → list-C6z1iw4a.mjs} +3 -3
- package/dist/{list-CtME3aDw.mjs.map → list-C6z1iw4a.mjs.map} +1 -1
- package/dist/{list-CLAcZYZ4.mjs → list-CD9j9did.mjs} +3 -3
- package/dist/{list-CLAcZYZ4.mjs.map → list-CD9j9did.mjs.map} +1 -1
- package/dist/{list-DbNCVZbz.mjs → list-DVMtBAHG.mjs} +3 -3
- package/dist/{list-DbNCVZbz.mjs.map → list-DVMtBAHG.mjs.map} +1 -1
- package/dist/{list-DHG-MzOM.mjs → list-DW5TcGxS.mjs} +3 -3
- package/dist/{list-DHG-MzOM.mjs.map → list-DW5TcGxS.mjs.map} +1 -1
- package/dist/{list-DN81zVDA.mjs → list-lmpHwOQx.mjs} +3 -3
- package/dist/{list-DN81zVDA.mjs.map → list-lmpHwOQx.mjs.map} +1 -1
- package/dist/{litexml-codec-CDoRloiR.mjs → litexml-codec-D-1oggXL.mjs} +3 -3
- package/dist/{litexml-codec-CDoRloiR.mjs.map → litexml-codec-D-1oggXL.mjs.map} +1 -1
- package/dist/{login-mjliJn8U.mjs → login-D-SoeV01.mjs} +20 -9
- package/dist/{login-mjliJn8U.mjs.map → login-D-SoeV01.mjs.map} +1 -1
- package/dist/logout-D63ZU-1Q.mjs +17 -0
- package/dist/logout-D63ZU-1Q.mjs.map +1 -0
- package/dist/ls-Bz3BCcwU.mjs +32 -0
- package/dist/ls-Bz3BCcwU.mjs.map +1 -0
- package/dist/mark-N-IpKK17.mjs +28 -0
- package/dist/mark-N-IpKK17.mjs.map +1 -0
- package/dist/onboarding-FPMcuqn8.mjs +212 -0
- package/dist/onboarding-FPMcuqn8.mjs.map +1 -0
- package/dist/{output-CTnO1lYt.d.mts → output-DQMhacTo.d.mts} +1 -1
- package/dist/output-Dg8PISJM.mjs +299 -0
- package/dist/output-Dg8PISJM.mjs.map +1 -0
- package/dist/{payload-CN11pUto.mjs → payload-CjlZ9CeZ.mjs} +3 -3
- package/dist/{payload-CN11pUto.mjs.map → payload-CjlZ9CeZ.mjs.map} +1 -1
- package/dist/{publish-CN3NTJ_r.mjs → publish-C9O5obZ6.mjs} +4 -4
- package/dist/{publish-CN3NTJ_r.mjs.map → publish-C9O5obZ6.mjs.map} +1 -1
- package/dist/{publish-akQWYsnL.mjs → publish-yuM6YGSb.mjs} +4 -4
- package/dist/{publish-akQWYsnL.mjs.map → publish-yuM6YGSb.mjs.map} +1 -1
- package/dist/{resolve-Bp1AfBmM.mjs → resolve-B4-fMQ6I.mjs} +3 -3
- package/dist/{resolve-Bp1AfBmM.mjs.map → resolve-B4-fMQ6I.mjs.map} +1 -1
- package/dist/{resolve-BogJOR7R.mjs → resolve-DIu9N2sD.mjs} +2 -2
- package/dist/{resolve-BogJOR7R.mjs.map → resolve-DIu9N2sD.mjs.map} +1 -1
- package/dist/{resolve-CyjMlaoJ.mjs → resolve-TBYXBS4i.mjs} +3 -3
- package/dist/{resolve-CyjMlaoJ.mjs.map → resolve-TBYXBS4i.mjs.map} +1 -1
- package/dist/{resolve-Bw5Po9yK.mjs → resolve-U6RJ3AnQ.mjs} +3 -3
- package/dist/{resolve-Bw5Po9yK.mjs.map → resolve-U6RJ3AnQ.mjs.map} +1 -1
- package/dist/{resolve-helpers-CahPoJ0Y.mjs → resolve-helpers-C7PIVziv.mjs} +2 -2
- package/dist/{resolve-helpers-CahPoJ0Y.mjs.map → resolve-helpers-C7PIVziv.mjs.map} +1 -1
- package/dist/rm-D9GvLhhF.mjs +32 -0
- package/dist/rm-D9GvLhhF.mjs.map +1 -0
- package/dist/{set-ClbrGFGv.mjs → set-jD79hpuF.mjs} +3 -3
- package/dist/{set-ClbrGFGv.mjs.map → set-jD79hpuF.mjs.map} +1 -1
- package/dist/{shared-C2EAn5h_.mjs → shared-SryY2QPY.mjs} +12 -8
- package/dist/shared-SryY2QPY.mjs.map +1 -0
- package/dist/show-C5Zk0tcK.mjs +38 -0
- package/dist/show-C5Zk0tcK.mjs.map +1 -0
- package/dist/status-evZpPR3N.mjs +22 -0
- package/dist/status-evZpPR3N.mjs.map +1 -0
- package/dist/{update-CHmckeo8.mjs → update--7NPzL_w.mjs} +4 -4
- package/dist/{update-CHmckeo8.mjs.map → update--7NPzL_w.mjs.map} +1 -1
- package/dist/{update-qfiC-9Og.mjs → update-0q5hxJFh.mjs} +5 -5
- package/dist/{update-qfiC-9Og.mjs.map → update-0q5hxJFh.mjs.map} +1 -1
- package/dist/{update-Duh-iVOZ.mjs → update-CPJXcOg_.mjs} +6 -6
- package/dist/{update-Duh-iVOZ.mjs.map → update-CPJXcOg_.mjs.map} +1 -1
- package/dist/{update-CJjwg09n.mjs → update-DN78pXGZ.mjs} +4 -4
- package/dist/{update-CJjwg09n.mjs.map → update-DN78pXGZ.mjs.map} +1 -1
- package/dist/{update-dc-72pUN.mjs → update-hhAcAz_M.mjs} +6 -6
- package/dist/{update-dc-72pUN.mjs.map → update-hhAcAz_M.mjs.map} +1 -1
- package/dist/use-CHDCEe38.mjs +28 -0
- package/dist/use-CHDCEe38.mjs.map +1 -0
- package/dist/{whoami-UwcdRchK.mjs → whoami-BHDYyY5D.mjs} +4 -5
- package/dist/whoami-BHDYyY5D.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-hT5z_Zn9.mjs +0 -35
- package/dist/config-store-WL7dNMS6.mjs.map +0 -1
- package/dist/logout-Bslt_ZJ4.mjs +0 -11
- package/dist/logout-Bslt_ZJ4.mjs.map +0 -1
- package/dist/onboarding-C1t1yoay.mjs.map +0 -1
- package/dist/output-BM7aBFwt.mjs +0 -120
- package/dist/output-BM7aBFwt.mjs.map +0 -1
- package/dist/shared-C2EAn5h_.mjs.map +0 -1
- package/dist/status-Cvyrrx-J.mjs +0 -22
- package/dist/status-Cvyrrx-J.mjs.map +0 -1
- package/dist/whoami-UwcdRchK.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-
|
|
1
|
+
{"version":3,"file":"resolve-DIu9N2sD.mjs","names":[],"sources":["../src/core/resolve.ts"],"sourcesContent":["import { MxsError } from './errors'\n\nexport interface ResolvableItem {\n id: string\n slug?: string\n name?: string\n}\n\nexport interface ResolverFetchers {\n fetchCategories?: () => Promise<ResolvableItem[]>\n fetchTopics?: () => Promise<ResolvableItem[]>\n}\n\ninterface CacheEntry {\n expiresAt: number\n items: ResolvableItem[]\n}\n\nconst SNOWFLAKE_RE = /^\\d{15,}$/\n\nexport function isSnowflakeId(value: string): boolean {\n return SNOWFLAKE_RE.test(value)\n}\n\nexport class NameResolver {\n private cache = new Map<string, CacheEntry>()\n private ttlMs: number\n\n constructor(\n private fetchers: ResolverFetchers,\n { ttlMs = 60_000 }: { ttlMs?: number } = {},\n ) {\n this.ttlMs = ttlMs\n }\n\n async resolveCategory(value: string): Promise<string> {\n return this.resolveWith('category', value, this.fetchers.fetchCategories)\n }\n\n async resolveTopic(value: string): Promise<string> {\n return this.resolveWith('topic', value, this.fetchers.fetchTopics)\n }\n\n invalidate(kind?: string): void {\n if (!kind) {\n this.cache.clear()\n return\n }\n this.cache.delete(kind)\n }\n\n private async resolveWith(\n kind: 'category' | 'topic',\n value: string,\n fetcher: (() => Promise<ResolvableItem[]>) | undefined,\n ): Promise<string> {\n if (isSnowflakeId(value)) return value\n if (!fetcher) {\n throw new MxsError({\n code: 'validation.failed',\n message: `cannot resolve ${kind}: no fetcher configured`,\n })\n }\n const items = await this.load(kind, fetcher)\n const hit = matchItem(items, value)\n if (hit) return hit.id\n const suggestions = fuzzySuggest(items, value)\n throw new MxsError({\n code: 'validation.failed',\n message: `${kind} \"${value}\" not found`,\n details: {\n issues: [\n {\n path: ['meta', kind],\n message: 'not found',\n ...(suggestions.length ? { suggestions } : {}),\n },\n ],\n },\n hint:\n kind === 'category'\n ? 'run `mxs category list` to see available categories'\n : 'run `mxs topic list` to see available topics',\n })\n }\n\n private async load(\n kind: string,\n fetcher: () => Promise<ResolvableItem[]>,\n ): Promise<ResolvableItem[]> {\n const cached = this.cache.get(kind)\n const now = Date.now()\n if (cached && cached.expiresAt > now) return cached.items\n const items = await fetcher()\n this.cache.set(kind, { items, expiresAt: now + this.ttlMs })\n return items\n }\n}\n\nexport function matchItem(\n items: ReadonlyArray<ResolvableItem>,\n value: string,\n): ResolvableItem | null {\n const bySlug = items.find((i) => i.slug && i.slug === value)\n if (bySlug) return bySlug\n const byName = items.find((i) => i.name && i.name === value)\n if (byName) return byName\n const lower = value.toLowerCase()\n const byNameCi = items.find((i) => i.name && i.name.toLowerCase() === lower)\n if (byNameCi) return byNameCi\n const bySlugCi = items.find((i) => i.slug && i.slug.toLowerCase() === lower)\n if (bySlugCi) return bySlugCi\n return null\n}\n\nexport function levenshtein(a: string, b: string): number {\n if (a === b) return 0\n if (!a.length) return b.length\n if (!b.length) return a.length\n const m = a.length\n const n = b.length\n let prev = Array.from<number>({ length: n + 1 })\n let curr = Array.from<number>({ length: n + 1 })\n for (let j = 0; j <= n; j++) prev[j] = j\n for (let i = 1; i <= m; i++) {\n curr[0] = i\n for (let j = 1; j <= n; j++) {\n const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1\n curr[j] = Math.min(\n (curr[j - 1] ?? 0) + 1,\n (prev[j] ?? 0) + 1,\n (prev[j - 1] ?? 0) + cost,\n )\n }\n ;[prev, curr] = [curr, prev]\n }\n return prev[n] ?? 0\n}\n\nexport function fuzzySuggest(\n items: ReadonlyArray<ResolvableItem>,\n value: string,\n maxDistance = 2,\n): string[] {\n const lower = value.toLowerCase()\n const scored: { label: string; score: number }[] = []\n for (const item of items) {\n const candidates: string[] = []\n if (item.name) candidates.push(item.name)\n if (item.slug) candidates.push(item.slug)\n let best = Number.POSITIVE_INFINITY\n let label = item.name ?? item.slug ?? item.id\n for (const c of candidates) {\n const d = levenshtein(c.toLowerCase(), lower)\n if (d < best) {\n best = d\n label = c\n }\n }\n if (best <= maxDistance) scored.push({ label, score: best })\n }\n scored.sort((a, b) => a.score - b.score)\n return scored.slice(0, 3).map((s) => s.label)\n}\n"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as isSnowflakeId } from "./resolve-
|
|
1
|
+
import { C as MxsError } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { r as isSnowflakeId } from "./resolve-DIu9N2sD.mjs";
|
|
3
3
|
//#region src/commands/note/resolve.ts
|
|
4
4
|
async function resolveNoteId(client, slugOrId) {
|
|
5
5
|
if (isSnowflakeId(slugOrId)) return slugOrId;
|
|
@@ -20,4 +20,4 @@ async function resolveNoteId(client, slugOrId) {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { resolveNoteId as t };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=resolve-
|
|
23
|
+
//# sourceMappingURL=resolve-TBYXBS4i.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-
|
|
1
|
+
{"version":3,"file":"resolve-TBYXBS4i.mjs","names":[],"sources":["../src/commands/note/resolve.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { isSnowflakeId } from '../../core/resolve'\n\ninterface NidEnvelope {\n data?: { id?: string }\n id?: string\n}\n\nexport async function resolveNoteId(\n client: ApiClient,\n slugOrId: string,\n): Promise<string> {\n if (isSnowflakeId(slugOrId)) return slugOrId\n if (/^\\d+$/.test(slugOrId)) {\n const res = await client.request<NidEnvelope>(\n `/notes/nid/${encodeURIComponent(slugOrId)}`,\n { query: { single: '1' } },\n )\n const id = res.data?.data?.id ?? res.data?.id\n if (!id) {\n throw new MxsError({\n code: 'resource.not_found',\n message: `note not found: ${slugOrId}`,\n })\n }\n return id\n }\n throw new MxsError({\n code: 'validation.failed',\n message: `invalid note reference: ${slugOrId} (use snowflake id or numeric nid)`,\n })\n}\n"],"mappings":";;;AASA,eAAsB,cACpB,QACA,UACiB;CACjB,IAAI,cAAc,QAAQ,GAAG,OAAO;CACpC,IAAI,QAAQ,KAAK,QAAQ,GAAG;EAC1B,MAAM,MAAM,MAAM,OAAO,QACvB,cAAc,mBAAmB,QAAQ,KACzC,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE,CAC3B;EACA,MAAM,KAAK,IAAI,MAAM,MAAM,MAAM,IAAI,MAAM;EAC3C,IAAI,CAAC,IACH,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,mBAAmB;EAC9B,CAAC;EAEH,OAAO;CACT;CACA,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,2BAA2B,SAAS;CAC/C,CAAC;AACH"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as isSnowflakeId } from "./resolve-
|
|
1
|
+
import { C as MxsError } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { r as isSnowflakeId } from "./resolve-DIu9N2sD.mjs";
|
|
3
3
|
//#region src/commands/category/resolve.ts
|
|
4
4
|
async function resolveCategoryId(client, slugOrId) {
|
|
5
5
|
if (isSnowflakeId(slugOrId)) return slugOrId;
|
|
@@ -13,4 +13,4 @@ async function resolveCategoryId(client, slugOrId) {
|
|
|
13
13
|
//#endregion
|
|
14
14
|
export { resolveCategoryId as t };
|
|
15
15
|
|
|
16
|
-
//# sourceMappingURL=resolve-
|
|
16
|
+
//# sourceMappingURL=resolve-U6RJ3AnQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-
|
|
1
|
+
{"version":3,"file":"resolve-U6RJ3AnQ.mjs","names":[],"sources":["../src/commands/category/resolve.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { isSnowflakeId } from '../../core/resolve'\n\ninterface CategoryEnvelope {\n data?: { id?: string }\n}\n\nexport async function resolveCategoryId(\n client: ApiClient,\n slugOrId: string,\n): Promise<string> {\n if (isSnowflakeId(slugOrId)) return slugOrId\n const res = await client.request<CategoryEnvelope>(\n `/categories/${encodeURIComponent(slugOrId)}`,\n )\n const id = res.data?.data?.id\n if (!id) {\n throw new MxsError({\n code: 'resource.not_found',\n message: `category not found: ${slugOrId}`,\n })\n }\n return id\n}\n"],"mappings":";;;AAQA,eAAsB,kBACpB,QACA,UACiB;CACjB,IAAI,cAAc,QAAQ,GAAG,OAAO;CAIpC,MAAM,MAAK,MAHO,OAAO,QACvB,eAAe,mBAAmB,QAAQ,GAC5C,GACe,MAAM,MAAM;CAC3B,IAAI,CAAC,IACH,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,uBAAuB;CAClC,CAAC;CAEH,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as NameResolver } from "./resolve-
|
|
1
|
+
import { t as NameResolver } from "./resolve-DIu9N2sD.mjs";
|
|
2
2
|
//#region src/commands/internal/resolve-helpers.ts
|
|
3
3
|
function buildResolver(client) {
|
|
4
4
|
return new NameResolver({
|
|
@@ -27,4 +27,4 @@ async function resolveTopicRefs(payload, resolver) {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { resolveCategoryRefs as n, resolveTopicRefs as r, buildResolver as t };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=resolve-helpers-
|
|
30
|
+
//# sourceMappingURL=resolve-helpers-C7PIVziv.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-helpers-
|
|
1
|
+
{"version":3,"file":"resolve-helpers-C7PIVziv.mjs","names":[],"sources":["../src/commands/internal/resolve-helpers.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { NameResolver, type ResolvableItem } from '../../core/resolve'\n\nexport function buildResolver(client: ApiClient): NameResolver {\n return new NameResolver({\n fetchCategories: async () => {\n const res = await client.request<\n { data: ResolvableItem[] } | ResolvableItem[]\n >('/categories')\n const data = Array.isArray(res.data) ? res.data : res.data?.data\n return Array.isArray(data) ? data : []\n },\n fetchTopics: async () => {\n const res = await client.request<\n { data: ResolvableItem[] } | ResolvableItem[]\n >('/topics/all')\n const data = Array.isArray(res.data) ? res.data : res.data?.data\n return Array.isArray(data) ? data : []\n },\n })\n}\n\nexport async function resolveCategoryRefs(\n payload: Record<string, unknown>,\n resolver: NameResolver,\n): Promise<void> {\n const nameRef = payload.__categoryName\n delete payload.__categoryName\n if (\n typeof nameRef === 'string' &&\n nameRef.length > 0 &&\n !payload.categoryId\n ) {\n payload.categoryId = await resolver.resolveCategory(nameRef)\n }\n}\n\nexport async function resolveTopicRefs(\n payload: Record<string, unknown>,\n resolver: NameResolver,\n): Promise<void> {\n const nameRef = payload.__topicName\n delete payload.__topicName\n if (typeof nameRef === 'string' && nameRef.length > 0 && !payload.topicId) {\n payload.topicId = await resolver.resolveTopic(nameRef)\n }\n}\n"],"mappings":";;AAGA,SAAgB,cAAc,QAAiC;CAC7D,OAAO,IAAI,aAAa;EACtB,iBAAiB,YAAY;GAC3B,MAAM,MAAM,MAAM,OAAO,QAEvB,aAAa;GACf,MAAM,OAAO,MAAM,QAAQ,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,MAAM;GAC5D,OAAO,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC;EACvC;EACA,aAAa,YAAY;GACvB,MAAM,MAAM,MAAM,OAAO,QAEvB,aAAa;GACf,MAAM,OAAO,MAAM,QAAQ,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,MAAM;GAC5D,OAAO,MAAM,QAAQ,IAAI,IAAI,OAAO,CAAC;EACvC;CACF,CAAC;AACH;AAEA,eAAsB,oBACpB,SACA,UACe;CACf,MAAM,UAAU,QAAQ;CACxB,OAAO,QAAQ;CACf,IACE,OAAO,YAAY,YACnB,QAAQ,SAAS,KACjB,CAAC,QAAQ,YAET,QAAQ,aAAa,MAAM,SAAS,gBAAgB,OAAO;AAE/D;AAEA,eAAsB,iBACpB,SACA,UACe;CACf,MAAM,UAAU,QAAQ;CACxB,OAAO,QAAQ;CACf,IAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,KAAK,CAAC,QAAQ,SAChE,QAAQ,UAAU,MAAM,SAAS,aAAa,OAAO;AAEzD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { n as ue, r as q } from "./dist-DJF1Ntdn.mjs";
|
|
2
|
+
import { C as MxsError, _ as removeProfile, c as getCurrentPath, l as getCurrentProfile, r as emitInfo, y as validateProfileName } from "./output-Dg8PISJM.mjs";
|
|
3
|
+
import { promises } from "node:fs";
|
|
4
|
+
//#region src/commands/profile/rm.ts
|
|
5
|
+
async function run(name, opts, _flags, out) {
|
|
6
|
+
validateProfileName(name);
|
|
7
|
+
const current = await getCurrentProfile();
|
|
8
|
+
if (current === name && !opts.force) throw new MxsError({
|
|
9
|
+
code: "validation.failed",
|
|
10
|
+
message: `profile '${name}' is currently active; pass --force to remove it`,
|
|
11
|
+
hint: "switch to another profile first with `mxs profile use <name>`"
|
|
12
|
+
});
|
|
13
|
+
if (!opts.force) {
|
|
14
|
+
if (!process.stdin.isTTY) throw new MxsError({
|
|
15
|
+
code: "validation.failed",
|
|
16
|
+
message: `cannot remove profile '${name}' non-interactively`,
|
|
17
|
+
hint: "pass --force to confirm removal in a non-interactive context"
|
|
18
|
+
});
|
|
19
|
+
const confirmed = await ue({ message: `Remove profile '${name}'? This cannot be undone.` });
|
|
20
|
+
if (q(confirmed) || !confirmed) return;
|
|
21
|
+
}
|
|
22
|
+
await removeProfile(name);
|
|
23
|
+
emitInfo(`mxs: profile '${name}' removed`, out);
|
|
24
|
+
if (current === name) {
|
|
25
|
+
await promises.rm(getCurrentPath(), { force: true });
|
|
26
|
+
emitInfo("mxs: cleared active profile pointer", out);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { run };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=rm-D9GvLhhF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rm-D9GvLhhF.mjs","names":["confirm","isCancel","fs"],"sources":["../src/commands/profile/rm.ts"],"sourcesContent":["import { promises as fs } from 'node:fs'\n\nimport { confirm, isCancel } from '@clack/prompts'\n\nimport { MxsError } from '../../core/errors'\nimport { emitInfo, type OutputOptions } from '../../core/output'\nimport {\n getCurrentPath,\n getCurrentProfile,\n removeProfile,\n validateProfileName,\n} from '../../core/profile'\nimport type { GlobalFlags } from '../internal/shared'\n\nexport interface RmOpts {\n force?: boolean\n}\n\nexport async function run(\n name: string,\n opts: RmOpts,\n _flags: GlobalFlags,\n out: OutputOptions,\n) {\n validateProfileName(name)\n\n const current = await getCurrentProfile()\n if (current === name && !opts.force) {\n throw new MxsError({\n code: 'validation.failed',\n message: `profile '${name}' is currently active; pass --force to remove it`,\n hint: 'switch to another profile first with `mxs profile use <name>`',\n })\n }\n\n if (!opts.force) {\n if (!process.stdin.isTTY) {\n throw new MxsError({\n code: 'validation.failed',\n message: `cannot remove profile '${name}' non-interactively`,\n hint: 'pass --force to confirm removal in a non-interactive context',\n })\n }\n const confirmed = await confirm({\n message: `Remove profile '${name}'? This cannot be undone.`,\n })\n if (isCancel(confirmed) || !confirmed) {\n return\n }\n }\n\n await removeProfile(name)\n emitInfo(`mxs: profile '${name}' removed`, out)\n\n if (current === name) {\n // clear the stale active-profile pointer so subsequent commands don't\n // hit profile.not_found on a profile that no longer exists\n await fs.rm(getCurrentPath(), { force: true })\n emitInfo('mxs: cleared active profile pointer', out)\n }\n}\n"],"mappings":";;;;AAkBA,eAAsB,IACpB,MACA,MACA,QACA,KACA;CACA,oBAAoB,IAAI;CAExB,MAAM,UAAU,MAAM,kBAAkB;CACxC,IAAI,YAAY,QAAQ,CAAC,KAAK,OAC5B,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS,YAAY,KAAK;EAC1B,MAAM;CACR,CAAC;CAGH,IAAI,CAAC,KAAK,OAAO;EACf,IAAI,CAAC,QAAQ,MAAM,OACjB,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,0BAA0B,KAAK;GACxC,MAAM;EACR,CAAC;EAEH,MAAM,YAAY,MAAMA,GAAQ,EAC9B,SAAS,mBAAmB,KAAK,2BACnC,CAAC;EACD,IAAIC,EAAS,SAAS,KAAK,CAAC,WAC1B;CAEJ;CAEA,MAAM,cAAc,IAAI;CACxB,SAAS,iBAAiB,KAAK,YAAY,GAAG;CAE9C,IAAI,YAAY,MAAM;EAGpB,MAAMC,SAAG,GAAG,eAAe,GAAG,EAAE,OAAO,KAAK,CAAC;EAC7C,SAAS,uCAAuC,GAAG;CACrD;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-
|
|
1
|
+
import { C as MxsError, i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
3
3
|
//#region src/commands/config/set.ts
|
|
4
4
|
async function run(key, value, opts, flags, out) {
|
|
5
5
|
const coerced = coerce(value, opts.type);
|
|
@@ -40,4 +40,4 @@ function coerce(value, type) {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
export { run };
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=set-
|
|
43
|
+
//# sourceMappingURL=set-jD79hpuF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-
|
|
1
|
+
{"version":3,"file":"set-jD79hpuF.mjs","names":[],"sources":["../src/commands/config/set.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport interface ConfigSetFlags {\n type?: 'json' | 'string' | 'number' | 'bool'\n}\n\nexport async function run(\n key: string,\n value: string,\n opts: ConfigSetFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const coerced = coerce(value, opts.type)\n if (flags.dryRun) {\n emitSuccess({ key, value: coerced }, out)\n return\n }\n const ctx = await resolveContext(flags, out)\n const client = buildApiClient(ctx, flags)\n const res = await client.request(`/options/${key}`, {\n method: 'PATCH',\n body: coerced,\n })\n emitSuccess(res.data, out)\n}\n\nfunction coerce(value: string, type?: ConfigSetFlags['type']): unknown {\n if (type === 'string') return value\n if (type === 'number') {\n const n = Number(value)\n if (Number.isNaN(n))\n throw new MxsError({\n code: 'validation.failed',\n message: `invalid number: ${value}`,\n })\n return n\n }\n if (type === 'bool') return value === 'true'\n if (type === 'json' || type === undefined) {\n try {\n return JSON.parse(value)\n } catch {\n if (type === 'json')\n throw new MxsError({\n code: 'validation.failed',\n message: `invalid JSON: ${value}`,\n })\n return value\n }\n }\n return value\n}\n"],"mappings":";;;AAQA,eAAsB,IACpB,KACA,OACA,MACA,OACA,KACA;CACA,MAAM,UAAU,OAAO,OAAO,KAAK,IAAI;CACvC,IAAI,MAAM,QAAQ;EAChB,YAAY;GAAE;GAAK,OAAO;EAAQ,GAAG,GAAG;EACxC;CACF;CAOA,aAAY,MALG,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KACZ,EAAE,QAAQ,YAAY,OAAO;EAClD,QAAQ;EACR,MAAM;CACR,CAAC,GACe,MAAM,GAAG;AAC3B;AAEA,SAAS,OAAO,OAAe,MAAwC;CACrE,IAAI,SAAS,UAAU,OAAO;CAC9B,IAAI,SAAS,UAAU;EACrB,MAAM,IAAI,OAAO,KAAK;EACtB,IAAI,OAAO,MAAM,CAAC,GAChB,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,mBAAmB;EAC9B,CAAC;EACH,OAAO;CACT;CACA,IAAI,SAAS,QAAQ,OAAO,UAAU;CACtC,IAAI,SAAS,UAAU,SAAS,KAAA,GAC9B,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,IAAI,SAAS,QACX,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,iBAAiB;EAC5B,CAAC;EACH,OAAO;CACT;CAEF,OAAO;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as ApiClient, t as runOnboarding } from "./onboarding-
|
|
1
|
+
import { C as MxsError, r as emitInfo } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { u as resolveConfig } from "./config-store-DmwX2iZU.mjs";
|
|
3
|
+
import { n as ApiClient, t as runOnboarding } from "./onboarding-FPMcuqn8.mjs";
|
|
4
4
|
//#region src/commands/internal/shared.ts
|
|
5
5
|
async function resolveContext(flags, out) {
|
|
6
6
|
let resolved;
|
|
@@ -8,15 +8,17 @@ async function resolveContext(flags, out) {
|
|
|
8
8
|
resolved = await resolveConfig({
|
|
9
9
|
apiUrl: flags.apiUrl,
|
|
10
10
|
token: flags.token,
|
|
11
|
-
apiKey: flags.apiKey
|
|
11
|
+
apiKey: flags.apiKey,
|
|
12
|
+
profile: flags.profile
|
|
12
13
|
});
|
|
13
14
|
} catch (err) {
|
|
14
15
|
if (err instanceof MxsError && err.code === "config.missing.api_url") {
|
|
15
|
-
emitInfo(`saved ${(await runOnboarding()).apiUrl} to config`, out);
|
|
16
|
+
emitInfo(`saved ${(await runOnboarding({ profile: flags.profile ?? process.env.MXS_PROFILE })).apiUrl} to config`, out);
|
|
16
17
|
resolved = await resolveConfig({
|
|
17
18
|
apiUrl: flags.apiUrl,
|
|
18
19
|
token: flags.token,
|
|
19
|
-
apiKey: flags.apiKey
|
|
20
|
+
apiKey: flags.apiKey,
|
|
21
|
+
profile: flags.profile
|
|
20
22
|
});
|
|
21
23
|
} else throw err;
|
|
22
24
|
}
|
|
@@ -30,7 +32,9 @@ function buildApiClient(resolved, flags) {
|
|
|
30
32
|
token: resolved.token,
|
|
31
33
|
apiKey: resolved.apiKey,
|
|
32
34
|
autoRefresh: Boolean(resolved.token) && !resolved.apiKey && !flags.token && !process.env.MXS_TOKEN,
|
|
33
|
-
verbose: flags.verbose
|
|
35
|
+
verbose: flags.verbose,
|
|
36
|
+
quiet: flags.quiet,
|
|
37
|
+
resolved
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
40
|
function withLangQuery(flags, query = {}) {
|
|
@@ -43,4 +47,4 @@ function withLangQuery(flags, query = {}) {
|
|
|
43
47
|
//#endregion
|
|
44
48
|
export { resolveContext as n, withLangQuery as r, buildApiClient as t };
|
|
45
49
|
|
|
46
|
-
//# sourceMappingURL=shared-
|
|
50
|
+
//# sourceMappingURL=shared-SryY2QPY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-SryY2QPY.mjs","names":[],"sources":["../src/commands/internal/shared.ts"],"sourcesContent":["import { ApiClient } from '../../core/api-client'\nimport { readConfig, resolveConfig, writeConfig } from '../../core/config-store'\nimport { MxsError } from '../../core/errors'\nimport { runOnboarding } from '../../core/onboarding'\nimport { emitInfo, type OutputOptions } from '../../core/output'\n\nexport interface GlobalFlags {\n json?: boolean\n apiUrl?: string\n token?: string\n apiKey?: string\n lang?: string\n quiet?: boolean\n verbose?: boolean\n dryRun?: boolean\n profile?: string\n}\n\nexport async function resolveContext(flags: GlobalFlags, out: OutputOptions) {\n let resolved\n try {\n resolved = await resolveConfig({\n apiUrl: flags.apiUrl,\n token: flags.token,\n apiKey: flags.apiKey,\n profile: flags.profile,\n })\n } catch (err) {\n if (err instanceof MxsError && err.code === 'config.missing.api_url') {\n const probed = await runOnboarding({\n profile: flags.profile ?? process.env.MXS_PROFILE,\n })\n emitInfo(`saved ${probed.apiUrl} to config`, out)\n resolved = await resolveConfig({\n apiUrl: flags.apiUrl,\n token: flags.token,\n apiKey: flags.apiKey,\n profile: flags.profile,\n })\n } else {\n throw err\n }\n }\n return resolved\n}\n\nexport function buildApiClient(\n resolved: Awaited<ReturnType<typeof resolveConfig>>,\n flags: GlobalFlags,\n) {\n return new ApiClient({\n apiBase: resolved.apiBase,\n authBase: resolved.authBase,\n clientId: resolved.clientId,\n token: resolved.token,\n apiKey: resolved.apiKey,\n autoRefresh:\n Boolean(resolved.token) &&\n !resolved.apiKey &&\n !flags.token &&\n !process.env.MXS_TOKEN,\n verbose: flags.verbose,\n quiet: flags.quiet,\n resolved,\n })\n}\n\nexport function withLangQuery(\n flags: GlobalFlags,\n query: Record<string, unknown> = {},\n): Record<string, unknown> {\n if (!flags.lang) return query\n return { ...query, lang: flags.lang }\n}\n\nexport async function persistApiVersion(version: number) {\n const cfg = await readConfig()\n if (cfg.api_version === version) return\n await writeConfig({ ...cfg, api_version: version })\n}\n"],"mappings":";;;;AAkBA,eAAsB,eAAe,OAAoB,KAAoB;CAC3E,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,cAAc;GAC7B,QAAQ,MAAM;GACd,OAAO,MAAM;GACb,QAAQ,MAAM;GACd,SAAS,MAAM;EACjB,CAAC;CACH,SAAS,KAAK;EACZ,IAAI,eAAe,YAAY,IAAI,SAAS,0BAA0B;GAIpE,SAAS,UAAS,MAHG,cAAc,EACjC,SAAS,MAAM,WAAW,QAAQ,IAAI,YACxC,CAAC,GACwB,OAAO,aAAa,GAAG;GAChD,WAAW,MAAM,cAAc;IAC7B,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,SAAS,MAAM;GACjB,CAAC;EACH,OACE,MAAM;CAEV;CACA,OAAO;AACT;AAEA,SAAgB,eACd,UACA,OACA;CACA,OAAO,IAAI,UAAU;EACnB,SAAS,SAAS;EAClB,UAAU,SAAS;EACnB,UAAU,SAAS;EACnB,OAAO,SAAS;EAChB,QAAQ,SAAS;EACjB,aACE,QAAQ,SAAS,KAAK,KACtB,CAAC,SAAS,UACV,CAAC,MAAM,SACP,CAAC,QAAQ,IAAI;EACf,SAAS,MAAM;EACf,OAAO,MAAM;EACb;CACF,CAAC;AACH;AAEA,SAAgB,cACd,OACA,QAAiC,CAAC,GACT;CACzB,IAAI,CAAC,MAAM,MAAM,OAAO;CACxB,OAAO;EAAE,GAAG;EAAO,MAAM,MAAM;CAAK;AACtC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { C as MxsError, f as getProfileDir, g as readProfileCredentials, h as readProfileConfig, i as emitSuccess, l as getCurrentProfile, y as validateProfileName } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { promises } from "node:fs";
|
|
3
|
+
//#region src/commands/profile/show.ts
|
|
4
|
+
async function run(nameArg, _flags, out) {
|
|
5
|
+
let name = nameArg;
|
|
6
|
+
if (!name) name = await getCurrentProfile() ?? void 0;
|
|
7
|
+
if (!name) throw new MxsError({
|
|
8
|
+
code: "profile.none_active",
|
|
9
|
+
message: "no profile specified and no active profile",
|
|
10
|
+
hint: "run `mxs profile use <name>` or pass a profile name"
|
|
11
|
+
});
|
|
12
|
+
validateProfileName(name);
|
|
13
|
+
try {
|
|
14
|
+
if (!(await promises.stat(getProfileDir(name))).isDirectory()) throw new Error("not a directory");
|
|
15
|
+
} catch (err) {
|
|
16
|
+
if (err?.code !== "ENOENT" && !(err instanceof MxsError)) throw err;
|
|
17
|
+
throw new MxsError({
|
|
18
|
+
code: "profile.not_found",
|
|
19
|
+
message: `profile '${name}' does not exist`
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const [cfg, creds] = await Promise.all([readProfileConfig(name), readProfileCredentials(name)]);
|
|
23
|
+
const expiresAt = creds?.expires_at ?? null;
|
|
24
|
+
const expiresHuman = expiresAt !== null ? new Date(expiresAt).toISOString() : null;
|
|
25
|
+
emitSuccess({
|
|
26
|
+
name,
|
|
27
|
+
api_url: cfg.api_url ?? null,
|
|
28
|
+
production: cfg.production ?? false,
|
|
29
|
+
user: creds?.user ?? null,
|
|
30
|
+
expires_at: expiresAt,
|
|
31
|
+
expires_at_human: expiresHuman,
|
|
32
|
+
authenticated: creds !== null
|
|
33
|
+
}, out);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { run };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=show-C5Zk0tcK.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-C5Zk0tcK.mjs","names":["fs"],"sources":["../src/commands/profile/show.ts"],"sourcesContent":["import { promises as fs } from 'node:fs'\n\nimport { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport {\n getCurrentProfile,\n getProfileDir,\n readProfileConfig,\n readProfileCredentials,\n validateProfileName,\n} from '../../core/profile'\nimport type { GlobalFlags } from '../internal/shared'\n\nexport async function run(\n nameArg: string | undefined,\n _flags: GlobalFlags,\n out: OutputOptions,\n) {\n let name = nameArg\n if (!name) {\n name = (await getCurrentProfile()) ?? undefined\n }\n if (!name) {\n throw new MxsError({\n code: 'profile.none_active',\n message: 'no profile specified and no active profile',\n hint: 'run `mxs profile use <name>` or pass a profile name',\n })\n }\n\n validateProfileName(name)\n\n try {\n const stat = await fs.stat(getProfileDir(name))\n if (!stat.isDirectory()) throw new Error('not a directory')\n } catch (err: any) {\n if (err?.code !== 'ENOENT' && !(err instanceof MxsError)) throw err\n throw new MxsError({\n code: 'profile.not_found',\n message: `profile '${name}' does not exist`,\n })\n }\n\n const [cfg, creds] = await Promise.all([\n readProfileConfig(name),\n readProfileCredentials(name),\n ])\n\n const expiresAt = creds?.expires_at ?? null\n const expiresHuman =\n expiresAt !== null ? new Date(expiresAt).toISOString() : null\n\n const data = {\n name,\n api_url: cfg.api_url ?? null,\n production: cfg.production ?? false,\n user: creds?.user ?? null,\n expires_at: expiresAt,\n expires_at_human: expiresHuman,\n authenticated: creds !== null,\n }\n\n emitSuccess(data, out)\n}\n"],"mappings":";;;AAaA,eAAsB,IACpB,SACA,QACA,KACA;CACA,IAAI,OAAO;CACX,IAAI,CAAC,MACH,OAAQ,MAAM,kBAAkB,KAAM,KAAA;CAExC,IAAI,CAAC,MACH,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CAGH,oBAAoB,IAAI;CAExB,IAAI;EAEF,IAAI,EAAC,MADcA,SAAG,KAAK,cAAc,IAAI,CAAC,GACpC,YAAY,GAAG,MAAM,IAAI,MAAM,iBAAiB;CAC5D,SAAS,KAAU;EACjB,IAAI,KAAK,SAAS,YAAY,EAAE,eAAe,WAAW,MAAM;EAChE,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,YAAY,KAAK;EAC5B,CAAC;CACH;CAEA,MAAM,CAAC,KAAK,SAAS,MAAM,QAAQ,IAAI,CACrC,kBAAkB,IAAI,GACtB,uBAAuB,IAAI,CAC7B,CAAC;CAED,MAAM,YAAY,OAAO,cAAc;CACvC,MAAM,eACJ,cAAc,OAAO,IAAI,KAAK,SAAS,EAAE,YAAY,IAAI;CAY3D,YAAY;EATV;EACA,SAAS,IAAI,WAAW;EACxB,YAAY,IAAI,cAAc;EAC9B,MAAM,OAAO,QAAQ;EACrB,YAAY;EACZ,kBAAkB;EAClB,eAAe,UAAU;CAGZ,GAAG,GAAG;AACvB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { g as readProfileCredentials, i as emitSuccess, l as getCurrentProfile } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { i as isExpiringSoon } from "./auth-Duj8jJn9.mjs";
|
|
3
|
+
//#region src/commands/auth/status.ts
|
|
4
|
+
async function run(flags, out) {
|
|
5
|
+
const profileName = flags.profile?.trim() || process.env.MXS_PROFILE?.trim() || await getCurrentProfile();
|
|
6
|
+
const cred = profileName ? await readProfileCredentials(profileName) : null;
|
|
7
|
+
if (!cred) {
|
|
8
|
+
emitSuccess({ authenticated: false }, out);
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
emitSuccess({
|
|
12
|
+
authenticated: true,
|
|
13
|
+
expires_at: cred.expires_at,
|
|
14
|
+
expiring_soon: isExpiringSoon(cred),
|
|
15
|
+
has_refresh: Boolean(cred.refresh_token),
|
|
16
|
+
user: cred.user ?? null
|
|
17
|
+
}, out);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { run };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=status-evZpPR3N.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-evZpPR3N.mjs","names":[],"sources":["../src/commands/auth/status.ts"],"sourcesContent":["import { isExpiringSoon } from '../../core/auth'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { getCurrentProfile, readProfileCredentials } from '../../core/profile'\nimport { type GlobalFlags } from '../internal/shared'\n\nexport async function run(flags: GlobalFlags, out: OutputOptions) {\n const profileName =\n flags.profile?.trim() ||\n process.env.MXS_PROFILE?.trim() ||\n (await getCurrentProfile())\n const cred = profileName ? await readProfileCredentials(profileName) : null\n if (!cred) {\n emitSuccess({ authenticated: false }, out)\n return\n }\n emitSuccess(\n {\n authenticated: true,\n expires_at: cred.expires_at,\n expiring_soon: isExpiringSoon(cred),\n has_refresh: Boolean(cred.refresh_token),\n user: cred.user ?? null,\n },\n out,\n )\n}\n"],"mappings":";;;AAKA,eAAsB,IAAI,OAAoB,KAAoB;CAChE,MAAM,cACJ,MAAM,SAAS,KAAK,KACpB,QAAQ,IAAI,aAAa,KAAK,KAC7B,MAAM,kBAAkB;CAC3B,MAAM,OAAO,cAAc,MAAM,uBAAuB,WAAW,IAAI;CACvE,IAAI,CAAC,MAAM;EACT,YAAY,EAAE,eAAe,MAAM,GAAG,GAAG;EACzC;CACF;CACA,YACE;EACE,eAAe;EACf,YAAY,KAAK;EACjB,eAAe,eAAe,IAAI;EAClC,aAAa,QAAQ,KAAK,aAAa;EACvC,MAAM,KAAK,QAAQ;CACrB,GACA,GACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as emitSuccess } from "./output-
|
|
2
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-
|
|
3
|
-
import { t as resolveCategoryId } from "./resolve-
|
|
1
|
+
import { i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
3
|
+
import { t as resolveCategoryId } from "./resolve-U6RJ3AnQ.mjs";
|
|
4
4
|
//#region src/commands/category/update.ts
|
|
5
5
|
async function run(slugOrId, opts, flags, out) {
|
|
6
6
|
const body = {};
|
|
@@ -25,4 +25,4 @@ async function run(slugOrId, opts, flags, out) {
|
|
|
25
25
|
//#endregion
|
|
26
26
|
export { run };
|
|
27
27
|
|
|
28
|
-
//# sourceMappingURL=update
|
|
28
|
+
//# sourceMappingURL=update--7NPzL_w.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update
|
|
1
|
+
{"version":3,"file":"update--7NPzL_w.mjs","names":[],"sources":["../src/commands/category/update.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport {\n buildApiClient,\n type GlobalFlags,\n resolveContext,\n} from '../internal/shared'\nimport { resolveCategoryId } from './resolve'\n\nexport interface CategoryUpdateFlags {\n name?: string\n slug?: string\n type?: 'category' | 'tag'\n icon?: string\n}\n\nexport async function run(\n slugOrId: string,\n opts: CategoryUpdateFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const body: Record<string, unknown> = {}\n if (opts.name) body.name = opts.name\n if (opts.slug) body.slug = opts.slug\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({ id: slugOrId, body }, 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 const res = await client.request(`/categories/${id}`, {\n method: 'PATCH',\n body,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;AAeA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,MAAM,OAAgC,CAAC;CACvC,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,SAAS,QAAQ,IAAI;CACrD,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,MAAM,QAAQ;EAChB,YAAY;GAAE,IAAI;GAAU;EAAK,GAAG,GAAG;EACvC;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,kBAAkB,QAAQ,QAAQ;CAKnD,aAAY,MAJM,OAAO,QAAQ,eAAe,MAAM;EACpD,QAAQ;EACR;CACF,CAAC,GACe,MAAM,GAAG;AAC3B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as buildPagePayload } from "./payload-
|
|
3
|
-
import { r as isSnowflakeId } from "./resolve-
|
|
4
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-
|
|
1
|
+
import { C as MxsError, i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { n as buildPagePayload } from "./payload-CjlZ9CeZ.mjs";
|
|
3
|
+
import { r as isSnowflakeId } from "./resolve-DIu9N2sD.mjs";
|
|
4
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
5
5
|
//#region src/commands/page/update.ts
|
|
6
6
|
async function run(slugOrId, opts, flags, out) {
|
|
7
7
|
const built = await buildPagePayload(opts);
|
|
@@ -33,4 +33,4 @@ async function resolveId(client, slugOrId) {
|
|
|
33
33
|
//#endregion
|
|
34
34
|
export { run };
|
|
35
35
|
|
|
36
|
-
//# sourceMappingURL=update-
|
|
36
|
+
//# sourceMappingURL=update-0q5hxJFh.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-
|
|
1
|
+
{"version":3,"file":"update-0q5hxJFh.mjs","names":[],"sources":["../src/commands/page/update.ts"],"sourcesContent":["import type { ApiClient } from '../../core/api-client'\nimport { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildPagePayload, type PageFlagInputs } from '../../core/payload'\nimport { isSnowflakeId } from '../../core/resolve'\nimport { buildApiClient, type GlobalFlags, resolveContext } from '../internal/shared'\n\nexport async function run(\n slugOrId: string,\n opts: PageFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildPagePayload(opts)\n if (opts.content === undefined && !opts.file) {\n delete built.payload.content\n delete built.payload.text\n delete built.payload.contentFormat\n }\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 id = await resolveId(client, slugOrId)\n const res = await client.request(`/pages/${id}`, {\n method: 'PATCH',\n body: built.payload,\n })\n emitSuccess(res.data, 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":";;;;;AAOA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,MAAM;EAC5C,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;CACvB;CACA,IAAI,MAAM,QAAQ;EAChB,YAAY,MAAM,SAAS,GAAG;EAC9B;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,UAAU,QAAQ,QAAQ;CAK3C,aAAY,MAJM,OAAO,QAAQ,UAAU,MAAM;EAC/C,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B;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,8 +1,8 @@
|
|
|
1
|
-
import { i as emitSuccess } from "./output-
|
|
2
|
-
import { t as buildNotePayload } from "./payload-
|
|
3
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-
|
|
4
|
-
import { r as resolveTopicRefs, t as buildResolver } from "./resolve-helpers-
|
|
5
|
-
import { t as resolveNoteId } from "./resolve-
|
|
1
|
+
import { i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { t as buildNotePayload } from "./payload-CjlZ9CeZ.mjs";
|
|
3
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
4
|
+
import { r as resolveTopicRefs, t as buildResolver } from "./resolve-helpers-C7PIVziv.mjs";
|
|
5
|
+
import { t as resolveNoteId } from "./resolve-TBYXBS4i.mjs";
|
|
6
6
|
//#region src/commands/note/update.ts
|
|
7
7
|
async function run(slugOrId, opts, flags, out) {
|
|
8
8
|
const built = await buildNotePayload(opts);
|
|
@@ -27,4 +27,4 @@ async function run(slugOrId, opts, flags, out) {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { run };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=update-
|
|
30
|
+
//# sourceMappingURL=update-CPJXcOg_.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-
|
|
1
|
+
{"version":3,"file":"update-CPJXcOg_.mjs","names":[],"sources":["../src/commands/note/update.ts"],"sourcesContent":["import { emitSuccess, type OutputOptions } from '../../core/output'\nimport { buildNotePayload, type NoteFlagInputs } from '../../core/payload'\nimport { buildResolver, resolveTopicRefs } from '../internal/resolve-helpers'\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: NoteFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildNotePayload(opts)\n if (opts.content === undefined && !opts.file) {\n delete built.payload.content\n delete built.payload.text\n delete built.payload.contentFormat\n }\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 id = await resolveNoteId(client, slugOrId)\n const res = await client.request(`/notes/${id}`, {\n method: 'PATCH',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;;;AAUA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,MAAM;EAC5C,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;CACvB;CACA,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;CAC9C,MAAM,KAAK,MAAM,cAAc,QAAQ,QAAQ;CAK/C,aAAY,MAJM,OAAO,QAAQ,UAAU,MAAM;EAC/C,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as isSnowflakeId } from "./resolve-
|
|
3
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-
|
|
1
|
+
import { C as MxsError, i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { r as isSnowflakeId } from "./resolve-DIu9N2sD.mjs";
|
|
3
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
4
4
|
//#region src/commands/topic/update.ts
|
|
5
5
|
async function run(slugOrId, opts, flags, out) {
|
|
6
6
|
const body = {};
|
|
@@ -34,4 +34,4 @@ async function resolveId(client, slugOrId) {
|
|
|
34
34
|
//#endregion
|
|
35
35
|
export { run };
|
|
36
36
|
|
|
37
|
-
//# sourceMappingURL=update-
|
|
37
|
+
//# sourceMappingURL=update-DN78pXGZ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-
|
|
1
|
+
{"version":3,"file":"update-DN78pXGZ.mjs","names":[],"sources":["../src/commands/topic/update.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 interface TopicUpdateFlags {\n name?: string\n slug?: string\n description?: string\n icon?: string\n}\n\nexport async function run(\n slugOrId: string,\n opts: TopicUpdateFlags,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const body: Record<string, unknown> = {}\n if (opts.name) body.name = opts.name\n if (opts.slug) body.slug = opts.slug\n if (opts.description) body.description = opts.description\n if (opts.icon) body.icon = opts.icon\n if (flags.dryRun) {\n emitSuccess({ id: slugOrId, body }, 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 const res = await client.request(`/topics/${id}`, {\n method: 'PATCH',\n body,\n })\n emitSuccess(res.data, 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":";;;;AAaA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,MAAM,OAAgC,CAAC;CACvC,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,KAAK,aAAa,KAAK,cAAc,KAAK;CAC9C,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK;CAChC,IAAI,MAAM,QAAQ;EAChB,YAAY;GAAE,IAAI;GAAU;EAAK,GAAG,GAAG;EACvC;CACF;CAEA,MAAM,SAAS,eAAe,MADZ,eAAe,OAAO,GAAG,GACR,KAAK;CACxC,MAAM,KAAK,MAAM,UAAU,QAAQ,QAAQ;CAK3C,aAAY,MAJM,OAAO,QAAQ,WAAW,MAAM;EAChD,QAAQ;EACR;CACF,CAAC,GACe,MAAM,GAAG;AAC3B;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,8 +1,8 @@
|
|
|
1
|
-
import { i as emitSuccess } from "./output-
|
|
2
|
-
import { r as buildPostPayload } from "./payload-
|
|
3
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-
|
|
4
|
-
import { n as resolveCategoryRefs, t as buildResolver } from "./resolve-helpers-
|
|
5
|
-
import { t as resolvePostId } from "./resolve-
|
|
1
|
+
import { i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { r as buildPostPayload } from "./payload-CjlZ9CeZ.mjs";
|
|
3
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
4
|
+
import { n as resolveCategoryRefs, t as buildResolver } from "./resolve-helpers-C7PIVziv.mjs";
|
|
5
|
+
import { t as resolvePostId } from "./resolve-B4-fMQ6I.mjs";
|
|
6
6
|
//#region src/commands/post/update.ts
|
|
7
7
|
async function run(slugOrId, opts, flags, out) {
|
|
8
8
|
const built = await buildPostPayload(opts);
|
|
@@ -27,4 +27,4 @@ async function run(slugOrId, opts, flags, out) {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { run };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=update-
|
|
30
|
+
//# sourceMappingURL=update-hhAcAz_M.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-
|
|
1
|
+
{"version":3,"file":"update-hhAcAz_M.mjs","names":[],"sources":["../src/commands/post/update.ts"],"sourcesContent":["import { 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'\nimport { resolvePostId } from './resolve'\n\nexport async function run(\n slugOrId: string,\n opts: PostFlagInputs,\n flags: GlobalFlags,\n out: OutputOptions,\n) {\n const built = await buildPostPayload(opts)\n if (opts.content === undefined && !opts.file) {\n delete built.payload.content\n delete built.payload.text\n delete built.payload.contentFormat\n }\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 resolveCategoryRefs(built.payload, resolver)\n const id = await resolvePostId(client, slugOrId)\n const res = await client.request(`/posts/${id}`, {\n method: 'PATCH',\n body: built.payload,\n })\n emitSuccess(res.data, out)\n}\n"],"mappings":";;;;;;AAMA,eAAsB,IACpB,UACA,MACA,OACA,KACA;CACA,MAAM,QAAQ,MAAM,iBAAiB,IAAI;CACzC,IAAI,KAAK,YAAY,KAAA,KAAa,CAAC,KAAK,MAAM;EAC5C,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;EACrB,OAAO,MAAM,QAAQ;CACvB;CACA,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,oBAAoB,MAAM,SAAS,QAAQ;CACjD,MAAM,KAAK,MAAM,cAAc,QAAQ,QAAQ;CAK/C,aAAY,MAJM,OAAO,QAAQ,UAAU,MAAM;EAC/C,QAAQ;EACR,MAAM,MAAM;CACd,CAAC,GACe,MAAM,GAAG;AAC3B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { C as MxsError, r as emitInfo, v as setCurrentProfile, y as validateProfileName } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
//#region src/commands/profile/use.ts
|
|
3
|
+
async function run(name, _flags, out) {
|
|
4
|
+
try {
|
|
5
|
+
validateProfileName(name);
|
|
6
|
+
} catch {
|
|
7
|
+
throw new MxsError({
|
|
8
|
+
code: "profile.invalid_name",
|
|
9
|
+
message: `'${name}' is not a valid profile name`,
|
|
10
|
+
hint: "profile name must match ^[a-z0-9_-]{1,32}$ and must not be \"current\""
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
await setCurrentProfile(name);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
if (err?.code === "validation.failed") throw new MxsError({
|
|
17
|
+
code: "profile.not_found",
|
|
18
|
+
message: `profile '${name}' does not exist`,
|
|
19
|
+
hint: "run `mxs profile ls` to see available profiles, or `mxs auth login --profile <name>` to create one"
|
|
20
|
+
});
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
emitInfo(`mxs: active profile is now '${name}'`, out);
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { run };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=use-CHDCEe38.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-CHDCEe38.mjs","names":[],"sources":["../src/commands/profile/use.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitInfo, type OutputOptions } from '../../core/output'\nimport { setCurrentProfile, validateProfileName } from '../../core/profile'\nimport type { GlobalFlags } from '../internal/shared'\n\nexport async function run(\n name: string,\n _flags: GlobalFlags,\n out: OutputOptions,\n) {\n try {\n validateProfileName(name)\n } catch {\n throw new MxsError({\n code: 'profile.invalid_name',\n message: `'${name}' is not a valid profile name`,\n hint: 'profile name must match ^[a-z0-9_-]{1,32}$ and must not be \"current\"',\n })\n }\n\n try {\n await setCurrentProfile(name)\n } catch (err: any) {\n if (err?.code === 'validation.failed') {\n throw new MxsError({\n code: 'profile.not_found',\n message: `profile '${name}' does not exist`,\n hint: 'run `mxs profile ls` to see available profiles, or `mxs auth login --profile <name>` to create one',\n })\n }\n throw err\n }\n\n emitInfo(`mxs: active profile is now '${name}'`, out)\n}\n"],"mappings":";;AAKA,eAAsB,IACpB,MACA,QACA,KACA;CACA,IAAI;EACF,oBAAoB,IAAI;CAC1B,QAAQ;EACN,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,IAAI,KAAK;GAClB,MAAM;EACR,CAAC;CACH;CAEA,IAAI;EACF,MAAM,kBAAkB,IAAI;CAC9B,SAAS,KAAU;EACjB,IAAI,KAAK,SAAS,qBAChB,MAAM,IAAI,SAAS;GACjB,MAAM;GACN,SAAS,YAAY,KAAK;GAC1B,MAAM;EACR,CAAC;EAEH,MAAM;CACR;CAEA,SAAS,+BAA+B,KAAK,IAAI,GAAG;AACtD"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as resolveContext, t as buildApiClient } from "./shared-C2EAn5h_.mjs";
|
|
1
|
+
import { C as MxsError, g as readProfileCredentials, i as emitSuccess } from "./output-Dg8PISJM.mjs";
|
|
2
|
+
import { n as resolveContext, t as buildApiClient } from "./shared-SryY2QPY.mjs";
|
|
4
3
|
//#region src/commands/auth/whoami.ts
|
|
5
4
|
async function run(flags, out) {
|
|
6
5
|
const ctx = await resolveContext(flags, out);
|
|
7
|
-
const cred = await
|
|
6
|
+
const cred = ctx.profileName ? await readProfileCredentials(ctx.profileName) : null;
|
|
8
7
|
if (!cred && !ctx.token && !ctx.apiKey) throw new MxsError({
|
|
9
8
|
code: "auth.missing",
|
|
10
9
|
message: "not authenticated",
|
|
@@ -19,4 +18,4 @@ async function run(flags, out) {
|
|
|
19
18
|
//#endregion
|
|
20
19
|
export { run };
|
|
21
20
|
|
|
22
|
-
//# sourceMappingURL=whoami-
|
|
21
|
+
//# sourceMappingURL=whoami-BHDYyY5D.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami-BHDYyY5D.mjs","names":[],"sources":["../src/commands/auth/whoami.ts"],"sourcesContent":["import { MxsError } from '../../core/errors'\nimport { emitSuccess, type OutputOptions } from '../../core/output'\nimport { readProfileCredentials } from '../../core/profile'\nimport {\n buildApiClient,\n type GlobalFlags,\n resolveContext,\n} from '../internal/shared'\n\nexport async function run(flags: GlobalFlags, out: OutputOptions) {\n const ctx = await resolveContext(flags, out)\n const cred = ctx.profileName\n ? await readProfileCredentials(ctx.profileName)\n : null\n if (!cred && !ctx.token && !ctx.apiKey) {\n throw new MxsError({\n code: 'auth.missing',\n message: 'not authenticated',\n hint: 'run `mxs auth login`',\n })\n }\n const client = buildApiClient(ctx, flags)\n const session =\n ctx.token && !ctx.apiKey\n ? await client.request('/auth/session').then((res) => res.data)\n : null\n emitSuccess(\n {\n user: session ?? cred?.user ?? null,\n api_url: ctx.apiUrl,\n },\n out,\n )\n}\n"],"mappings":";;;AASA,eAAsB,IAAI,OAAoB,KAAoB;CAChE,MAAM,MAAM,MAAM,eAAe,OAAO,GAAG;CAC3C,MAAM,OAAO,IAAI,cACb,MAAM,uBAAuB,IAAI,WAAW,IAC5C;CACJ,IAAI,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,IAAI,QAC9B,MAAM,IAAI,SAAS;EACjB,MAAM;EACN,SAAS;EACT,MAAM;CACR,CAAC;CAEH,MAAM,SAAS,eAAe,KAAK,KAAK;CAKxC,YACE;EACE,OALF,IAAI,SAAS,CAAC,IAAI,SACd,MAAM,OAAO,QAAQ,eAAe,EAAE,MAAM,QAAQ,IAAI,IAAI,IAC5D,SAGe,MAAM,QAAQ;EAC/B,SAAS,IAAI;CACf,GACA,GACF;AACF"}
|
package/package.json
CHANGED
package/dist/chunk-hT5z_Zn9.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
-
var __exportAll = (all, no_symbols) => {
|
|
11
|
-
let target = {};
|
|
12
|
-
for (var name in all) __defProp(target, name, {
|
|
13
|
-
get: all[name],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
-
return target;
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
|
-
key = keys[i];
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
-
get: ((k) => from[k]).bind(null, key),
|
|
24
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
32
|
-
}) : target, mod));
|
|
33
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
34
|
-
//#endregion
|
|
35
|
-
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
|