@porulle/core 0.18.0 → 0.19.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.
|
@@ -67,6 +67,7 @@ declare class RouteChain {
|
|
|
67
67
|
private _input;
|
|
68
68
|
private _query;
|
|
69
69
|
private _params;
|
|
70
|
+
private _output;
|
|
70
71
|
private _requireAuth;
|
|
71
72
|
private _requiredPermission;
|
|
72
73
|
constructor(method: string, fullPath: string, tag: string, routesList: PluginRouteRegistration[], pluginCtx?: {
|
|
@@ -84,6 +85,26 @@ declare class RouteChain {
|
|
|
84
85
|
query(schema: z.ZodType): this;
|
|
85
86
|
/** Override the auto-detected path parameter schema. */
|
|
86
87
|
params(schema: z.ZodType): this;
|
|
88
|
+
/**
|
|
89
|
+
* Declare the shape carried inside the `{ data }` envelope on success.
|
|
90
|
+
*
|
|
91
|
+
* Without it the route documents its payload as `any`, and every generated
|
|
92
|
+
* client sees `data?: unknown` — so a consumer has to hand-maintain a
|
|
93
|
+
* parallel schema, which is the drift the generated SDK exists to prevent.
|
|
94
|
+
*
|
|
95
|
+
* Documentation only: the handler's return value is not validated against
|
|
96
|
+
* this schema. Validating would mean either stripping unknown keys — silently
|
|
97
|
+
* changing what goes over the wire for anyone who adopts it — or throwing at
|
|
98
|
+
* runtime, turning an OpenAPI annotation into a new failure mode. A stale
|
|
99
|
+
* annotation is the cheaper wrong.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* vendors.get("/{id}").summary("Get").output(VendorSchema)
|
|
104
|
+
* .handler(async ({ params, services }) => services.vendor.get(params.id));
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
output(schema: z.ZodType): this;
|
|
87
108
|
/**
|
|
88
109
|
* Require authentication. The handler's `actor` is guaranteed non-null.
|
|
89
110
|
* Returns 401 if the request has no authenticated actor.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/interfaces/rest/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAwB/E,MAAM,WAAW,mBAAmB;IAClC,mFAAmF;IACnF,KAAK,EAAE,OAAO,CAAC;IACf,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,uFAAuF;IACvF,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/H,4FAA4F;IAC5F,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,gCAAgC;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,GAAG,EAAE,OAAO,CAAC;CACd;AAID,cAAM,UAAU;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/interfaces/rest/router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAe,CAAC,EAAE,MAA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AAM,EAAE,OAAO,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE;YAAE,EAAE,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE;IAiBzG,0EAA0E;IAC1E,IAAI,aAAa;iBAvBc,cAAc;kBAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;YAAM,OAAO;kBAuB9C;IAE/C,OAAO,CAAC,WAAW;IAMnB,GAAG,CAAC,IAAI,EAAE,MAAM;IAChB,IAAI,CAAC,IAAI,EAAE,MAAM;IACjB,KAAK,CAAC,IAAI,EAAE,MAAM;IAClB,MAAM,CAAC,IAAI,EAAE,MAAM;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM;IAEhB,iEAAiE;IACjE,MAAM,IAAI,uBAAuB,EAAE;CACpC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAAG,UAAU,CAEjK"}
|
|
@@ -56,6 +56,7 @@ class RouteChain {
|
|
|
56
56
|
_input;
|
|
57
57
|
_query;
|
|
58
58
|
_params;
|
|
59
|
+
_output;
|
|
59
60
|
_requireAuth = false;
|
|
60
61
|
_requiredPermission;
|
|
61
62
|
constructor(method, fullPath, tag, routesList, pluginCtx) {
|
|
@@ -79,6 +80,26 @@ class RouteChain {
|
|
|
79
80
|
query(schema) { this._query = schema; return this; }
|
|
80
81
|
/** Override the auto-detected path parameter schema. */
|
|
81
82
|
params(schema) { this._params = schema; return this; }
|
|
83
|
+
/**
|
|
84
|
+
* Declare the shape carried inside the `{ data }` envelope on success.
|
|
85
|
+
*
|
|
86
|
+
* Without it the route documents its payload as `any`, and every generated
|
|
87
|
+
* client sees `data?: unknown` — so a consumer has to hand-maintain a
|
|
88
|
+
* parallel schema, which is the drift the generated SDK exists to prevent.
|
|
89
|
+
*
|
|
90
|
+
* Documentation only: the handler's return value is not validated against
|
|
91
|
+
* this schema. Validating would mean either stripping unknown keys — silently
|
|
92
|
+
* changing what goes over the wire for anyone who adopts it — or throwing at
|
|
93
|
+
* runtime, turning an OpenAPI annotation into a new failure mode. A stale
|
|
94
|
+
* annotation is the cheaper wrong.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* vendors.get("/{id}").summary("Get").output(VendorSchema)
|
|
99
|
+
* .handler(async ({ params, services }) => services.vendor.get(params.id));
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
output(schema) { this._output = schema; return this; }
|
|
82
103
|
/**
|
|
83
104
|
* Require authentication. The handler's `actor` is guaranteed non-null.
|
|
84
105
|
* Returns 401 if the request has no authenticated actor.
|
|
@@ -126,7 +147,7 @@ class RouteChain {
|
|
|
126
147
|
...(this._description ? { description: this._description } : {}),
|
|
127
148
|
...(Object.keys(request).length > 0 ? { request } : {}),
|
|
128
149
|
responses: {
|
|
129
|
-
[status]: wrapJson(z.object({ data: z.any() })),
|
|
150
|
+
[status]: wrapJson(z.object({ data: this._output ?? z.any() })),
|
|
130
151
|
...errorResponses,
|
|
131
152
|
},
|
|
132
153
|
});
|
package/package.json
CHANGED
|
@@ -85,6 +85,7 @@ class RouteChain {
|
|
|
85
85
|
private _input: z.ZodType | undefined;
|
|
86
86
|
private _query: z.ZodType | undefined;
|
|
87
87
|
private _params: z.ZodType | undefined;
|
|
88
|
+
private _output: z.ZodType | undefined;
|
|
88
89
|
private _requireAuth = false;
|
|
89
90
|
private _requiredPermission: string | undefined;
|
|
90
91
|
constructor(
|
|
@@ -117,6 +118,27 @@ class RouteChain {
|
|
|
117
118
|
/** Override the auto-detected path parameter schema. */
|
|
118
119
|
params(schema: z.ZodType) { this._params = schema; return this; }
|
|
119
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Declare the shape carried inside the `{ data }` envelope on success.
|
|
123
|
+
*
|
|
124
|
+
* Without it the route documents its payload as `any`, and every generated
|
|
125
|
+
* client sees `data?: unknown` — so a consumer has to hand-maintain a
|
|
126
|
+
* parallel schema, which is the drift the generated SDK exists to prevent.
|
|
127
|
+
*
|
|
128
|
+
* Documentation only: the handler's return value is not validated against
|
|
129
|
+
* this schema. Validating would mean either stripping unknown keys — silently
|
|
130
|
+
* changing what goes over the wire for anyone who adopts it — or throwing at
|
|
131
|
+
* runtime, turning an OpenAPI annotation into a new failure mode. A stale
|
|
132
|
+
* annotation is the cheaper wrong.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* vendors.get("/{id}").summary("Get").output(VendorSchema)
|
|
137
|
+
* .handler(async ({ params, services }) => services.vendor.get(params.id));
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
output(schema: z.ZodType) { this._output = schema; return this; }
|
|
141
|
+
|
|
120
142
|
/**
|
|
121
143
|
* Require authentication. The handler's `actor` is guaranteed non-null.
|
|
122
144
|
* Returns 401 if the request has no authenticated actor.
|
|
@@ -165,7 +187,7 @@ class RouteChain {
|
|
|
165
187
|
...(this._description ? { description: this._description } : {}),
|
|
166
188
|
...(Object.keys(request).length > 0 ? { request } : {}),
|
|
167
189
|
responses: {
|
|
168
|
-
[status]: wrapJson(z.object({ data: z.any() })),
|
|
190
|
+
[status]: wrapJson(z.object({ data: this._output ?? z.any() })),
|
|
169
191
|
...errorResponses,
|
|
170
192
|
},
|
|
171
193
|
});
|