@descryy/adapter-python 0.2.0 → 0.3.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 +8 -0
- package/dist/adapter.d.ts +13 -20
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +91 -114
- package/dist/adapter.js.map +1 -1
- package/dist/client.d.ts +22 -41
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -62
- package/dist/client.js.map +1 -1
- package/dist/extract.d.ts +16 -0
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +81 -5
- package/dist/extract.js.map +1 -1
- package/dist/extract.py +45 -4
- package/dist/graphql.d.ts +57 -123
- package/dist/graphql.d.ts.map +1 -1
- package/dist/graphql.js +62 -130
- package/dist/graphql.js.map +1 -1
- package/dist/module.d.ts +23 -42
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +26 -47
- package/dist/module.js.map +1 -1
- package/dist/orm.d.ts +31 -46
- package/dist/orm.d.ts.map +1 -1
- package/dist/orm.js +53 -89
- package/dist/orm.js.map +1 -1
- package/dist/pydantic.d.ts +76 -91
- package/dist/pydantic.d.ts.map +1 -1
- package/dist/pydantic.js +106 -99
- package/dist/pydantic.js.map +1 -1
- package/dist/routes.d.ts +46 -93
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +65 -129
- package/dist/routes.js.map +1 -1
- package/package.json +14 -5
- package/src/extract.py +45 -4
package/dist/orm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orm.js","sourceRoot":"","sources":["../src/orm.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"orm.js","sourceRoot":"","sources":["../src/orm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAwCH;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwD;IACnF,UAAU,EAAE,IAAI,GAAG,CAAC;QAClB,gBAAgB;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AC,SAAS;QAC1B,KAAK;QACL,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAChE,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE;KACjC,CAAC;AACJ,CAAC"}
|
package/dist/pydantic.d.ts
CHANGED
|
@@ -1,45 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Pydantic extractor for Python — a `DTO` and the shape it declares.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* What Pydantic writes down at scale is **presence and type**: 1,409 annotated
|
|
27
|
-
* fields on dispatch, 874 of them optional. "This field is required" is a
|
|
28
|
-
* validation rule the route enforces on every request — a POST without it is a
|
|
29
|
-
* 422 — and it is stated in every model rather than in eighteen of them.
|
|
30
|
-
*
|
|
31
|
-
* So constraints are carried **where they are written** and never invented, and
|
|
32
|
-
* the capability is described by what it actually reads. `attrs.fields` is the
|
|
33
|
-
* same key `orm.ts` uses and the same key golden pattern 05 compares.
|
|
34
|
-
*
|
|
35
|
-
* ## What is deliberately not read
|
|
36
|
-
*
|
|
37
|
-
* A `@field_validator` body is arbitrary Python. 76 of them across the two
|
|
38
|
-
* repositories say something true about what the route accepts, and none of it
|
|
39
|
-
* is readable without executing the code. They are disclosed as an
|
|
40
|
-
* unreadable-constraint count on the node rather than silently treated as
|
|
41
|
-
* absent — the same distinction `orm.ts` draws with `fieldsUndecided`, and the
|
|
42
|
-
* one `nullable=FLAG` exists to protect.
|
|
4
|
+
* A `DTO` is a transport-boundary claim: DEC-043 declined to emit one from
|
|
5
|
+
* the language adapter, since the conformance corpus has three structurally
|
|
6
|
+
* identical classes (one `MODEL`, two `DTO`s) with nothing but names to
|
|
7
|
+
* separate them — a name rule is what golden pattern 12 punishes. A class
|
|
8
|
+
* whose base chain reaches `BaseModel` imported from `pydantic` has declared
|
|
9
|
+
* itself a validated boundary object, framework-enforced at runtime — same
|
|
10
|
+
* standard `orm.ts` holds `MODEL` to. First language adapter to earn `DTO`
|
|
11
|
+
* (`adapter-openapi` needed a published contract).
|
|
12
|
+
*
|
|
13
|
+
* The shape is measured, not assumed: `ge`/`le`/`min_length` etc. total 18
|
|
14
|
+
* across 515 models on two repositories — not the payload. What Pydantic
|
|
15
|
+
* writes at scale is presence and type (1,409 annotated fields on dispatch,
|
|
16
|
+
* 874 optional): "this field is required" is a rule enforced on every
|
|
17
|
+
* request, stated in every model rather than eighteen of them. Constraints
|
|
18
|
+
* are carried where written, never invented; `attrs.fields` matches
|
|
19
|
+
* `orm.ts`'s key, the one golden pattern 05 compares.
|
|
20
|
+
*
|
|
21
|
+
* Deliberately not read: a `@field_validator` body is arbitrary Python (76
|
|
22
|
+
* of them across the two repos say something true and none is statically
|
|
23
|
+
* readable) — disclosed as an unreadable-constraint count, the same
|
|
24
|
+
* distinction `orm.ts` draws with `fieldsUndecided`.
|
|
43
25
|
*/
|
|
44
26
|
import type { PyAttribute } from "./orm.ts";
|
|
45
27
|
/** Modules whose serializer roots are DRF's own. */
|
|
@@ -48,11 +30,9 @@ export declare const DRF_SERIALIZER_ROOTS: ReadonlySet<string>;
|
|
|
48
30
|
/** Is this base name, with this origin module, one of DRF's own serializer roots? */
|
|
49
31
|
export declare function isDrfSerializerRoot(baseName: string, originModule: string | undefined): boolean;
|
|
50
32
|
/**
|
|
51
|
-
* The shape a DRF serializer declares
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* `ormShapeOf` uses to keep a project's own serializer base out of the graph
|
|
55
|
-
* as a `DTO` of its own.
|
|
33
|
+
* The shape a DRF serializer declares, or `null` when the class declares no
|
|
34
|
+
* field — the same guard `ormShapeOf` uses to keep a serializer base out of
|
|
35
|
+
* the graph as a `DTO` of its own.
|
|
56
36
|
*/
|
|
57
37
|
export declare function drfShapeOf(input: {
|
|
58
38
|
readonly attributes: readonly PyAttribute[];
|
|
@@ -60,23 +40,45 @@ export declare function drfShapeOf(input: {
|
|
|
60
40
|
/** Modules whose `BaseModel` is Pydantic's. A local class of that name is not. */
|
|
61
41
|
export declare const PYDANTIC_MODULES: ReadonlySet<string>;
|
|
62
42
|
/**
|
|
63
|
-
* Bases that are Pydantic's own roots.
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `
|
|
67
|
-
* set carries both. Restricting a rule to one spelling of a library's own move
|
|
68
|
-
* is the mistake DEC-069 recorded when `collections.abc.Callable` was missed.
|
|
43
|
+
* Bases that are Pydantic's own roots. `BaseSettings` moved package in v2
|
|
44
|
+
* (`pydantic_settings`, was `pydantic`), so both are carried — restricting to
|
|
45
|
+
* one spelling of a library's move is the mistake DEC-069 recorded for
|
|
46
|
+
* `collections.abc.Callable`.
|
|
69
47
|
*/
|
|
70
48
|
export declare const PYDANTIC_ROOTS: ReadonlySet<string>;
|
|
49
|
+
/**
|
|
50
|
+
* `BaseModel`'s own public API surface — attributes and methods `BaseModel`
|
|
51
|
+
* itself provides, not a subclass's declared fields.
|
|
52
|
+
*
|
|
53
|
+
* This exists for `extract.ts`'s `baseChainIsFieldFree`: an unresolvable base
|
|
54
|
+
* ("nothing this run declares") is treated as contributing no fields of its
|
|
55
|
+
* own, which is correct for SQLAlchemy's bare `DeclarativeBase` marker class
|
|
56
|
+
* but wrong for `BaseModel` — external and unresolvable in exactly the same
|
|
57
|
+
* way, but with a real, stable set of its own members. A read of
|
|
58
|
+
* `model_dump()` or `model_fields_set` on a Pydantic subclass is not an
|
|
59
|
+
* undeclared-field access; without this list it was flagged as one (a real
|
|
60
|
+
* false positive reported as fact — "any call reaching this read raises when
|
|
61
|
+
* it runs" — on code that runs correctly).
|
|
62
|
+
*
|
|
63
|
+
* v2 and v1 combined, since this adapter recognises both (`PYDANTIC_MODULES`
|
|
64
|
+
* carries `pydantic.v1` alongside `pydantic`): the v2 `model_*` methods, plus
|
|
65
|
+
* the v1-compat aliases v2 still ships for migration (`dict`, `json`,
|
|
66
|
+
* `copy`, `parse_obj`, `parse_raw`, `parse_file`, `from_orm`, `schema`,
|
|
67
|
+
* `schema_json`, `validate`, `construct`) and are a v1 project's own native
|
|
68
|
+
* spelling. Kept as a closed, named, well-commented list rather than a
|
|
69
|
+
* heuristic — a false "this exists" is unreachable this way (no name outside
|
|
70
|
+
* `BaseModel`'s real surface is ever added), and the cost of a genuine
|
|
71
|
+
* user-declared field that happens to collide with one of these reserved
|
|
72
|
+
* names is a missed unresolved-field flag on that one field, not a wrong
|
|
73
|
+
* claim.
|
|
74
|
+
*/
|
|
75
|
+
export declare const PYDANTIC_MODEL_MEMBERS: ReadonlySet<string>;
|
|
71
76
|
/** Constraint keywords Pydantic enforces, as opposed to documents. */
|
|
72
77
|
export declare const CONSTRAINT_KEYWORDS: ReadonlySet<string>;
|
|
73
78
|
/**
|
|
74
|
-
* Keywords that describe rather than constrain.
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* Counting them as validation would make the capability look an order of
|
|
78
|
-
* magnitude larger than it is, which is the reporting failure this project
|
|
79
|
-
* exists to avoid.
|
|
79
|
+
* Keywords that describe rather than constrain. `description`/`title` are
|
|
80
|
+
* 189 of dispatch's 214 `Field(...)` keywords — counting them as validation
|
|
81
|
+
* would inflate the capability by an order of magnitude.
|
|
80
82
|
*/
|
|
81
83
|
export declare const DOCUMENTATION_KEYWORDS: ReadonlySet<string>;
|
|
82
84
|
export interface DtoField {
|
|
@@ -84,16 +86,12 @@ export interface DtoField {
|
|
|
84
86
|
/** The annotation as written — never evaluated. */
|
|
85
87
|
readonly type: string | null;
|
|
86
88
|
/**
|
|
87
|
-
* Must a request supply this field at all?
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* omit a required field, get a 422, and report it as a finding.
|
|
94
|
-
*
|
|
95
|
-
* This is the validation rule that is written on every one of 1,694 fields
|
|
96
|
-
* across two repositories, as against the 18 that carry a range constraint.
|
|
89
|
+
* Must a request supply this field at all? Distinct from `nullable`:
|
|
90
|
+
* `x: Optional[int]` with no default is required AND nullable; `x: int = 5`
|
|
91
|
+
* is optional and not nullable. Collapsing the two would make a request
|
|
92
|
+
* generator omit a required field, get a 422, and report it as a finding.
|
|
93
|
+
* Written on every one of 1,694 fields across two repositories, against 18
|
|
94
|
+
* that carry a range constraint.
|
|
97
95
|
*/
|
|
98
96
|
readonly required: boolean;
|
|
99
97
|
/** May the value be null once supplied? `Optional[X]`, `X | None`. */
|
|
@@ -104,10 +102,9 @@ export interface DtoField {
|
|
|
104
102
|
export interface DtoShape {
|
|
105
103
|
readonly fields: readonly DtoField[];
|
|
106
104
|
/**
|
|
107
|
-
* Fields whose constraint
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* reader failed to read it, which is not the same as the source being silent.
|
|
105
|
+
* Fields whose constraint (e.g. `min_length=LIMIT`) can't be evaluated.
|
|
106
|
+
* Listed, not dropped — same reason `orm.ts` lists undecided nullability:
|
|
107
|
+
* the source answered and this reader failed to read it.
|
|
111
108
|
*/
|
|
112
109
|
readonly undecided: readonly string[];
|
|
113
110
|
/** `@field_validator` and friends: real rules, none of them statically readable. */
|
|
@@ -116,32 +113,20 @@ export interface DtoShape {
|
|
|
116
113
|
/** Is this base name, with this origin module, one of Pydantic's own roots? */
|
|
117
114
|
export declare function isPydanticRoot(baseName: string, originModule: string | undefined): boolean;
|
|
118
115
|
/**
|
|
119
|
-
* Does this field have a default, so a request may omit it?
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* The `...` is an **explicit "no default"** — Pydantic's documented way of
|
|
127
|
-
* writing a required field that also carries constraints. Syntactically it is an
|
|
128
|
-
* assignment, so the naive reading is "has a default", and `hostname: str`
|
|
129
|
-
* carrying a `min_length` came out **nullable** — a required field reported as
|
|
130
|
-
* optional. That is the wrong direction to be wrong in: a request generator
|
|
131
|
-
* would omit it and call the resulting 422 a finding.
|
|
132
|
-
*
|
|
133
|
-
* Caught by the field's own type contradicting its verdict — `str`, not
|
|
134
|
-
* `str | None`, marked nullable — rather than by any check.
|
|
116
|
+
* Does this field have a default, so a request may omit it? `x: int = 5`
|
|
117
|
+
* does, `x: int` doesn't. The tricky case: `Field(..., min_length=3)` — the
|
|
118
|
+
* `...` is Pydantic's explicit "no default" for a required field that also
|
|
119
|
+
* carries constraints. Read naively as an assignment, this was misclassified
|
|
120
|
+
* as having a default (a required field reported as optional — the wrong
|
|
121
|
+
* direction, since a request generator would omit it and call the resulting
|
|
122
|
+
* 422 a finding). Caught by the type (`str`, not `str | None`) contradicting the verdict.
|
|
135
123
|
*/
|
|
136
124
|
export declare function hasDefault(annotated: boolean, attribute: PyAttribute | undefined): boolean;
|
|
137
125
|
/** Does an annotation admit absence — `Optional[X]`, `X | None`, `Any`? */
|
|
138
126
|
export declare function annotationIsNullable(annotation: string | null | undefined): boolean;
|
|
139
127
|
/**
|
|
140
|
-
* The shape a Pydantic class declares.
|
|
141
|
-
*
|
|
142
|
-
* `attributes` is every assignment in the class body, as `extract.py` recorded
|
|
143
|
-
* it — the same input `orm.ts` reads, which is why this extractor cost almost
|
|
144
|
-
* nothing to add.
|
|
128
|
+
* The shape a Pydantic class declares. `attributes` is every class-body
|
|
129
|
+
* assignment as `extract.py` recorded it — the same input `orm.ts` reads.
|
|
145
130
|
*/
|
|
146
131
|
export declare function dtoShapeOf(input: {
|
|
147
132
|
readonly attributes: readonly PyAttribute[];
|
package/dist/pydantic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pydantic.d.ts","sourceRoot":"","sources":["../src/pydantic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pydantic.d.ts","sourceRoot":"","sources":["../src/pydantic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAQ5C,oDAAoD;AACpD,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAGrD,CAAC;AAEH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAKnD,CAAC;AAEH,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQ/F;AAiBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE,GAAG,QAAQ,GAAG,IAAI,CA2ClG;AAED,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAO/C,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAK7C,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CA6BrD,CAAC;AAEH,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAclD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAOrD,CAAC;AAEH,MAAM,WAAW,QAAQ;IACvB,QAAQ,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CX;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGjE"}
|
package/dist/pydantic.js
CHANGED
|
@@ -1,58 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Pydantic extractor for Python — a `DTO` and the shape it declares.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* A `DTO` is a transport-boundary claim: DEC-043 declined to emit one from
|
|
5
|
+
* the language adapter, since the conformance corpus has three structurally
|
|
6
|
+
* identical classes (one `MODEL`, two `DTO`s) with nothing but names to
|
|
7
|
+
* separate them — a name rule is what golden pattern 12 punishes. A class
|
|
8
|
+
* whose base chain reaches `BaseModel` imported from `pydantic` has declared
|
|
9
|
+
* itself a validated boundary object, framework-enforced at runtime — same
|
|
10
|
+
* standard `orm.ts` holds `MODEL` to. First language adapter to earn `DTO`
|
|
11
|
+
* (`adapter-openapi` needed a published contract).
|
|
9
12
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* The shape is measured, not assumed: `ge`/`le`/`min_length` etc. total 18
|
|
14
|
+
* across 515 models on two repositories — not the payload. What Pydantic
|
|
15
|
+
* writes at scale is presence and type (1,409 annotated fields on dispatch,
|
|
16
|
+
* 874 optional): "this field is required" is a rule enforced on every
|
|
17
|
+
* request, stated in every model rather than eighteen of them. Constraints
|
|
18
|
+
* are carried where written, never invented; `attrs.fields` matches
|
|
19
|
+
* `orm.ts`'s key, the one golden pattern 05 compares.
|
|
15
20
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* §8 asked for "the validation rules a route enforces", which invites reading
|
|
22
|
-
* `ge`, `le`, `min_length` and friends. Counted across 515 models on two real
|
|
23
|
-
* repositories **before this file was written**, those total **18** — two of
|
|
24
|
-
* them on dispatch's 449 models. Ranked by that number they are not the payload.
|
|
25
|
-
*
|
|
26
|
-
* What Pydantic writes down at scale is **presence and type**: 1,409 annotated
|
|
27
|
-
* fields on dispatch, 874 of them optional. "This field is required" is a
|
|
28
|
-
* validation rule the route enforces on every request — a POST without it is a
|
|
29
|
-
* 422 — and it is stated in every model rather than in eighteen of them.
|
|
30
|
-
*
|
|
31
|
-
* So constraints are carried **where they are written** and never invented, and
|
|
32
|
-
* the capability is described by what it actually reads. `attrs.fields` is the
|
|
33
|
-
* same key `orm.ts` uses and the same key golden pattern 05 compares.
|
|
34
|
-
*
|
|
35
|
-
* ## What is deliberately not read
|
|
36
|
-
*
|
|
37
|
-
* A `@field_validator` body is arbitrary Python. 76 of them across the two
|
|
38
|
-
* repositories say something true about what the route accepts, and none of it
|
|
39
|
-
* is readable without executing the code. They are disclosed as an
|
|
40
|
-
* unreadable-constraint count on the node rather than silently treated as
|
|
41
|
-
* absent — the same distinction `orm.ts` draws with `fieldsUndecided`, and the
|
|
42
|
-
* one `nullable=FLAG` exists to protect.
|
|
21
|
+
* Deliberately not read: a `@field_validator` body is arbitrary Python (76
|
|
22
|
+
* of them across the two repos say something true and none is statically
|
|
23
|
+
* readable) — disclosed as an unreadable-constraint count, the same
|
|
24
|
+
* distinction `orm.ts` draws with `fieldsUndecided`.
|
|
43
25
|
*/
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
26
|
// DRF's `serializers.Serializer`/`ModelSerializer` — a second, structurally
|
|
46
|
-
// different producer of the same `DtoShape
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
// `name: str` — which is why `dtoShapeOf` reads `annotatedFields`. DRF
|
|
51
|
-
// fields are field-CONSTRUCTOR assignments — `email =
|
|
52
|
-
// serializers.EmailField()` — the same shape `orm.ts` already reads for
|
|
53
|
-
// Django's own ORM columns, and for the same reason: neither framework
|
|
54
|
-
// spells a field as a type annotation.
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
27
|
+
// different producer of the same `DtoShape`. Not an annotation shape: DRF
|
|
28
|
+
// fields are constructor assignments (`email = serializers.EmailField()`),
|
|
29
|
+
// the same shape `orm.ts` reads for Django's ORM columns, since neither
|
|
30
|
+
// framework spells a field as a type annotation.
|
|
56
31
|
/** Modules whose serializer roots are DRF's own. */
|
|
57
32
|
export const DRF_SERIALIZER_MODULES = new Set([
|
|
58
33
|
"rest_framework.serializers",
|
|
@@ -75,10 +50,9 @@ export function isDrfSerializerRoot(baseName, originModule) {
|
|
|
75
50
|
return [...DRF_SERIALIZER_MODULES].some((module) => originModule === module || originModule.startsWith(`${module}.`));
|
|
76
51
|
}
|
|
77
52
|
/**
|
|
78
|
-
* Is this attribute a DRF field
|
|
79
|
-
* every field class
|
|
80
|
-
*
|
|
81
|
-
* project writes, the same gap `isColumnCall` avoids for Django's ORM.
|
|
53
|
+
* Is this attribute a DRF field? Shape-based like Django's ORM fields —
|
|
54
|
+
* every field class ends in `Field` — since a closed list would miss every
|
|
55
|
+
* custom field a project writes, the gap `isColumnCall` avoids for Django's ORM.
|
|
82
56
|
*/
|
|
83
57
|
function isDrfFieldCall(attribute) {
|
|
84
58
|
if (attribute.callee === null)
|
|
@@ -90,11 +64,9 @@ function isDrfFieldCall(attribute) {
|
|
|
90
64
|
}
|
|
91
65
|
const DRF_NOT_A_FIELD = new Set(["Meta"]);
|
|
92
66
|
/**
|
|
93
|
-
* The shape a DRF serializer declares
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* `ormShapeOf` uses to keep a project's own serializer base out of the graph
|
|
97
|
-
* as a `DTO` of its own.
|
|
67
|
+
* The shape a DRF serializer declares, or `null` when the class declares no
|
|
68
|
+
* field — the same guard `ormShapeOf` uses to keep a serializer base out of
|
|
69
|
+
* the graph as a `DTO` of its own.
|
|
98
70
|
*/
|
|
99
71
|
export function drfShapeOf(input) {
|
|
100
72
|
const fields = [];
|
|
@@ -116,10 +88,8 @@ export function drfShapeOf(input) {
|
|
|
116
88
|
}
|
|
117
89
|
if (sawUnreadable)
|
|
118
90
|
undecided.push(attribute.name);
|
|
119
|
-
// DRF
|
|
120
|
-
//
|
|
121
|
-
// `default=` — the mirror image of Pydantic's "has a default" trigger,
|
|
122
|
-
// read the way DRF's own field constructor documents it.
|
|
91
|
+
// DRF default: required unless `required=False` or a `default=` is
|
|
92
|
+
// supplied — the mirror of Pydantic's "has a default" trigger.
|
|
123
93
|
let required = true;
|
|
124
94
|
if (!attribute.opaqueKeywords.includes("required") && typeof attribute.keywords["required"] === "boolean") {
|
|
125
95
|
required = attribute.keywords["required"];
|
|
@@ -153,12 +123,10 @@ export const PYDANTIC_MODULES = new Set([
|
|
|
153
123
|
"pydantic_settings",
|
|
154
124
|
]);
|
|
155
125
|
/**
|
|
156
|
-
* Bases that are Pydantic's own roots.
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* `
|
|
160
|
-
* set carries both. Restricting a rule to one spelling of a library's own move
|
|
161
|
-
* is the mistake DEC-069 recorded when `collections.abc.Callable` was missed.
|
|
126
|
+
* Bases that are Pydantic's own roots. `BaseSettings` moved package in v2
|
|
127
|
+
* (`pydantic_settings`, was `pydantic`), so both are carried — restricting to
|
|
128
|
+
* one spelling of a library's move is the mistake DEC-069 recorded for
|
|
129
|
+
* `collections.abc.Callable`.
|
|
162
130
|
*/
|
|
163
131
|
export const PYDANTIC_ROOTS = new Set([
|
|
164
132
|
"BaseModel",
|
|
@@ -166,6 +134,62 @@ export const PYDANTIC_ROOTS = new Set([
|
|
|
166
134
|
"RootModel",
|
|
167
135
|
"GenericModel",
|
|
168
136
|
]);
|
|
137
|
+
/**
|
|
138
|
+
* `BaseModel`'s own public API surface — attributes and methods `BaseModel`
|
|
139
|
+
* itself provides, not a subclass's declared fields.
|
|
140
|
+
*
|
|
141
|
+
* This exists for `extract.ts`'s `baseChainIsFieldFree`: an unresolvable base
|
|
142
|
+
* ("nothing this run declares") is treated as contributing no fields of its
|
|
143
|
+
* own, which is correct for SQLAlchemy's bare `DeclarativeBase` marker class
|
|
144
|
+
* but wrong for `BaseModel` — external and unresolvable in exactly the same
|
|
145
|
+
* way, but with a real, stable set of its own members. A read of
|
|
146
|
+
* `model_dump()` or `model_fields_set` on a Pydantic subclass is not an
|
|
147
|
+
* undeclared-field access; without this list it was flagged as one (a real
|
|
148
|
+
* false positive reported as fact — "any call reaching this read raises when
|
|
149
|
+
* it runs" — on code that runs correctly).
|
|
150
|
+
*
|
|
151
|
+
* v2 and v1 combined, since this adapter recognises both (`PYDANTIC_MODULES`
|
|
152
|
+
* carries `pydantic.v1` alongside `pydantic`): the v2 `model_*` methods, plus
|
|
153
|
+
* the v1-compat aliases v2 still ships for migration (`dict`, `json`,
|
|
154
|
+
* `copy`, `parse_obj`, `parse_raw`, `parse_file`, `from_orm`, `schema`,
|
|
155
|
+
* `schema_json`, `validate`, `construct`) and are a v1 project's own native
|
|
156
|
+
* spelling. Kept as a closed, named, well-commented list rather than a
|
|
157
|
+
* heuristic — a false "this exists" is unreachable this way (no name outside
|
|
158
|
+
* `BaseModel`'s real surface is ever added), and the cost of a genuine
|
|
159
|
+
* user-declared field that happens to collide with one of these reserved
|
|
160
|
+
* names is a missed unresolved-field flag on that one field, not a wrong
|
|
161
|
+
* claim.
|
|
162
|
+
*/
|
|
163
|
+
export const PYDANTIC_MODEL_MEMBERS = new Set([
|
|
164
|
+
// v2 — pydantic-native
|
|
165
|
+
"model_fields",
|
|
166
|
+
"model_fields_set",
|
|
167
|
+
"model_config",
|
|
168
|
+
"model_dump",
|
|
169
|
+
"model_dump_json",
|
|
170
|
+
"model_computed_fields",
|
|
171
|
+
"model_extra",
|
|
172
|
+
"model_construct",
|
|
173
|
+
"model_copy",
|
|
174
|
+
"model_json_schema",
|
|
175
|
+
"model_post_init",
|
|
176
|
+
"model_rebuild",
|
|
177
|
+
"model_validate",
|
|
178
|
+
"model_validate_json",
|
|
179
|
+
"model_validate_strings",
|
|
180
|
+
// v1 native / v2 v1-compat aliases
|
|
181
|
+
"dict",
|
|
182
|
+
"json",
|
|
183
|
+
"copy",
|
|
184
|
+
"parse_obj",
|
|
185
|
+
"parse_raw",
|
|
186
|
+
"parse_file",
|
|
187
|
+
"from_orm",
|
|
188
|
+
"schema",
|
|
189
|
+
"schema_json",
|
|
190
|
+
"validate",
|
|
191
|
+
"construct",
|
|
192
|
+
]);
|
|
169
193
|
/** Constraint keywords Pydantic enforces, as opposed to documents. */
|
|
170
194
|
export const CONSTRAINT_KEYWORDS = new Set([
|
|
171
195
|
"gt",
|
|
@@ -183,12 +207,9 @@ export const CONSTRAINT_KEYWORDS = new Set([
|
|
|
183
207
|
"decimal_places",
|
|
184
208
|
]);
|
|
185
209
|
/**
|
|
186
|
-
* Keywords that describe rather than constrain.
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* Counting them as validation would make the capability look an order of
|
|
190
|
-
* magnitude larger than it is, which is the reporting failure this project
|
|
191
|
-
* exists to avoid.
|
|
210
|
+
* Keywords that describe rather than constrain. `description`/`title` are
|
|
211
|
+
* 189 of dispatch's 214 `Field(...)` keywords — counting them as validation
|
|
212
|
+
* would inflate the capability by an order of magnitude.
|
|
192
213
|
*/
|
|
193
214
|
export const DOCUMENTATION_KEYWORDS = new Set([
|
|
194
215
|
"description",
|
|
@@ -204,29 +225,19 @@ export function isPydanticRoot(baseName, originModule) {
|
|
|
204
225
|
const bare = leaf.split("[")[0];
|
|
205
226
|
if (!PYDANTIC_ROOTS.has(bare))
|
|
206
227
|
return false;
|
|
207
|
-
//
|
|
208
|
-
// `BaseModel` is not Pydantic's, and matching the bare name would admit it.
|
|
228
|
+
// A repository's own `BaseModel` is not Pydantic's; matching the bare name would admit it.
|
|
209
229
|
if (originModule === undefined)
|
|
210
230
|
return false;
|
|
211
231
|
return [...PYDANTIC_MODULES].some((module) => originModule === module || originModule.startsWith(`${module}.`));
|
|
212
232
|
}
|
|
213
233
|
/**
|
|
214
|
-
* Does this field have a default, so a request may omit it?
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
* The `...` is an **explicit "no default"** — Pydantic's documented way of
|
|
222
|
-
* writing a required field that also carries constraints. Syntactically it is an
|
|
223
|
-
* assignment, so the naive reading is "has a default", and `hostname: str`
|
|
224
|
-
* carrying a `min_length` came out **nullable** — a required field reported as
|
|
225
|
-
* optional. That is the wrong direction to be wrong in: a request generator
|
|
226
|
-
* would omit it and call the resulting 422 a finding.
|
|
227
|
-
*
|
|
228
|
-
* Caught by the field's own type contradicting its verdict — `str`, not
|
|
229
|
-
* `str | None`, marked nullable — rather than by any check.
|
|
234
|
+
* Does this field have a default, so a request may omit it? `x: int = 5`
|
|
235
|
+
* does, `x: int` doesn't. The tricky case: `Field(..., min_length=3)` — the
|
|
236
|
+
* `...` is Pydantic's explicit "no default" for a required field that also
|
|
237
|
+
* carries constraints. Read naively as an assignment, this was misclassified
|
|
238
|
+
* as having a default (a required field reported as optional — the wrong
|
|
239
|
+
* direction, since a request generator would omit it and call the resulting
|
|
240
|
+
* 422 a finding). Caught by the type (`str`, not `str | None`) contradicting the verdict.
|
|
230
241
|
*/
|
|
231
242
|
export function hasDefault(annotated, attribute) {
|
|
232
243
|
if (!annotated)
|
|
@@ -256,11 +267,8 @@ export function annotationIsNullable(annotation) {
|
|
|
256
267
|
return /\bOptional\s*\[/.test(annotation) || /\bNone\b/.test(annotation);
|
|
257
268
|
}
|
|
258
269
|
/**
|
|
259
|
-
* The shape a Pydantic class declares.
|
|
260
|
-
*
|
|
261
|
-
* `attributes` is every assignment in the class body, as `extract.py` recorded
|
|
262
|
-
* it — the same input `orm.ts` reads, which is why this extractor cost almost
|
|
263
|
-
* nothing to add.
|
|
270
|
+
* The shape a Pydantic class declares. `attributes` is every class-body
|
|
271
|
+
* assignment as `extract.py` recorded it — the same input `orm.ts` reads.
|
|
264
272
|
*/
|
|
265
273
|
export function dtoShapeOf(input) {
|
|
266
274
|
const byName = new Map();
|
|
@@ -284,9 +292,8 @@ export function dtoShapeOf(input) {
|
|
|
284
292
|
constraints[key] = value;
|
|
285
293
|
}
|
|
286
294
|
for (const key of attribute.opaqueKeywords) {
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
// stand in for it would report the opposite of the source as fact.
|
|
295
|
+
// Unreadable constraint: the source stated a rule, and silence
|
|
296
|
+
// standing in for it would report the opposite as fact.
|
|
290
297
|
if (CONSTRAINT_KEYWORDS.has(key))
|
|
291
298
|
sawUnreadable = true;
|
|
292
299
|
}
|
package/dist/pydantic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pydantic.js","sourceRoot":"","sources":["../src/pydantic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pydantic.js","sourceRoot":"","sources":["../src/pydantic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,iDAAiD;AAEjD,oDAAoD;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAC;IACjE,4BAA4B;IAC5B,uBAAuB;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC;IAC/D,YAAY;IACZ,iBAAiB;IACjB,4BAA4B;IAC5B,gBAAgB;CACjB,CAAC,CAAC;AAEH,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,YAAgC;IACpF,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC/F,MAAM,IAAI,GAAG,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