remult 0.23.0-exp.31 → 0.23.0-exp.33
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/index.d.ts +1 -1
- package/esm/remult-hapi.d.ts +6 -0
- package/esm/remult-hapi.js +112 -0
- package/esm/server/expressBridge.js +1 -2
- package/esm/src/column-interfaces.d.ts +1 -1
- package/esm/src/context.js +1 -3
- package/esm/src/data-interfaces.d.ts +2 -2
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +2 -2
- package/esm/src/remult3/Fields.js +4 -4
- package/esm/src/remult3/RepositoryImplementation.js +30 -8
- package/esm/src/remult3/remult3.d.ts +20 -17
- package/esm/src/remult3/remult3.js +17 -17
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/remult-hapi.d.ts +6 -0
- package/remult-hapi.js +124 -0
- package/server/expressBridge.js +1 -2
- package/src/column-interfaces.d.ts +1 -1
- package/src/context.js +1 -3
- package/src/data-interfaces.d.ts +2 -2
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +2 -2
- package/src/remult3/Fields.js +4 -4
- package/src/remult3/RepositoryImplementation.js +44 -21
- package/src/remult3/remult3.d.ts +20 -17
- package/src/remult3/remult3.js +17 -17
package/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClassType } from './classType';
|
|
2
|
-
export { OmitEB, FieldsMetadata, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, EntityRef, SortSegments, Paginator, LiveQuery, LiveQueryChangeInfo, Subscribable, RefSubscriber, RefSubscriberBase, RelationOptions, ObjectMembersOnly, MembersToInclude, RepositoryRelations, EntityIdFields, ClassFieldDecorator, ClassFieldDecoratorContextStub, //n1 consider removing in ts5
|
|
2
|
+
export { OmitEB, OmitFunctions, FieldsMetadata, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, EntityRef, SortSegments, Paginator, LiveQuery, LiveQueryChangeInfo, Subscribable, RefSubscriber, RefSubscriberBase, RelationOptions, ObjectMembersOnly, MembersToInclude, RepositoryRelations, EntityIdFields, ClassFieldDecorator, ClassFieldDecoratorContextStub, //n1 consider removing in ts5
|
|
3
3
|
LifecycleEvent, } from './src/remult3/remult3';
|
|
4
4
|
export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, CaptionTransformer, } from './src/remult3/RepositoryImplementation';
|
|
5
5
|
export { Entity } from './src/remult3/entity';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Request, Plugin } from '@hapi/hapi';
|
|
2
|
+
import { type RemultServerCore, type RemultServerOptions } from './server';
|
|
3
|
+
export declare function remultHapi(options: RemultServerOptions<Request>): RemultHapiServer;
|
|
4
|
+
export type RemultHapiServer = Plugin<any, any> & RemultServerCore<Request> & {
|
|
5
|
+
withRemult<T>(req: Request, what: () => Promise<T>): Promise<T>;
|
|
6
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createRemultServer, } from './server';
|
|
2
|
+
import { PassThrough } from 'stream';
|
|
3
|
+
export function remultHapi(options) {
|
|
4
|
+
const api = createRemultServer(options, {
|
|
5
|
+
buildGenericRequestInfo: (req) => ({
|
|
6
|
+
method: req.method,
|
|
7
|
+
params: req.params,
|
|
8
|
+
query: req.query,
|
|
9
|
+
url: req.url.pathname,
|
|
10
|
+
on: (e, do1) => {
|
|
11
|
+
req.raw.req.on('close', do1);
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
getRequestBody: async (req) => req.payload,
|
|
15
|
+
});
|
|
16
|
+
const routesPlugin = {
|
|
17
|
+
name: 'remultPlugin',
|
|
18
|
+
register: async (server) => {
|
|
19
|
+
function hapiHandler(handler) {
|
|
20
|
+
return (request, h) => {
|
|
21
|
+
return new Promise((res, rej) => {
|
|
22
|
+
let status = 200;
|
|
23
|
+
let stream;
|
|
24
|
+
let r = {
|
|
25
|
+
status(statusCode) {
|
|
26
|
+
status = statusCode;
|
|
27
|
+
console.log(statusCode);
|
|
28
|
+
return r;
|
|
29
|
+
},
|
|
30
|
+
end() {
|
|
31
|
+
res(h.response().code(status));
|
|
32
|
+
},
|
|
33
|
+
json(data) {
|
|
34
|
+
res(h.response(data).code(status));
|
|
35
|
+
},
|
|
36
|
+
write(data) {
|
|
37
|
+
stream.write(data);
|
|
38
|
+
},
|
|
39
|
+
writeHead(status, headers) {
|
|
40
|
+
stream = new PassThrough();
|
|
41
|
+
res(h
|
|
42
|
+
.response(stream)
|
|
43
|
+
.header('content-type', 'text/event-stream')
|
|
44
|
+
.header('content-encoding', 'identity'));
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
Object.assign(request, {
|
|
49
|
+
on(event, listener) {
|
|
50
|
+
request.raw.req.on('close', () => {
|
|
51
|
+
listener();
|
|
52
|
+
console.log('Connection closed');
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
handler(request, r, () => { });
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
rej(err);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
let hapiRouter = {
|
|
65
|
+
route(path) {
|
|
66
|
+
path = path.replace(/:id\b/g, '{id}');
|
|
67
|
+
let r = {
|
|
68
|
+
get(handler) {
|
|
69
|
+
server.route({
|
|
70
|
+
method: 'GET',
|
|
71
|
+
path,
|
|
72
|
+
handler: hapiHandler(handler),
|
|
73
|
+
});
|
|
74
|
+
return r;
|
|
75
|
+
},
|
|
76
|
+
post(handler) {
|
|
77
|
+
server.route({
|
|
78
|
+
method: 'POST',
|
|
79
|
+
path,
|
|
80
|
+
handler: hapiHandler(handler),
|
|
81
|
+
});
|
|
82
|
+
return r;
|
|
83
|
+
},
|
|
84
|
+
put(handler) {
|
|
85
|
+
server.route({
|
|
86
|
+
method: 'PUT',
|
|
87
|
+
path,
|
|
88
|
+
handler: hapiHandler(handler),
|
|
89
|
+
});
|
|
90
|
+
return r;
|
|
91
|
+
},
|
|
92
|
+
delete(handler) {
|
|
93
|
+
server.route({
|
|
94
|
+
method: 'DELETE',
|
|
95
|
+
path,
|
|
96
|
+
handler: hapiHandler(handler),
|
|
97
|
+
});
|
|
98
|
+
return r;
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
return r;
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
api.registerRouter(hapiRouter);
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
return Object.assign(routesPlugin, {
|
|
108
|
+
getRemult: (x) => api.getRemult(x),
|
|
109
|
+
openApiDoc: (x) => api.openApiDoc(x),
|
|
110
|
+
withRemult: (req, what) => api.withRemultPromise(req, what),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -763,7 +763,7 @@ export class EntityQueueStorage {
|
|
|
763
763
|
return (this.sync = this.sync.then(() => what()));
|
|
764
764
|
}
|
|
765
765
|
async getJobInfo(queuedJobId) {
|
|
766
|
-
let q = await this.repo.findId(queuedJobId
|
|
766
|
+
let q = await this.repo.findId(queuedJobId);
|
|
767
767
|
let lastProgress = undefined;
|
|
768
768
|
return {
|
|
769
769
|
userId: q.userId,
|
|
@@ -992,4 +992,3 @@ JobsInQueueEntity = __decorate([
|
|
|
992
992
|
], JobsInQueueEntity);
|
|
993
993
|
export { JobsInQueueEntity };
|
|
994
994
|
allEntities.splice(allEntities.indexOf(JobsInQueueEntity), 1);
|
|
995
|
-
//p1 - implement dbname based on related field https://codesandbox.io/p/sandbox/fervent-yalow-66m78n?file=%2Fsrc%2Findex.ts%3A35%2C93
|
|
@@ -37,7 +37,7 @@ export interface FieldOptions<entityType = any, valueType = any> {
|
|
|
37
37
|
*/
|
|
38
38
|
validate?: ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => any | Promise<any>) | ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => any | Promise<any>)[];
|
|
39
39
|
/** Will be fired before this field is saved to the server/database */
|
|
40
|
-
saving?: (entity: entityType,
|
|
40
|
+
saving?: (entity: entityType, fieldRef: FieldRef<entityType, valueType>, e: LifecycleEvent<entityType>) => any | Promise<any>;
|
|
41
41
|
/** An expression that will determine this fields value on the backend and be provided to the front end*/
|
|
42
42
|
serverExpression?: (entity: entityType) => valueType | Promise<valueType>;
|
|
43
43
|
/** The name of the column in the database that holds the data for this field. If no name is set, the key will be used instead.
|
package/esm/src/context.js
CHANGED
|
@@ -286,7 +286,5 @@ class transactionLiveQueryPublisher {
|
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
//
|
|
290
|
-
//p1 - reconsider the case in tremping where create user id was updated with some user and not the actual user
|
|
291
|
-
//[ ] - when value changes for field with error, clear error - so the user will feel comfortable
|
|
289
|
+
//p2 - when value changes for field with error, clear error - so the user will feel comfortable
|
|
292
290
|
//y2 - require filter argument - and perform validation checks for it - site, id etc.. changelog, status changes etc...,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Filter } from './filter/filter-interfaces';
|
|
2
|
-
import type { EntityMetadata, OmitEB } from './remult3/remult3';
|
|
2
|
+
import type { EntityMetadata, OmitEB, OmitFunctions } from './remult3/remult3';
|
|
3
3
|
import { Sort } from './sort';
|
|
4
4
|
export interface DataProvider {
|
|
5
5
|
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
|
|
@@ -33,7 +33,7 @@ export declare function extractSort(sort: any): Sort;
|
|
|
33
33
|
export interface ErrorInfo<entityType = any> {
|
|
34
34
|
message?: string;
|
|
35
35
|
modelState?: {
|
|
36
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
36
|
+
[Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: string;
|
|
37
37
|
};
|
|
38
38
|
stack?: string;
|
|
39
39
|
exception?: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldMetadata } from '../column-interfaces';
|
|
2
2
|
import type { EntityMetadataOverloads, RepositoryOverloads } from '../remult3/RepositoryImplementation';
|
|
3
|
-
import type { EntityFilter, OmitEB } from '../remult3/remult3';
|
|
3
|
+
import type { EntityFilter, OmitEB, OmitFunctions } from '../remult3/remult3';
|
|
4
4
|
import type { SqlCommandWithParameters } from '../sql-command';
|
|
5
5
|
import type { Filter, FilterConsumer } from './filter-interfaces';
|
|
6
6
|
export declare class FilterConsumerBridgeToSqlRequest implements FilterConsumer {
|
|
@@ -45,6 +45,6 @@ export declare type EntityDbNamesBase = {
|
|
|
45
45
|
toString(): string;
|
|
46
46
|
};
|
|
47
47
|
export declare type EntityDbNames<entityType> = {
|
|
48
|
-
[Properties in keyof Required<OmitEB<entityType
|
|
48
|
+
[Properties in keyof Required<OmitFunctions<OmitEB<entityType>>>]: string;
|
|
49
49
|
} & EntityDbNamesBase;
|
|
50
50
|
export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>): Promise<EntityDbNames<entityType>>;
|
|
@@ -46,7 +46,7 @@ export class Fields {
|
|
|
46
46
|
static createdAt(...options) {
|
|
47
47
|
return Field(() => Date, {
|
|
48
48
|
allowApiUpdate: false,
|
|
49
|
-
saving: (_, { isNew }
|
|
49
|
+
saving: (_, ref, { isNew }) => {
|
|
50
50
|
if (isNew)
|
|
51
51
|
ref.value = new Date();
|
|
52
52
|
},
|
|
@@ -55,7 +55,7 @@ export class Fields {
|
|
|
55
55
|
static updatedAt(...options) {
|
|
56
56
|
return Field(() => Date, {
|
|
57
57
|
allowApiUpdate: false,
|
|
58
|
-
saving: (_,
|
|
58
|
+
saving: (_, ref) => {
|
|
59
59
|
ref.value = new Date();
|
|
60
60
|
},
|
|
61
61
|
}, ...options);
|
|
@@ -64,7 +64,7 @@ export class Fields {
|
|
|
64
64
|
return Field(() => String, {
|
|
65
65
|
allowApiUpdate: false,
|
|
66
66
|
defaultValue: () => uuid(),
|
|
67
|
-
saving: (_,
|
|
67
|
+
saving: (_, r) => {
|
|
68
68
|
if (!r.value)
|
|
69
69
|
r.value = uuid();
|
|
70
70
|
},
|
|
@@ -74,7 +74,7 @@ export class Fields {
|
|
|
74
74
|
return Field(() => String, {
|
|
75
75
|
allowApiUpdate: false,
|
|
76
76
|
defaultValue: () => createId(),
|
|
77
|
-
saving: (_,
|
|
77
|
+
saving: (_, r) => {
|
|
78
78
|
if (!r.value)
|
|
79
79
|
r.value = createId();
|
|
80
80
|
},
|
|
@@ -81,13 +81,17 @@ export class RepositoryImplementation {
|
|
|
81
81
|
if (!rel)
|
|
82
82
|
throw Error(key + ' is not a relation');
|
|
83
83
|
let repo = this.remult.repo(rel.toType());
|
|
84
|
-
let { findOptions } = this.findOptionsBasedOnRelation(rel, field, undefined, item, repo);
|
|
84
|
+
let { findOptions, returnNull, returnUndefined } = this.findOptionsBasedOnRelation(rel, field, undefined, item, repo);
|
|
85
85
|
const toRepo = new RepositoryImplementation(repo.entity, repo.remult, repo.dataProvider, repo._info, findOptions);
|
|
86
86
|
if (rel.type === 'toMany')
|
|
87
87
|
return toRepo;
|
|
88
88
|
else
|
|
89
89
|
return {
|
|
90
90
|
findOne: (options) => {
|
|
91
|
+
if (returnNull)
|
|
92
|
+
return Promise.resolve(null);
|
|
93
|
+
if (returnUndefined)
|
|
94
|
+
return Promise.resolve(undefined);
|
|
91
95
|
return toRepo.findFirst({}, options);
|
|
92
96
|
},
|
|
93
97
|
};
|
|
@@ -439,6 +443,8 @@ export class RepositoryImplementation {
|
|
|
439
443
|
metadata: toRepo.metadata,
|
|
440
444
|
}, findOptions)
|
|
441
445
|
.then((result) => {
|
|
446
|
+
if (result.length == 0 && rel.type == 'toOne')
|
|
447
|
+
return;
|
|
442
448
|
row[col.key] =
|
|
443
449
|
rel.type !== 'toMany'
|
|
444
450
|
? result.length == 0
|
|
@@ -455,6 +461,7 @@ export class RepositoryImplementation {
|
|
|
455
461
|
/*@internal */
|
|
456
462
|
findOptionsBasedOnRelation(rel, field, moreFindOptions, row, otherRepo) {
|
|
457
463
|
let returnNull = false;
|
|
464
|
+
let returnUndefined = false;
|
|
458
465
|
let where = [];
|
|
459
466
|
let findOptions = {};
|
|
460
467
|
let findOptionsSources = [];
|
|
@@ -527,6 +534,8 @@ export class RepositoryImplementation {
|
|
|
527
534
|
const val = row[options.field];
|
|
528
535
|
if (val === null)
|
|
529
536
|
returnNull = true;
|
|
537
|
+
if (val === undefined)
|
|
538
|
+
returnUndefined = true;
|
|
530
539
|
else
|
|
531
540
|
where.push(otherRepo.metadata.idMetadata.getIdFilter(val));
|
|
532
541
|
}
|
|
@@ -552,6 +561,8 @@ export class RepositoryImplementation {
|
|
|
552
561
|
: row[field.key];
|
|
553
562
|
if (val === null)
|
|
554
563
|
returnNull = true;
|
|
564
|
+
if (val === undefined)
|
|
565
|
+
returnUndefined = true;
|
|
555
566
|
else if (typeof val === 'object')
|
|
556
567
|
where.push(otherRepo.metadata.idMetadata.getIdFilter(otherRepo.metadata.idMetadata.getId(val)));
|
|
557
568
|
else
|
|
@@ -562,7 +573,7 @@ export class RepositoryImplementation {
|
|
|
562
573
|
findOptions.orderBy // I deduce from this that there may be more than one row and we want only the first
|
|
563
574
|
)
|
|
564
575
|
findOptions.limit = 1;
|
|
565
|
-
return { findOptions, returnNull };
|
|
576
|
+
return { findOptions, returnNull, returnUndefined };
|
|
566
577
|
}
|
|
567
578
|
async mapRawDataToResult(r, loadFields) {
|
|
568
579
|
if (!r)
|
|
@@ -723,7 +734,6 @@ export class RepositoryImplementation {
|
|
|
723
734
|
if (typeof id !== 'string' && typeof id !== 'number')
|
|
724
735
|
throw new Error('id can be either number or string, but got: ' + typeof id);
|
|
725
736
|
return this.findFirst({}, {
|
|
726
|
-
useCache: true,
|
|
727
737
|
...options,
|
|
728
738
|
where: this.metadata.idMetadata.getIdFilter(id),
|
|
729
739
|
}, true);
|
|
@@ -1199,7 +1209,7 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1199
1209
|
if (!this.remult.dataProvider.isProxy) {
|
|
1200
1210
|
for (const col of this.fields) {
|
|
1201
1211
|
if (col.metadata.options.saving)
|
|
1202
|
-
await col.metadata.options.saving(this.instance,
|
|
1212
|
+
await col.metadata.options.saving(this.instance, col, e);
|
|
1203
1213
|
}
|
|
1204
1214
|
if (this.info.entityInfo.saving) {
|
|
1205
1215
|
await this.info.entityInfo.saving(this.instance, e);
|
|
@@ -1355,8 +1365,10 @@ export class rowHelperImplementation extends rowHelperBase {
|
|
|
1355
1365
|
wasChanged() {
|
|
1356
1366
|
this._subscribers?.reportObserved();
|
|
1357
1367
|
for (const col of this.fields) {
|
|
1358
|
-
|
|
1359
|
-
|
|
1368
|
+
const rel = getRelationInfo(col.metadata.options);
|
|
1369
|
+
if (!rel || rel.type == 'reference')
|
|
1370
|
+
if (col.valueChanged())
|
|
1371
|
+
return true;
|
|
1360
1372
|
}
|
|
1361
1373
|
return false;
|
|
1362
1374
|
}
|
|
@@ -1472,8 +1484,10 @@ export class FieldRefImplementation {
|
|
|
1472
1484
|
.relations(this.container)[this.metadata.key].find());
|
|
1473
1485
|
}
|
|
1474
1486
|
else {
|
|
1475
|
-
|
|
1476
|
-
.relations(this.container)[this.metadata.key].findOne()
|
|
1487
|
+
let val = await this.helper.repository
|
|
1488
|
+
.relations(this.container)[this.metadata.key].findOne();
|
|
1489
|
+
if (val)
|
|
1490
|
+
this.container[this.metadata.key] = val;
|
|
1477
1491
|
}
|
|
1478
1492
|
}
|
|
1479
1493
|
else if (lu) {
|
|
@@ -1665,6 +1679,14 @@ export class columnDefsImpl {
|
|
|
1665
1679
|
return this.settings.dbName;
|
|
1666
1680
|
return result;
|
|
1667
1681
|
}
|
|
1682
|
+
const rel = getRelationInfo(this.settings);
|
|
1683
|
+
let field = rel?.type === 'toOne' &&
|
|
1684
|
+
this.settings.field;
|
|
1685
|
+
if (field) {
|
|
1686
|
+
let fInfo = this.entityDefs.fields.find(field);
|
|
1687
|
+
if (fInfo)
|
|
1688
|
+
return fInfo.getDbName();
|
|
1689
|
+
}
|
|
1668
1690
|
return this.settings.dbName;
|
|
1669
1691
|
}
|
|
1670
1692
|
finally {
|
|
@@ -89,7 +89,7 @@ export interface Subscribable {
|
|
|
89
89
|
subscribe(listener: RefSubscriber): Unsubscribe;
|
|
90
90
|
}
|
|
91
91
|
export type FieldsRef<entityType> = {
|
|
92
|
-
[Properties in keyof OmitEB<entityType
|
|
92
|
+
[Properties in keyof OmitFunctions<OmitEB<entityType>>]: NonNullable<entityType[Properties]> extends {
|
|
93
93
|
id?: number | string;
|
|
94
94
|
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
95
95
|
} & {
|
|
@@ -98,7 +98,7 @@ export type FieldsRef<entityType> = {
|
|
|
98
98
|
toArray(): FieldRef<entityType, any>[];
|
|
99
99
|
};
|
|
100
100
|
export type FieldsMetadata<entityType> = {
|
|
101
|
-
[Properties in keyof OmitEB<entityType
|
|
101
|
+
[Properties in keyof OmitFunctions<OmitEB<entityType>>]: FieldMetadata<entityType[Properties], entityType>;
|
|
102
102
|
} & {
|
|
103
103
|
find(fieldMetadataOrKey: FieldMetadata | string): FieldMetadata<any, entityType>;
|
|
104
104
|
[Symbol.iterator]: () => IterableIterator<FieldMetadata<any, entityType>>;
|
|
@@ -141,11 +141,11 @@ export interface IdMetadata<entityType = any> {
|
|
|
141
141
|
* @example
|
|
142
142
|
* repo.metadata.idMetadata.getId(task)
|
|
143
143
|
*/
|
|
144
|
-
getId(item: Partial<OmitEB<entityType
|
|
144
|
+
getId(item: Partial<OmitFunctions<OmitEB<entityType>>>): any;
|
|
145
145
|
field: FieldMetadata<any>;
|
|
146
146
|
getIdFilter(...ids: any[]): EntityFilter<entityType>;
|
|
147
147
|
isIdField(col: FieldMetadata): boolean;
|
|
148
|
-
createIdInFilter(items: Partial<OmitEB<entityType
|
|
148
|
+
createIdInFilter(items: Partial<OmitFunctions<OmitEB<entityType>>>[]): EntityFilter<entityType>;
|
|
149
149
|
}
|
|
150
150
|
/** Metadata for an `Entity`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
151
151
|
export interface EntityMetadata<entityType = any> {
|
|
@@ -200,6 +200,9 @@ export interface EntityMetadata<entityType = any> {
|
|
|
200
200
|
readonly idMetadata: IdMetadata<entityType>;
|
|
201
201
|
}
|
|
202
202
|
export declare type OmitEB<T> = Omit<T, keyof EntityBase>;
|
|
203
|
+
export type OmitFunctions<T> = Pick<T, {
|
|
204
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
205
|
+
}[keyof T]>;
|
|
203
206
|
export declare type idType<entityType> = entityType extends {
|
|
204
207
|
id?: number;
|
|
205
208
|
} ? number : entityType extends {
|
|
@@ -248,21 +251,21 @@ export interface Repository<entityType> {
|
|
|
248
251
|
* // Can also be used to validate specific fields
|
|
249
252
|
* const error = repo.validate(task,"title")
|
|
250
253
|
*/
|
|
251
|
-
validate(item: Partial<entityType>, ...fields: Extract<keyof OmitEB<entityType
|
|
254
|
+
validate(item: Partial<entityType>, ...fields: Extract<keyof OmitFunctions<OmitEB<entityType>>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
|
|
252
255
|
/** saves an item or item[] to the data source. It assumes that if an `id` value exists, it's an existing row - otherwise it's a new row
|
|
253
256
|
* @example
|
|
254
257
|
* await taskRepo.save({...task, completed:true })
|
|
255
258
|
*/
|
|
256
|
-
save(item: Partial<OmitEB<entityType
|
|
257
|
-
save(item: Partial<OmitEB<entityType
|
|
259
|
+
save(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
|
|
260
|
+
save(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
258
261
|
/**Insert an item or item[] to the data source
|
|
259
262
|
* @example
|
|
260
263
|
* await taskRepo.insert({title:"task a"})
|
|
261
264
|
* @example
|
|
262
265
|
* await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
|
|
263
266
|
*/
|
|
264
|
-
insert(item: Partial<OmitEB<entityType
|
|
265
|
-
insert(item: Partial<OmitEB<entityType
|
|
267
|
+
insert(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
|
|
268
|
+
insert(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
266
269
|
/** Updates an item, based on its `id`
|
|
267
270
|
* @example
|
|
268
271
|
* taskRepo.update(task.id,{...task,completed:true})
|
|
@@ -271,17 +274,17 @@ export interface Repository<entityType> {
|
|
|
271
274
|
id?: number;
|
|
272
275
|
} ? number : entityType extends {
|
|
273
276
|
id?: string;
|
|
274
|
-
} ? string : string | number, item: Partial<OmitEB<entityType
|
|
275
|
-
update(id: Partial<OmitEB<entityType
|
|
277
|
+
} ? string : string | number, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
278
|
+
update(id: Partial<OmitFunctions<OmitEB<entityType>>>, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
276
279
|
/** Deletes an Item*/
|
|
277
280
|
delete(id: entityType extends {
|
|
278
281
|
id?: number;
|
|
279
282
|
} ? number : entityType extends {
|
|
280
283
|
id?: string;
|
|
281
284
|
} ? string : string | number): Promise<void>;
|
|
282
|
-
delete(item: Partial<OmitEB<entityType
|
|
285
|
+
delete(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<void>;
|
|
283
286
|
/** Creates an instance of an item. It'll not be saved to the data source unless `save` or `insert` will be called for that item */
|
|
284
|
-
create(item?: Partial<OmitEB<entityType
|
|
287
|
+
create(item?: Partial<OmitFunctions<OmitEB<entityType>>>): entityType;
|
|
285
288
|
toJson(item: Promise<entityType[]>): Promise<any[]>;
|
|
286
289
|
toJson(item: entityType[]): any[];
|
|
287
290
|
toJson(item: Promise<entityType>): Promise<any>;
|
|
@@ -338,13 +341,13 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
|
338
341
|
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
339
342
|
*/
|
|
340
343
|
export declare type EntityOrderBy<entityType> = {
|
|
341
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
344
|
+
[Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: 'asc' | 'desc';
|
|
342
345
|
};
|
|
343
346
|
/**Used to filter the desired result set
|
|
344
347
|
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
345
348
|
*/
|
|
346
349
|
export declare type EntityFilter<entityType> = {
|
|
347
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
350
|
+
[Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: (Partial<OmitEB<entityType>>[Properties] extends number | Date | undefined ? ComparisonValueFilter<Partial<OmitEB<entityType>>[Properties]> : Partial<OmitEB<entityType>>[Properties] extends string | undefined ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<OmitEB<entityType>>[Properties] extends boolean | undefined ? ValueFilter<boolean> : Partial<OmitEB<entityType>>[Properties] extends {
|
|
348
351
|
id?: string | number;
|
|
349
352
|
} | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) | ContainsStringValueFilter;
|
|
350
353
|
} & {
|
|
@@ -536,7 +539,7 @@ export type RepositoryRelations<entityType> = {
|
|
|
536
539
|
} : never;
|
|
537
540
|
};
|
|
538
541
|
export declare type EntityIdFields<entityType> = {
|
|
539
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
542
|
+
[Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: true;
|
|
540
543
|
};
|
|
541
544
|
export interface ClassFieldDecoratorContextStub<entityType, valueType> {
|
|
542
545
|
readonly access: {
|
|
@@ -551,7 +554,7 @@ export interface ClassDecoratorContextStub<Class extends new (...args: any) => a
|
|
|
551
554
|
}
|
|
552
555
|
export type ClassFieldDecorator<entityType, valueType> = (target: any, context: string | ClassFieldDecoratorContextStub<entityType, valueType | undefined>, c?: any) => void;
|
|
553
556
|
/**
|
|
554
|
-
* //
|
|
557
|
+
* //p2 - doc this
|
|
555
558
|
remult.apiClient.httpClient = (
|
|
556
559
|
input: RequestInfo | URL,
|
|
557
560
|
init?: RequestInit
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//p1 - include relations in the api docs
|
|
3
|
-
//p1 - include Relation options in the api docs
|
|
4
|
-
//p1 - fix { allowApiRead: r => r.user.name === 'superman' } } in allowed for instace docs
|
|
5
|
-
//p1 - fix seeallowed in ref_entity
|
|
6
2
|
//p2 - write doc about controlling updates of rows...
|
|
7
3
|
//p2 - need a way to extract the fields from the relation - for generating relation based sql
|
|
8
|
-
//p1 - active record with include thinks that the row was change!
|
|
9
4
|
//p2 - add docs for apply changes
|
|
10
|
-
//p1 - when the include doesn't find the many to one - it deletes the id!!!
|
|
11
5
|
//y2 - discuss a default date formatter
|
|
12
6
|
//[ ] - consider using this in saving etc...
|
|
13
7
|
//p2 - when subscribe is forbidden - the query still runs after the renew process
|
|
14
8
|
//p2 - JSON FIELD LOST JSON STORAGE WHEN SET INPUT VALUE
|
|
15
9
|
//p2 - doc this:
|
|
16
10
|
/**
|
|
17
|
-
* //
|
|
11
|
+
* //p2 - doc this
|
|
18
12
|
remult.apiClient.httpClient = (
|
|
19
13
|
input: RequestInfo | URL,
|
|
20
14
|
init?: RequestInit
|
|
@@ -39,21 +33,27 @@ remult.apiClient.url='localhost:3007/api
|
|
|
39
33
|
//p2 - Operator '>' cannot be applied to types 'Number' and 'number'.ts(2365) - change fields to <entityType,number> (now it's Number)
|
|
40
34
|
//p2 - Field(()=>String) - doesn't play nice with strict mode - it prevents people from extending basic types
|
|
41
35
|
//p2 - with remult for remultexpress
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
36
|
+
//p2 - Add a with remult promise to Remult!
|
|
37
|
+
//y1 - YONI field didn't appear in intelisence of manyToNe
|
|
38
|
+
//y1 - YONI with relation to one, fields doesn't appear well in the overload options when trying to set driver phone on trempim
|
|
39
|
+
//y1 - YONI why didn't this._.relations.statusChanges.insert({})work?
|
|
40
|
+
//y1 - YONI 'taskid' toOne field parameter did not autocomplete in task app - C:\repos\help-zahal\src\app\events\volunteerInTask.ts 49
|
|
41
|
+
//y1 - Is OmitFunctions a good name from fields and relations
|
|
48
42
|
//p2 - filterToRaw should get a dbnames of - and we should create a dbnames of that supports an alias
|
|
49
|
-
//p1 - DO NOT BREAK - move fieldref to second parameter, and lifecycle to 3rd consider the breaking signature change of saving on field options - the field becomes the 3rd parameter.
|
|
50
|
-
//p1 - test what happens with a many to one relation where the one no longer exist, in all 3 cases (toOne,reference,toone with fields)
|
|
51
|
-
//p1 - findid by default has cache - it sucks!
|
|
52
43
|
//y2 - livequery for findfirst (@JY)
|
|
53
44
|
//y2 - #239 - (@JY) add a way to get from fieldMetadata back to entity repo (like we have in fieldRef)
|
|
54
45
|
//p2 - constraints (@JY)
|
|
55
46
|
//p2 - Add ability to process query that comes from the api
|
|
56
47
|
//p2 - too much data by mistake
|
|
57
48
|
//p2 - postgres case sensitive
|
|
58
|
-
//y1 - consider http status code for errors
|
|
59
49
|
//p2 - fix sql log to console to make more sense
|
|
50
|
+
//p2 - type metadata.key - to keyof entity - based on cwis input
|
|
51
|
+
//p2 - processError in remult express
|
|
52
|
+
//y1 - should we change relations to be a static const instead of a class (also for fields maybe) what's the point of doing new Relations
|
|
53
|
+
//y1 - add Class type to index of remult - it is used in repo and is important
|
|
54
|
+
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
55
|
+
//p2 - get backend methods to work when specifying types for date, and entities as poco's
|
|
56
|
+
//p2 - allow find options preprocessor for api calls, to use for authorization
|
|
57
|
+
//y2 - remove __dirname from tutorials
|
|
58
|
+
//y2 - add some api testing framework for user unit tests (will help with codesandbox based discussions)
|
|
59
|
+
//y2 - I tihnk there should be a way to throw a forbidden exception
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClassType } from './classType';
|
|
2
|
-
export { OmitEB, FieldsMetadata, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, EntityRef, SortSegments, Paginator, LiveQuery, LiveQueryChangeInfo, Subscribable, RefSubscriber, RefSubscriberBase, RelationOptions, ObjectMembersOnly, MembersToInclude, RepositoryRelations, EntityIdFields, ClassFieldDecorator, ClassFieldDecoratorContextStub, //n1 consider removing in ts5
|
|
2
|
+
export { OmitEB, OmitFunctions, FieldsMetadata, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, EntityRef, SortSegments, Paginator, LiveQuery, LiveQueryChangeInfo, Subscribable, RefSubscriber, RefSubscriberBase, RelationOptions, ObjectMembersOnly, MembersToInclude, RepositoryRelations, EntityIdFields, ClassFieldDecorator, ClassFieldDecoratorContextStub, //n1 consider removing in ts5
|
|
3
3
|
LifecycleEvent, } from './src/remult3/remult3';
|
|
4
4
|
export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, CaptionTransformer, } from './src/remult3/RepositoryImplementation';
|
|
5
5
|
export { Entity } from './src/remult3/entity';
|
package/package.json
CHANGED
package/remult-hapi.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Request, Plugin } from '@hapi/hapi';
|
|
2
|
+
import { type RemultServerCore, type RemultServerOptions } from './server';
|
|
3
|
+
export declare function remultHapi(options: RemultServerOptions<Request>): RemultHapiServer;
|
|
4
|
+
export type RemultHapiServer = Plugin<any, any> & RemultServerCore<Request> & {
|
|
5
|
+
withRemult<T>(req: Request, what: () => Promise<T>): Promise<T>;
|
|
6
|
+
};
|
package/remult-hapi.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remultHapi = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var server_1 = require("./server");
|
|
6
|
+
var stream_1 = require("stream");
|
|
7
|
+
function remultHapi(options) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
var api = (0, server_1.createRemultServer)(options, {
|
|
10
|
+
buildGenericRequestInfo: function (req) { return ({
|
|
11
|
+
method: req.method,
|
|
12
|
+
params: req.params,
|
|
13
|
+
query: req.query,
|
|
14
|
+
url: req.url.pathname,
|
|
15
|
+
on: function (e, do1) {
|
|
16
|
+
req.raw.req.on('close', do1);
|
|
17
|
+
},
|
|
18
|
+
}); },
|
|
19
|
+
getRequestBody: function (req) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
|
|
20
|
+
return [2 /*return*/, req.payload];
|
|
21
|
+
}); }); },
|
|
22
|
+
});
|
|
23
|
+
var routesPlugin = {
|
|
24
|
+
name: 'remultPlugin',
|
|
25
|
+
register: function (server) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
26
|
+
function hapiHandler(handler) {
|
|
27
|
+
return function (request, h) {
|
|
28
|
+
return new Promise(function (res, rej) {
|
|
29
|
+
var status = 200;
|
|
30
|
+
var stream;
|
|
31
|
+
var r = {
|
|
32
|
+
status: function (statusCode) {
|
|
33
|
+
status = statusCode;
|
|
34
|
+
console.log(statusCode);
|
|
35
|
+
return r;
|
|
36
|
+
},
|
|
37
|
+
end: function () {
|
|
38
|
+
res(h.response().code(status));
|
|
39
|
+
},
|
|
40
|
+
json: function (data) {
|
|
41
|
+
res(h.response(data).code(status));
|
|
42
|
+
},
|
|
43
|
+
write: function (data) {
|
|
44
|
+
stream.write(data);
|
|
45
|
+
},
|
|
46
|
+
writeHead: function (status, headers) {
|
|
47
|
+
stream = new stream_1.PassThrough();
|
|
48
|
+
res(h
|
|
49
|
+
.response(stream)
|
|
50
|
+
.header('content-type', 'text/event-stream')
|
|
51
|
+
.header('content-encoding', 'identity'));
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
Object.assign(request, {
|
|
56
|
+
on: function (event, listener) {
|
|
57
|
+
request.raw.req.on('close', function () {
|
|
58
|
+
listener();
|
|
59
|
+
console.log('Connection closed');
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
handler(request, r, function () { });
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
rej(err);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
var hapiRouter;
|
|
72
|
+
return tslib_1.__generator(this, function (_a) {
|
|
73
|
+
hapiRouter = {
|
|
74
|
+
route: function (path) {
|
|
75
|
+
path = path.replace(/:id\b/g, '{id}');
|
|
76
|
+
var r = {
|
|
77
|
+
get: function (handler) {
|
|
78
|
+
server.route({
|
|
79
|
+
method: 'GET',
|
|
80
|
+
path: path,
|
|
81
|
+
handler: hapiHandler(handler),
|
|
82
|
+
});
|
|
83
|
+
return r;
|
|
84
|
+
},
|
|
85
|
+
post: function (handler) {
|
|
86
|
+
server.route({
|
|
87
|
+
method: 'POST',
|
|
88
|
+
path: path,
|
|
89
|
+
handler: hapiHandler(handler),
|
|
90
|
+
});
|
|
91
|
+
return r;
|
|
92
|
+
},
|
|
93
|
+
put: function (handler) {
|
|
94
|
+
server.route({
|
|
95
|
+
method: 'PUT',
|
|
96
|
+
path: path,
|
|
97
|
+
handler: hapiHandler(handler),
|
|
98
|
+
});
|
|
99
|
+
return r;
|
|
100
|
+
},
|
|
101
|
+
delete: function (handler) {
|
|
102
|
+
server.route({
|
|
103
|
+
method: 'DELETE',
|
|
104
|
+
path: path,
|
|
105
|
+
handler: hapiHandler(handler),
|
|
106
|
+
});
|
|
107
|
+
return r;
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
return r;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
api.registerRouter(hapiRouter);
|
|
114
|
+
return [2 /*return*/];
|
|
115
|
+
});
|
|
116
|
+
}); },
|
|
117
|
+
};
|
|
118
|
+
return Object.assign(routesPlugin, {
|
|
119
|
+
getRemult: function (x) { return api.getRemult(x); },
|
|
120
|
+
openApiDoc: function (x) { return api.openApiDoc(x); },
|
|
121
|
+
withRemult: function (req, what) { return api.withRemultPromise(req, what); },
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
exports.remultHapi = remultHapi;
|
package/server/expressBridge.js
CHANGED
|
@@ -1125,7 +1125,7 @@ var EntityQueueStorage = /** @class */ (function () {
|
|
|
1125
1125
|
var _this = this;
|
|
1126
1126
|
return tslib_1.__generator(this, function (_a) {
|
|
1127
1127
|
switch (_a.label) {
|
|
1128
|
-
case 0: return [4 /*yield*/, this.repo.findId(queuedJobId
|
|
1128
|
+
case 0: return [4 /*yield*/, this.repo.findId(queuedJobId)];
|
|
1129
1129
|
case 1:
|
|
1130
1130
|
q = _a.sent();
|
|
1131
1131
|
lastProgress = undefined;
|
|
@@ -1406,4 +1406,3 @@ var JobsInQueueEntity = /** @class */ (function (_super) {
|
|
|
1406
1406
|
}(IdEntity_1.IdEntity));
|
|
1407
1407
|
exports.JobsInQueueEntity = JobsInQueueEntity;
|
|
1408
1408
|
context_1.allEntities.splice(context_1.allEntities.indexOf(JobsInQueueEntity), 1);
|
|
1409
|
-
//p1 - implement dbname based on related field https://codesandbox.io/p/sandbox/fervent-yalow-66m78n?file=%2Fsrc%2Findex.ts%3A35%2C93
|
|
@@ -37,7 +37,7 @@ export interface FieldOptions<entityType = any, valueType = any> {
|
|
|
37
37
|
*/
|
|
38
38
|
validate?: ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => any | Promise<any>) | ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => any | Promise<any>)[];
|
|
39
39
|
/** Will be fired before this field is saved to the server/database */
|
|
40
|
-
saving?: (entity: entityType,
|
|
40
|
+
saving?: (entity: entityType, fieldRef: FieldRef<entityType, valueType>, e: LifecycleEvent<entityType>) => any | Promise<any>;
|
|
41
41
|
/** An expression that will determine this fields value on the backend and be provided to the front end*/
|
|
42
42
|
serverExpression?: (entity: entityType) => valueType | Promise<valueType>;
|
|
43
43
|
/** The name of the column in the database that holds the data for this field. If no name is set, the key will be used instead.
|
package/src/context.js
CHANGED
|
@@ -450,7 +450,5 @@ var transactionLiveQueryPublisher = /** @class */ (function () {
|
|
|
450
450
|
};
|
|
451
451
|
return transactionLiveQueryPublisher;
|
|
452
452
|
}());
|
|
453
|
-
//
|
|
454
|
-
//p1 - reconsider the case in tremping where create user id was updated with some user and not the actual user
|
|
455
|
-
//[ ] - when value changes for field with error, clear error - so the user will feel comfortable
|
|
453
|
+
//p2 - when value changes for field with error, clear error - so the user will feel comfortable
|
|
456
454
|
//y2 - require filter argument - and perform validation checks for it - site, id etc.. changelog, status changes etc...,
|
package/src/data-interfaces.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Filter } from './filter/filter-interfaces';
|
|
2
|
-
import type { EntityMetadata, OmitEB } from './remult3/remult3';
|
|
2
|
+
import type { EntityMetadata, OmitEB, OmitFunctions } from './remult3/remult3';
|
|
3
3
|
import { Sort } from './sort';
|
|
4
4
|
export interface DataProvider {
|
|
5
5
|
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
|
|
@@ -33,7 +33,7 @@ export declare function extractSort(sort: any): Sort;
|
|
|
33
33
|
export interface ErrorInfo<entityType = any> {
|
|
34
34
|
message?: string;
|
|
35
35
|
modelState?: {
|
|
36
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
36
|
+
[Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: string;
|
|
37
37
|
};
|
|
38
38
|
stack?: string;
|
|
39
39
|
exception?: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FieldMetadata } from '../column-interfaces';
|
|
2
2
|
import type { EntityMetadataOverloads, RepositoryOverloads } from '../remult3/RepositoryImplementation';
|
|
3
|
-
import type { EntityFilter, OmitEB } from '../remult3/remult3';
|
|
3
|
+
import type { EntityFilter, OmitEB, OmitFunctions } from '../remult3/remult3';
|
|
4
4
|
import type { SqlCommandWithParameters } from '../sql-command';
|
|
5
5
|
import type { Filter, FilterConsumer } from './filter-interfaces';
|
|
6
6
|
export declare class FilterConsumerBridgeToSqlRequest implements FilterConsumer {
|
|
@@ -45,6 +45,6 @@ export declare type EntityDbNamesBase = {
|
|
|
45
45
|
toString(): string;
|
|
46
46
|
};
|
|
47
47
|
export declare type EntityDbNames<entityType> = {
|
|
48
|
-
[Properties in keyof Required<OmitEB<entityType
|
|
48
|
+
[Properties in keyof Required<OmitFunctions<OmitEB<entityType>>>]: string;
|
|
49
49
|
} & EntityDbNamesBase;
|
|
50
50
|
export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>): Promise<EntityDbNames<entityType>>;
|
package/src/remult3/Fields.js
CHANGED
|
@@ -86,7 +86,7 @@ var Fields = /** @class */ (function () {
|
|
|
86
86
|
return Field.apply(void 0, tslib_1.__spreadArray([function () { return Date; },
|
|
87
87
|
{
|
|
88
88
|
allowApiUpdate: false,
|
|
89
|
-
saving: function (_,
|
|
89
|
+
saving: function (_, ref, _a) {
|
|
90
90
|
var isNew = _a.isNew;
|
|
91
91
|
if (isNew)
|
|
92
92
|
ref.value = new Date();
|
|
@@ -101,7 +101,7 @@ var Fields = /** @class */ (function () {
|
|
|
101
101
|
return Field.apply(void 0, tslib_1.__spreadArray([function () { return Date; },
|
|
102
102
|
{
|
|
103
103
|
allowApiUpdate: false,
|
|
104
|
-
saving: function (_,
|
|
104
|
+
saving: function (_, ref) {
|
|
105
105
|
ref.value = new Date();
|
|
106
106
|
},
|
|
107
107
|
}], tslib_1.__read(options), false));
|
|
@@ -115,7 +115,7 @@ var Fields = /** @class */ (function () {
|
|
|
115
115
|
{
|
|
116
116
|
allowApiUpdate: false,
|
|
117
117
|
defaultValue: function () { return (0, uuid_1.v4)(); },
|
|
118
|
-
saving: function (_,
|
|
118
|
+
saving: function (_, r) {
|
|
119
119
|
if (!r.value)
|
|
120
120
|
r.value = (0, uuid_1.v4)();
|
|
121
121
|
},
|
|
@@ -130,7 +130,7 @@ var Fields = /** @class */ (function () {
|
|
|
130
130
|
{
|
|
131
131
|
allowApiUpdate: false,
|
|
132
132
|
defaultValue: function () { return (0, cuid2_1.createId)(); },
|
|
133
|
-
saving: function (_,
|
|
133
|
+
saving: function (_, r) {
|
|
134
134
|
if (!r.value)
|
|
135
135
|
r.value = (0, cuid2_1.createId)();
|
|
136
136
|
},
|
|
@@ -126,13 +126,17 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
126
126
|
if (!rel)
|
|
127
127
|
throw Error(key + ' is not a relation');
|
|
128
128
|
var repo = _this.remult.repo(rel.toType());
|
|
129
|
-
var
|
|
129
|
+
var _a = _this.findOptionsBasedOnRelation(rel, field, undefined, item, repo), findOptions = _a.findOptions, returnNull = _a.returnNull, returnUndefined = _a.returnUndefined;
|
|
130
130
|
var toRepo = new RepositoryImplementation(repo.entity, repo.remult, repo.dataProvider, repo._info, findOptions);
|
|
131
131
|
if (rel.type === 'toMany')
|
|
132
132
|
return toRepo;
|
|
133
133
|
else
|
|
134
134
|
return {
|
|
135
135
|
findOne: function (options) {
|
|
136
|
+
if (returnNull)
|
|
137
|
+
return Promise.resolve(null);
|
|
138
|
+
if (returnUndefined)
|
|
139
|
+
return Promise.resolve(undefined);
|
|
136
140
|
return toRepo.findFirst({}, options);
|
|
137
141
|
},
|
|
138
142
|
};
|
|
@@ -731,6 +735,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
731
735
|
metadata: toRepo_1.metadata,
|
|
732
736
|
}, findOptions)
|
|
733
737
|
.then(function (result) {
|
|
738
|
+
if (result.length == 0 && rel.type == 'toOne')
|
|
739
|
+
return;
|
|
734
740
|
row[col.key] =
|
|
735
741
|
rel.type !== 'toMany'
|
|
736
742
|
? result.length == 0
|
|
@@ -778,6 +784,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
778
784
|
RepositoryImplementation.prototype.findOptionsBasedOnRelation = function (rel, field, moreFindOptions, row, otherRepo) {
|
|
779
785
|
var e_13, _a, e_14, _b, e_15, _c, _d, _e;
|
|
780
786
|
var returnNull = false;
|
|
787
|
+
var returnUndefined = false;
|
|
781
788
|
var where = [];
|
|
782
789
|
var findOptions = {};
|
|
783
790
|
var findOptionsSources = [];
|
|
@@ -880,6 +887,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
880
887
|
var val = row[options.field];
|
|
881
888
|
if (val === null)
|
|
882
889
|
returnNull = true;
|
|
890
|
+
if (val === undefined)
|
|
891
|
+
returnUndefined = true;
|
|
883
892
|
else
|
|
884
893
|
where.push(otherRepo.metadata.idMetadata.getIdFilter(val));
|
|
885
894
|
}
|
|
@@ -905,6 +914,8 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
905
914
|
: row[field.key];
|
|
906
915
|
if (val === null)
|
|
907
916
|
returnNull = true;
|
|
917
|
+
if (val === undefined)
|
|
918
|
+
returnUndefined = true;
|
|
908
919
|
else if (typeof val === 'object')
|
|
909
920
|
where.push(otherRepo.metadata.idMetadata.getIdFilter(otherRepo.metadata.idMetadata.getId(val)));
|
|
910
921
|
else
|
|
@@ -915,7 +926,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
915
926
|
findOptions.orderBy // I deduce from this that there may be more than one row and we want only the first
|
|
916
927
|
)
|
|
917
928
|
findOptions.limit = 1;
|
|
918
|
-
return { findOptions: findOptions, returnNull: returnNull };
|
|
929
|
+
return { findOptions: findOptions, returnNull: returnNull, returnUndefined: returnUndefined };
|
|
919
930
|
};
|
|
920
931
|
RepositoryImplementation.prototype.mapRawDataToResult = function (r, loadFields) {
|
|
921
932
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
@@ -1157,7 +1168,7 @@ var RepositoryImplementation = /** @class */ (function () {
|
|
|
1157
1168
|
return null;
|
|
1158
1169
|
if (typeof id !== 'string' && typeof id !== 'number')
|
|
1159
1170
|
throw new Error('id can be either number or string, but got: ' + typeof id);
|
|
1160
|
-
return this.findFirst({}, tslib_1.__assign(tslib_1.__assign({
|
|
1171
|
+
return this.findFirst({}, tslib_1.__assign(tslib_1.__assign({}, options), { where: this.metadata.idMetadata.getIdFilter(id) }), true);
|
|
1161
1172
|
};
|
|
1162
1173
|
/* @internal*/
|
|
1163
1174
|
RepositoryImplementation.prototype.translateWhereToFilter = function (where) {
|
|
@@ -1905,7 +1916,7 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
1905
1916
|
if (!!_c.done) return [3 /*break*/, 7];
|
|
1906
1917
|
col = _c.value;
|
|
1907
1918
|
if (!col.metadata.options.saving) return [3 /*break*/, 6];
|
|
1908
|
-
return [4 /*yield*/, col.metadata.options.saving(this.instance,
|
|
1919
|
+
return [4 /*yield*/, col.metadata.options.saving(this.instance, col, e)];
|
|
1909
1920
|
case 5:
|
|
1910
1921
|
_l.sent();
|
|
1911
1922
|
_l.label = 6;
|
|
@@ -2253,8 +2264,10 @@ var rowHelperImplementation = /** @class */ (function (_super) {
|
|
|
2253
2264
|
try {
|
|
2254
2265
|
for (var _c = tslib_1.__values(this.fields), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2255
2266
|
var col = _d.value;
|
|
2256
|
-
|
|
2257
|
-
|
|
2267
|
+
var rel = (0, relationInfoMember_1.getRelationInfo)(col.metadata.options);
|
|
2268
|
+
if (!rel || rel.type == 'reference')
|
|
2269
|
+
if (col.valueChanged())
|
|
2270
|
+
return true;
|
|
2258
2271
|
}
|
|
2259
2272
|
}
|
|
2260
2273
|
catch (e_36_1) { e_36 = { error: e_36_1 }; }
|
|
@@ -2473,9 +2486,9 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2473
2486
|
};
|
|
2474
2487
|
FieldRefImplementation.prototype.load = function () {
|
|
2475
2488
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2476
|
-
var lu, rel, _a, _b,
|
|
2477
|
-
return tslib_1.__generator(this, function (
|
|
2478
|
-
switch (
|
|
2489
|
+
var lu, rel, _a, _b, val;
|
|
2490
|
+
return tslib_1.__generator(this, function (_c) {
|
|
2491
|
+
switch (_c.label) {
|
|
2479
2492
|
case 0:
|
|
2480
2493
|
lu = this.rowBase.lookups.get(this.metadata.key);
|
|
2481
2494
|
rel = (0, relationInfoMember_1.getRelationInfo)(this.metadata.options);
|
|
@@ -2485,23 +2498,24 @@ var FieldRefImplementation = /** @class */ (function () {
|
|
|
2485
2498
|
_b = this.metadata.key;
|
|
2486
2499
|
return [4 /*yield*/, this.helper.repository
|
|
2487
2500
|
.relations(this.container)[this.metadata.key].find()];
|
|
2488
|
-
case 1: return [2 /*return*/, (_a[_b] =
|
|
2489
|
-
case 2:
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2501
|
+
case 1: return [2 /*return*/, (_a[_b] = _c.sent())];
|
|
2502
|
+
case 2: return [4 /*yield*/, this.helper.repository
|
|
2503
|
+
.relations(this.container)[this.metadata.key].findOne()];
|
|
2504
|
+
case 3:
|
|
2505
|
+
val = _c.sent();
|
|
2506
|
+
if (val)
|
|
2507
|
+
this.container[this.metadata.key] = val;
|
|
2508
|
+
_c.label = 4;
|
|
2495
2509
|
case 4: return [3 /*break*/, 9];
|
|
2496
2510
|
case 5:
|
|
2497
2511
|
if (!lu) return [3 /*break*/, 9];
|
|
2498
2512
|
if (!this.valueChanged()) return [3 /*break*/, 7];
|
|
2499
2513
|
return [4 /*yield*/, lu.waitLoadOf(this.rawOriginalValue())];
|
|
2500
2514
|
case 6:
|
|
2501
|
-
|
|
2502
|
-
|
|
2515
|
+
_c.sent();
|
|
2516
|
+
_c.label = 7;
|
|
2503
2517
|
case 7: return [4 /*yield*/, lu.waitLoad()];
|
|
2504
|
-
case 8: return [2 /*return*/,
|
|
2518
|
+
case 8: return [2 /*return*/, _c.sent()];
|
|
2505
2519
|
case 9: return [2 /*return*/, this.value];
|
|
2506
2520
|
}
|
|
2507
2521
|
});
|
|
@@ -2743,7 +2757,7 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2743
2757
|
};
|
|
2744
2758
|
columnDefsImpl.prototype.getDbName = function () {
|
|
2745
2759
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
2746
|
-
var result;
|
|
2760
|
+
var result, rel, field, fInfo;
|
|
2747
2761
|
return tslib_1.__generator(this, function (_a) {
|
|
2748
2762
|
switch (_a.label) {
|
|
2749
2763
|
case 0:
|
|
@@ -2762,7 +2776,16 @@ var columnDefsImpl = /** @class */ (function () {
|
|
|
2762
2776
|
if (!result)
|
|
2763
2777
|
return [2 /*return*/, this.settings.dbName];
|
|
2764
2778
|
return [2 /*return*/, result];
|
|
2765
|
-
case 4:
|
|
2779
|
+
case 4:
|
|
2780
|
+
rel = (0, relationInfoMember_1.getRelationInfo)(this.settings);
|
|
2781
|
+
field = (rel === null || rel === void 0 ? void 0 : rel.type) === 'toOne' &&
|
|
2782
|
+
this.settings.field;
|
|
2783
|
+
if (field) {
|
|
2784
|
+
fInfo = this.entityDefs.fields.find(field);
|
|
2785
|
+
if (fInfo)
|
|
2786
|
+
return [2 /*return*/, fInfo.getDbName()];
|
|
2787
|
+
}
|
|
2788
|
+
return [2 /*return*/, this.settings.dbName];
|
|
2766
2789
|
case 5: return [7 /*endfinally*/];
|
|
2767
2790
|
case 6: return [2 /*return*/];
|
|
2768
2791
|
}
|
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export interface Subscribable {
|
|
|
89
89
|
subscribe(listener: RefSubscriber): Unsubscribe;
|
|
90
90
|
}
|
|
91
91
|
export type FieldsRef<entityType> = {
|
|
92
|
-
[Properties in keyof OmitEB<entityType
|
|
92
|
+
[Properties in keyof OmitFunctions<OmitEB<entityType>>]: NonNullable<entityType[Properties]> extends {
|
|
93
93
|
id?: number | string;
|
|
94
94
|
} ? IdFieldRef<entityType, entityType[Properties]> : FieldRef<entityType, entityType[Properties]>;
|
|
95
95
|
} & {
|
|
@@ -98,7 +98,7 @@ export type FieldsRef<entityType> = {
|
|
|
98
98
|
toArray(): FieldRef<entityType, any>[];
|
|
99
99
|
};
|
|
100
100
|
export type FieldsMetadata<entityType> = {
|
|
101
|
-
[Properties in keyof OmitEB<entityType
|
|
101
|
+
[Properties in keyof OmitFunctions<OmitEB<entityType>>]: FieldMetadata<entityType[Properties], entityType>;
|
|
102
102
|
} & {
|
|
103
103
|
find(fieldMetadataOrKey: FieldMetadata | string): FieldMetadata<any, entityType>;
|
|
104
104
|
[Symbol.iterator]: () => IterableIterator<FieldMetadata<any, entityType>>;
|
|
@@ -141,11 +141,11 @@ export interface IdMetadata<entityType = any> {
|
|
|
141
141
|
* @example
|
|
142
142
|
* repo.metadata.idMetadata.getId(task)
|
|
143
143
|
*/
|
|
144
|
-
getId(item: Partial<OmitEB<entityType
|
|
144
|
+
getId(item: Partial<OmitFunctions<OmitEB<entityType>>>): any;
|
|
145
145
|
field: FieldMetadata<any>;
|
|
146
146
|
getIdFilter(...ids: any[]): EntityFilter<entityType>;
|
|
147
147
|
isIdField(col: FieldMetadata): boolean;
|
|
148
|
-
createIdInFilter(items: Partial<OmitEB<entityType
|
|
148
|
+
createIdInFilter(items: Partial<OmitFunctions<OmitEB<entityType>>>[]): EntityFilter<entityType>;
|
|
149
149
|
}
|
|
150
150
|
/** Metadata for an `Entity`, this metadata can be used in the user interface to provide a richer UI experience */
|
|
151
151
|
export interface EntityMetadata<entityType = any> {
|
|
@@ -200,6 +200,9 @@ export interface EntityMetadata<entityType = any> {
|
|
|
200
200
|
readonly idMetadata: IdMetadata<entityType>;
|
|
201
201
|
}
|
|
202
202
|
export declare type OmitEB<T> = Omit<T, keyof EntityBase>;
|
|
203
|
+
export type OmitFunctions<T> = Pick<T, {
|
|
204
|
+
[K in keyof T]: T[K] extends Function ? never : K;
|
|
205
|
+
}[keyof T]>;
|
|
203
206
|
export declare type idType<entityType> = entityType extends {
|
|
204
207
|
id?: number;
|
|
205
208
|
} ? number : entityType extends {
|
|
@@ -248,21 +251,21 @@ export interface Repository<entityType> {
|
|
|
248
251
|
* // Can also be used to validate specific fields
|
|
249
252
|
* const error = repo.validate(task,"title")
|
|
250
253
|
*/
|
|
251
|
-
validate(item: Partial<entityType>, ...fields: Extract<keyof OmitEB<entityType
|
|
254
|
+
validate(item: Partial<entityType>, ...fields: Extract<keyof OmitFunctions<OmitEB<entityType>>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
|
|
252
255
|
/** saves an item or item[] to the data source. It assumes that if an `id` value exists, it's an existing row - otherwise it's a new row
|
|
253
256
|
* @example
|
|
254
257
|
* await taskRepo.save({...task, completed:true })
|
|
255
258
|
*/
|
|
256
|
-
save(item: Partial<OmitEB<entityType
|
|
257
|
-
save(item: Partial<OmitEB<entityType
|
|
259
|
+
save(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
|
|
260
|
+
save(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
258
261
|
/**Insert an item or item[] to the data source
|
|
259
262
|
* @example
|
|
260
263
|
* await taskRepo.insert({title:"task a"})
|
|
261
264
|
* @example
|
|
262
265
|
* await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
|
|
263
266
|
*/
|
|
264
|
-
insert(item: Partial<OmitEB<entityType
|
|
265
|
-
insert(item: Partial<OmitEB<entityType
|
|
267
|
+
insert(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
|
|
268
|
+
insert(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
266
269
|
/** Updates an item, based on its `id`
|
|
267
270
|
* @example
|
|
268
271
|
* taskRepo.update(task.id,{...task,completed:true})
|
|
@@ -271,17 +274,17 @@ export interface Repository<entityType> {
|
|
|
271
274
|
id?: number;
|
|
272
275
|
} ? number : entityType extends {
|
|
273
276
|
id?: string;
|
|
274
|
-
} ? string : string | number, item: Partial<OmitEB<entityType
|
|
275
|
-
update(id: Partial<OmitEB<entityType
|
|
277
|
+
} ? string : string | number, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
278
|
+
update(id: Partial<OmitFunctions<OmitEB<entityType>>>, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
|
|
276
279
|
/** Deletes an Item*/
|
|
277
280
|
delete(id: entityType extends {
|
|
278
281
|
id?: number;
|
|
279
282
|
} ? number : entityType extends {
|
|
280
283
|
id?: string;
|
|
281
284
|
} ? string : string | number): Promise<void>;
|
|
282
|
-
delete(item: Partial<OmitEB<entityType
|
|
285
|
+
delete(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<void>;
|
|
283
286
|
/** Creates an instance of an item. It'll not be saved to the data source unless `save` or `insert` will be called for that item */
|
|
284
|
-
create(item?: Partial<OmitEB<entityType
|
|
287
|
+
create(item?: Partial<OmitFunctions<OmitEB<entityType>>>): entityType;
|
|
285
288
|
toJson(item: Promise<entityType[]>): Promise<any[]>;
|
|
286
289
|
toJson(item: entityType[]): any[];
|
|
287
290
|
toJson(item: Promise<entityType>): Promise<any>;
|
|
@@ -338,13 +341,13 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
|
|
|
338
341
|
* await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
|
|
339
342
|
*/
|
|
340
343
|
export declare type EntityOrderBy<entityType> = {
|
|
341
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
344
|
+
[Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: 'asc' | 'desc';
|
|
342
345
|
};
|
|
343
346
|
/**Used to filter the desired result set
|
|
344
347
|
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
345
348
|
*/
|
|
346
349
|
export declare type EntityFilter<entityType> = {
|
|
347
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
350
|
+
[Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: (Partial<OmitEB<entityType>>[Properties] extends number | Date | undefined ? ComparisonValueFilter<Partial<OmitEB<entityType>>[Properties]> : Partial<OmitEB<entityType>>[Properties] extends string | undefined ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<OmitEB<entityType>>[Properties] extends boolean | undefined ? ValueFilter<boolean> : Partial<OmitEB<entityType>>[Properties] extends {
|
|
348
351
|
id?: string | number;
|
|
349
352
|
} | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) | ContainsStringValueFilter;
|
|
350
353
|
} & {
|
|
@@ -536,7 +539,7 @@ export type RepositoryRelations<entityType> = {
|
|
|
536
539
|
} : never;
|
|
537
540
|
};
|
|
538
541
|
export declare type EntityIdFields<entityType> = {
|
|
539
|
-
[Properties in keyof Partial<OmitEB<entityType
|
|
542
|
+
[Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: true;
|
|
540
543
|
};
|
|
541
544
|
export interface ClassFieldDecoratorContextStub<entityType, valueType> {
|
|
542
545
|
readonly access: {
|
|
@@ -551,7 +554,7 @@ export interface ClassDecoratorContextStub<Class extends new (...args: any) => a
|
|
|
551
554
|
}
|
|
552
555
|
export type ClassFieldDecorator<entityType, valueType> = (target: any, context: string | ClassFieldDecoratorContextStub<entityType, valueType | undefined>, c?: any) => void;
|
|
553
556
|
/**
|
|
554
|
-
* //
|
|
557
|
+
* //p2 - doc this
|
|
555
558
|
remult.apiClient.httpClient = (
|
|
556
559
|
input: RequestInfo | URL,
|
|
557
560
|
init?: RequestInit
|
package/src/remult3/remult3.js
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
//p1 - include relations in the api docs
|
|
4
|
-
//p1 - include Relation options in the api docs
|
|
5
|
-
//p1 - fix { allowApiRead: r => r.user.name === 'superman' } } in allowed for instace docs
|
|
6
|
-
//p1 - fix seeallowed in ref_entity
|
|
7
3
|
//p2 - write doc about controlling updates of rows...
|
|
8
4
|
//p2 - need a way to extract the fields from the relation - for generating relation based sql
|
|
9
|
-
//p1 - active record with include thinks that the row was change!
|
|
10
5
|
//p2 - add docs for apply changes
|
|
11
|
-
//p1 - when the include doesn't find the many to one - it deletes the id!!!
|
|
12
6
|
//y2 - discuss a default date formatter
|
|
13
7
|
//[ ] - consider using this in saving etc...
|
|
14
8
|
//p2 - when subscribe is forbidden - the query still runs after the renew process
|
|
15
9
|
//p2 - JSON FIELD LOST JSON STORAGE WHEN SET INPUT VALUE
|
|
16
10
|
//p2 - doc this:
|
|
17
11
|
/**
|
|
18
|
-
* //
|
|
12
|
+
* //p2 - doc this
|
|
19
13
|
remult.apiClient.httpClient = (
|
|
20
14
|
input: RequestInfo | URL,
|
|
21
15
|
init?: RequestInit
|
|
@@ -40,21 +34,27 @@ remult.apiClient.url='localhost:3007/api
|
|
|
40
34
|
//p2 - Operator '>' cannot be applied to types 'Number' and 'number'.ts(2365) - change fields to <entityType,number> (now it's Number)
|
|
41
35
|
//p2 - Field(()=>String) - doesn't play nice with strict mode - it prevents people from extending basic types
|
|
42
36
|
//p2 - with remult for remultexpress
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
//
|
|
37
|
+
//p2 - Add a with remult promise to Remult!
|
|
38
|
+
//y1 - YONI field didn't appear in intelisence of manyToNe
|
|
39
|
+
//y1 - YONI with relation to one, fields doesn't appear well in the overload options when trying to set driver phone on trempim
|
|
40
|
+
//y1 - YONI why didn't this._.relations.statusChanges.insert({})work?
|
|
41
|
+
//y1 - YONI 'taskid' toOne field parameter did not autocomplete in task app - C:\repos\help-zahal\src\app\events\volunteerInTask.ts 49
|
|
42
|
+
//y1 - Is OmitFunctions a good name from fields and relations
|
|
49
43
|
//p2 - filterToRaw should get a dbnames of - and we should create a dbnames of that supports an alias
|
|
50
|
-
//p1 - DO NOT BREAK - move fieldref to second parameter, and lifecycle to 3rd consider the breaking signature change of saving on field options - the field becomes the 3rd parameter.
|
|
51
|
-
//p1 - test what happens with a many to one relation where the one no longer exist, in all 3 cases (toOne,reference,toone with fields)
|
|
52
|
-
//p1 - findid by default has cache - it sucks!
|
|
53
44
|
//y2 - livequery for findfirst (@JY)
|
|
54
45
|
//y2 - #239 - (@JY) add a way to get from fieldMetadata back to entity repo (like we have in fieldRef)
|
|
55
46
|
//p2 - constraints (@JY)
|
|
56
47
|
//p2 - Add ability to process query that comes from the api
|
|
57
48
|
//p2 - too much data by mistake
|
|
58
49
|
//p2 - postgres case sensitive
|
|
59
|
-
//y1 - consider http status code for errors
|
|
60
50
|
//p2 - fix sql log to console to make more sense
|
|
51
|
+
//p2 - type metadata.key - to keyof entity - based on cwis input
|
|
52
|
+
//p2 - processError in remult express
|
|
53
|
+
//y1 - should we change relations to be a static const instead of a class (also for fields maybe) what's the point of doing new Relations
|
|
54
|
+
//y1 - add Class type to index of remult - it is used in repo and is important
|
|
55
|
+
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
56
|
+
//p2 - get backend methods to work when specifying types for date, and entities as poco's
|
|
57
|
+
//p2 - allow find options preprocessor for api calls, to use for authorization
|
|
58
|
+
//y2 - remove __dirname from tutorials
|
|
59
|
+
//y2 - add some api testing framework for user unit tests (will help with codesandbox based discussions)
|
|
60
|
+
//y2 - I tihnk there should be a way to throw a forbidden exception
|