@pikku/openapi-parser 0.12.16 → 0.12.18
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/CHANGELOG.md +45 -0
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/codegen.js +6 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -3
- package/package.json +1 -1
- package/src/codegen.ts +6 -6
- package/src/index.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @pikku/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.12.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fd9d834: Stop publishing internals that only their own package or file used. The declarations stay; only the entrypoint re-export is removed, so nothing that imported a name from where it is declared is affected.
|
|
8
|
+
|
|
9
|
+
## 0.12.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a7b26c5: rename the inspected declarations to `define*`: `wireScope` → `defineScope`, `wireSecret` → `defineSecret`, `wireVariable` → `defineVariable`, `wireCredential` → `defineCredential`
|
|
14
|
+
|
|
15
|
+
`wire*` meant two unrelated things. A transport wiring attaches a function to
|
|
16
|
+
something that can invoke it — `wireHTTP`, `wireChannel`, `wireScheduler`,
|
|
17
|
+
`wireQueueWorker` and the rest — and the thing it wires runs. These four wire
|
|
18
|
+
nothing: they are no-ops that exist only so the call typechecks, they are
|
|
19
|
+
tree-shaken out of the build, and their whole job is to be found by the
|
|
20
|
+
inspector's AST pass and turned into a type union. One word for both left the
|
|
21
|
+
declaration reading like a registration with a runtime.
|
|
22
|
+
|
|
23
|
+
So the vocabulary splits: **`wire*` is a transport, `define*` is an inspected
|
|
24
|
+
declaration.**
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { defineScope } from '@pikku/core/scope'
|
|
28
|
+
import { defineSecret } from '@pikku/core/secret'
|
|
29
|
+
import { defineVariable } from '@pikku/core/variable'
|
|
30
|
+
import { defineCredential } from '@pikku/core/credential'
|
|
31
|
+
|
|
32
|
+
defineScope({ admin: { scopes: { invoices: { scopes: { create: {} } } } } })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Breaking:** no alias is kept. Rename the four call sites; the module subpaths
|
|
36
|
+
(`@pikku/core/scope`, `/secret`, `/variable`) are unchanged.
|
|
37
|
+
|
|
38
|
+
The inspector matches these by identifier text, so a stale `wire*` call is not a
|
|
39
|
+
type error — it is silently not extracted, and the generated union comes back
|
|
40
|
+
empty. That fails as "this scope isn't declared" on code that was fine a moment
|
|
41
|
+
ago, nowhere near the declaration. Grep for the old names rather than trusting a
|
|
42
|
+
clean build.
|
|
43
|
+
|
|
44
|
+
An addon published with `.pikku` output generated before this release re-exports
|
|
45
|
+
`wireSecret` from `@pikku/core/secret` and will not typecheck against this core
|
|
46
|
+
until it is rebuilt and republished.
|
|
47
|
+
|
|
3
48
|
## 0.12.16
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 - present Yasser Fadl and Pikku contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @pikku/openapi-parser
|
|
2
|
+
|
|
3
|
+
Parses OpenAPI specs into a normalised shape and generates Pikku addon code
|
|
4
|
+
from them — operations, parameters, error responses and security schemes.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install -D @pikku/openapi-parser
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import { parseOpenAPISpec, computeContractHash } from '@pikku/openapi-parser'
|
|
16
|
+
|
|
17
|
+
const spec = await parseOpenAPISpec(specPath)
|
|
18
|
+
const hash = computeContractHash(spec)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The contract hash lets generated addons detect when an upstream spec changed.
|
|
22
|
+
|
|
23
|
+
## Docs
|
|
24
|
+
|
|
25
|
+
https://pikku.dev/docs
|
package/dist/codegen.js
CHANGED
|
@@ -1184,8 +1184,8 @@ function generateCredentialFile(spec, vars) {
|
|
|
1184
1184
|
: ['read', 'write'];
|
|
1185
1185
|
const lines = [];
|
|
1186
1186
|
lines.push("import { z } from 'zod'");
|
|
1187
|
-
lines.push("import {
|
|
1188
|
-
lines.push("import {
|
|
1187
|
+
lines.push("import { defineCredential } from '@pikku/core/credential'");
|
|
1188
|
+
lines.push("import { defineSecret } from '@pikku/core/secret'");
|
|
1189
1189
|
lines.push('');
|
|
1190
1190
|
lines.push(`export const ${camelName}TokenSchema = z.object({`);
|
|
1191
1191
|
lines.push(' accessToken: z.string(),');
|
|
@@ -1204,7 +1204,7 @@ function generateCredentialFile(spec, vars) {
|
|
|
1204
1204
|
}
|
|
1205
1205
|
// oauth2 must stay an inline object literal: the inspector reads it via AST
|
|
1206
1206
|
// (add-credential.ts) and silently drops a config behind an identifier.
|
|
1207
|
-
lines.push('
|
|
1207
|
+
lines.push('defineCredential({');
|
|
1208
1208
|
lines.push(` name: '${camelName}',`);
|
|
1209
1209
|
lines.push(` displayName: '${displayName}',`);
|
|
1210
1210
|
lines.push(` description: '${description}',`);
|
|
@@ -1219,7 +1219,7 @@ function generateCredentialFile(spec, vars) {
|
|
|
1219
1219
|
lines.push(' },');
|
|
1220
1220
|
lines.push('})');
|
|
1221
1221
|
lines.push('');
|
|
1222
|
-
lines.push('
|
|
1222
|
+
lines.push('defineSecret({');
|
|
1223
1223
|
lines.push(` name: '${camelName}OAuthApp',`);
|
|
1224
1224
|
lines.push(` displayName: '${displayName} OAuth App',`);
|
|
1225
1225
|
lines.push(` description: 'OAuth2 app credentials for ${displayName}',`);
|
|
@@ -1236,7 +1236,7 @@ function generateVariableFile(spec, vars) {
|
|
|
1236
1236
|
const defaultUrl = serverUrls[0];
|
|
1237
1237
|
const lines = [];
|
|
1238
1238
|
lines.push("import { z } from 'zod'");
|
|
1239
|
-
lines.push("import {
|
|
1239
|
+
lines.push("import { defineVariable } from '@pikku/core/variable'");
|
|
1240
1240
|
lines.push('');
|
|
1241
1241
|
const schemaVarName = `${camelName}BaseUrlSchema`;
|
|
1242
1242
|
if (serverUrls.length > 0) {
|
|
@@ -1247,7 +1247,7 @@ function generateVariableFile(spec, vars) {
|
|
|
1247
1247
|
lines.push(`export const ${schemaVarName} = z.string().describe('Base URL for the ${displayName} API')`);
|
|
1248
1248
|
}
|
|
1249
1249
|
lines.push('');
|
|
1250
|
-
lines.push(`
|
|
1250
|
+
lines.push(`defineVariable({`);
|
|
1251
1251
|
lines.push(` name: '${screamingName}_BASE_URL',`);
|
|
1252
1252
|
lines.push(` displayName: '${displayName} Base URL',`);
|
|
1253
1253
|
lines.push(` description: 'The base URL for the ${displayName} API.',`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { parseOpenAPISpec, computeContractHash, type ParsedSpec,
|
|
1
|
+
export { parseOpenAPISpec, computeContractHash, type ParsedSpec, } from './parse-openapi.js';
|
|
2
2
|
export { generateAddonFromOpenAPI } from './codegen.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { type OpenAPISchema, type ZodCodegenContext, createContext, schemaToZod, schemaVarName, sanitizeTypeName,
|
|
3
|
+
export { loadAuthConfig, type AuthConfig, type DelegatedLoginConfig, } from './auth-config.js';
|
|
4
|
+
export { type NamedOperation, } from './naming.js';
|
|
5
|
+
export { type OpenAPISchema, type ZodCodegenContext, createContext, schemaToZod, schemaVarName, sanitizeTypeName, } from './openapi-to-zod-schema.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { parseOpenAPISpec, computeContractHash, } from './parse-openapi.js';
|
|
2
2
|
export { generateAddonFromOpenAPI } from './codegen.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { createContext, schemaToZod, schemaVarName, sanitizeTypeName, snakeToCamel, } from './openapi-to-zod-schema.js';
|
|
3
|
+
export { loadAuthConfig, } from './auth-config.js';
|
|
4
|
+
export { createContext, schemaToZod, schemaVarName, sanitizeTypeName, } from './openapi-to-zod-schema.js';
|
package/package.json
CHANGED
package/src/codegen.ts
CHANGED
|
@@ -1575,8 +1575,8 @@ function generateCredentialFile(spec: ParsedSpec, vars: AddonVars): string {
|
|
|
1575
1575
|
|
|
1576
1576
|
const lines: string[] = []
|
|
1577
1577
|
lines.push("import { z } from 'zod'")
|
|
1578
|
-
lines.push("import {
|
|
1579
|
-
lines.push("import {
|
|
1578
|
+
lines.push("import { defineCredential } from '@pikku/core/credential'")
|
|
1579
|
+
lines.push("import { defineSecret } from '@pikku/core/secret'")
|
|
1580
1580
|
lines.push('')
|
|
1581
1581
|
lines.push(`export const ${camelName}TokenSchema = z.object({`)
|
|
1582
1582
|
lines.push(' accessToken: z.string(),')
|
|
@@ -1601,7 +1601,7 @@ function generateCredentialFile(spec: ParsedSpec, vars: AddonVars): string {
|
|
|
1601
1601
|
|
|
1602
1602
|
// oauth2 must stay an inline object literal: the inspector reads it via AST
|
|
1603
1603
|
// (add-credential.ts) and silently drops a config behind an identifier.
|
|
1604
|
-
lines.push('
|
|
1604
|
+
lines.push('defineCredential({')
|
|
1605
1605
|
lines.push(` name: '${camelName}',`)
|
|
1606
1606
|
lines.push(` displayName: '${displayName}',`)
|
|
1607
1607
|
lines.push(` description: '${description}',`)
|
|
@@ -1620,7 +1620,7 @@ function generateCredentialFile(spec: ParsedSpec, vars: AddonVars): string {
|
|
|
1620
1620
|
lines.push(' },')
|
|
1621
1621
|
lines.push('})')
|
|
1622
1622
|
lines.push('')
|
|
1623
|
-
lines.push('
|
|
1623
|
+
lines.push('defineSecret({')
|
|
1624
1624
|
lines.push(` name: '${camelName}OAuthApp',`)
|
|
1625
1625
|
lines.push(` displayName: '${displayName} OAuth App',`)
|
|
1626
1626
|
lines.push(` description: 'OAuth2 app credentials for ${displayName}',`)
|
|
@@ -1640,7 +1640,7 @@ function generateVariableFile(spec: ParsedSpec, vars: AddonVars): string {
|
|
|
1640
1640
|
|
|
1641
1641
|
const lines: string[] = []
|
|
1642
1642
|
lines.push("import { z } from 'zod'")
|
|
1643
|
-
lines.push("import {
|
|
1643
|
+
lines.push("import { defineVariable } from '@pikku/core/variable'")
|
|
1644
1644
|
lines.push('')
|
|
1645
1645
|
|
|
1646
1646
|
const schemaVarName = `${camelName}BaseUrlSchema`
|
|
@@ -1657,7 +1657,7 @@ function generateVariableFile(spec: ParsedSpec, vars: AddonVars): string {
|
|
|
1657
1657
|
}
|
|
1658
1658
|
|
|
1659
1659
|
lines.push('')
|
|
1660
|
-
lines.push(`
|
|
1660
|
+
lines.push(`defineVariable({`)
|
|
1661
1661
|
lines.push(` name: '${screamingName}_BASE_URL',`)
|
|
1662
1662
|
lines.push(` displayName: '${displayName} Base URL',`)
|
|
1663
1663
|
lines.push(` description: 'The base URL for the ${displayName} API.',`)
|
package/src/index.ts
CHANGED
|
@@ -2,26 +2,17 @@ export {
|
|
|
2
2
|
parseOpenAPISpec,
|
|
3
3
|
computeContractHash,
|
|
4
4
|
type ParsedSpec,
|
|
5
|
-
type ParsedOperation,
|
|
6
|
-
type ParsedParam,
|
|
7
|
-
type ErrorResponse,
|
|
8
|
-
type SecuritySchemeInfo,
|
|
9
5
|
} from './parse-openapi.js'
|
|
10
6
|
|
|
11
7
|
export { generateAddonFromOpenAPI } from './codegen.js'
|
|
12
8
|
|
|
13
9
|
export {
|
|
14
|
-
AuthConfigSchema,
|
|
15
|
-
DelegatedLoginSchema,
|
|
16
10
|
loadAuthConfig,
|
|
17
|
-
authHeaderValue,
|
|
18
11
|
type AuthConfig,
|
|
19
12
|
type DelegatedLoginConfig,
|
|
20
13
|
} from './auth-config.js'
|
|
21
14
|
|
|
22
15
|
export {
|
|
23
|
-
generateOperationNames,
|
|
24
|
-
detectCommonPrefix,
|
|
25
16
|
type NamedOperation,
|
|
26
17
|
} from './naming.js'
|
|
27
18
|
|
|
@@ -32,5 +23,4 @@ export {
|
|
|
32
23
|
schemaToZod,
|
|
33
24
|
schemaVarName,
|
|
34
25
|
sanitizeTypeName,
|
|
35
|
-
snakeToCamel,
|
|
36
26
|
} from './openapi-to-zod-schema.js'
|