toolcraft-openapi 0.0.27 → 0.0.34
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/dist/auth/bearer-token-auth.js +1 -1
- package/dist/bin/generate.d.ts +9 -1
- package/dist/bin/generate.js +65 -9
- package/dist/error-codes.d.ts +1 -0
- package/dist/error-codes.js +6 -0
- package/dist/generate.d.ts +20 -3
- package/dist/generate.js +604 -144
- package/dist/http.d.ts +17 -1
- package/dist/http.js +113 -7
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -0
- package/dist/inspect-source.d.ts +10 -0
- package/dist/inspect-source.js +14 -0
- package/dist/inspect.d.ts +22 -0
- package/dist/inspect.js +171 -0
- package/dist/interpreter.js +6 -2
- package/dist/mock/fetch.js +28 -12
- package/dist/mock/forgeyard.d.ts +4 -0
- package/dist/mock/forgeyard.js +452 -0
- package/dist/mock.d.ts +1 -0
- package/dist/mock.js +1 -0
- package/dist/naming.d.ts +4 -1
- package/dist/naming.js +93 -7
- package/dist/network-error.js +29 -12
- package/dist/normalize-swagger.d.ts +2 -0
- package/dist/normalize-swagger.js +201 -0
- package/dist/render-inspection.d.ts +2 -0
- package/dist/render-inspection.js +130 -0
- package/dist/request-shape.d.ts +4 -0
- package/dist/request-shape.js +1 -0
- package/dist/runtime.js +7 -1
- package/dist/spec-source.js +7 -4
- package/node_modules/auth-store/dist/create-secret-store.js +6 -1
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +1 -1
- package/node_modules/auth-store/dist/encrypted-file-store.js +32 -28
- package/node_modules/auth-store/dist/error-codes.d.ts +1 -0
- package/node_modules/auth-store/dist/error-codes.js +5 -0
- package/node_modules/auth-store/dist/keychain-store.js +23 -8
- package/node_modules/toolcraft-design/README.md +148 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/components.d.ts +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/components.js +12 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/index.d.ts +1 -1
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/index.js +1 -1
- package/node_modules/toolcraft-design/dist/components/catalog.d.ts +26 -0
- package/node_modules/toolcraft-design/dist/components/catalog.js +94 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.d.ts +2 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/index.js +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/footer.js +1 -2
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/output-pane.js +16 -19
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/stats-pane.js +1 -15
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/demo.js +2 -2
- package/node_modules/toolcraft-design/dist/explorer/theme.js +29 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/index.d.ts +7 -1
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/index.js +4 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.d.ts +1 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/theme-detect.js +28 -6
- package/node_modules/toolcraft-design/dist/internal/theme-state.d.ts +12 -0
- package/node_modules/toolcraft-design/dist/internal/theme-state.js +35 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/theme.d.ts +1 -1
- package/node_modules/toolcraft-design/dist/prompts/theme.js +15 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/frontmatter.js +50 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.d.ts +5 -0
- package/node_modules/toolcraft-design/dist/tokens/brand.js +5 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.d.ts +37 -0
- package/node_modules/toolcraft-design/dist/tokens/colors.js +85 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/index.d.ts +2 -0
- package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/index.js +1 -0
- package/node_modules/toolcraft-design/package.json +42 -0
- package/package.json +8 -6
- package/node_modules/@poe-code/design-system/dist/explorer/theme.js +0 -97
- package/node_modules/@poe-code/design-system/dist/prompts/theme.js +0 -12
- package/node_modules/@poe-code/design-system/dist/tokens/colors.d.ts +0 -35
- package/node_modules/@poe-code/design-system/dist/tokens/colors.js +0 -34
- package/node_modules/@poe-code/design-system/package.json +0 -29
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/writer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/acp/writer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/browser.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/browser.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/color.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/color.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/command-errors.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/command-errors.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/detail-card.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/detail-card.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter-plain.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter-plain.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/help-formatter.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/logger.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/logger.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/symbols.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/symbols.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/table.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/table.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/template.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/template.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/text.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/components/text.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/ansi.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/ansi.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/buffer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/buffer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/border.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/border.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/footer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/output-pane.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/components/stats-pane.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/dashboard.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/dashboard.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/demo.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/demo.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/keymap.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/keymap.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/layout.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/layout.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/should-use-dashboard.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/should-use-dashboard.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/snapshot.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/snapshot.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/store.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/store.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal-width.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal-width.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/terminal.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/types.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/dashboard/types.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/actions.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/actions.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/demo.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/events.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/events.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/filter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/filter.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/jobs.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/jobs.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/keymap.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/keymap.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/layout.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/layout.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/reducer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/reducer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/detail.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/detail.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/footer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/footer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/header.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/header.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/list.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/list.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/modal.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/modal.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/test-fixtures.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/test-fixtures.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/text.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/render/text.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.test-helpers.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/runtime.test-helpers.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/state.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/state.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/explorer/theme.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/color-support.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/color-support.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/output-format.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/output-format.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/strip-ansi.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/internal/strip-ansi.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/cancel.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/cancel.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/intro.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/intro.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/log.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/log.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/note.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/note.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/outro.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/outro.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/spinner.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/prompts/primitives/spinner.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/menu.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/menu.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/spinner.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/static/spinner.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/ast.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/ast.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/demo-content.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/demo-content.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/index.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/index.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/block.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/block.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/frontmatter.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/inline.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser/inline.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/parser.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/renderer.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/renderer.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/testing/theme-render-fixture.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/terminal-markdown/testing/theme-render-fixture.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/spacing.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/spacing.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/typography.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/typography.js +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/widths.d.ts +0 -0
- /package/node_modules/{@poe-code/design-system → toolcraft-design}/dist/tokens/widths.js +0 -0
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
export const FORGEYARD_BASE_URL = "https://api.forgeyard.invalid";
|
|
2
|
+
export const FORGEYARD_RESOURCES = [
|
|
3
|
+
"artifacts",
|
|
4
|
+
"audits",
|
|
5
|
+
"automations",
|
|
6
|
+
"branches",
|
|
7
|
+
"builds",
|
|
8
|
+
"checks",
|
|
9
|
+
"changes",
|
|
10
|
+
"comments",
|
|
11
|
+
"commits",
|
|
12
|
+
"deployments",
|
|
13
|
+
"discussions",
|
|
14
|
+
"environments",
|
|
15
|
+
"events",
|
|
16
|
+
"files",
|
|
17
|
+
"hooks",
|
|
18
|
+
"identities",
|
|
19
|
+
"integrations",
|
|
20
|
+
"invitations",
|
|
21
|
+
"jobs",
|
|
22
|
+
"keys",
|
|
23
|
+
"labels",
|
|
24
|
+
"licenses",
|
|
25
|
+
"members",
|
|
26
|
+
"milestones",
|
|
27
|
+
"notifications",
|
|
28
|
+
"organizations",
|
|
29
|
+
"packages",
|
|
30
|
+
"pages",
|
|
31
|
+
"permissions",
|
|
32
|
+
"pipelines",
|
|
33
|
+
"policies",
|
|
34
|
+
"projects",
|
|
35
|
+
"releases",
|
|
36
|
+
"repositories",
|
|
37
|
+
"reviews",
|
|
38
|
+
"runners",
|
|
39
|
+
"secrets",
|
|
40
|
+
"sessions",
|
|
41
|
+
"settings",
|
|
42
|
+
"snapshots",
|
|
43
|
+
"statuses",
|
|
44
|
+
"tags",
|
|
45
|
+
"teams",
|
|
46
|
+
"templates",
|
|
47
|
+
"tokens",
|
|
48
|
+
"topics",
|
|
49
|
+
"variables",
|
|
50
|
+
"webhooks",
|
|
51
|
+
"workflows",
|
|
52
|
+
"workspaces",
|
|
53
|
+
"approvals",
|
|
54
|
+
"archives",
|
|
55
|
+
"attestations",
|
|
56
|
+
"billing-accounts",
|
|
57
|
+
"codespaces",
|
|
58
|
+
"dependencies",
|
|
59
|
+
"exports",
|
|
60
|
+
"imports",
|
|
61
|
+
"mirrors",
|
|
62
|
+
"rulesets",
|
|
63
|
+
"security-alerts",
|
|
64
|
+
"service-accounts",
|
|
65
|
+
"signatures",
|
|
66
|
+
"sponsors"
|
|
67
|
+
];
|
|
68
|
+
const stringSchema = { type: "string" };
|
|
69
|
+
const identifierParameter = {
|
|
70
|
+
name: "id",
|
|
71
|
+
in: "path",
|
|
72
|
+
required: true,
|
|
73
|
+
description: "Stable Forgeyard resource identifier.",
|
|
74
|
+
schema: stringSchema
|
|
75
|
+
};
|
|
76
|
+
const queryParameter = {
|
|
77
|
+
name: "query",
|
|
78
|
+
in: "query",
|
|
79
|
+
description: "Search query.",
|
|
80
|
+
schema: stringSchema
|
|
81
|
+
};
|
|
82
|
+
const bodySchema = {
|
|
83
|
+
type: "object",
|
|
84
|
+
required: ["name"],
|
|
85
|
+
properties: {
|
|
86
|
+
name: { type: "string", description: "Display name." },
|
|
87
|
+
active: { type: "boolean", description: "Whether the resource is active." },
|
|
88
|
+
labels: { type: "array", items: { type: "string" }, description: "Labels to attach." }
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const successResponse = {
|
|
92
|
+
description: "Successful Forgeyard response.",
|
|
93
|
+
content: {
|
|
94
|
+
"application/json": {
|
|
95
|
+
schema: { type: "object" },
|
|
96
|
+
example: { ok: true }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export function createForgeyardSpec() {
|
|
101
|
+
const paths = {};
|
|
102
|
+
for (const resource of FORGEYARD_RESOURCES) {
|
|
103
|
+
const tag = resource;
|
|
104
|
+
const singular = singularize(resource);
|
|
105
|
+
const collectionPath = `/v1/${resource}`;
|
|
106
|
+
const resourcePath = `${collectionPath}/{id}`;
|
|
107
|
+
const searchPath = `${collectionPath}/search`;
|
|
108
|
+
const archivePath = `${collectionPath}/{id}/archive`;
|
|
109
|
+
paths[collectionPath] = {
|
|
110
|
+
get: operation(tag, `list ${resource}`, `List ${resource}.`, [queryParameter]),
|
|
111
|
+
post: operation(tag, `create ${singular}`, `Create a ${singular}.`, [], true)
|
|
112
|
+
};
|
|
113
|
+
paths[resourcePath] = {
|
|
114
|
+
get: operation(tag, `view ${singular}`, `View a ${singular}.`, [identifierParameter]),
|
|
115
|
+
put: operation(tag, `replace ${singular}`, `Replace a ${singular}.`, [identifierParameter], true),
|
|
116
|
+
patch: operation(tag, `update ${singular}`, `Update a ${singular}.`, [identifierParameter], true),
|
|
117
|
+
delete: operation(tag, `delete ${singular}`, `Delete a ${singular}.`, [identifierParameter])
|
|
118
|
+
};
|
|
119
|
+
paths[searchPath] = {
|
|
120
|
+
get: operation(tag, `search ${resource}`, `Search ${resource}.`, [queryParameter])
|
|
121
|
+
};
|
|
122
|
+
paths[archivePath] = {
|
|
123
|
+
post: operation(tag, `archive ${singular}`, `Archive a ${singular}.`, [identifierParameter], true)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
paths["/v1/compatibility/quotes"] = {
|
|
127
|
+
get: operation("compatibility", "listQuotes", "List compatibility quotes.", [])
|
|
128
|
+
};
|
|
129
|
+
paths["/v1/compatibility/symbols"] = {
|
|
130
|
+
get: operation("compatibility", "listSymbols", "List compatibility symbols.", [])
|
|
131
|
+
};
|
|
132
|
+
paths["/v1/compatibility/representation"] = {
|
|
133
|
+
get: {
|
|
134
|
+
...operation("compatibility", "get compatibility representation", "Negotiate a wildcard JSON representation.", [
|
|
135
|
+
{
|
|
136
|
+
name: "x-forgeyard-tenant",
|
|
137
|
+
in: "header",
|
|
138
|
+
required: true,
|
|
139
|
+
schema: { type: "string" }
|
|
140
|
+
}
|
|
141
|
+
]),
|
|
142
|
+
responses: {
|
|
143
|
+
"200": {
|
|
144
|
+
description: "Successful wildcard response.",
|
|
145
|
+
content: {
|
|
146
|
+
"*/*": {
|
|
147
|
+
schema: { type: "object" },
|
|
148
|
+
example: { ok: true }
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
paths["/v1/compatibility/jobs"] = {
|
|
156
|
+
post: {
|
|
157
|
+
tags: ["compatibility"],
|
|
158
|
+
summary: "Create a compatibility job without operationId.",
|
|
159
|
+
requestBody: {
|
|
160
|
+
required: true,
|
|
161
|
+
content: {
|
|
162
|
+
"application/json": {
|
|
163
|
+
schema: {
|
|
164
|
+
type: "object",
|
|
165
|
+
required: ["configuration"],
|
|
166
|
+
properties: {
|
|
167
|
+
configuration: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
retries: { type: "integer" },
|
|
171
|
+
matrix: { type: "array", items: { type: "object" } }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
responses: { "200": successResponse }
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
paths["/v1/compatibility/jobs/{id}"] = {
|
|
183
|
+
put: {
|
|
184
|
+
...operation("compatibility", "PUT /v1/compatibility/jobs/{id}", "Update a compatibility job without an explicit operationId.", [identifierParameter], true),
|
|
185
|
+
operationId: undefined
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
paths["/v1/compatibility/jobs/{id}/settings"] = {
|
|
189
|
+
put: {
|
|
190
|
+
...operation("compatibility", "PUT /v1/compatibility/jobs/{id}/settings", "Update compatibility job settings without an explicit operationId.", [identifierParameter], true),
|
|
191
|
+
operationId: undefined
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
paths["/v1/compatibility/dictionary"] = {
|
|
195
|
+
post: {
|
|
196
|
+
tags: ["compatibility"],
|
|
197
|
+
operationId: "create compatibility dictionary",
|
|
198
|
+
summary: "Create a free-form compatibility dictionary.",
|
|
199
|
+
requestBody: {
|
|
200
|
+
required: true,
|
|
201
|
+
content: {
|
|
202
|
+
"application/json": {
|
|
203
|
+
schema: { type: "object", additionalProperties: true }
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
responses: { "200": successResponse }
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
paths["/v1/compatibility/report"] = {
|
|
211
|
+
get: {
|
|
212
|
+
tags: ["compatibility"],
|
|
213
|
+
operationId: "export compatibility report",
|
|
214
|
+
responses: {
|
|
215
|
+
"200": {
|
|
216
|
+
description: "Text report.",
|
|
217
|
+
content: { "text/plain": { schema: { type: "string" }, example: "forgeyard report" } }
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
paths["/v1/compatibility/archive"] = {
|
|
223
|
+
get: {
|
|
224
|
+
tags: ["compatibility"],
|
|
225
|
+
operationId: "download compatibility archive",
|
|
226
|
+
responses: {
|
|
227
|
+
"200": {
|
|
228
|
+
description: "Binary archive.",
|
|
229
|
+
content: {
|
|
230
|
+
"application/octet-stream": {
|
|
231
|
+
schema: { type: "string", format: "binary" }
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
paths["/v1/compatibility/manifest"] = {
|
|
239
|
+
post: {
|
|
240
|
+
tags: ["compatibility"],
|
|
241
|
+
operationId: "import compatibility manifest",
|
|
242
|
+
requestBody: {
|
|
243
|
+
required: true,
|
|
244
|
+
content: {
|
|
245
|
+
"text/xml": {
|
|
246
|
+
schema: { type: "object", properties: { name: { type: "string" } } }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
responses: { "200": successResponse }
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
paths["/v1/compatibility/bundle"] = {
|
|
254
|
+
post: {
|
|
255
|
+
tags: ["compatibility"],
|
|
256
|
+
operationId: "upload compatibility bundle",
|
|
257
|
+
requestBody: {
|
|
258
|
+
required: true,
|
|
259
|
+
content: {
|
|
260
|
+
"application/zip": {
|
|
261
|
+
schema: { type: "string", format: "binary" }
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
responses: { "200": successResponse }
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
paths["/v1/compatibility/attachment"] = {
|
|
269
|
+
post: {
|
|
270
|
+
tags: ["compatibility"],
|
|
271
|
+
operationId: "upload compatibility attachment",
|
|
272
|
+
requestBody: {
|
|
273
|
+
required: true,
|
|
274
|
+
content: {
|
|
275
|
+
"multipart/form-data": {
|
|
276
|
+
schema: {
|
|
277
|
+
type: "object",
|
|
278
|
+
required: ["file", "description"],
|
|
279
|
+
properties: {
|
|
280
|
+
file: { type: "string", format: "binary" },
|
|
281
|
+
description: { type: "string" },
|
|
282
|
+
placement: { type: "integer" }
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
responses: { "200": successResponse }
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
paths["/v1/compatibility/token"] = {
|
|
292
|
+
post: {
|
|
293
|
+
tags: ["compatibility"],
|
|
294
|
+
operationId: "create compatibility token",
|
|
295
|
+
requestBody: {
|
|
296
|
+
required: true,
|
|
297
|
+
content: {
|
|
298
|
+
"application/x-www-form-urlencoded": {
|
|
299
|
+
schema: {
|
|
300
|
+
type: "object",
|
|
301
|
+
required: ["username"],
|
|
302
|
+
properties: { username: { type: "string" }, scopes: { type: "array", items: { type: "string" } } }
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
responses: { "200": successResponse }
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
paths["/v1/compatibility/filter"] = {
|
|
311
|
+
get: {
|
|
312
|
+
...operation("compatibility", "filter compatibility", "Filter compatibility data.", [
|
|
313
|
+
{
|
|
314
|
+
name: "filter",
|
|
315
|
+
in: "query",
|
|
316
|
+
style: "deepObject",
|
|
317
|
+
explode: true,
|
|
318
|
+
schema: { type: "object", properties: { owner: { type: "string" }, active: { type: "boolean" } } }
|
|
319
|
+
}
|
|
320
|
+
])
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
paths["/v1/compatibility/batches/{ids}"] = {
|
|
324
|
+
get: operation("compatibility", "view compatibility batch", "View a compatibility batch.", [
|
|
325
|
+
{ name: "ids", in: "path", required: true, schema: { type: "array", items: { type: "string" } } }
|
|
326
|
+
])
|
|
327
|
+
};
|
|
328
|
+
paths["/v1/compatibility/punctuation"] = {
|
|
329
|
+
get: operation("Product [identifier]", "view punctuation compatibility", "Test safe generated nouns.", [])
|
|
330
|
+
};
|
|
331
|
+
paths["/v1/compatibility/referenced/{id}"] = {
|
|
332
|
+
get: operation("compatibility", "view referenced compatibility", "Source for a cross-path reference.", [identifierParameter])
|
|
333
|
+
};
|
|
334
|
+
paths["/v1/compatibility/referenced/{id}/details"] = {
|
|
335
|
+
get: operation("compatibility", "view referenced compatibility details", "Use a cross-path parameter reference.", [
|
|
336
|
+
{ $ref: "#/paths/~1v1~1compatibility~1referenced~1%7Bid%7D/get/parameters/0" }
|
|
337
|
+
])
|
|
338
|
+
};
|
|
339
|
+
paths["/v1/compatibility/operation-server"] = {
|
|
340
|
+
get: {
|
|
341
|
+
...operation("compatibility", "view operation server compatibility", "Use a fixed operation-level server.", []),
|
|
342
|
+
servers: [{ url: "https://api.forgeyard.invalid" }]
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
paths["/v1/compatibility/explicit-authorization"] = {
|
|
346
|
+
post: {
|
|
347
|
+
...operation("compatibility", "create explicit authorization compatibility", "Use an explicit authorization header.", [
|
|
348
|
+
{ name: "Authorization", in: "header", required: true, schema: { type: "string" } }
|
|
349
|
+
]),
|
|
350
|
+
security: []
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
paths["/v1/compatibility/get-body"] = {
|
|
354
|
+
get: {
|
|
355
|
+
tags: ["compatibility"],
|
|
356
|
+
operationId: "search compatibility with body",
|
|
357
|
+
requestBody: {
|
|
358
|
+
required: true,
|
|
359
|
+
content: {
|
|
360
|
+
"application/json": {
|
|
361
|
+
schema: {
|
|
362
|
+
type: "object",
|
|
363
|
+
required: ["query"],
|
|
364
|
+
properties: { query: { type: "string" } }
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
responses: { "200": successResponse }
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
paths["/v1/compatibility/composed-query"] = {
|
|
373
|
+
get: operation("compatibility", "search composed compatibility", "Use equivalent composed query schemas.", [
|
|
374
|
+
{
|
|
375
|
+
name: "regions",
|
|
376
|
+
in: "query",
|
|
377
|
+
schema: {
|
|
378
|
+
oneOf: [
|
|
379
|
+
{ type: "array", items: { type: "string", format: "country-code-2" } },
|
|
380
|
+
{ type: "array", items: { type: "string", format: "negated-country-code-2" } }
|
|
381
|
+
]
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
])
|
|
385
|
+
};
|
|
386
|
+
paths["/v1/compatibility/bracketed-array"] = {
|
|
387
|
+
get: operation("compatibility", "search bracketed compatibility", "Use bracketed array query serialization.", [
|
|
388
|
+
{ name: "expand", in: "query", style: "deepObject", explode: true, schema: { type: "array", items: { type: "string" } } }
|
|
389
|
+
])
|
|
390
|
+
};
|
|
391
|
+
paths["/v1/compatibility/deep-union"] = {
|
|
392
|
+
get: operation("compatibility", "search union compatibility", "Use a deep-object query union.", [
|
|
393
|
+
{
|
|
394
|
+
name: "created",
|
|
395
|
+
in: "query",
|
|
396
|
+
style: "deepObject",
|
|
397
|
+
explode: true,
|
|
398
|
+
schema: { anyOf: [{ type: "object", properties: { gt: { type: "integer" } } }, { type: "integer" }] }
|
|
399
|
+
}
|
|
400
|
+
])
|
|
401
|
+
};
|
|
402
|
+
paths["/v1/maps/{id}/attachments"] = {
|
|
403
|
+
post: {
|
|
404
|
+
tags: ["attachments"],
|
|
405
|
+
parameters: [{ name: "id", in: "path", required: true, schema: { type: "string" } }],
|
|
406
|
+
responses: { "201": successResponse }
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
paths["/v1/spots/{id}/attachments"] = {
|
|
410
|
+
post: {
|
|
411
|
+
tags: ["attachments"],
|
|
412
|
+
parameters: [{ name: "id", in: "path", required: true, schema: { type: "string" } }],
|
|
413
|
+
responses: { "201": successResponse }
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
return {
|
|
417
|
+
openapi: "3.0.3",
|
|
418
|
+
info: {
|
|
419
|
+
title: "Forgeyard API",
|
|
420
|
+
version: "1.0.0"
|
|
421
|
+
},
|
|
422
|
+
paths
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function operation(tag, operationId, summary, parameters, requestBody = false) {
|
|
426
|
+
return {
|
|
427
|
+
tags: [tag],
|
|
428
|
+
operationId,
|
|
429
|
+
summary,
|
|
430
|
+
...(parameters.length === 0 ? {} : { parameters }),
|
|
431
|
+
...(requestBody
|
|
432
|
+
? {
|
|
433
|
+
requestBody: {
|
|
434
|
+
required: true,
|
|
435
|
+
content: {
|
|
436
|
+
"application/json": { schema: bodySchema }
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
: {}),
|
|
441
|
+
responses: { "200": successResponse }
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function singularize(resource) {
|
|
445
|
+
if (resource.endsWith("ies")) {
|
|
446
|
+
return `${resource.slice(0, -3)}y`;
|
|
447
|
+
}
|
|
448
|
+
if (resource.endsWith("ses")) {
|
|
449
|
+
return resource.slice(0, -2);
|
|
450
|
+
}
|
|
451
|
+
return resource.endsWith("s") ? resource.slice(0, -1) : resource;
|
|
452
|
+
}
|
package/dist/mock.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { mockFetch } from "./mock/fetch.js";
|
|
2
|
+
export { createForgeyardSpec, FORGEYARD_BASE_URL, FORGEYARD_RESOURCES } from "./mock/forgeyard.js";
|
|
2
3
|
export type { MockFetchHandle, MockFetchOptions, MockFetchFixtures, MockFixtureEntry, OnUnmocked, RequestRecord } from "./mock/fetch.js";
|
package/dist/mock.js
CHANGED
package/dist/naming.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
|
|
1
|
+
export type HttpMethod = "get" | "post" | "put" | "patch" | "delete" | "head" | "options";
|
|
2
2
|
type MethodDefaults = {
|
|
3
3
|
collection: string;
|
|
4
4
|
resource: string;
|
|
@@ -10,9 +10,12 @@ export declare const METHOD_DEFAULTS: Partial<Record<HttpMethod, MethodDefaults>
|
|
|
10
10
|
export declare function deriveNoun(operation: {
|
|
11
11
|
tags?: string[];
|
|
12
12
|
}, path: string, operationId: string): string;
|
|
13
|
+
export declare function normalizeNoun(value: string): string;
|
|
13
14
|
export declare function deriveVerb(method: HttpMethod, path: string, operation: {
|
|
14
15
|
operationId?: string;
|
|
15
16
|
}, operationId: string, noun: string): string;
|
|
17
|
+
export declare function deriveDisambiguatedVerb(operationId: string, noun: string): string;
|
|
18
|
+
export declare function derivePathDisambiguatedVerb(method: HttpMethod, path: string, noun: string, verb: string, includeTemplateQualifiers?: boolean, includeParentQualifiers?: boolean): string;
|
|
16
19
|
export declare function normalizeParamName(name: string): string;
|
|
17
20
|
export declare function toPascalCase(value: string): string;
|
|
18
21
|
export declare function toCamelCase(value: string): string;
|
package/dist/naming.js
CHANGED
|
@@ -10,18 +10,19 @@ export const METHOD_DEFAULTS = {
|
|
|
10
10
|
resource: "view",
|
|
11
11
|
genericVerbs: ["get", "list", "view"],
|
|
12
12
|
preferOperationIdWhenPathTailIsGeneric: true
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
head: { collection: "check", resource: "check" },
|
|
15
|
+
options: { collection: "options", resource: "options" }
|
|
14
16
|
};
|
|
15
17
|
export function deriveNoun(operation, path, operationId) {
|
|
16
18
|
const noun = operation.tags?.[0];
|
|
17
19
|
if (typeof noun !== "string" || noun.length === 0) {
|
|
18
|
-
|
|
19
|
-
if (fallbackNoun === undefined) {
|
|
20
|
-
throw new UserError(`Operation ${JSON.stringify(operationId)} must define tags[0] or a static resource segment in the path to derive a command noun.`);
|
|
21
|
-
}
|
|
22
|
-
return fallbackNoun;
|
|
20
|
+
return normalizeNoun(deriveNounFromPath(path) ?? operationId);
|
|
23
21
|
}
|
|
24
|
-
return
|
|
22
|
+
return normalizeNoun(noun);
|
|
23
|
+
}
|
|
24
|
+
export function normalizeNoun(value) {
|
|
25
|
+
return toKebabCase([...value].map((character) => (isNounWordCharacter(character) ? character : " ")).join(""));
|
|
25
26
|
}
|
|
26
27
|
export function deriveVerb(method, path, operation, operationId, noun) {
|
|
27
28
|
const segments = splitPathSegments(path);
|
|
@@ -49,8 +50,51 @@ export function deriveVerb(method, path, operation, operationId, noun) {
|
|
|
49
50
|
if (derived !== undefined) {
|
|
50
51
|
return derived;
|
|
51
52
|
}
|
|
53
|
+
const fallback = deriveVerbFromPath(method, segments, noun);
|
|
54
|
+
if (fallback !== undefined) {
|
|
55
|
+
return fallback;
|
|
56
|
+
}
|
|
52
57
|
throw new UserError(`Operation ${JSON.stringify(operationId)} is missing an operationId, so toolcraft-openapi cannot derive a stable command verb.`);
|
|
53
58
|
}
|
|
59
|
+
function deriveVerbFromPath(method, segments, noun) {
|
|
60
|
+
const action = method === "post" ? "create" : method === "put" || method === "patch" ? "update" : undefined;
|
|
61
|
+
if (action === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const staticSegments = segments
|
|
65
|
+
.filter((segment) => !isPathTemplateSegment(segment) && segment !== "api" && !isVersionWord(segment))
|
|
66
|
+
.map((segment) => toKebabCase(segment));
|
|
67
|
+
const nounIndex = staticSegments.indexOf(noun);
|
|
68
|
+
const qualifiers = nounIndex === -1 ? staticSegments.slice(1) : staticSegments.slice(nounIndex + 1);
|
|
69
|
+
return qualifiers.length === 0 ? action : `${action}-${qualifiers.join("-")}`;
|
|
70
|
+
}
|
|
71
|
+
export function deriveDisambiguatedVerb(operationId, noun) {
|
|
72
|
+
const words = trimLeadingWords(splitWords(operationId).filter((word) => !isVersionWord(word)), splitWords(noun));
|
|
73
|
+
const withoutGenericVerb = stripLeadingGenericVerb(words, ["create", "delete", "get", "list", "patch", "post", "put", "remove", "update", "view"]);
|
|
74
|
+
const candidate = withoutGenericVerb.length === 0 ? words : withoutGenericVerb;
|
|
75
|
+
return candidate.map(normalizeNoun).filter((word) => word.length > 0).join("-");
|
|
76
|
+
}
|
|
77
|
+
export function derivePathDisambiguatedVerb(method, path, noun, verb, includeTemplateQualifiers = false, includeParentQualifiers = false) {
|
|
78
|
+
const segments = splitPathSegments(path);
|
|
79
|
+
const nounIndex = segments.findIndex((segment) => toKebabCase(segment) === noun);
|
|
80
|
+
const relevantSegments = includeParentQualifiers || nounIndex === -1 ? segments : segments.slice(nounIndex + 1);
|
|
81
|
+
const staticQualifiers = relevantSegments
|
|
82
|
+
.flatMap(readStaticPathSegmentWords)
|
|
83
|
+
.filter((word) => word !== "api" && !isVersionWord(word));
|
|
84
|
+
const templateQualifiers = relevantSegments.flatMap(readPathTemplateWords);
|
|
85
|
+
const qualifiers = includeTemplateQualifiers
|
|
86
|
+
? [...staticQualifiers, ...templateQualifiers]
|
|
87
|
+
: staticQualifiers.length > 0
|
|
88
|
+
? staticQualifiers
|
|
89
|
+
: templateQualifiers;
|
|
90
|
+
if (qualifiers.length === 0) {
|
|
91
|
+
return verb;
|
|
92
|
+
}
|
|
93
|
+
const defaultVerb = METHOD_DEFAULTS[method]?.resource ??
|
|
94
|
+
METHOD_DEFAULTS[method]?.collection ??
|
|
95
|
+
(method === "post" ? "create" : method === "put" || method === "patch" ? "update" : verb);
|
|
96
|
+
return `${defaultVerb}-${qualifiers.join("-")}`;
|
|
97
|
+
}
|
|
54
98
|
export function normalizeParamName(name) {
|
|
55
99
|
return toCamelCase(name);
|
|
56
100
|
}
|
|
@@ -97,9 +141,51 @@ function deriveNounFromPath(path) {
|
|
|
97
141
|
.map((segment) => toKebabCase(segment))
|
|
98
142
|
.find((segment) => segment.length > 0);
|
|
99
143
|
}
|
|
144
|
+
function isNounWordCharacter(character) {
|
|
145
|
+
return ((character >= "a" && character <= "z") ||
|
|
146
|
+
(character >= "A" && character <= "Z") ||
|
|
147
|
+
(character >= "0" && character <= "9") ||
|
|
148
|
+
character === "-" ||
|
|
149
|
+
character === "_");
|
|
150
|
+
}
|
|
100
151
|
function isPathTemplateSegment(segment) {
|
|
101
152
|
return segment !== undefined && segment.startsWith("{") && segment.endsWith("}");
|
|
102
153
|
}
|
|
154
|
+
function readStaticPathSegmentWords(segment) {
|
|
155
|
+
let depth = 0;
|
|
156
|
+
let staticText = "";
|
|
157
|
+
for (const character of segment) {
|
|
158
|
+
if (character === "{") {
|
|
159
|
+
depth += 1;
|
|
160
|
+
staticText += " ";
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (character === "}") {
|
|
164
|
+
depth = Math.max(0, depth - 1);
|
|
165
|
+
staticText += " ";
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
staticText += depth === 0 ? character : " ";
|
|
169
|
+
}
|
|
170
|
+
return splitWords(staticText.replaceAll(":", " "));
|
|
171
|
+
}
|
|
172
|
+
function readPathTemplateWords(segment) {
|
|
173
|
+
let depth = 0;
|
|
174
|
+
let templateText = "";
|
|
175
|
+
for (const character of segment) {
|
|
176
|
+
if (character === "{") {
|
|
177
|
+
depth += 1;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (character === "}") {
|
|
181
|
+
depth = Math.max(0, depth - 1);
|
|
182
|
+
templateText += " ";
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
templateText += depth > 0 ? character : " ";
|
|
186
|
+
}
|
|
187
|
+
return splitWords(templateText.replaceAll(":", " "));
|
|
188
|
+
}
|
|
103
189
|
function deriveVerbFromOperationId(method, operationId, noun, defaults) {
|
|
104
190
|
const words = normalizeOperationIdWords(method, operationId, noun);
|
|
105
191
|
if (words === undefined) {
|