remult 0.23.0-exp.34 → 0.23.0-exp.35

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,6 @@
1
1
  import type { ClassType } from './classType';
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
2
+ export type { ClassType } from './classType';
3
+ export { MembersOnly, 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
4
  LifecycleEvent, } from './src/remult3/remult3';
4
5
  export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, CaptionTransformer, } from './src/remult3/RepositoryImplementation';
5
6
  export { Entity } from './src/remult3/entity';
@@ -1,6 +1,6 @@
1
1
  import type { ClassType } from '../classType';
2
2
  import type { AllowedForInstance } from './context';
3
- import type { EntityMetadata, FieldRef, LifecycleEvent, OmitEB } from './remult3/remult3';
3
+ import type { EntityMetadata, FieldRef, LifecycleEvent } from './remult3/remult3';
4
4
  export interface FieldOptions<entityType = any, valueType = any> {
5
5
  /** A human readable name for the field. Can be used to achieve a consistent caption for a field throughout the app
6
6
  * @example
@@ -132,9 +132,9 @@ export interface FieldMetadata<valueType = any, entityType = any> {
132
132
  * @example
133
133
  * repo.fields.createDate.displayValue(task) //will display the date as defined in the `displayValue` option defined for it.
134
134
  */
135
- displayValue(item: Partial<OmitEB<entityType>>): string;
136
- apiUpdateAllowed(item?: Partial<OmitEB<entityType>>): boolean;
137
- includedInApi(item?: Partial<OmitEB<entityType>>): boolean;
135
+ displayValue(item: Partial<entityType>): string;
136
+ apiUpdateAllowed(item?: Partial<entityType>): boolean;
137
+ includedInApi(item?: Partial<entityType>): boolean;
138
138
  /** Adapts the value for usage with html input
139
139
  * @example
140
140
  * @Fields.dateOnly()
@@ -1,5 +1,5 @@
1
1
  import type { Filter } from './filter/filter-interfaces';
2
- import type { EntityMetadata, OmitEB, OmitFunctions } from './remult3/remult3';
2
+ import type { EntityMetadata, MembersOnly } 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<OmitFunctions<OmitEB<entityType>>>]?: string;
36
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: string;
37
37
  };
38
38
  stack?: string;
39
39
  exception?: any;
@@ -1,24 +1,3 @@
1
- import type { EntityDataProvider, EntityDataProviderFindOptions } from '../data-interfaces';
2
- import { type EntityDbNamesBase } from '../filter/filter-consumer-bridge-to-sql-request';
3
- import { Filter } from '../filter/filter-interfaces';
4
- import type { EntityFilter, EntityMetadata } from '../remult3/remult3';
5
- export declare class ArrayEntityDataProvider implements EntityDataProvider {
6
- private entity;
7
- static rawFilter(filter: CustomArrayFilter): EntityFilter<any>;
8
- private rows;
9
- constructor(entity: EntityMetadata, rows?: any[]);
10
- __names: EntityDbNamesBase;
11
- init(): Promise<EntityDbNamesBase>;
12
- private verifyThatRowHasAllNotNullColumns;
13
- count(where?: Filter): Promise<number>;
14
- find(options?: EntityDataProviderFindOptions): Promise<any[]>;
15
- translateFromJson(row: any, dbNames: EntityDbNamesBase): {};
16
- translateToJson(row: any, dbNames: EntityDbNamesBase): {};
17
- private idMatches;
18
- update(id: any, data: any): Promise<any>;
19
- delete(id: any): Promise<void>;
20
- insert(data: any): Promise<any>;
21
- }
22
1
  export type CustomArrayFilter = (item: any) => boolean;
23
2
  export interface CustomArrayFilterObject {
24
3
  arrayFilter: CustomArrayFilter;
@@ -1,6 +1,7 @@
1
1
  import { CompoundIdField } from '../CompoundIdField';
2
2
  import { dbNamesOf, isDbReadonly, } from '../filter/filter-consumer-bridge-to-sql-request';
3
3
  import { Filter, customDatabaseFilterToken } from '../filter/filter-interfaces';
4
+ //@internal
4
5
  export class ArrayEntityDataProvider {
5
6
  entity;
6
7
  static rawFilter(filter) {
@@ -10,6 +11,7 @@ export class ArrayEntityDataProvider {
10
11
  },
11
12
  };
12
13
  }
14
+ //@internal
13
15
  rows;
14
16
  constructor(entity, rows) {
15
17
  this.entity = entity;
@@ -18,7 +20,9 @@ export class ArrayEntityDataProvider {
18
20
  else
19
21
  this.rows = rows;
20
22
  }
23
+ //@internal
21
24
  __names;
25
+ //@internal
22
26
  async init() {
23
27
  if (this.__names)
24
28
  return this.__names;
@@ -28,6 +32,7 @@ export class ArrayEntityDataProvider {
28
32
  }
29
33
  return this.__names;
30
34
  }
35
+ //@internal
31
36
  verifyThatRowHasAllNotNullColumns(r, names) {
32
37
  for (const f of this.entity.fields) {
33
38
  const key = names.$dbNameOf(f);
@@ -89,6 +94,7 @@ export class ArrayEntityDataProvider {
89
94
  });
90
95
  return [];
91
96
  }
97
+ //@internal
92
98
  translateFromJson(row, dbNames) {
93
99
  let result = {};
94
100
  for (const col of this.entity.fields) {
@@ -96,6 +102,7 @@ export class ArrayEntityDataProvider {
96
102
  }
97
103
  return result;
98
104
  }
105
+ //@internal
99
106
  translateToJson(row, dbNames) {
100
107
  let result = {};
101
108
  for (const col of this.entity.fields) {
@@ -104,6 +111,7 @@ export class ArrayEntityDataProvider {
104
111
  }
105
112
  return result;
106
113
  }
114
+ //@internal
107
115
  idMatches(id, names) {
108
116
  return (item) => {
109
117
  let x = new FilterConsumerBridgeToObject(item, names);
@@ -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, OmitFunctions } from '../remult3/remult3';
3
+ import type { EntityFilter, MembersOnly } 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<OmitFunctions<OmitEB<entityType>>>]: string;
48
+ [Properties in keyof Required<MembersOnly<entityType>>]: string;
49
49
  } & EntityDbNamesBase;
50
50
  export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>): Promise<EntityDbNames<entityType>>;
@@ -1,7 +1,6 @@
1
- import type { OmitEB } from './remult3';
2
1
  type Decorator<T = any> = (a: T, b: string, c?: any) => void;
3
2
  type Decorators<T> = T extends new (...args: any[]) => infer R ? {
4
- [K in keyof OmitEB<R>]?: Decorator;
3
+ [K in keyof R]?: Decorator;
5
4
  } : never;
6
5
  type StaticDecorators<T> = {
7
6
  [K in keyof T]?: Decorator;
@@ -35,37 +35,27 @@ export declare class Relations {
35
35
  * @Relations.toOne(() => Customer)
36
36
  * customer?: Customer;
37
37
  * ```
38
- */
39
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options?: FieldOptions<entityType, toEntityType> & Pick<RelationOptions<entityType, toEntityType, any, any>, 'defaultIncluded'>): ClassFieldDecorator<entityType, toEntityType | undefined>;
40
- /**
41
- * Define a to-one relation between entities, indicating a one-to-one relationship.
42
- * If no `fieldInMyEntity` is provided, this overload will automatically create a field in the database
43
- * to represent the relation.
44
- *
45
- * @param toEntityType A function that returns the target entity type.
46
- * @param fieldInMyEntity (Optional): The field in the current entity that represents the relation.
47
- * Use this if you want to specify a custom field name for the relation.
48
- * @returns A decorator function to apply the to-one relation to an entity field.
49
- *
50
- * Example usage:
51
38
  * ```
52
- * @Relations.toOne(() => Customer)
39
+ * Fields.string()
40
+ * customerId?: string;
41
+ *
42
+ * @Relations.toOne(() => Customer, "customerId")
53
43
  * customer?: Customer;
54
44
  * ```
55
- */
56
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
57
- /**
58
- * Define a to-one relation between entities, indicating a one-to-one relationship.
59
- * If no field or fields are provided, it will automatically create a field in the database
60
- * to represent the relation.
61
- *
62
- * @param toEntityType A function that returns the target entity type.
63
- * @param options An object containing options for configuring the to-one relation.
64
- * - fields (Optional): An object specifying custom field names for the relation.
65
- * @returns A decorator function to apply the virtual to-one relation to an entity field.
45
+ * ```
46
+ * Fields.string()
47
+ * customerId?: string;
66
48
  *
67
- * Example usage:
49
+ * @Relations.toOne(() => Customer, {
50
+ * field: "customerId",
51
+ * defaultIncluded: true
52
+ * })
53
+ * customer?: Customer;
68
54
  * ```
55
+ * ```
56
+ * Fields.string()
57
+ * customerId?: string;
58
+ *
69
59
  * @Relations.toOne(() => Customer, {
70
60
  * fields: {
71
61
  * customerId: "id",
@@ -73,10 +63,8 @@ export declare class Relations {
73
63
  * })
74
64
  * customer?: Customer;
75
65
  * ```
76
- */
77
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'field'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
78
- /** A to one relation with fields defined in the field/fields parameter */
79
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'fields'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
66
+ */
67
+ static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options?: FieldOptions<entityType, toEntityType> & Pick<RelationOptions<entityType, toEntityType, any, any>, 'defaultIncluded'> | RelationOptions<entityType, toEntityType, entityType> | keyof entityType): (target: any, context: string | ClassFieldDecoratorContextStub<any, toEntityType>, c?: any) => void;
80
68
  /**
81
69
  * Define a toMany relation between entities, indicating a one-to-many relationship.
82
70
  * This method allows you to establish a relationship where one entity can have multiple related entities.
@@ -88,6 +88,49 @@ export class Fields {
88
88
  }
89
89
  }
90
90
  export class Relations {
91
+ /**
92
+ * Define a to-one relation between entities, indicating a one-to-one relationship.
93
+ * If no field or fields are provided, it will automatically create a field in the database
94
+ * to represent the relation.
95
+ *
96
+ * @param toEntityType A function that returns the target entity type.
97
+ * @param options (Optional): An object containing options for configuring the to-one relation.
98
+ * @returns A decorator function to apply the to-one relation to an entity field.
99
+ *
100
+ * Example usage:
101
+ * ```
102
+ * @Relations.toOne(() => Customer)
103
+ * customer?: Customer;
104
+ * ```
105
+ * ```
106
+ * Fields.string()
107
+ * customerId?: string;
108
+ *
109
+ * @Relations.toOne(() => Customer, "customerId")
110
+ * customer?: Customer;
111
+ * ```
112
+ * ```
113
+ * Fields.string()
114
+ * customerId?: string;
115
+ *
116
+ * @Relations.toOne(() => Customer, {
117
+ * field: "customerId",
118
+ * defaultIncluded: true
119
+ * })
120
+ * customer?: Customer;
121
+ * ```
122
+ * ```
123
+ * Fields.string()
124
+ * customerId?: string;
125
+ *
126
+ * @Relations.toOne(() => Customer, {
127
+ * fields: {
128
+ * customerId: "id",
129
+ * },
130
+ * })
131
+ * customer?: Customer;
132
+ * ```
133
+ */
91
134
  static toOne(toEntityType, options) {
92
135
  let op = (typeof options === 'string'
93
136
  ? { field: options }
@@ -3,7 +3,7 @@ import { LookupColumn } from '../column';
3
3
  import type { FieldMetadata, FieldOptions, ValueConverter, ValueListItem } from '../column-interfaces';
4
4
  import { Remult } from '../context';
5
5
  import type { EntityOptions } from '../entity';
6
- import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, LoadOptions, OmitEB, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
6
+ import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, LoadOptions, MembersOnly, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
7
7
  import type { RefSubscriber } from './remult3';
8
8
  import type { entityEventListener } from '../__EntityValueProvider';
9
9
  import type { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo } from '../data-interfaces';
@@ -38,19 +38,19 @@ export declare class RepositoryImplementation<entityType> implements Repository<
38
38
  id?: string;
39
39
  } ? string : string | number): Promise<void>;
40
40
  delete(item: entityType): Promise<void>;
41
- insert(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
42
- insert(item: Partial<OmitEB<entityType>>): Promise<entityType>;
41
+ insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
42
+ insert(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
43
43
  get fields(): FieldsMetadata<entityType>;
44
- validate(entity: Partial<OmitEB<entityType>>, ...fields: Extract<keyof OmitEB<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
44
+ validate(entity: Partial<MembersOnly<entityType>>, ...fields: Extract<keyof MembersOnly<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
45
45
  update(id: entityType extends {
46
46
  id?: number;
47
47
  } ? number : entityType extends {
48
48
  id?: string;
49
- } ? string : string | number, item: Partial<OmitEB<entityType>>): Promise<entityType>;
50
- update(originalItem: Partial<OmitEB<entityType>>, item: Partial<OmitEB<entityType>>): Promise<entityType>;
49
+ } ? string : string | number, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
50
+ update(originalItem: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
51
51
  private getRefForExistingRow;
52
- save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
53
- save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
52
+ save(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
53
+ save(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
54
54
  liveQuery(options?: FindOptions<entityType>): LiveQuery<entityType>;
55
55
  rawFind(options: FindOptions<entityType>, skipOrderByAndLimit: boolean, loader: RelationLoader): Promise<entityType[]>;
56
56
  find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
@@ -64,7 +64,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
64
64
  private cache;
65
65
  findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType>;
66
66
  private fieldsOf;
67
- create(item?: Partial<OmitEB<entityType>>): entityType;
67
+ create(item?: Partial<MembersOnly<entityType>>): entityType;
68
68
  fixTypes(item: any): Promise<any>;
69
69
  findId(id: any, options?: FindFirstOptionsBase<entityType>): Promise<entityType>;
70
70
  }
@@ -259,12 +259,13 @@ export declare const storableMember: unique symbol;
259
259
  export declare function buildOptions<entityType = any, valueType = any>(options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[], remult: Remult): FieldOptions<entityType, valueType>;
260
260
  export declare function decorateColumnSettings<valueType>(settings: FieldOptions<any, valueType>, remult: Remult): FieldOptions<any, valueType>;
261
261
  export declare class EntityBase {
262
- get _(): EntityRef<this>;
262
+ ['י'](): EntityRef<this>;
263
+ get _(): ReturnType<this["י"]>;
263
264
  save(): Promise<this>;
264
265
  assign(values: Partial<Omit<this, keyof EntityBase>>): this;
265
266
  delete(): Promise<void>;
266
267
  isNew(): boolean;
267
- get $(): FieldsRef<this>;
268
+ get $(): this["_"]["fields"];
268
269
  }
269
270
  export declare class ControllerBase {
270
271
  protected remult: Remult;
@@ -259,6 +259,7 @@ export class RepositoryImplementation {
259
259
  let f = ref.fields[key];
260
260
  if (entity[key] === undefined && getRelationInfo(f.metadata.options))
261
261
  continue;
262
+ //@ts-ignore
262
263
  if (f)
263
264
  r[key] = entity[key];
264
265
  }
@@ -2114,11 +2115,14 @@ export function decorateColumnSettings(settings, remult) {
2114
2115
  return settings;
2115
2116
  }
2116
2117
  export class EntityBase {
2118
+ ['י']() {
2119
+ return getEntityRef(this);
2120
+ }
2117
2121
  get _() {
2118
2122
  return getEntityRef(this);
2119
2123
  }
2120
2124
  save() {
2121
- return this._.save();
2125
+ return getEntityRef(this).save();
2122
2126
  }
2123
2127
  assign(values) {
2124
2128
  assign(this, values);
@@ -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 OmitFunctions<OmitEB<entityType>>]: NonNullable<entityType[Properties]> extends {
92
+ [Properties in keyof MembersOnly<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 OmitFunctions<OmitEB<entityType>>]: FieldMetadata<entityType[Properties], entityType>;
101
+ [Properties in keyof MembersOnly<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<OmitFunctions<OmitEB<entityType>>>): any;
144
+ getId(item: Partial<MembersOnly<entityType>>): any;
145
145
  field: FieldMetadata<any>;
146
146
  getIdFilter(...ids: any[]): EntityFilter<entityType>;
147
147
  isIdField(col: FieldMetadata): boolean;
148
- createIdInFilter(items: Partial<OmitFunctions<OmitEB<entityType>>>[]): EntityFilter<entityType>;
148
+ createIdInFilter(items: Partial<MembersOnly<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> {
@@ -199,8 +199,9 @@ export interface EntityMetadata<entityType = any> {
199
199
  /** Metadata for the Entity's id */
200
200
  readonly idMetadata: IdMetadata<entityType>;
201
201
  }
202
- export declare type OmitEB<T> = Omit<T, keyof EntityBase>;
203
- export type OmitFunctions<T> = T;
202
+ export declare type MembersOnly<T> = {
203
+ [K in keyof Omit<T, keyof Pick<EntityBase, '$' | '_' | 'י'>> as T[K] extends Function ? never : K]: T[K];
204
+ };
204
205
  export declare type idType<entityType> = entityType extends {
205
206
  id?: number;
206
207
  } ? number : entityType extends {
@@ -249,21 +250,21 @@ export interface Repository<entityType> {
249
250
  * // Can also be used to validate specific fields
250
251
  * const error = repo.validate(task,"title")
251
252
  */
252
- validate(item: Partial<entityType>, ...fields: Extract<keyof OmitFunctions<OmitEB<entityType>>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
253
+ validate(item: Partial<entityType>, ...fields: Extract<keyof MembersOnly<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
253
254
  /** 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
254
255
  * @example
255
256
  * await taskRepo.save({...task, completed:true })
256
257
  */
257
- save(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
258
- save(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
258
+ save(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
259
+ save(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
259
260
  /**Insert an item or item[] to the data source
260
261
  * @example
261
262
  * await taskRepo.insert({title:"task a"})
262
263
  * @example
263
264
  * await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
264
265
  */
265
- insert(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
266
- insert(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
266
+ insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
267
+ insert(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
267
268
  /** Updates an item, based on its `id`
268
269
  * @example
269
270
  * taskRepo.update(task.id,{...task,completed:true})
@@ -272,17 +273,17 @@ export interface Repository<entityType> {
272
273
  id?: number;
273
274
  } ? number : entityType extends {
274
275
  id?: string;
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
+ } ? string : string | number, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
277
+ update(id: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
277
278
  /** Deletes an Item*/
278
279
  delete(id: entityType extends {
279
280
  id?: number;
280
281
  } ? number : entityType extends {
281
282
  id?: string;
282
283
  } ? string : string | number): Promise<void>;
283
- delete(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<void>;
284
+ delete(item: Partial<MembersOnly<entityType>>): Promise<void>;
284
285
  /** 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 */
285
- create(item?: Partial<OmitFunctions<OmitEB<entityType>>>): entityType;
286
+ create(item?: Partial<MembersOnly<entityType>>): entityType;
286
287
  toJson(item: Promise<entityType[]>): Promise<any[]>;
287
288
  toJson(item: entityType[]): any[];
288
289
  toJson(item: Promise<entityType>): Promise<any>;
@@ -339,15 +340,15 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
339
340
  * await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
340
341
  */
341
342
  export declare type EntityOrderBy<entityType> = {
342
- [Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: 'asc' | 'desc';
343
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: 'asc' | 'desc';
343
344
  };
344
345
  /**Used to filter the desired result set
345
346
  * @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
346
347
  */
347
348
  export declare type EntityFilter<entityType> = {
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 {
349
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: (Partial<entityType>[Properties] extends number | Date | undefined ? ComparisonValueFilter<Partial<entityType>[Properties]> : Partial<entityType>[Properties] extends string | undefined ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<entityType>[Properties] extends boolean | undefined ? ValueFilter<boolean> : Partial<entityType>[Properties] extends {
349
350
  id?: string | number;
350
- } | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) | ContainsStringValueFilter;
351
+ } | undefined ? IdFilter<Partial<entityType>[Properties]> : ValueFilter<Partial<entityType>[Properties]>) | ContainsStringValueFilter;
351
352
  } & {
352
353
  $or?: EntityFilter<entityType>[];
353
354
  $and?: EntityFilter<entityType>[];
@@ -523,11 +524,11 @@ export type RelationOptions<fromEntity, toEntity, matchIdEntity, optionsType ext
523
524
  */
524
525
  defaultIncluded?: boolean;
525
526
  } & Pick<FieldOptions, 'caption'>;
526
- export type ObjectMembersOnly<T> = {
527
+ export type ObjectMembersOnly<T> = MembersOnly<{
527
528
  [K in keyof Pick<T, {
528
529
  [K in keyof T]: T[K] extends object | undefined | null ? T[K] extends Date | undefined | null ? never : K : never;
529
530
  }[keyof T]>]: T[K];
530
- };
531
+ }>;
531
532
  export type MembersToInclude<T> = {
532
533
  [K in keyof ObjectMembersOnly<T>]?: boolean | (NonNullable<T[K]> extends Array<any> ? FindOptions<NonNullable<T[K]>[number]> : FindFirstOptions<NonNullable<T[K]>>);
533
534
  };
@@ -537,7 +538,7 @@ export type RepositoryRelations<entityType> = {
537
538
  } : never;
538
539
  };
539
540
  export declare type EntityIdFields<entityType> = {
540
- [Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: true;
541
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: true;
541
542
  };
542
543
  export interface ClassFieldDecoratorContextStub<entityType, valueType> {
543
544
  readonly access: {
@@ -34,11 +34,6 @@ remult.apiClient.url='localhost:3007/api
34
34
  //p2 - Field(()=>String) - doesn't play nice with strict mode - it prevents people from extending basic types
35
35
  //p2 - with remult for remultexpress
36
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 - YONI - trieed to implement this with OmitFunctions - but it breaks this.$.[something] a good name from fields and relations
42
37
  //p2 - filterToRaw should get a dbnames of - and we should create a dbnames of that supports an alias
43
38
  //y2 - livequery for findfirst (@JY)
44
39
  //y2 - #239 - (@JY) add a way to get from fieldMetadata back to entity repo (like we have in fieldRef)
@@ -49,8 +44,6 @@ remult.apiClient.url='localhost:3007/api
49
44
  //p2 - fix sql log to console to make more sense
50
45
  //p2 - type metadata.key - to keyof entity - based on cwis input
51
46
  //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
47
  //y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
55
48
  //p2 - get backend methods to work when specifying types for date, and entities as poco's
56
49
  //p2 - allow find options preprocessor for api calls, to use for authorization
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ClassType } from './classType';
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
2
+ export type { ClassType } from './classType';
3
+ export { MembersOnly, 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
4
  LifecycleEvent, } from './src/remult3/remult3';
4
5
  export { EntityBase, ControllerBase, FieldType, getFields, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, CaptionTransformer, } from './src/remult3/RepositoryImplementation';
5
6
  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.34",
3
+ "version": "0.23.0-exp.35",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "types": "index.d.ts",
6
6
  "module": "esm/index.js",
@@ -69,6 +69,14 @@
69
69
  },
70
70
  "import": "./esm/remult-fastify.js"
71
71
  },
72
+ "./remult-hapi": {
73
+ "require": "./remult-hapi.js",
74
+ "node": {
75
+ "require": "./remult-hapi.js",
76
+ "import": "./remult-hapi.js"
77
+ },
78
+ "import": "./esm/remult-hapi.js"
79
+ },
72
80
  "./remult-fresh": {
73
81
  "require": "./remult-fresh.js",
74
82
  "node": {
@@ -1,6 +1,6 @@
1
1
  import type { ClassType } from '../classType';
2
2
  import type { AllowedForInstance } from './context';
3
- import type { EntityMetadata, FieldRef, LifecycleEvent, OmitEB } from './remult3/remult3';
3
+ import type { EntityMetadata, FieldRef, LifecycleEvent } from './remult3/remult3';
4
4
  export interface FieldOptions<entityType = any, valueType = any> {
5
5
  /** A human readable name for the field. Can be used to achieve a consistent caption for a field throughout the app
6
6
  * @example
@@ -132,9 +132,9 @@ export interface FieldMetadata<valueType = any, entityType = any> {
132
132
  * @example
133
133
  * repo.fields.createDate.displayValue(task) //will display the date as defined in the `displayValue` option defined for it.
134
134
  */
135
- displayValue(item: Partial<OmitEB<entityType>>): string;
136
- apiUpdateAllowed(item?: Partial<OmitEB<entityType>>): boolean;
137
- includedInApi(item?: Partial<OmitEB<entityType>>): boolean;
135
+ displayValue(item: Partial<entityType>): string;
136
+ apiUpdateAllowed(item?: Partial<entityType>): boolean;
137
+ includedInApi(item?: Partial<entityType>): boolean;
138
138
  /** Adapts the value for usage with html input
139
139
  * @example
140
140
  * @Fields.dateOnly()
@@ -1,5 +1,5 @@
1
1
  import type { Filter } from './filter/filter-interfaces';
2
- import type { EntityMetadata, OmitEB, OmitFunctions } from './remult3/remult3';
2
+ import type { EntityMetadata, MembersOnly } 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<OmitFunctions<OmitEB<entityType>>>]?: string;
36
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: string;
37
37
  };
38
38
  stack?: string;
39
39
  exception?: any;
@@ -1,24 +1,3 @@
1
- import type { EntityDataProvider, EntityDataProviderFindOptions } from '../data-interfaces';
2
- import { type EntityDbNamesBase } from '../filter/filter-consumer-bridge-to-sql-request';
3
- import { Filter } from '../filter/filter-interfaces';
4
- import type { EntityFilter, EntityMetadata } from '../remult3/remult3';
5
- export declare class ArrayEntityDataProvider implements EntityDataProvider {
6
- private entity;
7
- static rawFilter(filter: CustomArrayFilter): EntityFilter<any>;
8
- private rows;
9
- constructor(entity: EntityMetadata, rows?: any[]);
10
- __names: EntityDbNamesBase;
11
- init(): Promise<EntityDbNamesBase>;
12
- private verifyThatRowHasAllNotNullColumns;
13
- count(where?: Filter): Promise<number>;
14
- find(options?: EntityDataProviderFindOptions): Promise<any[]>;
15
- translateFromJson(row: any, dbNames: EntityDbNamesBase): {};
16
- translateToJson(row: any, dbNames: EntityDbNamesBase): {};
17
- private idMatches;
18
- update(id: any, data: any): Promise<any>;
19
- delete(id: any): Promise<void>;
20
- insert(data: any): Promise<any>;
21
- }
22
1
  export type CustomArrayFilter = (item: any) => boolean;
23
2
  export interface CustomArrayFilterObject {
24
3
  arrayFilter: CustomArrayFilter;
@@ -5,6 +5,7 @@ var tslib_1 = require("tslib");
5
5
  var CompoundIdField_1 = require("../CompoundIdField");
6
6
  var filter_consumer_bridge_to_sql_request_1 = require("../filter/filter-consumer-bridge-to-sql-request");
7
7
  var filter_interfaces_1 = require("../filter/filter-interfaces");
8
+ //@internal
8
9
  var ArrayEntityDataProvider = /** @class */ (function () {
9
10
  function ArrayEntityDataProvider(entity, rows) {
10
11
  this.entity = entity;
@@ -21,6 +22,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
21
22
  },
22
23
  _a;
23
24
  };
25
+ //@internal
24
26
  ArrayEntityDataProvider.prototype.init = function () {
25
27
  return tslib_1.__awaiter(this, void 0, void 0, function () {
26
28
  var _a, _b, _c, r;
@@ -52,6 +54,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
52
54
  });
53
55
  });
54
56
  };
57
+ //@internal
55
58
  ArrayEntityDataProvider.prototype.verifyThatRowHasAllNotNullColumns = function (r, names) {
56
59
  var e_2, _a;
57
60
  try {
@@ -145,6 +148,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
145
148
  });
146
149
  });
147
150
  };
151
+ //@internal
148
152
  ArrayEntityDataProvider.prototype.translateFromJson = function (row, dbNames) {
149
153
  var e_3, _a;
150
154
  var result = {};
@@ -163,6 +167,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
163
167
  }
164
168
  return result;
165
169
  };
170
+ //@internal
166
171
  ArrayEntityDataProvider.prototype.translateToJson = function (row, dbNames) {
167
172
  var e_4, _a;
168
173
  var result = {};
@@ -182,6 +187,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
182
187
  }
183
188
  return result;
184
189
  };
190
+ //@internal
185
191
  ArrayEntityDataProvider.prototype.idMatches = function (id, names) {
186
192
  var _this = this;
187
193
  return function (item) {
@@ -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, OmitFunctions } from '../remult3/remult3';
3
+ import type { EntityFilter, MembersOnly } 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<OmitFunctions<OmitEB<entityType>>>]: string;
48
+ [Properties in keyof Required<MembersOnly<entityType>>]: string;
49
49
  } & EntityDbNamesBase;
50
50
  export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>): Promise<EntityDbNames<entityType>>;
@@ -1,7 +1,6 @@
1
- import type { OmitEB } from './remult3';
2
1
  type Decorator<T = any> = (a: T, b: string, c?: any) => void;
3
2
  type Decorators<T> = T extends new (...args: any[]) => infer R ? {
4
- [K in keyof OmitEB<R>]?: Decorator;
3
+ [K in keyof R]?: Decorator;
5
4
  } : never;
6
5
  type StaticDecorators<T> = {
7
6
  [K in keyof T]?: Decorator;
@@ -35,37 +35,27 @@ export declare class Relations {
35
35
  * @Relations.toOne(() => Customer)
36
36
  * customer?: Customer;
37
37
  * ```
38
- */
39
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options?: FieldOptions<entityType, toEntityType> & Pick<RelationOptions<entityType, toEntityType, any, any>, 'defaultIncluded'>): ClassFieldDecorator<entityType, toEntityType | undefined>;
40
- /**
41
- * Define a to-one relation between entities, indicating a one-to-one relationship.
42
- * If no `fieldInMyEntity` is provided, this overload will automatically create a field in the database
43
- * to represent the relation.
44
- *
45
- * @param toEntityType A function that returns the target entity type.
46
- * @param fieldInMyEntity (Optional): The field in the current entity that represents the relation.
47
- * Use this if you want to specify a custom field name for the relation.
48
- * @returns A decorator function to apply the to-one relation to an entity field.
49
- *
50
- * Example usage:
51
38
  * ```
52
- * @Relations.toOne(() => Customer)
39
+ * Fields.string()
40
+ * customerId?: string;
41
+ *
42
+ * @Relations.toOne(() => Customer, "customerId")
53
43
  * customer?: Customer;
54
44
  * ```
55
- */
56
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, fieldInMyEntity?: keyof entityType): ClassFieldDecorator<entityType, toEntityType | undefined>;
57
- /**
58
- * Define a to-one relation between entities, indicating a one-to-one relationship.
59
- * If no field or fields are provided, it will automatically create a field in the database
60
- * to represent the relation.
61
- *
62
- * @param toEntityType A function that returns the target entity type.
63
- * @param options An object containing options for configuring the to-one relation.
64
- * - fields (Optional): An object specifying custom field names for the relation.
65
- * @returns A decorator function to apply the virtual to-one relation to an entity field.
45
+ * ```
46
+ * Fields.string()
47
+ * customerId?: string;
66
48
  *
67
- * Example usage:
49
+ * @Relations.toOne(() => Customer, {
50
+ * field: "customerId",
51
+ * defaultIncluded: true
52
+ * })
53
+ * customer?: Customer;
68
54
  * ```
55
+ * ```
56
+ * Fields.string()
57
+ * customerId?: string;
58
+ *
69
59
  * @Relations.toOne(() => Customer, {
70
60
  * fields: {
71
61
  * customerId: "id",
@@ -73,10 +63,8 @@ export declare class Relations {
73
63
  * })
74
64
  * customer?: Customer;
75
65
  * ```
76
- */
77
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'field'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
78
- /** A to one relation with fields defined in the field/fields parameter */
79
- static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options: Omit<RelationOptions<entityType, toEntityType, entityType>, keyof Pick<RelationOptions<entityType, toEntityType, entityType>, 'fields'>>): ClassFieldDecorator<entityType, toEntityType | undefined>;
66
+ */
67
+ static toOne<entityType, toEntityType>(toEntityType: () => ClassType<toEntityType>, options?: FieldOptions<entityType, toEntityType> & Pick<RelationOptions<entityType, toEntityType, any, any>, 'defaultIncluded'> | RelationOptions<entityType, toEntityType, entityType> | keyof entityType): (target: any, context: string | ClassFieldDecoratorContextStub<any, toEntityType>, c?: any) => void;
80
68
  /**
81
69
  * Define a toMany relation between entities, indicating a one-to-many relationship.
82
70
  * This method allows you to establish a relationship where one entity can have multiple related entities.
@@ -156,6 +156,49 @@ exports.Fields = Fields;
156
156
  var Relations = /** @class */ (function () {
157
157
  function Relations() {
158
158
  }
159
+ /**
160
+ * Define a to-one relation between entities, indicating a one-to-one relationship.
161
+ * If no field or fields are provided, it will automatically create a field in the database
162
+ * to represent the relation.
163
+ *
164
+ * @param toEntityType A function that returns the target entity type.
165
+ * @param options (Optional): An object containing options for configuring the to-one relation.
166
+ * @returns A decorator function to apply the to-one relation to an entity field.
167
+ *
168
+ * Example usage:
169
+ * ```
170
+ * @Relations.toOne(() => Customer)
171
+ * customer?: Customer;
172
+ * ```
173
+ * ```
174
+ * Fields.string()
175
+ * customerId?: string;
176
+ *
177
+ * @Relations.toOne(() => Customer, "customerId")
178
+ * customer?: Customer;
179
+ * ```
180
+ * ```
181
+ * Fields.string()
182
+ * customerId?: string;
183
+ *
184
+ * @Relations.toOne(() => Customer, {
185
+ * field: "customerId",
186
+ * defaultIncluded: true
187
+ * })
188
+ * customer?: Customer;
189
+ * ```
190
+ * ```
191
+ * Fields.string()
192
+ * customerId?: string;
193
+ *
194
+ * @Relations.toOne(() => Customer, {
195
+ * fields: {
196
+ * customerId: "id",
197
+ * },
198
+ * })
199
+ * customer?: Customer;
200
+ * ```
201
+ */
159
202
  Relations.toOne = function (toEntityType, options) {
160
203
  var _a, _b;
161
204
  var op = (typeof options === 'string'
@@ -3,7 +3,7 @@ import { LookupColumn } from '../column';
3
3
  import type { FieldMetadata, FieldOptions, ValueConverter, ValueListItem } from '../column-interfaces';
4
4
  import { Remult } from '../context';
5
5
  import type { EntityOptions } from '../entity';
6
- import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, LoadOptions, OmitEB, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
6
+ import type { ControllerRef, EntityFilter, EntityMetadata, EntityOrderBy, EntityRef, FieldRef, FieldsMetadata, FieldsRef, FindFirstOptions, FindFirstOptionsBase, FindOptions, IdMetadata, LiveQuery, LoadOptions, MembersOnly, QueryOptions, QueryResult, Repository, RepositoryRelations, Subscribable } from './remult3';
7
7
  import type { RefSubscriber } from './remult3';
8
8
  import type { entityEventListener } from '../__EntityValueProvider';
9
9
  import type { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo } from '../data-interfaces';
@@ -38,19 +38,19 @@ export declare class RepositoryImplementation<entityType> implements Repository<
38
38
  id?: string;
39
39
  } ? string : string | number): Promise<void>;
40
40
  delete(item: entityType): Promise<void>;
41
- insert(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
42
- insert(item: Partial<OmitEB<entityType>>): Promise<entityType>;
41
+ insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
42
+ insert(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
43
43
  get fields(): FieldsMetadata<entityType>;
44
- validate(entity: Partial<OmitEB<entityType>>, ...fields: Extract<keyof OmitEB<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
44
+ validate(entity: Partial<MembersOnly<entityType>>, ...fields: Extract<keyof MembersOnly<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
45
45
  update(id: entityType extends {
46
46
  id?: number;
47
47
  } ? number : entityType extends {
48
48
  id?: string;
49
- } ? string : string | number, item: Partial<OmitEB<entityType>>): Promise<entityType>;
50
- update(originalItem: Partial<OmitEB<entityType>>, item: Partial<OmitEB<entityType>>): Promise<entityType>;
49
+ } ? string : string | number, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
50
+ update(originalItem: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
51
51
  private getRefForExistingRow;
52
- save(item: Partial<OmitEB<entityType>>[]): Promise<entityType[]>;
53
- save(item: Partial<OmitEB<entityType>>): Promise<entityType>;
52
+ save(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
53
+ save(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
54
54
  liveQuery(options?: FindOptions<entityType>): LiveQuery<entityType>;
55
55
  rawFind(options: FindOptions<entityType>, skipOrderByAndLimit: boolean, loader: RelationLoader): Promise<entityType[]>;
56
56
  find(options: FindOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType[]>;
@@ -64,7 +64,7 @@ export declare class RepositoryImplementation<entityType> implements Repository<
64
64
  private cache;
65
65
  findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>, skipOrderByAndLimit?: boolean): Promise<entityType>;
66
66
  private fieldsOf;
67
- create(item?: Partial<OmitEB<entityType>>): entityType;
67
+ create(item?: Partial<MembersOnly<entityType>>): entityType;
68
68
  fixTypes(item: any): Promise<any>;
69
69
  findId(id: any, options?: FindFirstOptionsBase<entityType>): Promise<entityType>;
70
70
  }
@@ -259,12 +259,13 @@ export declare const storableMember: unique symbol;
259
259
  export declare function buildOptions<entityType = any, valueType = any>(options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[], remult: Remult): FieldOptions<entityType, valueType>;
260
260
  export declare function decorateColumnSettings<valueType>(settings: FieldOptions<any, valueType>, remult: Remult): FieldOptions<any, valueType>;
261
261
  export declare class EntityBase {
262
- get _(): EntityRef<this>;
262
+ ['י'](): EntityRef<this>;
263
+ get _(): ReturnType<this["י"]>;
263
264
  save(): Promise<this>;
264
265
  assign(values: Partial<Omit<this, keyof EntityBase>>): this;
265
266
  delete(): Promise<void>;
266
267
  isNew(): boolean;
267
- get $(): FieldsRef<this>;
268
+ get $(): this["_"]["fields"];
268
269
  }
269
270
  export declare class ControllerBase {
270
271
  protected remult: Remult;
@@ -393,6 +393,7 @@ var RepositoryImplementation = /** @class */ (function () {
393
393
  f = ref.fields[key];
394
394
  if (entity[key] === undefined && (0, relationInfoMember_1.getRelationInfo)(f.metadata.options))
395
395
  continue;
396
+ //@ts-ignore
396
397
  if (f)
397
398
  r[key] = entity[key];
398
399
  }
@@ -3282,6 +3283,9 @@ exports.decorateColumnSettings = decorateColumnSettings;
3282
3283
  var EntityBase = /** @class */ (function () {
3283
3284
  function EntityBase() {
3284
3285
  }
3286
+ EntityBase.prototype['י'] = function () {
3287
+ return (0, getEntityRef_1.getEntityRef)(this);
3288
+ };
3285
3289
  Object.defineProperty(EntityBase.prototype, "_", {
3286
3290
  get: function () {
3287
3291
  return (0, getEntityRef_1.getEntityRef)(this);
@@ -3290,7 +3294,7 @@ var EntityBase = /** @class */ (function () {
3290
3294
  configurable: true
3291
3295
  });
3292
3296
  EntityBase.prototype.save = function () {
3293
- return this._.save();
3297
+ return (0, getEntityRef_1.getEntityRef)(this).save();
3294
3298
  };
3295
3299
  EntityBase.prototype.assign = function (values) {
3296
3300
  (0, assign_1.assign)(this, values);
@@ -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 OmitFunctions<OmitEB<entityType>>]: NonNullable<entityType[Properties]> extends {
92
+ [Properties in keyof MembersOnly<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 OmitFunctions<OmitEB<entityType>>]: FieldMetadata<entityType[Properties], entityType>;
101
+ [Properties in keyof MembersOnly<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<OmitFunctions<OmitEB<entityType>>>): any;
144
+ getId(item: Partial<MembersOnly<entityType>>): any;
145
145
  field: FieldMetadata<any>;
146
146
  getIdFilter(...ids: any[]): EntityFilter<entityType>;
147
147
  isIdField(col: FieldMetadata): boolean;
148
- createIdInFilter(items: Partial<OmitFunctions<OmitEB<entityType>>>[]): EntityFilter<entityType>;
148
+ createIdInFilter(items: Partial<MembersOnly<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> {
@@ -199,8 +199,9 @@ export interface EntityMetadata<entityType = any> {
199
199
  /** Metadata for the Entity's id */
200
200
  readonly idMetadata: IdMetadata<entityType>;
201
201
  }
202
- export declare type OmitEB<T> = Omit<T, keyof EntityBase>;
203
- export type OmitFunctions<T> = T;
202
+ export declare type MembersOnly<T> = {
203
+ [K in keyof Omit<T, keyof Pick<EntityBase, '$' | '_' | 'י'>> as T[K] extends Function ? never : K]: T[K];
204
+ };
204
205
  export declare type idType<entityType> = entityType extends {
205
206
  id?: number;
206
207
  } ? number : entityType extends {
@@ -249,21 +250,21 @@ export interface Repository<entityType> {
249
250
  * // Can also be used to validate specific fields
250
251
  * const error = repo.validate(task,"title")
251
252
  */
252
- validate(item: Partial<entityType>, ...fields: Extract<keyof OmitFunctions<OmitEB<entityType>>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
253
+ validate(item: Partial<entityType>, ...fields: Extract<keyof MembersOnly<entityType>, string>[]): Promise<ErrorInfo<entityType> | undefined>;
253
254
  /** 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
254
255
  * @example
255
256
  * await taskRepo.save({...task, completed:true })
256
257
  */
257
- save(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
258
- save(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
258
+ save(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
259
+ save(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
259
260
  /**Insert an item or item[] to the data source
260
261
  * @example
261
262
  * await taskRepo.insert({title:"task a"})
262
263
  * @example
263
264
  * await taskRepo.insert([{title:"task a"}, {title:"task b", completed:true }])
264
265
  */
265
- insert(item: Partial<OmitFunctions<OmitEB<entityType>>>[]): Promise<entityType[]>;
266
- insert(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<entityType>;
266
+ insert(item: Partial<MembersOnly<entityType>>[]): Promise<entityType[]>;
267
+ insert(item: Partial<MembersOnly<entityType>>): Promise<entityType>;
267
268
  /** Updates an item, based on its `id`
268
269
  * @example
269
270
  * taskRepo.update(task.id,{...task,completed:true})
@@ -272,17 +273,17 @@ export interface Repository<entityType> {
272
273
  id?: number;
273
274
  } ? number : entityType extends {
274
275
  id?: string;
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
+ } ? string : string | number, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
277
+ update(id: Partial<MembersOnly<entityType>>, item: Partial<MembersOnly<entityType>>): Promise<entityType>;
277
278
  /** Deletes an Item*/
278
279
  delete(id: entityType extends {
279
280
  id?: number;
280
281
  } ? number : entityType extends {
281
282
  id?: string;
282
283
  } ? string : string | number): Promise<void>;
283
- delete(item: Partial<OmitFunctions<OmitEB<entityType>>>): Promise<void>;
284
+ delete(item: Partial<MembersOnly<entityType>>): Promise<void>;
284
285
  /** 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 */
285
- create(item?: Partial<OmitFunctions<OmitEB<entityType>>>): entityType;
286
+ create(item?: Partial<MembersOnly<entityType>>): entityType;
286
287
  toJson(item: Promise<entityType[]>): Promise<any[]>;
287
288
  toJson(item: entityType[]): any[];
288
289
  toJson(item: Promise<entityType>): Promise<any>;
@@ -339,15 +340,15 @@ export interface FindOptions<entityType> extends FindOptionsBase<entityType> {
339
340
  * await this.remult.repo(Products).find({ orderBy: { price: "desc", name: "asc" }})
340
341
  */
341
342
  export declare type EntityOrderBy<entityType> = {
342
- [Properties in keyof Partial<OmitEB<OmitFunctions<entityType>>>]?: 'asc' | 'desc';
343
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: 'asc' | 'desc';
343
344
  };
344
345
  /**Used to filter the desired result set
345
346
  * @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
346
347
  */
347
348
  export declare type EntityFilter<entityType> = {
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 {
349
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: (Partial<entityType>[Properties] extends number | Date | undefined ? ComparisonValueFilter<Partial<entityType>[Properties]> : Partial<entityType>[Properties] extends string | undefined ? ContainsStringValueFilter & ComparisonValueFilter<string> : Partial<entityType>[Properties] extends boolean | undefined ? ValueFilter<boolean> : Partial<entityType>[Properties] extends {
349
350
  id?: string | number;
350
- } | undefined ? IdFilter<Partial<OmitEB<entityType>>[Properties]> : ValueFilter<Partial<OmitEB<entityType>>[Properties]>) | ContainsStringValueFilter;
351
+ } | undefined ? IdFilter<Partial<entityType>[Properties]> : ValueFilter<Partial<entityType>[Properties]>) | ContainsStringValueFilter;
351
352
  } & {
352
353
  $or?: EntityFilter<entityType>[];
353
354
  $and?: EntityFilter<entityType>[];
@@ -523,11 +524,11 @@ export type RelationOptions<fromEntity, toEntity, matchIdEntity, optionsType ext
523
524
  */
524
525
  defaultIncluded?: boolean;
525
526
  } & Pick<FieldOptions, 'caption'>;
526
- export type ObjectMembersOnly<T> = {
527
+ export type ObjectMembersOnly<T> = MembersOnly<{
527
528
  [K in keyof Pick<T, {
528
529
  [K in keyof T]: T[K] extends object | undefined | null ? T[K] extends Date | undefined | null ? never : K : never;
529
530
  }[keyof T]>]: T[K];
530
- };
531
+ }>;
531
532
  export type MembersToInclude<T> = {
532
533
  [K in keyof ObjectMembersOnly<T>]?: boolean | (NonNullable<T[K]> extends Array<any> ? FindOptions<NonNullable<T[K]>[number]> : FindFirstOptions<NonNullable<T[K]>>);
533
534
  };
@@ -537,7 +538,7 @@ export type RepositoryRelations<entityType> = {
537
538
  } : never;
538
539
  };
539
540
  export declare type EntityIdFields<entityType> = {
540
- [Properties in keyof Partial<OmitFunctions<OmitEB<entityType>>>]?: true;
541
+ [Properties in keyof Partial<MembersOnly<entityType>>]?: true;
541
542
  };
542
543
  export interface ClassFieldDecoratorContextStub<entityType, valueType> {
543
544
  readonly access: {
@@ -35,11 +35,6 @@ remult.apiClient.url='localhost:3007/api
35
35
  //p2 - Field(()=>String) - doesn't play nice with strict mode - it prevents people from extending basic types
36
36
  //p2 - with remult for remultexpress
37
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 - YONI - trieed to implement this with OmitFunctions - but it breaks this.$.[something] a good name from fields and relations
43
38
  //p2 - filterToRaw should get a dbnames of - and we should create a dbnames of that supports an alias
44
39
  //y2 - livequery for findfirst (@JY)
45
40
  //y2 - #239 - (@JY) add a way to get from fieldMetadata back to entity repo (like we have in fieldRef)
@@ -50,8 +45,6 @@ remult.apiClient.url='localhost:3007/api
50
45
  //p2 - fix sql log to console to make more sense
51
46
  //p2 - type metadata.key - to keyof entity - based on cwis input
52
47
  //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
48
  //y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
56
49
  //p2 - get backend methods to work when specifying types for date, and entities as poco's
57
50
  //p2 - allow find options preprocessor for api calls, to use for authorization