zinkee 0.1.44 → 0.1.45

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 (94) hide show
  1. package/README.md +4 -0
  2. package/dist/chunk-MHEVRMDX.js +1230 -0
  3. package/dist/chunk-MHEVRMDX.js.map +1 -0
  4. package/{src/utils/examples.ts → dist/examples-E6FFEVBE.js} +856 -1141
  5. package/dist/examples-E6FFEVBE.js.map +1 -0
  6. package/dist/index.js +1145 -8456
  7. package/dist/index.js.map +1 -1
  8. package/package.json +6 -3
  9. package/.github/workflows/npm-publish.yml +0 -77
  10. package/.github/workflows/pr-checks.yml +0 -36
  11. package/AGENTS.md +0 -110
  12. package/docs/cli-contract.md +0 -41
  13. package/docs/npm-release.md +0 -64
  14. package/docs/superpowers/plans/2026-03-24-zinkee-cli-implementation.md +0 -837
  15. package/docs/superpowers/plans/2026-03-25-cli-backend-error-contract.md +0 -503
  16. package/docs/superpowers/plans/2026-03-26-display-freeform-create.md +0 -389
  17. package/docs/superpowers/specs/2026-03-24-zinkee-cli-backend-blockers.md +0 -172
  18. package/docs/superpowers/specs/2026-03-24-zinkee-cli-design.md +0 -1576
  19. package/docs/superpowers/specs/2026-03-24-zinkee-cli-e2e-checklist.md +0 -215
  20. package/docs/superpowers/specs/2026-03-24-zinkee-cli-e2e-design.md +0 -492
  21. package/docs/superpowers/specs/2026-03-24-zinkee-cli-e2e-status.md +0 -307
  22. package/docs/superpowers/specs/2026-07-30-cli-pr-checks-design.md +0 -37
  23. package/src/api/automations.ts +0 -404
  24. package/src/api/comments.ts +0 -51
  25. package/src/api/displays.ts +0 -337
  26. package/src/api/document-templates.ts +0 -110
  27. package/src/api/files.ts +0 -50
  28. package/src/api/formulas.test.ts +0 -65
  29. package/src/api/formulas.ts +0 -67
  30. package/src/api/logs.ts +0 -34
  31. package/src/api/navigation.ts +0 -70
  32. package/src/api/records.ts +0 -184
  33. package/src/api/schemas.ts +0 -148
  34. package/src/api/teamspace.ts +0 -110
  35. package/src/cli-examples.ts +0 -130
  36. package/src/cli-runner.ts +0 -95
  37. package/src/client.test.ts +0 -189
  38. package/src/client.ts +0 -269
  39. package/src/command-registry.ts +0 -882
  40. package/src/commands/automations.test.ts +0 -1030
  41. package/src/commands/automations.ts +0 -2102
  42. package/src/commands/comments.test.ts +0 -214
  43. package/src/commands/comments.ts +0 -303
  44. package/src/commands/config.test.ts +0 -81
  45. package/src/commands/config.ts +0 -150
  46. package/src/commands/displays.test.ts +0 -1105
  47. package/src/commands/displays.ts +0 -1442
  48. package/src/commands/document-templates.test.ts +0 -569
  49. package/src/commands/document-templates.ts +0 -563
  50. package/src/commands/files.test.ts +0 -284
  51. package/src/commands/files.ts +0 -280
  52. package/src/commands/formulas.test.ts +0 -194
  53. package/src/commands/formulas.ts +0 -243
  54. package/src/commands/logs.test.ts +0 -123
  55. package/src/commands/logs.ts +0 -159
  56. package/src/commands/navigation.test.ts +0 -211
  57. package/src/commands/navigation.ts +0 -348
  58. package/src/commands/profiles.test.ts +0 -191
  59. package/src/commands/profiles.ts +0 -303
  60. package/src/commands/records.test.ts +0 -860
  61. package/src/commands/records.ts +0 -883
  62. package/src/commands/schemas.test.ts +0 -1252
  63. package/src/commands/schemas.ts +0 -890
  64. package/src/commands/teamspace.test.ts +0 -229
  65. package/src/commands/teamspace.ts +0 -546
  66. package/src/completion/engine.test.ts +0 -138
  67. package/src/completion/engine.ts +0 -168
  68. package/src/completion/install.test.ts +0 -179
  69. package/src/completion/install.ts +0 -260
  70. package/src/completion/runtime.ts +0 -150
  71. package/src/completion/scripts.ts +0 -91
  72. package/src/config.test.ts +0 -362
  73. package/src/config.ts +0 -294
  74. package/src/index.test.ts +0 -217
  75. package/src/index.ts +0 -8
  76. package/src/parsers/expressions.test.ts +0 -95
  77. package/src/parsers/expressions.ts +0 -128
  78. package/src/parsers/kv.test.ts +0 -35
  79. package/src/parsers/kv.ts +0 -49
  80. package/src/parsers/selectors.test.ts +0 -23
  81. package/src/parsers/selectors.ts +0 -29
  82. package/src/program.ts +0 -64
  83. package/src/runtime-context.ts +0 -103
  84. package/src/types.ts +0 -76
  85. package/src/utils/argv-rewrite.test.ts +0 -149
  86. package/src/utils/argv-rewrite.ts +0 -269
  87. package/src/utils/errors.test.ts +0 -85
  88. package/src/utils/errors.ts +0 -191
  89. package/src/utils/examples.test.ts +0 -374
  90. package/src/utils/output.test.ts +0 -65
  91. package/src/utils/output.ts +0 -154
  92. package/src/utils/schema-fields.ts +0 -1016
  93. package/tsconfig.json +0 -20
  94. package/tsup.config.ts +0 -13
@@ -1,503 +0,0 @@
1
- # CLI and Backend Error Contract Implementation Plan
2
-
3
- > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
-
5
- **Goal:** Make the CLI preserve useful backend error details, align request payloads with the real API contract, and close the highest-value backend validation gaps found during real E2E usage.
6
-
7
- **Architecture:** Fix the contract at two layers. In the CLI, preserve backend JSON errors instead of collapsing them to `unknown_error`, resolve schema slugs before hitting UUID-only endpoints, and emit patch payloads in the shape the API actually expects. In the backend, tighten request binding/validation so accepted CLI payloads work consistently and rejected payloads fail with specific, actionable reasons.
8
-
9
- **Tech Stack:** TypeScript ESM CLI with Commander/Vitest, Java Spring WebFlux backend, workflow service, nexus connection service.
10
-
11
- ---
12
-
13
- ## File Map
14
-
15
- **CLI files**
16
- - Modify: `/Users/david/dev/z2/cli/src/client.ts`
17
- - Modify: `/Users/david/dev/z2/cli/src/utils/errors.ts`
18
- - Modify: `/Users/david/dev/z2/cli/src/commands/records.ts`
19
- - Modify: `/Users/david/dev/z2/cli/src/commands/schemas.ts`
20
- - Modify: `/Users/david/dev/z2/cli/src/commands/automations.ts`
21
- - Modify: `/Users/david/dev/z2/cli/src/utils/examples.ts`
22
- - Modify: `/Users/david/dev/z2/cli/src/commands/records.test.ts`
23
- - Modify: `/Users/david/dev/z2/cli/src/commands/schemas.test.ts`
24
- - Modify: `/Users/david/dev/z2/cli/src/commands/automations.test.ts`
25
- - Create: `/Users/david/dev/z2/cli/src/client.test.ts`
26
-
27
- **Backend files**
28
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/infra/web/v2/schema/SchemaV2Handler.java`
29
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/domain/model/v2/schema/SchemaV2CreateFieldRequest.java`
30
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/schema/SchemaV2ContractValidator.java`
31
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/schema/SchemaV2FieldValidationService.java`
32
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/schema/SchemaV2FieldTranslator.java`
33
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationV2Service.java`
34
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationV2ContractValidator.java`
35
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationConnectionV2Service.java`
36
- - Modify: `/Users/david/dev/z2/z2-backend/workflow/src/main/java/com/zinkee/workflow/application/WorkflowService.java`
37
- - Modify: `/Users/david/dev/z2/z2-backend/nexus/src/main/java/com/zinkee/nexus/application/ConnectionService.java`
38
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/config/error/GlobalErrorWebExceptionHandlerTest.java`
39
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/schema/SchemaV2RequestBindingTest.java`
40
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/schema/SchemaV2ServiceTest.java`
41
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/automation/AutomationV2ServiceTest.java`
42
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/automation/AutomationCatalogV2ServiceTest.java`
43
- - Modify: `/Users/david/dev/z2/z2-backend/workflow/src/test/java/com/zinkee/workflow/application/WorkflowServiceTest.java`
44
- - Modify: `/Users/david/dev/z2/z2-backend/nexus/src/test/java/com/zinkee/nexus/application/ConnectionServiceTest.java`
45
-
46
- ## Task 1: Preserve Structured Backend Errors in the CLI
47
-
48
- **Files:**
49
- - Modify: `/Users/david/dev/z2/cli/src/client.ts`
50
- - Modify: `/Users/david/dev/z2/cli/src/utils/errors.ts`
51
- - Create: `/Users/david/dev/z2/cli/src/client.test.ts`
52
-
53
- - [ ] **Step 1: Add or adjust the relevant tests**
54
-
55
- Add tests that simulate a backend `400` returning JSON like:
56
-
57
- ```json
58
- {
59
- "status": 400,
60
- "error": "BAD_REQUEST",
61
- "reason": "schema_id_invalid",
62
- "message": "Schema identifier is invalid.",
63
- "action": "Use a valid UUID in the schemaId field.",
64
- "requestId": "req-123"
65
- }
66
- ```
67
-
68
- Assert that the CLI error JSON preserves:
69
- - backend `message`
70
- - backend `reason`
71
- - backend `action`
72
- - backend `requestId`
73
- - HTTP `status`
74
-
75
- - [ ] **Step 2: Run the relevant check and capture the current result**
76
-
77
- Run:
78
-
79
- ```bash
80
- npm test -- src/client.test.ts
81
- ```
82
-
83
- Expected: new assertions fail because `http_error` is currently converted into plain `unknown_error`.
84
-
85
- - [ ] **Step 3: Write minimal implementation**
86
-
87
- In `/Users/david/dev/z2/cli/src/client.ts`, keep attaching parsed `responseBody` to `ApiClientError`.
88
-
89
- In `/Users/david/dev/z2/cli/src/utils/errors.ts`, detect `ApiClientError` with `responseBody` shaped like the backend envelope and convert it into a `CliError` that preserves details:
90
-
91
- ```ts
92
- details: {
93
- status,
94
- reason,
95
- action,
96
- requestId,
97
- path,
98
- }
99
- ```
100
-
101
- Do not discard the backend `message`.
102
-
103
- - [ ] **Step 4: Run verification to confirm the intended result**
104
-
105
- Run:
106
-
107
- ```bash
108
- npm test -- src/client.test.ts src/commands/automations.test.ts src/commands/schemas.test.ts src/commands/records.test.ts
109
- ```
110
-
111
- Expected: CLI JSON errors now expose the backend reason/action/requestId when present.
112
-
113
- - [ ] **Step 5: Commit**
114
-
115
- ```bash
116
- git add src/client.ts src/utils/errors.ts src/client.test.ts src/commands/automations.test.ts src/commands/schemas.test.ts src/commands/records.test.ts
117
- git commit -m "fix: preserve backend error details in cli json output"
118
- ```
119
-
120
- ## Task 2: Resolve Schema Slugs Before Hitting UUID-Only Record Endpoints
121
-
122
- **Files:**
123
- - Modify: `/Users/david/dev/z2/cli/src/commands/records.ts`
124
- - Modify: `/Users/david/dev/z2/cli/src/commands/records.test.ts`
125
-
126
- - [ ] **Step 1: Add or adjust the relevant test**
127
-
128
- Add tests for `records create`, `records query`, `records update`, and `records delete` proving that when the user passes a schema slug, the command resolves it before calling the API path that currently requires UUID.
129
-
130
- - [ ] **Step 2: Run the relevant check and capture the current result**
131
-
132
- Run:
133
-
134
- ```bash
135
- npm test -- src/commands/records.test.ts
136
- ```
137
-
138
- Expected: slug-based write/query tests fail or do not exist yet.
139
-
140
- - [ ] **Step 3: Write minimal implementation**
141
-
142
- Extract the schema-resolution logic already present in `/Users/david/dev/z2/cli/src/commands/schemas.ts` into a shared helper, or duplicate it carefully for records first if you want the smallest safe change.
143
-
144
- Apply that resolver before:
145
- - `api.listRecords`
146
- - `api.queryRecords`
147
- - `api.getRecord`
148
- - `api.createRecord`
149
- - `api.updateRecord`
150
- - `api.deleteRecord`
151
-
152
- - [ ] **Step 4: Run verification to confirm the intended result**
153
-
154
- Run:
155
-
156
- ```bash
157
- npm test -- src/commands/records.test.ts
158
- ```
159
-
160
- Expected: record commands accept slug input and hit the API with UUID selectors.
161
-
162
- - [ ] **Step 5: Commit**
163
-
164
- ```bash
165
- git add src/commands/records.ts src/commands/records.test.ts
166
- git commit -m "fix: resolve schema slugs for records commands"
167
- ```
168
-
169
- ## Task 3: Align `automations update` With the Backend Patch Contract
170
-
171
- **Files:**
172
- - Modify: `/Users/david/dev/z2/cli/src/commands/automations.ts`
173
- - Modify: `/Users/david/dev/z2/cli/src/commands/automations.test.ts`
174
- - Modify: `/Users/david/dev/z2/cli/src/utils/examples.ts`
175
-
176
- - [ ] **Step 1: Add or adjust the relevant test**
177
-
178
- Add a test asserting that:
179
-
180
- ```bash
181
- zinkee automations update <id> --name X --description Y
182
- ```
183
-
184
- builds:
185
-
186
- ```json
187
- {
188
- "set": {
189
- "name": "X",
190
- "description": "Y"
191
- }
192
- }
193
- ```
194
-
195
- not:
196
-
197
- ```json
198
- {
199
- "name": "X",
200
- "description": "Y"
201
- }
202
- ```
203
-
204
- - [ ] **Step 2: Run the relevant check and capture the current result**
205
-
206
- Run:
207
-
208
- ```bash
209
- npm test -- src/commands/automations.test.ts
210
- ```
211
-
212
- Expected: update payload test fails because the CLI currently sends top-level fields.
213
-
214
- - [ ] **Step 3: Write minimal implementation**
215
-
216
- Change `buildAutomationUpdateInput` in `/Users/david/dev/z2/cli/src/commands/automations.ts` so CLI flags populate `input.set`, and `--raw` is either:
217
- - required to already be in backend patch shape, or
218
- - normalized into patch shape when passed as flat metadata fields.
219
-
220
- Do not mix two incompatible patch contracts in the same request.
221
-
222
- - [ ] **Step 4: Run verification to confirm the intended result**
223
-
224
- Run:
225
-
226
- ```bash
227
- npm test -- src/commands/automations.test.ts
228
- ```
229
-
230
- Expected: the command emits patch payloads compatible with `AutomationV2PatchRequest(Map<String,Object> set, List<String> unset)`.
231
-
232
- - [ ] **Step 5: Commit**
233
-
234
- ```bash
235
- git add src/commands/automations.ts src/commands/automations.test.ts src/utils/examples.ts
236
- git commit -m "fix: send automation patch payloads in backend contract shape"
237
- ```
238
-
239
- ## Task 4: Make `connections update` Nested Mutations Predictable
240
-
241
- **Files:**
242
- - Modify: `/Users/david/dev/z2/cli/src/commands/automations.ts`
243
- - Modify: `/Users/david/dev/z2/cli/src/commands/automations.test.ts`
244
-
245
- - [ ] **Step 1: Add or adjust the relevant test**
246
-
247
- Add tests for:
248
-
249
- ```bash
250
- zinkee automations connections update <id> --set name=foo
251
- zinkee automations connections update <id> --set config.headerName=X-Api-Key
252
- ```
253
-
254
- Assert that dotted keys are either:
255
- - expanded into `{ set: { config: { headerName: "X-Api-Key" }}}`, or
256
- - rejected locally with a precise CLI error telling the user to use `--raw`.
257
-
258
- - [ ] **Step 2: Run the relevant check and capture the current result**
259
-
260
- Run:
261
-
262
- ```bash
263
- npm test -- src/commands/automations.test.ts
264
- ```
265
-
266
- Expected: nested config path behavior is missing or wrong.
267
-
268
- - [ ] **Step 3: Write minimal implementation**
269
-
270
- Preferred CLI behavior:
271
- - keep flat keys like `name`
272
- - expand `config.*` into a nested `config` object inside `set`
273
- - if multiple `config.*` assignments appear, merge them
274
-
275
- Fallback acceptable behavior:
276
- - reject dotted paths with a precise `invalid_cli_usage` message and force `--raw`
277
-
278
- - [ ] **Step 4: Run verification to confirm the intended result**
279
-
280
- Run:
281
-
282
- ```bash
283
- npm test -- src/commands/automations.test.ts
284
- ```
285
-
286
- Expected: nested connection config updates are deterministic instead of silently partial.
287
-
288
- - [ ] **Step 5: Commit**
289
-
290
- ```bash
291
- git add src/commands/automations.ts src/commands/automations.test.ts
292
- git commit -m "fix: normalize nested connection patch paths"
293
- ```
294
-
295
- ## Task 5: Relax `schemas fields create` So Raw-Driven Flows Are Usable
296
-
297
- **Files:**
298
- - Modify: `/Users/david/dev/z2/cli/src/commands/schemas.ts`
299
- - Modify: `/Users/david/dev/z2/cli/src/commands/schemas.test.ts`
300
- - Modify: `/Users/david/dev/z2/cli/src/utils/examples.ts`
301
-
302
- - [ ] **Step 1: Add or adjust the relevant test**
303
-
304
- Add a test showing that this is valid:
305
-
306
- ```bash
307
- zinkee schemas fields create <schema> --raw '{"type":"TextField","slug":"email","label":"Email","config":{"placeholder":"Email"}}'
308
- ```
309
-
310
- and does not require duplicate `--type/--slug/--label` flags.
311
-
312
- - [ ] **Step 2: Run the relevant check and capture the current result**
313
-
314
- Run:
315
-
316
- ```bash
317
- npm test -- src/commands/schemas.test.ts
318
- ```
319
-
320
- Expected: raw-only field creation fails because Commander requires the explicit flags.
321
-
322
- - [ ] **Step 3: Write minimal implementation**
323
-
324
- Replace unconditional `.requiredOption(...)` with validation inside the action:
325
- - accept values from flags or raw payload
326
- - require `type`, `slug`, `label` only after merging both sources
327
- - preserve current shorthand normalization from `text` to `TextField`
328
-
329
- - [ ] **Step 4: Run verification to confirm the intended result**
330
-
331
- Run:
332
-
333
- ```bash
334
- npm test -- src/commands/schemas.test.ts
335
- ```
336
-
337
- Expected: field creation works in both flag-first and raw-first flows.
338
-
339
- - [ ] **Step 5: Commit**
340
-
341
- ```bash
342
- git add src/commands/schemas.ts src/commands/schemas.test.ts src/utils/examples.ts
343
- git commit -m "fix: allow raw-first schema field creation flows"
344
- ```
345
-
346
- ## Task 6: Backend Fixes for Schema Field Config and Automation Contracts
347
-
348
- **Files:**
349
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/domain/model/v2/schema/SchemaV2CreateFieldRequest.java`
350
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/schema/SchemaV2FieldValidationService.java`
351
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/schema/SchemaV2FieldTranslator.java`
352
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationV2Service.java`
353
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationV2ContractValidator.java`
354
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/schema/SchemaV2RequestBindingTest.java`
355
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/schema/SchemaV2ServiceTest.java`
356
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/automation/AutomationV2ServiceTest.java`
357
-
358
- - [ ] **Step 1: Add or adjust the relevant tests**
359
-
360
- Backend tests to add:
361
- - `SchemaV2CreateFieldRequest` binds `config` for `TextField`
362
- - `SchemaV2Service` accepts a `TextField` with a harmless config payload like `{"placeholder":"Email"}`
363
- - `AutomationV2Service.createAutomation` accepts the exact payload the CLI currently emits for `record_created`
364
- - `AutomationV2Service.patchAutomation` keeps honoring `{ set, unset }` and mutates metadata correctly
365
-
366
- - [ ] **Step 2: Run the relevant check and capture the current result**
367
-
368
- Run:
369
-
370
- ```bash
371
- cd /Users/david/dev/z2/z2-backend
372
- ./gradlew api:test --tests '*SchemaV2*' --tests '*AutomationV2ServiceTest*'
373
- ```
374
-
375
- Expected: at least one new test should fail and expose the current mismatch.
376
-
377
- - [ ] **Step 3: Write minimal implementation**
378
-
379
- For schema field config:
380
- - inspect `SchemaV2FieldConfigBinding.deserialize(type, config)`
381
- - make `TextField` config either bind successfully or be explicitly ignored if harmless
382
- - keep validation strict for truly invalid configs, but stop rejecting benign config objects wholesale
383
-
384
- For automation create:
385
- - inspect `AutomationV2ContractValidator.validateCreateRequest`
386
- - make sure the CLI-emitted trigger payload for `record_created` is actually accepted if semantically valid
387
-
388
- For automation patch:
389
- - keep the backend contract as `{ set, unset }`
390
- - confirm `applyMetadataPatch` remains the single source of truth
391
-
392
- - [ ] **Step 4: Run verification to confirm the intended result**
393
-
394
- Run:
395
-
396
- ```bash
397
- cd /Users/david/dev/z2/z2-backend
398
- ./gradlew api:test --tests '*SchemaV2RequestBindingTest*' --tests '*SchemaV2ServiceTest*' --tests '*AutomationV2ServiceTest*'
399
- ```
400
-
401
- Expected: request binding and contract tests pass.
402
-
403
- - [ ] **Step 5: Commit**
404
-
405
- ```bash
406
- git -C /Users/david/dev/z2/z2-backend add api/src/main/java api/src/test/java
407
- git -C /Users/david/dev/z2/z2-backend commit -m "fix: align schema field and automation api contracts"
408
- ```
409
-
410
- ## Task 7: Backend Fix for Nested Connection Patch Semantics
411
-
412
- **Files:**
413
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationConnectionV2Service.java`
414
- - Modify: `/Users/david/dev/z2/z2-backend/nexus/src/main/java/com/zinkee/nexus/application/ConnectionService.java`
415
- - Modify: `/Users/david/dev/z2/z2-backend/nexus/src/test/java/com/zinkee/nexus/application/ConnectionServiceTest.java`
416
- - Modify: `/Users/david/dev/z2/z2-backend/api/src/test/java/com/zinkee/api/service/v2/automation/AutomationCatalogV2ServiceTest.java`
417
-
418
- - [ ] **Step 1: Add or adjust the relevant test**
419
-
420
- Add a backend test asserting that a patch like:
421
-
422
- ```json
423
- {
424
- "set": {
425
- "name": "foo",
426
- "config": {
427
- "headerName": "X-Api-Key"
428
- }
429
- }
430
- }
431
- ```
432
-
433
- updates both the flat field and the config field.
434
-
435
- - [ ] **Step 2: Run the relevant check and capture the current result**
436
-
437
- Run:
438
-
439
- ```bash
440
- cd /Users/david/dev/z2/z2-backend
441
- ./gradlew api:test --tests '*AutomationCatalogV2ServiceTest*' --tests '*ConnectionServiceTest*'
442
- ```
443
-
444
- Expected: nested config patch coverage is missing or failing.
445
-
446
- - [ ] **Step 3: Write minimal implementation**
447
-
448
- Keep the backend contract simple:
449
- - `set.config` replaces config as a whole object
450
- - do not try to support dotted paths in the backend if the CLI can normalize them first
451
- - ensure config replacement preserves intentional values and passes validation in `ConnectionService`
452
-
453
- - [ ] **Step 4: Run verification to confirm the intended result**
454
-
455
- Run:
456
-
457
- ```bash
458
- cd /Users/david/dev/z2/z2-backend
459
- ./gradlew api:test --tests '*AutomationCatalogV2ServiceTest*' --tests '*ConnectionServiceTest*'
460
- ```
461
-
462
- Expected: connection patch semantics are explicit and test-covered.
463
-
464
- - [ ] **Step 5: Commit**
465
-
466
- ```bash
467
- git -C /Users/david/dev/z2/z2-backend add api/src/main/java nexus/src/main/java api/src/test/java nexus/src/test/java
468
- git -C /Users/david/dev/z2/z2-backend commit -m "fix: support config replacement in connection patch flows"
469
- ```
470
-
471
- ## Backend Agent Handoff
472
-
473
- Give the backend agent this brief:
474
-
475
- 1. Reproduce these exact contract mismatches from the CLI investigation:
476
- - `POST /api/v2/schemas/{id}/fields` with `{"type":"TextField","slug":"email","label":"Email","required":true,"config":{"placeholder":"Email probe"}}` returns `reason=schema_field_create_request_invalid`.
477
- - `POST /api/v2/automations` with `{"name":"proxy-auto-create","trigger":{"type":"record_created","config":{"schemaId":"2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e","conditions":[{"field":"status","comparator":"eq","values":["active"]}]}}}` returns `reason=automation_create_payload_invalid`.
478
- - `PATCH /api/v2/automations/{id}` with `{"set":{"name":"X","description":"Y"}}` should update metadata and return the updated resource.
479
- - `PATCH /api/v2/automation-connections/{id}` with `{"set":{"name":"foo","config":{"headerName":"X-Api-Key"}}}` should update both name and config.
480
-
481
- 2. Start in these files:
482
- - `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/infra/web/v2/schema/SchemaV2Handler.java`
483
- - `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/domain/model/v2/schema/SchemaV2CreateFieldRequest.java`
484
- - `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/schema/SchemaV2FieldValidationService.java`
485
- - `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationV2Service.java`
486
- - `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationV2ContractValidator.java`
487
- - `/Users/david/dev/z2/z2-backend/api/src/main/java/com/zinkee/api/service/v2/automation/AutomationConnectionV2Service.java`
488
- - `/Users/david/dev/z2/z2-backend/nexus/src/main/java/com/zinkee/nexus/application/ConnectionService.java`
489
- - `/Users/david/dev/z2/z2-backend/workflow/src/main/java/com/zinkee/workflow/application/WorkflowService.java`
490
-
491
- 3. Success criteria:
492
- - backend keeps returning structured `reason` codes
493
- - valid payloads stop failing
494
- - patch endpoints actually mutate and return the mutated resource
495
- - new tests cover the exact payloads above
496
-
497
- 4. Verification commands:
498
-
499
- ```bash
500
- cd /Users/david/dev/z2/z2-backend
501
- ./gradlew api:test --tests '*SchemaV2*' --tests '*AutomationV2*' --tests '*ConnectionServiceTest*'
502
- ```
503
-