Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7dd304e
remove internal schemas package, use ajv with @elastic/schemas
JoshMock Jul 8, 2026
00f1a1b
add memory benchmark
JoshMock Jul 16, 2026
bd458bd
chore: regenerate NOTICE.txt
github-actions[bot] Jul 10, 2026
4ea4b78
chore: update CLI schema
JoshMock Jul 22, 2026
2eb0f3a
don't print stack trace to stdout or stderr when in json output mode
JoshMock Jul 16, 2026
2469045
linter cleanup
JoshMock Jul 16, 2026
48b0a27
fix stderr-related test failure
JoshMock Jul 22, 2026
fdc8355
fix test failures
JoshMock Jul 22, 2026
1a18e99
fix kibana integration tests
JoshMock Jul 24, 2026
25b18eb
migrate cloud API to schemas tools
JoshMock Jul 27, 2026
3d693a5
migrate serverless apis to schemas
JoshMock Jul 29, 2026
c27606a
chore: upgrade @elastic/schemas
JoshMock Jul 30, 2026
483cbfe
fix: support for deferencing type defs in sidecar JSON schema files
JoshMock Jul 30, 2026
c9f5b4a
fix: update schema
JoshMock Jul 30, 2026
26d4f4e
drop codegen workflows and scripts
JoshMock Jul 31, 2026
9704a8c
address integration test failures
JoshMock Jul 31, 2026
c2a566a
update schema
JoshMock Jul 31, 2026
e6d9343
flatten nested oneOf/anyOf branches in Kibana APIs
JoshMock Jul 31, 2026
58c5fa0
resolve npm audit
JoshMock Aug 3, 2026
992d00e
fix(factory): validate stdin/--input-file bodies with the same relaxa…
JoshMock Aug 3, 2026
d3036b8
fix(kb): fail loudly on Kibana path-parameter mismatches instead of s…
JoshMock Aug 3, 2026
7353bdf
fix(cloud): resolve root $ref input schemas instead of discarding them
JoshMock Aug 3, 2026
97481ff
fix(cli): make --json validation errors clear and machine-readable
JoshMock Aug 3, 2026
f34cc64
fix(cli): configure ajv for the version actually installed
JoshMock Aug 3, 2026
821372c
chore(ci): drop release-please entries for the deleted es-schemas wor…
JoshMock Aug 3, 2026
28084a0
docs: describe the JSON Schema + ajv architecture instead of the remo…
JoshMock Aug 3, 2026
a001225
test: guard against silent @elastic/schemas command drift
JoshMock Aug 3, 2026
58c4f51
test(perf): make heap-check measure definition loading, not just the …
JoshMock Aug 3, 2026
33178af
test: validate against real @elastic/schemas shapes, not hand-crafted…
JoshMock Aug 3, 2026
2a46f21
chore: drop the last zod import and the unused @cli-schema packages
JoshMock Aug 3, 2026
f100dfa
fix: correct Zod-era `required` assumptions in path-parameter handling
JoshMock Aug 3, 2026
e923f14
refactor: fail loudly on CLI flag collisions and stop excluding real …
JoshMock Aug 3, 2026
d51abd4
chore: rename schema-args test and correct the stale build-memory com…
JoshMock Aug 3, 2026
54fde45
refactor(kb): delete the dead Kb*Param interfaces
JoshMock Aug 4, 2026
7c1dd11
refactor: drop the bare found_in strip branch, a Zod-era leftover
JoshMock Aug 4, 2026
47bfb42
refactor: use ajv's own types where they pay, keep a narrow view wher…
JoshMock Aug 4, 2026
ce475ca
merge main
JoshMock Aug 5, 2026
c10630f
refactor: use new JSON schema metadata to remove some workarounds
JoshMock Aug 4, 2026
d387f05
update schema
JoshMock Aug 5, 2026
12393d9
fix: update vulnerable packages
JoshMock Aug 5, 2026
3ef6720
use schemas metadata to build Cloud APIs list
JoshMock Aug 5, 2026
53fde2a
chore: regenerate NOTICE.txt
github-actions[bot] Aug 5, 2026
6ae2cff
fix bug found by kibana e2e test
JoshMock Aug 5, 2026
e31ec96
update docs schema
JoshMock Aug 5, 2026
030c879
refactor(kb): key multipart encoding off an explicit endpoint allowlist
JoshMock Aug 5, 2026
eab2b98
fix(config): validate URL parseability and share one AJV config
JoshMock Aug 5, 2026
ff5468c
fix(cloud): reject unknown input keys in cloud command schemas
JoshMock Aug 5, 2026
94a6e91
docs: restore JSDoc and rationale comments dropped in the JSON Schema…
JoshMock Aug 5, 2026
a6c5979
refactor(cli): use @cli-schema/spec types instead of local duplicates
JoshMock Aug 5, 2026
415d020
refactor(cli): single enforcement point for Kibana definition validation
JoshMock Aug 5, 2026
1f4ff0b
refactor(cli): revert grp rename churn and drop stale config/doc refe…
JoshMock Aug 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .buildkite/run-cloud-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ nvm use "$NODE_VERSION"
echo "--- Installing dependencies"
npm ci

# Per-endpoint Zod schemas (#171) make tsc's declaration emit exceed the 2 GB
# default Node heap. Match the GitHub Actions ceiling so build and tests agree.
# Per-endpoint Zod schemas (#171) that once required this are gone, but tsc
# build still peaks around 3.7 GB locally; match the GitHub Actions ceiling
# so build and tests agree.
export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=6144"

echo "--- Building CLI"
Expand Down
5 changes: 3 additions & 2 deletions .buildkite/run-es-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ echo "Using jq $(jq --version)"
echo "--- Installing dependencies"
npm ci

# Per-endpoint Zod schemas (#171) make tsc's declaration emit exceed the 2 GB
# default Node heap. Match the GitHub Actions ceiling so build and tests agree.
# Per-endpoint Zod schemas (#171) that once required this are gone, but tsc
# build still peaks around 3.7 GB locally; match the GitHub Actions ceiling
# so build and tests agree.
export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=6144"

echo "--- Building CLI"
Expand Down
2 changes: 1 addition & 1 deletion .github/.release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{".":"0.2.0","packages/config-resolver":"0.1.0","packages/es-schemas":"1.0.2"}
{".":"0.2.0","packages/config-resolver":"0.1.0"}
4 changes: 0 additions & 4 deletions .github/release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"packages/config-resolver": {
"component": "config-resolver",
"release-type": "node"
},
"packages/es-schemas": {
"component": "es-schemas",
"release-type": "node"
}
},
"plugins": [
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [22.x, 24.x, 25.x]
runs-on: ${{ matrix.os }}
# Per-endpoint Zod schemas (#171) compile to ~72 MB of .d.ts; tsc needs
# more than the 2 GB Node default to hold the type graph during emit.
# Per-endpoint Zod schemas (#171) that once bloated .d.ts emit are gone,
# but tsc build still peaks around 3.7 GB locally; keep headroom above
# the 2 GB Node default for slower/smaller CI runners.
env:
NODE_OPTIONS: --max-old-space-size=6144
steps:
Expand Down
130 changes: 0 additions & 130 deletions .github/workflows/codegen.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/heap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Heap memory

on:
pull_request:
push:
branches:
- main

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
heap:
name: Heap regression check
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false

- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24.x

- name: Install
run: npm ci

- name: Build
run: npm run build

- name: Run heap check
run: scripts/heap-check
5 changes: 1 addition & 4 deletions .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
"threshold": 5,
"reporters": ["console"],
"ignore": [
"NOTICE.txt",
"node_modules/**",
"dist/**",
"build/**",
"src/es/apis/schemas/**",
"src/es/apis/**",
"src/cloud/apis/**",
"packages/es-schemas/src/**",
"test/**",
"codegen/**",
"specs/**",
Expand Down
3 changes: 0 additions & 3 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ TYPESCRIPT_ES_CONFIG_FILE: eslint.config.js
# Global exclusions
FILTER_REGEX_EXCLUDE: "(node_modules/|dist/|build/|\\.git/)"

# Skip generated code for ESLint (39k lines of schemas + 2k lines of cloud APIs)
TYPESCRIPT_ES_FILTER_REGEX_EXCLUDE: "(src/es/apis/schemas/|src/cloud/apis/|packages/es-schemas/src/)"

# yamllint: skip test fixtures (custom multi-doc YAML DSL)
YAML_YAMLLINT_CONFIG_FILE: .yamllint.yml
YAML_YAMLLINT_FILTER_REGEX_EXCLUDE: "(codegen/functional/test/fixtures/|node_modules/)"
Expand Down
24 changes: 13 additions & 11 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full policy.

- **Runtime**: Node.js with native TypeScript (`--experimental-strip-types`)
- **CLI Framework**: Commander.js
- **Validation**: Zod v4
- **Validation**: JSON Schema (`@elastic/schemas`) validated with `ajv`
- **Config Management**: cosmiconfig (YAML serialization)
- **Testing**: Node.js built-in test runner (`node:test`)
- **Linting**: ESLint + TypeScript ESLint, MegaLinter (CI + pre-commit)
Expand All @@ -39,7 +39,7 @@ All requirements below are non-negotiable and enforced at review time.

- **JSON via stdin and `--input-file`**: Structured input MUST be accepted from stdin or `--input-file <path>`. Neither takes precedence; providing both MUST error.
- **CLI flags for all input fields**: Every top-level schema field MUST have a corresponding kebab-case CLI flag. When both JSON input and flags are provided, flags take precedence.
- **Zod input schema**: Every command with structured input MUST declare a Zod schema as the single source of truth for validation, type inference, and help text. `input: true` (untyped) MUST NOT be used in new commands.
- **JSON Schema input**: Every command with structured input MUST declare a JSON Schema document (from `@elastic/schemas`, or hand-authored for commands with no upstream schema) as the single source of truth for validation and help text. `input: true` (untyped) MUST NOT be used in new commands.
- **Validate before executing**: All input MUST be validated before any handler logic or network call. Invalid input is a hard error.
- **Reject unknown keys**: Input with undefined keys MUST produce a validation error naming the unknown field(s). Silent stripping is not acceptable.

Expand All @@ -60,8 +60,8 @@ All requirements below are non-negotiable and enforced at review time.

### Transport Abstraction

- **Hide routing metadata**: `found_in: path | query | body` is an implementation detail. It MUST NOT appear in help text, schema output, or error messages.
- **Validate path parameter coverage**: If a schema field has `found_in: "path"` but the URL template has no matching placeholder, the system MUST fail fast at registration time.
- **Hide routing metadata**: `x-found-in: path | query | body` is an implementation detail. It MUST NOT appear in help text, schema output, or error messages.
- **Validate path parameter coverage**: If a schema field has `x-found-in: "path"` but the URL template has no matching placeholder, the system MUST fail fast at registration time.

### Cross-Platform Compatibility

Expand Down Expand Up @@ -149,25 +149,27 @@ When constructing URLs, sending credentials, or making HTTP requests:

## Generic Abstractions: Lessons Learned

1. **Enumerate all variants upfront.** `unwrapField()` only handled `optional` and `default`; codegen also produced `z.lazy()`, `z.record()`, `z.any()`, `z.union()`, which all fell through silently. Inspect the full set of types the upstream system can produce and add explicit branches or a loud failure for unrecognized cases.
1. **Enumerate all variants upfront.** A now-retired field-unwrapping helper only handled two shapes out of the many the input source could produce, and the rest fell through silently. The current equivalent is `@elastic/schemas`' use of JSON Schema composition (`$ref`, `anyOf`, `oneOf`, `allOf`, root-level `$ref`): inspect the full set of shapes the upstream schemas can produce (see `src/lib/json-schema-refs.ts`, `src/kb/apis.ts`'s `flattenComposition`) and add explicit handling or a loud failure for unrecognized ones.

2. **Fail loudly on unrecognized input.** A catch-all `return { typeName: def.type, isOptional: false }` silently returned garbage. `throw new Error('unhandled Zod type: ' + def.type)` would have surfaced the problem at registration time.
The same applies to upstream `x-` annotations. The current set is `x-found-in`, `x-body-root`, `x-api`, `x-method`, `x-path`, `x-urls`, `x-body-format`, `x-destructive`, `x-response-type`, `x-availability`, `x-deprecated`. New ones appear without warning; classify each as routing (must be stripped from output) or user-facing (may be surfaced) rather than matching on the `x-` prefix. See `ARCHITECTURE.md` → "Schema Composition and `x-` Metadata".

3. **Test with real generated schemas.** Hand-crafted toy schemas miss codegen-specific types like `z.lazy`.
2. **Fail loudly on unrecognized input.** A catch-all fallback once silently returned a garbage field type instead of erroring. `src/lib/json-schema-refs.ts`'s `resolveRootRef()` follows the fix: it throws when a root ref doesn't resolve to an object schema with properties, rather than letting a silently-empty schema reach downstream flag derivation.

4. **Generic request builders need extension points for endpoint-specific semantics.** The bulk API needs NDJSON; the index API needs body promotion. Add explicit extension points (`bodyFormat`, `BODY_ROOT_FIELDS`) rather than special-casing later.
3. **Test with real schemas from the actual source.** Hand-crafted toy schemas miss shapes that only appear in real `@elastic/schemas` output (e.g. Kibana's per-rule-type `allOf`/`oneOf` bodies).

4. **Generic request builders need extension points for endpoint-specific semantics.** The bulk API needs NDJSON; the index API needs body promotion. Add explicit extension points (`bodyFormat`, and the upstream `x-body-root` annotation) rather than special-casing later.

5. **Diagnose common mistakes in user-facing errors.** Map known error patterns (TLS mismatch, auth failure, DNS) to actionable hints instead of propagating raw messages.

6. **Treat codegen output as untrusted input.** Validate assumptions about which Zod types appear with tests that use actual generated schemas.
6. **Treat upstream schema output as untrusted input.** Validate assumptions about which JSON Schema shapes appear with tests that use the actual `@elastic/schemas` definitions, not synthetic ones.

7. **Read external type definitions before setting properties.** `TransportRequestParams` has `bulkBody` for NDJSON, not `body` + custom headers. JavaScript silently ignores extra properties; only `tsc --noEmit` or CI catches this. Run `npx tsc --noEmit` before pushing.

8. **Guard clauses that discard data are dangerous.** `if (!(def.body instanceof z.ZodObject)) return undefined` silently dropped all stdin/`--input-file` input for Cloud POST commands. When a guard returns early with no data, ask what happens to the caller's input. Prefer forwarding with passthrough semantics over silent discard.
8. **Guard clauses that discard data are dangerous.** A guard that returned early whenever a Cloud POST body wasn't a recognized shape once silently dropped all stdin/`--input-file` input for those commands. When a guard returns early with no data, ask what happens to the caller's input. Prefer forwarding with passthrough semantics over silent discard.

9. **Trace the full data flow for every mode combination.** `--json` broke cat APIs because the handler returned raw text and the factory blindly called `JSON.stringify()`. When two layers cooperate (handler + formatter, request builder + transport), enumerate all mode combinations and verify each.

10. **Review codegen command names for UX.** Machine-generated names (e.g. `list-deployments`) are precise but verbose. Add short aliases where unambiguous so users can discover commands intuitively.
10. **Review upstream command names for UX.** Names sourced directly from `@elastic/schemas` (e.g. `list-deployments`) are precise but verbose. Add short aliases where unambiguous so users can discover commands intuitively.

## Spec-Kit Workflow

Expand Down
Loading
Loading