remult 0.25.6-exp.6 → 0.25.6
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/src/context.js +3 -5
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +18 -8
- package/esm/src/remult-proxy.js +29 -33
- package/esm/src/remult-static.js +5 -0
- package/esm/src/remult3/RepositoryImplementation.js +2 -2
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/context.d.ts +3 -2
- package/src/context.js +2 -4
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +5 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.js +40 -34
- package/src/remult-proxy.js +28 -32
- package/src/remult-static.d.ts +2 -0
- package/src/remult-static.js +7 -1
- package/src/remult3/RepositoryImplementation.js +2 -2
- package/src/remult3/remult3.d.ts +2 -2
package/esm/src/context.js
CHANGED
|
@@ -6,12 +6,11 @@ import { RepositoryImplementation, createOldEntity, } from './remult3/Repository
|
|
|
6
6
|
import { serverActionField } from './server-action-info.js';
|
|
7
7
|
import { buildRestDataProvider, isExternalHttpProvider, } from './buildRestDataProvider.js';
|
|
8
8
|
import { verifyFieldRelationInfo } from './remult3/relationInfoMember.js';
|
|
9
|
-
import { remultStatic } from './remult-static.js';
|
|
9
|
+
import { remultStatic, resetFactory } from './remult-static.js';
|
|
10
10
|
export class RemultAsyncLocalStorage {
|
|
11
11
|
remultObjectStorage;
|
|
12
12
|
static enable() {
|
|
13
|
-
|
|
14
|
-
remult.remultFactory = () => {
|
|
13
|
+
remultStatic.remultFactory = () => {
|
|
15
14
|
const r = remultStatic.asyncContext.getRemult();
|
|
16
15
|
if (r)
|
|
17
16
|
return r;
|
|
@@ -20,8 +19,7 @@ export class RemultAsyncLocalStorage {
|
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
static disable() {
|
|
23
|
-
;
|
|
24
|
-
remult.resetFactory();
|
|
22
|
+
resetFactory();
|
|
25
23
|
}
|
|
26
24
|
constructor(remultObjectStorage) {
|
|
27
25
|
this.remultObjectStorage = remultObjectStorage;
|
|
@@ -159,15 +159,18 @@ export function shouldNotCreateField(field, dbNames) {
|
|
|
159
159
|
return (field.isServerExpression ||
|
|
160
160
|
(field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
|
|
161
161
|
}
|
|
162
|
-
export async function dbNamesOf(repo,
|
|
162
|
+
export async function dbNamesOf(repo, wrapIdentifierOrOptions) {
|
|
163
|
+
let options = typeof wrapIdentifierOrOptions === 'function'
|
|
164
|
+
? { wrapIdentifier: wrapIdentifierOrOptions }
|
|
165
|
+
: wrapIdentifierOrOptions || {};
|
|
163
166
|
var meta = getEntityMetadata(repo);
|
|
164
|
-
if (!wrapIdentifier) {
|
|
165
|
-
wrapIdentifier = remult.dataProvider.wrapIdentifier;
|
|
167
|
+
if (!options.wrapIdentifier) {
|
|
168
|
+
options.wrapIdentifier = remult.dataProvider.wrapIdentifier;
|
|
166
169
|
}
|
|
167
|
-
if (!wrapIdentifier)
|
|
168
|
-
wrapIdentifier = (x) => x;
|
|
170
|
+
if (!options.wrapIdentifier)
|
|
171
|
+
options.wrapIdentifier = (x) => x;
|
|
169
172
|
const result = {
|
|
170
|
-
$entityName: await entityDbName(meta, wrapIdentifier),
|
|
173
|
+
$entityName: await entityDbName(meta, options.wrapIdentifier),
|
|
171
174
|
toString: () => result.$entityName,
|
|
172
175
|
$dbNameOf: (field) => {
|
|
173
176
|
var key;
|
|
@@ -179,7 +182,14 @@ export async function dbNamesOf(repo, wrapIdentifier) {
|
|
|
179
182
|
},
|
|
180
183
|
};
|
|
181
184
|
for (const field of meta.fields) {
|
|
182
|
-
|
|
185
|
+
let r = await fieldDbName(field, meta, options.wrapIdentifier);
|
|
186
|
+
if (!field.options.sqlExpression)
|
|
187
|
+
if (typeof options.tableName === 'string')
|
|
188
|
+
r = options.wrapIdentifier(options.tableName) + '.' + r;
|
|
189
|
+
else if (options.tableName === true) {
|
|
190
|
+
r = result.$entityName + '.' + r;
|
|
191
|
+
}
|
|
192
|
+
result[field.key] = r;
|
|
183
193
|
}
|
|
184
194
|
return result;
|
|
185
195
|
}
|
|
@@ -203,9 +213,9 @@ export async function fieldDbName(f, meta, wrapIdentifier = (x) => x) {
|
|
|
203
213
|
f.options.sqlExpression =
|
|
204
214
|
"recursive sqlExpression call for field '" + f.key + "'. ";
|
|
205
215
|
result = await prev(meta);
|
|
216
|
+
f.options.sqlExpression = () => result;
|
|
206
217
|
}
|
|
207
218
|
finally {
|
|
208
|
-
f.options.sqlExpression = prev;
|
|
209
219
|
}
|
|
210
220
|
}
|
|
211
221
|
else
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -1,79 +1,75 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { remultStatic } from './remult-static.js';
|
|
2
2
|
import { getInternalKey } from './remult3/repository-internals.js';
|
|
3
3
|
/*@internal*/
|
|
4
4
|
export class RemultProxy {
|
|
5
|
+
/* @internal*/
|
|
6
|
+
iAmRemultProxy = true;
|
|
5
7
|
/* @internal*/
|
|
6
8
|
get liveQuerySubscriber() {
|
|
7
|
-
return
|
|
9
|
+
return remultStatic.remultFactory().liveQuerySubscriber;
|
|
8
10
|
}
|
|
9
11
|
/* @internal*/
|
|
10
12
|
set liveQuerySubscriber(val) {
|
|
11
|
-
|
|
13
|
+
remultStatic.remultFactory().liveQuerySubscriber = val;
|
|
12
14
|
}
|
|
13
15
|
/* @internal*/
|
|
14
16
|
get liveQueryStorage() {
|
|
15
|
-
return
|
|
17
|
+
return remultStatic.remultFactory().liveQueryStorage;
|
|
16
18
|
}
|
|
17
19
|
/* @internal*/
|
|
18
20
|
set liveQueryStorage(val) {
|
|
19
|
-
|
|
21
|
+
remultStatic.remultFactory().liveQueryStorage = val;
|
|
20
22
|
}
|
|
21
23
|
/* @internal*/
|
|
22
24
|
get liveQueryPublisher() {
|
|
23
|
-
return
|
|
25
|
+
return remultStatic.remultFactory().liveQueryPublisher;
|
|
24
26
|
}
|
|
25
27
|
/* @internal*/
|
|
26
28
|
set liveQueryPublisher(val) {
|
|
27
|
-
|
|
29
|
+
remultStatic.remultFactory().liveQueryPublisher = val;
|
|
28
30
|
}
|
|
29
31
|
call(backendMethod, self, ...args) {
|
|
30
|
-
return
|
|
32
|
+
return remultStatic.remultFactory().call(backendMethod, self, ...args);
|
|
31
33
|
}
|
|
32
34
|
get context() {
|
|
33
|
-
return
|
|
35
|
+
return remultStatic.remultFactory().context;
|
|
34
36
|
}
|
|
35
37
|
get dataProvider() {
|
|
36
|
-
return
|
|
38
|
+
return remultStatic.remultFactory().dataProvider;
|
|
37
39
|
}
|
|
38
40
|
set dataProvider(provider) {
|
|
39
|
-
|
|
41
|
+
remultStatic.remultFactory().dataProvider = provider;
|
|
40
42
|
}
|
|
41
43
|
/*@internal*/
|
|
42
44
|
get repCache() {
|
|
43
|
-
return
|
|
45
|
+
return remultStatic.remultFactory().repCache;
|
|
44
46
|
}
|
|
45
47
|
authenticated() {
|
|
46
|
-
return
|
|
48
|
+
return remultStatic.remultFactory().authenticated();
|
|
47
49
|
}
|
|
48
50
|
isAllowed(roles) {
|
|
49
|
-
return
|
|
51
|
+
return remultStatic.remultFactory().isAllowed(roles);
|
|
50
52
|
}
|
|
51
53
|
isAllowedForInstance(instance, allowed) {
|
|
52
|
-
return
|
|
54
|
+
return remultStatic.remultFactory().isAllowedForInstance(instance, allowed);
|
|
53
55
|
}
|
|
54
56
|
clearAllCache() {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
/*@internal*/
|
|
58
|
-
remultFactory = () => defaultFactory();
|
|
59
|
-
/*@internal*/
|
|
60
|
-
resetFactory() {
|
|
61
|
-
this.remultFactory = () => defaultFactory();
|
|
57
|
+
return remultStatic.remultFactory().clearAllCache();
|
|
62
58
|
}
|
|
63
59
|
repoCache = new Map();
|
|
64
60
|
//@ts-ignore
|
|
65
61
|
repo = (...args) => {
|
|
66
|
-
let self =
|
|
67
|
-
let entityCache =
|
|
62
|
+
let self = remultStatic;
|
|
63
|
+
let entityCache = this.repoCache.get(args[0]);
|
|
68
64
|
if (!entityCache) {
|
|
69
|
-
|
|
65
|
+
this.repoCache.set(args[0], (entityCache = new Map()));
|
|
70
66
|
}
|
|
71
67
|
let result = entityCache.get(args[1]);
|
|
72
68
|
if (result)
|
|
73
69
|
return result;
|
|
74
70
|
result = {
|
|
75
71
|
get fields() {
|
|
76
|
-
return
|
|
72
|
+
return remultStatic.remultFactory().repo(...args).metadata.fields;
|
|
77
73
|
},
|
|
78
74
|
//@ts-ignore
|
|
79
75
|
[getInternalKey]() {
|
|
@@ -144,7 +140,7 @@ export class RemultProxy {
|
|
|
144
140
|
.repo(...args)
|
|
145
141
|
.liveQuery(...args2),
|
|
146
142
|
get metadata() {
|
|
147
|
-
return
|
|
143
|
+
return remultStatic.remultFactory().repo(...args).metadata;
|
|
148
144
|
},
|
|
149
145
|
query: (...args2) => self
|
|
150
146
|
.remultFactory()
|
|
@@ -163,22 +159,22 @@ export class RemultProxy {
|
|
|
163
159
|
return result;
|
|
164
160
|
};
|
|
165
161
|
get user() {
|
|
166
|
-
return
|
|
162
|
+
return remultStatic.remultFactory().user;
|
|
167
163
|
}
|
|
168
164
|
set user(info) {
|
|
169
|
-
|
|
165
|
+
remultStatic.remultFactory().user = info;
|
|
170
166
|
}
|
|
171
167
|
get apiClient() {
|
|
172
|
-
return
|
|
168
|
+
return remultStatic.remultFactory().apiClient;
|
|
173
169
|
}
|
|
174
170
|
set apiClient(client) {
|
|
175
|
-
|
|
171
|
+
remultStatic.remultFactory().apiClient = client;
|
|
176
172
|
}
|
|
177
173
|
get subscriptionServer() {
|
|
178
|
-
return
|
|
174
|
+
return remultStatic.remultFactory().subscriptionServer;
|
|
179
175
|
}
|
|
180
176
|
set subscriptionServer(value) {
|
|
181
|
-
|
|
177
|
+
remultStatic.remultFactory().subscriptionServer = value;
|
|
182
178
|
}
|
|
183
179
|
}
|
|
184
180
|
export const remult = new RemultProxy();
|
package/esm/src/remult-static.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const remultStaticKey = Symbol.for('remult-static1');
|
|
2
2
|
let x = {
|
|
3
3
|
defaultRemultFactory: undefined,
|
|
4
|
+
remultFactory: undefined,
|
|
4
5
|
defaultRemult: undefined,
|
|
5
6
|
asyncContext: undefined,
|
|
6
7
|
columnsOfType: new Map(),
|
|
@@ -34,3 +35,7 @@ export function defaultFactory() {
|
|
|
34
35
|
}
|
|
35
36
|
return remultStatic.defaultRemult;
|
|
36
37
|
}
|
|
38
|
+
export function resetFactory() {
|
|
39
|
+
remultStatic.remultFactory = () => defaultFactory();
|
|
40
|
+
}
|
|
41
|
+
resetFactory();
|
|
@@ -785,8 +785,8 @@ class rowHelperBase {
|
|
|
785
785
|
this.isNewRow = isNewRow;
|
|
786
786
|
{
|
|
787
787
|
let fac = remult;
|
|
788
|
-
if (fac != null && fac.
|
|
789
|
-
remult =
|
|
788
|
+
if (fac != null && fac.iAmRemultProxy) {
|
|
789
|
+
remult = remultStatic.remultFactory();
|
|
790
790
|
}
|
|
791
791
|
}
|
|
792
792
|
for (const col of fieldsMetadata) {
|
package/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { RestDataProvider } from './src/data-providers/rest-data-provider.js';
|
|
|
19
19
|
export { InMemoryDataProvider } from './src/data-providers/in-memory-database.js';
|
|
20
20
|
export { WebSqlDataProvider } from './src/data-providers/web-sql-data-provider.js';
|
|
21
21
|
export { SqlDatabase } from './src/data-providers/sql-database.js';
|
|
22
|
-
export { CustomSqlFilterObject, CustomSqlFilterBuilder, dbNamesOf, CustomSqlFilterBuilderFunction, EntityDbNames, } from './src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
22
|
+
export { CustomSqlFilterObject, CustomSqlFilterBuilder, dbNamesOf, dbNamesOfOptions, CustomSqlFilterBuilderFunction, EntityDbNames, } from './src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
23
23
|
export { JsonDataProvider, JsonEntityStorage, } from './src/data-providers/json-data-provider.js';
|
|
24
24
|
export { JsonEntityOpfsStorage } from './src/data-providers/json-entity-opfs-storage.js';
|
|
25
25
|
export { Controller, BackendMethodOptions, BackendMethod, ProgressListener, } from './src/server-action.js';
|
package/package.json
CHANGED
package/src/context.d.ts
CHANGED
|
@@ -132,8 +132,9 @@ export interface ApiClient {
|
|
|
132
132
|
subscriptionClient?: SubscriptionClient;
|
|
133
133
|
/**
|
|
134
134
|
* A function that wraps message handling for subscriptions. This is useful for executing some code before
|
|
135
|
-
* or after any message arrives from the subscription.
|
|
136
|
-
* a
|
|
135
|
+
* or after any message arrives from the subscription.
|
|
136
|
+
* For example, in Angular, to refresh a specific part of the UI,
|
|
137
|
+
* you can call the `NgZone` run method at this time.
|
|
137
138
|
*
|
|
138
139
|
* @example
|
|
139
140
|
* // Angular example
|
package/src/context.js
CHANGED
|
@@ -16,8 +16,7 @@ var RemultAsyncLocalStorage = /** @class */ (function () {
|
|
|
16
16
|
this.remultObjectStorage = remultObjectStorage;
|
|
17
17
|
}
|
|
18
18
|
RemultAsyncLocalStorage.enable = function () {
|
|
19
|
-
|
|
20
|
-
remult_proxy_js_1.remult.remultFactory = function () {
|
|
19
|
+
remult_static_js_1.remultStatic.remultFactory = function () {
|
|
21
20
|
var r = remult_static_js_1.remultStatic.asyncContext.getRemult();
|
|
22
21
|
if (r)
|
|
23
22
|
return r;
|
|
@@ -26,8 +25,7 @@ var RemultAsyncLocalStorage = /** @class */ (function () {
|
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
27
|
RemultAsyncLocalStorage.disable = function () {
|
|
29
|
-
;
|
|
30
|
-
remult_proxy_js_1.remult.resetFactory();
|
|
28
|
+
(0, remult_static_js_1.resetFactory)();
|
|
31
29
|
};
|
|
32
30
|
RemultAsyncLocalStorage.prototype.run = function (remult, callback) {
|
|
33
31
|
if (this.remultObjectStorage)
|
|
@@ -49,6 +49,10 @@ export declare type EntityDbNamesBase = {
|
|
|
49
49
|
export declare type EntityDbNames<entityType> = {
|
|
50
50
|
[Properties in keyof Required<MembersOnly<entityType>>]: string;
|
|
51
51
|
} & EntityDbNamesBase;
|
|
52
|
-
export
|
|
52
|
+
export interface dbNamesOfOptions {
|
|
53
|
+
wrapIdentifier?: (name: string) => string;
|
|
54
|
+
tableName?: boolean | string;
|
|
55
|
+
}
|
|
56
|
+
export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
|
|
53
57
|
export declare function entityDbName(metadata: EntityMetadata, wrapIdentifier?: (name: string) => string): Promise<string>;
|
|
54
58
|
export declare function fieldDbName(f: FieldMetadata, meta: EntityMetadata, wrapIdentifier?: (name: string) => string): Promise<string>;
|
|
@@ -269,25 +269,28 @@ function shouldNotCreateField(field, dbNames) {
|
|
|
269
269
|
(field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
|
|
270
270
|
}
|
|
271
271
|
exports.shouldNotCreateField = shouldNotCreateField;
|
|
272
|
-
function dbNamesOf(repo,
|
|
272
|
+
function dbNamesOf(repo, wrapIdentifierOrOptions) {
|
|
273
273
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
274
|
-
var meta, result, _a, _b, field,
|
|
275
|
-
var
|
|
276
|
-
return tslib_1.__generator(this, function (
|
|
277
|
-
switch (
|
|
274
|
+
var options, meta, result, _a, _b, field, r, e_3_1;
|
|
275
|
+
var _c, e_3, _d;
|
|
276
|
+
return tslib_1.__generator(this, function (_e) {
|
|
277
|
+
switch (_e.label) {
|
|
278
278
|
case 0:
|
|
279
|
+
options = typeof wrapIdentifierOrOptions === 'function'
|
|
280
|
+
? { wrapIdentifier: wrapIdentifierOrOptions }
|
|
281
|
+
: wrapIdentifierOrOptions || {};
|
|
279
282
|
meta = (0, RepositoryImplementation_js_1.getEntityMetadata)(repo);
|
|
280
|
-
if (!wrapIdentifier) {
|
|
281
|
-
wrapIdentifier = remult_proxy_js_1.remult.dataProvider.wrapIdentifier;
|
|
283
|
+
if (!options.wrapIdentifier) {
|
|
284
|
+
options.wrapIdentifier = remult_proxy_js_1.remult.dataProvider.wrapIdentifier;
|
|
282
285
|
}
|
|
283
|
-
if (!wrapIdentifier)
|
|
284
|
-
wrapIdentifier = function (x) { return x; };
|
|
285
|
-
|
|
286
|
-
return [4 /*yield*/, entityDbName(meta, wrapIdentifier)];
|
|
286
|
+
if (!options.wrapIdentifier)
|
|
287
|
+
options.wrapIdentifier = function (x) { return x; };
|
|
288
|
+
_c = {};
|
|
289
|
+
return [4 /*yield*/, entityDbName(meta, options.wrapIdentifier)];
|
|
287
290
|
case 1:
|
|
288
|
-
result = (
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
result = (_c.$entityName = _e.sent(),
|
|
292
|
+
_c.toString = function () { return result.$entityName; },
|
|
293
|
+
_c.$dbNameOf = function (field) {
|
|
291
294
|
var key;
|
|
292
295
|
if (typeof field === 'string')
|
|
293
296
|
key = field;
|
|
@@ -295,32 +298,37 @@ function dbNamesOf(repo, wrapIdentifier) {
|
|
|
295
298
|
key = field.key;
|
|
296
299
|
return result[key];
|
|
297
300
|
},
|
|
298
|
-
|
|
299
|
-
|
|
301
|
+
_c);
|
|
302
|
+
_e.label = 2;
|
|
300
303
|
case 2:
|
|
301
|
-
|
|
304
|
+
_e.trys.push([2, 7, 8, 9]);
|
|
302
305
|
_a = tslib_1.__values(meta.fields), _b = _a.next();
|
|
303
|
-
|
|
306
|
+
_e.label = 3;
|
|
304
307
|
case 3:
|
|
305
308
|
if (!!_b.done) return [3 /*break*/, 6];
|
|
306
309
|
field = _b.value;
|
|
307
|
-
|
|
308
|
-
_d = field.key;
|
|
309
|
-
return [4 /*yield*/, fieldDbName(field, meta, wrapIdentifier)];
|
|
310
|
+
return [4 /*yield*/, fieldDbName(field, meta, options.wrapIdentifier)];
|
|
310
311
|
case 4:
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
r = _e.sent();
|
|
313
|
+
if (!field.options.sqlExpression)
|
|
314
|
+
if (typeof options.tableName === 'string')
|
|
315
|
+
r = options.wrapIdentifier(options.tableName) + '.' + r;
|
|
316
|
+
else if (options.tableName === true) {
|
|
317
|
+
r = result.$entityName + '.' + r;
|
|
318
|
+
}
|
|
319
|
+
result[field.key] = r;
|
|
320
|
+
_e.label = 5;
|
|
313
321
|
case 5:
|
|
314
322
|
_b = _a.next();
|
|
315
323
|
return [3 /*break*/, 3];
|
|
316
324
|
case 6: return [3 /*break*/, 9];
|
|
317
325
|
case 7:
|
|
318
|
-
e_3_1 =
|
|
326
|
+
e_3_1 = _e.sent();
|
|
319
327
|
e_3 = { error: e_3_1 };
|
|
320
328
|
return [3 /*break*/, 9];
|
|
321
329
|
case 8:
|
|
322
330
|
try {
|
|
323
|
-
if (_b && !_b.done && (
|
|
331
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
324
332
|
}
|
|
325
333
|
finally { if (e_3) throw e_3.error; }
|
|
326
334
|
return [7 /*endfinally*/];
|
|
@@ -352,13 +360,12 @@ exports.entityDbName = entityDbName;
|
|
|
352
360
|
function fieldDbName(f, meta, wrapIdentifier) {
|
|
353
361
|
if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
|
|
354
362
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
355
|
-
var
|
|
363
|
+
var result_1, prev, rel, field, fInfo;
|
|
356
364
|
return tslib_1.__generator(this, function (_a) {
|
|
357
365
|
switch (_a.label) {
|
|
358
366
|
case 0:
|
|
359
367
|
_a.trys.push([0, , 8, 9]);
|
|
360
368
|
if (!f.options.sqlExpression) return [3 /*break*/, 7];
|
|
361
|
-
result = void 0;
|
|
362
369
|
if (!(typeof f.options.sqlExpression === 'function')) return [3 /*break*/, 5];
|
|
363
370
|
prev = f.options.sqlExpression;
|
|
364
371
|
_a.label = 1;
|
|
@@ -368,19 +375,18 @@ function fieldDbName(f, meta, wrapIdentifier) {
|
|
|
368
375
|
"recursive sqlExpression call for field '" + f.key + "'. ";
|
|
369
376
|
return [4 /*yield*/, prev(meta)];
|
|
370
377
|
case 2:
|
|
371
|
-
|
|
378
|
+
result_1 = _a.sent();
|
|
379
|
+
f.options.sqlExpression = function () { return result_1; };
|
|
372
380
|
return [3 /*break*/, 4];
|
|
373
|
-
case 3:
|
|
374
|
-
f.options.sqlExpression = prev;
|
|
375
|
-
return [7 /*endfinally*/];
|
|
381
|
+
case 3: return [7 /*endfinally*/];
|
|
376
382
|
case 4: return [3 /*break*/, 6];
|
|
377
383
|
case 5:
|
|
378
|
-
|
|
384
|
+
result_1 = f.options.sqlExpression;
|
|
379
385
|
_a.label = 6;
|
|
380
386
|
case 6:
|
|
381
|
-
if (!
|
|
387
|
+
if (!result_1)
|
|
382
388
|
return [2 /*return*/, f.dbName];
|
|
383
|
-
return [2 /*return*/,
|
|
389
|
+
return [2 /*return*/, result_1];
|
|
384
390
|
case 7:
|
|
385
391
|
rel = (0, relationInfoMember_js_1.getRelationFieldInfo)(f);
|
|
386
392
|
field = (rel === null || rel === void 0 ? void 0 : rel.type) === 'toOne' &&
|
package/src/remult-proxy.js
CHANGED
|
@@ -8,8 +8,8 @@ var repository_internals_js_1 = require("./remult3/repository-internals.js");
|
|
|
8
8
|
var RemultProxy = /** @class */ (function () {
|
|
9
9
|
function RemultProxy() {
|
|
10
10
|
var _this = this;
|
|
11
|
-
|
|
12
|
-
this.
|
|
11
|
+
/* @internal*/
|
|
12
|
+
this.iAmRemultProxy = true;
|
|
13
13
|
this.repoCache = new Map();
|
|
14
14
|
//@ts-ignore
|
|
15
15
|
this.repo = function () {
|
|
@@ -18,10 +18,10 @@ var RemultProxy = /** @class */ (function () {
|
|
|
18
18
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
19
19
|
args[_i] = arguments[_i];
|
|
20
20
|
}
|
|
21
|
-
var self =
|
|
22
|
-
var entityCache =
|
|
21
|
+
var self = remult_static_js_1.remultStatic;
|
|
22
|
+
var entityCache = _this.repoCache.get(args[0]);
|
|
23
23
|
if (!entityCache) {
|
|
24
|
-
|
|
24
|
+
_this.repoCache.set(args[0], (entityCache = new Map()));
|
|
25
25
|
}
|
|
26
26
|
var result = entityCache.get(args[1]);
|
|
27
27
|
if (result)
|
|
@@ -29,7 +29,7 @@ var RemultProxy = /** @class */ (function () {
|
|
|
29
29
|
result = (_a = {
|
|
30
30
|
get fields() {
|
|
31
31
|
var _a;
|
|
32
|
-
return (_a =
|
|
32
|
+
return (_a = remult_static_js_1.remultStatic.remultFactory()).repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).metadata.fields;
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
//@ts-ignore
|
|
@@ -178,7 +178,7 @@ var RemultProxy = /** @class */ (function () {
|
|
|
178
178
|
Object.defineProperty(_a, "metadata", {
|
|
179
179
|
get: function () {
|
|
180
180
|
var _a;
|
|
181
|
-
return (_a =
|
|
181
|
+
return (_a = remult_static_js_1.remultStatic.remultFactory()).repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).metadata;
|
|
182
182
|
},
|
|
183
183
|
enumerable: false,
|
|
184
184
|
configurable: true
|
|
@@ -214,11 +214,11 @@ var RemultProxy = /** @class */ (function () {
|
|
|
214
214
|
Object.defineProperty(RemultProxy.prototype, "liveQuerySubscriber", {
|
|
215
215
|
/* @internal*/
|
|
216
216
|
get: function () {
|
|
217
|
-
return
|
|
217
|
+
return remult_static_js_1.remultStatic.remultFactory().liveQuerySubscriber;
|
|
218
218
|
},
|
|
219
219
|
/* @internal*/
|
|
220
220
|
set: function (val) {
|
|
221
|
-
|
|
221
|
+
remult_static_js_1.remultStatic.remultFactory().liveQuerySubscriber = val;
|
|
222
222
|
},
|
|
223
223
|
enumerable: false,
|
|
224
224
|
configurable: true
|
|
@@ -226,11 +226,11 @@ var RemultProxy = /** @class */ (function () {
|
|
|
226
226
|
Object.defineProperty(RemultProxy.prototype, "liveQueryStorage", {
|
|
227
227
|
/* @internal*/
|
|
228
228
|
get: function () {
|
|
229
|
-
return
|
|
229
|
+
return remult_static_js_1.remultStatic.remultFactory().liveQueryStorage;
|
|
230
230
|
},
|
|
231
231
|
/* @internal*/
|
|
232
232
|
set: function (val) {
|
|
233
|
-
|
|
233
|
+
remult_static_js_1.remultStatic.remultFactory().liveQueryStorage = val;
|
|
234
234
|
},
|
|
235
235
|
enumerable: false,
|
|
236
236
|
configurable: true
|
|
@@ -238,11 +238,11 @@ var RemultProxy = /** @class */ (function () {
|
|
|
238
238
|
Object.defineProperty(RemultProxy.prototype, "liveQueryPublisher", {
|
|
239
239
|
/* @internal*/
|
|
240
240
|
get: function () {
|
|
241
|
-
return
|
|
241
|
+
return remult_static_js_1.remultStatic.remultFactory().liveQueryPublisher;
|
|
242
242
|
},
|
|
243
243
|
/* @internal*/
|
|
244
244
|
set: function (val) {
|
|
245
|
-
|
|
245
|
+
remult_static_js_1.remultStatic.remultFactory().liveQueryPublisher = val;
|
|
246
246
|
},
|
|
247
247
|
enumerable: false,
|
|
248
248
|
configurable: true
|
|
@@ -253,21 +253,21 @@ var RemultProxy = /** @class */ (function () {
|
|
|
253
253
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
254
254
|
args[_i - 2] = arguments[_i];
|
|
255
255
|
}
|
|
256
|
-
return (_a =
|
|
256
|
+
return (_a = remult_static_js_1.remultStatic.remultFactory()).call.apply(_a, tslib_1.__spreadArray([backendMethod, self], tslib_1.__read(args), false));
|
|
257
257
|
};
|
|
258
258
|
Object.defineProperty(RemultProxy.prototype, "context", {
|
|
259
259
|
get: function () {
|
|
260
|
-
return
|
|
260
|
+
return remult_static_js_1.remultStatic.remultFactory().context;
|
|
261
261
|
},
|
|
262
262
|
enumerable: false,
|
|
263
263
|
configurable: true
|
|
264
264
|
});
|
|
265
265
|
Object.defineProperty(RemultProxy.prototype, "dataProvider", {
|
|
266
266
|
get: function () {
|
|
267
|
-
return
|
|
267
|
+
return remult_static_js_1.remultStatic.remultFactory().dataProvider;
|
|
268
268
|
},
|
|
269
269
|
set: function (provider) {
|
|
270
|
-
|
|
270
|
+
remult_static_js_1.remultStatic.remultFactory().dataProvider = provider;
|
|
271
271
|
},
|
|
272
272
|
enumerable: false,
|
|
273
273
|
configurable: true
|
|
@@ -275,53 +275,49 @@ var RemultProxy = /** @class */ (function () {
|
|
|
275
275
|
Object.defineProperty(RemultProxy.prototype, "repCache", {
|
|
276
276
|
/*@internal*/
|
|
277
277
|
get: function () {
|
|
278
|
-
return
|
|
278
|
+
return remult_static_js_1.remultStatic.remultFactory().repCache;
|
|
279
279
|
},
|
|
280
280
|
enumerable: false,
|
|
281
281
|
configurable: true
|
|
282
282
|
});
|
|
283
283
|
RemultProxy.prototype.authenticated = function () {
|
|
284
|
-
return
|
|
284
|
+
return remult_static_js_1.remultStatic.remultFactory().authenticated();
|
|
285
285
|
};
|
|
286
286
|
RemultProxy.prototype.isAllowed = function (roles) {
|
|
287
|
-
return
|
|
287
|
+
return remult_static_js_1.remultStatic.remultFactory().isAllowed(roles);
|
|
288
288
|
};
|
|
289
289
|
RemultProxy.prototype.isAllowedForInstance = function (instance, allowed) {
|
|
290
|
-
return
|
|
290
|
+
return remult_static_js_1.remultStatic.remultFactory().isAllowedForInstance(instance, allowed);
|
|
291
291
|
};
|
|
292
292
|
RemultProxy.prototype.clearAllCache = function () {
|
|
293
|
-
return
|
|
294
|
-
};
|
|
295
|
-
/*@internal*/
|
|
296
|
-
RemultProxy.prototype.resetFactory = function () {
|
|
297
|
-
this.remultFactory = function () { return (0, remult_static_js_1.defaultFactory)(); };
|
|
293
|
+
return remult_static_js_1.remultStatic.remultFactory().clearAllCache();
|
|
298
294
|
};
|
|
299
295
|
Object.defineProperty(RemultProxy.prototype, "user", {
|
|
300
296
|
get: function () {
|
|
301
|
-
return
|
|
297
|
+
return remult_static_js_1.remultStatic.remultFactory().user;
|
|
302
298
|
},
|
|
303
299
|
set: function (info) {
|
|
304
|
-
|
|
300
|
+
remult_static_js_1.remultStatic.remultFactory().user = info;
|
|
305
301
|
},
|
|
306
302
|
enumerable: false,
|
|
307
303
|
configurable: true
|
|
308
304
|
});
|
|
309
305
|
Object.defineProperty(RemultProxy.prototype, "apiClient", {
|
|
310
306
|
get: function () {
|
|
311
|
-
return
|
|
307
|
+
return remult_static_js_1.remultStatic.remultFactory().apiClient;
|
|
312
308
|
},
|
|
313
309
|
set: function (client) {
|
|
314
|
-
|
|
310
|
+
remult_static_js_1.remultStatic.remultFactory().apiClient = client;
|
|
315
311
|
},
|
|
316
312
|
enumerable: false,
|
|
317
313
|
configurable: true
|
|
318
314
|
});
|
|
319
315
|
Object.defineProperty(RemultProxy.prototype, "subscriptionServer", {
|
|
320
316
|
get: function () {
|
|
321
|
-
return
|
|
317
|
+
return remult_static_js_1.remultStatic.remultFactory().subscriptionServer;
|
|
322
318
|
},
|
|
323
319
|
set: function (value) {
|
|
324
|
-
|
|
320
|
+
remult_static_js_1.remultStatic.remultFactory().subscriptionServer = value;
|
|
325
321
|
},
|
|
326
322
|
enumerable: false,
|
|
327
323
|
configurable: true
|
package/src/remult-static.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ClassHelper, Remult, RemultAsyncLocalStorage } from './context.js'
|
|
|
3
3
|
import type { columnInfo } from './remult3/columnInfo.js';
|
|
4
4
|
export declare const remultStatic: {
|
|
5
5
|
defaultRemultFactory: () => Remult;
|
|
6
|
+
remultFactory: () => Remult;
|
|
6
7
|
defaultRemult: Remult;
|
|
7
8
|
asyncContext: RemultAsyncLocalStorage;
|
|
8
9
|
columnsOfType: Map<any, columnInfo[]>;
|
|
@@ -20,3 +21,4 @@ export declare const remultStatic: {
|
|
|
20
21
|
captionTransformer: any;
|
|
21
22
|
};
|
|
22
23
|
export declare function defaultFactory(): Remult;
|
|
24
|
+
export declare function resetFactory(): void;
|
package/src/remult-static.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultFactory = exports.remultStatic = void 0;
|
|
3
|
+
exports.resetFactory = exports.defaultFactory = exports.remultStatic = void 0;
|
|
4
4
|
var remultStaticKey = Symbol.for('remult-static1');
|
|
5
5
|
var x = {
|
|
6
6
|
defaultRemultFactory: undefined,
|
|
7
|
+
remultFactory: undefined,
|
|
7
8
|
defaultRemult: undefined,
|
|
8
9
|
asyncContext: undefined,
|
|
9
10
|
columnsOfType: new Map(),
|
|
@@ -38,3 +39,8 @@ function defaultFactory() {
|
|
|
38
39
|
return exports.remultStatic.defaultRemult;
|
|
39
40
|
}
|
|
40
41
|
exports.defaultFactory = defaultFactory;
|
|
42
|
+
function resetFactory() {
|
|
43
|
+
exports.remultStatic.remultFactory = function () { return defaultFactory(); };
|
|
44
|
+
}
|
|
45
|
+
exports.resetFactory = resetFactory;
|
|
46
|
+
resetFactory();
|
|
@@ -1258,8 +1258,8 @@ var rowHelperBase = /** @class */ (function () {
|
|
|
1258
1258
|
this.originalValues = {};
|
|
1259
1259
|
{
|
|
1260
1260
|
var fac = remult;
|
|
1261
|
-
if (fac != null && fac.
|
|
1262
|
-
remult =
|
|
1261
|
+
if (fac != null && fac.iAmRemultProxy) {
|
|
1262
|
+
remult = remult_static_js_1.remultStatic.remultFactory();
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
1265
1265
|
var _loop_5 = function (col) {
|
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -194,7 +194,7 @@ export interface EntityMetadata<entityType = any> {
|
|
|
194
194
|
*/
|
|
195
195
|
readonly dbName: string;
|
|
196
196
|
/** The options send to the `Entity`'s decorator */
|
|
197
|
-
readonly options: EntityOptions
|
|
197
|
+
readonly options: EntityOptions;
|
|
198
198
|
/** The class type of the entity */
|
|
199
199
|
readonly entityType: ClassType<entityType>;
|
|
200
200
|
/** true if the current user is allowed to update an entity instance
|
|
@@ -347,7 +347,7 @@ export interface Repository<entityType> {
|
|
|
347
347
|
*/
|
|
348
348
|
metadata: EntityMetadata<entityType>;
|
|
349
349
|
addEventListener(listener: entityEventListener<entityType>): Unsubscribe;
|
|
350
|
-
relations
|
|
350
|
+
relations(item: entityType): RepositoryRelations<entityType>;
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* The `LiveQuery` interface represents a live query that allows subscribing to changes in the query results.
|