@webority/api-contract 0.153.0 → 0.155.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/README.md CHANGED
@@ -28,7 +28,7 @@ export const PetStatus = { available: 'available', 'on-hold': 'on-hold' } as con
28
28
  export type PetStatus = (typeof PetStatus)[keyof typeof PetStatus];
29
29
  ```
30
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:
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 `undefined`). The client reads it to choose the response type of the call:
32
32
 
33
33
  ```ts
34
34
  export const operations = {
package/dist/emitFile.js CHANGED
@@ -1,7 +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(`
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(S(l,i)),a.push(`export type OperationId = keyof typeof operations;`),a.push(C(l)),a.push(...e(t.hubs,i,r)),`${a.join(`
2
2
 
3
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
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(`
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 = ${b(t,n)};`}var y=`undefined`;function b(e,n){let r=[];for(let i of e.replies){if(!i.status.startsWith(`2`))continue;let e=i.schema===null?y:t(i.schema,n,0);r.includes(e)||r.push(e)}return r.length>0?r.join(` | `):y}function x(e,t){let n=b(e,t);return n===`Blob`?`blob`:n===y?`none`:`json`}function S(e,t){return e.length===0?`export const operations = {} as const;`:[`export const operations = {`,...e.map(({operation:e})=>{let n=x(e,t),r=`{ method: ${a(e.method)}, path: ${a(e.path)}, replyKind: ${a(n)} }`;return` ${i(e.id)}: ${r},`}),`} as const;`].join(`
6
+ `)}function C(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
7
  `)}export{l as emitFile};
package/dist/emitHubs.js CHANGED
@@ -1,3 +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};
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)=>_(e.name,t.name));for(let e of a){let a=c(r(e.name),n);i.push(...u(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}}}var l=`undefined`;function u(t,n,r){let i=g(n.methods),a=g(n.events),o=[d(t,i,a),`export type ${t}Method = keyof typeof ${t}.methods;`,`export type ${t}Event = keyof typeof ${t}.events;`,p(`${t}Methods`,i,t=>t.result===null?l:e(t.result,r,2),r),p(`${t}Events`,a,()=>l,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 d(e,t,n){return[`export const ${e} = {`,` methods: ${f(t)},`,` events: ${f(n)},`,`} as const;`].join(`
2
+ `)}function f(e){return e.length===0?`{}`:`{ ${e.map(e=>`${t(e.name)}: ${n(e.name)}`).join(`, `)} }`}function p(e,n,r,i){if(n.length===0)return`export interface ${e} {}`;let a=n.map(e=>` readonly ${t(e.name)}: { readonly args: readonly [${m(e.parameters,i)}]; readonly result: ${r(e)} };`);return[`export interface ${e} {`,...a,`}`].join(`
3
+ `)}function m(t,n){return t.map((t,r)=>`${h(t.name,r)}: ${e(t.schema,n,2)}`).join(`, `)}function h(e,t){return a.test(e)&&!o.has(e)?e:`arg${t}`}function g(e){return[...e].sort((e,t)=>_(e.name,t.name))}function _(e,t){return e<t?-1:+(e>t)}export{s as emitHubs};
@@ -1,3 +1,3 @@
1
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};
2
+ `,`\\n`],[`\r`,`\\r`],[`\u2028`,`\\u2028`],[`\u2029`,`\\u2029`]]),r=/[\\'\n\r\u2028\u2029]/g;function i(e,t,n){let r=a(e,t,n);return!k(e)||M(e)?r:D(e)===`intersection`?`(${r}) | null`:`${r} | null`}function a(e,t,n){if(e.$ref!==void 0)return o(e.$ref,t);let r=O(e);if(r!==void 0)return l(r);if(e.enum!==void 0)return s(e.enum);if(e.allOf!==void 0)return d(e.allOf,t,n);let a=T(e);return a===void 0?f(e,t,n):a.length===0?`never`:a.map(e=>i(e,t,n)).join(` | `)}function o(e,n){return e.startsWith(t)?n.get(e.slice(21))??`unknown`:`unknown`}function s(e){return e.length===0?`never`:e.map(l).join(` | `)}function c(e){if(e.$ref!==void 0||e.const!==void 0||e.allOf!==void 0||T(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 l(e){return e===null?`null`:typeof e==`string`?`'${e.replace(r,u)}'`:String(e)}function u(e){return n.get(e)??e}function d(e,t,n){let[r,...a]=e;return r===void 0?`unknown`:a.length===0?i(r,t,n):e.map(e=>{let r=i(e,t,n);return E(e)===`union`?`(${r})`:r}).join(` & `)}function f(e,t,n){let r=h(e);return r.length>0?r.map(r=>p(r,e,t,n)).join(` | `):m(e).length>0?`null`:e.contentMediaType!==void 0&&e.contentEncoding===void 0?`Blob`:S(e)?y(e,t,n):`unknown`}function p(e,t,n,r){return e===`string`?t.format===`binary`?`Blob`:`string`:e===`integer`||e===`number`?`number`:e===`boolean`?`boolean`:e===`array`?g(t,n,r):e===`object`?y(t,n,r):`unknown`}function m(e){let t=e.type;return t===void 0?[]:typeof t==`string`?[t]:t}function h(e){let t=/* @__PURE__ */ new Set,n=[];for(let r of m(e)){let e=r===`integer`?`number`:r;r!==`null`&&!t.has(e)&&(t.add(e),n.push(r))}return n}function g(e,t,n){let r=e.prefixItems??[];if(r.length>0)return _(e,r,t,n);let a=e.items;if(a===void 0||a===!0)return`readonly unknown[]`;if(a===!1)return`readonly never[]`;let o=i(a,t,n);return E(a)===`plain`&&!o.startsWith(`readonly `)?`readonly ${o}[]`:`readonly (${o})[]`}function _(e,t,n,r){let a=e.minItems??t.length,o=t.map((e,t)=>{let o=i(e,n,r);return t<a?o:E(e)===`plain`?`${o}?`:`(${o})?`}),s=v(e,t.length,n,r);return`readonly [${(s===void 0?o:[...o,s]).join(`, `)}]`}function v(e,t,n,r){let a=e.items;if(a===!1)return;if(a===void 0)return e.maxItems!==void 0&&e.maxItems<=t?void 0:`...unknown[]`;if(a===!0)return`...unknown[]`;let o=i(a,n,r);return E(a)===`plain`&&!o.startsWith(`readonly `)?`...${o}[]`:`...(${o})[]`}function y(t,n,r){let a=t.properties??{},o=Object.entries(a),s=b(t,n,r);if(o.length===0)return`Readonly<Record<string, ${s??`unknown`}>>`;let c=new Set(t.required??[]),l=`{\n${o.map(([t,a])=>{let o=c.has(t)?``:`?`;return`${P(r+1)}readonly ${e(t)}${o}: ${i(a,n,r+1)};`}).join(`
3
+ `)}\n${P(r)}}`;return s===void 0?l:`${l} & Readonly<Record<string, ${s}>>`}function b(e,t,n){let r=x(e),a=[];r===!0?a.push(`unknown`):r!==void 0&&r!==!1&&a.push(i(r,t,n));for(let r of Object.values(e.patternProperties??{}))a.push(i(r,t,n));if(a.length!==0)return a.includes(`unknown`)?`unknown`:[...new Set(a)].join(` | `)}function x(e){return e.additionalProperties??e.unevaluatedProperties}function S(e){return h(e).includes(`object`)?!0:m(e).length===0&&(C(e)||w(e))}function C(e){return Object.keys(e.properties??{}).length>0}function w(e){let t=x(e);return t===!0||typeof t==`object`||Object.keys(e.patternProperties??{}).length>0}function T(e){return e.oneOf??e.anyOf}function E(e){return k(e)&&!M(e)?`union`:D(e)}function D(e){if(e.$ref!==void 0||O(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?E(t):`intersection`}let t=T(e);if(t!==void 0){let[e,...n]=t;return e===void 0?`plain`:n.length===0?E(e):`union`}return h(e).length>1?`union`:S(e)&&C(e)&&w(e)?`intersection`:`plain`}function O(e){let t=e.const;return t===null||typeof t==`string`||typeof t==`number`||typeof t==`boolean`?t:void 0}function k(e){return e.nullable===!0||A(e)||j(e)}function A(e){if(!m(e).includes(`null`))return!1;let t=O(e)===void 0&&e.enum===void 0&&e.allOf===void 0&&T(e)===void 0;return e.$ref!==void 0||t}function j(e){return e.$ref!==void 0&&(T(e)?.some(e=>N(e))??!1)}function M(e){if(e.$ref!==void 0)return!1;if(O(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&&N(t)}let t=T(e);return t===void 0?m(e).length>0&&h(e).length===0:t.some(e=>N(e))}function N(e){return k(e)||M(e)}function P(e){return` `.repeat(e)}export{i as emitType,l as literalType,c as stringEnumMembers};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/api-contract",
3
- "version": "0.153.0",
3
+ "version": "0.155.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.153.0",
30
+ "@webority/biome-config": "0.155.0",
31
31
  "typescript": "^7.0.2",
32
32
  "vite": "^8.3.6",
33
33
  "vitest": "5.1.0"