@danceroutine/tango-resources 1.11.3 → 1.11.4
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 +2 -2
- package/dist/CursorPaginator-B_8MhYZY.js +195 -0
- package/dist/CursorPaginator-B_8MhYZY.js.map +1 -0
- package/dist/CursorPaginator-CfeMQCdJ.d.ts +177 -0
- package/dist/OffsetPaginator-CaycvxJU.js +188 -0
- package/dist/OffsetPaginator-CaycvxJU.js.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.js +2 -0
- package/dist/context-euBQvNRT.js +65 -0
- package/dist/context-euBQvNRT.js.map +1 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.js +2 -0
- package/dist/filters-46d2Nr5C.js +287 -0
- package/dist/filters-46d2Nr5C.js.map +1 -0
- package/dist/index-Ac94YL5S.d.ts +24 -0
- package/dist/index-BJJalUDB.d.ts +54 -0
- package/dist/index-Bg6TtnmQ.d.ts +175 -0
- package/dist/index-C55GDIOn.d.ts +222 -0
- package/dist/index-CiIB-1Ac.d.ts +123 -0
- package/dist/index-DkJtxvKu.d.ts +164 -0
- package/dist/index.d.ts +10 -12
- package/dist/index.js +10 -1013
- package/dist/inferModelFieldParsers-2irv7j1T.js +70 -0
- package/dist/inferModelFieldParsers-2irv7j1T.js.map +1 -0
- package/dist/pagination/index.d.ts +3 -0
- package/dist/pagination/index.js +15 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/paginators/index.d.ts +9 -0
- package/dist/paginators/index.js +12 -0
- package/dist/paginators/index.js.map +1 -0
- package/dist/resource/index.d.ts +3 -0
- package/dist/resource/index.js +7 -0
- package/dist/resource/index.js.map +1 -0
- package/dist/serializer/index.d.ts +2 -0
- package/dist/serializer/index.js +2 -0
- package/dist/serializer-RSwlXWls.js +305 -0
- package/dist/serializer-RSwlXWls.js.map +1 -0
- package/dist/view/index.d.ts +2 -1
- package/dist/view/index.js +1 -1
- package/dist/{view-C9B5Lln3.js → view-CYdJAO4t.js} +7 -314
- package/dist/view-CYdJAO4t.js.map +1 -0
- package/dist/viewset/index.d.ts +9 -0
- package/dist/viewset/index.js +2 -0
- package/dist/viewset-C9j-2U29.js +227 -0
- package/dist/viewset-C9j-2U29.js.map +1 -0
- package/package.json +21 -17
- package/dist/index-D6sfTSEj.d.ts +0 -902
- package/dist/index.js.map +0 -1
- package/dist/view-C9B5Lln3.js.map +0 -1
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { r as RequestContext } from "./index-BJJalUDB.js";
|
|
2
|
+
import { o as FilterSet } from "./index-CiIB-1Ac.js";
|
|
3
|
+
import { i as Paginator } from "./CursorPaginator-CfeMQCdJ.js";
|
|
4
|
+
import { C as ResourceModelMetadata, S as ResourceModelLike, g as SerializerOutput, n as AnyModelSerializer, r as AnyModelSerializerClass, x as ResourceModelFieldMetadata } from "./index-C55GDIOn.js";
|
|
5
|
+
import { TangoResponse } from "@danceroutine/tango-core";
|
|
6
|
+
import { ManagerLike, QuerySet } from "@danceroutine/tango-orm";
|
|
7
|
+
|
|
8
|
+
//#region src/view/APIView.d.ts
|
|
9
|
+
type APIViewMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
10
|
+
/**
|
|
11
|
+
* Lightweight class-based request dispatcher for non-model API endpoints.
|
|
12
|
+
*/
|
|
13
|
+
declare abstract class APIView {
|
|
14
|
+
static readonly BRAND: "tango.resources.api_view";
|
|
15
|
+
readonly __tangoBrand: typeof APIView.BRAND;
|
|
16
|
+
/**
|
|
17
|
+
* Narrow an unknown value to `APIView`.
|
|
18
|
+
*/
|
|
19
|
+
static isAPIView(value: unknown): value is APIView;
|
|
20
|
+
/**
|
|
21
|
+
* Dispatch the request to the handler for the current HTTP method.
|
|
22
|
+
*/
|
|
23
|
+
dispatch(ctx: RequestContext): Promise<TangoResponse>;
|
|
24
|
+
getAllowedMethods(): readonly APIViewMethod[];
|
|
25
|
+
protected get(_ctx: RequestContext): Promise<TangoResponse>;
|
|
26
|
+
protected post(_ctx: RequestContext): Promise<TangoResponse>;
|
|
27
|
+
protected put(_ctx: RequestContext): Promise<TangoResponse>;
|
|
28
|
+
protected patch(_ctx: RequestContext): Promise<TangoResponse>;
|
|
29
|
+
protected delete(_ctx: RequestContext): Promise<TangoResponse>;
|
|
30
|
+
protected httpMethodNotAllowed(): TangoResponse;
|
|
31
|
+
private getMethodHandler;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/viewset/ModelViewSet.d.ts
|
|
35
|
+
type ViewSetActionScope = 'detail' | 'collection';
|
|
36
|
+
type ViewSetActionMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
37
|
+
interface ViewSetActionDescriptor {
|
|
38
|
+
name: string;
|
|
39
|
+
scope: ViewSetActionScope;
|
|
40
|
+
methods: readonly ViewSetActionMethod[];
|
|
41
|
+
path?: string;
|
|
42
|
+
}
|
|
43
|
+
interface ResolvedViewSetActionDescriptor extends ViewSetActionDescriptor {
|
|
44
|
+
path: string;
|
|
45
|
+
}
|
|
46
|
+
type AnyModelViewSet = ModelViewSet<Record<string, unknown>, AnyModelSerializerClass>;
|
|
47
|
+
type SearchFieldRef$1<TModel extends Record<string, unknown>> = Extract<keyof TModel, string> | string;
|
|
48
|
+
/**
|
|
49
|
+
* Configuration for a ModelViewSet, defining how a serializer-backed model is exposed as an API resource.
|
|
50
|
+
*/
|
|
51
|
+
interface ModelViewSetConfig<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> {
|
|
52
|
+
/** Serializer class that owns validation, representation, and persistence hooks */
|
|
53
|
+
serializer: TSerializer;
|
|
54
|
+
/** Optional filter set defining which query parameters can filter the list endpoint */
|
|
55
|
+
filters?: FilterSet<TModel>;
|
|
56
|
+
/** Fields that clients are allowed to sort by via query parameters */
|
|
57
|
+
orderingFields?: (keyof TModel)[];
|
|
58
|
+
/** Fields that are searched when a free-text search query parameter is provided */
|
|
59
|
+
searchFields?: SearchFieldRef$1<TModel>[];
|
|
60
|
+
/** Optional paginator factory used by list endpoints. */
|
|
61
|
+
paginatorFactory?: (queryset: QuerySet<TModel>) => Paginator<TModel, SerializerOutput<TSerializer>>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Base class for creating RESTful API viewsets with built-in CRUD operations.
|
|
65
|
+
* Provides list, retrieve, create, update, and delete methods with filtering,
|
|
66
|
+
* search, pagination, and ordering support.
|
|
67
|
+
*/
|
|
68
|
+
declare abstract class ModelViewSet<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> {
|
|
69
|
+
static readonly BRAND: "tango.resources.model_view_set";
|
|
70
|
+
static readonly actions: readonly ViewSetActionDescriptor[];
|
|
71
|
+
readonly __tangoBrand: typeof ModelViewSet.BRAND;
|
|
72
|
+
protected readonly serializerClass: TSerializer;
|
|
73
|
+
protected readonly filters?: FilterSet<TModel>;
|
|
74
|
+
protected readonly orderingFields: (keyof TModel)[];
|
|
75
|
+
protected readonly searchFields: SearchFieldRef$1<TModel>[];
|
|
76
|
+
protected readonly paginatorFactory?: (queryset: QuerySet<TModel>) => Paginator<TModel, SerializerOutput<TSerializer>>;
|
|
77
|
+
private serializer?;
|
|
78
|
+
constructor(config: ModelViewSetConfig<TModel, TSerializer>);
|
|
79
|
+
/**
|
|
80
|
+
* Return the custom action descriptors declared by a viewset or constructor.
|
|
81
|
+
*/
|
|
82
|
+
static getActions(viewsetOrConstructor: AnyModelViewSet | (new (...args: never[]) => AnyModelViewSet)): readonly ResolvedViewSetActionDescriptor[];
|
|
83
|
+
/**
|
|
84
|
+
* Narrow an unknown value to `ModelViewSet`.
|
|
85
|
+
*/
|
|
86
|
+
static isModelViewSet(value: unknown): value is ModelViewSet<Record<string, unknown>, AnyModelSerializerClass>;
|
|
87
|
+
/**
|
|
88
|
+
* Preserve literal action inference while validating the descriptor shape.
|
|
89
|
+
*/
|
|
90
|
+
static defineViewSetActions<const T extends readonly ViewSetActionDescriptor[]>(actions: T): T;
|
|
91
|
+
private static resolvePathFromDescriptor;
|
|
92
|
+
private static toKebabCase;
|
|
93
|
+
/**
|
|
94
|
+
* Return the serializer class that owns this resource contract.
|
|
95
|
+
*/
|
|
96
|
+
getSerializerClass(): TSerializer;
|
|
97
|
+
/**
|
|
98
|
+
* Return the serializer instance for the current resource.
|
|
99
|
+
*/
|
|
100
|
+
getSerializer(): InstanceType<TSerializer>;
|
|
101
|
+
/**
|
|
102
|
+
* Describe the public HTTP contract that this resource contributes to OpenAPI generation.
|
|
103
|
+
*/
|
|
104
|
+
describeOpenAPI(): ModelViewSetOpenAPIDescription<TModel, TSerializer>;
|
|
105
|
+
/**
|
|
106
|
+
* List endpoint with filtering, search, ordering, and offset pagination.
|
|
107
|
+
*/
|
|
108
|
+
list(ctx: RequestContext): Promise<TangoResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieve endpoint for a single resource by id.
|
|
111
|
+
*/
|
|
112
|
+
retrieve(_ctx: RequestContext, id: string): Promise<TangoResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Create endpoint: validate input, persist, and return serialized output.
|
|
115
|
+
*/
|
|
116
|
+
create(ctx: RequestContext): Promise<TangoResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Update endpoint: validate partial payload and persist by id.
|
|
119
|
+
*/
|
|
120
|
+
update(ctx: RequestContext, id: string): Promise<TangoResponse>;
|
|
121
|
+
/**
|
|
122
|
+
* Destroy endpoint: delete a resource by id.
|
|
123
|
+
*/
|
|
124
|
+
destroy(_ctx: RequestContext, id: string): Promise<TangoResponse>;
|
|
125
|
+
protected getPaginator(queryset: QuerySet<TModel>): Paginator<TModel, SerializerOutput<TSerializer>>;
|
|
126
|
+
protected getManager(): ManagerLike<TModel>;
|
|
127
|
+
/**
|
|
128
|
+
* Convert thrown errors into normalized HTTP responses.
|
|
129
|
+
*/
|
|
130
|
+
protected handleError(error: unknown): TangoResponse;
|
|
131
|
+
/**
|
|
132
|
+
* Resolve route path segment(s) for a custom action.
|
|
133
|
+
* Override this in subclasses to customize path derivation globally.
|
|
134
|
+
*/
|
|
135
|
+
protected resolveActionPath(action: ViewSetActionDescriptor): string;
|
|
136
|
+
private requireModelMetadata;
|
|
137
|
+
private getLookupFieldFromMetadata;
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/resource/OpenAPIDescription.d.ts
|
|
141
|
+
type SearchFieldRef<TModel extends Record<string, unknown>> = Extract<keyof TModel, string> | string;
|
|
142
|
+
type GenericAPIViewOpenAPIDescription<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel> = AnyModelSerializer<TModel>> = {
|
|
143
|
+
model: ResourceModelLike<TModel> & {
|
|
144
|
+
metadata: NonNullable<ResourceModelLike<TModel>['metadata']>;
|
|
145
|
+
};
|
|
146
|
+
outputSchema: TSerializer['outputSchema'];
|
|
147
|
+
createSchema: TSerializer['createSchema'];
|
|
148
|
+
updateSchema: TSerializer['updateSchema'];
|
|
149
|
+
searchFields: readonly SearchFieldRef<TModel>[];
|
|
150
|
+
orderingFields: readonly (keyof TModel)[];
|
|
151
|
+
lookupField: keyof TModel;
|
|
152
|
+
lookupParam: string;
|
|
153
|
+
allowedMethods: readonly APIViewMethod[];
|
|
154
|
+
usesDefaultOffsetPagination: boolean;
|
|
155
|
+
};
|
|
156
|
+
type ModelViewSetOpenAPIDescription<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel> = AnyModelSerializer<TModel>> = GenericAPIViewOpenAPIDescription<TModel, TSerializer> & {
|
|
157
|
+
actions: readonly ResolvedViewSetActionDescriptor[];
|
|
158
|
+
};
|
|
159
|
+
declare namespace index_d_exports {
|
|
160
|
+
export { GenericAPIViewOpenAPIDescription, ModelViewSetOpenAPIDescription, ResourceModelFieldMetadata, ResourceModelLike, ResourceModelMetadata };
|
|
161
|
+
}
|
|
162
|
+
//#endregion
|
|
163
|
+
export { ModelViewSetConfig as a, ViewSetActionMethod as c, APIViewMethod as d, ModelViewSet as i, ViewSetActionScope as l, GenericAPIViewOpenAPIDescription as n, ResolvedViewSetActionDescriptor as o, ModelViewSetOpenAPIDescription as r, ViewSetActionDescriptor as s, index_d_exports as t, APIView as u };
|
|
164
|
+
//# sourceMappingURL=index-DkJtxvKu.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export { APIView, type APIViewMethod, type AliasFilterDeclaration, type AnyModelSerializer, type AnyModelSerializerClass, type AnySerializerClass, type BasePaginatedResponse, type BaseUser, CreateAPIView, CreateModelMixin, type CursorPaginatedResponse, CursorPaginationInput, CursorPaginator, DestroyModelMixin, type FieldFilterDeclaration, type FilterLookup, type FilterResolver, FilterSet, type FilterSetDefineConfig, type FilterType, type FilterValueParser, GenericAPIView, type GenericAPIViewConfig, type GenericAPIViewOpenAPIDescription, ListAPIView, ListCreateAPIView, ListModelMixin, type ManyToManyManagerKeys, type ManyToManyReadStrategy, type ManyToManyRelationField, type ManyToManyWriteStrategy, ModelSerializer, type ModelSerializerClass, type ModelSerializerRelationFields, ModelViewSet, type ModelViewSetConfig, type ModelViewSetOpenAPIDescription, type OffsetPaginatedResponse, OffsetPaginationInput, OffsetPaginator, type Page, type PaginatedResponse, type Paginator, type RangeOperator, RequestContext, type ResolvedViewSetActionDescriptor, type ResourceModelFieldMetadata, type ResourceModelLike, type ResourceModelMetadata, RetrieveAPIView, RetrieveDestroyAPIView, RetrieveModelMixin, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView, Serializer, type SerializerClass, type SerializerCreateInput, type SerializerOutput, type SerializerSchema, type SerializerUpdateInput, UpdateModelMixin, type ViewSetActionDescriptor, type ViewSetActionMethod, type ViewSetActionScope, index_d_exports as context, index_d_exports$1 as filters, index_d_exports$2 as pagination, index_d_exports$3 as paginators, relation, index_d_exports$4 as resource, index_d_exports$5 as serializer, index_d_exports$6 as view, index_d_exports$7 as viewset };
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { n as BaseUser, r as RequestContext, t as index_d_exports } from "./index-BJJalUDB.js";
|
|
2
|
+
import { a as FilterResolver, c as FilterValueParser, i as FilterLookup, l as RangeOperator, n as AliasFilterDeclaration, o as FilterSet, r as FieldFilterDeclaration, s as FilterSetDefineConfig, t as index_d_exports$1, u as FilterType } from "./index-CiIB-1Ac.js";
|
|
3
|
+
import { a as BasePaginatedResponse, c as PaginatedResponse, i as Paginator, n as OffsetPaginator, o as CursorPaginatedResponse, r as Page, s as OffsetPaginatedResponse, t as CursorPaginator } from "./CursorPaginator-CfeMQCdJ.js";
|
|
4
|
+
import { i as OffsetPaginationInput, n as CursorPaginationInput, t as index_d_exports$2 } from "./index-Ac94YL5S.js";
|
|
5
|
+
import { t as index_d_exports$3 } from "./paginators/index.js";
|
|
6
|
+
import { C as ResourceModelMetadata, S as ResourceModelLike, a as ModelSerializerClass, b as SerializerUpdateInput, c as ManyToManyRelationField, d as relation, f as AnySerializerClass, g as SerializerOutput, h as SerializerCreateInput, i as ModelSerializer, l as ManyToManyWriteStrategy, m as SerializerClass, n as AnyModelSerializer, o as ManyToManyManagerKeys, p as Serializer, r as AnyModelSerializerClass, s as ManyToManyReadStrategy, t as index_d_exports$5, u as ModelSerializerRelationFields, x as ResourceModelFieldMetadata, y as SerializerSchema } from "./index-C55GDIOn.js";
|
|
7
|
+
import { a as ModelViewSetConfig, c as ViewSetActionMethod, d as APIViewMethod, i as ModelViewSet, l as ViewSetActionScope, n as GenericAPIViewOpenAPIDescription, o as ResolvedViewSetActionDescriptor, r as ModelViewSetOpenAPIDescription, s as ViewSetActionDescriptor, t as index_d_exports$4, u as APIView } from "./index-DkJtxvKu.js";
|
|
8
|
+
import { t as index_d_exports$7 } from "./viewset/index.js";
|
|
9
|
+
import { a as ListCreateAPIView, c as ListAPIView, d as RetrieveModelMixin, f as CreateModelMixin, h as GenericAPIViewConfig, i as RetrieveUpdateAPIView, l as DestroyModelMixin, m as GenericAPIView, n as RetrieveUpdateDestroyAPIView, o as RetrieveAPIView, p as ListModelMixin, r as RetrieveDestroyAPIView, s as CreateAPIView, t as index_d_exports$6, u as UpdateModelMixin } from "./index-Bg6TtnmQ.js";
|
|
10
|
+
export { APIView, type APIViewMethod, type AliasFilterDeclaration, type AnyModelSerializer, type AnyModelSerializerClass, type AnySerializerClass, type BasePaginatedResponse, type BaseUser, CreateAPIView, CreateModelMixin, type CursorPaginatedResponse, CursorPaginationInput, CursorPaginator, DestroyModelMixin, type FieldFilterDeclaration, type FilterLookup, type FilterResolver, FilterSet, type FilterSetDefineConfig, type FilterType, type FilterValueParser, GenericAPIView, type GenericAPIViewConfig, type GenericAPIViewOpenAPIDescription, ListAPIView, ListCreateAPIView, ListModelMixin, type ManyToManyManagerKeys, type ManyToManyReadStrategy, type ManyToManyRelationField, type ManyToManyWriteStrategy, ModelSerializer, type ModelSerializerClass, type ModelSerializerRelationFields, ModelViewSet, type ModelViewSetConfig, type ModelViewSetOpenAPIDescription, type OffsetPaginatedResponse, OffsetPaginationInput, OffsetPaginator, type Page, type PaginatedResponse, type Paginator, type RangeOperator, RequestContext, type ResolvedViewSetActionDescriptor, type ResourceModelFieldMetadata, type ResourceModelLike, type ResourceModelMetadata, RetrieveAPIView, RetrieveDestroyAPIView, RetrieveModelMixin, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView, Serializer, type SerializerClass, type SerializerCreateInput, type SerializerOutput, type SerializerSchema, type SerializerUpdateInput, UpdateModelMixin, type ViewSetActionDescriptor, type ViewSetActionMethod, type ViewSetActionScope, index_d_exports as context, index_d_exports$1 as filters, index_d_exports$2 as pagination, index_d_exports$3 as paginators, relation, index_d_exports$4 as resource, index_d_exports$5 as serializer, index_d_exports$6 as view, index_d_exports$7 as viewset };
|