@dynamicforms/fastapi-viewsets 0.5.7 → 0.6.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dynamicforms/fastapi-viewsets",
3
3
  "private": false,
4
- "version": "0.5.7",
4
+ "version": "0.6.0",
5
5
  "type": "module",
6
6
  "description": "RESTful viewsets for Vue",
7
7
  "author": "Jure Erznožnik",
@@ -46,7 +46,8 @@
46
46
  },
47
47
  "issues": "https://github.com/dynamicforms/fastapi-viewsets/issues",
48
48
  "peerDependencies": {
49
- "@dynamicforms/vue-forms": "^0.17.1",
49
+ "@dynamicforms/translatable": "^0.1.0",
50
+ "@dynamicforms/vue-forms": "^1.0.0",
50
51
  "axios": "^1.13.6",
51
52
  "lodash-es": "^4.17.12",
52
53
  "vue": "^3.4",
@@ -56,7 +57,7 @@
56
57
  "@types/lodash-es": "^4.17.12",
57
58
  "@types/node": "^26",
58
59
  "@vitejs/plugin-vue": "^6",
59
- "@vitest/coverage-v8": "^3",
60
+ "@vitest/coverage-v8": "^4",
60
61
  "@vue/test-utils": "^2.2.4",
61
62
  "@vue/tsconfig": "^0.7.0",
62
63
  "eslint-config-velis": "^3",
@@ -64,9 +65,8 @@
64
65
  "rollup-plugin-visualizer": "^5.14.0",
65
66
  "typescript": "^5",
66
67
  "vite": "^8",
67
- "vite-plugin-dts": "^5",
68
- "vite-plugin-eslint": "^1.8.1",
69
- "vitest": "^3",
68
+ "vite-plugin-dts": "^4",
69
+ "vitest": "^4",
70
70
  "vue-tsc": "^2"
71
71
  },
72
72
  "peerDependenciesMeta": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../vue/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,YAAY,EACZ,SAAS,EACT,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,YAAY,GACb,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvH,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEvF,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAEzD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACpH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
package/dist/mixins.d.ts DELETED
@@ -1,199 +0,0 @@
1
- /**
2
- * FE counterpart of BE mixins.py — the mixins a ViewSet declaration is composed of.
3
- *
4
- * Each mixin is an interface merged into a class of the same name. The interface names the actions
5
- * and their signatures; the class carries the `actions` list that the schema check reads at
6
- * runtime. Both halves are needed because neither alone can do the job: a TypeScript `implements`
7
- * clause is erased before anything runs, and a runtime list of strings says nothing about types.
8
- *
9
- * class ItemViewSet extends restViewSet<Item>()('id', [ReadOnlyViewSetMixin, LookupMixin]) {}
10
- *
11
- * The list is written once, as values. `restViewSet` reads the action names off the mixins'
12
- * instance types to build the ViewSet's public surface, and hands the same list to the proxy so
13
- * that the schema check can compare it against the BE.
14
- *
15
- * The members are methods rather than properties, and are reached through an intersection rather
16
- * than a `Pick<>` of a lookup table: a mapped type re-emits a method as a function-valued property,
17
- * and a subclass may then not override an action with a method (TS2425). Overriding one to add
18
- * caching or reshape parameters works on a hand-written proxy subclass today, and must keep
19
- * working here.
20
- *
21
- * A composite mixin restates nothing: its interface extends the leaves its `actions` spread names,
22
- * so each action's signature exists in exactly one place.
23
- *
24
- * The methods have no implementation anywhere in this file. The implementation is one HTTP call in
25
- * ViewSetProxyBase, and a mixin carrying its own would be a second copy of it.
26
- */
27
- export interface LookupItem {
28
- group: unknown;
29
- pk: unknown;
30
- title: string;
31
- icon: string | null;
32
- }
33
- export type KeyType = string | number;
34
- export type DestroyReturnData = Record<KeyType, any>;
35
- export interface CreateMixin<T, PK extends keyof T> {
36
- create(data: Omit<T, PK>): Promise<T>;
37
- }
38
- export declare class CreateMixin<T, PK extends keyof T> {
39
- static readonly actions: readonly string[];
40
- }
41
- export interface BulkOnlyCreateMixin<T, PK extends keyof T> {
42
- bulkCreate(data: Omit<T, PK>[]): Promise<T[]>;
43
- }
44
- export declare class BulkOnlyCreateMixin<T, PK extends keyof T> {
45
- static readonly actions: readonly string[];
46
- }
47
- export interface BulkCreateMixin<T, PK extends keyof T> extends CreateMixin<T, PK>, BulkOnlyCreateMixin<T, PK> {
48
- }
49
- export declare class BulkCreateMixin<T, PK extends keyof T> extends CreateMixin<T, PK> {
50
- static readonly actions: readonly string[];
51
- }
52
- export interface ListMixin<T> {
53
- list(params?: ListParams): Promise<T[]>;
54
- }
55
- export declare class ListMixin<T> {
56
- static readonly actions: readonly string[];
57
- }
58
- /** Query parameters a list call accepts. `sort` is 'column:asc,other:desc'; the rest are filters. */
59
- export interface ListParams {
60
- sort?: string;
61
- [key: string]: string | number | boolean | null | undefined | Array<string | number>;
62
- }
63
- /**
64
- * One page, mirroring the BE PaginatedList.
65
- *
66
- * `count` is null when the backend could not know it without draining a lazy source. `hasMore` and
67
- * `hasPrevious` are stated rather than inferred — a client that guesses from a null gets the guess
68
- * wrong exactly at the boundary where it matters.
69
- */
70
- export interface PaginatedList<T> {
71
- results: T[];
72
- offset: number;
73
- limit: number | null;
74
- count: number | null;
75
- hasMore: boolean;
76
- hasPrevious: boolean;
77
- }
78
- export interface PageParams extends ListParams {
79
- offset?: number;
80
- limit?: number;
81
- }
82
- /**
83
- * One cursor page.
84
- *
85
- * `next`/`previous` are exclusive, so following them never repeats a row. `first`/`last` are the
86
- * same two edges read inclusively: they return their own row again — one duplicate to drop — and
87
- * in exchange they survive rows being inserted at that edge, which is what polling a live list
88
- * needs. They are present whenever the page is non-empty, even when `next` is null.
89
- *
90
- * There is no total count: producing one costs a second full pass per request and is stale by the
91
- * time it is read.
92
- */
93
- export interface CursorPage<T> {
94
- results: T[];
95
- limit: number;
96
- hasMore: boolean;
97
- hasPrevious: boolean;
98
- next: string | null;
99
- previous: string | null;
100
- first: string | null;
101
- last: string | null;
102
- }
103
- export interface CursorParams extends ListParams {
104
- cursor?: string;
105
- limit?: number;
106
- }
107
- /** FE counterpart of the BE CursorListMixin. See PaginatedListMixin on declaring several shapes. */
108
- export interface CursorListMixin<T> {
109
- listCursor(params?: CursorParams): Promise<CursorPage<T>>;
110
- }
111
- export declare class CursorListMixin<T> {
112
- static readonly actions: readonly string[];
113
- }
114
- /**
115
- * FE counterpart of the BE PaginatedListMixin. `GET {basePath}` is one endpoint answering in the
116
- * shape the BE viewset declared as its default; this client sends no X-List-Shape header, so a
117
- * ViewSet declares the mixin matching that default rather than one per shape it might want.
118
- */
119
- export interface PaginatedListMixin<T> {
120
- listPage(params?: PageParams): Promise<PaginatedList<T>>;
121
- }
122
- export declare class PaginatedListMixin<T> {
123
- static readonly actions: readonly string[];
124
- }
125
- export interface RetrieveMixin<K extends KeyType, T> {
126
- retrieve(pk: K): Promise<T>;
127
- }
128
- export declare class RetrieveMixin<K extends KeyType, T> {
129
- static readonly actions: readonly string[];
130
- }
131
- export interface UpdateMixin<K extends KeyType, T> {
132
- update(pk: K, data: T): Promise<T>;
133
- partialUpdate(pk: K, data: Partial<T>): Promise<T>;
134
- }
135
- export declare class UpdateMixin<K extends KeyType, T> {
136
- static readonly actions: readonly string[];
137
- }
138
- export interface BulkOnlyUpdateMixin<K extends KeyType, T> {
139
- bulkUpdate(records: Record<K, T>): Promise<T[]>;
140
- bulkPartialUpdate(records: Record<K, Partial<T>>): Promise<T[]>;
141
- }
142
- export declare class BulkOnlyUpdateMixin<K extends KeyType, T> {
143
- static readonly actions: readonly string[];
144
- }
145
- export interface BulkUpdateMixin<K extends KeyType, T> extends UpdateMixin<K, T>, BulkOnlyUpdateMixin<K, T> {
146
- }
147
- export declare class BulkUpdateMixin<K extends KeyType, T> extends UpdateMixin<K, T> {
148
- static readonly actions: readonly string[];
149
- }
150
- export interface DestroyMixin<K extends KeyType> {
151
- destroy(pk: K): Promise<DestroyReturnData>;
152
- }
153
- export declare class DestroyMixin<K extends KeyType> {
154
- static readonly actions: readonly string[];
155
- }
156
- export interface BulkOnlyDestroyMixin<K extends KeyType> {
157
- bulkDestroy(pks: K[]): Promise<DestroyReturnData[]>;
158
- }
159
- export declare class BulkOnlyDestroyMixin<K extends KeyType> {
160
- static readonly actions: readonly string[];
161
- }
162
- export interface BulkDestroyMixin<K extends KeyType> extends DestroyMixin<K>, BulkOnlyDestroyMixin<K> {
163
- }
164
- export declare class BulkDestroyMixin<K extends KeyType> extends DestroyMixin<K> {
165
- static readonly actions: readonly string[];
166
- }
167
- export interface LookupMixin {
168
- lookup(): Promise<LookupItem[]>;
169
- }
170
- export declare class LookupMixin {
171
- static readonly actions: readonly string[];
172
- }
173
- export interface ReadOnlyViewSetMixin<K extends KeyType, T> extends ListMixin<T>, RetrieveMixin<K, T> {
174
- }
175
- export declare class ReadOnlyViewSetMixin<K extends KeyType, T> extends ListMixin<T> {
176
- static readonly actions: readonly string[];
177
- }
178
- export interface ViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ReadOnlyViewSetMixin<K, T>, CreateMixin<T, PK>, UpdateMixin<K, T>, DestroyMixin<K> {
179
- }
180
- export declare class ViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ReadOnlyViewSetMixin<K, T> {
181
- static readonly actions: readonly string[];
182
- }
183
- export interface BulkViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ViewSetMixin<K, T, PK>, BulkOnlyCreateMixin<T, PK>, BulkOnlyUpdateMixin<K, T>, BulkOnlyDestroyMixin<K> {
184
- }
185
- export declare class BulkViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ViewSetMixin<K, T, PK> {
186
- static readonly actions: readonly string[];
187
- }
188
- /**
189
- * The actions named by `A`, each with the signature the mixin that contributes it declares. One
190
- * conditional per single-action mixin; the composites are absent on purpose, so that any action's
191
- * signature is written in exactly one place.
192
- *
193
- * An intersection rather than `Pick<>` of a table: a mapped type turns a method into a property,
194
- * and a subclass cannot then override an action with a method (TS2425).
195
- */
196
- export type ActionSurface<K extends KeyType, T, PK extends keyof T, A> = ('create' extends A ? CreateMixin<T, PK> : unknown) & ('bulkCreate' extends A ? BulkOnlyCreateMixin<T, PK> : unknown) & ('list' extends A ? ListMixin<T> : unknown) & ('listPage' extends A ? PaginatedListMixin<T> : unknown) & ('listCursor' extends A ? CursorListMixin<T> : unknown) & ('retrieve' extends A ? RetrieveMixin<K, T> : unknown) & ('update' extends A ? UpdateMixin<K, T> : unknown) & ('bulkUpdate' extends A ? BulkOnlyUpdateMixin<K, T> : unknown) & ('destroy' extends A ? DestroyMixin<K> : unknown) & ('bulkDestroy' extends A ? BulkOnlyDestroyMixin<K> : unknown) & ('lookup' extends A ? LookupMixin : unknown);
197
- /** Every action name there is: `A = string` selects all of them. */
198
- export type ActionName = keyof ActionSurface<KeyType, unknown, never, string>;
199
- //# sourceMappingURL=mixins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mix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AAY,SAAS,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GACvD,CAAC,UAAU,SAAS,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GACtD,CAAC,QAAQ,SAAS,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAClD,CAAC,YAAY,SAAS,CAAC,GAAG,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAC9D,CAAC,SAAS,SAAS,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GACjD,CAAC,aAAa,SAAS,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,GAC7D,CAAC,QAAQ,SAAS,CAAC,GAAG,WAAW,GAAG,OAAO,CAAC,CAAC;AAE/C,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC"}
@@ -1,69 +0,0 @@
1
- import { KeyType } from './mixins';
2
- import { FACTORY_BUILT, HttpMethod, ProxyBaseOptions, RequestOptions, ViewSetProxyBase } from './proxy-base';
3
- /**
4
- * The bits of a muxws Peer this proxy uses. Typed structurally rather than by importing the muxws
5
- * types, so that `muxws` stays an optional dependency: an application that only uses route_rest
6
- * should not have to install it.
7
- */
8
- export interface MuxwsStreamLike {
9
- result(options?: {
10
- timeoutMs?: number;
11
- }): Promise<unknown>;
12
- readonly replyHeadersArrived: Promise<void>;
13
- readonly replyHeaders: Record<string, unknown> | null | undefined;
14
- }
15
- export interface MuxwsPeerLike {
16
- open(payload?: unknown, options?: {
17
- headers?: Record<string, unknown>;
18
- end?: boolean;
19
- }): MuxwsStreamLike;
20
- }
21
- /**
22
- * Where the peer comes from. A bare peer is the simple case; a function is for the common shape
23
- * where the proxy is constructed at module scope but `connect()` has not resolved yet. The
24
- * function is called once and its result cached — a muxws Peer survives its own reconnects, so
25
- * there is nothing to re-resolve afterwards.
26
- */
27
- export type MuxwsPeerSource = MuxwsPeerLike | (() => MuxwsPeerLike | Promise<MuxwsPeerLike>);
28
- export type MuxwsProxy<M> = M;
29
- type ViewSetClass = abstract new (...args: any[]) => any;
30
- /**
31
- * The shape a factory-built class's constructor has, purely to give `route_muxws` an overload that
32
- * rejects it - see rest-proxy.ts's `FactoryBuiltClass` for why this has to be a plain overload
33
- * parameter rather than a type parameter conditioned on the argument.
34
- */
35
- type FactoryBuiltClass = (abstract new (...args: any[]) => any) & {
36
- declares: {
37
- readonly [FACTORY_BUILT]: any;
38
- };
39
- };
40
- /** Never assigned; its only use is `typeof FACTORY_BUILT_REJECTION` as a self-describing return type. */
41
- declare const FACTORY_BUILT_REJECTION: 'route_muxws cannot take a factory-built class - extend it directly instead';
42
- export interface MuxwsProxyOptions extends ProxyBaseOptions {
43
- peer: MuxwsPeerSource;
44
- /** Per-request timeout in milliseconds. muxws resets the stream with TIMEOUT when it expires. */
45
- timeoutMs?: number;
46
- /**
47
- * Headers added to every request this proxy makes. The WebSocket handshake already carries
48
- * whatever identified the session and the server treats that as the baseline; these override it
49
- * for this proxy's calls. There is no per-call header: `RequestOptions` is `{ query, body }`.
50
- */
51
- headers?: Record<string, string>;
52
- }
53
- export declare class MuxwsProxyImpl<K extends KeyType, T, PK extends keyof T> extends ViewSetProxyBase<K, T, PK> {
54
- private readonly peerSource;
55
- private readonly timeoutMs?;
56
- private readonly headers;
57
- private peerPromise?;
58
- constructor(options: MuxwsProxyOptions);
59
- private peer;
60
- protected request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
61
- }
62
- declare function route_muxws<M = never>(viewSetClass: FactoryBuiltClass, options: MuxwsProxyOptions): typeof FACTORY_BUILT_REJECTION;
63
- /**
64
- * Registers a muxws proxy for the given ViewSet class. The mirror of route_rest, and it takes the
65
- * same generic parameter for the same reason: TypeScript cannot inspect the Python class.
66
- */
67
- declare function route_muxws<M>(viewSetClass: ViewSetClass, options: MuxwsProxyOptions): MuxwsProxy<M>;
68
- export { route_muxws };
69
- //# sourceMappingURL=muxws-proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"muxws-proxy.d.ts","sourceRoot":"","sources":["../vue/muxws-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,aAAa,EACb,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACnB,gBAAgB,EAGjB,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CACnE;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,eAAe,CAAC;CAC1G;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AAE7F,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;AAE9B,KAAK,YAAY,GAAG,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,C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AAiB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAU/F,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -1,159 +0,0 @@
1
- import { BulkViewSetMixin, CursorListMixin, CursorPage, CursorParams, DestroyReturnData, KeyType, ListParams, LookupItem, LookupMixin, PageParams, PaginatedList, PaginatedListMixin } from './mixins';
2
- export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
3
- /** Query values; an array becomes a repeated key, which is how FastAPI binds `list[str]`. */
4
- export type QueryParams = Record<string, string | number | boolean | null | undefined | Array<string | number>>;
5
- export interface RequestOptions {
6
- query?: QueryParams;
7
- body?: unknown;
8
- }
9
- /**
10
- * What a failed call throws over muxws, where there is no axios to raise anything.
11
- *
12
- * The shape mirrors `AxiosError` — `error.response.status`, `error.response.data` and
13
- * `error.response.headers` — so a caller reads the same fields whichever transport the ViewSet
14
- * speaks. Over HTTP axios raises its own error, already in that shape, and it is passed through
15
- * untouched.
16
- *
17
- * `response` is always set here, unlike `AxiosError.response`, which is absent when the request
18
- * never reached a reply.
19
- */
20
- export declare class ViewSetRequestError extends Error {
21
- readonly response: {
22
- status: number;
23
- data: unknown;
24
- headers: Record<string, string>;
25
- };
26
- constructor(status: number, data: unknown, headers?: Record<string, string>);
27
- }
28
- /** One entry of a ViewSet's `static declares` list: a mixin naming the actions it contributes. */
29
- export interface ViewSetMixinDeclaration {
30
- readonly actions: readonly string[];
31
- }
32
- /**
33
- * Marks a class's `declares` as coming from the ViewSet factory (viewset.ts's `FactoryDeclares<D>`)
34
- * rather than being hand-written. Declared here, the module both viewset.ts and the two proxy
35
- * implementations already import from, so all three sides see the same `unique symbol` and a
36
- * structural check against it type-checks identically everywhere - `route_rest`/`route_muxws` use it
37
- * to reject a factory-built class at the call site (see rest-proxy.ts, muxws-proxy.ts), which would
38
- * otherwise type-check and hand back a bare proxy missing the class's own custom methods.
39
- */
40
- export declare const FACTORY_BUILT: unique symbol;
41
- export interface ProxyBaseOptions {
42
- /** Base path to the resource, e.g. '/items'. */
43
- basePath: string;
44
- /** Name of the PK field on the model, e.g. 'id'. */
45
- pkFieldName: string;
46
- /** Set false to skip the startup schema check (it is advisory and costs one request). */
47
- validateSchema?: boolean;
48
- /**
49
- * The mixins the ViewSet declares, for the `route_rest` / `route_muxws` path: those build a bare
50
- * proxy and use the ViewSet class only for typing, so a `static declares` on it would otherwise
51
- * never reach the object being checked.
52
- */
53
- declares?: readonly ViewSetMixinDeclaration[];
54
- }
55
- /**
56
- * What a ViewSet's own methods may reach - everything a custom endpoint needs, and nothing a caller
57
- * does.
58
- *
59
- * A real base class rather than a type, because `protected` is checked nominally: a subclass body
60
- * reaches `request()` only if it genuinely descends from the class that declared it. The ViewSet
61
- * factory hands back a class typed as this plus the declared actions, which is how a factory-built
62
- * ViewSet ends up with a narrow public surface and a usable private one.
63
- */
64
- export declare abstract class ViewSetInternals {
65
- protected readonly basePath: string;
66
- protected constructor(basePath: string);
67
- /**
68
- * Sends one request and returns the decoded response body.
69
- *
70
- * `path` is relative to `basePath` — '' for the collection, '/1' for a record, '/bulk', and so
71
- * on. Implementations must throw on a status of 400 or above, with `response.status` readable on
72
- * the thrown value. Below 400 the two differ, on a band a caller rarely sees: the muxws proxy
73
- * returns the body for any 3xx, while the REST proxy follows a redirect it can follow and rejects
74
- * whatever axios' default `validateStatus` then leaves outside 200-299.
75
- *
76
- * Concrete here, and never reached: ViewSetProxyBase re-declares it abstract, which is where a
77
- * transport is actually held to implementing it. It cannot be abstract at this level because
78
- * TypeScript propagates an abstract member through a constructor type, and the factory hands one
79
- * back - every ViewSet a consumer wrote would then fail TS2515 for a method the transport
80
- * underneath it has always implemented.
81
- */
82
- protected request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
83
- }
84
- export declare abstract class ViewSetProxyBase<K extends KeyType, T, PK extends keyof T> extends ViewSetInternals implements BulkViewSetMixin<K, T, PK>, CursorListMixin<T>, PaginatedListMixin<T>, LookupMixin {
85
- /**
86
- * The mixins this ViewSet is composed of — the FE counterpart of a BE viewset's base classes.
87
- *
88
- * class ItemViewSet extends RestProxyImpl<number, Item, 'id'> {
89
- * static declares = [ReadOnlyViewSetMixin, LookupMixin];
90
- * }
91
- *
92
- * Left undefined, the ViewSet is not checked against the BE schema at all. That is deliberate:
93
- * a ViewSet that never said what it has cannot be caught contradicting itself, and guessing on
94
- * its behalf is what made the check report actions nobody ever claimed.
95
- */
96
- static declares?: readonly ViewSetMixinDeclaration[];
97
- /**
98
- * Which field of `T` is the primary key, e.g. `'id'`. `public`, not `protected`: nothing in this
99
- * library reads it back, but a generic caller holding a ViewSet instance - a grid or table
100
- * component needing to know which column identifies a row - has no other way to ask.
101
- */
102
- readonly pkFieldName: string;
103
- private readonly schemaValidationEnabled;
104
- private readonly declaredMixins?;
105
- protected constructor(options: ProxyBaseOptions);
106
- /**
107
- * Starts the advisory schema check. Subclasses must call this as the *last* statement of their
108
- * constructor, never the base constructor itself: `request()` reads fields the subclass has not
109
- * assigned yet while `super()` is still running, and since the check swallows its own errors,
110
- * doing it here would leave it permanently and silently dead.
111
- */
112
- protected initSchemaValidation(): void;
113
- /** Abstract here, where a transport is actually held to it. See ViewSetInternals.request. */
114
- protected abstract request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
115
- /**
116
- * Fetches the BE schema and compares it against what this ViewSet declared.
117
- * Logs a console warning for any mismatch found.
118
- *
119
- * The comparison is against `static declares`, not against which methods exist on the object:
120
- * every action is implemented unconditionally on this class, so `typeof this[action]` is true for
121
- * every ViewSet and answers a question nobody asked. `declares` is the only place the FE says
122
- * anything a BE viewset could disagree with.
123
- *
124
- * Non-critical: errors during fetch or parsing are silently ignored. Note that the schema is
125
- * fetched over this proxy's own transport, so a muxws proxy validates against the muxws
126
- * endpoint set and a REST proxy against the REST one — which is the point, since the two are
127
- * allowed to differ.
128
- */
129
- private validateAgainstSchema;
130
- create(data: Omit<T, PK>): Promise<T>;
131
- bulkCreate(data: Omit<T, PK>[]): Promise<T[]>;
132
- list(params?: ListParams): Promise<T[]>;
133
- /**
134
- * Fetches one page. Only meaningful against a viewset built on the BE PaginatedListMixin — a
135
- * plain ListMixin ignores offset/limit and answers with the whole collection, which would not
136
- * match this return type.
137
- *
138
- * The BE speaks snake_case (`has_more`); the rest of this client speaks whatever the model
139
- * declares, so only the envelope's own fields are renamed here. The records inside are passed
140
- * through untouched.
141
- */
142
- /**
143
- * Fetches one cursor page. Only meaningful against a viewset built on the BE CursorListMixin.
144
- *
145
- * Follow `next` to walk forward. Unlike offset paging, a row inserted or removed behind you
146
- * cannot make the next page repeat or skip anything.
147
- */
148
- listCursor(params?: CursorParams): Promise<CursorPage<T>>;
149
- listPage(params?: PageParams): Promise<PaginatedList<T>>;
150
- retrieve(pk: K): Promise<T>;
151
- update(pk: K, data: T): Promise<T>;
152
- partialUpdate(pk: K, data: Partial<T>): Promise<T>;
153
- bulkUpdate(records: Record<K, T>): Promise<T[]>;
154
- bulkPartialUpdate(records: Record<K, Partial<T>>): Promise<T[]>;
155
- destroy(pk: K): Promise<DestroyReturnData>;
156
- bulkDestroy(pks: K[]): Promise<DestroyReturnData[]>;
157
- lookup(): Promise<LookupItem[]>;
158
- }
159
- //# sourceMappingURL=proxy-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxy-base.d.ts","sourceRoot":"","sources":["../vue/proxy-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAEV,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACb,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAErE,6FAA6F;AAC7F,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,M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AAC,CAAC,CAAC;IAuBzD,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAmBxD,QAAQ,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAI3B,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlC,aAAa,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlD,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAI/C,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAI/D,OAAO,CAAC,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI1C,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAInD,MAAM,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;CAGtC"}
@@ -1,84 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { KeyType } from './mixins';
3
- import { FACTORY_BUILT, HttpMethod, ProxyBaseOptions, RequestOptions, ViewSetProxyBase } from './proxy-base';
4
- /** ViewSet class constructor (for type-level introspection only). */
5
- type ViewSetClass = abstract new (...args: any[]) => any;
6
- /**
7
- * The shape a factory-built class's constructor has, purely to give `route_rest` an overload that
8
- * rejects it - a type parameter conditioned on the argument (`C extends FactoryBuiltClass ? ... :
9
- * C`) cannot be inferred from that position at all, so an overload with this as a plain parameter
10
- * type is the only form that actually sees the real argument.
11
- *
12
- * `route_rest` uses its `viewSetClass` argument only for the `declares` on it (see the function
13
- * body - the class itself is never `new`'d), then builds a bare `RestProxyImpl` and hands it back
14
- * cast to `M`. Pass a factory-built class and this still type-checks without the overload below -
15
- * `M` is usually inferred as `InstanceType<typeof ItemApi>` - but the object it returns is not an
16
- * `ItemApi`, so any custom method the factory-built class added is `undefined` at runtime despite
17
- * compiling. `declares` is required here, not optional: a hand-written class
18
- * (`class ItemViewSet extends RestProxyImpl<...> {}`) may have no `declares` at all, or one that is
19
- * a plain array rather than carrying `FACTORY_BUILT`, and either must fall through to the real
20
- * overload below rather than match this one.
21
- */
22
- type FactoryBuiltClass = (abstract new (...args: any[]) => any) & {
23
- declares: {
24
- readonly [FACTORY_BUILT]: any;
25
- };
26
- };
27
- /** Never assigned; its only use is `typeof FACTORY_BUILT_REJECTION` as a self-describing return type. */
28
- declare const FACTORY_BUILT_REJECTION: 'route_rest cannot take a factory-built class - extend it directly instead';
29
- /**
30
- * The REST proxy type is simply the mixin interface `M` the caller declares.
31
- * Because TypeScript cannot inspect Python class hierarchies at runtime, the
32
- * caller provides the explicit type via the generic parameter `M` (see route_rest).
33
- */
34
- export type RestProxy<M> = M;
35
- export interface RestProxyOptions extends ProxyBaseOptions {
36
- /** Optional: existing axios instance. Defaults to the global axios. */
37
- axiosInstance?: AxiosInstance;
38
- }
39
- export declare class RestProxyImpl<K extends KeyType, T, PK extends keyof T> extends ViewSetProxyBase<K, T, PK> {
40
- protected readonly http: AxiosInstance;
41
- constructor(options: RestProxyOptions);
42
- /**
43
- * Dispatches to axios' per-verb methods rather than to `http.request()`, deliberately. Those
44
- * are the calls this proxy has always made, and they are what application interceptors and test
45
- * doubles are written against — routing everything through `request()` would be invisible on
46
- * the wire but would break every one of them.
47
- *
48
- * axios throws its own AxiosError on a non-2xx, which already carries `response.status` — the
49
- * shape ViewSetRequestError mirrors for the muxws side. Nothing to translate here.
50
- */
51
- protected request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
52
- }
53
- /**
54
- * Registers a REST proxy for the given ViewSet class.
55
- *
56
- * The generic parameter `M` determines which mixin interfaces are available —
57
- * typically the ViewSet type (or a union of mixin interfaces).
58
- *
59
- * @example
60
- * ```ts
61
- * import type { BulkViewSetMixin, LookupMixin } from './mixins';
62
- *
63
- * interface Item { id: number; name: string }
64
- *
65
- * // with separate arguments (recommended)
66
- * const restItems = route_rest<BulkViewSetMixin<number, Item> & LookupMixin>(
67
- * ItemViewSet, '/items', 'id',
68
- * );
69
- *
70
- * // or with an options object
71
- * const restItems2 = route_rest<BulkViewSetMixin<number, Item> & LookupMixin>(
72
- * ItemViewSet, { basePath: '/items', pkFieldName: 'id' },
73
- * );
74
- *
75
- * const items = await restItems.list();
76
- * const item = await restItems.retrieve(1);
77
- * ```
78
- */
79
- declare function route_rest<M = never>(viewSetClass: FactoryBuiltClass, basePath: string, pkFieldName: string, axiosInstance?: AxiosInstance): typeof FACTORY_BUILT_REJECTION;
80
- declare function route_rest<M = never>(viewSetClass: FactoryBuiltClass, options: RestProxyOptions): typeof FACTORY_BUILT_REJECTION;
81
- declare function route_rest<M>(_viewSetClass: ViewSetClass, basePath: string, pkFieldName: string, axiosInstance?: AxiosInstance): RestProxy<M>;
82
- declare function route_rest<M>(_viewSetClass: ViewSetClass, options: RestProxyOptions): RestProxy<M>;
83
- export { route_rest };
84
- //# sourceMappingURL=rest-proxy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rest-proxy.d.ts","sourceRoot":"","sources":["../vue/rest-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,aAAa,EACb,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAEnB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAMtB,qEAAqE;AAErE,KAAK,YAAY,GAAG,QAAQ,MAAM,GAAG,I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