@webority/api-contract 0.0.0-stage → 0.151.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 +9 -0
- package/README.md +96 -2
- package/dist/bin.js +2 -0
- package/dist/call.js +1 -0
- package/dist/cli.js +2 -0
- package/dist/emitFile.js +7 -0
- package/dist/emitHubs.js +3 -0
- package/dist/emitSchema.js +3 -0
- package/dist/gaps.js +2 -0
- package/dist/index.js +1 -0
- package/dist/load.js +1 -0
- package/dist/model.js +1 -0
- package/dist/names.js +2 -0
- package/dist/types/bin.d.ts +2 -0
- package/dist/types/call.d.ts +27 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/emitFile.d.ts +2 -0
- package/dist/types/emitHubs.d.ts +2 -0
- package/dist/types/emitSchema.d.ts +7 -0
- package/dist/types/gaps.d.ts +3 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/load.d.ts +2 -0
- package/dist/types/model.d.ts +89 -0
- package/dist/types/names.d.ts +4 -0
- package/package.json +37 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Copyright (c) Webority Technologies. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and its NuGet packages are the proprietary and confidential property
|
|
4
|
+
of Webority Technologies. They are published publicly only for the convenience of
|
|
5
|
+
Webority's own projects and internal consumption.
|
|
6
|
+
|
|
7
|
+
No license or right to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
or create derivative works is granted to any third party. Unauthorized use,
|
|
9
|
+
reproduction, or distribution is prohibited.
|
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @webority/api-contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generates one TypeScript file of API types from a backend OpenAPI contract (3.0.x, 3.1.x or 3.2.x), written as plain text with no runtime dependencies.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add -D -E @webority/api-contract
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Generate
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
webority-api-contract generate <contract.json> --out <file.ts> [--check] [--strict]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- `<contract.json>`: the OpenAPI JSON document from the backend, version 3.0.x, 3.1.x or 3.2.x. Any other version is refused with exit 2, naming the version found.
|
|
18
|
+
- `--out <file.ts>`: the TypeScript file to write.
|
|
19
|
+
- `--check`: writes nothing. Exits 1 when the file on disk differs from what the contract generates, so a CI step can catch a stale file.
|
|
20
|
+
- `--strict`: writes nothing. Exits 1 when the contract has gaps that loosen the types or parts the generator left out, and prints them; fix them in the backend.
|
|
21
|
+
|
|
22
|
+
Exit codes: 0 when the file is written or matches, 1 for a failed `--check` or `--strict`, 2 for a bad contract or a usage error.
|
|
23
|
+
|
|
24
|
+
A component schema that is a string enum (a list of strings, with no null member and no other keyword that changes its type) is written as a const object of its members and the type of their values. A nullable string enum, and a number or boolean enum, stay a union of literals. A member that is not a plain identifier gets a quoted key:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export const PetStatus = { available: 'available', 'on-hold': 'on-hold' } as const;
|
|
28
|
+
export type PetStatus = (typeof PetStatus)[keyof typeof PetStatus];
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Each entry of the `operations` object carries a `replyKind` field that tells the client how to read the reply: `'json'` for a JSON reply, `'blob'` for a file (the response type is `Blob`), and `'none'` for no body (the response type is `void`). The client reads it to choose the response type of the call:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
export const operations = {
|
|
35
|
+
getPet: { method: 'GET', path: '/pets/{petId}', replyKind: 'json' },
|
|
36
|
+
downloadPhoto: { method: 'GET', path: '/pets/{petId}/photo', replyKind: 'blob' },
|
|
37
|
+
clearCache: { method: 'DELETE', path: '/cache', replyKind: 'none' },
|
|
38
|
+
} as const;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## OpenAPI versions
|
|
42
|
+
|
|
43
|
+
The same contract written for 3.0, 3.1 and 3.2 gives the same file where the meaning is the same.
|
|
44
|
+
|
|
45
|
+
Read in every version:
|
|
46
|
+
|
|
47
|
+
- `nullable: true` (3.0) and `type: ["string", "null"]` or `type: "null"` (3.1 and later). A schema that is nullable both ways still gets one `| null`.
|
|
48
|
+
- `const`, as one literal type.
|
|
49
|
+
- `$ref` with sibling keywords: the reference still names the type, and a sibling `type` list or `oneOf` / `anyOf` with a null member makes it nullable.
|
|
50
|
+
- `prefixItems` with `items` as a tuple. A position at or after `minItems` is optional; `items: false` or `maxItems` equal to the number of positions closes the tuple.
|
|
51
|
+
- `unevaluatedProperties` and `patternProperties`, written as a record. A record cannot name a key pattern, so its value type is the union of the pattern value types.
|
|
52
|
+
- File content: `format: binary` (3.0), `contentMediaType` with no `type` (3.1 and later) and a file body or reply with no schema or an empty schema, all as `Blob`. A body or reply of type `application/octet-stream`, `application/pdf`, `application/zip`, `application/gzip` or `image/*`, `audio/*`, `video/*` with no schema counts as a file in 3.1 and 3.2.
|
|
53
|
+
- `$defs` of a component schema, and local `$ref`s to them such as `#/components/schemas/Pet/$defs/Tag`: each entry becomes its own named type.
|
|
54
|
+
- `paths` is optional from 3.1: a document with none has no operations.
|
|
55
|
+
- A path item that is a `$ref` to `#/components/pathItems/<name>` (3.1 and later).
|
|
56
|
+
- 3.2: the `query` method as an operation with method `QUERY`; `itemSchema` of a sequential media type (`application/jsonl`, `text/event-stream`, `multipart/mixed` and the like), written as a `readonly` array of the item type; a media type entry that is a `$ref` to `#/components/mediaTypes/<name>`.
|
|
57
|
+
|
|
58
|
+
## Hubs
|
|
59
|
+
|
|
60
|
+
The backend lists its SignalR hubs in the contract under the root key `x-webority-hubs`. The head writes that key when it registers each hub with `AddHub<THub>()` (Webority.Delivery.OpenApi). The generator reads it, and a contract without the key generates no hub types.
|
|
61
|
+
|
|
62
|
+
For each hub `X` the file gets:
|
|
63
|
+
|
|
64
|
+
- `X`: a const listing the method and event names.
|
|
65
|
+
- `XMethod` and `XEvent`: the method names and the event names as types.
|
|
66
|
+
- `XMethods` and `XEvents`: each name's argument tuple and result.
|
|
67
|
+
- `XInvoke` and `XOn`: the function types for calling a method and for subscribing to an event.
|
|
68
|
+
|
|
69
|
+
A side with no members gets no `Invoke` or `On` type.
|
|
70
|
+
|
|
71
|
+
Bind the two functions once per connection, then call the hub. This example is for a hub named `ChatHub`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const invoke: ChatHubInvoke = (method, ...args) => connection.invoke(method, ...args);
|
|
75
|
+
const on: ChatHubOn = (event, handler) => connection.on(event, handler);
|
|
76
|
+
|
|
77
|
+
// A wrong argument type fails the TypeScript build.
|
|
78
|
+
await invoke("Send", message);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`--strict` also reports a hub argument or result with no shape as "hub values with no shape".
|
|
82
|
+
|
|
83
|
+
## What is not generated
|
|
84
|
+
|
|
85
|
+
Webhooks (`webhooks`) are not generated. They describe calls the backend makes, not operations a client sends.
|
|
86
|
+
|
|
87
|
+
These 3.2 parts are read but left out, and `--strict` and the gap report name each one:
|
|
88
|
+
|
|
89
|
+
- `additionalOperations` on a path item (methods with no field of their own, such as `COPY`).
|
|
90
|
+
- A parameter with `in: querystring`.
|
|
91
|
+
|
|
92
|
+
These are left out with no report:
|
|
93
|
+
|
|
94
|
+
- `$anchor` and `$dynamicRef` references, and a `$ref` that points into a schema at any place other than `#/components/schemas/<name>` or a `$defs` path under it, or to another file. Each gives `unknown`.
|
|
95
|
+
- `$defs` inside a nested schema (a property, an item or a union member): only the `$defs` of a component schema, and of another `$defs` entry, become types.
|
|
96
|
+
- `if` / `then` / `else`, `not`, `dependentSchemas` and `discriminator`: the type is the wider one without them.
|
|
97
|
+
- Operations with the methods `head`, `options` and `trace`, and parameters in a cookie.
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{run as e}from"./cli.js";import{readFile as t,writeFile as n}from"node:fs/promises";e(process.argv.slice(2),{readText:e=>t(e,`utf8`),writeText:(e,t)=>n(e,t,`utf8`),out:e=>{process.stdout.write(`${e}\n`)},err:e=>{process.stderr.write(`${e}\n`)}}).then(e=>{process.exitCode=e},e=>{process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`),process.exitCode=2});
|
package/dist/call.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e){super(e),this.name=`ContractCallError`}},t=/\{([^{}]+)\}/g;function n(n,r){let i=n.path.replace(t,(t,i)=>{let a=r.path?.[i],o=a===void 0?``:String(a);if(o===``)throw new e(`${n.method} ${n.path} needs a non-empty path value for "${i}"`);if(o===`.`||o===`..`)throw new e(`${n.method} ${n.path} needs a path value for "${i}" other than "." or ".."`);return encodeURIComponent(o)});return{method:n.method,url:i,params:r.query,headers:r.headers,data:r.body,responseType:n.replyKind===`blob`?`blob`:`json`}}export{e as ContractCallError,n as buildContractRequest};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{emitFile as e}from"./emitFile.js";import{findGaps as t,formatGaps as n}from"./gaps.js";import{loadContract as r}from"./load.js";import{ContractError as i}from"./model.js";import{createHash as a}from"node:crypto";import{basename as o}from"node:path";var s=`usage: webority-api-contract generate <contract.json> --out <file.ts> [--check] [--strict]`,c=`the contract has gaps that loosen the types; fix them in the backend`;async function l(e,t){let[n,...r]=e,i=n===`generate`?u(r):null;return i===null?(t.err(s),2):d(i,t)}function u(e){let t=[],n=[],r=!1,i=!1,a=!1;for(let o of e)if(a){if(o.startsWith(`-`))return null;n.push(o),a=!1}else if(o===`--out`)a=!0;else if(o===`--check`)r=!0;else if(o===`--strict`)i=!0;else if(o.startsWith(`-`))return null;else t.push(o);let[o,...s]=t,[c,...l]=n;return a||o===void 0||c===void 0||s.length>0||l.length>0?null:{contract:o,out:c,check:r,strict:i}}async function d(s,l){let u;try{u=await l.readText(s.contract)}catch(e){return l.err(`cannot read ${s.contract}: ${h(e)}`),2}let d;try{d=r(u)}catch(e){if(!(e instanceof i))throw e;return l.err(e.message),2}let p=t(d);if(s.strict&&p.length>0)return m(l,n(p)),l.err(c),1;let g={name:o(s.contract),sha256:a(`sha256`).update(u).digest(`hex`)},_=e(d,g);if(s.check)return f(s,_,l);try{await l.writeText(s.out,_)}catch(e){return l.err(`cannot write ${s.out}: ${h(e)}`),2}let v=d.operations.filter(e=>e.id!==``).length;return l.out(`wrote ${s.out} (${d.schemas.size} schemas, ${v} operations)`),p.length>0&&m(l,n(p)),0}async function f(e,t,n){return await p(e.out,n)===t?0:(n.err(`${e.out} is out of date with ${e.contract}; run: webority-api-contract generate ${e.contract} --out ${e.out}`),1)}async function p(e,t){try{return await t.readText(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return null;throw e}}function m(e,t){for(let n of t.split(`
|
|
2
|
+
`))e.err(n)}function h(e){return e instanceof Error?e.message:String(e)}export{l as run};
|
package/dist/emitFile.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{emitHubs as e}from"./emitHubs.js";import{emitType as t,literalType as n,stringEnumMembers as r}from"./emitSchema.js";import{propertyKey as i,quote as a,typeName as o,uniqueName as s}from"./names.js";var c=[`Blob`,`FormData`,`Record`,`Readonly`,`OperationId`,`OperationTypes`];function l(t,n){let r=new Set(c),i=/* @__PURE__ */ new Map;for(let e of t.schemas.keys())i.set(e,s(o(e),r));let a=[d(n)];for(let[e,n]of t.schemas)a.push(...u(f(i,e),n,i));let l=t.operations.filter(e=>e.id!==``).map(e=>({operation:e,op:p(o(e.id),r)}));for(let{operation:e,op:t}of l)a.push(m(t,e,i)),a.push(v(t,e,i));return a.push(x(l,i)),a.push(`export type OperationId = keyof typeof operations;`),a.push(S(l)),a.push(...e(t.hubs,i,r)),`${a.join(`
|
|
2
|
+
|
|
3
|
+
`)}\n`}function u(e,a,o){let s=r(a);return s===void 0?[`export type ${e} = ${t(a,o,0)};`]:[`export const ${e} = { ${s.map(e=>`${i(e)}: ${n(e)}`).join(`, `)} } as const;`,`export type ${e} = (typeof ${e})[keyof typeof ${e}];`]}function d(e){return`// Generated by @webority/api-contract from ${e.name} (sha256 ${e.sha256}). Do not edit: change the backend contract and generate again.`}function f(e,t){let n=e.get(t);if(n===void 0)throw Error(`no type name was made for schema ${t}`);return n}function p(e,t){for(let n=1;;n+=1){let r=n===1?e:`${e}${n}`,i=`${r}Request`,a=`${r}Response`;if(!t.has(r)&&!t.has(i)&&!t.has(a))return t.add(r),t.add(i),t.add(a),r}}function m(e,t,n){let r=t.parameters.filter(e=>e.place===`path`),i=t.parameters.filter(e=>e.place===`query`),a=t.parameters.filter(e=>e.place===`header`),o=[];return r.length>0&&o.push(h(`path`,r,!1,n)),i.length>0&&o.push(h(`query`,i,!i.some(e=>e.required),n)),a.length>0&&o.push(h(`headers`,a,!a.some(e=>e.required),n)),t.body!==null&&o.push(g(t.body,n)),o.length===0?`export type ${e}Request = Readonly<Record<string, never>>;`:`export type ${e}Request = {\n${o.join(`
|
|
4
|
+
`)}\n};`}function h(e,n,r,a){let o=n.map(e=>` readonly ${i(e.name)}${e.required?``:`?`}: ${t(e.schema,a,2)};`);return[` readonly ${e}${r?`?`:``}: {`,...o,` };`].join(`
|
|
5
|
+
`)}function g(e,t){let n=_(e,t);return` readonly body${e.required?``:`?`}: ${n};`}function _(e,n){return e.contentType===`multipart/form-data`?`FormData`:e.schema===null?`unknown`:t(e.schema,n,1)}function v(e,t,n){return`export type ${e}Response = ${y(t,n)};`}function y(e,n){let r=[];for(let i of e.replies){if(!i.status.startsWith(`2`))continue;let e=i.schema===null?`void`:t(i.schema,n,0);r.includes(e)||r.push(e)}return r.length>0?r.join(` | `):`void`}function b(e,t){let n=y(e,t);return n===`Blob`?`blob`:n===`void`?`none`:`json`}function x(e,t){return e.length===0?`export const operations = {} as const;`:[`export const operations = {`,...e.map(({operation:e})=>{let n=b(e,t),r=`{ method: ${a(e.method)}, path: ${a(e.path)}, replyKind: ${a(n)} }`;return` ${i(e.id)}: ${r},`}),`} as const;`].join(`
|
|
6
|
+
`)}function S(e){return e.length===0?`export interface OperationTypes {}`:[`export interface OperationTypes {`,...e.map(({operation:e,op:t})=>` readonly ${i(e.id)}: { readonly request: ${t}Request; readonly response: ${t}Response };`),`}`].join(`
|
|
7
|
+
`)}export{l as emitFile};
|
package/dist/emitHubs.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{emitType as e}from"./emitSchema.js";import{propertyKey as t,quote as n,typeName as r}from"./names.js";var i=[`Method`,`Event`,`Methods`,`Events`,`Invoke`,`On`],a=/^[A-Za-z_$][A-Za-z0-9_$]*$/,o=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield`.split(`.`));function s(e,t,n){let i=[],a=[...e].sort((e,t)=>g(e.name,t.name));for(let e of a){let a=c(r(e.name),n);i.push(...l(a,e,t))}return i}function c(e,t){for(let n=1;;n+=1){let r=n===1?e:`${e}${n}`,a=[r,...i.map(e=>`${r}${e}`)];if(a.every(e=>!t.has(e))){for(let e of a)t.add(e);return r}}}function l(t,n,r){let i=h(n.methods),a=h(n.events),o=[u(t,i,a),`export type ${t}Method = keyof typeof ${t}.methods;`,`export type ${t}Event = keyof typeof ${t}.events;`,f(`${t}Methods`,i,t=>t.result===null?`void`:e(t.result,r,2),r),f(`${t}Events`,a,()=>`void`,r)];return i.length>0&&o.push(`export type ${t}Invoke = <K extends ${t}Method>(method: K, ...args: ${t}Methods[K]['args']) => Promise<${t}Methods[K]['result']>;`),a.length>0&&o.push(`export type ${t}On = <K extends ${t}Event>(event: K, handler: (...args: ${t}Events[K]['args']) => void) => void;`),o}function u(e,t,n){return[`export const ${e} = {`,` methods: ${d(t)},`,` events: ${d(n)},`,`} as const;`].join(`
|
|
2
|
+
`)}function d(e){return e.length===0?`{}`:`{ ${e.map(e=>`${t(e.name)}: ${n(e.name)}`).join(`, `)} }`}function f(e,n,r,i){if(n.length===0)return`export interface ${e} {}`;let a=n.map(e=>` readonly ${t(e.name)}: { readonly args: readonly [${p(e.parameters,i)}]; readonly result: ${r(e)} };`);return[`export interface ${e} {`,...a,`}`].join(`
|
|
3
|
+
`)}function p(t,n){return t.map((t,r)=>`${m(t.name,r)}: ${e(t.schema,n,2)}`).join(`, `)}function m(e,t){return a.test(e)&&!o.has(e)?e:`arg${t}`}function h(e){return[...e].sort((e,t)=>g(e.name,t.name))}function g(e,t){return e<t?-1:+(e>t)}export{s as emitHubs};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{propertyKey as e}from"./names.js";var t=`#/components/schemas/`,n=/* @__PURE__ */ new Map([[`\\`,`\\\\`],[`'`,`\\'`],[`
|
|
2
|
+
`,`\\n`],[`\r`,`\\r`],[`\u2028`,`\\u2028`],[`\u2029`,`\\u2029`]]),r=/[\\'\n\r\u2028\u2029]/g,i=`readonly [`;function a(e,t,n){let r=o(e,t,n);return!A(e)||N(e)?r:O(e)===`intersection`?`(${r}) | null`:`${r} | null`}function o(e,t,n){if(e.$ref!==void 0)return s(e.$ref,t);let r=k(e);if(r!==void 0)return u(r);if(e.enum!==void 0)return c(e.enum);if(e.allOf!==void 0)return f(e.allOf,t,n);let i=E(e);return i===void 0?p(e,t,n):i.length===0?`never`:i.map(e=>a(e,t,n)).join(` | `)}function s(e,n){return e.startsWith(t)?n.get(e.slice(21))??`unknown`:`unknown`}function c(e){return e.length===0?`never`:e.map(u).join(` | `)}function l(e){if(e.$ref!==void 0||e.const!==void 0||e.allOf!==void 0||E(e)!==void 0||e.nullable===!0||e.type!==void 0&&e.type!==`string`)return;let t=e.enum;if(t===void 0||t.length===0)return;let n=[];for(let e of t){if(typeof e!=`string`)return;n.push(e)}return[...new Set(n)]}function u(e){return e===null?`null`:typeof e==`string`?`'${e.replace(r,d)}'`:String(e)}function d(e){return n.get(e)??e}function f(e,t,n){let[r,...i]=e;return r===void 0?`unknown`:i.length===0?a(r,t,n):e.map(e=>{let r=a(e,t,n);return D(e)===`union`?`(${r})`:r}).join(` & `)}function p(e,t,n){let r=g(e);return r.length>0?r.map(r=>m(r,e,t,n)).join(` | `):h(e).length>0?`null`:e.contentMediaType!==void 0&&e.contentEncoding===void 0?`Blob`:C(e)?b(e,t,n):`unknown`}function m(e,t,n,r){return e===`string`?t.format===`binary`?`Blob`:`string`:e===`integer`||e===`number`?`number`:e===`boolean`?`boolean`:e===`array`?_(t,n,r):e===`object`?b(t,n,r):`unknown`}function h(e){let t=e.type;return t===void 0?[]:typeof t==`string`?[t]:t}function g(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of h(e)){let e=r===`integer`?`number`:r;r!==`null`&&!t.has(e)&&(t.add(e),n.push(r))}return n}function _(e,t,n){let r=e.prefixItems??[];if(r.length>0)return v(e,r,t,n);let o=e.items;if(o===void 0||o===!0)return`readonly unknown[]`;if(o===!1)return`readonly never[]`;let s=a(o,t,n);return D(o)===`plain`&&!s.startsWith(i)?`readonly ${s}[]`:`readonly (${s})[]`}function v(e,t,n,r){let i=e.minItems??t.length,o=t.map((e,t)=>{let o=a(e,n,r);return t<i?o:D(e)===`plain`?`${o}?`:`(${o})?`}),s=y(e,t.length,n,r);return`readonly [${(s===void 0?o:[...o,s]).join(`, `)}]`}function y(e,t,n,r){let i=e.items;if(i===!1)return;if(i===void 0)return e.maxItems!==void 0&&e.maxItems<=t?void 0:`...unknown[]`;if(i===!0)return`...unknown[]`;let o=a(i,n,r);return D(i)===`plain`&&!o.startsWith(`readonly `)?`...${o}[]`:`...(${o})[]`}function b(t,n,r){let i=t.properties??{},o=Object.entries(i),s=x(t,n,r);if(o.length===0)return`Readonly<Record<string, ${s??`unknown`}>>`;let c=new Set(t.required??[]),l=`{\n${o.map(([t,i])=>{let o=c.has(t)?``:`?`;return`${F(r+1)}readonly ${e(t)}${o}: ${a(i,n,r+1)};`}).join(`
|
|
3
|
+
`)}\n${F(r)}}`;return s===void 0?l:`${l} & Readonly<Record<string, ${s}>>`}function x(e,t,n){let r=S(e),i=[];r===!0?i.push(`unknown`):r!==void 0&&r!==!1&&i.push(a(r,t,n));for(let r of Object.values(e.patternProperties??{}))i.push(a(r,t,n));if(i.length!==0)return i.includes(`unknown`)?`unknown`:[...new Set(i)].join(` | `)}function S(e){return e.additionalProperties??e.unevaluatedProperties}function C(e){return g(e).includes(`object`)?!0:h(e).length===0&&(w(e)||T(e))}function w(e){return Object.keys(e.properties??{}).length>0}function T(e){let t=S(e);return t===!0||typeof t==`object`||Object.keys(e.patternProperties??{}).length>0}function E(e){return e.oneOf??e.anyOf}function D(e){return A(e)&&!N(e)?`union`:O(e)}function O(e){if(e.$ref!==void 0||k(e)!==void 0)return`plain`;if(e.enum!==void 0)return e.enum.length>1?`union`:`plain`;if(e.allOf!==void 0){let[t,...n]=e.allOf;return t===void 0?`plain`:n.length===0?D(t):`intersection`}let t=E(e);if(t!==void 0){let[e,...n]=t;return e===void 0?`plain`:n.length===0?D(e):`union`}return g(e).length>1?`union`:C(e)&&w(e)&&T(e)?`intersection`:`plain`}function k(e){let t=e.const;return t===null||typeof t==`string`||typeof t==`number`||typeof t==`boolean`?t:void 0}function A(e){return e.nullable===!0||j(e)||M(e)}function j(e){if(!h(e).includes(`null`))return!1;let t=k(e)===void 0&&e.enum===void 0&&e.allOf===void 0&&E(e)===void 0;return e.$ref!==void 0||t}function M(e){return e.$ref!==void 0&&(E(e)?.some(e=>P(e))??!1)}function N(e){if(e.$ref!==void 0)return!1;if(k(e)!==void 0)return e.const===null;if(e.enum!==void 0)return e.enum.includes(null);if(e.allOf!==void 0){let[t,...n]=e.allOf;return t!==void 0&&n.length===0&&P(t)}let t=E(e);return t===void 0?h(e).length>0&&g(e).length===0:t.some(e=>P(e))}function P(e){return A(e)||N(e)}function F(e){return` `.repeat(e)}export{a as emitType,u as literalType,l as stringEnumMembers};
|
package/dist/gaps.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=[`operationWithoutId`,`bodyNotRequired`,`bodyWithoutShape`,`parameterWithoutShape`,`hubValueWithoutShape`,`replyWithoutSchema`,`schemaWithoutRequired`,`emptySchema`,`notGenerated`],t={operationWithoutId:`operations with no id`,bodyNotRequired:`request bodies not marked required`,bodyWithoutShape:`request bodies with no shape`,parameterWithoutShape:`parameters with no shape`,hubValueWithoutShape:`hub values with no shape`,replyWithoutSchema:`replies with no shape`,schemaWithoutRequired:`object schemas with no required list`,emptySchema:`empty schemas`,notGenerated:`parts of the contract not generated`},n=3,r=`#/components/schemas/`;function i(e){return[...s(e.operations),...c(e.operations),...l(e.operations),...u(e.operations),...d(e.hubs),...f(e.operations),...p(e.schemas,m(e)),...v(e.schemas),...e.leftOut.map(e=>({kind:`notGenerated`,where:e}))]}function a(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 o(e){return e.id===``?`${e.method} ${e.path}`:e.id}function s(e){return e.filter(e=>e.id===``).map(e=>({kind:`operationWithoutId`,where:`${e.method} ${e.path}`}))}function c(e){return e.filter(e=>e.body!==null&&!e.body.required).map(e=>({kind:`bodyNotRequired`,where:o(e)}))}function l(e){return e.filter(e=>e.body!==null&&e.body.schema===null).map(e=>({kind:`bodyWithoutShape`,where:o(e)}))}function u(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:`${o(n)} ${e.place} ${e.name}`});return t}function d(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 f(e){let t=[];for(let n of e)for(let e of n.replies)e.status.startsWith(`2`)&&e.status!==`200`&&e.status!==`204`&&e.schema===null&&t.push({kind:`replyWithoutSchema`,where:`${o(n)} ${e.status}`});return t}function p(e,t){let n=[];for(let[r,i]of e)t.has(r)&&i.properties!==void 0&&Object.keys(i.properties).length>0&&i.required===void 0&&n.push({kind:`schemaWithoutRequired`,where:r});return n}function m(e){let t=/* @__PURE__ */ new Set,n=h(e.operations,e.hubs);for(let i=n.pop();i!==void 0;i=n.pop()){if(i.$ref?.startsWith(r)){let r=i.$ref.slice(21),a=e.schemas.get(r);!t.has(r)&&a!==void 0&&(t.add(r),n.push(a))}n.push(...g(i))}return t}function h(e,t){let n=[];for(let t of e)for(let e of t.replies)e.schema!==null&&n.push(e.schema);for(let e of t){for(let t of e.methods)t.result!==null&&n.push(t.result);for(let t of e.events)n.push(...t.parameters.map(e=>e.schema)),t.result!==null&&n.push(t.result)}return n}function g(e){let t=[..._(e.properties),..._(e.patternProperties),...e.prefixItems??[],...e.allOf??[],...e.oneOf??[],...e.anyOf??[]];for(let n of[e.items,e.additionalProperties,e.unevaluatedProperties])typeof n==`object`&&n&&t.push(n);return t}function _(e){return e===void 0?[]:Object.values(e)}function v(e){let t=[];for(let[n,r]of e)Object.keys(r).length===0&&t.push({kind:`emptySchema`,where:n});return t}export{i as findGaps,a as formatGaps};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{emitFile as e}from"./emitFile.js";import{findGaps as t,formatGaps as n}from"./gaps.js";import{loadContract as r}from"./load.js";import{ContractError as i}from"./model.js";export{i as ContractError,e as emitFile,t as findGaps,n as formatGaps,r as loadContract};
|
package/dist/load.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ContractError as e}from"./model.js";var t=[{key:`get`,method:`GET`},{key:`post`,method:`POST`},{key:`put`,method:`PUT`},{key:`patch`,method:`PATCH`},{key:`delete`,method:`DELETE`}],n=[...t,{key:`query`,method:`QUERY`}],r=`application/json`,i=64,a=`3.0.x, 3.1.x and 3.2.x`,o=/^(3\.[012])(?:\.\d+(?:-[0-9A-Za-z.-]+)?)?$/,s=/* @__PURE__ */ new Map([[`3.0`,`3.0`],[`3.1`,`3.1`],[`3.2`,`3.2`]]),c=/^(?:application\/(?:octet-stream|pdf|zip|gzip)|(?:image|audio|video)\/)/,l={type:`string`,format:`binary`},u=[`properties`,`patternProperties`,`$defs`],d=[`allOf`,`oneOf`,`anyOf`,`prefixItems`],f=[`items`,`additionalProperties`,`unevaluatedProperties`];function p(e){let t=K(g(e)),n=m(t),r=h(t,n),i={version:n,components:K(t.components),leftOut:[]},a=_(i),o=y(r,i);return{version:n,title:q(K(t.info).title)??``,schemas:a,operations:o,hubs:b(t),leftOut:i.leftOut}}function m(t){let n=q(t.openapi),r=q(t.swagger);if(n===void 0){let t=r===void 0?`has no openapi version`:`is Swagger ${r}, which is not supported`;throw new e(`contract ${t}: supported versions are ${a}`)}let i=o.exec(n)?.[1],c=i===void 0?void 0:s.get(i);if(c===void 0)throw new e(`contract is OpenAPI ${n}, which is not supported: supported versions are ${a}`);return c}function h(t,n){if(G(t.paths))return t.paths;if(n===`3.0`)throw new e(`contract has no paths`);if(t.paths!==void 0)throw new e(`contract paths is not an object`);return{}}function g(t){try{return JSON.parse(t)}catch(t){let n=t instanceof Error?t.message:`unknown error`;throw new e(`contract is not valid JSON: ${n}`)}}function _(e){let t=/* @__PURE__ */ new Map;for(let[n,r]of Object.entries(K(e.components.schemas))){let i=B(r);t.set(n,i),e.version!==`3.0`&&v(t,n,i,0)}return t}function v(e,t,n,r){if(!(r>=i))for(let[i,a]of Object.entries(K(n.$defs))){let n=B(a),o=`${t}/$defs/${i}`;e.set(o,n),v(e,o,n,r+1)}}function y(e,r){let i=[],a=r.version===`3.2`?n:t;for(let[t,n]of Object.entries(e)){let e=K(E(r,n)),o=j(J(e.parameters),r,t);for(let{key:n,method:s}of a){let a=e[n];G(a)&&i.push(O(t,s,a,o,r))}r.version===`3.2`&&D(t,e,r)}return i}function b(t){let n=t[`x-webority-hubs`];if(n===void 0)return[];if(!G(n))throw new e(`x-webority-hubs is not an object`);return Object.entries(n).map(([e,t])=>x(`x-webority-hubs.${e}`,e,t))}function x(t,n,r){if(!G(r))throw new e(`${t} is not an object`);return{name:n,methods:S(`${t}.methods`,r.methods),events:S(`${t}.events`,r.events)}}function S(t,n){if(n===void 0)return[];if(!G(n))throw new e(`${t} is not an object`);return Object.entries(n).map(([e,n])=>C(`${t}.${e}`,e,n))}function C(t,n,r){if(!G(r))throw new e(`${t} is not an object`);let i=r.parameters;if(!Array.isArray(i))throw new e(`${t} has no parameters array`);return{name:n,parameters:i.map((e,n)=>w(`${t}.parameters[${n}]`,e)),result:r.result===void 0?null:T(`${t}.result`,r.result)}}function w(t,n){if(!G(n))throw new e(`${t} is not an object`);let r=q(n.name);if(r===void 0)throw new e(`${t} has no name`);return{name:r,schema:T(`${t}.schema`,n.schema)}}function T(t,n){if(!G(n))throw new e(`${t} is not an object`);return B(n)}function E(e,t){return e.version===`3.0`?t:R(e.components,`pathItems`,t)}function D(e,t,n){for(let[r,i]of Object.entries(K(t.additionalOperations)))G(i)&&n.leftOut.push(`the ${r} operation of ${e}`)}function O(e,t,n,r,i){return{id:q(n.operationId)??``,method:t,path:e,parameters:k(r,j(J(n.parameters),i,`${t} ${e}`)),body:P(n.requestBody,i),replies:F(n.responses,i)}}function k(e,t){let n=[...e,...t];return n.filter((e,t)=>n.every((n,r)=>r<=t||!A(e,n)))}function A(e,t){return e.name===t.name&&e.place===t.place}function j(e,t,n){let r=[];for(let i of e){let e=R(t.components,`parameters`,i);if(t.version===`3.2`&&G(e)&&e.in===`querystring`){t.leftOut.push(`the querystring parameter of ${n}`);continue}let a=M(e,t,n);a!==void 0&&r.push(a)}return r}function M(t,n,r){if(!G(t))throw new e(`a parameter of ${r} is not an object`);let i=q(t.name);if(i===void 0)throw new e(`a parameter of ${r} has no name`);let a=q(t.in);if(a===void 0)throw new e(`the parameter ${i} of ${r} has no "in"`);let o=N(a);if(o===void 0)n.leftOut.push(`the ${a} parameter ${i} of ${r}`);else return{name:i,place:o,required:o===`path`||t.required===!0,schema:B(t.schema)}}function N(e){if(e===`path`||e===`query`||e===`header`)return e}function P(e,t){let n=R(t.components,`requestBodies`,e);if(!G(n))return null;let r=I(n.content,t);return{required:n.required===!0,contentType:r.contentType,schema:r.schema}}function F(e,t){return Object.entries(K(e)).map(([e,n])=>({status:e,schema:I(K(R(t.components,`responses`,n)).content,t).schema}))}function I(e,t){let n=K(e),i=Object.keys(n),a=i.includes(r)?r:i[0]??``;return{contentType:a,schema:L(a,K(R(t.components,`mediaTypes`,n[a])),t.version)}}function L(e,t,n){let r=G(t.schema)?B(t.schema):null;return n===`3.0`?r:r===null&&n===`3.2`&&G(t.itemSchema)?{type:`array`,items:B(t.itemSchema)}:(r===null||Object.keys(r).length===0)&&c.test(e.trim().toLowerCase())?l:r}function R(t,n,r){let i=K(t[n]),a=/* @__PURE__ */ new Set,o=r;for(;G(o)&&`$ref`in o;){let t=q(o.$ref),r=`#/components/${n}/`,s=t?.startsWith(r)?t.slice(r.length):void 0;if(s===void 0||!Object.hasOwn(i,s))throw new e(`contract has a $ref that does not resolve: ${t??`a $ref that is not a string`}`);if(a.has(s))throw new e(`contract has a $ref cycle: ${[...a,s].join(` -> `)}`);a.add(s),o=i[s]}return o}function z(e){return G(e)}function B(e){return z(e)?(V(K(e),1),e):{}}function V(t,n){if(n>i)throw new e(`a schema is nested more than ${i} levels deep`);U(t.enum);for(let e of u)for(let r of Object.values(K(t[e])))H(r,n);for(let e of d)for(let r of J(t[e]))H(r,n);for(let e of f)H(t[e],n)}function H(e,t){G(e)&&V(e,t+1)}function U(t){if(t!==void 0&&(!Array.isArray(t)||!t.every(W)))throw new e(`a schema enum has a value that is not a string, number, boolean or null`)}function W(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return G(e)?e:{}}function q(e){return typeof e==`string`?e:void 0}function J(e){return Array.isArray(e)?e:[]}export{p as loadContract};
|
package/dist/model.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e){super(e),this.name=`ContractError`}};export{e as ContractError};
|
package/dist/names.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=/[^\p{L}\p{Nd}]+/u,t=/^\p{Nd}/u,n=/^[A-Za-z_$][A-Za-z0-9_$]*$/,r=/* @__PURE__ */ new Map([[`\\`,`\\\\`],[`'`,`\\'`],[`
|
|
2
|
+
`,`\\n`],[`\r`,`\\r`],[`\u2028`,`\\u2028`],[`\u2029`,`\\u2029`]]),i=/[\\'\n\r\u2028\u2029]/g;function a(n){let r=n.split(e).filter(e=>e!==``).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``);return r===``?`Unnamed`:t.test(r)?`_${r}`:r}function o(e,t){let n=e;for(let r=2;t.has(n);r++)n=`${e}${r}`;return t.add(n),n}function s(e){return e===`__proto__`?`[${c(e)}]`:n.test(e)?e:`'${e.replace(i,e=>r.get(e)??e)}'`}function c(e){return`'${e.replace(i,e=>r.get(e)??e)}'`}export{s as propertyKey,c as quote,a as typeName,o as uniqueName};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ReplyKind = "json" | "blob" | "none";
|
|
2
|
+
export interface OperationEntry {
|
|
3
|
+
readonly method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "QUERY";
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly replyKind: ReplyKind;
|
|
6
|
+
}
|
|
7
|
+
export interface OperationShape {
|
|
8
|
+
readonly request: {
|
|
9
|
+
readonly path?: Readonly<Record<string, string | number>>;
|
|
10
|
+
readonly query?: Readonly<Record<string, unknown>>;
|
|
11
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
12
|
+
readonly body?: unknown;
|
|
13
|
+
};
|
|
14
|
+
readonly response: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface ContractRequest {
|
|
17
|
+
readonly method: OperationEntry["method"];
|
|
18
|
+
readonly url: string;
|
|
19
|
+
readonly params: Readonly<Record<string, unknown>> | undefined;
|
|
20
|
+
readonly headers: Readonly<Record<string, string>> | undefined;
|
|
21
|
+
readonly data: unknown;
|
|
22
|
+
readonly responseType: "json" | "blob";
|
|
23
|
+
}
|
|
24
|
+
export declare class ContractCallError extends Error {
|
|
25
|
+
constructor(message: string);
|
|
26
|
+
}
|
|
27
|
+
export declare function buildContractRequest(entry: OperationEntry, request: OperationShape["request"]): ContractRequest;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SchemaObject } from "./model.js";
|
|
2
|
+
type Literal = string | number | boolean | null;
|
|
3
|
+
export declare function isUnion(schema: SchemaObject): boolean;
|
|
4
|
+
export declare function emitType(schema: SchemaObject, names: ReadonlyMap<string, string>, indent: number): string;
|
|
5
|
+
export declare function stringEnumMembers(schema: SchemaObject): readonly string[] | undefined;
|
|
6
|
+
export declare function literalType(value: Literal): string;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { emitFile } from "./emitFile.js";
|
|
2
|
+
export { findGaps, formatGaps } from "./gaps.js";
|
|
3
|
+
export { loadContract } from "./load.js";
|
|
4
|
+
export type { Contract, Gap, GapKind, Hub, HubMember, HubParameter, Operation, SchemaObject, SourceStamp } from "./model.js";
|
|
5
|
+
export { ContractError } from "./model.js";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "QUERY";
|
|
2
|
+
export type SchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
3
|
+
export interface SchemaObject {
|
|
4
|
+
readonly $ref?: string;
|
|
5
|
+
readonly type?: SchemaType | readonly SchemaType[];
|
|
6
|
+
readonly format?: string;
|
|
7
|
+
readonly nullable?: boolean;
|
|
8
|
+
readonly const?: unknown;
|
|
9
|
+
readonly enum?: readonly (string | number | boolean | null)[];
|
|
10
|
+
readonly properties?: Readonly<Record<string, SchemaObject>>;
|
|
11
|
+
readonly patternProperties?: Readonly<Record<string, SchemaObject>>;
|
|
12
|
+
readonly required?: readonly string[];
|
|
13
|
+
readonly items?: SchemaObject | boolean;
|
|
14
|
+
readonly prefixItems?: readonly SchemaObject[];
|
|
15
|
+
readonly minItems?: number;
|
|
16
|
+
readonly maxItems?: number;
|
|
17
|
+
readonly allOf?: readonly SchemaObject[];
|
|
18
|
+
readonly oneOf?: readonly SchemaObject[];
|
|
19
|
+
readonly anyOf?: readonly SchemaObject[];
|
|
20
|
+
readonly additionalProperties?: boolean | SchemaObject;
|
|
21
|
+
readonly unevaluatedProperties?: boolean | SchemaObject;
|
|
22
|
+
readonly contentMediaType?: string;
|
|
23
|
+
readonly contentEncoding?: string;
|
|
24
|
+
readonly $defs?: Readonly<Record<string, SchemaObject>>;
|
|
25
|
+
}
|
|
26
|
+
export type ParameterPlace = "path" | "query" | "header";
|
|
27
|
+
export interface Parameter {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly place: ParameterPlace;
|
|
30
|
+
readonly required: boolean;
|
|
31
|
+
readonly schema: SchemaObject;
|
|
32
|
+
}
|
|
33
|
+
export interface RequestBody {
|
|
34
|
+
readonly required: boolean;
|
|
35
|
+
readonly contentType: string;
|
|
36
|
+
readonly schema: SchemaObject | null;
|
|
37
|
+
}
|
|
38
|
+
export interface Reply {
|
|
39
|
+
readonly status: string;
|
|
40
|
+
readonly schema: SchemaObject | null;
|
|
41
|
+
}
|
|
42
|
+
export interface Operation {
|
|
43
|
+
readonly id: string;
|
|
44
|
+
readonly method: HttpMethod;
|
|
45
|
+
readonly path: string;
|
|
46
|
+
readonly parameters: readonly Parameter[];
|
|
47
|
+
readonly body: RequestBody | null;
|
|
48
|
+
readonly replies: readonly Reply[];
|
|
49
|
+
}
|
|
50
|
+
export interface HubParameter {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly schema: SchemaObject;
|
|
53
|
+
}
|
|
54
|
+
export interface HubMember {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly parameters: readonly HubParameter[];
|
|
57
|
+
readonly result: SchemaObject | null;
|
|
58
|
+
}
|
|
59
|
+
export interface Hub {
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly methods: readonly HubMember[];
|
|
62
|
+
readonly events: readonly HubMember[];
|
|
63
|
+
}
|
|
64
|
+
export interface Contract {
|
|
65
|
+
readonly version: "3.0" | "3.1" | "3.2";
|
|
66
|
+
readonly title: string;
|
|
67
|
+
readonly schemas: ReadonlyMap<string, SchemaObject>;
|
|
68
|
+
readonly operations: readonly Operation[];
|
|
69
|
+
readonly hubs: readonly Hub[];
|
|
70
|
+
readonly leftOut: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
export type GapKind = "bodyNotRequired" | "bodyWithoutShape" | "parameterWithoutShape" | "schemaWithoutRequired" | "replyWithoutSchema" | "emptySchema" | "operationWithoutId" | "notGenerated" | "hubValueWithoutShape";
|
|
73
|
+
export interface Gap {
|
|
74
|
+
readonly kind: GapKind;
|
|
75
|
+
readonly where: string;
|
|
76
|
+
}
|
|
77
|
+
export interface SourceStamp {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly sha256: string;
|
|
80
|
+
}
|
|
81
|
+
export interface Io {
|
|
82
|
+
readonly readText: (file: string) => Promise<string>;
|
|
83
|
+
readonly writeText: (file: string, text: string) => Promise<void>;
|
|
84
|
+
readonly out: (line: string) => void;
|
|
85
|
+
readonly err: (line: string) => void;
|
|
86
|
+
}
|
|
87
|
+
export declare class ContractError extends Error {
|
|
88
|
+
constructor(message: string);
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/api-contract",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.151.0",
|
|
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
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public",
|
|
9
|
+
"registry": "https://registry.npmjs.org/"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"bin": {
|
|
15
|
+
"webority-api-contract": "./dist/bin.js"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./call": {
|
|
23
|
+
"types": "./dist/types/call.d.ts",
|
|
24
|
+
"default": "./dist/call.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "25.6.0",
|
|
30
|
+
"@webority/code-standards": "0.151.0",
|
|
31
|
+
"typescript": "^7.0.2",
|
|
32
|
+
"vite": "^8.3.6",
|
|
33
|
+
"vitest": "5.1.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "vite build && tsc -p tsconfig.json",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
38
|
+
"test": "vitest run"
|
|
39
|
+
}
|
|
6
40
|
}
|