remult 0.22.9 → 0.22.10
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/README.md +1 -0
- package/esm/src/context.js +3 -0
- package/esm/src/remult-proxy.js +3 -2
- package/esm/src/remult3/Fields.d.ts +116 -3
- package/package.json +1 -1
- package/src/context.js +3 -0
- package/src/remult-proxy.js +9 -4
- package/src/remult3/Fields.d.ts +116 -3
package/README.md
CHANGED
|
@@ -278,6 +278,7 @@ with a Node.js Express backend.
|
|
|
278
278
|
- [Tutorial with Angular](https://remult.dev/tutorials/angular/)
|
|
279
279
|
- [Tutorial with Vue](https://remult.dev/tutorials/vue/)
|
|
280
280
|
- [Tutorial with Next.js](https://remult.dev/tutorials/react-next/)
|
|
281
|
+
- [Tutorial with Sveltekit](https://remult.dev/tutorials/sveltekit/)
|
|
281
282
|
|
|
282
283
|
## Documentation
|
|
283
284
|
|
package/esm/src/context.js
CHANGED
|
@@ -285,3 +285,6 @@ class transactionLiveQueryPublisher {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
+
//p1 - seems that after backend methods relations are loaded for some reason - see trempim - intake doRequest backend method
|
|
289
|
+
//p1 - reconsider the case in tremping where create user id was updated with some user and not the actual user
|
|
290
|
+
//[ ] - when value changes for field with error, clear error - so the user will feel comfortable
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -81,10 +81,11 @@ export class RemultProxy {
|
|
|
81
81
|
get fields() {
|
|
82
82
|
return self.remultFactory().repo(...args).metadata.fields;
|
|
83
83
|
},
|
|
84
|
-
validate: (a, b) => self
|
|
84
|
+
validate: (a, ...b) => self
|
|
85
85
|
.remultFactory()
|
|
86
86
|
.repo(...args)
|
|
87
|
-
|
|
87
|
+
//@ts-ignore
|
|
88
|
+
.validate(a, ...b),
|
|
88
89
|
addEventListener: (...args2) => self
|
|
89
90
|
.remultFactory()
|
|
90
91
|
.repo(...args)
|
|
@@ -21,15 +21,128 @@ export declare class Fields {
|
|
|
21
21
|
static boolean<entityType = any>(...options: (FieldOptions<entityType, boolean> | ((options: FieldOptions<entityType, boolean>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, boolean | undefined>;
|
|
22
22
|
}
|
|
23
23
|
export declare class Relations {
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
26
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
27
|
+
* to represent the relation.
|
|
28
|
+
*
|
|
29
|
+
* @param toEntityType A function that returns the target entity type.
|
|
30
|
+
* @param options (Optional): An object containing options for configuring the to-one relation.
|
|
31
|
+
* @returns A decorator function to apply the to-one relation to an entity field.
|
|
32
|
+
*
|
|
33
|
+
* Example usage:
|
|
34
|
+
* ```
|
|
35
|
+
* @Relations.toOne(() => Customer)
|
|
36
|
+
* customer?: Customer;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
25
39
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options?: FieldOptions<entityType, toEntityType> & Pick<RelationOptions<entityType, toEntityType, any, any>, 'defaultIncluded'>): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
26
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
42
|
+
* If no `fieldInMyEntity` is provided, this overload will automatically create a field in the database
|
|
43
|
+
* to represent the relation.
|
|
44
|
+
*
|
|
45
|
+
* @param toEntityType A function that returns the target entity type.
|
|
46
|
+
* @param fieldInMyEntity (Optional): The field in the current entity that represents the relation.
|
|
47
|
+
* Use this if you want to specify a custom field name for the relation.
|
|
48
|
+
* @returns A decorator function to apply the to-one relation to an entity field.
|
|
49
|
+
*
|
|
50
|
+
* Example usage:
|
|
51
|
+
* ```
|
|
52
|
+
* @Relations.toOne(() => Customer)
|
|
53
|
+
* customer?: Customer;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
27
56
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
28
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
59
|
+
* This overload allows you to define the relation using options.
|
|
60
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
61
|
+
* to represent the relation.
|
|
62
|
+
*
|
|
63
|
+
* @param toEntityType A function that returns the target entity type.
|
|
64
|
+
* @param options An object containing options for configuring the to-one relation.
|
|
65
|
+
* - field (Optional): The name of the field in the related entity that corresponds to this relation.
|
|
66
|
+
* @returns A decorator function to apply the virtual to-one relation to an entity field.
|
|
67
|
+
*
|
|
68
|
+
* Example usage:
|
|
69
|
+
* ```
|
|
70
|
+
* @Relations.toOne(() => Customer, {
|
|
71
|
+
* field: "customerId",
|
|
72
|
+
* })
|
|
73
|
+
* customer?: Customer;
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
79
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
80
|
+
* to represent the relation.
|
|
81
|
+
*
|
|
82
|
+
* @param toEntityType A function that returns the target entity type.
|
|
83
|
+
* @param options An object containing options for configuring the to-one relation.
|
|
84
|
+
* - fields (Optional): An object specifying custom field names for the relation.
|
|
85
|
+
* @returns A decorator function to apply the virtual to-one relation to an entity field.
|
|
86
|
+
*
|
|
87
|
+
* Example usage:
|
|
88
|
+
* ```
|
|
89
|
+
* @Relations.toOne(() => Customer, {
|
|
90
|
+
* fields: {
|
|
91
|
+
* customerId: "id",
|
|
92
|
+
* },
|
|
93
|
+
* })
|
|
94
|
+
* customer?: Customer;
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
29
97
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'field'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
30
98
|
/** A to one relation with fields defined in the field/fields parameter */
|
|
31
99
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'fields'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
100
|
+
/**
|
|
101
|
+
* Define a toMany relation between entities, indicating a one-to-many relationship.
|
|
102
|
+
* This method allows you to establish a relationship where one entity can have multiple related entities.
|
|
103
|
+
*
|
|
104
|
+
* @param toEntityType A function that returns the target entity type.
|
|
105
|
+
* @param fieldInToEntity (Optional) The field in the target entity that represents the relation.
|
|
106
|
+
* Use this if you want to specify a custom field name for the relation.
|
|
107
|
+
* @returns A decorator function to apply the toMany relation to an entity field.
|
|
108
|
+
*
|
|
109
|
+
* Example usage:
|
|
110
|
+
* ```
|
|
111
|
+
* @Relations.toMany(() => Order)
|
|
112
|
+
* orders?: Order[];
|
|
113
|
+
*
|
|
114
|
+
* // or with a custom field name:
|
|
115
|
+
* @Relations.toMany(() => Order, "customerId")
|
|
116
|
+
* orders?: Order[];
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
32
119
|
static toMany<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInToEntity?: keyof toEntityType): ClassFieldDecorator<entityType, toEntityType[] | undefined>;
|
|
120
|
+
/**
|
|
121
|
+
* Define a toMany relation between entities, indicating a one-to-many relationship.
|
|
122
|
+
* This method allows you to establish a relationship where one entity can have multiple related entities.
|
|
123
|
+
* You can also specify various options to customize the relation and control related data retrieval.
|
|
124
|
+
*
|
|
125
|
+
* @param toEntityType A function that returns the target entity type.
|
|
126
|
+
* @param options An object containing options for configuring the toMany relation.
|
|
127
|
+
* - field (Optional): The field in the target entity that represents the relation.
|
|
128
|
+
* Use this if you want to specify a custom field name for the relation.
|
|
129
|
+
* - findOptions (Optional): Customize the options for finding related entities.
|
|
130
|
+
* You can set limits, order, where conditions, and more.
|
|
131
|
+
* @returns A decorator function to apply the toMany relation to an entity field.
|
|
132
|
+
*
|
|
133
|
+
* Example usage:
|
|
134
|
+
* ```
|
|
135
|
+
* @Relations.toMany(() => Order, {
|
|
136
|
+
* field: "customerOrders",
|
|
137
|
+
* findOptions: {
|
|
138
|
+
* limit: 10,
|
|
139
|
+
* orderBy: { amount: "desc" },
|
|
140
|
+
* where: { completed: true },
|
|
141
|
+
* },
|
|
142
|
+
* })
|
|
143
|
+
* orders?: Order[];
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
33
146
|
static toMany<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: RelationOptions<entityType, toEntityType, toEntityType, FindOptions<toEntityType>>): ClassFieldDecorator<entityType, toEntityType[] | undefined>;
|
|
34
147
|
}
|
|
35
148
|
/**Decorates fields that should be used as fields.
|
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -449,3 +449,6 @@ var transactionLiveQueryPublisher = /** @class */ (function () {
|
|
|
449
449
|
};
|
|
450
450
|
return transactionLiveQueryPublisher;
|
|
451
451
|
}());
|
|
452
|
+
//p1 - seems that after backend methods relations are loaded for some reason - see trempim - intake doRequest backend method
|
|
453
|
+
//p1 - reconsider the case in tremping where create user id was updated with some user and not the actual user
|
|
454
|
+
//[ ] - when value changes for field with error, clear error - so the user will feel comfortable
|
package/src/remult-proxy.js
CHANGED
|
@@ -35,11 +35,16 @@ var RemultProxy = /** @class */ (function () {
|
|
|
35
35
|
var _a;
|
|
36
36
|
return (_a = self.remultFactory()).repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).metadata.fields;
|
|
37
37
|
},
|
|
38
|
-
validate: function (a
|
|
39
|
-
var _a;
|
|
40
|
-
|
|
38
|
+
validate: function (a) {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
var b = [];
|
|
41
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
42
|
+
b[_i - 1] = arguments[_i];
|
|
43
|
+
}
|
|
44
|
+
return (_a = (_b = self
|
|
41
45
|
.remultFactory())
|
|
42
|
-
.repo.apply(
|
|
46
|
+
.repo.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(args), false)))
|
|
47
|
+
.validate.apply(_a, tslib_1.__spreadArray([a], tslib_1.__read(b), false));
|
|
43
48
|
},
|
|
44
49
|
addEventListener: function () {
|
|
45
50
|
var _a, _b;
|
package/src/remult3/Fields.d.ts
CHANGED
|
@@ -21,15 +21,128 @@ export declare class Fields {
|
|
|
21
21
|
static boolean<entityType = any>(...options: (FieldOptions<entityType, boolean> | ((options: FieldOptions<entityType, boolean>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, boolean | undefined>;
|
|
22
22
|
}
|
|
23
23
|
export declare class Relations {
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
26
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
27
|
+
* to represent the relation.
|
|
28
|
+
*
|
|
29
|
+
* @param toEntityType A function that returns the target entity type.
|
|
30
|
+
* @param options (Optional): An object containing options for configuring the to-one relation.
|
|
31
|
+
* @returns A decorator function to apply the to-one relation to an entity field.
|
|
32
|
+
*
|
|
33
|
+
* Example usage:
|
|
34
|
+
* ```
|
|
35
|
+
* @Relations.toOne(() => Customer)
|
|
36
|
+
* customer?: Customer;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
25
39
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options?: FieldOptions<entityType, toEntityType> & Pick<RelationOptions<entityType, toEntityType, any, any>, 'defaultIncluded'>): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
26
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
42
|
+
* If no `fieldInMyEntity` is provided, this overload will automatically create a field in the database
|
|
43
|
+
* to represent the relation.
|
|
44
|
+
*
|
|
45
|
+
* @param toEntityType A function that returns the target entity type.
|
|
46
|
+
* @param fieldInMyEntity (Optional): The field in the current entity that represents the relation.
|
|
47
|
+
* Use this if you want to specify a custom field name for the relation.
|
|
48
|
+
* @returns A decorator function to apply the to-one relation to an entity field.
|
|
49
|
+
*
|
|
50
|
+
* Example usage:
|
|
51
|
+
* ```
|
|
52
|
+
* @Relations.toOne(() => Customer)
|
|
53
|
+
* customer?: Customer;
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
27
56
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
28
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
59
|
+
* This overload allows you to define the relation using options.
|
|
60
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
61
|
+
* to represent the relation.
|
|
62
|
+
*
|
|
63
|
+
* @param toEntityType A function that returns the target entity type.
|
|
64
|
+
* @param options An object containing options for configuring the to-one relation.
|
|
65
|
+
* - field (Optional): The name of the field in the related entity that corresponds to this relation.
|
|
66
|
+
* @returns A decorator function to apply the virtual to-one relation to an entity field.
|
|
67
|
+
*
|
|
68
|
+
* Example usage:
|
|
69
|
+
* ```
|
|
70
|
+
* @Relations.toOne(() => Customer, {
|
|
71
|
+
* field: "customerId",
|
|
72
|
+
* })
|
|
73
|
+
* customer?: Customer;
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* Define a to-one relation between entities, indicating a one-to-one relationship.
|
|
79
|
+
* If no field or fields are provided, it will automatically create a field in the database
|
|
80
|
+
* to represent the relation.
|
|
81
|
+
*
|
|
82
|
+
* @param toEntityType A function that returns the target entity type.
|
|
83
|
+
* @param options An object containing options for configuring the to-one relation.
|
|
84
|
+
* - fields (Optional): An object specifying custom field names for the relation.
|
|
85
|
+
* @returns A decorator function to apply the virtual to-one relation to an entity field.
|
|
86
|
+
*
|
|
87
|
+
* Example usage:
|
|
88
|
+
* ```
|
|
89
|
+
* @Relations.toOne(() => Customer, {
|
|
90
|
+
* fields: {
|
|
91
|
+
* customerId: "id",
|
|
92
|
+
* },
|
|
93
|
+
* })
|
|
94
|
+
* customer?: Customer;
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
29
97
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'field'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
30
98
|
/** A to one relation with fields defined in the field/fields parameter */
|
|
31
99
|
static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'fields'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
|
|
100
|
+
/**
|
|
101
|
+
* Define a toMany relation between entities, indicating a one-to-many relationship.
|
|
102
|
+
* This method allows you to establish a relationship where one entity can have multiple related entities.
|
|
103
|
+
*
|
|
104
|
+
* @param toEntityType A function that returns the target entity type.
|
|
105
|
+
* @param fieldInToEntity (Optional) The field in the target entity that represents the relation.
|
|
106
|
+
* Use this if you want to specify a custom field name for the relation.
|
|
107
|
+
* @returns A decorator function to apply the toMany relation to an entity field.
|
|
108
|
+
*
|
|
109
|
+
* Example usage:
|
|
110
|
+
* ```
|
|
111
|
+
* @Relations.toMany(() => Order)
|
|
112
|
+
* orders?: Order[];
|
|
113
|
+
*
|
|
114
|
+
* // or with a custom field name:
|
|
115
|
+
* @Relations.toMany(() => Order, "customerId")
|
|
116
|
+
* orders?: Order[];
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
32
119
|
static toMany<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInToEntity?: keyof toEntityType): ClassFieldDecorator<entityType, toEntityType[] | undefined>;
|
|
120
|
+
/**
|
|
121
|
+
* Define a toMany relation between entities, indicating a one-to-many relationship.
|
|
122
|
+
* This method allows you to establish a relationship where one entity can have multiple related entities.
|
|
123
|
+
* You can also specify various options to customize the relation and control related data retrieval.
|
|
124
|
+
*
|
|
125
|
+
* @param toEntityType A function that returns the target entity type.
|
|
126
|
+
* @param options An object containing options for configuring the toMany relation.
|
|
127
|
+
* - field (Optional): The field in the target entity that represents the relation.
|
|
128
|
+
* Use this if you want to specify a custom field name for the relation.
|
|
129
|
+
* - findOptions (Optional): Customize the options for finding related entities.
|
|
130
|
+
* You can set limits, order, where conditions, and more.
|
|
131
|
+
* @returns A decorator function to apply the toMany relation to an entity field.
|
|
132
|
+
*
|
|
133
|
+
* Example usage:
|
|
134
|
+
* ```
|
|
135
|
+
* @Relations.toMany(() => Order, {
|
|
136
|
+
* field: "customerOrders",
|
|
137
|
+
* findOptions: {
|
|
138
|
+
* limit: 10,
|
|
139
|
+
* orderBy: { amount: "desc" },
|
|
140
|
+
* where: { completed: true },
|
|
141
|
+
* },
|
|
142
|
+
* })
|
|
143
|
+
* orders?: Order[];
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
33
146
|
static toMany<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: RelationOptions<entityType, toEntityType, toEntityType, FindOptions<toEntityType>>): ClassFieldDecorator<entityType, toEntityType[] | undefined>;
|
|
34
147
|
}
|
|
35
148
|
/**Decorates fields that should be used as fields.
|