remult 3.2.1 → 3.2.2-next.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.
@@ -23,16 +23,16 @@ export interface RemultServerOptions<RequestType> {
23
23
  * @see [Connecting to a Database](https://remult.dev/docs/databases.html).
24
24
  */
25
25
  dataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>);
26
- /** Will create tables and columns in supporting databases. default: true
26
+ /** Will create tables and columns in supporting databases.
27
+ *
28
+ * @default true
27
29
  *
28
- * @description
29
30
  * when set to true, it'll create entities that do not exist, and add columns that are missing.
30
31
  */
31
32
  ensureSchema?: boolean;
32
- /** The path to use for the api, default:/api
33
+ /** The path to use for the api, if you want to use a different path adjust this field
33
34
  *
34
- * @description
35
- * If you want to use a different api path adjust this field
35
+ * @default `/api`
36
36
  */
37
37
  rootPath?: string;
38
38
  /** The default limit to use for find requests that did not specify a limit */
@@ -4,12 +4,16 @@ import type { EntityMetadata, FieldRef, LifecycleEvent, ValidateFieldEvent } fro
4
4
  export interface FieldOptions<entityType = unknown, valueType = unknown> {
5
5
  /** A human readable name for the field. Can be used to achieve a consistent caption for a field throughout the app
6
6
  * @example
7
- * <input placeholder={taskRepo.metadata.fields.title.caption}/>
7
+ * ```html
8
+ * <input placeholder={taskRepo.metadata.fields.title.caption} />
9
+ * ```
8
10
  */
9
11
  caption?: string;
10
12
  /** A human readable name for the field. Can be used to achieve a consistent label for a field throughout the app
11
13
  * @example
12
- * <input placeholder={taskRepo.metadata.fields.title.label}/>
14
+ * ```html
15
+ * <input placeholder={taskRepo.metadata.fields.title.label} />
16
+ * ```
13
17
  */
14
18
  label?: string;
15
19
  /** If it can store `null` in the database. @default false */
package/src/entity.d.ts CHANGED
@@ -13,8 +13,6 @@ export interface EntityOptions<entityType = unknown> {
13
13
  label?: string;
14
14
  /**
15
15
  * Determines if this Entity is available for get requests using Rest Api
16
- * @description
17
- * Determines if one has any access to the data of an entity.
18
16
  * @see [allowed](http://remult.dev/docs/allowed.html)
19
17
  * @see to restrict data based on a criteria, use [apiPrefilter](https://remult.dev/docs/ref_entity.html#apiprefilter)
20
18
  * */
@@ -115,7 +113,7 @@ export interface EntityOptions<entityType = unknown> {
115
113
  * },
116
114
  * })
117
115
  * @param entity - The instance of the entity being saved.
118
- * @param event - an @link LifeCycleEvent object
116
+ * @param event - [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks#lifecycle-event-args)
119
117
  * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
120
118
  */
121
119
  saving?: (entity: entityType, event: LifecycleEvent<entityType>) => Promise<any> | any;
@@ -123,7 +121,7 @@ export interface EntityOptions<entityType = unknown> {
123
121
  * A hook that runs after an entity has been successfully saved.
124
122
  *
125
123
  * @param entity The instance of the entity that was saved.
126
- * @param event - an @link LifeCycleEvent object
124
+ * @param event - [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks#lifecycle-event-args)
127
125
  * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
128
126
  */
129
127
  saved?: (entity: entityType, e: LifecycleEvent<entityType>) => Promise<any> | any;
@@ -131,7 +129,7 @@ export interface EntityOptions<entityType = unknown> {
131
129
  * A hook that runs before an entity is deleted.
132
130
  *
133
131
  * @param entity The instance of the entity being deleted.
134
- * @param event - an @link LifeCycleEvent object
132
+ * @param event - [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks#lifecycle-event-args)
135
133
  * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
136
134
  */
137
135
  deleting?: (entity: entityType, e: LifecycleEvent<entityType>) => Promise<any> | any;
@@ -139,7 +137,7 @@ export interface EntityOptions<entityType = unknown> {
139
137
  * A hook that runs after an entity has been successfully deleted.
140
138
  *
141
139
  * @param entity The instance of the entity that was deleted.
142
- * @param event - an @link LifeCycleEvent object
140
+ * @param event - [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks#lifecycle-event-args)
143
141
  * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
144
142
  */
145
143
  deleted?: (entity: entityType, e: LifecycleEvent<entityType>) => Promise<any> | any;
@@ -148,7 +146,7 @@ export interface EntityOptions<entityType = unknown> {
148
146
  * This hook is also executed on the frontend.
149
147
  *
150
148
  * @param entity The instance of the entity being validated.
151
- * @param event - an @link LifeCycleEvent object
149
+ * @param event - [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks#lifecycle-event-args)
152
150
  * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
153
151
  */
154
152
  validation?: (entity: entityType, ref: LifecycleEvent<entityType>) => Promise<any> | any;
@@ -213,8 +211,7 @@ export interface PreprocessFilterEvent<entityType> {
213
211
  * Retrieves precise values for each property in a filter for an entity.
214
212
  * @param filter Optional filter to analyze. If not provided, the current filter being preprocessed is used.
215
213
  * @returns A promise that resolves to a FilterPreciseValues object containing the precise values for each property.
216
-
217
- * @see {@Link FilterPreciseValues }
214
+ * @see {@link FilterPreciseValues}
218
215
  */
219
216
  getFilterPreciseValues(filter?: EntityFilter<entityType>): Promise<FilterPreciseValues<entityType>>;
220
217
  }
@@ -119,18 +119,18 @@ export declare class Relations {
119
119
  * @returns A decorator function to apply the to-one relation to an entity field.
120
120
  *
121
121
  * Example usage:
122
- * ```
122
+ * ```ts
123
123
  * @Relations.toOne(() => Customer)
124
124
  * customer?: Customer;
125
125
  * ```
126
- * ```
126
+ * ```ts
127
127
  * Fields.string()
128
128
  * customerId?: string;
129
129
  *
130
130
  * @Relations.toOne(() => Customer, "customerId")
131
131
  * customer?: Customer;
132
132
  * ```
133
- * ```
133
+ * ```ts
134
134
  * Fields.string()
135
135
  * customerId?: string;
136
136
  *
@@ -140,7 +140,7 @@ export declare class Relations {
140
140
  * })
141
141
  * customer?: Customer;
142
142
  * ```
143
- * ```
143
+ * ```ts
144
144
  * Fields.string()
145
145
  * customerId?: string;
146
146
  *
@@ -163,7 +163,7 @@ export declare class Relations {
163
163
  * @returns A decorator function to apply the toMany relation to an entity field.
164
164
  *
165
165
  * Example usage:
166
- * ```
166
+ * ```ts
167
167
  * @Relations.toMany(() => Order)
168
168
  * orders?: Order[];
169
169
  *
@@ -187,7 +187,7 @@ export declare class Relations {
187
187
  * @returns A decorator function to apply the toMany relation to an entity field.
188
188
  *
189
189
  * Example usage:
190
- * ```
190
+ * ```ts
191
191
  * @Relations.toMany(() => Order, {
192
192
  * field: "customerOrders",
193
193
  * findOptions: {
@@ -320,18 +320,18 @@ var Relations = /** @class */ (function () {
320
320
  * @returns A decorator function to apply the to-one relation to an entity field.
321
321
  *
322
322
  * Example usage:
323
- * ```
323
+ * ```ts
324
324
  * @Relations.toOne(() => Customer)
325
325
  * customer?: Customer;
326
326
  * ```
327
- * ```
327
+ * ```ts
328
328
  * Fields.string()
329
329
  * customerId?: string;
330
330
  *
331
331
  * @Relations.toOne(() => Customer, "customerId")
332
332
  * customer?: Customer;
333
333
  * ```
334
- * ```
334
+ * ```ts
335
335
  * Fields.string()
336
336
  * customerId?: string;
337
337
  *
@@ -341,7 +341,7 @@ var Relations = /** @class */ (function () {
341
341
  * })
342
342
  * customer?: Customer;
343
343
  * ```
344
- * ```
344
+ * ```ts
345
345
  * Fields.string()
346
346
  * customerId?: string;
347
347
  *
@@ -4,6 +4,7 @@ import type { ClassDecoratorContextStub } from './remult3.js';
4
4
  /**Decorates classes that should be used as entities.
5
5
  * Receives a key and an array of EntityOptions.
6
6
  * @example
7
+ * ```ts
7
8
  * import { Entity, Fields } from "remult";
8
9
  * @Entity("tasks", {
9
10
  * allowApiCrud: true
@@ -16,13 +17,17 @@ import type { ClassDecoratorContextStub } from './remult3.js';
16
17
  * @Fields.boolean()
17
18
  * completed = false;
18
19
  * }
19
- * @note
20
+ * ```
20
21
  * EntityOptions can be set in two ways:
21
22
  * @example
23
+ * ```ts
22
24
  * // as an object
23
25
  * @Entity("tasks",{ allowApiCrud:true })
26
+ * ```
24
27
  * @example
28
+ * ```ts
25
29
  * // as an arrow function that receives `remult` as a parameter
26
30
  * @Entity("tasks", (options,remult) => options.allowApiCrud = true)
31
+ * ```
27
32
  */
28
33
  export declare function Entity<entityType>(key: string, ...options: (EntityOptions<entityType extends new (...args: any) => any ? InstanceType<entityType> : entityType> | ((options: EntityOptions<entityType extends new (...args: any) => any ? InstanceType<entityType> : entityType>, remult: Remult) => void))[]): (target: any, info?: ClassDecoratorContextStub<entityType extends new (...args: any) => any ? entityType : never>) => any;
@@ -8,6 +8,7 @@ var remult_static_js_1 = require("../remult-static.js");
8
8
  /**Decorates classes that should be used as entities.
9
9
  * Receives a key and an array of EntityOptions.
10
10
  * @example
11
+ * ```ts
11
12
  * import { Entity, Fields } from "remult";
12
13
  * @Entity("tasks", {
13
14
  * allowApiCrud: true
@@ -20,14 +21,18 @@ var remult_static_js_1 = require("../remult-static.js");
20
21
  * @Fields.boolean()
21
22
  * completed = false;
22
23
  * }
23
- * @note
24
+ * ```
24
25
  * EntityOptions can be set in two ways:
25
26
  * @example
27
+ * ```ts
26
28
  * // as an object
27
29
  * @Entity("tasks",{ allowApiCrud:true })
30
+ * ```
28
31
  * @example
32
+ * ```ts
29
33
  * // as an arrow function that receives `remult` as a parameter
30
34
  * @Entity("tasks", (options,remult) => options.allowApiCrud = true)
35
+ * ```
31
36
  */
32
37
  function Entity(key) {
33
38
  var options = [];
@@ -216,11 +216,13 @@ export interface EntityMetadata<entityType = unknown> {
216
216
  /** The class type of the entity */
217
217
  readonly entityType: ClassType<entityType>;
218
218
  /** true if the current user is allowed to update an entity instance
219
- * @see {@link EntityOptions.allowApiUpdate
219
+ * @see {@link EntityOptions.allowApiUpdate}
220
220
  * @example
221
+ * ```ts
221
222
  * if (repo(Task).metadata.apiUpdateAllowed(task)){
222
223
  * // Allow user to edit the entity
223
224
  * }
225
+ * ```
224
226
  */
225
227
  apiUpdateAllowed(item?: entityType): boolean;
226
228
  /** true if the current user is allowed to read from entity
@@ -232,7 +234,7 @@ export interface EntityMetadata<entityType = unknown> {
232
234
  */
233
235
  readonly apiReadAllowed: boolean;
234
236
  /** true if the current user is allowed to delete an entity instance
235
- * * @see {@link EntityOptions.allowApiDelete}
237
+ * @see {@link EntityOptions.allowApiDelete}
236
238
  * @example
237
239
  * if (repo(Task).metadata.apiDeleteAllowed(task)){
238
240
  * // display delete button
@@ -652,7 +654,7 @@ export interface Repository<entityType> {
652
654
  */
653
655
  fields: FieldsMetadata<entityType>;
654
656
  /**The metadata for the `entity`
655
- * @See [EntityMetadata](https://remult.dev/docs/ref_entitymetadata.html)
657
+ * @see [EntityMetadata](https://remult.dev/docs/ref_entitymetadata.html)
656
658
  */
657
659
  metadata: EntityMetadata<entityType>;
658
660
  addEventListener(listener: entityEventListener<entityType>): Unsubscribe;
@@ -1029,7 +1031,7 @@ export interface LoadOptions<entityType> {
1029
1031
  * @param include An object specifying the related entities to include, their options, and filtering criteria.
1030
1032
  *
1031
1033
  * Example usage:
1032
- * ```
1034
+ * ```ts
1033
1035
  * const orders = await customerRepo.find({
1034
1036
  * include: {
1035
1037
  * // Include the 'tags' relation for each customer.
@@ -6,7 +6,7 @@ interface RemultEntitySchema<entityType, fields extends string[] = []> extends S
6
6
  /**
7
7
  * Implementation of the [Standard Schema](https://standardschema.dev/) specification
8
8
  *
9
- * @usage
9
+ * @example
10
10
  * ```ts
11
11
  * // The schema for the entire entity
12
12
  * const schema = standardSchema(repo(User))
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
5
5
  /**
6
6
  * Implementation of the [Standard Schema](https://standardschema.dev/) specification
7
7
  *
8
- * @usage
8
+ * @example
9
9
  * ```ts
10
10
  * // The schema for the entire entity
11
11
  * const schema = standardSchema(repo(User))