@sanity/runtime-cli 12.3.0 → 12.4.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.
Files changed (71) hide show
  1. package/README.md +32 -31
  2. package/dist/actions/blueprints/assets.js +7 -1
  3. package/dist/baseCommands.d.ts +43 -7
  4. package/dist/baseCommands.js +82 -10
  5. package/dist/commands/blueprints/add.d.ts +2 -2
  6. package/dist/commands/blueprints/add.js +2 -2
  7. package/dist/commands/blueprints/config.d.ts +2 -2
  8. package/dist/commands/blueprints/config.js +2 -2
  9. package/dist/commands/blueprints/deploy.d.ts +2 -2
  10. package/dist/commands/blueprints/deploy.js +2 -2
  11. package/dist/commands/blueprints/destroy.d.ts +2 -2
  12. package/dist/commands/blueprints/destroy.js +2 -2
  13. package/dist/commands/blueprints/doctor.d.ts +5 -4
  14. package/dist/commands/blueprints/doctor.js +10 -12
  15. package/dist/commands/blueprints/info.d.ts +2 -2
  16. package/dist/commands/blueprints/info.js +2 -2
  17. package/dist/commands/blueprints/init.d.ts +2 -2
  18. package/dist/commands/blueprints/init.js +6 -9
  19. package/dist/commands/blueprints/logs.d.ts +2 -2
  20. package/dist/commands/blueprints/logs.js +2 -2
  21. package/dist/commands/blueprints/plan.d.ts +2 -2
  22. package/dist/commands/blueprints/plan.js +2 -2
  23. package/dist/commands/blueprints/stacks.d.ts +2 -2
  24. package/dist/commands/blueprints/stacks.js +2 -2
  25. package/dist/commands/functions/add.d.ts +2 -2
  26. package/dist/commands/functions/add.js +2 -2
  27. package/dist/commands/functions/dev.d.ts +2 -2
  28. package/dist/commands/functions/dev.js +2 -2
  29. package/dist/commands/functions/env/add.d.ts +2 -2
  30. package/dist/commands/functions/env/add.js +2 -2
  31. package/dist/commands/functions/env/list.d.ts +2 -2
  32. package/dist/commands/functions/env/list.js +2 -2
  33. package/dist/commands/functions/env/remove.d.ts +2 -2
  34. package/dist/commands/functions/env/remove.js +2 -2
  35. package/dist/commands/functions/logs.d.ts +3 -3
  36. package/dist/commands/functions/logs.js +7 -4
  37. package/dist/commands/functions/test.d.ts +3 -3
  38. package/dist/commands/functions/test.js +7 -4
  39. package/dist/cores/blueprints/config.d.ts +2 -5
  40. package/dist/cores/blueprints/deploy.js +0 -1
  41. package/dist/cores/blueprints/destroy.d.ts +2 -5
  42. package/dist/cores/blueprints/doctor.js +12 -2
  43. package/dist/cores/blueprints/info.js +2 -2
  44. package/dist/cores/blueprints/stacks.d.ts +2 -5
  45. package/dist/cores/functions/logs.d.ts +3 -1
  46. package/dist/cores/functions/logs.js +11 -2
  47. package/dist/cores/functions/test.d.ts +3 -1
  48. package/dist/cores/functions/test.js +11 -2
  49. package/dist/server/static/components/app.css +0 -116
  50. package/dist/server/static/components/clear-button.js +1 -1
  51. package/dist/server/static/components/console-panel.js +27 -6
  52. package/dist/server/static/components/fetch-button.js +1 -1
  53. package/dist/server/static/components/filter-api-version.js +39 -3
  54. package/dist/server/static/components/filter-document-id.js +39 -3
  55. package/dist/server/static/components/filter-with-token.js +27 -4
  56. package/dist/server/static/components/filters.js +127 -62
  57. package/dist/server/static/components/function-list.js +33 -13
  58. package/dist/server/static/components/network-spinner.js +6 -4
  59. package/dist/server/static/components/payload-panel.js +46 -24
  60. package/dist/server/static/components/response-panel.js +33 -6
  61. package/dist/server/static/components/rule-panel.js +13 -4
  62. package/dist/server/static/components/run-panel.js +14 -7
  63. package/dist/server/static/components/select-dropdown.js +34 -5
  64. package/dist/server/static/components/shared-styles.js +31 -0
  65. package/dist/server/static/components/toggle-switch.js +11 -2
  66. package/dist/utils/display/blueprints-formatting.d.ts +2 -2
  67. package/dist/utils/display/blueprints-formatting.js +31 -26
  68. package/dist/utils/find-function.d.ts +4 -0
  69. package/dist/utils/find-function.js +6 -0
  70. package/oclif.manifest.json +281 -38
  71. package/package.json +2 -2
@@ -1,7 +1,8 @@
1
- import { Args, Command, Flags } from '@oclif/core';
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { baseFlags, RuntimeCommand, unhide } from '../../baseCommands.js';
2
3
  import { blueprintInitCore } from '../../cores/blueprints/init.js';
3
4
  import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
4
- export default class InitCommand extends Command {
5
+ export default class InitCommand extends RuntimeCommand {
5
6
  static description = 'Initialize a new Blueprint Stack deployment';
6
7
  static examples = [
7
8
  '<%= config.bin %> <%= command.id %>',
@@ -48,13 +49,9 @@ export default class InitCommand extends Command {
48
49
  aliases: ['name'],
49
50
  exclusive: ['stack-id'],
50
51
  }),
51
- verbose: Flags.boolean({
52
- description: 'Verbose output',
53
- default: false,
54
- }),
52
+ verbose: unhide(baseFlags.verbose),
55
53
  };
56
54
  async run() {
57
- const { args, flags } = await this.parse(InitCommand);
58
55
  const result = await validTokenOrErrorMessage();
59
56
  if (!result.ok)
60
57
  this.error(result.error.message);
@@ -62,8 +59,8 @@ export default class InitCommand extends Command {
62
59
  bin: this.config.bin,
63
60
  log: (message) => this.log(message),
64
61
  token: result.value,
65
- args,
66
- flags,
62
+ args: this.args,
63
+ flags: this.flags,
67
64
  });
68
65
  if (!success)
69
66
  this.error(error);
@@ -1,5 +1,5 @@
1
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
2
- export default class LogsCommand extends DeployedBlueprintCommand<typeof LogsCommand> {
1
+ import { DeployedStackCommand } from '../../baseCommands.js';
2
+ export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
@@ -1,7 +1,7 @@
1
1
  import { Flags } from '@oclif/core';
2
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
2
+ import { DeployedStackCommand } from '../../baseCommands.js';
3
3
  import { blueprintLogsCore } from '../../cores/blueprints/logs.js';
4
- export default class LogsCommand extends DeployedBlueprintCommand {
4
+ export default class LogsCommand extends DeployedStackCommand {
5
5
  static description = 'Display logs for a Blueprint Stack deployment';
6
6
  static examples = [
7
7
  '<%= config.bin %> <%= command.id %>',
@@ -1,5 +1,5 @@
1
- import { BlueprintCommand } from '../../baseCommands.js';
2
- export default class PlanCommand extends BlueprintCommand<typeof PlanCommand> {
1
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
2
+ export default class PlanCommand extends LocalBlueprintCommand<typeof PlanCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  run(): Promise<void>;
@@ -1,6 +1,6 @@
1
- import { BlueprintCommand } from '../../baseCommands.js';
1
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
2
2
  import { blueprintPlanCore } from '../../cores/blueprints/plan.js';
3
- export default class PlanCommand extends BlueprintCommand {
3
+ export default class PlanCommand extends LocalBlueprintCommand {
4
4
  static description = 'Enumerate resources to be deployed - will not modify any resources';
5
5
  static examples = ['<%= config.bin %> <%= command.id %>'];
6
6
  async run() {
@@ -1,5 +1,5 @@
1
- import { BlueprintCommand } from '../../baseCommands.js';
2
- export default class StacksCommand extends BlueprintCommand<typeof StacksCommand> {
1
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
2
+ export default class StacksCommand extends LocalBlueprintCommand<typeof StacksCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
@@ -1,7 +1,7 @@
1
1
  import { Flags } from '@oclif/core';
2
- import { BlueprintCommand } from '../../baseCommands.js';
2
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { blueprintStacksCore } from '../../cores/blueprints/stacks.js';
4
- export default class StacksCommand extends BlueprintCommand {
4
+ export default class StacksCommand extends LocalBlueprintCommand {
5
5
  static description = 'List all Blueprint Stacks';
6
6
  static examples = [
7
7
  '<%= config.bin %> <%= command.id %>',
@@ -1,5 +1,5 @@
1
- import { BlueprintCommand } from '../../baseCommands.js';
2
- export default class AddCommand extends BlueprintCommand<typeof AddCommand> {
1
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
2
+ export default class AddCommand extends LocalBlueprintCommand<typeof AddCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
@@ -1,7 +1,7 @@
1
1
  import { Flags } from '@oclif/core';
2
- import { BlueprintCommand } from '../../baseCommands.js';
2
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { functionAddCore } from '../../cores/functions/index.js';
4
- export default class AddCommand extends BlueprintCommand {
4
+ export default class AddCommand extends LocalBlueprintCommand {
5
5
  static description = 'Add a Function to your Blueprint';
6
6
  static examples = [
7
7
  '<%= config.bin %> <%= command.id %>',
@@ -1,5 +1,5 @@
1
- import { BlueprintCommand } from '../../baseCommands.js';
2
- export default class DevCommand extends BlueprintCommand<typeof DevCommand> {
1
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
2
+ export default class DevCommand extends LocalBlueprintCommand<typeof DevCommand> {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
@@ -1,7 +1,7 @@
1
1
  import { Flags } from '@oclif/core';
2
- import { BlueprintCommand } from '../../baseCommands.js';
2
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { functionDevCore } from '../../cores/functions/dev.js';
4
- export default class DevCommand extends BlueprintCommand {
4
+ export default class DevCommand extends LocalBlueprintCommand {
5
5
  static description = 'Start the Sanity Function emulator';
6
6
  static examples = ['<%= config.bin %> <%= command.id %> --host 127.0.0.1 --port 8974'];
7
7
  static flags = {
@@ -1,5 +1,5 @@
1
- import { DeployedBlueprintCommand } from '../../../baseCommands.js';
2
- export default class EnvAddCommand extends DeployedBlueprintCommand<typeof EnvAddCommand> {
1
+ import { DeployedStackCommand } from '../../../baseCommands.js';
2
+ export default class EnvAddCommand extends DeployedStackCommand<typeof EnvAddCommand> {
3
3
  static args: {
4
4
  name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
5
  key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -1,7 +1,7 @@
1
1
  import { Args } from '@oclif/core';
2
- import { DeployedBlueprintCommand } from '../../../baseCommands.js';
2
+ import { DeployedStackCommand } from '../../../baseCommands.js';
3
3
  import { functionEnvAddCore } from '../../../cores/functions/env/add.js';
4
- export default class EnvAddCommand extends DeployedBlueprintCommand {
4
+ export default class EnvAddCommand extends DeployedStackCommand {
5
5
  static args = {
6
6
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
7
7
  key: Args.string({ description: 'The name of the environment variable', required: true }),
@@ -1,5 +1,5 @@
1
- import { DeployedBlueprintCommand } from '../../../baseCommands.js';
2
- export default class EnvListCommand extends DeployedBlueprintCommand<typeof EnvListCommand> {
1
+ import { DeployedStackCommand } from '../../../baseCommands.js';
2
+ export default class EnvListCommand extends DeployedStackCommand<typeof EnvListCommand> {
3
3
  static args: {
4
4
  name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
5
  };
@@ -1,7 +1,7 @@
1
1
  import { Args } from '@oclif/core';
2
- import { DeployedBlueprintCommand } from '../../../baseCommands.js';
2
+ import { DeployedStackCommand } from '../../../baseCommands.js';
3
3
  import { functionEnvListCore } from '../../../cores/functions/env/list.js';
4
- export default class EnvListCommand extends DeployedBlueprintCommand {
4
+ export default class EnvListCommand extends DeployedStackCommand {
5
5
  static args = {
6
6
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
7
7
  };
@@ -1,5 +1,5 @@
1
- import { DeployedBlueprintCommand } from '../../../baseCommands.js';
2
- export default class EnvRemoveCommand extends DeployedBlueprintCommand<typeof EnvRemoveCommand> {
1
+ import { DeployedStackCommand } from '../../../baseCommands.js';
2
+ export default class EnvRemoveCommand extends DeployedStackCommand<typeof EnvRemoveCommand> {
3
3
  static args: {
4
4
  name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
5
  key: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
@@ -1,7 +1,7 @@
1
1
  import { Args } from '@oclif/core';
2
- import { DeployedBlueprintCommand } from '../../../baseCommands.js';
2
+ import { DeployedStackCommand } from '../../../baseCommands.js';
3
3
  import { functionEnvRemoveCore } from '../../../cores/functions/env/remove.js';
4
- export default class EnvRemoveCommand extends DeployedBlueprintCommand {
4
+ export default class EnvRemoveCommand extends DeployedStackCommand {
5
5
  static args = {
6
6
  name: Args.string({ description: 'The name of the Sanity Function', required: true }),
7
7
  key: Args.string({ description: 'The name of the environment variable', required: true }),
@@ -1,7 +1,7 @@
1
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
2
- export default class LogsCommand extends DeployedBlueprintCommand<typeof LogsCommand> {
1
+ import { DeployedStackCommand } from '../../baseCommands.js';
2
+ export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand> {
3
3
  static args: {
4
- name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
4
+ name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
6
6
  static description: string;
7
7
  static examples: string[];
@@ -1,9 +1,9 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
2
+ import { DeployedStackCommand } from '../../baseCommands.js';
3
3
  import { functionLogsCore } from '../../cores/functions/logs.js';
4
- export default class LogsCommand extends DeployedBlueprintCommand {
4
+ export default class LogsCommand extends DeployedStackCommand {
5
5
  static args = {
6
- name: Args.string({ description: 'The name of the Sanity Function', required: true }),
6
+ name: Args.string({ description: 'The name of the Sanity Function', required: false }),
7
7
  };
8
8
  static description = 'Retrieve or delete logs for a Sanity Function';
9
9
  static examples = [
@@ -48,10 +48,12 @@ export default class LogsCommand extends DeployedBlueprintCommand {
48
48
  }),
49
49
  };
50
50
  async run() {
51
+ const { name } = this.args;
51
52
  const { success, error } = await functionLogsCore({
52
53
  bin: this.config.bin,
53
54
  log: (msg) => this.log(msg),
54
- args: this.args,
55
+ error: (msg, options) => this.error(msg, options),
56
+ args: { name },
55
57
  flags: this.flags,
56
58
  auth: this.auth,
57
59
  blueprint: this.blueprint,
@@ -60,6 +62,7 @@ export default class LogsCommand extends DeployedBlueprintCommand {
60
62
  scopeId: this.scopeId,
61
63
  token: this.sanityToken,
62
64
  stackId: this.stackId,
65
+ helpText: LogsCommand.getHelpText(this.config.bin, 'functions logs'),
63
66
  });
64
67
  if (!success)
65
68
  this.error(error);
@@ -1,7 +1,7 @@
1
- import { BlueprintCommand } from '../../baseCommands.js';
2
- export default class TestCommand extends BlueprintCommand<typeof TestCommand> {
1
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
2
+ export default class TestCommand extends LocalBlueprintCommand<typeof TestCommand> {
3
3
  static args: {
4
- name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
4
+ name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
6
6
  static description: string;
7
7
  static examples: string[];
@@ -1,9 +1,9 @@
1
1
  import { Args, Flags } from '@oclif/core';
2
- import { BlueprintCommand } from '../../baseCommands.js';
2
+ import { LocalBlueprintCommand } from '../../baseCommands.js';
3
3
  import { functionTestCore } from '../../cores/functions/test.js';
4
- export default class TestCommand extends BlueprintCommand {
4
+ export default class TestCommand extends LocalBlueprintCommand {
5
5
  static args = {
6
- name: Args.string({ description: 'The name of the Sanity Function', required: true }),
6
+ name: Args.string({ description: 'The name of the Sanity Function', required: false }),
7
7
  };
8
8
  static description = 'Invoke a local Sanity Function';
9
9
  static examples = [
@@ -151,6 +151,7 @@ export default class TestCommand extends BlueprintCommand {
151
151
  }),
152
152
  };
153
153
  async run() {
154
+ const { name } = this.args;
154
155
  if (this.flags.event === 'update') {
155
156
  const hasDataPair = this.flags['data-before'] && this.flags['data-after'];
156
157
  const hasFilePair = this.flags['file-before'] && this.flags['file-after'];
@@ -165,9 +166,11 @@ export default class TestCommand extends BlueprintCommand {
165
166
  const { success, error } = await functionTestCore({
166
167
  bin: this.config.bin,
167
168
  log: (msg) => this.log(msg),
168
- args: this.args,
169
+ error: (msg, options) => this.error(msg, options),
170
+ args: { ...this.args, name },
169
171
  flags: this.flags,
170
172
  blueprint: this.blueprint,
173
+ helpText: TestCommand.getHelpText(this.config.bin, 'functions test'),
171
174
  });
172
175
  if (!success)
173
176
  this.error(error);
@@ -1,8 +1,5 @@
1
- import type { ReadBlueprintResult } from '../../actions/blueprints/blueprint.js';
2
- import type { CoreConfig, CoreResult } from '../index.js';
3
- export interface BlueprintConfigOptions extends CoreConfig {
4
- token: string;
5
- blueprint: ReadBlueprintResult;
1
+ import type { BlueprintConfig, CoreResult } from '../index.js';
2
+ export interface BlueprintConfigOptions extends BlueprintConfig {
6
3
  flags: {
7
4
  edit?: boolean;
8
5
  'project-id'?: string;
@@ -63,7 +63,6 @@ export async function blueprintDeployCore(options) {
63
63
  ? `Failed uploading function collection ${resource.name} (${resource.functions?.length || 0} functions), deploy has stopped`
64
64
  : `Failed uploading ${resource.name} asset, deploy has stopped`;
65
65
  fnSpinner.fail(errorMsg);
66
- log(` Error: ${result.error}`);
67
66
  return { success: false, error: result.error || 'Failed to process function resource' };
68
67
  }
69
68
  }
@@ -1,8 +1,5 @@
1
- import type { ReadBlueprintResult } from '../../actions/blueprints/blueprint.js';
2
- import type { CoreConfig, CoreResult } from '../index.js';
3
- export interface BlueprintDestroyOptions extends CoreConfig {
4
- token: string;
5
- blueprint: ReadBlueprintResult;
1
+ import type { BlueprintConfig, CoreResult } from '../index.js';
2
+ export interface BlueprintDestroyOptions extends BlueprintConfig {
6
3
  flags: {
7
4
  force?: boolean;
8
5
  'project-id'?: string;
@@ -181,21 +181,31 @@ export async function blueprintDoctorCore(options) {
181
181
  }
182
182
  else if (fix) {
183
183
  if (p) {
184
- return { success: false, error: `${errorMessage}. --fix cannot be used with --path` };
184
+ return {
185
+ success: false,
186
+ error: `${errorMessage}. --fix cannot be used with --path`,
187
+ data: { diagnostics },
188
+ };
185
189
  }
186
190
  if (!tokenOrError) {
187
- return { success: false, error: `${errorMessage}. Unable to fix: Missing authentication token` };
191
+ return {
192
+ success: false,
193
+ error: `${errorMessage}. Unable to fix: Missing authentication token`,
194
+ data: { diagnostics },
195
+ };
188
196
  }
189
197
  if (tokenOrError?.ok === false) {
190
198
  return {
191
199
  success: false,
192
200
  error: `${errorMessage}. Unable to fix: ${tokenOrError.error.message}`,
201
+ data: { diagnostics },
193
202
  };
194
203
  }
195
204
  if (!blueprint) {
196
205
  return {
197
206
  success: false,
198
207
  error: `${errorMessage}. Unable to fix: Blueprint is missing or invalid`,
208
+ data: { diagnostics },
199
209
  };
200
210
  }
201
211
  return blueprintConfigCore({
@@ -3,7 +3,7 @@ import { formatDeployedResourceTree, formatStackInfo, } from '../../utils/displa
3
3
  import { niceId } from '../../utils/display/presenters.js';
4
4
  export async function blueprintInfoCore(options) {
5
5
  const { log, auth, stackId, flags, deployedStack } = options;
6
- const { id: flagStackId, verbose: _verbose = false } = flags;
6
+ const { id: flagStackId, verbose = false } = flags;
7
7
  try {
8
8
  const targetStackId = flagStackId || stackId;
9
9
  let stack = deployedStack;
@@ -20,7 +20,7 @@ export async function blueprintInfoCore(options) {
20
20
  }
21
21
  log(formatStackInfo(stack, true));
22
22
  if (stack.resources)
23
- log(formatDeployedResourceTree(stack.resources));
23
+ log(formatDeployedResourceTree(stack.resources, verbose));
24
24
  return { success: true };
25
25
  }
26
26
  catch (error) {
@@ -1,8 +1,5 @@
1
- import type { ReadBlueprintResult } from '../../actions/blueprints/blueprint.js';
2
- import type { CoreConfig, CoreResult } from '../index.js';
3
- export interface BlueprintStacksOptions extends CoreConfig {
4
- token: string;
5
- blueprint: ReadBlueprintResult;
1
+ import type { BlueprintConfig, CoreResult } from '../index.js';
2
+ export interface BlueprintStacksOptions extends BlueprintConfig {
6
3
  flags: {
7
4
  'project-id'?: string;
8
5
  'organization-id'?: string;
@@ -1,7 +1,7 @@
1
1
  import type { CoreResult, DeployedBlueprintConfig } from '../index.js';
2
2
  export interface FunctionLogsOptions extends DeployedBlueprintConfig {
3
3
  args: {
4
- name: string;
4
+ name: string | undefined;
5
5
  };
6
6
  flags: {
7
7
  limit: number;
@@ -11,5 +11,7 @@ export interface FunctionLogsOptions extends DeployedBlueprintConfig {
11
11
  force?: boolean;
12
12
  watch?: boolean;
13
13
  };
14
+ error: (message: string, options: object) => void;
15
+ helpText: string;
14
16
  }
15
17
  export declare function functionLogsCore(options: FunctionLogsOptions): Promise<CoreResult>;
@@ -4,11 +4,20 @@ import ora from 'ora';
4
4
  import { deleteLogs as deleteLogsAction, logs as getLogsAction, streamLogs as streamLogsAction, } from '../../actions/functions/logs.js';
5
5
  import { formatTitle } from '../../utils/display/blueprints-formatting.js';
6
6
  import { niceId } from '../../utils/display/presenters.js';
7
- import { findFunctionInStack } from '../../utils/find-function.js';
7
+ import { findFunctionInStack, getFunctionNames } from '../../utils/find-function.js';
8
8
  export async function functionLogsCore(options) {
9
- const { args, flags, log, auth, deployedStack } = options;
9
+ const { args, flags, log, error, auth, deployedStack, blueprint, helpText } = options;
10
10
  const { name } = args;
11
11
  const { delete: shouldDelete, watch: shouldWatch, force, limit, json, utc } = flags;
12
+ if (!name) {
13
+ const functionNames = getFunctionNames(blueprint.parsedBlueprint.resources);
14
+ const validNames = functionNames.length > 0
15
+ ? `Valid names are: ${functionNames.join(', ')}`
16
+ : 'No functions are defined in the blueprint.';
17
+ error(`Missing required argument: name\n${validNames}\n`, { exit: false });
18
+ log(helpText);
19
+ return { success: true };
20
+ }
12
21
  const { externalId } = findFunctionInStack(deployedStack, name); // throws if not found
13
22
  if (shouldDelete)
14
23
  return deleteLogs({ name, externalId, auth, force, log });
@@ -3,7 +3,7 @@ import type { CoreConfig, CoreResult } from '../index.js';
3
3
  export interface FunctionTestOptions extends CoreConfig {
4
4
  blueprint: ReadBlueprintResult;
5
5
  args: {
6
- name: string;
6
+ name: string | undefined;
7
7
  };
8
8
  flags: {
9
9
  data?: string;
@@ -24,5 +24,7 @@ export interface FunctionTestOptions extends CoreConfig {
24
24
  'document-id-after'?: string;
25
25
  'media-library-id'?: string;
26
26
  };
27
+ error: (message: string, options: object) => void;
28
+ helpText: string;
27
29
  }
28
30
  export declare function functionTestCore(options: FunctionTestOptions): Promise<CoreResult>;
@@ -6,16 +6,25 @@ import { testAction } from '../../actions/functions/test.js';
6
6
  import config from '../../config.js';
7
7
  import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET } from '../../constants.js';
8
8
  import buildPayload from '../../utils/build-payload.js';
9
- import { findFunctionInBlueprint } from '../../utils/find-function.js';
9
+ import { findFunctionInBlueprint, getFunctionNames } from '../../utils/find-function.js';
10
10
  import { fetchAsset, fetchDocument } from '../../utils/functions/fetch-document.js';
11
11
  import { parseJsonObject } from '../../utils/parse-json-object.js';
12
12
  import { isEventType, isGroqContextOptions, } from '../../utils/types.js';
13
13
  export async function functionTestCore(options) {
14
- const { blueprint, log, args, flags } = options;
14
+ const { blueprint, log, error, args, flags, helpText } = options;
15
15
  const { name: fnName } = args;
16
16
  const { data, event, file, timeout, api, dataset, 'document-id': documentId, 'with-user-token': withUserToken, 'data-before': dataBefore, 'data-after': dataAfter, 'file-before': fileBefore, 'file-after': fileAfter, 'document-id-before': documentIdBefore, 'document-id-after': documentIdAfter, 'media-library-id': mediaLibraryId, } = flags;
17
17
  const { parsedBlueprint } = blueprint;
18
18
  const { 'project-id': projectId = blueprint?.projectId, 'organization-id': organizationId = blueprint?.organizationId, } = flags;
19
+ if (!fnName) {
20
+ const functionNames = getFunctionNames(blueprint.parsedBlueprint.resources);
21
+ const validNames = functionNames.length > 0
22
+ ? `Valid names are: ${functionNames.join(', ')}`
23
+ : 'No functions are defined in the blueprint.';
24
+ error(`Missing required argument: name\n${validNames}\n`, { exit: false });
25
+ log(helpText);
26
+ return { success: true };
27
+ }
19
28
  let eventType;
20
29
  if (!event) {
21
30
  eventType = 'create';
@@ -747,9 +747,6 @@ body {
747
747
  header {
748
748
  grid-area: header;
749
749
  }
750
- filters-component {
751
- grid-area: filters;
752
- }
753
750
  nav {
754
751
  grid-area: left-sidebar;
755
752
  }
@@ -763,36 +760,6 @@ footer {
763
760
  grid-area: footer;
764
761
  }
765
762
 
766
- /* Add styles for filters-component form */
767
- /* Default (Mobile) Styles */
768
- filters-component form {
769
- display: block; /* Stack direct children */
770
- padding: var(--m-space-3); /* Consistent padding */
771
- border-bottom: 1px solid var(--card-border-color);
772
- }
773
-
774
- filters-component form > * {
775
- /* Target direct children: dropdowns, fieldset */
776
- display: block; /* Ensure they are block level */
777
- width: 100%; /* Make them take full width */
778
- margin-bottom: var(--m-space-3); /* Add space below each item when stacked */
779
- }
780
-
781
- filters-component form > *:last-child {
782
- margin-bottom: 0; /* Remove margin from the last stacked item */
783
- }
784
-
785
- filters-component form label {
786
- display: block; /* Ensure label stacks above input if needed */
787
- margin-bottom: var(--m-space-1); /* Small space between label and input */
788
- }
789
-
790
- filters-component form input {
791
- width: 100%; /* Make input fill its container */
792
- box-sizing: border-box; /* Include padding/border in width calculation */
793
- }
794
- /* End of Mobile Styles */
795
-
796
763
  /* Apply grid styles to main#main-content */
797
764
  #main-content {
798
765
  display: grid;
@@ -808,26 +775,6 @@ filters-component form input {
808
775
  min-height: 0; /* Important for nested overflow/height */
809
776
  }
810
777
 
811
- payload-panel {
812
- grid-area: payload;
813
- max-height: 100%; /* Fit within allocated grid row space */
814
- overflow: hidden; /* Let internal elements scroll */
815
- min-height: 0; /* Allow shrinking */
816
- }
817
-
818
- response-panel {
819
- grid-area: response;
820
- max-height: 100%;
821
- overflow: hidden;
822
- min-height: 0;
823
- }
824
-
825
- /* Target console-panel for grid area and height constraints */
826
- console-panel {
827
- grid-area: console;
828
- overflow: hidden; /* The inner div handles scrolling */
829
- }
830
-
831
778
  @media (max-width: 40rem) {
832
779
  /* Mobile layout: stack elements vertically */
833
780
  #main-content {
@@ -843,20 +790,6 @@ console-panel {
843
790
  overflow-y: auto; /* Allow scrolling for the whole main area */
844
791
  }
845
792
 
846
- /* Reset max-heights on mobile if they cause layout issues */
847
- payload-panel,
848
- response-panel,
849
- console-panel {
850
- max-height: none;
851
- min-height: 200px; /* Give some minimum space on mobile */
852
- overflow: auto; /* Allow individual scrolling if content is large */
853
- }
854
-
855
- /* Ensure console has reasonable height on mobile */
856
- console-panel {
857
- max-height: 400px; /* Allow more console height on mobile maybe */
858
- }
859
-
860
793
  .block-lg {
861
794
  display: block !important;
862
795
  }
@@ -878,27 +811,6 @@ console-panel {
878
811
  .border-top-none-l {
879
812
  border-top: 0;
880
813
  }
881
-
882
- /* Revert filters-component form to horizontal layout on larger screens */
883
- filters-component form {
884
- display: flex;
885
- flex-direction: row;
886
- align-items: flex-end; /* Align form elements along their bottom edge */
887
- gap: var(--m-space-3); /* Space between elements */
888
- padding-left: var(--m-space-3);
889
- padding-bottom: var(--m-space-3);
890
- }
891
-
892
- filters-component form > * {
893
- width: auto; /* Allow elements to size based on content/flex rules */
894
- margin-bottom: 0; /* Remove stacking margin */
895
- }
896
-
897
- /* Optional: Give API version input a specific width or allow growth */
898
- filters-component form fieldset {
899
- min-width: 150px; /* Example minimum width */
900
- /* flex-grow: 1; */ /* Uncomment to allow it to fill space */
901
- }
902
814
  }
903
815
 
904
816
  header {
@@ -1088,34 +1000,6 @@ time {
1088
1000
  font-family: var(--font-family-mono);
1089
1001
  }
1090
1002
 
1091
- response-panel,
1092
- payload-panel {
1093
- max-height: 100%;
1094
- height: 100%;
1095
- overflow: hidden;
1096
- }
1097
-
1098
- toggle-switch {
1099
- display: inline-block;
1100
- cursor: pointer;
1101
- }
1102
-
1103
- toggle-switch::part(track) {
1104
- padding: 0.125em;
1105
- border-radius: 1em;
1106
- background-color: hsl(0, 0%, 67%);
1107
- }
1108
-
1109
- toggle-switch::part(slider) {
1110
- border-radius: 1em;
1111
- background-color: hsl(0, 0%, 100%);
1112
- box-shadow: 0.0625em 0.0625em 0.125em hsla(0, 0%, 0%, 0.25);
1113
- }
1114
-
1115
- toggle-switch[checked]::part(track) {
1116
- background-color: var(--color-interactive-primary-active-bg);
1117
- }
1118
-
1119
1003
  /* Default sidebar */
1120
1004
  #sidebar {
1121
1005
  transition: