remult 0.24.0 → 0.24.1

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.
Files changed (82) hide show
  1. package/esm/src/data-providers/json-data-provider.js +8 -8
  2. package/esm/src/remult3/remult3.js +7 -20
  3. package/package.json +1 -1
  4. package/src/data-providers/json-data-provider.d.ts +2 -2
  5. package/src/data-providers/json-data-provider.js +39 -16
  6. package/src/remult3/remult3.d.ts +0 -20
  7. package/src/remult3/remult3.js +7 -20
  8. package/esm/SseSubscriptionServer.d.ts +0 -25
  9. package/esm/ably.d.ts +0 -13
  10. package/esm/assign.d.ts +0 -1
  11. package/esm/classType.d.ts +0 -3
  12. package/esm/graphql.d.ts +0 -14
  13. package/esm/index.d.ts +0 -46
  14. package/esm/inputTypes.d.ts +0 -9
  15. package/esm/internals.d.ts +0 -7
  16. package/esm/live-query/data-provider-live-query-storage.d.ts +0 -23
  17. package/esm/myLog.d.ts +0 -1
  18. package/esm/postgres/index.d.ts +0 -2
  19. package/esm/postgres/postgres-data-provider.d.ts +0 -36
  20. package/esm/postgres/schema-builder.d.ts +0 -20
  21. package/esm/remult-express.d.ts +0 -9
  22. package/esm/remult-fastify.d.ts +0 -6
  23. package/esm/remult-fresh.d.ts +0 -17
  24. package/esm/remult-hapi.d.ts +0 -6
  25. package/esm/remult-knex/index.d.ts +0 -30
  26. package/esm/remult-mongo.d.ts +0 -24
  27. package/esm/remult-next.d.ts +0 -25
  28. package/esm/remult-sveltekit.d.ts +0 -6
  29. package/esm/server/JsonEntityFileStorage.d.ts +0 -11
  30. package/esm/server/core.d.ts +0 -4
  31. package/esm/server/expressBridge.d.ts +0 -136
  32. package/esm/server/index.d.ts +0 -6
  33. package/esm/server/initAsyncHooks.d.ts +0 -1
  34. package/esm/server/initDataProvider.d.ts +0 -2
  35. package/esm/src/CompoundIdField.d.ts +0 -27
  36. package/esm/src/__EntityValueProvider.d.ts +0 -11
  37. package/esm/src/__RowsOfDataForTesting.d.ts +0 -3
  38. package/esm/src/buildRestDataProvider.d.ts +0 -30
  39. package/esm/src/column-interfaces.d.ts +0 -172
  40. package/esm/src/column.d.ts +0 -19
  41. package/esm/src/context.d.ts +0 -134
  42. package/esm/src/data-api.d.ts +0 -39
  43. package/esm/src/data-interfaces.d.ts +0 -41
  44. package/esm/src/data-providers/array-entity-data-provider.d.ts +0 -4
  45. package/esm/src/data-providers/in-memory-database.d.ts +0 -9
  46. package/esm/src/data-providers/json-data-provider.d.ts +0 -12
  47. package/esm/src/data-providers/rest-data-provider.d.ts +0 -39
  48. package/esm/src/data-providers/sql-database.d.ts +0 -33
  49. package/esm/src/data-providers/web-sql-data-provider.d.ts +0 -21
  50. package/esm/src/entity.d.ts +0 -126
  51. package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -51
  52. package/esm/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -0
  53. package/esm/src/filter/filter-consumer-bridge-to-url-builder.js +0 -0
  54. package/esm/src/filter/filter-interfaces.d.ts +0 -74
  55. package/esm/src/live-query/LiveQueryClient.d.ts +0 -1
  56. package/esm/src/live-query/SseSubscriptionClient.d.ts +0 -5
  57. package/esm/src/live-query/SubscriptionChannel.d.ts +0 -41
  58. package/esm/src/live-query/SubscriptionServer.d.ts +0 -38
  59. package/esm/src/remult-proxy.d.ts +0 -2
  60. package/esm/src/remult3/DecoratorReplacer.d.ts +0 -9
  61. package/esm/src/remult3/Fields.d.ts +0 -133
  62. package/esm/src/remult3/IdEntity.d.ts +0 -4
  63. package/esm/src/remult3/RepositoryImplementation.d.ts +0 -289
  64. package/esm/src/remult3/__updateEntityBasedOnWhere.d.ts +0 -2
  65. package/esm/src/remult3/columnInfo.d.ts +0 -6
  66. package/esm/src/remult3/entity.d.ts +0 -28
  67. package/esm/src/remult3/getEntityRef.d.ts +0 -9
  68. package/esm/src/remult3/relation-loader-types.d.ts +0 -7
  69. package/esm/src/remult3/relation-loader.d.ts +0 -40
  70. package/esm/src/remult3/relationInfoMember.d.ts +0 -4
  71. package/esm/src/remult3/remult3.d.ts +0 -604
  72. package/esm/src/remult3/repository-internals.d.ts +0 -14
  73. package/esm/src/resultCompoundIdFilter.d.ts +0 -3
  74. package/esm/src/server-action-info.d.ts +0 -10
  75. package/esm/src/server-action.d.ts +0 -79
  76. package/esm/src/sort.d.ts +0 -16
  77. package/esm/src/sql-command.d.ts +0 -19
  78. package/esm/src/validators.d.ts +0 -14
  79. package/esm/src/valueConverters.d.ts +0 -13
  80. package/esm/urlBuilder.d.ts +0 -6
  81. package/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -0
  82. package/src/filter/filter-consumer-bridge-to-url-builder.js +0 -0
@@ -1,136 +0,0 @@
1
- import type { ClassType } from '../classType';
2
- import type { UserInfo } from '../src/context';
3
- import { Remult } from '../src/context';
4
- import type { DataProvider } from '../src/data-interfaces';
5
- import type { LiveQueryStorage, SubscriptionServer } from '../src/live-query/SubscriptionServer';
6
- import { IdEntity } from '../src/remult3/IdEntity';
7
- import type { Repository } from '../src/remult3/remult3';
8
- import type { queuedJobInfoResponse } from '../src/server-action';
9
- export interface RemultServerOptions<RequestType> {
10
- /**Entities to use for the api */
11
- entities?: ClassType<any>[];
12
- /**Controller to use for the api */
13
- controllers?: ClassType<any>[];
14
- /** Will be called to get the current user based on the current request */
15
- getUser?: (request: RequestType) => Promise<UserInfo | undefined>;
16
- /** Will be called for each request and can be used for configuration */
17
- initRequest?: (request: RequestType, options: InitRequestOptions) => Promise<void>;
18
- /** Will be called once the server is loaded and the data provider is ready */
19
- initApi?: (remult: Remult) => void | Promise<void>;
20
- /** Data Provider to use for the api.
21
- *
22
- * @see [Connecting to a Database](https://remult.dev/docs/databases.html).
23
- */
24
- dataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>);
25
- /** Will create tables and columns in supporting databases. default: true
26
- *
27
- * @description
28
- * when set to true, it'll create entities that do not exist, and add columns that are missing.
29
- */
30
- ensureSchema?: boolean;
31
- /** The path to use for the api, default:/api
32
- *
33
- * @description
34
- * If you want to use a different api path adjust this field
35
- */
36
- rootPath?: string;
37
- /** The default limit to use for find requests that did not specify a limit */
38
- defaultGetLimit?: number;
39
- /** When set to true (default) it'll console log each api endpoint that is created */
40
- logApiEndPoints?: boolean;
41
- /** A subscription server to use for live query and message channels */
42
- subscriptionServer?: SubscriptionServer;
43
- /** A storage to use to store live queries, relevant mostly for serverless scenarios or larger scales */
44
- liveQueryStorage?: LiveQueryStorage;
45
- /** Used to store the context relevant info for re running a live query */
46
- contextSerializer?: {
47
- serialize(remult: Remult): Promise<any>;
48
- deserialize(json: any, options: InitRequestOptions): Promise<void>;
49
- };
50
- /** Storage to use for backend methods that use queue */
51
- queueStorage?: QueueStorage;
52
- }
53
- export interface InitRequestOptions {
54
- liveQueryStorage: LiveQueryStorage;
55
- readonly remult: Remult;
56
- }
57
- export declare function createRemultServerCore<RequestType>(options: RemultServerOptions<RequestType>, serverCoreOptions: ServerCoreOptions<RequestType>): RemultServer<RequestType>;
58
- export type GenericRequestHandler = (req: GenericRequestInfo, res: GenericResponse, next: VoidFunction) => void;
59
- export interface ServerHandleResponse {
60
- data?: any;
61
- statusCode: number;
62
- }
63
- export interface RemultServer<RequestType> extends RemultServerCore<RequestType> {
64
- withRemult(req: RequestType, res: GenericResponse, next: VoidFunction): any;
65
- registerRouter(r: GenericRouter): void;
66
- handle(req: RequestType, gRes?: GenericResponse): Promise<ServerHandleResponse | undefined>;
67
- withRemultPromise<T>(request: RequestType, what: () => Promise<T>): Promise<T>;
68
- }
69
- export interface RemultServerCore<RequestType> {
70
- getRemult(req: RequestType): Promise<Remult>;
71
- openApiDoc(options: {
72
- title: string;
73
- version?: string;
74
- }): any;
75
- }
76
- export type GenericRouter = {
77
- route(path: string): SpecificRoute;
78
- };
79
- export type SpecificRoute = {
80
- get(handler: GenericRequestHandler): SpecificRoute;
81
- put(handler: GenericRequestHandler): SpecificRoute;
82
- post(handler: GenericRequestHandler): SpecificRoute;
83
- delete(handler: GenericRequestHandler): SpecificRoute;
84
- };
85
- export interface GenericRequestInfo {
86
- url?: string;
87
- method?: any;
88
- query?: any;
89
- params?: any;
90
- }
91
- export interface GenericResponse {
92
- json(data: any): any;
93
- status(statusCode: number): GenericResponse;
94
- end(): any;
95
- }
96
- export interface queuedJobInfo {
97
- info: queuedJobInfoResponse;
98
- userId: string;
99
- setErrorResult(error: any): void;
100
- setResult(result: any): void;
101
- setProgress(progress: number): void;
102
- }
103
- export interface QueueStorage {
104
- createJob(url: string, userId: string): Promise<string>;
105
- getJobInfo(queuedJobId: string): Promise<queuedJobInfo>;
106
- }
107
- export declare class EntityQueueStorage implements QueueStorage {
108
- private repo;
109
- constructor(repo: Repository<JobsInQueueEntity>);
110
- sync: Promise<any>;
111
- doSync<T>(what: () => Promise<T>): Promise<any>;
112
- getJobInfo(queuedJobId: string): Promise<queuedJobInfo>;
113
- createJob(url: string, userId: string): Promise<string>;
114
- }
115
- export declare class RouteImplementation<RequestType> {
116
- private coreOptions;
117
- constructor(coreOptions: ServerCoreOptions<RequestType>);
118
- map: Map<string, Map<string, GenericRequestHandler>>;
119
- route(path: string): SpecificRoute;
120
- handle(req: RequestType, gRes?: GenericResponse): Promise<ServerHandleResponse | undefined>;
121
- middleware(origReq: RequestType, res: GenericResponse, next: VoidFunction): void;
122
- }
123
- export declare class JobsInQueueEntity extends IdEntity {
124
- userId: string;
125
- url: string;
126
- submitTime: Date;
127
- doneTime: Date;
128
- result: string;
129
- done: boolean;
130
- error: boolean;
131
- progress: number;
132
- }
133
- export interface ServerCoreOptions<RequestType> {
134
- buildGenericRequestInfo(req: RequestType): GenericRequestInfo;
135
- getRequestBody(req: RequestType): Promise<any>;
136
- }
@@ -1,6 +0,0 @@
1
- import type { RemultServer, RemultServerOptions, ServerCoreOptions } from './expressBridge';
2
- export { SseSubscriptionServer } from '../SseSubscriptionServer';
3
- export { DataProviderLiveQueryStorage } from '../live-query/data-provider-live-query-storage';
4
- export { JsonEntityFileStorage, JsonFileDataProvider, } from './JsonEntityFileStorage';
5
- export { GenericRequestHandler, GenericRequestInfo, GenericResponse, GenericRouter, InitRequestOptions, QueueStorage, RemultServer, RemultServerCore, RemultServerOptions, SpecificRoute, queuedJobInfo, } from './expressBridge';
6
- export declare function createRemultServer<RequestType>(options: RemultServerOptions<RequestType>, serverCoreOptions?: ServerCoreOptions<RequestType>): RemultServer<RequestType>;
@@ -1 +0,0 @@
1
- export declare function initAsyncHooks(): void;
@@ -1,2 +0,0 @@
1
- import type { DataProvider } from '../src/data-interfaces';
2
- export declare function initDataProvider(optionsDataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>)): Promise<DataProvider>;
@@ -1,27 +0,0 @@
1
- import type { ClassType } from '../classType';
2
- import type { FieldMetadata, FieldOptions, ValueConverter } from './column-interfaces';
3
- import type { EntityFilter } from './remult3/remult3';
4
- export declare class CompoundIdField implements FieldMetadata<string> {
5
- fields: FieldMetadata[];
6
- constructor(...columns: FieldMetadata[]);
7
- apiUpdateAllowed(item: any): boolean;
8
- displayValue(item: any): string;
9
- includedInApi(item: any): boolean;
10
- toInput(value: string, inputType?: string): string;
11
- fromInput(inputValue: string, inputType?: string): string;
12
- getDbName(): Promise<string>;
13
- getId(instance: any): string;
14
- options: FieldOptions<any, any>;
15
- get valueConverter(): Required<ValueConverter<string>>;
16
- target: ClassType<any>;
17
- readonly: true;
18
- allowNull: boolean;
19
- dbReadOnly: boolean;
20
- isServerExpression: boolean;
21
- key: string;
22
- caption: string;
23
- inputType: string;
24
- dbName: string;
25
- valueType: any;
26
- isEqualTo(value: FieldMetadata<string> | string): EntityFilter<any>;
27
- }
@@ -1,11 +0,0 @@
1
- export interface packedRowInfo {
2
- data: any;
3
- isNewRow: boolean;
4
- id: string;
5
- wasChanged: boolean;
6
- }
7
- export interface entityEventListener<entityType> {
8
- deleted?: (entity: entityType) => void;
9
- saved?: (entity: entityType, isNew: boolean) => void;
10
- validating?: (entity: entityType) => Promise<any> | any;
11
- }
@@ -1,3 +0,0 @@
1
- export interface __RowsOfDataForTesting {
2
- rows: any;
3
- }
@@ -1,30 +0,0 @@
1
- import type { RestDataProviderHttpProvider } from './data-interfaces';
2
- export declare function buildRestDataProvider(provider: ExternalHttpProvider | typeof fetch): RestDataProviderHttpProvider;
3
- export declare function isExternalHttpProvider(item: any): boolean;
4
- export declare class HttpProviderBridgeToRestDataProviderHttpProvider implements RestDataProviderHttpProvider {
5
- private http;
6
- constructor(http: ExternalHttpProvider);
7
- post(url: string, data: any): Promise<any>;
8
- delete(url: string): Promise<void>;
9
- put(url: string, data: any): Promise<any>;
10
- get(url: string): Promise<any>;
11
- }
12
- export declare function retry<T>(what: () => Promise<T>): Promise<T>;
13
- export declare function toPromise<T>(p: Promise<T> | {
14
- toPromise(): Promise<T>;
15
- }): Promise<any>;
16
- export declare function processHttpException(ex: any): Promise<any>;
17
- export interface ExternalHttpProvider {
18
- post(url: string, data: any): Promise<any> | {
19
- toPromise(): Promise<any>;
20
- };
21
- delete(url: string): Promise<void> | {
22
- toPromise(): Promise<void>;
23
- };
24
- put(url: string, data: any): Promise<any> | {
25
- toPromise(): Promise<any>;
26
- };
27
- get(url: string): Promise<any> | {
28
- toPromise(): Promise<any>;
29
- };
30
- }
@@ -1,172 +0,0 @@
1
- import type { ClassType } from '../classType';
2
- import type { AllowedForInstance } from './context';
3
- import type { EntityMetadata, FieldRef, LifecycleEvent } from './remult3/remult3';
4
- export interface FieldOptions<entityType = any, valueType = any> {
5
- /** A human readable name for the field. Can be used to achieve a consistent caption for a field throughout the app
6
- * @example
7
- * <input placeholder={taskRepo.metadata.fields.title.caption}/>
8
- */
9
- caption?: string;
10
- /** If it can store null in the database */
11
- allowNull?: boolean;
12
- /** If this field data is included in the api.
13
- * @see [allowed](http://remult.dev/docs/allowed.html)*/
14
- includeInApi?: AllowedForInstance<entityType>;
15
- /** If this field data can be updated in the api.
16
- * @see [allowed](http://remult.dev/docs/allowed.html)*/
17
- allowApiUpdate?: AllowedForInstance<entityType>;
18
- /** An arrow function that'll be used to perform validations on it
19
- * @example
20
- * @Fields.string({
21
- * validate: Validators.required
22
- * })
23
- * @example
24
- * @Fields.string<Task>({
25
- * validate: task=>{
26
- * if (task.title.length<3)
27
- * throw "Too Short";
28
- * }
29
- * })
30
- * @example
31
- * @Fields.string({
32
- * validate: (_, fieldRef)=>{
33
- * if (fieldRef.value.length<3)
34
- * fieldRef.error = "Too Short";
35
- * }
36
- * })
37
- */
38
- validate?: ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => any | Promise<any>) | ((entity: entityType, fieldRef: FieldRef<entityType, valueType>) => any | Promise<any>)[];
39
- /** Will be fired before this field is saved to the server/database */
40
- saving?: (entity: entityType, fieldRef: FieldRef<entityType, valueType>, e: LifecycleEvent<entityType>) => any | Promise<any>;
41
- /** An expression that will determine this fields value on the backend and be provided to the front end*/
42
- serverExpression?: (entity: entityType) => valueType | Promise<valueType>;
43
- /** The name of the column in the database that holds the data for this field. If no name is set, the key will be used instead.
44
- * Be aware that if you are using postgres and want to keep your casing, you have to escape your string with double quotes.
45
- * @example
46
- *
47
- * @Fields.string({ dbName: '"userName"'})
48
- * userName=''
49
- */
50
- dbName?: string;
51
- /** Used or fields that are based on an sql expressions, instead of a physical table column
52
- * @example
53
- *
54
- * @Fields.integer({
55
- * sqlExpression:e=> 'length(title)'
56
- * })
57
- * titleLength = 0;
58
- * @Fields.string()
59
- * title='';
60
- */
61
- sqlExpression?: string | ((entity: EntityMetadata<entityType>) => string | Promise<string>);
62
- /** For fields that shouldn't be part of an update or insert statement */
63
- dbReadOnly?: boolean;
64
- /** The value converter to be used when loading and saving this field */
65
- valueConverter?: ValueConverter<valueType>;
66
- /** an arrow function that translates the value to a display value */
67
- displayValue?: (entity: entityType, value: valueType) => string;
68
- /** an arrow function that determines the default value of the field, when the entity is created using the `repo.create` method */
69
- defaultValue?: (entity: entityType) => valueType | Promise<valueType>;
70
- /** The html input type for this field */
71
- inputType?: string;
72
- /**
73
- * @deprecated The 'lazy' option is deprecated and will be removed in future versions.
74
- * Use 'Relations.toOne' instead.
75
- *
76
- * Example usage:
77
- * ```
78
- * // Deprecated usage with 'lazy' option
79
- * @Field(() => Customer, { lazy: true })
80
- * customer?: Customer;
81
- *
82
- * // Preferred usage with 'Relations.toOne'
83
- * @Relations.toOne(() => Customer)
84
- * customer?: Customer;
85
- * ```
86
- */
87
- lazy?: boolean;
88
- /** The value type for this field */
89
- valueType?: any;
90
- /** The entity type to which this field belongs */
91
- target?: ClassType<entityType>;
92
- /** The key to be used for this field */
93
- key?: string;
94
- }
95
- /**Metadata for a `Field`, this metadata can be used in the user interface to provide a richer UI experience */
96
- export interface FieldMetadata<valueType = any, entityType = any> {
97
- /** The field's member name in an object.
98
- * @example
99
- * const taskRepo = remult.repo(Task);
100
- * console.log(taskRepo.metadata.fields.title.key);
101
- * // result: title
102
- */
103
- readonly key: string;
104
- /** A human readable caption for the field. Can be used to achieve a consistent caption for a field throughout the app
105
- * @example
106
- * <input placeholder={taskRepo.metadata.fields.title.caption}/>
107
- */
108
- readonly caption: string;
109
- /** The field's value type (number,string etc...) */
110
- readonly valueType: any;
111
- /** The options sent to this field's decorator */
112
- readonly options: FieldOptions;
113
- /** The `inputType` relevant for this field, determined by the options sent to it's decorator and the valueConverter in these options */
114
- readonly inputType: string;
115
- /** if null is allowed for this field */
116
- readonly allowNull: boolean;
117
- /** The class that contains this field
118
- * @example
119
- * const taskRepo = remult.repo(Task);
120
- * Task == taskRepo.metadata.fields.title.target //will return true
121
- */
122
- readonly target: ClassType<valueType>;
123
- /** Returns the dbName - based on it's `dbName` option and it's `sqlExpression` option */
124
- getDbName(): Promise<string>;
125
- /** Indicates if this field is based on a server express */
126
- readonly isServerExpression: boolean;
127
- /** indicates that this field should only be included in select statement, and excluded from update or insert. useful for db generated ids etc... */
128
- readonly dbReadOnly: boolean;
129
- /** the Value converter for this field */
130
- readonly valueConverter: Required<ValueConverter<valueType>>;
131
- /** Get the display value for a specific item
132
- * @example
133
- * repo.fields.createDate.displayValue(task) //will display the date as defined in the `displayValue` option defined for it.
134
- */
135
- displayValue(item: Partial<entityType>): string;
136
- apiUpdateAllowed(item?: Partial<entityType>): boolean;
137
- includedInApi(item?: Partial<entityType>): boolean;
138
- /** Adapts the value for usage with html input
139
- * @example
140
- * @Fields.dateOnly()
141
- * birthDate = new Date(1976,5,16)
142
- * //...
143
- * input.value = repo.fields.birthDate.toInput(person) // will return '1976-06-16'
144
- */
145
- toInput(value: valueType, inputType?: string): string;
146
- /** Adapts the value for usage with html input
147
- * @example
148
- * @Fields.dateOnly()
149
- * birthDate = new Date(1976,5,16)
150
- * //...
151
- * person.birthDate = repo.fields.birthDate.fromInput(personFormState) // will return Date
152
- */
153
- fromInput(inputValue: string, inputType?: string): valueType;
154
- }
155
- export interface ValueConverter<valueType> {
156
- fromJson?(val: any): valueType;
157
- toJson?(val: valueType): any;
158
- fromDb?(val: any): valueType;
159
- toDb?(val: valueType): any;
160
- toInput?(val: valueType, inputType?: string): string;
161
- fromInput?(val: string, inputType?: string): valueType;
162
- displayValue?(val: valueType): string;
163
- readonly fieldTypeInDb?: string;
164
- readonly inputType?: string;
165
- }
166
- export declare type FieldValidator<entityType = any, valueType = any> = (entity: entityType, fieldRef: FieldRef<entityType, valueType>) => void | Promise<void>;
167
- export declare type ValueOrExpression<valueType> = valueType | (() => valueType);
168
- export declare function valueOrExpressionToValue<valueType>(f: ValueOrExpression<valueType>): valueType;
169
- export interface ValueListItem {
170
- id?: any;
171
- caption?: any;
172
- }
@@ -1,19 +0,0 @@
1
- import type { idType, Repository } from './remult3/remult3';
2
- export declare function makeTitle(name: string): string;
3
- export declare class LookupColumn<T> {
4
- private repository;
5
- private isReferenceRelation;
6
- private allowNull;
7
- toJson(): any;
8
- setId(val: any): void;
9
- waitLoadOf(id: any): Promise<T>;
10
- get(id: any): any;
11
- storedItem?: {
12
- item: T;
13
- };
14
- set(item: T): void;
15
- id: idType<T>;
16
- constructor(repository: Repository<T>, isReferenceRelation: any, allowNull: any);
17
- get item(): T;
18
- waitLoad(): Promise<T>;
19
- }
@@ -1,134 +0,0 @@
1
- import type { ClassType } from '../classType';
2
- import type { DataProvider } from './data-interfaces';
3
- import type { EntityMetadata, EntityRef, FindOptions, Repository } from './remult3/remult3';
4
- import type { ExternalHttpProvider } from './buildRestDataProvider';
5
- import type { SubscriptionClient, Unsubscribe } from './live-query/SubscriptionChannel';
6
- import type { SubscriptionServer } from './live-query/SubscriptionServer';
7
- export declare class RemultAsyncLocalStorage {
8
- private readonly remultObjectStorage;
9
- static enable(): void;
10
- static disable(): void;
11
- constructor(remultObjectStorage: myAsyncLocalStorage<Remult>);
12
- run(remult: Remult, callback: VoidFunction): void;
13
- getRemult(): Remult;
14
- static instance: RemultAsyncLocalStorage;
15
- }
16
- type myAsyncLocalStorage<T> = {
17
- run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
18
- getStore(): T | undefined;
19
- };
20
- export declare function isBackend(): boolean;
21
- export declare class Remult {
22
- /**Return's a `Repository` of the specific entity type
23
- * @example
24
- * const taskRepo = remult.repo(Task);
25
- * @see [Repository](https://remult.dev/docs/ref_repository.html)
26
- * @param entity - the entity to use
27
- * @param dataProvider - an optional alternative data provider to use. Useful for writing to offline storage or an alternative data provider
28
- */
29
- repo<T>(entity: ClassType<T>, dataProvider?: DataProvider): Repository<T>;
30
- /** Returns the current user's info */
31
- user?: UserInfo;
32
- /** Checks if a user was authenticated */
33
- authenticated(): boolean;
34
- /** checks if the user has any of the roles specified in the parameters
35
- * @example
36
- * remult.isAllowed("admin")
37
- * @see
38
- * [Allowed](https://remult.dev/docs/allowed.html)
39
- */
40
- isAllowed(roles?: Allowed): boolean;
41
- /** checks if the user matches the allowedForInstance callback
42
- * @see
43
- * [Allowed](https://remult.dev/docs/allowed.html)
44
- */
45
- isAllowedForInstance(instance: any, allowed?: AllowedForInstance<any>): boolean;
46
- /** The current data provider */
47
- dataProvider: DataProvider;
48
- /** Creates a new instance of the `remult` object.
49
- *
50
- * Can receive either an HttpProvider or a DataProvider as a parameter - which will be used to fetch data from.
51
- *
52
- * If no provider is specified, `fetch` will be used as an http provider
53
- */
54
- constructor(http: ExternalHttpProvider | typeof fetch | ApiClient);
55
- constructor(p: DataProvider);
56
- constructor();
57
- subscriptionServer?: SubscriptionServer;
58
- /** Used to call a `backendMethod` using a specific `remult` object
59
- * @example
60
- * await remult.call(TasksController.setAll, undefined, true);
61
- * @param backendMethod - the backend method to call
62
- * @param classInstance - the class instance of the backend method, for static backend methods use undefined
63
- * @param args - the arguments to send to the backend method
64
- */
65
- call<T extends (...args: any[]) => Promise<any>>(backendMethod: T, classInstance?: any, ...args: GetArguments<T>): ReturnType<T>;
66
- /** A helper callback that can be used to debug and trace all find operations. Useful in debugging scenarios */
67
- static onFind: (metadata: EntityMetadata, options: FindOptions<any>) => void;
68
- clearAllCache(): any;
69
- /** A helper callback that is called whenever an entity is created. */
70
- static entityRefInit?: (ref: EntityRef<any>, row: any) => void;
71
- /** context information that can be used to store custom information that will be disposed as part of the `remult` object */
72
- readonly context: RemultContext;
73
- /** The api client that will be used by `remult` to perform calls to the `api` */
74
- apiClient: ApiClient;
75
- static run<T>(callback: () => T, options: {
76
- dataProvider: DataProvider;
77
- }): T;
78
- }
79
- export type GetArguments<T> = T extends (...args: infer FirstArgument) => any ? FirstArgument : never;
80
- export interface RemultContext {
81
- }
82
- export interface ApiClient {
83
- /** The http client to use when making api calls.
84
- * @example
85
- * remult.apiClient.httpClient = axios;
86
- * @example
87
- * remult.apiClient.httpClient = httpClient;//angular http client
88
- * @example
89
- * remult.apiClient.httpClient = fetch; //this is the default
90
- */
91
- httpClient?: ExternalHttpProvider | typeof fetch;
92
- /** The base url to for making api calls */
93
- url?: string;
94
- subscriptionClient?: SubscriptionClient;
95
- wrapMessageHandling?: (x: VoidFunction) => void;
96
- }
97
- export declare const allEntities: ClassType<any>[];
98
- export interface ControllerOptions {
99
- key: string;
100
- }
101
- export declare const classHelpers: Map<any, ClassHelper>;
102
- export declare class ClassHelper {
103
- classes: Map<any, ControllerOptions>;
104
- }
105
- export declare function setControllerSettings(target: any, options: ControllerOptions): void;
106
- export interface UserInfo {
107
- id: string;
108
- name?: string;
109
- roles?: string[];
110
- }
111
- export declare type Allowed = boolean | string | string[] | ((c?: Remult) => boolean);
112
- export declare type AllowedForInstance<T> = boolean | string | string[] | ((entity?: T, c?: Remult) => boolean);
113
- export declare class Allow {
114
- static everyone: () => boolean;
115
- static authenticated: (...args: any[]) => any;
116
- }
117
- export declare const queryConfig: {
118
- defaultPageSize: number;
119
- };
120
- export interface EventDispatcher {
121
- observe(what: () => any | Promise<any>): Promise<Unsubscribe>;
122
- }
123
- export declare class EventSource {
124
- listeners: (() => {})[];
125
- fire(): Promise<void>;
126
- dispatcher: EventDispatcher;
127
- }
128
- export interface itemChange {
129
- id: any;
130
- oldId: any;
131
- deleted: boolean;
132
- }
133
- export declare function doTransaction(remult: Remult, what: () => Promise<void>): Promise<void>;
134
- export {};
@@ -1,39 +0,0 @@
1
- import type { Remult } from './context';
2
- import type { ErrorInfo } from './data-interfaces';
3
- import type { FindOptions, Repository } from './remult3/remult3';
4
- export declare class DataApi<T = any> {
5
- private repository;
6
- private remult;
7
- constructor(repository: Repository<T>, remult: Remult);
8
- httpGet(res: DataApiResponse, req: DataApiRequest, serializeContext: () => Promise<any>): Promise<void>;
9
- httpPost(res: DataApiResponse, req: DataApiRequest, body: any, serializeContext: () => Promise<any>): Promise<void>;
10
- static defaultGetLimit: number;
11
- get(response: DataApiResponse, id: any): Promise<void>;
12
- count(response: DataApiResponse, request: DataApiRequest, filterBody?: any): Promise<void>;
13
- getArrayImpl(response: DataApiResponse, request: DataApiRequest, filterBody: any): Promise<{
14
- r: any[];
15
- findOptions: FindOptions<T>;
16
- }>;
17
- private includeNone;
18
- getArray(response: DataApiResponse, request: DataApiRequest, filterBody?: any): Promise<void>;
19
- liveQuery(response: DataApiResponse, request: DataApiRequest, filterBody: any, serializeContext: () => Promise<any>, queryChannel: string): Promise<void>;
20
- private buildWhere;
21
- private doOnId;
22
- put(response: DataApiResponse, id: any, body: any): Promise<void>;
23
- delete(response: DataApiResponse, id: any): Promise<void>;
24
- post(response: DataApiResponse, body: any): Promise<void>;
25
- }
26
- export interface DataApiResponse {
27
- success(data: any): void;
28
- deleted(): void;
29
- created(data: any): void;
30
- notFound(): void;
31
- error(data: ErrorInfo): void;
32
- forbidden(): void;
33
- progress(progress: number): void;
34
- }
35
- export interface DataApiRequest {
36
- get(key: string): any;
37
- }
38
- export declare function determineSort(sortUrlParm: string, dirUrlParam: string): any;
39
- export declare function serializeError(data: ErrorInfo): ErrorInfo<any>;
@@ -1,41 +0,0 @@
1
- import type { Filter } from './filter/filter-interfaces';
2
- import type { EntityMetadata, MembersOnly } from './remult3/remult3';
3
- import { Sort } from './sort';
4
- export interface DataProvider {
5
- getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
6
- transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
7
- ensureSchema?(entities: EntityMetadata[]): Promise<void>;
8
- isProxy?: boolean;
9
- }
10
- export interface Storage {
11
- ensureSchema(): Promise<void>;
12
- }
13
- export interface EntityDataProvider {
14
- count(where: Filter): Promise<number>;
15
- find(options?: EntityDataProviderFindOptions): Promise<Array<any>>;
16
- update(id: any, data: any): Promise<any>;
17
- delete(id: any): Promise<void>;
18
- insert(data: any): Promise<any>;
19
- }
20
- export interface EntityDataProviderFindOptions {
21
- where?: Filter;
22
- limit?: number;
23
- page?: number;
24
- orderBy?: Sort;
25
- }
26
- export interface RestDataProviderHttpProvider {
27
- post(url: string, data: any): Promise<any>;
28
- delete(url: string): Promise<void>;
29
- put(url: string, data: any): Promise<any>;
30
- get(url: string): Promise<any>;
31
- }
32
- export declare function extractSort(sort: any): Sort;
33
- export interface ErrorInfo<entityType = any> {
34
- message?: string;
35
- modelState?: {
36
- [Properties in keyof Partial<MembersOnly<entityType>>]?: string;
37
- };
38
- stack?: string;
39
- exception?: any;
40
- httpStatusCode?: number;
41
- }
@@ -1,4 +0,0 @@
1
- export type CustomArrayFilter = (item: any) => boolean;
2
- export interface CustomArrayFilterObject {
3
- arrayFilter: CustomArrayFilter;
4
- }
@@ -1,9 +0,0 @@
1
- import type { __RowsOfDataForTesting } from '../__RowsOfDataForTesting';
2
- import type { DataProvider, EntityDataProvider } from '../data-interfaces';
3
- import type { EntityMetadata } from '../remult3/remult3';
4
- export declare class InMemoryDataProvider implements DataProvider, __RowsOfDataForTesting {
5
- transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
6
- rows: any;
7
- getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
8
- toString(): string;
9
- }
@@ -1,12 +0,0 @@
1
- import type { DataProvider, EntityDataProvider } from '../data-interfaces';
2
- import type { EntityMetadata } from '../remult3/remult3';
3
- export interface JsonEntityStorage {
4
- getItem(entityDbName: string): string | null;
5
- setItem(entityDbName: string, json: string): any;
6
- }
7
- export declare class JsonDataProvider implements DataProvider {
8
- private storage;
9
- constructor(storage: JsonEntityStorage);
10
- getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
11
- transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
12
- }