@statezero/core 0.1.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/adaptors/react/composables.d.ts +1 -0
- package/dist/adaptors/react/composables.js +4 -0
- package/dist/adaptors/react/index.d.ts +1 -0
- package/dist/adaptors/react/index.js +1 -0
- package/dist/adaptors/vue/composables.d.ts +2 -0
- package/dist/adaptors/vue/composables.js +36 -0
- package/dist/adaptors/vue/index.d.ts +2 -0
- package/dist/adaptors/vue/index.js +2 -0
- package/dist/adaptors/vue/reactivity.d.ts +18 -0
- package/dist/adaptors/vue/reactivity.js +125 -0
- package/dist/cli/commands/syncModels.d.ts +132 -0
- package/dist/cli/commands/syncModels.js +1040 -0
- package/dist/cli/configFileLoader.d.ts +10 -0
- package/dist/cli/configFileLoader.js +85 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +14 -0
- package/dist/config.d.ts +52 -0
- package/dist/config.js +242 -0
- package/dist/core/eventReceivers.d.ts +179 -0
- package/dist/core/eventReceivers.js +210 -0
- package/dist/core/utils.d.ts +8 -0
- package/dist/core/utils.js +62 -0
- package/dist/filtering/localFiltering.d.ts +116 -0
- package/dist/filtering/localFiltering.js +834 -0
- package/dist/flavours/django/dates.d.ts +33 -0
- package/dist/flavours/django/dates.js +99 -0
- package/dist/flavours/django/errors.d.ts +138 -0
- package/dist/flavours/django/errors.js +187 -0
- package/dist/flavours/django/f.d.ts +6 -0
- package/dist/flavours/django/f.js +91 -0
- package/dist/flavours/django/files.d.ts +76 -0
- package/dist/flavours/django/files.js +338 -0
- package/dist/flavours/django/makeApiCall.d.ts +20 -0
- package/dist/flavours/django/makeApiCall.js +169 -0
- package/dist/flavours/django/manager.d.ts +197 -0
- package/dist/flavours/django/manager.js +222 -0
- package/dist/flavours/django/model.d.ts +112 -0
- package/dist/flavours/django/model.js +253 -0
- package/dist/flavours/django/operationFactory.d.ts +65 -0
- package/dist/flavours/django/operationFactory.js +216 -0
- package/dist/flavours/django/q.d.ts +70 -0
- package/dist/flavours/django/q.js +43 -0
- package/dist/flavours/django/queryExecutor.d.ts +131 -0
- package/dist/flavours/django/queryExecutor.js +468 -0
- package/dist/flavours/django/querySet.d.ts +412 -0
- package/dist/flavours/django/querySet.js +601 -0
- package/dist/flavours/django/tempPk.d.ts +19 -0
- package/dist/flavours/django/tempPk.js +48 -0
- package/dist/flavours/django/utils.d.ts +19 -0
- package/dist/flavours/django/utils.js +29 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +38 -0
- package/dist/react-entry.d.ts +2 -0
- package/dist/react-entry.js +2 -0
- package/dist/reactiveAdaptor.d.ts +24 -0
- package/dist/reactiveAdaptor.js +38 -0
- package/dist/setup.d.ts +15 -0
- package/dist/setup.js +22 -0
- package/dist/syncEngine/cache/cache.d.ts +75 -0
- package/dist/syncEngine/cache/cache.js +341 -0
- package/dist/syncEngine/metrics/metricOptCalcs.d.ts +79 -0
- package/dist/syncEngine/metrics/metricOptCalcs.js +284 -0
- package/dist/syncEngine/registries/metricRegistry.d.ts +53 -0
- package/dist/syncEngine/registries/metricRegistry.js +162 -0
- package/dist/syncEngine/registries/modelStoreRegistry.d.ts +11 -0
- package/dist/syncEngine/registries/modelStoreRegistry.js +56 -0
- package/dist/syncEngine/registries/querysetStoreRegistry.d.ts +55 -0
- package/dist/syncEngine/registries/querysetStoreRegistry.js +244 -0
- package/dist/syncEngine/stores/metricStore.d.ts +55 -0
- package/dist/syncEngine/stores/metricStore.js +222 -0
- package/dist/syncEngine/stores/modelStore.d.ts +40 -0
- package/dist/syncEngine/stores/modelStore.js +405 -0
- package/dist/syncEngine/stores/operation.d.ts +99 -0
- package/dist/syncEngine/stores/operation.js +224 -0
- package/dist/syncEngine/stores/operationEventHandlers.d.ts +8 -0
- package/dist/syncEngine/stores/operationEventHandlers.js +239 -0
- package/dist/syncEngine/stores/querysetStore.d.ts +32 -0
- package/dist/syncEngine/stores/querysetStore.js +200 -0
- package/dist/syncEngine/stores/reactivity.d.ts +3 -0
- package/dist/syncEngine/stores/reactivity.js +4 -0
- package/dist/syncEngine/stores/utils.d.ts +14 -0
- package/dist/syncEngine/stores/utils.js +32 -0
- package/dist/syncEngine/sync.d.ts +32 -0
- package/dist/syncEngine/sync.js +169 -0
- package/dist/vue-entry.d.ts +6 -0
- package/dist/vue-entry.js +2 -0
- package/license.md +116 -0
- package/package.json +123 -0
- package/readme.md +222 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {'count'|'sum'|'avg'|'min'|'max'} AggregateFunction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Aggregation
|
|
6
|
+
* @property {AggregateFunction} function - The aggregation function.
|
|
7
|
+
* @property {string} field - The field to aggregate.
|
|
8
|
+
* @property {string} [alias] - Optional alias for the aggregated field.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {'filter'|'or'|'and'|'not'|'exclude'|'get'|'create'|'update'|'delete'|'get_or_create'|'update_or_create'|'first'|'last'|'exists'|'search'} QueryOperationType
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} QueryNode
|
|
15
|
+
* @property {QueryOperationType} type - The operation type.
|
|
16
|
+
* @property {Object.<string, any>} [conditions] - Filter conditions.
|
|
17
|
+
* @property {QueryNode[]} [children] - Child query nodes.
|
|
18
|
+
* @property {any} [lookup] - Extra parameter for operations that need it.
|
|
19
|
+
* @property {Partial<any>} [defaults] - Default values for create operations.
|
|
20
|
+
* @property {number} [pk] - Primary key value.
|
|
21
|
+
* @property {any} [data] - Data payload.
|
|
22
|
+
* @property {string} [searchQuery] - Search term for search operations.
|
|
23
|
+
* @property {string[]} [searchFields] - Optional array of field names for search.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {Object} SerializerOptions
|
|
27
|
+
* @property {number} [depth] - How deep to serialize nested objects.
|
|
28
|
+
* @property {string[]} [fields] - Fields to include.
|
|
29
|
+
* @property {number} [limit] - Limit for pagination.
|
|
30
|
+
* @property {number} [offset] - Offset for pagination.
|
|
31
|
+
* @property {number} [overfetch] - Overfetch additional items, for smooth optimistic delete replacement.
|
|
32
|
+
* @property {string} [namespace] - Custom namespace for real-time updates.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* @template T
|
|
36
|
+
* @typedef {Object.<string, any>} FieldLookup
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* @template T
|
|
40
|
+
* @typedef {Object.<string, any>} ObjectLookup
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* Django-specific Q helper type.
|
|
44
|
+
*
|
|
45
|
+
* A QCondition is either a partial object of type T or a combination
|
|
46
|
+
* of partial field and object lookups.
|
|
47
|
+
*
|
|
48
|
+
* @template T
|
|
49
|
+
* @typedef {Partial<T> | (Partial<FieldLookup<T>> & Partial<ObjectLookup<T>>)} QCondition
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Django-specific Q helper type representing a logical grouping of conditions.
|
|
53
|
+
*
|
|
54
|
+
* @template T
|
|
55
|
+
* @typedef {Object} QObject
|
|
56
|
+
* @property {'AND'|'OR'} operator - The logical operator.
|
|
57
|
+
* @property {Array<QCondition<T>|QObject<T>>} conditions - An array of conditions or nested Q objects.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Creates a Q object for combining conditions.
|
|
61
|
+
*
|
|
62
|
+
* @template T
|
|
63
|
+
* @param {'AND'|'OR'} operator - The operator to combine conditions.
|
|
64
|
+
* @param {...(QCondition<T>|QObject<T>)} conditions - The conditions to combine.
|
|
65
|
+
* @returns {QObject<T>} The combined Q object.
|
|
66
|
+
*/
|
|
67
|
+
export function Q<T>(operator: "AND" | "OR", ...conditions: (QCondition<T> | QObject<T>)[]): QObject<T>;
|
|
68
|
+
/**
|
|
69
|
+
* A QuerySet provides a fluent API for constructing and executing queries.
|
|
70
|
+
*
|
|
71
|
+
* @template T
|
|
72
|
+
*/
|
|
73
|
+
export class QuerySet<T> {
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new QuerySet.
|
|
76
|
+
*
|
|
77
|
+
* @param {ModelConstructor} ModelClass - The model constructor.
|
|
78
|
+
* @param {Object} [config={}] - The configuration for the QuerySet.
|
|
79
|
+
* @param {QueryNode[]} [config.nodes] - Array of query nodes.
|
|
80
|
+
* @param {Array<{ field: string, direction: 'asc'|'desc' }>} [config.orderBy] - Ordering configuration.
|
|
81
|
+
* @param {Set<string>} [config.fields] - Set of fields to retrieve.
|
|
82
|
+
* @param {Aggregation[]} [config.aggregations] - Aggregation operations.
|
|
83
|
+
* @param {string} [config.initialQueryset] - The initial queryset identifier.
|
|
84
|
+
* @param {SerializerOptions} [config.serializerOptions] - Serializer options.
|
|
85
|
+
* @param {boolean} [config.materialized] - Whether the queryset is materialized.
|
|
86
|
+
*/
|
|
87
|
+
constructor(ModelClass: ModelConstructor, config?: {
|
|
88
|
+
nodes?: QueryNode[] | undefined;
|
|
89
|
+
orderBy?: {
|
|
90
|
+
field: string;
|
|
91
|
+
direction: "asc" | "desc";
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
fields?: Set<string> | undefined;
|
|
94
|
+
aggregations?: Aggregation[] | undefined;
|
|
95
|
+
initialQueryset?: string | undefined;
|
|
96
|
+
serializerOptions?: SerializerOptions | undefined;
|
|
97
|
+
materialized?: boolean | undefined;
|
|
98
|
+
}, parent?: null);
|
|
99
|
+
ModelClass: ModelConstructor;
|
|
100
|
+
nodes: QueryNode[];
|
|
101
|
+
_orderBy: {
|
|
102
|
+
field: string;
|
|
103
|
+
direction: "asc" | "desc";
|
|
104
|
+
}[] | undefined;
|
|
105
|
+
_fields: Set<string>;
|
|
106
|
+
_aggregations: Aggregation[];
|
|
107
|
+
_initialQueryset: string | undefined;
|
|
108
|
+
_serializerOptions: SerializerOptions;
|
|
109
|
+
_materialized: boolean;
|
|
110
|
+
__uuid: string;
|
|
111
|
+
__parent: any;
|
|
112
|
+
__reactivityId: any;
|
|
113
|
+
/**
|
|
114
|
+
* Clones this QuerySet, creating a new instance with the same configuration.
|
|
115
|
+
*
|
|
116
|
+
* @returns {QuerySet} A new QuerySet instance.
|
|
117
|
+
*/
|
|
118
|
+
clone(): QuerySet<any>;
|
|
119
|
+
get semanticKey(): string;
|
|
120
|
+
get key(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Ensures the QuerySet is still lazy (not materialized).
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
* @throws {Error} If the QuerySet is already materialized.
|
|
126
|
+
*/
|
|
127
|
+
private ensureNotMaterialized;
|
|
128
|
+
/**
|
|
129
|
+
* Returns the model constructor for this QuerySet.
|
|
130
|
+
*
|
|
131
|
+
* @returns {ModelConstructor} The model constructor.
|
|
132
|
+
*/
|
|
133
|
+
get modelClass(): ModelConstructor;
|
|
134
|
+
/**
|
|
135
|
+
* Sets serializer options for the QuerySet.
|
|
136
|
+
*
|
|
137
|
+
* @param {SerializerOptions} options - The serializer options to set.
|
|
138
|
+
* @returns {QuerySet} This QuerySet instance for chaining.
|
|
139
|
+
*/
|
|
140
|
+
setSerializerOptions(options: SerializerOptions): QuerySet<any>;
|
|
141
|
+
/**
|
|
142
|
+
* Filters the QuerySet with the provided conditions.
|
|
143
|
+
*
|
|
144
|
+
* @param {Object} conditions - The filter conditions.
|
|
145
|
+
* @returns {QuerySet} A new QuerySet with the filter applied.
|
|
146
|
+
*/
|
|
147
|
+
filter(conditions: Object): QuerySet<any>;
|
|
148
|
+
/**
|
|
149
|
+
* Excludes the specified conditions from the QuerySet.
|
|
150
|
+
*
|
|
151
|
+
* @param {Object} conditions - The conditions to exclude.
|
|
152
|
+
* @returns {QuerySet} A new QuerySet with the exclusion applied.
|
|
153
|
+
*/
|
|
154
|
+
exclude(conditions: Object): QuerySet<any>;
|
|
155
|
+
/**
|
|
156
|
+
* Orders the QuerySet by the specified fields.
|
|
157
|
+
*
|
|
158
|
+
* @param {...string} fields - Fields to order by.
|
|
159
|
+
* @returns {QuerySet} A new QuerySet with ordering applied.
|
|
160
|
+
*/
|
|
161
|
+
orderBy(...fields: string[]): QuerySet<any>;
|
|
162
|
+
/**
|
|
163
|
+
* Applies a search to the QuerySet using the specified search query and fields.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} searchQuery - The search query.
|
|
166
|
+
* @param {string[]} [searchFields] - The fields to search.
|
|
167
|
+
* @returns {QuerySet} A new QuerySet with the search applied.
|
|
168
|
+
*/
|
|
169
|
+
search(searchQuery: string, searchFields?: string[]): QuerySet<any>;
|
|
170
|
+
/**
|
|
171
|
+
* Processes a Q object or condition into a QueryNode.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @param {QObject|QCondition} q - The query object or condition.
|
|
175
|
+
* @returns {QueryNode} The processed QueryNode.
|
|
176
|
+
*/
|
|
177
|
+
private processQObject;
|
|
178
|
+
/**
|
|
179
|
+
* Aggregates the QuerySet using the specified function.
|
|
180
|
+
*
|
|
181
|
+
* @param {AggregateFunction} fn - The aggregation function.
|
|
182
|
+
* @param {string} field - The field to aggregate.
|
|
183
|
+
* @param {string} [alias] - An optional alias for the aggregated field.
|
|
184
|
+
* @returns {QuerySet} A new QuerySet with the aggregation applied.
|
|
185
|
+
*/
|
|
186
|
+
aggregate(fn: AggregateFunction, field: string, alias?: string): QuerySet<any>;
|
|
187
|
+
/**
|
|
188
|
+
* Executes a count query on the QuerySet.
|
|
189
|
+
*
|
|
190
|
+
* @param {string} [field] - The field to count.
|
|
191
|
+
* @returns {Promise<number>} A promise that resolves to the count.
|
|
192
|
+
*/
|
|
193
|
+
count(field?: string): Promise<number>;
|
|
194
|
+
/**
|
|
195
|
+
* Executes a sum aggregation on the QuerySet.
|
|
196
|
+
*
|
|
197
|
+
* @param {string} field - The field to sum.
|
|
198
|
+
* @returns {Promise<number>} A promise that resolves to the sum.
|
|
199
|
+
*/
|
|
200
|
+
sum(field: string): Promise<number>;
|
|
201
|
+
/**
|
|
202
|
+
* Executes an average aggregation on the QuerySet.
|
|
203
|
+
*
|
|
204
|
+
* @param {string} field - The field to average.
|
|
205
|
+
* @returns {Promise<number>} A promise that resolves to the average.
|
|
206
|
+
*/
|
|
207
|
+
avg(field: string): Promise<number>;
|
|
208
|
+
/**
|
|
209
|
+
* Executes a min aggregation on the QuerySet.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} field - The field to find the minimum value for.
|
|
212
|
+
* @returns {Promise<any>} A promise that resolves to the minimum value.
|
|
213
|
+
*/
|
|
214
|
+
min(field: string): Promise<any>;
|
|
215
|
+
/**
|
|
216
|
+
* Executes a max aggregation on the QuerySet.
|
|
217
|
+
*
|
|
218
|
+
* @param {string} field - The field to find the maximum value for.
|
|
219
|
+
* @returns {Promise<any>} A promise that resolves to the maximum value.
|
|
220
|
+
*/
|
|
221
|
+
max(field: string): Promise<any>;
|
|
222
|
+
/**
|
|
223
|
+
* Retrieves the first record of the QuerySet.
|
|
224
|
+
*
|
|
225
|
+
* @param {SerializerOptions} [serializerOptions] - Optional serializer options.
|
|
226
|
+
* @returns {Promise<T|null>} A promise that resolves to the first record or null.
|
|
227
|
+
*/
|
|
228
|
+
first(serializerOptions?: SerializerOptions): Promise<T | null>;
|
|
229
|
+
/**
|
|
230
|
+
* Retrieves the last record of the QuerySet.
|
|
231
|
+
*
|
|
232
|
+
* @param {SerializerOptions} [serializerOptions] - Optional serializer options.
|
|
233
|
+
* @returns {Promise<T|null>} A promise that resolves to the last record or null.
|
|
234
|
+
*/
|
|
235
|
+
last(serializerOptions?: SerializerOptions): Promise<T | null>;
|
|
236
|
+
/**
|
|
237
|
+
* Checks if any records exist in the QuerySet.
|
|
238
|
+
*
|
|
239
|
+
* @returns {Promise<boolean>} A promise that resolves to true if records exist, otherwise false.
|
|
240
|
+
*/
|
|
241
|
+
exists(): Promise<boolean>;
|
|
242
|
+
/**
|
|
243
|
+
* Applies serializer options to the QuerySet.
|
|
244
|
+
*
|
|
245
|
+
* @param {SerializerOptions} [serializerOptions] - Optional serializer options.
|
|
246
|
+
* @returns {QuerySet} A new QuerySet with the serializer options applied.
|
|
247
|
+
*/
|
|
248
|
+
all(serializerOptions?: SerializerOptions): QuerySet<any>;
|
|
249
|
+
/**
|
|
250
|
+
* Creates a new record in the QuerySet.
|
|
251
|
+
* @param {Object} data - The fields and values for the new record.
|
|
252
|
+
* @returns {Promise<any>} The created model instance.
|
|
253
|
+
*/
|
|
254
|
+
create(data: Object): Promise<any>;
|
|
255
|
+
/**
|
|
256
|
+
* Updates records in the QuerySet.
|
|
257
|
+
*
|
|
258
|
+
* @param {Object} updates - The fields to update.
|
|
259
|
+
* @returns {Promise<[number, Object]>} A promise that resolves to a tuple with the number of updated records and a mapping of model names to counts.
|
|
260
|
+
*/
|
|
261
|
+
update(updates: Object, ...args: any[]): Promise<[number, Object]>;
|
|
262
|
+
/**
|
|
263
|
+
* Deletes records in the QuerySet.
|
|
264
|
+
*
|
|
265
|
+
* @returns {Promise<[number, Object]>} A promise that resolves to a tuple with the number of deleted records and a mapping of model names to counts.
|
|
266
|
+
*/
|
|
267
|
+
delete(...args: any[]): Promise<[number, Object]>;
|
|
268
|
+
/**
|
|
269
|
+
* Retrieves a single record from the QuerySet.
|
|
270
|
+
*
|
|
271
|
+
* @param {Object} [filters] - Optional filters to apply.
|
|
272
|
+
* @param {SerializerOptions} [serializerOptions] - Optional serializer options.
|
|
273
|
+
* @returns {Promise<T>} A promise that resolves to the retrieved record.
|
|
274
|
+
* @throws {MultipleObjectsReturned} If more than one record is found.
|
|
275
|
+
* @throws {DoesNotExist} If no records are found.
|
|
276
|
+
*/
|
|
277
|
+
get(filters?: Object, serializerOptions?: SerializerOptions): Promise<T>;
|
|
278
|
+
/**
|
|
279
|
+
* Builds the final query object to be sent to the backend (simple jsonable object format).
|
|
280
|
+
*
|
|
281
|
+
* @returns {Object} The final query object.
|
|
282
|
+
*/
|
|
283
|
+
build(): Object;
|
|
284
|
+
/**
|
|
285
|
+
* Returns the current configuration of the QuerySet.
|
|
286
|
+
*
|
|
287
|
+
* @private
|
|
288
|
+
* @returns {Object} The current QuerySet configuration.
|
|
289
|
+
*/
|
|
290
|
+
private _getConfig;
|
|
291
|
+
/**
|
|
292
|
+
* Materializes the QuerySet into an array of model instances.
|
|
293
|
+
*
|
|
294
|
+
* @param {SerializerOptions} [serializerOptions] - Optional serializer options.
|
|
295
|
+
* @returns {Promise<T[]>} A promise that resolves to an array of model instances.
|
|
296
|
+
*/
|
|
297
|
+
fetch(serializerOptions?: SerializerOptions): Promise<T[]>;
|
|
298
|
+
/**
|
|
299
|
+
* Implements the async iterator protocol so that you can iterate over the QuerySet.
|
|
300
|
+
*
|
|
301
|
+
* @returns {AsyncIterator<T>} An async iterator over the model instances.
|
|
302
|
+
*/
|
|
303
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
304
|
+
}
|
|
305
|
+
export type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
|
|
306
|
+
export type Aggregation = {
|
|
307
|
+
/**
|
|
308
|
+
* - The aggregation function.
|
|
309
|
+
*/
|
|
310
|
+
function: AggregateFunction;
|
|
311
|
+
/**
|
|
312
|
+
* - The field to aggregate.
|
|
313
|
+
*/
|
|
314
|
+
field: string;
|
|
315
|
+
/**
|
|
316
|
+
* - Optional alias for the aggregated field.
|
|
317
|
+
*/
|
|
318
|
+
alias?: string | undefined;
|
|
319
|
+
};
|
|
320
|
+
export type QueryOperationType = "filter" | "or" | "and" | "not" | "exclude" | "get" | "create" | "update" | "delete" | "get_or_create" | "update_or_create" | "first" | "last" | "exists" | "search";
|
|
321
|
+
export type QueryNode = {
|
|
322
|
+
/**
|
|
323
|
+
* - The operation type.
|
|
324
|
+
*/
|
|
325
|
+
type: QueryOperationType;
|
|
326
|
+
/**
|
|
327
|
+
* - Filter conditions.
|
|
328
|
+
*/
|
|
329
|
+
conditions?: {
|
|
330
|
+
[x: string]: any;
|
|
331
|
+
} | undefined;
|
|
332
|
+
/**
|
|
333
|
+
* - Child query nodes.
|
|
334
|
+
*/
|
|
335
|
+
children?: QueryNode[] | undefined;
|
|
336
|
+
/**
|
|
337
|
+
* - Extra parameter for operations that need it.
|
|
338
|
+
*/
|
|
339
|
+
lookup?: any;
|
|
340
|
+
/**
|
|
341
|
+
* - Default values for create operations.
|
|
342
|
+
*/
|
|
343
|
+
defaults?: Partial<any> | undefined;
|
|
344
|
+
/**
|
|
345
|
+
* - Primary key value.
|
|
346
|
+
*/
|
|
347
|
+
pk?: number | undefined;
|
|
348
|
+
/**
|
|
349
|
+
* - Data payload.
|
|
350
|
+
*/
|
|
351
|
+
data?: any;
|
|
352
|
+
/**
|
|
353
|
+
* - Search term for search operations.
|
|
354
|
+
*/
|
|
355
|
+
searchQuery?: string | undefined;
|
|
356
|
+
/**
|
|
357
|
+
* - Optional array of field names for search.
|
|
358
|
+
*/
|
|
359
|
+
searchFields?: string[] | undefined;
|
|
360
|
+
};
|
|
361
|
+
export type SerializerOptions = {
|
|
362
|
+
/**
|
|
363
|
+
* - How deep to serialize nested objects.
|
|
364
|
+
*/
|
|
365
|
+
depth?: number | undefined;
|
|
366
|
+
/**
|
|
367
|
+
* - Fields to include.
|
|
368
|
+
*/
|
|
369
|
+
fields?: string[] | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* - Limit for pagination.
|
|
372
|
+
*/
|
|
373
|
+
limit?: number | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* - Offset for pagination.
|
|
376
|
+
*/
|
|
377
|
+
offset?: number | undefined;
|
|
378
|
+
/**
|
|
379
|
+
* - Overfetch additional items, for smooth optimistic delete replacement.
|
|
380
|
+
*/
|
|
381
|
+
overfetch?: number | undefined;
|
|
382
|
+
/**
|
|
383
|
+
* - Custom namespace for real-time updates.
|
|
384
|
+
*/
|
|
385
|
+
namespace?: string | undefined;
|
|
386
|
+
};
|
|
387
|
+
export type FieldLookup<T> = {
|
|
388
|
+
[x: string]: any;
|
|
389
|
+
};
|
|
390
|
+
export type ObjectLookup<T> = {
|
|
391
|
+
[x: string]: any;
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Django-specific Q helper type.
|
|
395
|
+
*
|
|
396
|
+
* A QCondition is either a partial object of type T or a combination
|
|
397
|
+
* of partial field and object lookups.
|
|
398
|
+
*/
|
|
399
|
+
export type QCondition<T> = Partial<T> | (Partial<FieldLookup<T>> & Partial<ObjectLookup<T>>);
|
|
400
|
+
/**
|
|
401
|
+
* Django-specific Q helper type representing a logical grouping of conditions.
|
|
402
|
+
*/
|
|
403
|
+
export type QObject<T> = {
|
|
404
|
+
/**
|
|
405
|
+
* - The logical operator.
|
|
406
|
+
*/
|
|
407
|
+
operator: "AND" | "OR";
|
|
408
|
+
/**
|
|
409
|
+
* - An array of conditions or nested Q objects.
|
|
410
|
+
*/
|
|
411
|
+
conditions: Array<QCondition<T> | QObject<T>>;
|
|
412
|
+
};
|