monday-cli 0.3.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.
Files changed (198) hide show
  1. package/CHANGELOG.md +719 -0
  2. package/README.md +208 -36
  3. package/dist/api/assets.d.ts +326 -0
  4. package/dist/api/assets.d.ts.map +1 -0
  5. package/dist/api/assets.js +519 -0
  6. package/dist/api/assets.js.map +1 -0
  7. package/dist/api/column-types.d.ts +13 -7
  8. package/dist/api/column-types.d.ts.map +1 -1
  9. package/dist/api/column-types.js +7 -3
  10. package/dist/api/column-types.js.map +1 -1
  11. package/dist/api/column-values.d.ts +8 -1
  12. package/dist/api/column-values.d.ts.map +1 -1
  13. package/dist/api/column-values.js +16 -6
  14. package/dist/api/column-values.js.map +1 -1
  15. package/dist/api/documents.d.ts +1652 -0
  16. package/dist/api/documents.d.ts.map +1 -0
  17. package/dist/api/documents.js +2411 -0
  18. package/dist/api/documents.js.map +1 -0
  19. package/dist/api/item-watch.d.ts +263 -0
  20. package/dist/api/item-watch.d.ts.map +1 -0
  21. package/dist/api/item-watch.js +709 -0
  22. package/dist/api/item-watch.js.map +1 -0
  23. package/dist/api/multipart-transport.d.ts +223 -0
  24. package/dist/api/multipart-transport.d.ts.map +1 -0
  25. package/dist/api/multipart-transport.js +274 -0
  26. package/dist/api/multipart-transport.js.map +1 -0
  27. package/dist/api/parallel-dispatch.d.ts +155 -0
  28. package/dist/api/parallel-dispatch.d.ts.map +1 -0
  29. package/dist/api/parallel-dispatch.js +243 -0
  30. package/dist/api/parallel-dispatch.js.map +1 -0
  31. package/dist/api/partial-success-bulk.d.ts +118 -60
  32. package/dist/api/partial-success-bulk.d.ts.map +1 -1
  33. package/dist/api/partial-success-bulk.js +137 -79
  34. package/dist/api/partial-success-bulk.js.map +1 -1
  35. package/dist/api/partial-success-mutation.d.ts +13 -1
  36. package/dist/api/partial-success-mutation.d.ts.map +1 -1
  37. package/dist/api/partial-success-mutation.js +5 -1
  38. package/dist/api/partial-success-mutation.js.map +1 -1
  39. package/dist/api/raw-write.d.ts +13 -4
  40. package/dist/api/raw-write.d.ts.map +1 -1
  41. package/dist/api/raw-write.js +22 -11
  42. package/dist/api/raw-write.js.map +1 -1
  43. package/dist/api/resolve-client.d.ts +11 -0
  44. package/dist/api/resolve-client.d.ts.map +1 -1
  45. package/dist/api/resolve-client.js +9 -1
  46. package/dist/api/resolve-client.js.map +1 -1
  47. package/dist/api/teams.d.ts +657 -0
  48. package/dist/api/teams.d.ts.map +1 -0
  49. package/dist/api/teams.js +880 -0
  50. package/dist/api/teams.js.map +1 -0
  51. package/dist/cli/run.d.ts +20 -0
  52. package/dist/cli/run.d.ts.map +1 -1
  53. package/dist/cli/run.js +1 -0
  54. package/dist/cli/run.js.map +1 -1
  55. package/dist/commands/board/column-create.d.ts +6 -5
  56. package/dist/commands/board/column-create.d.ts.map +1 -1
  57. package/dist/commands/board/column-create.js +9 -6
  58. package/dist/commands/board/column-create.js.map +1 -1
  59. package/dist/commands/completion.d.ts +188 -0
  60. package/dist/commands/completion.d.ts.map +1 -0
  61. package/dist/commands/completion.js +418 -0
  62. package/dist/commands/completion.js.map +1 -0
  63. package/dist/commands/doc/append-markdown.d.ts +117 -0
  64. package/dist/commands/doc/append-markdown.d.ts.map +1 -0
  65. package/dist/commands/doc/append-markdown.js +253 -0
  66. package/dist/commands/doc/append-markdown.js.map +1 -0
  67. package/dist/commands/doc/block-create.d.ts +114 -0
  68. package/dist/commands/doc/block-create.d.ts.map +1 -0
  69. package/dist/commands/doc/block-create.js +206 -0
  70. package/dist/commands/doc/block-create.js.map +1 -0
  71. package/dist/commands/doc/block-delete.d.ts +72 -0
  72. package/dist/commands/doc/block-delete.d.ts.map +1 -0
  73. package/dist/commands/doc/block-delete.js +161 -0
  74. package/dist/commands/doc/block-delete.js.map +1 -0
  75. package/dist/commands/doc/block-update.d.ts +75 -0
  76. package/dist/commands/doc/block-update.d.ts.map +1 -0
  77. package/dist/commands/doc/block-update.js +162 -0
  78. package/dist/commands/doc/block-update.js.map +1 -0
  79. package/dist/commands/doc/create-in-workspace.d.ts +76 -0
  80. package/dist/commands/doc/create-in-workspace.d.ts.map +1 -0
  81. package/dist/commands/doc/create-in-workspace.js +164 -0
  82. package/dist/commands/doc/create-in-workspace.js.map +1 -0
  83. package/dist/commands/doc/create-on-column.d.ts +71 -0
  84. package/dist/commands/doc/create-on-column.d.ts.map +1 -0
  85. package/dist/commands/doc/create-on-column.js +146 -0
  86. package/dist/commands/doc/create-on-column.js.map +1 -0
  87. package/dist/commands/doc/delete.d.ts +68 -0
  88. package/dist/commands/doc/delete.d.ts.map +1 -0
  89. package/dist/commands/doc/delete.js +146 -0
  90. package/dist/commands/doc/delete.js.map +1 -0
  91. package/dist/commands/doc/duplicate.d.ts +101 -0
  92. package/dist/commands/doc/duplicate.d.ts.map +1 -0
  93. package/dist/commands/doc/duplicate.js +191 -0
  94. package/dist/commands/doc/duplicate.js.map +1 -0
  95. package/dist/commands/doc/get.d.ts +46 -0
  96. package/dist/commands/doc/get.d.ts.map +1 -0
  97. package/dist/commands/doc/get.js +95 -0
  98. package/dist/commands/doc/get.js.map +1 -0
  99. package/dist/commands/doc/import-html.d.ts +125 -0
  100. package/dist/commands/doc/import-html.d.ts.map +1 -0
  101. package/dist/commands/doc/import-html.js +273 -0
  102. package/dist/commands/doc/import-html.js.map +1 -0
  103. package/dist/commands/doc/list.d.ts +86 -0
  104. package/dist/commands/doc/list.d.ts.map +1 -0
  105. package/dist/commands/doc/list.js +217 -0
  106. package/dist/commands/doc/list.js.map +1 -0
  107. package/dist/commands/doc/rename.d.ts +60 -0
  108. package/dist/commands/doc/rename.d.ts.map +1 -0
  109. package/dist/commands/doc/rename.js +135 -0
  110. package/dist/commands/doc/rename.js.map +1 -0
  111. package/dist/commands/index.d.ts.map +1 -1
  112. package/dist/commands/index.js +162 -0
  113. package/dist/commands/index.js.map +1 -1
  114. package/dist/commands/item/create.js +2 -2
  115. package/dist/commands/item/update.d.ts +1 -0
  116. package/dist/commands/item/update.d.ts.map +1 -1
  117. package/dist/commands/item/update.js +61 -0
  118. package/dist/commands/item/update.js.map +1 -1
  119. package/dist/commands/item/upload.d.ts +108 -0
  120. package/dist/commands/item/upload.d.ts.map +1 -0
  121. package/dist/commands/item/upload.js +370 -0
  122. package/dist/commands/item/upload.js.map +1 -0
  123. package/dist/commands/item/watch.d.ts +90 -0
  124. package/dist/commands/item/watch.d.ts.map +1 -0
  125. package/dist/commands/item/watch.js +342 -0
  126. package/dist/commands/item/watch.js.map +1 -0
  127. package/dist/commands/update/create.d.ts.map +1 -1
  128. package/dist/commands/update/create.js +6 -4
  129. package/dist/commands/update/create.js.map +1 -1
  130. package/dist/commands/update/edit.d.ts +4 -2
  131. package/dist/commands/update/edit.d.ts.map +1 -1
  132. package/dist/commands/update/edit.js +10 -6
  133. package/dist/commands/update/edit.js.map +1 -1
  134. package/dist/commands/update/reply.d.ts +4 -2
  135. package/dist/commands/update/reply.d.ts.map +1 -1
  136. package/dist/commands/update/reply.js +10 -6
  137. package/dist/commands/update/reply.js.map +1 -1
  138. package/dist/commands/update/upload.d.ts +69 -0
  139. package/dist/commands/update/upload.d.ts.map +1 -0
  140. package/dist/commands/update/upload.js +235 -0
  141. package/dist/commands/update/upload.js.map +1 -0
  142. package/dist/commands/user/_team-membership.d.ts +10 -0
  143. package/dist/commands/user/_team-membership.d.ts.map +1 -0
  144. package/dist/commands/user/_team-membership.js +88 -0
  145. package/dist/commands/user/_team-membership.js.map +1 -0
  146. package/dist/commands/user/team-add-members.d.ts +81 -0
  147. package/dist/commands/user/team-add-members.d.ts.map +1 -0
  148. package/dist/commands/user/team-add-members.js +186 -0
  149. package/dist/commands/user/team-add-members.js.map +1 -0
  150. package/dist/commands/user/team-create.d.ts +82 -0
  151. package/dist/commands/user/team-create.d.ts.map +1 -0
  152. package/dist/commands/user/team-create.js +206 -0
  153. package/dist/commands/user/team-create.js.map +1 -0
  154. package/dist/commands/user/team-delete.d.ts +56 -0
  155. package/dist/commands/user/team-delete.d.ts.map +1 -0
  156. package/dist/commands/user/team-delete.js +137 -0
  157. package/dist/commands/user/team-delete.js.map +1 -0
  158. package/dist/commands/user/team-get.d.ts +41 -0
  159. package/dist/commands/user/team-get.d.ts.map +1 -0
  160. package/dist/commands/user/team-get.js +87 -0
  161. package/dist/commands/user/team-get.js.map +1 -0
  162. package/dist/commands/user/team-list.d.ts +39 -0
  163. package/dist/commands/user/team-list.d.ts.map +1 -0
  164. package/dist/commands/user/team-list.js +90 -0
  165. package/dist/commands/user/team-list.js.map +1 -0
  166. package/dist/commands/user/team-remove-members.d.ts +71 -0
  167. package/dist/commands/user/team-remove-members.d.ts.map +1 -0
  168. package/dist/commands/user/team-remove-members.js +176 -0
  169. package/dist/commands/user/team-remove-members.js.map +1 -0
  170. package/dist/types/ids.d.ts +8 -0
  171. package/dist/types/ids.d.ts.map +1 -1
  172. package/dist/types/ids.js +53 -5
  173. package/dist/types/ids.js.map +1 -1
  174. package/dist/utils/mime.d.ts +24 -0
  175. package/dist/utils/mime.d.ts.map +1 -0
  176. package/dist/utils/mime.js +64 -0
  177. package/dist/utils/mime.js.map +1 -0
  178. package/dist/utils/output/envelope.d.ts +30 -0
  179. package/dist/utils/output/envelope.d.ts.map +1 -1
  180. package/dist/utils/output/envelope.js +26 -0
  181. package/dist/utils/output/envelope.js.map +1 -1
  182. package/dist/utils/output/ndjson.d.ts +25 -0
  183. package/dist/utils/output/ndjson.d.ts.map +1 -1
  184. package/dist/utils/output/ndjson.js +12 -0
  185. package/dist/utils/output/ndjson.js.map +1 -1
  186. package/dist/utils/parse-brand-list.d.ts +95 -0
  187. package/dist/utils/parse-brand-list.d.ts.map +1 -0
  188. package/dist/utils/parse-brand-list.js +96 -0
  189. package/dist/utils/parse-brand-list.js.map +1 -0
  190. package/dist/utils/signal.d.ts +42 -0
  191. package/dist/utils/signal.d.ts.map +1 -0
  192. package/dist/utils/signal.js +45 -0
  193. package/dist/utils/signal.js.map +1 -0
  194. package/dist/utils/source-content.d.ts +93 -0
  195. package/dist/utils/source-content.d.ts.map +1 -0
  196. package/dist/utils/source-content.js +120 -0
  197. package/dist/utils/source-content.js.map +1 -0
  198. package/package.json +1 -1
@@ -0,0 +1,273 @@
1
+ /**
2
+ * `monday doc import-html --workspace <wid> (--html <file|-> |
3
+ * --html-string <s>) [--folder <fid>] [--kind public|private|share]
4
+ * [--title <t>] [--dry-run]` — import an HTML payload as a new workdoc
5
+ * (`cli-design.md` §4.3 DOC section + §13 v0.5 entry;
6
+ * `v0.5-plan.md` §3 M37 + §8 D12-D13).
7
+ *
8
+ * **Wire shape.** Single `import_doc_from_html(html, workspaceId,
9
+ * kind?, folderId?, title?) → ImportDocFromHtmlResult` round-trip via
10
+ * {@link importDocFromHtml} against `mutation ImportDocFromHtml` with
11
+ * `operationName: 'ImportDocFromHtml'` (R-NEW-37 W2 audit-point).
12
+ * Custom-OBJECT return shape: `{success!, doc_id?, error?}` —
13
+ * distinct from M35's opaque-JSON projection and M36's typed-OBJECT
14
+ * direct-unwrap (third doc-mutation return shape; see
15
+ * `src/api/documents.ts` M37 section header for the full taxonomy).
16
+ *
17
+ * **camelCase wire-arg note.** `import_doc_from_html` uses camelCase
18
+ * `workspaceId` / `folderId` on the wire (Finding 7); CLI argv stays
19
+ * kebab-case (`--workspace <wid>` / `--folder <fid>`); error envelope
20
+ * `details.*` keys stay snake_case (`details.workspace_id` /
21
+ * `details.folder_id`) per cli-design §6.5. See the canonical
22
+ * asymmetry note at `src/api/documents.ts` module header (5th
23
+ * supporting site for R-NEW-41).
24
+ *
25
+ * **Argv shape.**
26
+ *
27
+ * - `--workspace <wid>` — required (Monday's
28
+ * `import_doc_from_html.workspaceId` is `ID!`). Numeric workspace
29
+ * ID; brand-validated via {@link WorkspaceIdSchema} at the parse
30
+ * boundary.
31
+ * - `--html <file|->` OR `--html-string <s>` — **mutually-exclusive
32
+ * content source; exactly one required.** Both forms supply the
33
+ * HTML payload that Monday parses into a new doc; the source path
34
+ * vs inline-string split mirrors M13's `update reply / edit`
35
+ * `--body-file <path>` vs `--body <md>` shape. The file path form
36
+ * supports `-` for stdin (read up to EOF; cli-design §3.1 stdin
37
+ * discipline). The inline form caps at
38
+ * {@link MAX_DOC_IMPORT_PAYLOAD_BYTES} bytes at the parse
39
+ * boundary per D13 closure (empirical wire threshold sits
40
+ * between 250KB-OK and 500KB-rejected). The file/stdin form
41
+ * applies the same size guard at the runtime read boundary
42
+ * (defense-in-depth via the lifted {@link readSourceContent}
43
+ * helper's `maxBytes` slot).
44
+ * - `--folder <fid>` — optional (maps to wire `folderId: ID`).
45
+ * Numeric folder ID; brand-validated via {@link DocFolderIdSchema}.
46
+ * Absent → doc lands at workspace root.
47
+ * - `--kind <k>` — optional 3-value closed enum
48
+ * (`public` / `private` / `share`); maps to wire `kind: DocKind`.
49
+ * Absent → Monday applies the wire-side default `public` per
50
+ * probe description ("Defaults to 'public' if not specified").
51
+ * - `--title <t>` — optional, non-empty (maps to wire
52
+ * `title: String`). Absent → Monday infers the title from the
53
+ * HTML content per probe description ("If not provided, the
54
+ * title will be inferred from the HTML content").
55
+ *
56
+ * **Output envelope.** Custom-OBJECT projection per D12 — `data: {
57
+ * doc_id, success: true }` mirroring M35's
58
+ * {@link docMutationResultSchema} cadence so agents read a uniform
59
+ * `{ doc_id, success }` shape across rename / delete / duplicate /
60
+ * import-html. The `doc_id` slot carries the NEWLY-CREATED doc's id
61
+ * (extracted from `ImportDocFromHtmlResult.doc_id`).
62
+ *
63
+ * **Failure mapping** per D12 closure:
64
+ *
65
+ * - `success: false + populated error` → `validation_failed` with
66
+ * `details: { workspace_id, error, hint }`.
67
+ * - `success: false + empty/null error` → `internal_error` with
68
+ * wire-regression hint.
69
+ * - `success: true + missing/null doc_id` → `internal_error`
70
+ * (Monday promises a non-null `doc_id` on success).
71
+ * - Oversized inline `--html-string` at parse boundary →
72
+ * `usage_error.details.issues[{path: 'htmlString', message:
73
+ * '--html-string exceeds the 256000-byte wire-side limit ...'}]`
74
+ * from `parseArgv`'s zod-issues envelope (D13 closure). The
75
+ * `usage_error` rejection surfaces ahead of any wire dispatch.
76
+ * - Oversized file payload at runtime →
77
+ * `readSourceContent` rejects with `usage_error` carrying
78
+ * `details: { source: 'file' | 'stdin', size_bytes, limit_bytes,
79
+ * file_path? }`.
80
+ *
81
+ * **Dry-run shape** per cli-design §6.4 mutation-dry-run variant.
82
+ * Minimal envelope listing the planned `import_doc_from_html`
83
+ * operation + the resolved input fields (`workspace_id`, optional
84
+ * `folder_id`, optional `kind`, optional `title`, `html_source`
85
+ * descriptor — file path / `'(stdin)'` / `'(inline)'`). Does NOT
86
+ * include the HTML payload itself (which could be hundreds of KB);
87
+ * agents see WHAT would be sent, not the bytes. No preflight read
88
+ * fires; `meta.source: 'none'`.
89
+ *
90
+ * **Idempotent: false.** Re-running creates a duplicate doc with a
91
+ * fresh id (Monday's wire does not dedupe by HTML content or title).
92
+ * Agents that need idempotency must pair with a `monday doc list
93
+ * --workspace <wid>` lookup first.
94
+ *
95
+ * **Permission-sensitive.** Tokens lacking workdoc-create scope on
96
+ * the target workspace surface `forbidden` (mapped from Monday's
97
+ * PERMISSION_DENIED extension).
98
+ *
99
+ * **Runtime body landed at v0.5-M37 IMPL.** `parseArgv` runs BEFORE
100
+ * `resolveClient` so invalid argv surfaces `usage_error` ahead of any
101
+ * missing-token `config_error`; the lifted {@link readSourceContent}
102
+ * helper applies the same size guard at the runtime read boundary
103
+ * (file/stdin path) that the schema's `.refine()` applies at parse
104
+ * boundary (inline path). Dry-run emits minimal planned changes with
105
+ * the source descriptor; live path dispatches
106
+ * {@link importDocFromHtml} + projects via `emitMutation`.
107
+ */
108
+ import { z } from 'zod';
109
+ import { ensureSubcommand } from '../types.js';
110
+ import { parseArgv } from '../parse-argv.js';
111
+ import { emitDryRun, emitMutation } from '../emit.js';
112
+ import { resolveClient } from '../../api/resolve-client.js';
113
+ import { WorkspaceIdSchema, DocFolderIdSchema } from '../../types/ids.js';
114
+ import { DOC_KIND_VALUES, MAX_DOC_IMPORT_PAYLOAD_BYTES, docImportHtmlOutputSchema, importDocFromHtml, } from '../../api/documents.js';
115
+ import { readSourceContent } from '../../utils/source-content.js';
116
+ const inputSchema = z
117
+ .object({
118
+ workspace: WorkspaceIdSchema,
119
+ /**
120
+ * File path for the HTML content (`-` reads from stdin). Mutually
121
+ * exclusive with `htmlString` — exactly one required, enforced by
122
+ * the cross-field `.refine()` below. The size guard against
123
+ * {@link MAX_DOC_IMPORT_PAYLOAD_BYTES} applies at the runtime
124
+ * read boundary via {@link readSourceContent}'s `maxBytes` slot
125
+ * — file content size isn't known at argv-parse time.
126
+ */
127
+ html: z.string().min(1, '--html must be a non-empty file path (use `-` for stdin)').optional(),
128
+ /**
129
+ * Literal HTML payload string. Mutually exclusive with `html`.
130
+ * Capped at {@link MAX_DOC_IMPORT_PAYLOAD_BYTES} bytes (UTF-8)
131
+ * at parse boundary per D13 closure (empirical wire threshold
132
+ * sits between 250KB-OK and 500KB-rejected; conservative pin at
133
+ * 250KB last-known-good).
134
+ */
135
+ htmlString: z
136
+ .string()
137
+ .min(1, '--html-string must not be empty')
138
+ .refine((s) => s.trim().length > 0, {
139
+ message: '--html-string must not be whitespace-only (zero non-whitespace bytes after trim). Pass HTML content.',
140
+ })
141
+ .refine((s) => Buffer.byteLength(s, 'utf8') <= MAX_DOC_IMPORT_PAYLOAD_BYTES, {
142
+ message: `--html-string exceeds the ${MAX_DOC_IMPORT_PAYLOAD_BYTES.toString()}-byte wire-side limit (empirical probe pinned the threshold between 250KB OK and 500KB rejected; pass --html <file> with a smaller payload, or split the import across multiple calls)`,
143
+ })
144
+ .optional(),
145
+ folder: DocFolderIdSchema.optional(),
146
+ kind: z.enum(DOC_KIND_VALUES).optional(),
147
+ title: z.string().min(1, '--title must not be empty (omit the flag to let Monday infer the title from HTML)').optional(),
148
+ })
149
+ .strict()
150
+ .refine((v) => (v.html === undefined) !== (v.htmlString === undefined), {
151
+ message: '--html (file path or `-` for stdin) and --html-string (literal HTML) are mutually exclusive; supply exactly one',
152
+ path: ['html'],
153
+ });
154
+ const describeHtmlSource = (html, htmlString) => {
155
+ if (htmlString !== undefined)
156
+ return '(inline)';
157
+ if (html === '-')
158
+ return '(stdin)';
159
+ // The cross-field `.refine()` guarantees exactly one of `html` /
160
+ // `htmlString` is set at this point; the fallthrough only reaches
161
+ // a string-valued `html`.
162
+ if (html === undefined) {
163
+ // Defensive — the schema's `.refine()` prevents this branch from
164
+ // firing in production. Surface a clear internal error if a future
165
+ // refactor weakens the invariant.
166
+ throw new Error('describeHtmlSource: invariant violated — neither html nor htmlString set after refine');
167
+ }
168
+ return html;
169
+ };
170
+ export const docImportHtmlCommand = {
171
+ name: 'doc.import-html',
172
+ summary: 'Import an HTML payload as a new workdoc (--workspace + --html|--html-string required)',
173
+ examples: [
174
+ 'monday doc import-html --workspace 5555 --html-string \'<h1>Plan</h1><p>Body</p>\'',
175
+ 'monday doc import-html --workspace 5555 --html ./plan.html --title "Q4 launch plan"',
176
+ 'cat plan.html | monday doc import-html --workspace 5555 --html - --kind private',
177
+ 'monday doc import-html --workspace 5555 --html-string \'<p>x</p>\' --folder 12345 --dry-run --json',
178
+ ],
179
+ // Re-running creates a fresh duplicate doc — Monday's wire does not
180
+ // dedupe by HTML content or title. Mark non-idempotent so agents
181
+ // don't naively retry on transient failures.
182
+ idempotent: false,
183
+ inputSchema,
184
+ outputSchema: docImportHtmlOutputSchema,
185
+ attach: (program, ctx) => {
186
+ const noun = ensureSubcommand(program, 'doc', 'Workdoc commands');
187
+ noun
188
+ .command('import-html')
189
+ .description(docImportHtmlCommand.summary)
190
+ .requiredOption('--workspace <wid>', 'numeric workspace ID (maps to wire `workspaceId: ID!`)')
191
+ .option('--html <file>', 'file path containing the HTML payload (use `-` to read from stdin); mutually exclusive with --html-string')
192
+ .option('--html-string <s>', `literal HTML payload (maps to wire \`html: String!\`); capped at ${MAX_DOC_IMPORT_PAYLOAD_BYTES.toString()} bytes UTF-8 per D13 empirical threshold; mutually exclusive with --html`)
193
+ .option('--folder <fid>', 'optional numeric folder ID (maps to wire `folderId: ID`); absent → doc lands at workspace root')
194
+ .option(`--kind <${DOC_KIND_VALUES.join('|')}>`, 'optional doc kind (maps to wire `kind: DocKind`); absent → Monday\'s wire-side default `public` applies')
195
+ .option('--title <t>', 'optional doc title (maps to wire `title: String`); absent → Monday infers the title from the HTML content')
196
+ .addHelpText('after', [
197
+ '',
198
+ 'Examples:',
199
+ ...docImportHtmlCommand.examples.map((e) => ` ${e}`),
200
+ '',
201
+ 'Notes:',
202
+ ` - Inline --html-string is capped at ${MAX_DOC_IMPORT_PAYLOAD_BYTES.toString()} bytes (~250KB) at parse boundary per D13 closure; file path / stdin forms apply the same cap at runtime.`,
203
+ ' - Re-running creates a duplicate doc; this verb is non-idempotent.',
204
+ ' - `--dry-run` emits the planned `import_doc_from_html` operation + resolved input slots (HTML payload omitted; only its source descriptor is logged).',
205
+ '',
206
+ ].join('\n'))
207
+ .action(async (opts) => {
208
+ const parsed = parseArgv(docImportHtmlCommand.inputSchema, opts);
209
+ const { client, globalFlags, apiVersion } = resolveClient(ctx, program.opts());
210
+ if (globalFlags.dryRun) {
211
+ // Minimal dry-run shape per cli-design §6.4 mutation-
212
+ // dry-run variant — argv-derived, no preflight read. The
213
+ // HTML payload itself is omitted (potentially hundreds of
214
+ // KB); agents see WHAT would be sent + the source it would
215
+ // come from via `html_source: '(inline)' | '(stdin)' | <path>`.
216
+ const planned = {
217
+ operation: 'import_doc_from_html',
218
+ workspace_id: parsed.workspace,
219
+ html_source: describeHtmlSource(parsed.html, parsed.htmlString),
220
+ };
221
+ if (parsed.folder !== undefined) {
222
+ planned.folder_id = parsed.folder;
223
+ }
224
+ if (parsed.kind !== undefined) {
225
+ planned.kind = parsed.kind;
226
+ }
227
+ if (parsed.title !== undefined) {
228
+ planned.title = parsed.title;
229
+ }
230
+ emitDryRun({
231
+ ctx,
232
+ programOpts: program.opts(),
233
+ plannedChanges: [planned],
234
+ source: 'none',
235
+ cacheAgeSeconds: null,
236
+ warnings: [],
237
+ apiVersion,
238
+ });
239
+ return;
240
+ }
241
+ const html = await readSourceContent({
242
+ inline: parsed.htmlString,
243
+ file: parsed.html,
244
+ stdin: ctx.stdin,
245
+ inlineFlagName: '--html-string',
246
+ fileFlagName: '--html',
247
+ verbHint: 'monday doc import-html requires either --html <file|-> or ' +
248
+ '--html-string <s>. Use --html - to read from stdin.',
249
+ maxBytes: MAX_DOC_IMPORT_PAYLOAD_BYTES,
250
+ });
251
+ const result = await importDocFromHtml({
252
+ client,
253
+ html,
254
+ workspaceId: parsed.workspace,
255
+ ...(parsed.kind === undefined ? {} : { kind: parsed.kind }),
256
+ ...(parsed.folder === undefined ? {} : { folderId: parsed.folder }),
257
+ ...(parsed.title === undefined ? {} : { title: parsed.title }),
258
+ });
259
+ emitMutation({
260
+ ctx,
261
+ data: result.result,
262
+ schema: docImportHtmlCommand.outputSchema,
263
+ programOpts: program.opts(),
264
+ warnings: [],
265
+ source: result.source,
266
+ cacheAgeSeconds: result.cacheAgeSeconds,
267
+ complexity: result.complexity,
268
+ apiVersion,
269
+ });
270
+ });
271
+ },
272
+ };
273
+ //# sourceMappingURL=import-html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-html.js","sourceRoot":"","sources":["../../../src/commands/doc/import-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0GG;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,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AC;YACH,YAAY,CAAC;gBACX,GAAG;gBACH,IAAI,EAAE,MAAM,CAAC,MAAM;gBACnB,MAAM,EAAE,oBAAoB,CAAC,YAAY;gBACzC,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,CAAC,CAAC;IACP,CAAC;CACF,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * `monday doc list [--workspace <wid>,...] [--order-by <created_at|
3
+ * used_at>] [--limit <n>] [--page <n>]` — list workdocs visible to
4
+ * the token, optionally filtered by workspace and sorted by recency
5
+ * (cli-design.md §4.3 DOC section + §13 v0.4 entry; v0.4-plan.md §3
6
+ * M32).
7
+ *
8
+ * **Wire shape.** Single `Query.docs(...)` round-trip via
9
+ * {@link listDocuments} against `query ListDocs` with
10
+ * `operationName: 'ListDocs'` (R-NEW-37 W2 audit-point). Page/limit
11
+ * pagination — Monday's workdocs surface has no `items_page`-style
12
+ * cursor; agents paginate by incrementing `--page`. The list row
13
+ * projection ships every base Document field EXCEPT `blocks` per
14
+ * D6 closure (rich-text bodies belong to `monday doc get <did>`).
15
+ *
16
+ * **Argv shape.**
17
+ *
18
+ * - `--workspace <wid>,...` — comma-separated workspace ID
19
+ * filter (maps to wire `workspace_ids: [ID]`). Optional;
20
+ * absent → unfiltered (every visible doc across the account).
21
+ * Each entry is brand-validated via {@link WorkspaceIdSchema}.
22
+ * Inaccessible workspace IDs surface as empty filter results
23
+ * per D4 — Monday's wire silently drops unknown workspace IDs
24
+ * rather than rejecting the call; the CLI doesn't fire a
25
+ * resolver warning because the wire doesn't distinguish "no
26
+ * docs in workspace X" from "X not accessible".
27
+ * - `--order-by <created_at|used_at>` — pinned 2-value enum
28
+ * (per the M32 probe of `DocsOrderBy`). Default
29
+ * `created_at`. Both values sort `desc` server-side; no
30
+ * ascending variant on Monday's wire.
31
+ * - `--limit <n>` — `[1, 100]`, default `25` (matches Monday's
32
+ * wire-side default; ceiling pins worst-case payload size).
33
+ * Out-of-range argv rejects at parse boundary with
34
+ * `usage_error` (no wire call fires).
35
+ * - `--page <n>` — 1-based, default `1`. Out-of-range argv
36
+ * rejects at parse boundary.
37
+ *
38
+ * **Output envelope (D9).** Wrapped record `data: { documents:
39
+ * [Document], page, limit, returned_count, has_more }`.
40
+ * `has_more` is the `returned_count === limit` heuristic —
41
+ * Monday's wire doesn't surface a total count, so "exactly limit
42
+ * rows returned" is the only signal that a follow-up page may
43
+ * exist. Agents that need exhaustive listing loop until
44
+ * `has_more: false`.
45
+ *
46
+ * **Docs are live-only at v0.4-M32** per cli-design §8 cache
47
+ * scope. Output `meta.source: "live"`, `meta.cache_age_seconds:
48
+ * null`. Workdocs are content-heavy + frequently human-edited; the
49
+ * stale-cache risk outweighs the cache-hit value.
50
+ *
51
+ * **Idempotent: yes** (pure read).
52
+ *
53
+ * **Runtime body landed at v0.4-M32 IMPL.** Argv parsing + schema +
54
+ * commander wiring + `--workspace` comma-split helper all ship as
55
+ * the real shipped argv surface; the action body's wire-call
56
+ * dispatch + envelope emit are below. The verb is a thin wrapper
57
+ * around {@link listDocuments} — comma-split argv → branded array
58
+ * → fetcher → envelope.
59
+ */
60
+ import { z } from 'zod';
61
+ import { type CommandModule } from '../types.js';
62
+ import { type DocListOutput } from '../../api/documents.js';
63
+ declare const inputSchema: z.ZodObject<{
64
+ workspace: z.ZodOptional<z.ZodString>;
65
+ orderBy: z.ZodOptional<z.ZodEnum<{
66
+ created_at: "created_at";
67
+ used_at: "used_at";
68
+ }>>;
69
+ limit: z.ZodOptional<z.ZodNumber>;
70
+ page: z.ZodOptional<z.ZodNumber>;
71
+ }, z.core.$strict>;
72
+ export declare const docListCommand: CommandModule<z.infer<typeof inputSchema>, DocListOutput>;
73
+ /**
74
+ * Internals exposed for unit-test access (argv parser pinning).
75
+ * NOT a public API — the decimal parser stays production-internal.
76
+ * The previous `parseWorkspaceListArg` member migrated to the
77
+ * lifted {@link parseBrandedListArg} helper at the M34 pre-flight
78
+ * kickoff (R-NEW-70 4-consumer lift); per-flag user-facing message
79
+ * shapes for `--workspace` are pinned via the lifted helper's
80
+ * options + tested at `tests/unit/utils/parse-brand-list.test.ts`.
81
+ */
82
+ export declare const _internals: {
83
+ readonly parseStrictDecimal: (raw: string) => number;
84
+ };
85
+ export {};
86
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/doc/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAMnE,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAEhC,QAAA,MAAM,WAAW;;;;;;;;kBA6BN,CAAC;AAEZ,eAAO,MAAM,cAAc,EAAE,aAAa,CACxC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,EAC3B,aAAa,CAsHd,CAAC;AAwBF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU;uCAhBU,MAAM,KAAG,MAAM;CAkBtC,CAAC"}
@@ -0,0 +1,217 @@
1
+ /**
2
+ * `monday doc list [--workspace <wid>,...] [--order-by <created_at|
3
+ * used_at>] [--limit <n>] [--page <n>]` — list workdocs visible to
4
+ * the token, optionally filtered by workspace and sorted by recency
5
+ * (cli-design.md §4.3 DOC section + §13 v0.4 entry; v0.4-plan.md §3
6
+ * M32).
7
+ *
8
+ * **Wire shape.** Single `Query.docs(...)` round-trip via
9
+ * {@link listDocuments} against `query ListDocs` with
10
+ * `operationName: 'ListDocs'` (R-NEW-37 W2 audit-point). Page/limit
11
+ * pagination — Monday's workdocs surface has no `items_page`-style
12
+ * cursor; agents paginate by incrementing `--page`. The list row
13
+ * projection ships every base Document field EXCEPT `blocks` per
14
+ * D6 closure (rich-text bodies belong to `monday doc get <did>`).
15
+ *
16
+ * **Argv shape.**
17
+ *
18
+ * - `--workspace <wid>,...` — comma-separated workspace ID
19
+ * filter (maps to wire `workspace_ids: [ID]`). Optional;
20
+ * absent → unfiltered (every visible doc across the account).
21
+ * Each entry is brand-validated via {@link WorkspaceIdSchema}.
22
+ * Inaccessible workspace IDs surface as empty filter results
23
+ * per D4 — Monday's wire silently drops unknown workspace IDs
24
+ * rather than rejecting the call; the CLI doesn't fire a
25
+ * resolver warning because the wire doesn't distinguish "no
26
+ * docs in workspace X" from "X not accessible".
27
+ * - `--order-by <created_at|used_at>` — pinned 2-value enum
28
+ * (per the M32 probe of `DocsOrderBy`). Default
29
+ * `created_at`. Both values sort `desc` server-side; no
30
+ * ascending variant on Monday's wire.
31
+ * - `--limit <n>` — `[1, 100]`, default `25` (matches Monday's
32
+ * wire-side default; ceiling pins worst-case payload size).
33
+ * Out-of-range argv rejects at parse boundary with
34
+ * `usage_error` (no wire call fires).
35
+ * - `--page <n>` — 1-based, default `1`. Out-of-range argv
36
+ * rejects at parse boundary.
37
+ *
38
+ * **Output envelope (D9).** Wrapped record `data: { documents:
39
+ * [Document], page, limit, returned_count, has_more }`.
40
+ * `has_more` is the `returned_count === limit` heuristic —
41
+ * Monday's wire doesn't surface a total count, so "exactly limit
42
+ * rows returned" is the only signal that a follow-up page may
43
+ * exist. Agents that need exhaustive listing loop until
44
+ * `has_more: false`.
45
+ *
46
+ * **Docs are live-only at v0.4-M32** per cli-design §8 cache
47
+ * scope. Output `meta.source: "live"`, `meta.cache_age_seconds:
48
+ * null`. Workdocs are content-heavy + frequently human-edited; the
49
+ * stale-cache risk outweighs the cache-hit value.
50
+ *
51
+ * **Idempotent: yes** (pure read).
52
+ *
53
+ * **Runtime body landed at v0.4-M32 IMPL.** Argv parsing + schema +
54
+ * commander wiring + `--workspace` comma-split helper all ship as
55
+ * the real shipped argv surface; the action body's wire-call
56
+ * dispatch + envelope emit are below. The verb is a thin wrapper
57
+ * around {@link listDocuments} — comma-split argv → branded array
58
+ * → fetcher → envelope.
59
+ */
60
+ import { z } from 'zod';
61
+ import { ensureSubcommand } from '../types.js';
62
+ import { parseArgv } from '../parse-argv.js';
63
+ import { emitSuccess } from '../emit.js';
64
+ import { resolveClient } from '../../api/resolve-client.js';
65
+ import { WorkspaceIdSchema } from '../../types/ids.js';
66
+ import { parseBrandedListArg } from '../../utils/parse-brand-list.js';
67
+ import { DEFAULT_DOC_LIST_LIMIT, MAX_DOC_LIST_LIMIT, MIN_DOC_LIST_LIMIT, docListOutputSchema, docsOrderBySchema, listDocuments, } from '../../api/documents.js';
68
+ const inputSchema = z
69
+ .object({
70
+ /**
71
+ * Raw comma-separated workspace IDs (e.g. `"123,456"`). Split +
72
+ * brand-validated inside the action body so the per-entry parse
73
+ * boundary fires AFTER the top-level argv parse — keeps the
74
+ * error envelope's `details.issues[].path` pointing at the
75
+ * `--workspace` argv slot rather than a per-entry index.
76
+ */
77
+ workspace: z.string().min(1, '--workspace must not be empty').optional(),
78
+ orderBy: docsOrderBySchema.optional(),
79
+ limit: z
80
+ .number()
81
+ .int({ message: '--limit must be an integer' })
82
+ .min(MIN_DOC_LIST_LIMIT, {
83
+ message: `--limit must be at least ${String(MIN_DOC_LIST_LIMIT)}`,
84
+ })
85
+ .max(MAX_DOC_LIST_LIMIT, {
86
+ message: `--limit must be at most ${String(MAX_DOC_LIST_LIMIT)} ` +
87
+ `(M32 pins the ceiling to keep worst-case response sizes bounded ` +
88
+ `for doc-heavy accounts)`,
89
+ })
90
+ .optional(),
91
+ page: z
92
+ .number()
93
+ .int({ message: '--page must be an integer' })
94
+ .min(1, { message: '--page is 1-based and must be at least 1' })
95
+ .optional(),
96
+ })
97
+ .strict();
98
+ export const docListCommand = {
99
+ name: 'doc.list',
100
+ summary: 'List workdocs visible to the token (optional workspace filter)',
101
+ examples: [
102
+ 'monday doc list',
103
+ 'monday doc list --workspace 12345',
104
+ 'monday doc list --workspace 12345,67890 --order-by used_at --limit 50',
105
+ 'monday doc list --page 2 --limit 25 --json',
106
+ ],
107
+ idempotent: true,
108
+ inputSchema,
109
+ outputSchema: docListOutputSchema,
110
+ attach: (program, ctx) => {
111
+ const noun = ensureSubcommand(program, 'doc', 'Document commands (workdocs; read-only at v0.4 — see cli-design §13 v0.4 entry)');
112
+ noun
113
+ .command('list')
114
+ .description(docListCommand.summary)
115
+ .option('--workspace <list>', 'Comma-separated workspace IDs to filter docs by (e.g. "12345,67890"). Inaccessible workspace IDs return no docs.')
116
+ .option('--order-by <field>', 'Sort field; one of: created_at (default), used_at. Both sort desc; no ascending variant on the wire.')
117
+ .option('--limit <n>', `Page size, range [${String(MIN_DOC_LIST_LIMIT)}, ${String(MAX_DOC_LIST_LIMIT)}]; default ${String(DEFAULT_DOC_LIST_LIMIT)}.`, parseStrictDecimal)
118
+ .option('--page <n>', '1-based page number; default 1.', parseStrictDecimal)
119
+ .addHelpText('after', [
120
+ '',
121
+ 'Examples:',
122
+ ...docListCommand.examples.map((e) => ` ${e}`),
123
+ '',
124
+ 'Notes:',
125
+ ` - Default limit ${String(DEFAULT_DOC_LIST_LIMIT)} matches Monday's wire-side default.`,
126
+ ' - has_more in the envelope is a returned_count === limit heuristic (Monday\'s wire doesn\'t surface a total count).',
127
+ '',
128
+ ].join('\n'))
129
+ .action(async (opts) => {
130
+ const parsed = parseArgv(docListCommand.inputSchema, {
131
+ ...(opts.workspace === undefined ? {} : { workspace: opts.workspace }),
132
+ ...(opts.orderBy === undefined ? {} : { orderBy: opts.orderBy }),
133
+ ...(opts.limit === undefined ? {} : { limit: opts.limit }),
134
+ ...(opts.page === undefined ? {} : { page: opts.page }),
135
+ });
136
+ // Parse `--workspace` once at the boundary so a malformed
137
+ // workspace ID surfaces `usage_error` ahead of any wire
138
+ // call. Empty entries (trailing comma, double comma) reject
139
+ // with a clear hint. Brand each entry via WorkspaceIdSchema
140
+ // so a non-numeric token reaches the agent with the same
141
+ // brand-error shape every other ID validator uses.
142
+ // Helper lifted to `src/utils/parse-brand-list.ts` at the
143
+ // M34 pre-flight kickoff (R-NEW-70 4-consumer lift ahead-
144
+ // of-feat per R-NEW-29 M25 cadence; v0.5-plan §22).
145
+ const workspaceIds = parsed.workspace === undefined
146
+ ? undefined
147
+ : parseBrandedListArg(parsed.workspace, WorkspaceIdSchema, {
148
+ flagName: '--workspace',
149
+ entryDescription: 'numeric workspace ID',
150
+ hint: 'workspace IDs are numeric (e.g. 12345)',
151
+ emptyEntryHint: 'e.g. --workspace 12345,67890 — no leading, trailing, or ' +
152
+ 'duplicate commas',
153
+ });
154
+ const { client, apiVersion } = resolveClient(ctx, program.opts());
155
+ const result = await listDocuments({
156
+ client,
157
+ ...(workspaceIds === undefined ? {} : { workspaceIds }),
158
+ ...(parsed.orderBy === undefined ? {} : { orderBy: parsed.orderBy }),
159
+ ...(parsed.limit === undefined ? {} : { limit: parsed.limit }),
160
+ ...(parsed.page === undefined ? {} : { page: parsed.page }),
161
+ });
162
+ const returnedCount = result.documents.length;
163
+ emitSuccess({
164
+ ctx,
165
+ data: {
166
+ documents: [...result.documents],
167
+ page: result.page,
168
+ limit: result.limit,
169
+ returned_count: returnedCount,
170
+ has_more: returnedCount === result.limit,
171
+ },
172
+ schema: docListCommand.outputSchema,
173
+ programOpts: program.opts(),
174
+ kind: 'single',
175
+ warnings: [],
176
+ source: result.source,
177
+ cacheAgeSeconds: result.cacheAgeSeconds,
178
+ complexity: result.complexity,
179
+ apiVersion,
180
+ });
181
+ });
182
+ },
183
+ };
184
+ /**
185
+ * Strict decimal-integer parser for commander option-value coercion
186
+ * on `--limit` + `--page`. `Number.parseInt` would silently truncate
187
+ * `'25.5'` → `25` and `'25abc'` → `25`, bypassing the schema-layer
188
+ * `.int()` check (Codex round-1 P2-1). The strict variant returns
189
+ * `Number.NaN` for any input that isn't a decimal-integer string;
190
+ * the schema's `.int()` then rejects `NaN` and the user sees a
191
+ * `usage_error` with the per-flag bound-violation message.
192
+ *
193
+ * Leading-zero handling: a single `0` is accepted (range floor is
194
+ * enforced separately by the schema), but `'01'` / `'007'` are
195
+ * rejected because Monday's wire IDs and page numbers never carry
196
+ * leading zeros + the strict shape matches `DECIMAL_USER_ID_PATTERN`
197
+ * elsewhere in the codebase.
198
+ */
199
+ const parseStrictDecimal = (raw) => {
200
+ if (!/^(?:0|[1-9]\d*)$/u.test(raw)) {
201
+ return Number.NaN;
202
+ }
203
+ return Number.parseInt(raw, 10);
204
+ };
205
+ /**
206
+ * Internals exposed for unit-test access (argv parser pinning).
207
+ * NOT a public API — the decimal parser stays production-internal.
208
+ * The previous `parseWorkspaceListArg` member migrated to the
209
+ * lifted {@link parseBrandedListArg} helper at the M34 pre-flight
210
+ * kickoff (R-NEW-70 4-consumer lift); per-flag user-facing message
211
+ * shapes for `--workspace` are pinned via the lifted helper's
212
+ * options + tested at `tests/unit/utils/parse-brand-list.test.ts`.
213
+ */
214
+ export const _internals = {
215
+ parseStrictDecimal,
216
+ };
217
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/doc/list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;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,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAA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