@pikku/openapi-parser 0.12.16 → 0.12.17

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 CHANGED
@@ -1,5 +1,44 @@
1
1
  # @pikku/openapi-parser
2
2
 
3
+ ## 0.12.17
4
+
5
+ ### Patch Changes
6
+
7
+ - a7b26c5: rename the inspected declarations to `define*`: `wireScope` → `defineScope`, `wireSecret` → `defineSecret`, `wireVariable` → `defineVariable`, `wireCredential` → `defineCredential`
8
+
9
+ `wire*` meant two unrelated things. A transport wiring attaches a function to
10
+ something that can invoke it — `wireHTTP`, `wireChannel`, `wireScheduler`,
11
+ `wireQueueWorker` and the rest — and the thing it wires runs. These four wire
12
+ nothing: they are no-ops that exist only so the call typechecks, they are
13
+ tree-shaken out of the build, and their whole job is to be found by the
14
+ inspector's AST pass and turned into a type union. One word for both left the
15
+ declaration reading like a registration with a runtime.
16
+
17
+ So the vocabulary splits: **`wire*` is a transport, `define*` is an inspected
18
+ declaration.**
19
+
20
+ ```ts
21
+ import { defineScope } from '@pikku/core/scope'
22
+ import { defineSecret } from '@pikku/core/secret'
23
+ import { defineVariable } from '@pikku/core/variable'
24
+ import { defineCredential } from '@pikku/core/credential'
25
+
26
+ defineScope({ admin: { scopes: { invoices: { scopes: { create: {} } } } } })
27
+ ```
28
+
29
+ **Breaking:** no alias is kept. Rename the four call sites; the module subpaths
30
+ (`@pikku/core/scope`, `/secret`, `/variable`) are unchanged.
31
+
32
+ The inspector matches these by identifier text, so a stale `wire*` call is not a
33
+ type error — it is silently not extracted, and the generated union comes back
34
+ empty. That fails as "this scope isn't declared" on code that was fine a moment
35
+ ago, nowhere near the declaration. Grep for the old names rather than trusting a
36
+ clean build.
37
+
38
+ An addon published with `.pikku` output generated before this release re-exports
39
+ `wireSecret` from `@pikku/core/secret` and will not typecheck against this core
40
+ until it is rebuilt and republished.
41
+
3
42
  ## 0.12.16
4
43
 
5
44
  ### 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 { wireCredential } from '@pikku/core/credential'");
1188
- lines.push("import { wireSecret } from '@pikku/core/secret'");
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('wireCredential({');
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('wireSecret({');
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 { wireVariable } from '@pikku/core/variable'");
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(`wireVariable({`);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/openapi-parser",
3
- "version": "0.12.16",
3
+ "version": "0.12.17",
4
4
  "description": "OpenAPI spec parser and code generator for Pikku",
5
5
  "author": "yasser.fadl@gmail.com",
6
6
  "license": "MIT",
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 { wireCredential } from '@pikku/core/credential'")
1579
- lines.push("import { wireSecret } from '@pikku/core/secret'")
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('wireCredential({')
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('wireSecret({')
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 { wireVariable } from '@pikku/core/variable'")
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(`wireVariable({`)
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.',`)