remult 0.14.7 → 0.14.8
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/LICENSE +21 -0
- package/esm/assign.d.ts +1 -0
- package/esm/assign.js +5 -0
- package/esm/classType.d.ts +3 -0
- package/esm/classType.js +1 -0
- package/esm/graphql.d.ts +5 -0
- package/esm/graphql.js +102 -0
- package/esm/index.d.ts +36 -0
- package/esm/index.js +30 -0
- package/esm/inputTypes.d.ts +9 -0
- package/esm/inputTypes.js +9 -0
- package/esm/postgres/index.d.ts +2 -0
- package/esm/postgres/index.js +2 -0
- package/esm/postgres/postgres-data-provider.d.ts +28 -0
- package/esm/postgres/postgres-data-provider.js +97 -0
- package/esm/postgres/schema-builder.d.ts +15 -0
- package/esm/postgres/schema-builder.js +128 -0
- package/esm/remult-express.d.ts +5 -0
- package/esm/remult-express.js +16 -0
- package/esm/remult-knex/index.d.ts +51 -0
- package/esm/remult-knex/index.js +381 -0
- package/esm/remult-middleware.d.ts +2 -0
- package/esm/remult-middleware.js +63 -0
- package/esm/remult-mongo.d.ts +9 -0
- package/esm/remult-mongo.js +220 -0
- package/esm/server/JsonEntityFileStorage.d.ts +7 -0
- package/esm/server/JsonEntityFileStorage.js +20 -0
- package/esm/server/expressBridge.d.ts +140 -0
- package/esm/server/expressBridge.js +668 -0
- package/esm/server/index.d.ts +4 -0
- package/esm/server/index.js +4 -0
- package/esm/server/register-actions-on-server.d.ts +3 -0
- package/esm/server/register-actions-on-server.js +24 -0
- package/esm/server/register-entities-on-server.d.ts +3 -0
- package/esm/server/register-entities-on-server.js +15 -0
- package/esm/src/__EntityValueProvider.d.ts +10 -0
- package/esm/src/__EntityValueProvider.js +1 -0
- package/esm/src/__RowsOfDataForTesting.d.ts +3 -0
- package/esm/src/__RowsOfDataForTesting.js +1 -0
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +5 -0
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +113 -0
- package/esm/src/backend-tests/my-test.backend-spec.d.ts +1 -0
- package/esm/src/backend-tests/my-test.backend-spec.js +49 -0
- package/esm/src/column-interfaces.d.ts +95 -0
- package/esm/src/column-interfaces.js +7 -0
- package/esm/src/column.d.ts +49 -0
- package/esm/src/column.js +133 -0
- package/esm/src/context.d.ts +124 -0
- package/esm/src/context.js +285 -0
- package/esm/src/data-api.d.ts +33 -0
- package/esm/src/data-api.js +204 -0
- package/esm/src/data-interfaces.d.ts +37 -0
- package/esm/src/data-interfaces.js +12 -0
- package/esm/src/data-providers/array-entity-data-provider.d.ts +22 -0
- package/esm/src/data-providers/array-entity-data-provider.js +264 -0
- package/esm/src/data-providers/in-memory-database.d.ts +9 -0
- package/esm/src/data-providers/in-memory-database.js +16 -0
- package/esm/src/data-providers/json-data-provider.d.ts +12 -0
- package/esm/src/data-providers/json-data-provider.js +52 -0
- package/esm/src/data-providers/rest-data-provider.d.ts +35 -0
- package/esm/src/data-providers/rest-data-provider.js +188 -0
- package/esm/src/data-providers/sql-database.d.ts +16 -0
- package/esm/src/data-providers/sql-database.js +261 -0
- package/esm/src/data-providers/web-sql-data-provider.d.ts +18 -0
- package/esm/src/data-providers/web-sql-data-provider.js +121 -0
- package/esm/src/entity.d.ts +82 -0
- package/esm/src/entity.js +1 -0
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -0
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +139 -0
- package/esm/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -0
- package/esm/src/filter/filter-consumer-bridge-to-url-builder.js +1 -0
- package/esm/src/filter/filter-interfaces.d.ts +85 -0
- package/esm/src/filter/filter-interfaces.js +467 -0
- package/esm/src/id-entity.d.ts +4 -0
- package/esm/src/id-entity.js +8 -0
- package/esm/src/remult3/RepositoryImplementation.d.ts +326 -0
- package/esm/src/remult3/RepositoryImplementation.js +1806 -0
- package/esm/src/remult3/index.d.ts +2 -0
- package/esm/src/remult3/index.js +2 -0
- package/esm/src/remult3/remult3.d.ts +312 -0
- package/esm/src/remult3/remult3.js +1 -0
- package/esm/src/server-action.d.ts +70 -0
- package/esm/src/server-action.js +365 -0
- package/esm/src/shared-tests/db-tests-setup.d.ts +23 -0
- package/esm/src/shared-tests/db-tests-setup.js +66 -0
- package/esm/src/shared-tests/db-tests.db-tests.d.ts +26 -0
- package/esm/src/shared-tests/db-tests.db-tests.js +723 -0
- package/esm/src/shared-tests/deleteAll.d.ts +2 -0
- package/esm/src/shared-tests/deleteAll.js +4 -0
- package/esm/src/shared-tests/entityWithValidations.d.ts +14 -0
- package/esm/src/shared-tests/entityWithValidations.js +53 -0
- package/esm/src/shared-tests/index.d.ts +4 -0
- package/esm/src/shared-tests/index.js +4 -0
- package/esm/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
- package/esm/src/shared-tests/test-custom-id-column.spec.js +62 -0
- package/esm/src/shared-tests/test-special-value.spec.d.ts +10 -0
- package/esm/src/shared-tests/test-special-value.spec.js +88 -0
- package/esm/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
- package/esm/src/shared-tests/test-update-with-null.spec.js +47 -0
- package/esm/src/sort.d.ts +15 -0
- package/esm/src/sort.js +82 -0
- package/esm/src/sql-command.d.ts +15 -0
- package/esm/src/sql-command.js +1 -0
- package/esm/src/tests/Done.d.ts +5 -0
- package/esm/src/tests/Done.js +11 -0
- package/esm/src/tests/TestDataApiResponse.d.ts +10 -0
- package/esm/src/tests/TestDataApiResponse.js +22 -0
- package/esm/src/tests/c.d.ts +8 -0
- package/esm/src/tests/c.js +22 -0
- package/esm/src/tests/createData.d.ts +7 -0
- package/esm/src/tests/createData.js +22 -0
- package/esm/src/tests/d.d.ts +6 -0
- package/esm/src/tests/d.js +19 -0
- package/esm/src/tests/dWithPrefilter.d.ts +7 -0
- package/esm/src/tests/dWithPrefilter.js +32 -0
- package/esm/src/tests/entityForCustomFilter.d.ts +16 -0
- package/esm/src/tests/entityForCustomFilter.js +44 -0
- package/esm/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
- package/esm/src/tests/entityWithValidationsOnColumn.js +21 -0
- package/esm/src/tests/frontend-database-tests-setup.spec.d.ts +4 -0
- package/esm/src/tests/frontend-database-tests-setup.spec.js +38 -0
- package/esm/src/tests/h.d.ts +6 -0
- package/esm/src/tests/h.js +35 -0
- package/esm/src/tests/remult-3-entities.d.ts +23 -0
- package/esm/src/tests/remult-3-entities.js +72 -0
- package/esm/src/tests/tasks.d.ts +6 -0
- package/esm/src/tests/tasks.js +24 -0
- package/esm/src/tests/testHelper.spec.d.ts +34 -0
- package/esm/src/tests/testHelper.spec.js +217 -0
- package/esm/src/tests/testModel/models.d.ts +16 -0
- package/esm/src/tests/testModel/models.js +31 -0
- package/esm/src/validators.d.ts +14 -0
- package/esm/src/validators.js +33 -0
- package/esm/urlBuilder.d.ts +6 -0
- package/esm/urlBuilder.js +19 -0
- package/esm/valueConverters.d.ts +12 -0
- package/esm/valueConverters.js +169 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +22 -1
- package/postgres/index.d.ts +1 -0
- package/postgres/index.js +1 -0
- package/postgres/postgres-data-provider.d.ts +1 -13
- package/postgres/postgres-data-provider.js +28 -262
- package/postgres/schema-builder.d.ts +15 -0
- package/postgres/schema-builder.js +270 -0
- package/readme.md +68 -30
- package/src/data-providers/web-sql-data-provider.js +4 -3
- package/src/entity.d.ts +9 -2
- package/src/remult3/RepositoryImplementation.js +11 -3
- package/src/shared-tests/test-update-with-null.spec.js +38 -0
- package/valueConverters.js +4 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { ClassType } from "../../classType";
|
|
2
|
+
import { FieldMetadata } from "../column-interfaces";
|
|
3
|
+
import { Unobserve } from "../context";
|
|
4
|
+
import { EntityOptions as EntityOptions } from "../entity";
|
|
5
|
+
import { SortSegment } from "../sort";
|
|
6
|
+
import { entityEventListener } from "../__EntityValueProvider";
|
|
7
|
+
export interface EntityRef<entityType> extends Subscribable {
|
|
8
|
+
hasErrors(): boolean;
|
|
9
|
+
undoChanges(): any;
|
|
10
|
+
save(): Promise<entityType>;
|
|
11
|
+
reload(): Promise<entityType>;
|
|
12
|
+
delete(): Promise<void>;
|
|
13
|
+
isNew(): boolean;
|
|
14
|
+
wasChanged(): boolean;
|
|
15
|
+
wasDeleted(): boolean;
|
|
16
|
+
fields: FieldsRef<entityType>;
|
|
17
|
+
error: string;
|
|
18
|
+
getId(): any;
|
|
19
|
+
repository: Repository<entityType>;
|
|
20
|
+
metadata: EntityMetadata<entityType>;
|
|
21
|
+
toApiJson(): any;
|
|
22
|
+
validate(): Promise<boolean>;
|
|
23
|
+
readonly apiUpdateAllowed: boolean;
|
|
24
|
+
readonly apiDeleteAllowed: boolean;
|
|
25
|
+
readonly apiInsertAllowed: boolean;
|
|
26
|
+
readonly isLoading: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ControllerRef<entityType> extends Subscribable {
|
|
29
|
+
hasErrors(): boolean;
|
|
30
|
+
fields: FieldsRef<entityType>;
|
|
31
|
+
error: string;
|
|
32
|
+
validate(): Promise<boolean>;
|
|
33
|
+
readonly isLoading: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface RefSubscriberBase {
|
|
36
|
+
reportChanged: () => void;
|
|
37
|
+
reportObserved: () => void;
|
|
38
|
+
}
|
|
39
|
+
export declare type RefSubscriber = (() => void) | RefSubscriberBase;
|
|
40
|
+
export interface Subscribable {
|
|
41
|
+
subscribe(listener: RefSubscriber): Unobserve;
|
|
42
|
+
}
|
|
43
|
+
export declare type FieldsRef<entityType> = {
|
|
44
|
+
[Properties in keyof OmitEB<entityType>]: entityType[Properties] extends {
|
|
45
|
+
id?: (number | string);
|
|
46
|
+
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
47
|
+
} & {
|
|
48
|
+
find(fieldMetadataOrKey: FieldMetadata | string): FieldRef<entityType, any>;
|
|
49
|
+
[Symbol.iterator]: () => IterableIterator<FieldRef<entityType, any>>;
|
|
50
|
+
toArray(): FieldRef<entityType, any>[];
|
|
51
|
+
};
|
|
52
|
+
export declare type FieldsMetadata<entityType> = {
|
|
53
|
+
[Properties in keyof OmitEB<entityType>]: FieldMetadata<entityType[Properties]>;
|
|
54
|
+
} & {
|
|
55
|
+
find(fieldMetadataOrKey: FieldMetadata | string): FieldMetadata;
|
|
56
|
+
[Symbol.iterator]: () => IterableIterator<FieldMetadata>;
|
|
57
|
+
toArray(): FieldMetadata<any>[];
|
|
58
|
+
};
|
|
59
|
+
export declare type SortSegments<entityType> = {
|
|
60
|
+
[Properties in keyof entityType]: SortSegment & {
|
|
61
|
+
descending(): SortSegment;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export interface IdFieldRef<entityType, valueType> extends FieldRef<entityType, valueType> {
|
|
65
|
+
setId(id: valueType extends {
|
|
66
|
+
id?: number;
|
|
67
|
+
} ? number : valueType extends {
|
|
68
|
+
id?: string;
|
|
69
|
+
} ? string : (string | number)): any;
|
|
70
|
+
getId(): (valueType extends {
|
|
71
|
+
id?: number;
|
|
72
|
+
} ? number : valueType extends {
|
|
73
|
+
id?: string;
|
|
74
|
+
} ? string : (string | number));
|
|
75
|
+
}
|
|
76
|
+
export interface FieldRef<entityType = any, valueType = any> extends Subscribable {
|
|
77
|
+
error: string;
|
|
78
|
+
displayValue: string;
|
|
79
|
+
value: valueType;
|
|
80
|
+
originalValue: valueType;
|
|
81
|
+
inputValue: string;
|
|
82
|
+
valueChanged(): boolean;
|
|
83
|
+
entityRef: EntityRef<entityType>;
|
|
84
|
+
container: entityType;
|
|
85
|
+
metadata: FieldMetadata<valueType>;
|
|
86
|
+
load(): Promise<valueType>;
|
|
87
|
+
valueIsNull(): boolean;
|
|
88
|
+
originalValueIsNull(): boolean;
|
|
89
|
+
validate(): Promise<boolean>;
|
|
90
|
+
}
|
|
91
|
+
export interface IdMetadata<entityType = any> {
|
|
92
|
+
field: FieldMetadata<any>;
|
|
93
|
+
getIdFilter(...ids: any[]): EntityFilter<entityType>;
|
|
94
|
+
isIdField(col: FieldMetadata): boolean;
|
|
95
|
+
createIdInFilter(items: entityType[]): EntityFilter<entityType>;
|
|
96
|
+
}
|
|
97
|
+
export interface EntityMetadata<entityType = any> {
|
|
98
|
+
readonly idMetadata: IdMetadata<entityType>;
|
|
99
|
+
readonly key: string;
|
|
100
|
+
readonly fields: FieldsMetadata<entityType>;
|
|
101
|
+
readonly caption: string;
|
|
102
|
+
readonly options: EntityOptions;
|
|
103
|
+
readonly entityType: ClassType<entityType>;
|
|
104
|
+
readonly apiUpdateAllowed: boolean;
|
|
105
|
+
readonly apiReadAllowed: boolean;
|
|
106
|
+
readonly apiDeleteAllowed: boolean;
|
|
107
|
+
readonly apiInsertAllowed: boolean;
|
|
108
|
+
getDbName(): Promise<string>;
|
|
109
|
+
}
|
|
110
|
+
export declare type OmitEB<T> = Omit<T, keyof import('./RepositoryImplementation').EntityBase>;
|
|
111
|
+
/**used to perform CRUD operations on an `entityType` */
|
|
112
|
+
export interface Repository<entityType> {
|
|
113
|
+
/** returns a result array based on the provided options */
|
|
114
|
+
find(options?: FindOptions<entityType>): Promise<entityType[]>;
|
|
115
|
+
/** returns the first item that matchers the `where` condition
|
|
116
|
+
* @example
|
|
117
|
+
* await taskRepo.findFirst({ completed:false })
|
|
118
|
+
* @example
|
|
119
|
+
* await taskRepo.findFirst({ completed:false },{ createIfNotFound: true })
|
|
120
|
+
* */
|
|
121
|
+
findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>): Promise<entityType>;
|
|
122
|
+
/** returns the items that matches the idm the result is cached unless specified differently in the `options` parameter */
|
|
123
|
+
findId(id: entityType extends {
|
|
124
|
+
id?: number;
|
|
125
|
+
} ? number : entityType extends {
|
|
126
|
+
id?: string;
|
|
127
|
+
} ? string : (string | number), options?: FindFirstOptionsBase<entityType>): Promise<entityType>;
|
|
128
|
+
/** An alternative form of fetching data from the API server, which is intended for operating on large numbers of entity objects.
|
|
129
|
+
*
|
|
130
|
+
* It also has it's own paging mechanism that can be used n paging scenarios.
|
|
131
|
+
*
|
|
132
|
+
* The `query` method doesn't return an array (as the `find` method) and instead returns an `iteratable` `QueryResult` object
|
|
133
|
+
* which supports iterations using the JavaScript `for await` statement.
|
|
134
|
+
* @example
|
|
135
|
+
* for await (const task of taskRepo.query()) {
|
|
136
|
+
* // do something.
|
|
137
|
+
* }
|
|
138
|
+
* */
|
|
139
|
+
query(options?: QueryOptions<entityType>): QueryResult<entityType>;
|
|
140
|
+
/** Returns a count of the items matching the criteria.
|
|
141
|
+
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
142
|
+
* @example
|
|
143
|
+
* await taskRepo.count({ completed:false })
|
|
144
|
+
*/
|
|
145
|
+
count(where?: EntityFilter<entityType>): Promise<number>;
|
|
146
|
+
/** saves an item or item[] to the data source. It assumes that if an `id` value exists, it's an existing row - otherwise it's a new row
|
|
147
|
+
* @example
|
|
148
|
+
* await taskRepo.save({...task, completed:true })
|
|
149
|
+
*/
|
|
150
|
+
save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
151
|
+
save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
152
|
+
/**Insert an item or item[] to the data source
|
|
153
|
+
* @example
|
|
154
|
+
* await taskRepo.insert({title:"task a"})
|
|
155
|
+
* @example
|
|
156
|
+
* await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
|
|
157
|
+
*/
|
|
158
|
+
insert(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
159
|
+
insert(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
160
|
+
/** Updates an item, based on it's `id`
|
|
161
|
+
* @example
|
|
162
|
+
* taskRepo.update(task.id,{...task,completed:true})
|
|
163
|
+
*/
|
|
164
|
+
update(id: (entityType extends {
|
|
165
|
+
id?: number;
|
|
166
|
+
} ? number : entityType extends {
|
|
167
|
+
id?: string;
|
|
168
|
+
} ? string : (string | number)), item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
169
|
+
/** Deletes an Item*/
|
|
170
|
+
delete(id: (entityType extends {
|
|
171
|
+
id?: number;
|
|
172
|
+
} ? number : entityType extends {
|
|
173
|
+
id?: string;
|
|
174
|
+
} ? string : (string | number))): Promise<void>;
|
|
175
|
+
delete(item: entityType): Promise<void>;
|
|
176
|
+
/** Creates an instance of an item. It'll not be saved to the data source unless `save` or `insert` will be called for that item */
|
|
177
|
+
create(item?: Partial<OmitEB<entityType>>): entityType;
|
|
178
|
+
/** Translates a json object to an item instance */
|
|
179
|
+
fromJson(x: any, isNew?: boolean): Promise<entityType>;
|
|
180
|
+
/** returns an `entityRef` for an item returned by `create`, `find` etc... */
|
|
181
|
+
getEntityRef(item: entityType): EntityRef<entityType>;
|
|
182
|
+
/**The metadata for the `entity` */
|
|
183
|
+
metadata: EntityMetadata<entityType>;
|
|
184
|
+
addEventListener(listener: entityEventListener<entityType>): Unobserve;
|
|
185
|
+
}
|
|
186
|
+
export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
187
|
+
/** Determines the number of rows returned by the request, on the browser the default is 100 rows
|
|
188
|
+
* @example
|
|
189
|
+
* await this.remult.repo(Products).find({
|
|
190
|
+
* limit:10,
|
|
191
|
+
* page:2
|
|
192
|
+
* })
|
|
193
|
+
*/
|
|
194
|
+
limit?: number;
|
|
195
|
+
/** Determines the page number that will be used to extract the data
|
|
196
|
+
* @example
|
|
197
|
+
* await this.remult.repo(Products).find({
|
|
198
|
+
* limit:10,
|
|
199
|
+
* page:2
|
|
200
|
+
* })
|
|
201
|
+
*/
|
|
202
|
+
page?: number;
|
|
203
|
+
}
|
|
204
|
+
/** Determines the order of items returned .
|
|
205
|
+
* @example
|
|
206
|
+
* await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
|
|
207
|
+
* @example
|
|
208
|
+
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
209
|
+
*/
|
|
210
|
+
export declare type EntityOrderBy<entityType> = {
|
|
211
|
+
[Properties in keyof Partial<OmitEB<entityType>>]?: "asc" | "desc";
|
|
212
|
+
};
|
|
213
|
+
/**Used to filter the desired result set
|
|
214
|
+
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
215
|
+
*/
|
|
216
|
+
export declare type EntityFilter<entityType> = {
|
|
217
|
+
[Properties in keyof Partial<OmitEB<entityType>>]?: (Partial<OmitEB<entityType>>[Properties] extends (number | Date | undefined) ? ComparisonValueFilter<Partial<OmitEB<entityType>>[Properties]> : Partial<OmitEB<entityType>>[Properties] extends (string | undefined) ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<OmitEB<entityType>>[Properties] extends (boolean | undefined) ? ValueFilter<boolean> : Partial<OmitEB<entityType>>[Properties] extends ({
|
|
218
|
+
id?: (string | number);
|
|
219
|
+
} | undefined) ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) & ContainsStringValueFilter;
|
|
220
|
+
} & {
|
|
221
|
+
$or?: EntityFilter<entityType>[];
|
|
222
|
+
$and?: EntityFilter<entityType>[];
|
|
223
|
+
};
|
|
224
|
+
export declare type ValueFilter<valueType> = valueType | valueType[] | {
|
|
225
|
+
$ne?: valueType | valueType[];
|
|
226
|
+
"!="?: valueType | valueType[];
|
|
227
|
+
};
|
|
228
|
+
export declare type ComparisonValueFilter<valueType> = ValueFilter<valueType> & {
|
|
229
|
+
$gt?: valueType;
|
|
230
|
+
">"?: valueType;
|
|
231
|
+
$gte?: valueType;
|
|
232
|
+
">="?: valueType;
|
|
233
|
+
$lt?: valueType;
|
|
234
|
+
"<"?: valueType;
|
|
235
|
+
$lte?: valueType;
|
|
236
|
+
"<="?: valueType;
|
|
237
|
+
};
|
|
238
|
+
export interface ContainsStringValueFilter {
|
|
239
|
+
$contains?: string;
|
|
240
|
+
}
|
|
241
|
+
export declare type IdFilter<valueType> = ValueFilter<valueType> | {
|
|
242
|
+
$id: ValueFilter<valueType extends {
|
|
243
|
+
id?: number;
|
|
244
|
+
} ? number : string>;
|
|
245
|
+
};
|
|
246
|
+
export interface LoadOptions<entityType> {
|
|
247
|
+
load?: (entity: FieldsMetadata<entityType>) => FieldMetadata[];
|
|
248
|
+
}
|
|
249
|
+
export interface FindOptionsBase<entityType> extends LoadOptions<entityType> {
|
|
250
|
+
/** filters the data
|
|
251
|
+
* @example
|
|
252
|
+
* await taskRepo.find({where: { completed:false }})
|
|
253
|
+
* @see For more usage examples see [EntityFilter](https://remult.dev/docs/entityFilter.html)
|
|
254
|
+
*/
|
|
255
|
+
where?: EntityFilter<entityType>;
|
|
256
|
+
/** Determines the order of items returned .
|
|
257
|
+
* @example
|
|
258
|
+
* await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
|
|
259
|
+
* @example
|
|
260
|
+
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
261
|
+
*/
|
|
262
|
+
orderBy?: EntityOrderBy<entityType>;
|
|
263
|
+
}
|
|
264
|
+
export interface FindFirstOptions<entityType> extends FindOptionsBase<entityType>, FindFirstOptionsBase<entityType> {
|
|
265
|
+
}
|
|
266
|
+
export interface FindFirstOptionsBase<entityType> extends LoadOptions<entityType> {
|
|
267
|
+
/** determines if to cache the result, and return the results from cache.
|
|
268
|
+
*/
|
|
269
|
+
useCache?: boolean;
|
|
270
|
+
/** If set to true and an item is not found, it's created and returned*/
|
|
271
|
+
createIfNotFound?: boolean;
|
|
272
|
+
}
|
|
273
|
+
export interface QueryOptions<entityType> extends FindOptionsBase<entityType> {
|
|
274
|
+
/** The number of items to return in each step */
|
|
275
|
+
pageSize?: number;
|
|
276
|
+
/** A callback method to indicate the progress of the iteration */
|
|
277
|
+
progress?: {
|
|
278
|
+
progress: (progress: number) => void;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/** The result of a call to the `query` method in the `Repository` object.
|
|
282
|
+
*/
|
|
283
|
+
export interface QueryResult<entityType> {
|
|
284
|
+
/** returns an iterator that iterates the rows in the result using a paging mechanism
|
|
285
|
+
* @example
|
|
286
|
+
* for await (const task of taskRepo.query()) {
|
|
287
|
+
* await taskRepo.save({ ...task, completed });
|
|
288
|
+
* }
|
|
289
|
+
*/
|
|
290
|
+
[Symbol.asyncIterator](): {
|
|
291
|
+
next: () => Promise<IteratorResult<entityType, entityType>>;
|
|
292
|
+
};
|
|
293
|
+
/** returns the number of rows that match the query criteria */
|
|
294
|
+
count(): Promise<number>;
|
|
295
|
+
/** Returns a `Paginator` object that is used for efficient paging */
|
|
296
|
+
paginator(): Promise<Paginator<entityType>>;
|
|
297
|
+
/** gets the items in a specific page */
|
|
298
|
+
getPage(pageNumber?: number): Promise<entityType[]>;
|
|
299
|
+
/** Performs an operation on all the items matching the query criteria */
|
|
300
|
+
forEach(what: (item: entityType) => Promise<any>): Promise<number>;
|
|
301
|
+
}
|
|
302
|
+
/** An interface used to paginating using the `query` method in the `Repository` object */
|
|
303
|
+
export interface Paginator<entityType> {
|
|
304
|
+
/** the items in the current page */
|
|
305
|
+
items: entityType[];
|
|
306
|
+
/** True if next page exists */
|
|
307
|
+
hasNextPage: boolean;
|
|
308
|
+
/** Gets the next page in the `query`'s result set */
|
|
309
|
+
nextPage(): Promise<Paginator<entityType>>;
|
|
310
|
+
/** the count of the total items in the `query`'s result */
|
|
311
|
+
count(): Promise<number>;
|
|
312
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Remult, AllowedForInstance } from './context';
|
|
3
|
+
import { DataApiRequest, DataApiResponse } from './data-api';
|
|
4
|
+
import { DataProvider, RestDataProviderHttpProvider } from './data-interfaces';
|
|
5
|
+
interface inArgs {
|
|
6
|
+
args: any[];
|
|
7
|
+
}
|
|
8
|
+
interface result {
|
|
9
|
+
data: any;
|
|
10
|
+
}
|
|
11
|
+
export declare abstract class Action<inParam, outParam> {
|
|
12
|
+
private actionUrl;
|
|
13
|
+
private queue;
|
|
14
|
+
private allowed;
|
|
15
|
+
constructor(actionUrl: string, queue: boolean, allowed: AllowedForInstance<any>);
|
|
16
|
+
static apiUrlForJobStatus: string;
|
|
17
|
+
static provider: RestDataProviderHttpProvider;
|
|
18
|
+
run(pIn: inParam): Promise<outParam>;
|
|
19
|
+
protected abstract execute(info: inParam, req: Remult, res: DataApiResponse): Promise<outParam>;
|
|
20
|
+
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: ((data: any, req: Remult, res: DataApiResponse) => void)) => void): void;
|
|
21
|
+
}
|
|
22
|
+
export declare class myServerAction extends Action<inArgs, result> {
|
|
23
|
+
private types;
|
|
24
|
+
private options;
|
|
25
|
+
private originalMethod;
|
|
26
|
+
constructor(name: string, types: any[], options: BackendMethodOptions<any>, originalMethod: (args: any[]) => any);
|
|
27
|
+
protected execute(info: inArgs, remult: Remult, res: DataApiResponse): Promise<result>;
|
|
28
|
+
}
|
|
29
|
+
export interface BackendMethodOptions<type> {
|
|
30
|
+
/**Determines when this `BackendMethod` can execute, see: [Allowed](https://remult.dev/docs/allowed.html) */
|
|
31
|
+
allowed: AllowedForInstance<type>;
|
|
32
|
+
/** EXPERIMENTAL: Determines if this method should be queued for later execution */
|
|
33
|
+
queue?: boolean;
|
|
34
|
+
/** EXPERIMENTAL: Determines if the user should be blocked while this `BackendMethod` is running*/
|
|
35
|
+
blockUser?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const actionInfo: {
|
|
38
|
+
allActions: any[];
|
|
39
|
+
runningOnServer: boolean;
|
|
40
|
+
runActionWithoutBlockingUI: (what: () => Promise<any>) => Promise<any>;
|
|
41
|
+
startBusyWithProgress: () => {
|
|
42
|
+
progress: (percent: number) => void;
|
|
43
|
+
close: () => void;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare const serverActionField: unique symbol;
|
|
47
|
+
export declare function Controller(key: string): (target: any) => any;
|
|
48
|
+
/** Indicates that the decorated methods runs on the backend. See: [Backend Methods](https://remult.dev/docs/backendMethods.html) */
|
|
49
|
+
export declare function BackendMethod<type = any>(options: BackendMethodOptions<type>): (target: any, key: string, descriptor: any) => any;
|
|
50
|
+
export interface registrableAction {
|
|
51
|
+
__register: (reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: ((data: any, req: DataApiRequest, res: DataApiResponse) => void)) => void) => void;
|
|
52
|
+
}
|
|
53
|
+
export interface jobWasQueuedResult {
|
|
54
|
+
queuedJobId?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface queuedJobInfoResponse {
|
|
57
|
+
done: boolean;
|
|
58
|
+
result?: any;
|
|
59
|
+
error?: any;
|
|
60
|
+
progress?: number;
|
|
61
|
+
}
|
|
62
|
+
export declare class ProgressListener {
|
|
63
|
+
private res;
|
|
64
|
+
constructor(res: DataApiResponse);
|
|
65
|
+
progress(progress: number): void;
|
|
66
|
+
}
|
|
67
|
+
export declare function prepareArgsToSend(types: any[], args: any[]): any[];
|
|
68
|
+
export declare function prepareReceivedArgs(types: any[], args: any[], remult: Remult, ds: DataProvider, res: DataApiResponse): Promise<any[]>;
|
|
69
|
+
export declare const classBackendMethodsArray: unique symbol;
|
|
70
|
+
export {};
|