New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@remult/core

Package Overview
Dependencies
Maintainers
2
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remult/core - npm Package Compare versions

Comparing version 3.0.22 to 3.0.23

classType.d.ts

14

index.d.ts

@@ -1,7 +0,7 @@

export { ClassType, Field, FieldDefinitionsOf, Entity, EntityBase, EntityField, EntityFields, EntityDefinitions, EntityOrderBy, EntityWhere, FindOptions, InputTypes, IteratableResult, IterateOptions, Repository, FieldType, comparableFilterItem, controllerDefs, filterOf, filterOptions, getControllerDefs, getEntityOf, getEntitySettings, rowHelper, sortOf, supportsContains, ValueListFieldType, DateOnlyField, DecimalField, CaptionHelper } from './src/remult3';
export { EntitySettings } from './src/entity';
export { Field, FieldsMetadata, Entity, EntityBase, FieldRef, Fields, EntityMetadata, EntityOrderBy, EntityWhere, FindOptions, IterableResult, IterateOptions, Repository, FieldType, ComparisonFilterFactory, FilterFactories, FilterFactory, getFields, EntityRef, getEntityRef, SortSegments, ContainsFilterFactory, ValueListFieldType, DateOnlyField, DecimalField, CaptionTransformer } from './src/remult3';
export { EntityOptions } from './src/entity';
export { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo, RestDataProviderHttpProvider } from './src/data-interfaces';
export { SqlCommand, SqlImplementation, SqlResult } from './src/sql-command';
export { FieldDefinitions, FieldSettings, FieldValidator, ValueConverter, ValueListItem, // reconsider, maybe it should go to remult angular as the abstraction ?
ValueOrExpression, valueOrExpressionToValue } from './src/column-interfaces';
export { FieldMetadata, FieldOptions, FieldValidator, ValueConverter, ValueListItem, // reconsider, maybe it should go to remult angular as the abstraction ?
ValueOrExpression } from './src/column-interfaces';
export { RestDataProvider } from './src/data-providers/rest-data-provider';

@@ -13,4 +13,4 @@ export { InMemoryDataProvider } from './src/data-providers/in-memory-database';

export { JsonDataProvider, JsonEntityStorage } from './src/data-providers/json-data-provider';
export { ServerController, ServerFunction, ServerFunctionOptions, ServerMethod, ServerProgress, controllerAllowed } from './src/server-action';
export { Allowed, Context, ControllerOptions, DataProviderFactoryBuilder, EntityAllowed, EventDispatcher, EventSource, HttpProvider, IterateToArrayOptions, Role, RoleChecker, ServerContext, Unobserve, UserInfo, keyFor } from './src/context';
export { Controller, BackendMethodOptions, BackendMethod, ProgressListener } from './src/server-action';
export { Allowed, Context, DataProviderFactoryBuilder, AllowedForInstance, EventDispatcher, EventSource, HttpProvider, IterateToArrayOptions, Role, Unobserve, UserInfo } from './src/context';
export { IdEntity } from './src/id-entity';

@@ -21,3 +21,3 @@ export { SortSegment, Sort } from './src/sort';

export { FilterConsumerBridgeToSqlRequest } from './src/filter/filter-consumer-bridge-to-sql-request';
export { UrlBuilder } from './src/url-builder';
export { UrlBuilder } from './urlBuilder';
export { Validators } from './src/validators';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Validators = exports.UrlBuilder = exports.FilterConsumerBridgeToSqlRequest = exports.OrFilter = exports.AndFilter = exports.Filter = exports.OneToMany = exports.ManyToOne = exports.Sort = exports.IdEntity = exports.keyFor = exports.ServerContext = exports.Role = exports.EventSource = exports.Context = exports.controllerAllowed = exports.ServerProgress = exports.ServerMethod = exports.ServerFunction = exports.ServerController = exports.JsonDataProvider = exports.SqlDatabase = exports.WebSqlDataProvider = exports.ArrayEntityDataProvider = exports.InMemoryDataProvider = exports.RestDataProvider = exports.valueOrExpressionToValue = exports.CaptionHelper = exports.DecimalField = exports.DateOnlyField = exports.ValueListFieldType = exports.getEntitySettings = exports.getEntityOf = exports.getControllerDefs = exports.FieldType = exports.InputTypes = exports.EntityBase = exports.Entity = exports.Field = void 0;
exports.Validators = exports.UrlBuilder = exports.FilterConsumerBridgeToSqlRequest = exports.OrFilter = exports.AndFilter = exports.Filter = exports.OneToMany = exports.ManyToOne = exports.Sort = exports.IdEntity = exports.Role = exports.EventSource = exports.Context = exports.ProgressListener = exports.BackendMethod = exports.Controller = exports.JsonDataProvider = exports.SqlDatabase = exports.WebSqlDataProvider = exports.ArrayEntityDataProvider = exports.InMemoryDataProvider = exports.RestDataProvider = exports.CaptionTransformer = exports.DecimalField = exports.DateOnlyField = exports.ValueListFieldType = exports.getEntityRef = exports.getFields = exports.FieldType = exports.EntityBase = exports.Entity = exports.Field = void 0;
/*

@@ -11,13 +11,9 @@ * Public API Surface of @remult/core

Object.defineProperty(exports, "EntityBase", { enumerable: true, get: function () { return remult3_1.EntityBase; } });
Object.defineProperty(exports, "InputTypes", { enumerable: true, get: function () { return remult3_1.InputTypes; } });
Object.defineProperty(exports, "FieldType", { enumerable: true, get: function () { return remult3_1.FieldType; } });
Object.defineProperty(exports, "getControllerDefs", { enumerable: true, get: function () { return remult3_1.getControllerDefs; } });
Object.defineProperty(exports, "getEntityOf", { enumerable: true, get: function () { return remult3_1.getEntityOf; } });
Object.defineProperty(exports, "getEntitySettings", { enumerable: true, get: function () { return remult3_1.getEntitySettings; } });
Object.defineProperty(exports, "getFields", { enumerable: true, get: function () { return remult3_1.getFields; } });
Object.defineProperty(exports, "getEntityRef", { enumerable: true, get: function () { return remult3_1.getEntityRef; } });
Object.defineProperty(exports, "ValueListFieldType", { enumerable: true, get: function () { return remult3_1.ValueListFieldType; } });
Object.defineProperty(exports, "DateOnlyField", { enumerable: true, get: function () { return remult3_1.DateOnlyField; } });
Object.defineProperty(exports, "DecimalField", { enumerable: true, get: function () { return remult3_1.DecimalField; } });
Object.defineProperty(exports, "CaptionHelper", { enumerable: true, get: function () { return remult3_1.CaptionHelper; } });
var column_interfaces_1 = require("./src/column-interfaces"); // revisit input type
Object.defineProperty(exports, "valueOrExpressionToValue", { enumerable: true, get: function () { return column_interfaces_1.valueOrExpressionToValue; } });
Object.defineProperty(exports, "CaptionTransformer", { enumerable: true, get: function () { return remult3_1.CaptionTransformer; } });
var rest_data_provider_1 = require("./src/data-providers/rest-data-provider"); //V

@@ -37,7 +33,5 @@ Object.defineProperty(exports, "RestDataProvider", { enumerable: true, get: function () { return rest_data_provider_1.RestDataProvider; } });

var server_action_1 = require("./src/server-action");
Object.defineProperty(exports, "ServerController", { enumerable: true, get: function () { return server_action_1.ServerController; } });
Object.defineProperty(exports, "ServerFunction", { enumerable: true, get: function () { return server_action_1.ServerFunction; } });
Object.defineProperty(exports, "ServerMethod", { enumerable: true, get: function () { return server_action_1.ServerMethod; } });
Object.defineProperty(exports, "ServerProgress", { enumerable: true, get: function () { return server_action_1.ServerProgress; } });
Object.defineProperty(exports, "controllerAllowed", { enumerable: true, get: function () { return server_action_1.controllerAllowed; } });
Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return server_action_1.Controller; } });
Object.defineProperty(exports, "BackendMethod", { enumerable: true, get: function () { return server_action_1.BackendMethod; } });
Object.defineProperty(exports, "ProgressListener", { enumerable: true, get: function () { return server_action_1.ProgressListener; } });
var context_1 = require("./src/context");

@@ -47,4 +41,2 @@ Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.Context; } });

Object.defineProperty(exports, "Role", { enumerable: true, get: function () { return context_1.Role; } });
Object.defineProperty(exports, "ServerContext", { enumerable: true, get: function () { return context_1.ServerContext; } });
Object.defineProperty(exports, "keyFor", { enumerable: true, get: function () { return context_1.keyFor; } });
var id_entity_1 = require("./src/id-entity");

@@ -63,6 +55,6 @@ Object.defineProperty(exports, "IdEntity", { enumerable: true, get: function () { return id_entity_1.IdEntity; } });

Object.defineProperty(exports, "FilterConsumerBridgeToSqlRequest", { enumerable: true, get: function () { return filter_consumer_bridge_to_sql_request_1.FilterConsumerBridgeToSqlRequest; } });
var url_builder_1 = require("./src/url-builder");
Object.defineProperty(exports, "UrlBuilder", { enumerable: true, get: function () { return url_builder_1.UrlBuilder; } });
var urlBuilder_1 = require("./urlBuilder");
Object.defineProperty(exports, "UrlBuilder", { enumerable: true, get: function () { return urlBuilder_1.UrlBuilder; } });
var validators_1 = require("./src/validators");
Object.defineProperty(exports, "Validators", { enumerable: true, get: function () { return validators_1.Validators; } });
//# sourceMappingURL=index.js.map
{
"name": "@remult/core",
"schematics": "./schematics/collection.json",
"version": "3.0.22",
"version": "3.0.23",
"description": "remult core lib",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -1,2 +0,2 @@

import { SqlDatabase, SqlCommand, SqlImplementation, EntityDefinitions, FieldDefinitions } from '../';
import { SqlDatabase, SqlCommand, SqlImplementation, EntityMetadata, FieldMetadata } from '../';
import { QueryResult } from 'pg';

@@ -12,7 +12,7 @@ import { EntityQueueStorage } from '../server/expressBridge';

private pool;
entityIsUsedForTheFirstTime(entity: EntityDefinitions): Promise<void>;
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
getLimitSqlSyntax(limit: number, offset: number): string;
createCommand(): SqlCommand;
constructor(pool: PostgresPool);
insertAndReturnAutoIncrementId(command: SqlCommand, insertStatementString: string, entity: EntityDefinitions): Promise<number>;
insertAndReturnAutoIncrementId(command: SqlCommand, insertStatementString: string, entity: EntityMetadata): Promise<number>;
transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;

@@ -27,6 +27,6 @@ }

verifyStructureOfAllEntities(): Promise<void>;
createIfNotExist(e: EntityDefinitions): Promise<void>;
createIfNotExist(e: EntityMetadata): Promise<void>;
private addColumnSqlSyntax;
addColumnIfNotExist<T extends EntityDefinitions>(e: T, c: ((e: T) => FieldDefinitions)): Promise<void>;
verifyAllColumns<T extends EntityDefinitions>(e: T): Promise<void>;
addColumnIfNotExist<T extends EntityMetadata>(e: T, c: ((e: T) => FieldMetadata)): Promise<void>;
verifyAllColumns<T extends EntityMetadata>(e: T): Promise<void>;
additionalWhere: string;

@@ -33,0 +33,0 @@ constructor(pool: SqlDatabase, schema?: string);

@@ -5,5 +5,5 @@ "use strict";

var tslib_1 = require("tslib");
var __1 = require("../");
var context_1 = require("../src/context");
var expressBridge_1 = require("../server/expressBridge");
var valueConverters_1 = require("../valueConverters");
var PostgresDataProvider = /** @class */ (function () {

@@ -34,3 +34,3 @@ function PostgresDataProvider(pool) {

r = _a.sent();
return [4 /*yield*/, this.createCommand().execute("SELECT currval(pg_get_serial_sequence('" + entity.dbName + "','" + entity.idField.dbName + "'));")];
return [4 /*yield*/, this.createCommand().execute("SELECT currval(pg_get_serial_sequence('" + entity.dbName + "','" + entity.idMetadata.field.dbName + "'));")];
case 2:

@@ -139,3 +139,3 @@ r = _a.sent();

console.log("start verify structure");
context = new __1.ServerContext();
context = new context_1.Context();
_b.label = 1;

@@ -153,7 +153,7 @@ case 1:

_b.trys.push([3, 7, , 8]);
if (!(x.defs.dbName.toLowerCase().indexOf('from ') < 0)) return [3 /*break*/, 6];
return [4 /*yield*/, this.createIfNotExist(x.defs)];
if (!(x.metadata.dbName.toLowerCase().indexOf('from ') < 0)) return [3 /*break*/, 6];
return [4 /*yield*/, this.createIfNotExist(x.metadata)];
case 4:
_b.sent();
return [4 /*yield*/, this.verifyAllColumns(x.defs)];
return [4 /*yield*/, this.verifyAllColumns(x.metadata)];
case 5:

@@ -165,3 +165,3 @@ _b.sent();

err_2 = _b.sent();
console.log("failed verify structore of " + x.defs.dbName + " ", err_2);
console.log("failed verify structore of " + x.metadata.dbName + " ", err_2);
return [3 /*break*/, 8];

@@ -210,7 +210,7 @@ case 8:

result += '\r\n ';
if (x == e.idField && e.evilOriginalSettings.dbAutoIncrementId)
if (x == e.idMetadata.field && e.options.dbAutoIncrementId)
result += x.dbName + ' serial';
else {
result += this.addColumnSqlSyntax(x);
if (x == e.idField)
if (x == e.idMetadata.field)
result += ' primary key';

@@ -254,5 +254,6 @@ }

else if (x.dataType == Date)
result += " timestamp";
// else if (x instanceof DateColumn)
// result += " date";
if (x.valueConverter == valueConverters_1.DateOnlyValueConverter)
result += " date";
else
result += " timestamp";
else if (x.dataType == Boolean)

@@ -365,8 +366,9 @@ result += " boolean" + (x.allowNull ? "" : " default false not null");

case 0:
c = new __1.ServerContext(sql);
c = new context_1.Context();
c.setDataProvider(sql);
e = c.for(expressBridge_1.JobsInQueueEntity);
return [4 /*yield*/, new PostgresSchemaBuilder(sql).createIfNotExist(e.defs)];
return [4 /*yield*/, new PostgresSchemaBuilder(sql).createIfNotExist(e.metadata)];
case 1:
_a.sent();
return [4 /*yield*/, new PostgresSchemaBuilder(sql).verifyAllColumns(e.defs)];
return [4 /*yield*/, new PostgresSchemaBuilder(sql).verifyAllColumns(e.metadata)];
case 2:

@@ -373,0 +375,0 @@ _a.sent();

@@ -1,2 +0,2 @@

import { UserInfo, DataProvider, DataProviderFactoryBuilder, ServerContext, IdEntity } from '../';
import { UserInfo, DataProvider, DataProviderFactoryBuilder, IdEntity } from '../';
import * as express from 'express';

@@ -6,2 +6,3 @@ import { Repository } from '../src/remult3';

import { DataApi, DataApiRequest, DataApiResponse } from '../src/data-api';
import { ServerContext } from '../src/context';
export declare function initExpress(app: express.Express, options?: {

@@ -8,0 +9,0 @@ dataProvider?: DataProvider | DataProviderFactoryBuilder;

@@ -14,2 +14,3 @@ "use strict";

var data_api_1 = require("../src/data-api");
var context_1 = require("../src/context");
function initExpress(app, options) {

@@ -88,3 +89,3 @@ if (!options) {

api = entityOrDataApiFactory;
var contextForRouteExtraction = new __1.ServerContext();
var contextForRouteExtraction = new context_1.ServerContext();
contextForRouteExtraction.setReq({ clientIp: 'onServer', user: undefined, get: function (r) { return ''; }, getHeader: function (x) { return ""; }, getBaseUrl: function () { return ''; } });

@@ -151,3 +152,3 @@ var myRoute = api(contextForRouteExtraction).getRoute();

myReq.user = null;
context = new __1.ServerContext();
context = new context_1.ServerContext();
context.setReq(myReq);

@@ -154,0 +155,0 @@ context.setDataProvider(this.bridge._dataProviderFactory(context));

@@ -9,3 +9,3 @@ "use strict";

if (!x) {
throw 'failed to set server action, did you forget the ServerFunctionDecorator?';
throw 'failed to set server action, did you forget the BackendMethod Decorator?';
}

@@ -12,0 +12,0 @@ area.addAction(x);

@@ -1,4 +0,5 @@

import { Allowed, Context, EntityAllowed } from './context';
import { EntityField, ClassType, EntityDefinitions } from './remult3';
export interface FieldSettings<valueType = any, entityType = any> {
import { ClassType } from '../classType';
import { Allowed, Context, AllowedForInstance } from './context';
import { EntityMetadata, FieldRef } from './remult3';
export interface FieldOptions<valueType = any, entityType = any> {
key?: string;

@@ -14,3 +15,3 @@ target?: ClassType<entityType>;

dbName?: string;
sqlExpression?: string | ((entity: EntityDefinitions<entityType>, context: Context) => string);
sqlExpression?: string | ((entity: EntityMetadata<entityType>, context: Context) => string);
serverExpression?: (entity: entityType) => valueType | Promise<valueType>;

@@ -20,5 +21,5 @@ dbReadOnly?: boolean;

includeInApi?: Allowed;
allowApiUpdate?: EntityAllowed<entityType>;
allowApiUpdate?: AllowedForInstance<entityType>;
}
export interface FieldDefinitions<T = any> {
export interface FieldMetadata<T = any> {
readonly key: string;

@@ -34,3 +35,3 @@ readonly target: ClassType<T>;

readonly valueConverter: ValueConverter<T>;
readonly evilOriginalSettings: FieldSettings;
readonly options: FieldOptions;
}

@@ -48,5 +49,5 @@ export interface ValueConverter<T> {

}
export declare type FieldValidator<valueType = any, entityType = any> = (entity: entityType, col: EntityField<valueType, entityType>) => void | Promise<void>;
export declare type FieldValidator<valueType = any, entityType = any> = (entity: entityType, col: FieldRef<valueType, entityType>) => void | Promise<void>;
export declare type ValueOrExpression<valueType> = valueType | (() => valueType);
export declare function valueOrExpressionToValue<T>(f: ValueOrExpression<T>): T;
export declare function valueOrExpressionToValue<valueType>(f: ValueOrExpression<valueType>): valueType;
export interface ValueListItem {

@@ -53,0 +54,0 @@ id?: any;

@@ -1,10 +0,11 @@

import { FieldDefinitions, FieldSettings, ValueConverter } from './column-interfaces';
import { ClassType } from '../classType';
import { FieldMetadata, FieldOptions, ValueConverter } from './column-interfaces';
import { Filter } from './filter/filter-interfaces';
import { ClassType, EntityWhere, FindOptions, Repository } from './remult3';
import { EntityWhere, FindOptions, Repository } from './remult3';
export declare function makeTitle(name: string): string;
export declare class CompoundIdField implements FieldDefinitions<string> {
fields: FieldDefinitions[];
constructor(...columns: FieldDefinitions[]);
export declare class CompoundIdField implements FieldMetadata<string> {
fields: FieldMetadata[];
constructor(...columns: FieldMetadata[]);
getId(instance: any): string;
evilOriginalSettings: FieldSettings<any, any>;
options: FieldOptions<any, any>;
get valueConverter(): ValueConverter<string>;

@@ -21,3 +22,3 @@ target: ClassType<any>;

dataType: any;
isEqualTo(value: FieldDefinitions<string> | string): Filter;
isEqualTo(value: FieldMetadata<string> | string): Filter;
resultIdFilter(id: string, data: any): Filter;

@@ -24,0 +25,0 @@ }

@@ -73,3 +73,3 @@ "use strict";

LookupColumn.prototype.setId = function (val) {
if (this.repository.defs.idField.dataType == Number)
if (this.repository.metadata.idMetadata.field.dataType == Number)
val = +val;

@@ -93,3 +93,3 @@ this.id = val;

else {
var eo = remult3_1.getEntityOf(item, false);
var eo = remult3_1.getEntityRef(item, false);
if (eo) {

@@ -100,3 +100,3 @@ this.repository.addToCache(item);

else {
this.id = item[this.repository.defs.idField.key];
this.id = item[this.repository.metadata.idMetadata.field.key];
}

@@ -110,3 +110,3 @@ }

LookupColumn.prototype.exists = function () {
return !this.repository.getRowHelper(this.item).isNew();
return !this.repository.getEntityRef(this.item).isNew();
};

@@ -136,3 +136,3 @@ Object.defineProperty(LookupColumn.prototype, "item", {

ManyToOne.prototype.exists = function () {
return !this.repository.getRowHelper(this.item).isNew();
return !this.repository.getEntityRef(this.item).isNew();
};

@@ -205,3 +205,3 @@ Object.defineProperty(ManyToOne.prototype, "item", {

var r = this.provider.create();
remult3_1.__updateEntityBasedOnWhere(this.provider.defs, this.settings.where, r);
remult3_1.__updateEntityBasedOnWhere(this.provider.metadata, this.settings.where, r);
if (this.settings.create)

@@ -208,0 +208,0 @@ this.settings.create(r);

import { DataProvider } from "./data-interfaces";
import { DataApiRequest } from "./data-api";
import { ClassType, Repository } from "./remult3";
import { Repository } from "./remult3";
import { ClassType } from "../classType";
export interface HttpProvider {

@@ -21,8 +22,3 @@ post(url: string, data: any): Promise<any> | {

}): Promise<T>;
export declare class keyFor<T> {
}
export declare class Context {
map: Map<any, any>;
set<T>(key: keyFor<T>, value: T): void;
get<T>(key: keyFor<T>): T;
clearAllCache(): any;

@@ -36,4 +32,4 @@ isSignedIn(): boolean;

setDataProvider(dataProvider: DataProvider): void;
protected _onServer: boolean;
get onServer(): boolean;
protected _backend: boolean;
get backend(): boolean;
protected _user: UserInfo;

@@ -45,2 +41,3 @@ get user(): UserInfo;

static apiBaseUrl: string;
isAllowedForInstance(instance: any, x: AllowedForInstance<any>): any;
isAllowed(roles: Allowed): any;

@@ -63,3 +60,2 @@ repCache: Map<ClassType<any>, Repository<any>>;

key: string;
allowed: Allowed;
}

@@ -84,9 +80,4 @@ export declare const classHelpers: Map<any, ClassHelper>;

}
declare type AllowedRule = string | Role | ((c: Context) => boolean) | boolean;
export declare type Allowed = AllowedRule | AllowedRule[];
declare type EntityAllowedRule<T> = string | Role | ((c: Context, entity: T) => boolean) | boolean;
export declare type EntityAllowed<T> = EntityAllowedRule<T> | EntityAllowedRule<T>[];
export interface RoleChecker {
isAllowed(roles: Allowed): boolean;
}
export declare type Allowed = string | Role | ((c: Context) => boolean) | boolean | Allowed[];
export declare type AllowedForInstance<T> = string | Role | ((c: Context, entity: T) => boolean) | boolean | AllowedForInstance<T>[];
export interface IterateToArrayOptions {

@@ -108,2 +99,1 @@ limit?: number;

}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventSource = exports.iterateConfig = exports.Role = exports.setControllerSettings = exports.MethodHelper = exports.ClassHelper = exports.classHelpers = exports.allEntities = exports.ServerContext = exports.Context = exports.keyFor = exports.toPromise = void 0;
exports.EventSource = exports.iterateConfig = exports.Role = exports.setControllerSettings = exports.MethodHelper = exports.ClassHelper = exports.classHelpers = exports.allEntities = exports.ServerContext = exports.Context = exports.toPromise = void 0;
var tslib_1 = require("tslib");

@@ -107,12 +107,5 @@ var server_action_1 = require("./server-action");

exports.toPromise = toPromise;
var keyFor = /** @class */ (function () {
function keyFor() {
}
return keyFor;
}());
exports.keyFor = keyFor;
var Context = /** @class */ (function () {
function Context(http) {
this.map = new Map();
this._onServer = false;
this._backend = false;
this._userChangeEvent = new EventSource();

@@ -131,8 +124,2 @@ this.repCache = new Map();

}
Context.prototype.set = function (key, value) {
this.map.set(key, value);
};
Context.prototype.get = function (key) {
return this.map.get(key);
};
Context.prototype.clearAllCache = function () {

@@ -156,5 +143,5 @@ this.repCache.clear();

};
Object.defineProperty(Context.prototype, "onServer", {
Object.defineProperty(Context.prototype, "backend", {
get: function () {
return this._onServer;
return this._backend;
},

@@ -199,4 +186,30 @@ enumerable: false,

};
Context.prototype.isAllowedForInstance = function (instance, x) {
var e_1, _a;
if (Array.isArray(x)) {
{
try {
for (var x_1 = tslib_1.__values(x), x_1_1 = x_1.next(); !x_1_1.done; x_1_1 = x_1.next()) {
var item = x_1_1.value;
if (this.isAllowedForInstance(instance, item))
return true;
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (x_1_1 && !x_1_1.done && (_a = x_1.return)) _a.call(x_1);
}
finally { if (e_1) throw e_1.error; }
}
}
}
else if (typeof (x) === "function") {
return x(this, instance);
}
else
return this.isAllowed(x);
};
Context.prototype.isAllowed = function (roles) {
var e_1, _a;
var e_2, _a;
if (roles == undefined)

@@ -213,3 +226,3 @@ return undefined;

}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {

@@ -219,3 +232,3 @@ try {

}
finally { if (e_1) throw e_1.error; }
finally { if (e_2) throw e_2.error; }
}

@@ -254,3 +267,3 @@ return false;

var _this = _super.call(this) || this;
_this._onServer = true;
_this._backend = true;
if (dp)

@@ -271,3 +284,3 @@ _this.setDataProvider(dp);

ServerContext.prototype.getCookie = function (name) {
var e_2, _a;
var e_3, _a;
if (this.req) {

@@ -285,3 +298,3 @@ var cookie = this.req.getHeader('cookie');

}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {

@@ -291,3 +304,3 @@ try {

}
finally { if (e_2) throw e_2.error; }
finally { if (e_3) throw e_3.error; }
}

@@ -326,3 +339,3 @@ }

function setControllerSettings(target, options) {
var e_3, _a;
var e_4, _a;
var r = target;

@@ -333,3 +346,3 @@ while (true) {

try {
for (var _b = (e_3 = void 0, tslib_1.__values(helper.methods)), _c = _b.next(); !_c.done; _c = _b.next()) {
for (var _b = (e_4 = void 0, tslib_1.__values(helper.methods)), _c = _b.next(); !_c.done; _c = _b.next()) {
var m = _c.value;

@@ -339,3 +352,3 @@ m.classes.set(target, options);

}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {

@@ -345,3 +358,3 @@ try {

}
finally { if (e_3) throw e_3.error; }
finally { if (e_4) throw e_4.error; }
}

@@ -367,4 +380,2 @@ }

exports.Role = Role;
;
;
exports.iterateConfig = {

@@ -397,4 +408,4 @@ pageSize: 200

return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, _b, l, e_4_1;
var e_4, _c;
var _a, _b, l, e_5_1;
var e_5, _c;
return tslib_1.__generator(this, function (_d) {

@@ -418,4 +429,4 @@ switch (_d.label) {

case 5:
e_4_1 = _d.sent();
e_4 = { error: e_4_1 };
e_5_1 = _d.sent();
e_5 = { error: e_5_1 };
return [3 /*break*/, 7];

@@ -426,3 +437,3 @@ case 6:

}
finally { if (e_4) throw e_4.error; }
finally { if (e_5) throw e_5.error; }
return [7 /*endfinally*/];

@@ -429,0 +440,0 @@ case 7: return [2 /*return*/];

@@ -7,3 +7,2 @@ "use strict";

var filter_interfaces_2 = require("./filter/filter-interfaces");
var remult3_1 = require("./remult3");
var DataApi = /** @class */ (function () {

@@ -29,3 +28,3 @@ function DataApi(repository, context) {

return [4 /*yield*/, this.doOnId(response, id, function (row) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, response.success(this.repository.getRowHelper(row).toApiJson())];
return [2 /*return*/, response.success(this.repository.getEntityRef(row).toApiJson())];
}); }); })];

@@ -84,3 +83,3 @@ case 1:

hasId_1 = false;
w = filter_interfaces_2.Filter.translateWhereToFilter(filter_interfaces_2.Filter.createFilterOf(this.repository.defs), findOptions.where);
w = filter_interfaces_2.Filter.translateWhereToFilter(filter_interfaces_2.Filter.createFilterOf(this.repository.metadata), findOptions.where);
if (w) {

@@ -91,3 +90,3 @@ w.__applyToConsumer({

isEqualTo: function (col, val) {
if (_this.repository.defs.isIdField(col))
if (_this.repository.metadata.idMetadata.isIdField(col))
hasId_1 = true;

@@ -132,3 +131,3 @@ },

return [4 /*yield*/, Promise.all(r.map(function (y) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, this.repository.getRowHelper(y).toApiJson()];
return [2 /*return*/, this.repository.getEntityRef(y).toApiJson()];
}); }); }))];

@@ -158,6 +157,6 @@ case 1:

if (request) {
where = new filter_interfaces_1.AndFilter(where, filter_interfaces_2.Filter.extractWhere(this.repository.defs, request));
where = new filter_interfaces_1.AndFilter(where, filter_interfaces_2.Filter.extractWhere(this.repository.metadata, request));
}
if (filterBody)
where = new filter_interfaces_1.AndFilter(where, filter_interfaces_2.Filter.unpackWhere(this.repository.defs, filterBody));
where = new filter_interfaces_1.AndFilter(where, filter_interfaces_2.Filter.unpackWhere(this.repository.metadata, filterBody));
return where;

@@ -175,3 +174,3 @@ };

return [4 /*yield*/, this.repository.find({
where: [(_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.where, function (x) { return _this.repository.defs.getIdFilter(id); }]
where: [(_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.where, function (x) { return _this.repository.metadata.idMetadata.getIdFilter(id); }]
})

@@ -218,3 +217,3 @@ .then(function (r) { return tslib_1.__awaiter(_this, void 0, void 0, function () {

case 0:
this.repository.getRowHelper(row)._updateEntityBasedOnApi(body);
this.repository.getEntityRef(row)._updateEntityBasedOnApi(body);
if (!this._getApiSettings().allowUpdate(row)) {

@@ -224,6 +223,6 @@ response.forbidden();

}
return [4 /*yield*/, this.repository.getRowHelper(row).save()];
return [4 /*yield*/, this.repository.getEntityRef(row).save()];
case 1:
_a.sent();
response.success(this.repository.getRowHelper(row).toApiJson());
response.success(this.repository.getEntityRef(row).toApiJson());
return [2 /*return*/];

@@ -242,3 +241,3 @@ }

var _this = this;
var options = this.repository.defs.evilOriginalSettings;
var options = this.repository.metadata.options;
if (options.allowApiCrud !== undefined) {

@@ -257,5 +256,5 @@ if (options.allowApiDelete === undefined)

allowRead: this.context.isAllowed(options.allowApiRead),
allowUpdate: function (e) { return remult3_1.checkEntityAllowed(_this.context, options.allowApiUpdate, e); },
allowDelete: function (e) { return remult3_1.checkEntityAllowed(_this.context, options.allowApiDelete, e); },
allowInsert: function (e) { return remult3_1.checkEntityAllowed(_this.context, options.allowApiInsert, e); },
allowUpdate: function (e) { return _this.context.isAllowedForInstance(e, options.allowApiUpdate); },
allowDelete: function (e) { return _this.context.isAllowedForInstance(e, options.allowApiDelete); },
allowInsert: function (e) { return _this.context.isAllowedForInstance(e, options.allowApiInsert); },
requireId: this.context.isAllowed(options.apiRequireId),

@@ -285,3 +284,3 @@ get: {

}
return [4 /*yield*/, this.repository.getRowHelper(row).delete()];
return [4 /*yield*/, this.repository.getEntityRef(row).delete()];
case 1:

@@ -309,3 +308,3 @@ _a.sent();

newr = this.repository.create();
this.repository.getRowHelper(newr)._updateEntityBasedOnApi(body);
this.repository.getEntityRef(newr)._updateEntityBasedOnApi(body);
if (!this._getApiSettings().allowInsert(newr)) {

@@ -315,6 +314,6 @@ response.forbidden();

}
return [4 /*yield*/, this.repository.getRowHelper(newr).save()];
return [4 /*yield*/, this.repository.getEntityRef(newr).save()];
case 1:
_a.sent();
response.created(this.repository.getRowHelper(newr).toApiJson());
response.created(this.repository.getEntityRef(newr).toApiJson());
return [3 /*break*/, 3];

@@ -321,0 +320,0 @@ case 2:

import { Sort } from './sort';
import { Filter } from './filter/filter-interfaces';
import { EntityDefinitions } from './remult3';
import { EntityMetadata } from './remult3';
export interface DataProvider {
getEntityDataProvider(entity: EntityDefinitions): EntityDataProvider;
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;

@@ -7,0 +7,0 @@ }

import { EntityDataProvider, EntityDataProviderFindOptions } from '../data-interfaces';
import { Filter } from '../filter/filter-interfaces';
import { EntityDefinitions } from '../remult3';
import { EntityMetadata } from '../remult3';
export declare class ArrayEntityDataProvider implements EntityDataProvider {
private entity;
private rows?;
constructor(entity: EntityDefinitions, rows?: any[]);
constructor(entity: EntityMetadata, rows?: any[]);
count(where?: Filter): Promise<number>;

@@ -9,0 +9,0 @@ find(options?: EntityDataProviderFindOptions): Promise<any[]>;

@@ -117,3 +117,3 @@ "use strict";

var x = new FilterConsumerBridgeToObject(item);
_this.entity.getIdFilter(id).__applyToConsumer(x);
_this.entity.idMetadata.getIdFilter(id).__applyToConsumer(x);
return x.ok;

@@ -258,3 +258,5 @@ };

if (val)
val = col.valueConverter.toJson(val).toString().toLowerCase();
val = col.valueConverter.toJson(val);
if (val)
val = val.toString().toLowerCase();
if (s.toLowerCase().indexOf(val) < 0)

@@ -261,0 +263,0 @@ this.ok = false;

import { DataProvider, EntityDataProvider } from '../data-interfaces';
import { __RowsOfDataForTesting } from "../__RowsOfDataForTesting";
import { EntityDefinitions } from '../remult3';
import { EntityMetadata } from '../remult3';
export declare class InMemoryDataProvider implements DataProvider, __RowsOfDataForTesting {
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
rows: any;
getEntityDataProvider(entity: EntityDefinitions): EntityDataProvider;
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
toString(): string;
}
import { EntityDataProvider, DataProvider } from '../data-interfaces';
import { EntityDefinitions } from '../remult3';
import { EntityMetadata } from '../remult3';
export interface JsonEntityStorage {

@@ -10,4 +10,4 @@ getItem(entityDbName: string): string;

constructor(storage: JsonEntityStorage);
getEntityDataProvider(entity: EntityDefinitions): EntityDataProvider;
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
}
import { EntityDataProvider, DataProvider, RestDataProviderHttpProvider } from '../data-interfaces';
import { UrlBuilder } from '../url-builder';
import { EntityDefinitions } from '../remult3';
import { UrlBuilder } from '../../urlBuilder';
import { EntityMetadata } from '../remult3';
export declare class RestDataProvider implements DataProvider {

@@ -8,3 +8,3 @@ private url;

constructor(url: string, http: RestDataProviderHttpProvider);
getEntityDataProvider(entity: EntityDefinitions): EntityDataProvider;
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;

@@ -11,0 +11,0 @@ }

@@ -5,3 +5,3 @@ "use strict";

var tslib_1 = require("tslib");
var url_builder_1 = require("../url-builder");
var urlBuilder_1 = require("../../urlBuilder");
var filter_interfaces_1 = require("../filter/filter-interfaces");

@@ -72,3 +72,3 @@ var RestDataProvider = /** @class */ (function () {

return tslib_1.__generator(this, function (_a) {
url = new url_builder_1.UrlBuilder(this.url);
url = new urlBuilder_1.UrlBuilder(this.url);
url.add("__action", "count");

@@ -90,3 +90,3 @@ if (where) {

var _this = this;
var url = new url_builder_1.UrlBuilder(this.url);
var url = new urlBuilder_1.UrlBuilder(this.url);
var filterObject;

@@ -93,0 +93,0 @@ if (options) {

import { EntityDataProvider, DataProvider } from "../data-interfaces";
import { SqlCommand, SqlImplementation, SqlResult } from "../sql-command";
import { EntityDefinitions } from "../remult3";
import { EntityMetadata } from "../remult3";
export declare class SqlDatabase implements DataProvider {

@@ -8,3 +8,3 @@ private sql;

execute(sql: string): Promise<SqlResult>;
getEntityDataProvider(entity: EntityDefinitions): EntityDataProvider;
getEntityDataProvider(entity: EntityMetadata): EntityDataProvider;
transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;

@@ -11,0 +11,0 @@ static LogToConsole: boolean;

@@ -282,8 +282,8 @@ "use strict";

f = new filter_consumer_bridge_to_sql_request_1.FilterConsumerBridgeToSqlRequest(r);
this.entity.getIdFilter(id).__applyToConsumer(f);
this.entity.idMetadata.getIdFilter(id).__applyToConsumer(f);
statement = 'update ' + this.entity.dbName + ' set ';
added = false;
resultFilter = this.entity.getIdFilter(id);
resultFilter = this.entity.idMetadata.getIdFilter(id);
if (data.id != undefined)
resultFilter = this.entity.getIdFilter(data.id);
resultFilter = this.entity.idMetadata.getIdFilter(data.id);
try {

@@ -333,3 +333,3 @@ for (_a = tslib_1.__values(this.entity.fields), _b = _a.next(); !_b.done; _b = _a.next()) {

f = new filter_consumer_bridge_to_sql_request_1.FilterConsumerBridgeToSqlRequest(r);
this.entity.getIdFilter(id).__applyToConsumer(f);
this.entity.idMetadata.getIdFilter(id).__applyToConsumer(f);
statement = 'delete from ' + this.entity.dbName;

@@ -357,6 +357,6 @@ statement += f.where;

added = false;
if (this.entity.idField instanceof column_1.CompoundIdField)
resultFilter = this.entity.idField.resultIdFilter(undefined, data);
if (this.entity.idMetadata.field instanceof column_1.CompoundIdField)
resultFilter = this.entity.idMetadata.field.resultIdFilter(undefined, data);
else
resultFilter = this.entity.getIdFilter(data[this.entity.idField.key]);
resultFilter = this.entity.idMetadata.getIdFilter(data[this.entity.idMetadata.field.key]);
try {

@@ -389,7 +389,7 @@ for (_a = tslib_1.__values(this.entity.fields), _b = _a.next(); !_b.done; _b = _a.next()) {

statement = "insert into " + this.entity.dbName + " (" + cols + ") values (" + vals + ")";
if (!this.entity.evilOriginalSettings.dbAutoIncrementId) return [3 /*break*/, 3];
if (!this.entity.options.dbAutoIncrementId) return [3 /*break*/, 3];
return [4 /*yield*/, this.strategy.insertAndReturnAutoIncrementId(r, statement, this.entity)];
case 2:
newId_1 = _d.sent();
resultFilter = new filter_interfaces_1.Filter(function (x) { return x.isEqualTo(_this.entity.idField, newId_1); });
resultFilter = new filter_interfaces_1.Filter(function (x) { return x.isEqualTo(_this.entity.idMetadata.field, newId_1); });
return [3 /*break*/, 5];

@@ -396,0 +396,0 @@ case 3: return [4 /*yield*/, r.execute(statement)];

import { __RowsOfDataForTesting } from "../__RowsOfDataForTesting";
import { SqlCommand, SqlImplementation } from "../sql-command";
import { EntityDefinitions } from "../remult3";
import { EntityMetadata } from "../remult3";
export declare class WebSqlDataProvider implements SqlImplementation, __RowsOfDataForTesting {

@@ -10,7 +10,7 @@ private databaseName;

constructor(databaseName: string);
insertAndReturnAutoIncrementId(command: SqlCommand, insertStatementString: string, entity: EntityDefinitions): Promise<number>;
insertAndReturnAutoIncrementId(command: SqlCommand, insertStatementString: string, entity: EntityMetadata): Promise<number>;
getLimitSqlSyntax(limit: number, offset: number): string;
entityIsUsedForTheFirstTime(entity: EntityDefinitions): Promise<void>;
dropTable(entity: EntityDefinitions): Promise<void>;
createTable(entity: EntityDefinitions<any>): Promise<void>;
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
dropTable(entity: EntityMetadata): Promise<void>;
createTable(entity: EntityMetadata<any>): Promise<void>;
createCommand(): SqlCommand;

@@ -17,0 +17,0 @@ transaction(action: (dataProvider: SqlImplementation) => Promise<void>): Promise<void>;

@@ -69,5 +69,5 @@ "use strict";

result += this.addColumnSqlSyntax(x);
if (x.key == entity.idField.key) {
if (x.key == entity.idMetadata.field.key) {
result += ' primary key';
if (entity.evilOriginalSettings.dbAutoIncrementId)
if (entity.options.dbAutoIncrementId)
result += " autoincrement";

@@ -74,0 +74,0 @@ }

@@ -1,7 +0,7 @@

import { Allowed, Context, EntityAllowed } from "./context";
import { FieldDefinitions } from './column-interfaces';
import { EntityOrderBy, FieldDefinitionsOf, filterOf, EntityWhere } from "./remult3";
import { Allowed, Context, AllowedForInstance } from "./context";
import { FieldMetadata as FieldMetadata } from './column-interfaces';
import { EntityOrderBy, FieldsMetadata, FilterFactories, EntityWhere } from "./remult3";
import { Filter } from "./filter/filter-interfaces";
export interface EntitySettings<T = any> {
id?: (entity: FieldDefinitionsOf<T>) => FieldDefinitions;
export interface EntityOptions<T = any> {
id?: (entity: FieldsMetadata<T>) => FieldMetadata;
dbAutoIncrementId?: boolean;

@@ -20,3 +20,3 @@ /**

*/
dbName?: string | ((entity: FieldDefinitionsOf<T>, context: Context) => string);
dbName?: string | ((entity: FieldsMetadata<T>, context: Context) => string);
/**A human readable name for the entity */

@@ -30,7 +30,7 @@ caption?: string | ((context: Context) => string);

/** @see [allowed](http://remult-ts.github.io/guide/allowed.html)*/
allowApiUpdate?: EntityAllowed<T>;
allowApiUpdate?: AllowedForInstance<T>;
/** @see [allowed](http://remult-ts.github.io/guide/allowed.html)*/
allowApiDelete?: EntityAllowed<T>;
allowApiDelete?: AllowedForInstance<T>;
/** @see [allowed](http://remult-ts.github.io/guide/allowed.html)*/
allowApiInsert?: EntityAllowed<T>;
allowApiInsert?: AllowedForInstance<T>;
/** sets the `allowApiUpdate`, `allowApiDelete` and `allowApiInsert` properties in a single set */

@@ -45,3 +45,3 @@ allowApiCrud?: Allowed;

*/
apiDataFilter?: ((entityType: filterOf<T>, context: Context) => (Filter | Filter[]));
apiDataFilter?: ((entityType: FilterFactories<T>, context: Context) => (Filter | Filter[]));
apiRequireId?: Allowed;

@@ -48,0 +48,0 @@ /** A filter that will be used for all queries from this entity both from the API and from within the server.

import { SqlCommand } from "../sql-command";
import { Filter, FilterConsumer } from './filter-interfaces';
import { FieldDefinitions } from "../column-interfaces";
import { FieldMetadata } from "../column-interfaces";
export declare class FilterConsumerBridgeToSqlRequest implements FilterConsumer {

@@ -10,15 +10,15 @@ private r;

or(orElements: Filter[]): void;
isNull(col: FieldDefinitions): void;
isNotNull(col: FieldDefinitions): void;
isIn(col: FieldDefinitions, val: any[]): void;
isEqualTo(col: FieldDefinitions, val: any): void;
isDifferentFrom(col: FieldDefinitions, val: any): void;
isGreaterOrEqualTo(col: FieldDefinitions, val: any): void;
isGreaterThan(col: FieldDefinitions, val: any): void;
isLessOrEqualTo(col: FieldDefinitions, val: any): void;
isLessThan(col: FieldDefinitions, val: any): void;
containsCaseInsensitive(col: FieldDefinitions, val: any): void;
startsWith(col: FieldDefinitions, val: any): void;
isNull(col: FieldMetadata): void;
isNotNull(col: FieldMetadata): void;
isIn(col: FieldMetadata, val: any[]): void;
isEqualTo(col: FieldMetadata, val: any): void;
isDifferentFrom(col: FieldMetadata, val: any): void;
isGreaterOrEqualTo(col: FieldMetadata, val: any): void;
isGreaterThan(col: FieldMetadata, val: any): void;
isLessOrEqualTo(col: FieldMetadata, val: any): void;
isLessThan(col: FieldMetadata, val: any): void;
containsCaseInsensitive(col: FieldMetadata, val: any): void;
startsWith(col: FieldMetadata, val: any): void;
private add;
private addToWhere;
}

@@ -1,3 +0,3 @@

import { FieldDefinitions } from "../column-interfaces";
import { comparableFilterItem, EntityDefinitions, EntityWhere, filterOf, filterOptions, supportsContains } from "../remult3";
import { FieldMetadata } from "../column-interfaces";
import { ComparisonFilterFactory, EntityMetadata, EntityWhere, FilterFactories, FilterFactory, ContainsFilterFactory } from "../remult3";
export declare class Filter {

@@ -9,13 +9,13 @@ private apply?;

or(filter: Filter): Filter;
static createFilterOf<T>(entityDefs: EntityDefinitions<T>): filterOf<T>;
static translateWhereToFilter<T>(entity: filterOf<T>, where: EntityWhere<T>): Filter;
static packWhere<T>(entityDefs: EntityDefinitions<T>, where: EntityWhere<T>): any;
static unpackWhere<T>(entityDefs: EntityDefinitions<T>, packed: any): Filter;
static extractWhere<T>(entityDefs: EntityDefinitions<T>, filterInfo: {
static createFilterOf<T>(entityDefs: EntityMetadata<T>): FilterFactories<T>;
static translateWhereToFilter<T>(entity: FilterFactories<T>, where: EntityWhere<T>): Filter;
static packWhere<T>(entityDefs: EntityMetadata<T>, where: EntityWhere<T>): any;
static unpackWhere<T>(entityDefs: EntityMetadata<T>, packed: any): Filter;
static extractWhere<T>(entityDefs: EntityMetadata<T>, filterInfo: {
get: (key: string) => any;
}): Filter;
}
export declare class filterHelper implements filterOptions<any>, comparableFilterItem<any>, supportsContains<any> {
export declare class filterHelper implements FilterFactory<any>, ComparisonFilterFactory<any>, ContainsFilterFactory<any> {
private col;
constructor(col: FieldDefinitions);
constructor(col: FieldMetadata);
processVal(val: any): any;

@@ -35,13 +35,13 @@ startsWith(val: any): Filter;

or(orElements: Filter[]): any;
isEqualTo(col: FieldDefinitions, val: any): void;
isDifferentFrom(col: FieldDefinitions, val: any): void;
isNull(col: FieldDefinitions): void;
isNotNull(col: FieldDefinitions): void;
isGreaterOrEqualTo(col: FieldDefinitions, val: any): void;
isGreaterThan(col: FieldDefinitions, val: any): void;
isLessOrEqualTo(col: FieldDefinitions, val: any): void;
isLessThan(col: FieldDefinitions, val: any): void;
containsCaseInsensitive(col: FieldDefinitions, val: any): void;
startsWith(col: FieldDefinitions, val: any): void;
isIn(col: FieldDefinitions, val: any[]): void;
isEqualTo(col: FieldMetadata, val: any): void;
isDifferentFrom(col: FieldMetadata, val: any): void;
isNull(col: FieldMetadata): void;
isNotNull(col: FieldMetadata): void;
isGreaterOrEqualTo(col: FieldMetadata, val: any): void;
isGreaterThan(col: FieldMetadata, val: any): void;
isLessOrEqualTo(col: FieldMetadata, val: any): void;
isLessThan(col: FieldMetadata, val: any): void;
containsCaseInsensitive(col: FieldMetadata, val: any): void;
startsWith(col: FieldMetadata, val: any): void;
isIn(col: FieldMetadata, val: any[]): void;
}

@@ -60,18 +60,18 @@ export declare class AndFilter extends Filter {

or(orElements: Filter[]): void;
isNull(col: FieldDefinitions): void;
isNotNull(col: FieldDefinitions): void;
isIn(col: FieldDefinitions, val: any[]): void;
isEqualTo(col: FieldDefinitions, val: any): void;
isDifferentFrom(col: FieldDefinitions, val: any): void;
isGreaterOrEqualTo(col: FieldDefinitions, val: any): void;
isGreaterThan(col: FieldDefinitions, val: any): void;
isLessOrEqualTo(col: FieldDefinitions, val: any): void;
isLessThan(col: FieldDefinitions, val: any): void;
containsCaseInsensitive(col: FieldDefinitions, val: any): void;
startsWith(col: FieldDefinitions, val: any): void;
isNull(col: FieldMetadata): void;
isNotNull(col: FieldMetadata): void;
isIn(col: FieldMetadata, val: any[]): void;
isEqualTo(col: FieldMetadata, val: any): void;
isDifferentFrom(col: FieldMetadata, val: any): void;
isGreaterOrEqualTo(col: FieldMetadata, val: any): void;
isGreaterThan(col: FieldMetadata, val: any): void;
isLessOrEqualTo(col: FieldMetadata, val: any): void;
isLessThan(col: FieldMetadata, val: any): void;
containsCaseInsensitive(col: FieldMetadata, val: any): void;
startsWith(col: FieldMetadata, val: any): void;
}
export declare function unpackWhere(columns: FieldDefinitions[], packed: any): Filter;
export declare function extractWhere(columns: FieldDefinitions[], filterInfo: {
export declare function unpackWhere(columns: FieldMetadata[], packed: any): Filter;
export declare function extractWhere(columns: FieldMetadata[], filterInfo: {
get: (key: string) => any;
}): Filter;
export declare function packToRawWhere(w: Filter): any;

@@ -85,3 +85,3 @@ "use strict";

return val;
return remult3_1.getEntityOf(val).getId();
return remult3_1.getEntityRef(val).getId();
}

@@ -88,0 +88,0 @@ return val;

@@ -21,7 +21,7 @@ "use strict";

Lookup.prototype._internalGetByOptions = function (find) {
var f = filter_interfaces_1.Filter.packWhere(this.repository.defs, find.where);
var f = filter_interfaces_1.Filter.packWhere(this.repository.metadata, find.where);
var key = JSON.stringify(f);
var res = this.cache.get(key);
if (res !== undefined) {
if (this.repository.getRowHelper(res.value).wasDeleted()) {
if (this.repository.getEntityRef(res.value).wasDeleted()) {
res = undefined;

@@ -35,3 +35,3 @@ this.cache.set(key, undefined);

res.value = this.repository.create();
remult3_1.__updateEntityBasedOnWhere(this.repository.defs, find.where, res.value);
remult3_1.__updateEntityBasedOnWhere(this.repository.metadata, find.where, res.value);
this.cache.set(key, res);

@@ -38,0 +38,0 @@ var foundNonUnDefined = false;

@@ -1,8 +0,8 @@

import { FieldDefinitions } from "../column-interfaces";
import { FieldMetadata } from "../column-interfaces";
import { IterateToArrayOptions, Unobserve } from "../context";
import { EntitySettings } from "../entity";
import { EntityOptions as EntityOptions } from "../entity";
import { Filter } from "../filter/filter-interfaces";
import { SortSegment } from "../sort";
import { entityEventListener } from "../__EntityValueProvider";
export interface rowHelper<entityType> {
export interface EntityRef<entityType> {
hasErrors(): boolean;

@@ -16,55 +16,58 @@ undoChanges(): any;

wasDeleted(): boolean;
fields: EntityFields<entityType>;
fields: Fields<entityType>;
error: string;
getId(): any;
repository: Repository<entityType>;
defs: EntityDefinitions<entityType>;
metadata: EntityMetadata<entityType>;
toApiJson(): any;
}
export declare type EntityFields<Type> = {
[Properties in keyof Type]: EntityField<Type[Properties], Type>;
export declare type Fields<entityType> = {
[Properties in keyof entityType]: FieldRef<entityType[Properties], entityType>;
} & {
find(col: FieldDefinitions): EntityField<any, Type>;
[Symbol.iterator]: () => IterableIterator<EntityField<any, Type>>;
find(col: FieldMetadata): FieldRef<any, entityType>;
[Symbol.iterator]: () => IterableIterator<FieldRef<any, entityType>>;
};
export declare type FieldDefinitionsOf<Type> = {
[Properties in keyof Type]: FieldDefinitions;
export declare type FieldsMetadata<entityType> = {
[Properties in keyof entityType]: FieldMetadata;
} & {
find(col: FieldDefinitions): FieldDefinitions;
[Symbol.iterator]: () => IterableIterator<FieldDefinitions>;
find(col: FieldMetadata): FieldMetadata;
[Symbol.iterator]: () => IterableIterator<FieldMetadata>;
};
export declare type sortOf<Type> = {
[Properties in keyof Type]: SortSegment & {
export declare type SortSegments<entityType> = {
[Properties in keyof entityType]: SortSegment & {
descending(): SortSegment;
};
};
export interface EntityField<T, entityType = any> {
export interface FieldRef<valueType, entityType = any> {
inputType: string;
error: string;
displayValue: string;
value: T;
originalValue: T;
value: valueType;
originalValue: valueType;
inputValue: string;
wasChanged(): boolean;
rowHelper: rowHelper<entityType>;
entity: entityType;
defs: FieldDefinitions<entityType>;
load(): Promise<T>;
entityRef: EntityRef<entityType>;
container: entityType;
metadata: FieldMetadata<entityType>;
load(): Promise<valueType>;
}
export interface EntityDefinitions<entityType = any> {
readonly idField: FieldDefinitions<any>;
export interface IdMetadata<entityType = any> {
field: FieldMetadata<any>;
getIdFilter(id: any): Filter;
isIdField(col: FieldDefinitions): boolean;
isIdField(col: FieldMetadata): boolean;
createIdInFilter(items: entityType[]): Filter;
}
export interface EntityMetadata<entityType = any> {
readonly idMetadata: IdMetadata<entityType>;
readonly key: string;
readonly dbName: string;
readonly fields: FieldDefinitionsOf<entityType>;
readonly fields: FieldsMetadata<entityType>;
readonly caption: string;
readonly evilOriginalSettings: EntitySettings;
readonly options: EntityOptions;
}
export interface Repository<entityType> {
fromJson(x: any, isNew?: boolean): Promise<entityType>;
defs: EntityDefinitions<entityType>;
metadata: EntityMetadata<entityType>;
find(options?: FindOptions<entityType>): Promise<entityType[]>;
iterate(options?: EntityWhere<entityType> | IterateOptions<entityType>): IteratableResult<entityType>;
iterate(options?: EntityWhere<entityType> | IterateOptions<entityType>): IterableResult<entityType>;
count(where?: EntityWhere<entityType>): Promise<number>;

@@ -96,8 +99,8 @@ findFirst(where?: EntityWhere<entityType> | IterateOptions<entityType>): Promise<entityType>;

addToCache(item: entityType): any;
getRowHelper(item: entityType): rowHelper<entityType>;
save(entity: entityType): Promise<entityType>;
delete(entity: entityType): Promise<void>;
getEntityRef(item: entityType): EntityRef<entityType>;
save(item: entityType): Promise<entityType>;
delete(item: entityType): Promise<void>;
addEventListener(listener: entityEventListener<entityType>): Unobserve;
}
export interface FindOptions<T> {
export interface FindOptions<entityType> {
/** filters the data

@@ -108,7 +111,7 @@ * @example

*/
where?: EntityWhere<T>;
where?: EntityWhere<entityType>;
/** Determines the order in which the result will be sorted in
* @see See [EntityOrderBy](https://remult-ts.github.io/guide/ref__entityorderby) for more examples on how to sort
*/
orderBy?: EntityOrderBy<T>;
orderBy?: EntityOrderBy<entityType>;
/** Determines the number of rows returned by the request, on the browser the default is 25 rows

@@ -140,3 +143,3 @@ * @example

*/
export declare type EntityOrderBy<T> = (entity: sortOf<T>) => SortSegment[] | SortSegment;
export declare type EntityOrderBy<entityType> = (entity: SortSegments<entityType>) => SortSegment[] | SortSegment;
/**Used to filter the desired result set

@@ -146,24 +149,21 @@ * @example

*/
export declare type EntityWhere<entityType> = ((entityType: filterOf<entityType>) => (Filter | Filter[] | EntityWhere<entityType>)) | EntityWhere<entityType>[];
export interface filterOptions<x> {
isEqualTo(val: x): Filter;
isDifferentFrom(val: x): any;
isIn(val: x[]): Filter;
isNotIn(val: x[]): Filter;
export declare type EntityWhere<entityType> = ((entityType: FilterFactories<entityType>) => (Filter | Filter[] | EntityWhere<entityType>)) | EntityWhere<entityType>[];
export interface FilterFactory<valueType> {
isEqualTo(val: valueType): Filter;
isDifferentFrom(val: valueType): any;
isIn(val: valueType[]): Filter;
isNotIn(val: valueType[]): Filter;
}
export interface comparableFilterItem<x> extends filterOptions<x> {
isLessOrEqualTo(val: x): Filter;
isLessThan(val: x): Filter;
isGreaterThan(val: x): Filter;
isGreaterOrEqualTo(val: x): Filter;
export interface ComparisonFilterFactory<valueType> extends FilterFactory<valueType> {
isLessOrEqualTo(val: valueType): Filter;
isLessThan(val: valueType): Filter;
isGreaterThan(val: valueType): Filter;
isGreaterOrEqualTo(val: valueType): Filter;
}
export interface supportsContains<x> extends filterOptions<x> {
export interface ContainsFilterFactory<valueType> extends FilterFactory<valueType> {
contains(val: string): Filter;
}
export declare type filterOf<Type> = {
[Properties in keyof Type]: Type[Properties] extends number | Date ? comparableFilterItem<Type[Properties]> : Type[Properties] extends string ? (supportsContains<Type[Properties]> & comparableFilterItem<Type[Properties]>) : supportsContains<Type[Properties]>;
export declare type FilterFactories<entityType> = {
[Properties in keyof entityType]: entityType[Properties] extends number | Date ? ComparisonFilterFactory<entityType[Properties]> : entityType[Properties] extends string ? (ContainsFilterFactory<entityType[Properties]> & ComparisonFilterFactory<entityType[Properties]>) : ContainsFilterFactory<entityType[Properties]>;
};
export declare type ClassType<T> = {
new (...args: any[]): T;
};
export interface IterateOptions<entityType> {

@@ -176,3 +176,3 @@ where?: EntityWhere<entityType>;

}
export interface IteratableResult<T> {
export interface IterableResult<T> {
toArray(options?: IterateToArrayOptions): Promise<T[]>;

@@ -186,11 +186,1 @@ first(): Promise<T>;

}
export declare class InputTypes {
static number: string;
static date: string;
static checkbox: string;
static password: string;
static email: string;
static tel: string;
static time: string;
}
export declare function set<T>(item: T, valuesToSet: Partial<T>): T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.set = exports.InputTypes = void 0;
var InputTypes = /** @class */ (function () {
function InputTypes() {
}
InputTypes.number = 'number';
InputTypes.date = 'date';
InputTypes.checkbox = 'checkbox';
InputTypes.password = 'password';
InputTypes.email = 'email';
InputTypes.tel = 'tel';
InputTypes.time = "time";
return InputTypes;
}());
exports.InputTypes = InputTypes;
function set(item, valuesToSet) {
if (valuesToSet)
Object.assign(item, valuesToSet);
return item;
}
exports.set = set;
//# sourceMappingURL=remult3.js.map

@@ -1,7 +0,7 @@

import { FieldDefinitions, FieldSettings, ValueConverter, ValueListItem } from "../column-interfaces";
import { EntitySettings } from "../entity";
import { FieldMetadata, FieldOptions, ValueConverter, ValueListItem } from "../column-interfaces";
import { EntityOptions } from "../entity";
import { LookupColumn } from '../column';
import { EntityDefinitions, EntityField, EntityFields, EntityWhere, FindOptions, ClassType, Repository, rowHelper, IterateOptions, IteratableResult, EntityOrderBy, FieldDefinitionsOf } from "./remult3";
import { Context, EntityAllowed } from "../context";
import { Filter } from "../filter/filter-interfaces";
import { EntityMetadata, FieldRef, Fields, EntityWhere, FindOptions, Repository, EntityRef, IterateOptions, IterableResult, EntityOrderBy, FieldsMetadata, IdMetadata } from "./remult3";
import { ClassType } from "../../classType";
import { Context } from "../context";
import { entityEventListener } from "../__EntityValueProvider";

@@ -23,10 +23,10 @@ import { DataProvider, EntityDataProvider } from "../data-interfaces";

addToCache(item: T): void;
get defs(): EntityDefinitions;
get metadata(): EntityMetadata;
listeners: entityEventListener<T>[];
addEventListener(listener: entityEventListener<T>): () => void;
iterate(options?: EntityWhere<T> | IterateOptions<T>): IteratableResult<T>;
iterate(options?: EntityWhere<T> | IterateOptions<T>): IterableResult<T>;
findOrCreate(options?: EntityWhere<T> | IterateOptions<T>): Promise<T>;
lookup(filter: EntityWhere<T>): T;
lookupAsync(filter: EntityWhere<T>): Promise<T>;
getRowHelper(entity: T): rowHelper<T>;
getEntityRef(entity: T): EntityRef<T>;
delete(entity: T): Promise<void>;

@@ -43,5 +43,5 @@ save(entity: T): Promise<T>;

}
export declare function __updateEntityBasedOnWhere<T>(entityDefs: EntityDefinitions<T>, where: EntityWhere<T>, r: T): void;
export declare function __updateEntityBasedOnWhere<T>(entityDefs: EntityMetadata<T>, where: EntityWhere<T>, r: T): void;
export declare const entityInfo: unique symbol;
export declare function getEntitySettings<T>(entity: ClassType<T>, throwError?: boolean): EntitySettings<any>;
export declare function getEntitySettings<T>(entity: ClassType<T>, throwError?: boolean): EntityOptions<any>;
export declare const columnsOfType: Map<any, columnInfo[]>;

@@ -72,3 +72,3 @@ export declare function createOldEntity<T>(entity: ClassType<T>, context: Context): EntityFullInfo<T>;

}
export declare class rowHelperImplementation<T> extends rowHelperBase<T> implements rowHelper<T> {
export declare class rowHelperImplementation<T> extends rowHelperBase<T> implements EntityRef<T> {
private info;

@@ -79,3 +79,3 @@ repository: RepositoryImplementation<T>;

constructor(info: EntityFullInfo<T>, instance: T, repository: RepositoryImplementation<T>, edp: EntityDataProvider, context: Context, _isNew: boolean);
defs: EntityDefinitions<T>;
metadata: EntityMetadata<T>;
getId(): any;

@@ -87,3 +87,3 @@ private _wasDeleted;

private _columns;
get fields(): EntityFields<T>;
get fields(): Fields<T>;
save(): Promise<T>;

@@ -99,7 +99,5 @@ delete(): Promise<void>;

}
export declare function getControllerDefs<T>(controller: T, context?: Context): controllerDefsImpl<T>;
export interface controllerDefs<T = any> {
readonly fields: EntityFields<T>;
}
export declare class controllerDefsImpl<T = any> extends rowHelperBase<T> implements controllerDefs<T> {
export declare function getFields<fieldsContainerType>(container: fieldsContainerType, context?: Context): Fields<fieldsContainerType>;
export declare function getControllerRef<fieldsContainerType>(container: fieldsContainerType, context?: Context): controllerRefImpl<fieldsContainerType>;
export declare class controllerRefImpl<T = any> extends rowHelperBase<T> {
constructor(columnsInfo: columnInfo[], instance: any, context: Context);

@@ -111,11 +109,11 @@ __performColumnAndEntityValidations(): Promise<void>;

originalValues: any;
fields: EntityFields<T>;
fields: Fields<T>;
}
export declare class columnImpl<colType, rowType> implements EntityField<colType, rowType> {
export declare class columnImpl<colType, rowType> implements FieldRef<colType, rowType> {
private settings;
defs: FieldDefinitions;
entity: any;
metadata: FieldMetadata;
container: any;
private helper;
private rowBase;
constructor(settings: FieldSettings, defs: FieldDefinitions, entity: any, helper: rowHelper<rowType>, rowBase: rowHelperBase<rowType>);
constructor(settings: FieldOptions, metadata: FieldMetadata, container: any, helper: EntityRef<rowType>, rowBase: rowHelperBase<rowType>);
load(): Promise<colType>;

@@ -134,11 +132,11 @@ target: ClassType<any>;

wasChanged(): boolean;
rowHelper: rowHelper<any>;
entityRef: EntityRef<any>;
__performValidation(): Promise<void>;
}
export declare function getEntityOf<T>(item: T, throwException?: boolean): rowHelper<T>;
export declare const CaptionHelper: {
determineCaption: (context: Context, key: string, caption: string) => string;
export declare function getEntityRef<entityType>(entity: entityType, throwException?: boolean): EntityRef<entityType>;
export declare const CaptionTransformer: {
transformCaption: (context: Context, key: string, caption: string) => string;
};
export declare function buildCaption(caption: string | ((context: Context) => string), key: string, context: Context): string;
export declare class columnDefsImpl implements FieldDefinitions {
export declare class columnDefsImpl implements FieldMetadata {
private colInfo;

@@ -148,3 +146,3 @@ private entityDefs;

constructor(colInfo: columnInfo, entityDefs: EntityFullInfo<any>, context: Context);
evilOriginalSettings: FieldSettings<any, any>;
options: FieldOptions<any, any>;
target: ClassType<any>;

@@ -162,14 +160,11 @@ readonly: boolean;

}
declare class EntityFullInfo<T> implements EntityDefinitions<T> {
declare class EntityFullInfo<T> implements EntityMetadata<T> {
columnsInfo: columnInfo[];
entityInfo: EntitySettings;
entityInfo: EntityOptions;
private context;
evilOriginalSettings: EntitySettings<any>;
constructor(columnsInfo: columnInfo[], entityInfo: EntitySettings, context: Context);
options: EntityOptions<any>;
constructor(columnsInfo: columnInfo[], entityInfo: EntityOptions, context: Context);
idMetadata: IdMetadata<T>;
dbAutoIncrementId: boolean;
idField: FieldDefinitions<any>;
createIdInFilter(items: T[]): Filter;
isIdField(col: FieldDefinitions<any>): boolean;
getIdFilter(id: any): Filter;
fields: FieldDefinitionsOf<T>;
fields: FieldsMetadata<T>;
key: string;

@@ -179,17 +174,16 @@ dbName: string;

}
export declare function FieldType<T = any>(settings?: FieldSettings<T, any>): (target: any) => any;
export declare function DateOnlyField<T = any>(settings?: FieldSettings<Date, T>): (target: any, key: any, c?: any) => void;
export declare function DecimalField<T = any>(settings?: FieldSettings<Number, T>): (target: any, key: any, c?: any) => void;
export declare function ValueListFieldType<T = any, colType extends ValueListItem = any>(type: ClassType<colType>, settings?: FieldSettings<colType, T>): (target: any) => any;
export declare function Field<T = any, colType = any>(settings?: FieldSettings<colType, T>): (target: any, key: any, c?: any) => void;
export declare function decorateColumnSettings<T>(settings: FieldSettings<T>): FieldSettings<T, any>;
export declare function FieldType<T = any>(settings?: FieldOptions<T, any>): (target: any) => any;
export declare function DateOnlyField<T = any>(settings?: FieldOptions<Date, T>): (target: any, key: any, c?: any) => void;
export declare function DecimalField<T = any>(settings?: FieldOptions<Number, T>): (target: any, key: any, c?: any) => void;
export declare function ValueListFieldType<T = any, colType extends ValueListItem = any>(type: ClassType<colType>, settings?: FieldOptions<colType, T>): (target: any) => any;
export declare function Field<T = any, colType = any>(settings?: FieldOptions<colType, T>): (target: any, key: any, c?: any) => void;
export declare function decorateColumnSettings<T>(settings: FieldOptions<T>): FieldOptions<T, any>;
interface columnInfo {
key: string;
settings: FieldSettings;
settings: FieldOptions;
type: any;
}
export declare function Entity<T>(options: EntitySettings<T>): (target: any) => any;
export declare function checkEntityAllowed(context: Context, x: EntityAllowed<any>, entity: any): any;
export declare function Entity<T>(options: EntityOptions<T>): (target: any) => any;
export declare class EntityBase {
get _(): rowHelper<this>;
get _(): EntityRef<this>;
save(): Promise<this>;

@@ -199,4 +193,4 @@ delete(): Promise<void>;

wasChanged(): boolean;
get $(): EntityFields<this>;
get $(): Fields<this>;
}
export {};
import 'reflect-metadata';
import { Context, ServerContext, Allowed, ControllerOptions } from './context';
import { AllowedForInstance, ServerContext } from './context';
import { DataApiRequest, DataApiResponse } from './data-api';

@@ -25,7 +25,7 @@ import { DataProvider, RestDataProviderHttpProvider } from './data-interfaces';

private originalMethod;
constructor(name: string, types: any[], options: ServerFunctionOptions, originalMethod: (args: any[]) => any);
constructor(name: string, types: any[], options: BackendMethodOptions<any>, originalMethod: (args: any[]) => any);
protected execute(info: inArgs, context: ServerContext, res: DataApiResponse): Promise<result>;
}
export interface ServerFunctionOptions {
allowed: Allowed;
export interface BackendMethodOptions<type> {
allowed: AllowedForInstance<type>;
blockUser?: boolean;

@@ -43,7 +43,5 @@ queue?: boolean;

};
export declare function ServerFunction(options: ServerFunctionOptions): (target: any, key: string, descriptor: any) => any;
export declare const serverActionField: unique symbol;
export declare function ServerController(options: ControllerOptions): (target: any) => any;
export declare function ServerMethod(options?: ServerFunctionOptions): (target: any, key: string, descriptor: any) => any;
export declare function controllerAllowed(controller: any, context: Context): any;
export declare function Controller(key: string): (target: any) => any;
export declare function BackendMethod<type = any>(options: BackendMethodOptions<type>): (target: any, key: string, descriptor: any) => any;
export interface registrableAction {

@@ -61,3 +59,3 @@ __register: (reg: (url: string, queue: boolean, what: ((data: any, req: DataApiRequest, res: DataApiResponse) => void)) => void) => void;

}
export declare class ServerProgress {
export declare class ProgressListener {
private res;

@@ -64,0 +62,0 @@ constructor(res: DataApiResponse);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.prepareReceivedArgs = exports.prepareArgsToSend = exports.ServerProgress = exports.controllerAllowed = exports.ServerMethod = exports.ServerController = exports.serverActionField = exports.ServerFunction = exports.actionInfo = exports.myServerAction = exports.Action = void 0;
exports.prepareReceivedArgs = exports.prepareArgsToSend = exports.ProgressListener = exports.BackendMethod = exports.Controller = exports.serverActionField = exports.actionInfo = exports.myServerAction = exports.Action = void 0;
var tslib_1 = require("tslib");

@@ -119,3 +119,3 @@ require("reflect-metadata");

context.setDataProvider(ds);
if (!context.isAllowed(this.options.allowed))
if (!context.isAllowedForInstance(undefined, this.options.allowed))
throw 'not allowed';

@@ -160,58 +160,55 @@ _a = info;

};
function ServerFunction(options) {
return function (target, key, descriptor) {
var originalMethod = descriptor.value;
var types = Reflect.getMetadata("design:paramtypes", target, key);
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
var serverAction = new myServerAction(key, types, options, function (args) { return originalMethod.apply(undefined, args); });
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!exports.actionInfo.runningOnServer) return [3 /*break*/, 5];
args = prepareArgsToSend(types, args);
if (!(options.blockUser === false)) return [3 /*break*/, 2];
return [4 /*yield*/, exports.actionInfo.runActionWithoutBlockingUI(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, serverAction.run({ args: args })];
case 1: return [2 /*return*/, (_a.sent()).data];
}
}); }); })];
case 1: return [2 /*return*/, _a.sent()];
case 2: return [4 /*yield*/, serverAction.run({ args: args })];
case 3: return [2 /*return*/, (_a.sent()).data];
case 4: return [3 /*break*/, 7];
case 5: return [4 /*yield*/, originalMethod.apply(undefined, args)];
case 6: return [2 /*return*/, (_a.sent())];
case 7: return [2 /*return*/];
}
});
});
};
exports.actionInfo.allActions.push(descriptor.value);
descriptor.value[exports.serverActionField] = serverAction;
return descriptor;
};
}
exports.ServerFunction = ServerFunction;
exports.serverActionField = Symbol('serverActionField');
var methodHelpers = new Map();
var classOptions = new Map();
function ServerController(options) {
function Controller(key) {
return function (target) {
var r = target;
classOptions.set(r, options);
context_1.setControllerSettings(target, options);
classOptions.set(r, { key: key });
context_1.setControllerSettings(target, { key: key });
return target;
};
}
exports.ServerController = ServerController;
function ServerMethod(options) {
exports.Controller = Controller;
function BackendMethod(options) {
return function (target, key, descriptor) {
if (target.prototype !== undefined) {
var originalMethod = descriptor.value;
var types = Reflect.getMetadata("design:paramtypes", target, key);
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
var serverAction_1 = new myServerAction(key, types, options, function (args) { return originalMethod.apply(undefined, args); });
descriptor.value = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!!exports.actionInfo.runningOnServer) return [3 /*break*/, 5];
args = prepareArgsToSend(types, args);
if (!(options.blockUser === false)) return [3 /*break*/, 2];
return [4 /*yield*/, exports.actionInfo.runActionWithoutBlockingUI(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, serverAction_1.run({ args: args })];
case 1: return [2 /*return*/, (_a.sent()).data];
}
}); }); })];
case 1: return [2 /*return*/, _a.sent()];
case 2: return [4 /*yield*/, serverAction_1.run({ args: args })];
case 3: return [2 /*return*/, (_a.sent()).data];
case 4: return [3 /*break*/, 7];
case 5: return [4 /*yield*/, originalMethod.apply(undefined, args)];
case 6: return [2 /*return*/, (_a.sent())];
case 7: return [2 /*return*/];
}
});
});
};
exports.actionInfo.allActions.push(descriptor.value);
descriptor.value[exports.serverActionField] = serverAction_1;
return descriptor;
}
var types = Reflect.getMetadata("design:paramtypes", target, key);

@@ -235,3 +232,3 @@ var x = context_1.classHelpers.get(target.constructor);

if (!controllerOptions.key) {
controllerOptions.key = c.for(constructor).defs.key + "_methods";
controllerOptions.key = c.for(constructor).metadata.key + "_methods";
}

@@ -245,5 +242,3 @@ reg(controllerOptions.key + '/' + key, options ? options.queue : false, function (d, req, res) { return tslib_1.__awaiter(_this, void 0, void 0, function () {

d.args = d.args.map(function (x) { return isCustomUndefined(x) ? undefined : x; });
allowed = controllerOptions.allowed;
if (options && options.allowed !== undefined)
allowed = options.allowed;
allowed = options.allowed;
_a.label = 1;

@@ -254,6 +249,4 @@ case 1:

ds = context_2._dataSource;
if (!context_2.isAllowed(allowed))
throw 'not allowed';
return [4 /*yield*/, ds.transaction(function (ds) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _a, repo_1, y, rowHelper, rows, defs, err_4, y, defs, err_5;
var _a, repo_1, y, rowHelper, rows, defs, err_4, y, controllerRef, err_5;
var _b, _c, _d;

@@ -274,3 +267,3 @@ var _this = this;

y = repo_1.create();
rowHelper = repo_1.getRowHelper(y);
rowHelper = repo_1.getEntityRef(y);
rowHelper._updateEntityBasedOnApi(d.rowInfo.data);

@@ -280,3 +273,3 @@ return [3 /*break*/, 4];

where: function (x) {
var where = repo_1.defs.getIdFilter(d.rowInfo.id);
var where = repo_1.metadata.idMetadata.getIdFilter(d.rowInfo.id);
if (_this.options && _this.options.get && _this.options.get.where)

@@ -292,6 +285,8 @@ where = new filter_interfaces_1.AndFilter(where, _this.options.get.where(x));

y = rows[0];
repo_1.getRowHelper(y)._updateEntityBasedOnApi(d.rowInfo.data);
repo_1.getEntityRef(y)._updateEntityBasedOnApi(d.rowInfo.data);
_e.label = 4;
case 4:
defs = remult3_1.getEntityOf(y);
if (!context_2.isAllowedForInstance(y, allowed))
throw 'not allowed';
defs = remult3_1.getEntityRef(y);
return [4 /*yield*/, defs.__validateEntity()];

@@ -323,8 +318,10 @@ case 5:

y = new constructor(context_2, ds);
defs = remult3_1.getControllerDefs(y, context_2);
defs._updateEntityBasedOnApi(d.fields);
return [4 /*yield*/, Promise.all(tslib_1.__spread(defs.fields).map(function (x) { return x.load(); }))];
controllerRef = remult3_1.getControllerRef(y, context_2);
controllerRef._updateEntityBasedOnApi(d.fields);
return [4 /*yield*/, Promise.all(tslib_1.__spread(controllerRef.fields).map(function (x) { return x.load(); }))];
case 12:
_e.sent();
return [4 /*yield*/, defs.__validateEntity()];
if (!context_2.isAllowedForInstance(y, allowed))
throw 'not allowed';
return [4 /*yield*/, controllerRef.__validateEntity()];
case 13:

@@ -339,3 +336,3 @@ _e.sent();

_d.result = _e.sent();
return [4 /*yield*/, defs.toApiJson()];
return [4 /*yield*/, controllerRef.toApiJson()];
case 16:

@@ -347,3 +344,3 @@ r_1 = (_d.fields = _e.sent(),

err_5 = _e.sent();
throw defs.catchSaveErrors(err_5);
throw controllerRef.catchSaveErrors(err_5);
case 18: return [2 /*return*/];

@@ -396,3 +393,3 @@ }

if (!context_1.allEntities.includes(target.constructor)) return [3 /*break*/, 8];
defs = remult3_1.getEntityOf(self_1);
defs = remult3_1.getEntityRef(self_1);
return [4 /*yield*/, defs.__validateEntity()];

@@ -403,3 +400,3 @@ case 1:

if (!classOptions_1.key) {
classOptions_1.key = defs.repository.defs.key + "_methods";
classOptions_1.key = defs.repository.metadata.key + "_methods";
}

@@ -446,3 +443,3 @@ _h.label = 2;

case 8:
defs = remult3_1.getControllerDefs(self_1, undefined);
defs = remult3_1.getControllerRef(self_1, undefined);
_h.label = 9;

@@ -494,10 +491,3 @@ case 9:

}
exports.ServerMethod = ServerMethod;
function controllerAllowed(controller, context) {
var x = classOptions.get(controller.constructor);
if (x)
return context.isAllowed(x.allowed);
return undefined;
}
exports.controllerAllowed = controllerAllowed;
exports.BackendMethod = BackendMethod;
var customUndefined = {

@@ -509,12 +499,12 @@ _isUndefined: true

}
var ServerProgress = /** @class */ (function () {
function ServerProgress(res) {
var ProgressListener = /** @class */ (function () {
function ProgressListener(res) {
this.res = res;
}
ServerProgress.prototype.progress = function (progress) {
ProgressListener.prototype.progress = function (progress) {
this.res.progress(progress);
};
return ServerProgress;
return ProgressListener;
}());
exports.ServerProgress = ServerProgress;
exports.ProgressListener = ProgressListener;
function prepareArgsToSend(types, args) {

@@ -547,3 +537,3 @@ var e_3, _a;

if (eo != null) {
var rh = remult3_1.getEntityOf(args[index]);
var rh = remult3_1.getEntityRef(args[index]);
args[index] = rh.getId();

@@ -584,4 +574,4 @@ }

case 3:
if (!(types[i] == ServerProgress)) return [3 /*break*/, 4];
args[i] = new ServerProgress(res);
if (!(types[i] == ProgressListener)) return [3 /*break*/, 4];
args[i] = new ProgressListener(res);
return [3 /*break*/, 6];

@@ -588,0 +578,0 @@ case 4:

@@ -1,3 +0,3 @@

import { FieldDefinitions } from "./column-interfaces";
import { EntityDefinitions, EntityOrderBy, sortOf } from "./remult3";
import { FieldMetadata } from "./column-interfaces";
import { EntityMetadata, EntityOrderBy, SortSegments } from "./remult3";
export declare class Sort {

@@ -7,9 +7,9 @@ constructor(...segments: SortSegment[]);

reverse(): Sort;
static createSortOf<T>(entityDefs: EntityDefinitions<T>): sortOf<T>;
static translateOrderByToSort<T>(entityDefs: EntityDefinitions<T>, orderBy: EntityOrderBy<T>): Sort;
static createUniqueSort<T>(entityDefs: EntityDefinitions<T>, orderBy: EntityOrderBy<T>): Sort;
static createSortOf<T>(entityDefs: EntityMetadata<T>): SortSegments<T>;
static translateOrderByToSort<T>(entityDefs: EntityMetadata<T>, orderBy: EntityOrderBy<T>): Sort;
static createUniqueSort<T>(entityMetadata: EntityMetadata<T>, orderBy: EntityOrderBy<T>): Sort;
}
export interface SortSegment {
field: FieldDefinitions;
field: FieldMetadata;
isDescending?: boolean;
}

@@ -65,10 +65,10 @@ "use strict";

};
Sort.createUniqueSort = function (entityDefs, orderBy) {
Sort.createUniqueSort = function (entityMetadata, orderBy) {
var e_3, _a;
if (!orderBy)
orderBy = entityDefs.evilOriginalSettings.defaultOrderBy;
orderBy = entityMetadata.options.defaultOrderBy;
if (!orderBy)
orderBy = function (x) { return ({ field: entityDefs.idField }); };
var sort = Sort.translateOrderByToSort(entityDefs, orderBy);
if (entityDefs.idField instanceof column_1.CompoundIdField) {
orderBy = function (x) { return ({ field: entityMetadata.idMetadata.field }); };
var sort = Sort.translateOrderByToSort(entityMetadata, orderBy);
if (entityMetadata.idMetadata.field instanceof column_1.CompoundIdField) {
var _loop_1 = function (field) {

@@ -80,3 +80,3 @@ if (!sort.Segments.find(function (x) { return x.field == field; })) {

try {
for (var _b = tslib_1.__values(entityDefs.idField.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
for (var _b = tslib_1.__values(entityMetadata.idMetadata.field.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
var field = _c.value;

@@ -94,4 +94,4 @@ _loop_1(field);

}
else if (!sort.Segments.find(function (x) { return x.field == entityDefs.idField; })) {
sort.Segments.push({ field: entityDefs.idField });
else if (!sort.Segments.find(function (x) { return x.field == entityMetadata.idMetadata.field; })) {
sort.Segments.push({ field: entityMetadata.idMetadata.field });
}

@@ -98,0 +98,0 @@ return sort;

@@ -1,8 +0,8 @@

import { EntityDefinitions } from './remult3';
import { EntityMetadata } from './remult3';
export interface SqlImplementation {
insertAndReturnAutoIncrementId(command: SqlCommand, insertStatementString: string, entity: EntityDefinitions<any>): Promise<any>;
insertAndReturnAutoIncrementId(command: SqlCommand, insertStatementString: string, entity: EntityMetadata<any>): Promise<any>;
getLimitSqlSyntax(limit: number, offset: number): any;
createCommand(): SqlCommand;
transaction(action: (sql: SqlImplementation) => Promise<void>): Promise<void>;
entityIsUsedForTheFirstTime(entity: EntityDefinitions): Promise<void>;
entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
}

@@ -9,0 +9,0 @@ export interface SqlCommand {

@@ -1,9 +0,9 @@

import { EntityField } from "./remult3";
import { FieldRef } from "./remult3";
export declare class Validators {
static required: ((entity: any, col: EntityField<string, any>, message?: string) => void) & {
withMessage: (message: string) => (entity: any, col: EntityField<string, any>) => void;
static required: ((entity: any, col: FieldRef<string, any>, message?: string) => void) & {
withMessage: (message: string) => (entity: any, col: FieldRef<string, any>) => void;
};
static unique: ((entity: any, col: EntityField<any, any>, message?: string) => Promise<void>) & {
withMessage: (message: string) => (entity: any, col: EntityField<any, any>) => Promise<void>;
static unique: ((entity: any, col: FieldRef<any, any>, message?: string) => Promise<void>) & {
withMessage: (message: string) => (entity: any, col: FieldRef<any, any>) => Promise<void>;
};
}

@@ -23,6 +23,6 @@ "use strict";

case 0:
if (!col.rowHelper)
if (!col.entityRef)
throw "unique validation may only work on columns that are attached to an entity";
if (!(col.rowHelper.isNew() || col.wasChanged())) return [3 /*break*/, 2];
return [4 /*yield*/, col.rowHelper.repository.count(function (e) { return e[col.defs.key].isEqualTo(col.value); })];
if (!(col.entityRef.isNew() || col.wasChanged())) return [3 /*break*/, 2];
return [4 /*yield*/, col.entityRef.repository.count(function (e) { return e[col.metadata.key].isEqualTo(col.value); })];
case 1:

@@ -29,0 +29,0 @@ if (_a.sent())

@@ -0,3 +1,3 @@

import { ClassType } from "./classType";
import { ValueConverter, ValueListItem } from "./src/column-interfaces";
import { ClassType } from "./src/remult3";
export declare const DateValueConverter: ValueConverter<Date>;

@@ -4,0 +4,0 @@ export declare const DateOnlyValueConverter: ValueConverter<Date>;

@@ -5,4 +5,4 @@ "use strict";

var tslib_1 = require("tslib");
var inputTypes_1 = require("./inputTypes");
var column_1 = require("./src/column");
var remult3_1 = require("./src/remult3");
exports.DateValueConverter = {

@@ -53,3 +53,3 @@ toJson: function (val) {

},
inputType: remult3_1.InputTypes.date,
inputType: inputTypes_1.InputTypes.date,
toDb: function (val) {

@@ -86,3 +86,3 @@ if (!val)

toDb: function (val) { return val; },
inputType: remult3_1.InputTypes.checkbox,
inputType: inputTypes_1.InputTypes.checkbox,
fromDb: function (value) {

@@ -121,3 +121,3 @@ return exports.BoolValueConverter.fromJson(value);

},
inputType: remult3_1.InputTypes.number
inputType: inputTypes_1.InputTypes.number
};

@@ -124,0 +124,0 @@ exports.DecimalValueConverter = tslib_1.__assign(tslib_1.__assign({}, exports.IntValueConverter), { fieldTypeInDb: 'decimal' });

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 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 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 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 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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc