@sanity/runtime-cli 6.2.2 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity-run COMMAND
21
21
  running command...
22
22
  $ sanity-run (--version)
23
- @sanity/runtime-cli/6.2.2 linux-x64 node-v22.15.0
23
+ @sanity/runtime-cli/7.0.0 linux-x64 node-v22.15.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -52,17 +52,22 @@ Add a Resource to a Blueprint
52
52
  ```
53
53
  USAGE
54
54
  $ sanity-run blueprints add TYPE [--fn-type document-publish -n <value>] [--language ts|js] [--javascript]
55
+ [--fn-helpers] [-i | --fn-installer skip|npm|pnpm|yarn]
55
56
 
56
57
  ARGUMENTS
57
58
  TYPE (function) Type of resource to add (e.g. function)
58
59
 
59
60
  FLAGS
60
- -n, --name=<value> Name of the Resource to add
61
- --fn-type=<option> Type of new Function
62
- <options: document-publish>
63
- --javascript Use JavaScript instead of TypeScript
64
- --language=<option> [default: ts] Language of the new Function
65
- <options: ts|js>
61
+ -i, --install Shortcut for --fn-installer npm
62
+ -n, --name=<value> Name of the Resource to add
63
+ --[no-]fn-helpers Add helpers to the new Function
64
+ --fn-installer=<option> How to install the @sanity/functions helpers
65
+ <options: skip|npm|pnpm|yarn>
66
+ --fn-type=<option> Type of new Function
67
+ <options: document-publish>
68
+ --javascript Use JavaScript instead of TypeScript
69
+ --language=<option> [default: ts] Language of the new Function
70
+ <options: ts|js>
66
71
 
67
72
  DESCRIPTION
68
73
  Add a Resource to a Blueprint
@@ -70,6 +75,8 @@ DESCRIPTION
70
75
  EXAMPLES
71
76
  $ sanity-run blueprints add function
72
77
 
78
+ $ sanity-run blueprints add function --helpers
79
+
73
80
  $ sanity-run blueprints add function --name my-function
74
81
 
75
82
  $ sanity-run blueprints add function --name my-function --fn-type document-publish
@@ -77,7 +84,7 @@ EXAMPLES
77
84
  $ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
78
85
  ```
79
86
 
80
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/add.ts)_
87
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/add.ts)_
81
88
 
82
89
  ## `sanity-run blueprints config`
83
90
 
@@ -105,7 +112,7 @@ EXAMPLES
105
112
  $ sanity-run blueprints config --edit --project-id <projectId>
106
113
  ```
107
114
 
108
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/config.ts)_
115
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/config.ts)_
109
116
 
110
117
  ## `sanity-run blueprints deploy`
111
118
 
@@ -127,7 +134,7 @@ EXAMPLES
127
134
  $ sanity-run blueprints deploy --no-wait
128
135
  ```
129
136
 
130
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/deploy.ts)_
137
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/deploy.ts)_
131
138
 
132
139
  ## `sanity-run blueprints destroy`
133
140
 
@@ -148,7 +155,7 @@ EXAMPLES
148
155
  $ sanity-run blueprints destroy
149
156
  ```
150
157
 
151
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/destroy.ts)_
158
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/destroy.ts)_
152
159
 
153
160
  ## `sanity-run blueprints info`
154
161
 
@@ -165,7 +172,7 @@ EXAMPLES
165
172
  $ sanity-run blueprints info
166
173
  ```
167
174
 
168
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/info.ts)_
175
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/info.ts)_
169
176
 
170
177
  ## `sanity-run blueprints init [DIR]`
171
178
 
@@ -197,7 +204,7 @@ EXAMPLES
197
204
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId>
198
205
  ```
199
206
 
200
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/init.ts)_
207
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/init.ts)_
201
208
 
202
209
  ## `sanity-run blueprints logs`
203
210
 
@@ -219,7 +226,7 @@ EXAMPLES
219
226
  $ sanity-run blueprints logs --watch
220
227
  ```
221
228
 
222
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/logs.ts)_
229
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/logs.ts)_
223
230
 
224
231
  ## `sanity-run blueprints plan`
225
232
 
@@ -236,7 +243,7 @@ EXAMPLES
236
243
  $ sanity-run blueprints plan
237
244
  ```
238
245
 
239
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/blueprints/plan.ts)_
246
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/blueprints/plan.ts)_
240
247
 
241
248
  ## `sanity-run functions dev`
242
249
 
@@ -256,7 +263,7 @@ EXAMPLES
256
263
  $ sanity-run functions dev --port 8974
257
264
  ```
258
265
 
259
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/functions/dev.ts)_
266
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/functions/dev.ts)_
260
267
 
261
268
  ## `sanity-run functions env add NAME KEY VALUE`
262
269
 
@@ -278,7 +285,7 @@ EXAMPLES
278
285
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
279
286
  ```
280
287
 
281
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/functions/env/add.ts)_
288
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/functions/env/add.ts)_
282
289
 
283
290
  ## `sanity-run functions env list NAME`
284
291
 
@@ -298,7 +305,7 @@ EXAMPLES
298
305
  $ sanity-run functions env list MyFunction
299
306
  ```
300
307
 
301
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/functions/env/list.ts)_
308
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/functions/env/list.ts)_
302
309
 
303
310
  ## `sanity-run functions env remove NAME KEY`
304
311
 
@@ -319,7 +326,7 @@ EXAMPLES
319
326
  $ sanity-run functions env remove MyFunction API_URL
320
327
  ```
321
328
 
322
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/functions/env/remove.ts)_
329
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/functions/env/remove.ts)_
323
330
 
324
331
  ## `sanity-run functions logs NAME`
325
332
 
@@ -352,7 +359,7 @@ EXAMPLES
352
359
  $ sanity-run functions logs <name> --delete
353
360
  ```
354
361
 
355
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/functions/logs.ts)_
362
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/functions/logs.ts)_
356
363
 
357
364
  ## `sanity-run functions test NAME`
358
365
 
@@ -385,7 +392,7 @@ EXAMPLES
385
392
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
386
393
  ```
387
394
 
388
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v6.2.2/src/commands/functions/test.ts)_
395
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v7.0.0/src/commands/functions/test.ts)_
389
396
 
390
397
  ## `sanity-run help [COMMAND]`
391
398
 
@@ -30,6 +30,7 @@ type BlueprintFailure = {
30
30
  type BlueprintResult = BlueprintSuccess | BlueprintFailure;
31
31
  /**
32
32
  * Get the local Blueprint and deployed Stack
33
+ * @deprecated Use initBlueprintConfig or initDeployedBlueprintConfig instead
33
34
  * @param blueprintPath - The path of the Blueprint file or directory- will search up the directory tree if not provided
34
35
  * @param token - The Sanity API token
35
36
  * @returns The local Blueprint, issues, and maybe a deployed Stack
@@ -9,6 +9,7 @@ import { readLocalBlueprint } from './blueprint.js';
9
9
  import { getStack } from './stacks.js';
10
10
  /**
11
11
  * Get the local Blueprint and deployed Stack
12
+ * @deprecated Use initBlueprintConfig or initDeployedBlueprintConfig instead
12
13
  * @param blueprintPath - The path of the Blueprint file or directory- will search up the directory tree if not provided
13
14
  * @param token - The Sanity API token
14
15
  * @returns The local Blueprint, issues, and maybe a deployed Stack
@@ -3,15 +3,16 @@ interface FunctionResourceOptions {
3
3
  name: string;
4
4
  type: string;
5
5
  lang: string;
6
- displayName?: string;
7
6
  blueprintFilePath?: string;
7
+ addHelpers?: boolean;
8
+ installCommand?: string | null;
8
9
  }
9
10
  /**
10
11
  * Creates a new function resource file and adds it to the blueprint
11
12
  */
12
- export declare function createFunctionResource(options: FunctionResourceOptions): {
13
+ export declare function createFunctionResource(options: FunctionResourceOptions): Promise<{
13
14
  filePath: string;
14
15
  resourceAdded: boolean;
15
16
  resource: LocalFunctionResource;
16
- };
17
+ }>;
17
18
  export {};
@@ -1,12 +1,20 @@
1
+ import { spawn } from 'node:child_process';
1
2
  import { mkdirSync, writeFileSync } from 'node:fs';
2
3
  import { existsSync } from 'node:fs';
3
4
  import { dirname, join } from 'node:path';
4
5
  import { cwd } from 'node:process';
6
+ import chalk from 'chalk';
5
7
  import { addResourceToBlueprint } from './blueprint.js';
6
8
  const DEFAULT_FUNCTION_TEMPLATE = /*js*/ `export async function handler({context, event}) {
7
9
  const time = new Date().toLocaleTimeString()
8
10
  console.log(\`👋 Your Sanity Function was called at \${time}\`)
9
11
  }`;
12
+ const DEFAULT_HELPER_FUNCTION_TEMPLATE = /*ts*/ `import { documentEventHandler } from '@sanity/functions'
13
+
14
+ export const handler = documentEventHandler(async ({ context, event }) => {
15
+ const time = new Date().toLocaleTimeString()
16
+ console.log(\`👋 Your Sanity Function was called at \${time}\`)
17
+ })`;
10
18
  const DEFAULT_PACKAGE_JSON = {
11
19
  name: '',
12
20
  type: 'module',
@@ -15,8 +23,8 @@ const DEFAULT_PACKAGE_JSON = {
15
23
  /**
16
24
  * Creates a new function resource file and adds it to the blueprint
17
25
  */
18
- export function createFunctionResource(options) {
19
- const { name, type, lang, displayName = name, blueprintFilePath } = options;
26
+ export async function createFunctionResource(options) {
27
+ const { name, type, lang, blueprintFilePath, addHelpers = false, installCommand } = options;
20
28
  let workingDir = cwd();
21
29
  if (blueprintFilePath) {
22
30
  if (!existsSync(blueprintFilePath)) {
@@ -31,29 +39,41 @@ export function createFunctionResource(options) {
31
39
  }
32
40
  // Create function directory
33
41
  const functionDir = join(functionsDir, name);
34
- if (!existsSync(functionDir)) {
35
- mkdirSync(functionDir, { recursive: true });
36
- }
42
+ if (existsSync(functionDir))
43
+ throw Error(`${functionDir} already exists`);
44
+ mkdirSync(functionDir, { recursive: true });
37
45
  if (!['ts', 'js'].includes(lang))
38
46
  throw Error(`Unsupported language: ${lang}`);
39
47
  // Create index.<lang> with default template
40
48
  const indexPath = join(functionDir, `index.${lang}`);
41
- writeFileSync(indexPath, DEFAULT_FUNCTION_TEMPLATE);
49
+ writeFileSync(indexPath, addHelpers ? DEFAULT_HELPER_FUNCTION_TEMPLATE : DEFAULT_FUNCTION_TEMPLATE);
42
50
  // Create package.json
43
51
  const packagePath = join(functionDir, 'package.json');
44
52
  const packageContent = {
45
53
  ...DEFAULT_PACKAGE_JSON,
46
54
  name,
47
55
  main: `index.${lang}`,
56
+ dependencies: {},
48
57
  };
58
+ if (addHelpers) {
59
+ const helpersVersion = await getLatestNpmVersion('@sanity/functions');
60
+ packageContent.dependencies = {
61
+ '@sanity/functions': helpersVersion,
62
+ };
63
+ }
49
64
  writeFileSync(packagePath, JSON.stringify(packageContent, null, 2));
65
+ if (installCommand) {
66
+ const success = await runPackageInstall(functionDir, installCommand);
67
+ if (!success) {
68
+ throw new Error(`Failed to install dependencies using \`${installCommand}\``);
69
+ }
70
+ }
50
71
  // type looks like 'document-publish'
51
72
  const typeParts = type.split('-');
52
73
  const typeName = typeParts[0];
53
74
  const eventOn = typeParts[1];
54
75
  // Create resource definition
55
76
  const resourceJson = {
56
- displayName,
57
77
  name,
58
78
  src: `functions/${name}`,
59
79
  type: `sanity.function.${typeName}`,
@@ -69,3 +89,37 @@ export function createFunctionResource(options) {
69
89
  resource: resource || resourceJson,
70
90
  };
71
91
  }
92
+ async function getLatestNpmVersion(pkg) {
93
+ const url = `https://registry.npmjs.org/${pkg}/latest`;
94
+ try {
95
+ const res = await fetch(url);
96
+ if (!res.ok)
97
+ throw new Error(`Failed to fetch version for ${pkg}`);
98
+ const data = await res.json();
99
+ return data.version;
100
+ }
101
+ catch (error) {
102
+ return 'latest';
103
+ }
104
+ }
105
+ async function runPackageInstall(cwd, command) {
106
+ return new Promise((resolve) => {
107
+ const install = spawn(command, ['install'], { cwd });
108
+ const formatOutput = (data) => {
109
+ const lines = data.toString().split('\n');
110
+ return lines
111
+ .filter(Boolean)
112
+ .map((line) => ` ${chalk.magenta('│')} ${chalk.dim(line)}`)
113
+ .join('\n');
114
+ };
115
+ install.stdout?.on('data', (data) => {
116
+ console.log(formatOutput(data));
117
+ });
118
+ install.stderr?.on('data', (data) => {
119
+ console.error(formatOutput(data));
120
+ });
121
+ install.on('close', (code) => {
122
+ resolve(code === 0);
123
+ });
124
+ });
125
+ }
@@ -1,6 +1,6 @@
1
1
  import { Command } from '@oclif/core';
2
2
  import type { Interfaces } from '@oclif/core';
3
- import { readLocalBlueprint } from './actions/blueprints/blueprint.js';
3
+ import type { readLocalBlueprint } from './actions/blueprints/blueprint.js';
4
4
  import type { AuthParams, Stack } from './utils/types.js';
5
5
  export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BlueprintCommand)['baseFlags'] & T['flags']>;
6
6
  export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
@@ -1,9 +1,6 @@
1
1
  // * https://oclif.io/docs/base_class
2
2
  import { Command } from '@oclif/core';
3
- import { readLocalBlueprint } from './actions/blueprints/blueprint.js';
4
- import { getStack } from './actions/blueprints/stacks.js';
5
- import { presentBlueprintParserErrors } from './utils/display/errors.js';
6
- import { niceId } from './utils/display/presenters.js';
3
+ import { initBlueprintConfig, initDeployedBlueprintConfig } from './cores/index.js';
7
4
  import { validTokenOrErrorMessage } from './utils/validated-token.js';
8
5
  /**
9
6
  * @description Guarantees flags, args, sanityToken, and blueprint.
@@ -30,12 +27,12 @@ export class BlueprintCommand extends Command {
30
27
  if (tokenErr)
31
28
  this.error(tokenErr.message);
32
29
  this.sanityToken = token;
33
- const blueprint = await readLocalBlueprint();
34
- if (blueprint.errors.length > 0) {
35
- this.log(presentBlueprintParserErrors(blueprint.errors));
36
- this.error('Unable to parse Blueprint file.');
30
+ const result = await initBlueprintConfig(this.config.bin, (msg) => this.log(msg), token);
31
+ if (!result.ok) {
32
+ this.error(result.error);
37
33
  }
38
- this.blueprint = blueprint;
34
+ this.sanityToken = result.value.sanityToken;
35
+ this.blueprint = result.value.blueprint;
39
36
  }
40
37
  async catch(err) {
41
38
  // add any custom logic to handle errors from the command
@@ -59,23 +56,18 @@ export class DeployedBlueprintCommand extends BlueprintCommand {
59
56
  stackId;
60
57
  async init() {
61
58
  await super.init();
62
- const { projectId, stackId } = this.blueprint;
63
- if (!(projectId && stackId)) {
64
- this.log(`Run \`${this.config.bin} blueprints config --edit --test\` to update your config`);
65
- if (!projectId)
66
- this.error('Missing Project configuration for Blueprint');
67
- if (!stackId)
68
- this.error('Missing deployment configuration for Blueprint');
69
- }
70
- this.projectId = projectId;
71
- this.stackId = stackId;
72
- this.auth = { token: this.sanityToken, projectId };
73
- const stackResponse = await getStack({ stackId, auth: this.auth });
74
- if (!stackResponse.ok) {
75
- this.log(`Could not retrieve deployment info for ${niceId(stackId)}. Was it destroyed?`);
76
- this.log(`Run \`${this.config.bin} blueprints config --edit --test\` to update your config`);
77
- this.error('Missing deployment');
59
+ const result = await initDeployedBlueprintConfig({
60
+ bin: this.config.bin,
61
+ blueprint: this.blueprint,
62
+ log: (msg) => this.log(msg),
63
+ sanityToken: this.sanityToken,
64
+ });
65
+ if (!result.ok) {
66
+ this.error(result.error);
78
67
  }
79
- this.deployedStack = stackResponse.stack;
68
+ this.projectId = result.value.projectId;
69
+ this.stackId = result.value.stackId;
70
+ this.auth = result.value.auth;
71
+ this.deployedStack = result.value.deployedStack;
80
72
  }
81
73
  }
@@ -1,5 +1,5 @@
1
- import { Command } from '@oclif/core';
2
- export default class AddCommand extends Command {
1
+ import { BlueprintCommand } from '../../baseCommands.js';
2
+ export default class AddCommand extends BlueprintCommand<typeof AddCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static args: {
@@ -10,6 +10,9 @@ export default class AddCommand extends Command {
10
10
  'fn-type': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
11
  language: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
12
  javascript: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ 'fn-helpers': import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ 'fn-installer': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
+ install: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
16
  };
14
17
  run(): Promise<void>;
15
18
  }
@@ -1,9 +1,11 @@
1
- import { Args, Command, Flags } from '@oclif/core';
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { BlueprintCommand } from '../../baseCommands.js';
2
3
  import { blueprintAddCore } from '../../cores/blueprints/index.js';
3
- export default class AddCommand extends Command {
4
+ export default class AddCommand extends BlueprintCommand {
4
5
  static description = 'Add a Resource to a Blueprint';
5
6
  static examples = [
6
7
  '<%= config.bin %> <%= command.id %> function',
8
+ '<%= config.bin %> <%= command.id %> function --helpers',
7
9
  '<%= config.bin %> <%= command.id %> function --name my-function',
8
10
  '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish',
9
11
  '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish --lang js',
@@ -37,14 +39,30 @@ export default class AddCommand extends Command {
37
39
  description: 'Use JavaScript instead of TypeScript',
38
40
  aliases: ['js'],
39
41
  }),
42
+ 'fn-helpers': Flags.boolean({
43
+ description: 'Add helpers to the new Function',
44
+ aliases: ['function-helpers', 'helpers'],
45
+ default: true,
46
+ allowNo: true,
47
+ }),
48
+ 'fn-installer': Flags.string({
49
+ description: 'How to install the @sanity/functions helpers',
50
+ aliases: ['function-installer', 'installer'],
51
+ options: ['skip', 'npm', 'pnpm', 'yarn'],
52
+ }),
53
+ install: Flags.boolean({
54
+ description: 'Shortcut for --fn-installer npm',
55
+ char: 'i',
56
+ exclusive: ['fn-installer'],
57
+ }),
40
58
  };
41
59
  async run() {
42
- const { args, flags } = await this.parse(AddCommand);
43
60
  const { success, error } = await blueprintAddCore({
44
61
  bin: this.config.bin,
45
62
  log: (msg) => this.log(msg),
46
- args,
47
- flags,
63
+ blueprint: this.blueprint,
64
+ args: this.args,
65
+ flags: this.flags,
48
66
  });
49
67
  if (!success)
50
68
  this.error(error);
@@ -1,9 +1,6 @@
1
1
  import { Args } from '@oclif/core';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
- import { update } from '../../../actions/functions/env/update.js';
5
2
  import { DeployedBlueprintCommand } from '../../../baseCommands.js';
6
- import { findFunctionByName } from '../../../utils/find-function.js';
3
+ import { envAddCore } from '../../../cores/functions/env/add.js';
7
4
  export default class EnvAddCommand extends DeployedBlueprintCommand {
8
5
  static args = {
9
6
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
@@ -15,16 +12,18 @@ export default class EnvAddCommand extends DeployedBlueprintCommand {
15
12
  '<%= config.bin %> <%= command.id %> MyFunction API_URL https://api.example.com/',
16
13
  ];
17
14
  async run() {
18
- const args = this.args;
19
- const spinner = ora(`Updating "${args.key}" environment variable in "${args.name}"`).start();
20
- const { externalId } = findFunctionByName(this.deployedStack, args.name);
21
- const result = await update(externalId, args.key, args.value, this.auth);
22
- if (result.ok) {
23
- spinner.succeed(`Update of ${args.key} succeeded`);
24
- }
25
- else {
26
- spinner.fail(`${chalk.red('Failed')} to update ${args.key}`);
27
- this.log(`Error: ${result.error || 'Unknown error'}`);
28
- }
15
+ const { success, error } = await envAddCore({
16
+ bin: this.config.bin,
17
+ log: (msg) => this.log(msg),
18
+ args: this.args,
19
+ auth: this.auth,
20
+ blueprint: this.blueprint,
21
+ deployedStack: this.deployedStack,
22
+ projectId: this.projectId,
23
+ sanityToken: this.sanityToken,
24
+ stackId: this.stackId,
25
+ });
26
+ if (!success)
27
+ this.error(error);
29
28
  }
30
29
  }
@@ -1,8 +1,6 @@
1
1
  import { Args } from '@oclif/core';
2
- import ora from 'ora';
3
- import { list } from '../../../actions/functions/env/list.js';
4
2
  import { DeployedBlueprintCommand } from '../../../baseCommands.js';
5
- import { findFunctionByName } from '../../../utils/find-function.js';
3
+ import { envListCore } from '../../../cores/functions/env/list.js';
6
4
  export default class EnvListCommand extends DeployedBlueprintCommand {
7
5
  static args = {
8
6
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
@@ -10,17 +8,18 @@ export default class EnvListCommand extends DeployedBlueprintCommand {
10
8
  static description = 'List the environment variables for a Sanity function';
11
9
  static examples = ['<%= config.bin %> <%= command.id %> MyFunction'];
12
10
  async run() {
13
- const args = this.args;
14
- const spinner = ora(`Listing environment variables for "${args.name}"`).start();
15
- const { externalId } = findFunctionByName(this.deployedStack, args.name);
16
- const result = await list(externalId, this.auth);
17
- if (!result.ok) {
18
- spinner.stop();
19
- this.error(`Error: ${result.error || 'Unknown error'}`);
20
- }
21
- spinner.succeed(`Environment variables for "${args.name}"`);
22
- for (const key of result.envvars) {
23
- this.log(key);
24
- }
11
+ const { success, error } = await envListCore({
12
+ bin: this.config.bin,
13
+ log: (msg) => this.log(msg),
14
+ args: this.args,
15
+ auth: this.auth,
16
+ blueprint: this.blueprint,
17
+ deployedStack: this.deployedStack,
18
+ projectId: this.projectId,
19
+ sanityToken: this.sanityToken,
20
+ stackId: this.stackId,
21
+ });
22
+ if (!success)
23
+ this.error(error);
25
24
  }
26
25
  }
@@ -1,9 +1,6 @@
1
1
  import { Args } from '@oclif/core';
2
- import chalk from 'chalk';
3
- import ora from 'ora';
4
- import { remove } from '../../../actions/functions/env/remove.js';
5
2
  import { DeployedBlueprintCommand } from '../../../baseCommands.js';
6
- import { findFunctionByName } from '../../../utils/find-function.js';
3
+ import { envRemoveCore } from '../../../cores/functions/env/remove.js';
7
4
  export default class EnvRemoveCommand extends DeployedBlueprintCommand {
8
5
  static args = {
9
6
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
@@ -12,16 +9,18 @@ export default class EnvRemoveCommand extends DeployedBlueprintCommand {
12
9
  static description = 'Remove an environment variable for a Sanity function';
13
10
  static examples = ['<%= config.bin %> <%= command.id %> MyFunction API_URL'];
14
11
  async run() {
15
- const args = this.args;
16
- const spinner = ora(`Removing "${args.key}" environment variable in "${args.name}"`).start();
17
- const { externalId } = findFunctionByName(this.deployedStack, args.name);
18
- const result = await remove(externalId, args.key, this.auth);
19
- if (result.ok) {
20
- spinner.succeed(`Removal of ${args.key} succeeded`);
21
- }
22
- else {
23
- spinner.fail(`${chalk.red('Failed')} to remove ${args.key}`);
24
- this.log(`Error: ${result.error || 'Unknown error'}`);
25
- }
12
+ const { success, error } = await envRemoveCore({
13
+ bin: this.config.bin,
14
+ log: (msg) => this.log(msg),
15
+ args: this.args,
16
+ auth: this.auth,
17
+ blueprint: this.blueprint,
18
+ deployedStack: this.deployedStack,
19
+ projectId: this.projectId,
20
+ sanityToken: this.sanityToken,
21
+ stackId: this.stackId,
22
+ });
23
+ if (!success)
24
+ this.error(error);
26
25
  }
27
26
  }
@@ -1,5 +1,7 @@
1
+ import type { ReadBlueprintResult } from '../../actions/blueprints/blueprint.js';
1
2
  import type { CoreConfig, CoreResult } from '../index.js';
2
3
  export interface BlueprintAddOptions extends CoreConfig {
4
+ blueprint: ReadBlueprintResult;
3
5
  args: {
4
6
  type: string;
5
7
  };
@@ -8,6 +10,9 @@ export interface BlueprintAddOptions extends CoreConfig {
8
10
  'fn-type'?: string;
9
11
  language?: string;
10
12
  javascript?: boolean;
13
+ 'fn-helpers'?: boolean;
14
+ 'fn-installer'?: string;
15
+ install?: boolean;
11
16
  };
12
17
  }
13
18
  export declare function blueprintAddCore(options: BlueprintAddOptions): Promise<CoreResult>;
@@ -2,15 +2,28 @@ import { cwd } from 'node:process';
2
2
  import chalk from 'chalk';
3
3
  import highlight from 'color-json';
4
4
  import inquirer from 'inquirer';
5
- import { findBlueprintFile } from '../../actions/blueprints/blueprint.js';
6
5
  import { createFunctionResource } from '../../actions/blueprints/resources.js';
7
6
  import { validateFunctionName } from '../../utils/validate/resource.js';
8
7
  export async function blueprintAddCore(options) {
9
- const { bin = 'sanity', log, args, flags } = options;
8
+ const { bin = 'sanity', log, blueprint, args, flags } = options;
10
9
  const { type: resourceType } = args;
11
- const { name: flagResourceName, 'fn-type': flagFnType, javascript: flagJs } = flags;
12
- let { language: flagFnLang } = flags;
10
+ const { name: flagResourceName, 'fn-type': flagFnType, javascript: flagJs, 'fn-helpers': flagFnHelpers, install: flagI, } = flags;
11
+ let { language: flagFnLang, 'fn-installer': flagFnInstaller, // can be 'skip'!
12
+ } = flags;
13
13
  flagFnLang = flagJs ? 'js' : flagFnLang;
14
+ flagFnInstaller = flagFnInstaller === 'skip' ? undefined : flagFnInstaller;
15
+ if (flagI && flagFnInstaller) {
16
+ return {
17
+ success: false,
18
+ error: 'Cannot use -i flag with the --fn-installer flag',
19
+ };
20
+ }
21
+ if (flagI && !flagFnHelpers) {
22
+ return {
23
+ success: false,
24
+ error: 'Cannot use -i flag with the --no-fn-helpers flag',
25
+ };
26
+ }
14
27
  try {
15
28
  if (resourceType !== 'function') {
16
29
  return {
@@ -18,37 +31,71 @@ export async function blueprintAddCore(options) {
18
31
  error: `Unsupported Resource type: ${resourceType}`,
19
32
  };
20
33
  }
21
- const existingBlueprint = findBlueprintFile();
22
- if (!existingBlueprint) {
34
+ if (flagResourceName && !validateFunctionName(flagResourceName)) {
35
+ // if provided && invalid, return error
23
36
  return {
24
37
  success: false,
25
- error: `No Blueprint file found. Run \`${bin} blueprints init\` first.`,
38
+ error: `Invalid function name: ${flagResourceName}`,
26
39
  };
27
40
  }
28
41
  const fnName = flagResourceName || (await promptForFunctionName());
29
- if (!validateFunctionName(fnName)) {
30
- throw new Error('Invalid function name. Must be 6+ characters, no special characters, no spaces');
42
+ // look for existing function with same name
43
+ if (blueprint.parsedBlueprint.resources?.some((r) => r.name === fnName)) {
44
+ return {
45
+ success: false,
46
+ error: `Function "${chalk.bold(fnName)}" already exists.`,
47
+ };
31
48
  }
32
49
  const fnType = flagFnType || (await promptForFunctionType());
33
50
  const fnLang = flagFnLang || (await promptForFunctionLang());
34
51
  if (!['document-publish', 'document-create', 'document-delete'].includes(fnType)) {
35
52
  throw new Error('Invalid function type. Must be one of: document-publish, document-create, document-delete');
36
53
  }
37
- const { filePath, resourceAdded, resource } = createFunctionResource({
54
+ let addHelpers;
55
+ let installCommand;
56
+ if (!['ts', 'js'].includes(fnLang)) {
57
+ // language is not supported
58
+ addHelpers = false;
59
+ installCommand = null;
60
+ }
61
+ else if (!flagFnHelpers) {
62
+ // user does not want helpers: "--no-fn-helpers"
63
+ addHelpers = false;
64
+ installCommand = null;
65
+ }
66
+ else if (flagI) {
67
+ // user wants to install helpers with npm
68
+ addHelpers = true;
69
+ installCommand = 'npm';
70
+ }
71
+ else if (flagFnInstaller) {
72
+ // user wants to install helpers using a specific command
73
+ addHelpers = true;
74
+ installCommand = flagFnInstaller;
75
+ }
76
+ else {
77
+ // unsure; ask...
78
+ addHelpers = flagFnHelpers || (await promptForAddHelpers());
79
+ installCommand = addHelpers ? await promptForInstallCommand() : null;
80
+ }
81
+ if (installCommand)
82
+ log(`${chalk.magenta('Installing')} with ${installCommand}...`);
83
+ const { filePath, resourceAdded, resource } = await createFunctionResource({
38
84
  name: fnName,
39
85
  type: fnType,
40
86
  lang: fnLang,
41
- displayName: fnName,
87
+ addHelpers,
88
+ installCommand,
42
89
  });
43
90
  log(`\nCreated function: ${filePath.replace(cwd(), '')}`);
44
91
  if (!resourceAdded) {
45
92
  // print the resource JSON for manual addition
46
93
  log('\nAdd this Function resource to your blueprint:');
47
- log(highlight(JSON.stringify(resource, null, 2)));
94
+ log(highlight(JSON.stringify(resource, null, 2), undefined, undefined, 2));
48
95
  }
49
96
  else {
50
97
  // added to blueprint.json
51
- log(`Function "${chalk.bold(fnName)}" added to blueprint file.`);
98
+ log(`Function "${chalk.bold(fnName)}" added to Blueprint file.`);
52
99
  }
53
100
  if (fnLang === 'ts') {
54
101
  log(chalk.dim('Add "functions/**/.build/**" to your .gitignore.'));
@@ -69,7 +116,8 @@ async function promptForFunctionName() {
69
116
  type: 'input',
70
117
  name: 'functionName',
71
118
  message: 'Enter function name:',
72
- validate: (input) => input.length > 0 || 'Function name is required',
119
+ validate: (input) => validateFunctionName(input) ||
120
+ 'Invalid function name. Must be 6+ characters, no special characters, no spaces',
73
121
  },
74
122
  ]);
75
123
  return functionName;
@@ -105,3 +153,31 @@ async function promptForFunctionLang() {
105
153
  ]);
106
154
  return functionLang;
107
155
  }
156
+ async function promptForAddHelpers() {
157
+ const { addHelpers } = await inquirer.prompt([
158
+ {
159
+ type: 'confirm',
160
+ name: 'addHelpers',
161
+ message: 'Add @sanity/functions helpers to the new Function?',
162
+ default: true,
163
+ },
164
+ ]);
165
+ return addHelpers;
166
+ }
167
+ async function promptForInstallCommand() {
168
+ const { command } = await inquirer.prompt([
169
+ {
170
+ type: 'list',
171
+ name: 'command',
172
+ message: 'How to install the @sanity/functions helpers:',
173
+ choices: [
174
+ { name: 'npm', value: 'npm' },
175
+ { name: 'pnpm', value: 'pnpm' },
176
+ { name: 'yarn', value: 'yarn' },
177
+ { name: 'Skip install', value: null },
178
+ ],
179
+ default: 'npm',
180
+ },
181
+ ]);
182
+ return command;
183
+ }
@@ -0,0 +1,9 @@
1
+ import type { CoreResult, DeployedBlueprintConfig } from '../../index.js';
2
+ export interface EnvAddOptions extends DeployedBlueprintConfig {
3
+ args: {
4
+ name: string;
5
+ key: string;
6
+ value: string;
7
+ };
8
+ }
9
+ export declare function envAddCore(options: EnvAddOptions): Promise<CoreResult>;
@@ -0,0 +1,19 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { update } from '../../../actions/functions/env/update.js';
4
+ import { findFunctionByName } from '../../../utils/find-function.js';
5
+ export async function envAddCore(options) {
6
+ const args = options.args;
7
+ const spinner = ora(`Updating "${args.key}" environment variable in "${args.name}"`).start();
8
+ const { externalId } = findFunctionByName(options.deployedStack, args.name);
9
+ const result = await update(externalId, args.key, args.value, options.auth);
10
+ if (!result.ok) {
11
+ spinner.fail(`${chalk.red('Failed')} to update ${args.key}`);
12
+ return {
13
+ success: false,
14
+ error: result.error || 'Unknown error',
15
+ };
16
+ }
17
+ spinner.succeed(`Update of ${args.key} succeeded`);
18
+ return { success: true };
19
+ }
@@ -0,0 +1,7 @@
1
+ import type { CoreResult, DeployedBlueprintConfig } from '../../index.js';
2
+ export interface EnvListOptions extends DeployedBlueprintConfig {
3
+ args: {
4
+ name: string;
5
+ };
6
+ }
7
+ export declare function envListCore(options: EnvListOptions): Promise<CoreResult>;
@@ -0,0 +1,18 @@
1
+ import ora from 'ora';
2
+ import { list } from '../../../actions/functions/env/list.js';
3
+ import { findFunctionByName } from '../../../utils/find-function.js';
4
+ export async function envListCore(options) {
5
+ const args = options.args;
6
+ const spinner = ora(`Listing environment variables for "${args.name}"`).start();
7
+ const { externalId } = findFunctionByName(options.deployedStack, args.name);
8
+ const result = await list(externalId, options.auth);
9
+ if (!result.ok) {
10
+ spinner.stop();
11
+ return { success: false, error: result.error || 'Unknown error' };
12
+ }
13
+ spinner.succeed(`Environment variables for "${args.name}"`);
14
+ for (const key of result.envvars) {
15
+ options.log(key);
16
+ }
17
+ return { success: true };
18
+ }
@@ -0,0 +1,8 @@
1
+ import type { CoreResult, DeployedBlueprintConfig } from '../../index.js';
2
+ export interface EnvRemoveOptions extends DeployedBlueprintConfig {
3
+ args: {
4
+ name: string;
5
+ key: string;
6
+ };
7
+ }
8
+ export declare function envRemoveCore(options: EnvRemoveOptions): Promise<CoreResult>;
@@ -0,0 +1,16 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { remove } from '../../../actions/functions/env/remove.js';
4
+ import { findFunctionByName } from '../../../utils/find-function.js';
5
+ export async function envRemoveCore(options) {
6
+ const args = options.args;
7
+ const spinner = ora(`Removing "${args.key}" environment variable in "${args.name}"`).start();
8
+ const { externalId } = findFunctionByName(options.deployedStack, args.name);
9
+ const result = await remove(externalId, args.key, options.auth);
10
+ if (!result.ok) {
11
+ spinner.fail(`${chalk.red('Failed')} to remove ${args.key}`);
12
+ return { success: false, error: result.error || 'Unknown error' };
13
+ }
14
+ spinner.succeed(`Removal of ${args.key} succeeded`);
15
+ return { success: true };
16
+ }
@@ -0,0 +1,6 @@
1
+ export { envAddCore } from './env/add.js';
2
+ export type { EnvAddOptions } from './env/add.js';
3
+ export { envListCore } from './env/list.js';
4
+ export type { EnvListOptions } from './env/list.js';
5
+ export { envRemoveCore } from './env/remove.js';
6
+ export type { EnvRemoveOptions } from './env/remove.js';
@@ -0,0 +1,3 @@
1
+ export { envAddCore } from './env/add.js';
2
+ export { envListCore } from './env/list.js';
3
+ export { envRemoveCore } from './env/remove.js';
@@ -1,10 +1,23 @@
1
+ import { type ReadBlueprintResult } from '../actions/blueprints/blueprint.js';
2
+ import type { AuthParams, Result, Stack } from '../utils/types.js';
1
3
  export * as blueprintsCores from './blueprints/index.js';
4
+ export * as functionsCores from './functions/index.js';
2
5
  export interface CoreConfig {
3
6
  /** The CLI binary name. */
4
7
  bin: string;
5
8
  /** The log output function. */
6
9
  log: (message: string) => void;
7
10
  }
11
+ export interface BlueprintConfig extends CoreConfig {
12
+ sanityToken: string;
13
+ blueprint: ReadBlueprintResult;
14
+ }
15
+ export interface DeployedBlueprintConfig extends BlueprintConfig {
16
+ stackId: string;
17
+ projectId: string;
18
+ auth: AuthParams;
19
+ deployedStack: Stack;
20
+ }
8
21
  export type CoreResult = {
9
22
  /** Something went wrong. */
10
23
  success: false;
@@ -18,3 +31,5 @@ export type CoreResult = {
18
31
  streaming?: Promise<void>;
19
32
  error?: never;
20
33
  };
34
+ export declare function initBlueprintConfig(bin: string, log: (msg: string) => void, token: string): Promise<Result<BlueprintConfig>>;
35
+ export declare function initDeployedBlueprintConfig(config: Partial<BlueprintConfig> & Pick<BlueprintConfig, 'bin' | 'log' | 'sanityToken'>): Promise<Result<DeployedBlueprintConfig>>;
@@ -1 +1,60 @@
1
+ import { readLocalBlueprint } from '../actions/blueprints/blueprint.js';
2
+ import { getStack } from '../actions/blueprints/stacks.js';
3
+ import { presentBlueprintParserErrors } from '../utils/display/errors.js';
4
+ import { niceId } from '../utils/display/presenters.js';
1
5
  export * as blueprintsCores from './blueprints/index.js';
6
+ export * as functionsCores from './functions/index.js';
7
+ export async function initBlueprintConfig(bin, log, token) {
8
+ const blueprint = await readLocalBlueprint();
9
+ if (blueprint.errors.length > 0) {
10
+ log(presentBlueprintParserErrors(blueprint.errors));
11
+ return { ok: false, error: 'Unable to parse Blueprint file.' };
12
+ }
13
+ return {
14
+ ok: true,
15
+ value: {
16
+ bin,
17
+ blueprint,
18
+ log,
19
+ sanityToken: token,
20
+ },
21
+ };
22
+ }
23
+ export async function initDeployedBlueprintConfig(config) {
24
+ if (!config.blueprint) {
25
+ const blueprintResult = await initBlueprintConfig(config.bin, config.log, config.sanityToken);
26
+ if (!blueprintResult.ok) {
27
+ return blueprintResult;
28
+ }
29
+ config.blueprint = blueprintResult.value.blueprint;
30
+ config.sanityToken = blueprintResult.value.sanityToken;
31
+ }
32
+ const { projectId, stackId } = config.blueprint;
33
+ if (!(projectId && stackId)) {
34
+ config.log(`Run \`${config.bin} blueprints config --edit --test\` to update your config`);
35
+ if (!projectId)
36
+ return { ok: false, error: 'Missing Project configuration for Blueprint' };
37
+ if (!stackId)
38
+ return { ok: false, error: 'Missing deployment configuration for Blueprint' };
39
+ }
40
+ const auth = { token: config.sanityToken, projectId };
41
+ const stackResponse = await getStack({ stackId, auth });
42
+ if (!stackResponse.ok) {
43
+ config.log(`Could not retrieve deployment info for ${niceId(stackId)}. Was it destroyed?`);
44
+ config.log(`Run \`${config.bin} blueprints config --edit --test\` to update your config`);
45
+ return { ok: false, error: 'Missing deployment' };
46
+ }
47
+ return {
48
+ ok: true,
49
+ value: {
50
+ bin: config.bin,
51
+ log: config.log,
52
+ blueprint: config.blueprint,
53
+ sanityToken: config.sanityToken,
54
+ projectId,
55
+ stackId,
56
+ auth,
57
+ deployedStack: stackResponse.stack,
58
+ },
59
+ };
60
+ }
@@ -1,3 +1,11 @@
1
+ /** Result utility type */
2
+ export type Result<T> = {
3
+ ok: true;
4
+ value: T;
5
+ } | {
6
+ ok: false;
7
+ error: string;
8
+ };
1
9
  /** @internal */
2
10
  export interface AuthParams {
3
11
  token: string;
@@ -15,6 +15,7 @@
15
15
  "description": "Add a Resource to a Blueprint",
16
16
  "examples": [
17
17
  "<%= config.bin %> <%= command.id %> function",
18
+ "<%= config.bin %> <%= command.id %> function --helpers",
18
19
  "<%= config.bin %> <%= command.id %> function --name my-function",
19
20
  "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish",
20
21
  "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish --lang js"
@@ -68,6 +69,43 @@
68
69
  "name": "javascript",
69
70
  "allowNo": false,
70
71
  "type": "boolean"
72
+ },
73
+ "fn-helpers": {
74
+ "aliases": [
75
+ "function-helpers",
76
+ "helpers"
77
+ ],
78
+ "description": "Add helpers to the new Function",
79
+ "name": "fn-helpers",
80
+ "allowNo": true,
81
+ "type": "boolean"
82
+ },
83
+ "fn-installer": {
84
+ "aliases": [
85
+ "function-installer",
86
+ "installer"
87
+ ],
88
+ "description": "How to install the @sanity/functions helpers",
89
+ "name": "fn-installer",
90
+ "hasDynamicHelp": false,
91
+ "multiple": false,
92
+ "options": [
93
+ "skip",
94
+ "npm",
95
+ "pnpm",
96
+ "yarn"
97
+ ],
98
+ "type": "option"
99
+ },
100
+ "install": {
101
+ "char": "i",
102
+ "description": "Shortcut for --fn-installer npm",
103
+ "exclusive": [
104
+ "fn-installer"
105
+ ],
106
+ "name": "install",
107
+ "allowNo": false,
108
+ "type": "boolean"
71
109
  }
72
110
  },
73
111
  "hasDynamicHelp": false,
@@ -77,7 +115,6 @@
77
115
  "pluginName": "@sanity/runtime-cli",
78
116
  "pluginType": "core",
79
117
  "strict": true,
80
- "enableJsonFlag": false,
81
118
  "isESM": true,
82
119
  "relativePath": [
83
120
  "dist",
@@ -790,5 +827,5 @@
790
827
  ]
791
828
  }
792
829
  },
793
- "version": "6.2.2"
830
+ "version": "7.0.0"
794
831
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "6.2.2",
4
+ "version": "7.0.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -23,10 +23,18 @@
23
23
  "types": "./dist/actions/functions/index.d.ts",
24
24
  "import": "./dist/actions/functions/index.js"
25
25
  },
26
+ "./cores": {
27
+ "types": "./dist/cores/index.d.ts",
28
+ "import": "./dist/cores/index.js"
29
+ },
26
30
  "./cores/blueprints": {
27
31
  "types": "./dist/cores/blueprints/index.d.ts",
28
32
  "import": "./dist/cores/blueprints/index.js"
29
33
  },
34
+ "./cores/functions": {
35
+ "types": "./dist/cores/functions/index.d.ts",
36
+ "import": "./dist/cores/functions/index.js"
37
+ },
30
38
  "./utils": {
31
39
  "types": "./dist/utils/index.d.ts",
32
40
  "import": "./dist/utils/index.js"