@stackwright-pro/openapi 0.3.0-alpha.2 → 0.3.0-alpha.4
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/dist/index.d.mts +103 -4
- package/dist/index.d.ts +103 -4
- package/dist/index.js +320 -5734
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +323 -5739
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -60,6 +60,32 @@ interface EndpointFilter$1 {
|
|
|
60
60
|
/** Endpoints/patterns to exclude */
|
|
61
61
|
exclude?: string[];
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for a single action endpoint in stackwright.yml
|
|
65
|
+
*
|
|
66
|
+
* Actions are write-through endpoints (POST, PUT, DELETE, PATCH) that can be
|
|
67
|
+
* invoked from workflow on_submit handlers via service: references.
|
|
68
|
+
*
|
|
69
|
+
* Unlike collections (which generate CollectionProviders for data display),
|
|
70
|
+
* actions generate typed, schema-validated callables that the workflow runtime
|
|
71
|
+
* resolves by name.
|
|
72
|
+
*
|
|
73
|
+
* Example stackwright.yml:
|
|
74
|
+
* actions:
|
|
75
|
+
* - name: create-supply-request # resolves service:create-supply-request
|
|
76
|
+
* endpoint: /supplies/request
|
|
77
|
+
* method: POST
|
|
78
|
+
*/
|
|
79
|
+
interface ActionConfig {
|
|
80
|
+
/** Service name — resolves service:<name> in workflow YAML on_submit.action */
|
|
81
|
+
name: string;
|
|
82
|
+
/** API endpoint path (e.g. '/supplies/request') */
|
|
83
|
+
endpoint: string;
|
|
84
|
+
/** HTTP method — typically POST, PUT, PATCH, or DELETE */
|
|
85
|
+
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
86
|
+
/** Optional human-readable description (used in generated JSDoc) */
|
|
87
|
+
description?: string;
|
|
88
|
+
}
|
|
63
89
|
/**
|
|
64
90
|
* Configuration for OpenAPI integration in stackwright.yml
|
|
65
91
|
*/
|
|
@@ -82,9 +108,13 @@ interface OpenAPIConfig {
|
|
|
82
108
|
endpoint: string;
|
|
83
109
|
/** Field to use as slug/ID */
|
|
84
110
|
slug_field: string;
|
|
111
|
+
/** HTTP method for this collection endpoint — defaults to 'GET' */
|
|
112
|
+
method?: string;
|
|
85
113
|
/** Optional filters */
|
|
86
114
|
filters?: Record<string, unknown>;
|
|
87
115
|
}>;
|
|
116
|
+
/** Actions to generate from write endpoints (POST, PUT, PATCH, DELETE) */
|
|
117
|
+
actions?: ActionConfig[];
|
|
88
118
|
/** Endpoint filter - only generate code for matching endpoints */
|
|
89
119
|
endpoints?: EndpointFilter$1;
|
|
90
120
|
}
|
|
@@ -100,6 +130,8 @@ interface OpenAPICompilationResult {
|
|
|
100
130
|
provider: string;
|
|
101
131
|
/** Generated API client */
|
|
102
132
|
client: string;
|
|
133
|
+
/** Generated CollectionAction implementations */
|
|
134
|
+
actions: string;
|
|
103
135
|
}
|
|
104
136
|
|
|
105
137
|
interface ParseOptions {
|
|
@@ -164,16 +196,38 @@ type SchemaObject$1 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject;
|
|
|
164
196
|
*/
|
|
165
197
|
declare class SchemaResolver {
|
|
166
198
|
private document;
|
|
199
|
+
/**
|
|
200
|
+
* @param document - Fully dereferenced OpenAPI document. Pass the result of
|
|
201
|
+
* SwaggerParser.dereference() or OpenAPIParser.parse(). Passing a document
|
|
202
|
+
* with unresolved $ref objects will produce console warnings and undefined
|
|
203
|
+
* returns from schema extraction methods.
|
|
204
|
+
*/
|
|
167
205
|
constructor(document: OpenAPIV3.Document | OpenAPIV3_1.Document);
|
|
168
206
|
/**
|
|
169
|
-
* Get schema for a specific path and method
|
|
207
|
+
* Get schema for a specific path and method.
|
|
208
|
+
*
|
|
209
|
+
* Tries `preferredResponseCode` first (default `'200'`). If that code is
|
|
210
|
+
* absent or has no JSON schema, falls back through other 2xx codes in
|
|
211
|
+
* priority order so that REST-correct `201 Created` responses are resolved
|
|
212
|
+
* automatically.
|
|
170
213
|
*
|
|
171
214
|
* @param path - API path (e.g., '/equipment')
|
|
172
215
|
* @param method - HTTP method (e.g., 'get')
|
|
173
|
-
* @param
|
|
216
|
+
* @param preferredResponseCode - Response code to try first (default: '200')
|
|
217
|
+
* @returns Schema object or undefined
|
|
218
|
+
*/
|
|
219
|
+
getResponseSchema(path: string, method: string, preferredResponseCode?: string): SchemaObject$1 | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Get the request body schema for a specific path and method.
|
|
222
|
+
*
|
|
223
|
+
* Extracts the application/json schema from the operation's requestBody.
|
|
224
|
+
* Returns undefined if the operation has no requestBody or no JSON content.
|
|
225
|
+
*
|
|
226
|
+
* @param path - API path (e.g., '/supplies/request')
|
|
227
|
+
* @param method - HTTP method (e.g., 'post')
|
|
174
228
|
* @returns Schema object or undefined
|
|
175
229
|
*/
|
|
176
|
-
|
|
230
|
+
getRequestBodySchema(path: string, method: string): SchemaObject$1 | undefined;
|
|
177
231
|
/**
|
|
178
232
|
* Get all schemas defined in components
|
|
179
233
|
*/
|
|
@@ -377,6 +431,50 @@ declare class CollectionProviderGenerator {
|
|
|
377
431
|
private guessTitle;
|
|
378
432
|
}
|
|
379
433
|
|
|
434
|
+
/**
|
|
435
|
+
* ActionGenerator
|
|
436
|
+
*
|
|
437
|
+
* Generates typed CollectionAction implementations from OpenAPI action configs.
|
|
438
|
+
* Each configured action endpoint becomes a named export satisfying the
|
|
439
|
+
* CollectionAction<TInput, TOutput> interface from @stackwright-pro/workflow.
|
|
440
|
+
*
|
|
441
|
+
* The generated actions.ts is the bridge between:
|
|
442
|
+
* - stackwright.yml actions: config (what to generate)
|
|
443
|
+
* - workflow YAML service: refs (how it's addressed at runtime)
|
|
444
|
+
* - useWorkflow actions registry (where it executes)
|
|
445
|
+
*
|
|
446
|
+
* IoC note: This generator emits `import type { CollectionAction } from
|
|
447
|
+
* '@stackwright-pro/workflow'` as a string. The generator package itself has
|
|
448
|
+
* no dependency on @stackwright-pro/workflow — only the generated files do.
|
|
449
|
+
*/
|
|
450
|
+
declare class ActionGenerator {
|
|
451
|
+
private document;
|
|
452
|
+
private resolver;
|
|
453
|
+
private zodGenerator;
|
|
454
|
+
constructor(document: OpenAPIDocument);
|
|
455
|
+
/**
|
|
456
|
+
* Generate the complete actions.ts file content.
|
|
457
|
+
*
|
|
458
|
+
* @param actions - Action configs from stackwright.yml
|
|
459
|
+
* @param integrationName - Used in the file header comment
|
|
460
|
+
* @param clientClassName - Name of the generated API client class to import
|
|
461
|
+
* @returns Complete TypeScript source for actions.ts
|
|
462
|
+
*/
|
|
463
|
+
generate(actions: ActionConfig[], integrationName: string, clientClassName: string): string;
|
|
464
|
+
private processAction;
|
|
465
|
+
private generateHeader;
|
|
466
|
+
private generateImports;
|
|
467
|
+
private generateInlineSchemas;
|
|
468
|
+
private generateActionExports;
|
|
469
|
+
private generateRegistry;
|
|
470
|
+
private generateEmptyFile;
|
|
471
|
+
/** Derives the client method name from endpoint + method (best-effort) */
|
|
472
|
+
private endpointToClientMethod;
|
|
473
|
+
private toCamelCase;
|
|
474
|
+
private toPascalCase;
|
|
475
|
+
private capitalize;
|
|
476
|
+
}
|
|
477
|
+
|
|
380
478
|
/**
|
|
381
479
|
* Mapping of operationId to schema names
|
|
382
480
|
*/
|
|
@@ -685,6 +783,7 @@ declare class OpenAPIPlugin implements PrebuildPlugin {
|
|
|
685
783
|
private generateSchemas;
|
|
686
784
|
private generateTypes;
|
|
687
785
|
private generateProvider;
|
|
786
|
+
private generateActions;
|
|
688
787
|
private generateClient;
|
|
689
788
|
private extractComponentName;
|
|
690
789
|
private getOperationTypeName;
|
|
@@ -954,4 +1053,4 @@ declare class ApprovedSpecsValidator {
|
|
|
954
1053
|
clearCache(): void;
|
|
955
1054
|
}
|
|
956
1055
|
|
|
957
|
-
export { type ApprovedSpec, ApprovedSpecsValidator, type ClientGenerationOptions, ClientGenerator, type CollectionConfig, CollectionProviderGenerator, EndpointFilter, type OpenAPICompilationResult, type OpenAPIConfig, type OpenAPIDocument, OpenAPIParser, OpenAPIPlugin, type OpenAPISourceConfig, type ParseOptions, type ParseResult, type PrebuildSecurityConfig, type ProviderGenerationOptions, type SchemaMapping, SchemaResolver, type SiteConfig, type TypeGenerationOptions, TypeGenerator, type ValidationResult, type ZodGenerationOptions, ZodSchemaGenerator, createOpenAPIFetcher, createOpenAPIPlugin, isUrlSafe, validateUrlSafe };
|
|
1056
|
+
export { type ActionConfig, ActionGenerator, type ApprovedSpec, ApprovedSpecsValidator, type ClientGenerationOptions, ClientGenerator, type CollectionConfig, CollectionProviderGenerator, EndpointFilter, type OpenAPICompilationResult, type OpenAPIConfig, type OpenAPIDocument, OpenAPIParser, OpenAPIPlugin, type OpenAPISourceConfig, type ParseOptions, type ParseResult, type PrebuildSecurityConfig, type ProviderGenerationOptions, type SchemaMapping, SchemaResolver, type SiteConfig, type TypeGenerationOptions, TypeGenerator, type ValidationResult, type ZodGenerationOptions, ZodSchemaGenerator, createOpenAPIFetcher, createOpenAPIPlugin, isUrlSafe, validateUrlSafe };
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,32 @@ interface EndpointFilter$1 {
|
|
|
60
60
|
/** Endpoints/patterns to exclude */
|
|
61
61
|
exclude?: string[];
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Configuration for a single action endpoint in stackwright.yml
|
|
65
|
+
*
|
|
66
|
+
* Actions are write-through endpoints (POST, PUT, DELETE, PATCH) that can be
|
|
67
|
+
* invoked from workflow on_submit handlers via service: references.
|
|
68
|
+
*
|
|
69
|
+
* Unlike collections (which generate CollectionProviders for data display),
|
|
70
|
+
* actions generate typed, schema-validated callables that the workflow runtime
|
|
71
|
+
* resolves by name.
|
|
72
|
+
*
|
|
73
|
+
* Example stackwright.yml:
|
|
74
|
+
* actions:
|
|
75
|
+
* - name: create-supply-request # resolves service:create-supply-request
|
|
76
|
+
* endpoint: /supplies/request
|
|
77
|
+
* method: POST
|
|
78
|
+
*/
|
|
79
|
+
interface ActionConfig {
|
|
80
|
+
/** Service name — resolves service:<name> in workflow YAML on_submit.action */
|
|
81
|
+
name: string;
|
|
82
|
+
/** API endpoint path (e.g. '/supplies/request') */
|
|
83
|
+
endpoint: string;
|
|
84
|
+
/** HTTP method — typically POST, PUT, PATCH, or DELETE */
|
|
85
|
+
method: 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
86
|
+
/** Optional human-readable description (used in generated JSDoc) */
|
|
87
|
+
description?: string;
|
|
88
|
+
}
|
|
63
89
|
/**
|
|
64
90
|
* Configuration for OpenAPI integration in stackwright.yml
|
|
65
91
|
*/
|
|
@@ -82,9 +108,13 @@ interface OpenAPIConfig {
|
|
|
82
108
|
endpoint: string;
|
|
83
109
|
/** Field to use as slug/ID */
|
|
84
110
|
slug_field: string;
|
|
111
|
+
/** HTTP method for this collection endpoint — defaults to 'GET' */
|
|
112
|
+
method?: string;
|
|
85
113
|
/** Optional filters */
|
|
86
114
|
filters?: Record<string, unknown>;
|
|
87
115
|
}>;
|
|
116
|
+
/** Actions to generate from write endpoints (POST, PUT, PATCH, DELETE) */
|
|
117
|
+
actions?: ActionConfig[];
|
|
88
118
|
/** Endpoint filter - only generate code for matching endpoints */
|
|
89
119
|
endpoints?: EndpointFilter$1;
|
|
90
120
|
}
|
|
@@ -100,6 +130,8 @@ interface OpenAPICompilationResult {
|
|
|
100
130
|
provider: string;
|
|
101
131
|
/** Generated API client */
|
|
102
132
|
client: string;
|
|
133
|
+
/** Generated CollectionAction implementations */
|
|
134
|
+
actions: string;
|
|
103
135
|
}
|
|
104
136
|
|
|
105
137
|
interface ParseOptions {
|
|
@@ -164,16 +196,38 @@ type SchemaObject$1 = OpenAPIV3.SchemaObject | OpenAPIV3_1.SchemaObject;
|
|
|
164
196
|
*/
|
|
165
197
|
declare class SchemaResolver {
|
|
166
198
|
private document;
|
|
199
|
+
/**
|
|
200
|
+
* @param document - Fully dereferenced OpenAPI document. Pass the result of
|
|
201
|
+
* SwaggerParser.dereference() or OpenAPIParser.parse(). Passing a document
|
|
202
|
+
* with unresolved $ref objects will produce console warnings and undefined
|
|
203
|
+
* returns from schema extraction methods.
|
|
204
|
+
*/
|
|
167
205
|
constructor(document: OpenAPIV3.Document | OpenAPIV3_1.Document);
|
|
168
206
|
/**
|
|
169
|
-
* Get schema for a specific path and method
|
|
207
|
+
* Get schema for a specific path and method.
|
|
208
|
+
*
|
|
209
|
+
* Tries `preferredResponseCode` first (default `'200'`). If that code is
|
|
210
|
+
* absent or has no JSON schema, falls back through other 2xx codes in
|
|
211
|
+
* priority order so that REST-correct `201 Created` responses are resolved
|
|
212
|
+
* automatically.
|
|
170
213
|
*
|
|
171
214
|
* @param path - API path (e.g., '/equipment')
|
|
172
215
|
* @param method - HTTP method (e.g., 'get')
|
|
173
|
-
* @param
|
|
216
|
+
* @param preferredResponseCode - Response code to try first (default: '200')
|
|
217
|
+
* @returns Schema object or undefined
|
|
218
|
+
*/
|
|
219
|
+
getResponseSchema(path: string, method: string, preferredResponseCode?: string): SchemaObject$1 | undefined;
|
|
220
|
+
/**
|
|
221
|
+
* Get the request body schema for a specific path and method.
|
|
222
|
+
*
|
|
223
|
+
* Extracts the application/json schema from the operation's requestBody.
|
|
224
|
+
* Returns undefined if the operation has no requestBody or no JSON content.
|
|
225
|
+
*
|
|
226
|
+
* @param path - API path (e.g., '/supplies/request')
|
|
227
|
+
* @param method - HTTP method (e.g., 'post')
|
|
174
228
|
* @returns Schema object or undefined
|
|
175
229
|
*/
|
|
176
|
-
|
|
230
|
+
getRequestBodySchema(path: string, method: string): SchemaObject$1 | undefined;
|
|
177
231
|
/**
|
|
178
232
|
* Get all schemas defined in components
|
|
179
233
|
*/
|
|
@@ -377,6 +431,50 @@ declare class CollectionProviderGenerator {
|
|
|
377
431
|
private guessTitle;
|
|
378
432
|
}
|
|
379
433
|
|
|
434
|
+
/**
|
|
435
|
+
* ActionGenerator
|
|
436
|
+
*
|
|
437
|
+
* Generates typed CollectionAction implementations from OpenAPI action configs.
|
|
438
|
+
* Each configured action endpoint becomes a named export satisfying the
|
|
439
|
+
* CollectionAction<TInput, TOutput> interface from @stackwright-pro/workflow.
|
|
440
|
+
*
|
|
441
|
+
* The generated actions.ts is the bridge between:
|
|
442
|
+
* - stackwright.yml actions: config (what to generate)
|
|
443
|
+
* - workflow YAML service: refs (how it's addressed at runtime)
|
|
444
|
+
* - useWorkflow actions registry (where it executes)
|
|
445
|
+
*
|
|
446
|
+
* IoC note: This generator emits `import type { CollectionAction } from
|
|
447
|
+
* '@stackwright-pro/workflow'` as a string. The generator package itself has
|
|
448
|
+
* no dependency on @stackwright-pro/workflow — only the generated files do.
|
|
449
|
+
*/
|
|
450
|
+
declare class ActionGenerator {
|
|
451
|
+
private document;
|
|
452
|
+
private resolver;
|
|
453
|
+
private zodGenerator;
|
|
454
|
+
constructor(document: OpenAPIDocument);
|
|
455
|
+
/**
|
|
456
|
+
* Generate the complete actions.ts file content.
|
|
457
|
+
*
|
|
458
|
+
* @param actions - Action configs from stackwright.yml
|
|
459
|
+
* @param integrationName - Used in the file header comment
|
|
460
|
+
* @param clientClassName - Name of the generated API client class to import
|
|
461
|
+
* @returns Complete TypeScript source for actions.ts
|
|
462
|
+
*/
|
|
463
|
+
generate(actions: ActionConfig[], integrationName: string, clientClassName: string): string;
|
|
464
|
+
private processAction;
|
|
465
|
+
private generateHeader;
|
|
466
|
+
private generateImports;
|
|
467
|
+
private generateInlineSchemas;
|
|
468
|
+
private generateActionExports;
|
|
469
|
+
private generateRegistry;
|
|
470
|
+
private generateEmptyFile;
|
|
471
|
+
/** Derives the client method name from endpoint + method (best-effort) */
|
|
472
|
+
private endpointToClientMethod;
|
|
473
|
+
private toCamelCase;
|
|
474
|
+
private toPascalCase;
|
|
475
|
+
private capitalize;
|
|
476
|
+
}
|
|
477
|
+
|
|
380
478
|
/**
|
|
381
479
|
* Mapping of operationId to schema names
|
|
382
480
|
*/
|
|
@@ -685,6 +783,7 @@ declare class OpenAPIPlugin implements PrebuildPlugin {
|
|
|
685
783
|
private generateSchemas;
|
|
686
784
|
private generateTypes;
|
|
687
785
|
private generateProvider;
|
|
786
|
+
private generateActions;
|
|
688
787
|
private generateClient;
|
|
689
788
|
private extractComponentName;
|
|
690
789
|
private getOperationTypeName;
|
|
@@ -954,4 +1053,4 @@ declare class ApprovedSpecsValidator {
|
|
|
954
1053
|
clearCache(): void;
|
|
955
1054
|
}
|
|
956
1055
|
|
|
957
|
-
export { type ApprovedSpec, ApprovedSpecsValidator, type ClientGenerationOptions, ClientGenerator, type CollectionConfig, CollectionProviderGenerator, EndpointFilter, type OpenAPICompilationResult, type OpenAPIConfig, type OpenAPIDocument, OpenAPIParser, OpenAPIPlugin, type OpenAPISourceConfig, type ParseOptions, type ParseResult, type PrebuildSecurityConfig, type ProviderGenerationOptions, type SchemaMapping, SchemaResolver, type SiteConfig, type TypeGenerationOptions, TypeGenerator, type ValidationResult, type ZodGenerationOptions, ZodSchemaGenerator, createOpenAPIFetcher, createOpenAPIPlugin, isUrlSafe, validateUrlSafe };
|
|
1056
|
+
export { type ActionConfig, ActionGenerator, type ApprovedSpec, ApprovedSpecsValidator, type ClientGenerationOptions, ClientGenerator, type CollectionConfig, CollectionProviderGenerator, EndpointFilter, type OpenAPICompilationResult, type OpenAPIConfig, type OpenAPIDocument, OpenAPIParser, OpenAPIPlugin, type OpenAPISourceConfig, type ParseOptions, type ParseResult, type PrebuildSecurityConfig, type ProviderGenerationOptions, type SchemaMapping, SchemaResolver, type SiteConfig, type TypeGenerationOptions, TypeGenerator, type ValidationResult, type ZodGenerationOptions, ZodSchemaGenerator, createOpenAPIFetcher, createOpenAPIPlugin, isUrlSafe, validateUrlSafe };
|