@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.
Files changed (49) hide show
  1. package/README.md +2 -2
  2. package/dist/CursorPaginator-B_8MhYZY.js +195 -0
  3. package/dist/CursorPaginator-B_8MhYZY.js.map +1 -0
  4. package/dist/CursorPaginator-CfeMQCdJ.d.ts +177 -0
  5. package/dist/OffsetPaginator-CaycvxJU.js +188 -0
  6. package/dist/OffsetPaginator-CaycvxJU.js.map +1 -0
  7. package/dist/context/index.d.ts +2 -0
  8. package/dist/context/index.js +2 -0
  9. package/dist/context-euBQvNRT.js +65 -0
  10. package/dist/context-euBQvNRT.js.map +1 -0
  11. package/dist/filters/index.d.ts +2 -0
  12. package/dist/filters/index.js +2 -0
  13. package/dist/filters-46d2Nr5C.js +287 -0
  14. package/dist/filters-46d2Nr5C.js.map +1 -0
  15. package/dist/index-Ac94YL5S.d.ts +24 -0
  16. package/dist/index-BJJalUDB.d.ts +54 -0
  17. package/dist/index-Bg6TtnmQ.d.ts +175 -0
  18. package/dist/index-C55GDIOn.d.ts +222 -0
  19. package/dist/index-CiIB-1Ac.d.ts +123 -0
  20. package/dist/index-DkJtxvKu.d.ts +164 -0
  21. package/dist/index.d.ts +10 -12
  22. package/dist/index.js +10 -1013
  23. package/dist/inferModelFieldParsers-2irv7j1T.js +70 -0
  24. package/dist/inferModelFieldParsers-2irv7j1T.js.map +1 -0
  25. package/dist/pagination/index.d.ts +3 -0
  26. package/dist/pagination/index.js +15 -0
  27. package/dist/pagination/index.js.map +1 -0
  28. package/dist/paginators/index.d.ts +9 -0
  29. package/dist/paginators/index.js +12 -0
  30. package/dist/paginators/index.js.map +1 -0
  31. package/dist/resource/index.d.ts +3 -0
  32. package/dist/resource/index.js +7 -0
  33. package/dist/resource/index.js.map +1 -0
  34. package/dist/serializer/index.d.ts +2 -0
  35. package/dist/serializer/index.js +2 -0
  36. package/dist/serializer-RSwlXWls.js +305 -0
  37. package/dist/serializer-RSwlXWls.js.map +1 -0
  38. package/dist/view/index.d.ts +2 -1
  39. package/dist/view/index.js +1 -1
  40. package/dist/{view-C9B5Lln3.js → view-CYdJAO4t.js} +7 -314
  41. package/dist/view-CYdJAO4t.js.map +1 -0
  42. package/dist/viewset/index.d.ts +9 -0
  43. package/dist/viewset/index.js +2 -0
  44. package/dist/viewset-C9j-2U29.js +227 -0
  45. package/dist/viewset-C9j-2U29.js.map +1 -0
  46. package/package.json +21 -17
  47. package/dist/index-D6sfTSEj.d.ts +0 -902
  48. package/dist/index.js.map +0 -1
  49. package/dist/view-C9B5Lln3.js.map +0 -1
@@ -0,0 +1,175 @@
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 { g as SerializerOutput, n as AnyModelSerializer } from "./index-C55GDIOn.js";
5
+ import { d as APIViewMethod, n as GenericAPIViewOpenAPIDescription, u as APIView } from "./index-DkJtxvKu.js";
6
+ import { TangoResponse } from "@danceroutine/tango-core";
7
+ import { ManagerLike, QuerySet } from "@danceroutine/tango-orm";
8
+
9
+ //#region src/view/GenericAPIView.d.ts
10
+ type SearchFieldRef<TModel extends Record<string, unknown>> = Extract<keyof TModel, string> | string;
11
+ interface GenericAPIViewConfig<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> {
12
+ serializer: TSerializer;
13
+ filters?: FilterSet<TModel>;
14
+ orderingFields?: (keyof TModel)[];
15
+ searchFields?: SearchFieldRef<TModel>[];
16
+ lookupField?: keyof TModel;
17
+ lookupParam?: string;
18
+ paginatorFactory?: (queryset: QuerySet<TModel>) => Paginator<TModel, SerializerOutput<TSerializer>>;
19
+ }
20
+ /**
21
+ * Generic API base class that centralizes query/build/validation helpers.
22
+ */
23
+ declare abstract class GenericAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends APIView {
24
+ protected readonly serializerClass: TSerializer;
25
+ protected readonly filters?: FilterSet<TModel>;
26
+ protected readonly orderingFields: readonly (keyof TModel)[];
27
+ protected readonly searchFields: readonly SearchFieldRef<TModel>[];
28
+ protected readonly lookupField?: keyof TModel;
29
+ protected readonly lookupParam: string;
30
+ protected readonly paginatorFactory?: (queryset: QuerySet<TModel>) => Paginator<TModel, SerializerOutput<TSerializer>>;
31
+ private serializer?;
32
+ constructor(config: GenericAPIViewConfig<TModel, TSerializer>);
33
+ /**
34
+ * Return the serializer class that owns this resource contract.
35
+ */
36
+ getSerializerClass(): TSerializer;
37
+ /**
38
+ * Return the serializer instance for the current resource.
39
+ */
40
+ getSerializer(): InstanceType<TSerializer>;
41
+ /**
42
+ * Describe the public HTTP contract that this resource contributes to OpenAPI generation.
43
+ */
44
+ describeOpenAPI(): GenericAPIViewOpenAPIDescription<TModel, TSerializer>;
45
+ protected getManager(): ManagerLike<TModel>;
46
+ protected getOutputSchema(): TSerializer['outputSchema'];
47
+ protected getCreateSchema(): TSerializer['createSchema'];
48
+ protected getUpdateSchema(): TSerializer['updateSchema'];
49
+ protected getLookupField(): keyof TModel;
50
+ protected getLookupValue(ctx: RequestContext): string | null;
51
+ protected getPaginator(queryset: QuerySet<TModel>): Paginator<TModel, SerializerOutput<TSerializer>>;
52
+ protected performList(ctx: RequestContext): Promise<TangoResponse>;
53
+ protected performCreate(ctx: RequestContext): Promise<TangoResponse>;
54
+ protected performRetrieve(ctx: RequestContext): Promise<TangoResponse>;
55
+ protected performUpdate(ctx: RequestContext): Promise<TangoResponse>;
56
+ protected performDestroy(ctx: RequestContext): Promise<TangoResponse>;
57
+ protected handleError(error: unknown): TangoResponse;
58
+ private requireModelMetadata;
59
+ private getLookupFieldFromMetadata;
60
+ }
61
+ //#endregion
62
+ //#region src/view/mixins/ListModelMixin.d.ts
63
+ /**
64
+ * Mixin that wires `GET` requests to the generic list implementation.
65
+ */
66
+ declare abstract class ListModelMixin<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
67
+ protected list(ctx: RequestContext): Promise<TangoResponse>;
68
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
69
+ }
70
+ //#endregion
71
+ //#region src/view/mixins/CreateModelMixin.d.ts
72
+ /**
73
+ * Mixin that wires `POST` requests to the generic create implementation.
74
+ */
75
+ declare abstract class CreateModelMixin<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
76
+ protected create(ctx: RequestContext): Promise<TangoResponse>;
77
+ protected post(ctx: RequestContext): Promise<TangoResponse>;
78
+ }
79
+ //#endregion
80
+ //#region src/view/mixins/RetrieveModelMixin.d.ts
81
+ /**
82
+ * Mixin that wires `GET` requests to the generic retrieve implementation.
83
+ */
84
+ declare abstract class RetrieveModelMixin<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
85
+ protected retrieve(ctx: RequestContext): Promise<TangoResponse>;
86
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
87
+ }
88
+ //#endregion
89
+ //#region src/view/mixins/UpdateModelMixin.d.ts
90
+ /**
91
+ * Mixin that wires `PUT` and `PATCH` requests to the generic update implementation.
92
+ */
93
+ declare abstract class UpdateModelMixin<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
94
+ protected update(ctx: RequestContext): Promise<TangoResponse>;
95
+ protected put(ctx: RequestContext): Promise<TangoResponse>;
96
+ protected patch(ctx: RequestContext): Promise<TangoResponse>;
97
+ }
98
+ //#endregion
99
+ //#region src/view/mixins/DestroyModelMixin.d.ts
100
+ /**
101
+ * Mixin that wires `DELETE` requests to the generic destroy implementation.
102
+ */
103
+ declare abstract class DestroyModelMixin<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
104
+ protected destroy(ctx: RequestContext): Promise<TangoResponse>;
105
+ protected delete(ctx: RequestContext): Promise<TangoResponse>;
106
+ }
107
+ //#endregion
108
+ //#region src/view/generics/ListAPIView.d.ts
109
+ /**
110
+ * Generic API view for endpoints that only expose a list operation.
111
+ */
112
+ declare abstract class ListAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends ListModelMixin<TModel, TSerializer> {
113
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
114
+ }
115
+ //#endregion
116
+ //#region src/view/generics/CreateAPIView.d.ts
117
+ /**
118
+ * Generic API view for endpoints that only support resource creation.
119
+ */
120
+ declare abstract class CreateAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends CreateModelMixin<TModel, TSerializer> {
121
+ protected post(ctx: RequestContext): Promise<TangoResponse>;
122
+ }
123
+ //#endregion
124
+ //#region src/view/generics/RetrieveAPIView.d.ts
125
+ /**
126
+ * Generic API view for endpoints that retrieve a single resource by lookup.
127
+ */
128
+ declare abstract class RetrieveAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends RetrieveModelMixin<TModel, TSerializer> {
129
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
130
+ }
131
+ //#endregion
132
+ //#region src/view/generics/ListCreateAPIView.d.ts
133
+ /**
134
+ * Generic API view for collection endpoints that list and create resources.
135
+ */
136
+ declare abstract class ListCreateAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
137
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
138
+ protected post(ctx: RequestContext): Promise<TangoResponse>;
139
+ }
140
+ //#endregion
141
+ //#region src/view/generics/RetrieveUpdateAPIView.d.ts
142
+ /**
143
+ * Generic API view for endpoints that retrieve and update a single resource.
144
+ */
145
+ declare abstract class RetrieveUpdateAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
146
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
147
+ protected put(ctx: RequestContext): Promise<TangoResponse>;
148
+ protected patch(ctx: RequestContext): Promise<TangoResponse>;
149
+ }
150
+ //#endregion
151
+ //#region src/view/generics/RetrieveDestroyAPIView.d.ts
152
+ /**
153
+ * Generic API view for endpoints that retrieve and delete a single resource.
154
+ */
155
+ declare abstract class RetrieveDestroyAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
156
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
157
+ protected delete(ctx: RequestContext): Promise<TangoResponse>;
158
+ }
159
+ //#endregion
160
+ //#region src/view/generics/RetrieveUpdateDestroyAPIView.d.ts
161
+ /**
162
+ * Generic API view for full detail endpoints that retrieve, update, and delete.
163
+ */
164
+ declare abstract class RetrieveUpdateDestroyAPIView<TModel extends Record<string, unknown>, TSerializer extends AnyModelSerializer<TModel>> extends GenericAPIView<TModel, TSerializer> {
165
+ protected get(ctx: RequestContext): Promise<TangoResponse>;
166
+ protected put(ctx: RequestContext): Promise<TangoResponse>;
167
+ protected patch(ctx: RequestContext): Promise<TangoResponse>;
168
+ protected delete(ctx: RequestContext): Promise<TangoResponse>;
169
+ }
170
+ declare namespace index_d_exports {
171
+ export { APIView, APIViewMethod, CreateAPIView, CreateModelMixin, DestroyModelMixin, GenericAPIView, GenericAPIViewConfig, GenericAPIViewOpenAPIDescription, ListAPIView, ListCreateAPIView, ListModelMixin, RetrieveAPIView, RetrieveDestroyAPIView, RetrieveModelMixin, RetrieveUpdateAPIView, RetrieveUpdateDestroyAPIView, UpdateModelMixin };
172
+ }
173
+ //#endregion
174
+ export { ListCreateAPIView as a, ListAPIView as c, RetrieveModelMixin as d, CreateModelMixin as f, GenericAPIViewConfig as h, RetrieveUpdateAPIView as i, DestroyModelMixin as l, GenericAPIView as m, RetrieveUpdateDestroyAPIView as n, RetrieveAPIView as o, ListModelMixin as p, RetrieveDestroyAPIView as r, CreateAPIView as s, index_d_exports as t, UpdateModelMixin as u };
175
+ //# sourceMappingURL=index-Bg6TtnmQ.d.ts.map
@@ -0,0 +1,222 @@
1
+ import { ManagerLike, ManyToManyRelatedManager } from "@danceroutine/tango-orm";
2
+ import { z } from "zod";
3
+
4
+ //#region src/resource/ResourceModelLike.d.ts
5
+ type ResourceModelFieldMetadata = {
6
+ name: string;
7
+ type: string;
8
+ notNull?: boolean;
9
+ default?: unknown;
10
+ primaryKey?: boolean;
11
+ };
12
+ type ResourceModelMetadata = {
13
+ name: string;
14
+ fields: ResourceModelFieldMetadata[];
15
+ };
16
+ type ResourceModelLike<TModel extends Record<string, unknown>, TModelRecord extends Record<string, unknown> = TModel> = {
17
+ /**
18
+ * Resource-layer contracts own the outward representation. The underlying
19
+ * model may materialize a richer ORM record, so the manager record type is kept
20
+ * separate from the serializer-facing model shape.
21
+ */
22
+ readonly objects: ManagerLike<TModelRecord>;
23
+ readonly metadata?: ResourceModelMetadata;
24
+ readonly __tangoModelShape?: TModel;
25
+ };
26
+ //#endregion
27
+ //#region src/serializer/Serializer.d.ts
28
+ type SerializerSchema = z.ZodTypeAny;
29
+ type SerializerClass<TCreateSchema extends SerializerSchema = SerializerSchema, TUpdateSchema extends SerializerSchema = SerializerSchema, TOutputSchema extends SerializerSchema = SerializerSchema, TRecord = unknown> = {
30
+ new (): Serializer<TCreateSchema, TUpdateSchema, TOutputSchema, TRecord>;
31
+ readonly createSchema: TCreateSchema;
32
+ readonly updateSchema: TUpdateSchema;
33
+ readonly outputSchema: TOutputSchema;
34
+ readonly outputResolvers?: SerializerOutputResolvers<TRecord>;
35
+ };
36
+ type AnySerializerClass = SerializerClass<SerializerSchema, SerializerSchema, SerializerSchema, any>;
37
+ type SerializerCreateInput<TSerializer extends AnySerializerClass> = z.output<TSerializer['createSchema']>;
38
+ type SerializerUpdateInput<TSerializer extends AnySerializerClass> = z.output<TSerializer['updateSchema']>;
39
+ type SerializerOutput<TSerializer extends AnySerializerClass> = z.output<TSerializer['outputSchema']>;
40
+ type SerializerOutputResolver<TRecord = unknown> = (record: TRecord) => unknown | Promise<unknown>;
41
+ type SerializerOutputResolvers<TRecord = unknown> = Record<string, SerializerOutputResolver<TRecord>>;
42
+ /**
43
+ * DRF-inspired base serializer backed by Zod schemas.
44
+ *
45
+ * Tango serializers keep Zod as the source of truth for validation and type
46
+ * inference while centralizing create, update, and representation workflows in
47
+ * one class-owned contract.
48
+ */
49
+ declare abstract class Serializer<TCreateSchema extends SerializerSchema, TUpdateSchema extends SerializerSchema, TOutputSchema extends SerializerSchema, TRecord = unknown> {
50
+ static readonly createSchema: SerializerSchema;
51
+ static readonly updateSchema: SerializerSchema;
52
+ static readonly outputSchema: SerializerSchema;
53
+ static readonly outputResolvers: SerializerOutputResolvers< // oxlint-disable-next-line typescript/no-explicit-any
54
+ any> | undefined;
55
+ /**
56
+ * Return the serializer class for the current instance.
57
+ */
58
+ getSerializerClass(): SerializerClass<TCreateSchema, TUpdateSchema, TOutputSchema, TRecord>;
59
+ /**
60
+ * Return the Zod schema used for create payloads.
61
+ */
62
+ getCreateSchema(): TCreateSchema;
63
+ /**
64
+ * Return the Zod schema used for update payloads.
65
+ */
66
+ getUpdateSchema(): TUpdateSchema;
67
+ /**
68
+ * Return the Zod schema used for serialized output.
69
+ */
70
+ getOutputSchema(): TOutputSchema;
71
+ /**
72
+ * Return the resolver map used to enrich serializer output fields before
73
+ * the outward Zod schema parses the final response shape.
74
+ */
75
+ getOutputResolvers(): SerializerOutputResolvers<TRecord>;
76
+ /**
77
+ * Validate unknown input for create workflows.
78
+ */
79
+ deserializeCreate(input: unknown): z.output<TCreateSchema>;
80
+ /**
81
+ * Validate unknown input for update workflows.
82
+ */
83
+ deserializeUpdate(input: unknown): z.output<TUpdateSchema>;
84
+ /**
85
+ * Convert a persisted record into its outward-facing representation.
86
+ *
87
+ * @deprecated Use `serialize(...)` instead so serializer-owned output
88
+ * resolvers run before the outward Zod schema parses the response shape.
89
+ */
90
+ toRepresentation(record: TRecord): z.output<TOutputSchema>;
91
+ /**
92
+ * Resolve serializer-owned output fields and parse the outward response
93
+ * contract.
94
+ */
95
+ serialize(record: TRecord): Promise<z.output<TOutputSchema>>;
96
+ /**
97
+ * Serialize many records through the same outward response contract.
98
+ */
99
+ serializeMany(records: readonly TRecord[]): Promise<z.output<TOutputSchema>[]>;
100
+ private applyOutputResolvers;
101
+ }
102
+ //#endregion
103
+ //#region src/serializer/internal/InternalSerializerRelationKind.d.ts
104
+ declare const InternalSerializerRelationKind: {
105
+ readonly MANY_TO_MANY: "manyToMany";
106
+ };
107
+ declare const InternalManyToManyReadStrategyKind: {
108
+ readonly PK_LIST: "pkList";
109
+ readonly NESTED: "nested";
110
+ };
111
+ declare const InternalManyToManyWriteStrategyKind: {
112
+ readonly PK_LIST: "pkList";
113
+ readonly SLUG_LIST: "slugList";
114
+ };
115
+ //#endregion
116
+ //#region src/serializer/relation.d.ts
117
+ type AnyRecord = Record<string, unknown>;
118
+ type ManyToManyManagerKeys<TRecord extends AnyRecord> = Extract<{ [K in keyof TRecord]: TRecord[K] extends ManyToManyRelatedManager<AnyRecord> ? K : never }[keyof TRecord], string>;
119
+ type ManyToManyTargetRow<TRecord extends AnyRecord, TFieldName extends ManyToManyManagerKeys<TRecord>> = TRecord[TFieldName] extends ManyToManyRelatedManager<infer TTarget extends AnyRecord> ? TTarget : never;
120
+ type ManyToManyPkListStrategy = {
121
+ kind: typeof InternalManyToManyReadStrategyKind.PK_LIST | typeof InternalManyToManyWriteStrategyKind.PK_LIST;
122
+ };
123
+ type ManyToManyNestedStrategy = {
124
+ kind: typeof InternalManyToManyReadStrategyKind.NESTED;
125
+ schema: z.ZodTypeAny;
126
+ };
127
+ type ManyToManySlugListStrategy<TTarget extends AnyRecord> = {
128
+ kind: typeof InternalManyToManyWriteStrategyKind.SLUG_LIST;
129
+ model: ResourceModelLike<any, any>;
130
+ lookupField: Extract<keyof TTarget, string>;
131
+ createIfMissing?: boolean;
132
+ buildCreateInput?: (value: string) => Partial<TTarget>;
133
+ };
134
+ type ManyToManyReadStrategy = ManyToManyPkListStrategy | ManyToManyNestedStrategy;
135
+ type ManyToManyWriteStrategy<TTarget extends AnyRecord> = ManyToManyPkListStrategy | ManyToManySlugListStrategy<TTarget>;
136
+ type ManyToManyRelationField<TRecord extends AnyRecord, TFieldName extends ManyToManyManagerKeys<TRecord>> = {
137
+ kind: typeof InternalSerializerRelationKind.MANY_TO_MANY;
138
+ read: ManyToManyReadStrategy;
139
+ write: ManyToManyWriteStrategy<ManyToManyTargetRow<TRecord, TFieldName>>;
140
+ };
141
+ type ModelSerializerRelationFields<TRecord extends AnyRecord> = Partial<{ [K in ManyToManyManagerKeys<TRecord>]: ManyToManyRelationField<TRecord, K> }>;
142
+ declare function pkList(): ManyToManyPkListStrategy;
143
+ declare function nested(schema: z.ZodTypeAny): ManyToManyNestedStrategy;
144
+ declare function slugList<TTarget extends AnyRecord>(options: Omit<ManyToManySlugListStrategy<TTarget>, 'kind'>): ManyToManySlugListStrategy<TTarget>;
145
+ declare function manyToMany(config?: Partial<Pick<ManyToManyRelationField<any, any>, 'read' | 'write'>>): ManyToManyRelationField<any, any>;
146
+ type RelationHelpers = {
147
+ manyToMany: typeof manyToMany;
148
+ pkList: typeof pkList;
149
+ nested: typeof nested;
150
+ slugList: typeof slugList;
151
+ };
152
+ declare const relation: RelationHelpers;
153
+ //#endregion
154
+ //#region src/serializer/ModelSerializer.d.ts
155
+ type ModelSerializerClass<TModel extends Record<string, unknown> = Record<string, unknown>, TCreateSchema extends SerializerSchema = SerializerSchema, TUpdateSchema extends SerializerSchema = SerializerSchema, TOutputSchema extends SerializerSchema = SerializerSchema, TModelRecord extends Record<string, unknown> = TModel> = SerializerClass<TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord> & {
156
+ new (): ModelSerializer<TModel, TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord>;
157
+ readonly model?: ResourceModelLike<TModel, TModelRecord>;
158
+ readonly relationFields?: ModelSerializerRelationFields<TModelRecord>;
159
+ };
160
+ type AnyModelSerializer<TModel extends Record<string, unknown> = Record<string, unknown>> = ModelSerializerClass<TModel, SerializerSchema, SerializerSchema, SerializerSchema, any>;
161
+ type AnyModelSerializerClass = AnyModelSerializer;
162
+ /**
163
+ * Zod-backed serializer with default model-manager persistence behavior.
164
+ */
165
+ declare abstract class ModelSerializer<TModel extends Record<string, unknown>, TCreateSchema extends SerializerSchema, TUpdateSchema extends SerializerSchema, TOutputSchema extends SerializerSchema, TModelRecord extends Record<string, unknown> = TModel> extends Serializer<TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord> {
166
+ static readonly model?: unknown;
167
+ static readonly relationFields: ModelSerializerRelationFields<Record<string, unknown>> | undefined;
168
+ /**
169
+ * Return the Tango model backing this serializer.
170
+ */
171
+ getModel(): ResourceModelLike<TModel, TModelRecord>;
172
+ /**
173
+ * Return the manager used for create and update workflows.
174
+ */
175
+ getManager(): ManagerLike<TModelRecord>;
176
+ /**
177
+ * Return the declarative relation-field map for this serializer.
178
+ */
179
+ getRelationFields(): ModelSerializerRelationFields<TModelRecord>;
180
+ /**
181
+ * Merge relation-field read resolvers into the serializer output path.
182
+ */
183
+ getOutputResolvers(): SerializerOutputResolvers<TModelRecord>;
184
+ /**
185
+ * Validate, enrich, persist, and serialize a create workflow.
186
+ */
187
+ create(input: unknown): Promise<SerializerOutput<ModelSerializerClass<TModel, TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord>>>;
188
+ /**
189
+ * Validate, enrich, persist, and serialize an update workflow.
190
+ */
191
+ update(id: TModelRecord[keyof TModelRecord], input: unknown): Promise<SerializerOutput<ModelSerializerClass<TModel, TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord>>>;
192
+ /**
193
+ * Override to normalize create input for this resource workflow before the
194
+ * manager call.
195
+ *
196
+ * Model-owned persistence rules belong in model hooks so they also run for
197
+ * scripts and direct manager usage.
198
+ */
199
+ protected beforeCreate(data: SerializerCreateInput<ModelSerializerClass<TModel, TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord>>): Promise<Partial<TModelRecord>>;
200
+ /**
201
+ * Override to normalize update input for this resource workflow before the
202
+ * manager call.
203
+ *
204
+ * Model-owned persistence rules belong in model hooks so they also run for
205
+ * scripts and direct manager usage.
206
+ */
207
+ protected beforeUpdate(_id: TModelRecord[keyof TModelRecord], data: SerializerUpdateInput<ModelSerializerClass<TModel, TCreateSchema, TUpdateSchema, TOutputSchema, TModelRecord>>): Promise<Partial<TModelRecord>>;
208
+ private extractRelationWrites;
209
+ private stripRelationFields;
210
+ private applyRelationWrites;
211
+ private serializeRelationField;
212
+ private syncManyToManyRelation;
213
+ private resolveWriteTargets;
214
+ private getManyToManyManager;
215
+ private getManyToManyRelationMeta;
216
+ }
217
+ declare namespace index_d_exports {
218
+ export { AnyModelSerializer, AnyModelSerializerClass, AnySerializerClass, ManyToManyManagerKeys, ManyToManyReadStrategy, ManyToManyRelationField, ManyToManyWriteStrategy, ModelSerializer, ModelSerializerClass, ModelSerializerRelationFields, Serializer, SerializerClass, SerializerCreateInput, SerializerOutput, SerializerOutputResolver, SerializerOutputResolvers, SerializerSchema, SerializerUpdateInput, relation };
219
+ }
220
+ //#endregion
221
+ export { ResourceModelMetadata as C, ResourceModelLike as S, SerializerOutputResolver as _, ModelSerializerClass as a, SerializerUpdateInput as b, ManyToManyRelationField as c, relation as d, AnySerializerClass as f, SerializerOutput as g, SerializerCreateInput as h, ModelSerializer as i, ManyToManyWriteStrategy as l, SerializerClass as m, AnyModelSerializer as n, ManyToManyManagerKeys as o, Serializer as p, AnyModelSerializerClass as r, ManyToManyReadStrategy as s, index_d_exports as t, ModelSerializerRelationFields as u, SerializerOutputResolvers as v, ResourceModelFieldMetadata as x, SerializerSchema as y };
222
+ //# sourceMappingURL=index-C55GDIOn.d.ts.map
@@ -0,0 +1,123 @@
1
+ import { TangoQueryParams } from "@danceroutine/tango-core";
2
+ import { FilterInput, FilterValue, LookupType } from "@danceroutine/tango-orm";
3
+
4
+ //#region src/filters/internal/InternalFilterType.d.ts
5
+ declare const InternalFilterType: {
6
+ readonly SCALAR: "scalar";
7
+ readonly ILIKE: "ilike";
8
+ readonly RANGE: "range";
9
+ readonly IN: "in";
10
+ readonly CUSTOM: "custom";
11
+ };
12
+ //#endregion
13
+ //#region src/filters/FilterType.d.ts
14
+ type FilterType = (typeof InternalFilterType)[keyof typeof InternalFilterType];
15
+ //#endregion
16
+ //#region src/filters/internal/InternalRangeOperator.d.ts
17
+ declare const InternalRangeOperator: {
18
+ readonly GTE: "gte";
19
+ readonly LTE: "lte";
20
+ readonly GT: "gt";
21
+ readonly LT: "lt";
22
+ };
23
+ //#endregion
24
+ //#region src/filters/RangeOperator.d.ts
25
+ type RangeOperator = (typeof InternalRangeOperator)[keyof typeof InternalRangeOperator];
26
+ //#endregion
27
+ //#region src/filters/FilterSet.d.ts
28
+ type FilterFieldRef<T extends Record<string, unknown>> = Extract<keyof T, string> | string;
29
+ /**
30
+ * Configuration for how a query parameter should be resolved into a filter.
31
+ * Supports scalar equality, case-insensitive search, range comparisons, IN queries, and custom logic.
32
+ */
33
+ type FilterResolver<T extends Record<string, unknown>> = {
34
+ type: typeof InternalFilterType.SCALAR;
35
+ column: FilterFieldRef<T>;
36
+ } | {
37
+ type: typeof InternalFilterType.ILIKE;
38
+ columns: FilterFieldRef<T>[];
39
+ } | {
40
+ type: typeof InternalFilterType.RANGE;
41
+ column: FilterFieldRef<T>;
42
+ op: RangeOperator;
43
+ } | {
44
+ type: typeof InternalFilterType.IN;
45
+ column: FilterFieldRef<T>;
46
+ } | {
47
+ type: typeof InternalFilterType.CUSTOM;
48
+ apply: (value: string | string[] | undefined) => FilterInput<T> | undefined;
49
+ };
50
+ type FilterLookup = LookupType;
51
+ type FilterValueParser = (raw: string | string[]) => FilterValue | FilterValue[] | undefined;
52
+ type FieldFilterDeclaration = true | readonly FilterLookup[] | {
53
+ lookups?: readonly FilterLookup[];
54
+ param?: string;
55
+ parse?: FilterValueParser;
56
+ };
57
+ type AliasFilterDeclaration<T extends Record<string, unknown>> = FilterResolver<T> | {
58
+ field: FilterFieldRef<T>;
59
+ lookup?: FilterLookup;
60
+ parse?: FilterValueParser;
61
+ } | {
62
+ fields: readonly FilterFieldRef<T>[];
63
+ lookup?: FilterLookup;
64
+ parse?: FilterValueParser;
65
+ };
66
+ interface FilterSetDefineConfig<T extends Record<string, unknown>> {
67
+ fields?: Partial<Record<string, FieldFilterDeclaration>>;
68
+ aliases?: Record<string, AliasFilterDeclaration<T>>;
69
+ parsers?: Partial<Record<string, FilterValueParser>>;
70
+ all?: '__all__';
71
+ }
72
+ /**
73
+ * Declarative query-param to filter translation.
74
+ *
75
+ * A `FilterSet` lets viewsets expose safe, explicit filtering behavior
76
+ * without leaking raw ORM filter syntax to request handlers.
77
+ */
78
+ declare class FilterSet<T extends Record<string, unknown>> {
79
+ private readonly spec;
80
+ private readonly allowAllParams;
81
+ static readonly BRAND: "tango.resources.filter_set";
82
+ readonly __tangoBrand: typeof FilterSet.BRAND;
83
+ /**
84
+ * Resolve matching query parameters into ORM filter inputs.
85
+ */
86
+ constructor(spec: Record<string, FilterResolver<T>>, allowAllParams?: boolean);
87
+ /**
88
+ * Build a filter set from Django-style field declarations.
89
+ */
90
+ static define<T extends Record<string, unknown>>(config: FilterSetDefineConfig<T>): FilterSet<T>;
91
+ /**
92
+ * Narrow an unknown value to `FilterSet`.
93
+ */
94
+ static isFilterSet<T extends Record<string, unknown>>(value: unknown): value is FilterSet<T>;
95
+ private static normalizeDefineConfig;
96
+ private static addFieldDeclaration;
97
+ private static isLookupArray;
98
+ private static normalizeAliasDeclaration;
99
+ private static isFilterResolverDeclaration;
100
+ private static createMultiFieldResolver;
101
+ private static createLookupResolver;
102
+ private static resolveLookupFilter;
103
+ private static resolveLookupParam;
104
+ private static resolveParserValue;
105
+ private static toScalarString;
106
+ /**
107
+ * Return a new filter set with parser-aware scalar/range/in resolvers for matching fields.
108
+ */
109
+ withFieldParsers(parsers: Partial<Record<string, FilterValueParser>>): FilterSet<T>;
110
+ /**
111
+ * Apply all configured resolvers against query params.
112
+ */
113
+ apply(params: TangoQueryParams): FilterInput<T>[];
114
+ private buildAllResolver;
115
+ private resolveFilter;
116
+ private applyFieldParserOverride;
117
+ }
118
+ declare namespace index_d_exports {
119
+ export { AliasFilterDeclaration, FieldFilterDeclaration, FilterLookup, FilterResolver, FilterSet, FilterSetDefineConfig, FilterType, FilterValueParser, RangeOperator };
120
+ }
121
+ //#endregion
122
+ export { FilterResolver as a, FilterValueParser as c, FilterLookup as i, RangeOperator as l, AliasFilterDeclaration as n, FilterSet as o, FieldFilterDeclaration as r, FilterSetDefineConfig as s, index_d_exports as t, FilterType as u };
123
+ //# sourceMappingURL=index-CiIB-1Ac.d.ts.map