@abitechdev/openchasqui-spec 0.0.0-stage → 0.1.1

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 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,4 @@
1
+ OpenChasqui
2
+ Copyright 2026 The OpenChasqui Authors
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
package/README.md CHANGED
@@ -1,3 +1,56 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <a href="https://github.com/abitech-dev/abitech-openchasqui-cli#readme"><img alt="OpenChasqui" src="https://raw.githubusercontent.com/abitech-dev/abitech-openchasqui-cli/main/.github/assets/logo-light.svg" width="320"></a>
3
+ </p>
2
4
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
5
+ # @abitechdev/openchasqui-spec
6
+
7
+ [![npm](https://img.shields.io/npm/v/@abitechdev/openchasqui-spec?color=c2410c&label=npm)](https://www.npmjs.com/package/@abitechdev/openchasqui-spec)
8
+ [![CI](https://github.com/abitech-dev/abitech-openchasqui-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/abitech-dev/abitech-openchasqui-cli/actions/workflows/ci.yml)
9
+ [![Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/abitech-dev/abitech-openchasqui-cli/blob/main/LICENSE)
10
+
11
+ Contrato de OpenChasqui: el modelo canónico de la API, los tipos de la configuración y la interfaz de cada tipo de plugin. Es la única dependencia que necesitas para escribir un plugin propio.
12
+
13
+ > **¿Solo quieres generar colecciones?** Instala el CLI,
14
+ > [`@abitechdev/openchasqui`](https://www.npmjs.com/package/@abitechdev/openchasqui), que ya incluye este paquete.
15
+
16
+ ## Instalación
17
+
18
+ ```bash
19
+ npm i @abitechdev/openchasqui-spec
20
+ pnpm add @abitechdev/openchasqui-spec
21
+ yarn add @abitechdev/openchasqui-spec
22
+ ```
23
+
24
+ Requiere Node.js 22 o superior.
25
+
26
+ ## Uso
27
+
28
+ Un emisor que lista las rutas del contrato:
29
+
30
+ ```ts
31
+ import type { Emitter } from "@abitechdev/openchasqui-spec";
32
+
33
+ export const routesEmitter: Emitter = {
34
+ name: "routes-emitter",
35
+ kind: "emitter",
36
+ apiVersion: 1,
37
+ target: "routes",
38
+ emit: async ({ model }) => [
39
+ {
40
+ path: "routes.txt",
41
+ contents: model.operations.map((op) => `${op.method} ${op.path}`).join("\n"),
42
+ },
43
+ ],
44
+ };
45
+ ```
46
+
47
+ Los tipos de plugin son `document-transformer`, `loader`, `transformer`,
48
+ `generator`, `validator` y `emitter`.
49
+
50
+ ## Documentación
51
+
52
+ [Español](https://github.com/abitech-dev/abitech-openchasqui-cli#readme) · [English](https://github.com/abitech-dev/abitech-openchasqui-cli/blob/main/README.en.md)
53
+
54
+ ## Licencia
55
+
56
+ [Apache-2.0](https://github.com/abitech-dev/abitech-openchasqui-cli/blob/main/LICENSE). Parte de [OpenChasqui](https://github.com/abitech-dev/abitech-openchasqui-cli).
@@ -0,0 +1,37 @@
1
+ /** Configuration file version. `openchasqui migrate` moves it forward. */
2
+ export declare const CONFIG_VERSION: 1;
3
+ export interface OpenChasquiConfig {
4
+ readonly version: typeof CONFIG_VERSION;
5
+ /** Path to the OpenAPI document, relative to the configuration file. */
6
+ readonly source: string;
7
+ /** Overlay 1.0 documents, applied in order. */
8
+ readonly overlays?: readonly string[];
9
+ readonly environments?: Readonly<Record<string, EnvironmentConfig>>;
10
+ readonly variables?: VariableNames;
11
+ /** Data set for synthetic examples, `generic` by default or `es-pe`. */
12
+ readonly data?: "generic" | "es-pe";
13
+ readonly tests?: TestOptions;
14
+ readonly targets: readonly string[];
15
+ /** Folder for the emitted collections, one subfolder per target. */
16
+ readonly output: string;
17
+ }
18
+ export interface TestOptions {
19
+ /** Slowest acceptable response. Defaults to 5000. */
20
+ readonly responseTimeMs?: number;
21
+ }
22
+ /** Names of the variables the collections use. */
23
+ export interface VariableNames {
24
+ /** Defaults to `baseUrl`. */
25
+ readonly baseUrl?: string;
26
+ /** Defaults to `token`. */
27
+ readonly token?: string;
28
+ /** Defaults to `apiKey`. */
29
+ readonly apiKey?: string;
30
+ }
31
+ export declare const DEFAULT_VARIABLES: Required<VariableNames>;
32
+ export interface EnvironmentConfig {
33
+ readonly variables: Readonly<Record<string, string>>;
34
+ /** Variable names whose values never leave the user's machine. */
35
+ readonly secrets?: readonly string[];
36
+ }
37
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,eAAO,MAAM,cAAc,EAAG,CAAU,CAAC;AAEzC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,cAAc,CAAC;IACxC,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,kDAAkD;AAClD,MAAM,WAAW,aAAa;IAC5B,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,4BAA4B;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,aAAa,CAIrD,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,kEAAkE;IAClE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC"}
package/dist/config.js ADDED
@@ -0,0 +1,8 @@
1
+ /** Configuration file version. `openchasqui migrate` moves it forward. */
2
+ export const CONFIG_VERSION = 1;
3
+ export const DEFAULT_VARIABLES = {
4
+ baseUrl: "baseUrl",
5
+ token: "token",
6
+ apiKey: "apiKey",
7
+ };
8
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAU,CAAC;AAiCzC,MAAM,CAAC,MAAM,iBAAiB,GAA4B;IACxD,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACjB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./config.js";
2
+ export * from "./model.js";
3
+ export * from "./plugin.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./config.js";
2
+ export * from "./model.js";
3
+ export * from "./plugin.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,97 @@
1
+ /** Version of the canonical model. A breaking change ships with a migration. */
2
+ export declare const MODEL_VERSION: 1;
3
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
4
+ /** JSON Schema 2020-12, as found in an OpenAPI 3.1 document. */
5
+ export type JsonSchema = {
6
+ readonly [keyword: string]: unknown;
7
+ };
8
+ export interface ApiModel {
9
+ readonly modelVersion: typeof MODEL_VERSION;
10
+ readonly info: ApiInfo;
11
+ readonly servers: readonly Server[];
12
+ readonly securitySchemes: Readonly<Record<string, SecurityScheme>>;
13
+ readonly operations: readonly Operation[];
14
+ readonly schemas: Readonly<Record<string, JsonSchema>>;
15
+ }
16
+ export interface ApiInfo {
17
+ readonly title: string;
18
+ readonly version: string;
19
+ readonly description?: string;
20
+ }
21
+ export interface Server {
22
+ readonly url: string;
23
+ readonly description?: string;
24
+ }
25
+ export type SecurityScheme = {
26
+ readonly type: "http";
27
+ readonly scheme: "bearer" | "basic";
28
+ readonly bearerFormat?: string;
29
+ } | {
30
+ readonly type: "apiKey";
31
+ readonly in: "header" | "query" | "cookie";
32
+ readonly name: string;
33
+ } | {
34
+ readonly type: "oauth2" | "openIdConnect";
35
+ };
36
+ export interface Operation {
37
+ /** The operationId, or the method plus the path when it is missing. */
38
+ readonly id: string;
39
+ readonly method: HttpMethod;
40
+ /** Path template with OpenAPI braces, e.g. `/banks/{id}`. */
41
+ readonly path: string;
42
+ /** Display name in the collection. */
43
+ readonly name: string;
44
+ /** Folder path from the root of the collection. */
45
+ readonly folder: readonly string[];
46
+ /** Position inside its folder, starting at 1. */
47
+ readonly order: number;
48
+ readonly summary?: string;
49
+ readonly description?: string;
50
+ readonly deprecated: boolean;
51
+ readonly parameters: readonly Parameter[];
52
+ readonly requestBody?: RequestBody;
53
+ readonly responses: readonly Response[];
54
+ /** Names of the security schemes that apply. Empty means public. */
55
+ readonly security: readonly string[];
56
+ readonly tests: readonly TestCase[];
57
+ /** `x-` extensions of the source operation, untouched. */
58
+ readonly extensions: Readonly<Record<string, unknown>>;
59
+ }
60
+ export type ParameterLocation = "path" | "query" | "header" | "cookie";
61
+ export interface Parameter {
62
+ readonly name: string;
63
+ readonly in: ParameterLocation;
64
+ readonly required: boolean;
65
+ readonly description?: string;
66
+ readonly schema?: JsonSchema;
67
+ readonly example?: unknown;
68
+ }
69
+ export interface RequestBody {
70
+ readonly required: boolean;
71
+ readonly content: readonly MediaContent[];
72
+ }
73
+ export interface MediaContent {
74
+ readonly mediaType: string;
75
+ readonly schema?: JsonSchema;
76
+ readonly example?: unknown;
77
+ }
78
+ export interface Response {
79
+ /** Status code (`200`), range (`2XX`) or `default`, as in OpenAPI. */
80
+ readonly status: string;
81
+ readonly description?: string;
82
+ readonly content: readonly MediaContent[];
83
+ }
84
+ export type TestCase = {
85
+ readonly kind: "status";
86
+ readonly expected: readonly number[];
87
+ } | {
88
+ readonly kind: "contentType";
89
+ readonly mediaType: string;
90
+ } | {
91
+ readonly kind: "jsonSchema";
92
+ readonly schema: JsonSchema;
93
+ } | {
94
+ readonly kind: "responseTime";
95
+ readonly maxMilliseconds: number;
96
+ };
97
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,aAAa,EAAG,CAAU,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ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 {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAU,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { VariableNames } from "./config.js";
2
+ import type { ApiModel } from "./model.js";
3
+ /** Plugin contract version. The core also accepts the previous one. */
4
+ export declare const PLUGIN_API_VERSION: 1;
5
+ export type PluginKind = "document-transformer" | "loader" | "transformer" | "generator" | "validator" | "emitter" | "runner" | "reporter";
6
+ export interface PluginBase {
7
+ readonly name: string;
8
+ readonly kind: PluginKind;
9
+ readonly apiVersion: typeof PLUGIN_API_VERSION;
10
+ }
11
+ /** Reads files for a plugin. Plugins never touch the disk themselves. */
12
+ export interface SourceReader {
13
+ readText(path: string): Promise<string>;
14
+ }
15
+ export interface PluginContext {
16
+ readonly reader: SourceReader;
17
+ readonly options: Readonly<Record<string, unknown>>;
18
+ }
19
+ export interface DocumentTransformResult {
20
+ readonly document: unknown;
21
+ readonly findings: readonly Finding[];
22
+ }
23
+ /** Changes the source document before a loader reads it, as Overlay does. */
24
+ export interface DocumentTransformer extends PluginBase {
25
+ readonly kind: "document-transformer";
26
+ transformDocument(document: unknown, context: PluginContext): Promise<DocumentTransformResult>;
27
+ }
28
+ export interface Loader extends PluginBase {
29
+ readonly kind: "loader";
30
+ canLoad(document: unknown): boolean;
31
+ load(document: unknown, context: PluginContext): Promise<ApiModel>;
32
+ }
33
+ export interface Transformer extends PluginBase {
34
+ readonly kind: "transformer";
35
+ transform(model: ApiModel, context: PluginContext): Promise<ApiModel>;
36
+ }
37
+ export interface Generator extends PluginBase {
38
+ readonly kind: "generator";
39
+ generate(model: ApiModel, context: PluginContext): Promise<ApiModel>;
40
+ }
41
+ export type Severity = "error" | "warning" | "info";
42
+ export interface Finding {
43
+ readonly rule: string;
44
+ readonly severity: Severity;
45
+ readonly message: string;
46
+ readonly operationId?: string;
47
+ readonly file?: string;
48
+ }
49
+ export interface Validator extends PluginBase {
50
+ readonly kind: "validator";
51
+ validate(model: ApiModel, context: PluginContext): Promise<readonly Finding[]>;
52
+ }
53
+ export interface EmittedFile {
54
+ /** Relative to the target folder, with forward slashes. */
55
+ readonly path: string;
56
+ readonly contents: string;
57
+ }
58
+ export interface EnvironmentDefinition {
59
+ readonly name: string;
60
+ readonly variables: Readonly<Record<string, string>>;
61
+ readonly secrets: readonly string[];
62
+ }
63
+ export interface EmitInput {
64
+ readonly model: ApiModel;
65
+ readonly environments: readonly EnvironmentDefinition[];
66
+ readonly variables: Required<VariableNames>;
67
+ }
68
+ export interface Emitter extends PluginBase {
69
+ readonly kind: "emitter";
70
+ /** Name used in the configuration, e.g. `postman`. */
71
+ readonly target: string;
72
+ emit(input: EmitInput, context: PluginContext): Promise<readonly EmittedFile[]>;
73
+ }
74
+ export type Plugin = DocumentTransformer | Loader | Transformer | Generator | Validator | Emitter;
75
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,uEAAuE;AACvE,eAAO,MAAM,kBAAkB,EAAG,CAAU,CAAC;AAE7C,MAAM,MAAM,UAAU,GAClB,sBAAsB,GACtB,QAAQ,GACR,aAAa,GACb,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,kBAAkB,CAAC;CAChD;AAED,yEAAyE;AACzE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC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,CAAC,CAAC;CACjF;AAED,MAAM,MAAM,MAAM,GAAG,mBAAmB,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,3 @@
1
+ /** Plugin contract version. The core also accepts the previous one. */
2
+ export const PLUGIN_API_VERSION = 1;
3
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@abitechdev/openchasqui-spec",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Canonical API model, plugin contract and configuration types for OpenChasqui.",
5
+ "keywords": [
6
+ "openapi",
7
+ "api-model",
8
+ "plugin-contract",
9
+ "typescript",
10
+ "openchasqui"
11
+ ],
12
+ "license": "Apache-2.0",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "src",
23
+ "NOTICE"
24
+ ],
25
+ "engines": {
26
+ "node": ">=22"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/abitech-dev/abitech-openchasqui-cli.git",
31
+ "directory": "packages/spec"
32
+ }
6
33
  }
package/src/config.ts ADDED
@@ -0,0 +1,45 @@
1
+ /** Configuration file version. `openchasqui migrate` moves it forward. */
2
+ export const CONFIG_VERSION = 1 as const;
3
+
4
+ export interface OpenChasquiConfig {
5
+ readonly version: typeof CONFIG_VERSION;
6
+ /** Path to the OpenAPI document, relative to the configuration file. */
7
+ readonly source: string;
8
+ /** Overlay 1.0 documents, applied in order. */
9
+ readonly overlays?: readonly string[];
10
+ readonly environments?: Readonly<Record<string, EnvironmentConfig>>;
11
+ readonly variables?: VariableNames;
12
+ /** Data set for synthetic examples, `generic` by default or `es-pe`. */
13
+ readonly data?: "generic" | "es-pe";
14
+ readonly tests?: TestOptions;
15
+ readonly targets: readonly string[];
16
+ /** Folder for the emitted collections, one subfolder per target. */
17
+ readonly output: string;
18
+ }
19
+
20
+ export interface TestOptions {
21
+ /** Slowest acceptable response. Defaults to 5000. */
22
+ readonly responseTimeMs?: number;
23
+ }
24
+
25
+ /** Names of the variables the collections use. */
26
+ export interface VariableNames {
27
+ /** Defaults to `baseUrl`. */
28
+ readonly baseUrl?: string;
29
+ /** Defaults to `token`. */
30
+ readonly token?: string;
31
+ /** Defaults to `apiKey`. */
32
+ readonly apiKey?: string;
33
+ }
34
+
35
+ export const DEFAULT_VARIABLES: Required<VariableNames> = {
36
+ baseUrl: "baseUrl",
37
+ token: "token",
38
+ apiKey: "apiKey",
39
+ };
40
+
41
+ export interface EnvironmentConfig {
42
+ readonly variables: Readonly<Record<string, string>>;
43
+ /** Variable names whose values never leave the user's machine. */
44
+ readonly secrets?: readonly string[];
45
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./config.js";
2
+ export * from "./model.js";
3
+ export * from "./plugin.js";
package/src/model.ts ADDED
@@ -0,0 +1,92 @@
1
+ /** Version of the canonical model. A breaking change ships with a migration. */
2
+ export const MODEL_VERSION = 1 as const;
3
+
4
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
5
+
6
+ /** JSON Schema 2020-12, as found in an OpenAPI 3.1 document. */
7
+ export type JsonSchema = { readonly [keyword: string]: unknown };
8
+
9
+ export interface ApiModel {
10
+ readonly modelVersion: typeof MODEL_VERSION;
11
+ readonly info: ApiInfo;
12
+ readonly servers: readonly Server[];
13
+ readonly securitySchemes: Readonly<Record<string, SecurityScheme>>;
14
+ readonly operations: readonly Operation[];
15
+ readonly schemas: Readonly<Record<string, JsonSchema>>;
16
+ }
17
+
18
+ export interface ApiInfo {
19
+ readonly title: string;
20
+ readonly version: string;
21
+ readonly description?: string;
22
+ }
23
+
24
+ export interface Server {
25
+ readonly url: string;
26
+ readonly description?: string;
27
+ }
28
+
29
+ export type SecurityScheme =
30
+ | { readonly type: "http"; readonly scheme: "bearer" | "basic"; readonly bearerFormat?: string }
31
+ | { readonly type: "apiKey"; readonly in: "header" | "query" | "cookie"; readonly name: string }
32
+ | { readonly type: "oauth2" | "openIdConnect" };
33
+
34
+ export interface Operation {
35
+ /** The operationId, or the method plus the path when it is missing. */
36
+ readonly id: string;
37
+ readonly method: HttpMethod;
38
+ /** Path template with OpenAPI braces, e.g. `/banks/{id}`. */
39
+ readonly path: string;
40
+ /** Display name in the collection. */
41
+ readonly name: string;
42
+ /** Folder path from the root of the collection. */
43
+ readonly folder: readonly string[];
44
+ /** Position inside its folder, starting at 1. */
45
+ readonly order: number;
46
+ readonly summary?: string;
47
+ readonly description?: string;
48
+ readonly deprecated: boolean;
49
+ readonly parameters: readonly Parameter[];
50
+ readonly requestBody?: RequestBody;
51
+ readonly responses: readonly Response[];
52
+ /** Names of the security schemes that apply. Empty means public. */
53
+ readonly security: readonly string[];
54
+ readonly tests: readonly TestCase[];
55
+ /** `x-` extensions of the source operation, untouched. */
56
+ readonly extensions: Readonly<Record<string, unknown>>;
57
+ }
58
+
59
+ export type ParameterLocation = "path" | "query" | "header" | "cookie";
60
+
61
+ export interface Parameter {
62
+ readonly name: string;
63
+ readonly in: ParameterLocation;
64
+ readonly required: boolean;
65
+ readonly description?: string;
66
+ readonly schema?: JsonSchema;
67
+ readonly example?: unknown;
68
+ }
69
+
70
+ export interface RequestBody {
71
+ readonly required: boolean;
72
+ readonly content: readonly MediaContent[];
73
+ }
74
+
75
+ export interface MediaContent {
76
+ readonly mediaType: string;
77
+ readonly schema?: JsonSchema;
78
+ readonly example?: unknown;
79
+ }
80
+
81
+ export interface Response {
82
+ /** Status code (`200`), range (`2XX`) or `default`, as in OpenAPI. */
83
+ readonly status: string;
84
+ readonly description?: string;
85
+ readonly content: readonly MediaContent[];
86
+ }
87
+
88
+ export type TestCase =
89
+ | { readonly kind: "status"; readonly expected: readonly number[] }
90
+ | { readonly kind: "contentType"; readonly mediaType: string }
91
+ | { readonly kind: "jsonSchema"; readonly schema: JsonSchema }
92
+ | { readonly kind: "responseTime"; readonly maxMilliseconds: number };
package/src/plugin.ts ADDED
@@ -0,0 +1,100 @@
1
+ import type { VariableNames } from "./config.js";
2
+ import type { ApiModel } from "./model.js";
3
+
4
+ /** Plugin contract version. The core also accepts the previous one. */
5
+ export const PLUGIN_API_VERSION = 1 as const;
6
+
7
+ export type PluginKind =
8
+ | "document-transformer"
9
+ | "loader"
10
+ | "transformer"
11
+ | "generator"
12
+ | "validator"
13
+ | "emitter"
14
+ | "runner"
15
+ | "reporter";
16
+
17
+ export interface PluginBase {
18
+ readonly name: string;
19
+ readonly kind: PluginKind;
20
+ readonly apiVersion: typeof PLUGIN_API_VERSION;
21
+ }
22
+
23
+ /** Reads files for a plugin. Plugins never touch the disk themselves. */
24
+ export interface SourceReader {
25
+ readText(path: string): Promise<string>;
26
+ }
27
+
28
+ export interface PluginContext {
29
+ readonly reader: SourceReader;
30
+ readonly options: Readonly<Record<string, unknown>>;
31
+ }
32
+
33
+ export interface DocumentTransformResult {
34
+ readonly document: unknown;
35
+ readonly findings: readonly Finding[];
36
+ }
37
+
38
+ /** Changes the source document before a loader reads it, as Overlay does. */
39
+ export interface DocumentTransformer extends PluginBase {
40
+ readonly kind: "document-transformer";
41
+ transformDocument(document: unknown, context: PluginContext): Promise<DocumentTransformResult>;
42
+ }
43
+
44
+ export interface Loader extends PluginBase {
45
+ readonly kind: "loader";
46
+ canLoad(document: unknown): boolean;
47
+ load(document: unknown, context: PluginContext): Promise<ApiModel>;
48
+ }
49
+
50
+ export interface Transformer extends PluginBase {
51
+ readonly kind: "transformer";
52
+ transform(model: ApiModel, context: PluginContext): Promise<ApiModel>;
53
+ }
54
+
55
+ export interface Generator extends PluginBase {
56
+ readonly kind: "generator";
57
+ generate(model: ApiModel, context: PluginContext): Promise<ApiModel>;
58
+ }
59
+
60
+ export type Severity = "error" | "warning" | "info";
61
+
62
+ export interface Finding {
63
+ readonly rule: string;
64
+ readonly severity: Severity;
65
+ readonly message: string;
66
+ readonly operationId?: string;
67
+ readonly file?: string;
68
+ }
69
+
70
+ export interface Validator extends PluginBase {
71
+ readonly kind: "validator";
72
+ validate(model: ApiModel, context: PluginContext): Promise<readonly Finding[]>;
73
+ }
74
+
75
+ export interface EmittedFile {
76
+ /** Relative to the target folder, with forward slashes. */
77
+ readonly path: string;
78
+ readonly contents: string;
79
+ }
80
+
81
+ export interface EnvironmentDefinition {
82
+ readonly name: string;
83
+ readonly variables: Readonly<Record<string, string>>;
84
+ readonly secrets: readonly string[];
85
+ }
86
+
87
+ export interface EmitInput {
88
+ readonly model: ApiModel;
89
+ readonly environments: readonly EnvironmentDefinition[];
90
+ readonly variables: Required<VariableNames>;
91
+ }
92
+
93
+ export interface Emitter extends PluginBase {
94
+ readonly kind: "emitter";
95
+ /** Name used in the configuration, e.g. `postman`. */
96
+ readonly target: string;
97
+ emit(input: EmitInput, context: PluginContext): Promise<readonly EmittedFile[]>;
98
+ }
99
+
100
+ export type Plugin = DocumentTransformer | Loader | Transformer | Generator | Validator | Emitter;