remult 0.13.29 → 0.14.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/index.d.ts +13 -0
- package/index.js +17 -1
- package/package.json +1 -1
- package/remult-express.d.ts +5 -1
- package/remult-express.js +16 -1
- package/remult-middleware.d.ts +2 -0
- package/remult-middleware.js +69 -0
- package/server/expressBridge.d.ts +41 -16
- package/server/expressBridge.js +32 -40
- package/src/column-interfaces.d.ts +3 -3
- package/src/entity.d.ts +2 -2
- package/src/remult3/RepositoryImplementation.d.ts +6 -5
- package/src/remult3/RepositoryImplementation.js +6 -5
- package/src/remult3/remult3.d.ts +8 -3
package/index.d.ts
CHANGED
|
@@ -20,3 +20,16 @@ export { FilterConsumerBridgeToSqlRequest } from './src/filter/filter-consumer-b
|
|
|
20
20
|
export { UrlBuilder } from './urlBuilder';
|
|
21
21
|
export { Validators } from './src/validators';
|
|
22
22
|
export { ValueConverters } from './valueConverters';
|
|
23
|
+
export { ClassType } from "./classType";
|
|
24
|
+
export { allEntities } from "./src/context";
|
|
25
|
+
export { serializeError } from "./src/data-api";
|
|
26
|
+
export { DataApiRequest } from "./src/data-api";
|
|
27
|
+
export { DataApiResponse } from "./src/data-api";
|
|
28
|
+
export { DataApi } from "./src/data-api";
|
|
29
|
+
export { getEntityKey } from "./src/remult3/index";
|
|
30
|
+
export { jobWasQueuedResult } from "./src/server-action";
|
|
31
|
+
export { queuedJobInfoResponse } from "./src/server-action";
|
|
32
|
+
export { Action } from "./src/server-action";
|
|
33
|
+
export { actionInfo } from "./src/server-action";
|
|
34
|
+
export { registerActionsOnServer } from './server/register-actions-on-server';
|
|
35
|
+
export { registerEntitiesOnServer } from './server/register-entities-on-server';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ValueConverters = exports.Validators = exports.UrlBuilder = exports.FilterConsumerBridgeToSqlRequest = exports.Filter = exports.CompoundIdField = exports.OneToMany = exports.Sort = exports.IdEntity = exports.EventSource = exports.isBackend = exports.Remult = exports.Allow = exports.ProgressListener = exports.BackendMethod = exports.Controller = exports.JsonDataProvider = exports.SqlDatabase = exports.WebSqlDataProvider = exports.ArrayEntityDataProvider = exports.InMemoryDataProvider = exports.RestDataProvider = exports.CaptionTransformer = exports.ValueListInfo = exports.getValueList = exports.ValueListFieldType = exports.getEntityRef = exports.getFields = exports.FieldType = exports.ControllerBase = exports.EntityBase = exports.BuildEntity = exports.Entity = exports.Fields = exports.Field = void 0;
|
|
3
|
+
exports.registerEntitiesOnServer = exports.registerActionsOnServer = exports.actionInfo = exports.Action = exports.getEntityKey = exports.DataApi = exports.serializeError = exports.allEntities = exports.ValueConverters = exports.Validators = exports.UrlBuilder = exports.FilterConsumerBridgeToSqlRequest = exports.Filter = exports.CompoundIdField = exports.OneToMany = exports.Sort = exports.IdEntity = exports.EventSource = exports.isBackend = exports.Remult = exports.Allow = exports.ProgressListener = exports.BackendMethod = exports.Controller = exports.JsonDataProvider = exports.SqlDatabase = exports.WebSqlDataProvider = exports.ArrayEntityDataProvider = exports.InMemoryDataProvider = exports.RestDataProvider = exports.CaptionTransformer = exports.ValueListInfo = exports.getValueList = exports.ValueListFieldType = exports.getEntityRef = exports.getFields = exports.FieldType = exports.ControllerBase = exports.EntityBase = exports.BuildEntity = exports.Entity = exports.Fields = exports.Field = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Public API Surface of remult
|
|
6
6
|
*/
|
|
@@ -57,3 +57,19 @@ var validators_1 = require("./src/validators");
|
|
|
57
57
|
Object.defineProperty(exports, "Validators", { enumerable: true, get: function () { return validators_1.Validators; } });
|
|
58
58
|
var valueConverters_1 = require("./valueConverters");
|
|
59
59
|
Object.defineProperty(exports, "ValueConverters", { enumerable: true, get: function () { return valueConverters_1.ValueConverters; } });
|
|
60
|
+
var context_2 = require("./src/context");
|
|
61
|
+
Object.defineProperty(exports, "allEntities", { enumerable: true, get: function () { return context_2.allEntities; } });
|
|
62
|
+
var data_api_1 = require("./src/data-api");
|
|
63
|
+
Object.defineProperty(exports, "serializeError", { enumerable: true, get: function () { return data_api_1.serializeError; } });
|
|
64
|
+
var data_api_2 = require("./src/data-api");
|
|
65
|
+
Object.defineProperty(exports, "DataApi", { enumerable: true, get: function () { return data_api_2.DataApi; } });
|
|
66
|
+
var index_1 = require("./src/remult3/index");
|
|
67
|
+
Object.defineProperty(exports, "getEntityKey", { enumerable: true, get: function () { return index_1.getEntityKey; } });
|
|
68
|
+
var server_action_2 = require("./src/server-action");
|
|
69
|
+
Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return server_action_2.Action; } });
|
|
70
|
+
var server_action_3 = require("./src/server-action");
|
|
71
|
+
Object.defineProperty(exports, "actionInfo", { enumerable: true, get: function () { return server_action_3.actionInfo; } });
|
|
72
|
+
var register_actions_on_server_1 = require("./server/register-actions-on-server");
|
|
73
|
+
Object.defineProperty(exports, "registerActionsOnServer", { enumerable: true, get: function () { return register_actions_on_server_1.registerActionsOnServer; } });
|
|
74
|
+
var register_entities_on_server_1 = require("./server/register-entities-on-server");
|
|
75
|
+
Object.defineProperty(exports, "registerEntitiesOnServer", { enumerable: true, get: function () { return register_entities_on_server_1.registerEntitiesOnServer; } });
|
package/package.json
CHANGED
package/remult-express.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { RemultMiddlewareOptions } from './server/expressBridge';
|
|
2
|
+
export declare function remultExpress(options?: RemultMiddlewareOptions & {
|
|
3
|
+
bodyParser?: boolean;
|
|
4
|
+
bodySizeLimit?: string;
|
|
5
|
+
}): import("./server/expressBridge").RemultExpressBridge;
|
package/remult-express.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.remultExpress = void 0;
|
|
4
|
+
var express = require("express");
|
|
4
5
|
var expressBridge_1 = require("./server/expressBridge");
|
|
5
|
-
|
|
6
|
+
function remultExpress(options) {
|
|
7
|
+
var app = express.Router();
|
|
8
|
+
if (!options) {
|
|
9
|
+
options = {};
|
|
10
|
+
}
|
|
11
|
+
if (options.bodySizeLimit === undefined) {
|
|
12
|
+
options.bodySizeLimit = '10mb';
|
|
13
|
+
}
|
|
14
|
+
if ((options === null || options === void 0 ? void 0 : options.bodyParser) !== false) {
|
|
15
|
+
app.use(express.json({ limit: options.bodySizeLimit }));
|
|
16
|
+
app.use(express.urlencoded({ extended: true, limit: options.bodySizeLimit }));
|
|
17
|
+
}
|
|
18
|
+
return expressBridge_1.remultMiddlewareBase(app, options);
|
|
19
|
+
}
|
|
20
|
+
exports.remultExpress = remultExpress;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.remultMiddleware = void 0;
|
|
4
|
+
var expressBridge_1 = require("./server/expressBridge");
|
|
5
|
+
function remultMiddleware(options) {
|
|
6
|
+
var m = new middleware();
|
|
7
|
+
var app = Object.assign(m, function (req, res, next) { return m.handleRequest(req, res, next); });
|
|
8
|
+
return expressBridge_1.remultMiddlewareBase(app, options);
|
|
9
|
+
}
|
|
10
|
+
exports.remultMiddleware = remultMiddleware;
|
|
11
|
+
var middleware = /** @class */ (function () {
|
|
12
|
+
function middleware() {
|
|
13
|
+
this.map = new Map();
|
|
14
|
+
}
|
|
15
|
+
middleware.prototype.route = function (path) {
|
|
16
|
+
//consider using:
|
|
17
|
+
//* https://raw.githubusercontent.com/cmorten/opine/main/src/utils/pathToRegex.ts
|
|
18
|
+
//* https://github.com/pillarjs/path-to-regexp
|
|
19
|
+
var r = path.toLowerCase();
|
|
20
|
+
var m = new Map();
|
|
21
|
+
this.map.set(r, m);
|
|
22
|
+
var route = {
|
|
23
|
+
get: function (h) {
|
|
24
|
+
m.set("get", h);
|
|
25
|
+
return route;
|
|
26
|
+
},
|
|
27
|
+
put: function (h) {
|
|
28
|
+
m.set("put", h);
|
|
29
|
+
return route;
|
|
30
|
+
},
|
|
31
|
+
post: function (h) {
|
|
32
|
+
m.set("post", h);
|
|
33
|
+
return route;
|
|
34
|
+
},
|
|
35
|
+
delete: function (h) {
|
|
36
|
+
m.set("delete", h);
|
|
37
|
+
return route;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return route;
|
|
41
|
+
};
|
|
42
|
+
middleware.prototype.handleRequest = function (req, res, next) {
|
|
43
|
+
var lowerPath = req.path.toLowerCase();
|
|
44
|
+
var m = this.map.get(lowerPath);
|
|
45
|
+
if (m) {
|
|
46
|
+
var h = m.get(req.method.toLowerCase());
|
|
47
|
+
if (h) {
|
|
48
|
+
h(req, res, next);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var idPosition = req.path.lastIndexOf('/');
|
|
53
|
+
if (idPosition >= 0) {
|
|
54
|
+
lowerPath = req.path.substring(0, idPosition) + '/:id';
|
|
55
|
+
m = this.map.get(lowerPath);
|
|
56
|
+
if (m) {
|
|
57
|
+
var h = m.get(req.method.toLowerCase());
|
|
58
|
+
if (h) {
|
|
59
|
+
req.params.id = req.path.substring(idPosition + 1);
|
|
60
|
+
h(req, res, next);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
console.log(req.path);
|
|
66
|
+
next();
|
|
67
|
+
};
|
|
68
|
+
return middleware;
|
|
69
|
+
}());
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { DataProvider, Remult, IdEntity } from '../';
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { Repository } from '../src/remult3';
|
|
1
|
+
import { DataProvider, Remult, IdEntity, Repository } from '../';
|
|
4
2
|
import { queuedJobInfoResponse } from '../src/server-action';
|
|
5
3
|
import { DataApi, DataApiRequest, DataApiResponse } from '../src/data-api';
|
|
6
4
|
import { AllowedForInstance } from '../src/context';
|
|
7
5
|
import { ClassType } from '../classType';
|
|
8
|
-
export declare
|
|
6
|
+
export declare type RemultMiddlewareOptions = {
|
|
9
7
|
/** Sets a database connection for Remult.
|
|
10
8
|
*
|
|
11
9
|
* @see [Connecting to a Database](https://remult.dev/docs/databases.html).
|
|
12
10
|
*/
|
|
13
11
|
dataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>);
|
|
14
|
-
bodySizeLimit?: string;
|
|
15
12
|
disableAutoApi?: boolean;
|
|
16
13
|
queueStorage?: QueueStorage;
|
|
17
|
-
initRequest?: (remult: Remult, origReq:
|
|
14
|
+
initRequest?: (remult: Remult, origReq: GenericRequest) => Promise<void>;
|
|
18
15
|
initApi?: (remult: Remult) => void | Promise<void>;
|
|
19
16
|
logApiEndPoints?: boolean;
|
|
20
17
|
defaultGetLimit?: number;
|
|
@@ -22,42 +19,70 @@ export declare function remultExpress(options?: {
|
|
|
22
19
|
controllers?: ClassType<any>[];
|
|
23
20
|
bodyParser?: boolean;
|
|
24
21
|
rootPath?: string;
|
|
25
|
-
}
|
|
26
|
-
export
|
|
27
|
-
|
|
22
|
+
};
|
|
23
|
+
export declare function remultMiddlewareBase(app: GenericRouter, options: RemultMiddlewareOptions): RemultExpressBridge;
|
|
24
|
+
export interface RemultExpressBridge extends GenericRequestHandler {
|
|
25
|
+
getRemult(req: GenericRequest): Promise<Remult>;
|
|
28
26
|
openApiDoc(options: {
|
|
29
27
|
title: string;
|
|
30
28
|
}): any;
|
|
31
29
|
addArea(rootUrl: string): any;
|
|
32
30
|
}
|
|
31
|
+
export interface GenericRequest {
|
|
32
|
+
method: any;
|
|
33
|
+
path: any;
|
|
34
|
+
originalUrl: any;
|
|
35
|
+
query: any;
|
|
36
|
+
body: any;
|
|
37
|
+
params: any;
|
|
38
|
+
}
|
|
39
|
+
export interface GenericResponse {
|
|
40
|
+
status(arg0: number): any;
|
|
41
|
+
statusCode: number;
|
|
42
|
+
json(data: any): any;
|
|
43
|
+
writeHead(status: number): {
|
|
44
|
+
end: VoidFunction;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export declare type GenericRouter = GenericRequestHandler & {
|
|
48
|
+
route(path: string): SpecificRoute;
|
|
49
|
+
};
|
|
50
|
+
export declare type SpecificRoute = {
|
|
51
|
+
get(handler: GenericRequestHandler): SpecificRoute;
|
|
52
|
+
put(handler: GenericRequestHandler): SpecificRoute;
|
|
53
|
+
post(handler: GenericRequestHandler): SpecificRoute;
|
|
54
|
+
delete(handler: GenericRequestHandler): SpecificRoute;
|
|
55
|
+
};
|
|
56
|
+
export declare type GenericRequestHandler = (req: GenericRequest, res: GenericResponse, next: VoidFunction) => void;
|
|
33
57
|
declare class ExpressBridge {
|
|
34
58
|
private app;
|
|
35
59
|
queue: inProcessQueueHandler;
|
|
36
|
-
initRequest: (remult: Remult, origReq:
|
|
60
|
+
initRequest: (remult: Remult, origReq: GenericRequest) => Promise<void>;
|
|
37
61
|
dataProvider: DataProvider | Promise<DataProvider>;
|
|
38
62
|
openApiDoc(options: {
|
|
39
63
|
title: string;
|
|
64
|
+
version?: string;
|
|
40
65
|
}): any;
|
|
41
66
|
backendMethodsOpenApi: {
|
|
42
67
|
path: string;
|
|
43
68
|
allowed: AllowedForInstance<any>;
|
|
44
69
|
tag: string;
|
|
45
70
|
}[];
|
|
46
|
-
constructor(app:
|
|
71
|
+
constructor(app: GenericRouter, queue: inProcessQueueHandler, initRequest: (remult: Remult, origReq: GenericRequest) => Promise<void>, dataProvider: DataProvider | Promise<DataProvider>);
|
|
47
72
|
logApiEndPoints: boolean;
|
|
48
73
|
private firstArea;
|
|
49
74
|
addArea(rootUrl: string): SiteArea;
|
|
50
|
-
getRemult(req?:
|
|
75
|
+
getRemult(req?: GenericRequest): Promise<Remult>;
|
|
51
76
|
}
|
|
52
77
|
export declare class SiteArea {
|
|
53
78
|
private bridge;
|
|
54
79
|
private app;
|
|
55
80
|
private rootUrl;
|
|
56
81
|
private logApiEndpoints;
|
|
57
|
-
constructor(bridge: ExpressBridge, app:
|
|
82
|
+
constructor(bridge: ExpressBridge, app: GenericRouter, rootUrl: string, logApiEndpoints: boolean);
|
|
58
83
|
add(key: string, dataApiFactory: ((req: Remult) => DataApi)): void;
|
|
59
|
-
process(what: (remult: Remult, myReq: DataApiRequest, myRes: DataApiResponse, origReq:
|
|
60
|
-
getRemult(req:
|
|
84
|
+
process(what: (remult: Remult, myReq: DataApiRequest, myRes: DataApiResponse, origReq: GenericRequest) => Promise<void>): (req: GenericRequest, res: GenericResponse) => Promise<void>;
|
|
85
|
+
getRemult(req: GenericRequest): Promise<Remult>;
|
|
61
86
|
initQueue(): void;
|
|
62
87
|
addAction(action: {
|
|
63
88
|
__register: (reg: (url: string, queue: boolean, allowed: AllowedForInstance<any>, what: ((data: any, req: Remult, res: DataApiResponse) => void)) => void) => void;
|
|
@@ -66,7 +91,7 @@ export declare class SiteArea {
|
|
|
66
91
|
export declare class ExpressRequestBridgeToDataApiRequest implements DataApiRequest {
|
|
67
92
|
private r;
|
|
68
93
|
get(key: string): any;
|
|
69
|
-
constructor(r:
|
|
94
|
+
constructor(r: GenericRequest);
|
|
70
95
|
}
|
|
71
96
|
declare class inProcessQueueHandler {
|
|
72
97
|
private storage;
|
package/server/expressBridge.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JobsInQueueEntity = exports.EntityQueueStorage = exports.ExpressRequestBridgeToDataApiRequest = exports.SiteArea = exports.
|
|
3
|
+
exports.JobsInQueueEntity = exports.EntityQueueStorage = exports.ExpressRequestBridgeToDataApiRequest = exports.SiteArea = exports.remultMiddlewareBase = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var __1 = require("../");
|
|
6
|
-
var express = require("express");
|
|
7
6
|
var register_actions_on_server_1 = require("./register-actions-on-server");
|
|
8
7
|
var register_entities_on_server_1 = require("./register-entities-on-server");
|
|
9
8
|
var JsonEntityFileStorage_1 = require("./JsonEntityFileStorage");
|
|
10
|
-
var json_data_provider_1 = require("../src/data-providers/json-data-provider");
|
|
11
|
-
var remult3_1 = require("../src/remult3");
|
|
12
9
|
var server_action_1 = require("../src/server-action");
|
|
13
10
|
var data_api_1 = require("../src/data-api");
|
|
14
11
|
var context_1 = require("../src/context");
|
|
15
|
-
|
|
12
|
+
var remult3_1 = require("../src/remult3");
|
|
13
|
+
function remultMiddlewareBase(app, options) {
|
|
16
14
|
var _this = this;
|
|
17
|
-
var app = express.Router();
|
|
18
15
|
if (!options) {
|
|
19
16
|
options = {};
|
|
20
17
|
}
|
|
@@ -22,16 +19,9 @@ function remultExpress(options) {
|
|
|
22
19
|
if (options.defaultGetLimit) {
|
|
23
20
|
data_api_1.DataApi.defaultGetLimit = options.defaultGetLimit;
|
|
24
21
|
}
|
|
25
|
-
if (options.bodySizeLimit === undefined) {
|
|
26
|
-
options.bodySizeLimit = '10mb';
|
|
27
|
-
}
|
|
28
22
|
if (!options.queueStorage) {
|
|
29
23
|
options.queueStorage = new InMemoryQueueStorage();
|
|
30
24
|
}
|
|
31
|
-
if ((options === null || options === void 0 ? void 0 : options.bodyParser) !== false) {
|
|
32
|
-
app.use(express.json({ limit: options.bodySizeLimit }));
|
|
33
|
-
app.use(express.urlencoded({ extended: true, limit: options.bodySizeLimit }));
|
|
34
|
-
}
|
|
35
25
|
var dataProvider;
|
|
36
26
|
if (typeof options.dataProvider === "function") {
|
|
37
27
|
dataProvider = options.dataProvider();
|
|
@@ -41,7 +31,7 @@ function remultExpress(options) {
|
|
|
41
31
|
dataProvider = dataProvider.then(function (dp) {
|
|
42
32
|
if (dp)
|
|
43
33
|
return dp;
|
|
44
|
-
return new
|
|
34
|
+
return new __1.JsonDataProvider(new JsonEntityFileStorage_1.JsonEntityFileStorage('./db'));
|
|
45
35
|
});
|
|
46
36
|
if (options.initApi) {
|
|
47
37
|
dataProvider = dataProvider.then(function (dp) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -79,7 +69,7 @@ function remultExpress(options) {
|
|
|
79
69
|
addArea: function (x) { return bridge.addArea(x); }
|
|
80
70
|
});
|
|
81
71
|
}
|
|
82
|
-
exports.
|
|
72
|
+
exports.remultMiddlewareBase = remultMiddlewareBase;
|
|
83
73
|
var ExpressBridge = /** @class */ (function () {
|
|
84
74
|
function ExpressBridge(app, queue, initRequest, dataProvider) {
|
|
85
75
|
this.app = app;
|
|
@@ -93,11 +83,14 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
93
83
|
ExpressBridge.prototype.openApiDoc = function (options) {
|
|
94
84
|
var e_1, _a, e_2, _b;
|
|
95
85
|
var r = new __1.Remult();
|
|
86
|
+
if (!options.version)
|
|
87
|
+
options.version = "1.0.0";
|
|
96
88
|
var spec = {
|
|
97
|
-
info: { title: options.title },
|
|
89
|
+
info: { title: options.title, version: options.version },
|
|
98
90
|
openapi: "3.0.0",
|
|
99
91
|
//swagger: "2.0",
|
|
100
92
|
"components": {
|
|
93
|
+
"schemas": {},
|
|
101
94
|
"securitySchemes": {
|
|
102
95
|
"bearerAuth": {
|
|
103
96
|
"scheme": "bearer",
|
|
@@ -106,8 +99,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
106
99
|
}
|
|
107
100
|
}
|
|
108
101
|
},
|
|
109
|
-
paths: {}
|
|
110
|
-
definitions: {}
|
|
102
|
+
paths: {}
|
|
111
103
|
};
|
|
112
104
|
var validationError = {
|
|
113
105
|
"400": {
|
|
@@ -115,7 +107,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
115
107
|
"content": {
|
|
116
108
|
"application/json": {
|
|
117
109
|
"schema": {
|
|
118
|
-
"$ref": "#/
|
|
110
|
+
"$ref": "#/components/schemas/InvalidResponse"
|
|
119
111
|
}
|
|
120
112
|
}
|
|
121
113
|
}
|
|
@@ -182,12 +174,12 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
182
174
|
}
|
|
183
175
|
finally { if (e_3) throw e_3.error; }
|
|
184
176
|
}
|
|
185
|
-
spec.
|
|
177
|
+
spec.components.schemas[key] = {
|
|
186
178
|
type: "object",
|
|
187
179
|
properties: properties
|
|
188
180
|
};
|
|
189
181
|
var definition = {
|
|
190
|
-
"$ref": "#/
|
|
182
|
+
"$ref": "#/components/schemas/" + key
|
|
191
183
|
};
|
|
192
184
|
var secure = function (condition, def, item) {
|
|
193
185
|
item.tags = [meta.key];
|
|
@@ -206,28 +198,28 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
206
198
|
"description": "limit the number of returned rows, default 100",
|
|
207
199
|
"required": false,
|
|
208
200
|
"style": "simple",
|
|
209
|
-
"type": "
|
|
201
|
+
"schema": { "type": "integer" }
|
|
210
202
|
},
|
|
211
203
|
{
|
|
212
204
|
"name": "_page",
|
|
213
205
|
"in": "query",
|
|
214
206
|
"description": "to be used for paging",
|
|
215
207
|
"required": false,
|
|
216
|
-
"type": "
|
|
208
|
+
"schema": { "type": "integer" }
|
|
217
209
|
},
|
|
218
210
|
{
|
|
219
211
|
"name": "_sort",
|
|
220
212
|
"in": "query",
|
|
221
213
|
"description": "the columns to sort on",
|
|
222
214
|
"required": false,
|
|
223
|
-
"type": "string"
|
|
215
|
+
"schema": { "type": "string" }
|
|
224
216
|
},
|
|
225
217
|
{
|
|
226
218
|
"name": "_order",
|
|
227
219
|
"in": "query",
|
|
228
220
|
"description": "the sort order to user for the columns in `_sort`",
|
|
229
221
|
"required": false,
|
|
230
|
-
"type": "string"
|
|
222
|
+
"schema": { "type": "string" }
|
|
231
223
|
}], parameters),
|
|
232
224
|
responses: {
|
|
233
225
|
"200": {
|
|
@@ -248,14 +240,14 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
248
240
|
"in": "path",
|
|
249
241
|
"description": "id of " + key,
|
|
250
242
|
"required": true,
|
|
251
|
-
"type": "string"
|
|
243
|
+
"schema": { "type": "string" },
|
|
252
244
|
};
|
|
253
245
|
var itemInBody = {
|
|
254
246
|
"requestBody": {
|
|
255
247
|
"content": {
|
|
256
248
|
"application/json": {
|
|
257
249
|
"schema": {
|
|
258
|
-
"$ref": "#/
|
|
250
|
+
"$ref": "#/components/schemas/" + key
|
|
259
251
|
}
|
|
260
252
|
}
|
|
261
253
|
}
|
|
@@ -269,7 +261,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
269
261
|
"content": {
|
|
270
262
|
"application/json": {
|
|
271
263
|
"schema": {
|
|
272
|
-
"$ref": "#/
|
|
264
|
+
"$ref": "#/components/schemas/" + key
|
|
273
265
|
}
|
|
274
266
|
}
|
|
275
267
|
}
|
|
@@ -282,7 +274,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
282
274
|
"content": {
|
|
283
275
|
"application/json": {
|
|
284
276
|
"schema": {
|
|
285
|
-
"$ref": "#/
|
|
277
|
+
"$ref": "#/components/schemas/" + key
|
|
286
278
|
}
|
|
287
279
|
}
|
|
288
280
|
}
|
|
@@ -299,7 +291,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
299
291
|
"content": {
|
|
300
292
|
"application/json": {
|
|
301
293
|
"schema": {
|
|
302
|
-
"$ref": "#/
|
|
294
|
+
"$ref": "#/components/schemas/" + key
|
|
303
295
|
}
|
|
304
296
|
}
|
|
305
297
|
}
|
|
@@ -378,7 +370,7 @@ var ExpressBridge = /** @class */ (function () {
|
|
|
378
370
|
}
|
|
379
371
|
finally { if (e_2) throw e_2.error; }
|
|
380
372
|
}
|
|
381
|
-
spec.
|
|
373
|
+
spec.components.schemas["InvalidResponse"] = {
|
|
382
374
|
"type": "object",
|
|
383
375
|
properties: {
|
|
384
376
|
"message": {
|
|
@@ -819,39 +811,39 @@ var JobsInQueueEntity = /** @class */ (function (_super) {
|
|
|
819
811
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
820
812
|
}
|
|
821
813
|
tslib_1.__decorate([
|
|
822
|
-
|
|
814
|
+
__1.Fields.string(),
|
|
823
815
|
tslib_1.__metadata("design:type", String)
|
|
824
816
|
], JobsInQueueEntity.prototype, "userId", void 0);
|
|
825
817
|
tslib_1.__decorate([
|
|
826
|
-
|
|
818
|
+
__1.Fields.string(),
|
|
827
819
|
tslib_1.__metadata("design:type", String)
|
|
828
820
|
], JobsInQueueEntity.prototype, "url", void 0);
|
|
829
821
|
tslib_1.__decorate([
|
|
830
|
-
|
|
822
|
+
__1.Fields.date(),
|
|
831
823
|
tslib_1.__metadata("design:type", Date)
|
|
832
824
|
], JobsInQueueEntity.prototype, "submitTime", void 0);
|
|
833
825
|
tslib_1.__decorate([
|
|
834
|
-
|
|
826
|
+
__1.Fields.date(),
|
|
835
827
|
tslib_1.__metadata("design:type", Date)
|
|
836
828
|
], JobsInQueueEntity.prototype, "doneTime", void 0);
|
|
837
829
|
tslib_1.__decorate([
|
|
838
|
-
|
|
830
|
+
__1.Fields.string(),
|
|
839
831
|
tslib_1.__metadata("design:type", String)
|
|
840
832
|
], JobsInQueueEntity.prototype, "result", void 0);
|
|
841
833
|
tslib_1.__decorate([
|
|
842
|
-
|
|
834
|
+
__1.Fields.boolean(),
|
|
843
835
|
tslib_1.__metadata("design:type", Boolean)
|
|
844
836
|
], JobsInQueueEntity.prototype, "done", void 0);
|
|
845
837
|
tslib_1.__decorate([
|
|
846
|
-
|
|
838
|
+
__1.Fields.boolean(),
|
|
847
839
|
tslib_1.__metadata("design:type", Boolean)
|
|
848
840
|
], JobsInQueueEntity.prototype, "error", void 0);
|
|
849
841
|
tslib_1.__decorate([
|
|
850
|
-
|
|
842
|
+
__1.Fields.number(),
|
|
851
843
|
tslib_1.__metadata("design:type", Number)
|
|
852
844
|
], JobsInQueueEntity.prototype, "progress", void 0);
|
|
853
845
|
JobsInQueueEntity = tslib_1.__decorate([
|
|
854
|
-
|
|
846
|
+
__1.Entity(undefined, {
|
|
855
847
|
dbName: 'jobsInQueue'
|
|
856
848
|
})
|
|
857
849
|
], JobsInQueueEntity);
|
|
@@ -14,18 +14,18 @@ export interface FieldOptions<entityType = any, valueType = any> {
|
|
|
14
14
|
allowApiUpdate?: AllowedForInstance<entityType>;
|
|
15
15
|
/** An arrow function that'll be used to perform validations on it
|
|
16
16
|
* @example
|
|
17
|
-
*
|
|
17
|
+
* @Fields.string({
|
|
18
18
|
* validate: Validators.required
|
|
19
19
|
* })
|
|
20
20
|
* @example
|
|
21
|
-
*
|
|
21
|
+
* @Fields.string<Task>({
|
|
22
22
|
* validate: task=>{
|
|
23
23
|
* if (task.title.length<3)
|
|
24
24
|
* throw "Too Short";
|
|
25
25
|
* }
|
|
26
26
|
* })
|
|
27
27
|
* @example
|
|
28
|
-
*
|
|
28
|
+
* @Fields.string({
|
|
29
29
|
* validate: (_, fieldRef)=>{
|
|
30
30
|
* if (fieldRef.value.length<3)
|
|
31
31
|
* fieldRef.error = "Too Short";
|
package/src/entity.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface EntityOptions<entityType = any> {
|
|
|
29
29
|
apiPrefilter?: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>);
|
|
30
30
|
/** A filter that will be used for all queries from this entity both from the API and from within the backend.
|
|
31
31
|
* @example
|
|
32
|
-
*
|
|
32
|
+
* backendPrefilter: { archive:false }
|
|
33
33
|
* @see [EntityFilter](http://remult.dev/docs/entityFilter.html)
|
|
34
34
|
*/
|
|
35
35
|
backendPrefilter?: EntityFilter<entityType> | (() => EntityFilter<entityType> | Promise<EntityFilter<entityType>>);
|
|
@@ -45,7 +45,7 @@ export interface EntityOptions<entityType = any> {
|
|
|
45
45
|
* If the `error` property of the entity's ref or any of it's fields will be set, the save will be aborted and an exception will be thrown.
|
|
46
46
|
* this is the place to run logic that we want to run in any case before an entity is saved.
|
|
47
47
|
* @example
|
|
48
|
-
*
|
|
48
|
+
* @Entity<Task>("tasks", {
|
|
49
49
|
* saving: async task => {
|
|
50
50
|
* task.lastUpdated = new Date()
|
|
51
51
|
* }
|
|
@@ -256,11 +256,11 @@ export declare function getValueList<T>(type: ClassType<T>): T[];
|
|
|
256
256
|
* FieldOptions can be set in two ways:
|
|
257
257
|
* @example
|
|
258
258
|
* // as an object
|
|
259
|
-
*
|
|
259
|
+
* @Fields.string({ includeInApi:false })
|
|
260
260
|
* title='';
|
|
261
261
|
* @example
|
|
262
262
|
* // as an arrow function that receives `remult` as a parameter
|
|
263
|
-
*
|
|
263
|
+
* @Fields.string((options,remult) => options.includeInApi = true)
|
|
264
264
|
* title='';
|
|
265
265
|
*/
|
|
266
266
|
export declare function Field<entityType = any, valueType = any>(valueType: () => ClassType<valueType>, ...options: (FieldOptions<entityType, valueType> | ((options: FieldOptions<entityType, valueType>, remult: Remult) => void))[]): (target: any, key: any, c?: any) => void;
|
|
@@ -289,13 +289,14 @@ export declare function BuildEntity<entityType>(c: ClassType<entityType>, key: s
|
|
|
289
289
|
* @Fields.boolean()
|
|
290
290
|
* completed = false;
|
|
291
291
|
* }
|
|
292
|
-
*
|
|
292
|
+
* @note
|
|
293
|
+
* EntityOptions can be set in two ways:
|
|
293
294
|
* @example
|
|
294
295
|
* // as an object
|
|
295
|
-
*
|
|
296
|
+
* @Entity("tasks",{ allowApiCrud:true })
|
|
296
297
|
* @example
|
|
297
298
|
* // as an arrow function that receives `remult` as a parameter
|
|
298
|
-
*
|
|
299
|
+
* @Entity("tasks", (options,remult) => options.allowApiCrud = true)
|
|
299
300
|
*/
|
|
300
301
|
export declare function Entity<entityType>(key: string, ...options: (EntityOptions<entityType> | ((options: EntityOptions<entityType>, remult: Remult) => void))[]): (target: any) => any;
|
|
301
302
|
export declare class EntityBase {
|
|
@@ -2467,11 +2467,11 @@ exports.getValueList = getValueList;
|
|
|
2467
2467
|
* FieldOptions can be set in two ways:
|
|
2468
2468
|
* @example
|
|
2469
2469
|
* // as an object
|
|
2470
|
-
*
|
|
2470
|
+
* @Fields.string({ includeInApi:false })
|
|
2471
2471
|
* title='';
|
|
2472
2472
|
* @example
|
|
2473
2473
|
* // as an arrow function that receives `remult` as a parameter
|
|
2474
|
-
*
|
|
2474
|
+
* @Fields.string((options,remult) => options.includeInApi = true)
|
|
2475
2475
|
* title='';
|
|
2476
2476
|
*/
|
|
2477
2477
|
function Field(valueType) {
|
|
@@ -2637,13 +2637,14 @@ exports.BuildEntity = BuildEntity;
|
|
|
2637
2637
|
* @Fields.boolean()
|
|
2638
2638
|
* completed = false;
|
|
2639
2639
|
* }
|
|
2640
|
-
*
|
|
2640
|
+
* @note
|
|
2641
|
+
* EntityOptions can be set in two ways:
|
|
2641
2642
|
* @example
|
|
2642
2643
|
* // as an object
|
|
2643
|
-
*
|
|
2644
|
+
* @Entity("tasks",{ allowApiCrud:true })
|
|
2644
2645
|
* @example
|
|
2645
2646
|
* // as an arrow function that receives `remult` as a parameter
|
|
2646
|
-
*
|
|
2647
|
+
* @Entity("tasks", (options,remult) => options.allowApiCrud = true)
|
|
2647
2648
|
*/
|
|
2648
2649
|
function Entity(key) {
|
|
2649
2650
|
var options = [];
|
package/src/remult3/remult3.d.ts
CHANGED
|
@@ -112,7 +112,12 @@ export declare type OmitEB<T> = Omit<T, keyof import('./RepositoryImplementation
|
|
|
112
112
|
export interface Repository<entityType> {
|
|
113
113
|
/** returns a result array based on the provided options */
|
|
114
114
|
find(options?: FindOptions<entityType>): Promise<entityType[]>;
|
|
115
|
-
/** returns the first item that matchers the `where` condition
|
|
115
|
+
/** returns the first item that matchers the `where` condition
|
|
116
|
+
* @example
|
|
117
|
+
* await taskRepo.findFirst({ completed:false })
|
|
118
|
+
* @example
|
|
119
|
+
* await taskRepo.findFirst({ completed:false },{ createIfNotFound: true })
|
|
120
|
+
* */
|
|
116
121
|
findFirst(where?: EntityFilter<entityType>, options?: FindFirstOptions<entityType>): Promise<entityType>;
|
|
117
122
|
/** returns the items that matches the idm the result is cached unless specified differently in the `options` parameter */
|
|
118
123
|
findId(id: entityType extends {
|
|
@@ -285,7 +290,7 @@ export interface QueryResult<entityType> {
|
|
|
285
290
|
[Symbol.asyncIterator](): {
|
|
286
291
|
next: () => Promise<IteratorResult<entityType, entityType>>;
|
|
287
292
|
};
|
|
288
|
-
/** returns the number of rows that match the query
|
|
293
|
+
/** returns the number of rows that match the query criteria */
|
|
289
294
|
count(): Promise<number>;
|
|
290
295
|
/** Returns a `Paginator` object that is used for efficient paging */
|
|
291
296
|
paginator(): Promise<Paginator<entityType>>;
|
|
@@ -300,7 +305,7 @@ export interface Paginator<entityType> {
|
|
|
300
305
|
items: entityType[];
|
|
301
306
|
/** True if next page exists */
|
|
302
307
|
hasNextPage: boolean;
|
|
303
|
-
/**
|
|
308
|
+
/** Gets the next page in the `query`'s result set */
|
|
304
309
|
nextPage(): Promise<Paginator<entityType>>;
|
|
305
310
|
/** the count of the total items in the `query`'s result */
|
|
306
311
|
count(): Promise<number>;
|