@webority/api-contract 0.155.1 → 0.156.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/dist/call.js +1 -1
- package/dist/gaps.js +2 -2
- package/dist/types/call.d.ts +1 -1
- package/dist/types/model.d.ts +1 -1
- package/package.json +2 -2
package/dist/call.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=class extends Error{constructor(e){super(e),this.name=`ContractCallError`}},t=/\{([^{}]+)\}/g;function n(n,
|
|
1
|
+
var e=class extends Error{constructor(e){super(e),this.name=`ContractCallError`}},t=/\{([^{}]+)\}/g,n=e=>e instanceof Date?encodeURIComponent(e.toISOString()):encodeURIComponent(typeof e==`object`?JSON.stringify(e):String(e));function r(e){let t=[];for(let[r,i]of Object.entries(e??{})){if(i==null)continue;let e=encodeURIComponent(r);for(let r of Array.isArray(i)?i:[i])r!=null&&t.push(`${e}=${n(r)}`)}return t.join(`&`)}function i(n,i){let a=n.path.replace(t,(t,r)=>{let a=i.path?.[r],o=a===void 0?``:String(a);if(o===``)throw new e(`${n.method} ${n.path} needs a non-empty path value for "${r}"`);if(o===`.`||o===`..`)throw new e(`${n.method} ${n.path} needs a path value for "${r}" other than "." or ".."`);return encodeURIComponent(o)}),o=r(i.query);return{method:n.method,url:o===``?a:`${a}?${o}`,headers:i.headers,data:i.body,responseType:n.replyKind===`blob`?`blob`:`json`}}export{e as ContractCallError,i as buildContractRequest};
|
package/dist/gaps.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=[`operationWithoutId`,`
|
|
2
|
-
`)}function
|
|
1
|
+
var e=[`operationWithoutId`,`bodyWithoutShape`,`parameterWithoutShape`,`hubValueWithoutShape`,`replyWithoutSchema`,`emptySchema`,`notGenerated`],t={operationWithoutId:`operations with no id`,bodyWithoutShape:`request bodies with no shape`,parameterWithoutShape:`parameters with no shape`,hubValueWithoutShape:`hub values with no shape`,replyWithoutSchema:`replies with no shape`,emptySchema:`empty schemas`,notGenerated:`parts of the contract not generated`},n=3;function r(e){return[...o(e.operations),...s(e.operations),...c(e.operations),...l(e.hubs),...u(e.operations),...d(e.schemas),...e.leftOut.map(e=>({kind:`notGenerated`,where:e}))]}function i(r){let i=[];for(let a of e){let e=r.filter(e=>e.kind===a).map(e=>e.where);if(e.length===0)continue;let o=e.slice(0,n).join(`, `),s=e.length>n?` and ${e.length-n} more`:``;i.push(`${e.length} ${t[a]}: ${o}${s}`)}return i.join(`
|
|
2
|
+
`)}function a(e){return e.id===``?`${e.method} ${e.path}`:e.id}function o(e){return e.filter(e=>e.id===``).map(e=>({kind:`operationWithoutId`,where:`${e.method} ${e.path}`}))}function s(e){return e.filter(e=>e.body!==null&&e.body.schema===null).map(e=>({kind:`bodyWithoutShape`,where:a(e)}))}function c(e){let t=[];for(let n of e)for(let e of n.parameters)Object.keys(e.schema).length===0&&t.push({kind:`parameterWithoutShape`,where:`${a(n)} ${e.place} ${e.name}`});return t}function l(e){let t=[];for(let n of e)for(let e of[...n.methods,...n.events]){let r=`${n.name}.${e.name}`;for(let n of e.parameters)Object.keys(n.schema).length===0&&t.push({kind:`hubValueWithoutShape`,where:`${r}(${n.name})`});e.result!==null&&Object.keys(e.result).length===0&&t.push({kind:`hubValueWithoutShape`,where:`${r} result`})}return t}function u(e){let t=[];for(let n of e)for(let e of n.replies)e.status.startsWith(`2`)&&e.status!==`200`&&e.status!==`202`&&e.status!==`204`&&e.schema===null&&t.push({kind:`replyWithoutSchema`,where:`${a(n)} ${e.status}`});return t}function d(e){let t=[];for(let[n,r]of e)Object.keys(r).length===0&&t.push({kind:`emptySchema`,where:n});return t}export{r as findGaps,i as formatGaps};
|
package/dist/types/call.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export interface OperationShape {
|
|
|
15
15
|
}
|
|
16
16
|
export interface ContractRequest {
|
|
17
17
|
readonly method: OperationEntry["method"];
|
|
18
|
+
/** The path with its values filled in, and the query string when the request has one. */
|
|
18
19
|
readonly url: string;
|
|
19
|
-
readonly params: Readonly<Record<string, unknown>> | undefined;
|
|
20
20
|
readonly headers: Readonly<Record<string, string>> | undefined;
|
|
21
21
|
readonly data: unknown;
|
|
22
22
|
readonly responseType: "json" | "blob";
|
package/dist/types/model.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface Contract {
|
|
|
69
69
|
readonly hubs: readonly Hub[];
|
|
70
70
|
readonly leftOut: readonly string[];
|
|
71
71
|
}
|
|
72
|
-
export type GapKind = "
|
|
72
|
+
export type GapKind = "bodyWithoutShape" | "parameterWithoutShape" | "replyWithoutSchema" | "emptySchema" | "operationWithoutId" | "notGenerated" | "hubValueWithoutShape";
|
|
73
73
|
export interface Gap {
|
|
74
74
|
readonly kind: GapKind;
|
|
75
75
|
readonly where: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/api-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.156.0",
|
|
4
4
|
"description": "Generates one TypeScript file of API types from a backend OpenAPI 3.0, 3.1 or 3.2 contract, as plain text, with no runtime dependencies.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "25.6.0",
|
|
30
|
-
"@webority/biome-config": "0.
|
|
30
|
+
"@webority/biome-config": "0.156.0",
|
|
31
31
|
"typescript": "^7.0.2",
|
|
32
32
|
"vite": "^8.3.6",
|
|
33
33
|
"vitest": "5.1.0"
|