typespec-http-zod 0.19.0 → 0.19.1
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/src/api.js +31 -7
- package/package.json +1 -1
package/dist/src/api.js
CHANGED
|
@@ -1780,7 +1780,29 @@ type Identical<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends
|
|
|
1780
1780
|
*
|
|
1781
1781
|
* Deep, because openness recurs: a nested open model puts one at every level, which is why a single
|
|
1782
1782
|
* spread never repaired the shape it was supposed to repair.
|
|
1783
|
+
*
|
|
1784
|
+
* **An index signature arrives two ways and only one of them is openness.** A model spreading
|
|
1785
|
+
* \`...Record<unknown>\` gains one because its validator is loose - a fact about the MODEL, which the
|
|
1786
|
+
* contract type does not state, so it is stripped. A property declared \`Record<unknown>\` gains one
|
|
1787
|
+
* because that IS its type, stated identically in both artefacts, and stripping it destroys the
|
|
1788
|
+
* property: \`Declared<Record<string, unknown>>\` became \`{}\`, and any spec with a dictionary
|
|
1789
|
+
* property emitted an assertion that does not compile.
|
|
1790
|
+
*
|
|
1791
|
+
* The two are told apart the same way \`types.ts\` already tells them apart: **a string indexer means
|
|
1792
|
+
* "dictionary" only when there are no declared properties beside it.** So the index signature is
|
|
1793
|
+
* dropped from a shape that has other keys, and kept - with its value type still mapped - from one
|
|
1794
|
+
* that does not.
|
|
1783
1795
|
*/
|
|
1796
|
+
type DeclaredKeyOf<T> = keyof {
|
|
1797
|
+
[K in keyof T as string extends K
|
|
1798
|
+
? never
|
|
1799
|
+
: number extends K
|
|
1800
|
+
? never
|
|
1801
|
+
: symbol extends K
|
|
1802
|
+
? never
|
|
1803
|
+
: K]: 0;
|
|
1804
|
+
};
|
|
1805
|
+
|
|
1784
1806
|
type Declared<T> = T extends (...args: never[]) => unknown
|
|
1785
1807
|
? T
|
|
1786
1808
|
: T extends readonly (infer Element)[]
|
|
@@ -1788,15 +1810,17 @@ type Declared<T> = T extends (...args: never[]) => unknown
|
|
|
1788
1810
|
? Declared<Element>[]
|
|
1789
1811
|
: readonly Declared<Element>[]
|
|
1790
1812
|
: T extends object
|
|
1791
|
-
?
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1813
|
+
? [DeclaredKeyOf<T>] extends [never]
|
|
1814
|
+
? { [K in keyof T]: Declared<T[K]> }
|
|
1815
|
+
: {
|
|
1816
|
+
[K in keyof T as string extends K
|
|
1795
1817
|
? never
|
|
1796
|
-
:
|
|
1818
|
+
: number extends K
|
|
1797
1819
|
? never
|
|
1798
|
-
:
|
|
1799
|
-
|
|
1820
|
+
: symbol extends K
|
|
1821
|
+
? never
|
|
1822
|
+
: K]: Declared<T[K]>;
|
|
1823
|
+
}
|
|
1800
1824
|
: T;
|
|
1801
1825
|
|
|
1802
1826
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typespec-http-zod",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "TypeSpec emitter and library: turn an HTTP service definition into Zod validators and framework-free contract types that agree, keyword for keyword, with the OpenAPI document @typespec/openapi3 publishes from the same source.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|