Comparing version 0.4.19 to 0.5.1
{ | ||
"name": "remult", | ||
"version": "0.4.19", | ||
"version": "0.5.1", | ||
"description": "remult core lib", | ||
@@ -5,0 +5,0 @@ "homepage": "https://remult.github.io/", |
import { SqlDatabase, SqlCommand, SqlImplementation, EntityMetadata, FieldMetadata } from '../'; | ||
import { QueryResult } from 'pg'; | ||
import { PoolConfig, QueryResult } from 'pg'; | ||
import { Remult } from '../src/context'; | ||
@@ -33,1 +33,6 @@ export interface PostgresPool extends PostgresCommandSource { | ||
export declare function preparePostgresQueueStorage(sql: SqlDatabase): Promise<import("../server/expressBridge").EntityQueueStorage>; | ||
export declare function createPostgresConnection(options: { | ||
connectionString?: string; | ||
sslInDev?: boolean; | ||
configuration?: "heroku" | PoolConfig; | ||
}): Promise<SqlDatabase>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preparePostgresQueueStorage = exports.PostgresSchemaBuilder = exports.verifyStructureOfAllEntities = exports.PostgresDataProvider = void 0; | ||
exports.createPostgresConnection = exports.preparePostgresQueueStorage = exports.PostgresSchemaBuilder = exports.verifyStructureOfAllEntities = exports.PostgresDataProvider = void 0; | ||
var tslib_1 = require("tslib"); | ||
var __1 = require("../"); | ||
var pg_1 = require("pg"); | ||
var context_1 = require("../src/context"); | ||
@@ -424,2 +426,32 @@ var sql_database_1 = require("../src/data-providers/sql-database"); | ||
exports.preparePostgresQueueStorage = preparePostgresQueueStorage; | ||
function createPostgresConnection(options) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var config, db, remult; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
config = {}; | ||
if (options.configuration == "heroku") { | ||
config = { | ||
connectionString: process.env.DATABASE_URL, | ||
ssl: process.env.NODE_ENV !== "production" && !options.sslInDev ? false : { | ||
rejectUnauthorized: false | ||
} | ||
}; | ||
} | ||
if (!config.connectionString && options.connectionString) { | ||
config.connectionString = options.connectionString; | ||
} | ||
db = new __1.SqlDatabase(new PostgresDataProvider(new pg_1.Pool(config))); | ||
remult = new context_1.Remult(); | ||
remult.setDataProvider(db); | ||
return [4 /*yield*/, verifyStructureOfAllEntities(db, remult)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/, db]; | ||
} | ||
}); | ||
}); | ||
} | ||
exports.createPostgresConnection = createPostgresConnection; | ||
//# sourceMappingURL=postgres-data-provider.js.map |
@@ -8,3 +8,3 @@ import { DataProvider, Remult, IdEntity } from '../'; | ||
export declare function initExpress(app: express.Express, options?: { | ||
dataProvider?: DataProvider; | ||
dataProvider?: DataProvider | Promise<DataProvider> | (() => Promise<DataProvider | undefined>); | ||
bodySizeLimit?: string; | ||
@@ -19,3 +19,3 @@ disableAutoApi?: boolean; | ||
initRequest: (remult: Remult, origReq: express.Request) => Promise<void>; | ||
dataProvider: DataProvider; | ||
dataProvider: DataProvider | Promise<DataProvider>; | ||
openApiDoc(options: { | ||
@@ -28,7 +28,7 @@ title: string; | ||
}[]; | ||
constructor(app: express.Express, queue: inProcessQueueHandler, initRequest: (remult: Remult, origReq: express.Request) => Promise<void>, dataProvider: DataProvider); | ||
constructor(app: express.Express, queue: inProcessQueueHandler, initRequest: (remult: Remult, origReq: express.Request) => Promise<void>, dataProvider: DataProvider | Promise<DataProvider>); | ||
logApiEndPoints: boolean; | ||
private firstArea; | ||
addArea(rootUrl: string): SiteArea; | ||
getValidContext(req: express.Request): Promise<Remult>; | ||
getRemult(req?: express.Request): Promise<Remult>; | ||
} | ||
@@ -43,3 +43,3 @@ export declare class SiteArea { | ||
process(what: (remult: Remult, myReq: DataApiRequest, myRes: DataApiResponse, origReq: express.Request) => Promise<void>): (req: express.Request, res: express.Response) => Promise<void>; | ||
getValidContext(req: express.Request): Promise<Remult>; | ||
getRemult(req: express.Request): Promise<Remult>; | ||
initQueue(): void; | ||
@@ -46,0 +46,0 @@ addAction(action: { |
@@ -19,2 +19,3 @@ "use strict"; | ||
} | ||
server_action_1.actionInfo.runningOnServer = true; | ||
if (options.bodySizeLimit === undefined) { | ||
@@ -28,6 +29,14 @@ options.bodySizeLimit = '10mb'; | ||
app.use(bodyParser.urlencoded({ extended: true, limit: options.bodySizeLimit })); | ||
if (!options.dataProvider) { | ||
options.dataProvider = new json_data_provider_1.JsonDataProvider(new JsonEntityFileStorage_1.JsonEntityFileStorage('./db')); | ||
var dataProvider; | ||
if (typeof options.dataProvider === "function") { | ||
dataProvider = options.dataProvider(); | ||
} | ||
var result = new ExpressBridge(app, new inProcessQueueHandler(options.queueStorage), options.initRequest, options.dataProvider); | ||
else | ||
dataProvider = Promise.resolve(options.dataProvider); | ||
dataProvider = dataProvider.then(function (dp) { | ||
if (dp) | ||
return dp; | ||
return new json_data_provider_1.JsonDataProvider(new JsonEntityFileStorage_1.JsonEntityFileStorage('./db')); | ||
}); | ||
var result = new ExpressBridge(app, new inProcessQueueHandler(options.queueStorage), options.initRequest, dataProvider); | ||
var apiArea = result.addArea('/' + __1.Remult.apiBaseUrl); | ||
@@ -142,3 +151,3 @@ if (!options.disableAutoApi) { | ||
apiPath.get = secure(meta.options.allowApiRead, true, { | ||
description: "return an array of " + key + ". supports filter operators", | ||
description: "return an array of " + key + ". supports filter operators. For more info on filtering [see this article](https://remult.dev/blog/rest-api.html#filter)", | ||
parameters: [{ | ||
@@ -343,6 +352,6 @@ "name": "_limit", | ||
}; | ||
ExpressBridge.prototype.getValidContext = function (req) { | ||
ExpressBridge.prototype.getRemult = function (req) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.firstArea.getValidContext(req)]; | ||
return [2 /*return*/, this.firstArea.getRemult(req)]; | ||
}); | ||
@@ -395,5 +404,5 @@ }); | ||
return function (req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var myReq, myRes, remult, user; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
var myReq, myRes, remult, _a, _b, user; | ||
return tslib_1.__generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
@@ -403,12 +412,17 @@ myReq = new ExpressRequestBridgeToDataApiRequest(req); | ||
remult = new __1.Remult(); | ||
remult.setDataProvider(this.bridge.dataProvider); | ||
user = req['user']; | ||
if (user) | ||
remult.setUser(user); | ||
if (!this.bridge.initRequest) return [3 /*break*/, 2]; | ||
_b = (_a = remult).setDataProvider; | ||
return [4 /*yield*/, this.bridge.dataProvider]; | ||
case 1: | ||
_b.apply(_a, [_c.sent()]); | ||
if (req) { | ||
user = req['user']; | ||
if (user) | ||
remult.setUser(user); | ||
} | ||
if (!this.bridge.initRequest) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, this.bridge.initRequest(remult, req)]; | ||
case 1: | ||
_a.sent(); | ||
_a.label = 2; | ||
case 2: | ||
_c.sent(); | ||
_c.label = 3; | ||
case 3: | ||
what(remult, myReq, myRes, req); | ||
@@ -421,3 +435,3 @@ return [2 /*return*/]; | ||
; | ||
SiteArea.prototype.getValidContext = function (req) { | ||
SiteArea.prototype.getRemult = function (req) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -453,3 +467,3 @@ var remult; | ||
userId = undefined; | ||
if (req.user) | ||
if (req === null || req === void 0 ? void 0 : req.user) | ||
userId = req.user.id; | ||
@@ -456,0 +470,0 @@ if (job.userId == '') |
@@ -22,7 +22,7 @@ import { DataProvider } from "./data-interfaces"; | ||
export declare function processHttpException(ex: any): Promise<any>; | ||
export declare function isBackend(): any; | ||
export declare function isBackend(): boolean; | ||
export declare class Remult { | ||
clearAllCache(): any; | ||
authenticated(): boolean; | ||
constructor(http?: HttpProvider); | ||
constructor(provider?: HttpProvider | DataProvider); | ||
_dataSource: DataProvider; | ||
@@ -29,0 +29,0 @@ setDataProvider(dataProvider: DataProvider): void; |
@@ -136,15 +136,20 @@ "use strict"; | ||
var Remult = /** @class */ (function () { | ||
function Remult(http) { | ||
function Remult(provider) { | ||
this._userChangeEvent = new EventSource(); | ||
this.repCache = new Map(); | ||
var provider; | ||
if (provider && provider.getEntityDataProvider) { | ||
this._dataSource = provider; | ||
return; | ||
} | ||
var http = provider; | ||
var dataProvider; | ||
if (http) { | ||
provider = new HttpProviderBridgeToRestDataProviderHttpProvider(http); | ||
dataProvider = new HttpProviderBridgeToRestDataProviderHttpProvider(http); | ||
} | ||
if (!provider) { | ||
provider = new rest_data_provider_1.RestDataProviderHttpProviderUsingFetch(); | ||
if (!dataProvider) { | ||
dataProvider = new rest_data_provider_1.RestDataProviderHttpProviderUsingFetch(); | ||
} | ||
this._dataSource = new rest_data_provider_1.RestDataProvider(Remult.apiBaseUrl, provider); | ||
this._dataSource = new rest_data_provider_1.RestDataProvider(Remult.apiBaseUrl, dataProvider); | ||
if (!server_action_1.Action.provider) | ||
server_action_1.Action.provider = provider; | ||
server_action_1.Action.provider = dataProvider; | ||
} | ||
@@ -151,0 +156,0 @@ Remult.prototype.clearAllCache = function () { |
@@ -10,4 +10,4 @@ import { FieldMetadata } from "../column-interfaces"; | ||
or(filter: Filter): Filter; | ||
static createCustom<T>(customFilterTranslator: customFilterTranslator<T, any>): (() => Filter) & customFilterInfo<T>; | ||
static createCustom<T, Y>(customFilterTranslator: customFilterTranslator<T, Y>): ((y: Y) => Filter) & customFilterInfo<T>; | ||
static createCustom<entityType>(customFilterTranslator: (e: FilterFactories<entityType>, r: Remult) => (Filter | Filter[] | Promise<Filter> | Promise<Filter[]>)): (() => Filter) & customFilterInfo<entityType>; | ||
static createCustom<entityType, argsType>(customFilterTranslator: (e: FilterFactories<entityType>, r: Remult, args: argsType) => (Filter | Filter[] | Promise<Filter> | Promise<Filter[]>)): ((y: argsType) => Filter) & customFilterInfo<entityType>; | ||
static createFilterFactories<T>(entityDefs: EntityMetadata<T>): FilterFactories<T>; | ||
@@ -87,5 +87,4 @@ static fromEntityFilter<T>(entity: FilterFactories<T>, ...where: EntityFilter<T>[]): Promise<Filter>; | ||
key: string; | ||
customFilterTranslator: customFilterTranslator<entityType>; | ||
customFilterTranslator: (e: FilterFactories<entityType>, r: Remult, args: any) => (Filter | Filter[] | Promise<Filter> | Promise<Filter[]>); | ||
}; | ||
} | ||
export declare type customFilterTranslator<entityType, argsType = any> = (e: FilterFactories<entityType>, r: Remult, args: argsType) => (Filter | Filter[] | Promise<Filter> | Promise<Filter[]>); |
@@ -23,2 +23,3 @@ import { ClassType } from "../../classType"; | ||
toApiJson(): any; | ||
validate(): Promise<boolean>; | ||
} | ||
@@ -55,2 +56,3 @@ export declare type Fields<entityType> = { | ||
originalValueIsNull(): boolean; | ||
validate(): Promise<boolean>; | ||
} | ||
@@ -77,3 +79,3 @@ export interface IdMetadata<entityType = any> { | ||
/** returns a result array based on the provided options */ | ||
find(options?: FindOptions<entityType>): Promise<entityType[]>; | ||
find(whereOrOptions?: EntityFilter<entityType> | FindOptions<entityType>): Promise<entityType[]>; | ||
iterate(whereOrOptions?: EntityFilter<entityType> | IterateOptions<entityType>): IterableResult<entityType>; | ||
@@ -168,2 +170,3 @@ findFirst(whereOrOptions?: EntityFilter<entityType> | FindFirstOptions<entityType>): Promise<entityType>; | ||
export interface IterateOptions<entityType> extends FindOptionsBase<entityType> { | ||
pageSize?: number; | ||
progress?: { | ||
@@ -179,4 +182,4 @@ progress: (progress: number) => void; | ||
[Symbol.asyncIterator](): { | ||
next: () => Promise<IteratorResult<entityType>>; | ||
next: () => Promise<IteratorResult<entityType, entityType>>; | ||
}; | ||
} |
@@ -29,3 +29,3 @@ import { FieldMetadata, FieldOptions, ValueListItem } from "../column-interfaces"; | ||
save(entity: entityType): Promise<entityType>; | ||
find(options?: FindOptions<entityType>): Promise<entityType[]>; | ||
find(whereOrOptions?: EntityFilter<entityType> | FindOptions<entityType>): Promise<entityType[]>; | ||
private mapRawDataToResult; | ||
@@ -67,2 +67,3 @@ count(where?: EntityFilter<entityType>): Promise<number>; | ||
saveOriginalData(): void; | ||
validate(): Promise<boolean>; | ||
__validateEntity(): Promise<void>; | ||
@@ -131,2 +132,3 @@ __performColumnAndEntityValidations(): Promise<void>; | ||
__performValidation(): Promise<void>; | ||
validate(): Promise<boolean>; | ||
} | ||
@@ -133,0 +135,0 @@ export declare function getEntityRef<entityType>(entity: entityType, throwException?: boolean): EntityRef<entityType>; |
@@ -36,3 +36,3 @@ import 'reflect-metadata'; | ||
allActions: any[]; | ||
runningOnServer: any; | ||
runningOnServer: boolean; | ||
runActionWithoutBlockingUI: (what: () => Promise<any>) => Promise<any>; | ||
@@ -39,0 +39,0 @@ startBusyWithProgress: () => { |
@@ -151,6 +151,5 @@ "use strict"; | ||
exports.myServerAction = myServerAction; | ||
var isNode = new Function("try {return this===global;}catch(e){return false;}"); | ||
exports.actionInfo = { | ||
allActions: [], | ||
runningOnServer: isNode(), | ||
runningOnServer: false, | ||
runActionWithoutBlockingUI: function (what) { return what(); }, | ||
@@ -157,0 +156,0 @@ startBusyWithProgress: function () { return ({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
618559
9341
2
3