@openapi-typescript-infra/service 4.1.1 → 4.3.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/.trunk/trunk.yaml +5 -5
- package/CHANGELOG.md +19 -0
- package/Makefile +20 -0
- package/build/bin/generate-config-schema.d.ts +2 -0
- package/build/bin/generate-config-schema.js +53 -0
- package/build/bin/generate-config-schema.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/bin/generate-config-schema.ts +55 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-typescript-infra/service",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "An opinionated framework for building configuration driven services - web, api, or ob. Uses OpenAPI, pino logging, express, confit, Typescript and vitest.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"url": "git+https://github.com/openapi-typescript-infra/service.git"
|
|
18
18
|
},
|
|
19
19
|
"bin": {
|
|
20
|
+
"generate-config-schema": "./build/bin/generate-config-schema.js",
|
|
20
21
|
"start-service": "./build/bin/start-service.js"
|
|
21
22
|
},
|
|
22
23
|
"config": {
|
|
@@ -80,8 +81,9 @@
|
|
|
80
81
|
"@opentelemetry/sdk-node": "^0.43.0",
|
|
81
82
|
"@opentelemetry/sdk-trace-base": "^1.17.1",
|
|
82
83
|
"@opentelemetry/semantic-conventions": "^1.17.1",
|
|
83
|
-
"@sesamecare-oss/confit": "^2.0.
|
|
84
|
+
"@sesamecare-oss/confit": "^2.0.1",
|
|
84
85
|
"@sesamecare-oss/opentelemetry-node-metrics": "^1.0.1",
|
|
86
|
+
"ajv": "^8.12.0",
|
|
85
87
|
"cookie-parser": "^1.4.6",
|
|
86
88
|
"dotenv": "^16.3.1",
|
|
87
89
|
"express": "next",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
"devDependencies": {
|
|
97
99
|
"@commitlint/cli": "^17.8.0",
|
|
98
100
|
"@commitlint/config-conventional": "^17.8.0",
|
|
99
|
-
"@openapi-typescript-infra/coconfig": "^4.2.
|
|
101
|
+
"@openapi-typescript-infra/coconfig": "^4.2.2",
|
|
100
102
|
"@semantic-release/changelog": "^6.0.3",
|
|
101
103
|
"@semantic-release/commit-analyzer": "^11.0.0",
|
|
102
104
|
"@semantic-release/exec": "^6.0.3",
|
|
@@ -108,7 +110,7 @@
|
|
|
108
110
|
"@types/lodash": "^4.14.200",
|
|
109
111
|
"@types/minimist": "^1.2.4",
|
|
110
112
|
"@types/node": "^20.8.7",
|
|
111
|
-
"@types/supertest": "^2.0.
|
|
113
|
+
"@types/supertest": "^2.0.15",
|
|
112
114
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
113
115
|
"@typescript-eslint/parser": "^6.8.0",
|
|
114
116
|
"coconfig": "^1.0.0",
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
4
|
+
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
|
+
import standaloneCode from 'ajv/dist/standalone';
|
|
7
|
+
import minimist from 'minimist';
|
|
8
|
+
|
|
9
|
+
// Generate an AJV validator from a Typescript type
|
|
10
|
+
// This is mostly included since we already have AJV,
|
|
11
|
+
// and we want you to use it to validate configurations.
|
|
12
|
+
const argv = minimist(process.argv.slice(2));
|
|
13
|
+
|
|
14
|
+
async function run() {
|
|
15
|
+
// First we need to run typescript-json-schema to
|
|
16
|
+
// generate the JSON schema. We use npx to avoid the
|
|
17
|
+
// runtime dependency.
|
|
18
|
+
const tsJsonSchema = spawnSync(
|
|
19
|
+
'npx',
|
|
20
|
+
[
|
|
21
|
+
'-y',
|
|
22
|
+
'typescript-json-schema',
|
|
23
|
+
argv.tsconfig || 'tsconfig.build.json',
|
|
24
|
+
argv.type,
|
|
25
|
+
'--required',
|
|
26
|
+
'--noExtraProps',
|
|
27
|
+
'--strictNullChecks',
|
|
28
|
+
'--include',
|
|
29
|
+
argv.source || 'src/types/config.ts',
|
|
30
|
+
],
|
|
31
|
+
{
|
|
32
|
+
stdio: 'pipe',
|
|
33
|
+
encoding: 'utf-8',
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
if (tsJsonSchema.status !== 0) {
|
|
37
|
+
console.error(tsJsonSchema.stderr);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
const schema = JSON.parse(tsJsonSchema.stdout);
|
|
41
|
+
|
|
42
|
+
const ajv = new Ajv({ code: { source: true, esm: true } });
|
|
43
|
+
const validate = ajv.compile(schema);
|
|
44
|
+
const moduleCode = standaloneCode(ajv, validate);
|
|
45
|
+
if (argv.output) {
|
|
46
|
+
fs.writeFileSync(argv.output, `// @ts-nocheck\n${moduleCode}\n`);
|
|
47
|
+
} else {
|
|
48
|
+
console.log(moduleCode);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
run().catch((err) => {
|
|
53
|
+
console.error(err);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|