monday-cli 0.5.0 → 0.7.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 (49) hide show
  1. package/CHANGELOG.md +665 -0
  2. package/README.md +209 -35
  3. package/dist/api/column-types.d.ts +81 -19
  4. package/dist/api/column-types.d.ts.map +1 -1
  5. package/dist/api/column-types.js +44 -11
  6. package/dist/api/column-types.js.map +1 -1
  7. package/dist/api/column-values.d.ts +22 -10
  8. package/dist/api/column-values.d.ts.map +1 -1
  9. package/dist/api/column-values.js +50 -20
  10. package/dist/api/column-values.js.map +1 -1
  11. package/dist/api/file-column-set.d.ts +613 -0
  12. package/dist/api/file-column-set.d.ts.map +1 -0
  13. package/dist/api/file-column-set.js +568 -0
  14. package/dist/api/file-column-set.js.map +1 -0
  15. package/dist/api/raw-write.d.ts +38 -17
  16. package/dist/api/raw-write.d.ts.map +1 -1
  17. package/dist/api/raw-write.js +62 -25
  18. package/dist/api/raw-write.js.map +1 -1
  19. package/dist/api/resolver-error-fold.d.ts +25 -0
  20. package/dist/api/resolver-error-fold.d.ts.map +1 -1
  21. package/dist/api/resolver-error-fold.js +56 -0
  22. package/dist/api/resolver-error-fold.js.map +1 -1
  23. package/dist/commands/board/column-create.d.ts +13 -3
  24. package/dist/commands/board/column-create.d.ts.map +1 -1
  25. package/dist/commands/board/column-create.js +27 -8
  26. package/dist/commands/board/column-create.js.map +1 -1
  27. package/dist/commands/item/create.d.ts +24 -8
  28. package/dist/commands/item/create.d.ts.map +1 -1
  29. package/dist/commands/item/create.js +601 -44
  30. package/dist/commands/item/create.js.map +1 -1
  31. package/dist/commands/item/set.d.ts +33 -3
  32. package/dist/commands/item/set.d.ts.map +1 -1
  33. package/dist/commands/item/set.js +193 -15
  34. package/dist/commands/item/set.js.map +1 -1
  35. package/dist/commands/item/update.d.ts +203 -3
  36. package/dist/commands/item/update.d.ts.map +1 -1
  37. package/dist/commands/item/update.js +1015 -68
  38. package/dist/commands/item/update.js.map +1 -1
  39. package/dist/commands/item/upload.d.ts.map +1 -1
  40. package/dist/commands/item/upload.js +16 -69
  41. package/dist/commands/item/upload.js.map +1 -1
  42. package/dist/commands/update/upload.d.ts.map +1 -1
  43. package/dist/commands/update/upload.js +9 -59
  44. package/dist/commands/update/upload.js.map +1 -1
  45. package/dist/utils/file-source.d.ts +93 -0
  46. package/dist/utils/file-source.d.ts.map +1 -0
  47. package/dist/utils/file-source.js +140 -0
  48. package/dist/utils/file-source.js.map +1 -0
  49. package/package.json +1 -1
@@ -45,8 +45,26 @@
45
45
  */
46
46
  import { z } from 'zod';
47
47
  import { type CommandModule } from '../types.js';
48
+ import type { MondayClient } from '../../api/client.js';
49
+ import { type FileColumnSetOutput, type PreCheckM38FileDispatchResult } from '../../api/file-column-set.js';
50
+ import type { MultipartTransport } from '../../api/multipart-transport.js';
51
+ import type { RunContext } from '../../cli/run.js';
48
52
  import { type ProjectedItem } from '../../api/item-projection.js';
49
- export declare const itemUpdateOutputSchema: z.ZodObject<{
53
+ import type { Warning } from '../../utils/output/envelope.js';
54
+ /**
55
+ * Output envelope union — projected-item for the JSON translator
56
+ * path (text / status / dropdown / date / people / etc.) +
57
+ * file-dispatch envelope for the friendly `--set <file-col>=<path>`
58
+ * path. The file-dispatch shape ships across v0.6-M38 (single-item
59
+ * — `operation: 'add_file_to_column'`) and v0.7-M42 (bulk —
60
+ * `operation: 'item_update_bulk_file_set'`; the per-item fan-out's
61
+ * `data.results[i].asset` slots wrap M31's `Asset` projection). The
62
+ * union below admits only the single-item shape because the bulk
63
+ * variant is emitted via its own `bulkFileSetDataSchema` at the
64
+ * `runItemUpdateBulkFileDispatch` helper; agents discriminate on
65
+ * `operation` (present + literal value identifies the variant).
66
+ */
67
+ export declare const itemUpdateOutputSchema: z.ZodUnion<readonly [z.ZodObject<{
50
68
  id: z.ZodString;
51
69
  name: z.ZodString;
52
70
  board_id: z.ZodNullable<z.ZodString>;
@@ -71,8 +89,29 @@ export declare const itemUpdateOutputSchema: z.ZodObject<{
71
89
  kind: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
90
  }, z.core.$loose>>>;
73
91
  }, z.core.$loose>>;
74
- }, z.core.$strict>;
75
- export type ItemUpdateOutput = ProjectedItem;
92
+ }, z.core.$strict>, z.ZodObject<{
93
+ operation: z.ZodLiteral<"add_file_to_column">;
94
+ item_id: z.ZodString;
95
+ column_id: z.ZodString;
96
+ filename: z.ZodString;
97
+ file_size_bytes: z.ZodNumber;
98
+ asset: z.ZodObject<{
99
+ id: z.ZodString;
100
+ name: z.ZodString;
101
+ url: z.ZodString;
102
+ public_url: z.ZodString;
103
+ file_extension: z.ZodString;
104
+ file_size: z.ZodNumber;
105
+ created_at: z.ZodNullable<z.ZodString>;
106
+ uploaded_by: z.ZodObject<{
107
+ id: z.ZodString;
108
+ name: z.ZodString;
109
+ }, z.core.$strict>;
110
+ original_geometry: z.ZodNullable<z.ZodString>;
111
+ url_thumbnail: z.ZodNullable<z.ZodString>;
112
+ }, z.core.$strict>;
113
+ }, z.core.$strict>]>;
114
+ export type ItemUpdateOutput = ProjectedItem | FileColumnSetOutput;
76
115
  /**
77
116
  * Input shape — supports both single-item and bulk shapes.
78
117
  *
@@ -96,6 +135,167 @@ declare const inputSchema: z.ZodObject<{
96
135
  continueOnError: z.ZodOptional<z.ZodBoolean>;
97
136
  concurrency: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
98
137
  }, z.core.$strict>;
138
+ type ParsedInput = z.infer<typeof inputSchema>;
99
139
  export declare const itemUpdateCommand: CommandModule<z.infer<typeof inputSchema>, ItemUpdateOutput>;
140
+ /**
141
+ * Per-item dispatch result for v0.7-M42 bulk file `--set` carve-out
142
+ * fold. Mirrors the M25 `partialSuccessBulkUpdateResultSchema` shape
143
+ * with the file-dispatch's `asset` slot replacing the JSON path's
144
+ * `item` projection:
145
+ *
146
+ * - Success: `{ item_id, ok: true, asset: { id, name, ... } }`
147
+ * - Failure: `{ item_id, ok: false, error: { code, message } }`
148
+ *
149
+ * Schema landed at the v0.7-M42 pre-flight contract diff
150
+ * (`160330b`); runtime body shipped at v0.7-M42 IMPL (`22df2fa`)
151
+ * + R1 fix-up (`968b154`).
152
+ */
153
+ export declare const bulkFileSetResultSchema: z.ZodObject<{
154
+ item_id: z.ZodString;
155
+ ok: z.ZodBoolean;
156
+ asset: z.ZodOptional<z.ZodObject<{
157
+ id: z.ZodString;
158
+ name: z.ZodString;
159
+ }, z.core.$loose>>;
160
+ error: z.ZodOptional<z.ZodObject<{
161
+ code: z.ZodString;
162
+ message: z.ZodString;
163
+ }, z.core.$strip>>;
164
+ }, z.core.$strip>;
165
+ export type BulkFileSetResult = z.infer<typeof bulkFileSetResultSchema>;
166
+ /**
167
+ * Output `data` shape for the v0.7-M42 bulk file `--set` envelope.
168
+ * Mirrors M25's `partialSuccessBulkUpdateDataSchema` structure —
169
+ * `operation: 'item_update_bulk_file_set'` literal discriminator
170
+ * + `summary.{matched_count, applied_count, failed_count,
171
+ * board_id}` aggregate slots + per-item `results[]` array.
172
+ *
173
+ * Invariant: `matched_count === applied_count + failed_count` for
174
+ * every emitted envelope (mirrors M25's invariant).
175
+ */
176
+ export declare const bulkFileSetDataSchema: z.ZodObject<{
177
+ operation: z.ZodLiteral<"item_update_bulk_file_set">;
178
+ summary: z.ZodObject<{
179
+ matched_count: z.ZodNumber;
180
+ applied_count: z.ZodNumber;
181
+ failed_count: z.ZodNumber;
182
+ board_id: z.ZodString;
183
+ column_id: z.ZodString;
184
+ filename: z.ZodString;
185
+ file_size_bytes: z.ZodNumber;
186
+ }, z.core.$strip>;
187
+ results: z.ZodArray<z.ZodObject<{
188
+ item_id: z.ZodString;
189
+ ok: z.ZodBoolean;
190
+ asset: z.ZodOptional<z.ZodObject<{
191
+ id: z.ZodString;
192
+ name: z.ZodString;
193
+ }, z.core.$loose>>;
194
+ error: z.ZodOptional<z.ZodObject<{
195
+ code: z.ZodString;
196
+ message: z.ZodString;
197
+ }, z.core.$strip>>;
198
+ }, z.core.$strip>>;
199
+ }, z.core.$strip>;
200
+ export type BulkFileSetData = z.infer<typeof bulkFileSetDataSchema>;
201
+ interface RunItemUpdateBulkFileDispatchInputs {
202
+ readonly parsed: ParsedInput;
203
+ readonly client: MondayClient;
204
+ readonly multipart: MultipartTransport;
205
+ readonly ctx: RunContext;
206
+ readonly programOpts: unknown;
207
+ readonly apiVersion: string;
208
+ readonly boardId: string;
209
+ readonly matchedItemIds: readonly string[];
210
+ readonly m38: Extract<PreCheckM38FileDispatchResult, {
211
+ kind: 'file_bulk';
212
+ }>;
213
+ readonly metaSource: 'live' | 'cache' | 'mixed';
214
+ readonly metaCacheAgeSeconds: number | null;
215
+ readonly filterWarnings: readonly Warning[];
216
+ readonly retries: number;
217
+ /**
218
+ * v0.7-M42 IMPL: dry-run vs live branching. Carries `globalFlags.dryRun`
219
+ * from the bulk action body so the helper emits the D4 planned_changes
220
+ * envelope (per-item `add_file_to_column` entry) without burning multipart
221
+ * wire round-trips, or runs the per-item dispatch loop on the live path.
222
+ * Mirrors the M38 single-file helper's `isDryRun` slot for consistency
223
+ * across the file-dispatch family.
224
+ */
225
+ readonly isDryRun: boolean;
226
+ /**
227
+ * v0.7-M42 IMPL Codex R1 P1-1 fix: `globalFlags.noCache` threaded
228
+ * through so `foldAndRemap` (Codex pass-1 F4 remap from `src/api/
229
+ * resolver-error-fold.ts`) can refresh stale board metadata when a
230
+ * cache-served file-column resolution surfaces `validation_failed`
231
+ * post-dispatch. Without this, per-item failures bypass the
232
+ * stable-code rule (cli-design §6.5) — `column_archived` would not
233
+ * remap and agents would see `validation_failed` for an archived
234
+ * file column on file-bulk dispatch while the JSON-bulk path
235
+ * already surfaces `column_archived` for the same root cause.
236
+ */
237
+ readonly noCache: boolean;
238
+ }
239
+ /**
240
+ * Bulk file `--set` per-item dispatch helper (v0.7-M42 D5 carve-out
241
+ * fold).
242
+ *
243
+ * **Status: runtime body shipped at v0.7-M42 IMPL.** argv parse,
244
+ * shape validation, board-metadata load, pre-check (which returned
245
+ * `kind: 'file_bulk'` for callers reaching this helper), items_page
246
+ * walk, and the confirmation gate run upstream — this helper takes
247
+ * the resolved file-column dispatch slot + matched item-IDs and
248
+ * fans the multipart wire across them under the partial-success vs
249
+ * fail-fast contract.
250
+ *
251
+ * **Execution shape:**
252
+ *
253
+ * 1. Single upfront `precheckLocalFile(inputs.m38.rawValue)` —
254
+ * one file path shared across all matched items. Failure
255
+ * surfaces as `usage_error` (`file_not_readable` /
256
+ * `file_empty`) whole-call-abort regardless of
257
+ * `--continue-on-error` per D3 + cli-design §5.8 atomicity
258
+ * discipline (pre-checks MUST fire BEFORE any wire round-trip).
259
+ * 2. Dry-run branch — emits the D4-shaped envelope with one
260
+ * `add_file_to_column` planned_change per matched item-ID
261
+ * (no file bytes loaded; no multipart wire). Unlike M38
262
+ * single-item which pins `source: 'none'` (its dry-run is
263
+ * pure-local), bulk dry-run carries the upstream legs'
264
+ * aggregated `source` (metadata load + items_page walk —
265
+ * `mixed` when metadata was cache-served, `live` otherwise);
266
+ * reaching this branch already paid for those wire legs.
267
+ * 3. Live dispatch — two shapes per `parsed.continueOnError`:
268
+ * - **Fail-fast (default)** — sequential loop over matched
269
+ * items (no `--concurrency` per M30 D2 closure:
270
+ * `--concurrency requires --continue-on-error`); first
271
+ * per-item failure aborts whole-call with the v0.1-shaped
272
+ * `details.applied_to` / `applied_count` / `failed_at_item`
273
+ * / `matched_count` decoration so agents see how many
274
+ * items applied before the failure.
275
+ * - **`--continue-on-error`** — routes through
276
+ * {@link dispatchSequential} (concurrency `undefined`/`1`)
277
+ * or {@link dispatchParallel} (concurrency `> 1`) over a
278
+ * shared {@link MultipartTransport}; per-item failures
279
+ * land as `data.results[i].error: {code, message}` records,
280
+ * successes carry `data.results[i].asset` via a side-map
281
+ * fold keyed by `item_id`. `internal_error` re-throws
282
+ * whole-call via the shared dispatchers' escape hatch
283
+ * (M14 round-2 F1 precedent) so schema drift surfaces as
284
+ * top-level `ok: false` rather than per-record.
285
+ * 4. Cache invalidation — single `invalidateBoard(boardId, env)`
286
+ * after the dispatch loop completes (mirrors M38's single-
287
+ * leg invalidate timing; one board covers every matched
288
+ * item's mutated `asset` slot).
289
+ * 5. Envelope emit — `data: BulkFileSetData` with the
290
+ * `operation: 'item_update_bulk_file_set'` literal
291
+ * discriminator + per-item `results[]` + aggregate
292
+ * `summary.{matched_count, applied_count, failed_count,
293
+ * board_id, column_id, filename, file_size_bytes}`. Warnings
294
+ * threaded as `dedupeWarnings([...filterWarnings,
295
+ * ...m38.warnings])` (mirrors the JSON-bulk path); source
296
+ * derives from `metaSource` (cache-served metadata + live
297
+ * wire calls → `mixed`).
298
+ */
299
+ export declare const runItemUpdateBulkFileDispatch: (inputs: RunItemUpdateBulkFileDispatchInputs) => Promise<void>;
100
300
  export {};
101
301
  //# sourceMappingURL=update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/item/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AA+CnE,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AActC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;kBAAsB,CAAC;AAC1D,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,QAAA,MAAM,WAAW;;;;;;;;;;;kBAmFd,CAAC;AA0FJ,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAC3C,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAC3B,gBAAgB,CAoPjB,CAAC"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/item/update.ts"],"names":[],"mappings":"AAAA;;;;;;;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