sdtk-kit 0.3.1 → 0.3.2

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 (25) hide show
  1. package/assets/manifest/toolkit-bundle.manifest.json +69 -34
  2. package/assets/manifest/toolkit-bundle.sha256.txt +22 -15
  3. package/assets/toolkit/toolkit/AGENTS.md +5 -3
  4. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/SKILL.md +6 -4
  5. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/API_DESIGN_CREATION_RULES.md +12 -208
  6. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +451 -0
  7. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/references/FLOWCHART_CREATION_RULES.md +15 -392
  8. package/assets/toolkit/toolkit/skills/sdtk-api-design-spec/scripts/generate_api_design_detail.py +95 -4
  9. package/assets/toolkit/toolkit/skills/sdtk-api-doc/SKILL.md +4 -2
  10. package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +451 -0
  11. package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/FLOWCHART_CREATION_RULES.md +15 -392
  12. package/assets/toolkit/toolkit/skills/sdtk-api-doc/references/YAML_CREATION_RULES.md +128 -0
  13. package/assets/toolkit/toolkit/skills/sdtk-arch/SKILL.md +3 -2
  14. package/assets/toolkit/toolkit/skills/sdtk-arch/references/API_DESIGN_CREATION_RULES.md +12 -208
  15. package/assets/toolkit/toolkit/skills/sdtk-arch/references/API_DESIGN_FLOWCHART_CREATION_RULES.md +451 -0
  16. package/assets/toolkit/toolkit/skills/sdtk-arch/references/FLOWCHART_CREATION_RULES.md +15 -392
  17. package/assets/toolkit/toolkit/skills/sdtk-arch/references/YAML_CREATION_RULES.md +128 -0
  18. package/assets/toolkit/toolkit/templates/README.md +3 -2
  19. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_CREATION_RULES.md +12 -208
  20. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_DETAIL_TEMPLATE.md +1 -2
  21. package/assets/toolkit/toolkit/templates/docs/api/API_DESIGN_FLOWCHART_CREATION_RULES.md +451 -0
  22. package/assets/toolkit/toolkit/templates/docs/api/API_ENDPOINTS_TEMPLATE.md +1 -1
  23. package/assets/toolkit/toolkit/templates/docs/api/FLOWCHART_CREATION_RULES.md +15 -392
  24. package/assets/toolkit/toolkit/templates/docs/api/YAML_CREATION_RULES.md +128 -0
  25. package/package.json +44 -45
@@ -0,0 +1,451 @@
1
+ # API DESIGN + FLOWCHART CREATION RULES FINAL
2
+
3
+ This file is the canonical rule set for:
4
+ - API flow source (`*_api_flow_list.txt`)
5
+ - PlantUML API flowcharts
6
+ - API design detail markdown (`*_API_DESIGN_DETAIL.md`)
7
+
8
+ Use `YAML_CREATION_RULES_FINAL.md` as the source of truth for endpoint contract design.
9
+
10
+ The rules below include the 2026-03-03 flow-style refinements extracted from the Whiteboard API flowchart review.
11
+
12
+ ## 1. Final Review Result
13
+
14
+ After the final pass on `docs/api/schedule_whiteboard_api_flow_list.txt`, there are no remaining critical style mismatches that should block reuse of the current flowchart-writing rules.
15
+
16
+ Current state:
17
+ - All API blocks use visible API header lines.
18
+ - Search-like APIs use query-builder style.
19
+ - CRUD/detail APIs no longer overuse search-style `fullQuery` construction.
20
+ - Batch create uses batch-create style instead of search-style query-builder.
21
+ - `api_design_detail.md` has been regenerated and is aligned with the current flow source.
22
+
23
+ Accepted low-priority exceptions:
24
+ - `POST /file-manager/env/{company_uuid}` uses pseudo `UPSERT` wording. This is acceptable because it is a shared upsert-style API, not a search API.
25
+ - `GET /api/whiteboard/assignment/{company_uuid}/{sagyo_assign_uuid}` still uses a fixed `query = ...` + `LEFT JOIN ...` style. This is intentional and acceptable for a fixed-detail API.
26
+
27
+ ## 2. Source of Extracted Rules
28
+
29
+ These rules were extracted by comparing:
30
+ - `docs/api/schedule_whiteboard_api_flow_list.txt`
31
+ - `docs/api/api_design_detail.md`
32
+ - `Example/Docs/API/bukken-api-flowchart-list.txt`
33
+
34
+ Primary sample references:
35
+ - `POST /bukken/{company_uuid}` style
36
+ - `POST /bukken/edit/{company_uuid}/{bukken_uuid}` style
37
+ - `POST /bukken/delete-parmanent/{company_uuid}/{bukken_uuid}` style
38
+ - `GET /bukken/info/{company_uuid}/{bukken_uuid}` style
39
+ - search API query-builder style shown in the Bukken sample helper flow
40
+
41
+ ## 3. Core Flowchart Writing Rules
42
+
43
+ ### Rule A. Add a visible API header for every block
44
+
45
+ Every API block must start with a visible API header line, for example:
46
+
47
+ ```text
48
+ API: <METHOD> <PATH> <Short Title>
49
+ ```
50
+
51
+ Project-specific variants such as `笆API:` are acceptable only when encoding is stable.
52
+
53
+ Reason:
54
+ - Matches the sample style.
55
+ - Makes raw flow-list files scannable before rendering.
56
+ - Reduces ambiguity when one file contains many APIs.
57
+
58
+ ### Rule B. Use one `@startuml` block per API when generator mapping depends on block count
59
+
60
+ If the markdown/API-design generator maps flow blocks to API endpoints by block count/order:
61
+ - keep exactly one main `@startuml ... @enduml` block per API
62
+ - do not split helper flows into extra standalone blocks unless the generator is updated accordingly
63
+
64
+ Reason:
65
+ - Avoids breaking flow-to-endpoint mapping in generated `*_API_DESIGN_DETAIL.md`.
66
+
67
+ ### Rule C. Flow style must match API type
68
+
69
+ Do not use one style for every API.
70
+ Choose the flow style based on the API purpose:
71
+
72
+ 1. Search/List/Lookup APIs
73
+ - Use query-builder style.
74
+
75
+ 2. Create APIs
76
+ - Use CRUD create style.
77
+
78
+ 3. Edit APIs
79
+ - Use CRUD update style.
80
+
81
+ 4. Delete APIs
82
+ - Use CRUD delete style.
83
+
84
+ 5. Detail APIs
85
+ - Use fixed-record read style.
86
+
87
+ 6. Batch create APIs
88
+ - Use batch-create style with loop.
89
+
90
+ Reason:
91
+ - This is the main difference between the sample Bukken flowchart style and the over-generalized Whiteboard draft.
92
+
93
+ ## 4. Search / List API Rules
94
+
95
+ Applies to:
96
+ - assignment search APIs
97
+ - reserve employee/customer-employee search APIs
98
+ - duplicate-check / lookup APIs that are effectively query-based
99
+ - shared env lookup APIs when they dynamically build lookup conditions
100
+
101
+ ### Rule D. Search APIs should use query-builder style
102
+
103
+ Preferred structure:
104
+
105
+ ```text
106
+ :Create search query and condition statement from request.data.info;
107
+ :query = "SELECT ... FROM ...";
108
+ :query += " LEFT JOIN ...";
109
+ :condition = "WHERE ...";
110
+ ...
111
+ :order_by = "ORDER BY ...";
112
+ :Compose full query:\nfullQuery = query + " " + condition;
113
+ :Add order_by into fullQuery;
114
+ :Execute fullQuery and get data;
115
+ :Close DB connection;
116
+ :Create api response;
117
+ ```
118
+
119
+ ### Rule E. Use uppercase table/column names inside pseudo-SQL
120
+
121
+ Inside SQL-like action text:
122
+ - use uppercase table names
123
+ - use uppercase column names where practical
124
+
125
+ Good:
126
+ - `CLD_DAT_BUKKEN_INFO`
127
+ - `CLD_DAT_BUKKEN_SAGYO_ASSIGN_INFO`
128
+
129
+ Avoid:
130
+ - lowercase-only SQL object names in pseudo-SQL lines
131
+
132
+ Reason:
133
+ - Matches the sample style and improves visual separation between logic text and table identifiers.
134
+
135
+ ### Rule E-1. Do not use fake helper-function wording unless a helper flow is defined
136
+
137
+ Do not write:
138
+ - `Call search_logic_function(parameters)`
139
+ - `Execute search_logic_function(parameters)`
140
+
141
+ unless the flow source also contains a real helper sub-flow block that defines that function logic.
142
+
143
+ If the helper is not actually defined in the same source:
144
+ - write the processing step directly inline
145
+
146
+ Good:
147
+ - `Create search query and condition statement from request.data.info;`
148
+ - `Create duplicate check query and condition statement from request.data.info;`
149
+
150
+ Reason:
151
+ - Avoids implying a reusable sub-flow that does not exist.
152
+ - Keeps the flow self-contained and accurate.
153
+
154
+ ### Rule F. Dynamic array filters should use object-based wording
155
+
156
+ For array filters, use the sample-like loop style:
157
+
158
+ ```text
159
+ if (data.info.department_uuids not null && data.info.department_uuids not empty) then (yes)
160
+ :condition += " AND ( 1 != 1 ";
161
+ repeat
162
+ :Get departmentObject from data.info.department_uuids;
163
+ :condition += " OR E.DEPARTMENT_UUID = <departmentObject.uuid>";
164
+ repeat while (more value data?) is (yes)
165
+ ->no;
166
+ :condition += " )";
167
+ else (no)
168
+ endif
169
+ ```
170
+
171
+ Do not use overly simplified wording like:
172
+ - `Add department filter`
173
+
174
+ Reason:
175
+ - The sample explicitly shows how OR-group conditions are built.
176
+
177
+ ### Rule G. Search APIs should not describe response shaping internals
178
+
179
+ Avoid lines such as:
180
+ - `Compute duplicate_assign ...`
181
+ - `Group data into ...`
182
+ - `Return data.xxx[]`
183
+ - `Aggregate created_count ...` (for non-batch search flows)
184
+
185
+ Instead end the flow at:
186
+ - query completed
187
+ - DB connection closed
188
+ - API response created
189
+
190
+ Reason:
191
+ - The response structure is already defined in YAML.
192
+ - Flowchart should focus on processing logic, not renderer-side or response-object assembly internals.
193
+
194
+ ### Rule H. Explicit `ORDER BY` is required when output order matters
195
+
196
+ If the endpoint contract depends on a specific order:
197
+ - define `order_by = "ORDER BY ..."`
198
+ - then add it into `fullQuery`
199
+
200
+ Do not leave ordering implicit.
201
+
202
+ ## 5. Create API Rules
203
+
204
+ Applies to:
205
+ - single create APIs
206
+
207
+ ### Rule I. Create APIs should use `Insert into ... with parameter value`
208
+
209
+ Preferred style:
210
+
211
+ ```text
212
+ :Insert into CLD_DAT_XXX with parameter value
213
+ field_a = param.data.info.field_a
214
+ field_b = param.data.info.field_b
215
+ create_dt = now;
216
+ :GET inserted_xxx_uuid = XXX_UUID value when Insert into CLD_DAT_XXX;
217
+ :Close DB connection;
218
+ :Create api response;
219
+ ```
220
+
221
+ ### Rule J. Do not over-describe query-builder logic inside create flows
222
+
223
+ Avoid using:
224
+ - `query = "SELECT 1 ..."`
225
+ - `condition = ...`
226
+ - `Compose full query ...`
227
+
228
+ inside normal create flows.
229
+
230
+ If duplicate/business validation is needed:
231
+ - describe it as a business step only
232
+
233
+ Example:
234
+ - `Check overlap conflicts with current parameter value;`
235
+
236
+ Reason:
237
+ - This matches the sample create style and keeps flow readable.
238
+
239
+ ## 6. Edit API Rules
240
+
241
+ Applies to:
242
+ - update APIs
243
+
244
+ ### Rule K. Edit APIs should follow `Select existing -> Update with parameter value`
245
+
246
+ Preferred structure:
247
+
248
+ ```text
249
+ :Get target_uuid from endpoint;
250
+ :Select from CLD_DAT_XXX with target_uuid and del_flg = 0;
251
+ if (record exists) then (yes)
252
+ else (no)
253
+ :Return error status = 140 ...;
254
+ stop
255
+ endif
256
+ :Check business rule if needed;
257
+ :Update CLD_DAT_XXX with parameter value
258
+ field_a = param.data.info.field_a
259
+ field_b = param.data.info.field_b
260
+ update_dt = now
261
+ where target_uuid = target_uuid;
262
+ :Close DB connection;
263
+ :Create api response;
264
+ ```
265
+
266
+ ### Rule L. Keep business checks short inside edit flows
267
+
268
+ If edit has duplicate overlap or other business validation:
269
+ - keep it as one business step
270
+ - do not expand it into a full search-style query-builder
271
+
272
+ Good:
273
+ - `Check overlap conflicts excluding current xxx_uuid;`
274
+
275
+ Avoid:
276
+ - full `query/condition/fullQuery` sequence inside edit flow
277
+
278
+ ## 7. Delete API Rules
279
+
280
+ Applies to:
281
+ - logical delete
282
+ - physical delete
283
+
284
+ ### Rule M. Delete APIs should follow `Select existing -> Delete/Update -> Close -> Response`
285
+
286
+ Preferred structure:
287
+
288
+ ```text
289
+ :Get target_uuid from endpoint;
290
+ :Select from CLD_DAT_XXX with target_uuid and del_flg = 0;
291
+ if (record exists) then (yes)
292
+ else (no)
293
+ :Return error status = 140 ...;
294
+ stop
295
+ endif
296
+ :Update CLD_DAT_XXX with parameter value
297
+ del_flg = 1,
298
+ update_dt = now
299
+ where target_uuid = target_uuid;
300
+ :Close DB connection;
301
+ :Create api response;
302
+ ```
303
+
304
+ If the API is truly permanent delete:
305
+ - use `Delete ... with key is ...`
306
+
307
+ Rule:
308
+ - style may mirror permanent-delete sample
309
+ - but business semantics must still match the actual API contract
310
+
311
+ ## 8. Detail API Rules
312
+
313
+ Applies to:
314
+ - read-one / detail APIs
315
+
316
+ ### Rule N. Detail APIs may use a fixed query, but not search-style dynamic query-builder
317
+
318
+ Allowed:
319
+
320
+ ```text
321
+ :Get target_uuid from endpoint;
322
+ :query = "SELECT ... FROM CLD_DAT_XXX WHERE TARGET_UUID = target_uuid";
323
+ :query += " LEFT JOIN ...";
324
+ :Execute query and get data;
325
+ if (record exists) then (yes)
326
+ ...
327
+ :Close DB connection;
328
+ :Create api response;
329
+ ```
330
+
331
+ Avoid:
332
+ - `condition = ...`
333
+ - `Compose full query ...`
334
+ - dynamic filter loops
335
+
336
+ Reason:
337
+ - Detail APIs are fixed-record lookups, not flexible searches.
338
+
339
+ ## 9. Batch Create API Rules
340
+
341
+ Applies to:
342
+ - APIs that create multiple records in one request
343
+
344
+ ### Rule O. Batch create APIs should use create-style logic with a loop
345
+
346
+ Preferred structure:
347
+
348
+ ```text
349
+ :Create target date list ...;
350
+ ...
351
+ repeat
352
+ :Build per-item datetime/value;
353
+ :Check business conflict with current target date parameter value;
354
+ if (duplicate and skip = false) then (yes)
355
+ :Append skipped result ...;
356
+ else (no)
357
+ :Insert into CLD_DAT_XXX with parameter value
358
+ ...
359
+ :GET inserted_xxx_uuid = XXX_UUID value when Insert into CLD_DAT_XXX;
360
+ :Append created result ...;
361
+ endif
362
+ repeat while (has next target item?) is (yes)
363
+ :Build batch result list and summary counts;
364
+ :Close DB connection;
365
+ :Create api response;
366
+ ```
367
+
368
+ ### Rule P. Do not use search-style query-builder in batch-create loops
369
+
370
+ Avoid inside the loop:
371
+ - `query = "SELECT 1 ..."`
372
+ - `condition = ...`
373
+ - `Compose full query ...`
374
+
375
+ Even when duplicate validation exists, batch create should still read like a create flow with looped business validation.
376
+
377
+ ## 10. Shared System API Rules
378
+
379
+ Applies to:
380
+ - APIs reused from another module but documented in feature flowchart
381
+
382
+ ### Rule Q. Shared lookup APIs may still use query-builder style if they behave like lookup/search
383
+
384
+ Example:
385
+ - environment lookup APIs that build conditions from request array items
386
+
387
+ Allowed:
388
+ - `query = ...`
389
+ - `condition = ...`
390
+ - `Compose full query ...`
391
+
392
+ ### Rule R. Shared upsert APIs should use action-oriented wording, not search wording
393
+
394
+ Example:
395
+
396
+ ```text
397
+ :Create Environment Manager upsert statement from request.data;
398
+ :query = "UPSERT CLD_DAT_ENV_INFO";
399
+ :Resolve target row by ...;
400
+ :Set VALUE / NUMVALUE ...;
401
+ :Execute upsert statement;
402
+ :Close DB connection;
403
+ :Create api response;
404
+ ```
405
+
406
+ Reason:
407
+ - Keeps style aligned with operation type.
408
+
409
+ ## 11. Error / Connection / Ending Rules
410
+
411
+ ### Rule S. Keep auth and validation at the top
412
+
413
+ Use the common pattern:
414
+ - authentication
415
+ - permission
416
+ - validation
417
+ - business processing
418
+ - DB close
419
+ - response
420
+
421
+ ### Rule T. `Close DB connection;` should be near the end of the main flow
422
+
423
+ Preferred:
424
+ - after DB processing finishes
425
+ - before `Create api response;`
426
+
427
+ Avoid:
428
+ - excessive `Close DB connection;` inside every inner loop branch unless the logic truly requires separate connections
429
+
430
+ ### Rule U. End with `Create api response;`
431
+
432
+ Use a simple terminal response action.
433
+
434
+ Do not over-specify:
435
+ - HTTP 200
436
+ - response JSON object construction
437
+ - field-by-field response shaping
438
+
439
+ unless there is a concrete reason the sample style requires it.
440
+
441
+ ## 12. Non-Flow Logic That Should Stay Out of the Flowchart
442
+
443
+ Do not put these into the flow unless they are the core processing logic:
444
+ - FE-only rendering logic
445
+ - detailed response nesting assembly
446
+ - UI display-specific transformations already described by YAML schema
447
+
448
+ Reason:
449
+ - Flowchart should describe processing logic.
450
+ - YAML and endpoint docs already define the response contract.
451
+