@contractkit/plugin-bruno 0.9.1 → 1.0.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.
@@ -1,35 +1,19 @@
1
-
2
- 
3
- > @contractkit/plugin-bruno@0.9.0 build:ci /Users/robert/projects/contractkit/packages/plugin-bruno
4
- > eslint --max-warnings=0 && pnpm run build
5
-
6
- =============
7
-
8
-
9
- WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree.
10
-
11
-
12
- * @typescript-eslint/typescript-estree version: 8.57.2
13
- * Supported TypeScript versions: >=4.8.4 <6.0.0
14
- * Your TypeScript version: 6.0.2
15
-
16
-
17
- Please only submit bug reports when using the officially supported version.
18
-
19
-
20
- =============
21
-
22
- > @contractkit/plugin-bruno@0.9.0 build /Users/robert/projects/contractkit/packages/plugin-bruno
23
- > tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
24
-
25
- CLI Building entry: src/index.ts
26
- CLI Using tsconfig: tsconfig.json
27
- CLI tsup v8.5.1
28
- CLI Target: esnext
29
- ESM Build start
30
- ESM dist/index.js 19.94 KB
31
- ESM dist/index.js.map 46.49 KB
32
- ESM ⚡️ Build success in 41ms
33
- DTS Build start
34
- DTS ⚡️ Build success in 622ms
35
- DTS dist/index.d.ts 1.37 KB
1
+
2
+ > @contractkit/plugin-bruno@1.0.0 build:ci /home/runner/work/ContractKit/ContractKit/packages/plugin-bruno
3
+ > eslint --max-warnings=0 && pnpm run build
4
+
5
+
6
+ > @contractkit/plugin-bruno@1.0.0 build /home/runner/work/ContractKit/ContractKit/packages/plugin-bruno
7
+ > tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration
8
+
9
+ CLI Building entry: src/index.ts
10
+ CLI Using tsconfig: tsconfig.json
11
+ CLI tsup v8.5.1
12
+ CLI Target: esnext
13
+ ESM Build start
14
+ ESM dist/index.js 20.98 KB
15
+ ESM dist/index.js.map 50.34 KB
16
+ ESM ⚡️ Build success in 158ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 3705ms
19
+ DTS dist/index.d.ts 2.09 KB
@@ -1,128 +1,25 @@
1
-
2
- 
3
- > @contractkit/plugin-bruno@0.9.0 test:ci /Users/robert/projects/contractkit/packages/plugin-bruno
4
- > vitest run --coverage
5
-
6
- [?25l
7
-  RUN  v4.1.5 /Users/robert/projects/contractkit/packages/plugin-bruno
8
- Coverage enabled with v8
9
-
10
- [?2026h
11
-  tests/codegen-bruno.test.ts [queued]
12
-
13
-  Test Files 0 passed (1)
14
-  Tests 0 passed (0)
15
-  Start at 08:51:09
16
-  Duration 407ms
17
- [?2026l[?2026h
18
-  tests/codegen-bruno.test.ts [queued]
19
-
20
-  Test Files 0 passed (1)
21
-  Tests 0 passed (0)
22
-  Start at 08:51:09
23
-  Duration 927ms
24
- [?2026l ✓ tests/codegen-bruno.test.ts (85 tests) 11ms
25
- ✓ generateOpenCollection (80)
26
- ✓ generates opencollection.yml with correct spec version and collection name 2ms
27
- ✓ generates Local environment file with baseUrl variable 0ms
28
- ✓ emits requests for internal operations by default 0ms
29
- ✓ skips internal operations when includeInternal is false 0ms
30
- ✓ creates one folder per op root file 0ms
31
- ✓ folder.yml has info block with name, type: folder, and seq 0ms
32
- ✓ generates one .yml file per route+method combination 0ms
33
- ✓ request info block has name, type: http, and seq 0ms
34
- ✓ seq increments across operations within a folder 0ms
35
- ✓ uses slugified name as filename when op.name is set 0ms
36
- ✓ falls back to method-path filename when op.name is not set 0ms
37
- ✓ uses area meta as the top-level folder name 0ms
38
- ✓ falls back to filename when no area meta 0ms
39
- ✓ places request files in subfolder when subarea meta is set 0ms
40
- ✓ generates folder.yml for subarea with correct name 0ms
41
- ✓ still generates top-level folder.yml when subarea is set 0ms
42
- ✓ slugifies subarea for the folder path 0ms
43
- ✓ places request files directly in folder when no subarea 0ms
44
- ✓ uses {{baseUrl}} prefix and Bruno :param syntax for path params 0ms
45
- ✓ generates path params as flat array entries with type: path 0ms
46
- ✓ uses uuid example value for uuid path params 0ms
47
- ✓ uses typed example values for scalar path params 0ms
48
- ✓ uses ISO 8601 duration example value for duration path params 0ms
49
- ✓ uses first enum value as example for enum path params 0ms
50
- ✓ falls back to empty string for untyped path params 0ms
51
- ✓ does not generate params block when path has no params and no query 0ms
52
- ✓ generates query params as flat array entries with type: query 0ms
53
- ✓ uses typed example values for query params 0ms
54
- ✓ falls back to single placeholder entry for ref query params with no registry 0ms
55
- ✓ expands ref query params into individual fields when model registry provided 0ms
56
- ✓ mixes path and query params in the same flat array 0ms
57
- ✓ generates headers block from op.headers inline params 0ms
58
- ✓ falls back to single placeholder entry for ref header source with no registry 0ms
59
- ✓ expands ref header source into individual fields when model registry provided 0ms
60
- ✓ does not generate headers block when op has no headers 0ms
61
- ✓ generates body with type: json and data block literal for JSON requests 0ms
62
- ✓ expands inline object body type into a JSON skeleton 0ms
63
- ✓ uses ISO 8601 duration example value in body skeleton 0ms
64
- ✓ excludes readonly fields from inline object body skeleton 0ms
65
- ✓ uses empty object for ref body types when no contractRoots provided 0ms
66
- ✓ expands ref body type into a JSON skeleton when contractRoots provided 0ms
67
- ✓ excludes readonly fields from expanded ref body 0ms
68
- ✓ sets optional fields to null in expanded ref body 0ms
69
- ✓ expands inherited fields from base model in ref body 0ms
70
- ✓ uses field default value in body for non-optional fields 0ms
71
- ✓ uses field default value in body for optional fields 0ms
72
- ✓ uses field defaults from expanded ref model body 1ms
73
- ✓ uses first enum value in body 0ms
74
- ✓ uses example values for nested array fields in body 0ms
75
- ✓ leaves ref fields as empty objects in body 0ms
76
- ✓ generates body with type: multipart-form for multipart requests 0ms
77
- ✓ does not generate body block when no request body 0ms
78
- ✓ handles empty roots array 0ms
79
- ✓ derives folder name from file path with directory prefix 0ms
80
- ✓ does not generate any .bru files 0ms
81
- ✓ adds bearer auth block to opencollection.yml when security config provided 0ms
82
- ✓ adds apikey auth block to opencollection.yml 0ms
83
- ✓ adds basic auth block to opencollection.yml 0ms
84
- ✓ adds auth env vars to local.yml for bearer 0ms
85
- ✓ does not add request or auth to opencollection.yml when no security config 0ms
86
- ✓ adds auth: none inside http block when operation security is none 0ms
87
- ✓ adds auth: inherit inside http block for normal operations when default scheme is set 0ms
88
- ✓ does not add auth when no default scheme is set 0ms
89
- ✓ emits a status-code assertion using the first declared 2xx response 0ms
90
- ✓ falls back to the first response when no 2xx is declared 0ms
91
- ✓ does not emit a runtime block when the operation declares no responses 0ms
92
- ✓ emits assertions for required response headers and lists them in the docs 0ms
93
- ✓ emits a docs block from the operation description 0ms
94
- ✓ combines route and operation descriptions into the docs block 0ms
95
- ✓ does not emit a docs block when no description is set 0ms
96
- ✓ marks optional query params with disabled: true 0ms
97
- ✓ marks optional headers with disabled: true 0ms
98
- ✓ does not mark path params as disabled even though they have no optional flag 0ms
99
- ✓ marks optional fields from a ref-expanded query model as disabled 0ms
100
- ✓ emits a manifest listing every generated file 0ms
101
- ✓ parseManifest returns [] for malformed input 0ms
102
- ✓ emits Bruno faker templates for compatible scalar params when randomExamples is true 0ms
103
- ✓ keeps deterministic placeholders when randomExamples is false 0ms
104
- ✓ uses faker templates inside JSON body skeletons for string-valued scalars 0ms
105
- ✓ does not override field defaults when randomExamples is true 0ms
106
- ✓ sanitizePath (5)
107
- ✓ converts simple path to filename-safe string 0ms
108
- ✓ replaces path params with their names 0ms
109
- ✓ handles multiple segments and params 0ms
110
- ✓ returns root for bare slash 0ms
111
- ✓ collapses consecutive dashes 0ms
112
-
113
-  Test Files  1 passed (1)
114
-  Tests  85 passed (85)
115
-  Start at  08:51:09
116
-  Duration  1.08s (transform 161ms, setup 0ms, import 586ms, tests 11ms, environment 0ms)
117
-
118
-  % Coverage report from v8
119
- -------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------
120
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
121
- -------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------
122
- All files  |  83.77 |  74.26 |  84.05 |  85.42 |  
123
-  src  |  86.1 |  75.1 |  90.9 |  87.54 |  
124
-  codegen-bruno.ts |  86.1 |  75.1 |  90.9 |  87.54 | 239-240,324,332,385-388,395-402,422,428,432-434,450,460,484,494-496,502-504,509,513-521,530,534
125
-  tests  |  68.18 |  67.74 |  72 |  71.05 |  
126
-  helpers.ts  |  68.18 |  67.74 |  72 |  71.05 | 43-47,55-59,71,113,131-135,145 
127
- -------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------
128
- [?25h
1
+
2
+ > @contractkit/plugin-bruno@1.0.0 test:ci /home/runner/work/ContractKit/ContractKit/packages/plugin-bruno
3
+ > vitest run --coverage
4
+
5
+
6
+  RUN  v4.1.5 /home/runner/work/ContractKit/ContractKit/packages/plugin-bruno
7
+ Coverage enabled with v8
8
+
9
+ ✓ tests/codegen-bruno.test.ts (96 tests) 489ms
10
+
11
+  Test Files  1 passed (1)
12
+  Tests  96 passed (96)
13
+  Start at  18:49:07
14
+  Duration  4.73s (transform 1.31s, setup 0ms, import 3.04s, tests 489ms, environment 0ms)
15
+
16
+  % Coverage report from v8
17
+ -------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------
18
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
19
+ -------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------
20
+ All files | 85.26 | 76.65 | 85.91 | 87.05 |
21
+ src | 86.73 | 76.56 | 91.3 | 88.19 |
22
+ codegen-bruno.ts | 86.73 | 76.56 | 91.3 | 88.19 | 285-286,370,378,431-434,441-448,468,474,478-480,496,506,530,540-542,548-550,555,559-567,576,580
23
+ tests | 75 | 77.41 | 76 | 78.94 |
24
+ helpers.ts | 75 | 77.41 | 76 | 78.94 | 43-47,55-59,71,113,133,145
25
+ -------------------|---------|----------|---------|---------|-------------------------------------------------------------------------------------------------
package/CHANGELOG.md CHANGED
@@ -1,5 +1,41 @@
1
1
  # @contractkit/contractkit-plugin-bruno
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 7555412: Drop the `overrideDir` config option from the Bruno plugin.
8
+
9
+ Per-operation overrides via `plugins: { bruno: "..." }` combined with the new `{{var}}` substitution in `.ck` files cover the same use cases more directly. Define a shared base path once in `options { keys: { bruno: "../bruno-overrides" } }` (or in the plugin's `keys` config in `contractkit.config.json` for a workspace-wide default) and reference per-operation override files with `plugins: { bruno: "{{bruno}}/path/to/file.yml" }`.
10
+
11
+ Migration: replace the `overrideDir` entry in your plugin config with a per-operation `plugins.bruno` declaration on each operation that needs an override.
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [7555412]
16
+ - @contractkit/core@0.13.0
17
+
18
+ ## 0.10.0
19
+
20
+ ### Minor Changes
21
+
22
+ - 876696f: Omit optional fields from generated request body skeletons instead of emitting them as `null`.
23
+
24
+ Previously, an optional field with no default produced `"nickname": null` in the example JSON body. The field is now absent so the example body sends only what the contract actually requires, matching how most APIs treat "omit" vs. "explicit null".
25
+
26
+ - f2d6a74: Add YAML override support to the Bruno plugin via per-operation plugin files and a new `overrideDir` config option.
27
+
28
+ Per-operation overrides: declare `plugins: { bruno: "override.yml" }` on an operation in a `.ck` file and the file's YAML content is deep-merged into the generated request file at codegen time. Objects recurse; arrays replace entirely.
29
+
30
+ Directory overrides: set `overrideDir` in the plugin config to a directory that mirrors the generated output structure. Any file found there is deep-merged into the matching generated file, enabling overrides for collection-level files (`opencollection.yml`, `environments/local.yml`) as well as individual request files.
31
+
32
+ The `mergePluginFile` function is now exported from `@contractkit/plugin-bruno` for use in custom tooling.
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [876696f]
37
+ - @contractkit/core@0.12.0
38
+
3
39
  ## 0.9.1
4
40
 
5
41
  ### Patch Changes
package/README.md CHANGED
@@ -38,6 +38,7 @@ pnpm add @contractkit/contractkit-plugin-bruno
38
38
  | `output` | `string` | `"bruno-collection"` | Output directory name |
39
39
  | `collectionName` | `string` | basename of `rootDir` | Collection name shown in Bruno |
40
40
  | `randomExamples` | `boolean` | `true` | Use Bruno faker templates (`{{$randomUUID}}`, `{{$randomEmail}}`, etc.) for compatible scalar fields so each send produces fresh data. Set to `false` for stable, deterministic placeholders. |
41
+ | `includeInternal` | `boolean` | `true` | Include operations marked `internal`. Set to `false` to omit them from the collection. |
41
42
  | `auth.defaultScheme` | `string` | — | Key from `auth.schemes` to apply by default |
42
43
  | `auth.schemes` | `object` | — | Map of scheme name → security scheme definition |
43
44
 
@@ -62,6 +63,46 @@ bruno-collection/
62
63
 
63
64
  The output directory is fully replaced on each run — stale request files from removed operations are automatically cleaned up.
64
65
 
66
+ ## Per-operation overrides
67
+
68
+ Add a `plugins` block to any operation in a `.ck` file to deep-merge a YAML file into the generated request:
69
+
70
+ ```
71
+ post: {
72
+ plugins: {
73
+ bruno: "overrides/auth-token.yml"
74
+ }
75
+ response: { 200: AuthResponse }
76
+ }
77
+ ```
78
+
79
+ The file path is relative to the `.ck` source file. Its content is deep-merged into the generated request YAML — objects recurse, arrays replace entirely:
80
+
81
+ ```yaml
82
+ # overrides/auth-token.yml
83
+ runtime:
84
+ script:
85
+ req: |
86
+ bru.setVar("token", bru.getEnvVar("adminToken"));
87
+ ```
88
+
89
+ Authoring tip: combine per-operation `plugins.bruno` paths with `{{var}}` substitution to factor out a shared override directory:
90
+
91
+ ```
92
+ options {
93
+ keys: { bruno: "../../bruno-overrides" }
94
+ }
95
+
96
+ operation /payments/{id}: {
97
+ get: {
98
+ plugins: { bruno: "{{bruno}}/payments/get-payment.yml" }
99
+ response: { 200: { application/json: Payment } }
100
+ }
101
+ }
102
+ ```
103
+
104
+ The `{{bruno}}` reference can also be supplied workspace-wide via the plugin's `keys` config in `contractkit.config.json`.
105
+
65
106
  ## Programmatic use
66
107
 
67
108
  ```typescript