Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit f0fe738

Browse files
committed
initial commit
0 parents  commit f0fe738

File tree

106 files changed

+6124
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+6124
-0
lines changed

.github/workflows/fetch.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Fetch OpenAPI spec
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
jobs:
7+
fetch:
8+
name: Fetch pi OpenAPI spec
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
steps:
14+
- name: Checkout this repo
15+
uses: actions/checkout@v4
16+
with:
17+
ref: main
18+
fetch-depth: 0
19+
20+
- name: fetch mediator OpenAPI spec
21+
shell: bash
22+
run: |
23+
set -euo pipefail
24+
gh api -H "Accept: application/vnd.github+json" \
25+
-H "X-GitHub-Api-Version: 2022-11-28" \
26+
/repos/stacklok/mediator/contents/pkg/api/openapi/mediator/v1/mediator.swagger.json | jq -r '.content' | base64 -d > src/openapi.json
27+
env:
28+
GH_TOKEN: ${{ secrets.REPO_READER_TOKEN }}
29+
30+
- name: Check if OpenAPI changed
31+
id: check-openapi
32+
run: |
33+
if ! git diff --quiet src/openapi.json; then
34+
echo "changed=true" >> "$GITHUB_OUTPUT"
35+
else
36+
echo "changed=false" >> "$GITHUB_OUTPUT"
37+
fi
38+
39+
- name: Set Git config
40+
run: |
41+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
42+
git config --global user.name "github-actions[bot]"
43+
44+
- name: Generate PR if needed
45+
if: steps.check-openapi.outputs.changed == 'true'
46+
run: |
47+
git checkout -b update-openapi-$GITHUB_SHA
48+
49+
git add src/openapi.json
50+
git commit -m "Update mediator OpenAPI to version generated from ref $GITHUB_SHA"
51+
52+
echo "Pushing branch so we can create a PR..."
53+
git push --set-upstream origin update-openapi-$GITHUB_SHA
54+
55+
gh pr create --title "Update OpenAPI" \
56+
--body "This PR updates the OpenAPI definition to the version generated from ref $GITHUB_SHA" \
57+
--repo "$GITHUB_REPOSITORY" \
58+
--base main \
59+
--head update-openapi-$GITHUB_SHA
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/generate.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Generate clients
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
jobs:
8+
generate-clients:
9+
name: Generate clients
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup npm
19+
uses: actions/setup-node@v3
20+
with:
21+
node-version: 20
22+
cache: npm
23+
24+
- name: Install dependencies
25+
run: npm install
26+
27+
- name: Generate mediator clients
28+
run: npm run generate
29+
30+
- name: Check if generated clients changed
31+
id: check-openapi
32+
run: |
33+
if [[ -z $(git status --porcelain generated) ]]; then
34+
echo "changed=false" >> "$GITHUB_OUTPUT"
35+
else
36+
echo "changed=true" >> "$GITHUB_OUTPUT"
37+
fi
38+
39+
- name: Set Git config
40+
run: |
41+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
42+
git config --global user.name "github-actions[bot]"
43+
44+
- name: Generate PR if needed
45+
if: steps.check-openapi.outputs.changed == 'true'
46+
run: |
47+
git checkout -b update-generated-$GITHUB_SHA
48+
49+
git add generated
50+
git commit -m "Update generated clients to version generated from ref $GITHUB_SHA"
51+
52+
echo "Pushing branch so we can create a PR..."
53+
git push --set-upstream origin update-generated-$GITHUB_SHA
54+
55+
gh pr create --title "Update Generated" \
56+
--body "This PR updates the generated clients to the version generated from ref $GITHUB_SHA" \
57+
--repo "$GITHUB_REPOSITORY" \
58+
--base main \
59+
--head update-generated-$GITHUB_SHA
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Publish Node Package
3+
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
publish-gpr:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup npm
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 20
21+
cache: npm
22+
registry-url: 'https://npm.pkg.github.com/'
23+
24+
- name: Compute version number
25+
id: version-string
26+
run: |
27+
DATE="$(date +%Y%m%d)"
28+
COMMIT="$(git rev-parse --short HEAD)"
29+
echo "tag=0.$DATE.$GITHUB_RUN_NUMBER+ref.$COMMIT" >> "$GITHUB_OUTPUT"
30+
31+
- name: Set version number
32+
run: |
33+
jq ".version = \"$VERSION\"" package.json > package.json.tmp
34+
mv package.json.tmp package.json
35+
env:
36+
VERSION: ${{ steps.version-string.outputs.tag }}
37+
38+
- run: npm run build
39+
40+
- run: npm publish
41+
env:
42+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Taken from https://github.com/github/gitignore/blob/main/Node.gitignore
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
lerna-debug.log*
10+
.pnpm-debug.log*
11+
12+
# Diagnostic reports (https://nodejs.org/api/report.html)
13+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
14+
15+
# Runtime data
16+
pids
17+
*.pid
18+
*.seed
19+
*.pid.lock
20+
21+
# Directory for instrumented libs generated by jscoverage/JSCover
22+
lib-cov
23+
24+
# Coverage directory used by tools like istanbul
25+
coverage
26+
*.lcov
27+
28+
# nyc test coverage
29+
.nyc_output
30+
31+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
32+
.grunt
33+
34+
# Bower dependency directory (https://bower.io/)
35+
bower_components
36+
37+
# node-waf configuration
38+
.lock-wscript
39+
40+
# Compiled binary addons (https://nodejs.org/api/addons.html)
41+
build/Release
42+
43+
# Dependency directories
44+
node_modules/
45+
jspm_packages/
46+
47+
# Snowpack dependency directory (https://snowpack.dev/)
48+
web_modules/
49+
50+
# TypeScript cache
51+
*.tsbuildinfo
52+
53+
# Optional npm cache directory
54+
.npm
55+
56+
# Optional eslint cache
57+
.eslintcache
58+
59+
# Optional stylelint cache
60+
.stylelintcache
61+
62+
# Microbundle cache
63+
.rpt2_cache/
64+
.rts2_cache_cjs/
65+
.rts2_cache_es/
66+
.rts2_cache_umd/
67+
68+
# Optional REPL history
69+
.node_repl_history
70+
71+
# Output of 'npm pack'
72+
*.tgz
73+
74+
# Yarn Integrity file
75+
.yarn-integrity
76+
77+
# dotenv environment variable files
78+
.env
79+
.env.development.local
80+
.env.test.local
81+
.env.production.local
82+
.env.local
83+
84+
# parcel-bundler cache (https://parceljs.org/)
85+
.cache
86+
.parcel-cache
87+
88+
# Next.js build output
89+
.next
90+
out
91+
92+
# Nuxt.js build / generate output
93+
.nuxt
94+
dist
95+
96+
# Gatsby files
97+
.cache/
98+
# Comment in the public line in if your project uses Gatsby and not Next.js
99+
# https://nextjs.org/blog/next-9-1#public-directory-support
100+
# public
101+
102+
# vuepress build output
103+
.vuepress/dist
104+
105+
# vuepress v2.x temp and cache directory
106+
.temp
107+
.cache
108+
109+
# Docusaurus cache and generated files
110+
.docusaurus
111+
112+
# Serverless directories
113+
.serverless/
114+
115+
# FuseBox cache
116+
.fusebox/
117+
118+
# DynamoDB Local files
119+
.dynamodb/
120+
121+
# TernJS port file
122+
.tern-port
123+
124+
# Stores VSCode versions used for testing VSCode extensions
125+
.vscode-test
126+
127+
# yarn v2
128+
.yarn/cache
129+
.yarn/unplugged
130+
.yarn/build-state.yml
131+
.yarn/install-state.gz
132+
.pnp.*

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Stacklok Mediator typescript clients
2+
3+
These are auto-generated clients for the [Stacklok](https://stacklok.com) APIs.
4+
They are generated from the [OpenAPI](https://swagger.io/specification/) specification.
5+
6+
The `src/` directory contains the OpenAPI specs from which the clients where generated.
7+
8+
The `generated/` directory contains the generated clients.

generated/core/ApiError.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
import type { ApiRequestOptions } from './ApiRequestOptions';
6+
import type { ApiResult } from './ApiResult';
7+
8+
export class ApiError extends Error {
9+
public readonly url: string;
10+
public readonly status: number;
11+
public readonly statusText: string;
12+
public readonly body: any;
13+
public readonly request: ApiRequestOptions;
14+
15+
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
16+
super(message);
17+
18+
this.name = 'ApiError';
19+
this.url = response.url;
20+
this.status = response.status;
21+
this.statusText = response.statusText;
22+
this.body = response.body;
23+
this.request = request;
24+
}
25+
}

generated/core/ApiRequestOptions.ts

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
export type ApiRequestOptions = {
6+
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
7+
readonly url: string;
8+
readonly path?: Record<string, any>;
9+
readonly cookies?: Record<string, any>;
10+
readonly headers?: Record<string, any>;
11+
readonly query?: Record<string, any>;
12+
readonly formData?: Record<string, any>;
13+
readonly body?: any;
14+
readonly mediaType?: string;
15+
readonly responseHeader?: string;
16+
readonly errors?: Record<number, string>;
17+
};

generated/core/ApiResult.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* generated using openapi-typescript-codegen -- do no edit */
2+
/* istanbul ignore file */
3+
/* tslint:disable */
4+
/* eslint-disable */
5+
export type ApiResult = {
6+
readonly url: string;
7+
readonly ok: boolean;
8+
readonly status: number;
9+
readonly statusText: string;
10+
readonly body: any;
11+
};

0 commit comments

Comments
 (0)