@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/dist/fastapi-viewsets.js +142 -120
- 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 +695 -11
- package/package.json +6 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/mixins.d.ts +0 -199
- package/dist/mixins.d.ts.map +0 -1
- package/dist/muxws-proxy.d.ts +0 -69
- package/dist/muxws-proxy.d.ts.map +0 -1
- package/dist/proxy-base.d.ts +0 -159
- package/dist/proxy-base.d.ts.map +0 -1
- package/dist/rest-proxy.d.ts +0 -84
- package/dist/rest-proxy.d.ts.map +0 -1
- package/dist/viewset.d.ts +0 -69
- package/dist/viewset.d.ts.map +0 -1
package/dist/viewset.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { ActionName, ActionSurface, KeyType } from './mixins';
|
|
2
|
-
import { MuxwsProxyOptions } from './muxws-proxy';
|
|
3
|
-
import { FACTORY_BUILT, 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
|
-
* Brands a factory-built class's `declares` so a subclass restating it fails on one flat "missing
|
|
22
|
-
* property" line naming `declares` itself, rather than TypeScript recursing into which method each
|
|
23
|
-
* mixin in the plain, unbranded replacement array is missing relative to the original. A record
|
|
24
|
-
* type wrapping `D` behind the phantom key, not `D & {brand}`: an intersection would still expose
|
|
25
|
-
* `D`'s own array shape to the comparison and recurse into it exactly as before; a plain array
|
|
26
|
-
* literal has no property at all under this key, so the mismatch stops at the top. Erased at
|
|
27
|
-
* runtime - `bindViewSet` casts through `unknown`, so the actual `static declares` stays a plain
|
|
28
|
-
* array, and every internal reader (rest-proxy.ts, muxws-proxy.ts, proxy-base.ts's
|
|
29
|
-
* `declaredActions`) already reads it through its own cast rather than this type.
|
|
30
|
-
*
|
|
31
|
-
* `FACTORY_BUILT` lives in proxy-base.ts, not here, so `route_rest`/`route_muxws` can check for the
|
|
32
|
-
* same brand without importing from this module - see proxy-base.ts's doc comment on the symbol.
|
|
33
|
-
*/
|
|
34
|
-
type FactoryDeclares<D extends readonly ViewSetMixinClass[]> = {
|
|
35
|
-
readonly [FACTORY_BUILT]: D;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* What the factory hands back: a class to extend.
|
|
39
|
-
*
|
|
40
|
-
* A `declares` list naming no action — `[]`, or one annotated `ViewSetMixinClass[]`, which erases
|
|
41
|
-
* which mixins are in it — would otherwise produce a ViewSet with no actions and no complaint.
|
|
42
|
-
* TS2507 prints the type it was given, so the type is the sentence.
|
|
43
|
-
*
|
|
44
|
-
* `pkFieldName: PK` is added on top of `ViewSetInternals` explicitly: the constructed instance's
|
|
45
|
-
* real runtime type is `ProxyBaseOptions`'s `ViewSetProxyBase`, which already carries the public
|
|
46
|
-
* `pkFieldName`, but `ViewSetInternals` is deliberately narrow (see its own doc comment), so this
|
|
47
|
-
* type would otherwise hide a field that is genuinely there. Typed as the literal `PK` rather than
|
|
48
|
-
* `string`, since the factory already knows exactly which field it is.
|
|
49
|
-
*/
|
|
50
|
-
export type ViewSetClass<T, PK extends keyof T, D extends readonly ViewSetMixinClass[], O extends ProxyBaseOptions> = [
|
|
51
|
-
ActionsOf<D[number]>
|
|
52
|
-
] extends [never] ? 'declares must name at least one action: pass the mixin classes themselves, unannotated' : {
|
|
53
|
-
new (options: Omit<O, 'pkFieldName' | 'declares'>): ViewSetInternals & ActionSurface<PkType<T, PK>, T, PK, ActionsOf<D[number]>> & {
|
|
54
|
-
readonly pkFieldName: PK;
|
|
55
|
-
};
|
|
56
|
-
readonly declares: FactoryDeclares<D>;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* A REST ViewSet base class.
|
|
60
|
-
*
|
|
61
|
-
* The empty `()` is not decoration: TypeScript has no partial type-argument inference, so the model
|
|
62
|
-
* cannot be given explicitly while the pk field and the mixin list are inferred from arguments in
|
|
63
|
-
* the same call (TS2558). Currying is the only way to have both.
|
|
64
|
-
*/
|
|
65
|
-
export declare function restViewSet<T>(): <PK extends PkFieldName<T> & keyof T, D extends readonly ViewSetMixinClass[]>(pkFieldName: PK, declares: D) => ViewSetClass<T, PK, D, RestProxyOptions>;
|
|
66
|
-
/** A muxws ViewSet base class. See `restViewSet` for why the call is curried. */
|
|
67
|
-
export declare function muxwsViewSet<T>(): <PK extends PkFieldName<T> & keyof T, D extends readonly ViewSetMixinClass[]>(pkFieldName: PK, declares: D) => ViewSetClass<T, PK, D, MuxwsProxyOptions>;
|
|
68
|
-
export {};
|
|
69
|
-
//# sourceMappingURL=viewset.d.ts.map
|
package/dist/viewset.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|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