remult 0.24.0 → 0.24.1
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/esm/src/data-providers/json-data-provider.js +8 -8
- package/esm/src/remult3/remult3.js +7 -20
- package/package.json +1 -1
- package/src/data-providers/json-data-provider.d.ts +2 -2
- package/src/data-providers/json-data-provider.js +39 -16
- package/src/remult3/remult3.d.ts +0 -20
- package/src/remult3/remult3.js +7 -20
- package/esm/SseSubscriptionServer.d.ts +0 -25
- package/esm/ably.d.ts +0 -13
- package/esm/assign.d.ts +0 -1
- package/esm/classType.d.ts +0 -3
- package/esm/graphql.d.ts +0 -14
- package/esm/index.d.ts +0 -46
- package/esm/inputTypes.d.ts +0 -9
- package/esm/internals.d.ts +0 -7
- package/esm/live-query/data-provider-live-query-storage.d.ts +0 -23
- package/esm/myLog.d.ts +0 -1
- package/esm/postgres/index.d.ts +0 -2
- package/esm/postgres/postgres-data-provider.d.ts +0 -36
- package/esm/postgres/schema-builder.d.ts +0 -20
- package/esm/remult-express.d.ts +0 -9
- package/esm/remult-fastify.d.ts +0 -6
- package/esm/remult-fresh.d.ts +0 -17
- package/esm/remult-hapi.d.ts +0 -6
- package/esm/remult-knex/index.d.ts +0 -30
- package/esm/remult-mongo.d.ts +0 -24
- package/esm/remult-next.d.ts +0 -25
- package/esm/remult-sveltekit.d.ts +0 -6
- package/esm/server/JsonEntityFileStorage.d.ts +0 -11
- package/esm/server/core.d.ts +0 -4
- package/esm/server/expressBridge.d.ts +0 -136
- package/esm/server/index.d.ts +0 -6
- package/esm/server/initAsyncHooks.d.ts +0 -1
- package/esm/server/initDataProvider.d.ts +0 -2
- package/esm/src/CompoundIdField.d.ts +0 -27
- package/esm/src/__EntityValueProvider.d.ts +0 -11
- package/esm/src/__RowsOfDataForTesting.d.ts +0 -3
- package/esm/src/buildRestDataProvider.d.ts +0 -30
- package/esm/src/column-interfaces.d.ts +0 -172
- package/esm/src/column.d.ts +0 -19
- package/esm/src/context.d.ts +0 -134
- package/esm/src/data-api.d.ts +0 -39
- package/esm/src/data-interfaces.d.ts +0 -41
- package/esm/src/data-providers/array-entity-data-provider.d.ts +0 -4
- package/esm/src/data-providers/in-memory-database.d.ts +0 -9
- package/esm/src/data-providers/json-data-provider.d.ts +0 -12
- package/esm/src/data-providers/rest-data-provider.d.ts +0 -39
- package/esm/src/data-providers/sql-database.d.ts +0 -33
- package/esm/src/data-providers/web-sql-data-provider.d.ts +0 -21
- package/esm/src/entity.d.ts +0 -126
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -51
- package/esm/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -0
- package/esm/src/filter/filter-consumer-bridge-to-url-builder.js +0 -0
- package/esm/src/filter/filter-interfaces.d.ts +0 -74
- package/esm/src/live-query/LiveQueryClient.d.ts +0 -1
- package/esm/src/live-query/SseSubscriptionClient.d.ts +0 -5
- package/esm/src/live-query/SubscriptionChannel.d.ts +0 -41
- package/esm/src/live-query/SubscriptionServer.d.ts +0 -38
- package/esm/src/remult-proxy.d.ts +0 -2
- package/esm/src/remult3/DecoratorReplacer.d.ts +0 -9
- package/esm/src/remult3/Fields.d.ts +0 -133
- package/esm/src/remult3/IdEntity.d.ts +0 -4
- package/esm/src/remult3/RepositoryImplementation.d.ts +0 -289
- package/esm/src/remult3/__updateEntityBasedOnWhere.d.ts +0 -2
- package/esm/src/remult3/columnInfo.d.ts +0 -6
- package/esm/src/remult3/entity.d.ts +0 -28
- package/esm/src/remult3/getEntityRef.d.ts +0 -9
- package/esm/src/remult3/relation-loader-types.d.ts +0 -7
- package/esm/src/remult3/relation-loader.d.ts +0 -40
- package/esm/src/remult3/relationInfoMember.d.ts +0 -4
- package/esm/src/remult3/remult3.d.ts +0 -604
- package/esm/src/remult3/repository-internals.d.ts +0 -14
- package/esm/src/resultCompoundIdFilter.d.ts +0 -3
- package/esm/src/server-action-info.d.ts +0 -10
- package/esm/src/server-action.d.ts +0 -79
- package/esm/src/sort.d.ts +0 -16
- package/esm/src/sql-command.d.ts +0 -19
- package/esm/src/validators.d.ts +0 -14
- package/esm/src/valueConverters.d.ts +0 -13
- package/esm/urlBuilder.d.ts +0 -6
- package/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -0
- package/src/filter/filter-consumer-bridge-to-url-builder.js +0 -0
|
@@ -1,604 +0,0 @@
|
|
|
1
|
-
import type { ErrorInfo, FieldOptions } from '../..';
|
|
2
|
-
import type { ClassType } from '../../classType';
|
|
3
|
-
import type { entityEventListener } from '../__EntityValueProvider';
|
|
4
|
-
import type { FieldMetadata } from '../column-interfaces';
|
|
5
|
-
import type { EntityOptions } from '../entity';
|
|
6
|
-
import type { LiveQueryChange, SubscriptionListener, Unsubscribe } from '../live-query/SubscriptionChannel';
|
|
7
|
-
import type { SortSegment } from '../sort';
|
|
8
|
-
import type { EntityBase } from './RepositoryImplementation';
|
|
9
|
-
export interface EntityRefBase<entityType> extends Subscribable {
|
|
10
|
-
hasErrors(): boolean;
|
|
11
|
-
undoChanges(): any;
|
|
12
|
-
save(): Promise<entityType>;
|
|
13
|
-
reload(): Promise<entityType>;
|
|
14
|
-
delete(): Promise<void>;
|
|
15
|
-
isNew(): boolean;
|
|
16
|
-
wasChanged(): boolean;
|
|
17
|
-
wasDeleted(): boolean;
|
|
18
|
-
error: string;
|
|
19
|
-
getId(): idType<entityType>;
|
|
20
|
-
getOriginalId(): idType<entityType>;
|
|
21
|
-
repository: Repository<entityType>;
|
|
22
|
-
metadata: EntityMetadata<entityType>;
|
|
23
|
-
toApiJson(): any;
|
|
24
|
-
validate(): Promise<ErrorInfo<entityType> | undefined>;
|
|
25
|
-
readonly apiUpdateAllowed: boolean;
|
|
26
|
-
readonly apiDeleteAllowed: boolean;
|
|
27
|
-
readonly apiInsertAllowed: boolean;
|
|
28
|
-
readonly isLoading: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface EntityRef<entityType> extends EntityRefBase<entityType> {
|
|
31
|
-
fields: FieldsRef<entityType>;
|
|
32
|
-
relations: RepositoryRelations<entityType>;
|
|
33
|
-
}
|
|
34
|
-
export interface EntityRefForEntityBase<entityType> extends EntityRefBase<entityType> {
|
|
35
|
-
fields: FieldsRefForEntityBase<entityType>;
|
|
36
|
-
relations: RepositoryRelationsForEntityBase<entityType>;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Represents a lifecycle event associated with an entity instance. These events
|
|
40
|
-
* are triggered during various stages of the entity's lifecycle, such as validation,
|
|
41
|
-
* saving, saved, deleting, and deleted.
|
|
42
|
-
*
|
|
43
|
-
* @template entityType The type of the entity associated with the event.
|
|
44
|
-
* @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
|
|
45
|
-
*/
|
|
46
|
-
export interface LifecycleEvent<entityType> {
|
|
47
|
-
/**
|
|
48
|
-
* Indicates whether the entity is new or existing.
|
|
49
|
-
*/
|
|
50
|
-
isNew: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* A reference to the fields of the entity, providing access to its properties.
|
|
53
|
-
*/
|
|
54
|
-
fields: FieldsRef<entityType>;
|
|
55
|
-
/**
|
|
56
|
-
* The ID of the entity.
|
|
57
|
-
*/
|
|
58
|
-
id: idType<entityType>;
|
|
59
|
-
/**
|
|
60
|
-
* The original ID of the entity, useful for tracking changes.
|
|
61
|
-
*/
|
|
62
|
-
originalId: idType<entityType>;
|
|
63
|
-
/**
|
|
64
|
-
* The repository associated with the entity, providing access to repository methods.
|
|
65
|
-
*/
|
|
66
|
-
repository: Repository<entityType>;
|
|
67
|
-
/**
|
|
68
|
-
* Metadata describing the entity's structure and configuration.
|
|
69
|
-
*/
|
|
70
|
-
metadata: EntityMetadata<entityType>;
|
|
71
|
-
/**
|
|
72
|
-
* A function that can be used to prevent the default behavior associated with
|
|
73
|
-
* the lifecycle event.
|
|
74
|
-
*/
|
|
75
|
-
preventDefault: VoidFunction;
|
|
76
|
-
/**
|
|
77
|
-
* A reference to the repository relations associated with the entity, providing
|
|
78
|
-
* access to related entities and their data.
|
|
79
|
-
*/
|
|
80
|
-
relations: RepositoryRelations<entityType>;
|
|
81
|
-
}
|
|
82
|
-
export interface ControllerRefBase<entityType> extends Subscribable {
|
|
83
|
-
hasErrors(): boolean;
|
|
84
|
-
error: string;
|
|
85
|
-
validate(): Promise<ErrorInfo<entityType> | undefined>;
|
|
86
|
-
readonly isLoading: boolean;
|
|
87
|
-
}
|
|
88
|
-
export interface ControllerRef<entityType> extends ControllerRefBase<entityType> {
|
|
89
|
-
fields: FieldsRef<entityType>;
|
|
90
|
-
}
|
|
91
|
-
export interface ControllerRefForControllerBase<entityType> extends ControllerRefBase<entityType> {
|
|
92
|
-
fields: FieldsRefForEntityBase<entityType>;
|
|
93
|
-
}
|
|
94
|
-
export interface RefSubscriberBase {
|
|
95
|
-
reportChanged: () => void;
|
|
96
|
-
reportObserved: () => void;
|
|
97
|
-
}
|
|
98
|
-
export declare type RefSubscriber = (() => void) | RefSubscriberBase;
|
|
99
|
-
export interface Subscribable {
|
|
100
|
-
subscribe(listener: RefSubscriber): Unsubscribe;
|
|
101
|
-
}
|
|
102
|
-
export type FieldsRefBase<entityType> = {
|
|
103
|
-
find(fieldMetadataOrKey: FieldMetadata | string): FieldRef<entityType, any>;
|
|
104
|
-
[Symbol.iterator]: () => IterableIterator<FieldRef<entityType, any>>;
|
|
105
|
-
toArray(): FieldRef<entityType, any>[];
|
|
106
|
-
};
|
|
107
|
-
export type FieldsMetadata<entityType> = {
|
|
108
|
-
[Properties in keyof MembersOnly<entityType>]: FieldMetadata<entityType[Properties], entityType>;
|
|
109
|
-
} & {
|
|
110
|
-
find(fieldMetadataOrKey: FieldMetadata | string): FieldMetadata<any, entityType>;
|
|
111
|
-
[Symbol.iterator]: () => IterableIterator<FieldMetadata<any, entityType>>;
|
|
112
|
-
toArray(): FieldMetadata<any, entityType>[];
|
|
113
|
-
};
|
|
114
|
-
export type FieldsRef<entityType> = FieldsRefBase<entityType> & {
|
|
115
|
-
[Properties in keyof MembersOnly<entityType>]: NonNullable<entityType[Properties]> extends {
|
|
116
|
-
id?: number | string;
|
|
117
|
-
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
118
|
-
};
|
|
119
|
-
export type FieldsRefForEntityBase<entityType> = FieldsRefBase<entityType> & {
|
|
120
|
-
[Properties in keyof Omit<entityType, keyof EntityBase>]: NonNullable<entityType[Properties]> extends {
|
|
121
|
-
id?: number | string;
|
|
122
|
-
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
123
|
-
};
|
|
124
|
-
export type SortSegments<entityType> = {
|
|
125
|
-
[Properties in keyof entityType]: SortSegment & {
|
|
126
|
-
descending(): SortSegment;
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
export interface IdFieldRef<entityType, valueType> extends FieldRef<entityType, valueType> {
|
|
130
|
-
setId(id: valueType extends {
|
|
131
|
-
id?: number;
|
|
132
|
-
} ? number : valueType extends {
|
|
133
|
-
id?: string;
|
|
134
|
-
} ? string : string | number): any;
|
|
135
|
-
getId(): valueType extends {
|
|
136
|
-
id?: number;
|
|
137
|
-
} ? number : valueType extends {
|
|
138
|
-
id?: string;
|
|
139
|
-
} ? string : string | number;
|
|
140
|
-
}
|
|
141
|
-
export interface FieldRef<entityType = any, valueType = any> extends Subscribable {
|
|
142
|
-
error: string;
|
|
143
|
-
displayValue: string;
|
|
144
|
-
value: valueType;
|
|
145
|
-
originalValue: valueType;
|
|
146
|
-
inputValue: string;
|
|
147
|
-
valueChanged(): boolean;
|
|
148
|
-
entityRef: EntityRef<entityType>;
|
|
149
|
-
container: entityType;
|
|
150
|
-
metadata: FieldMetadata<valueType>;
|
|
151
|
-
load(): Promise<valueType>;
|
|
152
|
-
valueIsNull(): boolean;
|
|
153
|
-
originalValueIsNull(): boolean;
|
|
154
|
-
validate(): Promise<boolean>;
|
|
155
|
-
}
|
|
156
|
-
export interface IdMetadata<entityType = any> {
|
|
157
|
-
/** Extracts the id value of an entity item. Useful in cases where the id column is not called id
|
|
158
|
-
* @example
|
|
159
|
-
* repo.metadata.idMetadata.getId(task)
|
|
160
|
-
*/
|
|
161
|
-
getId(item: Partial<MembersOnly<entityType>>): any;
|
|
162
|
-
field: FieldMetadata<any>;
|
|
163
|
-
getIdFilter(...ids: any[]): EntityFilter<entityType>;
|
|
164
|
-
isIdField(col: FieldMetadata): boolean;
|
|
165
|
-
createIdInFilter(items: Partial<MembersOnly<entityType>>[]): EntityFilter<entityType>;
|
|
166
|
-
}
|
|
167
|
-
/** Metadata for an `Entity`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
168
|
-
export interface EntityMetadata<entityType = any> {
|
|
169
|
-
/** The Entity's key also used as it's url */
|
|
170
|
-
readonly key: string;
|
|
171
|
-
/** Metadata for the Entity's fields */
|
|
172
|
-
readonly fields: FieldsMetadata<entityType>;
|
|
173
|
-
/** A human readable caption for the entity. Can be used to achieve a consistent caption for a field throughout the app
|
|
174
|
-
* @example
|
|
175
|
-
* <h1>Create a new item in {taskRepo.metadata.caption}</h1>
|
|
176
|
-
*/
|
|
177
|
-
readonly caption: string;
|
|
178
|
-
/** The options send to the `Entity`'s decorator */
|
|
179
|
-
readonly options: EntityOptions;
|
|
180
|
-
/** The class type of the entity */
|
|
181
|
-
readonly entityType: ClassType<entityType>;
|
|
182
|
-
/** true if the current user is allowed to update an entity instance
|
|
183
|
-
* @example
|
|
184
|
-
* const taskRepo = remult.repo(Task);
|
|
185
|
-
* if (taskRepo.metadata.apiUpdateAllowed(task)){
|
|
186
|
-
* // Allow user to edit the entity
|
|
187
|
-
* }
|
|
188
|
-
*/
|
|
189
|
-
apiUpdateAllowed(item?: entityType): boolean;
|
|
190
|
-
/** true if the current user is allowed to read from entity
|
|
191
|
-
* @example
|
|
192
|
-
* const taskRepo = remult.repo(Task);
|
|
193
|
-
* if (taskRepo.metadata.apiReadAllowed){
|
|
194
|
-
* await taskRepo.find()
|
|
195
|
-
* }
|
|
196
|
-
*/
|
|
197
|
-
readonly apiReadAllowed: boolean;
|
|
198
|
-
/** true if the current user is allowed to delete an entity instance
|
|
199
|
-
* @example
|
|
200
|
-
* const taskRepo = remult.repo(Task);
|
|
201
|
-
* if (taskRepo.metadata.apiDeleteAllowed(task)){
|
|
202
|
-
* // display delete button
|
|
203
|
-
* }
|
|
204
|
-
*/
|
|
205
|
-
apiDeleteAllowed(item?: entityType): boolean;
|
|
206
|
-
/** true if the current user is allowed to create an entity instance
|
|
207
|
-
* @example
|
|
208
|
-
* const taskRepo = remult.repo(Task);
|
|
209
|
-
* if (taskRepo.metadata.apiInsertAllowed(task)){
|
|
210
|
-
* // display insert button
|
|
211
|
-
* }
|
|
212
|
-
*/
|
|
213
|
-
apiInsertAllowed(item?: entityType): boolean;
|
|
214
|
-
/** Returns the dbName - based on it's `dbName` option and it's `sqlExpression` option */
|
|
215
|
-
getDbName(): Promise<string>;
|
|
216
|
-
/** Metadata for the Entity's id */
|
|
217
|
-
readonly idMetadata: IdMetadata<entityType>;
|
|
218
|
-
}
|
|
219
|
-
export declare type MembersOnly<T> = {
|
|
220
|
-
[K in keyof Omit<T, keyof EntityBase> as T[K] extends Function ? never : K]: T[K];
|
|
221
|
-
};
|
|
222
|
-
export declare type idType<entityType> = entityType extends {
|
|
223
|
-
id?: number;
|
|
224
|
-
} ? number : entityType extends {
|
|
225
|
-
id?: string;
|
|
226
|
-
} ? string : string | number;
|
|
227
|
-
/**used to perform CRUD operations on an `entityType` */
|
|
228
|
-
export interface Repository<entityType> {
|
|
229
|
-
/** returns a result array based on the provided options */
|
|
230
|
-
find(options?: FindOptions<entityType>): Promise<entityType[]>;
|
|
231
|
-
/** returns a result array based on the provided options */
|
|
232
|
-
liveQuery(options?: FindOptions<entityType>): LiveQuery<entityType>;
|
|
233
|
-
/** returns the first item that matchers the `where` condition
|
|
234
|
-
* @example
|
|
235
|
-
* await taskRepo.findFirst({ completed:false })
|
|
236
|
-
* @example
|
|
237
|
-
* await taskRepo.findFirst({ completed:false },{ createIfNotFound: true })
|
|
238
|
-
* */
|
|
239
|
-
findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>): Promise<entityType>;
|
|
240
|
-
/** returns the items that matches the idm the result is cached unless specified differently in the `options` parameter */
|
|
241
|
-
findId(id: idType<entityType>, options?: FindFirstOptionsBase<entityType>): Promise<entityType>;
|
|
242
|
-
/** An alternative form of fetching data from the API server, which is intended for operating on large numbers of entity objects.
|
|
243
|
-
*
|
|
244
|
-
* It also has it's own paging mechanism that can be used n paging scenarios.
|
|
245
|
-
*
|
|
246
|
-
* The `query` method doesn't return an array (as the `find` method) and instead returns an `iterable` `QueryResult` object
|
|
247
|
-
* which supports iterations using the JavaScript `for await` statement.
|
|
248
|
-
* @example
|
|
249
|
-
* for await (const task of taskRepo.query()) {
|
|
250
|
-
* // do something.
|
|
251
|
-
* }
|
|
252
|
-
* */
|
|
253
|
-
query(options?: QueryOptions<entityType>): QueryResult<entityType>;
|
|
254
|
-
/** Returns a count of the items matching the criteria.
|
|
255
|
-
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
256
|
-
* @example
|
|
257
|
-
* await taskRepo.count({ completed:false })
|
|
258
|
-
*/
|
|
259
|
-
count(where?: EntityFilter<entityType>): Promise<number>;
|
|
260
|
-
/**Validates an item
|
|
261
|
-
* @example
|
|
262
|
-
* const error = repo.validate(task);
|
|
263
|
-
* if (error){
|
|
264
|
-
* alert(error.message);
|
|
265
|
-
* alert(error.modelState.title);//shows the specific error for the title field
|
|
266
|
-
* }
|
|
267
|
-
* // Can also be used to validate specific fields
|
|
268
|
-
* const error = repo.validate(task,"title")
|
|
269
|
-
*/
|
|
270
|
-
validate(item: Partial<entityType>, ...fields: Extract<keyof MembersOnly<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
|
|
271
|
-
/** 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
|
|
272
|
-
* @example
|
|
273
|
-
* await taskRepo.save({...task, completed:true })
|
|
274
|
-
*/
|
|
275
|
-
save(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
|
|
276
|
-
save(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
|
|
277
|
-
/**Insert an item or item[] to the data source
|
|
278
|
-
* @example
|
|
279
|
-
* await taskRepo.insert({title:"task a"})
|
|
280
|
-
* @example
|
|
281
|
-
* await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
|
|
282
|
-
*/
|
|
283
|
-
insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
|
|
284
|
-
insert(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
|
|
285
|
-
/** Updates an item, based on its `id`
|
|
286
|
-
* @example
|
|
287
|
-
* taskRepo.update(task.id,{...task,completed:true})
|
|
288
|
-
*/
|
|
289
|
-
update(id: entityType extends {
|
|
290
|
-
id?: number;
|
|
291
|
-
} ? number : entityType extends {
|
|
292
|
-
id?: string;
|
|
293
|
-
} ? string : string | number, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
|
|
294
|
-
update(id: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
|
|
295
|
-
/** Deletes an Item*/
|
|
296
|
-
delete(id: entityType extends {
|
|
297
|
-
id?: number;
|
|
298
|
-
} ? number : entityType extends {
|
|
299
|
-
id?: string;
|
|
300
|
-
} ? string : string | number): Promise<void>;
|
|
301
|
-
delete(item: Partial<MembersOnly<entityType>>): Promise<void>;
|
|
302
|
-
/** 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 */
|
|
303
|
-
create(item?: Partial<MembersOnly<entityType>>): entityType;
|
|
304
|
-
toJson(item: Promise<entityType[]>): Promise<any[]>;
|
|
305
|
-
toJson(item: entityType[]): any[];
|
|
306
|
-
toJson(item: Promise<entityType>): Promise<any>;
|
|
307
|
-
toJson(item: entityType): any;
|
|
308
|
-
/** Translates a json object to an item instance */
|
|
309
|
-
fromJson(x: any[], isNew?: boolean): entityType[];
|
|
310
|
-
fromJson(x: any, isNew?: boolean): entityType;
|
|
311
|
-
/** returns an `entityRef` for an item returned by `create`, `find` etc... */
|
|
312
|
-
getEntityRef(item: entityType): EntityRef<entityType>;
|
|
313
|
-
/** Provides information about the fields of the Repository's entity
|
|
314
|
-
* @example
|
|
315
|
-
* console.log(repo.fields.title.caption) // displays the caption of a specific field
|
|
316
|
-
* console.log(repo.fields.title.options)// writes the options that were defined for this field
|
|
317
|
-
*/
|
|
318
|
-
fields: FieldsMetadata<entityType>;
|
|
319
|
-
/**The metadata for the `entity`
|
|
320
|
-
* @See [EntityMetadata](https://remult.dev/docs/ref_entitymetadata.html)
|
|
321
|
-
*/
|
|
322
|
-
metadata: EntityMetadata<entityType>;
|
|
323
|
-
addEventListener(listener: entityEventListener<entityType>): Unsubscribe;
|
|
324
|
-
relations: (item: entityType) => RepositoryRelations<entityType>;
|
|
325
|
-
}
|
|
326
|
-
export interface LiveQuery<entityType> {
|
|
327
|
-
subscribe(next: (info: LiveQueryChangeInfo<entityType>) => void): Unsubscribe;
|
|
328
|
-
subscribe(listener: Partial<SubscriptionListener<LiveQueryChangeInfo<entityType>>>): Unsubscribe;
|
|
329
|
-
}
|
|
330
|
-
export interface LiveQueryChangeInfo<entityType> {
|
|
331
|
-
items: entityType[];
|
|
332
|
-
changes: LiveQueryChange[];
|
|
333
|
-
applyChanges(prevState: entityType[] | undefined): entityType[];
|
|
334
|
-
}
|
|
335
|
-
export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
336
|
-
/** Determines the number of rows returned by the request, on the browser the default is 100 rows
|
|
337
|
-
* @example
|
|
338
|
-
* await this.remult.repo(Products).find({
|
|
339
|
-
* limit:10,
|
|
340
|
-
* page:2
|
|
341
|
-
* })
|
|
342
|
-
*/
|
|
343
|
-
limit?: number;
|
|
344
|
-
/** Determines the page number that will be used to extract the data
|
|
345
|
-
* @example
|
|
346
|
-
* await this.remult.repo(Products).find({
|
|
347
|
-
* limit:10,
|
|
348
|
-
* page:2
|
|
349
|
-
* })
|
|
350
|
-
*/
|
|
351
|
-
page?: number;
|
|
352
|
-
}
|
|
353
|
-
/** Determines the order of items returned .
|
|
354
|
-
* @example
|
|
355
|
-
* await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
|
|
356
|
-
* @example
|
|
357
|
-
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
358
|
-
*/
|
|
359
|
-
export declare type EntityOrderBy<entityType> = {
|
|
360
|
-
[Properties in keyof Partial<MembersOnly<entityType>>]?: 'asc' | 'desc';
|
|
361
|
-
};
|
|
362
|
-
/**Used to filter the desired result set
|
|
363
|
-
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
364
|
-
*/
|
|
365
|
-
export declare type EntityFilter<entityType> = {
|
|
366
|
-
[Properties in keyof Partial<MembersOnly<entityType>>]?: (Partial<entityType>[Properties] extends number | Date | undefined ? ComparisonValueFilter<Partial<entityType>[Properties]> : Partial<entityType>[Properties] extends string | undefined ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<entityType>[Properties] extends boolean | undefined ? ValueFilter<boolean> : Partial<entityType>[Properties] extends {
|
|
367
|
-
id?: string | number;
|
|
368
|
-
} | undefined ? IdFilter<Partial<entityType>[Properties]> : ValueFilter<Partial<entityType>[Properties]>) | ContainsStringValueFilter;
|
|
369
|
-
} & {
|
|
370
|
-
$or?: EntityFilter<entityType>[];
|
|
371
|
-
$and?: EntityFilter<entityType>[];
|
|
372
|
-
};
|
|
373
|
-
export type ValueFilter<valueType> = valueType | valueType[] | {
|
|
374
|
-
$ne?: valueType | valueType[];
|
|
375
|
-
'!='?: valueType | valueType[];
|
|
376
|
-
$in?: valueType[];
|
|
377
|
-
$nin?: valueType[];
|
|
378
|
-
};
|
|
379
|
-
export type ComparisonValueFilter<valueType> = ValueFilter<valueType> & {
|
|
380
|
-
$gt?: valueType;
|
|
381
|
-
'>'?: valueType;
|
|
382
|
-
$gte?: valueType;
|
|
383
|
-
'>='?: valueType;
|
|
384
|
-
$lt?: valueType;
|
|
385
|
-
'<'?: valueType;
|
|
386
|
-
$lte?: valueType;
|
|
387
|
-
'<='?: valueType;
|
|
388
|
-
};
|
|
389
|
-
export interface ContainsStringValueFilter {
|
|
390
|
-
$contains?: string;
|
|
391
|
-
$notContains?: string;
|
|
392
|
-
}
|
|
393
|
-
export type IdFilter<valueType> = ValueFilter<valueType> | {
|
|
394
|
-
$id: ValueFilter<valueType extends {
|
|
395
|
-
id?: number;
|
|
396
|
-
} ? number : string>;
|
|
397
|
-
};
|
|
398
|
-
export interface LoadOptions<entityType> {
|
|
399
|
-
/**
|
|
400
|
-
* @deprecated The 'load' option is deprecated and will be removed in future versions.
|
|
401
|
-
* Use 'Relations.toOne' along with the 'include' option instead.
|
|
402
|
-
*
|
|
403
|
-
* Example usage:
|
|
404
|
-
* ```
|
|
405
|
-
* // Deprecated usage with 'load' option
|
|
406
|
-
* await remult.repo(Order).find({
|
|
407
|
-
* load: (o) => [o.customer],
|
|
408
|
-
* });
|
|
409
|
-
*
|
|
410
|
-
*
|
|
411
|
-
* // Preferred usage with 'Relations.toOne' and 'include' option
|
|
412
|
-
* await remult.repo(Order).find({
|
|
413
|
-
* include: { customer: true },
|
|
414
|
-
* });
|
|
415
|
-
* ```
|
|
416
|
-
*/
|
|
417
|
-
load?: (entity: FieldsMetadata<entityType>) => FieldMetadata[];
|
|
418
|
-
/**
|
|
419
|
-
* An option used in the `find` and `findFirst` methods to specify which related entities should be included
|
|
420
|
-
* when querying the source entity. It allows you to eagerly load related data to avoid N+1 query problems.
|
|
421
|
-
*
|
|
422
|
-
* @param include An object specifying the related entities to include, their options, and filtering criteria.
|
|
423
|
-
*
|
|
424
|
-
* Example usage:
|
|
425
|
-
* ```
|
|
426
|
-
* const orders = await customerRepo.find({
|
|
427
|
-
* include: {
|
|
428
|
-
* // Include the 'tags' relation for each customer.
|
|
429
|
-
* tags: true,
|
|
430
|
-
* },
|
|
431
|
-
* });
|
|
432
|
-
* ```
|
|
433
|
-
* In this example, the `tags` relation for each customer will be loaded and included in the query result.
|
|
434
|
-
*
|
|
435
|
-
* @see {@link Relations.toMany}
|
|
436
|
-
* @see {@link Relations.toOne}
|
|
437
|
-
* @see {@link RelationOptions}
|
|
438
|
-
*/
|
|
439
|
-
include?: MembersToInclude<entityType>;
|
|
440
|
-
}
|
|
441
|
-
export interface FindOptionsBase<entityType> extends LoadOptions<entityType> {
|
|
442
|
-
/** filters the data
|
|
443
|
-
* @example
|
|
444
|
-
* await taskRepo.find({where: { completed:false }})
|
|
445
|
-
* @see For more usage examples see [EntityFilter](https://remult.dev/docs/entityFilter.html)
|
|
446
|
-
*/
|
|
447
|
-
where?: EntityFilter<entityType>;
|
|
448
|
-
/** Determines the order of items returned .
|
|
449
|
-
* @example
|
|
450
|
-
* await this.remult.repo(Products).find({ orderBy: { name: "asc" }})
|
|
451
|
-
* @example
|
|
452
|
-
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
453
|
-
*/
|
|
454
|
-
orderBy?: EntityOrderBy<entityType>;
|
|
455
|
-
}
|
|
456
|
-
export interface FindFirstOptions<entityType> extends FindOptionsBase<entityType>, FindFirstOptionsBase<entityType> {
|
|
457
|
-
}
|
|
458
|
-
export interface FindFirstOptionsBase<entityType> extends LoadOptions<entityType> {
|
|
459
|
-
/** determines if to cache the result, and return the results from cache.
|
|
460
|
-
*/
|
|
461
|
-
useCache?: boolean;
|
|
462
|
-
/** If set to true and an item is not found, it's created and returned*/
|
|
463
|
-
createIfNotFound?: boolean;
|
|
464
|
-
}
|
|
465
|
-
export interface QueryOptions<entityType> extends FindOptionsBase<entityType> {
|
|
466
|
-
/** The number of items to return in each step */
|
|
467
|
-
pageSize?: number;
|
|
468
|
-
/** A callback method to indicate the progress of the iteration */
|
|
469
|
-
progress?: {
|
|
470
|
-
progress: (progress: number) => void;
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
/** The result of a call to the `query` method in the `Repository` object.
|
|
474
|
-
*/
|
|
475
|
-
export interface QueryResult<entityType> {
|
|
476
|
-
/** returns an iterator that iterates the rows in the result using a paging mechanism
|
|
477
|
-
* @example
|
|
478
|
-
* for await (const task of taskRepo.query()) {
|
|
479
|
-
* await taskRepo.save({ ...task, completed });
|
|
480
|
-
* }
|
|
481
|
-
*/
|
|
482
|
-
[Symbol.asyncIterator](): {
|
|
483
|
-
next: () => Promise<IteratorResult<entityType, entityType>>;
|
|
484
|
-
};
|
|
485
|
-
/** returns the number of rows that match the query criteria */
|
|
486
|
-
count(): Promise<number>;
|
|
487
|
-
/** Returns a `Paginator` object that is used for efficient paging */
|
|
488
|
-
paginator(): Promise<Paginator<entityType>>;
|
|
489
|
-
/** gets the items in a specific page */
|
|
490
|
-
getPage(pageNumber?: number): Promise<entityType[]>;
|
|
491
|
-
/** Performs an operation on all the items matching the query criteria */
|
|
492
|
-
forEach(what: (item: entityType) => Promise<any>): Promise<number>;
|
|
493
|
-
}
|
|
494
|
-
/** An interface used to paginating using the `query` method in the `Repository` object */
|
|
495
|
-
export interface Paginator<entityType> {
|
|
496
|
-
/** the items in the current page */
|
|
497
|
-
items: entityType[];
|
|
498
|
-
/** True if next page exists */
|
|
499
|
-
hasNextPage: boolean;
|
|
500
|
-
/** Gets the next page in the `query`'s result set */
|
|
501
|
-
nextPage(): Promise<Paginator<entityType>>;
|
|
502
|
-
/** the count of the total items in the `query`'s result */
|
|
503
|
-
count(): Promise<number>;
|
|
504
|
-
}
|
|
505
|
-
export interface RelationInfo {
|
|
506
|
-
toType: () => any;
|
|
507
|
-
type: 'reference' | 'toOne' | 'toMany';
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Options for configuring a relation between entities.
|
|
511
|
-
*
|
|
512
|
-
* @template fromEntity The type of the source entity (the entity defining the relation).
|
|
513
|
-
* @template toEntity The type of the target entity (the related entity).
|
|
514
|
-
* @template matchIdEntity The type used for matching IDs in the relation.
|
|
515
|
-
* @template optionsType The type of find options to apply to the relation (default is FindOptionsBase<toEntity>).
|
|
516
|
-
*/
|
|
517
|
-
export type RelationOptions<fromEntity, toEntity, matchIdEntity, optionsType extends FindOptionsBase<toEntity> = FindOptionsBase<toEntity>> = {
|
|
518
|
-
/**
|
|
519
|
-
* An object specifying custom field names for the relation.
|
|
520
|
-
* Each key represents a field in the related entity, and its value is the corresponding field in the source entity.
|
|
521
|
-
* For example, `{ customerId: 'id' }` maps the 'customerId' field in the related entity to the 'id' field in the source entity.
|
|
522
|
-
* This is useful when you want to define custom field mappings for the relation.
|
|
523
|
-
*/
|
|
524
|
-
fields?: {
|
|
525
|
-
[K in keyof toEntity]?: keyof fromEntity;
|
|
526
|
-
};
|
|
527
|
-
/**
|
|
528
|
-
* The name of the field for this relation.
|
|
529
|
-
*/
|
|
530
|
-
field?: keyof matchIdEntity;
|
|
531
|
-
/**
|
|
532
|
-
* Find options to apply to the relation when fetching related entities.
|
|
533
|
-
* You can specify a predefined set of find options or provide a function that takes the source entity
|
|
534
|
-
* and returns find options dynamically.
|
|
535
|
-
* These options allow you to customize how related entities are retrieved.
|
|
536
|
-
*/
|
|
537
|
-
findOptions?: optionsType | ((entity: fromEntity) => optionsType);
|
|
538
|
-
/**
|
|
539
|
-
* Determines whether the relation should be included by default when querying the source entity.
|
|
540
|
-
* When set to true, related entities will be automatically included when querying the source entity.
|
|
541
|
-
* If false or not specified, related entities will need to be explicitly included using the `include` option.
|
|
542
|
-
*/
|
|
543
|
-
defaultIncluded?: boolean;
|
|
544
|
-
} & Pick<FieldOptions, 'caption'>;
|
|
545
|
-
export type ObjectMembersOnly<T> = MembersOnly<{
|
|
546
|
-
[K in keyof Pick<T, {
|
|
547
|
-
[K in keyof T]: T[K] extends object | undefined | null ? T[K] extends Date | undefined | null ? never : K : never;
|
|
548
|
-
}[keyof T]>]: T[K];
|
|
549
|
-
}>;
|
|
550
|
-
export type MembersToInclude<T> = {
|
|
551
|
-
[K in keyof ObjectMembersOnly<T>]?: boolean | (NonNullable<T[K]> extends Array<any> ? FindOptions<NonNullable<T[K]>[number]> : FindFirstOptions<NonNullable<T[K]>>);
|
|
552
|
-
};
|
|
553
|
-
export type RepositoryRelations<entityType> = {
|
|
554
|
-
[K in keyof ObjectMembersOnly<entityType>]-?: NonNullable<entityType[K]> extends Array<infer R> ? Repository<R> : entityType[K] extends infer R ? {
|
|
555
|
-
findOne: (options?: FindOptionsBase<R>) => Promise<R>;
|
|
556
|
-
} : never;
|
|
557
|
-
};
|
|
558
|
-
export type RepositoryRelationsForEntityBase<entityType> = {
|
|
559
|
-
[K in keyof Omit<entityType, keyof EntityBase>]-?: NonNullable<entityType[K]> extends Array<infer R> ? Repository<R> : entityType[K] extends infer R ? {
|
|
560
|
-
findOne: (options?: FindOptionsBase<R>) => Promise<R>;
|
|
561
|
-
} : never;
|
|
562
|
-
};
|
|
563
|
-
export declare type EntityIdFields<entityType> = {
|
|
564
|
-
[Properties in keyof Partial<MembersOnly<entityType>>]?: true;
|
|
565
|
-
};
|
|
566
|
-
export interface ClassFieldDecoratorContextStub<entityType, valueType> {
|
|
567
|
-
readonly access: {
|
|
568
|
-
set(object: entityType, value: valueType): void;
|
|
569
|
-
};
|
|
570
|
-
readonly name: string;
|
|
571
|
-
}
|
|
572
|
-
export interface ClassDecoratorContextStub<Class extends new (...args: any) => any = new (...args: any) => any> {
|
|
573
|
-
readonly kind: 'class';
|
|
574
|
-
readonly name: string | undefined;
|
|
575
|
-
addInitializer(initializer: (this: Class) => void): void;
|
|
576
|
-
}
|
|
577
|
-
export type ClassFieldDecorator<entityType, valueType> = (target: any, context: string | ClassFieldDecoratorContextStub<entityType, valueType | undefined>, c?: any) => void;
|
|
578
|
-
/**
|
|
579
|
-
* //p2 - doc this
|
|
580
|
-
remult.apiClient.httpClient = (
|
|
581
|
-
input: RequestInfo | URL,
|
|
582
|
-
init?: RequestInit
|
|
583
|
-
) => {
|
|
584
|
-
return fetch(input, {
|
|
585
|
-
...init,
|
|
586
|
-
headers: {
|
|
587
|
-
authorization: 'Bearer ' + sessionStorage.sessionId,
|
|
588
|
-
},
|
|
589
|
-
cache: 'no-store',
|
|
590
|
-
})
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
&&
|
|
594
|
-
remult.apiClient.url='localhost:3007/api
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
*/
|
|
598
|
-
/**
|
|
599
|
-
* our default is allow null false.
|
|
600
|
-
* for sql databases we add a db default of 0/''/false
|
|
601
|
-
* when we set a relation to null - we update the related field to null
|
|
602
|
-
* we do not enforce allow null false (mongo, json it'll get stored)
|
|
603
|
-
|
|
604
|
-
*/
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { EntityDataProviderFindOptions } from '../data-interfaces';
|
|
2
|
-
import type { Filter } from '../filter/filter-interfaces';
|
|
3
|
-
import type { EntityFilter, EntityOrderBy, FindOptions, LoadOptions, Repository } from './remult3';
|
|
4
|
-
export interface RepositoryInternal<entityType> {
|
|
5
|
-
createAfterFilter(orderBy: EntityOrderBy<entityType>, lastRow: entityType): Promise<EntityFilter<entityType>>;
|
|
6
|
-
fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<entityType[]>;
|
|
7
|
-
buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
|
|
8
|
-
translateWhereToFilter(where: EntityFilter<entityType>): Promise<Filter>;
|
|
9
|
-
getCachedById(id: any, doNotLoadIfNotFound: boolean): entityType;
|
|
10
|
-
getCachedByIdAsync(id: any, doNotLoadIfNotFound: boolean): Promise<entityType>;
|
|
11
|
-
addToCache(item: entityType): any;
|
|
12
|
-
}
|
|
13
|
-
export declare function getRepositoryInternals<entityType>(repo: Repository<entityType>): RepositoryInternal<entityType>;
|
|
14
|
-
export declare const getInternalKey = "getInternal";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const actionInfo: {
|
|
2
|
-
allActions: any[];
|
|
3
|
-
runningOnServer: boolean;
|
|
4
|
-
runActionWithoutBlockingUI: <T>(what: () => Promise<T>) => Promise<T>;
|
|
5
|
-
startBusyWithProgress: () => {
|
|
6
|
-
progress: (percent: number) => void;
|
|
7
|
-
close: () => void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export declare const serverActionField: unique symbol;
|