@picked/cli 0.0.117-next.2 → 0.0.117-next.3

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 (64) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cjs/auth/oauth.d.ts +26 -0
  3. package/dist/cjs/auth/oauth.d.ts.map +1 -0
  4. package/dist/cjs/auth/pkce.d.ts +26 -0
  5. package/dist/cjs/auth/pkce.d.ts.map +1 -0
  6. package/dist/cjs/auth/session.d.ts +12 -0
  7. package/dist/cjs/auth/session.d.ts.map +1 -0
  8. package/dist/cjs/auth/token-store.d.ts +63 -0
  9. package/dist/cjs/auth/token-store.d.ts.map +1 -0
  10. package/dist/cjs/cli.d.ts +2 -0
  11. package/dist/cjs/cli.d.ts.map +1 -0
  12. package/dist/cjs/commands/app-deploy.d.ts +22 -0
  13. package/dist/cjs/commands/app-deploy.d.ts.map +1 -0
  14. package/dist/cjs/commands/app-keys.d.ts +19 -0
  15. package/dist/cjs/commands/app-keys.d.ts.map +1 -0
  16. package/dist/cjs/commands/docs.d.ts +65 -0
  17. package/dist/cjs/commands/docs.d.ts.map +1 -0
  18. package/dist/cjs/commands/generate-types.d.ts +15 -0
  19. package/dist/cjs/commands/generate-types.d.ts.map +1 -0
  20. package/dist/cjs/commands/login.d.ts +15 -0
  21. package/dist/cjs/commands/login.d.ts.map +1 -0
  22. package/dist/cjs/commands/logout.d.ts +14 -0
  23. package/dist/cjs/commands/logout.d.ts.map +1 -0
  24. package/dist/cjs/commands/pull.d.ts +19 -0
  25. package/dist/cjs/commands/pull.d.ts.map +1 -0
  26. package/dist/cjs/commands/status.d.ts +15 -0
  27. package/dist/cjs/commands/status.d.ts.map +1 -0
  28. package/dist/cjs/commands/whoami.d.ts +14 -0
  29. package/dist/cjs/commands/whoami.d.ts.map +1 -0
  30. package/dist/cjs/commands/workspace-export.d.ts +28 -0
  31. package/dist/cjs/commands/workspace-export.d.ts.map +1 -0
  32. package/dist/cjs/commands/workspace-import.d.ts +26 -0
  33. package/dist/cjs/commands/workspace-import.d.ts.map +1 -0
  34. package/dist/cjs/commands/workspace-list.d.ts +16 -0
  35. package/dist/cjs/commands/workspace-list.d.ts.map +1 -0
  36. package/dist/cjs/commands/workspace-use.d.ts +20 -0
  37. package/dist/cjs/commands/workspace-use.d.ts.map +1 -0
  38. package/dist/cjs/index.d.ts +13 -0
  39. package/dist/cjs/index.d.ts.map +1 -0
  40. package/dist/cjs/lib/admin-client.d.ts +22 -0
  41. package/dist/cjs/lib/admin-client.d.ts.map +1 -0
  42. package/dist/cjs/lib/api-url.d.ts +13 -0
  43. package/dist/cjs/lib/api-url.d.ts.map +1 -0
  44. package/dist/cjs/lib/browser.d.ts +12 -0
  45. package/dist/cjs/lib/browser.d.ts.map +1 -0
  46. package/dist/cjs/lib/bundle.d.ts +79 -0
  47. package/dist/cjs/lib/bundle.d.ts.map +1 -0
  48. package/dist/cjs/lib/docs.d.ts +94 -0
  49. package/dist/cjs/lib/docs.d.ts.map +1 -0
  50. package/dist/cjs/lib/paths.d.ts +13 -0
  51. package/dist/cjs/lib/paths.d.ts.map +1 -0
  52. package/dist/cjs/lib/prompt.d.ts +17 -0
  53. package/dist/cjs/lib/prompt.d.ts.map +1 -0
  54. package/dist/cjs/lib/workspace-transfer.d.ts +120 -0
  55. package/dist/cjs/lib/workspace-transfer.d.ts.map +1 -0
  56. package/dist/cjs/lib/workspaces.d.ts +53 -0
  57. package/dist/cjs/lib/workspaces.d.ts.map +1 -0
  58. package/dist/cjs/package.json +3 -0
  59. package/dist/cjs/telemetry.d.ts +26 -0
  60. package/dist/cjs/telemetry.d.ts.map +1 -0
  61. package/dist/types/auth/oauth.d.ts +1 -1
  62. package/dist/types/commands/docs.d.ts +1 -1
  63. package/dist/types/index.d.ts +11 -11
  64. package/package.json +24 -14
@@ -0,0 +1,79 @@
1
+ /** File name of the bundle document inside a bundle directory. */
2
+ export declare const BUNDLE_FILE = "bundle.json";
3
+ /** Directory inside a bundle directory that holds the asset files. */
4
+ export declare const ASSETS_DIR = "assets";
5
+ /**
6
+ * Resolves the bundle directory a flag names against the current directory.
7
+ *
8
+ * @param {string} cwd - The current directory.
9
+ * @param {string} value - The flag's value.
10
+ * @param {string} flag - The flag, for the error message.
11
+ * @returns {string} The absolute bundle directory, strictly inside `cwd`.
12
+ * @throws {Error} When the directory is `cwd` itself or lies outside it.
13
+ * @example
14
+ * resolveBundleDir('/work', 'bundle', '--out') // '/work/bundle'
15
+ */
16
+ export declare function resolveBundleDir(cwd: string, value: string, flag: string): string;
17
+ /** One asset version of a bundle's `assets` manifest, as the CLI reads it. */
18
+ export interface BundleAsset {
19
+ /** The asset version id in the source project. */
20
+ versionId: string;
21
+ fileName: string;
22
+ mimeType: string;
23
+ sizeBytes: number;
24
+ /** Lower-case hex SHA-256 of the bytes, or null when the source never recorded one. */
25
+ sha256: string | null;
26
+ downloadUrl: string;
27
+ }
28
+ /**
29
+ * Narrows a value to a plain JSON object.
30
+ *
31
+ * @param {unknown} value - The value.
32
+ * @returns {boolean} True for a non-null, non-array object.
33
+ * @example
34
+ * isRecord(JSON.parse(text))
35
+ */
36
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
37
+ /**
38
+ * Returns the path of an asset file inside a bundle directory.
39
+ *
40
+ * @param {string} bundleDir - The bundle directory.
41
+ * @param {string} sha256 - The lower-case hex SHA-256 of the file's bytes.
42
+ * @returns {string} `<bundleDir>/assets/<sha256>`.
43
+ * @example
44
+ * assetPath('./bundle', asset.sha256)
45
+ */
46
+ export declare function assetPath(bundleDir: string, sha256: string): string;
47
+ /**
48
+ * Reads the `assets` manifest of a bundle.
49
+ *
50
+ * @param {Record<string, unknown>} bundle - The bundle document.
51
+ * @returns {BundleAsset[]} Its items, in manifest order.
52
+ * @throws {Error} When `assets` is not an array of well-formed items.
53
+ * @example
54
+ * const assets = readAssetManifest(bundle)
55
+ */
56
+ export declare function readAssetManifest(bundle: Record<string, unknown>): BundleAsset[];
57
+ /**
58
+ * Checks bytes against the size and, when it has one, the SHA-256 of a manifest item.
59
+ *
60
+ * @param {BundleAsset} asset - The manifest item.
61
+ * @param {Uint8Array} bytes - The bytes.
62
+ * @param {string} source - Where the bytes came from, for the error message.
63
+ * @returns {string} The lower-case hex SHA-256 of `bytes`.
64
+ * @throws {Error} When the size or the SHA-256 differs from the manifest.
65
+ * @example
66
+ * const sha256 = verifyAssetBytes(asset, bytes, asset.downloadUrl)
67
+ */
68
+ export declare function verifyAssetBytes(asset: BundleAsset, bytes: Uint8Array, source: string): string;
69
+ /**
70
+ * Returns a copy of a bundle whose manifest items carry the given SHA-256 digests.
71
+ *
72
+ * @param {Record<string, unknown>} bundle - The bundle document.
73
+ * @param {string[]} hashes - The digest of each manifest item, in manifest order.
74
+ * @returns {Record<string, unknown>} The bundle with every item's `sha256` set.
75
+ * @example
76
+ * const written = withAssetHashes(bundle, [sha256])
77
+ */
78
+ export declare function withAssetHashes(bundle: Record<string, unknown>, hashes: string[]): Record<string, unknown>;
79
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../src/lib/bundle.ts"],"names":[],"mappings":"AAOA,kEAAkE;AAClE,eAAO,MAAM,WAAW,gBAAgB,CAAA;AAExC,sEAAsE;AACtE,eAAO,MAAM,UAAU,WAAW,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CASjF;AAED,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,uFAAuF;IACvF,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAcD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnE;AAuCD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,EAAE,CAIhF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAe9F;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}
@@ -0,0 +1,94 @@
1
+ /** Origin of the published documentation site. */
2
+ export declare const DOCS_SITE = "https://docs.picked.app";
3
+ /** One documentation page, addressed by its site path. */
4
+ export interface DocPage {
5
+ /** Site path without extension, e.g. `/how-to/build-a-flow`; `/` for the home page. */
6
+ path: string;
7
+ /** Page title, from its first `#` heading. */
8
+ title: string;
9
+ /** Diátaxis content type: `tutorial`, `how-to`, `reference` or `explanation`. */
10
+ type?: string;
11
+ /** The page's first paragraph. */
12
+ description?: string;
13
+ /** Absolute path of the bundled Markdown file; local pages only. */
14
+ file?: string;
15
+ }
16
+ /** Where `picked docs` reads pages from. */
17
+ export interface DocsSource {
18
+ /** Where the pages come from: a directory, or the index URL. */
19
+ location: string;
20
+ /** Lists every page, in path order. */
21
+ list: () => Promise<DocPage[]>;
22
+ /** Reads one page's Markdown without frontmatter; `undefined` when no page has that path. */
23
+ read: (path: string) => Promise<string | undefined>;
24
+ }
25
+ /**
26
+ * Turns any way of naming a page into its site path: a path with or without its leading
27
+ * slash, a docs URL with or without an anchor, or a bundled file path.
28
+ *
29
+ * @param {string} input - The page as the caller named it.
30
+ * @returns {string} The site path, e.g. `/reference/sdk/steps`.
31
+ * @example
32
+ * normalizeDocPath('node_modules/picked/docs/reference/sdk/steps.md') // '/reference/sdk/steps'
33
+ */
34
+ export declare function normalizeDocPath(input: string): string;
35
+ /**
36
+ * Reads pages from a directory laid out like `docs/public-docs/docs/pages`, which is how
37
+ * `picked` bundles them.
38
+ *
39
+ * @param {string} dir - The docs directory, e.g. `node_modules/picked/docs`.
40
+ * @returns {DocsSource} The source.
41
+ * @example
42
+ * const pages = await createLocalDocsSource('node_modules/picked/docs').list()
43
+ */
44
+ export declare function createLocalDocsSource(dir: string): DocsSource;
45
+ /**
46
+ * Reads pages from the index the docs site publishes, for a project without `picked`
47
+ * installed.
48
+ *
49
+ * @param {typeof fetch} [fetchImpl] - The fetch to use.
50
+ * @returns {DocsSource} The source. Its methods throw when the index cannot be fetched.
51
+ * @example
52
+ * const body = await createRemoteDocsSource().read('/reference/tools/cli')
53
+ */
54
+ export declare function createRemoteDocsSource(fetchImpl?: typeof fetch): DocsSource;
55
+ /**
56
+ * Finds the docs bundled in the `picked` package, in order: `PICKED_DOCS_DIR`, the `picked`
57
+ * package whose bin runs this command, then the `picked` package installed in `cwd`.
58
+ *
59
+ * @param {object} options - Where to look.
60
+ * @param {string} options.cwd - The working directory.
61
+ * @param {string | undefined} options.bin - The script that started the process (`process.argv[1]`).
62
+ * @param {Record<string, string | undefined>} options.env - The environment.
63
+ * @returns {string | undefined} The docs directory, or `undefined` when none is installed.
64
+ * @example
65
+ * findLocalDocsDir({ cwd: process.cwd(), bin: process.argv[1], env: process.env })
66
+ */
67
+ export declare function findLocalDocsDir(options: {
68
+ cwd: string;
69
+ bin: string | undefined;
70
+ env: Record<string, string | undefined>;
71
+ }): string | undefined;
72
+ /**
73
+ * The docs bundled in `picked` when they are installed, otherwise the published index.
74
+ *
75
+ * @param {object} [options] - Where to look; defaults to the running process.
76
+ * @param {string} [options.cwd] - The working directory.
77
+ * @returns {DocsSource} The source to read.
78
+ * @example
79
+ * const source = resolveDocsSource()
80
+ */
81
+ export declare function resolveDocsSource(options?: {
82
+ cwd?: string;
83
+ }): DocsSource;
84
+ /**
85
+ * Keeps the pages whose path, title or description holds every word of `query`.
86
+ *
87
+ * @param {DocPage[]} pages - The pages to search.
88
+ * @param {string} query - Words to look for, in any case.
89
+ * @returns {DocPage[]} The matching pages, in their original order.
90
+ * @example
91
+ * searchDocPages(pages, 'feature flag')
92
+ */
93
+ export declare function searchDocPages(pages: DocPage[], query: string): DocPage[];
94
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../src/lib/docs.ts"],"names":[],"mappings":"AAKA,kDAAkD;AAClD,eAAO,MAAM,SAAS,4BAA4B,CAAA;AAElD,0DAA0D;AAC1D,MAAM,WAAW,OAAO;IACtB,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAA;IACb,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9B,6FAA6F;IAC7F,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUtD;AAwDD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA+B7D;AAmCD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,GAAE,OAAO,KAAa,GAAG,UAAU,CA6BlF;AA2BD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACxC,GAAG,MAAM,GAAG,SAAS,CAqBrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAOxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CASzE"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Returns the auth config file path for a given API origin,
3
+ * `~/.picked/auth/<slug>.json`. The origin is normalised first, so cosmetically
4
+ * different spellings of one origin resolve to the same file.
5
+ *
6
+ * @param {string} apiUrl - The API base URL whose session is stored.
7
+ * @returns {string} Absolute path to that origin's auth config file.
8
+ * @throws {Error} When the URL is malformed, or not HTTPS and not a loopback host.
9
+ * @example
10
+ * authConfigPath('https://api.picked.app') // '/Users/dev/.picked/auth/api.picked.app-3f2a9c1b.json'
11
+ */
12
+ export declare function authConfigPath(apiUrl: string): string;
13
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/lib/paths.ts"],"names":[],"mappings":"AAuCA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Prompts the user to pick one item from a list by number. Prompts are written to
3
+ * stderr so a command's `--json` stdout output stays machine-readable.
4
+ *
5
+ * @template T
6
+ * @param {string} title - Prompt heading.
7
+ * @param {ReadonlyArray<{ label: string; value: T }>} choices - Options to choose from.
8
+ * @returns {Promise<T>} The chosen value.
9
+ * @throws {Error} When `choices` is empty.
10
+ * @example
11
+ * const project = await selectOne('Pick a project', [{ label: 'Website', value: 'proj-1' }])
12
+ */
13
+ export declare function selectOne<T>(title: string, choices: ReadonlyArray<{
14
+ label: string;
15
+ value: T;
16
+ }>): Promise<T>;
17
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/lib/prompt.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,aAAa,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,GAClD,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
@@ -0,0 +1,120 @@
1
+ import type { AdminApiClient } from '@picked/admin-api-client';
2
+ /** One `workspaceImport` asset mapping: a bundle asset version and the target version for it. */
3
+ export interface AssetMapping {
4
+ sourceVersionId: string;
5
+ assetId: string;
6
+ versionId: string;
7
+ }
8
+ /** The target project's asset version for some bytes, and whether they had to be uploaded. */
9
+ interface UploadedAsset {
10
+ assetId: string;
11
+ versionId: string;
12
+ /** True when the project already held the bytes and nothing was uploaded. */
13
+ deduplicated: boolean;
14
+ }
15
+ /**
16
+ * The error thrown when a mutation payload carries user errors: the API answered and
17
+ * rejected the operation.
18
+ *
19
+ * @example
20
+ * if (error instanceof PayloadUserErrorsError) console.error(error.message)
21
+ */
22
+ export declare class PayloadUserErrorsError extends Error {
23
+ readonly name = "PayloadUserErrorsError";
24
+ }
25
+ /**
26
+ * Resolves the workspace that holds a project's live version: the snapshot workspace of
27
+ * the version the project serves.
28
+ *
29
+ * @param {AdminApiClient} client - The admin API client.
30
+ * @param {string} projectId - The project.
31
+ * @returns {Promise<string>} The snapshot workspace id.
32
+ * @throws {Error} When the project is not found, has no published version, or its live
33
+ * version has no snapshot workspace.
34
+ * @example
35
+ * const workspaceId = await resolveLiveWorkspaceId(client, 'proj-1')
36
+ */
37
+ export declare function resolveLiveWorkspaceId(client: AdminApiClient, projectId: string): Promise<string>;
38
+ /**
39
+ * Exports a workspace as a bundle.
40
+ *
41
+ * @param {AdminApiClient} client - The admin API client.
42
+ * @param {string} workspaceId - The workspace.
43
+ * @returns {Promise<Record<string, unknown>>} The bundle document.
44
+ * @throws {Error} On user errors, or when the payload has no bundle object.
45
+ * @example
46
+ * const bundle = await exportWorkspaceBundle(client, 'ws-1')
47
+ */
48
+ export declare function exportWorkspaceBundle(client: AdminApiClient, workspaceId: string): Promise<Record<string, unknown>>;
49
+ /**
50
+ * Stores bytes as an asset of a project. `assetUploadInit` receives their SHA-256: when the
51
+ * project already holds them it returns that version and nothing is uploaded; otherwise the
52
+ * bytes are PUT to the upload URL and committed with the same SHA-256.
53
+ *
54
+ * @param {AdminApiClient} client - The admin API client.
55
+ * @param {object} params - The upload.
56
+ * @param {string} params.projectId - The target project.
57
+ * @param {string} params.fileName - The asset's file name.
58
+ * @param {string} params.mimeType - The bytes' content type.
59
+ * @param {string} params.sha256 - Lower-case hex SHA-256 of `bytes`.
60
+ * @param {Uint8Array<ArrayBuffer>} params.bytes - The bytes.
61
+ * @returns {Promise<UploadedAsset>} The project's asset version for the bytes.
62
+ * @throws {Error} When storage rejects the upload or the commit returns user errors.
63
+ * @example
64
+ * const uploaded = await uploadAsset(client, { projectId, fileName, mimeType, sha256, bytes })
65
+ */
66
+ export declare function uploadAsset(client: AdminApiClient, params: {
67
+ projectId: string;
68
+ fileName: string;
69
+ mimeType: string;
70
+ sha256: string;
71
+ bytes: Uint8Array<ArrayBuffer>;
72
+ }): Promise<UploadedAsset>;
73
+ /**
74
+ * Deletes an asset of a project.
75
+ *
76
+ * @param {AdminApiClient} client - The admin API client.
77
+ * @param {string} assetId - The asset.
78
+ * @returns {Promise<void>} Resolves once deleted.
79
+ * @example
80
+ * await deleteAsset(client, 'asset-1')
81
+ */
82
+ export declare function deleteAsset(client: AdminApiClient, assetId: string): Promise<void>;
83
+ /**
84
+ * Imports a bundle as a new draft workspace of a project. The request may run for up to
85
+ * five minutes.
86
+ *
87
+ * @param {AdminApiClient} client - The admin API client.
88
+ * @param {object} params - The import.
89
+ * @param {string} params.projectId - The target project.
90
+ * @param {string} [params.name] - The new workspace's name; the bundle's name when omitted.
91
+ * @param {Record<string, unknown>} params.bundle - The bundle document.
92
+ * @param {AssetMapping[]} params.assetMap - The target version of every bundle asset version.
93
+ * @returns {Promise<{ id: string; name: string }>} The new workspace.
94
+ * @throws {PayloadUserErrorsError} On user errors.
95
+ * @throws {Error} When the request fails, or the payload has neither a workspace nor user errors.
96
+ * @example
97
+ * const workspace = await importWorkspaceBundle(client, { projectId, bundle, assetMap })
98
+ */
99
+ export declare function importWorkspaceBundle(client: AdminApiClient, params: {
100
+ projectId: string;
101
+ name?: string;
102
+ bundle: Record<string, unknown>;
103
+ assetMap: AssetMapping[];
104
+ }): Promise<{
105
+ id: string;
106
+ name: string;
107
+ }>;
108
+ /**
109
+ * Publishes a workspace, making it its project's live version.
110
+ *
111
+ * @param {AdminApiClient} client - The admin API client.
112
+ * @param {string} workspaceId - The workspace.
113
+ * @returns {Promise<void>} Resolves once published.
114
+ * @throws {Error} On user errors.
115
+ * @example
116
+ * await publishWorkspace(client, 'ws-1')
117
+ */
118
+ export declare function publishWorkspace(client: AdminApiClient, workspaceId: string): Promise<void>;
119
+ export {};
120
+ //# sourceMappingURL=workspace-transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-transfer.d.ts","sourceRoot":"","sources":["../../../src/lib/workspace-transfer.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAe9D,iGAAiG;AACjG,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,8FAA8F;AAC9F,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,YAAY,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;GAMG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,SAAkB,IAAI,4BAA2B;CAClD;AAqBD;;;;;;;;;;;GAWG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAUlC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;CAC/B,GACA,OAAO,CAAC,aAAa,CAAC,CAmCxB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,QAAQ,EAAE,YAAY,EAAE,CAAA;CACzB,GACA,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAYvC;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKjG"}
@@ -0,0 +1,53 @@
1
+ import type { AdminApiClient } from '@picked/admin-api-client';
2
+ import type { WorkspaceStatus } from '@picked/config';
3
+ /** A workspace within a project, as returned by the workspace-tree query. */
4
+ export interface WorkspaceNode {
5
+ id: string;
6
+ name: string;
7
+ status: WorkspaceStatus;
8
+ }
9
+ /** A project within an organization, as returned by the workspace-tree query. */
10
+ export interface ProjectNode {
11
+ id: string;
12
+ name: string;
13
+ liveWorkspaceId: string | null;
14
+ /** The project's live published version id, or `null` when nothing is served to delivery. */
15
+ liveVersionId: string | null;
16
+ workspaces: WorkspaceNode[];
17
+ }
18
+ /** An organization, as returned by the workspace-tree query. */
19
+ export interface OrgNode {
20
+ id: string;
21
+ name: string;
22
+ slug: string;
23
+ projects: ProjectNode[];
24
+ }
25
+ /** Workspace lookup result carrying its stateless preview delivery token. */
26
+ export interface WorkspacePreviewInfo {
27
+ status: WorkspaceStatus;
28
+ name: string;
29
+ previewToken: string;
30
+ }
31
+ /**
32
+ * Fetches every organization, project, and workspace visible to the authenticated user.
33
+ *
34
+ * @param {AdminApiClient} client - The admin API client.
35
+ * @returns {Promise<OrgNode[]>} The organization/project/workspace tree.
36
+ * @throws {Error} When the request fails or the caller is not a signed-in user.
37
+ * @example
38
+ * const orgs = await fetchWorkspaceTree(client)
39
+ */
40
+ export declare function fetchWorkspaceTree(client: AdminApiClient): Promise<OrgNode[]>;
41
+ /**
42
+ * Fetches a single workspace's status, name, and stateless preview delivery token.
43
+ *
44
+ * @param {AdminApiClient} client - The admin API client.
45
+ * @param {string} projectId - Project the workspace belongs to.
46
+ * @param {string} workspaceId - Workspace to fetch.
47
+ * @returns {Promise<WorkspacePreviewInfo>} The workspace's status, name, and preview token.
48
+ * @throws {Error} When the request fails or the workspace cannot be found.
49
+ * @example
50
+ * const info = await fetchPreviewToken(client, projectId, workspaceId)
51
+ */
52
+ export declare function fetchPreviewToken(client: AdminApiClient, projectId: string, workspaceId: string): Promise<WorkspacePreviewInfo>;
53
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../../src/lib/workspaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,6FAA6F;IAC7F,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,EAAE,aAAa,EAAE,CAAA;CAC5B;AAED,gEAAgE;AAChE,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,eAAe,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;CACrB;AAoDD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CA+BnF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,oBAAoB,CAAC,CAS/B"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Begins recording a command.
3
+ *
4
+ * @param {string} name - The command's own event name, from its dispatch site.
5
+ * @returns {void}
6
+ * @example beginCommand('whoami')
7
+ */
8
+ export declare function beginCommand(name: string): void;
9
+ /**
10
+ * Finishes the recorded command.
11
+ *
12
+ * @param {number} exitCode - The exit code the command produced.
13
+ * @returns {void}
14
+ * @example endCommand(0)
15
+ */
16
+ export declare function endCommand(exitCode: number): void;
17
+ /**
18
+ * Sends the recorded command span, if telemetry is on.
19
+ *
20
+ * Races a hard timeout so a captive network cannot delay the process exiting.
21
+ *
22
+ * @returns {Promise<void>} Resolves once the attempt has finished or timed out.
23
+ * @example await flushCommandTelemetry()
24
+ */
25
+ export declare function flushCommandTelemetry(): Promise<void>;
26
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../src/telemetry.ts"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAqB/C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAKjD;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAwB3D"}
@@ -1,4 +1,4 @@
1
- import type { AuthConfig, StoredSession } from './token-store';
1
+ import type { AuthConfig, StoredSession } from './token-store.js';
2
2
  /**
3
3
  * Runs the full browser + loopback PKCE OAuth login flow against the Picked API's
4
4
  * authorization server and returns the resulting session. The client registration is
@@ -1,5 +1,5 @@
1
1
  /** @file `picked docs list` and `picked docs read` command implementations. */
2
- import { type DocsSource } from '../lib/docs';
2
+ import { type DocsSource } from '../lib/docs.js';
3
3
  /**
4
4
  * Runs `picked docs list`: prints the path and title of each documentation page, one per
5
5
  * line, or every field as JSON.
@@ -1,13 +1,13 @@
1
1
  /** @file Public exports for `\@picked/cli`. */
2
- export { runDocs, runDocsList, runDocsRead } from './commands/docs';
3
- export { runGenerateTypes } from './commands/generate-types';
4
- export { runLogin } from './commands/login';
5
- export { runLogout } from './commands/logout';
6
- export { runPull } from './commands/pull';
7
- export { runStatus } from './commands/status';
8
- export { runWhoami } from './commands/whoami';
9
- export { runWorkspaceExport } from './commands/workspace-export';
10
- export { runWorkspaceImport } from './commands/workspace-import';
11
- export { runWorkspaceList } from './commands/workspace-list';
12
- export { runWorkspaceUse } from './commands/workspace-use';
2
+ export { runDocs, runDocsList, runDocsRead } from './commands/docs.js';
3
+ export { runGenerateTypes } from './commands/generate-types.js';
4
+ export { runLogin } from './commands/login.js';
5
+ export { runLogout } from './commands/logout.js';
6
+ export { runPull } from './commands/pull.js';
7
+ export { runStatus } from './commands/status.js';
8
+ export { runWhoami } from './commands/whoami.js';
9
+ export { runWorkspaceExport } from './commands/workspace-export.js';
10
+ export { runWorkspaceImport } from './commands/workspace-import.js';
11
+ export { runWorkspaceList } from './commands/workspace-list.js';
12
+ export { runWorkspaceUse } from './commands/workspace-use.js';
13
13
  //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@picked/cli",
3
3
  "description": "Picked command-line interface for local development workflows",
4
- "version": "0.0.117-next.2",
4
+ "version": "0.0.117-next.3",
5
5
  "bin": {
6
6
  "picked": "dist/esm/cli.js"
7
7
  },
8
8
  "dependencies": {
9
- "@picked/admin-api-client": "0.0.117-next.2",
10
- "@picked/app-protocol": "0.0.117-next.2",
11
- "@picked/config": "0.0.117-next.2",
12
- "@picked/telemetry": "0.0.117-next.2",
13
- "@picked/typegen": "0.0.117-next.2"
9
+ "@picked/admin-api-client": "0.0.117-next.3",
10
+ "@picked/app-protocol": "0.0.117-next.3",
11
+ "@picked/config": "0.0.117-next.3",
12
+ "@picked/telemetry": "0.0.117-next.3",
13
+ "@picked/typegen": "0.0.117-next.3"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@repo/eslint-config": "workspace:*",
@@ -25,15 +25,25 @@
25
25
  },
26
26
  "exports": {
27
27
  ".": {
28
- "types": "./dist/types/index.d.ts",
29
- "import": "./dist/esm/index.js",
30
- "require": "./dist/cjs/index.js",
28
+ "import": {
29
+ "types": "./dist/types/index.d.ts",
30
+ "default": "./dist/esm/index.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/cjs/index.d.ts",
34
+ "default": "./dist/cjs/index.js"
35
+ },
31
36
  "default": "./dist/esm/index.js"
32
37
  },
33
38
  "./cli": {
34
- "types": "./dist/types/cli.d.ts",
35
- "import": "./dist/esm/cli.js",
36
- "require": "./dist/cjs/cli.js",
39
+ "import": {
40
+ "types": "./dist/types/cli.d.ts",
41
+ "default": "./dist/esm/cli.js"
42
+ },
43
+ "require": {
44
+ "types": "./dist/cjs/cli.d.ts",
45
+ "default": "./dist/cjs/cli.js"
46
+ },
37
47
  "default": "./dist/esm/cli.js"
38
48
  }
39
49
  },
@@ -72,7 +82,7 @@
72
82
  "access": "public"
73
83
  },
74
84
  "scripts": {
75
- "build": "vite build && tsgo -p tsconfig.build.json",
85
+ "build": "vite build && tsgo -p tsconfig.build.json && node ../../scripts/sdk-dist.mjs",
76
86
  "check": "pnpm type-check && pnpm lint && pnpm knip && pnpm jscpd",
77
87
  "dev": "node ../../scripts/sdk-watch-build.mjs",
78
88
  "jscpd": "jscpd src",
@@ -83,7 +93,7 @@
83
93
  "lint:report": "eslint . -o './.reports/eslint.json' -f json || true",
84
94
  "test": "vitest run",
85
95
  "test:coverage": "../../scripts/vitest-coverage.sh",
86
- "test:packaged-types": "attw --pack",
96
+ "test:packaged-types": "attw --pack --profile node16",
87
97
  "test:watch": "vitest",
88
98
  "type-check": "tsgo -p . --noEmit"
89
99
  },