@zigrivers/scaffold 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +477 -0
- package/dist/cli/commands/adopt.d.ts +12 -0
- package/dist/cli/commands/adopt.d.ts.map +1 -0
- package/dist/cli/commands/adopt.js +107 -0
- package/dist/cli/commands/adopt.js.map +1 -0
- package/dist/cli/commands/adopt.test.d.ts +2 -0
- package/dist/cli/commands/adopt.test.d.ts.map +1 -0
- package/dist/cli/commands/adopt.test.js +277 -0
- package/dist/cli/commands/adopt.test.js.map +1 -0
- package/dist/cli/commands/build.d.ts +12 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +105 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/build.test.d.ts +2 -0
- package/dist/cli/commands/build.test.d.ts.map +1 -0
- package/dist/cli/commands/build.test.js +272 -0
- package/dist/cli/commands/build.test.js.map +1 -0
- package/dist/cli/commands/dashboard.d.ts +14 -0
- package/dist/cli/commands/dashboard.d.ts.map +1 -0
- package/dist/cli/commands/dashboard.js +102 -0
- package/dist/cli/commands/dashboard.js.map +1 -0
- package/dist/cli/commands/dashboard.test.d.ts +2 -0
- package/dist/cli/commands/dashboard.test.d.ts.map +1 -0
- package/dist/cli/commands/dashboard.test.js +142 -0
- package/dist/cli/commands/dashboard.test.js.map +1 -0
- package/dist/cli/commands/decisions.d.ts +13 -0
- package/dist/cli/commands/decisions.d.ts.map +1 -0
- package/dist/cli/commands/decisions.js +62 -0
- package/dist/cli/commands/decisions.js.map +1 -0
- package/dist/cli/commands/decisions.test.d.ts +2 -0
- package/dist/cli/commands/decisions.test.d.ts.map +1 -0
- package/dist/cli/commands/decisions.test.js +154 -0
- package/dist/cli/commands/decisions.test.js.map +1 -0
- package/dist/cli/commands/info.d.ts +12 -0
- package/dist/cli/commands/info.d.ts.map +1 -0
- package/dist/cli/commands/info.js +110 -0
- package/dist/cli/commands/info.js.map +1 -0
- package/dist/cli/commands/info.test.d.ts +2 -0
- package/dist/cli/commands/info.test.d.ts.map +1 -0
- package/dist/cli/commands/info.test.js +392 -0
- package/dist/cli/commands/info.test.js.map +1 -0
- package/dist/cli/commands/init.d.ts +13 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +46 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/init.test.d.ts +2 -0
- package/dist/cli/commands/init.test.d.ts.map +1 -0
- package/dist/cli/commands/init.test.js +156 -0
- package/dist/cli/commands/init.test.js.map +1 -0
- package/dist/cli/commands/knowledge.d.ts +4 -0
- package/dist/cli/commands/knowledge.d.ts.map +1 -0
- package/dist/cli/commands/knowledge.js +346 -0
- package/dist/cli/commands/knowledge.js.map +1 -0
- package/dist/cli/commands/knowledge.test.d.ts +2 -0
- package/dist/cli/commands/knowledge.test.d.ts.map +1 -0
- package/dist/cli/commands/knowledge.test.js +293 -0
- package/dist/cli/commands/knowledge.test.js.map +1 -0
- package/dist/cli/commands/list.d.ts +12 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +73 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/list.test.d.ts +2 -0
- package/dist/cli/commands/list.test.d.ts.map +1 -0
- package/dist/cli/commands/list.test.js +166 -0
- package/dist/cli/commands/list.test.js.map +1 -0
- package/dist/cli/commands/next.d.ts +12 -0
- package/dist/cli/commands/next.d.ts.map +1 -0
- package/dist/cli/commands/next.js +75 -0
- package/dist/cli/commands/next.js.map +1 -0
- package/dist/cli/commands/next.test.d.ts +2 -0
- package/dist/cli/commands/next.test.d.ts.map +1 -0
- package/dist/cli/commands/next.test.js +236 -0
- package/dist/cli/commands/next.test.js.map +1 -0
- package/dist/cli/commands/reset.d.ts +13 -0
- package/dist/cli/commands/reset.d.ts.map +1 -0
- package/dist/cli/commands/reset.js +105 -0
- package/dist/cli/commands/reset.js.map +1 -0
- package/dist/cli/commands/reset.test.d.ts +2 -0
- package/dist/cli/commands/reset.test.d.ts.map +1 -0
- package/dist/cli/commands/reset.test.js +211 -0
- package/dist/cli/commands/reset.test.js.map +1 -0
- package/dist/cli/commands/run.d.ts +14 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +379 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/run.test.d.ts +2 -0
- package/dist/cli/commands/run.test.d.ts.map +1 -0
- package/dist/cli/commands/run.test.js +535 -0
- package/dist/cli/commands/run.test.js.map +1 -0
- package/dist/cli/commands/skip.d.ts +13 -0
- package/dist/cli/commands/skip.d.ts.map +1 -0
- package/dist/cli/commands/skip.js +123 -0
- package/dist/cli/commands/skip.js.map +1 -0
- package/dist/cli/commands/skip.test.d.ts +2 -0
- package/dist/cli/commands/skip.test.d.ts.map +1 -0
- package/dist/cli/commands/skip.test.js +339 -0
- package/dist/cli/commands/skip.test.js.map +1 -0
- package/dist/cli/commands/status.d.ts +12 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +79 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/status.test.d.ts +2 -0
- package/dist/cli/commands/status.test.d.ts.map +1 -0
- package/dist/cli/commands/status.test.js +245 -0
- package/dist/cli/commands/status.test.js.map +1 -0
- package/dist/cli/commands/update.d.ts +11 -0
- package/dist/cli/commands/update.d.ts.map +1 -0
- package/dist/cli/commands/update.js +159 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands/update.test.d.ts +2 -0
- package/dist/cli/commands/update.test.d.ts.map +1 -0
- package/dist/cli/commands/update.test.js +140 -0
- package/dist/cli/commands/update.test.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +12 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +65 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/validate.test.d.ts +2 -0
- package/dist/cli/commands/validate.test.d.ts.map +1 -0
- package/dist/cli/commands/validate.test.js +159 -0
- package/dist/cli/commands/validate.test.js.map +1 -0
- package/dist/cli/commands/version.d.ts +13 -0
- package/dist/cli/commands/version.d.ts.map +1 -0
- package/dist/cli/commands/version.js +89 -0
- package/dist/cli/commands/version.js.map +1 -0
- package/dist/cli/commands/version.test.d.ts +2 -0
- package/dist/cli/commands/version.test.d.ts.map +1 -0
- package/dist/cli/commands/version.test.js +63 -0
- package/dist/cli/commands/version.test.js.map +1 -0
- package/dist/cli/index.d.ts +4 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/index.test.d.ts +2 -0
- package/dist/cli/index.test.d.ts.map +1 -0
- package/dist/cli/index.test.js +8 -0
- package/dist/cli/index.test.js.map +1 -0
- package/dist/cli/middleware/output-mode.d.ts +21 -0
- package/dist/cli/middleware/output-mode.d.ts.map +1 -0
- package/dist/cli/middleware/output-mode.js +27 -0
- package/dist/cli/middleware/output-mode.js.map +1 -0
- package/dist/cli/middleware/output-mode.test.d.ts +2 -0
- package/dist/cli/middleware/output-mode.test.d.ts.map +1 -0
- package/dist/cli/middleware/output-mode.test.js +41 -0
- package/dist/cli/middleware/output-mode.test.js.map +1 -0
- package/dist/cli/middleware/project-root.d.ts +21 -0
- package/dist/cli/middleware/project-root.d.ts.map +1 -0
- package/dist/cli/middleware/project-root.js +54 -0
- package/dist/cli/middleware/project-root.js.map +1 -0
- package/dist/cli/middleware/project-root.test.d.ts +2 -0
- package/dist/cli/middleware/project-root.test.d.ts.map +1 -0
- package/dist/cli/middleware/project-root.test.js +112 -0
- package/dist/cli/middleware/project-root.test.js.map +1 -0
- package/dist/cli/output/auto.d.ts +18 -0
- package/dist/cli/output/auto.d.ts.map +1 -0
- package/dist/cli/output/auto.js +43 -0
- package/dist/cli/output/auto.js.map +1 -0
- package/dist/cli/output/context.d.ts +19 -0
- package/dist/cli/output/context.d.ts.map +1 -0
- package/dist/cli/output/context.js +15 -0
- package/dist/cli/output/context.js.map +1 -0
- package/dist/cli/output/context.test.d.ts +2 -0
- package/dist/cli/output/context.test.d.ts.map +1 -0
- package/dist/cli/output/context.test.js +335 -0
- package/dist/cli/output/context.test.js.map +1 -0
- package/dist/cli/output/error-display.d.ts +31 -0
- package/dist/cli/output/error-display.d.ts.map +1 -0
- package/dist/cli/output/error-display.js +79 -0
- package/dist/cli/output/error-display.js.map +1 -0
- package/dist/cli/output/error-display.test.d.ts +2 -0
- package/dist/cli/output/error-display.test.d.ts.map +1 -0
- package/dist/cli/output/error-display.test.js +230 -0
- package/dist/cli/output/error-display.test.js.map +1 -0
- package/dist/cli/output/interactive.d.ts +22 -0
- package/dist/cli/output/interactive.d.ts.map +1 -0
- package/dist/cli/output/interactive.js +126 -0
- package/dist/cli/output/interactive.js.map +1 -0
- package/dist/cli/output/json.d.ts +17 -0
- package/dist/cli/output/json.d.ts.map +1 -0
- package/dist/cli/output/json.js +62 -0
- package/dist/cli/output/json.js.map +1 -0
- package/dist/cli/types.d.ts +11 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/config/loader.d.ts +22 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +159 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/loader.test.d.ts +2 -0
- package/dist/config/loader.test.d.ts.map +1 -0
- package/dist/config/loader.test.js +226 -0
- package/dist/config/loader.test.js.map +1 -0
- package/dist/config/migration.d.ts +15 -0
- package/dist/config/migration.d.ts.map +1 -0
- package/dist/config/migration.js +39 -0
- package/dist/config/migration.js.map +1 -0
- package/dist/config/migration.test.d.ts +2 -0
- package/dist/config/migration.test.d.ts.map +1 -0
- package/dist/config/migration.test.js +44 -0
- package/dist/config/migration.test.js.map +1 -0
- package/dist/config/schema.d.ts +121 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +22 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/schema.test.d.ts +2 -0
- package/dist/config/schema.test.d.ts.map +1 -0
- package/dist/config/schema.test.js +126 -0
- package/dist/config/schema.test.js.map +1 -0
- package/dist/core/adapters/adapter.d.ts +64 -0
- package/dist/core/adapters/adapter.d.ts.map +1 -0
- package/dist/core/adapters/adapter.js +25 -0
- package/dist/core/adapters/adapter.js.map +1 -0
- package/dist/core/adapters/adapter.test.d.ts +2 -0
- package/dist/core/adapters/adapter.test.d.ts.map +1 -0
- package/dist/core/adapters/adapter.test.js +175 -0
- package/dist/core/adapters/adapter.test.js.map +1 -0
- package/dist/core/adapters/claude-code.d.ts +9 -0
- package/dist/core/adapters/claude-code.d.ts.map +1 -0
- package/dist/core/adapters/claude-code.js +34 -0
- package/dist/core/adapters/claude-code.js.map +1 -0
- package/dist/core/adapters/claude-code.test.d.ts +2 -0
- package/dist/core/adapters/claude-code.test.d.ts.map +1 -0
- package/dist/core/adapters/claude-code.test.js +100 -0
- package/dist/core/adapters/claude-code.test.js.map +1 -0
- package/dist/core/adapters/codex.d.ts +10 -0
- package/dist/core/adapters/codex.d.ts.map +1 -0
- package/dist/core/adapters/codex.js +61 -0
- package/dist/core/adapters/codex.js.map +1 -0
- package/dist/core/adapters/codex.test.d.ts +2 -0
- package/dist/core/adapters/codex.test.d.ts.map +1 -0
- package/dist/core/adapters/codex.test.js +122 -0
- package/dist/core/adapters/codex.test.js.map +1 -0
- package/dist/core/adapters/universal.d.ts +10 -0
- package/dist/core/adapters/universal.d.ts.map +1 -0
- package/dist/core/adapters/universal.js +45 -0
- package/dist/core/adapters/universal.js.map +1 -0
- package/dist/core/adapters/universal.test.d.ts +2 -0
- package/dist/core/adapters/universal.test.d.ts.map +1 -0
- package/dist/core/adapters/universal.test.js +121 -0
- package/dist/core/adapters/universal.test.js.map +1 -0
- package/dist/core/assembly/context-gatherer.d.ts +17 -0
- package/dist/core/assembly/context-gatherer.d.ts.map +1 -0
- package/dist/core/assembly/context-gatherer.js +49 -0
- package/dist/core/assembly/context-gatherer.js.map +1 -0
- package/dist/core/assembly/context-gatherer.test.d.ts +2 -0
- package/dist/core/assembly/context-gatherer.test.d.ts.map +1 -0
- package/dist/core/assembly/context-gatherer.test.js +252 -0
- package/dist/core/assembly/context-gatherer.test.js.map +1 -0
- package/dist/core/assembly/depth-resolver.d.ts +11 -0
- package/dist/core/assembly/depth-resolver.d.ts.map +1 -0
- package/dist/core/assembly/depth-resolver.js +23 -0
- package/dist/core/assembly/depth-resolver.js.map +1 -0
- package/dist/core/assembly/depth-resolver.test.d.ts +2 -0
- package/dist/core/assembly/depth-resolver.test.d.ts.map +1 -0
- package/dist/core/assembly/depth-resolver.test.js +100 -0
- package/dist/core/assembly/depth-resolver.test.js.map +1 -0
- package/dist/core/assembly/engine.d.ts +22 -0
- package/dist/core/assembly/engine.d.ts.map +1 -0
- package/dist/core/assembly/engine.js +215 -0
- package/dist/core/assembly/engine.js.map +1 -0
- package/dist/core/assembly/engine.test.d.ts +2 -0
- package/dist/core/assembly/engine.test.d.ts.map +1 -0
- package/dist/core/assembly/engine.test.js +462 -0
- package/dist/core/assembly/engine.test.js.map +1 -0
- package/dist/core/assembly/instruction-loader.d.ts +16 -0
- package/dist/core/assembly/instruction-loader.d.ts.map +1 -0
- package/dist/core/assembly/instruction-loader.js +40 -0
- package/dist/core/assembly/instruction-loader.js.map +1 -0
- package/dist/core/assembly/instruction-loader.test.d.ts +2 -0
- package/dist/core/assembly/instruction-loader.test.d.ts.map +1 -0
- package/dist/core/assembly/instruction-loader.test.js +109 -0
- package/dist/core/assembly/instruction-loader.test.js.map +1 -0
- package/dist/core/assembly/knowledge-loader.d.ts +34 -0
- package/dist/core/assembly/knowledge-loader.d.ts.map +1 -0
- package/dist/core/assembly/knowledge-loader.js +204 -0
- package/dist/core/assembly/knowledge-loader.js.map +1 -0
- package/dist/core/assembly/knowledge-loader.test.d.ts +2 -0
- package/dist/core/assembly/knowledge-loader.test.d.ts.map +1 -0
- package/dist/core/assembly/knowledge-loader.test.js +205 -0
- package/dist/core/assembly/knowledge-loader.test.js.map +1 -0
- package/dist/core/assembly/meta-prompt-loader.d.ts +13 -0
- package/dist/core/assembly/meta-prompt-loader.d.ts.map +1 -0
- package/dist/core/assembly/meta-prompt-loader.js +91 -0
- package/dist/core/assembly/meta-prompt-loader.js.map +1 -0
- package/dist/core/assembly/meta-prompt-loader.test.d.ts +2 -0
- package/dist/core/assembly/meta-prompt-loader.test.d.ts.map +1 -0
- package/dist/core/assembly/meta-prompt-loader.test.js +232 -0
- package/dist/core/assembly/meta-prompt-loader.test.js.map +1 -0
- package/dist/core/assembly/methodology-change.d.ts +27 -0
- package/dist/core/assembly/methodology-change.d.ts.map +1 -0
- package/dist/core/assembly/methodology-change.js +41 -0
- package/dist/core/assembly/methodology-change.js.map +1 -0
- package/dist/core/assembly/methodology-change.test.d.ts +2 -0
- package/dist/core/assembly/methodology-change.test.d.ts.map +1 -0
- package/dist/core/assembly/methodology-change.test.js +145 -0
- package/dist/core/assembly/methodology-change.test.js.map +1 -0
- package/dist/core/assembly/methodology-resolver.d.ts +11 -0
- package/dist/core/assembly/methodology-resolver.d.ts.map +1 -0
- package/dist/core/assembly/methodology-resolver.js +19 -0
- package/dist/core/assembly/methodology-resolver.js.map +1 -0
- package/dist/core/assembly/methodology-resolver.test.d.ts +2 -0
- package/dist/core/assembly/methodology-resolver.test.d.ts.map +1 -0
- package/dist/core/assembly/methodology-resolver.test.js +87 -0
- package/dist/core/assembly/methodology-resolver.test.js.map +1 -0
- package/dist/core/assembly/preset-loader.d.ts +26 -0
- package/dist/core/assembly/preset-loader.d.ts.map +1 -0
- package/dist/core/assembly/preset-loader.js +146 -0
- package/dist/core/assembly/preset-loader.js.map +1 -0
- package/dist/core/assembly/preset-loader.test.d.ts +2 -0
- package/dist/core/assembly/preset-loader.test.d.ts.map +1 -0
- package/dist/core/assembly/preset-loader.test.js +107 -0
- package/dist/core/assembly/preset-loader.test.js.map +1 -0
- package/dist/core/assembly/update-mode.d.ts +25 -0
- package/dist/core/assembly/update-mode.d.ts.map +1 -0
- package/dist/core/assembly/update-mode.js +70 -0
- package/dist/core/assembly/update-mode.js.map +1 -0
- package/dist/core/assembly/update-mode.test.d.ts +2 -0
- package/dist/core/assembly/update-mode.test.d.ts.map +1 -0
- package/dist/core/assembly/update-mode.test.js +235 -0
- package/dist/core/assembly/update-mode.test.js.map +1 -0
- package/dist/core/dependency/dependency.d.ts +20 -0
- package/dist/core/dependency/dependency.d.ts.map +1 -0
- package/dist/core/dependency/dependency.js +104 -0
- package/dist/core/dependency/dependency.js.map +1 -0
- package/dist/core/dependency/dependency.test.d.ts +2 -0
- package/dist/core/dependency/dependency.test.d.ts.map +1 -0
- package/dist/core/dependency/dependency.test.js +166 -0
- package/dist/core/dependency/dependency.test.js.map +1 -0
- package/dist/core/dependency/eligibility.d.ts +17 -0
- package/dist/core/dependency/eligibility.d.ts.map +1 -0
- package/dist/core/dependency/eligibility.js +60 -0
- package/dist/core/dependency/eligibility.js.map +1 -0
- package/dist/core/dependency/eligibility.test.d.ts +2 -0
- package/dist/core/dependency/eligibility.test.d.ts.map +1 -0
- package/dist/core/dependency/eligibility.test.js +198 -0
- package/dist/core/dependency/eligibility.test.js.map +1 -0
- package/dist/core/dependency/graph.d.ts +12 -0
- package/dist/core/dependency/graph.d.ts.map +1 -0
- package/dist/core/dependency/graph.js +34 -0
- package/dist/core/dependency/graph.js.map +1 -0
- package/dist/core/knowledge/knowledge-update-assembler.d.ts +24 -0
- package/dist/core/knowledge/knowledge-update-assembler.d.ts.map +1 -0
- package/dist/core/knowledge/knowledge-update-assembler.js +46 -0
- package/dist/core/knowledge/knowledge-update-assembler.js.map +1 -0
- package/dist/core/knowledge/knowledge-update-assembler.test.d.ts +2 -0
- package/dist/core/knowledge/knowledge-update-assembler.test.d.ts.map +1 -0
- package/dist/core/knowledge/knowledge-update-assembler.test.js +93 -0
- package/dist/core/knowledge/knowledge-update-assembler.test.js.map +1 -0
- package/dist/core/knowledge/knowledge-update-template.md +55 -0
- package/dist/dashboard/generator.d.ts +37 -0
- package/dist/dashboard/generator.d.ts.map +1 -0
- package/dist/dashboard/generator.js +42 -0
- package/dist/dashboard/generator.js.map +1 -0
- package/dist/dashboard/generator.test.d.ts +2 -0
- package/dist/dashboard/generator.test.d.ts.map +1 -0
- package/dist/dashboard/generator.test.js +186 -0
- package/dist/dashboard/generator.test.js.map +1 -0
- package/dist/dashboard/template.d.ts +4 -0
- package/dist/dashboard/template.d.ts.map +1 -0
- package/dist/dashboard/template.js +190 -0
- package/dist/dashboard/template.js.map +1 -0
- package/dist/e2e/commands.test.d.ts +9 -0
- package/dist/e2e/commands.test.d.ts.map +1 -0
- package/dist/e2e/commands.test.js +499 -0
- package/dist/e2e/commands.test.js.map +1 -0
- package/dist/e2e/init.test.d.ts +10 -0
- package/dist/e2e/init.test.d.ts.map +1 -0
- package/dist/e2e/init.test.js +180 -0
- package/dist/e2e/init.test.js.map +1 -0
- package/dist/e2e/knowledge.test.d.ts +2 -0
- package/dist/e2e/knowledge.test.d.ts.map +1 -0
- package/dist/e2e/knowledge.test.js +103 -0
- package/dist/e2e/knowledge.test.js.map +1 -0
- package/dist/e2e/pipeline.test.d.ts +8 -0
- package/dist/e2e/pipeline.test.d.ts.map +1 -0
- package/dist/e2e/pipeline.test.js +295 -0
- package/dist/e2e/pipeline.test.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/project/adopt.d.ts +28 -0
- package/dist/project/adopt.d.ts.map +1 -0
- package/dist/project/adopt.js +49 -0
- package/dist/project/adopt.js.map +1 -0
- package/dist/project/adopt.test.d.ts +2 -0
- package/dist/project/adopt.test.d.ts.map +1 -0
- package/dist/project/adopt.test.js +220 -0
- package/dist/project/adopt.test.js.map +1 -0
- package/dist/project/claude-md.d.ts +33 -0
- package/dist/project/claude-md.d.ts.map +1 -0
- package/dist/project/claude-md.js +112 -0
- package/dist/project/claude-md.js.map +1 -0
- package/dist/project/claude-md.test.d.ts +2 -0
- package/dist/project/claude-md.test.d.ts.map +1 -0
- package/dist/project/claude-md.test.js +151 -0
- package/dist/project/claude-md.test.js.map +1 -0
- package/dist/project/detector.d.ts +7 -0
- package/dist/project/detector.d.ts.map +1 -0
- package/dist/project/detector.js +78 -0
- package/dist/project/detector.js.map +1 -0
- package/dist/project/detector.test.d.ts +2 -0
- package/dist/project/detector.test.d.ts.map +1 -0
- package/dist/project/detector.test.js +137 -0
- package/dist/project/detector.test.js.map +1 -0
- package/dist/project/frontmatter.d.ts +17 -0
- package/dist/project/frontmatter.d.ts.map +1 -0
- package/dist/project/frontmatter.js +236 -0
- package/dist/project/frontmatter.js.map +1 -0
- package/dist/project/frontmatter.test.d.ts +2 -0
- package/dist/project/frontmatter.test.d.ts.map +1 -0
- package/dist/project/frontmatter.test.js +218 -0
- package/dist/project/frontmatter.test.js.map +1 -0
- package/dist/project/signals.d.ts +12 -0
- package/dist/project/signals.d.ts.map +1 -0
- package/dist/project/signals.js +2 -0
- package/dist/project/signals.js.map +1 -0
- package/dist/state/completion.d.ts +22 -0
- package/dist/state/completion.d.ts.map +1 -0
- package/dist/state/completion.js +82 -0
- package/dist/state/completion.js.map +1 -0
- package/dist/state/completion.test.d.ts +2 -0
- package/dist/state/completion.test.d.ts.map +1 -0
- package/dist/state/completion.test.js +246 -0
- package/dist/state/completion.test.js.map +1 -0
- package/dist/state/decision-logger.d.ts +16 -0
- package/dist/state/decision-logger.d.ts.map +1 -0
- package/dist/state/decision-logger.js +80 -0
- package/dist/state/decision-logger.js.map +1 -0
- package/dist/state/decision-logger.test.d.ts +2 -0
- package/dist/state/decision-logger.test.d.ts.map +1 -0
- package/dist/state/decision-logger.test.js +182 -0
- package/dist/state/decision-logger.test.js.map +1 -0
- package/dist/state/lock-manager.d.ts +18 -0
- package/dist/state/lock-manager.d.ts.map +1 -0
- package/dist/state/lock-manager.js +134 -0
- package/dist/state/lock-manager.js.map +1 -0
- package/dist/state/lock-manager.test.d.ts +2 -0
- package/dist/state/lock-manager.test.d.ts.map +1 -0
- package/dist/state/lock-manager.test.js +190 -0
- package/dist/state/lock-manager.test.js.map +1 -0
- package/dist/state/state-manager.d.ts +37 -0
- package/dist/state/state-manager.d.ts.map +1 -0
- package/dist/state/state-manager.js +125 -0
- package/dist/state/state-manager.js.map +1 -0
- package/dist/state/state-manager.test.d.ts +2 -0
- package/dist/state/state-manager.test.d.ts.map +1 -0
- package/dist/state/state-manager.test.js +240 -0
- package/dist/state/state-manager.test.js.map +1 -0
- package/dist/types/adapter.d.ts +24 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/adapter.js +2 -0
- package/dist/types/adapter.js.map +1 -0
- package/dist/types/assembly.d.ts +89 -0
- package/dist/types/assembly.d.ts.map +1 -0
- package/dist/types/assembly.js +2 -0
- package/dist/types/assembly.js.map +1 -0
- package/dist/types/claude-md.d.ts +11 -0
- package/dist/types/claude-md.d.ts.map +1 -0
- package/dist/types/claude-md.js +2 -0
- package/dist/types/claude-md.js.map +1 -0
- package/dist/types/cli.d.ts +15 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +2 -0
- package/dist/types/cli.js.map +1 -0
- package/dist/types/config.d.ts +40 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/decision.d.ts +14 -0
- package/dist/types/decision.d.ts.map +1 -0
- package/dist/types/decision.js +2 -0
- package/dist/types/decision.js.map +1 -0
- package/dist/types/dependency.d.ts +12 -0
- package/dist/types/dependency.d.ts.map +1 -0
- package/dist/types/dependency.js +2 -0
- package/dist/types/dependency.js.map +1 -0
- package/dist/types/enums.d.ts +23 -0
- package/dist/types/enums.d.ts.map +1 -0
- package/dist/types/enums.js +11 -0
- package/dist/types/enums.js.map +1 -0
- package/dist/types/enums.test.d.ts +2 -0
- package/dist/types/enums.test.d.ts.map +1 -0
- package/dist/types/enums.test.js +13 -0
- package/dist/types/enums.test.js.map +1 -0
- package/dist/types/errors.d.ts +24 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +2 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/frontmatter.d.ts +43 -0
- package/dist/types/frontmatter.d.ts.map +1 -0
- package/dist/types/frontmatter.js +2 -0
- package/dist/types/frontmatter.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +14 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/lock.d.ts +10 -0
- package/dist/types/lock.d.ts.map +1 -0
- package/dist/types/lock.js +2 -0
- package/dist/types/lock.js.map +1 -0
- package/dist/types/state.d.ts +49 -0
- package/dist/types/state.d.ts.map +1 -0
- package/dist/types/state.js +2 -0
- package/dist/types/state.js.map +1 -0
- package/dist/types/wizard.d.ts +14 -0
- package/dist/types/wizard.d.ts.map +1 -0
- package/dist/types/wizard.js +2 -0
- package/dist/types/wizard.js.map +1 -0
- package/dist/utils/errors.d.ts +42 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +232 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/errors.test.d.ts +2 -0
- package/dist/utils/errors.test.d.ts.map +1 -0
- package/dist/utils/errors.test.js +91 -0
- package/dist/utils/errors.test.js.map +1 -0
- package/dist/utils/fs.d.ts +11 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +20 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/fs.test.d.ts +2 -0
- package/dist/utils/fs.test.d.ts.map +1 -0
- package/dist/utils/fs.test.js +93 -0
- package/dist/utils/fs.test.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/levenshtein.d.ts +11 -0
- package/dist/utils/levenshtein.d.ts.map +1 -0
- package/dist/utils/levenshtein.js +37 -0
- package/dist/utils/levenshtein.js.map +1 -0
- package/dist/utils/levenshtein.test.d.ts +2 -0
- package/dist/utils/levenshtein.test.d.ts.map +1 -0
- package/dist/utils/levenshtein.test.js +34 -0
- package/dist/utils/levenshtein.test.js.map +1 -0
- package/dist/validation/config-validator.d.ts +10 -0
- package/dist/validation/config-validator.d.ts.map +1 -0
- package/dist/validation/config-validator.js +11 -0
- package/dist/validation/config-validator.js.map +1 -0
- package/dist/validation/dependency-validator.d.ts +10 -0
- package/dist/validation/dependency-validator.d.ts.map +1 -0
- package/dist/validation/dependency-validator.js +34 -0
- package/dist/validation/dependency-validator.js.map +1 -0
- package/dist/validation/frontmatter-validator.d.ts +12 -0
- package/dist/validation/frontmatter-validator.d.ts.map +1 -0
- package/dist/validation/frontmatter-validator.js +50 -0
- package/dist/validation/frontmatter-validator.js.map +1 -0
- package/dist/validation/index.d.ts +19 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +64 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/index.test.d.ts +2 -0
- package/dist/validation/index.test.d.ts.map +1 -0
- package/dist/validation/index.test.js +241 -0
- package/dist/validation/index.test.js.map +1 -0
- package/dist/validation/state-validator.d.ts +15 -0
- package/dist/validation/state-validator.d.ts.map +1 -0
- package/dist/validation/state-validator.js +104 -0
- package/dist/validation/state-validator.js.map +1 -0
- package/dist/wizard/questions.d.ts +18 -0
- package/dist/wizard/questions.d.ts.map +1 -0
- package/dist/wizard/questions.js +46 -0
- package/dist/wizard/questions.js.map +1 -0
- package/dist/wizard/suggestion.d.ts +10 -0
- package/dist/wizard/suggestion.d.ts.map +1 -0
- package/dist/wizard/suggestion.js +17 -0
- package/dist/wizard/suggestion.js.map +1 -0
- package/dist/wizard/wizard.d.ts +19 -0
- package/dist/wizard/wizard.d.ts.map +1 -0
- package/dist/wizard/wizard.js +104 -0
- package/dist/wizard/wizard.js.map +1 -0
- package/dist/wizard/wizard.test.d.ts +2 -0
- package/dist/wizard/wizard.test.d.ts.map +1 -0
- package/dist/wizard/wizard.test.js +167 -0
- package/dist/wizard/wizard.test.js.map +1 -0
- package/knowledge/core/adr-craft.md +281 -0
- package/knowledge/core/api-design.md +501 -0
- package/knowledge/core/database-design.md +380 -0
- package/knowledge/core/domain-modeling.md +317 -0
- package/knowledge/core/operations-runbook.md +513 -0
- package/knowledge/core/security-review.md +523 -0
- package/knowledge/core/system-architecture.md +402 -0
- package/knowledge/core/task-decomposition.md +372 -0
- package/knowledge/core/testing-strategy.md +409 -0
- package/knowledge/core/user-stories.md +337 -0
- package/knowledge/core/user-story-innovation.md +171 -0
- package/knowledge/core/ux-specification.md +380 -0
- package/knowledge/finalization/apply-fixes-and-freeze.md +93 -0
- package/knowledge/finalization/developer-onboarding.md +376 -0
- package/knowledge/finalization/implementation-playbook.md +404 -0
- package/knowledge/product/gap-analysis.md +305 -0
- package/knowledge/product/prd-craft.md +324 -0
- package/knowledge/product/prd-innovation.md +204 -0
- package/knowledge/review/review-adr.md +203 -0
- package/knowledge/review/review-api-contracts.md +233 -0
- package/knowledge/review/review-database-schema.md +229 -0
- package/knowledge/review/review-domain-modeling.md +288 -0
- package/knowledge/review/review-implementation-tasks.md +202 -0
- package/knowledge/review/review-methodology.md +215 -0
- package/knowledge/review/review-operations.md +212 -0
- package/knowledge/review/review-prd.md +235 -0
- package/knowledge/review/review-security.md +213 -0
- package/knowledge/review/review-system-architecture.md +296 -0
- package/knowledge/review/review-testing-strategy.md +176 -0
- package/knowledge/review/review-user-stories.md +172 -0
- package/knowledge/review/review-ux-spec.md +208 -0
- package/knowledge/validation/critical-path-analysis.md +203 -0
- package/knowledge/validation/cross-phase-consistency.md +181 -0
- package/knowledge/validation/decision-completeness.md +218 -0
- package/knowledge/validation/dependency-validation.md +233 -0
- package/knowledge/validation/implementability-review.md +252 -0
- package/knowledge/validation/scope-management.md +223 -0
- package/knowledge/validation/traceability.md +198 -0
- package/methodology/custom-defaults.yml +43 -0
- package/methodology/deep.yml +42 -0
- package/methodology/mvp.yml +42 -0
- package/package.json +58 -0
- package/pipeline/architecture/review-architecture.md +44 -0
- package/pipeline/architecture/system-architecture.md +45 -0
- package/pipeline/decisions/adrs.md +45 -0
- package/pipeline/decisions/review-adrs.md +39 -0
- package/pipeline/finalization/apply-fixes-and-freeze.md +39 -0
- package/pipeline/finalization/developer-onboarding-guide.md +36 -0
- package/pipeline/finalization/implementation-playbook.md +45 -0
- package/pipeline/modeling/domain-modeling.md +57 -0
- package/pipeline/modeling/review-domain-modeling.md +41 -0
- package/pipeline/planning/implementation-tasks.md +57 -0
- package/pipeline/planning/review-tasks.md +38 -0
- package/pipeline/pre/create-prd.md +45 -0
- package/pipeline/pre/innovate-prd.md +47 -0
- package/pipeline/pre/innovate-user-stories.md +47 -0
- package/pipeline/pre/review-prd.md +44 -0
- package/pipeline/pre/review-user-stories.md +43 -0
- package/pipeline/pre/user-stories.md +48 -0
- package/pipeline/quality/operations.md +42 -0
- package/pipeline/quality/review-operations.md +37 -0
- package/pipeline/quality/review-security.md +40 -0
- package/pipeline/quality/review-testing.md +39 -0
- package/pipeline/quality/security.md +44 -0
- package/pipeline/quality/testing-strategy.md +42 -0
- package/pipeline/specification/api-contracts.md +44 -0
- package/pipeline/specification/database-schema.md +41 -0
- package/pipeline/specification/review-api.md +40 -0
- package/pipeline/specification/review-database.md +39 -0
- package/pipeline/specification/review-ux.md +38 -0
- package/pipeline/specification/ux-spec.md +43 -0
- package/pipeline/validation/critical-path-walkthrough.md +37 -0
- package/pipeline/validation/cross-phase-consistency.md +35 -0
- package/pipeline/validation/decision-completeness.md +36 -0
- package/pipeline/validation/dependency-graph-validation.md +36 -0
- package/pipeline/validation/implementability-dry-run.md +36 -0
- package/pipeline/validation/scope-creep-check.md +38 -0
- package/pipeline/validation/traceability-matrix.md +36 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-design
|
|
3
|
+
description: API design principles for REST, GraphQL, and inter-service communication
|
|
4
|
+
topics: [api, rest, graphql, endpoints, contracts, versioning, error-handling, authentication]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## API-First Development
|
|
8
|
+
|
|
9
|
+
Design the API contract before writing implementation code. The contract defines what the API does; the implementation fulfills that contract. This order matters because:
|
|
10
|
+
|
|
11
|
+
- Consumers can build against the contract in parallel with the API implementation
|
|
12
|
+
- The contract reflects domain concepts, not implementation details
|
|
13
|
+
- Contract changes are visible and reviewed before code changes
|
|
14
|
+
- Tests can be written against the contract specification
|
|
15
|
+
|
|
16
|
+
### Contract as Source of Truth
|
|
17
|
+
|
|
18
|
+
The API specification (OpenAPI for REST, GraphQL schema for GraphQL) is the authoritative definition of the API. Implementation code must conform to the specification, not the other way around.
|
|
19
|
+
|
|
20
|
+
**Specification-driven workflow:**
|
|
21
|
+
|
|
22
|
+
1. Define the API specification (endpoints, types, error codes)
|
|
23
|
+
2. Generate server stubs and client types from the specification
|
|
24
|
+
3. Implement the server stubs
|
|
25
|
+
4. Validate implementation against specification in CI (contract testing)
|
|
26
|
+
5. When the API needs to change, change the specification first, then update implementation
|
|
27
|
+
|
|
28
|
+
### Consumer-Driven Contract Testing
|
|
29
|
+
|
|
30
|
+
When multiple consumers depend on an API, each consumer defines a contract describing what it needs from the API. The API provider runs all consumer contracts as part of its test suite. If a provider change breaks a consumer contract, the tests fail before deployment.
|
|
31
|
+
|
|
32
|
+
Tools: Pact (language-agnostic), Spring Cloud Contract (JVM), Dredd (OpenAPI-based).
|
|
33
|
+
|
|
34
|
+
### API Documentation
|
|
35
|
+
|
|
36
|
+
Documentation is generated from the specification, not written separately. Separately-maintained docs drift from the implementation.
|
|
37
|
+
|
|
38
|
+
- **OpenAPI/Swagger:** Auto-generates interactive documentation (Swagger UI, Redoc)
|
|
39
|
+
- **GraphQL:** Schema introspection provides self-documenting APIs (GraphiQL, Apollo Studio)
|
|
40
|
+
- **Supplement with:** Usage examples, authentication guides, rate limiting policies, error handling guides
|
|
41
|
+
|
|
42
|
+
## REST Design
|
|
43
|
+
|
|
44
|
+
### Resource Modeling
|
|
45
|
+
|
|
46
|
+
REST APIs model resources (nouns), not actions (verbs). Resources correspond to domain entities or aggregates.
|
|
47
|
+
|
|
48
|
+
**URL structure:**
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
GET /api/v1/orders # List orders
|
|
52
|
+
POST /api/v1/orders # Create an order
|
|
53
|
+
GET /api/v1/orders/:id # Get a specific order
|
|
54
|
+
PATCH /api/v1/orders/:id # Update an order
|
|
55
|
+
DELETE /api/v1/orders/:id # Delete an order
|
|
56
|
+
GET /api/v1/orders/:id/lines # List order lines (sub-resource)
|
|
57
|
+
POST /api/v1/orders/:id/lines # Add a line to an order
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Resource naming rules:**
|
|
61
|
+
|
|
62
|
+
- Use plural nouns: `/orders` not `/order`
|
|
63
|
+
- Use lowercase with hyphens: `/order-lines` not `/orderLines` or `/order_lines`
|
|
64
|
+
- Nest sub-resources only one level deep: `/orders/:id/lines` is fine; `/customers/:id/orders/:id/lines/:id/adjustments` is too deep — flatten it
|
|
65
|
+
- Use nouns, not verbs: `/orders` not `/getOrders` or `/createOrder`
|
|
66
|
+
|
|
67
|
+
**Actions that don't fit CRUD:**
|
|
68
|
+
|
|
69
|
+
Some operations don't map cleanly to resource CRUD. Use sub-resource patterns:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
POST /api/v1/orders/:id/submit # Submit an order (state transition)
|
|
73
|
+
POST /api/v1/orders/:id/cancel # Cancel an order
|
|
74
|
+
POST /api/v1/reports/generate # Trigger report generation
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or use a command-style resource:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
POST /api/v1/order-submissions # Create an "order submission" resource
|
|
81
|
+
POST /api/v1/password-resets # Create a "password reset" resource
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### HTTP Methods
|
|
85
|
+
|
|
86
|
+
| Method | Semantics | Idempotent | Safe |
|
|
87
|
+
|--------|-----------|------------|------|
|
|
88
|
+
| GET | Retrieve resource(s) | Yes | Yes |
|
|
89
|
+
| POST | Create resource or trigger action | No | No |
|
|
90
|
+
| PUT | Replace entire resource | Yes | No |
|
|
91
|
+
| PATCH | Partially update resource | No* | No |
|
|
92
|
+
| DELETE | Remove resource | Yes | No |
|
|
93
|
+
|
|
94
|
+
*PATCH can be made idempotent with proper design but isn't inherently.
|
|
95
|
+
|
|
96
|
+
**Use the correct method:**
|
|
97
|
+
|
|
98
|
+
- Don't use GET with side effects (creating, updating, deleting data)
|
|
99
|
+
- Don't use POST for idempotent operations that PUT handles
|
|
100
|
+
- Prefer PATCH over PUT for partial updates (PUT requires sending the entire resource)
|
|
101
|
+
- DELETE should be idempotent: deleting an already-deleted resource returns 204, not 404
|
|
102
|
+
|
|
103
|
+
### Status Codes
|
|
104
|
+
|
|
105
|
+
Use the correct HTTP status code for every response:
|
|
106
|
+
|
|
107
|
+
**Success (2xx):**
|
|
108
|
+
|
|
109
|
+
| Code | When |
|
|
110
|
+
|------|------|
|
|
111
|
+
| 200 OK | Successful GET, PATCH, or action that returns data |
|
|
112
|
+
| 201 Created | Successful POST that creates a resource. Include `Location` header. |
|
|
113
|
+
| 204 No Content | Successful DELETE or update that returns no body |
|
|
114
|
+
|
|
115
|
+
**Client errors (4xx):**
|
|
116
|
+
|
|
117
|
+
| Code | When |
|
|
118
|
+
|------|------|
|
|
119
|
+
| 400 Bad Request | Request body/params fail validation |
|
|
120
|
+
| 401 Unauthorized | No valid authentication credentials |
|
|
121
|
+
| 403 Forbidden | Authenticated but insufficient permissions |
|
|
122
|
+
| 404 Not Found | Resource doesn't exist |
|
|
123
|
+
| 409 Conflict | State conflict (duplicate email, invalid state transition) |
|
|
124
|
+
| 422 Unprocessable Entity | Syntactically valid but semantically invalid request |
|
|
125
|
+
| 429 Too Many Requests | Rate limit exceeded. Include `Retry-After` header. |
|
|
126
|
+
|
|
127
|
+
**Server errors (5xx):**
|
|
128
|
+
|
|
129
|
+
| Code | When |
|
|
130
|
+
|------|------|
|
|
131
|
+
| 500 Internal Server Error | Unexpected server failure |
|
|
132
|
+
| 502 Bad Gateway | Upstream service failure |
|
|
133
|
+
| 503 Service Unavailable | Temporary overload or maintenance |
|
|
134
|
+
|
|
135
|
+
**Anti-pattern: 200 for everything.** Returning 200 with `{ "error": true, "message": "Not found" }` breaks HTTP semantics and makes error handling inconsistent.
|
|
136
|
+
|
|
137
|
+
### Content Negotiation
|
|
138
|
+
|
|
139
|
+
- Default to `application/json` for request and response bodies
|
|
140
|
+
- Accept and return `Content-Type` headers
|
|
141
|
+
- For file uploads, accept `multipart/form-data`
|
|
142
|
+
- For file downloads, return the appropriate MIME type with `Content-Disposition` header
|
|
143
|
+
|
|
144
|
+
## GraphQL Design
|
|
145
|
+
|
|
146
|
+
### Schema-First Design
|
|
147
|
+
|
|
148
|
+
Define the GraphQL schema before implementing resolvers. The schema is the contract.
|
|
149
|
+
|
|
150
|
+
```graphql
|
|
151
|
+
type Order {
|
|
152
|
+
id: ID!
|
|
153
|
+
customer: Customer!
|
|
154
|
+
lines: [OrderLine!]!
|
|
155
|
+
status: OrderStatus!
|
|
156
|
+
total: Money!
|
|
157
|
+
createdAt: DateTime!
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
type Query {
|
|
161
|
+
order(id: ID!): Order
|
|
162
|
+
orders(filter: OrderFilter, pagination: PaginationInput): OrderConnection!
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
type Mutation {
|
|
166
|
+
createOrder(input: CreateOrderInput!): CreateOrderPayload!
|
|
167
|
+
submitOrder(id: ID!): SubmitOrderPayload!
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Type System
|
|
172
|
+
|
|
173
|
+
- Use non-nullable (`!`) by default. Make fields nullable only when absence is meaningful.
|
|
174
|
+
- Use input types (`input`) for mutation arguments, not the same types used for output.
|
|
175
|
+
- Use enums for finite value sets: `enum OrderStatus { DRAFT SUBMITTED CONFIRMED SHIPPED DELIVERED CANCELLED }`
|
|
176
|
+
- Use interfaces and unions for polymorphic types.
|
|
177
|
+
- Use custom scalars for domain-specific types: `scalar DateTime`, `scalar Money`, `scalar EmailAddress`.
|
|
178
|
+
|
|
179
|
+
### Query Complexity
|
|
180
|
+
|
|
181
|
+
GraphQL's flexibility allows expensive queries. Mitigate:
|
|
182
|
+
|
|
183
|
+
**Depth limiting:** Reject queries deeper than a configured maximum (typically 5-10 levels).
|
|
184
|
+
|
|
185
|
+
**Complexity analysis:** Assign cost to each field. Reject queries whose total cost exceeds a threshold.
|
|
186
|
+
|
|
187
|
+
```graphql
|
|
188
|
+
# This query might cost: 1 (orders) + 100 * (1 (customer) + 10 * 1 (items)) = 1101
|
|
189
|
+
{
|
|
190
|
+
orders(first: 100) {
|
|
191
|
+
customer {
|
|
192
|
+
orders(first: 10) {
|
|
193
|
+
items { name }
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Pagination enforcement:** Never return unbounded lists. Require pagination arguments on all list fields.
|
|
201
|
+
|
|
202
|
+
### N+1 Prevention
|
|
203
|
+
|
|
204
|
+
The N+1 problem: fetching a list of N orders, then issuing N separate queries for each order's customer. GraphQL's nested resolution naturally creates this pattern.
|
|
205
|
+
|
|
206
|
+
**Solution: DataLoader pattern.** Batch and deduplicate database queries within a single request. When N orders reference 5 distinct customers, issue one query for those 5 customers, not N queries.
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
const customerLoader = new DataLoader(async (ids: string[]) => {
|
|
210
|
+
const customers = await db.customers.findMany({ where: { id: { in: ids } } });
|
|
211
|
+
return ids.map(id => customers.find(c => c.id === id));
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Subscription Patterns
|
|
216
|
+
|
|
217
|
+
For real-time data, GraphQL subscriptions provide a typed, schema-driven alternative to raw WebSockets:
|
|
218
|
+
|
|
219
|
+
```graphql
|
|
220
|
+
type Subscription {
|
|
221
|
+
orderStatusChanged(orderId: ID!): Order!
|
|
222
|
+
newNotification(userId: ID!): Notification!
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Implement with WebSocket transport (graphql-ws protocol). Consider:
|
|
227
|
+
- Authentication for subscription connections
|
|
228
|
+
- Connection lifecycle management (reconnection, timeout)
|
|
229
|
+
- Scaling (subscriptions are stateful — sticky sessions or pub/sub backend needed)
|
|
230
|
+
|
|
231
|
+
## Error Contracts
|
|
232
|
+
|
|
233
|
+
### Structured Error Responses
|
|
234
|
+
|
|
235
|
+
Every error response should follow a consistent structure:
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"error": {
|
|
240
|
+
"code": "VALIDATION_ERROR",
|
|
241
|
+
"message": "The request contains invalid fields",
|
|
242
|
+
"details": [
|
|
243
|
+
{
|
|
244
|
+
"field": "email",
|
|
245
|
+
"code": "INVALID_FORMAT",
|
|
246
|
+
"message": "Must be a valid email address"
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"field": "age",
|
|
250
|
+
"code": "OUT_OF_RANGE",
|
|
251
|
+
"message": "Must be between 13 and 150"
|
|
252
|
+
}
|
|
253
|
+
],
|
|
254
|
+
"requestId": "req_abc123"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Error Code Taxonomy
|
|
260
|
+
|
|
261
|
+
Define a finite set of error codes, not free-text messages:
|
|
262
|
+
|
|
263
|
+
**Authentication errors:** `UNAUTHENTICATED`, `TOKEN_EXPIRED`, `TOKEN_INVALID`
|
|
264
|
+
|
|
265
|
+
**Authorization errors:** `FORBIDDEN`, `INSUFFICIENT_PERMISSIONS`, `RESOURCE_NOT_OWNED`
|
|
266
|
+
|
|
267
|
+
**Validation errors:** `VALIDATION_ERROR` (with per-field details), `INVALID_FORMAT`, `REQUIRED_FIELD`, `OUT_OF_RANGE`, `TOO_LONG`, `DUPLICATE_VALUE`
|
|
268
|
+
|
|
269
|
+
**Resource errors:** `NOT_FOUND`, `ALREADY_EXISTS`, `CONFLICT`, `GONE`
|
|
270
|
+
|
|
271
|
+
**Business logic errors:** `INVALID_STATE_TRANSITION`, `BUSINESS_RULE_VIOLATION`, `LIMIT_EXCEEDED`
|
|
272
|
+
|
|
273
|
+
**Server errors:** `INTERNAL_ERROR`, `SERVICE_UNAVAILABLE`, `UPSTREAM_ERROR`, `TIMEOUT`
|
|
274
|
+
|
|
275
|
+
### Error Documentation
|
|
276
|
+
|
|
277
|
+
For each error code, document:
|
|
278
|
+
- What triggers it
|
|
279
|
+
- What the client should do about it (retry? show message? redirect?)
|
|
280
|
+
- Example response body
|
|
281
|
+
- Whether the error is transient (may succeed on retry) or permanent (same request will always fail)
|
|
282
|
+
|
|
283
|
+
## Authentication and Authorization
|
|
284
|
+
|
|
285
|
+
### Authentication Patterns
|
|
286
|
+
|
|
287
|
+
**Session-based authentication:**
|
|
288
|
+
- Server creates a session on login, stores session data server-side, sends session ID in a cookie
|
|
289
|
+
- Works well for web applications with server-side rendering
|
|
290
|
+
- Requires session storage (database, Redis) that scales with concurrent users
|
|
291
|
+
|
|
292
|
+
**JWT (JSON Web Tokens):**
|
|
293
|
+
- Server issues a signed token containing claims (user ID, roles, expiration)
|
|
294
|
+
- Token is sent in the `Authorization: Bearer <token>` header
|
|
295
|
+
- Stateless on the server — no session storage needed
|
|
296
|
+
- Trade-off: cannot be individually revoked without a blocklist (which reintroduces state)
|
|
297
|
+
- Always set short expiration (15-60 minutes) and use refresh tokens for re-authentication
|
|
298
|
+
|
|
299
|
+
**OAuth 2.0 / OIDC:**
|
|
300
|
+
- Delegated authentication via a third-party identity provider (Google, GitHub, Auth0)
|
|
301
|
+
- OIDC (OpenID Connect) adds identity claims on top of OAuth 2.0's authorization framework
|
|
302
|
+
- Use for "Sign in with X" features or when managing user credentials is out of scope
|
|
303
|
+
|
|
304
|
+
**API Keys:**
|
|
305
|
+
- Long-lived tokens for service-to-service or developer API access
|
|
306
|
+
- Not suitable for end-user authentication (no expiration management, no MFA)
|
|
307
|
+
- Hash and store; never return the full key after creation
|
|
308
|
+
|
|
309
|
+
### Authorization Patterns
|
|
310
|
+
|
|
311
|
+
**Per-endpoint authorization:** Every endpoint declares its required permissions. The auth middleware checks the authenticated user's permissions before the handler executes.
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
POST /api/v1/orders -> requires: orders:create
|
|
315
|
+
GET /api/v1/orders/:id -> requires: orders:read (+ resource-level check: own orders only?)
|
|
316
|
+
DELETE /api/v1/admin/users -> requires: admin:users:delete
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Token scope model:** Access tokens carry scopes (permissions). Each API endpoint requires specific scopes. The token must include all required scopes for the request to proceed.
|
|
320
|
+
|
|
321
|
+
**RBAC (Role-Based Access Control):** Users have roles. Roles have permissions. Simple and sufficient for most applications.
|
|
322
|
+
|
|
323
|
+
**ABAC (Attribute-Based Access Control):** Authorization decisions based on attributes of the user, resource, and environment. More flexible than RBAC but more complex. Use when RBAC's role-to-permission mapping doesn't capture the required policies.
|
|
324
|
+
|
|
325
|
+
## Pagination, Filtering, and Sorting
|
|
326
|
+
|
|
327
|
+
### Cursor-Based Pagination
|
|
328
|
+
|
|
329
|
+
Preferred for most APIs. Uses an opaque cursor (encoded primary key or timestamp) to mark the position in the result set.
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
GET /api/v1/orders?first=20&after=cursor_abc123
|
|
333
|
+
|
|
334
|
+
Response:
|
|
335
|
+
{
|
|
336
|
+
"data": [...],
|
|
337
|
+
"pageInfo": {
|
|
338
|
+
"hasNextPage": true,
|
|
339
|
+
"hasPreviousPage": true,
|
|
340
|
+
"startCursor": "cursor_xyz789",
|
|
341
|
+
"endCursor": "cursor_def456"
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Advantages:** Stable under concurrent inserts/deletes. No duplicate or skipped records. Performs well on large datasets (no OFFSET scan).
|
|
347
|
+
|
|
348
|
+
**Disadvantage:** Cannot jump to "page 5." Users can only go forward/backward.
|
|
349
|
+
|
|
350
|
+
### Offset-Based Pagination
|
|
351
|
+
|
|
352
|
+
Uses page number and page size. Simple to implement and allows jumping to any page.
|
|
353
|
+
|
|
354
|
+
```
|
|
355
|
+
GET /api/v1/orders?page=3&pageSize=20
|
|
356
|
+
|
|
357
|
+
Response:
|
|
358
|
+
{
|
|
359
|
+
"data": [...],
|
|
360
|
+
"pagination": {
|
|
361
|
+
"page": 3,
|
|
362
|
+
"pageSize": 20,
|
|
363
|
+
"totalItems": 156,
|
|
364
|
+
"totalPages": 8
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**Disadvantage:** Unstable under concurrent writes (inserts shift items between pages). Performance degrades on large offsets (database must scan and discard OFFSET rows).
|
|
370
|
+
|
|
371
|
+
### Filtering
|
|
372
|
+
|
|
373
|
+
Design a consistent filtering syntax:
|
|
374
|
+
|
|
375
|
+
```
|
|
376
|
+
GET /api/v1/orders?status=active&customerId=123&createdAfter=2026-01-01
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
For complex filtering, consider a structured filter parameter:
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
GET /api/v1/orders?filter[status]=active&filter[total][gte]=1000
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**Rules:**
|
|
386
|
+
- Unknown filter parameters should return 400, not be silently ignored
|
|
387
|
+
- Filter parameter names should match resource field names
|
|
388
|
+
- Document which fields are filterable (not all fields need to be)
|
|
389
|
+
- Validate filter values against field types
|
|
390
|
+
|
|
391
|
+
### Sorting
|
|
392
|
+
|
|
393
|
+
```
|
|
394
|
+
GET /api/v1/orders?sort=-createdAt,status
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
Convention: prefix with `-` for descending, no prefix for ascending. Multiple sort fields separated by commas.
|
|
398
|
+
|
|
399
|
+
**Rules:**
|
|
400
|
+
- Document which fields are sortable
|
|
401
|
+
- Define a default sort order (usually `-createdAt`)
|
|
402
|
+
- Limit the number of sort fields (2-3 is sufficient)
|
|
403
|
+
|
|
404
|
+
### Total Count Considerations
|
|
405
|
+
|
|
406
|
+
Returning `totalItems` requires a COUNT query, which can be expensive on large tables. Options:
|
|
407
|
+
|
|
408
|
+
- Return exact count for small datasets (<10,000 rows)
|
|
409
|
+
- Return approximate count for large datasets (`EXPLAIN` count estimate)
|
|
410
|
+
- Omit count entirely and use `hasNextPage` only
|
|
411
|
+
- Make count optional: `GET /api/v1/orders?includeCount=true`
|
|
412
|
+
|
|
413
|
+
## Versioning
|
|
414
|
+
|
|
415
|
+
### URL Versioning
|
|
416
|
+
|
|
417
|
+
```
|
|
418
|
+
/api/v1/orders
|
|
419
|
+
/api/v2/orders
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
Simple, explicit, cacheable. The version is visible in every request. Best for public APIs where consumers need clear migration paths.
|
|
423
|
+
|
|
424
|
+
### Header Versioning
|
|
425
|
+
|
|
426
|
+
```
|
|
427
|
+
Accept: application/vnd.myapp.v2+json
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Keeps URLs clean. Harder to test (can't just change the URL in a browser). Suitable for internal APIs.
|
|
431
|
+
|
|
432
|
+
### Evolution Without Versioning
|
|
433
|
+
|
|
434
|
+
For many APIs, additive changes don't need versioning:
|
|
435
|
+
|
|
436
|
+
**Non-breaking changes (no version bump):**
|
|
437
|
+
- Adding a new field to a response
|
|
438
|
+
- Adding a new optional query parameter
|
|
439
|
+
- Adding a new endpoint
|
|
440
|
+
- Adding a new enum value (if clients handle unknown values)
|
|
441
|
+
|
|
442
|
+
**Breaking changes (version bump or migration):**
|
|
443
|
+
- Removing a field from a response
|
|
444
|
+
- Renaming a field
|
|
445
|
+
- Changing a field's type
|
|
446
|
+
- Making an optional parameter required
|
|
447
|
+
- Changing the meaning of a status code
|
|
448
|
+
|
|
449
|
+
**Design for evolution:** use nullable fields, design enum handling to tolerate unknown values, and avoid coupling to response shape.
|
|
450
|
+
|
|
451
|
+
## Idempotency
|
|
452
|
+
|
|
453
|
+
### Idempotent Operations
|
|
454
|
+
|
|
455
|
+
An operation is idempotent if calling it multiple times produces the same result as calling it once. GET, PUT, and DELETE are inherently idempotent. POST is not.
|
|
456
|
+
|
|
457
|
+
### Idempotency Keys
|
|
458
|
+
|
|
459
|
+
For non-idempotent operations (POST), clients send a unique key with the request. The server uses this key to detect and deduplicate retries.
|
|
460
|
+
|
|
461
|
+
```
|
|
462
|
+
POST /api/v1/payments
|
|
463
|
+
Idempotency-Key: idk_550e8400-e29b-41d4-a716-446655440000
|
|
464
|
+
|
|
465
|
+
# First call: processes payment, stores result keyed by idempotency key
|
|
466
|
+
# Second call with same key: returns stored result without reprocessing
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
**Implementation:**
|
|
470
|
+
|
|
471
|
+
1. Client generates a UUID as the idempotency key
|
|
472
|
+
2. Server checks if the key exists in the idempotency store
|
|
473
|
+
3. If found: return the stored response (no side effects)
|
|
474
|
+
4. If not found: process the request, store the response keyed by the idempotency key, return the response
|
|
475
|
+
5. Keys expire after a defined period (24-72 hours)
|
|
476
|
+
|
|
477
|
+
### Safe Retries
|
|
478
|
+
|
|
479
|
+
Design APIs so that transient failures can be safely retried:
|
|
480
|
+
|
|
481
|
+
- All GET requests are safe to retry (they're idempotent and safe)
|
|
482
|
+
- PUT and DELETE are safe to retry (they're idempotent)
|
|
483
|
+
- POST requests should accept idempotency keys for any operation with side effects (charges, notifications, resource creation)
|
|
484
|
+
|
|
485
|
+
## Common Pitfalls
|
|
486
|
+
|
|
487
|
+
**Chatty APIs.** A page load requires 15 API calls to assemble the necessary data. Each call adds latency and failure surface. Fix: design aggregation endpoints that return the data a specific consumer needs, or use GraphQL for flexible data fetching.
|
|
488
|
+
|
|
489
|
+
**Missing error contracts.** The API returns different error shapes from different endpoints. One returns `{ "error": "message" }`, another returns `{ "errors": [{ "msg": "..." }] }`. Fix: define a single error response schema and use it everywhere.
|
|
490
|
+
|
|
491
|
+
**Authentication as afterthought.** Endpoints built without auth, then auth bolted on later. Leads to inconsistent protection, forgotten endpoints, and auth bypass vulnerabilities. Fix: design auth requirements for every endpoint at API design time, not implementation time.
|
|
492
|
+
|
|
493
|
+
**Not designing for pagination from the start.** A list endpoint returns all records. Works fine with 10 records, crashes with 100,000. Fix: every list endpoint must be paginated from day one. Never return unbounded lists.
|
|
494
|
+
|
|
495
|
+
**Exposing internal models.** Returning database entities directly as API responses. Internal fields leak (internal IDs, audit columns, soft-delete flags). Schema changes break clients. Fix: use response DTOs that shape data for the consumer, not the database.
|
|
496
|
+
|
|
497
|
+
**Inconsistent naming.** One endpoint uses `created_at`, another uses `createdAt`, another uses `creation_date`. Fix: choose one naming convention (camelCase is standard for JSON APIs) and enforce it project-wide.
|
|
498
|
+
|
|
499
|
+
**Missing rate limiting.** No protection against abusive or buggy clients sending excessive requests. Fix: implement rate limiting on all public endpoints. Return 429 with `Retry-After` header.
|
|
500
|
+
|
|
501
|
+
**Ignoring CORS.** Frontend can't call the API because CORS headers are missing. Fix: configure CORS at API design time. Be specific about allowed origins — don't use `*` in production.
|