@sanity/workflows-cli 0.0.0 → 0.39.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 (80) hide show
  1. package/CHANGELOG.md +407 -0
  2. package/README.md +95 -44
  3. package/dist/commands/workflows/codemod/packages.js +2 -2
  4. package/dist/commands/workflows/definitions/delete.js +2 -2
  5. package/dist/commands/workflows/definitions/list.d.ts +1 -0
  6. package/dist/commands/workflows/definitions/show.d.ts +1 -0
  7. package/dist/commands/workflows/definitions/validate.js +3 -3
  8. package/dist/commands/workflows/deploy.d.ts +2 -2
  9. package/dist/commands/workflows/deploy.js +4 -4
  10. package/dist/commands/workflows/diagnose.d.ts +1 -0
  11. package/dist/commands/workflows/diagnose.js +2 -2
  12. package/dist/commands/workflows/fire-action.js +3 -3
  13. package/dist/commands/workflows/list.d.ts +1 -0
  14. package/dist/commands/workflows/list.js +2 -1
  15. package/dist/commands/workflows/nuke.js +2 -3
  16. package/dist/commands/workflows/show.d.ts +1 -0
  17. package/dist/commands/workflows/start.js +6 -6
  18. package/dist/commands/workflows/tail.d.ts +1 -0
  19. package/dist/commands/workflows/tail.js +3 -3
  20. package/dist/commands/workflows/whoami.d.ts +1 -0
  21. package/dist/commands/workflows/whoami.js +11 -11
  22. package/dist/hooks/finally/telemetry.js +2 -1
  23. package/dist/hooks/prerun/telemetry.d.ts +5 -0
  24. package/dist/hooks/prerun/telemetry.js +19 -4
  25. package/dist/lib/base-command.d.ts +3 -3
  26. package/dist/lib/base-command.js +12 -5
  27. package/dist/lib/blueprint-needs.d.ts +1 -1
  28. package/dist/lib/blueprint-needs.js +98 -19
  29. package/dist/lib/blueprint-stacks.js +38 -8
  30. package/dist/lib/client.d.ts +4 -1
  31. package/dist/lib/client.js +9 -4
  32. package/dist/lib/codemod/ast.d.ts +17 -0
  33. package/dist/lib/codemod/ast.js +14 -0
  34. package/dist/lib/codemod/export-rename.d.ts +19 -0
  35. package/dist/lib/codemod/export-rename.js +337 -0
  36. package/dist/lib/codemod/manifest-rewrite.d.ts +5 -2
  37. package/dist/lib/codemod/manifest-rewrite.js +57 -21
  38. package/dist/lib/codemod/package-map.d.ts +5 -0
  39. package/dist/lib/codemod/package-map.js +27 -0
  40. package/dist/lib/codemod/report.d.ts +0 -1
  41. package/dist/lib/codemod/report.js +9 -1
  42. package/dist/lib/codemod/run.d.ts +5 -3
  43. package/dist/lib/codemod/run.js +6 -1
  44. package/dist/lib/codemod/source-rewrite.d.ts +6 -4
  45. package/dist/lib/codemod/source-rewrite.js +12 -17
  46. package/dist/lib/context.d.ts +6 -10
  47. package/dist/lib/context.js +18 -23
  48. package/dist/lib/default-partition.js +2 -3
  49. package/dist/lib/definition-files.d.ts +3 -0
  50. package/dist/lib/definition-files.js +5 -3
  51. package/dist/lib/fail.d.ts +8 -1
  52. package/dist/lib/fail.js +16 -7
  53. package/dist/lib/failure-kind.d.ts +7 -0
  54. package/dist/lib/failure-kind.js +66 -0
  55. package/dist/lib/flags.d.ts +7 -3
  56. package/dist/lib/flags.js +16 -6
  57. package/dist/lib/load-config.d.ts +5 -0
  58. package/dist/lib/load-config.js +4 -6
  59. package/dist/lib/nuke.d.ts +4 -4
  60. package/dist/lib/nuke.js +3 -3
  61. package/dist/lib/operation-args.d.ts +4 -4
  62. package/dist/lib/operation-args.js +1 -1
  63. package/dist/lib/ops-report.d.ts +1 -3
  64. package/dist/lib/ops-report.js +2 -2
  65. package/dist/lib/pick-resource.d.ts +13 -0
  66. package/dist/lib/pick-resource.js +82 -0
  67. package/dist/lib/read-fanout.d.ts +4 -4
  68. package/dist/lib/read-fanout.js +5 -4
  69. package/dist/lib/resource-target.d.ts +10 -0
  70. package/dist/lib/resource-target.js +12 -0
  71. package/dist/lib/telemetry-setup.d.ts +20 -24
  72. package/dist/lib/telemetry-setup.js +36 -30
  73. package/dist/lib/telemetry.d.ts +3 -0
  74. package/dist/lib/telemetry.js +2 -2
  75. package/dist/lib/ui.d.ts +1 -4
  76. package/dist/lib/ui.js +2 -4
  77. package/oclif.manifest.json +189 -26
  78. package/package.json +5 -5
  79. package/dist/lib/pick-dataset.d.ts +0 -10
  80. package/dist/lib/pick-dataset.js +0 -30
@@ -0,0 +1,82 @@
1
+ import { styleText } from 'node:util';
2
+ import { isResourceType, RESOURCE_TYPES, resourceGdr, resourceLabel, resourceListPath, } from '@sanity/workflows';
3
+ import logSymbols from 'log-symbols';
4
+ import { globalClient } from './client.js';
5
+ import { fail } from './fail.js';
6
+ import { selectOnStderr } from './prompt.js';
7
+ export const RESOURCE_FLAGS_HINT = 'Pass --workflow-resource <type>:<id> (or --project-id with --dataset) to read one resource without a config.';
8
+ export async function pickResource(token, { client = globalClient(token), select = selectOnStderr, } = {}) {
9
+ const type = await select({
10
+ message: 'Select a resource type to read',
11
+ choices: RESOURCE_TYPES.map((value) => ({ name: capitalized(resourceLabel(value)), value })),
12
+ });
13
+ const resource = await pickOfType({ client, select, type: requireListedType(type) });
14
+ process.stderr.write(`${logSymbols.info} To read this resource again without the prompt, pass: ${styleText('bold', `--workflow-resource ${resourceGdr(resource)}`)}\n`);
15
+ return resource;
16
+ }
17
+ function capitalized(text) {
18
+ return `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
19
+ }
20
+ function requireListedType(value) {
21
+ if (!isResourceType(value))
22
+ throw new Error(`Unexpected resource type choice "${value}".`);
23
+ return value;
24
+ }
25
+ function pickOfType({ client, select, type, }) {
26
+ const listPath = resourceListPath(type);
27
+ return listPath === undefined
28
+ ? pickDataset(client, select)
29
+ : pickListed({ client, select, type, listPath });
30
+ }
31
+ async function pickListed({ client, select, type, listPath, }) {
32
+ const label = resourceLabel(type);
33
+ const ids = listedIds(await client.request({ url: listPath }), listPath);
34
+ if (ids.length === 0) {
35
+ fail(`No ${label} resources found for this login.`, RESOURCE_FLAGS_HINT);
36
+ }
37
+ const id = await select({
38
+ message: `Select a ${label} to read`,
39
+ choices: ids.map((value) => ({ name: value, value })),
40
+ });
41
+ return { type, id };
42
+ }
43
+ function listRows(answer) {
44
+ if (typeof answer !== 'object' || answer === null || !('data' in answer))
45
+ return undefined;
46
+ return Array.isArray(answer.data) ? answer.data : undefined;
47
+ }
48
+ function rowId(row) {
49
+ return typeof row === 'object' && row !== null && 'id' in row && typeof row.id === 'string'
50
+ ? row.id
51
+ : undefined;
52
+ }
53
+ export function listedIds(answer, listPath) {
54
+ const ids = listRows(answer)?.map(rowId);
55
+ if (ids === undefined || ids.includes(undefined)) {
56
+ throw new Error(`${listPath} answered with something other than a {data: [{id}]} list.`);
57
+ }
58
+ return ids.filter((id) => id !== undefined);
59
+ }
60
+ async function pickDataset(client, select) {
61
+ const projects = await client.projects.list({ includeMembers: false });
62
+ if (projects.length === 0) {
63
+ fail('No Sanity projects found for this login.', RESOURCE_FLAGS_HINT);
64
+ }
65
+ const projectId = await select({
66
+ message: 'Select a project to read',
67
+ choices: projects.map((project) => ({
68
+ name: project.displayName,
69
+ value: project.id,
70
+ description: project.id,
71
+ })),
72
+ });
73
+ const datasets = await client.withConfig({ projectId }).datasets.list();
74
+ if (datasets.length === 0) {
75
+ fail(`Project ${projectId} has no datasets.`, RESOURCE_FLAGS_HINT);
76
+ }
77
+ const dataset = await select({
78
+ message: 'Select a dataset to read',
79
+ choices: datasets.map(({ name }) => ({ name, value: name })),
80
+ });
81
+ return { type: 'dataset', id: `${projectId}.${dataset}` };
82
+ }
@@ -1,4 +1,4 @@
1
- import type { WorkflowResource } from '@sanity/workflows';
1
+ import { type WorkflowResource } from '@sanity/workflows';
2
2
  import type { ReadTarget } from './context.ts';
3
3
  /** A read target whose query threw — noted in place and reflected in the
4
4
  * command's exit code. */
@@ -34,9 +34,9 @@ export declare function logJsonListing<T, R>({ targets, fetch, toRow, key, limit
34
34
  * the read spans several, then whatever `run` logs for that target. A throw
35
35
  * from one target is noted under its banner and the rest still render — a
36
36
  * token that can't read one dataset must not sink the whole listing. A
37
- * single-target run rethrows instead, keeping the plain unprefixed output
38
- * and clean error rendering at the command boundary. Callers exit non-zero
39
- * when failures come back.
37
+ * single-target run fails the command instead, naming the resource it read
38
+ * and keeping the error as the cause. Callers exit non-zero when failures
39
+ * come back.
40
40
  */
41
41
  export declare function runReadAcrossTargets({ targets, log, run, }: {
42
42
  targets: ReadTarget[];
@@ -1,6 +1,7 @@
1
+ import { describeResource } from '@sanity/workflows';
1
2
  import logSymbols from 'log-symbols';
2
- import { failureDetail } from './fail.js';
3
- import { clipToLimit, groupBanner, resourceLabel } from './ui.js';
3
+ import { failOn, failureDetail } from './fail.js';
4
+ import { clipToLimit, groupBanner } from './ui.js';
4
5
  export async function logJsonListing({ targets, fetch, toRow, key, limit, log, }) {
5
6
  const fetched = await Promise.all(targets.map(async (target) => {
6
7
  const { rows, hasMore } = await fetch(target);
@@ -21,7 +22,7 @@ export async function runReadAcrossTargets({ targets, log, run, }) {
21
22
  const failures = [];
22
23
  for (const [index, target] of targets.entries()) {
23
24
  const banner = groupBanner({
24
- label: resourceLabel(target.resource),
25
+ label: describeResource(target.resource),
25
26
  index,
26
27
  total: targets.length,
27
28
  });
@@ -33,7 +34,7 @@ export async function runReadAcrossTargets({ targets, log, run, }) {
33
34
  }
34
35
  catch (error) {
35
36
  if (targets.length === 1) {
36
- throw error;
37
+ failOn(error, `Could not read ${describeResource(target.resource)}:`);
37
38
  }
38
39
  const message = failureDetail(error);
39
40
  failures.push({ resource: target.resource, message });
@@ -0,0 +1,10 @@
1
+ import { type WorkflowResource } from '@sanity/workflows';
2
+ export interface ResourceTargetFlags {
3
+ 'workflow-resource'?: WorkflowResource | undefined;
4
+ 'project-id'?: string | undefined;
5
+ dataset?: string | undefined;
6
+ 'media-library-id'?: string | undefined;
7
+ }
8
+ /** The one resource the resource flags name, or `undefined` to read the
9
+ * resources `sanity.workflow.ts` declares. */
10
+ export declare function explicitResource(flags: ResourceTargetFlags): WorkflowResource | undefined;
@@ -0,0 +1,12 @@
1
+ import { parseResourceGdr } from '@sanity/workflows';
2
+ export function explicitResource(flags) {
3
+ if (flags['workflow-resource'] !== undefined)
4
+ return flags['workflow-resource'];
5
+ if (flags['media-library-id'] !== undefined) {
6
+ return parseResourceGdr(`media-library:${flags['media-library-id']}`);
7
+ }
8
+ if (flags['project-id'] !== undefined && flags.dataset !== undefined) {
9
+ return { type: 'dataset', id: `${flags['project-id']}.${flags.dataset}` };
10
+ }
11
+ return undefined;
12
+ }
@@ -1,6 +1,6 @@
1
1
  /** Discovery is deliberately soft: telemetry must never break or exit a
2
2
  * command — a missing/broken config, token, or dataset just leaves it off. */
3
- import { processShellUserProperties, type TelemetryIntakeClient } from '@sanity/workflows';
3
+ import { processShellUserProperties, type TelemetryIntakeClient, type WorkflowResource } from '@sanity/workflows';
4
4
  import { type WorkflowCliCommandContext } from './command-context.ts';
5
5
  /** The get/set slice of the shared Sanity user config (cli-core's
6
6
  * `getUserConfig`) the shell persists flags into — narrow so tests fake
@@ -18,23 +18,16 @@ export declare function maybeShowTelemetryDisclosure(args: {
18
18
  userConfig: UserConfigStore;
19
19
  writeStderr: (message: string) => void;
20
20
  }): void;
21
- /** The project a run's events are attributed to. */
22
- export interface TelemetryProject {
23
- projectId: string;
24
- dataset?: string | undefined;
25
- }
26
- type TelemetryTarget = {
27
- projectId?: string | undefined;
28
- dataset?: string | undefined;
29
- };
30
21
  /**
31
22
  * Assemble and install the invocation's shell: a config-provided
32
23
  * `telemetry` logger replaces the built-in shell wholesale (none of its
33
24
  * policy applies); otherwise the built-in Sanity-intake store is
34
25
  * constructed whenever an auth token exists, with or without a config —
35
26
  * mirroring the standard recipe's "not logged in → nothing sent". Events
36
- * are attributed to the `--project-id` the run names, else the config's
37
- * first dataset deployment, else to no project.
27
+ * are attributed to the resource the run's flags name, else to the resource
28
+ * of the deployment `--deployment` names, else (without `--deployment`) to
29
+ * the config's first deployment's resource, else to no resource. The intake
30
+ * project is that resource's project when it lives in one.
38
31
  *
39
32
  * The optional args exist for the hook's dependencies (config path, environment,
40
33
  * user config, stderr) — omitted, the real process surfaces apply.
@@ -42,8 +35,10 @@ type TelemetryTarget = {
42
35
  export declare function setupCliTelemetry(args?: {
43
36
  /** The command's `--path`; omitted, the search starts in the working directory. */
44
37
  configPath?: string | undefined;
45
- /** The command's `--project-id` and `--dataset`, which win over the config's project. */
46
- target?: TelemetryTarget;
38
+ /** The resource the command's resource flags name, which wins over the config's. */
39
+ target?: WorkflowResource | undefined;
40
+ /** The command's `--deployment`, whose resource the config fallback reads. */
41
+ deployment?: string | undefined;
47
42
  env?: Record<string, string | undefined>;
48
43
  userConfig?: UserConfigStore;
49
44
  writeStderr?: (message: string) => void;
@@ -60,22 +55,23 @@ export declare function setupCliTelemetry(args?: {
60
55
  context?: WorkflowCliCommandContext;
61
56
  }): Promise<void>;
62
57
  /**
63
- * The invocation's environment user properties — the sanity CLI's precedent
64
- * set (versions, platform, runtime, and project coordinates when a project is
65
- * known). `orgId` — which
66
- * Studio's shell sends and the sanity CLI doesn't yet — attaches separately
67
- * once {@link resolveOrgId} resolves. Joined to the session's events by
68
- * sessionId downstream; user identity stays sink-side.
58
+ * The invocation's environment user properties: the sanity CLI's precedent
59
+ * set (versions, platform, runtime), the resource the run reads or writes as
60
+ * `resourceType` and `resourceId`, and a dataset's `projectId` and `dataset`
61
+ * coordinates. `orgId`, which Studio's shell sends and the sanity CLI does not
62
+ * yet, attaches separately once {@link resolveOrgId} resolves. Joined to the
63
+ * session's events by sessionId downstream; user identity stays sink-side.
69
64
  */
70
65
  export declare function cliUserProperties(args: {
71
- project: TelemetryProject | undefined;
66
+ resource: WorkflowResource | undefined;
72
67
  cliVersion: string | undefined;
73
68
  }): ReturnType<typeof processShellUserProperties> & {
74
69
  cliVersion?: string;
70
+ resourceType?: WorkflowResource['type'];
71
+ resourceId?: string;
75
72
  projectId?: string;
76
73
  dataset?: string;
77
74
  };
78
- /** The intake project's organization id — degrade-soft: a failed, slow, or
75
+ /** The organization that owns the run's resource. Degrade-soft: a failed, slow, or
79
76
  * org-less lookup resolves undefined, never rejects, never breaks a command. */
80
- export declare function resolveOrgId(client: TelemetryIntakeClient, projectId: string): Promise<string | undefined>;
81
- export {};
77
+ export declare function resolveOrgId(client: TelemetryIntakeClient, resource: WorkflowResource): Promise<string | undefined>;
@@ -1,6 +1,6 @@
1
1
  import { styleText } from 'node:util';
2
2
  import { getUserConfig } from '@sanity/cli-core';
3
- import { datasetResourceParts, processShellUserProperties, } from '@sanity/workflows';
3
+ import { _requestResourceOrganizationId, clientConfigFromResource, processShellUserProperties, } from '@sanity/workflows';
4
4
  import boxen from 'boxen';
5
5
  import { globalClient, resolveToken } from './client.js';
6
6
  import { commandTraceContext } from './command-context.js';
@@ -21,11 +21,11 @@ To opt in/out, run ${styleText('cyan', 'npx sanity telemetry enable/disable')}.
21
21
  Learn more: https://www.sanity.io/telemetry`, { borderColor: 'yellow', borderStyle: 'round', margin: 1, padding: 1 })}\n`);
22
22
  userConfig.set(DISCLOSURE_KEY, Date.now());
23
23
  }
24
- function configProject(config) {
25
- const resource = config?.deployments
26
- .map((deployment) => deployment.workflowResource)
27
- .find((candidate) => candidate.type === 'dataset');
28
- return resource === undefined ? undefined : datasetResourceParts(resource.id);
24
+ function configResource(config, deployment) {
25
+ const deployments = config?.deployments ?? [];
26
+ if (deployment === undefined)
27
+ return deployments[0]?.workflowResource;
28
+ return deployments.find(({ name }) => name === deployment)?.workflowResource;
29
29
  }
30
30
  export async function setupCliTelemetry(args) {
31
31
  const env = args?.env ?? process.env;
@@ -47,36 +47,25 @@ export async function setupCliTelemetry(args) {
47
47
  if (token === undefined) {
48
48
  return;
49
49
  }
50
- const project = targetProject(args?.target) ?? configProject(config);
50
+ const resource = args?.target ?? configResource(config, args?.deployment);
51
51
  const client = args?.client ?? globalClient(token);
52
52
  const telemetry = createBuiltinTelemetry({
53
53
  client,
54
- projectId: project?.projectId,
54
+ projectId: resource === undefined ? undefined : resourceProperties(resource).projectId,
55
55
  env,
56
56
  forceSend: args?.forceSend ?? false,
57
57
  packageVersion: args?.cliVersion,
58
58
  });
59
59
  setCliTelemetry(telemetry, context);
60
- attachBuiltinContext({ telemetry, project, client, deps: args });
60
+ attachBuiltinContext({ telemetry, resource, client, deps: args });
61
61
  }
62
62
  catch {
63
63
  }
64
64
  }
65
- function targetProject(target) {
66
- return target?.projectId === undefined
67
- ? undefined
68
- : { projectId: target.projectId, dataset: target.dataset };
69
- }
70
65
  function attachBuiltinContext(args) {
71
- const { telemetry, project, client, deps } = args;
66
+ const { telemetry, resource, client, deps } = args;
72
67
  if (!telemetry.envDenied || telemetry.forceSend) {
73
- telemetry.store.logger.updateUserProperties(cliUserProperties({ project, cliVersion: deps?.cliVersion }));
74
- if (project !== undefined) {
75
- void resolveOrgId(client, project.projectId).then((orgId) => {
76
- if (orgId !== undefined)
77
- telemetry.store.logger.updateUserProperties({ orgId });
78
- });
79
- }
68
+ attachResourceContext({ telemetry, resource, client, cliVersion: deps?.cliVersion });
80
69
  }
81
70
  if (!telemetry.envDenied) {
82
71
  maybeShowTelemetryDisclosure({
@@ -85,25 +74,42 @@ function attachBuiltinContext(args) {
85
74
  });
86
75
  }
87
76
  }
77
+ function attachResourceContext(args) {
78
+ const { telemetry, resource, client, cliVersion } = args;
79
+ telemetry.store.logger.updateUserProperties(cliUserProperties({ resource, cliVersion }));
80
+ if (resource === undefined)
81
+ return;
82
+ void resolveOrgId(client, resource).then((orgId) => {
83
+ if (orgId !== undefined)
84
+ telemetry.store.logger.updateUserProperties({ orgId });
85
+ return undefined;
86
+ });
87
+ }
88
88
  const ORG_LOOKUP_DEADLINE_MS = 2_000;
89
89
  const CONTEXT_TAG = 'telemetry.context';
90
90
  export function cliUserProperties(args) {
91
- const { project, cliVersion } = args;
91
+ const { resource, cliVersion } = args;
92
92
  return {
93
93
  ...processShellUserProperties('cli'),
94
94
  ...(cliVersion !== undefined ? { cliVersion } : {}),
95
- ...(project !== undefined ? { projectId: project.projectId } : {}),
96
- ...(project?.dataset !== undefined ? { dataset: project.dataset } : {}),
95
+ ...(resource === undefined ? {} : resourceProperties(resource)),
96
+ };
97
+ }
98
+ function resourceProperties(resource) {
99
+ const address = clientConfigFromResource(resource);
100
+ return {
101
+ resourceType: resource.type,
102
+ resourceId: resource.id,
103
+ ...('dataset' in address ? { projectId: address.projectId, dataset: address.dataset } : {}),
97
104
  };
98
105
  }
99
- export async function resolveOrgId(client, projectId) {
106
+ export async function resolveOrgId(client, resource) {
100
107
  try {
101
- const project = await raceWithDeadline(client.request({
102
- url: `/projects/${encodeURIComponent(projectId)}`,
108
+ return await raceWithDeadline(_requestResourceOrganizationId({
109
+ request: (options) => client.request({ ...options, timeout: ORG_LOOKUP_DEADLINE_MS }),
110
+ resource,
103
111
  tag: CONTEXT_TAG,
104
- timeout: ORG_LOOKUP_DEADLINE_MS,
105
112
  }), ORG_LOOKUP_DEADLINE_MS);
106
- return project?.organizationId ?? undefined;
107
113
  }
108
114
  catch {
109
115
  return undefined;
@@ -3,8 +3,11 @@
3
3
  import { type DefinedTelemetryTrace, type TelemetryStore } from '@sanity/telemetry';
4
4
  import { type DerivedEventData, type TelemetryIntakeClient, type WorkflowDefinitionDeployedData, type WorkflowTelemetryLogger } from '@sanity/workflows';
5
5
  import type { WorkflowCliCommandContext } from './command-context.ts';
6
+ import type { CliFailureKind } from './failure-kind.ts';
6
7
  export interface WorkflowCliCommandResult {
7
8
  success: boolean;
9
+ /** Present only when `success` is false. */
10
+ failureKind?: CliFailureKind;
8
11
  }
9
12
  export declare const WorkflowCliCommandExecuted: DefinedTelemetryTrace<WorkflowCliCommandResult, void>;
10
13
  export type WorkflowDefinitionSharedData = Omit<DerivedEventData<WorkflowDefinitionDeployedData>, 'status'>;
@@ -2,8 +2,8 @@ import { createBatchedStore, createSessionId, defineEvent, defineTrace, } from '
2
2
  import { createTelemetryIntake, _resolveTelemetryEnvironment, isTelemetryEnvDenied, noopTelemetry, } from '@sanity/workflows';
3
3
  export const WorkflowCliCommandExecuted = defineTrace({
4
4
  name: 'Workflows CLI Command Executed',
5
- version: 2,
6
- description: 'A Workflows CLI command was executed — the trace context carries the command path and each flag used in canonical long form (an option flag as `--name=value`, a boolean as `--name` or `--no-name`, a redacted or undeclared flag as its name only), and the payload carries a success flag',
5
+ version: 3,
6
+ description: 'A Workflows CLI command was executed — the trace context carries the command path and each flag used in canonical long form (an option flag as `--name=value`, a boolean as `--name` or `--no-name`, a redacted or undeclared flag as its name only), and the payload carries a success flag plus, on failure, a closed failure kind (an engine error kind, or usage, auth-missing, permission-denied, resource-not-found, request-failed, config-invalid, definition-file-invalid, or other)',
7
7
  });
8
8
  export const WorkflowDefinitionShared = defineEvent({
9
9
  name: 'Workflows CLI Definition Shared',
package/dist/lib/ui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { styleText } from 'node:util';
2
- import type { ActivityStatus, WorkflowResource } from '@sanity/workflows';
2
+ import { type ActivityStatus, type WorkflowResource } from '@sanity/workflows';
3
3
  /**
4
4
  * A bold `Title:` section heading. Mirrors the Sanity CLI's `sectionHeader`
5
5
  * (name + shape) so it folds into the shared helper when this CLI merges in.
@@ -75,9 +75,6 @@ export declare function groupBanner({ label, index, total, }: {
75
75
  index: number;
76
76
  total: number;
77
77
  }): string | undefined;
78
- /** A workflow resource as a display label: a dataset's `project.dataset` id
79
- * reads naturally bare; other resource types keep their type for clarity. */
80
- export declare function resourceLabel(resource: WorkflowResource): string;
81
78
  /** Where a read looked, for an empty result: `in partition prod of acme.workflows (deployment prod)`. */
82
79
  export declare function searchedScope(args: {
83
80
  partition: string | undefined;
package/dist/lib/ui.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { stripVTControlCharacters, styleText } from 'node:util';
2
+ import { describeResource } from '@sanity/workflows';
2
3
  import logSymbols from 'log-symbols';
3
4
  import wrapAnsi from 'wrap-ansi';
4
5
  export function sectionHeader(title) {
@@ -97,13 +98,10 @@ export function groupBanner({ label, index, total, }) {
97
98
  const gap = index > 0 ? '\n' : '';
98
99
  return `${gap}${styleText('bold', `▸ ${label}`)}`;
99
100
  }
100
- export function resourceLabel(resource) {
101
- return resource.type === 'dataset' ? resource.id : `${resource.type}:${resource.id}`;
102
- }
103
101
  export function searchedScope(args) {
104
102
  const partition = args.partition === undefined ? 'any partition' : `partition ${args.partition}`;
105
103
  const deployment = args.deployment === undefined ? '' : ` (deployment ${args.deployment})`;
106
- return `in ${partition} of ${args.resources.map(resourceLabel).join(', ')}${deployment}`;
104
+ return `in ${partition} of ${args.resources.map(describeResource).join(', ')}${deployment}`;
107
105
  }
108
106
  export const activityIcon = {
109
107
  done: logSymbols.success,