remult 0.23.0-exp.2 → 0.23.0-exp.21
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 +26 -27
- package/esm/graphql.js +7 -1
- package/esm/index.d.ts +16 -3
- package/esm/index.js +17 -2
- package/esm/internals.d.ts +2 -1
- package/esm/internals.js +1 -1
- package/esm/remult-express.js +1 -1
- package/esm/remult-knex/index.js +2 -1
- package/esm/remult-mongo.js +2 -1
- package/esm/server/JsonEntityFileStorage.js +1 -1
- package/esm/server/expressBridge.js +1 -1
- package/esm/src/CompoundIdField.d.ts +1 -1
- package/esm/src/CompoundIdField.js +3 -1
- package/esm/src/buildRestDataProvider.d.ts +1 -2
- package/esm/src/column-interfaces.d.ts +19 -7
- package/esm/src/column.d.ts +4 -18
- package/esm/src/column.js +10 -44
- package/esm/src/context.d.ts +1 -1
- package/esm/src/context.js +5 -1
- package/esm/src/data-interfaces.js +1 -2
- package/esm/src/data-providers/array-entity-data-provider.d.ts +1 -1
- package/esm/src/data-providers/array-entity-data-provider.js +6 -6
- package/esm/src/data-providers/sql-database.js +2 -1
- package/esm/src/data-providers/web-sql-data-provider.js +3 -3
- package/esm/src/entity.d.ts +48 -17
- package/esm/src/filter/filter-interfaces.d.ts +2 -16
- package/esm/src/filter/filter-interfaces.js +87 -6
- package/esm/src/live-query/LiveQueryClient.js +2 -1
- package/esm/src/live-query/SubscriptionChannel.js +4 -3
- package/esm/src/remult-proxy.js +10 -2
- package/esm/src/remult3/Fields.d.ts +140 -21
- package/esm/src/remult3/Fields.js +26 -30
- package/esm/src/remult3/RepositoryImplementation.d.ts +10 -16
- package/esm/src/remult3/RepositoryImplementation.js +165 -48
- package/esm/src/remult3/entity.d.ts +1 -1
- package/esm/src/remult3/entity.js +0 -1
- package/esm/src/remult3/getEntityRef.d.ts +1 -1
- package/esm/src/remult3/getEntityRef.js +1 -1
- package/esm/src/remult3/relation-loader.js +4 -1
- package/esm/src/remult3/remult3.d.ts +132 -7
- package/esm/src/remult3/remult3.js +30 -0
- package/esm/src/remult3/repository-internals.d.ts +14 -0
- package/esm/src/remult3/repository-internals.js +7 -0
- package/esm/src/server-action.js +1 -1
- package/esm/src/sort.d.ts +3 -3
- package/esm/src/sort.js +36 -8
- package/graphql.js +10 -2
- package/index.d.ts +16 -3
- package/index.js +19 -3
- package/internals.d.ts +2 -1
- package/internals.js +3 -1
- package/package.json +1 -1
- package/remult-express.js +1 -1
- package/remult-knex/index.js +2 -1
- package/remult-mongo.js +2 -1
- package/server/JsonEntityFileStorage.js +1 -1
- package/server/expressBridge.js +1 -1
- package/src/CompoundIdField.d.ts +1 -1
- package/src/CompoundIdField.js +3 -0
- package/src/buildRestDataProvider.d.ts +1 -2
- package/src/column-interfaces.d.ts +19 -7
- package/src/column.d.ts +4 -18
- package/src/column.js +10 -56
- package/src/context.d.ts +1 -1
- package/src/context.js +5 -1
- package/src/data-interfaces.js +1 -2
- package/src/data-providers/array-entity-data-provider.d.ts +1 -1
- package/src/data-providers/array-entity-data-provider.js +5 -6
- package/src/data-providers/sql-database.js +2 -1
- package/src/data-providers/web-sql-data-provider.js +3 -3
- package/src/entity.d.ts +48 -17
- package/src/filter/filter-interfaces.d.ts +2 -16
- package/src/filter/filter-interfaces.js +101 -9
- package/src/live-query/LiveQueryClient.js +2 -1
- package/src/live-query/SubscriptionChannel.js +4 -3
- package/src/remult-proxy.js +43 -29
- package/src/remult3/Fields.d.ts +140 -21
- package/src/remult3/Fields.js +32 -32
- package/src/remult3/RepositoryImplementation.d.ts +10 -16
- package/src/remult3/RepositoryImplementation.js +286 -163
- package/src/remult3/entity.d.ts +1 -1
- package/src/remult3/entity.js +0 -1
- package/src/remult3/getEntityRef.d.ts +1 -1
- package/src/remult3/getEntityRef.js +2 -1
- package/src/remult3/relation-loader.js +4 -1
- package/src/remult3/remult3.d.ts +132 -7
- package/src/remult3/remult3.js +30 -0
- package/src/remult3/repository-internals.d.ts +14 -0
- package/src/remult3/repository-internals.js +11 -0
- package/src/server-action.js +1 -1
- package/src/sort.d.ts +3 -3
- package/src/sort.js +43 -11
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createId } from '@paralleldrive/cuid2';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
3
|
import { ValueConverters } from '../valueConverters';
|
|
4
|
-
import {
|
|
5
|
-
import { buildOptions, columnsOfType, } from './RepositoryImplementation';
|
|
4
|
+
import { buildOptions, columnsOfType } from './RepositoryImplementation';
|
|
6
5
|
import { relationInfoMember } from './relationInfoMember';
|
|
7
6
|
export class Fields {
|
|
8
7
|
/**
|
|
@@ -47,8 +46,8 @@ export class Fields {
|
|
|
47
46
|
static createdAt(...options) {
|
|
48
47
|
return Field(() => Date, {
|
|
49
48
|
allowApiUpdate: false,
|
|
50
|
-
saving: (_, ref) => {
|
|
51
|
-
if (
|
|
49
|
+
saving: (_, { isNew }, ref) => {
|
|
50
|
+
if (isNew)
|
|
52
51
|
ref.value = new Date();
|
|
53
52
|
},
|
|
54
53
|
}, ...options);
|
|
@@ -56,7 +55,7 @@ export class Fields {
|
|
|
56
55
|
static updatedAt(...options) {
|
|
57
56
|
return Field(() => Date, {
|
|
58
57
|
allowApiUpdate: false,
|
|
59
|
-
saving: (_, ref) => {
|
|
58
|
+
saving: (_, _1, ref) => {
|
|
60
59
|
ref.value = new Date();
|
|
61
60
|
},
|
|
62
61
|
}, ...options);
|
|
@@ -65,7 +64,7 @@ export class Fields {
|
|
|
65
64
|
return Field(() => String, {
|
|
66
65
|
allowApiUpdate: false,
|
|
67
66
|
defaultValue: () => uuid(),
|
|
68
|
-
saving: (_, r) => {
|
|
67
|
+
saving: (_, _1, r) => {
|
|
69
68
|
if (!r.value)
|
|
70
69
|
r.value = uuid();
|
|
71
70
|
},
|
|
@@ -75,7 +74,7 @@ export class Fields {
|
|
|
75
74
|
return Field(() => String, {
|
|
76
75
|
allowApiUpdate: false,
|
|
77
76
|
defaultValue: () => createId(),
|
|
78
|
-
saving: (_, r) => {
|
|
77
|
+
saving: (_, _1, r) => {
|
|
79
78
|
if (!r.value)
|
|
80
79
|
r.value = createId();
|
|
81
80
|
},
|
|
@@ -87,25 +86,24 @@ export class Fields {
|
|
|
87
86
|
static boolean(...options) {
|
|
88
87
|
return Field(() => Boolean, ...options);
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
? {}
|
|
94
|
-
: options);
|
|
95
|
-
return Field(toEntityType, {
|
|
96
|
-
...op,
|
|
97
|
-
//@ts-ignore
|
|
98
|
-
[relationInfoMember]: {
|
|
99
|
-
//field,
|
|
100
|
-
toType: toEntityType,
|
|
101
|
-
type: 'reference',
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
static many(toEntityType, options) {
|
|
89
|
+
}
|
|
90
|
+
export class Relations {
|
|
91
|
+
static toOne(toEntityType, options) {
|
|
106
92
|
let op = (typeof options === 'string'
|
|
107
93
|
? { field: options }
|
|
108
|
-
: options
|
|
94
|
+
: !options
|
|
95
|
+
? {}
|
|
96
|
+
: options);
|
|
97
|
+
if (!op.field && !op.fields && !op.findOptions)
|
|
98
|
+
return Field(toEntityType, {
|
|
99
|
+
...op,
|
|
100
|
+
//@ts-ignore
|
|
101
|
+
[relationInfoMember]: {
|
|
102
|
+
//field,
|
|
103
|
+
toType: toEntityType,
|
|
104
|
+
type: 'reference',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
109
107
|
return Field(() => undefined, {
|
|
110
108
|
...op,
|
|
111
109
|
serverExpression: () => undefined,
|
|
@@ -113,16 +111,14 @@ export class Fields {
|
|
|
113
111
|
[relationInfoMember]: {
|
|
114
112
|
//field,
|
|
115
113
|
toType: toEntityType,
|
|
116
|
-
type: '
|
|
114
|
+
type: 'toOne',
|
|
117
115
|
},
|
|
118
116
|
});
|
|
119
117
|
}
|
|
120
|
-
static
|
|
118
|
+
static toMany(toEntityType, options) {
|
|
121
119
|
let op = (typeof options === 'string'
|
|
122
120
|
? { field: options }
|
|
123
|
-
:
|
|
124
|
-
? {}
|
|
125
|
-
: options);
|
|
121
|
+
: options);
|
|
126
122
|
return Field(() => undefined, {
|
|
127
123
|
...op,
|
|
128
124
|
serverExpression: () => undefined,
|
|
@@ -130,7 +126,7 @@ export class Fields {
|
|
|
130
126
|
[relationInfoMember]: {
|
|
131
127
|
//field,
|
|
132
128
|
toType: toEntityType,
|
|
133
|
-
type: '
|
|
129
|
+
type: 'toMany',
|
|
134
130
|
},
|
|
135
131
|
});
|
|
136
132
|
}
|
|
@@ -10,12 +10,14 @@ import type { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, E
|
|
|
10
10
|
import type { Unsubscribe } from '../live-query/SubscriptionChannel';
|
|
11
11
|
import type { columnInfo } from './columnInfo';
|
|
12
12
|
import { RelationLoader } from './relation-loader';
|
|
13
|
+
import { getInternalKey } from './repository-internals';
|
|
13
14
|
export declare class RepositoryImplementation<entityType> implements Repository<entityType> {
|
|
14
15
|
private entity;
|
|
15
16
|
remult: Remult;
|
|
16
17
|
private dataProvider;
|
|
17
18
|
private _info;
|
|
18
19
|
private defaultFindOptions?;
|
|
20
|
+
[getInternalKey](): this;
|
|
19
21
|
createAfterFilter(orderBy: EntityOrderBy<entityType>, lastRow: entityType): Promise<EntityFilter<entityType>>;
|
|
20
22
|
relations(item: entityType): RepositoryRelations<entityType>;
|
|
21
23
|
private __edp;
|
|
@@ -50,10 +52,10 @@ export declare class RepositoryImplementation<entityType> implements Repository<
|
|
|
50
52
|
save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
|
|
51
53
|
save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
|
|
52
54
|
liveQuery(options?: FindOptions<entityType>): LiveQuery<entityType>;
|
|
53
|
-
rawFind(options: FindOptions<entityType>, skipOrderByAndLimit: boolean, loader: RelationLoader): Promise<
|
|
55
|
+
rawFind(options: FindOptions<entityType>, skipOrderByAndLimit: boolean, loader: RelationLoader): Promise<entityType[]>;
|
|
54
56
|
find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
|
|
55
57
|
buildEntityDataProviderFindOptions(options: FindOptions<entityType>): Promise<EntityDataProviderFindOptions>;
|
|
56
|
-
fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<
|
|
58
|
+
fromJsonArray(jsonItems: any[], loadOptions: LoadOptions<entityType>): Promise<entityType[]>;
|
|
57
59
|
private loadManyToOneForManyRows;
|
|
58
60
|
private mapRawDataToResult;
|
|
59
61
|
toJson(item: entityType | entityType[] | Promise<entityType> | Promise<entityType[]>): any;
|
|
@@ -73,10 +75,11 @@ declare abstract class rowHelperBase<T> {
|
|
|
73
75
|
protected columnsInfo: FieldOptions[];
|
|
74
76
|
protected instance: T;
|
|
75
77
|
protected remult: Remult;
|
|
78
|
+
protected isNewRow: boolean;
|
|
76
79
|
_error: string;
|
|
77
80
|
get error(): string;
|
|
78
81
|
set error(val: string);
|
|
79
|
-
constructor(columnsInfo: FieldOptions[], instance: T, remult: Remult);
|
|
82
|
+
constructor(columnsInfo: FieldOptions[], instance: T, remult: Remult, isNewRow: boolean);
|
|
80
83
|
_subscribers: SubscribableImp;
|
|
81
84
|
subscribe(listener: RefSubscriber): Unsubscribe;
|
|
82
85
|
_isLoading: boolean;
|
|
@@ -103,7 +106,7 @@ declare abstract class rowHelperBase<T> {
|
|
|
103
106
|
__validateEntity(): Promise<void>;
|
|
104
107
|
__performColumnAndEntityValidations(): Promise<void>;
|
|
105
108
|
toApiJson(includeRelatedEntities?: boolean): any;
|
|
106
|
-
_updateEntityBasedOnApi(body: any): Promise<void>;
|
|
109
|
+
_updateEntityBasedOnApi(body: any, ignoreApiAllowed?: boolean): Promise<void>;
|
|
107
110
|
}
|
|
108
111
|
export declare class rowHelperImplementation<T> extends rowHelperBase<T> implements EntityRef<T> {
|
|
109
112
|
private info;
|
|
@@ -111,6 +114,7 @@ export declare class rowHelperImplementation<T> extends rowHelperBase<T> impleme
|
|
|
111
114
|
private edp;
|
|
112
115
|
private _isNew;
|
|
113
116
|
constructor(info: EntityFullInfo<T>, instance: T, repository: RepositoryImplementation<T>, edp: EntityDataProvider, remult: Remult, _isNew: boolean);
|
|
117
|
+
get relations(): RepositoryRelations<T>;
|
|
114
118
|
get apiUpdateAllowed(): boolean;
|
|
115
119
|
get apiDeleteAllowed(): boolean;
|
|
116
120
|
get apiInsertAllowed(): boolean;
|
|
@@ -125,6 +129,7 @@ export declare class rowHelperImplementation<T> extends rowHelperBase<T> impleme
|
|
|
125
129
|
get fields(): FieldsRef<T>;
|
|
126
130
|
private _saving;
|
|
127
131
|
save(onlyTheseFieldsSentOnlyInTheCaseOfProxySaveWithPartialObject?: string[]): Promise<T>;
|
|
132
|
+
private buildLifeCycleEvent;
|
|
128
133
|
private getIdFilter;
|
|
129
134
|
delete(): Promise<void>;
|
|
130
135
|
loadDataFrom(data: any, loadItems?: FieldMetadata[]): Promise<void>;
|
|
@@ -185,7 +190,7 @@ export declare class columnDefsImpl implements FieldMetadata {
|
|
|
185
190
|
constructor(settings: FieldOptions, entityDefs: EntityFullInfo<any>, remult: Remult);
|
|
186
191
|
apiUpdateAllowed(item?: any): boolean;
|
|
187
192
|
displayValue(item: any): string;
|
|
188
|
-
|
|
193
|
+
includedInApi(item?: any): boolean;
|
|
189
194
|
toInput(value: any, inputType?: string): string;
|
|
190
195
|
fromInput(inputValue: string, inputType?: string): any;
|
|
191
196
|
getDbName(): Promise<string>;
|
|
@@ -250,17 +255,6 @@ export declare class ValueListInfo<T extends ValueListItem> implements ValueConv
|
|
|
250
255
|
export declare function getValueList<T>(field: FieldRef<T>): T[];
|
|
251
256
|
export declare function getValueList<T>(field: FieldMetadata<T>): T[];
|
|
252
257
|
export declare function getValueList<T>(type: ClassType<T>): T[];
|
|
253
|
-
export interface ClassFieldDecoratorContextStub<entityType, valueType> {
|
|
254
|
-
readonly access: {
|
|
255
|
-
set(object: entityType, value: valueType): void;
|
|
256
|
-
};
|
|
257
|
-
readonly name: string;
|
|
258
|
-
}
|
|
259
|
-
export interface ClassDecoratorContextStub<Class extends new (...args: any) => any = new (...args: any) => any> {
|
|
260
|
-
readonly kind: 'class';
|
|
261
|
-
readonly name: string | undefined;
|
|
262
|
-
addInitializer(initializer: (this: Class) => void): void;
|
|
263
|
-
}
|
|
264
258
|
export declare const storableMember: unique symbol;
|
|
265
259
|
export declare function buildOptions<entityType = any, valueType = any>(options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[], remult: Remult): FieldOptions<entityType, valueType>;
|
|
266
260
|
export declare function decorateColumnSettings<valueType>(settings: FieldOptions<any, valueType>, remult: Remult): FieldOptions<any, valueType>;
|