@opensip-cli/config 0.1.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/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/capability-preferences.d.ts +39 -0
- package/dist/capability-preferences.d.ts.map +1 -0
- package/dist/capability-preferences.js +61 -0
- package/dist/capability-preferences.js.map +1 -0
- package/dist/composer.d.ts +58 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +111 -0
- package/dist/composer.js.map +1 -0
- package/dist/declaration.d.ts +59 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +15 -0
- package/dist/declaration.js.map +1 -0
- package/dist/document/cli-config.d.ts +102 -0
- package/dist/document/cli-config.d.ts.map +1 -0
- package/dist/document/cli-config.js +150 -0
- package/dist/document/cli-config.js.map +1 -0
- package/dist/document/dashboard.d.ts +21 -0
- package/dist/document/dashboard.d.ts.map +1 -0
- package/dist/document/dashboard.js +21 -0
- package/dist/document/dashboard.js.map +1 -0
- package/dist/document/global-config.d.ts +101 -0
- package/dist/document/global-config.d.ts.map +1 -0
- package/dist/document/global-config.js +163 -0
- package/dist/document/global-config.js.map +1 -0
- package/dist/document/host-declarations.d.ts +44 -0
- package/dist/document/host-declarations.d.ts.map +1 -0
- package/dist/document/host-declarations.js +48 -0
- package/dist/document/host-declarations.js.map +1 -0
- package/dist/document/targeting.d.ts +151 -0
- package/dist/document/targeting.d.ts.map +1 -0
- package/dist/document/targeting.js +71 -0
- package/dist/document/targeting.js.map +1 -0
- package/dist/document/template.d.ts +43 -0
- package/dist/document/template.d.ts.map +1 -0
- package/dist/document/template.js +63 -0
- package/dist/document/template.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +23 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +25 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/namespace-claims.d.ts +29 -0
- package/dist/namespace-claims.d.ts.map +1 -0
- package/dist/namespace-claims.js +62 -0
- package/dist/namespace-claims.js.map +1 -0
- package/dist/precedence.d.ts +47 -0
- package/dist/precedence.d.ts.map +1 -0
- package/dist/precedence.js +103 -0
- package/dist/precedence.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
OpenSIP CLI
|
|
2
|
+
Copyright 2026 opensip-ai
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this software except in compliance with the License. A copy of the License is
|
|
6
|
+
included in the LICENSE file and is also available at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- Generated by scripts/build-package-readmes.mjs — do not edit by hand.
|
|
2
|
+
Change the package's "description" (or the generator template) and run
|
|
3
|
+
`pnpm docs:readmes`. CI enforces sync via `pnpm docs:readmes:check`. -->
|
|
4
|
+
|
|
5
|
+
# @opensip-cli/config
|
|
6
|
+
|
|
7
|
+
> Configuration layer for OpenSIP CLI — the capability-configuration composer and schema registry
|
|
8
|
+
|
|
9
|
+
This is an **internal library** of the opensip-cli toolkit. It is published so the CLI and tools can depend on it; most users will not install it directly.
|
|
10
|
+
|
|
11
|
+
Part of [**opensip-cli**](https://github.com/opensip-ai/opensip-cli) — an open-source codebase-analysis toolkit: fitness checks (`fit`), static call-graph analysis (`graph`), and simulation (`sim`).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Most users install the CLI, which bundles the first-party tools:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
curl -fsSL https://opensip.ai/cli/install.sh | bash
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This package is published for the CLI and advanced plugin authors; most users should not install `@opensip-cli/config` directly.
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
- 📚 Project docs: https://opensip.ai/docs/opensip-cli/
|
|
26
|
+
- 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.0/docs/public/70-reference/02-package-catalog.md
|
|
27
|
+
- 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.0/packages/config
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
Apache-2.0 © opensip-ai
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview One descriptor-driven capability-preference resolver (§5.3,
|
|
3
|
+
* Phase 3).
|
|
4
|
+
*
|
|
5
|
+
* Three bespoke readers parse three key-sets today — fitness's
|
|
6
|
+
* `readCheckPackagePreferences` (`plugins.checkPackages`), simulation's
|
|
7
|
+
* `readScenarioPackagePreferences` (`plugins.scenarioPackages` /
|
|
8
|
+
* `autoDiscoverScenarios` / `packageScopes`), and graph's
|
|
9
|
+
* `readGraphAdapterPackagePreferences` (`plugins.graphAdapters` /
|
|
10
|
+
* `autoDiscoverGraphAdapters`). Each domain's discovery descriptor maps domain →
|
|
11
|
+
* config keys (`descriptor.configKeys`), so this one resolver replaces all three
|
|
12
|
+
* WITHOUT renaming a single key — the documented `opensip-cli.config.yml`
|
|
13
|
+
* surface is byte-identical, no migration.
|
|
14
|
+
*
|
|
15
|
+
* Reads from the raw `plugins` block of the project config (the same block the
|
|
16
|
+
* three readers read). Lives in `@opensip-cli/config` because reading config is
|
|
17
|
+
* a config-layer concern; the generic substrate (core) receives the RESOLVED
|
|
18
|
+
* preferences, staying config-pure.
|
|
19
|
+
*/
|
|
20
|
+
import type { CapabilityDiscoveryDescriptor } from '@opensip-cli/core';
|
|
21
|
+
/** Resolved discovery preferences for one domain — the shape the substrate consumes. */
|
|
22
|
+
export interface CapabilityPreferences {
|
|
23
|
+
/** Explicit package-name list (present → the substrate skips/augments auto per its mode). */
|
|
24
|
+
readonly packages?: readonly string[];
|
|
25
|
+
/** Auto-discovery enabled. Documented default: ON unless explicitly `false`. */
|
|
26
|
+
readonly autoDiscover: boolean;
|
|
27
|
+
/** name-pattern mode: the resolved+validated scopes to scan (default ∪ customer). */
|
|
28
|
+
readonly scopes?: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a domain's discovery preferences from the project config's `plugins`
|
|
32
|
+
* block through the keys its descriptor declares.
|
|
33
|
+
*
|
|
34
|
+
* @param descriptor The domain's discovery descriptor (supplies `configKeys` + mode).
|
|
35
|
+
* @param pluginsConfig The raw `plugins` block from `opensip-cli.config.yml`
|
|
36
|
+
* (or anything — a non-object is treated as "no preferences declared").
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveCapabilityPreferences(descriptor: CapabilityDiscoveryDescriptor, pluginsConfig: unknown): CapabilityPreferences;
|
|
39
|
+
//# sourceMappingURL=capability-preferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-preferences.d.ts","sourceRoot":"","sources":["../src/capability-preferences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,wFAAwF;AACxF,MAAM,WAAW,qBAAqB;IACpC,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,gFAAgF;IAChF,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAYD;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,6BAA6B,EACzC,aAAa,EAAE,OAAO,GACrB,qBAAqB,CAqBvB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview One descriptor-driven capability-preference resolver (§5.3,
|
|
3
|
+
* Phase 3).
|
|
4
|
+
*
|
|
5
|
+
* Three bespoke readers parse three key-sets today — fitness's
|
|
6
|
+
* `readCheckPackagePreferences` (`plugins.checkPackages`), simulation's
|
|
7
|
+
* `readScenarioPackagePreferences` (`plugins.scenarioPackages` /
|
|
8
|
+
* `autoDiscoverScenarios` / `packageScopes`), and graph's
|
|
9
|
+
* `readGraphAdapterPackagePreferences` (`plugins.graphAdapters` /
|
|
10
|
+
* `autoDiscoverGraphAdapters`). Each domain's discovery descriptor maps domain →
|
|
11
|
+
* config keys (`descriptor.configKeys`), so this one resolver replaces all three
|
|
12
|
+
* WITHOUT renaming a single key — the documented `opensip-cli.config.yml`
|
|
13
|
+
* surface is byte-identical, no migration.
|
|
14
|
+
*
|
|
15
|
+
* Reads from the raw `plugins` block of the project config (the same block the
|
|
16
|
+
* three readers read). Lives in `@opensip-cli/config` because reading config is
|
|
17
|
+
* a config-layer concern; the generic substrate (core) receives the RESOLVED
|
|
18
|
+
* preferences, staying config-pure.
|
|
19
|
+
*/
|
|
20
|
+
import { isRecord, resolveScopes } from '@opensip-cli/core';
|
|
21
|
+
/** Read a key as a `string[]`, filtering non-strings; `undefined` when the key is not an array. */
|
|
22
|
+
function stringArrayAt(record, key) {
|
|
23
|
+
if (key === undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
const value = record[key];
|
|
26
|
+
return Array.isArray(value) ? value.filter((v) => typeof v === 'string') : undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a domain's discovery preferences from the project config's `plugins`
|
|
30
|
+
* block through the keys its descriptor declares.
|
|
31
|
+
*
|
|
32
|
+
* @param descriptor The domain's discovery descriptor (supplies `configKeys` + mode).
|
|
33
|
+
* @param pluginsConfig The raw `plugins` block from `opensip-cli.config.yml`
|
|
34
|
+
* (or anything — a non-object is treated as "no preferences declared").
|
|
35
|
+
*/
|
|
36
|
+
export function resolveCapabilityPreferences(descriptor, pluginsConfig) {
|
|
37
|
+
const plugins = isRecord(pluginsConfig) ? pluginsConfig : {};
|
|
38
|
+
const keys = descriptor.configKeys;
|
|
39
|
+
// Explicit list: present (even empty) → the substrate honors it; absent → undefined.
|
|
40
|
+
const packages = stringArrayAt(plugins, keys.packages);
|
|
41
|
+
// Auto-discover: documented default ON; only an explicit boolean `false` disables it.
|
|
42
|
+
const autoRaw = keys.autoDiscover === undefined ? undefined : plugins[keys.autoDiscover];
|
|
43
|
+
const autoDiscover = typeof autoRaw === 'boolean' ? autoRaw : true;
|
|
44
|
+
// Scopes (name-pattern only): merge the descriptor's default scopes with any
|
|
45
|
+
// customer-configured additions, validated + deduped — exactly the
|
|
46
|
+
// `resolveScopes(DEFAULT_SCOPE, packageScopes)` the sim reader did.
|
|
47
|
+
const scopes = resolveNamePatternScopes(descriptor, stringArrayAt(plugins, keys.scopes) ?? []);
|
|
48
|
+
return {
|
|
49
|
+
...(packages === undefined ? {} : { packages }),
|
|
50
|
+
autoDiscover,
|
|
51
|
+
...(scopes === undefined ? {} : { scopes }),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Merge default + customer scopes for name-pattern mode; `undefined` for marker mode. */
|
|
55
|
+
function resolveNamePatternScopes(descriptor, customerScopes) {
|
|
56
|
+
if (descriptor.discovery.mode !== 'name-pattern')
|
|
57
|
+
return undefined;
|
|
58
|
+
const [primary = '@opensip-cli', ...restDefaults] = descriptor.discovery.defaultScopes;
|
|
59
|
+
return resolveScopes(primary, [...restDefaults, ...customerScopes], 'plugin.capability.invalid_scope');
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=capability-preferences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-preferences.js","sourceRoot":"","sources":["../src/capability-preferences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAc5D,mGAAmG;AACnG,SAAS,aAAa,CACpB,MAA+B,EAC/B,GAAuB;IAEvB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC1C,UAAyC,EACzC,aAAsB;IAEtB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC;IAEnC,qFAAqF;IACrF,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEvD,sFAAsF;IACtF,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAEnE,6EAA6E;IAC7E,mEAAmE;IACnE,oEAAoE;IACpE,MAAM,MAAM,GAAG,wBAAwB,CAAC,UAAU,EAAE,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAE/F,OAAO;QACL,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;QAC/C,YAAY;QACZ,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;KAC5C,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,SAAS,wBAAwB,CAC/B,UAAyC,EACzC,cAAiC;IAEjC,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,cAAc;QAAE,OAAO,SAAS,CAAC;IACnE,MAAM,CAAC,OAAO,GAAG,cAAc,EAAE,GAAG,YAAY,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC;IACvF,OAAO,aAAa,CAClB,OAAO,EACP,CAAC,GAAG,YAAY,EAAE,GAAG,cAAc,CAAC,EACpC,iCAAiC,CAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* composer — merges the registered namespaced schemas into one strict
|
|
3
|
+
* whole-document schema, and validates a raw config document against it.
|
|
4
|
+
*
|
|
5
|
+
* ADR-0023. Each tool contributes a {@link ToolConfigDeclaration}; the host
|
|
6
|
+
* composes them into a single Zod object keyed by namespace. Two rules govern
|
|
7
|
+
* unknown keys:
|
|
8
|
+
*
|
|
9
|
+
* 1. STRICT within a namespace — an unknown key inside a *known* namespace
|
|
10
|
+
* (e.g. `fitness.faliOnErrors`, a typo) is rejected. Achieved by making
|
|
11
|
+
* each namespace's object schema `.strict()`.
|
|
12
|
+
*
|
|
13
|
+
* 2. TOLERANT at the document level — a top-level key claimed by NO
|
|
14
|
+
* registered declaration is passed through, not rejected. This is a
|
|
15
|
+
* deliberate, permanent forward-compatibility contract, NOT migration
|
|
16
|
+
* debt: a config document may carry a namespace block for a tool that is
|
|
17
|
+
* not installed in this run (a third-party plugin missing from
|
|
18
|
+
* `plugins.<domain>`, or one config shared across projects with
|
|
19
|
+
* different tool sets). Rejecting it would make installing/uninstalling
|
|
20
|
+
* a tool break the shared document. Achieved by a
|
|
21
|
+
* `.catchall(z.unknown())` at the document level. The moment a namespace
|
|
22
|
+
* IS claimed — by a tool declaration or a host declaration
|
|
23
|
+
* (`document/host-declarations.ts` claims `cli`, `targets`,
|
|
24
|
+
* `globalExcludes`, `checkOverrides`, `dashboard`, `plugins`,
|
|
25
|
+
* `schemaVersion`) — it gains the strict treatment of rule 1.
|
|
26
|
+
* (Historical note: this catchall once also covered then-unclaimed host
|
|
27
|
+
* blocks; that migration use ended when host-declarations claimed them.)
|
|
28
|
+
*
|
|
29
|
+
* A validation failure in ANY namespace throws the same typed
|
|
30
|
+
* {@link ConfigurationError} (→ `CONFIGURATION_ERROR` exit), so a typo in
|
|
31
|
+
* `fitness` and a typo in `graph` fail identically.
|
|
32
|
+
*/
|
|
33
|
+
import { type ZodType } from 'zod';
|
|
34
|
+
import type { ToolConfigDeclaration } from './declaration.js';
|
|
35
|
+
/**
|
|
36
|
+
* Compose the registered tool declarations into one strict whole-document
|
|
37
|
+
* schema.
|
|
38
|
+
*
|
|
39
|
+
* The result is a Zod object whose keys are the registered namespaces (each a
|
|
40
|
+
* strict version of the tool's schema, made optional so a config omitting a
|
|
41
|
+
* tool's block is valid) plus a catchall that tolerates unclaimed top-level
|
|
42
|
+
* keys (the uninstalled-tool forward-compat contract — see the module
|
|
43
|
+
* docstring, rule 2).
|
|
44
|
+
*
|
|
45
|
+
* @param declarations The tool declarations to compose. Duplicate namespaces
|
|
46
|
+
* are rejected — two tools may not own the same top-level key.
|
|
47
|
+
*/
|
|
48
|
+
export declare function composeConfigSchema(declarations: readonly ToolConfigDeclaration[]): ZodType;
|
|
49
|
+
/**
|
|
50
|
+
* Validate a raw config document against the composed schema.
|
|
51
|
+
*
|
|
52
|
+
* @returns The parsed, type-narrowed document on success.
|
|
53
|
+
* @throws {ConfigurationError} On any validation failure, with the formatted
|
|
54
|
+
* Zod issues attached as `issues` for diagnosis. The same error shape is
|
|
55
|
+
* thrown regardless of which namespace failed.
|
|
56
|
+
*/
|
|
57
|
+
export declare function validateConfigDocument(schema: ZodType, raw: unknown): unknown;
|
|
58
|
+
//# sourceMappingURL=composer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.d.ts","sourceRoot":"","sources":["../src/composer.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAgB9D;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,SAAS,qBAAqB,EAAE,GAAG,OAAO,CAkB3F;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAwB7E"}
|
package/dist/composer.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// @fitness-ignore-file null-safety -- Zod schema builder chains (.strict()/.optional()/.catchall()) always return valid schema objects; there is no nullable access
|
|
2
|
+
/**
|
|
3
|
+
* composer — merges the registered namespaced schemas into one strict
|
|
4
|
+
* whole-document schema, and validates a raw config document against it.
|
|
5
|
+
*
|
|
6
|
+
* ADR-0023. Each tool contributes a {@link ToolConfigDeclaration}; the host
|
|
7
|
+
* composes them into a single Zod object keyed by namespace. Two rules govern
|
|
8
|
+
* unknown keys:
|
|
9
|
+
*
|
|
10
|
+
* 1. STRICT within a namespace — an unknown key inside a *known* namespace
|
|
11
|
+
* (e.g. `fitness.faliOnErrors`, a typo) is rejected. Achieved by making
|
|
12
|
+
* each namespace's object schema `.strict()`.
|
|
13
|
+
*
|
|
14
|
+
* 2. TOLERANT at the document level — a top-level key claimed by NO
|
|
15
|
+
* registered declaration is passed through, not rejected. This is a
|
|
16
|
+
* deliberate, permanent forward-compatibility contract, NOT migration
|
|
17
|
+
* debt: a config document may carry a namespace block for a tool that is
|
|
18
|
+
* not installed in this run (a third-party plugin missing from
|
|
19
|
+
* `plugins.<domain>`, or one config shared across projects with
|
|
20
|
+
* different tool sets). Rejecting it would make installing/uninstalling
|
|
21
|
+
* a tool break the shared document. Achieved by a
|
|
22
|
+
* `.catchall(z.unknown())` at the document level. The moment a namespace
|
|
23
|
+
* IS claimed — by a tool declaration or a host declaration
|
|
24
|
+
* (`document/host-declarations.ts` claims `cli`, `targets`,
|
|
25
|
+
* `globalExcludes`, `checkOverrides`, `dashboard`, `plugins`,
|
|
26
|
+
* `schemaVersion`) — it gains the strict treatment of rule 1.
|
|
27
|
+
* (Historical note: this catchall once also covered then-unclaimed host
|
|
28
|
+
* blocks; that migration use ended when host-declarations claimed them.)
|
|
29
|
+
*
|
|
30
|
+
* A validation failure in ANY namespace throws the same typed
|
|
31
|
+
* {@link ConfigurationError} (→ `CONFIGURATION_ERROR` exit), so a typo in
|
|
32
|
+
* `fitness` and a typo in `graph` fail identically.
|
|
33
|
+
*/
|
|
34
|
+
import { ConfigurationError } from '@opensip-cli/core';
|
|
35
|
+
import { z } from 'zod';
|
|
36
|
+
/**
|
|
37
|
+
* Make a namespace schema reject unknown keys.
|
|
38
|
+
*
|
|
39
|
+
* Object schemas gain `.strict()`. A non-object schema (a tool could contribute
|
|
40
|
+
* a `z.record(...)` or a union) has no "unknown key" concept, so it is returned
|
|
41
|
+
* unchanged — strictness is meaningful only for object shapes.
|
|
42
|
+
*/
|
|
43
|
+
function strictenNamespace(schema) {
|
|
44
|
+
if (schema instanceof z.ZodObject) {
|
|
45
|
+
return schema.strict();
|
|
46
|
+
}
|
|
47
|
+
return schema;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Compose the registered tool declarations into one strict whole-document
|
|
51
|
+
* schema.
|
|
52
|
+
*
|
|
53
|
+
* The result is a Zod object whose keys are the registered namespaces (each a
|
|
54
|
+
* strict version of the tool's schema, made optional so a config omitting a
|
|
55
|
+
* tool's block is valid) plus a catchall that tolerates unclaimed top-level
|
|
56
|
+
* keys (the uninstalled-tool forward-compat contract — see the module
|
|
57
|
+
* docstring, rule 2).
|
|
58
|
+
*
|
|
59
|
+
* @param declarations The tool declarations to compose. Duplicate namespaces
|
|
60
|
+
* are rejected — two tools may not own the same top-level key.
|
|
61
|
+
*/
|
|
62
|
+
export function composeConfigSchema(declarations) {
|
|
63
|
+
const shape = {};
|
|
64
|
+
for (const decl of declarations) {
|
|
65
|
+
if (Object.prototype.hasOwnProperty.call(shape, decl.namespace)) {
|
|
66
|
+
throw new ConfigurationError(`Duplicate config namespace '${decl.namespace}': two tools cannot own the same top-level key.`, { code: 'CONFIGURATION_ERROR', namespace: decl.namespace });
|
|
67
|
+
}
|
|
68
|
+
// Optional so a document that omits a tool's block stays valid; strict so a
|
|
69
|
+
// typo *inside* the block is rejected.
|
|
70
|
+
shape[decl.namespace] = strictenNamespace(decl.schema).optional();
|
|
71
|
+
}
|
|
72
|
+
// `.catchall(z.unknown())` tolerates unclaimed top-level keys — the
|
|
73
|
+
// namespace block of a tool not installed in this run must pass through
|
|
74
|
+
// (forward compat; module docstring rule 2). Strictness lives inside each
|
|
75
|
+
// claimed namespace, not at the document root.
|
|
76
|
+
return z.object(shape).catchall(z.unknown());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Validate a raw config document against the composed schema.
|
|
80
|
+
*
|
|
81
|
+
* @returns The parsed, type-narrowed document on success.
|
|
82
|
+
* @throws {ConfigurationError} On any validation failure, with the formatted
|
|
83
|
+
* Zod issues attached as `issues` for diagnosis. The same error shape is
|
|
84
|
+
* thrown regardless of which namespace failed.
|
|
85
|
+
*/
|
|
86
|
+
export function validateConfigDocument(schema, raw) {
|
|
87
|
+
const result = schema.safeParse(raw);
|
|
88
|
+
if (result.success) {
|
|
89
|
+
return result.data;
|
|
90
|
+
}
|
|
91
|
+
const issues = result.error.issues;
|
|
92
|
+
const summary = issues
|
|
93
|
+
.map((issue) => {
|
|
94
|
+
const path = issue.path.length > 0 ? issue.path.join('.') : '(document root)';
|
|
95
|
+
return `${path}: ${issue.message}`;
|
|
96
|
+
})
|
|
97
|
+
.join('; ');
|
|
98
|
+
const error = new ConfigurationError(`Invalid configuration: ${summary}`, {
|
|
99
|
+
code: 'CONFIGURATION_ERROR',
|
|
100
|
+
});
|
|
101
|
+
// Attach the formatted Zod issues for downstream diagnosis. The base
|
|
102
|
+
// ToolError constructor only copies `code` off the options bag, so the
|
|
103
|
+
// structured issues must be set on the instance directly.
|
|
104
|
+
Object.defineProperty(error, 'issues', {
|
|
105
|
+
value: issues,
|
|
106
|
+
enumerable: true,
|
|
107
|
+
writable: false,
|
|
108
|
+
});
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=composer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.js","sourceRoot":"","sources":["../src/composer.ts"],"names":[],"mappings":"AAAA,oKAAoK;AACpK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,CAAC,EAAgB,MAAM,KAAK,CAAC;AAItC;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,MAAe;IACxC,IAAI,MAAM,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;QAClC,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAA8C;IAChF,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;QAChC,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAChE,MAAM,IAAI,kBAAkB,CAC1B,+BAA+B,IAAI,CAAC,SAAS,iDAAiD,EAC9F,EAAE,IAAI,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAC3D,CAAC;QACJ,CAAC;QACD,4EAA4E;QAC5E,uCAAuC;QACvC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IACpE,CAAC;IACD,oEAAoE;IACpE,wEAAwE;IACxE,0EAA0E;IAC1E,+CAA+C;IAC/C,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAe,EAAE,GAAY;IAClE,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;IACnC,MAAM,OAAO,GAAG,MAAM;SACnB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;QAC9E,OAAO,GAAG,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACrC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC,0BAA0B,OAAO,EAAE,EAAE;QACxE,IAAI,EAAE,qBAAqB;KAC5B,CAAC,CAAC;IACH,qEAAqE;IACrE,uEAAuE;IACvE,0DAA0D;IAC1D,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE;QACrC,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;IACH,MAAM,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* declaration — the contract a tool offers to the configuration layer.
|
|
3
|
+
*
|
|
4
|
+
* Each tool contributes a {@link ToolConfigDeclaration}: a namespace (its
|
|
5
|
+
* top-level key in `opensip-cli.config.yml`), a Zod schema describing that
|
|
6
|
+
* namespace's block, optional defaults, and optional environment-variable
|
|
7
|
+
* bindings. The host composes the registered declarations into one strict
|
|
8
|
+
* whole-document schema (see {@link ./composer}) and resolves precedence across
|
|
9
|
+
* flags / env / file / defaults (see {@link ./precedence}).
|
|
10
|
+
*
|
|
11
|
+
* Nothing here imports a tool; the declaration is a pure data contract the
|
|
12
|
+
* tools hand to the composition root (wired in Phase 4).
|
|
13
|
+
*/
|
|
14
|
+
import type { ZodType } from 'zod';
|
|
15
|
+
/**
|
|
16
|
+
* Coercion applied to a raw environment-variable string before it is merged
|
|
17
|
+
* into the resolved config.
|
|
18
|
+
*
|
|
19
|
+
* - `string` — passed through verbatim (the default).
|
|
20
|
+
* - `number` — parsed with `Number(...)`; a non-finite result is dropped.
|
|
21
|
+
* - `boolean` — `'true'`/`'1'` → true, `'false'`/`'0'` → false (case-insensitive);
|
|
22
|
+
* anything else is dropped.
|
|
23
|
+
*/
|
|
24
|
+
export type EnvBindingType = 'string' | 'number' | 'boolean';
|
|
25
|
+
/**
|
|
26
|
+
* Binds one environment variable to one config key within a namespace.
|
|
27
|
+
*
|
|
28
|
+
* The precedence resolver reads `process.env[envVar]` (supplied as the `env`
|
|
29
|
+
* map), coerces it per `type`, and writes it onto the namespace's resolved
|
|
30
|
+
* object under `key` — but only if no higher-precedence source (a flag) already
|
|
31
|
+
* set it.
|
|
32
|
+
*/
|
|
33
|
+
export interface EnvBindingDeclaration {
|
|
34
|
+
/** The environment variable name, e.g. `OPENSIP_FIT_FAIL_ON_ERRORS`. */
|
|
35
|
+
readonly envVar: string;
|
|
36
|
+
/** The config key within the owning namespace this variable populates. */
|
|
37
|
+
readonly key: string;
|
|
38
|
+
/** How the raw string is coerced before merge. Defaults to `'string'`. */
|
|
39
|
+
readonly type?: EnvBindingType;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A tool's contribution to the composed configuration document.
|
|
43
|
+
*
|
|
44
|
+
* `namespace` is the tool's top-level key (e.g. `fitness`, `graph`,
|
|
45
|
+
* `simulation`); `schema` validates that namespace's block. The composer makes
|
|
46
|
+
* each namespace schema `.strict()` so a typo inside a known namespace is
|
|
47
|
+
* rejected, while tolerating unclaimed top-level keys for forward compatibility.
|
|
48
|
+
*/
|
|
49
|
+
export interface ToolConfigDeclaration {
|
|
50
|
+
/** Top-level config key owned by this tool. */
|
|
51
|
+
readonly namespace: string;
|
|
52
|
+
/** Zod schema validating the namespace's block. */
|
|
53
|
+
readonly schema: ZodType;
|
|
54
|
+
/** Optional defaults for the namespace, used as the lowest-precedence source. */
|
|
55
|
+
readonly defaults?: unknown;
|
|
56
|
+
/** Optional environment-variable bindings for keys in this namespace. */
|
|
57
|
+
readonly env?: readonly EnvBindingDeclaration[];
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAEnC;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACjD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* declaration — the contract a tool offers to the configuration layer.
|
|
3
|
+
*
|
|
4
|
+
* Each tool contributes a {@link ToolConfigDeclaration}: a namespace (its
|
|
5
|
+
* top-level key in `opensip-cli.config.yml`), a Zod schema describing that
|
|
6
|
+
* namespace's block, optional defaults, and optional environment-variable
|
|
7
|
+
* bindings. The host composes the registered declarations into one strict
|
|
8
|
+
* whole-document schema (see {@link ./composer}) and resolves precedence across
|
|
9
|
+
* flags / env / file / defaults (see {@link ./precedence}).
|
|
10
|
+
*
|
|
11
|
+
* Nothing here imports a tool; the declaration is a pure data contract the
|
|
12
|
+
* tools hand to the composition root (wired in Phase 4).
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=declaration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.js","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|