@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/dist/mixins.d.ts CHANGED
@@ -1,12 +1,28 @@
1
1
  /**
2
- * FE counterpart of BE mixins.py — abstract mixin classes for ViewSet declarations.
2
+ * FE counterpart of BE mixins.py — the mixins a ViewSet declaration is composed of.
3
3
  *
4
- * Each mixin class corresponds to its BE counterpart. ViewSet classes on the FE
5
- * declare their capabilities by extending these mixins, mirroring the BE pattern:
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.
6
8
  *
7
- * class ItemViewSet extends BulkViewSetMixin<number, Item> implements LookupMixin {}
9
+ * class ItemViewSet extends restViewSet<Item>()('id', [ReadOnlyViewSetMixin, LookupMixin]) {}
8
10
  *
9
- * The actual HTTP implementation is provided by RestProxyImpl via route_rest().
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.
10
26
  */
11
27
  export interface LookupItem {
12
28
  group: unknown;
@@ -16,58 +32,168 @@ export interface LookupItem {
16
32
  }
17
33
  export type KeyType = string | number;
18
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
+ }
19
38
  export declare class CreateMixin<T, PK extends keyof T> {
20
- create: (data: Omit<T, PK>) => Promise<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[]>;
21
43
  }
22
44
  export declare class BulkOnlyCreateMixin<T, PK extends keyof T> {
23
- bulkCreate: (data: Omit<T, PK>[]) => Promise<T[]>;
45
+ static readonly actions: readonly string[];
24
46
  }
25
- export declare class BulkCreateMixin<T, PK extends keyof T> extends CreateMixin<T, PK> implements BulkOnlyCreateMixin<T, PK> {
26
- bulkCreate: (data: Omit<T, PK>[]) => Promise<T[]>;
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[]>;
27
54
  }
28
55
  export declare class ListMixin<T> {
29
- list: () => Promise<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>;
30
127
  }
31
128
  export declare class RetrieveMixin<K extends KeyType, T> {
32
- retrieve: (pk: K) => Promise<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>;
33
134
  }
34
135
  export declare class UpdateMixin<K extends KeyType, T> {
35
- update: (pk: K, data: T) => Promise<T>;
36
- partialUpdate: (pk: K, data: Partial<T>) => Promise<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[]>;
37
141
  }
38
142
  export declare class BulkOnlyUpdateMixin<K extends KeyType, T> {
39
- bulkUpdate: (records: Record<K, T>) => Promise<T[]>;
40
- bulkPartialUpdate: (records: Record<K, Partial<T>>) => Promise<T[]>;
143
+ static readonly actions: readonly string[];
144
+ }
145
+ export interface BulkUpdateMixin<K extends KeyType, T> extends UpdateMixin<K, T>, BulkOnlyUpdateMixin<K, T> {
41
146
  }
42
- export declare class BulkUpdateMixin<K extends KeyType, T> extends UpdateMixin<K, T> implements BulkOnlyUpdateMixin<K, T> {
43
- bulkUpdate: (records: Record<K, T>) => Promise<T[]>;
44
- bulkPartialUpdate: (records: Record<K, Partial<T>>) => Promise<T[]>;
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>;
45
152
  }
46
153
  export declare class DestroyMixin<K extends KeyType> {
47
- destroy: (pk: K) => Promise<DestroyReturnData>;
154
+ static readonly actions: readonly string[];
155
+ }
156
+ export interface BulkOnlyDestroyMixin<K extends KeyType> {
157
+ bulkDestroy(pks: K[]): Promise<DestroyReturnData[]>;
48
158
  }
49
159
  export declare class BulkOnlyDestroyMixin<K extends KeyType> {
50
- bulkDestroy: (pks: K[]) => Promise<DestroyReturnData[]>;
160
+ static readonly actions: readonly string[];
51
161
  }
52
- export declare class BulkDestroyMixin<K extends KeyType> extends DestroyMixin<K> implements BulkOnlyDestroyMixin<K> {
53
- bulkDestroy: (pks: K[]) => Promise<DestroyReturnData[]>;
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[]>;
54
169
  }
55
170
  export declare class LookupMixin {
56
- lookup: () => Promise<LookupItem[]>;
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[];
57
177
  }
58
- export declare class ReadOnlyViewSetMixin<K extends KeyType, T> extends ListMixin<T> implements RetrieveMixin<K, T> {
59
- retrieve: (pk: K) => Promise<T>;
178
+ export interface ViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ReadOnlyViewSetMixin<K, T>, CreateMixin<T, PK>, UpdateMixin<K, T>, DestroyMixin<K> {
60
179
  }
61
- export declare class ViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ReadOnlyViewSetMixin<K, T> implements CreateMixin<T, PK>, UpdateMixin<K, T>, DestroyMixin<K> {
62
- create: (data: Omit<T, PK>) => Promise<T>;
63
- update: (pk: K, data: T) => Promise<T>;
64
- partialUpdate: (pk: K, data: Partial<T>) => Promise<T>;
65
- destroy: (pk: K) => Promise<Record<string, unknown>>;
180
+ export declare class ViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ReadOnlyViewSetMixin<K, T> {
181
+ static readonly actions: readonly string[];
66
182
  }
67
- export declare class BulkViewSetMixin<K extends KeyType, T, PK extends keyof T> extends ViewSetMixin<K, T, PK> implements BulkCreateMixin<T, PK>, BulkUpdateMixin<K, T>, BulkDestroyMixin<K> {
68
- bulkCreate: (data: Omit<T, PK>[]) => Promise<T[]>;
69
- bulkUpdate: (records: Record<K, T>) => Promise<T[]>;
70
- bulkPartialUpdate: (records: Record<K, Partial<T>>) => Promise<T[]>;
71
- bulkDestroy: (pks: K[]) => Promise<Record<string, unknown>[]>;
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> {
72
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>;
73
199
  //# sourceMappingURL=mixins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mixins.d.ts","sourceRoot":"","sources":["../vue/mixins.ts"],"names":[],"mappings":"AAAA;;;;;;;;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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"}
@@ -0,0 +1,56 @@
1
+ import { KeyType } from './mixins';
2
+ import { 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
+ export interface MuxwsProxyOptions extends ProxyBaseOptions {
31
+ peer: MuxwsPeerSource;
32
+ /** Per-request timeout in milliseconds. muxws resets the stream with TIMEOUT when it expires. */
33
+ timeoutMs?: number;
34
+ /**
35
+ * Headers added to every request this proxy makes. The WebSocket handshake already carries
36
+ * whatever identified the session and the server treats that as the baseline; these override it
37
+ * for this proxy's calls. There is no per-call header: `RequestOptions` is `{ query, body }`.
38
+ */
39
+ headers?: Record<string, string>;
40
+ }
41
+ export declare class MuxwsProxyImpl<K extends KeyType, T, PK extends keyof T> extends ViewSetProxyBase<K, T, PK> {
42
+ private readonly peerSource;
43
+ private readonly timeoutMs?;
44
+ private readonly headers;
45
+ private peerPromise?;
46
+ constructor(options: MuxwsProxyOptions);
47
+ private peer;
48
+ protected request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
49
+ }
50
+ /**
51
+ * Registers a muxws proxy for the given ViewSet class. The mirror of route_rest, and it takes the
52
+ * same generic parameter for the same reason: TypeScript cannot inspect the Python class.
53
+ */
54
+ declare function route_muxws<M>(viewSetClass: ViewSetClass, options: MuxwsProxyOptions): MuxwsProxy<M>;
55
+ export { route_muxws };
56
+ //# sourceMappingURL=muxws-proxy.d.ts.map
@@ -0,0 +1 @@
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,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,CA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CAO7F;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,145 @@
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
+ export interface ProxyBaseOptions {
33
+ /** Base path to the resource, e.g. '/items'. */
34
+ basePath: string;
35
+ /** Name of the PK field on the model, e.g. 'id'. */
36
+ pkFieldName: string;
37
+ /** Set false to skip the startup schema check (it is advisory and costs one request). */
38
+ validateSchema?: boolean;
39
+ /**
40
+ * The mixins the ViewSet declares, for the `route_rest` / `route_muxws` path: those build a bare
41
+ * proxy and use the ViewSet class only for typing, so a `static declares` on it would otherwise
42
+ * never reach the object being checked.
43
+ */
44
+ declares?: readonly ViewSetMixinDeclaration[];
45
+ }
46
+ /**
47
+ * What a ViewSet's own methods may reach - everything a custom endpoint needs, and nothing a caller
48
+ * does.
49
+ *
50
+ * A real base class rather than a type, because `protected` is checked nominally: a subclass body
51
+ * reaches `request()` only if it genuinely descends from the class that declared it. The ViewSet
52
+ * factory hands back a class typed as this plus the declared actions, which is how a factory-built
53
+ * ViewSet ends up with a narrow public surface and a usable private one.
54
+ */
55
+ export declare abstract class ViewSetInternals {
56
+ protected readonly basePath: string;
57
+ protected constructor(basePath: string);
58
+ /**
59
+ * Sends one request and returns the decoded response body.
60
+ *
61
+ * `path` is relative to `basePath` — '' for the collection, '/1' for a record, '/bulk', and so
62
+ * on. Implementations must throw on a status of 400 or above, with `response.status` readable on
63
+ * the thrown value. Below 400 the two differ, on a band a caller rarely sees: the muxws proxy
64
+ * returns the body for any 3xx, while the REST proxy follows a redirect it can follow and rejects
65
+ * whatever axios' default `validateStatus` then leaves outside 200-299.
66
+ *
67
+ * Concrete here, and never reached: ViewSetProxyBase re-declares it abstract, which is where a
68
+ * transport is actually held to implementing it. It cannot be abstract at this level because
69
+ * TypeScript propagates an abstract member through a constructor type, and the factory hands one
70
+ * back - every ViewSet a consumer wrote would then fail TS2515 for a method the transport
71
+ * underneath it has always implemented.
72
+ */
73
+ protected request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
74
+ }
75
+ 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 {
76
+ /**
77
+ * The mixins this ViewSet is composed of — the FE counterpart of a BE viewset's base classes.
78
+ *
79
+ * class ItemViewSet extends RestProxyImpl<number, Item, 'id'> {
80
+ * static declares = [ReadOnlyViewSetMixin, LookupMixin];
81
+ * }
82
+ *
83
+ * Left undefined, the ViewSet is not checked against the BE schema at all. That is deliberate:
84
+ * a ViewSet that never said what it has cannot be caught contradicting itself, and guessing on
85
+ * its behalf is what made the check report actions nobody ever claimed.
86
+ */
87
+ static declares?: readonly ViewSetMixinDeclaration[];
88
+ protected readonly pkFieldName: string;
89
+ private readonly schemaValidationEnabled;
90
+ private readonly declaredMixins?;
91
+ protected constructor(options: ProxyBaseOptions);
92
+ /**
93
+ * Starts the advisory schema check. Subclasses must call this as the *last* statement of their
94
+ * constructor, never the base constructor itself: `request()` reads fields the subclass has not
95
+ * assigned yet while `super()` is still running, and since the check swallows its own errors,
96
+ * doing it here would leave it permanently and silently dead.
97
+ */
98
+ protected initSchemaValidation(): void;
99
+ /** Abstract here, where a transport is actually held to it. See ViewSetInternals.request. */
100
+ protected abstract request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
101
+ /**
102
+ * Fetches the BE schema and compares it against what this ViewSet declared.
103
+ * Logs a console warning for any mismatch found.
104
+ *
105
+ * The comparison is against `static declares`, not against which methods exist on the object:
106
+ * every action is implemented unconditionally on this class, so `typeof this[action]` is true for
107
+ * every ViewSet and answers a question nobody asked. `declares` is the only place the FE says
108
+ * anything a BE viewset could disagree with.
109
+ *
110
+ * Non-critical: errors during fetch or parsing are silently ignored. Note that the schema is
111
+ * fetched over this proxy's own transport, so a muxws proxy validates against the muxws
112
+ * endpoint set and a REST proxy against the REST one — which is the point, since the two are
113
+ * allowed to differ.
114
+ */
115
+ private validateAgainstSchema;
116
+ create(data: Omit<T, PK>): Promise<T>;
117
+ bulkCreate(data: Omit<T, PK>[]): Promise<T[]>;
118
+ list(params?: ListParams): Promise<T[]>;
119
+ /**
120
+ * Fetches one page. Only meaningful against a viewset built on the BE PaginatedListMixin — a
121
+ * plain ListMixin ignores offset/limit and answers with the whole collection, which would not
122
+ * match this return type.
123
+ *
124
+ * The BE speaks snake_case (`has_more`); the rest of this client speaks whatever the model
125
+ * declares, so only the envelope's own fields are renamed here. The records inside are passed
126
+ * through untouched.
127
+ */
128
+ /**
129
+ * Fetches one cursor page. Only meaningful against a viewset built on the BE CursorListMixin.
130
+ *
131
+ * Follow `next` to walk forward. Unlike offset paging, a row inserted or removed behind you
132
+ * cannot make the next page repeat or skip anything.
133
+ */
134
+ listCursor(params?: CursorParams): Promise<CursorPage<T>>;
135
+ listPage(params?: PageParams): Promise<PaginatedList<T>>;
136
+ retrieve(pk: K): Promise<T>;
137
+ update(pk: K, data: T): Promise<T>;
138
+ partialUpdate(pk: K, data: Partial<T>): Promise<T>;
139
+ bulkUpdate(records: Record<K, T>): Promise<T[]>;
140
+ bulkPartialUpdate(records: Record<K, Partial<T>>): Promise<T[]>;
141
+ destroy(pk: K): Promise<DestroyReturnData>;
142
+ bulkDestroy(pks: K[]): Promise<DestroyReturnData[]>;
143
+ lookup(): Promise<LookupItem[]>;
144
+ }
145
+ //# sourceMappingURL=proxy-base.d.ts.map
@@ -0,0 +1 @@
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,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAEhH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,QAAQ,EA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AAC,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,5 +1,6 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { BulkViewSetMixin, DestroyReturnData, KeyType, LookupItem, LookupMixin } from './mixins';
2
+ import { KeyType } from './mixins';
3
+ import { HttpMethod, ProxyBaseOptions, RequestOptions, ViewSetProxyBase } from './proxy-base';
3
4
  /** ViewSet class constructor (for type-level introspection only). */
4
5
  type ViewSetClass = abstract new (...args: any[]) => any;
5
6
  /**
@@ -8,36 +9,23 @@ type ViewSetClass = abstract new (...args: any[]) => any;
8
9
  * caller provides the explicit type via the generic parameter `M` (see route_rest).
9
10
  */
10
11
  export type RestProxy<M> = M;
11
- export interface RestProxyOptions {
12
- /** Base path to the resource, e.g. '/items'. */
13
- basePath: string;
14
- /** Name of the PK field on the model, e.g. 'id'. */
15
- pkFieldName: string;
12
+ export interface RestProxyOptions extends ProxyBaseOptions {
16
13
  /** Optional: existing axios instance. Defaults to the global axios. */
17
14
  axiosInstance?: AxiosInstance;
18
15
  }
19
- export declare class RestProxyImpl<K extends KeyType, T, PK extends keyof T> implements BulkViewSetMixin<K, T, PK>, LookupMixin {
16
+ export declare class RestProxyImpl<K extends KeyType, T, PK extends keyof T> extends ViewSetProxyBase<K, T, PK> {
20
17
  protected readonly http: AxiosInstance;
21
- protected readonly basePath: string;
22
- protected readonly pkFieldName: string;
23
18
  constructor(options: RestProxyOptions);
24
19
  /**
25
- * Fetches the BE schema and compares it against the FE method set.
26
- * Logs a console warning for any mismatch found.
27
- * Non-critical: errors during fetch or parsing are silently ignored.
20
+ * Dispatches to axios' per-verb methods rather than to `http.request()`, deliberately. Those
21
+ * are the calls this proxy has always made, and they are what application interceptors and test
22
+ * doubles are written against routing everything through `request()` would be invisible on
23
+ * the wire but would break every one of them.
24
+ *
25
+ * axios throws its own AxiosError on a non-2xx, which already carries `response.status` — the
26
+ * shape ViewSetRequestError mirrors for the muxws side. Nothing to translate here.
28
27
  */
29
- private validateAgainstSchema;
30
- create(data: Omit<T, PK>): Promise<T>;
31
- bulkCreate(data: Omit<T, PK>[]): Promise<T[]>;
32
- list(): Promise<T[]>;
33
- retrieve(pk: K): Promise<T>;
34
- update(pk: K, data: T): Promise<T>;
35
- partialUpdate(pk: K, data: Partial<T>): Promise<T>;
36
- bulkUpdate(records: Record<K, T>): Promise<T[]>;
37
- bulkPartialUpdate(records: Record<K, Partial<T>>): Promise<T[]>;
38
- destroy(pk: K): Promise<DestroyReturnData>;
39
- bulkDestroy(pks: K[]): Promise<DestroyReturnData[]>;
40
- lookup(): Promise<LookupItem[]>;
28
+ protected request<R>(method: HttpMethod, path: string, options?: RequestOptions): Promise<R>;
41
29
  }
42
30
  /**
43
31
  * Registers a REST proxy for the given ViewSet class.
@@ -1 +1 @@
1
- {"version":3,"file":"rest-proxy.d.ts","sourceRoot":"","sources":["../vue/rest-proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAc,EAAE,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAgDtG,qEAAqE;AAErE,KAAK,YAAY,GAAG,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEzD;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WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,uEAAuE;IACvE,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAMD,qBAAa,aAAa,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,MAAM,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACrG,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;gBAE3B,OAAO,EAAE,gBAAgB;IAMrC;;;;;;;;OAQG;cACa,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC;CAsCvG;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,iBAAS,UAAU,CAAC,CAAC,EACnB,aAAa,EAAE,YAAY,EAC3B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,aAAa,GAC5B,SAAS,CAAC,CAAC,CAAC,CAAC;AAChB,iBAAS,UAAU,CAAC,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAuB7F,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { ActionName, ActionSurface, KeyType } from './mixins';
2
+ import { MuxwsProxyOptions } from './muxws-proxy';
3
+ import { ProxyBaseOptions, ViewSetInternals, ViewSetMixinDeclaration } from './proxy-base';
4
+ import { RestProxyOptions } from './rest-proxy';
5
+ /** A mixin class: the runtime `actions` the schema check reads, and the type naming those actions. */
6
+ export type ViewSetMixinClass = ViewSetMixinDeclaration & (abstract new (...args: any[]) => object);
7
+ /**
8
+ * The actions a mixin class names, read off its instance type.
9
+ *
10
+ * The instance type rather than the `actions` tuple, because a tuple would have to be `as const` on
11
+ * every mixin, and a `readonly ['create']` static cannot then be inherited by a composite whose own
12
+ * static is a different tuple (TS2417). `D` is naked so that a union of mixins distributes.
13
+ */
14
+ type ActionsOf<D> = D extends abstract new (...args: any[]) => infer I ? Extract<keyof I, ActionName> : never;
15
+ /** The fields of `T` that could be a primary key. */
16
+ export type PkFieldName<T> = Extract<{
17
+ [F in keyof T]-?: NonNullable<T[F]> extends KeyType ? F : never;
18
+ }[keyof T], string>;
19
+ type PkType<T, PK extends keyof T> = NonNullable<T[PK]> & KeyType;
20
+ /**
21
+ * What the factory hands back: a class to extend.
22
+ *
23
+ * A `declares` list naming no action — `[]`, or one annotated `ViewSetMixinClass[]`, which erases
24
+ * which mixins are in it — would otherwise produce a ViewSet with no actions and no complaint.
25
+ * TS2507 prints the type it was given, so the type is the sentence.
26
+ */
27
+ export type ViewSetClass<T, PK extends keyof T, D extends readonly ViewSetMixinClass[], O extends ProxyBaseOptions> = [
28
+ ActionsOf<D[number]>
29
+ ] extends [never] ? 'declares must name at least one action: pass the mixin classes themselves, unannotated' : {
30
+ new (options: Omit<O, 'pkFieldName' | 'declares'>): ViewSetInternals & ActionSurface<PkType<T, PK>, T, PK, ActionsOf<D[number]>>;
31
+ readonly declares: D;
32
+ };
33
+ /**
34
+ * A REST ViewSet base class.
35
+ *
36
+ * The empty `()` is not decoration: TypeScript has no partial type-argument inference, so the model
37
+ * cannot be given explicitly while the pk field and the mixin list are inferred from arguments in
38
+ * the same call (TS2558). Currying is the only way to have both.
39
+ */
40
+ export declare function restViewSet<T>(): <PK extends PkFieldName<T> & keyof T, D extends readonly ViewSetMixinClass[]>(pkFieldName: PK, declares: D) => ViewSetClass<T, PK, D, RestProxyOptions>;
41
+ /** A muxws ViewSet base class. See `restViewSet` for why the call is curried. */
42
+ export declare function muxwsViewSet<T>(): <PK extends PkFieldName<T> & keyof T, D extends readonly ViewSetMixinClass[]>(pkFieldName: PK, declares: D) => ViewSetClass<T, PK, D, MuxwsProxyOptions>;
43
+ export {};
44
+ //# sourceM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