remult 0.26.23 → 0.27.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.
- package/SseSubscriptionServer.d.ts +3 -4
- package/assign.js +1 -2
- package/esm/graphql.js +1 -1
- package/esm/remult-hono.js +3 -1
- package/esm/remult-knex/index.js +3 -1
- package/esm/remult-sqlite3.js +4 -1
- package/esm/remult-sveltekit.js +1 -0
- package/esm/server/index.js +3 -2
- package/esm/server/initAsyncHooks.js +3 -3
- package/esm/server/remult-admin.js +1 -4
- package/esm/server/remult-api-server.js +47 -48
- package/esm/src/CompoundIdField.js +9 -9
- package/esm/src/data-api.js +1 -1
- package/esm/src/data-providers/json-entity-opfs-storage.js +9 -5
- package/esm/src/data-providers/sql-database.js +9 -9
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +3 -1
- package/esm/src/filter/filter-interfaces.js +1 -1
- package/esm/src/live-query/LiveQueryClient.js +0 -1
- package/esm/src/remult-proxy.js +1 -3
- package/esm/src/remult-static.js +1 -0
- package/esm/src/remult3/Fields.js +15 -7
- package/esm/src/remult3/RepositoryImplementation.js +165 -125
- package/esm/src/remult3/entity.js +1 -1
- package/esm/src/remult3/relation-loader.js +2 -2
- package/esm/src/remult3/remult3.js +15 -0
- package/esm/src/server-action.js +16 -12
- package/esm/src/sort.js +0 -2
- package/esm/src/validators.js +3 -3
- package/esm/src/valueConverters.js +2 -2
- package/graphql.js +3 -4
- package/index.js +2 -2
- package/live-query/data-provider-live-query-storage.js +6 -6
- package/migrations/compare-migration-snapshots.js +48 -49
- package/migrations/generate-migrations.js +1 -2
- package/migrations/migrate.js +2 -3
- package/migrations/migration-types.d.ts +1 -1
- package/migrations/migration-types.js +4 -4
- package/migrations/update-migrations-ts-file.js +1 -2
- package/myLog.js +1 -2
- package/package.json +1 -1
- package/postgres/postgres-data-provider.d.ts +2 -2
- package/postgres/postgres-data-provider.js +5 -5
- package/postgres/schema-builder.d.ts +1 -1
- package/postgres/schema-builder.js +3 -3
- package/remult-express.js +4 -3
- package/remult-fastify.js +4 -3
- package/remult-fresh.js +1 -2
- package/remult-hapi.js +4 -3
- package/remult-hono.js +6 -3
- package/remult-knex/index.d.ts +2 -2
- package/remult-knex/index.js +7 -5
- package/remult-mongo.d.ts +1 -1
- package/remult-next.d.ts +5 -6
- package/remult-next.js +11 -6
- package/remult-nuxt.js +1 -2
- package/remult-solid-start.js +1 -2
- package/remult-sqlite3.js +4 -1
- package/remult-sveltekit.d.ts +1 -1
- package/remult-sveltekit.js +33 -35
- package/server/JsonEntityFileStorage.d.ts +1 -1
- package/server/get-remult-admin-html.js +1 -2
- package/server/index.js +4 -3
- package/server/initAsyncHooks.d.ts +10 -10
- package/server/initAsyncHooks.js +5 -2
- package/server/initDataProvider.js +1 -2
- package/server/initDataProviderOrJson.js +1 -2
- package/server/remult-admin.js +3 -7
- package/server/remult-api-server.d.ts +21 -21
- package/server/remult-api-server.js +54 -48
- package/src/CompoundIdField.d.ts +2 -2
- package/src/CompoundIdField.js +9 -0
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +8 -8
- package/src/column-interfaces.d.ts +4 -4
- package/src/column-interfaces.js +1 -2
- package/src/column.d.ts +4 -4
- package/src/column.js +2 -2
- package/src/context.d.ts +4 -4
- package/src/context.js +5 -5
- package/src/data-api.d.ts +4 -4
- package/src/data-api.js +4 -4
- package/src/data-interfaces.d.ts +1 -1
- package/src/data-interfaces.js +1 -2
- package/src/data-providers/json-entity-opfs-storage.js +30 -16
- package/src/data-providers/rest-data-provider.d.ts +3 -3
- package/src/data-providers/rest-data-provider.js +4 -4
- package/src/data-providers/sql-database.d.ts +1 -1
- package/src/data-providers/sql-database.js +11 -11
- 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 +3 -3
- package/src/filter/filter-consumer-bridge-to-sql-request.js +21 -19
- package/src/filter/filter-interfaces.d.ts +2 -1
- package/src/filter/filter-interfaces.js +10 -7
- package/src/isOfType.js +2 -3
- package/src/live-query/SubscriptionServer.js +95 -97
- package/src/remult-proxy.js +1 -3
- package/src/remult-static.d.ts +2 -2
- package/src/remult-static.js +7 -4
- package/src/remult3/Fields.d.ts +17 -17
- package/src/remult3/Fields.js +22 -13
- package/src/remult3/RepositoryImplementation.d.ts +51 -46
- package/src/remult3/RepositoryImplementation.js +421 -368
- package/src/remult3/__updateEntityBasedOnWhere.js +1 -2
- package/src/remult3/addValidator.d.ts +1 -1
- package/src/remult3/addValidator.js +1 -2
- package/src/remult3/classDescribers.d.ts +4 -4
- package/src/remult3/classDescribers.js +3 -4
- package/src/remult3/columnInfo.d.ts +1 -1
- package/src/remult3/entity.js +2 -4
- package/src/remult3/getEntityRef.js +4 -4
- package/src/remult3/relation-loader.d.ts +1 -1
- package/src/remult3/relationInfoMember.d.ts +3 -3
- package/src/remult3/relationInfoMember.js +4 -5
- package/src/remult3/remult3.d.ts +23 -20
- package/src/remult3/remult3.js +15 -0
- package/src/remult3/repository-internals.d.ts +3 -3
- package/src/remult3/repository-internals.js +2 -2
- package/src/server-action.d.ts +2 -2
- package/src/server-action.js +65 -58
- package/src/sort.d.ts +1 -1
- package/src/sort.js +0 -2
- package/src/sql-command.d.ts +1 -1
- package/src/validators.d.ts +1 -1
- package/src/validators.js +13 -11
- package/src/valueConverters.js +3 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.__updateEntityBasedOnWhere =
|
|
3
|
+
exports.__updateEntityBasedOnWhere = __updateEntityBasedOnWhere;
|
|
4
4
|
var filter_interfaces_js_1 = require("../filter/filter-interfaces.js");
|
|
5
5
|
function __updateEntityBasedOnWhere(entityDefs, where, r) {
|
|
6
6
|
var w = filter_interfaces_js_1.Filter.fromEntityFilter(entityDefs, where);
|
|
@@ -29,4 +29,3 @@ function __updateEntityBasedOnWhere(entityDefs, where, r) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
exports.__updateEntityBasedOnWhere = __updateEntityBasedOnWhere;
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addValidator =
|
|
3
|
+
exports.addValidator = addValidator;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
function addValidator(validators, newValidator, atStart) {
|
|
6
6
|
if (atStart === void 0) { atStart = false; }
|
|
@@ -17,4 +17,3 @@ function addValidator(validators, newValidator, atStart) {
|
|
|
17
17
|
return atStart
|
|
18
18
|
? tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(newValidators), false), tslib_1.__read(validatorsArray), false) : tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(validatorsArray), false), tslib_1.__read(newValidators), false);
|
|
19
19
|
}
|
|
20
|
-
exports.addValidator = addValidator;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ClassType } from '../../classType.js';
|
|
2
|
-
import { EntityOptions } from '../entity.js';
|
|
3
|
-
import { BackendMethodOptions } from '../server-action.js';
|
|
4
|
-
type Descriptor<T =
|
|
1
|
+
import type { ClassType } from '../../classType.js';
|
|
2
|
+
import type { EntityOptions } from '../entity.js';
|
|
3
|
+
import { type BackendMethodOptions } from '../server-action.js';
|
|
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;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.describeClass = describeClass;
|
|
4
|
+
exports.describeBackendMethods = describeBackendMethods;
|
|
5
|
+
exports.describeEntity = describeEntity;
|
|
4
6
|
var server_action_js_1 = require("../server-action.js");
|
|
5
7
|
var entity_js_1 = require("./entity.js");
|
|
6
8
|
function describeClass(classType, classDescriber, members, staticMembers) {
|
|
@@ -23,7 +25,6 @@ function describeClass(classType, classDescriber, members, staticMembers) {
|
|
|
23
25
|
Object.defineProperty(classType, staticFieldKey, prop);
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
exports.describeClass = describeClass;
|
|
27
28
|
function describeBackendMethods(classType, backendMethods) {
|
|
28
29
|
var result = {};
|
|
29
30
|
for (var key in backendMethods) {
|
|
@@ -34,8 +35,6 @@ function describeBackendMethods(classType, backendMethods) {
|
|
|
34
35
|
}
|
|
35
36
|
describeClass(classType, undefined, undefined, result);
|
|
36
37
|
}
|
|
37
|
-
exports.describeBackendMethods = describeBackendMethods;
|
|
38
38
|
function describeEntity(classType, key, fields, options) {
|
|
39
39
|
describeClass(classType, (0, entity_js_1.Entity)(key, options), fields);
|
|
40
40
|
}
|
|
41
|
-
exports.describeEntity = describeEntity;
|
package/src/remult3/entity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Entity =
|
|
3
|
+
exports.Entity = Entity;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var context_js_1 = require("../context.js");
|
|
6
6
|
var getEntityRef_js_1 = require("./getEntityRef.js");
|
|
@@ -35,11 +35,10 @@ function Entity(key) {
|
|
|
35
35
|
options[_i - 1] = arguments[_i];
|
|
36
36
|
}
|
|
37
37
|
return function (target, info) {
|
|
38
|
-
var _a;
|
|
39
38
|
for (var rawFilterMember in target) {
|
|
40
39
|
if (Object.prototype.hasOwnProperty.call(target, rawFilterMember)) {
|
|
41
40
|
var element = target[rawFilterMember];
|
|
42
|
-
if (
|
|
41
|
+
if (element === null || element === void 0 ? void 0 : element.rawFilterInfo) {
|
|
43
42
|
if (!element.rawFilterInfo.key)
|
|
44
43
|
element.rawFilterInfo.key = rawFilterMember;
|
|
45
44
|
}
|
|
@@ -85,4 +84,3 @@ function Entity(key) {
|
|
|
85
84
|
return target;
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
exports.Entity = Entity;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.entityInfo_key = exports.entityInfo = exports.entityMember = void 0;
|
|
4
|
+
exports.getEntityRef = getEntityRef;
|
|
5
|
+
exports.getEntitySettings = getEntitySettings;
|
|
6
|
+
exports.getEntityKey = getEntityKey;
|
|
4
7
|
/**
|
|
5
8
|
* Retrieves the EntityRef object associated with the specified entity instance.
|
|
6
9
|
* The EntityRef provides methods for performing operations on the entity instance.
|
|
@@ -20,7 +23,6 @@ function getEntityRef(entity, throwException) {
|
|
|
20
23
|
' was not initialized using a context');
|
|
21
24
|
return x;
|
|
22
25
|
}
|
|
23
|
-
exports.getEntityRef = getEntityRef;
|
|
24
26
|
exports.entityMember = Symbol.for('entityMember');
|
|
25
27
|
exports.entityInfo = Symbol.for('entityInfo');
|
|
26
28
|
exports.entityInfo_key = Symbol.for('entityInfo_key');
|
|
@@ -38,8 +40,6 @@ function getEntitySettings(entity, throwError) {
|
|
|
38
40
|
" is not a known entity, did you forget to set @Entity() or did you forget to add the '@' before the call to Entity?");
|
|
39
41
|
return info;
|
|
40
42
|
}
|
|
41
|
-
exports.getEntitySettings = getEntitySettings;
|
|
42
43
|
function getEntityKey(entity) {
|
|
43
44
|
return entity[exports.entityInfo_key];
|
|
44
45
|
}
|
|
45
|
-
exports.getEntityKey = getEntityKey;
|
|
@@ -2,7 +2,7 @@ import type { RelationLoaderHelper } from './relation-loader-types.js';
|
|
|
2
2
|
import type { FindOptions } from './remult3.js';
|
|
3
3
|
export declare class RelationLoader {
|
|
4
4
|
entityLoaders: Map<any, EntityLoader>;
|
|
5
|
-
promises: any[];
|
|
5
|
+
promises: Promise<any>[];
|
|
6
6
|
load(rel: RelationLoaderHelper<any>, findOptions: FindOptions<any>): Promise<any[]>;
|
|
7
7
|
constructor();
|
|
8
8
|
resolveAll(): Promise<void>;
|
|
@@ -3,7 +3,7 @@ import type { FieldMetadata, FieldOptions } from '../column-interfaces.js';
|
|
|
3
3
|
import type { Remult } from '../context.js';
|
|
4
4
|
import type { DataProvider } from '../data-interfaces.js';
|
|
5
5
|
import type { RelationOptions, Repository } from './remult3.js';
|
|
6
|
-
export declare function relationInfoMemberInOptions(toEntityType: () => ClassType<any>, type: RelationFieldInfo['type']): FieldOptions
|
|
6
|
+
export declare function relationInfoMemberInOptions(toEntityType: () => ClassType<any>, type: RelationFieldInfo['type']): FieldOptions;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated
|
|
9
9
|
*/
|
|
@@ -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): RelationFieldInfo;
|
|
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;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.relationInfoMemberInOptions = relationInfoMemberInOptions;
|
|
4
|
+
exports.getRelationInfo = getRelationInfo;
|
|
5
|
+
exports.getRelationFieldInfo = getRelationFieldInfo;
|
|
6
|
+
exports.verifyFieldRelationInfo = verifyFieldRelationInfo;
|
|
4
7
|
var tslib_1 = require("tslib");
|
|
5
8
|
var CompoundIdField_js_1 = require("../CompoundIdField.js");
|
|
6
9
|
function relationInfoMemberInOptions(toEntityType, type) {
|
|
@@ -12,7 +15,6 @@ function relationInfoMemberInOptions(toEntityType, type) {
|
|
|
12
15
|
},
|
|
13
16
|
_a;
|
|
14
17
|
}
|
|
15
|
-
exports.relationInfoMemberInOptions = relationInfoMemberInOptions;
|
|
16
18
|
var relationInfoMember = Symbol.for('relationInfo');
|
|
17
19
|
/**
|
|
18
20
|
* @deprecated
|
|
@@ -20,12 +22,10 @@ var relationInfoMember = Symbol.for('relationInfo');
|
|
|
20
22
|
function getRelationInfo(options) {
|
|
21
23
|
return options === null || options === void 0 ? void 0 : options[relationInfoMember];
|
|
22
24
|
}
|
|
23
|
-
exports.getRelationInfo = getRelationInfo;
|
|
24
25
|
var fieldRelationInfo = Symbol.for('fieldRelationInfo');
|
|
25
26
|
function getRelationFieldInfo(field) {
|
|
26
27
|
return field[fieldRelationInfo];
|
|
27
28
|
}
|
|
28
|
-
exports.getRelationFieldInfo = getRelationFieldInfo;
|
|
29
29
|
function verifyFieldRelationInfo(repo, remult, dp) {
|
|
30
30
|
var e_1, _a;
|
|
31
31
|
var _loop_1 = function (field) {
|
|
@@ -147,4 +147,3 @@ function verifyFieldRelationInfo(repo, remult, dp) {
|
|
|
147
147
|
finally { if (e_1) throw e_1.error; }
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
exports.verifyFieldRelationInfo = verifyFieldRelationInfo;
|
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -8,18 +8,18 @@ import type { SortSegment } from '../sort.js';
|
|
|
8
8
|
import type { EntityBase } from './RepositoryImplementation.js';
|
|
9
9
|
export interface EntityRefBase<entityType> extends Subscribable {
|
|
10
10
|
hasErrors(): boolean;
|
|
11
|
-
undoChanges():
|
|
11
|
+
undoChanges(): void;
|
|
12
12
|
save(): Promise<entityType>;
|
|
13
13
|
reload(): Promise<entityType>;
|
|
14
14
|
delete(): Promise<void>;
|
|
15
15
|
isNew(): boolean;
|
|
16
16
|
wasChanged(): boolean;
|
|
17
17
|
wasDeleted(): boolean;
|
|
18
|
-
error: string;
|
|
18
|
+
error: string | undefined;
|
|
19
19
|
getId(): idType<entityType>;
|
|
20
20
|
getOriginalId(): idType<entityType>;
|
|
21
|
-
repository: Repository<
|
|
22
|
-
metadata: EntityMetadata<
|
|
21
|
+
repository: Repository<unknown>;
|
|
22
|
+
metadata: EntityMetadata<unknown>;
|
|
23
23
|
toApiJson(): any;
|
|
24
24
|
validate(): Promise<ErrorInfo<entityType> | undefined>;
|
|
25
25
|
readonly apiUpdateAllowed: boolean;
|
|
@@ -36,8 +36,8 @@ export interface EntityRefForEntityBase<entityType> extends EntityRefBase<entity
|
|
|
36
36
|
fields: FieldsRefForEntityBase<entityType>;
|
|
37
37
|
relations: RepositoryRelationsForEntityBase<entityType>;
|
|
38
38
|
}
|
|
39
|
-
export interface ValidateFieldEvent<entityType =
|
|
40
|
-
error
|
|
39
|
+
export interface ValidateFieldEvent<entityType = unknown, valueType = unknown> {
|
|
40
|
+
error?: string;
|
|
41
41
|
value: valueType;
|
|
42
42
|
originalValue: valueType;
|
|
43
43
|
valueChanged(): boolean;
|
|
@@ -95,7 +95,7 @@ export interface LifecycleEvent<entityType> {
|
|
|
95
95
|
}
|
|
96
96
|
export interface ControllerRefBase<entityType> extends Subscribable {
|
|
97
97
|
hasErrors(): boolean;
|
|
98
|
-
error: string;
|
|
98
|
+
error: string | undefined;
|
|
99
99
|
validate(): Promise<ErrorInfo<entityType> | undefined>;
|
|
100
100
|
readonly isLoading: boolean;
|
|
101
101
|
}
|
|
@@ -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
|
};
|
|
@@ -145,15 +145,15 @@ export interface IdFieldRef<entityType, valueType> extends FieldRef<entityType,
|
|
|
145
145
|
id?: number;
|
|
146
146
|
} ? number : valueType extends {
|
|
147
147
|
id?: string;
|
|
148
|
-
} ? string : string | number):
|
|
148
|
+
} ? string : string | number): void;
|
|
149
149
|
getId(): valueType extends {
|
|
150
150
|
id?: number;
|
|
151
151
|
} ? number : valueType extends {
|
|
152
152
|
id?: string;
|
|
153
153
|
} ? string : string | number;
|
|
154
154
|
}
|
|
155
|
-
export interface FieldRef<entityType =
|
|
156
|
-
error: string;
|
|
155
|
+
export interface FieldRef<entityType = unknown, valueType = unknown> extends Subscribable {
|
|
156
|
+
error: string | undefined;
|
|
157
157
|
displayValue: string;
|
|
158
158
|
value: valueType;
|
|
159
159
|
originalValue: valueType;
|
|
@@ -162,12 +162,15 @@ export interface FieldRef<entityType = any, valueType = any> extends Subscribabl
|
|
|
162
162
|
entityRef: EntityRef<entityType>;
|
|
163
163
|
container: entityType;
|
|
164
164
|
metadata: FieldMetadata<valueType>;
|
|
165
|
+
/**
|
|
166
|
+
* Loads the related value - returns null if the related value is not found
|
|
167
|
+
*/
|
|
165
168
|
load(): Promise<valueType>;
|
|
166
169
|
valueIsNull(): boolean;
|
|
167
170
|
originalValueIsNull(): boolean;
|
|
168
171
|
validate(): Promise<boolean>;
|
|
169
172
|
}
|
|
170
|
-
export interface IdMetadata<entityType =
|
|
173
|
+
export interface IdMetadata<entityType = unknown> {
|
|
171
174
|
/** Extracts the id value of an entity item. Useful in cases where the id column is not called id
|
|
172
175
|
* @example
|
|
173
176
|
* repo.metadata.idMetadata.getId(task)
|
|
@@ -180,7 +183,7 @@ export interface IdMetadata<entityType = any> {
|
|
|
180
183
|
createIdInFilter(items: Partial<MembersOnly<entityType>>[]): EntityFilter<entityType>;
|
|
181
184
|
}
|
|
182
185
|
/** Metadata for an `Entity`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
183
|
-
export interface EntityMetadata<entityType =
|
|
186
|
+
export interface EntityMetadata<entityType = unknown> {
|
|
184
187
|
/** The Entity's key also used as it's url */
|
|
185
188
|
readonly key: string;
|
|
186
189
|
/** Metadata for the Entity's fields */
|
|
@@ -265,16 +268,16 @@ export interface Repository<entityType> {
|
|
|
265
268
|
* @example
|
|
266
269
|
* await taskRepo.findFirst({ completed:false },{ createIfNotFound: true })
|
|
267
270
|
* */
|
|
268
|
-
findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>): Promise<entityType>;
|
|
271
|
+
findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>): Promise<entityType | undefined>;
|
|
269
272
|
/** returns the first item that matchers the `where` condition
|
|
270
273
|
* @example
|
|
271
274
|
* await taskRepo.findOne({ where:{ completed:false }})
|
|
272
275
|
* @example
|
|
273
276
|
* await taskRepo.findFirst({ where:{ completed:false }, createIfNotFound: true })
|
|
274
277
|
* */
|
|
275
|
-
findOne(options?: FindFirstOptions<entityType>): Promise<entityType>;
|
|
276
|
-
/** returns the items that matches the
|
|
277
|
-
findId(id: idType<entityType>, options?: FindFirstOptionsBase<entityType>): Promise<entityType>;
|
|
278
|
+
findOne(options?: FindFirstOptions<entityType>): Promise<entityType | undefined>;
|
|
279
|
+
/** returns the items that matches the id. If id is undefined | null, returns null */
|
|
280
|
+
findId(id: idType<entityType>, options?: FindFirstOptionsBase<entityType>): Promise<entityType | undefined | null>;
|
|
278
281
|
/** An alternative form of fetching data from the API server, which is intended for operating on large numbers of entity objects.
|
|
279
282
|
*
|
|
280
283
|
* It also has it's own paging mechanism that can be used n paging scenarios.
|
package/src/remult3/remult3.js
CHANGED
|
@@ -16,6 +16,21 @@ exports.flags = {
|
|
|
16
16
|
//p1 - replace uuid with crypto.randomUUID and allow custom fallback NO
|
|
17
17
|
//p1 - add nanoid - NO
|
|
18
18
|
//p1 - add id and use luid by default, but allow changes with Fields.id.defaultIdProvider NO but defaultProvider yes
|
|
19
|
+
/*p1
|
|
20
|
+
* field, fieldType ,ValueListFieldType, - return optional parameter for decorators
|
|
21
|
+
* options to remultExpress tc... should be mandatory
|
|
22
|
+
* return value converter to previous typing
|
|
23
|
+
* add breaking change notification about findOne and findFirst and findId
|
|
24
|
+
*/
|
|
25
|
+
//p1 - fix query docs to also explain how it can be used for infinite scroll and pagination.
|
|
26
|
+
//y1 - 'test expression columns without aliases'
|
|
27
|
+
//y1 - ts issue with fields - when a field is optional, it's $ is also optional and thats a problem
|
|
28
|
+
//p1 - vite 5.3 supports ts5 decorators - check and adapt.
|
|
29
|
+
//p1 - see if I can fix the no alias problem in selects
|
|
30
|
+
//p1 - add luid - it's cool for order by.
|
|
31
|
+
//p1 - replace uuid with crypto.randomUUID and allow custom fallback
|
|
32
|
+
//p1 - add nanoid
|
|
33
|
+
//p1 - add id and use luid by default, but allow changes with Fields.id.defaultIdProvider
|
|
19
34
|
//p1 - explain the benefits of changing the default provider for testing in docs.
|
|
20
35
|
//p1 - fix sqlite to support alter table when adding a column with ensure schema = on
|
|
21
36
|
//p1 - fix app custom filters example for multiple filters.
|
|
@@ -7,9 +7,9 @@ export interface RepositoryInternal<entityType> {
|
|
|
7
7
|
_fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<entityType[]>;
|
|
8
8
|
_buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
|
|
9
9
|
_translateWhereToFilter(where: EntityFilter<entityType>): Promise<Filter>;
|
|
10
|
-
_getCachedById(id: any, doNotLoadIfNotFound: boolean): entityType;
|
|
11
|
-
_getCachedByIdAsync(id: any, doNotLoadIfNotFound: boolean): Promise<entityType>;
|
|
12
|
-
_addToCache(item: entityType):
|
|
10
|
+
_getCachedById(id: any, doNotLoadIfNotFound: boolean): entityType | undefined;
|
|
11
|
+
_getCachedByIdAsync(id: any, doNotLoadIfNotFound: boolean): Promise<entityType | undefined>;
|
|
12
|
+
_addToCache(item: entityType): void;
|
|
13
13
|
_getFocusedRelationRepo(field: FieldMetadata, item: any): {
|
|
14
14
|
toRepo: Repository<any>;
|
|
15
15
|
returnNull: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInternalKey =
|
|
3
|
+
exports.getInternalKey = void 0;
|
|
4
|
+
exports.getRepositoryInternals = getRepositoryInternals;
|
|
4
5
|
function getRepositoryInternals(repo) {
|
|
5
6
|
var x = repo;
|
|
6
7
|
if (typeof x[exports.getInternalKey] === 'function')
|
|
7
8
|
return x[exports.getInternalKey]();
|
|
8
9
|
throw Error('Error getting repository internal from ' + repo);
|
|
9
10
|
}
|
|
10
|
-
exports.getRepositoryInternals = getRepositoryInternals;
|
|
11
11
|
exports.getInternalKey = Symbol.for('getInternal');
|
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
|
}
|
|
@@ -74,6 +74,6 @@ export declare function prepareReceivedArgs(types: any[], args: any[], remult: R
|
|
|
74
74
|
export declare const classBackendMethodsArray: unique symbol;
|
|
75
75
|
export interface ActionInterface {
|
|
76
76
|
doWork: (args: any[], self: any, baseUrl?: string, http?: RestDataProviderHttpProvider) => Promise<any>;
|
|
77
|
-
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: (data: any, req: Remult, res: DataApiResponse) => void) => void):
|
|
77
|
+
__register(reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: (data: any, req: Remult, res: DataApiResponse) => void) => void): void;
|
|
78
78
|
}
|
|
79
79
|
export {};
|