remult 0.25.5-exp.1 → 0.25.5-exp.3
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/graphql.js +3 -4
- package/esm/internals.js +3 -2
- package/esm/live-query/data-provider-live-query-storage.js +3 -2
- package/esm/postgres/schema-builder.js +2 -2
- package/esm/remult-knex/index.js +2 -2
- package/esm/server/expressBridge.js +7 -6
- package/esm/server/initAsyncHooks.js +2 -1
- package/esm/src/context.js +13 -11
- package/esm/src/data-api.js +2 -2
- package/esm/src/data-providers/rest-data-provider.js +7 -8
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +2 -2
- package/esm/src/filter/filter-interfaces.js +4 -6
- package/esm/src/live-query/LiveQueryClient.js +2 -2
- package/esm/src/live-query/SseSubscriptionClient.js +3 -3
- package/esm/src/remult-proxy.js +2 -8
- package/esm/src/remult-static.js +36 -0
- package/esm/src/remult3/Fields.js +8 -22
- package/esm/src/remult3/RepositoryImplementation.js +55 -143
- package/esm/src/remult3/entity.js +3 -2
- package/esm/src/remult3/relation-loader.js +2 -2
- package/esm/src/remult3/relationInfoMember.js +113 -1
- package/esm/src/remult3/remult3.js +2 -0
- package/esm/src/remult3/repository-internals.js +1 -1
- package/esm/src/server-action-info.js +0 -11
- package/esm/src/server-action.js +11 -10
- package/esm/src/sort.js +3 -3
- package/graphql.js +2 -3
- package/internals.d.ts +10 -3
- package/internals.js +4 -3
- package/live-query/data-provider-live-query-storage.js +2 -1
- package/package.json +1 -1
- package/postgres/schema-builder.js +2 -2
- package/remult-knex/index.js +2 -2
- package/server/expressBridge.js +5 -4
- package/server/initAsyncHooks.js +2 -1
- package/src/context.d.ts +0 -3
- package/src/context.js +12 -10
- package/src/data-api.js +2 -2
- package/src/data-providers/rest-data-provider.d.ts +1 -1
- package/src/data-providers/rest-data-provider.js +6 -7
- package/src/filter/filter-consumer-bridge-to-sql-request.js +1 -1
- package/src/filter/filter-interfaces.d.ts +1 -1
- package/src/filter/filter-interfaces.js +3 -5
- package/src/live-query/LiveQueryClient.js +8 -10
- package/src/live-query/SseSubscriptionClient.js +3 -3
- package/src/remult-proxy.js +4 -9
- package/src/remult-static.d.ts +22 -0
- package/src/remult-static.js +40 -0
- package/src/remult3/Fields.js +7 -20
- package/src/remult3/RepositoryImplementation.d.ts +0 -2
- package/src/remult3/RepositoryImplementation.js +203 -304
- package/src/remult3/entity.js +2 -1
- package/src/remult3/relation-loader.js +1 -1
- package/src/remult3/relationInfoMember.d.ts +29 -3
- package/src/remult3/relationInfoMember.js +145 -3
- package/src/remult3/remult3.d.ts +2 -6
- package/src/remult3/remult3.js +2 -0
- package/src/remult3/repository-internals.d.ts +1 -1
- package/src/remult3/repository-internals.js +1 -1
- package/src/server-action-info.d.ts +0 -9
- package/src/server-action-info.js +1 -12
- package/src/server-action.js +9 -8
- package/src/sort.js +3 -3
package/esm/graphql.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getRelationFieldInfo } from './internals.js';
|
|
2
2
|
import { Remult, remult } from './index.js';
|
|
3
3
|
import { DataApi } from './src/data-api.js';
|
|
4
4
|
const v2ConnectionAndPagination = false;
|
|
@@ -397,8 +397,7 @@ export function remultGraphql(options) {
|
|
|
397
397
|
}
|
|
398
398
|
const whereTypeFields = [];
|
|
399
399
|
for (const f of meta.fields) {
|
|
400
|
-
const ri =
|
|
401
|
-
// let's not consider toMany relations for now
|
|
400
|
+
const ri = getRelationFieldInfo(f);
|
|
402
401
|
if (f.options.includeInApi === false)
|
|
403
402
|
continue;
|
|
404
403
|
let type = 'String';
|
|
@@ -423,7 +422,7 @@ export function remultGraphql(options) {
|
|
|
423
422
|
let notARealField = false;
|
|
424
423
|
if (ri) {
|
|
425
424
|
{
|
|
426
|
-
const refType = ri.
|
|
425
|
+
const refType = ri.toEntity;
|
|
427
426
|
ref = entities.find((i) => i.entityType === refType);
|
|
428
427
|
}
|
|
429
428
|
notARealField = ri.type === 'toOne' || ri.type === 'toMany';
|
package/esm/internals.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { remultStatic } from './src/remult-static.js';
|
|
2
|
+
export { getRelationInfo, getRelationFieldInfo, } from './src/remult3/relationInfoMember.js';
|
|
2
3
|
export { decorateColumnSettings, controllerRefImpl, getControllerRef, } from './src/remult3/RepositoryImplementation.js';
|
|
3
4
|
export { getEntitySettings } from './src/remult3/getEntityRef.js';
|
|
4
5
|
export { __updateEntityBasedOnWhere } from './src/filter/filter-interfaces.js';
|
|
5
|
-
export
|
|
6
|
+
export const actionInfo = remultStatic.actionInfo;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { initDataProvider } from '../server/initDataProvider.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Remult } from '../src/context.js';
|
|
4
4
|
import { EntityBase } from '../src/remult3/RepositoryImplementation.js';
|
|
5
5
|
import { Fields } from '../src/remult3/Fields.js';
|
|
6
6
|
import { Entity } from '../src/remult3/entity.js';
|
|
7
|
+
import { remultStatic } from '../src/remult-static.js';
|
|
7
8
|
export class DataProviderLiveQueryStorage {
|
|
8
9
|
repo;
|
|
9
10
|
dataProvider;
|
|
@@ -89,4 +90,4 @@ LiveQueryStorageEntity = __decorate([
|
|
|
89
90
|
/*@internal */
|
|
90
91
|
], LiveQueryStorageEntity);
|
|
91
92
|
export { LiveQueryStorageEntity };
|
|
92
|
-
allEntities.splice(allEntities.indexOf(LiveQueryStorageEntity), 1);
|
|
93
|
+
remultStatic.allEntities.splice(remultStatic.allEntities.indexOf(LiveQueryStorageEntity), 1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { allEntities } from '../src/context.js';
|
|
2
1
|
import { dbNamesOf, shouldNotCreateField, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
3
2
|
import { remult as defaultRemult } from '../src/remult-proxy.js';
|
|
3
|
+
import { remultStatic } from '../src/remult-static.js';
|
|
4
4
|
import { isAutoIncrement } from '../src/remult3/RepositoryImplementation.js';
|
|
5
5
|
import { ValueConverters } from '../src/valueConverters.js';
|
|
6
6
|
export function postgresColumnSyntax(x, dbName) {
|
|
@@ -95,7 +95,7 @@ export class PostgresSchemaBuilder {
|
|
|
95
95
|
}
|
|
96
96
|
const completed = new Set();
|
|
97
97
|
const entities = [];
|
|
98
|
-
for (const entityClass of [...allEntities].reverse()) {
|
|
98
|
+
for (const entityClass of [...remultStatic.allEntities].reverse()) {
|
|
99
99
|
let entity = remult.repo(entityClass).metadata;
|
|
100
100
|
let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
|
|
101
101
|
if (completed.has(e.$entityName))
|
package/esm/remult-knex/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { allEntities } from '../src/context.js';
|
|
2
1
|
import { dbNamesOf, isDbReadonly, shouldNotCreateField, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
|
|
3
2
|
import { customDatabaseFilterToken, Filter, } from '../src/filter/filter-interfaces.js';
|
|
4
3
|
import { CompoundIdField } from '../src/CompoundIdField.js';
|
|
@@ -8,6 +7,7 @@ import { Sort } from '../src/sort.js';
|
|
|
8
7
|
import { ValueConverters } from '../src/valueConverters.js';
|
|
9
8
|
import { resultCompoundIdFilter as resultCompoundIdFilter } from '../src/resultCompoundIdFilter.js';
|
|
10
9
|
import { getRepositoryInternals } from '../src/remult3/repository-internals.js';
|
|
10
|
+
import { remultStatic } from '../src/remult-static.js';
|
|
11
11
|
export class KnexDataProvider {
|
|
12
12
|
knex;
|
|
13
13
|
constructor(knex) {
|
|
@@ -331,7 +331,7 @@ export class KnexSchemaBuilder {
|
|
|
331
331
|
async verifyStructureOfAllEntities(remult) {
|
|
332
332
|
if (!remult)
|
|
333
333
|
remult = remultContext;
|
|
334
|
-
const entities = allEntities.map((x) => remult.repo(x).metadata);
|
|
334
|
+
const entities = remultStatic.allEntities.map((x) => remult.repo(x).metadata);
|
|
335
335
|
await this.ensureSchema(entities);
|
|
336
336
|
}
|
|
337
337
|
async ensureSchema(entities) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { SseSubscriptionServer } from '../SseSubscriptionServer.js';
|
|
3
|
-
import { Remult, RemultAsyncLocalStorage,
|
|
3
|
+
import { Remult, RemultAsyncLocalStorage, withRemult } from '../src/context.js';
|
|
4
4
|
import { DataApi, serializeError } from '../src/data-api.js';
|
|
5
5
|
import { liveQueryKeepAliveRoute, streamUrl, } from '../src/live-query/SubscriptionChannel.js';
|
|
6
6
|
import { InMemoryLiveQueryStorage, LiveQueryPublisher, } from '../src/live-query/SubscriptionServer.js';
|
|
@@ -9,8 +9,9 @@ import { Fields } from '../src/remult3/Fields.js';
|
|
|
9
9
|
import { Entity } from '../src/remult3/entity.js';
|
|
10
10
|
import { getEntityKey } from '../src/remult3/getEntityRef.js';
|
|
11
11
|
import { Action, classBackendMethodsArray } from '../src/server-action.js';
|
|
12
|
-
import {
|
|
12
|
+
import { serverActionField } from '../src/server-action-info.js';
|
|
13
13
|
import { initDataProvider } from './initDataProvider.js';
|
|
14
|
+
import { remultStatic } from '../src/remult-static.js';
|
|
14
15
|
export function createRemultServerCore(options, serverCoreOptions) {
|
|
15
16
|
if (!options) {
|
|
16
17
|
options = {};
|
|
@@ -20,7 +21,7 @@ export function createRemultServerCore(options, serverCoreOptions) {
|
|
|
20
21
|
}
|
|
21
22
|
if (options.logApiEndPoints === undefined)
|
|
22
23
|
options.logApiEndPoints = true;
|
|
23
|
-
actionInfo.runningOnServer = true;
|
|
24
|
+
remultStatic.actionInfo.runningOnServer = true;
|
|
24
25
|
if (options.defaultGetLimit) {
|
|
25
26
|
DataApi.defaultGetLimit = options.defaultGetLimit;
|
|
26
27
|
}
|
|
@@ -34,7 +35,7 @@ export function createRemultServerCore(options, serverCoreOptions) {
|
|
|
34
35
|
{
|
|
35
36
|
let allControllers = [];
|
|
36
37
|
if (!options.entities)
|
|
37
|
-
options.entities = [...allEntities];
|
|
38
|
+
options.entities = [...remultStatic.allEntities];
|
|
38
39
|
if (options.entities)
|
|
39
40
|
allControllers.push(...options.entities);
|
|
40
41
|
if (options.controllers)
|
|
@@ -43,7 +44,7 @@ export function createRemultServerCore(options, serverCoreOptions) {
|
|
|
43
44
|
}
|
|
44
45
|
if (options.rootPath === undefined)
|
|
45
46
|
options.rootPath = '/api';
|
|
46
|
-
actionInfo.runningOnServer = true;
|
|
47
|
+
remultStatic.actionInfo.runningOnServer = true;
|
|
47
48
|
let bridge = new RemultServerImplementation(new inProcessQueueHandler(options.queueStorage), options, dataProvider, serverCoreOptions);
|
|
48
49
|
return bridge;
|
|
49
50
|
}
|
|
@@ -987,4 +988,4 @@ JobsInQueueEntity = __decorate([
|
|
|
987
988
|
})
|
|
988
989
|
], JobsInQueueEntity);
|
|
989
990
|
export { JobsInQueueEntity };
|
|
990
|
-
allEntities.splice(allEntities.indexOf(JobsInQueueEntity), 1);
|
|
991
|
+
remultStatic.allEntities.splice(remultStatic.allEntities.indexOf(JobsInQueueEntity), 1);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
2
|
import { RemultAsyncLocalStorage } from '../src/context.js';
|
|
3
|
+
import { remultStatic } from '../src/remult-static.js';
|
|
3
4
|
let init = false;
|
|
4
5
|
export function initAsyncHooks() {
|
|
5
6
|
if (init)
|
|
6
7
|
return;
|
|
7
8
|
init = true;
|
|
8
|
-
|
|
9
|
+
remultStatic.asyncContext = new RemultAsyncLocalStorage(new AsyncLocalStorage());
|
|
9
10
|
}
|
package/esm/src/context.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { RestDataProvider } from './data-providers/rest-data-provider.js';
|
|
2
2
|
import { LiveQueryClient } from './live-query/LiveQueryClient.js';
|
|
3
3
|
import { SseSubscriptionClient } from './live-query/SseSubscriptionClient.js';
|
|
4
|
-
import {
|
|
4
|
+
import { remult } from './remult-proxy.js';
|
|
5
5
|
import { RepositoryImplementation, createOldEntity, } from './remult3/RepositoryImplementation.js';
|
|
6
|
-
import {
|
|
6
|
+
import { serverActionField } from './server-action-info.js';
|
|
7
7
|
import { buildRestDataProvider, isExternalHttpProvider, } from './buildRestDataProvider.js';
|
|
8
|
+
import { verifyFieldRelationInfo } from './remult3/relationInfoMember.js';
|
|
9
|
+
import { remultStatic } from './remult-static.js';
|
|
8
10
|
export class RemultAsyncLocalStorage {
|
|
9
11
|
remultObjectStorage;
|
|
10
12
|
static enable() {
|
|
11
13
|
;
|
|
12
14
|
remult.remultFactory = () => {
|
|
13
|
-
const r =
|
|
15
|
+
const r = remultStatic.asyncContext.getRemult();
|
|
14
16
|
if (r)
|
|
15
17
|
return r;
|
|
16
18
|
else
|
|
@@ -36,10 +38,11 @@ export class RemultAsyncLocalStorage {
|
|
|
36
38
|
}
|
|
37
39
|
return this.remultObjectStorage.getStore();
|
|
38
40
|
}
|
|
39
|
-
static instance = new RemultAsyncLocalStorage(undefined);
|
|
40
41
|
}
|
|
42
|
+
if (!remultStatic.asyncContext)
|
|
43
|
+
remultStatic.asyncContext = new RemultAsyncLocalStorage(undefined);
|
|
41
44
|
export function isBackend() {
|
|
42
|
-
return actionInfo.runningOnServer || !remult.dataProvider.isProxy;
|
|
45
|
+
return remultStatic.actionInfo.runningOnServer || !remult.dataProvider.isProxy;
|
|
43
46
|
}
|
|
44
47
|
export class Remult {
|
|
45
48
|
/**Return's a `Repository` of the specific entity type
|
|
@@ -58,6 +61,7 @@ export class Remult {
|
|
|
58
61
|
let r = dpCache.get(entity);
|
|
59
62
|
if (!r) {
|
|
60
63
|
dpCache.set(entity, (r = new RepositoryImplementation(entity, this, dataProvider, createOldEntity(entity, this))));
|
|
64
|
+
verifyFieldRelationInfo(r, this, dataProvider);
|
|
61
65
|
}
|
|
62
66
|
return r;
|
|
63
67
|
}
|
|
@@ -178,18 +182,16 @@ export class Remult {
|
|
|
178
182
|
subscriptionClient: new SseSubscriptionClient(),
|
|
179
183
|
};
|
|
180
184
|
}
|
|
181
|
-
|
|
182
|
-
export const allEntities = [];
|
|
183
|
-
export const classHelpers = new Map();
|
|
185
|
+
remultStatic.defaultRemultFactory = () => new Remult();
|
|
184
186
|
export class ClassHelper {
|
|
185
187
|
classes = new Map();
|
|
186
188
|
}
|
|
187
189
|
export function setControllerSettings(target, options) {
|
|
188
190
|
let r = target;
|
|
189
191
|
while (true) {
|
|
190
|
-
let helper = classHelpers.get(r);
|
|
192
|
+
let helper = remultStatic.classHelpers.get(r);
|
|
191
193
|
if (!helper)
|
|
192
|
-
classHelpers.set(r, (helper = new ClassHelper()));
|
|
194
|
+
remultStatic.classHelpers.set(r, (helper = new ClassHelper()));
|
|
193
195
|
helper.classes.set(target, options);
|
|
194
196
|
let p = Object.getPrototypeOf(r.prototype);
|
|
195
197
|
if (p == null)
|
|
@@ -280,7 +282,7 @@ export function withRemult(callback, options) {
|
|
|
280
282
|
if (options?.dataProvider)
|
|
281
283
|
remult.dataProvider = options.dataProvider;
|
|
282
284
|
let r;
|
|
283
|
-
|
|
285
|
+
remultStatic.asyncContext.run(remult, () => {
|
|
284
286
|
r = new Promise(async (res, rej) => {
|
|
285
287
|
try {
|
|
286
288
|
res(await callback(remult));
|
package/esm/src/data-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getRelationInfo } from '../internals.js';
|
|
2
1
|
import { doTransaction } from './context.js';
|
|
3
2
|
import { findOptionsToJson, liveQueryAction, } from './data-providers/rest-data-provider.js';
|
|
4
3
|
import { Filter, buildFilterFromRequestParameters, customUrlToken, } from './filter/filter-interfaces.js';
|
|
4
|
+
import { getRelationFieldInfo } from './remult3/relationInfoMember.js';
|
|
5
5
|
import { ForbiddenError } from './server-action.js';
|
|
6
6
|
export class DataApi {
|
|
7
7
|
repository;
|
|
@@ -118,7 +118,7 @@ export class DataApi {
|
|
|
118
118
|
includeNone() {
|
|
119
119
|
let include = {};
|
|
120
120
|
for (const field of this.repository.metadata.fields) {
|
|
121
|
-
if (
|
|
121
|
+
if (getRelationFieldInfo(field)) {
|
|
122
122
|
include[field.key] = false;
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { UrlBuilder } from '../../urlBuilder.js';
|
|
2
2
|
import { buildRestDataProvider, retry } from '../buildRestDataProvider.js';
|
|
3
|
-
import { Remult } from '../context.js';
|
|
4
3
|
import { customUrlToken, Filter } from '../filter/filter-interfaces.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { getRelationFieldInfo } from '../remult3/relationInfoMember.js';
|
|
5
|
+
import { remultStatic } from '../remult-static.js';
|
|
7
6
|
export class RestDataProvider {
|
|
8
7
|
apiProvider;
|
|
9
8
|
constructor(apiProvider) {
|
|
@@ -32,9 +31,9 @@ export function findOptionsToJson(options, meta) {
|
|
|
32
31
|
if (Object.prototype.hasOwnProperty.call(options.include, key)) {
|
|
33
32
|
let element = options.include[key];
|
|
34
33
|
if (typeof element === 'object') {
|
|
35
|
-
const rel =
|
|
34
|
+
const rel = getRelationFieldInfo(meta.fields.find(key));
|
|
36
35
|
if (rel) {
|
|
37
|
-
element = findOptionsToJson(element,
|
|
36
|
+
element = findOptionsToJson(element, rel.toRepo.metadata);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
newInclude[key] = element;
|
|
@@ -74,9 +73,9 @@ export function findOptionsFromJson(json, meta) {
|
|
|
74
73
|
if (Object.prototype.hasOwnProperty.call(newInclude, key)) {
|
|
75
74
|
let element = newInclude[key];
|
|
76
75
|
if (typeof element === 'object') {
|
|
77
|
-
const rel =
|
|
76
|
+
const rel = getRelationFieldInfo(meta.fields.find(key));
|
|
78
77
|
if (rel) {
|
|
79
|
-
element = findOptionsFromJson(element,
|
|
78
|
+
element = findOptionsFromJson(element, rel.toRepo.metadata);
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
newInclude[key] = element;
|
|
@@ -179,7 +178,7 @@ export class RestEntityDataProvider {
|
|
|
179
178
|
return {
|
|
180
179
|
result,
|
|
181
180
|
unsubscribe: async () => {
|
|
182
|
-
return actionInfo.runActionWithoutBlockingUI(() => this.http().post(this.url() + '?__action=endLiveQuery', {
|
|
181
|
+
return remultStatic.actionInfo.runActionWithoutBlockingUI(() => this.http().post(this.url() + '?__action=endLiveQuery', {
|
|
183
182
|
id: queryId,
|
|
184
183
|
}));
|
|
185
184
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SqlDatabase } from '../data-providers/sql-database.js';
|
|
2
2
|
import { getEntityMetadata } from '../remult3/RepositoryImplementation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getRelationFieldInfo } from '../remult3/relationInfoMember.js';
|
|
4
4
|
export class FilterConsumerBridgeToSqlRequest {
|
|
5
5
|
r;
|
|
6
6
|
nameProvider;
|
|
@@ -200,7 +200,7 @@ export async function fieldDbName(f, meta, wrapIdentifier = (x) => x) {
|
|
|
200
200
|
return f.dbName;
|
|
201
201
|
return result;
|
|
202
202
|
}
|
|
203
|
-
const rel =
|
|
203
|
+
const rel = getRelationFieldInfo(f);
|
|
204
204
|
let field = rel?.type === 'toOne' &&
|
|
205
205
|
f.options.field;
|
|
206
206
|
if (field) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Remult } from '../context.js';
|
|
2
1
|
import { getEntityRef, getEntitySettings } from '../remult3/getEntityRef.js';
|
|
3
|
-
import {
|
|
2
|
+
import { getRelationFieldInfo } from '../remult3/relationInfoMember.js';
|
|
4
3
|
export class Filter {
|
|
5
4
|
apply;
|
|
6
5
|
constructor(apply) {
|
|
@@ -49,7 +48,7 @@ export class Filter {
|
|
|
49
48
|
}
|
|
50
49
|
else {
|
|
51
50
|
const field = entity.fields[key];
|
|
52
|
-
const rel =
|
|
51
|
+
const rel = getRelationFieldInfo(field);
|
|
53
52
|
const op = field.options;
|
|
54
53
|
let fh = rel?.type === 'toOne'
|
|
55
54
|
? op.fields
|
|
@@ -167,10 +166,9 @@ class filterHelper {
|
|
|
167
166
|
if (ei) {
|
|
168
167
|
if (!val) {
|
|
169
168
|
if (val === null && !this.metadata.allowNull) {
|
|
170
|
-
const rel =
|
|
169
|
+
const rel = getRelationFieldInfo(this.metadata);
|
|
171
170
|
if (rel?.type === 'reference')
|
|
172
|
-
if (
|
|
173
|
-
.valueType === Number)
|
|
171
|
+
if (rel.toRepo.metadata.idMetadata.field.options.valueType === Number)
|
|
174
172
|
return 0;
|
|
175
173
|
else
|
|
176
174
|
return '';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { buildRestDataProvider } from '../buildRestDataProvider.js';
|
|
2
2
|
import { RestDataProvider } from '../data-providers/rest-data-provider.js';
|
|
3
|
+
import { remultStatic } from '../remult-static.js';
|
|
3
4
|
import { getRepositoryInternals } from '../remult3/repository-internals.js';
|
|
4
5
|
import { liveQueryKeepAliveRoute, LiveQuerySubscriber, } from './SubscriptionChannel.js';
|
|
5
6
|
/* @internal*/
|
|
@@ -165,8 +166,7 @@ export class LiveQueryClient {
|
|
|
165
166
|
}
|
|
166
167
|
if (ids.length > 0) {
|
|
167
168
|
let p = this.apiProvider();
|
|
168
|
-
|
|
169
|
-
const invalidIds = await this.runPromise(await actionInfo.runActionWithoutBlockingUI(() => buildRestDataProvider(p.httpClient).post(p.url + '/' + liveQueryKeepAliveRoute, ids)));
|
|
169
|
+
const invalidIds = await this.runPromise(await remultStatic.actionInfo.runActionWithoutBlockingUI(() => buildRestDataProvider(p.httpClient).post(p.url + '/' + liveQueryKeepAliveRoute, ids)));
|
|
170
170
|
for (const id of invalidIds) {
|
|
171
171
|
for (const q of this.queries.values()) {
|
|
172
172
|
if (q.queryChannel === id)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildRestDataProvider } from '../buildRestDataProvider.js';
|
|
2
2
|
import { remult } from '../remult-proxy.js';
|
|
3
|
-
import {
|
|
3
|
+
import { remultStatic } from '../remult-static.js';
|
|
4
4
|
import { streamUrl } from './SubscriptionChannel.js';
|
|
5
5
|
export class SseSubscriptionClient {
|
|
6
6
|
openConnection(onReconnect) {
|
|
@@ -23,7 +23,7 @@ export class SseSubscriptionClient {
|
|
|
23
23
|
return () => {
|
|
24
24
|
listeners.splice(listeners.indexOf(handler, 1));
|
|
25
25
|
if (listeners.length == 0) {
|
|
26
|
-
actionInfo.runActionWithoutBlockingUI(() => provider.post(remult.apiClient.url + '/' + streamUrl + '/unsubscribe', {
|
|
26
|
+
remultStatic.actionInfo.runActionWithoutBlockingUI(() => provider.post(remult.apiClient.url + '/' + streamUrl + '/unsubscribe', {
|
|
27
27
|
channel: channel,
|
|
28
28
|
clientId: connectionId,
|
|
29
29
|
}));
|
|
@@ -69,7 +69,7 @@ export class SseSubscriptionClient {
|
|
|
69
69
|
});
|
|
70
70
|
return createConnectionPromise();
|
|
71
71
|
async function subscribeToChannel(channel) {
|
|
72
|
-
const result = await actionInfo.runActionWithoutBlockingUI(() => {
|
|
72
|
+
const result = await remultStatic.actionInfo.runActionWithoutBlockingUI(() => {
|
|
73
73
|
return provider.post(remult.apiClient.url + '/' + streamUrl + '/subscribe', {
|
|
74
74
|
channel: channel,
|
|
75
75
|
clientId: connectionId,
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
+
import { defaultFactory } from './remult-static.js';
|
|
1
2
|
import { getInternalKey } from './remult3/repository-internals.js';
|
|
2
|
-
let defaultRemult;
|
|
3
|
-
function defaultFactory() {
|
|
4
|
-
if (!defaultRemult) {
|
|
5
|
-
defaultRemult = RemultProxy.defaultRemultFactory();
|
|
6
|
-
}
|
|
7
|
-
return defaultRemult;
|
|
8
|
-
}
|
|
9
3
|
/*@internal*/
|
|
10
4
|
export class RemultProxy {
|
|
11
|
-
static defaultRemultFactory;
|
|
12
5
|
/* @internal*/
|
|
13
6
|
get liveQuerySubscriber() {
|
|
14
7
|
return this.remultFactory().liveQuerySubscriber;
|
|
@@ -82,6 +75,7 @@ export class RemultProxy {
|
|
|
82
75
|
get fields() {
|
|
83
76
|
return self.remultFactory().repo(...args).metadata.fields;
|
|
84
77
|
},
|
|
78
|
+
//@ts-ignore
|
|
85
79
|
[getInternalKey]() {
|
|
86
80
|
return self
|
|
87
81
|
.remultFactory()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const remultStaticKey = Symbol.for('remult-static1');
|
|
2
|
+
let x = {
|
|
3
|
+
defaultRemultFactory: undefined,
|
|
4
|
+
defaultRemult: undefined,
|
|
5
|
+
asyncContext: undefined,
|
|
6
|
+
columnsOfType: new Map(),
|
|
7
|
+
allEntities: [],
|
|
8
|
+
classHelpers: new Map(),
|
|
9
|
+
actionInfo: {
|
|
10
|
+
allActions: [],
|
|
11
|
+
runningOnServer: false,
|
|
12
|
+
runActionWithoutBlockingUI: (what) => {
|
|
13
|
+
return what();
|
|
14
|
+
},
|
|
15
|
+
startBusyWithProgress: () => ({
|
|
16
|
+
progress: (percent) => { },
|
|
17
|
+
close: () => { },
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
captionTransformer: undefined,
|
|
21
|
+
};
|
|
22
|
+
if ((typeof process !== 'undefined' &&
|
|
23
|
+
process.env['IGNORE_GLOBAL_REMULT_IN_TESTS']) ||
|
|
24
|
+
typeof globalThis[remultStaticKey] === 'undefined') {
|
|
25
|
+
globalThis[remultStaticKey] = x;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
x = globalThis[remultStaticKey];
|
|
29
|
+
}
|
|
30
|
+
export const remultStatic = x;
|
|
31
|
+
export function defaultFactory() {
|
|
32
|
+
if (!remultStatic.defaultRemult) {
|
|
33
|
+
remultStatic.defaultRemult = remultStatic.defaultRemultFactory();
|
|
34
|
+
}
|
|
35
|
+
return remultStatic.defaultRemult;
|
|
36
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createId } from '@paralleldrive/cuid2';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
3
|
import { ValueConverters } from '../valueConverters.js';
|
|
4
|
-
import { buildOptions
|
|
5
|
-
import { relationInfoMember } from './relationInfoMember.js';
|
|
4
|
+
import { buildOptions } from './RepositoryImplementation.js';
|
|
6
5
|
import { Validators } from '../validators.js';
|
|
6
|
+
import { relationInfoMemberInOptions } from './relationInfoMember.js';
|
|
7
|
+
import { remultStatic } from '../remult-static.js';
|
|
7
8
|
export class Fields {
|
|
8
9
|
/**
|
|
9
10
|
* Stored as a JSON.stringify - to store as json use Fields.json
|
|
@@ -146,22 +147,12 @@ export class Relations {
|
|
|
146
147
|
//@ts-ignore
|
|
147
148
|
return Field(toEntityType, {
|
|
148
149
|
...op,
|
|
149
|
-
|
|
150
|
-
[relationInfoMember]: {
|
|
151
|
-
//field,
|
|
152
|
-
toType: toEntityType,
|
|
153
|
-
type: 'reference',
|
|
154
|
-
},
|
|
150
|
+
...relationInfoMemberInOptions(toEntityType, 'reference'),
|
|
155
151
|
});
|
|
156
152
|
return Field(() => undefined, {
|
|
157
153
|
...op,
|
|
158
154
|
serverExpression: () => undefined,
|
|
159
|
-
|
|
160
|
-
[relationInfoMember]: {
|
|
161
|
-
//field,
|
|
162
|
-
toType: toEntityType,
|
|
163
|
-
type: 'toOne',
|
|
164
|
-
},
|
|
155
|
+
...relationInfoMemberInOptions(toEntityType, 'toOne'),
|
|
165
156
|
});
|
|
166
157
|
}
|
|
167
158
|
static toMany(toEntityType, options) {
|
|
@@ -171,12 +162,7 @@ export class Relations {
|
|
|
171
162
|
return Field(() => undefined, {
|
|
172
163
|
...op,
|
|
173
164
|
serverExpression: () => undefined,
|
|
174
|
-
|
|
175
|
-
[relationInfoMember]: {
|
|
176
|
-
//field,
|
|
177
|
-
toType: toEntityType,
|
|
178
|
-
type: 'toMany',
|
|
179
|
-
},
|
|
165
|
+
...relationInfoMemberInOptions(toEntityType, 'toMany'),
|
|
180
166
|
});
|
|
181
167
|
}
|
|
182
168
|
}
|
|
@@ -223,10 +209,10 @@ export function Field(valueType, ...options) {
|
|
|
223
209
|
return r;
|
|
224
210
|
};
|
|
225
211
|
checkTarget(target);
|
|
226
|
-
let names = columnsOfType.get(target.constructor);
|
|
212
|
+
let names = remultStatic.columnsOfType.get(target.constructor);
|
|
227
213
|
if (!names) {
|
|
228
214
|
names = [];
|
|
229
|
-
columnsOfType.set(target.constructor, names);
|
|
215
|
+
remultStatic.columnsOfType.set(target.constructor, names);
|
|
230
216
|
}
|
|
231
217
|
let set = names.find((x) => x.key == key);
|
|
232
218
|
if (!set)
|