@dynamicforms/fastapi-viewsets 0.3.5 → 0.4.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 +42 -3
- package/dist/fastapi-viewsets.js +313 -73
- package/dist/fastapi-viewsets.js.map +1 -1
- package/dist/fastapi-viewsets.umd.cjs +2 -2
- package/dist/fastapi-viewsets.umd.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/mixins.d.ts +161 -35
- package/dist/mixins.d.ts.map +1 -1
- package/dist/muxws-proxy.d.ts +56 -0
- package/dist/muxws-proxy.d.ts.map +1 -0
- package/dist/proxy-base.d.ts +145 -0
- package/dist/proxy-base.d.ts.map +1 -0
- package/dist/rest-proxy.d.ts +12 -24
- package/dist/rest-proxy.d.ts.map +1 -1
- package/dist/viewset.d.ts +44 -0
- package/dist/viewset.d.ts.map +1 -0
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -8,12 +8,29 @@ Celery-backed async execution and a matching Vue/TypeScript client counterpart.
|
|
|
8
8
|
Handles type resolution, lifecycle management and OpenAPI schema automatically.
|
|
9
9
|
- **`CollectionViewSet`** — zero-boilerplate in-memory viewset backed by any Python list, set or dict.
|
|
10
10
|
Great for prototyping and testing.
|
|
11
|
+
- **`DjangoORMViewSet`** — back a viewset with a Django QuerySet. The filters it can compile, the
|
|
12
|
+
sort order with its NULL placement, the page as LIMIT/OFFSET and the total as `COUNT(*)` all
|
|
13
|
+
become SQL; a stage it declines falls back to the in-memory pass instead of failing, and
|
|
14
|
+
`pk_field_name` comes from the model's primary key (requires the `django` extra).
|
|
11
15
|
- **`celery_viewset` decorator** — move a viewset's execution to a Celery worker with no code changes
|
|
12
16
|
to the viewset itself, for long-running or background processing scenarios (requires the `celery`
|
|
13
17
|
extra).
|
|
14
18
|
- **Bulk operations** — first-class support for bulk create, update, partial update and destroy.
|
|
15
|
-
- **
|
|
16
|
-
|
|
19
|
+
- **muxws transport** — reach the same viewsets over a single WebSocket instead of one HTTP request
|
|
20
|
+
per call. A command is dispatched into an app built from the endpoints published on muxws, each
|
|
21
|
+
carrying the route kwargs REST is given, so validation, dependencies, response models and the
|
|
22
|
+
command middleware from `settings.viewsets_command_middleware` behave identically; that app is the
|
|
23
|
+
library's own, so what you attached anywhere but the endpoint itself sees a command only if you
|
|
24
|
+
pass your app to `process_command`. In the demo, a burst of 100 requests takes 156 ms over REST
|
|
25
|
+
and 37 ms over muxws.
|
|
26
|
+
- **Three list shapes** — a bare array, offset paging, or cursor paging. A viewset declares which,
|
|
27
|
+
and may let a client pick per request with an `X-List-Shape` header.
|
|
28
|
+
- **Declarative filters** — declare which fields accept which operators and get query parameters,
|
|
29
|
+
an OpenAPI schema and filtering for free; backends translate what they can into their own query.
|
|
30
|
+
- **Vue / TypeScript counterpart** — mirror mixin classes and the `restViewSet` / `muxwsViewSet` class
|
|
31
|
+
factory give you a fully typed client that matches your backend viewset exactly: the mixins a ViewSet
|
|
32
|
+
declares are its public surface, so calling an action it did not declare is a compile error rather
|
|
33
|
+
than a runtime 404 (published separately as
|
|
17
34
|
[`@dynamicforms/fastapi-viewsets`](https://www.npmjs.com/package/@dynamicforms/fastapi-viewsets) on npm).
|
|
18
35
|
|
|
19
36
|
## Installation
|
|
@@ -23,6 +40,12 @@ pip install dynamicforms-fastapi-viewsets
|
|
|
23
40
|
|
|
24
41
|
# with Celery-backed viewset support
|
|
25
42
|
pip install "dynamicforms-fastapi-viewsets[celery]"
|
|
43
|
+
|
|
44
|
+
# with the muxws WebSocket transport
|
|
45
|
+
pip install "dynamicforms-fastapi-viewsets[muxws]"
|
|
46
|
+
|
|
47
|
+
# with the Django ORM backend (Django 4.2+ and asgiref)
|
|
48
|
+
pip install "dynamicforms-fastapi-viewsets[django]"
|
|
26
49
|
```
|
|
27
50
|
|
|
28
51
|
Requires Python 3.10+, FastAPI and Pydantic v2.
|
|
@@ -59,7 +82,23 @@ app.include_router(router)
|
|
|
59
82
|
```
|
|
60
83
|
|
|
61
84
|
See the [full documentation](https://docs.velis.si/dynamicforms/fastapi-viewsets/) for guides on
|
|
62
|
-
the mixin system, `route_viewset`, `CollectionViewSet`, `celery_viewset`,
|
|
85
|
+
the mixin system, `route_viewset`, `CollectionViewSet`, `DjangoORMViewSet`, `celery_viewset`, the
|
|
86
|
+
list pipeline and pagination, the muxws transport, and the Vue client.
|
|
87
|
+
|
|
88
|
+
## Demo
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
python demo.py # backend on :8000, frontend on :5173
|
|
92
|
+
python demo.py --celery # ... with every viewset call routed through a Celery worker
|
|
93
|
+
npm run test:e2e # drives the demo in a browser
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
An infinite-scrolling grid over a 5000-track library, cursor-paged. Switch the whole grid between
|
|
97
|
+
the REST and muxws transports and between the in-memory and SQLite backends, and compare their
|
|
98
|
+
latency side by side. Sorting and filtering are server-side.
|
|
99
|
+
|
|
100
|
+
`--celery` needs Redis on localhost:6379. The end-to-end suite starts its own backend and dev
|
|
101
|
+
server on their own ports.
|
|
63
102
|
|
|
64
103
|
## License
|
|
65
104
|
|
package/dist/fastapi-viewsets.js
CHANGED
|
@@ -37,8 +37,54 @@ function i(e, t, n) {
|
|
|
37
37
|
}) : e[t] = n, e;
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
+
//#region vue/mixins.ts
|
|
41
|
+
var a = class {};
|
|
42
|
+
i(a, "actions", ["create"]);
|
|
43
|
+
var o = class {};
|
|
44
|
+
i(o, "actions", ["bulkCreate"]);
|
|
45
|
+
var s = class extends a {};
|
|
46
|
+
i(s, "actions", [...a.actions, ...o.actions]);
|
|
47
|
+
var c = class {};
|
|
48
|
+
i(c, "actions", ["list"]);
|
|
49
|
+
var l = class {};
|
|
50
|
+
i(l, "actions", ["listCursor"]);
|
|
51
|
+
var u = class {};
|
|
52
|
+
i(u, "actions", ["listPage"]);
|
|
53
|
+
var d = class {};
|
|
54
|
+
i(d, "actions", ["retrieve"]);
|
|
55
|
+
var f = class {};
|
|
56
|
+
i(f, "actions", ["update", "partialUpdate"]);
|
|
57
|
+
var p = class {};
|
|
58
|
+
i(p, "actions", ["bulkUpdate", "bulkPartialUpdate"]);
|
|
59
|
+
var m = class extends f {};
|
|
60
|
+
i(m, "actions", [...f.actions, ...p.actions]);
|
|
61
|
+
var h = class {};
|
|
62
|
+
i(h, "actions", ["destroy"]);
|
|
63
|
+
var g = class {};
|
|
64
|
+
i(g, "actions", ["bulkDestroy"]);
|
|
65
|
+
var _ = class extends h {};
|
|
66
|
+
i(_, "actions", [...h.actions, ...g.actions]);
|
|
67
|
+
var v = class {};
|
|
68
|
+
i(v, "actions", ["lookup"]);
|
|
69
|
+
var y = class extends c {};
|
|
70
|
+
i(y, "actions", [...c.actions, ...d.actions]);
|
|
71
|
+
var b = class extends y {};
|
|
72
|
+
i(b, "actions", [
|
|
73
|
+
...y.actions,
|
|
74
|
+
...a.actions,
|
|
75
|
+
...f.actions,
|
|
76
|
+
...h.actions
|
|
77
|
+
]);
|
|
78
|
+
var x = class extends b {};
|
|
79
|
+
i(x, "actions", [
|
|
80
|
+
...b.actions,
|
|
81
|
+
...o.actions,
|
|
82
|
+
...p.actions,
|
|
83
|
+
...g.actions
|
|
84
|
+
]);
|
|
85
|
+
//#endregion
|
|
40
86
|
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/asyncToGenerator.js
|
|
41
|
-
function
|
|
87
|
+
function S(e, t, n, r, i, a, o) {
|
|
42
88
|
try {
|
|
43
89
|
var s = e[a](o), c = s.value;
|
|
44
90
|
} catch (e) {
|
|
@@ -47,24 +93,32 @@ function a(e, t, n, r, i, a, o) {
|
|
|
47
93
|
}
|
|
48
94
|
s.done ? t(c) : Promise.resolve(c).then(r, i);
|
|
49
95
|
}
|
|
50
|
-
function
|
|
96
|
+
function C(e) {
|
|
51
97
|
return function() {
|
|
52
98
|
var t = this, n = arguments;
|
|
53
99
|
return new Promise(function(r, i) {
|
|
54
|
-
var
|
|
55
|
-
function
|
|
56
|
-
a
|
|
100
|
+
var a = e.apply(t, n);
|
|
101
|
+
function o(e) {
|
|
102
|
+
S(a, r, i, o, s, "next", e);
|
|
57
103
|
}
|
|
58
|
-
function
|
|
59
|
-
a
|
|
104
|
+
function s(e) {
|
|
105
|
+
S(a, r, i, o, s, "throw", e);
|
|
60
106
|
}
|
|
61
|
-
|
|
107
|
+
o(void 0);
|
|
62
108
|
});
|
|
63
109
|
};
|
|
64
110
|
}
|
|
65
111
|
//#endregion
|
|
66
|
-
//#region vue/
|
|
67
|
-
var
|
|
112
|
+
//#region vue/proxy-base.ts
|
|
113
|
+
var w = class extends Error {
|
|
114
|
+
constructor(e, t, n = {}) {
|
|
115
|
+
super(`Request failed with status code ${e}`), i(this, "response", void 0), this.name = "ViewSetRequestError", this.response = {
|
|
116
|
+
status: e,
|
|
117
|
+
data: t,
|
|
118
|
+
headers: n
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}, T = new Set([
|
|
68
122
|
"get",
|
|
69
123
|
"post",
|
|
70
124
|
"put",
|
|
@@ -73,26 +127,32 @@ var s = new Set([
|
|
|
73
127
|
"head",
|
|
74
128
|
"options",
|
|
75
129
|
"trace"
|
|
76
|
-
]),
|
|
130
|
+
]), E = {
|
|
77
131
|
base: {
|
|
78
|
-
GET:
|
|
79
|
-
|
|
132
|
+
GET: [
|
|
133
|
+
"list",
|
|
134
|
+
"listPage",
|
|
135
|
+
"listCursor"
|
|
136
|
+
],
|
|
137
|
+
POST: ["create"]
|
|
80
138
|
},
|
|
81
139
|
pk: {
|
|
82
|
-
GET: "retrieve",
|
|
83
|
-
PUT: "update",
|
|
84
|
-
PATCH: "partialUpdate",
|
|
85
|
-
DELETE: "destroy"
|
|
140
|
+
GET: ["retrieve"],
|
|
141
|
+
PUT: ["update"],
|
|
142
|
+
PATCH: ["partialUpdate"],
|
|
143
|
+
DELETE: ["destroy"]
|
|
86
144
|
},
|
|
87
145
|
bulk: {
|
|
88
|
-
POST: "bulkCreate",
|
|
89
|
-
PUT: "bulkUpdate",
|
|
90
|
-
PATCH: "bulkPartialUpdate",
|
|
91
|
-
DELETE: "bulkDestroy"
|
|
146
|
+
POST: ["bulkCreate"],
|
|
147
|
+
PUT: ["bulkUpdate"],
|
|
148
|
+
PATCH: ["bulkPartialUpdate"],
|
|
149
|
+
DELETE: ["bulkDestroy"]
|
|
92
150
|
},
|
|
93
|
-
lookup: { GET: "lookup" }
|
|
94
|
-
},
|
|
151
|
+
lookup: { GET: ["lookup"] }
|
|
152
|
+
}, D = [
|
|
95
153
|
"list",
|
|
154
|
+
"listPage",
|
|
155
|
+
"listCursor",
|
|
96
156
|
"create",
|
|
97
157
|
"retrieve",
|
|
98
158
|
"update",
|
|
@@ -103,119 +163,299 @@ var s = new Set([
|
|
|
103
163
|
"bulkPartialUpdate",
|
|
104
164
|
"bulkDestroy",
|
|
105
165
|
"lookup"
|
|
106
|
-
]
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
166
|
+
];
|
|
167
|
+
function O(e, t) {
|
|
168
|
+
var n;
|
|
169
|
+
let r = t == null ? e.constructor.declares : t;
|
|
170
|
+
if (!Array.isArray(r)) return null;
|
|
171
|
+
let i = /* @__PURE__ */ new Set();
|
|
172
|
+
for (let e of r) for (let t of (n = e == null ? void 0 : e.actions) == null ? [] : n) i.add(t);
|
|
173
|
+
return i;
|
|
174
|
+
}
|
|
175
|
+
var k = class {
|
|
176
|
+
constructor(e) {
|
|
177
|
+
i(this, "basePath", void 0), this.basePath = e.replace(/\/$/, "");
|
|
178
|
+
}
|
|
179
|
+
request(e, t, n) {
|
|
180
|
+
throw Error("ViewSetInternals.request: no transport");
|
|
181
|
+
}
|
|
182
|
+
}, A = class extends k {
|
|
183
|
+
constructor(e) {
|
|
184
|
+
super(e.basePath), i(this, "pkFieldName", void 0), i(this, "schemaValidationEnabled", void 0), i(this, "declaredMixins", void 0), this.pkFieldName = e.pkFieldName, this.schemaValidationEnabled = e.validateSchema !== !1, this.declaredMixins = e.declares;
|
|
185
|
+
}
|
|
186
|
+
initSchemaValidation() {
|
|
187
|
+
this.schemaValidationEnabled && this.validateAgainstSchema();
|
|
110
188
|
}
|
|
111
189
|
validateAgainstSchema() {
|
|
112
190
|
var e = this;
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
191
|
+
return C(function* () {
|
|
192
|
+
let t = O(e, e.declaredMixins);
|
|
193
|
+
if (t !== null) try {
|
|
194
|
+
var n;
|
|
195
|
+
let i = yield e.request("GET", "/schema"), a = (n = i == null ? void 0 : i.paths) == null ? {} : n, o = /* @__PURE__ */ new Set(), s = [], c = [];
|
|
196
|
+
for (let [t, n] of Object.entries(a)) {
|
|
118
197
|
var r;
|
|
119
|
-
let i = t.slice(e.basePath.length).replace(/^\//, ""), l;
|
|
198
|
+
let i = t.slice(e.basePath.length).replace(/^\//, ""), a = Object.keys(n).filter((e) => T.has(e.toLowerCase())), l;
|
|
120
199
|
if (i === "") l = "base";
|
|
121
200
|
else if (i === "bulk") l = "bulk";
|
|
122
201
|
else if (i === "lookup") l = "lookup";
|
|
123
202
|
else if (i === "schema") continue;
|
|
124
|
-
else if (i.startsWith("{")) l = "pk";
|
|
203
|
+
else if (i.startsWith("{") && !i.includes("/")) l = "pk";
|
|
125
204
|
else {
|
|
126
|
-
for (let e of
|
|
205
|
+
for (let e of a) c.push({
|
|
206
|
+
endpoint: `${e.toUpperCase()} ${t}`,
|
|
207
|
+
method: i.split("/")[0]
|
|
208
|
+
});
|
|
127
209
|
continue;
|
|
128
210
|
}
|
|
129
|
-
let u = (r =
|
|
130
|
-
for (let e of
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
211
|
+
let u = (r = E[l]) == null ? {} : r;
|
|
212
|
+
for (let e of a) {
|
|
213
|
+
let n = u[e.toUpperCase()];
|
|
214
|
+
if (n) {
|
|
215
|
+
s.push({
|
|
216
|
+
endpoint: `${e.toUpperCase()} ${t}`,
|
|
217
|
+
actions: n
|
|
218
|
+
});
|
|
219
|
+
for (let e of n) o.add(e);
|
|
220
|
+
}
|
|
134
221
|
}
|
|
135
222
|
}
|
|
136
|
-
let
|
|
137
|
-
for (let
|
|
138
|
-
for (let
|
|
139
|
-
for (let
|
|
140
|
-
|
|
223
|
+
let l = [];
|
|
224
|
+
for (let e of D) t.has(e) && !o.has(e) && l.push(`declares '${e}' but the BE viewset serves no such endpoint`);
|
|
225
|
+
for (let { endpoint: e, actions: n } of s) n.some((e) => t.has(e)) || l.push(`BE serves '${e}' but the ViewSet declares no ${n.join(" / ")}`);
|
|
226
|
+
for (let { endpoint: t, method: n } of c) typeof e[n] != "function" && l.push(`BE serves '${t}' but the ViewSet has no '${n}()' method`);
|
|
227
|
+
l.length > 0 && console.warn(`[ViewSet ${e.basePath}] FE/BE definition mismatch:\n` + l.map((e) => ` • ${e}`).join("\n"));
|
|
141
228
|
} catch (e) {}
|
|
142
229
|
})();
|
|
143
230
|
}
|
|
144
231
|
create(e) {
|
|
145
232
|
var t = this;
|
|
146
|
-
return
|
|
147
|
-
return
|
|
233
|
+
return C(function* () {
|
|
234
|
+
return t.request("POST", "", { body: e });
|
|
148
235
|
})();
|
|
149
236
|
}
|
|
150
237
|
bulkCreate(e) {
|
|
151
238
|
var t = this;
|
|
152
|
-
return
|
|
153
|
-
return
|
|
239
|
+
return C(function* () {
|
|
240
|
+
return t.request("POST", "/bulk", { body: e });
|
|
154
241
|
})();
|
|
155
242
|
}
|
|
156
|
-
list() {
|
|
157
|
-
var
|
|
158
|
-
return
|
|
159
|
-
return (
|
|
243
|
+
list(e) {
|
|
244
|
+
var t = this;
|
|
245
|
+
return C(function* () {
|
|
246
|
+
return t.request("GET", "", { query: e });
|
|
247
|
+
})();
|
|
248
|
+
}
|
|
249
|
+
listCursor(e) {
|
|
250
|
+
var t = this;
|
|
251
|
+
return C(function* () {
|
|
252
|
+
let n = yield t.request("GET", "", { query: e });
|
|
253
|
+
return {
|
|
254
|
+
results: n.results,
|
|
255
|
+
limit: n.limit,
|
|
256
|
+
hasMore: n.has_more,
|
|
257
|
+
hasPrevious: n.has_previous,
|
|
258
|
+
next: n.next,
|
|
259
|
+
previous: n.previous,
|
|
260
|
+
first: n.first,
|
|
261
|
+
last: n.last
|
|
262
|
+
};
|
|
263
|
+
})();
|
|
264
|
+
}
|
|
265
|
+
listPage(e) {
|
|
266
|
+
var t = this;
|
|
267
|
+
return C(function* () {
|
|
268
|
+
let n = yield t.request("GET", "", { query: e });
|
|
269
|
+
return {
|
|
270
|
+
results: n.results,
|
|
271
|
+
offset: n.offset,
|
|
272
|
+
limit: n.limit,
|
|
273
|
+
count: n.count,
|
|
274
|
+
hasMore: n.has_more,
|
|
275
|
+
hasPrevious: n.has_previous
|
|
276
|
+
};
|
|
160
277
|
})();
|
|
161
278
|
}
|
|
162
279
|
retrieve(e) {
|
|
163
280
|
var t = this;
|
|
164
|
-
return
|
|
165
|
-
return
|
|
281
|
+
return C(function* () {
|
|
282
|
+
return t.request("GET", `/${e}`);
|
|
166
283
|
})();
|
|
167
284
|
}
|
|
168
285
|
update(e, t) {
|
|
169
286
|
var n = this;
|
|
170
|
-
return
|
|
171
|
-
return
|
|
287
|
+
return C(function* () {
|
|
288
|
+
return n.request("PUT", `/${e}`, { body: t });
|
|
172
289
|
})();
|
|
173
290
|
}
|
|
174
291
|
partialUpdate(e, t) {
|
|
175
292
|
var n = this;
|
|
176
|
-
return
|
|
177
|
-
return
|
|
293
|
+
return C(function* () {
|
|
294
|
+
return n.request("PATCH", `/${e}`, { body: t });
|
|
178
295
|
})();
|
|
179
296
|
}
|
|
180
297
|
bulkUpdate(e) {
|
|
181
298
|
var t = this;
|
|
182
|
-
return
|
|
183
|
-
return
|
|
299
|
+
return C(function* () {
|
|
300
|
+
return t.request("PUT", "/bulk", { body: e });
|
|
184
301
|
})();
|
|
185
302
|
}
|
|
186
303
|
bulkPartialUpdate(e) {
|
|
187
304
|
var t = this;
|
|
188
|
-
return
|
|
189
|
-
return
|
|
305
|
+
return C(function* () {
|
|
306
|
+
return t.request("PATCH", "/bulk", { body: e });
|
|
190
307
|
})();
|
|
191
308
|
}
|
|
192
309
|
destroy(e) {
|
|
193
310
|
var t = this;
|
|
194
|
-
return
|
|
195
|
-
return
|
|
311
|
+
return C(function* () {
|
|
312
|
+
return t.request("DELETE", `/${e}`);
|
|
196
313
|
})();
|
|
197
314
|
}
|
|
198
315
|
bulkDestroy(e) {
|
|
199
316
|
var t = this;
|
|
200
|
-
return
|
|
201
|
-
return
|
|
317
|
+
return C(function* () {
|
|
318
|
+
return t.request("DELETE", "/bulk", { body: e });
|
|
202
319
|
})();
|
|
203
320
|
}
|
|
204
321
|
lookup() {
|
|
205
322
|
var e = this;
|
|
206
|
-
return
|
|
207
|
-
return
|
|
323
|
+
return C(function* () {
|
|
324
|
+
return e.request("GET", "/lookup");
|
|
208
325
|
})();
|
|
209
326
|
}
|
|
210
327
|
};
|
|
211
|
-
|
|
212
|
-
|
|
328
|
+
i(A, "declares", void 0);
|
|
329
|
+
//#endregion
|
|
330
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/objectSpread2.js
|
|
331
|
+
function j(e, t) {
|
|
332
|
+
var n = Object.keys(e);
|
|
333
|
+
if (Object.getOwnPropertySymbols) {
|
|
334
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
335
|
+
t && (r = r.filter(function(t) {
|
|
336
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
337
|
+
})), n.push.apply(n, r);
|
|
338
|
+
}
|
|
339
|
+
return n;
|
|
340
|
+
}
|
|
341
|
+
function M(e) {
|
|
342
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
343
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
344
|
+
t % 2 ? j(Object(n), !0).forEach(function(t) {
|
|
345
|
+
i(e, t, n[t]);
|
|
346
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : j(Object(n)).forEach(function(t) {
|
|
347
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return e;
|
|
351
|
+
}
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region vue/muxws-proxy.ts
|
|
354
|
+
var N = class extends A {
|
|
355
|
+
constructor(e) {
|
|
356
|
+
var t;
|
|
357
|
+
super(e), i(this, "peerSource", void 0), i(this, "timeoutMs", void 0), i(this, "headers", void 0), i(this, "peerPromise", void 0), this.peerSource = e.peer, this.timeoutMs = e.timeoutMs, this.headers = (t = e.headers) == null ? {} : t, this.initSchemaValidation();
|
|
358
|
+
}
|
|
359
|
+
peer() {
|
|
360
|
+
if (!this.peerPromise) {
|
|
361
|
+
let e = this.peerSource;
|
|
362
|
+
this.peerPromise = Promise.resolve(typeof e == "function" ? e() : e);
|
|
363
|
+
}
|
|
364
|
+
return this.peerPromise;
|
|
365
|
+
}
|
|
366
|
+
request(e, t) {
|
|
367
|
+
var n = this;
|
|
368
|
+
return C(function* (e, t, r = {}) {
|
|
369
|
+
let i = yield n.peer(), a = M(M({}, n.headers), {}, {
|
|
370
|
+
":method": e,
|
|
371
|
+
":path": `${n.basePath}${t}`
|
|
372
|
+
});
|
|
373
|
+
r.query && Object.keys(r.query).length > 0 && (a[":query"] = P(r.query));
|
|
374
|
+
let o = i.open(r.body, {
|
|
375
|
+
headers: a,
|
|
376
|
+
end: !0
|
|
377
|
+
});
|
|
378
|
+
yield o.replyHeadersArrived;
|
|
379
|
+
let s = F(o.replyHeaders), c = yield o.result(n.timeoutMs === void 0 ? void 0 : { timeoutMs: n.timeoutMs });
|
|
380
|
+
if (s >= 400) throw new w(s, c, I(o.replyHeaders));
|
|
381
|
+
return c;
|
|
382
|
+
}).apply(this, arguments);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
function P(e) {
|
|
386
|
+
let t = {};
|
|
387
|
+
for (let [n, r] of Object.entries(e)) r != null && (t[n] = r);
|
|
388
|
+
return t;
|
|
389
|
+
}
|
|
390
|
+
function F(e) {
|
|
391
|
+
let t = e == null ? void 0 : e[":status"];
|
|
392
|
+
if (typeof t == "number") return t;
|
|
393
|
+
if (typeof t == "string") {
|
|
394
|
+
let e = Number.parseInt(t, 10);
|
|
395
|
+
if (!Number.isNaN(e)) return e;
|
|
396
|
+
}
|
|
397
|
+
return 200;
|
|
398
|
+
}
|
|
399
|
+
function I(e) {
|
|
400
|
+
let t = {};
|
|
401
|
+
for (let [n, r] of Object.entries(e == null ? {} : e)) n.startsWith(":") || (t[n] = String(r));
|
|
402
|
+
return t;
|
|
403
|
+
}
|
|
404
|
+
function L(e, t) {
|
|
405
|
+
return new N(M({ declares: e.declares }, t));
|
|
406
|
+
}
|
|
407
|
+
//#endregion
|
|
408
|
+
//#region vue/rest-proxy.ts
|
|
409
|
+
var R = class extends A {
|
|
410
|
+
constructor(t) {
|
|
411
|
+
var n;
|
|
412
|
+
super(t), i(this, "http", void 0), this.http = (n = t.axiosInstance) == null ? e : n, this.initSchemaValidation();
|
|
413
|
+
}
|
|
414
|
+
request(e, t) {
|
|
415
|
+
var n = this;
|
|
416
|
+
return C(function* (e, t, r = {}) {
|
|
417
|
+
let i = `${n.basePath}${t}`, a = r.query !== void 0 && Object.keys(r.query).length > 0 ? { params: r.query } : void 0;
|
|
418
|
+
switch (e) {
|
|
419
|
+
case "GET": return (a ? yield n.http.get(i, a) : yield n.http.get(i)).data;
|
|
420
|
+
case "POST": return (a ? yield n.http.post(i, r.body, a) : yield n.http.post(i, r.body)).data;
|
|
421
|
+
case "PUT": return (a ? yield n.http.put(i, r.body, a) : yield n.http.put(i, r.body)).data;
|
|
422
|
+
case "PATCH": return (a ? yield n.http.patch(i, r.body, a) : yield n.http.patch(i, r.body)).data;
|
|
423
|
+
case "DELETE": {
|
|
424
|
+
let e = r.body === void 0 ? a : M(M({}, a == null ? {} : a), {}, { data: r.body });
|
|
425
|
+
return (e ? yield n.http.delete(i, e) : yield n.http.delete(i)).data;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}).apply(this, arguments);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
function z(e, t, n, r) {
|
|
432
|
+
let i = typeof t == "string" ? {
|
|
213
433
|
basePath: t,
|
|
214
434
|
pkFieldName: n,
|
|
215
435
|
axiosInstance: r
|
|
216
|
-
} : t
|
|
436
|
+
} : t;
|
|
437
|
+
return new R(M({ declares: e.declares }, i));
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region vue/viewset.ts
|
|
441
|
+
function B(e, t, n) {
|
|
442
|
+
var r;
|
|
443
|
+
return r = class extends e {
|
|
444
|
+
constructor(e) {
|
|
445
|
+
super(M(M({}, e), {}, {
|
|
446
|
+
pkFieldName: t,
|
|
447
|
+
declares: void 0
|
|
448
|
+
}));
|
|
449
|
+
}
|
|
450
|
+
}, i(r, "declares", n), r;
|
|
451
|
+
}
|
|
452
|
+
function V() {
|
|
453
|
+
return (e, t) => B(R, e, t);
|
|
454
|
+
}
|
|
455
|
+
function H() {
|
|
456
|
+
return (e, t) => B(N, e, t);
|
|
217
457
|
}
|
|
218
458
|
//#endregion
|
|
219
|
-
export { u as RestProxyImpl, d as route_rest };
|
|
459
|
+
export { s as BulkCreateMixin, _ as BulkDestroyMixin, o as BulkOnlyCreateMixin, g as BulkOnlyDestroyMixin, p as BulkOnlyUpdateMixin, m as BulkUpdateMixin, x as BulkViewSetMixin, a as CreateMixin, l as CursorListMixin, h as DestroyMixin, c as ListMixin, v as LookupMixin, N as MuxwsProxyImpl, u as PaginatedListMixin, y as ReadOnlyViewSetMixin, R as RestProxyImpl, d as RetrieveMixin, f as UpdateMixin, k as ViewSetInternals, b as ViewSetMixin, A as ViewSetProxyBase, w as ViewSetRequestError, H as muxwsViewSet, V as restViewSet, L as route_muxws, z as route_rest };
|
|
220
460
|
|
|
221
461
|
//# sourceMappingURL=fastapi-viewsets.js.map
|