remult 2.7.31 → 2.7.32
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/server/get-remult-admin-html.js +1 -1
- package/esm/src/context.js +16 -1
- package/esm/src/remult-proxy.js +3 -0
- package/esm/src/remult3/RepositoryImplementation.js +1 -26
- package/esm/src/remult3/SubscribableImp.js +26 -0
- package/package.json +1 -1
- package/server/get-remult-admin-html.js +1 -1
- package/src/context.d.ts +6 -2
- package/src/context.js +21 -0
- package/src/remult-proxy.js +3 -0
- package/src/remult3/RepositoryImplementation.d.ts +2 -10
- package/src/remult3/RepositoryImplementation.js +5 -35
- package/src/remult3/SubscribableImp.d.ts +11 -0
- package/src/remult3/SubscribableImp.js +35 -0
package/src/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ClassType } from '../classType.js';
|
|
2
2
|
import type { DataProvider } from './data-interfaces.js';
|
|
3
|
-
import type { EntityMetadata, EntityRef, FindOptions, Repository } from './remult3/remult3.js';
|
|
3
|
+
import type { EntityMetadata, EntityRef, FindOptions, RefSubscriber, Repository } from './remult3/remult3.js';
|
|
4
4
|
import type { ExternalHttpProvider } from './buildRestDataProvider.js';
|
|
5
5
|
import type { SubscriptionClient, Unsubscribe } from './live-query/SubscriptionChannel.js';
|
|
6
6
|
import type { LiveQueryStorage, SubscriptionServer } from './live-query/SubscriptionServer.js';
|
|
@@ -36,8 +36,12 @@ export declare class Remult {
|
|
|
36
36
|
* @param dataProvider - an optional alternative data provider to use. Useful for writing to offline storage or an alternative data provider
|
|
37
37
|
*/
|
|
38
38
|
repo: <T>(entity: ClassType<T>, dataProvider?: DataProvider) => Repository<T>;
|
|
39
|
+
private _subscribers?;
|
|
40
|
+
subscribeAuth(listener: RefSubscriber): Unsubscribe;
|
|
41
|
+
private __user?;
|
|
39
42
|
/** Returns the current user's info */
|
|
40
|
-
user
|
|
43
|
+
get user(): UserInfo | undefined;
|
|
44
|
+
set user(user: UserInfo | undefined);
|
|
41
45
|
/**
|
|
42
46
|
* Fetches user information from the backend and updates the `remult.user` object.
|
|
43
47
|
* Typically used during application initialization and user authentication.
|
package/src/context.js
CHANGED
|
@@ -16,6 +16,7 @@ var buildRestDataProvider_js_1 = require("./buildRestDataProvider.js");
|
|
|
16
16
|
var relationInfoMember_js_1 = require("./remult3/relationInfoMember.js");
|
|
17
17
|
var remult_static_js_1 = require("./remult-static.js");
|
|
18
18
|
var initDataProvider_js_1 = require("../server/initDataProvider.js");
|
|
19
|
+
var SubscribableImp_js_1 = require("./remult3/SubscribableImp.js");
|
|
19
20
|
var RemultAsyncLocalStorage = /** @class */ (function () {
|
|
20
21
|
function RemultAsyncLocalStorage(remultObjectStorage) {
|
|
21
22
|
this.remultObjectStorage = remultObjectStorage;
|
|
@@ -133,6 +134,26 @@ var Remult = /** @class */ (function () {
|
|
|
133
134
|
this.apiClient.wrapMessageHandling = apiClient.wrapMessageHandling;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
137
|
+
Remult.prototype.subscribeAuth = function (listener) {
|
|
138
|
+
if (!this._subscribers)
|
|
139
|
+
this._subscribers = new SubscribableImp_js_1.SubscribableImp();
|
|
140
|
+
return this._subscribers.subscribe(listener);
|
|
141
|
+
};
|
|
142
|
+
Object.defineProperty(Remult.prototype, "user", {
|
|
143
|
+
/** Returns the current user's info */
|
|
144
|
+
get: function () {
|
|
145
|
+
var _a;
|
|
146
|
+
(_a = this._subscribers) === null || _a === void 0 ? void 0 : _a.reportObserved();
|
|
147
|
+
return this.__user;
|
|
148
|
+
},
|
|
149
|
+
set: function (user) {
|
|
150
|
+
var _a;
|
|
151
|
+
this.__user = user;
|
|
152
|
+
(_a = this._subscribers) === null || _a === void 0 ? void 0 : _a.reportChanged();
|
|
153
|
+
},
|
|
154
|
+
enumerable: false,
|
|
155
|
+
configurable: true
|
|
156
|
+
});
|
|
136
157
|
/**
|
|
137
158
|
* Fetches user information from the backend and updates the `remult.user` object.
|
|
138
159
|
* Typically used during application initialization and user authentication.
|
package/src/remult-proxy.js
CHANGED
|
@@ -285,6 +285,9 @@ var RemultProxy = /** @class */ (function () {
|
|
|
285
285
|
enumerable: false,
|
|
286
286
|
configurable: true
|
|
287
287
|
});
|
|
288
|
+
RemultProxy.prototype.subscribeAuth = function (listener) {
|
|
289
|
+
return remult_static_js_1.remultStatic.remultFactory().subscribeAuth(listener);
|
|
290
|
+
};
|
|
288
291
|
RemultProxy.prototype.initUser = function () {
|
|
289
292
|
return remult_static_js_1.remultStatic.remultFactory().initUser();
|
|
290
293
|
};
|
|
@@ -4,13 +4,14 @@ import type { FieldMetadata, FieldOptions, ValueConverter, ValueListItem } from
|
|
|
4
4
|
import { Remult } from '../context.js';
|
|
5
5
|
import type { EntityOptions } from '../entity.js';
|
|
6
6
|
import { Filter } from '../filter/filter-interfaces.js';
|
|
7
|
-
import { type GroupByOptions, type GroupByResult, type ControllerRef, type ControllerRefForControllerBase, type EntityFilter, type EntityMetadata, type EntityOrderBy, type EntityRef, type EntityRefForEntityBase, type FieldRef, type FieldsMetadata, type FieldsRef, type FieldsRefForEntityBase, type FindFirstOptions, type FindFirstOptionsBase, type FindOptions, type IdMetadata, type LiveQuery, type LoadOptions, type MembersOnly, type NumericKeys, type Repository, type RepositoryRelations, type
|
|
7
|
+
import { type GroupByOptions, type GroupByResult, type ControllerRef, type ControllerRefForControllerBase, type EntityFilter, type EntityMetadata, type EntityOrderBy, type EntityRef, type EntityRefForEntityBase, type FieldRef, type FieldsMetadata, type FieldsRef, type FieldsRefForEntityBase, type FindFirstOptions, type FindFirstOptionsBase, type FindOptions, type IdMetadata, type LiveQuery, type LoadOptions, type MembersOnly, type NumericKeys, type Repository, type RepositoryRelations, type idType } from './remult3.js';
|
|
8
8
|
import type { QueryOptions, RefSubscriber, UpsertOptions } from './remult3.js';
|
|
9
9
|
import type { entityEventListener } from '../__EntityValueProvider.js';
|
|
10
10
|
import { type DataProvider, type EntityDataProvider, type EntityDataProviderGroupByOptions, type EntityDataProviderFindOptions, type ErrorInfo, EntityError } from '../data-interfaces.js';
|
|
11
11
|
import type { Unsubscribe } from '../live-query/SubscriptionChannel.js';
|
|
12
12
|
import { RelationLoader } from './relation-loader.js';
|
|
13
13
|
import { type RepositoryInternal, getInternalKey } from './repository-internals.js';
|
|
14
|
+
import { SubscribableImp } from './SubscribableImp.js';
|
|
14
15
|
export declare class RepositoryImplementation<entityType> implements Repository<entityType>, RepositoryInternal<entityType> {
|
|
15
16
|
private _entity;
|
|
16
17
|
_remult: Remult;
|
|
@@ -333,15 +334,6 @@ export declare class ControllerBase {
|
|
|
333
334
|
get $(): FieldsRefForEntityBase<this>;
|
|
334
335
|
get _(): ControllerRefForControllerBase<this>;
|
|
335
336
|
}
|
|
336
|
-
declare class SubscribableImp implements Subscribable {
|
|
337
|
-
reportChanged(): void;
|
|
338
|
-
reportObserved(): void;
|
|
339
|
-
private _subscribers?;
|
|
340
|
-
subscribe(listener: (() => void) | {
|
|
341
|
-
reportChanged: () => void;
|
|
342
|
-
reportObserved: () => void;
|
|
343
|
-
}): Unsubscribe;
|
|
344
|
-
}
|
|
345
337
|
export declare function getEntityMetadata<entityType>(entity: EntityMetadataOverloads<entityType>): EntityMetadata<entityType>;
|
|
346
338
|
export declare function getRepository<entityType>(entity: RepositoryOverloads<entityType>): Repository<entityType>;
|
|
347
339
|
export type EntityMetadataOverloads<entityType> = Repository<entityType> | EntityMetadata<entityType> | ClassType<entityType>;
|
|
@@ -36,6 +36,7 @@ var validators_js_1 = require("../validators.js");
|
|
|
36
36
|
var addValidator_js_1 = require("./addValidator.js");
|
|
37
37
|
var isOfType_js_1 = require("../isOfType.js");
|
|
38
38
|
var QueryResultImpl_js_1 = require("./QueryResultImpl.js");
|
|
39
|
+
var SubscribableImp_js_1 = require("./SubscribableImp.js");
|
|
39
40
|
//import { remult } from "../remult-proxy";
|
|
40
41
|
var classValidatorValidate = undefined;
|
|
41
42
|
// import ("class-validator".toString())
|
|
@@ -1773,7 +1774,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1773
1774
|
if (!refImpl_1) {
|
|
1774
1775
|
refImpl_1 = _this.fields.find(col.key);
|
|
1775
1776
|
if (!refImpl_1._subscribers) {
|
|
1776
|
-
refImpl_1._subscribers = new SubscribableImp();
|
|
1777
|
+
refImpl_1._subscribers = new SubscribableImp_js_1.SubscribableImp();
|
|
1777
1778
|
}
|
|
1778
1779
|
}
|
|
1779
1780
|
refImpl_1._subscribers.reportObserved();
|
|
@@ -1787,7 +1788,7 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1787
1788
|
if (!refImpl_1) {
|
|
1788
1789
|
refImpl_1 = _this.fields.find(col.key);
|
|
1789
1790
|
if (!refImpl_1._subscribers) {
|
|
1790
|
-
refImpl_1._subscribers = new SubscribableImp();
|
|
1791
|
+
refImpl_1._subscribers = new SubscribableImp_js_1.SubscribableImp();
|
|
1791
1792
|
}
|
|
1792
1793
|
}
|
|
1793
1794
|
refImpl_1._subscribers.reportChanged();
|
|
@@ -1869,12 +1870,12 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1869
1870
|
rowHelperBase.prototype.initSubscribers = function () {
|
|
1870
1871
|
var e_28, _a;
|
|
1871
1872
|
if (!this._subscribers) {
|
|
1872
|
-
this._subscribers = new SubscribableImp();
|
|
1873
|
+
this._subscribers = new SubscribableImp_js_1.SubscribableImp();
|
|
1873
1874
|
var safeSubscribers_1 = this._subscribers;
|
|
1874
1875
|
var _loop_6 = function (col) {
|
|
1875
1876
|
var ei = (0, getEntityRef_js_1.getEntitySettings)(col.valueType, false);
|
|
1876
1877
|
var refImpl = this_3.fields.find(col.key);
|
|
1877
|
-
refImpl._subscribers = new SubscribableImp();
|
|
1878
|
+
refImpl._subscribers = new SubscribableImp_js_1.SubscribableImp();
|
|
1878
1879
|
if ((ei && this_3.remult) || (0, relationInfoMember_js_1.getRelationFieldInfo)(col)) {
|
|
1879
1880
|
}
|
|
1880
1881
|
else {
|
|
@@ -3977,37 +3978,6 @@ var cacheEntityInfo = /** @class */ (function () {
|
|
|
3977
3978
|
}
|
|
3978
3979
|
return cacheEntityInfo;
|
|
3979
3980
|
}());
|
|
3980
|
-
var SubscribableImp = /** @class */ (function () {
|
|
3981
|
-
function SubscribableImp() {
|
|
3982
|
-
}
|
|
3983
|
-
SubscribableImp.prototype.reportChanged = function () {
|
|
3984
|
-
if (this._subscribers)
|
|
3985
|
-
this._subscribers.forEach(function (x) { return x.reportChanged(); });
|
|
3986
|
-
};
|
|
3987
|
-
SubscribableImp.prototype.reportObserved = function () {
|
|
3988
|
-
if (this._subscribers)
|
|
3989
|
-
this._subscribers.forEach(function (x) { return x.reportObserved(); });
|
|
3990
|
-
};
|
|
3991
|
-
SubscribableImp.prototype.subscribe = function (listener) {
|
|
3992
|
-
var _this = this;
|
|
3993
|
-
var list;
|
|
3994
|
-
if (typeof listener === 'function')
|
|
3995
|
-
list = {
|
|
3996
|
-
reportChanged: function () { return listener(); },
|
|
3997
|
-
reportObserved: function () { },
|
|
3998
|
-
};
|
|
3999
|
-
else
|
|
4000
|
-
list = listener;
|
|
4001
|
-
if (!this._subscribers) {
|
|
4002
|
-
this._subscribers = [];
|
|
4003
|
-
}
|
|
4004
|
-
this._subscribers.push(list);
|
|
4005
|
-
return function () {
|
|
4006
|
-
return (_this._subscribers = _this._subscribers.filter(function (x) { return x != list; }));
|
|
4007
|
-
};
|
|
4008
|
-
};
|
|
4009
|
-
return SubscribableImp;
|
|
4010
|
-
}());
|
|
4011
3981
|
function getEntityMetadata(entity) {
|
|
4012
3982
|
if (entity.metadata)
|
|
4013
3983
|
return entity.metadata;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Unsubscribe } from '../live-query/SubscriptionChannel.js';
|
|
2
|
+
import type { Subscribable } from './remult3.js';
|
|
3
|
+
export declare class SubscribableImp implements Subscribable {
|
|
4
|
+
reportChanged(): void;
|
|
5
|
+
reportObserved(): void;
|
|
6
|
+
private _subscribers?;
|
|
7
|
+
subscribe(listener: (() => void) | {
|
|
8
|
+
reportChanged: () => void;
|
|
9
|
+
reportObserved: () => void;
|
|
10
|
+
}): Unsubscribe;
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubscribableImp = void 0;
|
|
4
|
+
var SubscribableImp = /** @class */ (function () {
|
|
5
|
+
function SubscribableImp() {
|
|
6
|
+
}
|
|
7
|
+
SubscribableImp.prototype.reportChanged = function () {
|
|
8
|
+
if (this._subscribers)
|
|
9
|
+
this._subscribers.forEach(function (x) { return x.reportChanged(); });
|
|
10
|
+
};
|
|
11
|
+
SubscribableImp.prototype.reportObserved = function () {
|
|
12
|
+
if (this._subscribers)
|
|
13
|
+
this._subscribers.forEach(function (x) { return x.reportObserved(); });
|
|
14
|
+
};
|
|
15
|
+
SubscribableImp.prototype.subscribe = function (listener) {
|
|
16
|
+
var _this = this;
|
|
17
|
+
var list;
|
|
18
|
+
if (typeof listener === 'function')
|
|
19
|
+
list = {
|
|
20
|
+
reportChanged: function () { return listener(); },
|
|
21
|
+
reportObserved: function () { },
|
|
22
|
+
};
|
|
23
|
+
else
|
|
24
|
+
list = listener;
|
|
25
|
+
if (!this._subscribers) {
|
|
26
|
+
this._subscribers = [];
|
|
27
|
+
}
|
|
28
|
+
this._subscribers.push(list);
|
|
29
|
+
return function () {
|
|
30
|
+
return (_this._subscribers = _this._subscribers.filter(function (x) { return x != list; }));
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
return SubscribableImp;
|
|
34
|
+
}());
|
|
35
|
+
exports.SubscribableImp = SubscribableImp;
|