up
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Symbols Server CI / symbols-smoke (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled

This commit is contained in:
StellaOps Bot
2025-11-24 20:57:49 +02:00
parent 46c8c47d06
commit 7c39058386
92 changed files with 3549 additions and 157 deletions

View File

@@ -0,0 +1,36 @@
# TypeScript SDK (SDKGEN-63-001)
This directory contains deterministic generator settings for the TypeScript SDK.
## Prereqs
- OpenAPI spec file path exported as `STELLA_OAS_FILE` (temporary until APIG0101 publishes the canonical spec).
- OpenAPI Generator CLI 7.4.0 jar at `tools/openapi-generator-cli-7.4.0.jar` or override `STELLA_OPENAPI_GENERATOR_JAR`.
- JDK 21 available on PATH (vendored at `../tools/jdk-21.0.1+12`; set `JAVA_HOME` accordingly).
## Generate
```bash
cd src/Sdk/StellaOps.Sdk.Generator
STELLA_OAS_FILE=/path/to/api.yaml \
STELLA_SDK_OUT=$(mktemp -d) \
STELLA_OPENAPI_GENERATOR_JAR=tools/openapi-generator-cli-7.4.0.jar \
ts/generate-ts.sh
```
Outputs land in `out/typescript/` and are post-processed to:
- Normalize whitespace/line endings.
- Inject traceability banner.
- Copy shared helpers (`sdk-hooks.ts`) and wire them through the package barrel.
To validate the pipeline locally with a tiny fixture spec (`ts/fixtures/ping.yaml`), run:
```bash
cd src/Sdk/StellaOps.Sdk.Generator/ts
./test_generate_ts.sh # skips if the generator jar is absent
```
## Notes
- README/package.json are suppressed in generator output; Release pipeline provides deterministic packaging instead.
- Global properties disable model/api docs/tests to keep the alpha lean and deterministic.
- Helper wiring depends on `STELLA_POSTPROCESS_ROOT`/`STELLA_POSTPROCESS_LANG` being set by the script.
- Override output directory via `STELLA_SDK_OUT` to avoid mutating the repo during local tests.

View File

@@ -0,0 +1,29 @@
# OpenAPI Generator config for the StellaOps TypeScript SDK (alpha)
generatorName: typescript-fetch
outputDir: out/typescript
additionalProperties:
npmName: "@stellaops/sdk"
npmVersion: "0.0.0-alpha"
supportsES6: true
useSingleRequestParameter: true
modelPropertyNaming: original
enumPropertyNaming: original
withoutRuntimeChecks: true
withNodeImports: true
snapshot: true
legacyDiscriminatorBehavior: false
withoutPrefixEnums: true
typescriptThreePlus: true
stringifyEnums: false
npmRepository: ""
projectName: "stellaops-sdk"
gitUserId: "stella-ops"
gitRepoId: "sdk-typescript"
# Post-process hook is supplied via env (STELLA_SDK_POSTPROCESS / postProcessFile)
globalProperty:
apiDocs: false
modelDocs: false
apiTests: false
modelTests: false

View File

@@ -0,0 +1,27 @@
openapi: 3.0.3
info:
title: StellaOps SDK Fixture
version: 0.0.1
paths:
/ping:
get:
summary: Health probe
operationId: ping
responses:
"200":
description: ok
content:
application/json:
schema:
$ref: '#/components/schemas/PingResponse'
components:
schemas:
PingResponse:
type: object
properties:
message:
type: string
example: pong
required:
- message

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail
root_dir="$(cd -- "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
config="$root_dir/ts/config.yaml"
spec="${STELLA_OAS_FILE:-}"
if [ -z "$spec" ]; then
echo "STELLA_OAS_FILE is required (path to OpenAPI spec)" >&2
exit 1
fi
output_dir="${STELLA_SDK_OUT:-$root_dir/out/typescript}"
mkdir -p "$output_dir"
# Ensure postprocess copies shared helpers into the generated tree
export STELLA_POSTPROCESS_ROOT="$output_dir"
export STELLA_POSTPROCESS_LANG="ts"
JAR="${STELLA_OPENAPI_GENERATOR_JAR:-$root_dir/tools/openapi-generator-cli-7.4.0.jar}"
if [ ! -f "$JAR" ]; then
echo "OpenAPI Generator CLI jar not found at $JAR" >&2
echo "Set STELLA_OPENAPI_GENERATOR_JAR or download to tools/." >&2
exit 1
fi
JAVA_OPTS="${JAVA_OPTS:-} -Dorg.openapitools.codegen.utils.postProcessFile=$root_dir/postprocess/postprocess.sh"
export JAVA_OPTS
java -jar "$JAR" generate \
-i "$spec" \
-g typescript-fetch \
-c "$config" \
--skip-validate-spec \
--enable-post-process-file \
--type-mappings object=any,DateTime=string,Date=date \
--import-mappings Set=Array \
--global-property models,apis,supportingFiles \
-o "$output_dir"
# Ensure shared helpers are present even if upstream post-process hooks were skipped for some files
if [ -f "$output_dir/src/index.ts" ]; then
"$root_dir/postprocess/postprocess.sh" "$output_dir/src/index.ts"
fi
echo "TypeScript SDK generated at $output_dir"

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
root_dir="$(cd -- "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
script="$root_dir/ts/generate-ts.sh"
spec="$root_dir/ts/fixtures/ping.yaml"
jar_default="$root_dir/tools/openapi-generator-cli-7.4.0.jar"
jar="${STELLA_OPENAPI_GENERATOR_JAR:-$jar_default}"
if [ ! -f "$jar" ]; then
echo "SKIP: generator jar not found at $jar" >&2
exit 0
fi
if ! command -v java >/dev/null 2>&1; then
echo "SKIP: java not on PATH; set JAVA_HOME or install JDK to run this smoke." >&2
exit 0
fi
out_dir="$(mktemp -d)"
trap 'rm -rf "$out_dir"' EXIT
STELLA_OAS_FILE="$spec" \
STELLA_SDK_OUT="$out_dir" \
STELLA_OPENAPI_GENERATOR_JAR="$jar" \
JAVA_OPTS="${JAVA_OPTS:-} -Dorg.openapitools.codegen.utils.postProcessFile=$root_dir/postprocess/postprocess.sh" \
"$script"
test -f "$out_dir/src/apis/DefaultApi.ts" || { echo "missing generated API" >&2; exit 1; }
test -f "$out_dir/sdk-hooks.ts" || { echo "missing helper copy" >&2; exit 1; }
# Basic eslint-free sanity: ensure banner on generated helper
first_line=$(head -n 1 "$out_dir/sdk-hooks.ts")
if [[ "$first_line" != "// Generated by StellaOps SDK generator — do not edit." ]]; then
echo "missing banner in helper" >&2
exit 1
fi
echo "TypeScript generator smoke test passed"