@picked/config 0.0.117-next.1 → 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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/config.d.ts +131 -0
- package/dist/cjs/config.d.ts.map +1 -0
- package/dist/cjs/define.d.ts +7 -0
- package/dist/cjs/define.d.ts.map +1 -0
- package/dist/cjs/host-environment.d.ts +18 -0
- package/dist/cjs/host-environment.d.ts.map +1 -0
- package/dist/cjs/index.d.ts +14 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/load-config.d.ts +49 -0
- package/dist/cjs/load-config.d.ts.map +1 -0
- package/dist/cjs/manifest.d.ts +59 -0
- package/dist/cjs/manifest.d.ts.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/settings.d.ts +49 -0
- package/dist/cjs/settings.d.ts.map +1 -0
- package/dist/cjs/snapshot.d.ts +110 -0
- package/dist/cjs/snapshot.d.ts.map +1 -0
- package/dist/cjs/telemetry-config.d.ts +25 -0
- package/dist/cjs/telemetry-config.d.ts.map +1 -0
- package/dist/cjs/url-safety.d.ts +26 -0
- package/dist/cjs/url-safety.d.ts.map +1 -0
- package/dist/types/define.d.ts +2 -2
- package/dist/types/index.d.ts +12 -12
- package/dist/types/load-config.d.ts +2 -2
- package/dist/types/manifest.d.ts +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/snapshot.d.ts +1 -1
- package/dist/types/telemetry-config.d.ts +1 -1
- package/package.json +21 -11
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/** @file Configuration types for Picked tooling. */
|
|
2
|
+
import type { AppManifest } from '@picked/app-protocol';
|
|
3
|
+
/** Schema source for codegen — published or live preview. */
|
|
4
|
+
export type PickedConfigSource = 'published' | 'preview';
|
|
5
|
+
/**
|
|
6
|
+
* Where a build's project config and CMS content come from. `'bundle'` fetches them on every
|
|
7
|
+
* build and embeds them; `'api'` embeds nothing and leaves the SDK to fetch at runtime;
|
|
8
|
+
* `'snapshot'` embeds the committed `picked.snapshot.json` and fetches nothing.
|
|
9
|
+
*/
|
|
10
|
+
export type PickedDataMode = 'bundle' | 'api' | 'snapshot';
|
|
11
|
+
/** The `picked.config` fields a project config and an app config share. */
|
|
12
|
+
interface PickedConfigFields {
|
|
13
|
+
/** Origin of the Picked API to call. Defaults to production; `PICKED_API_URL` overrides it. */
|
|
14
|
+
apiUrl?: string;
|
|
15
|
+
/** Path the generated type declarations are written to. */
|
|
16
|
+
typesOutput?: string;
|
|
17
|
+
/** Whether codegen reads the published schema or the live preview. */
|
|
18
|
+
source?: PickedConfigSource;
|
|
19
|
+
/**
|
|
20
|
+
* Workspace preview delivery token, required when `source` is `preview` and read only
|
|
21
|
+
* then. Supply it directly, or from wherever the project keeps secrets — the value is a
|
|
22
|
+
* long-lived, unexpiring, workspace-scoped secret, so a committed literal publishes
|
|
23
|
+
* preview access to anyone who can read the repository.
|
|
24
|
+
*/
|
|
25
|
+
previewToken?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Send anonymous telemetry from the CLI and the Vite plugin about their own behaviour.
|
|
28
|
+
* Off unless set. Overridden by `PICKED_TELEMETRY` and `DO_NOT_TRACK`, each taking
|
|
29
|
+
* `1`/`0` or `true`/`false`.
|
|
30
|
+
*/
|
|
31
|
+
telemetry?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Where a build's project config and CMS content come from. Defaults to `'bundle'`.
|
|
34
|
+
* Overridden for one run by `PICKED_DATA`.
|
|
35
|
+
*/
|
|
36
|
+
data?: PickedDataMode;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A `picked.config` that names a project: the shape `picked generate types`, `picked pull` and
|
|
40
|
+
* the Vite plugin read. It may also hold an `app`.
|
|
41
|
+
*/
|
|
42
|
+
export type PickedProjectConfig = PickedConfigFields & {
|
|
43
|
+
/** Picked project that schema and content are read from. */
|
|
44
|
+
projectId: string;
|
|
45
|
+
/**
|
|
46
|
+
* The app manifest `picked app deploy` and `picked app dev` deploy, exactly as Picked receives
|
|
47
|
+
* it and the app serves it at `/manifest.json`. It holds no secrets.
|
|
48
|
+
*/
|
|
49
|
+
app?: AppManifest;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A `picked.config` that holds an app: the shape `picked app deploy` and `picked app dev` read.
|
|
53
|
+
* It may also name a project.
|
|
54
|
+
*/
|
|
55
|
+
export type PickedAppConfig = PickedConfigFields & {
|
|
56
|
+
/** Picked project that schema and content are read from. */
|
|
57
|
+
projectId?: string;
|
|
58
|
+
/**
|
|
59
|
+
* The app manifest `picked app deploy` and `picked app dev` deploy, exactly as Picked receives
|
|
60
|
+
* it and the app serves it at `/manifest.json`. It holds no secrets.
|
|
61
|
+
*/
|
|
62
|
+
app: AppManifest;
|
|
63
|
+
};
|
|
64
|
+
/** User-facing `picked.config` shape: it names a project, holds an app, or both. */
|
|
65
|
+
export type PickedConfig = PickedProjectConfig | PickedAppConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Returns whether a config names a project.
|
|
68
|
+
*
|
|
69
|
+
* @param {PickedConfig} config - A loaded config.
|
|
70
|
+
* @returns {boolean} Whether `config` has a `projectId`.
|
|
71
|
+
* @example
|
|
72
|
+
* if (hasProject(config)) console.log(config.projectId)
|
|
73
|
+
*/
|
|
74
|
+
export declare function hasProject(config: PickedConfig): config is PickedProjectConfig;
|
|
75
|
+
/**
|
|
76
|
+
* Returns whether a config holds an app.
|
|
77
|
+
*
|
|
78
|
+
* @param {PickedConfig} config - A loaded config.
|
|
79
|
+
* @returns {boolean} Whether `config` has an `app` manifest.
|
|
80
|
+
* @example
|
|
81
|
+
* if (hasApp(config)) console.log(config.app.handle)
|
|
82
|
+
*/
|
|
83
|
+
export declare function hasApp(config: PickedConfig): config is PickedAppConfig;
|
|
84
|
+
/** Fully resolved configuration with defaults applied. */
|
|
85
|
+
export interface ResolvedPickedConfig {
|
|
86
|
+
/** Picked project that schema and content are read from. */
|
|
87
|
+
projectId: string;
|
|
88
|
+
/** Origin of the Picked API to call. */
|
|
89
|
+
apiUrl: string;
|
|
90
|
+
/** Absolute path the generated type declarations are written to. */
|
|
91
|
+
typesOutput: string;
|
|
92
|
+
/** Whether codegen reads the published schema or the live preview. */
|
|
93
|
+
source: PickedConfigSource;
|
|
94
|
+
/** Workspace preview delivery token, or null when `source` is `published`. */
|
|
95
|
+
previewToken: string | null;
|
|
96
|
+
/** Absolute directory holding `picked.config`, which relative paths resolve against. */
|
|
97
|
+
projectRoot: string;
|
|
98
|
+
/** The committed telemetry setting, as read through `isTelemetryEnabled`. */
|
|
99
|
+
telemetry: boolean;
|
|
100
|
+
/** Where a build's project config and CMS content come from, after `PICKED_DATA`. */
|
|
101
|
+
data: PickedDataMode;
|
|
102
|
+
}
|
|
103
|
+
/** Manifest written under `.picked/` after a schema fetch. */
|
|
104
|
+
export interface PickedCodegenManifest {
|
|
105
|
+
/** Workspace version the schema came from, or null when the schema carries none. */
|
|
106
|
+
versionId: string | null;
|
|
107
|
+
/** Content hash of the schema JSON, used to skip regenerating unchanged types. */
|
|
108
|
+
schemaHash: string;
|
|
109
|
+
/** When the schema was fetched, as an ISO 8601 timestamp. */
|
|
110
|
+
fetchedAt: string;
|
|
111
|
+
/** Project the schema was fetched for. */
|
|
112
|
+
projectId: string;
|
|
113
|
+
/** Whether the schema came from the published or preview source. */
|
|
114
|
+
source: PickedConfigSource;
|
|
115
|
+
/**
|
|
116
|
+
* Emitted-module format the committed types were written in.
|
|
117
|
+
*/
|
|
118
|
+
emitFormatVersion?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Helper for authoring `picked.config.ts` with full type inference. It returns the config it is
|
|
122
|
+
* given.
|
|
123
|
+
*
|
|
124
|
+
* @param {PickedConfig} config - A project's configuration, an app's, or both in one.
|
|
125
|
+
* @returns {PickedConfig} The same configuration object.
|
|
126
|
+
* @example
|
|
127
|
+
* export default defineConfig({ projectId: 'abc', app: { handle: 'acme', name: 'Acme' } })
|
|
128
|
+
*/
|
|
129
|
+
export declare function defineConfig(config: PickedConfig): PickedConfig;
|
|
130
|
+
export {};
|
|
131
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAAA;AAExD;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,CAAA;AAE1D,2EAA2E;AAC3E,UAAU,kBAAkB;IAC1B,+FAA+F;IAC/F,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sEAAsE;IACtE,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG;IACrD,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,GAAG,CAAC,EAAE,WAAW,CAAA;CAClB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG;IACjD,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAA;CACjB,CAAA;AAED,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,eAAe,CAAA;AAEhE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,mBAAmB,CAE9E;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,eAAe,CAEtE;AAED,0DAA0D;AAC1D,MAAM,WAAW,oBAAoB;IACnC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAA;IACjB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAA;IACnB,sEAAsE;IACtE,MAAM,EAAE,kBAAkB,CAAA;IAC1B,8EAA8E;IAC9E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAA;IACnB,6EAA6E;IAC7E,SAAS,EAAE,OAAO,CAAA;IAClB,qFAAqF;IACrF,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACpC,oFAAoF;IACpF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,oEAAoE;IACpE,MAAM,EAAE,kBAAkB,CAAA;IAC1B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file `@picked/config/define`: `defineConfig`, `hasApp`, `hasProject` and the config types. Nothing
|
|
3
|
+
* it imports reads files or loads a Node built-in.
|
|
4
|
+
*/
|
|
5
|
+
export { defineConfig, hasApp, hasProject } from './config.js';
|
|
6
|
+
export type { PickedAppConfig, PickedConfig, PickedConfigSource, PickedDataMode, PickedProjectConfig, } from './config.js';
|
|
7
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/define.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC3D,YAAY,EACV,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,mBAAmB,GACpB,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @file Detects the platform the CLI or the Vite plugin is running on. */
|
|
2
|
+
/** Platforms worth telling apart. `unknown` covers anything unrecognised. */
|
|
3
|
+
export type HostProvider = 'vercel' | 'netlify' | 'cloudflare-pages' | 'github-actions' | 'gitlab-ci' | 'circleci' | 'bitbucket-pipelines' | 'local' | 'unknown';
|
|
4
|
+
/** Where a Picked build or command is running. */
|
|
5
|
+
export interface HostEnvironment {
|
|
6
|
+
/** The platform, as a bounded value. */
|
|
7
|
+
provider: HostProvider;
|
|
8
|
+
/** Whether this looks like an automated run. */
|
|
9
|
+
ci: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Determines where the current process is running.
|
|
13
|
+
*
|
|
14
|
+
* @returns {HostEnvironment} The detected provider and whether it looks automated.
|
|
15
|
+
* @example detectHostEnvironment() // { provider: 'vercel', ci: true }
|
|
16
|
+
*/
|
|
17
|
+
export declare function detectHostEnvironment(): HostEnvironment;
|
|
18
|
+
//# sourceMappingURL=host-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-environment.d.ts","sourceRoot":"","sources":["../../src/host-environment.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,6EAA6E;AAC7E,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,SAAS,GACT,kBAAkB,GAClB,gBAAgB,GAChB,WAAW,GACX,UAAU,GACV,qBAAqB,GACrB,OAAO,GACP,SAAS,CAAA;AAEb,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,QAAQ,EAAE,YAAY,CAAA;IACtB,gDAAgD;IAChD,EAAE,EAAE,OAAO,CAAA;CACZ;AAmBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CASvD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @file Public exports for `\@picked/config`. */
|
|
2
|
+
export { defineConfig, hasApp, hasProject } from './config.js';
|
|
3
|
+
export type { PickedAppConfig, PickedCodegenManifest, PickedConfig, PickedConfigSource, PickedDataMode, PickedProjectConfig, ResolvedPickedConfig, } from './config.js';
|
|
4
|
+
export { loadPickedConfig, loadResolvedPickedConfig, resolvePickedConfig } from './load-config.js';
|
|
5
|
+
export { appendPickedGitignore, hashSchemaJson, readCodegenManifest, resolvePickedPaths, writeCodegenArtifacts, } from './manifest.js';
|
|
6
|
+
export { detectHostEnvironment } from './host-environment.js';
|
|
7
|
+
export type { HostEnvironment, HostProvider } from './host-environment.js';
|
|
8
|
+
export { isTelemetryEnabled, isTelemetryForcedOffByEnvironment } from './telemetry-config.js';
|
|
9
|
+
export { readActiveSelection, resolveSettingsPath, writeActiveSelection } from './settings.js';
|
|
10
|
+
export type { ActiveSelection, ActiveWorkspaceSelection, WorkspaceStatus } from './settings.js';
|
|
11
|
+
export { assertSecureApiUrl, normalizeApiUrl } from './url-safety.js';
|
|
12
|
+
export { SNAPSHOT_FILENAME, SNAPSHOT_VERSION, collectCmsExperienceIds, fetchSnapshot, readSnapshot, requireSnapshot, resolveSnapshotPath, serializeSnapshot, writeSnapshot, } from './snapshot.js';
|
|
13
|
+
export type { FetchSnapshotOptions, PickedSnapshot } from './snapshot.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC3D,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAC/F,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,kBAAkB,EAAE,iCAAiC,EAAE,MAAM,oBAAoB,CAAA;AAC1F,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAC3F,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5F,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PickedConfig, PickedProjectConfig, ResolvedPickedConfig } from './config.js';
|
|
2
|
+
import type { ActiveSelection } from './settings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a user config with defaults, an optional persisted selection, and env overrides.
|
|
5
|
+
*
|
|
6
|
+
* Precedence: an active selection (`.picked/settings.json`) overrides `projectId`/`source`;
|
|
7
|
+
* `PICKED_PROJECT_ID` / `PICKED_PREVIEW_TOKEN` / `PICKED_DATA` env vars override on top for
|
|
8
|
+
* CI/headless.
|
|
9
|
+
* The preview token resolves env first, then the selected workspace's token, then the
|
|
10
|
+
* config's own `previewToken`, so a committed default stays in force until a developer
|
|
11
|
+
* selects a workspace or a CI run supplies its own.
|
|
12
|
+
*
|
|
13
|
+
* @param {PickedProjectConfig} config - Raw project configuration.
|
|
14
|
+
* @param {string} projectRoot - Absolute project root directory.
|
|
15
|
+
* @param {ActiveSelection | null} [selection] - Persisted active selection, if any.
|
|
16
|
+
* @returns {ResolvedPickedConfig} Fully resolved configuration.
|
|
17
|
+
* @throws {Error} When `data` or `PICKED_DATA` names no mode, or the API URL is insecure.
|
|
18
|
+
* @example
|
|
19
|
+
* resolvePickedConfig({ projectId: 'p1' }, process.cwd())
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolvePickedConfig(config: PickedProjectConfig, projectRoot: string, selection?: ActiveSelection | null): ResolvedPickedConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Loads `picked.config` from the project root when present.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} [projectRoot] - Directory to search; defaults to `process.cwd()`.
|
|
26
|
+
* @returns {Promise<PickedConfig | null>} Parsed config, or `null` when no file exists.
|
|
27
|
+
* @throws {Error} When the file sets neither `projectId` nor `app`, or is malformed.
|
|
28
|
+
* @example
|
|
29
|
+
* const config = await loadPickedConfig()
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadPickedConfig(projectRoot?: string): Promise<PickedConfig | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Loads and resolves `picked.config` from the project root.
|
|
34
|
+
*
|
|
35
|
+
* `fallback` supplies the fields the config file omits, which lets a caller that already
|
|
36
|
+
* holds project identity or a data mode — the Vite plugin's deprecated `projectId`, `apiUrl`
|
|
37
|
+
* and `mode` options — resolve through the same precedence as everything else, config file
|
|
38
|
+
* included. A config that also holds an `app` resolves like any other; one without a
|
|
39
|
+
* `projectId`, from the file or `fallback`, is an error.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} [projectRoot] - Directory to search; defaults to `process.cwd()`.
|
|
42
|
+
* @param {Partial<PickedProjectConfig>} [fallback] - Values to use for the fields the file omits.
|
|
43
|
+
* @returns {Promise<ResolvedPickedConfig | null>} Resolved config, or `null` when no project is named.
|
|
44
|
+
* @throws {Error} When `picked.config` exists and neither it nor `fallback` names a project.
|
|
45
|
+
* @example
|
|
46
|
+
* const config = await loadResolvedPickedConfig()
|
|
47
|
+
*/
|
|
48
|
+
export declare function loadResolvedPickedConfig(projectRoot?: string, fallback?: Partial<PickedProjectConfig>): Promise<ResolvedPickedConfig | null>;
|
|
49
|
+
//# sourceMappingURL=load-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/load-config.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEV,YAAY,EAGZ,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAoMjD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,GACjC,oBAAoB,CA0BtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,SAAgB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAoBhG;AAiCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,SAAgB,EAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACtC,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAetC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { PickedCodegenManifest } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns absolute paths for `.picked/` artefacts.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} projectRoot - Consumer project root.
|
|
6
|
+
* @returns {{ pickedDir: string; manifestPath: string; schemaPath: string; codegenManifestPath: string }} Artefact paths.
|
|
7
|
+
* @example
|
|
8
|
+
* resolvePickedPaths(process.cwd())
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolvePickedPaths(projectRoot: string): {
|
|
11
|
+
pickedDir: string;
|
|
12
|
+
manifestPath: string;
|
|
13
|
+
schemaPath: string;
|
|
14
|
+
codegenManifestPath: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Computes a stable SHA-256 hash for a schema JSON string.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} schemaJson - Serialised schema document.
|
|
20
|
+
* @returns {string} Hex-encoded hash.
|
|
21
|
+
* @example
|
|
22
|
+
* hashSchemaJson('{"$schema":"..."}')
|
|
23
|
+
*/
|
|
24
|
+
export declare function hashSchemaJson(schemaJson: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Reads the codegen manifest from disk when present.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} manifestPath - Absolute path to `.picked/schema-manifest.json`.
|
|
29
|
+
* @returns {Promise<PickedCodegenManifest | null>} Parsed manifest or `null`.
|
|
30
|
+
* @example
|
|
31
|
+
* readCodegenManifest(paths.codegenManifestPath)
|
|
32
|
+
*/
|
|
33
|
+
export declare function readCodegenManifest(manifestPath: string): Promise<PickedCodegenManifest | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Writes the schema document and codegen manifest under `.picked/`.
|
|
36
|
+
*
|
|
37
|
+
* @param {object} params - Write parameters.
|
|
38
|
+
* @param {string} params.projectRoot - Consumer project root.
|
|
39
|
+
* @param {string} params.schemaJson - Serialised schema document.
|
|
40
|
+
* @param {PickedCodegenManifest} params.manifest - Manifest metadata to persist.
|
|
41
|
+
* @returns {Promise<void>} Resolves when artefacts are written.
|
|
42
|
+
* @example
|
|
43
|
+
* await writeCodegenArtifacts({ projectRoot, schemaJson, manifest })
|
|
44
|
+
*/
|
|
45
|
+
export declare function writeCodegenArtifacts(params: {
|
|
46
|
+
projectRoot: string;
|
|
47
|
+
schemaJson: string;
|
|
48
|
+
manifest: PickedCodegenManifest;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Appends `.picked/` to `.gitignore` on first run when missing.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} projectRoot - Consumer project root.
|
|
54
|
+
* @returns {Promise<void>} Resolves after ensuring gitignore contains `.picked/`.
|
|
55
|
+
* @example
|
|
56
|
+
* await appendPickedGitignore(process.cwd())
|
|
57
|
+
*/
|
|
58
|
+
export declare function appendPickedGitignore(projectRoot: string): Promise<void>;
|
|
59
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/manifest.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAOrD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG;IACvD,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CASA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAkBD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAavC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,qBAAqB,CAAA;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAShB;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAa9E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PickedConfigSource } from './config.js';
|
|
2
|
+
/** Lifecycle status of a selected workspace, mirroring the GraphQL `WorkspaceStatus`. */
|
|
3
|
+
export type WorkspaceStatus = 'DRAFT' | 'LIVE' | 'ARCHIVED' | 'HIDDEN';
|
|
4
|
+
/** The workspace portion of an active selection. */
|
|
5
|
+
export interface ActiveWorkspaceSelection {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
status: WorkspaceStatus;
|
|
9
|
+
source: PickedConfigSource;
|
|
10
|
+
previewToken?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Per-developer active selection persisted at `<root>/.picked/settings.json`. */
|
|
13
|
+
export interface ActiveSelection {
|
|
14
|
+
projectId: string;
|
|
15
|
+
workspace?: ActiveWorkspaceSelection;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the absolute path to `<root>/.picked/settings.json`.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} projectRoot - Consumer project root.
|
|
21
|
+
* @returns {string} Absolute settings path.
|
|
22
|
+
* @example
|
|
23
|
+
* resolveSettingsPath(process.cwd())
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveSettingsPath(projectRoot: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Reads the active selection for an API origin, or `null` when absent/malformed. A
|
|
28
|
+
* selection made against one origin never applies to another.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} projectRoot - Consumer project root.
|
|
31
|
+
* @param {string} apiUrl - The API origin whose selection to read.
|
|
32
|
+
* @returns {Promise<ActiveSelection | null>} The selection for that origin, or `null`.
|
|
33
|
+
* @example
|
|
34
|
+
* const sel = await readActiveSelection(process.cwd(), 'https://api.picked.app')
|
|
35
|
+
*/
|
|
36
|
+
export declare function readActiveSelection(projectRoot: string, apiUrl: string): Promise<ActiveSelection | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Persists the active selection for an API origin to `<root>/.picked/settings.json`,
|
|
39
|
+
* preserving selections stored for other origins.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} projectRoot - Consumer project root.
|
|
42
|
+
* @param {string} apiUrl - The API origin this selection targets.
|
|
43
|
+
* @param {ActiveSelection} selection - Selection to persist.
|
|
44
|
+
* @returns {Promise<void>} Resolves after write.
|
|
45
|
+
* @example
|
|
46
|
+
* await writeActiveSelection(process.cwd(), 'https://api.picked.app', { projectId: 'p1' })
|
|
47
|
+
*/
|
|
48
|
+
export declare function writeActiveSelection(projectRoot: string, apiUrl: string, selection: ActiveSelection): Promise<void>;
|
|
49
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/settings.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAQlD,yFAAyF;AACzF,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEtE,oDAAoD;AACpD,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,kBAAkB,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,wBAAwB,CAAA;CACrC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/D;AA4ED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAGjC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,eAAe,GACzB,OAAO,CAAC,IAAI,CAAC,CAef"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type ExperienceContentResponse, type ProjectConfig, type WorkspaceSchema } from '@picked/delivery-api-client';
|
|
2
|
+
import type { PickedConfigSource, ResolvedPickedConfig } from './config.js';
|
|
3
|
+
/** File name of the snapshot, in the directory holding `picked.config`. */
|
|
4
|
+
export declare const SNAPSHOT_FILENAME = "picked.snapshot.json";
|
|
5
|
+
/** Format version written to `snapshotVersion`. A reader refuses any other. */
|
|
6
|
+
export declare const SNAPSHOT_VERSION = 1;
|
|
7
|
+
/** The contents of `picked.snapshot.json`. */
|
|
8
|
+
export interface PickedSnapshot {
|
|
9
|
+
/** Format version; see {@link SNAPSHOT_VERSION}. */
|
|
10
|
+
snapshotVersion: number;
|
|
11
|
+
/** Project the snapshot was pulled from. */
|
|
12
|
+
projectId: string;
|
|
13
|
+
/** Workspace the snapshot was pulled from. */
|
|
14
|
+
workspaceId: string;
|
|
15
|
+
/** Workspace version every payload was served at; `null` for preview data, which has none. */
|
|
16
|
+
projectVersionId: string | null;
|
|
17
|
+
/** Whether the snapshot holds published or preview data. */
|
|
18
|
+
source: PickedConfigSource;
|
|
19
|
+
/** The workspace schema that type generation reads. */
|
|
20
|
+
schema: WorkspaceSchema;
|
|
21
|
+
/** The project config the SDK runs on. */
|
|
22
|
+
projectConfig: ProjectConfig;
|
|
23
|
+
/** Content for every experience whose steps reference CMS content, keyed by experience id. */
|
|
24
|
+
experiences: Record<string, ExperienceContentResponse>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the absolute path of `picked.snapshot.json` in a project root.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} projectRoot - Directory holding `picked.config`.
|
|
30
|
+
* @returns {string} Absolute snapshot path.
|
|
31
|
+
* @example
|
|
32
|
+
* resolveSnapshotPath('/app') // '/app/picked.snapshot.json'
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveSnapshotPath(projectRoot: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the ids of experiences whose steps reference CMS content, in config order.
|
|
37
|
+
*
|
|
38
|
+
* @param {ProjectConfig} config - Project config to walk.
|
|
39
|
+
* @returns {string[]} Ids of the CMS-using experiences.
|
|
40
|
+
* @example
|
|
41
|
+
* collectCmsExperienceIds(config) // ['exp-a', 'exp-b']
|
|
42
|
+
*/
|
|
43
|
+
export declare function collectCmsExperienceIds(config: ProjectConfig): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Serialises a snapshot: top-level fields in a fixed order, experiences by id, two-space
|
|
46
|
+
* indentation and a trailing newline. Payloads keep the key order the API served them in, so
|
|
47
|
+
* unchanged data serialises to the same bytes.
|
|
48
|
+
*
|
|
49
|
+
* @param {PickedSnapshot} snapshot - Snapshot to serialise.
|
|
50
|
+
* @returns {string} The file contents.
|
|
51
|
+
* @example
|
|
52
|
+
* await writeFile(path, serializeSnapshot(snapshot))
|
|
53
|
+
*/
|
|
54
|
+
export declare function serializeSnapshot(snapshot: PickedSnapshot): string;
|
|
55
|
+
/**
|
|
56
|
+
* Reads `picked.snapshot.json` from a project root.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} projectRoot - Directory holding `picked.config`.
|
|
59
|
+
* @returns {Promise<PickedSnapshot | null>} The snapshot, or `null` when the file does not exist.
|
|
60
|
+
* @throws {Error} When the file is not JSON, is in another format version, or lacks a field.
|
|
61
|
+
* @example
|
|
62
|
+
* const snapshot = await readSnapshot('/app')
|
|
63
|
+
*/
|
|
64
|
+
export declare function readSnapshot(projectRoot: string): Promise<PickedSnapshot | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Reads the snapshot a `data: 'snapshot'` run builds from, and checks it is for the project in
|
|
67
|
+
* force.
|
|
68
|
+
*
|
|
69
|
+
* @param {Pick<ResolvedPickedConfig, 'projectRoot' | 'projectId'>} config - The resolved config.
|
|
70
|
+
* @returns {Promise<PickedSnapshot>} The snapshot.
|
|
71
|
+
* @throws {Error} When the snapshot is missing, unreadable, or for another project.
|
|
72
|
+
* @example
|
|
73
|
+
* const snapshot = await requireSnapshot(resolvedConfig)
|
|
74
|
+
*/
|
|
75
|
+
export declare function requireSnapshot(config: Pick<ResolvedPickedConfig, 'projectRoot' | 'projectId'>): Promise<PickedSnapshot>;
|
|
76
|
+
/**
|
|
77
|
+
* Writes `picked.snapshot.json` to a project root.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} projectRoot - Directory holding `picked.config`.
|
|
80
|
+
* @param {PickedSnapshot} snapshot - Snapshot to write.
|
|
81
|
+
* @returns {Promise<void>} Resolves once the file is written.
|
|
82
|
+
* @example
|
|
83
|
+
* await writeSnapshot('/app', snapshot)
|
|
84
|
+
*/
|
|
85
|
+
export declare function writeSnapshot(projectRoot: string, snapshot: PickedSnapshot): Promise<void>;
|
|
86
|
+
/** Options for {@link fetchSnapshot}. */
|
|
87
|
+
export interface FetchSnapshotOptions {
|
|
88
|
+
/** Origin of the Picked API. */
|
|
89
|
+
apiUrl: string;
|
|
90
|
+
/** Project to pull. */
|
|
91
|
+
projectId: string;
|
|
92
|
+
/** Whether the pull reads published or preview data. Recorded in the snapshot. */
|
|
93
|
+
source: PickedConfigSource;
|
|
94
|
+
/** Workspace preview token, sent with every request and never written to the snapshot. */
|
|
95
|
+
previewToken?: string;
|
|
96
|
+
/** Headers to send with every request, such as `Picked-Client`. */
|
|
97
|
+
headers?: Record<string, string>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Fetches a snapshot from the delivery API: the workspace schema, the project config, and the
|
|
101
|
+
* content of every experience whose steps reference CMS content.
|
|
102
|
+
*
|
|
103
|
+
* @param {FetchSnapshotOptions} options - What to pull, and from where.
|
|
104
|
+
* @returns {Promise<PickedSnapshot>} The snapshot.
|
|
105
|
+
* @throws {Error} When a request fails, or the payloads come from different versions.
|
|
106
|
+
* @example
|
|
107
|
+
* const snapshot = await fetchSnapshot({ apiUrl, projectId, source: 'published' })
|
|
108
|
+
*/
|
|
109
|
+
export declare function fetchSnapshot(options: FetchSnapshotOptions): Promise<PickedSnapshot>;
|
|
110
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/snapshot.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAExE,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,yBAAyB,CAAA;AAEvD,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,IAAI,CAAA;AAEjC,8CAA8C;AAC9C,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,eAAe,EAAE,MAAM,CAAA;IACvB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAA;IACnB,8FAA8F;IAC9F,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,4DAA4D;IAC5D,MAAM,EAAE,kBAAkB,CAAA;IAC1B,uDAAuD;IACvD,MAAM,EAAE,eAAe,CAAA;IACvB,0CAA0C;IAC1C,aAAa,EAAE,aAAa,CAAA;IAC5B,8FAA8F;IAC9F,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;CACvD;AAID;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAiBvE;AAiBD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAmBlE;AA0ED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA4BtF;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,aAAa,GAAG,WAAW,CAAC,GAC9D,OAAO,CAAC,cAAc,CAAC,CAezB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG;AAED,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,MAAM,EAAE,kBAAkB,CAAA;IAC1B,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACjC;AAkDD;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CAyC1F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @file The telemetry opt-in chain shared by the CLI and the Vite plugin. */
|
|
2
|
+
import type { ResolvedPickedConfig } from './config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether the environment forces telemetry off, whatever any other layer says.
|
|
5
|
+
*
|
|
6
|
+
* Callers use this to short-circuit before doing any telemetry work.
|
|
7
|
+
*
|
|
8
|
+
* @returns {boolean} True when `PICKED_TELEMETRY` is off or `DO_NOT_TRACK` is on.
|
|
9
|
+
* @example isTelemetryForcedOffByEnvironment()
|
|
10
|
+
*/
|
|
11
|
+
export declare function isTelemetryForcedOffByEnvironment(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves whether telemetry is on, across every layer that can say so.
|
|
14
|
+
*
|
|
15
|
+
* Precedence, highest first: `PICKED_TELEMETRY` off or `DO_NOT_TRACK` on, the caller's
|
|
16
|
+
* override, `PICKED_TELEMETRY` on, then `picked.config`. Both variables take `1`/`0` and
|
|
17
|
+
* `true`/`false` in any case; any other value says nothing and defers to the next layer.
|
|
18
|
+
*
|
|
19
|
+
* @param {ResolvedPickedConfig} config - Resolved configuration carrying the committed setting.
|
|
20
|
+
* @param {boolean} [override] - A caller-supplied setting, such as the Vite plugin's option.
|
|
21
|
+
* @returns {boolean} True when telemetry should be emitted.
|
|
22
|
+
* @example isTelemetryEnabled(resolved, options.telemetry)
|
|
23
|
+
*/
|
|
24
|
+
export declare function isTelemetryEnabled(config: ResolvedPickedConfig, override?: boolean): boolean;
|
|
25
|
+
//# sourceMappingURL=telemetry-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-config.d.ts","sourceRoot":"","sources":["../../src/telemetry-config.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAyBpD;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,IAAI,OAAO,CAK3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAM5F"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @file Shared HTTPS-enforcement guard for API URLs carrying tokens/secrets. */
|
|
2
|
+
/**
|
|
3
|
+
* Returns `url` when it is safe to send bearer/refresh/preview tokens to, else
|
|
4
|
+
* throws. HTTPS is required except for loopback hosts (local development).
|
|
5
|
+
*
|
|
6
|
+
* @param {string} url - Candidate API base URL.
|
|
7
|
+
* @returns {string} The same URL when it is safe.
|
|
8
|
+
* @throws {Error} When the URL is malformed, or not HTTPS and not a loopback host.
|
|
9
|
+
* @example
|
|
10
|
+
* assertSecureApiUrl('https://api.picked.app')
|
|
11
|
+
*/
|
|
12
|
+
export declare function assertSecureApiUrl(url: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Reduces a Picked API URL to its canonical origin: protocol, lowercased host, and
|
|
15
|
+
* non-default port only. Validates it with {@link assertSecureApiUrl} first, so the
|
|
16
|
+
* result is always safe to send tokens to. Path, query, and trailing slash are dropped,
|
|
17
|
+
* giving a stable key for per-origin storage that will not vary with cosmetic spelling.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} url - Candidate API base URL.
|
|
20
|
+
* @returns {string} The canonical origin, e.g. `https://api.picked.app` or `http://127.0.0.1:6232`.
|
|
21
|
+
* @throws {Error} When the URL is malformed, or not HTTPS and not a loopback host.
|
|
22
|
+
* @example
|
|
23
|
+
* normalizeApiUrl('https://API.Picked.App/api/graphql/') // 'https://api.picked.app'
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeApiUrl(url: string): string;
|
|
26
|
+
//# sourceMappingURL=url-safety.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-safety.d.ts","sourceRoot":"","sources":["../../src/url-safety.ts"],"names":[],"mappings":"AAAA,iFAAiF;AAEjF;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsBtD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD"}
|
package/dist/types/define.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* @file `@picked/config/define`: `defineConfig`, `hasApp`, `hasProject` and the config types. Nothing
|
|
3
3
|
* it imports reads files or loads a Node built-in.
|
|
4
4
|
*/
|
|
5
|
-
export { defineConfig, hasApp, hasProject } from './config';
|
|
6
|
-
export type { PickedAppConfig, PickedConfig, PickedConfigSource, PickedDataMode, PickedProjectConfig, } from './config';
|
|
5
|
+
export { defineConfig, hasApp, hasProject } from './config.js';
|
|
6
|
+
export type { PickedAppConfig, PickedConfig, PickedConfigSource, PickedDataMode, PickedProjectConfig, } from './config.js';
|
|
7
7
|
//# sourceMappingURL=define.d.ts.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/** @file Public exports for `\@picked/config`. */
|
|
2
|
-
export { defineConfig, hasApp, hasProject } from './config';
|
|
3
|
-
export type { PickedAppConfig, PickedCodegenManifest, PickedConfig, PickedConfigSource, PickedDataMode, PickedProjectConfig, ResolvedPickedConfig, } from './config';
|
|
4
|
-
export { loadPickedConfig, loadResolvedPickedConfig, resolvePickedConfig } from './load-config';
|
|
5
|
-
export { appendPickedGitignore, hashSchemaJson, readCodegenManifest, resolvePickedPaths, writeCodegenArtifacts, } from './manifest';
|
|
6
|
-
export { detectHostEnvironment } from './host-environment';
|
|
7
|
-
export type { HostEnvironment, HostProvider } from './host-environment';
|
|
8
|
-
export { isTelemetryEnabled, isTelemetryForcedOffByEnvironment } from './telemetry-config';
|
|
9
|
-
export { readActiveSelection, resolveSettingsPath, writeActiveSelection } from './settings';
|
|
10
|
-
export type { ActiveSelection, ActiveWorkspaceSelection, WorkspaceStatus } from './settings';
|
|
11
|
-
export { assertSecureApiUrl, normalizeApiUrl } from './url-safety';
|
|
12
|
-
export { SNAPSHOT_FILENAME, SNAPSHOT_VERSION, collectCmsExperienceIds, fetchSnapshot, readSnapshot, requireSnapshot, resolveSnapshotPath, serializeSnapshot, writeSnapshot, } from './snapshot';
|
|
13
|
-
export type { FetchSnapshotOptions, PickedSnapshot } from './snapshot';
|
|
2
|
+
export { defineConfig, hasApp, hasProject } from './config.js';
|
|
3
|
+
export type { PickedAppConfig, PickedCodegenManifest, PickedConfig, PickedConfigSource, PickedDataMode, PickedProjectConfig, ResolvedPickedConfig, } from './config.js';
|
|
4
|
+
export { loadPickedConfig, loadResolvedPickedConfig, resolvePickedConfig } from './load-config.js';
|
|
5
|
+
export { appendPickedGitignore, hashSchemaJson, readCodegenManifest, resolvePickedPaths, writeCodegenArtifacts, } from './manifest.js';
|
|
6
|
+
export { detectHostEnvironment } from './host-environment.js';
|
|
7
|
+
export type { HostEnvironment, HostProvider } from './host-environment.js';
|
|
8
|
+
export { isTelemetryEnabled, isTelemetryForcedOffByEnvironment } from './telemetry-config.js';
|
|
9
|
+
export { readActiveSelection, resolveSettingsPath, writeActiveSelection } from './settings.js';
|
|
10
|
+
export type { ActiveSelection, ActiveWorkspaceSelection, WorkspaceStatus } from './settings.js';
|
|
11
|
+
export { assertSecureApiUrl, normalizeApiUrl } from './url-safety.js';
|
|
12
|
+
export { SNAPSHOT_FILENAME, SNAPSHOT_VERSION, collectCmsExperienceIds, fetchSnapshot, readSnapshot, requireSnapshot, resolveSnapshotPath, serializeSnapshot, writeSnapshot, } from './snapshot.js';
|
|
13
|
+
export type { FetchSnapshotOptions, PickedSnapshot } from './snapshot.js';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PickedConfig, PickedProjectConfig, ResolvedPickedConfig } from './config';
|
|
2
|
-
import type { ActiveSelection } from './settings';
|
|
1
|
+
import type { PickedConfig, PickedProjectConfig, ResolvedPickedConfig } from './config.js';
|
|
2
|
+
import type { ActiveSelection } from './settings.js';
|
|
3
3
|
/**
|
|
4
4
|
* Resolves a user config with defaults, an optional persisted selection, and env overrides.
|
|
5
5
|
*
|
package/dist/types/manifest.d.ts
CHANGED
package/dist/types/settings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PickedConfigSource } from './config';
|
|
1
|
+
import type { PickedConfigSource } from './config.js';
|
|
2
2
|
/** Lifecycle status of a selected workspace, mirroring the GraphQL `WorkspaceStatus`. */
|
|
3
3
|
export type WorkspaceStatus = 'DRAFT' | 'LIVE' | 'ARCHIVED' | 'HIDDEN';
|
|
4
4
|
/** The workspace portion of an active selection. */
|
package/dist/types/snapshot.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExperienceContentResponse, type ProjectConfig, type WorkspaceSchema } from '@picked/delivery-api-client';
|
|
2
|
-
import type { PickedConfigSource, ResolvedPickedConfig } from './config';
|
|
2
|
+
import type { PickedConfigSource, ResolvedPickedConfig } from './config.js';
|
|
3
3
|
/** File name of the snapshot, in the directory holding `picked.config`. */
|
|
4
4
|
export declare const SNAPSHOT_FILENAME = "picked.snapshot.json";
|
|
5
5
|
/** Format version written to `snapshotVersion`. A reader refuses any other. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @file The telemetry opt-in chain shared by the CLI and the Vite plugin. */
|
|
2
|
-
import type { ResolvedPickedConfig } from './config';
|
|
2
|
+
import type { ResolvedPickedConfig } from './config.js';
|
|
3
3
|
/**
|
|
4
4
|
* Whether the environment forces telemetry off, whatever any other layer says.
|
|
5
5
|
*
|