@sanity/cli-core 0.0.2-alpha.3 → 0.1.0-alpha.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 (39) hide show
  1. package/dist/SanityCommand.d.ts +12 -0
  2. package/dist/SanityCommand.js +14 -0
  3. package/dist/SanityCommand.js.map +1 -1
  4. package/dist/_exports/tree.d.ts +1 -0
  5. package/dist/_exports/tree.js +3 -0
  6. package/dist/_exports/tree.js.map +1 -0
  7. package/dist/_exports/ux.d.ts +4 -0
  8. package/dist/_exports/ux.js +6 -0
  9. package/dist/_exports/ux.js.map +1 -0
  10. package/dist/config/studio/readStudioConfig.d.ts +270 -10
  11. package/dist/config/studio/readStudioConfig.js +13 -9
  12. package/dist/config/studio/readStudioConfig.js.map +1 -1
  13. package/dist/index.d.ts +2 -4
  14. package/dist/index.js +1 -3
  15. package/dist/index.js.map +1 -1
  16. package/dist/services/apiClient.js +1 -2
  17. package/dist/services/apiClient.js.map +1 -1
  18. package/dist/types.d.ts +8 -0
  19. package/dist/types.js +2 -0
  20. package/dist/types.js.map +1 -1
  21. package/dist/util/resolveLocalPackage.d.ts +18 -0
  22. package/dist/util/resolveLocalPackage.js +33 -0
  23. package/dist/util/resolveLocalPackage.js.map +1 -0
  24. package/dist/util/tree.d.ts +31 -0
  25. package/dist/util/tree.js +108 -0
  26. package/dist/util/tree.js.map +1 -0
  27. package/dist/ux/chalk.d.ts +2 -0
  28. package/dist/ux/chalk.js +4 -0
  29. package/dist/ux/chalk.js.map +1 -0
  30. package/dist/ux/prompts.d.ts +1 -0
  31. package/dist/ux/prompts.js +3 -0
  32. package/dist/ux/prompts.js.map +1 -0
  33. package/dist/ux/spinner.d.ts +1 -1
  34. package/dist/ux/spinner.js +1 -1
  35. package/dist/ux/spinner.js.map +1 -1
  36. package/package.json +15 -3
  37. package/dist/util/isHttpError.d.ts +0 -29
  38. package/dist/util/isHttpError.js +0 -18
  39. package/dist/util/isHttpError.js.map +0 -1
@@ -52,5 +52,17 @@ export declare abstract class SanityCommand<T extends typeof Command> extends Co
52
52
  */
53
53
  protected getProjectRoot(): Promise<ProjectRootResult>;
54
54
  init(): Promise<void>;
55
+ /**
56
+ * Check if the command is running in unattended mode.
57
+ *
58
+ * This means the command should not ask for user input, instead using defaults where
59
+ * possible, and if that does not make sense (eg there's missing information), then we
60
+ * should error out (remember to exit with a non-zero code).
61
+ *
62
+ * Most commands should take an explicit `--yes` flag to enable unattended mode, but
63
+ * some commands may also be run in unattended mode if `process.stdin` is not a TTY
64
+ * (eg when running in a CI environment).
65
+ */
66
+ protected isUnattended(): boolean;
55
67
  }
56
68
  export {};
@@ -2,6 +2,7 @@ import { Command } from '@oclif/core';
2
2
  import { getCliConfig } from './config/cli/getCliConfig.js';
3
3
  import { findProjectRoot } from './config/findProjectRoot.js';
4
4
  import { getGlobalCliClient, getProjectCliClient } from './services/apiClient.js';
5
+ import { isInteractive } from './util/isInteractive.js';
5
6
  export class SanityCommand extends Command {
6
7
  args;
7
8
  flags;
@@ -67,6 +68,19 @@ export class SanityCommand extends Command {
67
68
  this.flags = flags;
68
69
  await super.init();
69
70
  }
71
+ /**
72
+ * Check if the command is running in unattended mode.
73
+ *
74
+ * This means the command should not ask for user input, instead using defaults where
75
+ * possible, and if that does not make sense (eg there's missing information), then we
76
+ * should error out (remember to exit with a non-zero code).
77
+ *
78
+ * Most commands should take an explicit `--yes` flag to enable unattended mode, but
79
+ * some commands may also be run in unattended mode if `process.stdin` is not a TTY
80
+ * (eg when running in a CI environment).
81
+ */ isUnattended() {
82
+ return this.flags.yes || !isInteractive();
83
+ }
70
84
  }
71
85
 
72
86
  //# sourceMappingURL=SanityCommand.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/SanityCommand.ts"],"sourcesContent":["import {Command, Interfaces} from '@oclif/core'\n\nimport {getCliConfig} from './config/cli/getCliConfig.js'\nimport {type CliConfig} from './config/cli/types/cliConfig.js'\nimport {findProjectRoot} from './config/findProjectRoot.js'\nimport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nimport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from './services/apiClient.js'\nimport {type Output} from './types.js'\n\ntype Flags<T extends typeof Command> = Interfaces.InferredFlags<\n (typeof SanityCommand)['baseFlags'] & T['flags']\n>\n\ntype Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>\n\nexport abstract class SanityCommand<T extends typeof Command> extends Command {\n protected args!: Args<T>\n protected flags!: Flags<T>\n\n /**\n * Get the global API client.\n *\n * @param args - The global API client options.\n * @returns The global API client.\n */\n protected getGlobalApiClient = (args: GlobalCliClientOptions) => getGlobalCliClient(args)\n\n /**\n * Get the project API client.\n *\n * @param args - The project API client options.\n * @returns The project API client.\n */\n protected getProjectApiClient = (args: ProjectCliClientOptions) => getProjectCliClient(args)\n\n /**\n * Helper for outputting to the console.\n *\n * @example\n * ```ts\n * this.output.log('Hello')\n * this.output.warn('Warning')\n * this.output.error('Error')\n * ```\n */\n protected output: Output = {\n error: this.error.bind(this),\n log: this.log.bind(this),\n warn: this.warn.bind(this),\n }\n\n /**\n * Get the CLI config.\n *\n * @returns The CLI config.\n */\n protected async getCliConfig(): Promise<CliConfig> {\n const root = await this.getProjectRoot()\n const config = await getCliConfig(root.directory)\n\n return config\n }\n\n /**\n * Get the project ID from the CLI config.\n *\n * @returns The project ID or `undefined` if it's not set.\n */\n protected async getProjectId(): Promise<string | undefined> {\n const config = await this.getCliConfig()\n\n return config.api?.projectId\n }\n\n /**\n * Get the project's root directory by resolving the config\n *\n * @returns The root project root.\n */\n protected getProjectRoot(): Promise<ProjectRootResult> {\n return findProjectRoot(process.cwd())\n }\n\n public async init(): Promise<void> {\n const {args, flags} = await this.parse({\n args: this.ctor.args,\n baseFlags: (super.ctor as typeof SanityCommand).baseFlags,\n enableJsonFlag: this.ctor.enableJsonFlag,\n flags: this.ctor.flags,\n strict: this.ctor.strict,\n })\n\n this.args = args as Args<T>\n this.flags = flags as Flags<T>\n\n await super.init()\n }\n}\n"],"names":["Command","getCliConfig","findProjectRoot","getGlobalCliClient","getProjectCliClient","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","root","getProjectRoot","config","directory","getProjectId","api","projectId","process","cwd","init","parse","ctor","baseFlags","enableJsonFlag","strict"],"mappings":"AAAA,SAAQA,OAAO,QAAmB,cAAa;AAE/C,SAAQC,YAAY,QAAO,+BAA8B;AAEzD,SAAQC,eAAe,QAAO,8BAA6B;AAE3D,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,0BAAyB;AAShC,OAAO,MAAeC,sBAAgDL;IAC1DM,KAAc;IACdC,MAAgB;IAE1B;;;;;GAKC,GACD,AAAUC,qBAAqB,CAACF,OAAiCH,mBAAmBG,MAAK;IAEzF;;;;;GAKC,GACD,AAAUG,sBAAsB,CAACH,OAAkCF,oBAAoBE,MAAK;IAE5F;;;;;;;;;GASC,GACD,AAAUI,SAAiB;QACzBC,OAAO,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,IAAI;QAC3BC,KAAK,IAAI,CAACA,GAAG,CAACD,IAAI,CAAC,IAAI;QACvBE,MAAM,IAAI,CAACA,IAAI,CAACF,IAAI,CAAC,IAAI;IAC3B,EAAC;IAED;;;;GAIC,GACD,MAAgBX,eAAmC;QACjD,MAAMc,OAAO,MAAM,IAAI,CAACC,cAAc;QACtC,MAAMC,SAAS,MAAMhB,aAAac,KAAKG,SAAS;QAEhD,OAAOD;IACT;IAEA;;;;GAIC,GACD,MAAgBE,eAA4C;QAC1D,MAAMF,SAAS,MAAM,IAAI,CAAChB,YAAY;QAEtC,OAAOgB,OAAOG,GAAG,EAAEC;IACrB;IAEA;;;;GAIC,GACD,AAAUL,iBAA6C;QACrD,OAAOd,gBAAgBoB,QAAQC,GAAG;IACpC;IAEA,MAAaC,OAAsB;QACjC,MAAM,EAAClB,IAAI,EAAEC,KAAK,EAAC,GAAG,MAAM,IAAI,CAACkB,KAAK,CAAC;YACrCnB,MAAM,IAAI,CAACoB,IAAI,CAACpB,IAAI;YACpBqB,WAAW,AAAC,KAAK,CAACD,KAA8BC,SAAS;YACzDC,gBAAgB,IAAI,CAACF,IAAI,CAACE,cAAc;YACxCrB,OAAO,IAAI,CAACmB,IAAI,CAACnB,KAAK;YACtBsB,QAAQ,IAAI,CAACH,IAAI,CAACG,MAAM;QAC1B;QAEA,IAAI,CAACvB,IAAI,GAAGA;QACZ,IAAI,CAACC,KAAK,GAAGA;QAEb,MAAM,KAAK,CAACiB;IACd;AACF"}
1
+ {"version":3,"sources":["../src/SanityCommand.ts"],"sourcesContent":["import {Command, Interfaces} from '@oclif/core'\n\nimport {getCliConfig} from './config/cli/getCliConfig.js'\nimport {type CliConfig} from './config/cli/types/cliConfig.js'\nimport {findProjectRoot} from './config/findProjectRoot.js'\nimport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nimport {\n getGlobalCliClient,\n getProjectCliClient,\n type GlobalCliClientOptions,\n type ProjectCliClientOptions,\n} from './services/apiClient.js'\nimport {type Output} from './types.js'\nimport {isInteractive} from './util/isInteractive.js'\n\ntype Flags<T extends typeof Command> = Interfaces.InferredFlags<\n (typeof SanityCommand)['baseFlags'] & T['flags']\n>\n\ntype Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>\n\nexport abstract class SanityCommand<T extends typeof Command> extends Command {\n protected args!: Args<T>\n protected flags!: Flags<T>\n\n /**\n * Get the global API client.\n *\n * @param args - The global API client options.\n * @returns The global API client.\n */\n protected getGlobalApiClient = (args: GlobalCliClientOptions) => getGlobalCliClient(args)\n\n /**\n * Get the project API client.\n *\n * @param args - The project API client options.\n * @returns The project API client.\n */\n protected getProjectApiClient = (args: ProjectCliClientOptions) => getProjectCliClient(args)\n\n /**\n * Helper for outputting to the console.\n *\n * @example\n * ```ts\n * this.output.log('Hello')\n * this.output.warn('Warning')\n * this.output.error('Error')\n * ```\n */\n protected output: Output = {\n error: this.error.bind(this),\n log: this.log.bind(this),\n warn: this.warn.bind(this),\n }\n\n /**\n * Get the CLI config.\n *\n * @returns The CLI config.\n */\n protected async getCliConfig(): Promise<CliConfig> {\n const root = await this.getProjectRoot()\n const config = await getCliConfig(root.directory)\n\n return config\n }\n\n /**\n * Get the project ID from the CLI config.\n *\n * @returns The project ID or `undefined` if it's not set.\n */\n protected async getProjectId(): Promise<string | undefined> {\n const config = await this.getCliConfig()\n\n return config.api?.projectId\n }\n\n /**\n * Get the project's root directory by resolving the config\n *\n * @returns The root project root.\n */\n protected getProjectRoot(): Promise<ProjectRootResult> {\n return findProjectRoot(process.cwd())\n }\n\n public async init(): Promise<void> {\n const {args, flags} = await this.parse({\n args: this.ctor.args,\n baseFlags: (super.ctor as typeof SanityCommand).baseFlags,\n enableJsonFlag: this.ctor.enableJsonFlag,\n flags: this.ctor.flags,\n strict: this.ctor.strict,\n })\n\n this.args = args as Args<T>\n this.flags = flags as Flags<T>\n\n await super.init()\n }\n\n /**\n * Check if the command is running in unattended mode.\n *\n * This means the command should not ask for user input, instead using defaults where\n * possible, and if that does not make sense (eg there's missing information), then we\n * should error out (remember to exit with a non-zero code).\n *\n * Most commands should take an explicit `--yes` flag to enable unattended mode, but\n * some commands may also be run in unattended mode if `process.stdin` is not a TTY\n * (eg when running in a CI environment).\n */\n protected isUnattended(): boolean {\n return this.flags.yes || !isInteractive()\n }\n}\n"],"names":["Command","getCliConfig","findProjectRoot","getGlobalCliClient","getProjectCliClient","isInteractive","SanityCommand","args","flags","getGlobalApiClient","getProjectApiClient","output","error","bind","log","warn","root","getProjectRoot","config","directory","getProjectId","api","projectId","process","cwd","init","parse","ctor","baseFlags","enableJsonFlag","strict","isUnattended","yes"],"mappings":"AAAA,SAAQA,OAAO,QAAmB,cAAa;AAE/C,SAAQC,YAAY,QAAO,+BAA8B;AAEzD,SAAQC,eAAe,QAAO,8BAA6B;AAE3D,SACEC,kBAAkB,EAClBC,mBAAmB,QAGd,0BAAyB;AAEhC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AEA;;;;;;;;;;GAUC,GACD,AAAUM,eAAwB;QAChC,OAAO,IAAI,CAACvB,KAAK,CAACwB,GAAG,IAAI,CAAC3B;IAC5B;AACF"}
@@ -0,0 +1 @@
1
+ export * from '../util/tree.js';
@@ -0,0 +1,3 @@
1
+ export * from '../util/tree.js';
2
+
3
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/_exports/tree.ts"],"sourcesContent":["export * from '../util/tree.js'\n"],"names":[],"mappings":"AAAA,cAAc,kBAAiB"}
@@ -0,0 +1,4 @@
1
+ export * from '../ux/chalk.js';
2
+ export * from '../ux/logSymbols.js';
3
+ export * from '../ux/prompts.js';
4
+ export * from '../ux/spinner.js';
@@ -0,0 +1,6 @@
1
+ export * from '../ux/chalk.js';
2
+ export * from '../ux/logSymbols.js';
3
+ export * from '../ux/prompts.js';
4
+ export * from '../ux/spinner.js';
5
+
6
+ //# sourceMappingURL=ux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/_exports/ux.ts"],"sourcesContent":["export * from '../ux/chalk.js'\nexport * from '../ux/logSymbols.js'\nexport * from '../ux/prompts.js'\nexport * from '../ux/spinner.js'\n"],"names":[],"mappings":"AAAA,cAAc,iBAAgB;AAC9B,cAAc,sBAAqB;AACnC,cAAc,mBAAkB;AAChC,cAAc,mBAAkB"}
@@ -1,9 +1,54 @@
1
1
  import { z } from 'zod';
2
2
  declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
3
3
  basePath: z.ZodString;
4
- dataset: z.ZodString;
5
4
  name: z.ZodString;
6
5
  plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
6
+ title: z.ZodString;
7
+ unstable_sources: z.ZodArray<z.ZodObject<{
8
+ dataset: z.ZodString;
9
+ projectId: z.ZodString;
10
+ schema: z.ZodObject<{
11
+ _original: z.ZodObject<{
12
+ name: z.ZodOptional<z.ZodString>;
13
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
14
+ }, "strip", z.ZodTypeAny, {
15
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
16
+ name?: string | undefined;
17
+ }, {
18
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
19
+ name?: string | undefined;
20
+ }>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ _original: {
23
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
24
+ name?: string | undefined;
25
+ };
26
+ }, {
27
+ _original: {
28
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
29
+ name?: string | undefined;
30
+ };
31
+ }>;
32
+ }, "strip", z.ZodTypeAny, {
33
+ dataset: string;
34
+ projectId: string;
35
+ schema: {
36
+ _original: {
37
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
38
+ name?: string | undefined;
39
+ };
40
+ };
41
+ }, {
42
+ dataset: string;
43
+ projectId: string;
44
+ schema: {
45
+ _original: {
46
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
47
+ name?: string | undefined;
48
+ };
49
+ };
50
+ }>, "many">;
51
+ dataset: z.ZodString;
7
52
  projectId: z.ZodString;
8
53
  schema: z.ZodObject<{
9
54
  _original: z.ZodObject<{
@@ -27,7 +72,6 @@ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
27
72
  name?: string | undefined;
28
73
  };
29
74
  }>;
30
- title: z.ZodString;
31
75
  }, "strip", z.ZodTypeAny, {
32
76
  name: string;
33
77
  dataset: string;
@@ -40,6 +84,16 @@ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
40
84
  };
41
85
  };
42
86
  title: string;
87
+ unstable_sources: {
88
+ dataset: string;
89
+ projectId: string;
90
+ schema: {
91
+ _original: {
92
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
93
+ name?: string | undefined;
94
+ };
95
+ };
96
+ }[];
43
97
  plugins?: unknown[] | undefined;
44
98
  }, {
45
99
  name: string;
@@ -53,13 +107,21 @@ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
53
107
  };
54
108
  };
55
109
  title: string;
110
+ unstable_sources: {
111
+ dataset: string;
112
+ projectId: string;
113
+ schema: {
114
+ _original: {
115
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
116
+ name?: string | undefined;
117
+ };
118
+ };
119
+ }[];
56
120
  plugins?: unknown[] | undefined;
57
121
  }>, "many">, z.ZodObject<{
58
122
  basePath: z.ZodOptional<z.ZodString>;
59
- dataset: z.ZodString;
60
123
  name: z.ZodOptional<z.ZodString>;
61
124
  plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
62
- projectId: z.ZodString;
63
125
  schema: z.ZodOptional<z.ZodObject<{
64
126
  name: z.ZodOptional<z.ZodString>;
65
127
  types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
@@ -71,12 +133,56 @@ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
71
133
  name?: string | undefined;
72
134
  }>>;
73
135
  title: z.ZodOptional<z.ZodString>;
136
+ unstable_sources: z.ZodArray<z.ZodObject<{
137
+ dataset: z.ZodString;
138
+ projectId: z.ZodString;
139
+ schema: z.ZodObject<{
140
+ _original: z.ZodObject<{
141
+ name: z.ZodOptional<z.ZodString>;
142
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
143
+ }, "strip", z.ZodTypeAny, {
144
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
145
+ name?: string | undefined;
146
+ }, {
147
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
148
+ name?: string | undefined;
149
+ }>;
150
+ }, "strip", z.ZodTypeAny, {
151
+ _original: {
152
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
153
+ name?: string | undefined;
154
+ };
155
+ }, {
156
+ _original: {
157
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
158
+ name?: string | undefined;
159
+ };
160
+ }>;
161
+ }, "strip", z.ZodTypeAny, {
162
+ dataset: string;
163
+ projectId: string;
164
+ schema: {
165
+ _original: {
166
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
167
+ name?: string | undefined;
168
+ };
169
+ };
170
+ }, {
171
+ dataset: string;
172
+ projectId: string;
173
+ schema: {
174
+ _original: {
175
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
176
+ name?: string | undefined;
177
+ };
178
+ };
179
+ }>, "many">;
180
+ dataset: z.ZodString;
181
+ projectId: z.ZodString;
74
182
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
75
183
  basePath: z.ZodOptional<z.ZodString>;
76
- dataset: z.ZodString;
77
184
  name: z.ZodOptional<z.ZodString>;
78
185
  plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
79
- projectId: z.ZodString;
80
186
  schema: z.ZodOptional<z.ZodObject<{
81
187
  name: z.ZodOptional<z.ZodString>;
82
188
  types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
@@ -88,12 +194,56 @@ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
88
194
  name?: string | undefined;
89
195
  }>>;
90
196
  title: z.ZodOptional<z.ZodString>;
197
+ unstable_sources: z.ZodArray<z.ZodObject<{
198
+ dataset: z.ZodString;
199
+ projectId: z.ZodString;
200
+ schema: z.ZodObject<{
201
+ _original: z.ZodObject<{
202
+ name: z.ZodOptional<z.ZodString>;
203
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
204
+ }, "strip", z.ZodTypeAny, {
205
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
206
+ name?: string | undefined;
207
+ }, {
208
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
209
+ name?: string | undefined;
210
+ }>;
211
+ }, "strip", z.ZodTypeAny, {
212
+ _original: {
213
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
214
+ name?: string | undefined;
215
+ };
216
+ }, {
217
+ _original: {
218
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
219
+ name?: string | undefined;
220
+ };
221
+ }>;
222
+ }, "strip", z.ZodTypeAny, {
223
+ dataset: string;
224
+ projectId: string;
225
+ schema: {
226
+ _original: {
227
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
228
+ name?: string | undefined;
229
+ };
230
+ };
231
+ }, {
232
+ dataset: string;
233
+ projectId: string;
234
+ schema: {
235
+ _original: {
236
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
237
+ name?: string | undefined;
238
+ };
239
+ };
240
+ }>, "many">;
241
+ dataset: z.ZodString;
242
+ projectId: z.ZodString;
91
243
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
92
244
  basePath: z.ZodOptional<z.ZodString>;
93
- dataset: z.ZodString;
94
245
  name: z.ZodOptional<z.ZodString>;
95
246
  plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
96
- projectId: z.ZodString;
97
247
  schema: z.ZodOptional<z.ZodObject<{
98
248
  name: z.ZodOptional<z.ZodString>;
99
249
  types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
@@ -105,12 +255,103 @@ declare const rawConfigSchema: z.ZodUnion<[z.ZodArray<z.ZodObject<{
105
255
  name?: string | undefined;
106
256
  }>>;
107
257
  title: z.ZodOptional<z.ZodString>;
258
+ unstable_sources: z.ZodArray<z.ZodObject<{
259
+ dataset: z.ZodString;
260
+ projectId: z.ZodString;
261
+ schema: z.ZodObject<{
262
+ _original: z.ZodObject<{
263
+ name: z.ZodOptional<z.ZodString>;
264
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
265
+ }, "strip", z.ZodTypeAny, {
266
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
267
+ name?: string | undefined;
268
+ }, {
269
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
270
+ name?: string | undefined;
271
+ }>;
272
+ }, "strip", z.ZodTypeAny, {
273
+ _original: {
274
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
275
+ name?: string | undefined;
276
+ };
277
+ }, {
278
+ _original: {
279
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
280
+ name?: string | undefined;
281
+ };
282
+ }>;
283
+ }, "strip", z.ZodTypeAny, {
284
+ dataset: string;
285
+ projectId: string;
286
+ schema: {
287
+ _original: {
288
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
289
+ name?: string | undefined;
290
+ };
291
+ };
292
+ }, {
293
+ dataset: string;
294
+ projectId: string;
295
+ schema: {
296
+ _original: {
297
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
298
+ name?: string | undefined;
299
+ };
300
+ };
301
+ }>, "many">;
302
+ dataset: z.ZodString;
303
+ projectId: z.ZodString;
108
304
  }, z.ZodTypeAny, "passthrough">>]>;
109
305
  declare const resolvedConfigSchema: z.ZodArray<z.ZodObject<{
110
306
  basePath: z.ZodString;
111
- dataset: z.ZodString;
112
307
  name: z.ZodString;
113
308
  plugins: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
309
+ title: z.ZodString;
310
+ unstable_sources: z.ZodArray<z.ZodObject<{
311
+ dataset: z.ZodString;
312
+ projectId: z.ZodString;
313
+ schema: z.ZodObject<{
314
+ _original: z.ZodObject<{
315
+ name: z.ZodOptional<z.ZodString>;
316
+ types: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
317
+ }, "strip", z.ZodTypeAny, {
318
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
319
+ name?: string | undefined;
320
+ }, {
321
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
322
+ name?: string | undefined;
323
+ }>;
324
+ }, "strip", z.ZodTypeAny, {
325
+ _original: {
326
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
327
+ name?: string | undefined;
328
+ };
329
+ }, {
330
+ _original: {
331
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
332
+ name?: string | undefined;
333
+ };
334
+ }>;
335
+ }, "strip", z.ZodTypeAny, {
336
+ dataset: string;
337
+ projectId: string;
338
+ schema: {
339
+ _original: {
340
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
341
+ name?: string | undefined;
342
+ };
343
+ };
344
+ }, {
345
+ dataset: string;
346
+ projectId: string;
347
+ schema: {
348
+ _original: {
349
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
350
+ name?: string | undefined;
351
+ };
352
+ };
353
+ }>, "many">;
354
+ dataset: z.ZodString;
114
355
  projectId: z.ZodString;
115
356
  schema: z.ZodObject<{
116
357
  _original: z.ZodObject<{
@@ -134,7 +375,6 @@ declare const resolvedConfigSchema: z.ZodArray<z.ZodObject<{
134
375
  name?: string | undefined;
135
376
  };
136
377
  }>;
137
- title: z.ZodString;
138
378
  }, "strip", z.ZodTypeAny, {
139
379
  name: string;
140
380
  dataset: string;
@@ -147,6 +387,16 @@ declare const resolvedConfigSchema: z.ZodArray<z.ZodObject<{
147
387
  };
148
388
  };
149
389
  title: string;
390
+ unstable_sources: {
391
+ dataset: string;
392
+ projectId: string;
393
+ schema: {
394
+ _original: {
395
+ types: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
396
+ name?: string | undefined;
397
+ };
398
+ };
399
+ }[];
150
400
  plugins?: unknown[] | undefined;
151
401
  }, {
152
402
  name: string;
@@ -160,6 +410,16 @@ declare const resolvedConfigSchema: z.ZodArray<z.ZodObject<{
160
410
  };
161
411
  };
162
412
  title: string;
413
+ unstable_sources: {
414
+ dataset: string;
415
+ projectId: string;
416
+ schema: {
417
+ _original: {
418
+ types: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
419
+ name?: string | undefined;
420
+ };
421
+ };
422
+ }[];
163
423
  plugins?: unknown[] | undefined;
164
424
  }>, "many">;
165
425
  export type RawStudioConfig = z.infer<typeof rawConfigSchema>;
@@ -5,25 +5,29 @@ const schemaSchema = z.object({
5
5
  name: z.string().optional(),
6
6
  types: z.array(z.object({}).passthrough())
7
7
  });
8
+ const sourceSchema = z.object({
9
+ dataset: z.string(),
10
+ projectId: z.string(),
11
+ schema: z.object({
12
+ _original: schemaSchema
13
+ })
14
+ });
8
15
  const singleStudioWorkspaceSchema = z.object({
16
+ ...sourceSchema.shape,
9
17
  basePath: z.string().optional(),
10
- dataset: z.string(),
11
18
  name: z.string().optional(),
12
19
  plugins: z.array(z.unknown()).optional(),
13
- projectId: z.string(),
14
20
  schema: schemaSchema.optional(),
15
- title: z.string().optional()
21
+ title: z.string().optional(),
22
+ unstable_sources: z.array(sourceSchema)
16
23
  }).passthrough();
17
24
  const studioWorkspaceSchema = z.object({
25
+ ...sourceSchema.shape,
18
26
  basePath: z.string(),
19
- dataset: z.string(),
20
27
  name: z.string(),
21
28
  plugins: z.array(z.unknown()).optional(),
22
- projectId: z.string(),
23
- schema: z.object({
24
- _original: schemaSchema
25
- }),
26
- title: z.string()
29
+ title: z.string(),
30
+ unstable_sources: z.array(sourceSchema)
27
31
  });
28
32
  const rawConfigSchema = z.union([
29
33
  z.array(studioWorkspaceSchema),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/studio/readStudioConfig.ts"],"sourcesContent":["import {dirname} from 'node:path'\n\nimport {z} from 'zod'\n\nimport {studioWorkerTask} from '../../loaders/studio/studioWorkerTask.js'\n\nconst schemaSchema = z.object({\n name: z.string().optional(),\n types: z.array(z.object({}).passthrough()),\n})\n\nconst singleStudioWorkspaceSchema = z\n .object({\n basePath: z.string().optional(),\n dataset: z.string(),\n name: z.string().optional(),\n plugins: z.array(z.unknown()).optional(),\n projectId: z.string(),\n schema: schemaSchema.optional(),\n title: z.string().optional(),\n })\n .passthrough()\n\nconst studioWorkspaceSchema = z.object({\n basePath: z.string(),\n dataset: z.string(),\n name: z.string(),\n plugins: z.array(z.unknown()).optional(),\n projectId: z.string(),\n schema: z.object({_original: schemaSchema}),\n title: z.string(),\n})\n\nconst rawConfigSchema = z.union([z.array(studioWorkspaceSchema), singleStudioWorkspaceSchema])\nconst resolvedConfigSchema = z.array(studioWorkspaceSchema)\n\nexport type RawStudioConfig = z.infer<typeof rawConfigSchema>\nexport type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>\n\nexport interface ReadStudioConfigOptions {\n /**\n * Whether or not to resolve the plugins defined in the config.\n *\n * In some cases, you need this in order to have the full picture of what the studio\n * would \"see\". As an example, plugins can define schema types that are not explicitly\n * defined in the users' schema types. In order to get the full picture, you need to\n * resolve the plugins, which is an asyncronous operation.\n *\n * In other cases, it might be enough to only do a shallow pass. As an example, if you\n * only need to know about the defined workspace, or the user-defined schema types,\n * this can be set to `false` - which should resolve faster (and potentially \"safer\")\n * in terms of not triggering all kinds of browser behavior that may or may not be\n * loaded as the plugins are resolved.\n */\n resolvePlugins: boolean\n}\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const result = await studioWorkerTask(new URL('readStudioConfig.worker.js', import.meta.url), {\n name: 'studioConfig',\n studioRootPath: dirname(configPath),\n workerData: {configPath, resolvePlugins: options.resolvePlugins},\n })\n\n return options.resolvePlugins ? resolvedConfigSchema.parse(result) : rawConfigSchema.parse(result)\n}\n"],"names":["dirname","z","studioWorkerTask","schemaSchema","object","name","string","optional","types","array","passthrough","singleStudioWorkspaceSchema","basePath","dataset","plugins","unknown","projectId","schema","title","studioWorkspaceSchema","_original","rawConfigSchema","union","resolvedConfigSchema","readStudioConfig","configPath","options","result","URL","url","studioRootPath","workerData","resolvePlugins","parse"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAW;AAEjC,SAAQC,CAAC,QAAO,MAAK;AAErB,SAAQC,gBAAgB,QAAO,2CAA0C;AAEzE,MAAMC,eAAeF,EAAEG,MAAM,CAAC;IAC5BC,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBC,OAAOP,EAAEQ,KAAK,CAACR,EAAEG,MAAM,CAAC,CAAC,GAAGM,WAAW;AACzC;AAEA,MAAMC,8BAA8BV,EACjCG,MAAM,CAAC;IACNQ,UAAUX,EAAEK,MAAM,GAAGC,QAAQ;IAC7BM,SAASZ,EAAEK,MAAM;IACjBD,MAAMJ,EAAEK,MAAM,GAAGC,QAAQ;IACzBO,SAASb,EAAEQ,KAAK,CAACR,EAAEc,OAAO,IAAIR,QAAQ;IACtCS,WAAWf,EAAEK,MAAM;IACnBW,QAAQd,aAAaI,QAAQ;IAC7BW,OAAOjB,EAAEK,MAAM,GAAGC,QAAQ;AAC5B,GACCG,WAAW;AAEd,MAAMS,wBAAwBlB,EAAEG,MAAM,CAAC;IACrCQ,UAAUX,EAAEK,MAAM;IAClBO,SAASZ,EAAEK,MAAM;IACjBD,MAAMJ,EAAEK,MAAM;IACdQ,SAASb,EAAEQ,KAAK,CAACR,EAAEc,OAAO,IAAIR,QAAQ;IACtCS,WAAWf,EAAEK,MAAM;IACnBW,QAAQhB,EAAEG,MAAM,CAAC;QAACgB,WAAWjB;IAAY;IACzCe,OAAOjB,EAAEK,MAAM;AACjB;AAEA,MAAMe,kBAAkBpB,EAAEqB,KAAK,CAAC;IAACrB,EAAEQ,KAAK,CAACU;IAAwBR;CAA4B;AAC7F,MAAMY,uBAAuBtB,EAAEQ,KAAK,CAACU;AAiCrC,OAAO,eAAeK,iBACpBC,UAAkB,EAClBC,OAAgC;IAEhC,MAAMC,SAAS,MAAMzB,iBAAiB,IAAI0B,IAAI,8BAA8B,YAAYC,GAAG,GAAG;QAC5FxB,MAAM;QACNyB,gBAAgB9B,QAAQyB;QACxBM,YAAY;YAACN;YAAYO,gBAAgBN,QAAQM,cAAc;QAAA;IACjE;IAEA,OAAON,QAAQM,cAAc,GAAGT,qBAAqBU,KAAK,CAACN,UAAUN,gBAAgBY,KAAK,CAACN;AAC7F"}
1
+ {"version":3,"sources":["../../../src/config/studio/readStudioConfig.ts"],"sourcesContent":["import {dirname} from 'node:path'\n\nimport {z} from 'zod'\n\nimport {studioWorkerTask} from '../../loaders/studio/studioWorkerTask.js'\n\nconst schemaSchema = z.object({\n name: z.string().optional(),\n types: z.array(z.object({}).passthrough()),\n})\n\nconst sourceSchema = z.object({\n dataset: z.string(),\n projectId: z.string(),\n schema: z.object({_original: schemaSchema}),\n})\n\nconst singleStudioWorkspaceSchema = z\n .object({\n ...sourceSchema.shape,\n basePath: z.string().optional(),\n name: z.string().optional(),\n plugins: z.array(z.unknown()).optional(),\n schema: schemaSchema.optional(),\n title: z.string().optional(),\n unstable_sources: z.array(sourceSchema),\n })\n .passthrough()\n\nconst studioWorkspaceSchema = z.object({\n ...sourceSchema.shape,\n basePath: z.string(),\n name: z.string(),\n plugins: z.array(z.unknown()).optional(),\n title: z.string(),\n unstable_sources: z.array(sourceSchema),\n})\n\nconst rawConfigSchema = z.union([z.array(studioWorkspaceSchema), singleStudioWorkspaceSchema])\nconst resolvedConfigSchema = z.array(studioWorkspaceSchema)\n\nexport type RawStudioConfig = z.infer<typeof rawConfigSchema>\nexport type ResolvedStudioConfig = z.infer<typeof resolvedConfigSchema>\n\nexport interface ReadStudioConfigOptions {\n /**\n * Whether or not to resolve the plugins defined in the config.\n *\n * In some cases, you need this in order to have the full picture of what the studio\n * would \"see\". As an example, plugins can define schema types that are not explicitly\n * defined in the users' schema types. In order to get the full picture, you need to\n * resolve the plugins, which is an asyncronous operation.\n *\n * In other cases, it might be enough to only do a shallow pass. As an example, if you\n * only need to know about the defined workspace, or the user-defined schema types,\n * this can be set to `false` - which should resolve faster (and potentially \"safer\")\n * in terms of not triggering all kinds of browser behavior that may or may not be\n * loaded as the plugins are resolved.\n */\n resolvePlugins: boolean\n}\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: true},\n): Promise<ResolvedStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: {resolvePlugins: false},\n): Promise<RawStudioConfig>\n\nexport async function readStudioConfig(\n configPath: string,\n options: ReadStudioConfigOptions,\n): Promise<RawStudioConfig | ResolvedStudioConfig> {\n const result = await studioWorkerTask(new URL('readStudioConfig.worker.js', import.meta.url), {\n name: 'studioConfig',\n studioRootPath: dirname(configPath),\n workerData: {configPath, resolvePlugins: options.resolvePlugins},\n })\n\n return options.resolvePlugins ? resolvedConfigSchema.parse(result) : rawConfigSchema.parse(result)\n}\n"],"names":["dirname","z","studioWorkerTask","schemaSchema","object","name","string","optional","types","array","passthrough","sourceSchema","dataset","projectId","schema","_original","singleStudioWorkspaceSchema","shape","basePath","plugins","unknown","title","unstable_sources","studioWorkspaceSchema","rawConfigSchema","union","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EQ,KAAK,CAACc;AAiCrC,OAAO,eAAeI,iBACpBC,UAAkB,EAClBC,OAAgC;IAEhC,MAAMC,SAAS,MAAM5B,iBAAiB,IAAI6B,IAAI,8BAA8B,YAAYC,GAAG,GAAG;QAC5F3B,MAAM;QACN4B,gBAAgBjC,QAAQ4B;QACxBM,YAAY;YAACN;YAAYO,gBAAgBN,QAAQM,cAAc;QAAA;IACjE;IAEA,OAAON,QAAQM,cAAc,GAAGT,qBAAqBU,KAAK,CAACN,UAAUN,gBAAgBY,KAAK,CAACN;AAC7F"}
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export * from './SanityCommand.js';
15
15
  export * from './services/apiClient.js';
16
16
  export * from './services/cliUserConfig.js';
17
17
  export * from './services/getCliToken.js';
18
- export { type Output } from './types.js';
18
+ export { type Output, type SanityOrgUser } from './types.js';
19
19
  export * from './util/createExpiringConfig.js';
20
20
  export * from './util/environment/mockBrowserEnvironment.js';
21
21
  export * from './util/fileExists.js';
@@ -24,13 +24,11 @@ export * from './util/getSanityEnvVar.js';
24
24
  export * from './util/getSanityUrl.js';
25
25
  export * from './util/getUserConfig.js';
26
26
  export * from './util/isCi.js';
27
- export * from './util/isHttpError.js';
28
27
  export * from './util/isInteractive.js';
29
28
  export * from './util/isTrueish.js';
29
+ export * from './util/resolveLocalPackage.js';
30
30
  export * from './util/tryGetDefaultExport.js';
31
31
  export * from './ux/colorizeJson.js';
32
32
  export * from './ux/formatObject.js';
33
- export * from './ux/logSymbols.js';
34
33
  export * from './ux/printKeyValue.js';
35
- export * from './ux/spinner.js';
36
34
  export * from './ux/timer.js';
package/dist/index.js CHANGED
@@ -20,15 +20,13 @@ export * from './util/getSanityEnvVar.js';
20
20
  export * from './util/getSanityUrl.js';
21
21
  export * from './util/getUserConfig.js';
22
22
  export * from './util/isCi.js';
23
- export * from './util/isHttpError.js';
24
23
  export * from './util/isInteractive.js';
25
24
  export * from './util/isTrueish.js';
25
+ export * from './util/resolveLocalPackage.js';
26
26
  export * from './util/tryGetDefaultExport.js';
27
27
  export * from './ux/colorizeJson.js';
28
28
  export * from './ux/formatObject.js';
29
- export * from './ux/logSymbols.js';
30
29
  export * from './ux/printKeyValue.js';
31
- export * from './ux/spinner.js';
32
30
  export * from './ux/timer.js';
33
31
 
34
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './config/cli/getCliConfig.js'\nexport * from './config/cli/getCliConfigSync.js'\nexport {cliConfigSchema} from './config/cli/schemas.js'\nexport {type CliConfig} from './config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from './config/cli/types/userViteConfig.js'\nexport * from './config/findProjectRoot.js'\nexport * from './config/findProjectRootSync.js'\nexport * from './config/studio/getStudioConfig.js'\nexport * from './config/util/findConfigsPaths.js'\nexport * from './config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nexport * from './debug.js'\nexport * from './loaders/tsx/tsxWorkerTask.js'\nexport * from './SanityCommand.js'\nexport * from './services/apiClient.js'\nexport * from './services/cliUserConfig.js'\nexport * from './services/getCliToken.js'\nexport {type Output} from './types.js'\nexport * from './util/createExpiringConfig.js'\nexport * from './util/environment/mockBrowserEnvironment.js'\nexport * from './util/fileExists.js'\nexport * from './util/getEmptyAuth.js'\nexport * from './util/getSanityEnvVar.js'\nexport * from './util/getSanityUrl.js'\nexport * from './util/getUserConfig.js'\nexport * from './util/isCi.js'\nexport * from './util/isHttpError.js'\nexport * from './util/isInteractive.js'\nexport * from './util/isTrueish.js'\nexport * from './util/tryGetDefaultExport.js'\nexport * from './ux/colorizeJson.js'\nexport * from './ux/formatObject.js'\nexport * from './ux/logSymbols.js'\nexport * from './ux/printKeyValue.js'\nexport * from './ux/spinner.js'\nexport * from './ux/timer.js'\n"],"names":["cliConfigSchema"],"mappings":"AAAA,cAAc,+BAA8B;AAC5C,cAAc,mCAAkC;AAChD,SAAQA,eAAe,QAAO,0BAAyB;AAGvD,cAAc,8BAA6B;AAC3C,cAAc,kCAAiC;AAC/C,cAAc,qCAAoC;AAClD,cAAc,oCAAmC;AACjD,cAAc,wCAAuC;AAErD,cAAc,aAAY;AAC1B,cAAc,iCAAgC;AAC9C,cAAc,qBAAoB;AAClC,cAAc,0BAAyB;AACvC,cAAc,8BAA6B;AAC3C,cAAc,4BAA2B;AAEzC,cAAc,iCAAgC;AAC9C,cAAc,+CAA8C;AAC5D,cAAc,uBAAsB;AACpC,cAAc,yBAAwB;AACtC,cAAc,4BAA2B;AACzC,cAAc,yBAAwB;AACtC,cAAc,0BAAyB;AACvC,cAAc,iBAAgB;AAC9B,cAAc,wBAAuB;AACrC,cAAc,0BAAyB;AACvC,cAAc,sBAAqB;AACnC,cAAc,gCAA+B;AAC7C,cAAc,uBAAsB;AACpC,cAAc,uBAAsB;AACpC,cAAc,qBAAoB;AAClC,cAAc,wBAAuB;AACrC,cAAc,kBAAiB;AAC/B,cAAc,gBAAe"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './config/cli/getCliConfig.js'\nexport * from './config/cli/getCliConfigSync.js'\nexport {cliConfigSchema} from './config/cli/schemas.js'\nexport {type CliConfig} from './config/cli/types/cliConfig.js'\nexport {type UserViteConfig} from './config/cli/types/userViteConfig.js'\nexport * from './config/findProjectRoot.js'\nexport * from './config/findProjectRootSync.js'\nexport * from './config/studio/getStudioConfig.js'\nexport * from './config/util/findConfigsPaths.js'\nexport * from './config/util/findStudioConfigPath.js'\nexport {type ProjectRootResult} from './config/util/recursivelyResolveProjectRoot.js'\nexport * from './debug.js'\nexport * from './loaders/tsx/tsxWorkerTask.js'\nexport * from './SanityCommand.js'\nexport * from './services/apiClient.js'\nexport * from './services/cliUserConfig.js'\nexport * from './services/getCliToken.js'\nexport {type Output, type SanityOrgUser} from './types.js'\nexport * from './util/createExpiringConfig.js'\nexport * from './util/environment/mockBrowserEnvironment.js'\nexport * from './util/fileExists.js'\nexport * from './util/getEmptyAuth.js'\nexport * from './util/getSanityEnvVar.js'\nexport * from './util/getSanityUrl.js'\nexport * from './util/getUserConfig.js'\nexport * from './util/isCi.js'\nexport * from './util/isInteractive.js'\nexport * from './util/isTrueish.js'\nexport * from './util/resolveLocalPackage.js'\nexport * from './util/tryGetDefaultExport.js'\nexport * from './ux/colorizeJson.js'\nexport * from './ux/formatObject.js'\nexport * from './ux/printKeyValue.js'\nexport * from './ux/timer.js'\n"],"names":["cliConfigSchema"],"mappings":"AAAA,cAAc,+BAA8B;AAC5C,cAAc,mCAAkC;AAChD,SAAQA,eAAe,QAAO,0BAAyB;AAGvD,cAAc,8BAA6B;AAC3C,cAAc,kCAAiC;AAC/C,cAAc,qCAAoC;AAClD,cAAc,oCAAmC;AACjD,cAAc,wCAAuC;AAErD,cAAc,aAAY;AAC1B,cAAc,iCAAgC;AAC9C,cAAc,qBAAoB;AAClC,cAAc,0BAAyB;AACvC,cAAc,8BAA6B;AAC3C,cAAc,4BAA2B;AAEzC,cAAc,iCAAgC;AAC9C,cAAc,+CAA8C;AAC5D,cAAc,uBAAsB;AACpC,cAAc,yBAAwB;AACtC,cAAc,4BAA2B;AACzC,cAAc,yBAAwB;AACtC,cAAc,0BAAyB;AACvC,cAAc,iBAAgB;AAC9B,cAAc,0BAAyB;AACvC,cAAc,sBAAqB;AACnC,cAAc,gCAA+B;AAC7C,cAAc,gCAA+B;AAC7C,cAAc,uBAAsB;AACpC,cAAc,uBAAsB;AACpC,cAAc,wBAAuB;AACrC,cAAc,gBAAe"}
@@ -1,7 +1,6 @@
1
1
  import { ux } from '@oclif/core';
2
- import { createClient, requester as defaultRequester } from '@sanity/client';
2
+ import { createClient, requester as defaultRequester, isHttpError } from '@sanity/client';
3
3
  import { generateHelpUrl } from '../util/generateHelpUrl.js';
4
- import { isHttpError } from '../util/isHttpError.js';
5
4
  import { getCliToken } from './getCliToken.js';
6
5
  const apiHosts = {
7
6
  staging: 'https://api.sanity.work'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/apiClient.ts"],"sourcesContent":["import {ux} from '@oclif/core'\nimport {\n type ClientConfig,\n type ClientError,\n createClient,\n requester as defaultRequester,\n type SanityClient,\n type ServerError,\n} from '@sanity/client'\n\nimport {generateHelpUrl} from '../util/generateHelpUrl.js'\nimport {isHttpError} from '../util/isHttpError.js'\nimport {getCliToken} from './getCliToken.js'\n\nconst apiHosts: Record<string, string | undefined> = {\n staging: 'https://api.sanity.work',\n}\n\nconst CLI_REQUEST_TAG_PREFIX = 'sanity.cli'\n\n/**\n * @internal\n */\nexport interface GlobalCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getGlobalCliClient({\n requireUser,\n ...config\n}: GlobalCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n let token: string | undefined\n if (requireUser) {\n token = await getCliToken()\n if (!token) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: false,\n ...config,\n })\n}\n\n/**\n * @internal\n */\nexport interface ProjectCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * The project ID to use for this client.\n */\n projectId: string\n\n /**\n * The dataset to use for this client.\n */\n dataset?: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getProjectCliClient({\n requireUser,\n ...config\n}: ProjectCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n let token: string | undefined\n if (requireUser) {\n token = await getCliToken()\n if (!token) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: true,\n ...config,\n })\n}\n\n/**\n * `get-it` middleware that checks for 401 authentication errors and extends the error with more\n * helpful guidance on what to do next.\n *\n * @returns get-it middleware with `onError` handler\n * @internal\n */\nfunction authErrors() {\n return {\n onError: (err: Error | null) => {\n if (!err || !isReqResError(err)) {\n return err\n }\n\n const statusCode = isHttpError(err) && err.response.body.statusCode\n if (statusCode === 401) {\n err.message = `${err.message}. You may need to login again with ${ux.colorize('cyan', 'sanity login')}.\\nFor more information, see ${generateHelpUrl('cli-errors')}.`\n }\n\n return err\n },\n }\n}\n\nfunction isReqResError(err: Error): err is ClientError | ServerError {\n return Object.prototype.hasOwnProperty.call(err, 'response')\n}\n"],"names":["ux","createClient","requester","defaultRequester","generateHelpUrl","isHttpError","getCliToken","apiHosts","staging","CLI_REQUEST_TAG_PREFIX","getGlobalCliClient","requireUser","config","clone","use","authErrors","sanityEnv","process","env","SANITY_INTERNAL_ENV","apiHost","token","Error","requestTagPrefix","useCdn","useProjectHostname","getProjectCliClient","onError","err","isReqResError","statusCode","response","body","message","colorize","Object","prototype","hasOwnProperty","call"],"mappings":"AAAA,SAAQA,EAAE,QAAO,cAAa;AAC9B,SAGEC,YAAY,EACZC,aAAaC,gBAAgB,QAGxB,iBAAgB;AAEvB,SAAQC,eAAe,QAA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ACC,cAAcD,MAAM;gBAC/B,OAAOA;YACT;YAEA,MAAME,aAAazB,YAAYuB,QAAQA,IAAIG,QAAQ,CAACC,IAAI,CAACF,UAAU;YACnE,IAAIA,eAAe,KAAK;gBACtBF,IAAIK,OAAO,GAAG,GAAGL,IAAIK,OAAO,CAAC,mCAAmC,EAAEjC,GAAGkC,QAAQ,CAAC,QAAQ,gBAAgB,6BAA6B,EAAE9B,gBAAgB,cAAc,CAAC,CAAC;YACvK;YAEA,OAAOwB;QACT;IACF;AACF;AAEA,SAASC,cAAcD,GAAU;IAC/B,OAAOO,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACV,KAAK;AACnD"}
1
+ {"version":3,"sources":["../../src/services/apiClient.ts"],"sourcesContent":["import {ux} from '@oclif/core'\nimport {\n type ClientConfig,\n type ClientError,\n createClient,\n requester as defaultRequester,\n isHttpError,\n type SanityClient,\n type ServerError,\n} from '@sanity/client'\n\nimport {generateHelpUrl} from '../util/generateHelpUrl.js'\nimport {getCliToken} from './getCliToken.js'\n\nconst apiHosts: Record<string, string | undefined> = {\n staging: 'https://api.sanity.work',\n}\n\nconst CLI_REQUEST_TAG_PREFIX = 'sanity.cli'\n\n/**\n * @internal\n */\nexport interface GlobalCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getGlobalCliClient({\n requireUser,\n ...config\n}: GlobalCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n let token: string | undefined\n if (requireUser) {\n token = await getCliToken()\n if (!token) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: false,\n ...config,\n })\n}\n\n/**\n * @internal\n */\nexport interface ProjectCliClientOptions extends ClientConfig {\n /**\n * The API version to use for this client.\n */\n apiVersion: string\n\n /**\n * The project ID to use for this client.\n */\n projectId: string\n\n /**\n * The dataset to use for this client.\n */\n dataset?: string\n\n /**\n * Whether to require a user to be authenticated to use this client.\n * Default: `false`.\n * Throws an error if `true` and user is not authenticated.\n */\n requireUser?: boolean\n}\n\n/**\n * Create a \"global\" (unscoped) Sanity API client.\n *\n * @param options - The options to use for the client.\n * @returns Promise that resolves to a configured Sanity API client.\n */\nexport async function getProjectCliClient({\n requireUser,\n ...config\n}: ProjectCliClientOptions): Promise<SanityClient> {\n const requester = defaultRequester.clone()\n requester.use(authErrors())\n\n const sanityEnv = process.env.SANITY_INTERNAL_ENV || 'production'\n\n const apiHost = apiHosts[sanityEnv]\n\n let token: string | undefined\n if (requireUser) {\n token = await getCliToken()\n if (!token) {\n throw new Error('You must login first - run \"sanity login\"')\n }\n }\n\n return createClient({\n ...(apiHost ? {apiHost} : {}),\n requester,\n requestTagPrefix: CLI_REQUEST_TAG_PREFIX,\n token,\n useCdn: false,\n useProjectHostname: true,\n ...config,\n })\n}\n\n/**\n * `get-it` middleware that checks for 401 authentication errors and extends the error with more\n * helpful guidance on what to do next.\n *\n * @returns get-it middleware with `onError` handler\n * @internal\n */\nfunction authErrors() {\n return {\n onError: (err: Error | null) => {\n if (!err || !isReqResError(err)) {\n return err\n }\n\n const statusCode = isHttpError(err) && err.response.body.statusCode\n if (statusCode === 401) {\n err.message = `${err.message}. You may need to login again with ${ux.colorize('cyan', 'sanity login')}.\\nFor more information, see ${generateHelpUrl('cli-errors')}.`\n }\n\n return err\n },\n }\n}\n\nfunction isReqResError(err: Error): err is ClientError | ServerError {\n return Object.prototype.hasOwnProperty.call(err, 'response')\n}\n"],"names":["ux","createClient","requester","defaultRequester","isHttpError","generateHelpUrl","getCliToken","apiHosts","staging","CLI_REQUEST_TAG_PREFIX","getGlobalCliClient","requireUser","config","clone","use","authErrors","sanityEnv","process","env","SANITY_INTERNAL_ENV","apiHost","token","Error","requestTagPrefix","useCdn","useProjectHostname","getProjectCliClient","onError","err","isReqResError","statusCode","response","body","message","colorize","Object","prototype","hasOwnProperty","call"],"mappings":"AAAA,SAAQA,EAAE,QAAO,cAAa;AAC9B,SAGEC,YAAY,EACZC,aAAaC,gBAAgB,EAC7BC,WAAW,QAGN,iBAAgB;AAEvB,SAAQC,eAAe,QAAO,6BAA4B;AAC1D,SAAQC,WAAW,QAAO,mBAAkB;AAE5C,MAAMC,WAA+C;IACnDC,SAAS;AACX;AAEA,MAAMC,yBAAyB;AAmB/B;;;;;CAKC,GACD,OAAO,eAAeC,mBAAmB,EACvCC,WAAW,EACX,GAAGC,QACoB;IACvB,MAAMV,YAAYC,iBAAiBU,KAAK;IACxCX,UAAUY,GAAG,CAACC;IAEd,MAAMC,YAAYC,QAAQC,GAAG,CAACC,mBAAmB,IAAI;IAErD,MAAMC,UAAUb,QAAQ,CAACS,UAAU;IAEnC,IAAIK;IACJ,IAAIV,aAAa;QACfU,QAAQ,MAAMf;QACd,IAAI,CAACe,OAAO;YACV,MAAM,IAAIC,MAAM;QAClB;IACF;IAEA,OAAOrB,aAAa;QAClB,GAAImB,UAAU;YAACA;QAAO,IAAI,CAAC,CAAC;QAC5BlB;QACAqB,kBAAkBd;QAClBY;QACAG,QAAQ;QACRC,oBAAoB;QACpB,GAAGb,MAAM;IACX;AACF;AA6BA;;;;;CAKC,GACD,OAAO,eAAec,oBAAoB,EACxCf,WAAW,EACX,GAAGC,QACqB;IACxB,MAAMV,YAAYC,iBAAiBU,KAAK;IACxCX,UAAUY,GAAG,CAACC;IAEd,MAAMC,YAAYC,QAAQC,GAAG,CAACC,mBAAmB,IAAI;IAErD,MAAMC,UAAUb,QAAQ,CAACS,UAAU;IAEnC,IAAIK;IACJ,IAAIV,aAAa;QACfU,QAAQ,MAAMf;QACd,IAAI,CAACe,OAAO;YACV,MAAM,IAAIC,MAAM;QAClB;IACF;IAEA,OAAOrB,aAAa;QAClB,GAAImB,UAAU;YAACA;QAAO,IAAI,CAAC,CAAC;QAC5BlB;QACAqB,kBAAkBd;QAClBY;QACAG,QAAQ;QACRC,oBAAoB;QACpB,GAAGb,MAAM;IACX;AACF;AAEA;;;;;;CAMC,GACD,SAASG;IACP,OAAO;QACLY,SAAS,CAACC;YACR,IAAI,CAACA,OAAO,CAACC,cAAcD,MAAM;gBAC/B,OAAOA;YACT;YAEA,MAAME,aAAa1B,YAAYwB,QAAQA,IAAIG,QAAQ,CAACC,IAAI,CAACF,UAAU;YACnE,IAAIA,eAAe,KAAK;gBACtBF,IAAIK,OAAO,GAAG,GAAGL,IAAIK,OAAO,CAAC,mCAAmC,EAAEjC,GAAGkC,QAAQ,CAAC,QAAQ,gBAAgB,6BAA6B,EAAE7B,gBAAgB,cAAc,CAAC,CAAC;YACvK;YAEA,OAAOuB;QACT;IACF;AACF;AAEA,SAASC,cAAcD,GAAU;IAC/B,OAAOO,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACV,KAAK;AACnD"}
package/dist/types.d.ts CHANGED
@@ -5,3 +5,11 @@ export interface Output {
5
5
  warn: Command['warn'];
6
6
  }
7
7
  export type RequireProps<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
8
+ export type SanityOrgUser = {
9
+ email: string;
10
+ id: string;
11
+ name: string;
12
+ profileImage?: string;
13
+ provider: 'github' | 'google' | 'sanity' | `saml-${string}`;
14
+ tosAcceptedAt?: string;
15
+ };
package/dist/types.js CHANGED
@@ -1,3 +1,5 @@
1
+ // @todo
2
+ // Replace with SanityUser type from client once implemented
1
3
  export { };
2
4
 
3
5
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {type Command} from '@oclif/core'\n\nexport interface Output {\n error: Command['error']\n log: Command['log']\n warn: Command['warn']\n}\n\nexport type RequireProps<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>\n"],"names":[],"mappings":"AAQA,WAAkF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import {type Command} from '@oclif/core'\n\nexport interface Output {\n error: Command['error']\n log: Command['log']\n warn: Command['warn']\n}\n\nexport type RequireProps<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>\n\n// @todo\n// Replace with SanityUser type from client once implemented\nexport type SanityOrgUser = {\n email: string\n id: string\n name: string\n profileImage?: string\n provider: 'github' | 'google' | 'sanity' | `saml-${string}`\n tosAcceptedAt?: string\n}\n"],"names":[],"mappings":"AAUA,QAAQ;AACR,4DAA4D;AAC5D,WAOC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Resolves and imports a package from the local project's node_modules,
3
+ * relative to the given working directory. This avoids circular dependencies
4
+ * and ensures the correct version of the package is used.
5
+ *
6
+ * @param packageName - The name of the package to resolve (e.g., 'sanity')
7
+ * @param workDir - The working directory to resolve the package from
8
+ * @returns The imported module
9
+ * @throws If the package cannot be resolved or imported
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const {createSchema} = await resolveLocalPackage('sanity', workDir)
14
+ * ```
15
+ *
16
+ * @internal
17
+ */
18
+ export declare function resolveLocalPackage<T = unknown>(packageName: string, workDir: string): Promise<T>;
@@ -0,0 +1,33 @@
1
+ import { resolve } from 'node:path';
2
+ import { pathToFileURL } from 'node:url';
3
+ import { moduleResolve } from 'import-meta-resolve';
4
+ /**
5
+ * Resolves and imports a package from the local project's node_modules,
6
+ * relative to the given working directory. This avoids circular dependencies
7
+ * and ensures the correct version of the package is used.
8
+ *
9
+ * @param packageName - The name of the package to resolve (e.g., 'sanity')
10
+ * @param workDir - The working directory to resolve the package from
11
+ * @returns The imported module
12
+ * @throws If the package cannot be resolved or imported
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * const {createSchema} = await resolveLocalPackage('sanity', workDir)
17
+ * ```
18
+ *
19
+ * @internal
20
+ */ export async function resolveLocalPackage(packageName, workDir) {
21
+ // Create a fake cli config URL - doesn't have to be correct, just need the root path
22
+ // This ensures we resolve packages relative to the user's repo, not the CLI package
23
+ const fakeCliConfigUrl = pathToFileURL(resolve(workDir, 'sanity.cli.mjs'));
24
+ try {
25
+ const packageUrl = moduleResolve(packageName, fakeCliConfigUrl);
26
+ const module = await import(packageUrl.href);
27
+ return module;
28
+ } catch (error) {
29
+ throw new Error(`Failed to resolve package "${packageName}" from "${workDir}": ${error instanceof Error ? error.message : String(error)}`);
30
+ }
31
+ }
32
+
33
+ //# sourceMappingURL=resolveLocalPackage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/resolveLocalPackage.ts"],"sourcesContent":["import {resolve} from 'node:path'\nimport {pathToFileURL} from 'node:url'\n\nimport {moduleResolve} from 'import-meta-resolve'\n\n/**\n * Resolves and imports a package from the local project's node_modules,\n * relative to the given working directory. This avoids circular dependencies\n * and ensures the correct version of the package is used.\n *\n * @param packageName - The name of the package to resolve (e.g., 'sanity')\n * @param workDir - The working directory to resolve the package from\n * @returns The imported module\n * @throws If the package cannot be resolved or imported\n *\n * @example\n * ```ts\n * const {createSchema} = await resolveLocalPackage('sanity', workDir)\n * ```\n *\n * @internal\n */\nexport async function resolveLocalPackage<T = unknown>(\n packageName: string,\n workDir: string,\n): Promise<T> {\n // Create a fake cli config URL - doesn't have to be correct, just need the root path\n // This ensures we resolve packages relative to the user's repo, not the CLI package\n const fakeCliConfigUrl = pathToFileURL(resolve(workDir, 'sanity.cli.mjs'))\n\n try {\n const packageUrl = moduleResolve(packageName, fakeCliConfigUrl)\n const module = await import(packageUrl.href)\n return module as T\n } catch (error) {\n throw new Error(\n `Failed to resolve package \"${packageName}\" from \"${workDir}\": ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n}\n"],"names":["resolve","pathToFileURL","moduleResolve","resolveLocalPackage","packageName","workDir","fakeCliConfigUrl","packageUrl","module","href","error","Error","message","String"],"mappings":"AAAA,SAAQA,OAAO,QAAO,YAAW;AACjC,SAAQC,aAAa,QAAO,WAAU;AAEtC,SAAQC,aAAa,QAAO,sBAAqB;AAEjD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,eAAeC,oBACpBC,WAAmB,EACnBC,OAAe;IAEf,qFAAqF;IACrF,oFAAoF;IACpF,MAAMC,mBAAmBL,cAAcD,QAAQK,SAAS;IAExD,IAAI;QACF,MAAME,aAAaL,cAAcE,aAAaE;QAC9C,MAAME,SAAS,MAAM,MAAM,CAACD,WAAWE,IAAI;QAC3C,OAAOD;IACT,EAAE,OAAOE,OAAO;QACd,MAAM,IAAIC,MACR,CAAC,2BAA2B,EAAEP,YAAY,QAAQ,EAAEC,QAAQ,GAAG,EAAEK,iBAAiBC,QAAQD,MAAME,OAAO,GAAGC,OAAOH,QAAQ;IAE7H;AACF"}
@@ -0,0 +1,31 @@
1
+ import { type Path } from '@sanity/types';
2
+ interface BaseNode {
3
+ path: Path;
4
+ }
5
+ export interface Tree<Node extends BaseNode> {
6
+ children?: Record<string, Tree<Node>>;
7
+ nodes?: Node[];
8
+ }
9
+ /**
10
+ * Recursively calculates the max length of all the keys in the given validation
11
+ * tree respecting extra length due to indentation depth. Used to calculate the
12
+ * padding for the rest of the tree.
13
+ */
14
+ export declare const maxKeyLength: (children?: Record<string, Tree<BaseNode>>, depth?: number) => number;
15
+ interface Options<Node extends BaseNode> {
16
+ getMessage: (node: Node) => string;
17
+ paddingLength: number;
18
+ getNodes?: (node: Tree<Node>) => Node[] | undefined;
19
+ indent?: string;
20
+ node?: Record<string, Tree<Node>>;
21
+ }
22
+ /**
23
+ * Recursively formats a given tree into a printed user-friendly tree structure
24
+ */
25
+ export declare const formatTree: <Node extends BaseNode>({ getMessage, getNodes: getLeaves, indent, node, paddingLength, }: Options<Node>) => string;
26
+ /**
27
+ * Converts a set of markers with paths into a tree of markers where the paths
28
+ * are embedded in the tree
29
+ */
30
+ export declare function convertToTree<const Node extends BaseNode>(nodes: Node[]): Tree<Node>;
31
+ export {};
@@ -0,0 +1,108 @@
1
+ import { isIndexSegment, isIndexTuple, isKeySegment } from '@sanity/types';
2
+ // FIXME: de-dupe this
3
+ // copy/paste of `pathToString` from 'sanity' to prevent circular imports
4
+ function pathToString(path) {
5
+ if (!Array.isArray(path)) {
6
+ throw new TypeError('Path is not an array');
7
+ }
8
+ let target = '';
9
+ let i = 0;
10
+ for (const segment of path){
11
+ if (isIndexSegment(segment)) {
12
+ target = `${target}[${segment}]`;
13
+ } else if (isKeySegment(segment) && segment._key) {
14
+ target = `${target}[_key=="${segment._key}"]`;
15
+ } else if (isIndexTuple(segment)) {
16
+ const [from, to] = segment;
17
+ target = `${target}[${from}:${to}]`;
18
+ } else if (typeof segment === 'string') {
19
+ const separator = i === 0 ? '' : '.';
20
+ target = `${target}${separator}${segment}`;
21
+ } else {
22
+ throw new TypeError(`Unsupported path segment \`${JSON.stringify(segment)}\``);
23
+ }
24
+ i++;
25
+ }
26
+ return target;
27
+ }
28
+ /**
29
+ * Recursively calculates the max length of all the keys in the given validation
30
+ * tree respecting extra length due to indentation depth. Used to calculate the
31
+ * padding for the rest of the tree.
32
+ */ export const maxKeyLength = (children = {}, depth = 0)=>{
33
+ let max = 0;
34
+ for (const [key, child] of Object.entries(children)){
35
+ const currentMax = Math.max(key.length + depth * 2, maxKeyLength(child.children, depth + 1));
36
+ max = Math.max(max, currentMax);
37
+ }
38
+ return max;
39
+ };
40
+ /**
41
+ * Recursively formats a given tree into a printed user-friendly tree structure
42
+ */ export const formatTree = ({ getMessage, getNodes: getLeaves = ({ nodes })=>nodes, indent = '', node = {}, paddingLength })=>{
43
+ const entries = Object.entries(node);
44
+ return entries.map(([key, child], index)=>{
45
+ const isLast = index === entries.length - 1;
46
+ const nextIndent = `${indent}${isLast ? ' ' : '│ '}`;
47
+ const leaves = getLeaves(child);
48
+ const nested = formatTree({
49
+ getMessage,
50
+ getNodes: getLeaves,
51
+ indent: nextIndent,
52
+ node: child.children,
53
+ paddingLength
54
+ });
55
+ if (!leaves?.length) {
56
+ const current = `${indent}${isLast ? '└' : '├'}─ ${key}`;
57
+ return [
58
+ current,
59
+ nested
60
+ ].filter(Boolean).join('\n');
61
+ }
62
+ const [first, ...rest] = leaves;
63
+ const firstPadding = '.'.repeat(paddingLength - indent.length - key.length);
64
+ const elbow = isLast ? '└' : '├';
65
+ const subsequentPadding = ' '.repeat(paddingLength - indent.length + 2);
66
+ const firstMessage = `${indent}${elbow}─ ${key} ${firstPadding} ${getMessage(first)}`;
67
+ const subsequentMessages = rest.map((marker)=>`${nextIndent}${subsequentPadding} ${getMessage(marker)}`).join('\n');
68
+ const current = [
69
+ firstMessage,
70
+ subsequentMessages
71
+ ].filter(Boolean).join('\n');
72
+ return [
73
+ current,
74
+ nested
75
+ ].filter(Boolean).join('\n');
76
+ }).join('\n');
77
+ };
78
+ /**
79
+ * Converts a set of markers with paths into a tree of markers where the paths
80
+ * are embedded in the tree
81
+ */ export function convertToTree(nodes) {
82
+ const root = {};
83
+ // add the markers to the tree
84
+ function addNode(node, tree = root) {
85
+ // if we've traversed the whole path
86
+ if (node.path.length === 0) {
87
+ if (!tree.nodes) tree.nodes = []; // ensure markers is defined
88
+ // then add the marker to the front
89
+ tree.nodes.push(node);
90
+ return;
91
+ }
92
+ const [current, ...rest] = node.path;
93
+ const key = pathToString([
94
+ current
95
+ ]);
96
+ // ensure the current node has children and the next node
97
+ if (!tree.children) tree.children = {};
98
+ if (!(key in tree.children)) tree.children[key] = {};
99
+ addNode({
100
+ ...node,
101
+ path: rest
102
+ }, tree.children[key]);
103
+ }
104
+ for (const node of nodes)addNode(node);
105
+ return root;
106
+ }
107
+
108
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/util/tree.ts"],"sourcesContent":["import {isIndexSegment, isIndexTuple, isKeySegment, type Path} from '@sanity/types'\n\n// FIXME: de-dupe this\n// copy/paste of `pathToString` from 'sanity' to prevent circular imports\nfunction pathToString(path: Path): string {\n if (!Array.isArray(path)) {\n throw new TypeError('Path is not an array')\n }\n\n let target = ''\n let i = 0\n for (const segment of path) {\n if (isIndexSegment(segment)) {\n target = `${target}[${segment}]`\n } else if (isKeySegment(segment) && segment._key) {\n target = `${target}[_key==\"${segment._key}\"]`\n } else if (isIndexTuple(segment)) {\n const [from, to] = segment\n target = `${target}[${from}:${to}]`\n } else if (typeof segment === 'string') {\n const separator = i === 0 ? '' : '.'\n target = `${target}${separator}${segment}`\n } else {\n throw new TypeError(`Unsupported path segment \\`${JSON.stringify(segment)}\\``)\n }\n i++\n }\n return target\n}\n\ninterface BaseNode {\n path: Path\n}\n\nexport interface Tree<Node extends BaseNode> {\n children?: Record<string, Tree<Node>>\n nodes?: Node[]\n}\n\n/**\n * Recursively calculates the max length of all the keys in the given validation\n * tree respecting extra length due to indentation depth. Used to calculate the\n * padding for the rest of the tree.\n */\nexport const maxKeyLength = (children: Record<string, Tree<BaseNode>> = {}, depth = 0): number => {\n let max = 0\n for (const [key, child] of Object.entries(children)) {\n const currentMax = Math.max(key.length + depth * 2, maxKeyLength(child.children, depth + 1))\n max = Math.max(max, currentMax)\n }\n return max\n}\n\ninterface Options<Node extends BaseNode> {\n getMessage: (node: Node) => string\n paddingLength: number\n\n getNodes?: (node: Tree<Node>) => Node[] | undefined\n indent?: string\n node?: Record<string, Tree<Node>>\n}\n\n/**\n * Recursively formats a given tree into a printed user-friendly tree structure\n */\nexport const formatTree = <Node extends BaseNode>({\n getMessage,\n getNodes: getLeaves = ({nodes}) => nodes,\n indent = '',\n node = {},\n paddingLength,\n}: Options<Node>): string => {\n const entries = Object.entries(node)\n\n return entries\n .map(([key, child], index) => {\n const isLast = index === entries.length - 1\n const nextIndent = `${indent}${isLast ? ' ' : '│ '}`\n const leaves = getLeaves(child)\n\n const nested = formatTree({\n getMessage,\n getNodes: getLeaves,\n indent: nextIndent,\n node: child.children,\n paddingLength,\n })\n\n if (!leaves?.length) {\n const current = `${indent}${isLast ? '└' : '├'}─ ${key}`\n return [current, nested].filter(Boolean).join('\\n')\n }\n\n const [first, ...rest] = leaves\n const firstPadding = '.'.repeat(paddingLength - indent.length - key.length)\n const elbow = isLast ? '└' : '├'\n const subsequentPadding = ' '.repeat(paddingLength - indent.length + 2)\n\n const firstMessage = `${indent}${elbow}─ ${key} ${firstPadding} ${getMessage(first)}`\n const subsequentMessages = rest\n .map((marker) => `${nextIndent}${subsequentPadding} ${getMessage(marker)}`)\n .join('\\n')\n\n const current = [firstMessage, subsequentMessages].filter(Boolean).join('\\n')\n return [current, nested].filter(Boolean).join('\\n')\n })\n .join('\\n')\n}\n\n/**\n * Converts a set of markers with paths into a tree of markers where the paths\n * are embedded in the tree\n */\nexport function convertToTree<const Node extends BaseNode>(nodes: Node[]): Tree<Node> {\n const root: Tree<Node> = {}\n\n // add the markers to the tree\n function addNode(node: Node, tree: Tree<Node> = root) {\n // if we've traversed the whole path\n if (node.path.length === 0) {\n if (!tree.nodes) tree.nodes = [] // ensure markers is defined\n\n // then add the marker to the front\n tree.nodes.push(node)\n return\n }\n\n const [current, ...rest] = node.path\n const key = pathToString([current])\n\n // ensure the current node has children and the next node\n if (!tree.children) tree.children = {}\n if (!(key in tree.children)) tree.children[key] = {}\n\n addNode({...node, path: rest}, tree.children[key])\n }\n\n for (const node of nodes) addNode(node)\n return root\n}\n"],"names":["isIndexSegment","isIndexTuple","isKeySegment","pathToString","path","Array","isArray","TypeError","target","i","segment","_key","from","to","separator","JSON","stringify","maxKeyLength","children","depth","max","key","child","Object","entries","currentMax","Math","length","formatTree","getMessage","getNodes","getLeaves","nodes","indent","node","paddingLength","map","index","isLast","nextIndent","leaves","nested","current","filter","Boolean","join","first","rest","firstPadding","repeat","elbow","subsequentPadding","firstMessage","subsequentMessages","marker","convertToTree","root","addNode","tree","push"],"mappings":"AAAA,SAAQ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H;YAASD;SAAO,CAACE,MAAM,CAACC,SAASC,IAAI,CAAC;IAChD,GACCA,IAAI,CAAC;AACV,EAAC;AAED;;;CAGC,GACD,OAAO,SAASU,cAA2CvB,KAAa;IACtE,MAAMwB,OAAmB,CAAC;IAE1B,8BAA8B;IAC9B,SAASC,QAAQvB,IAAU,EAAEwB,OAAmBF,IAAI;QAClD,oCAAoC;QACpC,IAAItB,KAAK9B,IAAI,CAACuB,MAAM,KAAK,GAAG;YAC1B,IAAI,CAAC+B,KAAK1B,KAAK,EAAE0B,KAAK1B,KAAK,GAAG,EAAE,EAAC,4BAA4B;YAE7D,mCAAmC;YACnC0B,KAAK1B,KAAK,CAAC2B,IAAI,CAACzB;YAChB;QACF;QAEA,MAAM,CAACQ,SAAS,GAAGK,KAAK,GAAGb,KAAK9B,IAAI;QACpC,MAAMiB,MAAMlB,aAAa;YAACuC;SAAQ;QAElC,yDAAyD;QACzD,IAAI,CAACgB,KAAKxC,QAAQ,EAAEwC,KAAKxC,QAAQ,GAAG,CAAC;QACrC,IAAI,CAAEG,CAAAA,OAAOqC,KAAKxC,QAAQ,AAAD,GAAIwC,KAAKxC,QAAQ,CAACG,IAAI,GAAG,CAAC;QAEnDoC,QAAQ;YAAC,GAAGvB,IAAI;YAAE9B,MAAM2C;QAAI,GAAGW,KAAKxC,QAAQ,CAACG,IAAI;IACnD;IAEA,KAAK,MAAMa,QAAQF,MAAOyB,QAAQvB;IAClC,OAAOsB;AACT"}
@@ -0,0 +1,2 @@
1
+ export { default as chalk } from 'chalk';
2
+ export * from 'chalk';
@@ -0,0 +1,4 @@
1
+ export { default as chalk } from 'chalk';
2
+ export * from 'chalk';
3
+
4
+ //# sourceMappingURL=chalk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ux/chalk.ts"],"sourcesContent":["export {default as chalk} from 'chalk'\nexport * from 'chalk'\n"],"names":["default","chalk"],"mappings":"AAAA,SAAQA,WAAWC,KAAK,QAAO,QAAO;AACtC,cAAc,QAAO"}
@@ -0,0 +1 @@
1
+ export * from '@inquirer/prompts';
@@ -0,0 +1,3 @@
1
+ export * from '@inquirer/prompts';
2
+
3
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ux/prompts.ts"],"sourcesContent":["export * from '@inquirer/prompts'\n"],"names":[],"mappings":"AAAA,cAAc,oBAAmB"}
@@ -1 +1 @@
1
- export { default as spinner } from 'ora';
1
+ export { default as spinner, type Spinner, type Ora as SpinnerInstance, type Options as SpinnerOptions, oraPromise as spinnerPromise, type PromiseOptions as SpinnerPromiseOptions, } from 'ora';
@@ -1,3 +1,3 @@
1
- export { default as spinner } from 'ora';
1
+ export { default as spinner, oraPromise as spinnerPromise } from 'ora';
2
2
 
3
3
  //# sourceMappingURL=spinner.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ux/spinner.ts"],"sourcesContent":["export {default as spinner} from 'ora'\n"],"names":["default","spinner"],"mappings":"AAAA,SAAQA,WAAWC,OAAO,QAAO,MAAK"}
1
+ {"version":3,"sources":["../../src/ux/spinner.ts"],"sourcesContent":["export {\n default as spinner,\n type Spinner,\n type Ora as SpinnerInstance,\n type Options as SpinnerOptions,\n oraPromise as spinnerPromise,\n type PromiseOptions as SpinnerPromiseOptions,\n} from 'ora'\n"],"names":["default","spinner","oraPromise","spinnerPromise"],"mappings":"AAAA,SACEA,WAAWC,OAAO,EAIlBC,cAAcC,cAAc,QAEvB,MAAK"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cli-core",
3
- "version": "0.0.2-alpha.3",
3
+ "version": "0.1.0-alpha.3",
4
4
  "description": "Sanity CLI core package",
5
5
  "keywords": [
6
6
  "sanity",
@@ -23,6 +23,16 @@
23
23
  "require": "./dist/index.js",
24
24
  "import": "./dist/index.js"
25
25
  },
26
+ "./tree": {
27
+ "source": "./src/_exports/tree.ts",
28
+ "require": "./dist/_exports/tree.js",
29
+ "import": "./dist/_exports/tree.js"
30
+ },
31
+ "./ux": {
32
+ "source": "./src/_exports/ux.ts",
33
+ "require": "./dist/_exports/ux.js",
34
+ "import": "./dist/_exports/ux.js"
35
+ },
26
36
  "./package.json": "./package.json"
27
37
  },
28
38
  "main": "dist/index.js",
@@ -31,10 +41,12 @@
31
41
  "./dist"
32
42
  ],
33
43
  "dependencies": {
44
+ "@inquirer/prompts": "^8.1.0",
34
45
  "@oclif/core": "^4.8.0",
35
46
  "@sanity/client": "^7.11.2",
47
+ "@sanity/types": "^4.21.0",
36
48
  "babel-plugin-react-compiler": "^1.0.0",
37
- "chalk": "^5.4.1",
49
+ "chalk": "^5.6.2",
38
50
  "configstore": "^7.0.0",
39
51
  "debug": "^4.4.3",
40
52
  "get-tsconfig": "^4.10.1",
@@ -42,7 +54,7 @@
42
54
  "jsdom": "^26.0.0",
43
55
  "json-lexer": "^1.2.0",
44
56
  "log-symbols": "^7.0.1",
45
- "ora": "^8.2.0",
57
+ "ora": "^9.0.0",
46
58
  "tsx": "^4.20.3",
47
59
  "vite": "^7.1.6",
48
60
  "vite-node": "^3.0.8",
@@ -1,29 +0,0 @@
1
- /**
2
- * Incomplete error type for [get-it](https://github.com/sanity-io/get-it)
3
- * `httpError` middleware. Should preferably be tidied up and exported
4
- * from that module. Feel free to do so if you've got time! 🙏
5
- *
6
- * @internal
7
- */
8
- interface HttpError {
9
- request: {
10
- headers: unknown;
11
- };
12
- response: {
13
- body: unknown;
14
- method: string;
15
- statusCode: number;
16
- statusMessage: string;
17
- url: string;
18
- };
19
- }
20
- /**
21
- * Checks if the given `err` is an instance of `HttpError` from `get-it`
22
- * (request library used by `@sanity/client`).
23
- *
24
- * @param err - The error to check
25
- * @returns `true` if the error is an instance of `HttpError`, otherwise `false`
26
- * @internal
27
- */
28
- export declare function isHttpError(err: unknown): err is HttpError;
29
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
- * Incomplete error type for [get-it](https://github.com/sanity-io/get-it)
3
- * `httpError` middleware. Should preferably be tidied up and exported
4
- * from that module. Feel free to do so if you've got time! 🙏
5
- *
6
- * @internal
7
- */ /**
8
- * Checks if the given `err` is an instance of `HttpError` from `get-it`
9
- * (request library used by `@sanity/client`).
10
- *
11
- * @param err - The error to check
12
- * @returns `true` if the error is an instance of `HttpError`, otherwise `false`
13
- * @internal
14
- */ export function isHttpError(err) {
15
- return err instanceof Error && 'request' in err && 'response' in err && typeof err.response === 'object' && err.response !== null && 'statusCode' in err.response && typeof err.response.statusCode === 'number';
16
- }
17
-
18
- //# sourceMappingURL=isHttpError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/util/isHttpError.ts"],"sourcesContent":["/**\n * Incomplete error type for [get-it](https://github.com/sanity-io/get-it)\n * `httpError` middleware. Should preferably be tidied up and exported\n * from that module. Feel free to do so if you've got time! 🙏\n *\n * @internal\n */\ninterface HttpError {\n request: {\n headers: unknown\n }\n response: {\n body: unknown\n method: string\n statusCode: number\n statusMessage: string\n url: string\n }\n}\n\n/**\n * Checks if the given `err` is an instance of `HttpError` from `get-it`\n * (request library used by `@sanity/client`).\n *\n * @param err - The error to check\n * @returns `true` if the error is an instance of `HttpError`, otherwise `false`\n * @internal\n */\nexport function isHttpError(err: unknown): err is HttpError {\n return (\n err instanceof Error &&\n 'request' in err &&\n 'response' in err &&\n typeof err.response === 'object' &&\n err.response !== null &&\n 'statusCode' in err.response &&\n typeof err.response.statusCode === 'number'\n )\n}\n"],"names":["isHttpError","err","Error","response","statusCode"],"mappings":"AAAA;;;;;;CAMC,GAcD;;;;;;;CAOC,GACD,OAAO,SAASA,YAAYC,GAAY;IACtC,OACEA,eAAeC,SACf,aAAaD,OACb,cAAcA,OACd,OAAOA,IAAIE,QAAQ,KAAK,YACxBF,IAAIE,QAAQ,KAAK,QACjB,gBAAgBF,IAAIE,QAAQ,IAC5B,OAAOF,IAAIE,QAAQ,CAACC,UAAU,KAAK;AAEvC"}