remult 0.26.23-next.0 → 0.26.23-next.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/remult3/Fields.js +13 -6
- package/esm/src/remult3/RepositoryImplementation.js +8 -8
- package/esm/src/remult3/remult3.js +6 -6
- package/package.json +1 -1
- package/postgres/schema-builder.d.ts +1 -1
- package/remult-knex/index.d.ts +1 -1
- package/remult-next.d.ts +1 -1
- package/remult-sveltekit.d.ts +1 -1
- package/server/index.d.ts +1 -1
- package/server/remult-api-server.d.ts +1 -1
- package/src/CompoundIdField.d.ts +1 -1
- package/src/column-interfaces.d.ts +12 -12
- package/src/data-api.d.ts +2 -2
- package/src/data-interfaces.d.ts +1 -1
- package/src/data-providers/sql-database.d.ts +1 -1
- package/src/data-providers/web-sql-data-provider.d.ts +2 -2
- package/src/entity.d.ts +1 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +1 -1
- package/src/remult3/Fields.d.ts +17 -17
- package/src/remult3/Fields.js +13 -6
- package/src/remult3/RepositoryImplementation.d.ts +16 -16
- package/src/remult3/RepositoryImplementation.js +8 -8
- package/src/remult3/addValidator.d.ts +1 -1
- package/src/remult3/classDescribers.d.ts +1 -1
- package/src/remult3/columnInfo.d.ts +1 -1
- package/src/remult3/relationInfoMember.d.ts +2 -2
- package/src/remult3/remult3.d.ts +8 -8
- package/src/remult3/remult3.js +6 -6
- package/src/server-action.d.ts +1 -1
|
@@ -6,6 +6,7 @@ import { Validators, createValueValidator, getEnumValues, } from '../validators.
|
|
|
6
6
|
import { relationInfoMemberInOptions } from './relationInfoMember.js';
|
|
7
7
|
import { remultStatic } from '../remult-static.js';
|
|
8
8
|
import { addValidator } from './addValidator.js';
|
|
9
|
+
import { isOfType } from '../isOfType.js';
|
|
9
10
|
const validateNumber = createValueValidator((x) => {
|
|
10
11
|
return !isNaN(x) && isFinite(x);
|
|
11
12
|
});
|
|
@@ -98,7 +99,7 @@ export class Fields {
|
|
|
98
99
|
},
|
|
99
100
|
}, ...options);
|
|
100
101
|
}
|
|
101
|
-
// static id<entityType =
|
|
102
|
+
// static id<entityType = unknown>(
|
|
102
103
|
// options?: FieldOptions<entityType, string> & { idFactory?: () => string },
|
|
103
104
|
// ): ClassFieldDecorator<entityType, string | undefined> {
|
|
104
105
|
// let buildId = options?.idFactory ?? createId
|
|
@@ -267,18 +268,24 @@ export class Relations {
|
|
|
267
268
|
*/
|
|
268
269
|
export function Field(valueType, ...options) {
|
|
269
270
|
// import ANT!!!! if you call this in another decorator, make sure to set It's return type correctly with the | undefined
|
|
270
|
-
return (target, context) => {
|
|
271
|
+
return (target, context, c) => {
|
|
271
272
|
const key = typeof context === 'string' ? context : context.name.toString();
|
|
272
273
|
let factory = (remult) => {
|
|
273
274
|
let r = buildOptions(options, remult);
|
|
274
275
|
if (r.required) {
|
|
275
276
|
r.validate = addValidator(r.validate, Validators.required, true);
|
|
276
277
|
}
|
|
277
|
-
if (r
|
|
278
|
-
|
|
278
|
+
if (isOfType(r, 'maxLength')) {
|
|
279
|
+
let z = r;
|
|
280
|
+
if (z.maxLength) {
|
|
281
|
+
z.validate = addValidator(z.validate, Validators.maxLength(z.maxLength));
|
|
282
|
+
}
|
|
279
283
|
}
|
|
280
|
-
if (r
|
|
281
|
-
|
|
284
|
+
if (isOfType(r, 'minLength')) {
|
|
285
|
+
let z = r;
|
|
286
|
+
if (z.minLength) {
|
|
287
|
+
z.validate = addValidator(z.validate, Validators.minLength(z.minLength));
|
|
288
|
+
}
|
|
282
289
|
}
|
|
283
290
|
if (!r.valueType && valueType) {
|
|
284
291
|
r.valueType = valueType();
|
|
@@ -1183,8 +1183,8 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
}
|
|
1186
|
-
if (this.info.
|
|
1187
|
-
this.info.
|
|
1186
|
+
if (this.info.entityInfo.entityRefInit)
|
|
1187
|
+
this.info.entityInfo.entityRefInit(this, instance);
|
|
1188
1188
|
if (Remult.entityRefInit)
|
|
1189
1189
|
Remult.entityRefInit(this, instance);
|
|
1190
1190
|
}
|
|
@@ -1456,7 +1456,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1456
1456
|
for (const col of this.info.fieldsMetadata) {
|
|
1457
1457
|
if (col.options.serverExpression) {
|
|
1458
1458
|
this.instance[col.key] =
|
|
1459
|
-
await col.options.serverExpression(this.instance);
|
|
1459
|
+
(await col.options.serverExpression(this.instance));
|
|
1460
1460
|
}
|
|
1461
1461
|
}
|
|
1462
1462
|
}
|
|
@@ -1865,11 +1865,11 @@ class EntityFullInfo {
|
|
|
1865
1865
|
else
|
|
1866
1866
|
crud = this.options.allowApiCrud;
|
|
1867
1867
|
if (this.options.allowApiDelete === undefined)
|
|
1868
|
-
this.
|
|
1868
|
+
this.entityInfo.allowApiDelete = crud;
|
|
1869
1869
|
if (this.options.allowApiInsert === undefined)
|
|
1870
|
-
this.
|
|
1870
|
+
this.entityInfo.allowApiInsert = crud;
|
|
1871
1871
|
if (this.options.allowApiUpdate === undefined)
|
|
1872
|
-
this.
|
|
1872
|
+
this.entityInfo.allowApiUpdate = crud;
|
|
1873
1873
|
if (this.options.allowApiRead === undefined)
|
|
1874
1874
|
this.options.allowApiRead = this.options.allowApiCrud;
|
|
1875
1875
|
}
|
|
@@ -2003,7 +2003,7 @@ class EntityFullInfo {
|
|
|
2003
2003
|
caption;
|
|
2004
2004
|
}
|
|
2005
2005
|
export function FieldType(...options) {
|
|
2006
|
-
return (target) => {
|
|
2006
|
+
return (target, context) => {
|
|
2007
2007
|
if (!options) {
|
|
2008
2008
|
options = [];
|
|
2009
2009
|
}
|
|
@@ -2016,7 +2016,7 @@ export function isAutoIncrement(f) {
|
|
|
2016
2016
|
return f.options?.valueConverter?.fieldTypeInDb === 'autoincrement';
|
|
2017
2017
|
}
|
|
2018
2018
|
export function ValueListFieldType(...options) {
|
|
2019
|
-
return (type) => {
|
|
2019
|
+
return (type, context) => {
|
|
2020
2020
|
FieldType((o) => {
|
|
2021
2021
|
;
|
|
2022
2022
|
(o.valueConverter = ValueListInfo.get(type)),
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export const flags = {
|
|
2
2
|
error500RetryCount: 4,
|
|
3
3
|
};
|
|
4
|
-
/*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Sql server expression supports undefined as a response
|
|
4
|
+
/*p1
|
|
5
|
+
* field, fieldType ,ValueListFieldType, - return optional parameter for decorators
|
|
6
|
+
* options to remultExpress tc... should be mandatory
|
|
7
|
+
* return value converter to previous typing
|
|
8
|
+
* add breaking change notification about findOne and findFirst and findId
|
|
10
9
|
*/
|
|
11
10
|
//p1 - fix query docs to also explain how it can be used for infinite scroll and pagination.
|
|
12
11
|
//y1 - 'test expression columns without aliases'
|
|
13
12
|
//y1 - ts issue with fields - when a field is optional, it's $ is also optional and thats a problem
|
|
13
|
+
//p1 - vite 5.3 supports ts5 decorators - check and adapt.
|
|
14
14
|
//p1 - see if I can fix the no alias problem in selects
|
|
15
15
|
//p1 - add luid - it's cool for order by.
|
|
16
16
|
//p1 - replace uuid with crypto.randomUUID and allow custom fallback
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ export declare class PostgresSchemaBuilder {
|
|
|
11
11
|
private schemaAndName;
|
|
12
12
|
private schemaOnly;
|
|
13
13
|
verifyStructureOfAllEntities(remult?: Remult): Promise<void>;
|
|
14
|
-
ensureSchema(entities: EntityMetadata
|
|
14
|
+
ensureSchema(entities: EntityMetadata[]): Promise<void>;
|
|
15
15
|
createIfNotExist(entity: EntityMetadata): Promise<void>;
|
|
16
16
|
addColumnIfNotExist<T extends EntityMetadata>(entity: T, c: (e: T) => FieldMetadata): Promise<void>;
|
|
17
17
|
verifyAllColumns<T extends EntityMetadata>(entity: T): Promise<void>;
|
package/remult-knex/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class KnexSchemaBuilder {
|
|
|
29
29
|
verifyStructureOfAllEntities(remult?: Remult): Promise<void>;
|
|
30
30
|
ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
|
|
31
31
|
createIfNotExist(entity: EntityMetadata): Promise<void>;
|
|
32
|
-
createTableKnexCommand(entity: EntityMetadata
|
|
32
|
+
createTableKnexCommand(entity: EntityMetadata, e: EntityDbNamesBase): Knex.SchemaBuilder;
|
|
33
33
|
addColumnIfNotExist(entity: EntityMetadata, c: (e: EntityMetadata) => FieldMetadata): Promise<void>;
|
|
34
34
|
createColumnKnexCommand(e: EntityDbNamesBase, col: FieldMetadata<any, any>, colName: string): Knex.SchemaBuilder;
|
|
35
35
|
verifyAllColumns<T extends EntityMetadata>(entity: T): Promise<void>;
|
package/remult-next.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GetServerSideProps, NextApiHandler, NextApiRequest, PreviewData } from 'next';
|
|
2
2
|
import type { ParsedUrlQuery } from 'querystring';
|
|
3
3
|
import type { RemultServerCore, RemultServerOptions } from './server/index.js';
|
|
4
|
-
export declare function remultNext(options
|
|
4
|
+
export declare function remultNext(options: RemultServerOptions<NextApiRequest>): RemultNextServer;
|
|
5
5
|
export type RemultNextServer = RemultServerCore<NextApiRequest> & NextApiHandler & {
|
|
6
6
|
getServerSideProps<P extends {
|
|
7
7
|
[key: string]: any;
|
package/remult-sveltekit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Handle, RequestEvent, RequestHandler } from '@sveltejs/kit';
|
|
2
2
|
import type { RemultServerCore, RemultServerOptions, RemultServer } from './server/index.js';
|
|
3
|
-
export declare function remultSveltekit(options
|
|
3
|
+
export declare function remultSveltekit(options: RemultServerOptions<RequestEvent>): RemultSveltekitServer;
|
|
4
4
|
export type RemultSveltekitServer = RemultServerCore<RequestEvent> & Handle & {
|
|
5
5
|
withRemult: RemultServer<RequestEvent>['withRemultAsync'];
|
|
6
6
|
GET: RequestHandler;
|
package/server/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export { SseSubscriptionServer } from '../SseSubscriptionServer.js';
|
|
|
3
3
|
export { DataProviderLiveQueryStorage } from '../live-query/data-provider-live-query-storage.js';
|
|
4
4
|
export { JsonEntityFileStorage, JsonFileDataProvider, } from './JsonEntityFileStorage.js';
|
|
5
5
|
export { GenericRequestHandler, GenericRequestInfo, GenericResponse, GenericRouter, InitRequestOptions, QueueStorage, RemultServer, RemultServerCore, RemultServerOptions, SpecificRoute, queuedJobInfo, } from './remult-api-server.js';
|
|
6
|
-
export declare function createRemultServer<RequestType>(options: RemultServerOptions<RequestType
|
|
6
|
+
export declare function createRemultServer<RequestType>(options: RemultServerOptions<RequestType>, serverCoreOptions?: ServerCoreOptions<RequestType>): RemultServer<RequestType>;
|
|
@@ -92,7 +92,7 @@ export interface InitRequestOptions {
|
|
|
92
92
|
liveQueryStorage: LiveQueryStorage;
|
|
93
93
|
readonly remult: Remult;
|
|
94
94
|
}
|
|
95
|
-
export declare function createRemultServerCore<RequestType>(options: RemultServerOptions<RequestType
|
|
95
|
+
export declare function createRemultServerCore<RequestType>(options: RemultServerOptions<RequestType>, serverCoreOptions: ServerCoreOptions<RequestType>): RemultServer<RequestType>;
|
|
96
96
|
export type GenericRequestHandler<RequestType> = (req: RequestType, res: GenericResponse, next: VoidFunction) => void;
|
|
97
97
|
export interface ServerHandleResponse {
|
|
98
98
|
data?: any;
|
package/src/CompoundIdField.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare class CompoundIdField implements FieldMetadata<string> {
|
|
|
11
11
|
fromInput(inputValue: string, inputType?: string): string;
|
|
12
12
|
getDbName(): Promise<string>;
|
|
13
13
|
getId(instance: any): string;
|
|
14
|
-
options: FieldOptions<
|
|
14
|
+
options: FieldOptions<unknown, unknown>;
|
|
15
15
|
get valueConverter(): Required<ValueConverter<string>>;
|
|
16
16
|
target: ClassType<any>;
|
|
17
17
|
readonly: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClassType } from '../classType.js';
|
|
2
2
|
import type { AllowedForInstance } from './context.js';
|
|
3
3
|
import type { EntityMetadata, FieldRef, LifecycleEvent, ValidateFieldEvent } from './remult3/remult3.js';
|
|
4
|
-
export interface FieldOptions<entityType =
|
|
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
7
|
* <input placeholder={taskRepo.metadata.fields.title.caption}/>
|
|
@@ -119,14 +119,14 @@ export interface FieldOptions<entityType = any, valueType = any> {
|
|
|
119
119
|
key?: string;
|
|
120
120
|
}
|
|
121
121
|
/**Metadata for a `Field`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
122
|
-
export interface FieldMetadata<valueType =
|
|
122
|
+
export interface FieldMetadata<valueType = unknown, entityType = unknown> {
|
|
123
123
|
/** The field's member name in an object.
|
|
124
124
|
* @example
|
|
125
125
|
* const taskRepo = remult.repo(Task);
|
|
126
126
|
* console.log(taskRepo.metadata.fields.title.key);
|
|
127
127
|
* // result: title
|
|
128
128
|
*/
|
|
129
|
-
readonly key: string;
|
|
129
|
+
readonly key: entityType extends object ? keyof entityType & string : string;
|
|
130
130
|
/** A human readable caption for the field. Can be used to achieve a consistent caption for a field throughout the app
|
|
131
131
|
* @example
|
|
132
132
|
* <input placeholder={taskRepo.metadata.fields.title.caption}/>
|
|
@@ -211,7 +211,7 @@ export interface FieldMetadata<valueType = any, entityType = any> {
|
|
|
211
211
|
* input.value = repo.fields.birthDate.toInput(person) // will return '1976-06-16'
|
|
212
212
|
* @see {@link ValueConverter#toInput} for configuration details
|
|
213
213
|
*/
|
|
214
|
-
toInput(value: valueType
|
|
214
|
+
toInput(value: valueType, inputType?: string): string;
|
|
215
215
|
/** Adapts the value for usage with html input
|
|
216
216
|
* @example
|
|
217
217
|
* @Fields.dateOnly()
|
|
@@ -239,7 +239,7 @@ export interface ValueConverter<valueType> {
|
|
|
239
239
|
* @example
|
|
240
240
|
* fromJson: val => new Date(val)
|
|
241
241
|
*/
|
|
242
|
-
fromJson?(val: any): valueType
|
|
242
|
+
fromJson?(val: any): valueType;
|
|
243
243
|
/**
|
|
244
244
|
* Converts a value of valueType to a JSON DTO. This method is typically used when sending data
|
|
245
245
|
* to a REST API or serializing an object to a JSON payload.
|
|
@@ -250,7 +250,7 @@ export interface ValueConverter<valueType> {
|
|
|
250
250
|
* @example
|
|
251
251
|
* toJson: val => val?.toISOString()
|
|
252
252
|
*/
|
|
253
|
-
toJson?(val: valueType
|
|
253
|
+
toJson?(val: valueType): any;
|
|
254
254
|
/**
|
|
255
255
|
* Converts a value from the database format to the valueType.
|
|
256
256
|
*
|
|
@@ -260,7 +260,7 @@ export interface ValueConverter<valueType> {
|
|
|
260
260
|
* @example
|
|
261
261
|
* fromDb: val => new Date(val)
|
|
262
262
|
*/
|
|
263
|
-
fromDb?(val: any): valueType
|
|
263
|
+
fromDb?(val: any): valueType;
|
|
264
264
|
/**
|
|
265
265
|
* Converts a value of valueType to the database format.
|
|
266
266
|
*
|
|
@@ -270,7 +270,7 @@ export interface ValueConverter<valueType> {
|
|
|
270
270
|
* @example
|
|
271
271
|
* toDb: val => val?.toISOString()
|
|
272
272
|
*/
|
|
273
|
-
toDb?(val: valueType
|
|
273
|
+
toDb?(val: valueType): any;
|
|
274
274
|
/**
|
|
275
275
|
* Converts a value of valueType to a string suitable for an HTML input element.
|
|
276
276
|
*
|
|
@@ -281,7 +281,7 @@ export interface ValueConverter<valueType> {
|
|
|
281
281
|
* @example
|
|
282
282
|
* toInput: (val, inputType) => val?.toISOString().substring(0, 10)
|
|
283
283
|
*/
|
|
284
|
-
toInput?(val: valueType
|
|
284
|
+
toInput?(val: valueType, inputType?: string): string;
|
|
285
285
|
/**
|
|
286
286
|
* Converts a string from an HTML input element to the valueType.
|
|
287
287
|
*
|
|
@@ -292,7 +292,7 @@ export interface ValueConverter<valueType> {
|
|
|
292
292
|
* @example
|
|
293
293
|
* fromInput: (val, inputType) => new Date(val)
|
|
294
294
|
*/
|
|
295
|
-
fromInput?(val: string, inputType?: string): valueType
|
|
295
|
+
fromInput?(val: string, inputType?: string): valueType;
|
|
296
296
|
/**
|
|
297
297
|
* Returns a displayable string representation of a value of valueType.
|
|
298
298
|
*
|
|
@@ -302,7 +302,7 @@ export interface ValueConverter<valueType> {
|
|
|
302
302
|
* @example
|
|
303
303
|
* displayValue: val => val?.toLocaleDateString()
|
|
304
304
|
*/
|
|
305
|
-
displayValue?(val: valueType
|
|
305
|
+
displayValue?(val: valueType): string;
|
|
306
306
|
/**
|
|
307
307
|
* Specifies the storage type used in the database for this field. This can be used to explicitly define the data type and precision of the field in the database.
|
|
308
308
|
*
|
|
@@ -324,7 +324,7 @@ export interface ValueConverter<valueType> {
|
|
|
324
324
|
*/
|
|
325
325
|
readonly inputType?: string;
|
|
326
326
|
}
|
|
327
|
-
export declare type FieldValidator<entityType =
|
|
327
|
+
export declare type FieldValidator<entityType = unknown, valueType = unknown> = (entity: entityType, event: ValidateFieldEvent<entityType, valueType>) => boolean | string | void | undefined | Promise<boolean | string | void | undefined>;
|
|
328
328
|
export declare type ValueOrExpression<valueType> = valueType | (() => valueType);
|
|
329
329
|
export declare function valueOrExpressionToValue<valueType>(f: ValueOrExpression<valueType>): valueType;
|
|
330
330
|
export interface ValueListItem {
|
package/src/data-api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Remult } from './context.js';
|
|
|
2
2
|
import type { ErrorInfo } from './data-interfaces.js';
|
|
3
3
|
import type { EntityMetadata, FindOptions, Repository } from './remult3/remult3.js';
|
|
4
4
|
import type { rowHelperImplementation } from './remult3/RepositoryImplementation.js';
|
|
5
|
-
export declare class DataApi<T =
|
|
5
|
+
export declare class DataApi<T = unknown> {
|
|
6
6
|
private repository;
|
|
7
7
|
private remult;
|
|
8
8
|
constructor(repository: Repository<T>, remult: Remult);
|
|
@@ -45,4 +45,4 @@ export interface DataApiRequest {
|
|
|
45
45
|
get(key: string): any;
|
|
46
46
|
}
|
|
47
47
|
export declare function determineSort(sortUrlParm: string, dirUrlParam: string): any;
|
|
48
|
-
export declare function serializeError(data: ErrorInfo): ErrorInfo<
|
|
48
|
+
export declare function serializeError(data: ErrorInfo): ErrorInfo<unknown>;
|
package/src/data-interfaces.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface RestDataProviderHttpProvider {
|
|
|
35
35
|
get(url: string): Promise<any>;
|
|
36
36
|
}
|
|
37
37
|
export declare function extractSort(sort: any): Sort;
|
|
38
|
-
export interface ErrorInfo<entityType =
|
|
38
|
+
export interface ErrorInfo<entityType = unknown> {
|
|
39
39
|
message?: string;
|
|
40
40
|
modelState?: {
|
|
41
41
|
[Properties in keyof Partial<MembersOnly<entityType>>]?: string;
|
|
@@ -37,7 +37,7 @@ export declare class SqlDatabase implements DataProvider, HasWrapIdentifier, Can
|
|
|
37
37
|
* Wraps an identifier with the database's identifier syntax.
|
|
38
38
|
*/
|
|
39
39
|
wrapIdentifier: (name: string) => string;
|
|
40
|
-
ensureSchema(entities: EntityMetadata
|
|
40
|
+
ensureSchema(entities: EntityMetadata[]): Promise<void>;
|
|
41
41
|
/**
|
|
42
42
|
* Gets the entity data provider.
|
|
43
43
|
* @param entity - The entity metadata.
|
|
@@ -10,9 +10,9 @@ export declare class WebSqlDataProvider implements SqlImplementation, __RowsOfDa
|
|
|
10
10
|
end(): Promise<void>;
|
|
11
11
|
getLimitSqlSyntax(limit: number, offset: number): string;
|
|
12
12
|
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
|
|
13
|
-
ensureSchema(entities: EntityMetadata
|
|
13
|
+
ensureSchema(entities: EntityMetadata[]): Promise<void>;
|
|
14
14
|
dropTable(entity: EntityMetadata): Promise<void>;
|
|
15
|
-
createTable(entity: EntityMetadata
|
|
15
|
+
createTable(entity: EntityMetadata): Promise<void>;
|
|
16
16
|
createCommand(): SqlCommand;
|
|
17
17
|
transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;
|
|
18
18
|
private addColumnSqlSyntax;
|
package/src/entity.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Allowed, AllowedForInstance } from './context.js';
|
|
|
2
2
|
import type { FieldMetadata } from './column-interfaces.js';
|
|
3
3
|
import type { EntityFilter, EntityIdFields, EntityMetadata, EntityOrderBy, EntityRef, FieldsMetadata, LifecycleEvent } from './remult3/remult3.js';
|
|
4
4
|
import type { FilterPreciseValues } from './filter/filter-interfaces.js';
|
|
5
|
-
export interface EntityOptions<entityType =
|
|
5
|
+
export interface EntityOptions<entityType = unknown> {
|
|
6
6
|
/**A human readable name for the entity */
|
|
7
7
|
caption?: string;
|
|
8
8
|
/**
|
|
@@ -68,7 +68,7 @@ export declare class CustomSqlFilterBuilder implements SqlCommandWithParameters,
|
|
|
68
68
|
}
|
|
69
69
|
export declare function isDbReadonly<entityType>(field: FieldMetadata, dbNames: EntityDbNames<entityType>): boolean | "" | undefined;
|
|
70
70
|
export declare function shouldNotCreateField<entityType>(field: FieldMetadata, dbNames: EntityDbNames<entityType>): boolean;
|
|
71
|
-
export declare function shouldCreateEntity(entity: EntityMetadata
|
|
71
|
+
export declare function shouldCreateEntity(entity: EntityMetadata, e: EntityDbNamesBase): boolean;
|
|
72
72
|
export declare type EntityDbNamesBase = {
|
|
73
73
|
$entityName: string;
|
|
74
74
|
$dbNameOf(field: FieldMetadata<any> | string): string;
|
package/src/remult3/Fields.d.ts
CHANGED
|
@@ -6,22 +6,22 @@ export declare class Fields {
|
|
|
6
6
|
/**
|
|
7
7
|
* Stored as a JSON.stringify - to store as json use Fields.json
|
|
8
8
|
*/
|
|
9
|
-
static object<entityType =
|
|
10
|
-
static json<entityType =
|
|
11
|
-
static dateOnly<entityType =
|
|
12
|
-
static date<entityType =
|
|
13
|
-
static integer<entityType =
|
|
14
|
-
static autoIncrement<entityType =
|
|
15
|
-
static number<entityType =
|
|
16
|
-
static createdAt<entityType =
|
|
17
|
-
static updatedAt<entityType =
|
|
18
|
-
static uuid<entityType =
|
|
9
|
+
static object<entityType = unknown, valueType = unknown>(...options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, valueType | undefined>;
|
|
10
|
+
static json<entityType = unknown, valueType = unknown>(...options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, valueType | undefined>;
|
|
11
|
+
static dateOnly<entityType = unknown>(...options: (FieldOptions<entityType, Date> | ((options: FieldOptions<entityType, Date>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, Date | undefined>;
|
|
12
|
+
static date<entityType = unknown>(...options: (FieldOptions<entityType, Date> | ((options: FieldOptions<entityType, Date>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, Date | undefined>;
|
|
13
|
+
static integer<entityType = unknown>(...options: (FieldOptions<entityType, number> | ((options: FieldOptions<entityType, number>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, number | undefined>;
|
|
14
|
+
static autoIncrement<entityType = unknown>(...options: (FieldOptions<entityType, number> | ((options: FieldOptions<entityType, number>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, number | undefined>;
|
|
15
|
+
static number<entityType = unknown>(...options: (FieldOptions<entityType, number> | ((options: FieldOptions<entityType, number>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, number | undefined>;
|
|
16
|
+
static createdAt<entityType = unknown>(...options: (FieldOptions<entityType, Date> | ((options: FieldOptions<entityType, Date>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, Date | undefined>;
|
|
17
|
+
static updatedAt<entityType = unknown>(...options: (FieldOptions<entityType, Date> | ((options: FieldOptions<entityType, Date>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, Date | undefined>;
|
|
18
|
+
static uuid<entityType = unknown>(...options: (FieldOptions<entityType, string> | ((options: FieldOptions<entityType, string>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, string | undefined>;
|
|
19
19
|
/**
|
|
20
20
|
* A CUID (Collision Resistant Unique Identifier) field.
|
|
21
21
|
* This id value is determined on the backend on insert, and can't be updated through the API.
|
|
22
22
|
* The CUID is generated using the `@paralleldrive/cuid2` npm package.
|
|
23
23
|
*/
|
|
24
|
-
static cuid<entityType =
|
|
24
|
+
static cuid<entityType = unknown>(...options: (FieldOptions<entityType, string> | ((options: FieldOptions<entityType, string>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, string | undefined>;
|
|
25
25
|
/**
|
|
26
26
|
* Defines a field that can hold a value from a specified set of string literals.
|
|
27
27
|
* @param {() => readonly valueType[]} optionalValues - A function that returns an array of allowed string literals.
|
|
@@ -51,10 +51,10 @@ export declare class Fields {
|
|
|
51
51
|
*
|
|
52
52
|
* // This approach allows easy management and updates of the allowed values for the `status` field.
|
|
53
53
|
*/
|
|
54
|
-
static literal<entityType =
|
|
55
|
-
static enum<entityType =
|
|
56
|
-
static string<entityType =
|
|
57
|
-
static boolean<entityType =
|
|
54
|
+
static literal<entityType = unknown, valueType extends string = string>(optionalValues: () => readonly valueType[], ...options: (StringFieldOptions<entityType, valueType> | ((options: StringFieldOptions<entityType, valueType>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, valueType | undefined>;
|
|
55
|
+
static enum<entityType = unknown, theEnum = object>(enumType: () => theEnum, ...options: (FieldOptions<entityType, theEnum[keyof theEnum]> | ((options: FieldOptions<entityType, theEnum[keyof theEnum]>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, theEnum[keyof theEnum] | undefined>;
|
|
56
|
+
static string<entityType = unknown, valueType = string>(...options: (StringFieldOptions<entityType, valueType> | ((options: StringFieldOptions<entityType, valueType>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, valueType | undefined>;
|
|
57
|
+
static boolean<entityType = unknown>(...options: (FieldOptions<entityType, boolean> | ((options: FieldOptions<entityType, boolean>, remult: Remult) => void))[]): ClassFieldDecorator<entityType, boolean | undefined>;
|
|
58
58
|
}
|
|
59
59
|
export declare class Relations {
|
|
60
60
|
/**
|
|
@@ -162,8 +162,8 @@ export declare class Relations {
|
|
|
162
162
|
* @Fields.string((options,remult) => options.includeInApi = true)
|
|
163
163
|
* title='';
|
|
164
164
|
*/
|
|
165
|
-
export declare function Field<entityType =
|
|
166
|
-
export interface StringFieldOptions<entityType =
|
|
165
|
+
export declare function Field<entityType = unknown, valueType = unknown>(valueType: (() => valueType extends number ? Number : valueType extends string ? String : valueType extends boolean ? Boolean : ClassType<valueType>) | undefined, ...options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[]): (target: any, context: ClassFieldDecoratorContextStub<entityType, valueType | undefined> | string, c?: any) => void;
|
|
166
|
+
export interface StringFieldOptions<entityType = unknown, valueType = string> extends FieldOptions<entityType, valueType> {
|
|
167
167
|
maxLength?: number;
|
|
168
168
|
minLength?: number;
|
|
169
169
|
}
|
package/src/remult3/Fields.js
CHANGED
|
@@ -12,6 +12,7 @@ var validators_js_1 = require("../validators.js");
|
|
|
12
12
|
var relationInfoMember_js_1 = require("./relationInfoMember.js");
|
|
13
13
|
var remult_static_js_1 = require("../remult-static.js");
|
|
14
14
|
var addValidator_js_1 = require("./addValidator.js");
|
|
15
|
+
var isOfType_js_1 = require("../isOfType.js");
|
|
15
16
|
var validateNumber = (0, validators_js_1.createValueValidator)(function (x) {
|
|
16
17
|
return !isNaN(x) && isFinite(x);
|
|
17
18
|
});
|
|
@@ -157,7 +158,7 @@ var Fields = /** @class */ (function () {
|
|
|
157
158
|
},
|
|
158
159
|
}], tslib_1.__read(options), false));
|
|
159
160
|
};
|
|
160
|
-
// static id<entityType =
|
|
161
|
+
// static id<entityType = unknown>(
|
|
161
162
|
// options?: FieldOptions<entityType, string> & { idFactory?: () => string },
|
|
162
163
|
// ): ClassFieldDecorator<entityType, string | undefined> {
|
|
163
164
|
// let buildId = options?.idFactory ?? createId
|
|
@@ -351,18 +352,24 @@ function Field(valueType) {
|
|
|
351
352
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
352
353
|
options[_i - 1] = arguments[_i];
|
|
353
354
|
}
|
|
354
|
-
return function (target, context) {
|
|
355
|
+
return function (target, context, c) {
|
|
355
356
|
var key = typeof context === 'string' ? context : context.name.toString();
|
|
356
357
|
var factory = function (remult) {
|
|
357
358
|
var r = (0, RepositoryImplementation_js_1.buildOptions)(options, remult);
|
|
358
359
|
if (r.required) {
|
|
359
360
|
r.validate = (0, addValidator_js_1.addValidator)(r.validate, validators_js_1.Validators.required, true);
|
|
360
361
|
}
|
|
361
|
-
if (r
|
|
362
|
-
|
|
362
|
+
if ((0, isOfType_js_1.isOfType)(r, 'maxLength')) {
|
|
363
|
+
var z = r;
|
|
364
|
+
if (z.maxLength) {
|
|
365
|
+
z.validate = (0, addValidator_js_1.addValidator)(z.validate, validators_js_1.Validators.maxLength(z.maxLength));
|
|
366
|
+
}
|
|
363
367
|
}
|
|
364
|
-
if (r
|
|
365
|
-
|
|
368
|
+
if ((0, isOfType_js_1.isOfType)(r, 'minLength')) {
|
|
369
|
+
var z = r;
|
|
370
|
+
if (z.minLength) {
|
|
371
|
+
z.validate = (0, addValidator_js_1.addValidator)(z.validate, validators_js_1.Validators.minLength(z.minLength));
|
|
372
|
+
}
|
|
366
373
|
}
|
|
367
374
|
if (!r.valueType && valueType) {
|
|
368
375
|
r.valueType = valueType();
|
|
@@ -103,7 +103,7 @@ declare abstract class rowHelperBase<T> {
|
|
|
103
103
|
[key: string]: string | undefined;
|
|
104
104
|
};
|
|
105
105
|
protected __assertValidity(): void;
|
|
106
|
-
buildErrorInfoObject(): ErrorInfo<
|
|
106
|
+
buildErrorInfoObject(): ErrorInfo<unknown>;
|
|
107
107
|
abstract get fields(): FieldsRef<T>;
|
|
108
108
|
catchSaveErrors(err: any): any;
|
|
109
109
|
__clearErrorsAndReportChanged(): void;
|
|
@@ -113,7 +113,7 @@ declare abstract class rowHelperBase<T> {
|
|
|
113
113
|
originalValues: any;
|
|
114
114
|
saveOriginalData(): void;
|
|
115
115
|
saveMoreOriginalData(): void;
|
|
116
|
-
validate(): Promise<ErrorInfo<
|
|
116
|
+
validate(): Promise<ErrorInfo<unknown> | undefined>;
|
|
117
117
|
__validateEntity(): Promise<void>;
|
|
118
118
|
__performColumnAndEntityValidations(): Promise<void>;
|
|
119
119
|
toApiJson(includeRelatedEntities?: boolean, notJustApi?: boolean): any;
|
|
@@ -157,18 +157,18 @@ export declare class rowHelperImplementation<T> extends rowHelperBase<T> impleme
|
|
|
157
157
|
}
|
|
158
158
|
export declare function getFields<fieldsContainerType>(container: fieldsContainerType, remult?: Remult): FieldsRef<fieldsContainerType>;
|
|
159
159
|
export declare function getControllerRef<fieldsContainerType>(container: fieldsContainerType, remultArg?: Remult): ControllerRef<fieldsContainerType>;
|
|
160
|
-
export declare class controllerRefImpl<T =
|
|
160
|
+
export declare class controllerRefImpl<T = unknown> extends rowHelperBase<T> implements ControllerRef<T> {
|
|
161
161
|
constructor(columnsInfo: FieldMetadata[], instance: any, remult: Remult);
|
|
162
162
|
__performColumnAndEntityValidations(): Promise<void>;
|
|
163
163
|
fields: FieldsRef<T>;
|
|
164
164
|
}
|
|
165
165
|
export declare class FieldRefImplementation<entityType, valueType> implements FieldRef<entityType, valueType> {
|
|
166
166
|
private settings;
|
|
167
|
-
metadata: FieldMetadata
|
|
167
|
+
metadata: FieldMetadata<valueType, entityType>;
|
|
168
168
|
container: any;
|
|
169
169
|
private helper;
|
|
170
170
|
private rowBase;
|
|
171
|
-
constructor(settings: FieldOptions, metadata: FieldMetadata, container: any, helper: EntityRef<entityType> | undefined, rowBase: rowHelperBase<entityType>);
|
|
171
|
+
constructor(settings: FieldOptions, metadata: FieldMetadata<valueType, entityType>, container: any, helper: EntityRef<entityType> | undefined, rowBase: rowHelperBase<entityType>);
|
|
172
172
|
_subscribers?: SubscribableImp;
|
|
173
173
|
subscribe(listener: RefSubscriber): Unsubscribe;
|
|
174
174
|
valueIsNull(): boolean;
|
|
@@ -230,14 +230,14 @@ export declare class columnDefsImpl implements FieldMetadata {
|
|
|
230
230
|
private settings;
|
|
231
231
|
private entityDefs;
|
|
232
232
|
private remult;
|
|
233
|
-
constructor(settings: FieldOptions, entityDefs: EntityFullInfo<any>, remult: Remult);
|
|
233
|
+
constructor(settings: FieldOptions<unknown, unknown>, entityDefs: EntityFullInfo<any>, remult: Remult);
|
|
234
234
|
apiUpdateAllowed(item?: any): boolean;
|
|
235
235
|
displayValue(item: any): string;
|
|
236
236
|
includedInApi(item?: any): boolean;
|
|
237
237
|
toInput(value: any, inputType?: string): string;
|
|
238
238
|
fromInput(inputValue: string, inputType?: string): any;
|
|
239
239
|
getDbName(): Promise<string>;
|
|
240
|
-
options: FieldOptions<
|
|
240
|
+
options: FieldOptions<unknown, unknown>;
|
|
241
241
|
target: ClassType<any>;
|
|
242
242
|
readonly: boolean;
|
|
243
243
|
valueConverter: Required<ValueConverter<any>>;
|
|
@@ -255,9 +255,9 @@ declare class EntityFullInfo<T> implements EntityMetadata<T> {
|
|
|
255
255
|
private remult;
|
|
256
256
|
readonly entityType: ClassType<T>;
|
|
257
257
|
readonly key: string;
|
|
258
|
-
options: EntityOptions<
|
|
258
|
+
options: EntityOptions<unknown>;
|
|
259
259
|
fieldsMetadata: FieldMetadata[];
|
|
260
|
-
constructor(columnsInfo: FieldOptions[], entityInfo: EntityOptions<T>, remult: Remult, entityType: ClassType<T>, key: string);
|
|
260
|
+
constructor(columnsInfo: FieldOptions<unknown, unknown>[], entityInfo: EntityOptions<T>, remult: Remult, entityType: ClassType<T>, key: string);
|
|
261
261
|
apiUpdateAllowed(item: T): boolean;
|
|
262
262
|
get apiReadAllowed(): boolean;
|
|
263
263
|
apiDeleteAllowed(item: T): boolean;
|
|
@@ -269,9 +269,9 @@ declare class EntityFullInfo<T> implements EntityMetadata<T> {
|
|
|
269
269
|
dbName: string;
|
|
270
270
|
caption: string;
|
|
271
271
|
}
|
|
272
|
-
export declare function FieldType<valueType =
|
|
272
|
+
export declare function FieldType<valueType = unknown>(...options: (FieldOptions<any, valueType> | ((options: FieldOptions<any, valueType>, remult: Remult) => void))[]): (target: any, context?: any) => any;
|
|
273
273
|
export declare function isAutoIncrement(f: FieldMetadata): boolean;
|
|
274
|
-
export declare function ValueListFieldType<valueType extends ValueListItem =
|
|
274
|
+
export declare function ValueListFieldType<valueType extends ValueListItem = ValueListItem>(...options: (ValueListFieldOptions<any, valueType> | ((options: FieldOptions<any, valueType>, remult: Remult) => void))[]): (type: ClassType<valueType>, context?: any) => void;
|
|
275
275
|
export interface ValueListFieldOptions<entityType, valueType> extends FieldOptions<entityType, valueType> {
|
|
276
276
|
getValues?: () => valueType[];
|
|
277
277
|
}
|
|
@@ -284,12 +284,12 @@ export declare class ValueListInfo<T extends ValueListItem> implements ValueConv
|
|
|
284
284
|
private constructor();
|
|
285
285
|
getValues(): T[];
|
|
286
286
|
byId(key: any): T | undefined;
|
|
287
|
-
fromJson(val: any): T
|
|
287
|
+
fromJson(val: any): T;
|
|
288
288
|
toJson(val: T): any;
|
|
289
|
-
fromDb(val: any): T
|
|
289
|
+
fromDb(val: any): T;
|
|
290
290
|
toDb(val: T): any;
|
|
291
291
|
toInput(val: T, inputType: string): string;
|
|
292
|
-
fromInput(val: string, inputType: string): T
|
|
292
|
+
fromInput(val: string, inputType: string): T;
|
|
293
293
|
displayValue?(val: T): string;
|
|
294
294
|
fieldTypeInDb?: string;
|
|
295
295
|
inputType?: string;
|
|
@@ -299,8 +299,8 @@ export declare function getValueList<T>(field: FieldMetadata<T>): T[];
|
|
|
299
299
|
export declare function getValueList<T>(type: ClassType<T>): T[];
|
|
300
300
|
export declare const storableMember: unique symbol;
|
|
301
301
|
export declare const fieldOptionalValuesFunctionKey: unique symbol;
|
|
302
|
-
export declare function buildOptions<entityType =
|
|
303
|
-
export declare function decorateColumnSettings<valueType>(settings: FieldOptions<
|
|
302
|
+
export declare function buildOptions<entityType = unknown, valueType = unknown>(options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[], remult: Remult): FieldOptions<entityType, valueType>;
|
|
303
|
+
export declare function decorateColumnSettings<valueType>(settings: FieldOptions<unknown, valueType>, remult: Remult): FieldOptions<unknown, valueType>;
|
|
304
304
|
export declare class EntityBase {
|
|
305
305
|
get _(): EntityRefForEntityBase<this>;
|
|
306
306
|
save(): Promise<this>;
|
|
@@ -1957,8 +1957,8 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1957
1957
|
finally { if (e_30) throw e_30.error; }
|
|
1958
1958
|
}
|
|
1959
1959
|
}
|
|
1960
|
-
if (_this.info.
|
|
1961
|
-
_this.info.
|
|
1960
|
+
if (_this.info.entityInfo.entityRefInit)
|
|
1961
|
+
_this.info.entityInfo.entityRefInit(_this, instance);
|
|
1962
1962
|
if (context_js_1.Remult.entityRefInit)
|
|
1963
1963
|
context_js_1.Remult.entityRefInit(_this, instance);
|
|
1964
1964
|
return _this;
|
|
@@ -2518,7 +2518,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2518
2518
|
return [4 /*yield*/, col.options.serverExpression(this.instance)];
|
|
2519
2519
|
case 3:
|
|
2520
2520
|
_c[_d] =
|
|
2521
|
-
_f.sent();
|
|
2521
|
+
(_f.sent());
|
|
2522
2522
|
_f.label = 4;
|
|
2523
2523
|
case 4:
|
|
2524
2524
|
_b = _a.next();
|
|
@@ -3207,11 +3207,11 @@ var EntityFullInfo = /** @class */ (function () {
|
|
|
3207
3207
|
else
|
|
3208
3208
|
crud = this.options.allowApiCrud;
|
|
3209
3209
|
if (this.options.allowApiDelete === undefined)
|
|
3210
|
-
this.
|
|
3210
|
+
this.entityInfo.allowApiDelete = crud;
|
|
3211
3211
|
if (this.options.allowApiInsert === undefined)
|
|
3212
|
-
this.
|
|
3212
|
+
this.entityInfo.allowApiInsert = crud;
|
|
3213
3213
|
if (this.options.allowApiUpdate === undefined)
|
|
3214
|
-
this.
|
|
3214
|
+
this.entityInfo.allowApiUpdate = crud;
|
|
3215
3215
|
if (this.options.allowApiRead === undefined)
|
|
3216
3216
|
this.options.allowApiRead = this.options.allowApiCrud;
|
|
3217
3217
|
}
|
|
@@ -3312,7 +3312,7 @@ function FieldType() {
|
|
|
3312
3312
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3313
3313
|
options[_i] = arguments[_i];
|
|
3314
3314
|
}
|
|
3315
|
-
return function (target) {
|
|
3315
|
+
return function (target, context) {
|
|
3316
3316
|
if (!options) {
|
|
3317
3317
|
options = [];
|
|
3318
3318
|
}
|
|
@@ -3330,7 +3330,7 @@ function ValueListFieldType() {
|
|
|
3330
3330
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3331
3331
|
options[_i] = arguments[_i];
|
|
3332
3332
|
}
|
|
3333
|
-
return function (type) {
|
|
3333
|
+
return function (type, context) {
|
|
3334
3334
|
FieldType.apply(void 0, tslib_1.__spreadArray([function (o) {
|
|
3335
3335
|
;
|
|
3336
3336
|
(o.valueConverter = ValueListInfo.get(type)),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { FieldOptions } from '../column-interfaces.js';
|
|
2
|
-
export declare function addValidator(validators: FieldOptions['validate'], newValidator: FieldOptions['validate'], atStart?: boolean): import("../column-interfaces.js").FieldValidator<
|
|
2
|
+
export declare function addValidator<entityType, valueType>(validators: FieldOptions<entityType, valueType>['validate'], newValidator: FieldOptions<entityType, valueType>['validate'], atStart?: boolean): import("../column-interfaces.js").FieldValidator<entityType, valueType> | import("../column-interfaces.js").FieldValidator<entityType, valueType>[] | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ClassType } from '../../classType.js';
|
|
2
2
|
import type { EntityOptions } from '../entity.js';
|
|
3
3
|
import { type BackendMethodOptions } from '../server-action.js';
|
|
4
|
-
type Descriptor<T =
|
|
4
|
+
type Descriptor<T = unknown> = (a: T, b: string, c?: any) => void;
|
|
5
5
|
type FieldsDescriptor<T> = T extends new (...args: any[]) => infer R ? {
|
|
6
6
|
[K in keyof R]?: Descriptor;
|
|
7
7
|
} : never;
|
|
@@ -15,10 +15,10 @@ export interface RelationInfo {
|
|
|
15
15
|
toType: () => any;
|
|
16
16
|
type: RelationFieldInfo['type'];
|
|
17
17
|
}
|
|
18
|
-
export declare function getRelationFieldInfo(field: FieldMetadata
|
|
18
|
+
export declare function getRelationFieldInfo(field: FieldMetadata): RelationFieldInfo | undefined;
|
|
19
19
|
export interface RelationFieldInfo {
|
|
20
20
|
type: 'reference' | 'toOne' | 'toMany';
|
|
21
|
-
options: RelationOptions<
|
|
21
|
+
options: RelationOptions<unknown, unknown, unknown>;
|
|
22
22
|
toEntity: any;
|
|
23
23
|
toRepo: Repository<unknown>;
|
|
24
24
|
getFields(): RelationFields;
|
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface EntityRefForEntityBase<entityType> extends EntityRefBase<entity
|
|
|
36
36
|
fields: FieldsRefForEntityBase<entityType>;
|
|
37
37
|
relations: RepositoryRelationsForEntityBase<entityType>;
|
|
38
38
|
}
|
|
39
|
-
export interface ValidateFieldEvent<entityType =
|
|
39
|
+
export interface ValidateFieldEvent<entityType = unknown, valueType = unknown> {
|
|
40
40
|
error?: string;
|
|
41
41
|
value: valueType;
|
|
42
42
|
originalValue: valueType;
|
|
@@ -119,19 +119,19 @@ export type FieldsRefBase<entityType> = {
|
|
|
119
119
|
toArray(): FieldRef<entityType, any>[];
|
|
120
120
|
};
|
|
121
121
|
export type FieldsMetadata<entityType> = {
|
|
122
|
-
[Properties in keyof MembersOnly<entityType>]
|
|
122
|
+
[Properties in keyof MembersOnly<entityType>]-?: FieldMetadata<entityType[Properties], entityType>;
|
|
123
123
|
} & {
|
|
124
|
-
find(fieldMetadataOrKey: FieldMetadata | string): FieldMetadata<
|
|
124
|
+
find(fieldMetadataOrKey: FieldMetadata | string): FieldMetadata<unknown, entityType>;
|
|
125
125
|
[Symbol.iterator]: () => IterableIterator<FieldMetadata<any, entityType>>;
|
|
126
126
|
toArray(): FieldMetadata<any, entityType>[];
|
|
127
127
|
};
|
|
128
128
|
export type FieldsRef<entityType> = FieldsRefBase<entityType> & {
|
|
129
|
-
[Properties in keyof MembersOnly<entityType>]
|
|
129
|
+
[Properties in keyof MembersOnly<entityType>]-?: NonNullable<entityType[Properties]> extends {
|
|
130
130
|
id?: number | string;
|
|
131
131
|
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
132
132
|
};
|
|
133
133
|
export type FieldsRefForEntityBase<entityType> = FieldsRefBase<entityType> & {
|
|
134
|
-
[Properties in keyof Omit<entityType, keyof EntityBase>]
|
|
134
|
+
[Properties in keyof Omit<entityType, keyof EntityBase>]-?: NonNullable<entityType[Properties]> extends {
|
|
135
135
|
id?: number | string;
|
|
136
136
|
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
137
137
|
};
|
|
@@ -152,7 +152,7 @@ export interface IdFieldRef<entityType, valueType> extends FieldRef<entityType,
|
|
|
152
152
|
id?: string;
|
|
153
153
|
} ? string : string | number;
|
|
154
154
|
}
|
|
155
|
-
export interface FieldRef<entityType =
|
|
155
|
+
export interface FieldRef<entityType = unknown, valueType = unknown> extends Subscribable {
|
|
156
156
|
error: string | undefined;
|
|
157
157
|
displayValue: string;
|
|
158
158
|
value: valueType;
|
|
@@ -170,7 +170,7 @@ export interface FieldRef<entityType = any, valueType = any> extends Subscribabl
|
|
|
170
170
|
originalValueIsNull(): boolean;
|
|
171
171
|
validate(): Promise<boolean>;
|
|
172
172
|
}
|
|
173
|
-
export interface IdMetadata<entityType =
|
|
173
|
+
export interface IdMetadata<entityType = unknown> {
|
|
174
174
|
/** Extracts the id value of an entity item. Useful in cases where the id column is not called id
|
|
175
175
|
* @example
|
|
176
176
|
* repo.metadata.idMetadata.getId(task)
|
|
@@ -183,7 +183,7 @@ export interface IdMetadata<entityType = any> {
|
|
|
183
183
|
createIdInFilter(items: Partial<MembersOnly<entityType>>[]): EntityFilter<entityType>;
|
|
184
184
|
}
|
|
185
185
|
/** Metadata for an `Entity`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
186
|
-
export interface EntityMetadata<entityType =
|
|
186
|
+
export interface EntityMetadata<entityType = unknown> {
|
|
187
187
|
/** The Entity's key also used as it's url */
|
|
188
188
|
readonly key: string;
|
|
189
189
|
/** Metadata for the Entity's fields */
|
package/src/remult3/remult3.js
CHANGED
|
@@ -4,16 +4,16 @@ exports.flags = void 0;
|
|
|
4
4
|
exports.flags = {
|
|
5
5
|
error500RetryCount: 4,
|
|
6
6
|
};
|
|
7
|
-
/*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Sql server expression supports undefined as a response
|
|
7
|
+
/*p1
|
|
8
|
+
* field, fieldType ,ValueListFieldType, - return optional parameter for decorators
|
|
9
|
+
* options to remultExpress tc... should be mandatory
|
|
10
|
+
* return value converter to previous typing
|
|
11
|
+
* add breaking change notification about findOne and findFirst and findId
|
|
13
12
|
*/
|
|
14
13
|
//p1 - fix query docs to also explain how it can be used for infinite scroll and pagination.
|
|
15
14
|
//y1 - 'test expression columns without aliases'
|
|
16
15
|
//y1 - ts issue with fields - when a field is optional, it's $ is also optional and thats a problem
|
|
16
|
+
//p1 - vite 5.3 supports ts5 decorators - check and adapt.
|
|
17
17
|
//p1 - see if I can fix the no alias problem in selects
|
|
18
18
|
//p1 - add luid - it's cool for order by.
|
|
19
19
|
//p1 - replace uuid with crypto.randomUUID and allow custom fallback
|
package/src/server-action.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface ClassMethodDecoratorContextStub<This = unknown, Value extends (
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
/** Indicates that the decorated methods runs on the backend. See: [Backend Methods](https://remult.dev/docs/backendMethods.html) */
|
|
57
|
-
export declare function BackendMethod<type =
|
|
57
|
+
export declare function BackendMethod<type = unknown>(options: BackendMethodOptions<type>): (target: any, context: ClassMethodDecoratorContextStub<type> | string, descriptor?: any) => any;
|
|
58
58
|
export interface jobWasQueuedResult {
|
|
59
59
|
queuedJobId?: string;
|
|
60
60
|
}
|