remult 0.23.0-exp.32 → 0.23.0-exp.34

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 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
+ }
@@ -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>>]?: string;
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>>]: string;
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>>;
@@ -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>]: NonNullable<entityType[Properties]> extends {
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>]: FieldMetadata<entityType[Properties], 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>>): any;
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>>[]): EntityFilter<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,7 @@ 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> = T;
203
204
  export declare type idType<entityType> = entityType extends {
204
205
  id?: number;
205
206
  } ? number : entityType extends {
@@ -248,21 +249,21 @@ export interface Repository<entityType> {
248
249
  * // Can also be used to validate specific fields
249
250
  * const error = repo.validate(task,"title")
250
251
  */
251
- validate(item: Partial<entityType>, ...fields: Extract<keyof OmitEB<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
252
+ validate(item: Partial<entityType>, ...fields: Extract<keyof OmitFunctions<OmitEB<entityType>>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
252
253
  /** 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
254
  * @example
254
255
  * await taskRepo.save({...task, completed:true })
255
256
  */
256
- save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
257
- save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
257
+ save(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
258
+ save(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
258
259
  /**Insert an item or item[] to the data source
259
260
  * @example
260
261
  * await taskRepo.insert({title:"task a"})
261
262
  * @example
262
263
  * await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
263
264
  */
264
- insert(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
265
- insert(item: Partial<OmitEB<entityType>>): Promise<entityType>;
265
+ insert(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
266
+ insert(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
266
267
  /** Updates an item, based on its `id`
267
268
  * @example
268
269
  * taskRepo.update(task.id,{...task,completed:true})
@@ -271,17 +272,17 @@ export interface Repository<entityType> {
271
272
  id?: number;
272
273
  } ? number : entityType extends {
273
274
  id?: string;
274
- } ? string : string | number, item: Partial<OmitEB<entityType>>): Promise<entityType>;
275
- update(id: Partial<OmitEB<entityType>>, item: Partial<OmitEB<entityType>>): Promise<entityType>;
275
+ } ? string : string | number, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
276
+ update(id: Partial<OmitFunctions<OmitEB<entityType>>>, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
276
277
  /** Deletes an Item*/
277
278
  delete(id: entityType extends {
278
279
  id?: number;
279
280
  } ? number : entityType extends {
280
281
  id?: string;
281
282
  } ? string : string | number): Promise<void>;
282
- delete(item: Partial<OmitEB<entityType>>): Promise<void>;
283
+ delete(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<void>;
283
284
  /** 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>>): entityType;
285
+ create(item?: Partial<OmitFunctions<OmitEB<entityType>>>): entityType;
285
286
  toJson(item: Promise<entityType[]>): Promise<any[]>;
286
287
  toJson(item: entityType[]): any[];
287
288
  toJson(item: Promise<entityType>): Promise<any>;
@@ -338,13 +339,13 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
338
339
  * await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
339
340
  */
340
341
  export declare type EntityOrderBy<entityType> = {
341
- [Properties in keyof Partial<OmitEB<entityType>>]?: 'asc' | 'desc';
342
+ [Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: 'asc' | 'desc';
342
343
  };
343
344
  /**Used to filter the desired result set
344
345
  * @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
345
346
  */
346
347
  export declare type EntityFilter<entityType> = {
347
- [Properties in keyof Partial<OmitEB<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
+ [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
349
  id?: string | number;
349
350
  } | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) | ContainsStringValueFilter;
350
351
  } & {
@@ -536,7 +537,7 @@ export type RepositoryRelations<entityType> = {
536
537
  } : never;
537
538
  };
538
539
  export declare type EntityIdFields<entityType> = {
539
- [Properties in keyof Partial<OmitEB<entityType>>]?: true;
540
+ [Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: true;
540
541
  };
541
542
  export interface ClassFieldDecoratorContextStub<entityType, valueType> {
542
543
  readonly access: {
@@ -38,7 +38,7 @@ remult.apiClient.url='localhost:3007/api
38
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
39
  //y1 - YONI why didn't this._.relations.statusChanges.insert({})work?
40
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 - YONI omit functions from fields and relations
41
+ //y1 - YONI - trieed to implement this with OmitFunctions - but it breaks this.$.[something] a good name from fields and relations
42
42
  //p2 - filterToRaw should get a dbnames of - and we should create a dbnames of that supports an alias
43
43
  //y2 - livequery for findfirst (@JY)
44
44
  //y2 - #239 - (@JY) add a way to get from fieldMetadata back to entity repo (like we have in fieldRef)
@@ -54,3 +54,6 @@ remult.apiClient.url='localhost:3007/api
54
54
  //y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
55
55
  //p2 - get backend methods to work when specifying types for date, and entities as poco's
56
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.23.0-exp.32",
3
+ "version": "0.23.0-exp.34",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "types": "index.d.ts",
6
6
  "module": "esm/index.js",
@@ -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;
@@ -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>>]?: string;
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>>]: string;
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>>;
@@ -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>]: NonNullable<entityType[Properties]> extends {
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>]: FieldMetadata<entityType[Properties], 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>>): any;
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>>[]): EntityFilter<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,7 @@ 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> = T;
203
204
  export declare type idType<entityType> = entityType extends {
204
205
  id?: number;
205
206
  } ? number : entityType extends {
@@ -248,21 +249,21 @@ export interface Repository<entityType> {
248
249
  * // Can also be used to validate specific fields
249
250
  * const error = repo.validate(task,"title")
250
251
  */
251
- validate(item: Partial<entityType>, ...fields: Extract<keyof OmitEB<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
252
+ validate(item: Partial<entityType>, ...fields: Extract<keyof OmitFunctions<OmitEB<entityType>>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
252
253
  /** 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
254
  * @example
254
255
  * await taskRepo.save({...task, completed:true })
255
256
  */
256
- save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
257
- save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
257
+ save(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
258
+ save(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
258
259
  /**Insert an item or item[] to the data source
259
260
  * @example
260
261
  * await taskRepo.insert({title:"task a"})
261
262
  * @example
262
263
  * await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
263
264
  */
264
- insert(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
265
- insert(item: Partial<OmitEB<entityType>>): Promise<entityType>;
265
+ insert(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
266
+ insert(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
266
267
  /** Updates an item, based on its `id`
267
268
  * @example
268
269
  * taskRepo.update(task.id,{...task,completed:true})
@@ -271,17 +272,17 @@ export interface Repository<entityType> {
271
272
  id?: number;
272
273
  } ? number : entityType extends {
273
274
  id?: string;
274
- } ? string : string | number, item: Partial<OmitEB<entityType>>): Promise<entityType>;
275
- update(id: Partial<OmitEB<entityType>>, item: Partial<OmitEB<entityType>>): Promise<entityType>;
275
+ } ? string : string | number, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
276
+ update(id: Partial<OmitFunctions<OmitEB<entityType>>>, item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
276
277
  /** Deletes an Item*/
277
278
  delete(id: entityType extends {
278
279
  id?: number;
279
280
  } ? number : entityType extends {
280
281
  id?: string;
281
282
  } ? string : string | number): Promise<void>;
282
- delete(item: Partial<OmitEB<entityType>>): Promise<void>;
283
+ delete(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<void>;
283
284
  /** 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>>): entityType;
285
+ create(item?: Partial<OmitFunctions<OmitEB<entityType>>>): entityType;
285
286
  toJson(item: Promise<entityType[]>): Promise<any[]>;
286
287
  toJson(item: entityType[]): any[];
287
288
  toJson(item: Promise<entityType>): Promise<any>;
@@ -338,13 +339,13 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
338
339
  * await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
339
340
  */
340
341
  export declare type EntityOrderBy<entityType> = {
341
- [Properties in keyof Partial<OmitEB<entityType>>]?: 'asc' | 'desc';
342
+ [Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: 'asc' | 'desc';
342
343
  };
343
344
  /**Used to filter the desired result set
344
345
  * @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
345
346
  */
346
347
  export declare type EntityFilter<entityType> = {
347
- [Properties in keyof Partial<OmitEB<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
+ [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
349
  id?: string | number;
349
350
  } | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) | ContainsStringValueFilter;
350
351
  } & {
@@ -536,7 +537,7 @@ export type RepositoryRelations<entityType> = {
536
537
  } : never;
537
538
  };
538
539
  export declare type EntityIdFields<entityType> = {
539
- [Properties in keyof Partial<OmitEB<entityType>>]?: true;
540
+ [Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: true;
540
541
  };
541
542
  export interface ClassFieldDecoratorContextStub<entityType, valueType> {
542
543
  readonly access: {
@@ -39,7 +39,7 @@ remult.apiClient.url='localhost:3007/api
39
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
40
  //y1 - YONI why didn't this._.relations.statusChanges.insert({})work?
41
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 - YONI omit functions from fields and relations
42
+ //y1 - YONI - trieed to implement this with OmitFunctions - but it breaks this.$.[something] a good name from fields and relations
43
43
  //p2 - filterToRaw should get a dbnames of - and we should create a dbnames of that supports an alias
44
44
  //y2 - livequery for findfirst (@JY)
45
45
  //y2 - #239 - (@JY) add a way to get from fieldMetadata back to entity repo (like we have in fieldRef)
@@ -55,3 +55,6 @@ remult.apiClient.url='localhost:3007/api
55
55
  //y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
56
56
  //p2 - get backend methods to work when specifying types for date, and entities as poco's
57
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