remult 0.26.23 → 0.27.1-next.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.
- package/SseSubscriptionServer.d.ts +3 -4
- package/assign.js +1 -2
- package/esm/graphql.js +1 -1
- package/esm/remult-hono.js +3 -1
- package/esm/remult-knex/index.js +3 -1
- package/esm/remult-sqlite3.js +4 -1
- package/esm/remult-sveltekit.js +1 -0
- package/esm/server/index.js +3 -2
- package/esm/server/initAsyncHooks.js +3 -3
- package/esm/server/remult-admin.js +1 -4
- package/esm/server/remult-api-server.js +48 -48
- package/esm/src/CompoundIdField.js +9 -9
- package/esm/src/data-api.js +1 -1
- package/esm/src/data-providers/json-entity-opfs-storage.js +9 -5
- package/esm/src/data-providers/sql-database.js +9 -9
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +3 -1
- package/esm/src/filter/filter-interfaces.js +1 -1
- package/esm/src/live-query/LiveQueryClient.js +0 -1
- package/esm/src/remult-proxy.js +1 -3
- package/esm/src/remult-static.js +1 -0
- package/esm/src/remult3/Fields.js +15 -7
- package/esm/src/remult3/RepositoryImplementation.js +165 -125
- package/esm/src/remult3/entity.js +1 -1
- package/esm/src/remult3/relation-loader.js +2 -2
- package/esm/src/remult3/remult3.js +18 -2
- package/esm/src/server-action.js +16 -12
- package/esm/src/sort.js +0 -2
- package/esm/src/validators.js +3 -3
- package/esm/src/valueConverters.js +2 -2
- package/graphql.js +3 -4
- package/index.js +2 -2
- package/live-query/data-provider-live-query-storage.js +6 -6
- package/migrations/compare-migration-snapshots.js +48 -49
- package/migrations/generate-migrations.js +1 -2
- package/migrations/migrate.js +2 -3
- package/migrations/migration-types.d.ts +1 -1
- package/migrations/migration-types.js +4 -4
- package/migrations/update-migrations-ts-file.js +1 -2
- package/myLog.js +1 -2
- package/package.json +1 -1
- package/postgres/postgres-data-provider.d.ts +2 -2
- package/postgres/postgres-data-provider.js +5 -5
- package/postgres/schema-builder.d.ts +1 -1
- package/postgres/schema-builder.js +3 -3
- package/remult-express.js +4 -3
- package/remult-fastify.js +4 -3
- package/remult-fresh.js +1 -2
- package/remult-hapi.js +4 -3
- package/remult-hono.js +6 -3
- package/remult-knex/index.d.ts +2 -2
- package/remult-knex/index.js +7 -5
- package/remult-mongo.d.ts +1 -1
- package/remult-next.d.ts +5 -6
- package/remult-next.js +11 -6
- package/remult-nuxt.js +1 -2
- package/remult-solid-start.js +1 -2
- package/remult-sqlite3.js +4 -1
- package/remult-sveltekit.d.ts +1 -1
- package/remult-sveltekit.js +33 -35
- package/server/JsonEntityFileStorage.d.ts +1 -1
- package/server/get-remult-admin-html.js +1 -2
- package/server/index.js +4 -3
- package/server/initAsyncHooks.d.ts +10 -10
- package/server/initAsyncHooks.js +5 -2
- package/server/initDataProvider.js +1 -2
- package/server/initDataProviderOrJson.js +1 -2
- package/server/remult-admin.js +3 -7
- package/server/remult-api-server.d.ts +21 -21
- package/server/remult-api-server.js +55 -48
- package/src/CompoundIdField.d.ts +2 -2
- package/src/CompoundIdField.js +9 -0
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +8 -8
- package/src/column-interfaces.d.ts +4 -4
- package/src/column-interfaces.js +1 -2
- package/src/column.d.ts +4 -4
- package/src/column.js +2 -2
- package/src/context.d.ts +21 -4
- package/src/context.js +5 -5
- package/src/data-api.d.ts +4 -4
- package/src/data-api.js +4 -4
- package/src/data-interfaces.d.ts +1 -1
- package/src/data-interfaces.js +1 -2
- package/src/data-providers/json-entity-opfs-storage.js +30 -16
- package/src/data-providers/rest-data-provider.d.ts +3 -3
- package/src/data-providers/rest-data-provider.js +4 -4
- package/src/data-providers/sql-database.d.ts +1 -1
- package/src/data-providers/sql-database.js +11 -11
- package/src/data-providers/web-sql-data-provider.d.ts +2 -2
- package/src/entity.d.ts +1 -1
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +3 -3
- package/src/filter/filter-consumer-bridge-to-sql-request.js +21 -19
- package/src/filter/filter-interfaces.d.ts +2 -1
- package/src/filter/filter-interfaces.js +10 -7
- package/src/isOfType.js +2 -3
- package/src/live-query/SubscriptionServer.js +95 -97
- package/src/remult-proxy.js +1 -3
- package/src/remult-static.d.ts +2 -2
- package/src/remult-static.js +7 -4
- package/src/remult3/Fields.d.ts +17 -17
- package/src/remult3/Fields.js +22 -13
- package/src/remult3/RepositoryImplementation.d.ts +51 -46
- package/src/remult3/RepositoryImplementation.js +421 -368
- package/src/remult3/__updateEntityBasedOnWhere.js +1 -2
- package/src/remult3/addValidator.d.ts +1 -1
- package/src/remult3/addValidator.js +1 -2
- package/src/remult3/classDescribers.d.ts +4 -4
- package/src/remult3/classDescribers.js +3 -4
- package/src/remult3/columnInfo.d.ts +1 -1
- package/src/remult3/entity.js +2 -4
- package/src/remult3/getEntityRef.js +4 -4
- package/src/remult3/relation-loader.d.ts +1 -1
- package/src/remult3/relationInfoMember.d.ts +3 -3
- package/src/remult3/relationInfoMember.js +4 -5
- package/src/remult3/remult3.d.ts +23 -20
- package/src/remult3/remult3.js +18 -2
- package/src/remult3/repository-internals.d.ts +3 -3
- package/src/remult3/repository-internals.js +2 -2
- package/src/server-action.d.ts +2 -2
- package/src/server-action.js +65 -58
- package/src/sort.d.ts +1 -1
- package/src/sort.js +0 -2
- package/src/sql-command.d.ts +1 -1
- package/src/validators.d.ts +1 -1
- package/src/validators.js +13 -11
- package/src/valueConverters.js +3 -2
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import type { GenericResponse } from './server/index.js';
|
|
3
2
|
import type { Remult } from './src/context.js';
|
|
4
3
|
import type { SubscriptionServer } from './src/live-query/SubscriptionServer.js';
|
|
5
4
|
export declare class SseSubscriptionServer implements SubscriptionServer {
|
|
6
5
|
private canUserConnectToChannel?;
|
|
7
|
-
constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
|
|
6
|
+
constructor(canUserConnectToChannel?: ((channel: string, remult: Remult) => boolean) | undefined);
|
|
8
7
|
publishMessage<T>(channel: string, message: any): Promise<void>;
|
|
9
8
|
}
|
|
10
9
|
export interface ResponseRequiredForSSE {
|
|
@@ -15,11 +14,11 @@ export interface ResponseRequiredForSSE {
|
|
|
15
14
|
export declare class clientConnection {
|
|
16
15
|
response: GenericResponse & ResponseRequiredForSSE;
|
|
17
16
|
channels: Record<string, boolean>;
|
|
18
|
-
timeOutRef
|
|
17
|
+
timeOutRef?: NodeJS.Timeout;
|
|
19
18
|
close(): void;
|
|
20
19
|
closed: boolean;
|
|
21
20
|
write(eventData: string, eventType?: string): void;
|
|
22
|
-
connectionId:
|
|
21
|
+
connectionId: string;
|
|
23
22
|
constructor(response: GenericResponse & ResponseRequiredForSSE);
|
|
24
23
|
sendLiveMessage(): void;
|
|
25
24
|
}
|
package/assign.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assign =
|
|
3
|
+
exports.assign = assign;
|
|
4
4
|
function assign(item, valuesToSet) {
|
|
5
5
|
if (valuesToSet)
|
|
6
6
|
Object.assign(item, valuesToSet);
|
|
7
7
|
return item;
|
|
8
8
|
}
|
|
9
|
-
exports.assign = assign;
|
package/esm/graphql.js
CHANGED
|
@@ -976,7 +976,7 @@ export function translateWhereToRestBody(fields, { where }) {
|
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
978
|
if (where.OR) {
|
|
979
|
-
result.OR = where.OR.map((where) => translateWhereToRestBody(fields, { where })
|
|
979
|
+
result.OR = where.OR.map((where) => translateWhereToRestBody(fields, { where })?.where);
|
|
980
980
|
}
|
|
981
981
|
return { where: result };
|
|
982
982
|
}
|
package/esm/remult-hono.js
CHANGED
|
@@ -18,6 +18,7 @@ export function remultHono(options) {
|
|
|
18
18
|
}),
|
|
19
19
|
url: c.req.url,
|
|
20
20
|
on: (e, do1) => {
|
|
21
|
+
;
|
|
21
22
|
c['_tempOnClose'](() => do1());
|
|
22
23
|
// c.req.on('close', do1)
|
|
23
24
|
},
|
|
@@ -78,7 +79,8 @@ export function remultHono(options) {
|
|
|
78
79
|
res(streamSSE(c, (s) => {
|
|
79
80
|
sse = s;
|
|
80
81
|
return new Promise((res) => {
|
|
81
|
-
|
|
82
|
+
;
|
|
83
|
+
c['_tempOnClose'] = (x) => sse.onAbort(() => x());
|
|
82
84
|
});
|
|
83
85
|
}));
|
|
84
86
|
},
|
package/esm/remult-knex/index.js
CHANGED
|
@@ -91,8 +91,10 @@ export class KnexDataProvider {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
static async filterToRaw(entity, condition, wrapIdentifier) {
|
|
94
|
+
if (!wrapIdentifier)
|
|
95
|
+
wrapIdentifier = (x) => x;
|
|
94
96
|
const repo = getRepository(entity);
|
|
95
|
-
var b = new FilterConsumerBridgeToKnexRequest(await dbNamesOfWithForceSqlExpression(repo.metadata,
|
|
97
|
+
var b = new FilterConsumerBridgeToKnexRequest(await dbNamesOfWithForceSqlExpression(repo.metadata, wrapIdentifier), wrapIdentifier ?? wrapIdentifier);
|
|
96
98
|
b._addWhere = false;
|
|
97
99
|
await (await getRepositoryInternals(repo)._translateWhereToFilter(condition)).__applyToConsumer(b);
|
|
98
100
|
let r = await b.resolveWhere();
|
package/esm/remult-sqlite3.js
CHANGED
|
@@ -20,7 +20,10 @@ class Sqlite3Command {
|
|
|
20
20
|
if (err)
|
|
21
21
|
error(err);
|
|
22
22
|
else
|
|
23
|
-
resolve(new Sqlite3SqlResult([
|
|
23
|
+
resolve(new Sqlite3SqlResult([
|
|
24
|
+
//@ts-expect-error last id comes from sql lite as a lastId member of the function this
|
|
25
|
+
this.lastID,
|
|
26
|
+
]));
|
|
24
27
|
});
|
|
25
28
|
}
|
|
26
29
|
else
|
package/esm/remult-sveltekit.js
CHANGED
package/esm/server/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { createRemultServerCore } from './remult-api-server.js';
|
|
1
|
+
import { createRemultServerCore, } from './remult-api-server.js';
|
|
2
2
|
import { initAsyncHooks } from './initAsyncHooks.js';
|
|
3
|
+
import { cast } from '../src/isOfType.js';
|
|
3
4
|
export { SseSubscriptionServer } from '../SseSubscriptionServer.js';
|
|
4
5
|
export { DataProviderLiveQueryStorage } from '../live-query/data-provider-live-query-storage.js';
|
|
5
6
|
export { JsonEntityFileStorage, JsonFileDataProvider, } from './JsonEntityFileStorage.js';
|
|
6
7
|
export function createRemultServer(options, serverCoreOptions) {
|
|
7
8
|
initAsyncHooks();
|
|
8
9
|
return createRemultServerCore(options, serverCoreOptions || {
|
|
9
|
-
buildGenericRequestInfo: (req) => req,
|
|
10
|
+
buildGenericRequestInfo: (req) => cast(req, 'method'),
|
|
10
11
|
getRequestBody: async (req) => req.body,
|
|
11
12
|
});
|
|
12
13
|
}
|
|
@@ -18,7 +18,7 @@ export function initAsyncHooks() {
|
|
|
18
18
|
}
|
|
19
19
|
export class AsyncLocalStorageBridgeToRemultAsyncLocalStorageCoreImpl {
|
|
20
20
|
asyncLocalStorage = new AsyncLocalStorage();
|
|
21
|
-
wasImplemented;
|
|
21
|
+
wasImplemented = 'yes';
|
|
22
22
|
run(store, callback) {
|
|
23
23
|
let r;
|
|
24
24
|
this.asyncLocalStorage.run(store, () => {
|
|
@@ -44,7 +44,7 @@ const ignoreInStack = [
|
|
|
44
44
|
'RemultServerImplementation.runWithRemult',
|
|
45
45
|
];
|
|
46
46
|
export class SequentialRemultAsyncLocalStorageCore {
|
|
47
|
-
wasImplemented;
|
|
47
|
+
wasImplemented = 'yes';
|
|
48
48
|
async run(store, callback) {
|
|
49
49
|
let log = (msg) => { };
|
|
50
50
|
if (false) {
|
|
@@ -87,7 +87,7 @@ export class SequentialRemultAsyncLocalStorageCore {
|
|
|
87
87
|
currentValue;
|
|
88
88
|
}
|
|
89
89
|
export class StubRemultAsyncLocalStorageCore {
|
|
90
|
-
wasImplemented;
|
|
90
|
+
wasImplemented = 'yes';
|
|
91
91
|
async run(store, callback) {
|
|
92
92
|
this.currentValue = store;
|
|
93
93
|
return await callback();
|
|
@@ -3,10 +3,7 @@ import { Filter } from '../src/filter/filter-interfaces.js';
|
|
|
3
3
|
import { getHtml } from './get-remult-admin-html.js';
|
|
4
4
|
import { getValueList } from '../src/remult3/RepositoryImplementation.js';
|
|
5
5
|
export default function remultAdminHtml(options) {
|
|
6
|
-
let optionsFromServer = { ...options };
|
|
7
|
-
//@ts-ignore
|
|
8
|
-
delete optionsFromServer.entities;
|
|
9
|
-
delete optionsFromServer.remult;
|
|
6
|
+
let { remult, entities, ...optionsFromServer } = { ...options };
|
|
10
7
|
return getHtml().replace('<!--PLACE_HERE-->', `<script >const entities = ${JSON.stringify(buildEntityInfo(options))}
|
|
11
8
|
const optionsFromServer = ${JSON.stringify(optionsFromServer)}
|
|
12
9
|
</script>`);
|
|
@@ -15,40 +15,38 @@ import remultAdminHtml from './remult-admin.js';
|
|
|
15
15
|
import { isOfType } from '../src/isOfType.js';
|
|
16
16
|
import { initDataProviderOrJson } from './initDataProviderOrJson.js';
|
|
17
17
|
export function createRemultServerCore(options, serverCoreOptions) {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const safeOptions = options ?? {};
|
|
19
|
+
if (!safeOptions.subscriptionServer) {
|
|
20
|
+
safeOptions.subscriptionServer = new SseSubscriptionServer();
|
|
20
21
|
}
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (options.logApiEndPoints === undefined)
|
|
25
|
-
options.logApiEndPoints = true;
|
|
22
|
+
if (safeOptions.logApiEndPoints === undefined)
|
|
23
|
+
safeOptions.logApiEndPoints = true;
|
|
26
24
|
remultStatic.actionInfo.runningOnServer = true;
|
|
27
|
-
if (
|
|
28
|
-
DataApi.defaultGetLimit =
|
|
25
|
+
if (safeOptions.defaultGetLimit) {
|
|
26
|
+
DataApi.defaultGetLimit = safeOptions.defaultGetLimit;
|
|
29
27
|
}
|
|
30
|
-
if (!
|
|
31
|
-
|
|
28
|
+
if (!safeOptions.queueStorage) {
|
|
29
|
+
safeOptions.queueStorage = new InMemoryQueueStorage();
|
|
32
30
|
}
|
|
33
|
-
let dataProvider = initDataProviderOrJson(
|
|
31
|
+
let dataProvider = initDataProviderOrJson(safeOptions.dataProvider);
|
|
34
32
|
remultStatic.defaultDataProvider = () => dataProvider;
|
|
35
|
-
if (
|
|
36
|
-
|
|
33
|
+
if (safeOptions.ensureSchema === undefined)
|
|
34
|
+
safeOptions.ensureSchema = true;
|
|
37
35
|
RemultAsyncLocalStorage.enable();
|
|
38
36
|
{
|
|
39
37
|
let allControllers = [];
|
|
40
|
-
if (!
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
allControllers.push(...
|
|
44
|
-
if (
|
|
45
|
-
allControllers.push(...
|
|
46
|
-
|
|
38
|
+
if (!safeOptions.entities)
|
|
39
|
+
safeOptions.entities = [...remultStatic.allEntities];
|
|
40
|
+
if (safeOptions.entities)
|
|
41
|
+
allControllers.push(...safeOptions.entities);
|
|
42
|
+
if (safeOptions.controllers)
|
|
43
|
+
allControllers.push(...safeOptions.controllers);
|
|
44
|
+
safeOptions.controllers = allControllers;
|
|
47
45
|
}
|
|
48
|
-
if (
|
|
49
|
-
|
|
46
|
+
if (safeOptions.rootPath === undefined)
|
|
47
|
+
safeOptions.rootPath = '/api';
|
|
50
48
|
remultStatic.actionInfo.runningOnServer = true;
|
|
51
|
-
let bridge = new RemultServerImplementation(new inProcessQueueHandler(
|
|
49
|
+
let bridge = new RemultServerImplementation(new inProcessQueueHandler(safeOptions.queueStorage), safeOptions, dataProvider, serverCoreOptions);
|
|
52
50
|
return bridge;
|
|
53
51
|
}
|
|
54
52
|
/* @internal*/
|
|
@@ -223,7 +221,7 @@ export class RemultServerImplementation {
|
|
|
223
221
|
;
|
|
224
222
|
remult.subscriptionServer.openHttpServerStream(origReq, origRes);
|
|
225
223
|
}));
|
|
226
|
-
r.route(streamPath + '/subscribe').post(this.process(async (remult,
|
|
224
|
+
r.route(streamPath + '/subscribe').post(this.process(async (remult, _2, res, _, _1, origReq) => {
|
|
227
225
|
const body = remult.subscriptionServer.subscribeToChannel(await this.coreOptions.getRequestBody(origReq), res, remult);
|
|
228
226
|
}));
|
|
229
227
|
r.route(streamPath + '/unsubscribe').post(this.process(async (remult, req, res, reqInfo, origRes, origReq) => {
|
|
@@ -284,14 +282,12 @@ export class RemultServerImplementation {
|
|
|
284
282
|
x.liveQueryStorage = this.liveQueryStorage;
|
|
285
283
|
return await what(x);
|
|
286
284
|
}, {
|
|
287
|
-
dataProvider,
|
|
285
|
+
dataProvider: dataProvider,
|
|
288
286
|
});
|
|
289
287
|
}
|
|
290
288
|
process(what) {
|
|
291
289
|
return async (req, origRes) => {
|
|
292
|
-
const genReq = req
|
|
293
|
-
? this.coreOptions.buildGenericRequestInfo(req)
|
|
294
|
-
: undefined;
|
|
290
|
+
const genReq = req ? this.coreOptions.buildGenericRequestInfo(req) : {};
|
|
295
291
|
if (req) {
|
|
296
292
|
if (!genReq.query) {
|
|
297
293
|
genReq.query = req['_tempQuery'];
|
|
@@ -300,13 +296,14 @@ export class RemultServerImplementation {
|
|
|
300
296
|
genReq.params = req['_tempParams'];
|
|
301
297
|
}
|
|
302
298
|
let myReq = new RequestBridgeToDataApiRequest(genReq);
|
|
303
|
-
let myRes = new ResponseBridgeToDataApiResponse(origRes, req, this.options.error);
|
|
299
|
+
let myRes = new ResponseBridgeToDataApiResponse(origRes, req, genReq, this.options.error);
|
|
304
300
|
try {
|
|
305
301
|
if (remultStatic.asyncContext.isInInitRequest())
|
|
306
302
|
return await what(remultStatic.asyncContext.getStore().remult, myReq, myRes, genReq, origRes, req);
|
|
307
303
|
else
|
|
308
304
|
await this.runWithRemult(async (remult) => {
|
|
309
305
|
if (req) {
|
|
306
|
+
remult.context.request = req;
|
|
310
307
|
remultStatic.asyncContext.setInInitRequest(true);
|
|
311
308
|
try {
|
|
312
309
|
let user;
|
|
@@ -767,6 +764,7 @@ class RequestBridgeToDataApiRequest {
|
|
|
767
764
|
class ResponseBridgeToDataApiResponse {
|
|
768
765
|
r;
|
|
769
766
|
req;
|
|
767
|
+
genReq;
|
|
770
768
|
handleError;
|
|
771
769
|
forbidden() {
|
|
772
770
|
this.error({ message: 'Forbidden' }, undefined, 403);
|
|
@@ -774,9 +772,10 @@ class ResponseBridgeToDataApiResponse {
|
|
|
774
772
|
setStatus(status) {
|
|
775
773
|
return this.r.status(status);
|
|
776
774
|
}
|
|
777
|
-
constructor(r, req, handleError) {
|
|
775
|
+
constructor(r, req, genReq, handleError) {
|
|
778
776
|
this.r = r;
|
|
779
777
|
this.req = req;
|
|
778
|
+
this.genReq = genReq;
|
|
780
779
|
this.handleError = handleError;
|
|
781
780
|
}
|
|
782
781
|
progress(progress) { }
|
|
@@ -819,8 +818,8 @@ class ResponseBridgeToDataApiResponse {
|
|
|
819
818
|
message: body.message,
|
|
820
819
|
httpStatusCode,
|
|
821
820
|
stack: data.stack?.split('\n'),
|
|
822
|
-
url: this.
|
|
823
|
-
method: this.
|
|
821
|
+
url: this.genReq?.url,
|
|
822
|
+
method: this.genReq?.method,
|
|
824
823
|
});
|
|
825
824
|
this.setStatus(httpStatusCode).json(body);
|
|
826
825
|
};
|
|
@@ -911,7 +910,7 @@ export class EntityQueueStorage {
|
|
|
911
910
|
return (this.sync = this.sync.then(() => what()));
|
|
912
911
|
}
|
|
913
912
|
async getJobInfo(queuedJobId) {
|
|
914
|
-
let q = await this.repo.findId(queuedJobId);
|
|
913
|
+
let q = (await this.repo.findId(queuedJobId));
|
|
915
914
|
let lastProgress = undefined;
|
|
916
915
|
return {
|
|
917
916
|
userId: q.userId,
|
|
@@ -1009,8 +1008,9 @@ export class RouteImplementation {
|
|
|
1009
1008
|
res({ statusCode });
|
|
1010
1009
|
}
|
|
1011
1010
|
flush() {
|
|
1012
|
-
if (gRes
|
|
1011
|
+
if (isOfType(gRes, 'flush')) {
|
|
1013
1012
|
gRes.flush();
|
|
1013
|
+
}
|
|
1014
1014
|
}
|
|
1015
1015
|
statusCode = 200;
|
|
1016
1016
|
json(data) {
|
|
@@ -1047,7 +1047,7 @@ export class RouteImplementation {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
middleware(origReq, res, next) {
|
|
1049
1049
|
const req = this.coreOptions.buildGenericRequestInfo(origReq);
|
|
1050
|
-
let theUrl = req.url;
|
|
1050
|
+
let theUrl = req.url?.toString() || '';
|
|
1051
1051
|
if (theUrl.startsWith('/'))
|
|
1052
1052
|
//next sends a partial url '/api/tasks' and not the full url
|
|
1053
1053
|
theUrl = 'http://stam' + theUrl;
|
|
@@ -1107,22 +1107,22 @@ export class RouteImplementation {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
1109
1109
|
let JobsInQueueEntity = class JobsInQueueEntity extends IdEntity {
|
|
1110
|
-
userId;
|
|
1111
|
-
url;
|
|
1110
|
+
userId = '';
|
|
1111
|
+
url = '';
|
|
1112
1112
|
submitTime;
|
|
1113
1113
|
doneTime;
|
|
1114
|
-
result;
|
|
1115
|
-
done;
|
|
1116
|
-
error;
|
|
1117
|
-
progress;
|
|
1114
|
+
result = '';
|
|
1115
|
+
done = false;
|
|
1116
|
+
error = false;
|
|
1117
|
+
progress = 0;
|
|
1118
1118
|
};
|
|
1119
1119
|
__decorate([
|
|
1120
1120
|
Fields.string(),
|
|
1121
|
-
__metadata("design:type",
|
|
1121
|
+
__metadata("design:type", Object)
|
|
1122
1122
|
], JobsInQueueEntity.prototype, "userId", void 0);
|
|
1123
1123
|
__decorate([
|
|
1124
1124
|
Fields.string(),
|
|
1125
|
-
__metadata("design:type",
|
|
1125
|
+
__metadata("design:type", Object)
|
|
1126
1126
|
], JobsInQueueEntity.prototype, "url", void 0);
|
|
1127
1127
|
__decorate([
|
|
1128
1128
|
Fields.date(),
|
|
@@ -1134,19 +1134,19 @@ __decorate([
|
|
|
1134
1134
|
], JobsInQueueEntity.prototype, "doneTime", void 0);
|
|
1135
1135
|
__decorate([
|
|
1136
1136
|
Fields.string(),
|
|
1137
|
-
__metadata("design:type",
|
|
1137
|
+
__metadata("design:type", Object)
|
|
1138
1138
|
], JobsInQueueEntity.prototype, "result", void 0);
|
|
1139
1139
|
__decorate([
|
|
1140
1140
|
Fields.boolean(),
|
|
1141
|
-
__metadata("design:type",
|
|
1141
|
+
__metadata("design:type", Object)
|
|
1142
1142
|
], JobsInQueueEntity.prototype, "done", void 0);
|
|
1143
1143
|
__decorate([
|
|
1144
1144
|
Fields.boolean(),
|
|
1145
|
-
__metadata("design:type",
|
|
1145
|
+
__metadata("design:type", Object)
|
|
1146
1146
|
], JobsInQueueEntity.prototype, "error", void 0);
|
|
1147
1147
|
__decorate([
|
|
1148
1148
|
Fields.number(),
|
|
1149
|
-
__metadata("design:type",
|
|
1149
|
+
__metadata("design:type", Object)
|
|
1150
1150
|
], JobsInQueueEntity.prototype, "progress", void 0);
|
|
1151
1151
|
JobsInQueueEntity = __decorate([
|
|
1152
1152
|
Entity(undefined, {
|
|
@@ -36,19 +36,19 @@ export class CompoundIdField {
|
|
|
36
36
|
});
|
|
37
37
|
return r;
|
|
38
38
|
}
|
|
39
|
-
options;
|
|
39
|
+
options = {};
|
|
40
40
|
get valueConverter() {
|
|
41
41
|
throw new Error('cant get value converter of compound id');
|
|
42
42
|
}
|
|
43
43
|
target;
|
|
44
|
-
readonly;
|
|
45
|
-
allowNull;
|
|
46
|
-
dbReadOnly;
|
|
47
|
-
isServerExpression;
|
|
48
|
-
key;
|
|
49
|
-
caption;
|
|
50
|
-
inputType;
|
|
51
|
-
dbName;
|
|
44
|
+
readonly = true;
|
|
45
|
+
allowNull = false;
|
|
46
|
+
dbReadOnly = false;
|
|
47
|
+
isServerExpression = false;
|
|
48
|
+
key = '';
|
|
49
|
+
caption = '';
|
|
50
|
+
inputType = '';
|
|
51
|
+
dbName = '';
|
|
52
52
|
valueType;
|
|
53
53
|
isEqualTo(value) {
|
|
54
54
|
let result = {};
|
package/esm/src/data-api.js
CHANGED
|
@@ -286,7 +286,7 @@ export class DataApi {
|
|
|
286
286
|
async updateManyImplementation(response, request, body) {
|
|
287
287
|
try {
|
|
288
288
|
let where = await this.buildWhere(request, body);
|
|
289
|
-
Filter.throwErrorIfFilterIsEmpty(where, '
|
|
289
|
+
Filter.throwErrorIfFilterIsEmpty(where, 'updateMany');
|
|
290
290
|
return await doTransaction(this.remult, async () => {
|
|
291
291
|
let updated = 0;
|
|
292
292
|
for await (const x of this.repository.query({
|
|
@@ -2,17 +2,21 @@ export class JsonEntityOpfsStorage {
|
|
|
2
2
|
//@internal
|
|
3
3
|
opfsRoot;
|
|
4
4
|
async getItem(entityDbName) {
|
|
5
|
-
|
|
6
|
-
this.opfsRoot = await navigator.storage.getDirectory();
|
|
7
|
-
}
|
|
8
|
-
const opfsFile = await this.opfsRoot.getFileHandle(entityDbName + '.json', {
|
|
5
|
+
const opfsFile = await (await this.init()).getFileHandle(entityDbName + '.json', {
|
|
9
6
|
create: true,
|
|
10
7
|
});
|
|
11
8
|
const readable = await opfsFile.getFile();
|
|
12
9
|
return await readable.text();
|
|
13
10
|
}
|
|
11
|
+
//@internal
|
|
12
|
+
async init() {
|
|
13
|
+
if (!this.opfsRoot) {
|
|
14
|
+
this.opfsRoot = await navigator.storage.getDirectory();
|
|
15
|
+
}
|
|
16
|
+
return this.opfsRoot;
|
|
17
|
+
}
|
|
14
18
|
async setItem(entityDbName, json) {
|
|
15
|
-
const opfsFile = await this.
|
|
19
|
+
const opfsFile = await await (await this.init()).getFileHandle(entityDbName + '.json', {
|
|
16
20
|
create: true,
|
|
17
21
|
});
|
|
18
22
|
const writable = await opfsFile.createWritable();
|
|
@@ -193,16 +193,16 @@ export class SqlDatabase {
|
|
|
193
193
|
}
|
|
194
194
|
const icons = new Map([
|
|
195
195
|
// CRUD
|
|
196
|
-
['INSERT', '⚪'],
|
|
197
|
-
['SELECT', '🔵'],
|
|
198
|
-
['UPDATE', '🟣'],
|
|
199
|
-
['DELETE', '🟤'],
|
|
196
|
+
['INSERT', '⚪'], // Used to insert new data into a database.
|
|
197
|
+
['SELECT', '🔵'], // Used to select data from a database and retrieve it.
|
|
198
|
+
['UPDATE', '🟣'], // Used to update existing data within a database.
|
|
199
|
+
['DELETE', '🟤'], // Used to delete existing data from a database.
|
|
200
200
|
// Additional
|
|
201
|
-
['CREATE', '🟩'],
|
|
202
|
-
['ALTER', '🟨'],
|
|
203
|
-
['DROP', '🟥'],
|
|
204
|
-
['TRUNCATE', '⬛'],
|
|
205
|
-
['GRANT', '🟪'],
|
|
201
|
+
['CREATE', '🟩'], // Used to create a new table, or database.
|
|
202
|
+
['ALTER', '🟨'], // Used to modify an existing database object, such as a table.
|
|
203
|
+
['DROP', '🟥'], // Used to delete an entire table or database.
|
|
204
|
+
['TRUNCATE', '⬛'], // Used to remove all records from a table, including all spaces allocated for the records are removed.
|
|
205
|
+
['GRANT', '🟪'], // Used to give a specific user permission to perform certain tasks.
|
|
206
206
|
['REVOKE', '🟫'], // Used to take back permissions from a user.
|
|
207
207
|
]);
|
|
208
208
|
class LogSQLCommand {
|
|
@@ -211,7 +211,7 @@ export function isDbReadonly(field, dbNames) {
|
|
|
211
211
|
(field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
|
|
212
212
|
}
|
|
213
213
|
export function shouldNotCreateField(field, dbNames) {
|
|
214
|
-
return (field.isServerExpression ||
|
|
214
|
+
return Boolean(field.isServerExpression ||
|
|
215
215
|
(field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
|
|
216
216
|
}
|
|
217
217
|
export function shouldCreateEntity(entity, e) {
|
|
@@ -255,6 +255,7 @@ async function internalDbNamesOf(repo, wrapIdentifierOrOptions, forceSqlExpressi
|
|
|
255
255
|
else if (options.tableName === true) {
|
|
256
256
|
r = result.$entityName + '.' + r;
|
|
257
257
|
}
|
|
258
|
+
;
|
|
258
259
|
result[field.key] = r;
|
|
259
260
|
}
|
|
260
261
|
return result;
|
|
@@ -287,6 +288,7 @@ export async function fieldDbName(f, meta, wrapIdentifier = (x) => x, forceSqlEx
|
|
|
287
288
|
return "recursive sqlExpression call for field '" + f.key + "'. ";
|
|
288
289
|
}
|
|
289
290
|
try {
|
|
291
|
+
;
|
|
290
292
|
f[sqlExpressionInProgressKey] = true;
|
|
291
293
|
result = await f.options.sqlExpression(meta);
|
|
292
294
|
f.options.sqlExpression = () => result;
|
|
@@ -285,8 +285,8 @@ export class Filter {
|
|
|
285
285
|
this.__applyToConsumer(r);
|
|
286
286
|
return r.result;
|
|
287
287
|
}
|
|
288
|
-
//@internal
|
|
289
288
|
static async translateCustomWhere(r, entity, remult) {
|
|
289
|
+
// Used in hagai
|
|
290
290
|
let f = new customTranslator(async (filterKey, custom) => {
|
|
291
291
|
let r = [];
|
|
292
292
|
for (const key in entity.entityType) {
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -73,9 +73,7 @@ export class RemultProxy {
|
|
|
73
73
|
},
|
|
74
74
|
//@ts-ignore
|
|
75
75
|
[getInternalKey]() {
|
|
76
|
-
return self
|
|
77
|
-
.remultFactory()
|
|
78
|
-
.repo(...args)[getInternalKey]();
|
|
76
|
+
return self.remultFactory().repo(...args)[getInternalKey]();
|
|
79
77
|
},
|
|
80
78
|
relations: (args2) => self
|
|
81
79
|
.remultFactory()
|
package/esm/src/remult-static.js
CHANGED
|
@@ -6,6 +6,7 @@ import { Validators, createValueValidator, getEnumValues, } from '../validators.
|
|
|
6
6
|
import { relationInfoMemberInOptions } from './relationInfoMember.js';
|
|
7
7
|
import { remultStatic } from '../remult-static.js';
|
|
8
8
|
import { addValidator } from './addValidator.js';
|
|
9
|
+
import { isOfType } from '../isOfType.js';
|
|
9
10
|
const validateNumber = createValueValidator((x) => {
|
|
10
11
|
return !isNaN(x) && isFinite(x);
|
|
11
12
|
});
|
|
@@ -98,7 +99,7 @@ export class Fields {
|
|
|
98
99
|
},
|
|
99
100
|
}, ...options);
|
|
100
101
|
}
|
|
101
|
-
// static id<entityType =
|
|
102
|
+
// static id<entityType = unknown>(
|
|
102
103
|
// options?: FieldOptions<entityType, string> & { idFactory?: () => string },
|
|
103
104
|
// ): ClassFieldDecorator<entityType, string | undefined> {
|
|
104
105
|
// let buildId = options?.idFactory ?? createId
|
|
@@ -148,12 +149,13 @@ export class Fields {
|
|
|
148
149
|
}
|
|
149
150
|
static enum(enumType, ...options) {
|
|
150
151
|
let valueConverter;
|
|
151
|
-
return Field(
|
|
152
|
+
return Field(
|
|
152
153
|
//@ts-ignore
|
|
153
|
-
enumType(), {
|
|
154
|
+
() => enumType(), {
|
|
154
155
|
validate: (entity, event) => Validators.enum(enumType())(entity, event),
|
|
155
156
|
[fieldOptionalValuesFunctionKey]: () => getEnumValues(enumType()),
|
|
156
157
|
}, ...options, (options) => {
|
|
158
|
+
;
|
|
157
159
|
options[fieldOptionalValuesFunctionKey] = () => getEnumValues(enumType());
|
|
158
160
|
if (valueConverter === undefined) {
|
|
159
161
|
let enumObj = enumType();
|
|
@@ -273,11 +275,17 @@ export function Field(valueType, ...options) {
|
|
|
273
275
|
if (r.required) {
|
|
274
276
|
r.validate = addValidator(r.validate, Validators.required, true);
|
|
275
277
|
}
|
|
276
|
-
if (r
|
|
277
|
-
|
|
278
|
+
if (isOfType(r, 'maxLength')) {
|
|
279
|
+
let z = r;
|
|
280
|
+
if (z.maxLength) {
|
|
281
|
+
z.validate = addValidator(z.validate, Validators.maxLength(z.maxLength));
|
|
282
|
+
}
|
|
278
283
|
}
|
|
279
|
-
if (r
|
|
280
|
-
|
|
284
|
+
if (isOfType(r, 'minLength')) {
|
|
285
|
+
let z = r;
|
|
286
|
+
if (z.minLength) {
|
|
287
|
+
z.validate = addValidator(z.validate, Validators.minLength(z.minLength));
|
|
288
|
+
}
|
|
281
289
|
}
|
|
282
290
|
if (!r.valueType && valueType) {
|
|
283
291
|
r.valueType = valueType();
|