remult 0.24.0 → 0.24.2-exp.0

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 (88) hide show
  1. package/esm/index.js +3 -2
  2. package/esm/src/data-providers/ipfs-data-provider.js +22 -0
  3. package/esm/src/data-providers/json-data-provider.js +8 -8
  4. package/esm/src/remult3/remult3.js +7 -20
  5. package/index.d.ts +3 -1
  6. package/index.js +5 -3
  7. package/package.json +1 -1
  8. package/src/data-providers/ipfs-data-provider.d.ts +5 -0
  9. package/src/data-providers/ipfs-data-provider.js +60 -0
  10. package/src/data-providers/json-data-provider.d.ts +2 -2
  11. package/src/data-providers/json-data-provider.js +39 -16
  12. package/src/remult3/remult3.d.ts +0 -20
  13. package/src/remult3/remult3.js +7 -20
  14. package/esm/SseSubscriptionServer.d.ts +0 -25
  15. package/esm/ably.d.ts +0 -13
  16. package/esm/assign.d.ts +0 -1
  17. package/esm/classType.d.ts +0 -3
  18. package/esm/graphql.d.ts +0 -14
  19. package/esm/index.d.ts +0 -46
  20. package/esm/inputTypes.d.ts +0 -9
  21. package/esm/internals.d.ts +0 -7
  22. package/esm/live-query/data-provider-live-query-storage.d.ts +0 -23
  23. package/esm/myLog.d.ts +0 -1
  24. package/esm/postgres/index.d.ts +0 -2
  25. package/esm/postgres/postgres-data-provider.d.ts +0 -36
  26. package/esm/postgres/schema-builder.d.ts +0 -20
  27. package/esm/remult-express.d.ts +0 -9
  28. package/esm/remult-fastify.d.ts +0 -6
  29. package/esm/remult-fresh.d.ts +0 -17
  30. package/esm/remult-hapi.d.ts +0 -6
  31. package/esm/remult-knex/index.d.ts +0 -30
  32. package/esm/remult-mongo.d.ts +0 -24
  33. package/esm/remult-next.d.ts +0 -25
  34. package/esm/remult-sveltekit.d.ts +0 -6
  35. package/esm/server/JsonEntityFileStorage.d.ts +0 -11
  36. package/esm/server/core.d.ts +0 -4
  37. package/esm/server/expressBridge.d.ts +0 -136
  38. package/esm/server/index.d.ts +0 -6
  39. package/esm/server/initAsyncHooks.d.ts +0 -1
  40. package/esm/server/initDataProvider.d.ts +0 -2
  41. package/esm/src/CompoundIdField.d.ts +0 -27
  42. package/esm/src/__EntityValueProvider.d.ts +0 -11
  43. package/esm/src/__RowsOfDataForTesting.d.ts +0 -3
  44. package/esm/src/buildRestDataProvider.d.ts +0 -30
  45. package/esm/src/column-interfaces.d.ts +0 -172
  46. package/esm/src/column.d.ts +0 -19
  47. package/esm/src/context.d.ts +0 -134
  48. package/esm/src/data-api.d.ts +0 -39
  49. package/esm/src/data-interfaces.d.ts +0 -41
  50. package/esm/src/data-providers/array-entity-data-provider.d.ts +0 -4
  51. package/esm/src/data-providers/in-memory-database.d.ts +0 -9
  52. package/esm/src/data-providers/json-data-provider.d.ts +0 -12
  53. package/esm/src/data-providers/rest-data-provider.d.ts +0 -39
  54. package/esm/src/data-providers/sql-database.d.ts +0 -33
  55. package/esm/src/data-providers/web-sql-data-provider.d.ts +0 -21
  56. package/esm/src/entity.d.ts +0 -126
  57. package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -51
  58. package/esm/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -0
  59. package/esm/src/filter/filter-consumer-bridge-to-url-builder.js +0 -0
  60. package/esm/src/filter/filter-interfaces.d.ts +0 -74
  61. package/esm/src/live-query/LiveQueryClient.d.ts +0 -1
  62. package/esm/src/live-query/SseSubscriptionClient.d.ts +0 -5
  63. package/esm/src/live-query/SubscriptionChannel.d.ts +0 -41
  64. package/esm/src/live-query/SubscriptionServer.d.ts +0 -38
  65. package/esm/src/remult-proxy.d.ts +0 -2
  66. package/esm/src/remult3/DecoratorReplacer.d.ts +0 -9
  67. package/esm/src/remult3/Fields.d.ts +0 -133
  68. package/esm/src/remult3/IdEntity.d.ts +0 -4
  69. package/esm/src/remult3/RepositoryImplementation.d.ts +0 -289
  70. package/esm/src/remult3/__updateEntityBasedOnWhere.d.ts +0 -2
  71. package/esm/src/remult3/columnInfo.d.ts +0 -6
  72. package/esm/src/remult3/entity.d.ts +0 -28
  73. package/esm/src/remult3/getEntityRef.d.ts +0 -9
  74. package/esm/src/remult3/relation-loader-types.d.ts +0 -7
  75. package/esm/src/remult3/relation-loader.d.ts +0 -40
  76. package/esm/src/remult3/relationInfoMember.d.ts +0 -4
  77. package/esm/src/remult3/remult3.d.ts +0 -604
  78. package/esm/src/remult3/repository-internals.d.ts +0 -14
  79. package/esm/src/resultCompoundIdFilter.d.ts +0 -3
  80. package/esm/src/server-action-info.d.ts +0 -10
  81. package/esm/src/server-action.d.ts +0 -79
  82. package/esm/src/sort.d.ts +0 -16
  83. package/esm/src/sql-command.d.ts +0 -19
  84. package/esm/src/validators.d.ts +0 -14
  85. package/esm/src/valueConverters.d.ts +0 -13
  86. package/esm/urlBuilder.d.ts +0 -6
  87. package/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -0
  88. package/src/filter/filter-consumer-bridge-to-url-builder.js +0 -0
@@ -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
- }
@@ -1,39 +0,0 @@
1
- import type { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, RestDataProviderHttpProvider } from '../data-interfaces';
2
- import { UrlBuilder } from '../../urlBuilder';
3
- import { type ApiClient } from '../context';
4
- import { Filter } from '../filter/filter-interfaces';
5
- import type { EntityMetadata } from '../remult3/remult3';
6
- export declare class RestDataProvider implements DataProvider {
7
- private apiProvider;
8
- constructor(apiProvider: () => ApiClient);
9
- getEntityDataProvider(entity: EntityMetadata): RestEntityDataProvider;
10
- transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
11
- isProxy: boolean;
12
- }
13
- export declare class RestEntityDataProvider implements EntityDataProvider {
14
- private url;
15
- private http;
16
- private entity;
17
- constructor(url: () => string, http: () => RestDataProviderHttpProvider, entity: EntityMetadata);
18
- translateFromJson(row: any): {};
19
- translateToJson(row: any): {};
20
- count(where: Filter): Promise<number>;
21
- find(options?: EntityDataProviderFindOptions): Promise<Array<any>>;
22
- update(id: any, data: any): Promise<any>;
23
- delete(id: any): Promise<void>;
24
- insert(data: any): Promise<any>;
25
- }
26
- export declare class RestDataProviderHttpProviderUsingFetch implements RestDataProviderHttpProvider {
27
- private fetch?;
28
- constructor(fetch?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
29
- get(url: string): Promise<any>;
30
- put(url: string, data: any): Promise<any>;
31
- delete(url: string): Promise<any>;
32
- post(url: string, data: any): Promise<any>;
33
- myFetch(url: string, options?: {
34
- method?: string;
35
- body?: string;
36
- }): Promise<any>;
37
- }
38
- export declare function addFilterToUrlAndReturnTrueIfSuccessful(filter: any, url: UrlBuilder): boolean;
39
- export declare const liveQueryAction = "liveQuery-";
@@ -1,33 +0,0 @@
1
- import type { DataProvider, EntityDataProvider } from '../data-interfaces';
2
- import type { SqlCommand, SqlCommandWithParameters, SqlImplementation, SqlResult } from '../sql-command';
3
- import type { Remult } from '../context';
4
- import type { CustomSqlFilterBuilderFunction } from '../filter/filter-consumer-bridge-to-sql-request';
5
- import type { EntityFilter, EntityMetadata } from '../remult3/remult3';
6
- import type { RepositoryOverloads } from '../remult3/RepositoryImplementation';
7
- export declare class SqlDatabase implements DataProvider {
8
- private sql;
9
- static getDb(remult?: Remult): SqlDatabase;
10
- createCommand(): SqlCommand;
11
- execute(sql: string): Promise<SqlResult>;
12
- ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
13
- getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
14
- transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
15
- static rawFilter(build: CustomSqlFilterBuilderFunction): EntityFilter<any>;
16
- static filterToRaw<entityType>(repo: RepositoryOverloads<entityType>, condition: EntityFilter<entityType>, sqlCommand?: SqlCommandWithParameters): Promise<string>;
17
- /**
18
- * `false` _(default)_ - No logging
19
- *
20
- * `true` - to log all queries to the console
21
- *
22
- * `oneLiner` - to log all queries to the console as one line
23
- *
24
- * a `function` - to log all queries to the console as a custom format
25
- */
26
- static LogToConsole: boolean | 'oneLiner' | ((duration: number, query: string, args: Record<string, any>) => void);
27
- /**
28
- * Threshold in milliseconds for logging queries to the console.
29
- */
30
- static durationThreshold: number;
31
- constructor(sql: SqlImplementation);
32
- private createdEntities;
33
- }
@@ -1,21 +0,0 @@
1
- import type { __RowsOfDataForTesting } from '../__RowsOfDataForTesting';
2
- import type { SqlCommand, SqlImplementation } from '../sql-command';
3
- import type { Remult } from '../context';
4
- import type { EntityMetadata } from '../remult3/remult3';
5
- export declare class WebSqlDataProvider implements SqlImplementation, __RowsOfDataForTesting {
6
- private databaseName;
7
- rows: {
8
- [tableName: string]: any;
9
- };
10
- constructor(databaseName: string, databaseSize?: number);
11
- static getDb(remult?: Remult): any;
12
- getLimitSqlSyntax(limit: number, offset: number): string;
13
- entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
14
- ensureSchema(entities: EntityMetadata<any>[]): Promise<void>;
15
- dropTable(entity: EntityMetadata): Promise<void>;
16
- createTable(entity: EntityMetadata<any>): Promise<void>;
17
- createCommand(): SqlCommand;
18
- transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;
19
- private addColumnSqlSyntax;
20
- toString(): string;
21
- }
@@ -1,126 +0,0 @@
1
- import type { Allowed, AllowedForInstance } from './context';
2
- import type { FieldMetadata } from './column-interfaces';
3
- import type { EntityFilter, EntityIdFields, EntityMetadata, EntityOrderBy, EntityRef, FieldsMetadata, LifecycleEvent } from './remult3/remult3';
4
- export interface EntityOptions<entityType = any> {
5
- /**A human readable name for the entity */
6
- caption?: string;
7
- /**
8
- * Determines if this Entity is available for get requests using Rest Api
9
- * @description
10
- * Determines if one has any access to the data of an entity.
11
- * @see [allowed](http://remult.dev/docs/allowed.html)
12
- * @see to restrict data based on a criteria, use [apiPrefilter](https://remult.dev/docs/ref_entity.html#apiprefilter)
13
- * */
14
- allowApiRead?: Allowed;
15
- /**
16
- * Determines if this entity can be updated through the api.
17
- * @see [allowed](http://remult.dev/docs/allowed.html)*/
18
- allowApiUpdate?: AllowedForInstance<entityType>;
19
- /** Determines if entries for this entity can be deleted through the api.
20
- * @see [allowed](http://remult.dev/docs/allowed.html)*/
21
- allowApiDelete?: AllowedForInstance<entityType>;
22
- /** Determines if new entries for this entity can be posted through the api.
23
- * @see [allowed](http://remult.dev/docs/allowed.html)*/
24
- allowApiInsert?: AllowedForInstance<entityType>;
25
- /** sets the `allowApiUpdate`, `allowApiDelete` and `allowApiInsert` properties in a single set */
26
- allowApiCrud?: Allowed;
27
- /** A filter that determines which rows can be queries using the api.
28
- * @description
29
- * Use apiPrefilter in cases where you to restrict data based on user profile
30
- * @example
31
- * apiPrefilter: { archive:false }
32
- *
33
- * @example
34
- * apiPrefilter: ()=> remult.isAllowed("admin")?{}:{ archive:false }
35
- * @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
36
- *
37
- */
38
- apiPrefilter?: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>);
39
- /** A filter that will be used for all queries from this entity both from the API and from within the backend.
40
- * @example
41
- * backendPrefilter: { archive:false }
42
- * @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
43
- */
44
- backendPrefilter?: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>);
45
- /** An order by to be used, in case no order by was specified
46
- * @example
47
- * defaultOrderBy: { name: "asc" }
48
- *
49
- * @example
50
- * defaultOrderBy: { price: "desc", name: "asc" }
51
- */
52
- defaultOrderBy?: EntityOrderBy<entityType>;
53
- /** An event that will be fired before the Entity will be saved to the database.
54
- * If the `error` property of the entity's ref or any of its fields will be set, the save will be aborted and an exception will be thrown.
55
- * this is the place to run logic that we want to run in any case before an entity is saved.
56
- * @example
57
- * @Entity<Task>("tasks", {
58
- * saving: async (task, e) => {
59
- * if (e.isNew) {
60
- * task.createdAt = new Date(); // Set the creation date for new tasks.
61
- * }
62
- * task.lastUpdated = new Date(); // Update the last updated date.
63
- * },
64
- * })
65
- * @param entity - The instance of the entity being saved.
66
- * @param event - an @link LifeCycleEvent object
67
- * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
68
- */
69
- saving?: (entity: entityType, event: LifecycleEvent<entityType>) => Promise<any> | any;
70
- /**
71
- * A hook that runs after an entity has been successfully saved.
72
- *
73
- * @param entity The instance of the entity that was saved.
74
- * @param event - an @link LifeCycleEvent object
75
- * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
76
- */
77
- saved?: (entity: entityType, e: LifecycleEvent<entityType>) => Promise<any> | any;
78
- /**
79
- * A hook that runs before an entity is deleted.
80
- *
81
- * @param entity The instance of the entity being deleted.
82
- * @param event - an @link LifeCycleEvent object
83
- * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
84
- */
85
- deleting?: (entity: entityType, e: LifecycleEvent<entityType>) => Promise<any> | any;
86
- /**
87
- * A hook that runs after an entity has been successfully deleted.
88
- *
89
- * @param entity The instance of the entity that was deleted.
90
- * @param event - an @link LifeCycleEvent object
91
- * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
92
- */
93
- deleted?: (entity: entityType, e: LifecycleEvent<entityType>) => Promise<any> | any;
94
- /**
95
- * A hook that runs to perform validation checks on an entity before saving.
96
- * This hook is also executed on the frontend.
97
- *
98
- * @param entity The instance of the entity being validated.
99
- * @param event - an @link LifeCycleEvent object
100
- * @see [Entity Lifecycle Hooks](http://remult.dev/docs/lifecycle-hooks)
101
- */
102
- validation?: (entity: entityType, ref: LifecycleEvent<entityType>) => Promise<any> | any;
103
- /** The name of the table in the database that holds the data for this entity.
104
- * If no name is set, the `key` will be used instead.
105
- * @example
106
- * dbName:'myProducts'
107
- *
108
- * You can also add your schema name to the table name
109
- * @example
110
- * dbName:'public."myProducts"'
111
- */
112
- dbName?: string;
113
- /** For entities that are based on SQL expressions instead of a physical table or view*/
114
- sqlExpression?: string | ((entity: EntityMetadata<entityType>) => string | Promise<string>);
115
- /** An arrow function that identifies the `id` column to use for this entity
116
- * @example
117
- * //Single column id
118
- * @Entity<Products>("products", { id: {productCode: true} })
119
- * @example
120
- * //Multiple columns id
121
- * @Entity<OrderDetails>("orderDetails", { id:{ orderId:true, productCode:true} })
122
- */
123
- id?: EntityIdFields<entityType> | ((entity: FieldsMetadata<entityType>) => FieldMetadata | FieldMetadata[]);
124
- entityRefInit?: (ref: EntityRef<entityType>, row: entityType) => void;
125
- apiRequireId?: Allowed;
126
- }
@@ -1,51 +0,0 @@
1
- import type { FieldMetadata } from '../column-interfaces';
2
- import type { EntityMetadataOverloads, RepositoryOverloads } from '../remult3/RepositoryImplementation';
3
- import type { EntityFilter, MembersOnly } from '../remult3/remult3';
4
- import type { SqlCommandWithParameters } from '../sql-command';
5
- import type { Filter, FilterConsumer } from './filter-interfaces';
6
- export declare class FilterConsumerBridgeToSqlRequest implements FilterConsumer {
7
- private r;
8
- private nameProvider;
9
- private where;
10
- _addWhere: boolean;
11
- promises: Promise<void>[];
12
- resolveWhere(): Promise<string>;
13
- constructor(r: SqlCommandWithParameters, nameProvider: EntityDbNamesBase);
14
- custom(key: string, customItem: any): void;
15
- or(orElements: Filter[]): void;
16
- isNull(col: FieldMetadata): void;
17
- isNotNull(col: FieldMetadata): void;
18
- isIn(col: FieldMetadata, val: any[]): void;
19
- isEqualTo(col: FieldMetadata, val: any): void;
20
- isDifferentFrom(col: FieldMetadata, val: any): void;
21
- isGreaterOrEqualTo(col: FieldMetadata, val: any): void;
22
- isGreaterThan(col: FieldMetadata, val: any): void;
23
- isLessOrEqualTo(col: FieldMetadata, val: any): void;
24
- isLessThan(col: FieldMetadata, val: any): void;
25
- containsCaseInsensitive(col: FieldMetadata, val: any): void;
26
- notContainsCaseInsensitive(col: FieldMetadata, val: any): void;
27
- private add;
28
- private addToWhere;
29
- databaseCustom(databaseCustom: CustomSqlFilterObject): void;
30
- }
31
- export type CustomSqlFilterBuilderFunction = (builder: CustomSqlFilterBuilder) => void | Promise<any>;
32
- export interface CustomSqlFilterObject {
33
- buildSql: CustomSqlFilterBuilderFunction;
34
- }
35
- export declare class CustomSqlFilterBuilder {
36
- private r;
37
- constructor(r: SqlCommandWithParameters);
38
- sql: string;
39
- addParameterAndReturnSqlToken<valueType>(val: valueType, field?: FieldMetadata<valueType>): string;
40
- filterToRaw<entityType>(repo: RepositoryOverloads<entityType>, condition: EntityFilter<entityType>): Promise<string>;
41
- }
42
- export declare function isDbReadonly<entityType>(field: FieldMetadata, dbNames: EntityDbNames<entityType>): boolean;
43
- export declare type EntityDbNamesBase = {
44
- $entityName: string;
45
- $dbNameOf(field: FieldMetadata<any> | string): string;
46
- toString(): string;
47
- };
48
- export declare type EntityDbNames<entityType> = {
49
- [Properties in keyof Required<MembersOnly<entityType>>]: string;
50
- } & EntityDbNamesBase;
51
- export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>): Promise<EntityDbNames<entityType>>;
@@ -1,74 +0,0 @@
1
- import type { FieldMetadata } from '../column-interfaces';
2
- import { Remult } from '../context';
3
- import type { EntityFilter, EntityMetadata } from '../remult3/remult3';
4
- export declare class Filter {
5
- private apply;
6
- constructor(apply: (add: FilterConsumer) => void);
7
- __applyToConsumer(add: FilterConsumer): void;
8
- static resolve<entityType>(filter: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>)): Promise<EntityFilter<entityType>>;
9
- static createCustom<entityType>(rawFilterTranslator: (unused: never, r: Remult) => EntityFilter<entityType> | Promise<EntityFilter<entityType>>, key?: string): (() => EntityFilter<entityType>) & customFilterInfo<entityType>;
10
- static createCustom<entityType, argsType>(rawFilterTranslator: (args: argsType, r: Remult) => EntityFilter<entityType> | Promise<EntityFilter<entityType>>, key?: string): ((y: argsType) => EntityFilter<entityType>) & customFilterInfo<entityType>;
11
- static fromEntityFilter<T>(entity: EntityMetadata<T>, whereItem: EntityFilter<T>): Filter;
12
- toJson(): any;
13
- static entityFilterToJson<T>(entityDefs: EntityMetadata<T>, where: EntityFilter<T>): any;
14
- static entityFilterFromJson<T>(entityDefs: EntityMetadata<T>, packed: any): EntityFilter<T>;
15
- static translateCustomWhere<T>(r: Filter, entity: EntityMetadata<T>, remult: Remult): Promise<Filter>;
16
- }
17
- export interface FilterConsumer {
18
- or(orElements: Filter[]): any;
19
- isEqualTo(col: FieldMetadata, val: any): void;
20
- isDifferentFrom(col: FieldMetadata, val: any): void;
21
- isNull(col: FieldMetadata): void;
22
- isNotNull(col: FieldMetadata): void;
23
- isGreaterOrEqualTo(col: FieldMetadata, val: any): void;
24
- isGreaterThan(col: FieldMetadata, val: any): void;
25
- isLessOrEqualTo(col: FieldMetadata, val: any): void;
26
- isLessThan(col: FieldMetadata, val: any): void;
27
- containsCaseInsensitive(col: FieldMetadata, val: any): void;
28
- notContainsCaseInsensitive(col: FieldMetadata, val: any): void;
29
- isIn(col: FieldMetadata, val: any[]): void;
30
- custom(key: string, customItem: any): void;
31
- databaseCustom(databaseCustom: any): void;
32
- }
33
- export declare class AndFilter extends Filter {
34
- readonly filters: Filter[];
35
- constructor(...filters: Filter[]);
36
- add(filter: Filter): void;
37
- }
38
- export declare class OrFilter extends Filter {
39
- readonly filters: Filter[];
40
- constructor(...filters: Filter[]);
41
- }
42
- export declare const customUrlToken = "$custom$";
43
- export declare const customDatabaseFilterToken = "$db$";
44
- export declare class FilterSerializer implements FilterConsumer {
45
- result: any;
46
- constructor();
47
- databaseCustom(databaseCustom: any): void;
48
- custom(key: any, customItem: any): void;
49
- hasUndefined: boolean;
50
- add(key: string, val: any): void;
51
- or(orElements: Filter[]): void;
52
- isNull(col: FieldMetadata): void;
53
- isNotNull(col: FieldMetadata): void;
54
- isIn(col: FieldMetadata, val: any[]): void;
55
- isEqualTo(col: FieldMetadata, val: any): void;
56
- isDifferentFrom(col: FieldMetadata, val: any): void;
57
- isGreaterOrEqualTo(col: FieldMetadata, val: any): void;
58
- isGreaterThan(col: FieldMetadata, val: any): void;
59
- isLessOrEqualTo(col: FieldMetadata, val: any): void;
60
- isLessThan(col: FieldMetadata, val: any): void;
61
- containsCaseInsensitive(col: FieldMetadata, val: any): void;
62
- notContainsCaseInsensitive(col: FieldMetadata, val: any): void;
63
- }
64
- export declare function entityFilterToJson<T>(entityDefs: EntityMetadata<T>, where: EntityFilter<T>): any;
65
- export declare function buildFilterFromRequestParameters(entity: EntityMetadata, filterInfo: {
66
- get: (key: string) => any;
67
- }): EntityFilter<any>;
68
- export interface customFilterInfo<entityType> {
69
- rawFilterInfo: {
70
- key: string;
71
- rawFilterTranslator: (args: any, r: Remult) => EntityFilter<entityType> | Promise<EntityFilter<entityType>>;
72
- };
73
- }
74
- export declare function __updateEntityBasedOnWhere<T>(entityDefs: EntityMetadata<T>, where: EntityFilter<T>, r: T): void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- import type { SubscriptionClient, SubscriptionClientConnection } from './SubscriptionChannel';
2
- export declare class SseSubscriptionClient implements SubscriptionClient {
3
- openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
4
- }
5
- export declare const ConnectionNotFoundError = "client connection not found";
@@ -1,41 +0,0 @@
1
- import type { Remult } from '../context';
2
- export declare const streamUrl = "stream";
3
- export interface SubscriptionListener<type> {
4
- next(message: type): void;
5
- error(err: any): void;
6
- complete(): void;
7
- }
8
- export type Unsubscribe = VoidFunction;
9
- export interface SubscriptionClientConnection {
10
- subscribe(channel: string, onMessage: (message: any) => void, onError: (err: any) => void): Promise<Unsubscribe>;
11
- close(): void;
12
- }
13
- export interface SubscriptionClient {
14
- openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
15
- }
16
- export declare const liveQueryKeepAliveRoute = "_liveQueryKeepAlive";
17
- export declare type LiveQueryChange = {
18
- type: 'all';
19
- data: any[];
20
- } | {
21
- type: 'add';
22
- data: any;
23
- } | {
24
- type: 'replace';
25
- data: {
26
- oldId: any;
27
- item: any;
28
- };
29
- } | {
30
- type: 'remove';
31
- data: {
32
- id: any;
33
- };
34
- };
35
- export declare class SubscriptionChannel<messageType> {
36
- channelKey: string;
37
- constructor(channelKey: string);
38
- publish(message: messageType, remult?: Remult): void;
39
- subscribe(next: (message: messageType) => void, remult?: Remult): Promise<Unsubscribe>;
40
- subscribe(listener: Partial<SubscriptionListener<messageType>>): Promise<Unsubscribe>;
41
- }