monday-cli 0.4.0 → 0.5.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/CHANGELOG.md +368 -0
- package/README.md +112 -34
- package/dist/api/column-types.d.ts +3 -1
- package/dist/api/column-types.d.ts.map +1 -1
- package/dist/api/column-types.js +3 -1
- package/dist/api/column-types.js.map +1 -1
- package/dist/api/column-values.d.ts +5 -4
- package/dist/api/column-values.d.ts.map +1 -1
- package/dist/api/column-values.js +6 -5
- package/dist/api/column-values.js.map +1 -1
- package/dist/api/documents.d.ts +1136 -3
- package/dist/api/documents.d.ts.map +1 -1
- package/dist/api/documents.js +1828 -3
- package/dist/api/documents.js.map +1 -1
- package/dist/api/raw-write.d.ts +6 -5
- package/dist/api/raw-write.d.ts.map +1 -1
- package/dist/api/raw-write.js +7 -6
- package/dist/api/raw-write.js.map +1 -1
- package/dist/api/teams.d.ts +657 -0
- package/dist/api/teams.d.ts.map +1 -0
- package/dist/api/teams.js +880 -0
- package/dist/api/teams.js.map +1 -0
- package/dist/commands/doc/append-markdown.d.ts +117 -0
- package/dist/commands/doc/append-markdown.d.ts.map +1 -0
- package/dist/commands/doc/append-markdown.js +253 -0
- package/dist/commands/doc/append-markdown.js.map +1 -0
- package/dist/commands/doc/block-create.d.ts +114 -0
- package/dist/commands/doc/block-create.d.ts.map +1 -0
- package/dist/commands/doc/block-create.js +206 -0
- package/dist/commands/doc/block-create.js.map +1 -0
- package/dist/commands/doc/block-delete.d.ts +72 -0
- package/dist/commands/doc/block-delete.d.ts.map +1 -0
- package/dist/commands/doc/block-delete.js +161 -0
- package/dist/commands/doc/block-delete.js.map +1 -0
- package/dist/commands/doc/block-update.d.ts +75 -0
- package/dist/commands/doc/block-update.d.ts.map +1 -0
- package/dist/commands/doc/block-update.js +162 -0
- package/dist/commands/doc/block-update.js.map +1 -0
- package/dist/commands/doc/create-in-workspace.d.ts +76 -0
- package/dist/commands/doc/create-in-workspace.d.ts.map +1 -0
- package/dist/commands/doc/create-in-workspace.js +164 -0
- package/dist/commands/doc/create-in-workspace.js.map +1 -0
- package/dist/commands/doc/create-on-column.d.ts +71 -0
- package/dist/commands/doc/create-on-column.d.ts.map +1 -0
- package/dist/commands/doc/create-on-column.js +146 -0
- package/dist/commands/doc/create-on-column.js.map +1 -0
- package/dist/commands/doc/delete.d.ts +68 -0
- package/dist/commands/doc/delete.d.ts.map +1 -0
- package/dist/commands/doc/delete.js +146 -0
- package/dist/commands/doc/delete.js.map +1 -0
- package/dist/commands/doc/duplicate.d.ts +101 -0
- package/dist/commands/doc/duplicate.d.ts.map +1 -0
- package/dist/commands/doc/duplicate.js +191 -0
- package/dist/commands/doc/duplicate.js.map +1 -0
- package/dist/commands/doc/import-html.d.ts +125 -0
- package/dist/commands/doc/import-html.d.ts.map +1 -0
- package/dist/commands/doc/import-html.js +273 -0
- package/dist/commands/doc/import-html.js.map +1 -0
- package/dist/commands/doc/list.d.ts +6 -3
- package/dist/commands/doc/list.d.ts.map +1 -1
- package/dist/commands/doc/list.js +17 -48
- package/dist/commands/doc/list.js.map +1 -1
- package/dist/commands/doc/rename.d.ts +60 -0
- package/dist/commands/doc/rename.d.ts.map +1 -0
- package/dist/commands/doc/rename.js +135 -0
- package/dist/commands/doc/rename.js.map +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +116 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/item/create.js +2 -2
- package/dist/commands/update/create.d.ts.map +1 -1
- package/dist/commands/update/create.js +6 -4
- package/dist/commands/update/create.js.map +1 -1
- package/dist/commands/update/edit.d.ts +4 -2
- package/dist/commands/update/edit.d.ts.map +1 -1
- package/dist/commands/update/edit.js +10 -6
- package/dist/commands/update/edit.js.map +1 -1
- package/dist/commands/update/reply.d.ts +4 -2
- package/dist/commands/update/reply.d.ts.map +1 -1
- package/dist/commands/update/reply.js +10 -6
- package/dist/commands/update/reply.js.map +1 -1
- package/dist/commands/user/_team-membership.d.ts +10 -0
- package/dist/commands/user/_team-membership.d.ts.map +1 -0
- package/dist/commands/user/_team-membership.js +88 -0
- package/dist/commands/user/_team-membership.js.map +1 -0
- package/dist/commands/user/team-add-members.d.ts +81 -0
- package/dist/commands/user/team-add-members.d.ts.map +1 -0
- package/dist/commands/user/team-add-members.js +186 -0
- package/dist/commands/user/team-add-members.js.map +1 -0
- package/dist/commands/user/team-create.d.ts +82 -0
- package/dist/commands/user/team-create.d.ts.map +1 -0
- package/dist/commands/user/team-create.js +206 -0
- package/dist/commands/user/team-create.js.map +1 -0
- package/dist/commands/user/team-delete.d.ts +56 -0
- package/dist/commands/user/team-delete.d.ts.map +1 -0
- package/dist/commands/user/team-delete.js +137 -0
- package/dist/commands/user/team-delete.js.map +1 -0
- package/dist/commands/user/team-get.d.ts +41 -0
- package/dist/commands/user/team-get.d.ts.map +1 -0
- package/dist/commands/user/team-get.js +87 -0
- package/dist/commands/user/team-get.js.map +1 -0
- package/dist/commands/user/team-list.d.ts +39 -0
- package/dist/commands/user/team-list.d.ts.map +1 -0
- package/dist/commands/user/team-list.js +90 -0
- package/dist/commands/user/team-list.js.map +1 -0
- package/dist/commands/user/team-remove-members.d.ts +71 -0
- package/dist/commands/user/team-remove-members.d.ts.map +1 -0
- package/dist/commands/user/team-remove-members.js +176 -0
- package/dist/commands/user/team-remove-members.js.map +1 -0
- package/dist/types/ids.d.ts +6 -0
- package/dist/types/ids.d.ts.map +1 -1
- package/dist/types/ids.js +46 -5
- package/dist/types/ids.js.map +1 -1
- package/dist/utils/parse-brand-list.d.ts +95 -0
- package/dist/utils/parse-brand-list.d.ts.map +1 -0
- package/dist/utils/parse-brand-list.js +96 -0
- package/dist/utils/parse-brand-list.js.map +1 -0
- package/dist/utils/source-content.d.ts +93 -0
- package/dist/utils/source-content.d.ts.map +1 -0
- package/dist/utils/source-content.js +120 -0
- package/dist/utils/source-content.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `monday doc block-update <block-id> --content <json> [--dry-run]`
|
|
3
|
+
* — replace the content payload of an existing rich-text block
|
|
4
|
+
* inside a workdoc (`cli-design.md` §4.3 DOC section + §13 v0.5
|
|
5
|
+
* entry; `v0.5-plan.md` §3 M36 + §8 D10-D11).
|
|
6
|
+
*
|
|
7
|
+
* **Wire shape.** Single `update_doc_block(block_id, content) →
|
|
8
|
+
* DocumentBlock` round-trip via {@link updateDocBlock} against
|
|
9
|
+
* `mutation UpdateDocBlock` with `operationName: 'UpdateDocBlock'`
|
|
10
|
+
* (R-NEW-37 W2 audit-point). Returns the full 9-field
|
|
11
|
+
* `DocumentBlock` shape per the M32 probe (id / type / content /
|
|
12
|
+
* position / parent_block_id / doc_id / created_at / created_by /
|
|
13
|
+
* updated_at). OBJECT-return cadence (distinct from M35's opaque-
|
|
14
|
+
* JSON projection cadence).
|
|
15
|
+
*
|
|
16
|
+
* **Snake_case wire arg names.** M36's wire uses snake_case
|
|
17
|
+
* (`block_id`) — back to Monday's standard cadence after the M35
|
|
18
|
+
* camelCase asymmetry. NOT a new R-NEW-41 supporting site.
|
|
19
|
+
*
|
|
20
|
+
* **No `--type` slot on the wire.** Monday's `update_doc_block`
|
|
21
|
+
* mutation has no `type` arg — content type is fixed at creation
|
|
22
|
+
* time. Agents needing to switch a block's content type must
|
|
23
|
+
* `block-delete` + `block-create` (lossy: new id, new position).
|
|
24
|
+
* The CLI surface mirrors the wire constraint exactly — no
|
|
25
|
+
* client-side "change type" shim that papers over the destructive
|
|
26
|
+
* recreate.
|
|
27
|
+
*
|
|
28
|
+
* **Argv shape.**
|
|
29
|
+
*
|
|
30
|
+
* - `<block-id>` — required positional (Monday's
|
|
31
|
+
* `update_doc_block.block_id` is `String!`). Brand-validated
|
|
32
|
+
* via {@link DocBlockIdSchema} (opaque non-empty string —
|
|
33
|
+
* distinct from `DocId`'s numeric shape).
|
|
34
|
+
* - `--content <json>` — required JSON-string slot. Parsed once
|
|
35
|
+
* at the argv boundary via `parseJsonArg` (R-NEW-42 helper, 5th
|
|
36
|
+
* consumer; same shape `monday raw --vars` /
|
|
37
|
+
* `board column-create --settings` /
|
|
38
|
+
* `webhook create --config` / `doc block-create --content`
|
|
39
|
+
* use). The parsed JS value passes through to Monday's wire
|
|
40
|
+
* `JSON` scalar unmodified. The new content payload MUST match
|
|
41
|
+
* the existing block's `DocBlockContentType` shape (Monday's
|
|
42
|
+
* wire rejects shape-incompatible payloads with
|
|
43
|
+
* `validation_failed`); the CLI doesn't pre-validate.
|
|
44
|
+
*
|
|
45
|
+
* **Output envelope.** Direct unwrap of the updated DocumentBlock
|
|
46
|
+
* — `data: <DocumentBlock>` per cli-design §6.1 single-record
|
|
47
|
+
* convention. Mirrors `block-create`'s output shape — Monday's
|
|
48
|
+
* wire returns the full post-update block.
|
|
49
|
+
*
|
|
50
|
+
* **Dry-run shape** per cli-design §6.4 mutation-dry-run variant:
|
|
51
|
+
* minimal `{operation: "update_doc_block", block_id, content}`. No
|
|
52
|
+
* preflight read fires; the dry-run is purely argv-derived.
|
|
53
|
+
* `meta.source: 'none'`.
|
|
54
|
+
*
|
|
55
|
+
* **Idempotent: yes.** Re-running with the same `<block-id>` and
|
|
56
|
+
* `--content` produces the same end state; Monday's wire is a
|
|
57
|
+
* no-op when the content value matches.
|
|
58
|
+
*
|
|
59
|
+
* **Runtime body landed at v0.5-M36 IMPL.** `parseArgv` +
|
|
60
|
+
* `parseJsonArg` fire BEFORE `resolveClient` so invalid argv
|
|
61
|
+
* surfaces `usage_error` ahead of any missing-token `config_error`
|
|
62
|
+
* (R-NEW-76 graduated discipline). Dry-run path emits minimal
|
|
63
|
+
* planned changes (no wire call fires); live path dispatches
|
|
64
|
+
* {@link updateDocBlock} + projects via `emitMutation`.
|
|
65
|
+
*/
|
|
66
|
+
import { z } from 'zod';
|
|
67
|
+
import { ensureSubcommand } from '../types.js';
|
|
68
|
+
import { parseArgv } from '../parse-argv.js';
|
|
69
|
+
import { parseJsonArg } from '../../utils/json.js';
|
|
70
|
+
import { emitDryRun, emitMutation } from '../emit.js';
|
|
71
|
+
import { resolveClient } from '../../api/resolve-client.js';
|
|
72
|
+
import { DocBlockIdSchema } from '../../types/ids.js';
|
|
73
|
+
import { updateDocBlock, docBlockUpdateOutputSchema, } from '../../api/documents.js';
|
|
74
|
+
const inputSchema = z
|
|
75
|
+
.object({
|
|
76
|
+
blockId: DocBlockIdSchema,
|
|
77
|
+
content: z.string().min(1, '--content must not be empty'),
|
|
78
|
+
})
|
|
79
|
+
.strict();
|
|
80
|
+
export const docBlockUpdateCommand = {
|
|
81
|
+
name: 'doc.block-update',
|
|
82
|
+
summary: 'Replace the content payload of an existing doc block (--content required)',
|
|
83
|
+
examples: [
|
|
84
|
+
'monday doc block-update blk_abc123 --content \'{"alignment":"center","content":"Hi"}\'',
|
|
85
|
+
'monday doc block-update blk_abc123 --content \'{"items":["x","y","z"]}\' --dry-run --json',
|
|
86
|
+
],
|
|
87
|
+
// Re-running with the same content is a no-op on Monday's wire;
|
|
88
|
+
// re-running converges idempotently.
|
|
89
|
+
idempotent: true,
|
|
90
|
+
inputSchema,
|
|
91
|
+
outputSchema: docBlockUpdateOutputSchema,
|
|
92
|
+
attach: (program, ctx) => {
|
|
93
|
+
const noun = ensureSubcommand(program, 'doc', 'Workdoc commands');
|
|
94
|
+
noun
|
|
95
|
+
.command('block-update <blockId>')
|
|
96
|
+
.description(docBlockUpdateCommand.summary)
|
|
97
|
+
.requiredOption('--content <json>', 'new block content payload (JSON-encoded string parsed at argv boundary; shape must match the block\'s existing content type)')
|
|
98
|
+
.addHelpText('after', [
|
|
99
|
+
'',
|
|
100
|
+
'Examples:',
|
|
101
|
+
...docBlockUpdateCommand.examples.map((e) => ` ${e}`),
|
|
102
|
+
'',
|
|
103
|
+
'Notes:',
|
|
104
|
+
' - Monday\'s wire has no `type` arg on `update_doc_block`; content type is fixed at block creation. Agents needing to change type use `doc block-delete` + `doc block-create` (lossy: new id, new position).',
|
|
105
|
+
' - Per-block content shapes are documented in `output-shapes.md` "Per-block content shapes" reference table.',
|
|
106
|
+
' - `--dry-run` emits the planned `update_doc_block` operation + resolved input fields (no wire call fires; `meta.source: "none"`).',
|
|
107
|
+
'',
|
|
108
|
+
].join('\n'))
|
|
109
|
+
.action(async (blockIdArg, opts) => {
|
|
110
|
+
const parsed = parseArgv(docBlockUpdateCommand.inputSchema, {
|
|
111
|
+
blockId: blockIdArg,
|
|
112
|
+
content: opts.content,
|
|
113
|
+
});
|
|
114
|
+
// Parse the opaque `--content` JSON string once at the
|
|
115
|
+
// boundary (R-NEW-42 lift).
|
|
116
|
+
const parsedContent = parseJsonArg(parsed.content, {
|
|
117
|
+
context: '--content must be a valid JSON-encoded string',
|
|
118
|
+
details: {
|
|
119
|
+
block_id: parsed.blockId,
|
|
120
|
+
hint: 'check the JSON syntax — strings need double-quotes; the ' +
|
|
121
|
+
'shell may consume quotes if --content is not single-quoted',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
const { client, globalFlags, apiVersion } = resolveClient(ctx, program.opts());
|
|
125
|
+
if (globalFlags.dryRun) {
|
|
126
|
+
emitDryRun({
|
|
127
|
+
ctx,
|
|
128
|
+
programOpts: program.opts(),
|
|
129
|
+
plannedChanges: [
|
|
130
|
+
{
|
|
131
|
+
operation: 'update_doc_block',
|
|
132
|
+
block_id: parsed.blockId,
|
|
133
|
+
content: parsedContent,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
source: 'none',
|
|
137
|
+
cacheAgeSeconds: null,
|
|
138
|
+
warnings: [],
|
|
139
|
+
apiVersion,
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const result = await updateDocBlock({
|
|
144
|
+
client,
|
|
145
|
+
blockId: parsed.blockId,
|
|
146
|
+
content: parsedContent,
|
|
147
|
+
});
|
|
148
|
+
emitMutation({
|
|
149
|
+
ctx,
|
|
150
|
+
data: result.block,
|
|
151
|
+
schema: docBlockUpdateCommand.outputSchema,
|
|
152
|
+
programOpts: program.opts(),
|
|
153
|
+
warnings: [],
|
|
154
|
+
source: result.source,
|
|
155
|
+
cacheAgeSeconds: result.cacheAgeSeconds,
|
|
156
|
+
complexity: result.complexity,
|
|
157
|
+
apiVersion,
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=block-update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-update.js","sourceRoot":"","sources":["../../../src/commands/doc/block-update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,0BAA0B,GAE3B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;CAC1D,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,qBAAqB,GAG9B;IACF,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,2EAA2E;IACpF,QAAQ,EAAE;QACR,wFAAwF;QACxF,2FAA2F;KAC5F;IACD,gEAAgE;IA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UAAU,CAAC;oBACT,GAAG;oBACH,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE;oBAC3B,cAAc,EAAE;wBACd;4BACE,SAAS,EAAE,kBAAkB;4BAC7B,QAAQ,EAAE,MAAM,CAAC,OAAO;4BACxB,OAAO,EAAE,aAAa;yBACvB;qBACF;oBACD,MAAM,EAAE,MAAM;oBACd,eAAe,EAAE,IAAI;oBACrB,QAAQ,EAAE,EAAE;oBACZ,UAAU;iBACX,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;gBAClC,MAAM;gBACN,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO,EAAE,aAAa;aACvB,CAAC,CAAC;YACH,YAAY,CAAC;gBACX,GAAG;gBACH,IAAI,EAAE,MAAM,CAAC,KAAK;gBAClB,MAAM,EAAE,qBAAqB,CAAC,YAAY;gBAC1C,WAAW,EAAE,OAAO,CAAC,IAAI,EAAE;gBAC3B,QAAQ,EAAE,EAAE;gBACZ,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,UAAU;aACX,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACN,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `monday doc create-in-workspace --workspace <wid> --name <n>
|
|
3
|
+
* [--folder <fid>] [--kind public|private|share] [--dry-run]` —
|
|
4
|
+
* create a new workspace-scoped workdoc (`cli-design.md` §4.3
|
|
5
|
+
* DOC section + §13 v0.5 entry; `v0.5-plan.md` §3 M35 + §8 D7-D9).
|
|
6
|
+
*
|
|
7
|
+
* **Wire shape.** Single `create_doc(location: {workspace: ...})`
|
|
8
|
+
* round-trip via {@link createDocInWorkspace} against `mutation
|
|
9
|
+
* CreateDocInWorkspace` with `operationName:
|
|
10
|
+
* 'CreateDocInWorkspace'` (R-NEW-37 W2 audit-point). Returns the
|
|
11
|
+
* created `Document` with `id` populated post-create. The wire's
|
|
12
|
+
* `CreateDocInput` is mutually-exclusive between `board` (item-
|
|
13
|
+
* scoped) and `workspace` (workspace-scoped) variants per D7; this
|
|
14
|
+
* verb supplies only the `workspace` slot. The sibling verb
|
|
15
|
+
* `monday doc create-on-column` covers the board variant.
|
|
16
|
+
*
|
|
17
|
+
* **Argv shape.**
|
|
18
|
+
*
|
|
19
|
+
* - `--workspace <wid>` — required (Monday's
|
|
20
|
+
* `CreateDocWorkspaceInput.workspace_id` is `ID!`). Numeric
|
|
21
|
+
* workspace ID; brand-validated via {@link WorkspaceIdSchema}
|
|
22
|
+
* at the parse boundary.
|
|
23
|
+
* - `--name <n>` — required (Monday's
|
|
24
|
+
* `CreateDocWorkspaceInput.name` is `String!`). Empty string
|
|
25
|
+
* rejects at parse.
|
|
26
|
+
* - `--folder <fid>` — optional (maps to wire `folder_id: ID`).
|
|
27
|
+
* Numeric folder ID; brand-validated via the existing folder-
|
|
28
|
+
* id brand. Absent → omitted (doc lands at workspace root).
|
|
29
|
+
* - `--kind <k>` — optional 3-value closed enum
|
|
30
|
+
* (`public` / `private` / `share`); maps to wire
|
|
31
|
+
* `kind: BoardKind`. Absent → omitted (Monday's wire applies
|
|
32
|
+
* the workspace-default kind).
|
|
33
|
+
*
|
|
34
|
+
* **Output envelope.** Direct unwrap of the created Document —
|
|
35
|
+
* `data: <Document>`. Mirrors M32 `doc get` cadence (sans the
|
|
36
|
+
* `blocks` slot — Monday returns `blocks: null` on a fresh create).
|
|
37
|
+
*
|
|
38
|
+
* **Dry-run shape** per cli-design §6.4 mutation-dry-run variant.
|
|
39
|
+
* Minimal envelope listing the planned `create_doc` operation +
|
|
40
|
+
* the resolved input fields (`workspace_id`, `name`, optional
|
|
41
|
+
* `folder_id`, optional `kind`). No preflight read fires; the
|
|
42
|
+
* dry-run is purely argv-derived. `meta.source: 'none'`.
|
|
43
|
+
*
|
|
44
|
+
* **Idempotent: false.** Re-running `doc create-in-workspace
|
|
45
|
+
* --name foo` creates a SECOND doc with the same name (Monday
|
|
46
|
+
* allows duplicate doc names within a workspace). Agents that
|
|
47
|
+
* need idempotency must pair with a `doc list` lookup first.
|
|
48
|
+
*
|
|
49
|
+
* **Permission-sensitive.** Tokens lacking workdoc-create scope
|
|
50
|
+
* on the target workspace surface `forbidden` (mapped from
|
|
51
|
+
* Monday's PERMISSION_DENIED extension).
|
|
52
|
+
*
|
|
53
|
+
* **Runtime body landed at v0.5-M35 IMPL.** `parseArgv` runs
|
|
54
|
+
* BEFORE `resolveClient` so invalid argv surfaces `usage_error`
|
|
55
|
+
* ahead of any missing-token `config_error`; `resolveClient`
|
|
56
|
+
* parses global flags internally before `loadConfig`. Dry-run
|
|
57
|
+
* path emits minimal planned changes (no wire call fires); live
|
|
58
|
+
* path dispatches {@link createDocInWorkspace} + projects via
|
|
59
|
+
* `emitMutation`.
|
|
60
|
+
*/
|
|
61
|
+
import { z } from 'zod';
|
|
62
|
+
import { type CommandModule } from '../types.js';
|
|
63
|
+
import { type DocCreateInWorkspaceOutput } from '../../api/documents.js';
|
|
64
|
+
declare const inputSchema: z.ZodObject<{
|
|
65
|
+
workspace: z.core.$ZodBranded<z.ZodString, "WorkspaceId", "out">;
|
|
66
|
+
name: z.ZodString;
|
|
67
|
+
folder: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "DocFolderId", "out">>;
|
|
68
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
69
|
+
public: "public";
|
|
70
|
+
private: "private";
|
|
71
|
+
share: "share";
|
|
72
|
+
}>>;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
export declare const docCreateInWorkspaceCommand: CommandModule<z.infer<typeof inputSchema>, DocCreateInWorkspaceOutput>;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=create-in-workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-in-workspace.d.ts","sourceRoot":"","sources":["../../../src/commands/doc/create-in-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAKnE,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,wBAAwB,CAAC;AAEhC,QAAA,MAAM,WAAW;;;;;;;;;kBAON,CAAC;AAEZ,eAAO,MAAM,2BAA2B,EAAE,aAAa,CACrD,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAC3B,0BAA0B,CAoG3B,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `monday doc create-in-workspace --workspace <wid> --name <n>
|
|
3
|
+
* [--folder <fid>] [--kind public|private|share] [--dry-run]` —
|
|
4
|
+
* create a new workspace-scoped workdoc (`cli-design.md` §4.3
|
|
5
|
+
* DOC section + §13 v0.5 entry; `v0.5-plan.md` §3 M35 + §8 D7-D9).
|
|
6
|
+
*
|
|
7
|
+
* **Wire shape.** Single `create_doc(location: {workspace: ...})`
|
|
8
|
+
* round-trip via {@link createDocInWorkspace} against `mutation
|
|
9
|
+
* CreateDocInWorkspace` with `operationName:
|
|
10
|
+
* 'CreateDocInWorkspace'` (R-NEW-37 W2 audit-point). Returns the
|
|
11
|
+
* created `Document` with `id` populated post-create. The wire's
|
|
12
|
+
* `CreateDocInput` is mutually-exclusive between `board` (item-
|
|
13
|
+
* scoped) and `workspace` (workspace-scoped) variants per D7; this
|
|
14
|
+
* verb supplies only the `workspace` slot. The sibling verb
|
|
15
|
+
* `monday doc create-on-column` covers the board variant.
|
|
16
|
+
*
|
|
17
|
+
* **Argv shape.**
|
|
18
|
+
*
|
|
19
|
+
* - `--workspace <wid>` — required (Monday's
|
|
20
|
+
* `CreateDocWorkspaceInput.workspace_id` is `ID!`). Numeric
|
|
21
|
+
* workspace ID; brand-validated via {@link WorkspaceIdSchema}
|
|
22
|
+
* at the parse boundary.
|
|
23
|
+
* - `--name <n>` — required (Monday's
|
|
24
|
+
* `CreateDocWorkspaceInput.name` is `String!`). Empty string
|
|
25
|
+
* rejects at parse.
|
|
26
|
+
* - `--folder <fid>` — optional (maps to wire `folder_id: ID`).
|
|
27
|
+
* Numeric folder ID; brand-validated via the existing folder-
|
|
28
|
+
* id brand. Absent → omitted (doc lands at workspace root).
|
|
29
|
+
* - `--kind <k>` — optional 3-value closed enum
|
|
30
|
+
* (`public` / `private` / `share`); maps to wire
|
|
31
|
+
* `kind: BoardKind`. Absent → omitted (Monday's wire applies
|
|
32
|
+
* the workspace-default kind).
|
|
33
|
+
*
|
|
34
|
+
* **Output envelope.** Direct unwrap of the created Document —
|
|
35
|
+
* `data: <Document>`. Mirrors M32 `doc get` cadence (sans the
|
|
36
|
+
* `blocks` slot — Monday returns `blocks: null` on a fresh create).
|
|
37
|
+
*
|
|
38
|
+
* **Dry-run shape** per cli-design §6.4 mutation-dry-run variant.
|
|
39
|
+
* Minimal envelope listing the planned `create_doc` operation +
|
|
40
|
+
* the resolved input fields (`workspace_id`, `name`, optional
|
|
41
|
+
* `folder_id`, optional `kind`). No preflight read fires; the
|
|
42
|
+
* dry-run is purely argv-derived. `meta.source: 'none'`.
|
|
43
|
+
*
|
|
44
|
+
* **Idempotent: false.** Re-running `doc create-in-workspace
|
|
45
|
+
* --name foo` creates a SECOND doc with the same name (Monday
|
|
46
|
+
* allows duplicate doc names within a workspace). Agents that
|
|
47
|
+
* need idempotency must pair with a `doc list` lookup first.
|
|
48
|
+
*
|
|
49
|
+
* **Permission-sensitive.** Tokens lacking workdoc-create scope
|
|
50
|
+
* on the target workspace surface `forbidden` (mapped from
|
|
51
|
+
* Monday's PERMISSION_DENIED extension).
|
|
52
|
+
*
|
|
53
|
+
* **Runtime body landed at v0.5-M35 IMPL.** `parseArgv` runs
|
|
54
|
+
* BEFORE `resolveClient` so invalid argv surfaces `usage_error`
|
|
55
|
+
* ahead of any missing-token `config_error`; `resolveClient`
|
|
56
|
+
* parses global flags internally before `loadConfig`. Dry-run
|
|
57
|
+
* path emits minimal planned changes (no wire call fires); live
|
|
58
|
+
* path dispatches {@link createDocInWorkspace} + projects via
|
|
59
|
+
* `emitMutation`.
|
|
60
|
+
*/
|
|
61
|
+
import { z } from 'zod';
|
|
62
|
+
import { ensureSubcommand } from '../types.js';
|
|
63
|
+
import { parseArgv } from '../parse-argv.js';
|
|
64
|
+
import { emitDryRun, emitMutation } from '../emit.js';
|
|
65
|
+
import { resolveClient } from '../../api/resolve-client.js';
|
|
66
|
+
import { WorkspaceIdSchema, DocFolderIdSchema } from '../../types/ids.js';
|
|
67
|
+
import { createDocInWorkspace, DOC_KIND_VALUES, docCreateInWorkspaceOutputSchema, } from '../../api/documents.js';
|
|
68
|
+
const inputSchema = z
|
|
69
|
+
.object({
|
|
70
|
+
workspace: WorkspaceIdSchema,
|
|
71
|
+
name: z.string().min(1, '--name must not be empty'),
|
|
72
|
+
folder: DocFolderIdSchema.optional(),
|
|
73
|
+
kind: z.enum(DOC_KIND_VALUES).optional(),
|
|
74
|
+
})
|
|
75
|
+
.strict();
|
|
76
|
+
export const docCreateInWorkspaceCommand = {
|
|
77
|
+
name: 'doc.create-in-workspace',
|
|
78
|
+
summary: 'Create a workspace-scoped workdoc (--workspace + --name required)',
|
|
79
|
+
examples: [
|
|
80
|
+
'monday doc create-in-workspace --workspace 5555 --name "Q4 launch plan"',
|
|
81
|
+
'monday doc create-in-workspace --workspace 5555 --name "Q4 launch plan" --folder 12345',
|
|
82
|
+
'monday doc create-in-workspace --workspace 5555 --name "Q4 launch plan" --kind private',
|
|
83
|
+
'monday doc create-in-workspace --workspace 5555 --name "Q4 launch plan" --dry-run --json',
|
|
84
|
+
],
|
|
85
|
+
// Re-running creates a duplicate-named doc — Monday's wire does
|
|
86
|
+
// NOT dedupe by name within a workspace. Mark non-idempotent so
|
|
87
|
+
// agents don't naively retry on transient failures.
|
|
88
|
+
idempotent: false,
|
|
89
|
+
inputSchema,
|
|
90
|
+
outputSchema: docCreateInWorkspaceOutputSchema,
|
|
91
|
+
attach: (program, ctx) => {
|
|
92
|
+
const noun = ensureSubcommand(program, 'doc', 'Workdoc commands');
|
|
93
|
+
noun
|
|
94
|
+
.command('create-in-workspace')
|
|
95
|
+
.description(docCreateInWorkspaceCommand.summary)
|
|
96
|
+
.requiredOption('--workspace <wid>', 'numeric workspace ID (maps to wire `workspace_id: ID!`)')
|
|
97
|
+
.requiredOption('--name <n>', 'doc name (Monday\'s `String!` — must not be empty)')
|
|
98
|
+
.option('--folder <fid>', 'optional numeric folder ID (maps to wire `folder_id: ID`); absent → doc lands at workspace root')
|
|
99
|
+
.option(`--kind <${DOC_KIND_VALUES.join('|')}>`, `optional doc kind (maps to wire \`kind: BoardKind\`); absent → Monday's workspace-default kind applies`)
|
|
100
|
+
.addHelpText('after', [
|
|
101
|
+
'',
|
|
102
|
+
'Examples:',
|
|
103
|
+
...docCreateInWorkspaceCommand.examples.map((e) => ` ${e}`),
|
|
104
|
+
'',
|
|
105
|
+
'Notes:',
|
|
106
|
+
' - Monday allows duplicate doc names within a workspace; this verb is non-idempotent.',
|
|
107
|
+
' - `--dry-run` emits the planned `create_doc` operation + resolved input fields (no wire call fires; `meta.source: "none"`).',
|
|
108
|
+
' - For item-scoped docs use `monday doc create-on-column --item <iid> --column <cid>`.',
|
|
109
|
+
'',
|
|
110
|
+
].join('\n'))
|
|
111
|
+
.action(async (opts) => {
|
|
112
|
+
const parsed = parseArgv(docCreateInWorkspaceCommand.inputSchema, opts);
|
|
113
|
+
const { client, globalFlags, apiVersion } = resolveClient(ctx, program.opts());
|
|
114
|
+
if (globalFlags.dryRun) {
|
|
115
|
+
// Minimal dry-run shape per cli-design §6.4 mutation-
|
|
116
|
+
// dry-run variant — argv-derived, no preflight read.
|
|
117
|
+
// Only supplied input slots land in the planned payload
|
|
118
|
+
// (mirrors the wire-side omit-vs-null discipline the live
|
|
119
|
+
// path uses; agents see exactly what the live mutation
|
|
120
|
+
// would send).
|
|
121
|
+
const planned = {
|
|
122
|
+
operation: 'create_doc',
|
|
123
|
+
workspace_id: parsed.workspace,
|
|
124
|
+
name: parsed.name,
|
|
125
|
+
};
|
|
126
|
+
if (parsed.folder !== undefined) {
|
|
127
|
+
planned.folder_id = parsed.folder;
|
|
128
|
+
}
|
|
129
|
+
if (parsed.kind !== undefined) {
|
|
130
|
+
planned.kind = parsed.kind;
|
|
131
|
+
}
|
|
132
|
+
emitDryRun({
|
|
133
|
+
ctx,
|
|
134
|
+
programOpts: program.opts(),
|
|
135
|
+
plannedChanges: [planned],
|
|
136
|
+
source: 'none',
|
|
137
|
+
cacheAgeSeconds: null,
|
|
138
|
+
warnings: [],
|
|
139
|
+
apiVersion,
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const result = await createDocInWorkspace({
|
|
144
|
+
client,
|
|
145
|
+
workspaceId: parsed.workspace,
|
|
146
|
+
name: parsed.name,
|
|
147
|
+
...(parsed.folder === undefined ? {} : { folderId: parsed.folder }),
|
|
148
|
+
...(parsed.kind === undefined ? {} : { kind: parsed.kind }),
|
|
149
|
+
});
|
|
150
|
+
emitMutation({
|
|
151
|
+
ctx,
|
|
152
|
+
data: result.document,
|
|
153
|
+
schema: docCreateInWorkspaceCommand.outputSchema,
|
|
154
|
+
programOpts: program.opts(),
|
|
155
|
+
warnings: [],
|
|
156
|
+
source: result.source,
|
|
157
|
+
cacheAgeSeconds: result.cacheAgeSeconds,
|
|
158
|
+
complexity: result.complexity,
|
|
159
|
+
apiVersion,
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=create-in-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-in-workspace.js","sourceRoot":"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
|
|
1
|
+
/**
|
|
2
|
+
* `monday doc create-on-column --item <iid> --column <cid>
|
|
3
|
+
* [--dry-run]` — create a new workdoc embedded into a doc-column
|
|
4
|
+
* on an existing item (`cli-design.md` §4.3 DOC section + §13
|
|
5
|
+
* v0.5 entry; `v0.5-plan.md` §3 M35 + §8 D7-D9).
|
|
6
|
+
*
|
|
7
|
+
* **Wire shape.** Single `create_doc(location: {board: ...})`
|
|
8
|
+
* round-trip via {@link createDocOnColumn} against `mutation
|
|
9
|
+
* CreateDocOnColumn` with `operationName: 'CreateDocOnColumn'`
|
|
10
|
+
* (R-NEW-37 W2 audit-point). Returns the created `Document`.
|
|
11
|
+
* The wire's `CreateDocInput` is mutually-exclusive between
|
|
12
|
+
* `board` (item-scoped) and `workspace` (workspace-scoped)
|
|
13
|
+
* variants per D7; this verb supplies only the `board` slot.
|
|
14
|
+
* The sibling verb `monday doc create-in-workspace` covers the
|
|
15
|
+
* workspace variant.
|
|
16
|
+
*
|
|
17
|
+
* **Argv shape.**
|
|
18
|
+
*
|
|
19
|
+
* - `--item <iid>` — required (Monday's
|
|
20
|
+
* `CreateDocBoardInput.item_id` is `ID!`). Numeric item ID;
|
|
21
|
+
* brand-validated via {@link ItemIdSchema}.
|
|
22
|
+
* - `--column <cid>` — required (Monday's
|
|
23
|
+
* `CreateDocBoardInput.column_id` is `ID!`). Column ID slug;
|
|
24
|
+
* brand-validated via {@link ColumnIdSchema}. The column must
|
|
25
|
+
* be a doc-typed column on the item's board — CLI doesn't
|
|
26
|
+
* pre-check column-type compatibility (mirrors M8's
|
|
27
|
+
* `change_column_value` cadence); incompatible columns
|
|
28
|
+
* surface `validation_failed` at the wire.
|
|
29
|
+
*
|
|
30
|
+
* **Output envelope.** Direct unwrap of the created Document —
|
|
31
|
+
* `data: <Document>`. Same shape as
|
|
32
|
+
* `monday doc create-in-workspace` per the create-variant
|
|
33
|
+
* symmetry.
|
|
34
|
+
*
|
|
35
|
+
* **Dry-run shape** per cli-design §6.4 mutation-dry-run variant.
|
|
36
|
+
* Minimal envelope listing the planned `create_doc` operation +
|
|
37
|
+
* the resolved input fields (`item_id`, `column_id`). No
|
|
38
|
+
* preflight read fires; the dry-run is purely argv-derived.
|
|
39
|
+
* `meta.source: 'none'`.
|
|
40
|
+
*
|
|
41
|
+
* **Idempotent: false.** Re-running creates a SECOND doc on the
|
|
42
|
+
* same column slot (Monday's wire allows multiple docs to attach
|
|
43
|
+
* to one item-column pair). Agents that need idempotency must
|
|
44
|
+
* pair with a column-value read first.
|
|
45
|
+
*
|
|
46
|
+
* **Permission-sensitive.** Tokens lacking write scope on the
|
|
47
|
+
* target item's board (or lacking the column-write permission
|
|
48
|
+
* for the doc-typed column) surface `forbidden` (mapped from
|
|
49
|
+
* Monday's PERMISSION_DENIED extension). Distinct from the
|
|
50
|
+
* separate `validation_failed` rejection for incompatible
|
|
51
|
+
* column types — permission failure precedes column-type
|
|
52
|
+
* validation at Monday's wire.
|
|
53
|
+
*
|
|
54
|
+
* **Runtime body landed at v0.5-M35 IMPL.** `parseArgv` runs
|
|
55
|
+
* BEFORE `resolveClient` so invalid argv surfaces `usage_error`
|
|
56
|
+
* ahead of any missing-token `config_error`; `resolveClient`
|
|
57
|
+
* parses global flags internally before `loadConfig`. Dry-run
|
|
58
|
+
* path emits minimal planned changes (no wire call fires); live
|
|
59
|
+
* path dispatches {@link createDocOnColumn} + projects via
|
|
60
|
+
* `emitMutation`.
|
|
61
|
+
*/
|
|
62
|
+
import { z } from 'zod';
|
|
63
|
+
import { type CommandModule } from '../types.js';
|
|
64
|
+
import { type DocCreateOnColumnOutput } from '../../api/documents.js';
|
|
65
|
+
declare const inputSchema: z.ZodObject<{
|
|
66
|
+
item: z.core.$ZodBranded<z.ZodString, "ItemId", "out">;
|
|
67
|
+
column: z.core.$ZodBranded<z.ZodString, "ColumnId", "out">;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
export declare const docCreateOnColumnCommand: CommandModule<z.infer<typeof inputSchema>, DocCreateOnColumnOutput>;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=create-on-column.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-on-column.d.ts","sourceRoot":"","sources":["../../../src/commands/doc/create-on-column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAKnE,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAEhC,QAAA,MAAM,WAAW;;;kBAKN,CAAC;AAEZ,eAAO,MAAM,wBAAwB,EAAE,aAAa,CAClD,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAC3B,uBAAuB,CAgFxB,CAAC"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `monday doc create-on-column --item <iid> --column <cid>
|
|
3
|
+
* [--dry-run]` — create a new workdoc embedded into a doc-column
|
|
4
|
+
* on an existing item (`cli-design.md` §4.3 DOC section + §13
|
|
5
|
+
* v0.5 entry; `v0.5-plan.md` §3 M35 + §8 D7-D9).
|
|
6
|
+
*
|
|
7
|
+
* **Wire shape.** Single `create_doc(location: {board: ...})`
|
|
8
|
+
* round-trip via {@link createDocOnColumn} against `mutation
|
|
9
|
+
* CreateDocOnColumn` with `operationName: 'CreateDocOnColumn'`
|
|
10
|
+
* (R-NEW-37 W2 audit-point). Returns the created `Document`.
|
|
11
|
+
* The wire's `CreateDocInput` is mutually-exclusive between
|
|
12
|
+
* `board` (item-scoped) and `workspace` (workspace-scoped)
|
|
13
|
+
* variants per D7; this verb supplies only the `board` slot.
|
|
14
|
+
* The sibling verb `monday doc create-in-workspace` covers the
|
|
15
|
+
* workspace variant.
|
|
16
|
+
*
|
|
17
|
+
* **Argv shape.**
|
|
18
|
+
*
|
|
19
|
+
* - `--item <iid>` — required (Monday's
|
|
20
|
+
* `CreateDocBoardInput.item_id` is `ID!`). Numeric item ID;
|
|
21
|
+
* brand-validated via {@link ItemIdSchema}.
|
|
22
|
+
* - `--column <cid>` — required (Monday's
|
|
23
|
+
* `CreateDocBoardInput.column_id` is `ID!`). Column ID slug;
|
|
24
|
+
* brand-validated via {@link ColumnIdSchema}. The column must
|
|
25
|
+
* be a doc-typed column on the item's board — CLI doesn't
|
|
26
|
+
* pre-check column-type compatibility (mirrors M8's
|
|
27
|
+
* `change_column_value` cadence); incompatible columns
|
|
28
|
+
* surface `validation_failed` at the wire.
|
|
29
|
+
*
|
|
30
|
+
* **Output envelope.** Direct unwrap of the created Document —
|
|
31
|
+
* `data: <Document>`. Same shape as
|
|
32
|
+
* `monday doc create-in-workspace` per the create-variant
|
|
33
|
+
* symmetry.
|
|
34
|
+
*
|
|
35
|
+
* **Dry-run shape** per cli-design §6.4 mutation-dry-run variant.
|
|
36
|
+
* Minimal envelope listing the planned `create_doc` operation +
|
|
37
|
+
* the resolved input fields (`item_id`, `column_id`). No
|
|
38
|
+
* preflight read fires; the dry-run is purely argv-derived.
|
|
39
|
+
* `meta.source: 'none'`.
|
|
40
|
+
*
|
|
41
|
+
* **Idempotent: false.** Re-running creates a SECOND doc on the
|
|
42
|
+
* same column slot (Monday's wire allows multiple docs to attach
|
|
43
|
+
* to one item-column pair). Agents that need idempotency must
|
|
44
|
+
* pair with a column-value read first.
|
|
45
|
+
*
|
|
46
|
+
* **Permission-sensitive.** Tokens lacking write scope on the
|
|
47
|
+
* target item's board (or lacking the column-write permission
|
|
48
|
+
* for the doc-typed column) surface `forbidden` (mapped from
|
|
49
|
+
* Monday's PERMISSION_DENIED extension). Distinct from the
|
|
50
|
+
* separate `validation_failed` rejection for incompatible
|
|
51
|
+
* column types — permission failure precedes column-type
|
|
52
|
+
* validation at Monday's wire.
|
|
53
|
+
*
|
|
54
|
+
* **Runtime body landed at v0.5-M35 IMPL.** `parseArgv` runs
|
|
55
|
+
* BEFORE `resolveClient` so invalid argv surfaces `usage_error`
|
|
56
|
+
* ahead of any missing-token `config_error`; `resolveClient`
|
|
57
|
+
* parses global flags internally before `loadConfig`. Dry-run
|
|
58
|
+
* path emits minimal planned changes (no wire call fires); live
|
|
59
|
+
* path dispatches {@link createDocOnColumn} + projects via
|
|
60
|
+
* `emitMutation`.
|
|
61
|
+
*/
|
|
62
|
+
import { z } from 'zod';
|
|
63
|
+
import { ensureSubcommand } from '../types.js';
|
|
64
|
+
import { parseArgv } from '../parse-argv.js';
|
|
65
|
+
import { emitDryRun, emitMutation } from '../emit.js';
|
|
66
|
+
import { resolveClient } from '../../api/resolve-client.js';
|
|
67
|
+
import { ItemIdSchema, ColumnIdSchema } from '../../types/ids.js';
|
|
68
|
+
import { createDocOnColumn, docCreateOnColumnOutputSchema, } from '../../api/documents.js';
|
|
69
|
+
const inputSchema = z
|
|
70
|
+
.object({
|
|
71
|
+
item: ItemIdSchema,
|
|
72
|
+
column: ColumnIdSchema,
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
75
|
+
export const docCreateOnColumnCommand = {
|
|
76
|
+
name: 'doc.create-on-column',
|
|
77
|
+
summary: 'Create a workdoc embedded on a doc-column of an existing item (--item + --column required)',
|
|
78
|
+
examples: [
|
|
79
|
+
'monday doc create-on-column --item 12345 --column doc_column_1',
|
|
80
|
+
'monday doc create-on-column --item 12345 --column doc_column_1 --dry-run --json',
|
|
81
|
+
],
|
|
82
|
+
// Monday allows multiple docs on the same item-column slot
|
|
83
|
+
// (the column is a one-to-many holder); creates are
|
|
84
|
+
// non-idempotent against the column slot.
|
|
85
|
+
idempotent: false,
|
|
86
|
+
inputSchema,
|
|
87
|
+
outputSchema: docCreateOnColumnOutputSchema,
|
|
88
|
+
attach: (program, ctx) => {
|
|
89
|
+
const noun = ensureSubcommand(program, 'doc', 'Workdoc commands');
|
|
90
|
+
noun
|
|
91
|
+
.command('create-on-column')
|
|
92
|
+
.description(docCreateOnColumnCommand.summary)
|
|
93
|
+
.requiredOption('--item <iid>', 'numeric item ID (maps to wire `item_id: ID!`)')
|
|
94
|
+
.requiredOption('--column <cid>', 'column ID slug (maps to wire `column_id: ID!`); column must be a doc-typed column on the item\'s board')
|
|
95
|
+
.addHelpText('after', [
|
|
96
|
+
'',
|
|
97
|
+
'Examples:',
|
|
98
|
+
...docCreateOnColumnCommand.examples.map((e) => ` ${e}`),
|
|
99
|
+
'',
|
|
100
|
+
'Notes:',
|
|
101
|
+
' - The column must be a doc-typed column on the item\'s board; incompatible columns surface `validation_failed` at the wire (CLI does not pre-check column type).',
|
|
102
|
+
' - `--dry-run` emits the planned `create_doc` operation + resolved input fields (no wire call fires; `meta.source: "none"`).',
|
|
103
|
+
' - For workspace-scoped docs use `monday doc create-in-workspace --workspace <wid> --name <n>`.',
|
|
104
|
+
'',
|
|
105
|
+
].join('\n'))
|
|
106
|
+
.action(async (opts) => {
|
|
107
|
+
const parsed = parseArgv(docCreateOnColumnCommand.inputSchema, opts);
|
|
108
|
+
const { client, globalFlags, apiVersion } = resolveClient(ctx, program.opts());
|
|
109
|
+
if (globalFlags.dryRun) {
|
|
110
|
+
emitDryRun({
|
|
111
|
+
ctx,
|
|
112
|
+
programOpts: program.opts(),
|
|
113
|
+
plannedChanges: [
|
|
114
|
+
{
|
|
115
|
+
operation: 'create_doc',
|
|
116
|
+
item_id: parsed.item,
|
|
117
|
+
column_id: parsed.column,
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
source: 'none',
|
|
121
|
+
cacheAgeSeconds: null,
|
|
122
|
+
warnings: [],
|
|
123
|
+
apiVersion,
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const result = await createDocOnColumn({
|
|
128
|
+
client,
|
|
129
|
+
itemId: parsed.item,
|
|
130
|
+
columnId: parsed.column,
|
|
131
|
+
});
|
|
132
|
+
emitMutation({
|
|
133
|
+
ctx,
|
|
134
|
+
data: result.document,
|
|
135
|
+
schema: docCreateOnColumnCommand.outputSchema,
|
|
136
|
+
programOpts: program.opts(),
|
|
137
|
+
warnings: [],
|
|
138
|
+
source: result.source,
|
|
139
|
+
cacheAgeSeconds: result.cacheAgeSeconds,
|
|
140
|
+
complexity: result.complexity,
|
|
141
|
+
apiVersion,
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=create-on-column.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-on-column.js","sourceRoot":"","sources":["../../../src/commands/doc/create-on-column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,6BAA6B,GAE9B,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,GAAG,CAAC;KAClB,MAAM,CAAC;IACN,IAAI,EAAE,YAAY;IAClB,MAAM,EAAE,cAAc;CACvB,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,wBAAwB,GAGjC;IACF,IAAI,EAAE,sBAAsB;IAC5B,OAAO,EAAE,4FAA4F;IACrG,QAAQ,EAAE;QACR,gEAAgE;QAChE,iFAAiF;KAClF;IACD,2DAA2D;IAC3D,oDAAoD;IACpD,0CAA0C;IAC1C,U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