remult 0.16.3-exp.0 → 0.16.3-exp.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/src/context.d.ts +0 -3
- package/esm/src/context.js +3 -10
- package/esm/src/remult3/DecoratorReplacer.d.ts +10 -0
- package/esm/src/remult3/DecoratorReplacer.js +20 -0
- package/esm/src/remult3/RepositoryImplementation.d.ts +1 -5
- package/esm/src/remult3/RepositoryImplementation.js +1 -10
- package/esm/src/server-action.d.ts +1 -0
- package/esm/src/server-action.js +9 -9
- package/esm/src/shared-tests/test-custom-id-column.spec.js +4 -3
- package/index.d.ts +2 -1
- package/index.js +3 -2
- package/package.json +1 -1
- package/src/context.d.ts +0 -3
- package/src/context.js +10 -30
- package/src/remult3/DecoratorReplacer.d.ts +10 -0
- package/src/remult3/DecoratorReplacer.js +24 -0
- package/src/remult3/RepositoryImplementation.d.ts +1 -5
- package/src/remult3/RepositoryImplementation.js +2 -16
- package/src/server-action.d.ts +1 -0
- package/src/server-action.js +8 -8
- package/src/shared-tests/test-custom-id-column.spec.js +3 -2
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { Field, Fields, StringFieldOptions, FieldsMetadata, Entity,
|
|
1
|
+
export { Field, Fields, StringFieldOptions, FieldsMetadata, Entity, EntityBase, ControllerBase, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FieldType, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, getFields, EntityRef, getEntityRef, SortSegments, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, OmitEB, Paginator, CaptionTransformer } from './src/remult3';
|
|
2
|
+
export { describeClass } from './src/remult3/DecoratorReplacer';
|
|
2
3
|
export { EntityOptions } from './src/entity';
|
|
3
4
|
export { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo, RestDataProviderHttpProvider } from './src/data-interfaces';
|
|
4
5
|
export { SqlCommand, SqlImplementation, SqlResult } from './src/sql-command';
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Public API Surface of remult
|
|
3
3
|
*/
|
|
4
|
-
export { Field, Fields, Entity,
|
|
4
|
+
export { Field, Fields, Entity, EntityBase, ControllerBase, FieldType, getFields, getEntityRef, ValueListFieldType, getValueList, ValueListInfo, CaptionTransformer } from './src/remult3';
|
|
5
|
+
export { describeClass } from './src/remult3/DecoratorReplacer';
|
|
5
6
|
export { RestDataProvider } from './src/data-providers/rest-data-provider'; //V
|
|
6
7
|
export { InMemoryDataProvider } from './src/data-providers/in-memory-database'; //V
|
|
7
8
|
export { ArrayEntityDataProvider } from './src/data-providers/array-entity-data-provider'; //V
|
package/esm/src/context.d.ts
CHANGED
|
@@ -85,9 +85,6 @@ export interface ControllerOptions {
|
|
|
85
85
|
}
|
|
86
86
|
export declare const classHelpers: Map<any, ClassHelper>;
|
|
87
87
|
export declare class ClassHelper {
|
|
88
|
-
methods: MethodHelper[];
|
|
89
|
-
}
|
|
90
|
-
export declare class MethodHelper {
|
|
91
88
|
classes: Map<any, ControllerOptions>;
|
|
92
89
|
}
|
|
93
90
|
export declare function buildRestDataProvider(provider: ExternalHttpProvider | typeof fetch): RestDataProviderHttpProvider | RestDataProviderHttpProviderUsingFetch;
|
package/esm/src/context.js
CHANGED
|
@@ -206,11 +206,6 @@ Remult.onFind = (metadata, options) => { };
|
|
|
206
206
|
export const allEntities = [];
|
|
207
207
|
export const classHelpers = new Map();
|
|
208
208
|
export class ClassHelper {
|
|
209
|
-
constructor() {
|
|
210
|
-
this.methods = [];
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
export class MethodHelper {
|
|
214
209
|
constructor() {
|
|
215
210
|
this.classes = new Map();
|
|
216
211
|
}
|
|
@@ -241,11 +236,9 @@ export function setControllerSettings(target, options) {
|
|
|
241
236
|
let r = target;
|
|
242
237
|
while (true) {
|
|
243
238
|
let helper = classHelpers.get(r);
|
|
244
|
-
if (helper)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
}
|
|
239
|
+
if (!helper)
|
|
240
|
+
classHelpers.set(r, helper = new ClassHelper());
|
|
241
|
+
helper.classes.set(target, options);
|
|
249
242
|
let p = Object.getPrototypeOf(r.prototype);
|
|
250
243
|
if (p == null)
|
|
251
244
|
break;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OmitEB } from "./remult3";
|
|
2
|
+
declare type Decorator<T = any> = (a: T, b: string, c?: any) => void;
|
|
3
|
+
declare type Decorators<T> = T extends new (...args: any[]) => infer R ? {
|
|
4
|
+
[K in keyof OmitEB<R>]?: Decorator;
|
|
5
|
+
} : never;
|
|
6
|
+
declare type StaticDecorators<T> = {
|
|
7
|
+
[K in keyof T]?: Decorator;
|
|
8
|
+
};
|
|
9
|
+
export declare function describeClass<classType>(classType: classType, classDecorator: ((x: any) => any) | undefined, members?: Decorators<classType> | undefined, staticMembers?: StaticDecorators<classType>): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function describeClass(classType, classDecorator, members, staticMembers) {
|
|
2
|
+
if (classDecorator)
|
|
3
|
+
classDecorator(classType);
|
|
4
|
+
for (const fieldKey in members) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(members, fieldKey)) {
|
|
6
|
+
const element = members[fieldKey];
|
|
7
|
+
const prop = Object.getOwnPropertyDescriptor(classType.prototype, fieldKey);
|
|
8
|
+
element(classType.prototype, fieldKey, prop);
|
|
9
|
+
if (prop)
|
|
10
|
+
Object.defineProperty(classType.prototype, fieldKey, prop);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
for (const staticFieldKey in staticMembers) {
|
|
14
|
+
const staticElement = staticMembers[staticFieldKey];
|
|
15
|
+
const prop = Object.getOwnPropertyDescriptor(classType, staticFieldKey);
|
|
16
|
+
staticElement(classType, staticFieldKey, prop);
|
|
17
|
+
if (prop)
|
|
18
|
+
Object.defineProperty(classType, staticFieldKey, prop);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -271,10 +271,6 @@ interface columnInfo {
|
|
|
271
271
|
key: string;
|
|
272
272
|
settings: (remult: Remult) => FieldOptions;
|
|
273
273
|
}
|
|
274
|
-
export declare type BuildEntityFields<entityType> = {
|
|
275
|
-
[Properties in keyof Partial<OmitEB<entityType>>]: any;
|
|
276
|
-
};
|
|
277
|
-
export declare function BuildEntity<entityType>(c: ClassType<entityType>, key: string, fields: BuildEntityFields<entityType>, ...options: (EntityOptions<entityType> | ((options: EntityOptions<entityType>, remult: Remult) => void))[]): void;
|
|
278
274
|
/**Decorates classes that should be used as entities.
|
|
279
275
|
* Receives a key and an array of EntityOptions.
|
|
280
276
|
* @example
|
|
@@ -309,7 +305,7 @@ export declare class EntityBase {
|
|
|
309
305
|
get $(): FieldsRef<this>;
|
|
310
306
|
}
|
|
311
307
|
export declare class ControllerBase {
|
|
312
|
-
protected remult
|
|
308
|
+
protected remult: Remult;
|
|
313
309
|
constructor(remult?: Remult);
|
|
314
310
|
assign(values: Partial<Omit<this, keyof EntityBase>>): this;
|
|
315
311
|
get $(): FieldsRef<this>;
|
|
@@ -1578,15 +1578,6 @@ export function decorateColumnSettings(settings, remult) {
|
|
|
1578
1578
|
}
|
|
1579
1579
|
return settings;
|
|
1580
1580
|
}
|
|
1581
|
-
export function BuildEntity(c, key, fields, ...options) {
|
|
1582
|
-
Entity(key, ...options)(c);
|
|
1583
|
-
for (const fieldKey in fields) {
|
|
1584
|
-
if (Object.prototype.hasOwnProperty.call(fields, fieldKey)) {
|
|
1585
|
-
const element = fields[fieldKey];
|
|
1586
|
-
element(c.prototype, fieldKey);
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
1581
|
/**Decorates classes that should be used as entities.
|
|
1591
1582
|
* Receives a key and an array of EntityOptions.
|
|
1592
1583
|
* @example
|
|
@@ -1667,7 +1658,7 @@ export class EntityBase {
|
|
|
1667
1658
|
}
|
|
1668
1659
|
export class ControllerBase {
|
|
1669
1660
|
constructor(remult) {
|
|
1670
|
-
this.remult = remult;
|
|
1661
|
+
this.remult = remult || RepositoryImplementation.defaultRemult;
|
|
1671
1662
|
}
|
|
1672
1663
|
assign(values) {
|
|
1673
1664
|
assign(this, values);
|
|
@@ -33,6 +33,7 @@ export interface BackendMethodOptions<type> {
|
|
|
33
33
|
queue?: boolean;
|
|
34
34
|
/** EXPERIMENTAL: Determines if the user should be blocked while this `BackendMethod` is running*/
|
|
35
35
|
blockUser?: boolean;
|
|
36
|
+
paramTypes?: any[];
|
|
36
37
|
}
|
|
37
38
|
export declare const actionInfo: {
|
|
38
39
|
allActions: any[];
|
package/esm/src/server-action.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { Remult, allEntities, classHelpers, ClassHelper,
|
|
2
|
+
import { Remult, allEntities, classHelpers, ClassHelper, setControllerSettings, buildRestDataProvider } from './context';
|
|
3
3
|
import { SqlDatabase } from './data-providers/sql-database';
|
|
4
4
|
import { getEntityRef, decorateColumnSettings, getEntitySettings, getControllerRef, RepositoryImplementation } from './remult3';
|
|
5
5
|
export class Action {
|
|
@@ -100,7 +100,6 @@ export const actionInfo = {
|
|
|
100
100
|
})
|
|
101
101
|
};
|
|
102
102
|
export const serverActionField = Symbol('serverActionField');
|
|
103
|
-
const methodHelpers = new Map();
|
|
104
103
|
const classOptions = new Map();
|
|
105
104
|
export function Controller(key) {
|
|
106
105
|
return function (target) {
|
|
@@ -116,6 +115,8 @@ export function BackendMethod(options) {
|
|
|
116
115
|
if (target.prototype !== undefined) {
|
|
117
116
|
var originalMethod = descriptor.value;
|
|
118
117
|
var types = Reflect.getMetadata("design:paramtypes", target, key);
|
|
118
|
+
if (options.paramTypes)
|
|
119
|
+
types = options.paramTypes;
|
|
119
120
|
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
|
|
120
121
|
let serverAction = new myServerAction(key, types, options, args => originalMethod.apply(undefined, args));
|
|
121
122
|
serverAction.doWork = async (args, self, url, http) => {
|
|
@@ -138,20 +139,19 @@ export function BackendMethod(options) {
|
|
|
138
139
|
return descriptor;
|
|
139
140
|
}
|
|
140
141
|
var types = Reflect.getMetadata("design:paramtypes", target, key);
|
|
142
|
+
if (options.paramTypes)
|
|
143
|
+
types = options.paramTypes;
|
|
141
144
|
let x = classHelpers.get(target.constructor);
|
|
142
145
|
if (!x) {
|
|
143
146
|
x = new ClassHelper();
|
|
144
147
|
classHelpers.set(target.constructor, x);
|
|
145
148
|
}
|
|
146
|
-
let mh = new MethodHelper();
|
|
147
|
-
methodHelpers.set(descriptor, mh);
|
|
148
|
-
x.methods.push(mh);
|
|
149
149
|
var originalMethod = descriptor.value;
|
|
150
150
|
let serverAction = {
|
|
151
151
|
__register(reg) {
|
|
152
152
|
let c = new Remult();
|
|
153
|
-
for (const constructor of
|
|
154
|
-
let controllerOptions =
|
|
153
|
+
for (const constructor of x.classes.keys()) {
|
|
154
|
+
let controllerOptions = x.classes.get(constructor);
|
|
155
155
|
if (!controllerOptions.key) {
|
|
156
156
|
controllerOptions.key = c.repo(constructor).metadata.key;
|
|
157
157
|
}
|
|
@@ -238,7 +238,7 @@ export function BackendMethod(options) {
|
|
|
238
238
|
if (allEntities.includes(target.constructor)) {
|
|
239
239
|
let defs = getEntityRef(self);
|
|
240
240
|
await defs.__validateEntity();
|
|
241
|
-
let classOptions =
|
|
241
|
+
let classOptions = x.classes.get(self.constructor);
|
|
242
242
|
if (!classOptions.key) {
|
|
243
243
|
classOptions.key = defs.repository.metadata.key + "_methods";
|
|
244
244
|
}
|
|
@@ -265,7 +265,7 @@ export function BackendMethod(options) {
|
|
|
265
265
|
try {
|
|
266
266
|
await defs.__validateEntity();
|
|
267
267
|
let r = await (new class extends Action {
|
|
268
|
-
}(
|
|
268
|
+
}(x.classes.get(self.constructor).key + "/" + key, options ? options.queue : false, options.allowed).run({
|
|
269
269
|
args,
|
|
270
270
|
fields: await defs.toApiJson()
|
|
271
271
|
}, baseUrl, http));
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Entity, EntityBase,
|
|
1
|
+
import { Entity, EntityBase, Fields } from '../remult3';
|
|
2
|
+
import { describeClass } from '../remult3/DecoratorReplacer';
|
|
2
3
|
import { testAll } from './db-tests-setup';
|
|
3
4
|
describe("custom id column", () => {
|
|
4
5
|
testAll("basic test", async ({ createEntity }) => {
|
|
5
6
|
let type = class extends EntityBase {
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
describeClass(type, Entity('custom', { allowApiCrud: true }), {
|
|
8
9
|
a: Fields.number(),
|
|
9
10
|
b: Fields.number()
|
|
10
|
-
}
|
|
11
|
+
});
|
|
11
12
|
let c = await createEntity(type);
|
|
12
13
|
let r = c.create();
|
|
13
14
|
r.a = 1;
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { Field, Fields, StringFieldOptions, FieldsMetadata, Entity,
|
|
1
|
+
export { Field, Fields, StringFieldOptions, FieldsMetadata, Entity, EntityBase, ControllerBase, FieldRef, IdFieldRef, FieldsRef, EntityMetadata, EntityOrderBy, EntityFilter, FindOptions, QueryResult, QueryOptions, Repository, FieldType, FindFirstOptions, ComparisonValueFilter, ValueFilter, IdFilter, ContainsStringValueFilter, getFields, EntityRef, getEntityRef, SortSegments, ValueListFieldType, getValueList, ValueListFieldOptions, ValueListInfo, OmitEB, Paginator, CaptionTransformer } from './src/remult3';
|
|
2
|
+
export { describeClass } from './src/remult3/DecoratorReplacer';
|
|
2
3
|
export { EntityOptions } from './src/entity';
|
|
3
4
|
export { DataProvider, EntityDataProvider, EntityDataProviderFindOptions, ErrorInfo, RestDataProviderHttpProvider } from './src/data-interfaces';
|
|
4
5
|
export { SqlCommand, SqlImplementation, SqlResult } from './src/sql-command';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.remult = exports.ValueConverters = exports.Validators = exports.UrlBuilder = exports.FilterConsumerBridgeToSqlRequest = exports.Filter = exports.CompoundIdField = exports.OneToMany = exports.Sort = exports.IdEntity = exports.EventSource = exports.isBackend = exports.Remult = exports.Allow = exports.ProgressListener = exports.BackendMethod = exports.Controller = exports.JsonDataProvider = exports.CustomSqlFilterBuilder = exports.SqlDatabase = exports.WebSqlDataProvider = exports.ArrayEntityDataProvider = exports.InMemoryDataProvider = exports.RestDataProvider = exports.CaptionTransformer = exports.ValueListInfo = exports.getValueList = exports.ValueListFieldType = exports.getEntityRef = exports.getFields = exports.FieldType = exports.ControllerBase = exports.EntityBase = exports.
|
|
3
|
+
exports.remult = exports.ValueConverters = exports.Validators = exports.UrlBuilder = exports.FilterConsumerBridgeToSqlRequest = exports.Filter = exports.CompoundIdField = exports.OneToMany = exports.Sort = exports.IdEntity = exports.EventSource = exports.isBackend = exports.Remult = exports.Allow = exports.ProgressListener = exports.BackendMethod = exports.Controller = exports.JsonDataProvider = exports.CustomSqlFilterBuilder = exports.SqlDatabase = exports.WebSqlDataProvider = exports.ArrayEntityDataProvider = exports.InMemoryDataProvider = exports.RestDataProvider = exports.describeClass = exports.CaptionTransformer = exports.ValueListInfo = exports.getValueList = exports.ValueListFieldType = exports.getEntityRef = exports.getFields = exports.FieldType = exports.ControllerBase = exports.EntityBase = exports.Entity = exports.Fields = exports.Field = void 0;
|
|
4
4
|
/*
|
|
5
5
|
* Public API Surface of remult
|
|
6
6
|
*/
|
|
@@ -8,7 +8,6 @@ var remult3_1 = require("./src/remult3");
|
|
|
8
8
|
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return remult3_1.Field; } });
|
|
9
9
|
Object.defineProperty(exports, "Fields", { enumerable: true, get: function () { return remult3_1.Fields; } });
|
|
10
10
|
Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return remult3_1.Entity; } });
|
|
11
|
-
Object.defineProperty(exports, "BuildEntity", { enumerable: true, get: function () { return remult3_1.BuildEntity; } });
|
|
12
11
|
Object.defineProperty(exports, "EntityBase", { enumerable: true, get: function () { return remult3_1.EntityBase; } });
|
|
13
12
|
Object.defineProperty(exports, "ControllerBase", { enumerable: true, get: function () { return remult3_1.ControllerBase; } });
|
|
14
13
|
Object.defineProperty(exports, "FieldType", { enumerable: true, get: function () { return remult3_1.FieldType; } });
|
|
@@ -18,6 +17,8 @@ Object.defineProperty(exports, "ValueListFieldType", { enumerable: true, get: fu
|
|
|
18
17
|
Object.defineProperty(exports, "getValueList", { enumerable: true, get: function () { return remult3_1.getValueList; } });
|
|
19
18
|
Object.defineProperty(exports, "ValueListInfo", { enumerable: true, get: function () { return remult3_1.ValueListInfo; } });
|
|
20
19
|
Object.defineProperty(exports, "CaptionTransformer", { enumerable: true, get: function () { return remult3_1.CaptionTransformer; } });
|
|
20
|
+
var DecoratorReplacer_1 = require("./src/remult3/DecoratorReplacer");
|
|
21
|
+
Object.defineProperty(exports, "describeClass", { enumerable: true, get: function () { return DecoratorReplacer_1.describeClass; } });
|
|
21
22
|
var rest_data_provider_1 = require("./src/data-providers/rest-data-provider"); //V
|
|
22
23
|
Object.defineProperty(exports, "RestDataProvider", { enumerable: true, get: function () { return rest_data_provider_1.RestDataProvider; } });
|
|
23
24
|
var in_memory_database_1 = require("./src/data-providers/in-memory-database"); //V
|
package/package.json
CHANGED
package/src/context.d.ts
CHANGED
|
@@ -85,9 +85,6 @@ export interface ControllerOptions {
|
|
|
85
85
|
}
|
|
86
86
|
export declare const classHelpers: Map<any, ClassHelper>;
|
|
87
87
|
export declare class ClassHelper {
|
|
88
|
-
methods: MethodHelper[];
|
|
89
|
-
}
|
|
90
|
-
export declare class MethodHelper {
|
|
91
88
|
classes: Map<any, ControllerOptions>;
|
|
92
89
|
}
|
|
93
90
|
export declare function buildRestDataProvider(provider: ExternalHttpProvider | typeof fetch): RestDataProviderHttpProvider | RestDataProviderHttpProviderUsingFetch;
|
package/src/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventSource = exports.queryConfig = exports.Allow = exports.setControllerSettings = exports.buildRestDataProvider = exports.
|
|
3
|
+
exports.EventSource = exports.queryConfig = exports.Allow = exports.setControllerSettings = exports.buildRestDataProvider = exports.ClassHelper = exports.classHelpers = exports.allEntities = exports.Remult = exports.isBackend = exports.processHttpException = exports.toPromise = exports.retry = exports.HttpProviderBridgeToRestDataProviderHttpProvider = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var server_action_1 = require("./server-action");
|
|
6
6
|
var rest_data_provider_1 = require("./data-providers/rest-data-provider");
|
|
@@ -290,18 +290,11 @@ exports.allEntities = [];
|
|
|
290
290
|
exports.classHelpers = new Map();
|
|
291
291
|
var ClassHelper = /** @class */ (function () {
|
|
292
292
|
function ClassHelper() {
|
|
293
|
-
this.
|
|
293
|
+
this.classes = new Map();
|
|
294
294
|
}
|
|
295
295
|
return ClassHelper;
|
|
296
296
|
}());
|
|
297
297
|
exports.ClassHelper = ClassHelper;
|
|
298
|
-
var MethodHelper = /** @class */ (function () {
|
|
299
|
-
function MethodHelper() {
|
|
300
|
-
this.classes = new Map();
|
|
301
|
-
}
|
|
302
|
-
return MethodHelper;
|
|
303
|
-
}());
|
|
304
|
-
exports.MethodHelper = MethodHelper;
|
|
305
298
|
function isExternalHttpProvider(item) {
|
|
306
299
|
var http = item;
|
|
307
300
|
if (http && http.get && http.put && http.post && http.delete)
|
|
@@ -326,25 +319,12 @@ function buildRestDataProvider(provider) {
|
|
|
326
319
|
}
|
|
327
320
|
exports.buildRestDataProvider = buildRestDataProvider;
|
|
328
321
|
function setControllerSettings(target, options) {
|
|
329
|
-
var e_3, _a;
|
|
330
322
|
var r = target;
|
|
331
323
|
while (true) {
|
|
332
324
|
var helper = exports.classHelpers.get(r);
|
|
333
|
-
if (helper)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
var m = _c.value;
|
|
337
|
-
m.classes.set(target, options);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
341
|
-
finally {
|
|
342
|
-
try {
|
|
343
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
344
|
-
}
|
|
345
|
-
finally { if (e_3) throw e_3.error; }
|
|
346
|
-
}
|
|
347
|
-
}
|
|
325
|
+
if (!helper)
|
|
326
|
+
exports.classHelpers.set(r, helper = new ClassHelper());
|
|
327
|
+
helper.classes.set(target, options);
|
|
348
328
|
var p = Object.getPrototypeOf(r.prototype);
|
|
349
329
|
if (p == null)
|
|
350
330
|
break;
|
|
@@ -387,8 +367,8 @@ var EventSource = /** @class */ (function () {
|
|
|
387
367
|
}
|
|
388
368
|
EventSource.prototype.fire = function () {
|
|
389
369
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
390
|
-
var _a, _b, l,
|
|
391
|
-
var
|
|
370
|
+
var _a, _b, l, e_3_1;
|
|
371
|
+
var e_3, _c;
|
|
392
372
|
return tslib_1.__generator(this, function (_d) {
|
|
393
373
|
switch (_d.label) {
|
|
394
374
|
case 0:
|
|
@@ -407,14 +387,14 @@ var EventSource = /** @class */ (function () {
|
|
|
407
387
|
return [3 /*break*/, 1];
|
|
408
388
|
case 4: return [3 /*break*/, 7];
|
|
409
389
|
case 5:
|
|
410
|
-
|
|
411
|
-
|
|
390
|
+
e_3_1 = _d.sent();
|
|
391
|
+
e_3 = { error: e_3_1 };
|
|
412
392
|
return [3 /*break*/, 7];
|
|
413
393
|
case 6:
|
|
414
394
|
try {
|
|
415
395
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
416
396
|
}
|
|
417
|
-
finally { if (
|
|
397
|
+
finally { if (e_3) throw e_3.error; }
|
|
418
398
|
return [7 /*endfinally*/];
|
|
419
399
|
case 7: return [2 /*return*/];
|
|
420
400
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OmitEB } from "./remult3";
|
|
2
|
+
declare type Decorator<T = any> = (a: T, b: string, c?: any) => void;
|
|
3
|
+
declare type Decorators<T> = T extends new (...args: any[]) => infer R ? {
|
|
4
|
+
[K in keyof OmitEB<R>]?: Decorator;
|
|
5
|
+
} : never;
|
|
6
|
+
declare type StaticDecorators<T> = {
|
|
7
|
+
[K in keyof T]?: Decorator;
|
|
8
|
+
};
|
|
9
|
+
export declare function describeClass<classType>(classType: classType, classDecorator: ((x: any) => any) | undefined, members?: Decorators<classType> | undefined, staticMembers?: StaticDecorators<classType>): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeClass = void 0;
|
|
4
|
+
function describeClass(classType, classDecorator, members, staticMembers) {
|
|
5
|
+
if (classDecorator)
|
|
6
|
+
classDecorator(classType);
|
|
7
|
+
for (var fieldKey in members) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(members, fieldKey)) {
|
|
9
|
+
var element = members[fieldKey];
|
|
10
|
+
var prop = Object.getOwnPropertyDescriptor(classType.prototype, fieldKey);
|
|
11
|
+
element(classType.prototype, fieldKey, prop);
|
|
12
|
+
if (prop)
|
|
13
|
+
Object.defineProperty(classType.prototype, fieldKey, prop);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
for (var staticFieldKey in staticMembers) {
|
|
17
|
+
var staticElement = staticMembers[staticFieldKey];
|
|
18
|
+
var prop = Object.getOwnPropertyDescriptor(classType, staticFieldKey);
|
|
19
|
+
staticElement(classType, staticFieldKey, prop);
|
|
20
|
+
if (prop)
|
|
21
|
+
Object.defineProperty(classType, staticFieldKey, prop);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.describeClass = describeClass;
|
|
@@ -271,10 +271,6 @@ interface columnInfo {
|
|
|
271
271
|
key: string;
|
|
272
272
|
settings: (remult: Remult) => FieldOptions;
|
|
273
273
|
}
|
|
274
|
-
export declare type BuildEntityFields<entityType> = {
|
|
275
|
-
[Properties in keyof Partial<OmitEB<entityType>>]: any;
|
|
276
|
-
};
|
|
277
|
-
export declare function BuildEntity<entityType>(c: ClassType<entityType>, key: string, fields: BuildEntityFields<entityType>, ...options: (EntityOptions<entityType> | ((options: EntityOptions<entityType>, remult: Remult) => void))[]): void;
|
|
278
274
|
/**Decorates classes that should be used as entities.
|
|
279
275
|
* Receives a key and an array of EntityOptions.
|
|
280
276
|
* @example
|
|
@@ -309,7 +305,7 @@ export declare class EntityBase {
|
|
|
309
305
|
get $(): FieldsRef<this>;
|
|
310
306
|
}
|
|
311
307
|
export declare class ControllerBase {
|
|
312
|
-
protected remult
|
|
308
|
+
protected remult: Remult;
|
|
313
309
|
constructor(remult?: Remult);
|
|
314
310
|
assign(values: Partial<Omit<this, keyof EntityBase>>): this;
|
|
315
311
|
get $(): FieldsRef<this>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ControllerBase = exports.EntityBase = exports.Entity = exports.
|
|
3
|
+
exports.ControllerBase = exports.EntityBase = exports.Entity = exports.decorateColumnSettings = exports.storableMember = exports.Field = exports.getValueList = exports.ValueListInfo = exports.ValueListFieldType = exports.isAutoIncrement = exports.Fields = exports.FieldType = exports.columnDefsImpl = exports.buildCaption = exports.CaptionTransformer = exports.getEntityRef = exports.FieldRefImplementation = exports.controllerRefImpl = exports.getControllerRef = exports.getFields = exports.rowHelperImplementation = exports.createOldEntity = exports.columnsOfType = exports.getEntityKey = exports.getEntitySettings = exports.entityInfo_key = exports.entityInfo = exports.__updateEntityBasedOnWhere = exports.RepositoryImplementation = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var column_1 = require("../column");
|
|
6
6
|
var context_1 = require("../context");
|
|
@@ -2618,20 +2618,6 @@ function decorateColumnSettings(settings, remult) {
|
|
|
2618
2618
|
return settings;
|
|
2619
2619
|
}
|
|
2620
2620
|
exports.decorateColumnSettings = decorateColumnSettings;
|
|
2621
|
-
function BuildEntity(c, key, fields) {
|
|
2622
|
-
var options = [];
|
|
2623
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
2624
|
-
options[_i - 3] = arguments[_i];
|
|
2625
|
-
}
|
|
2626
|
-
Entity.apply(void 0, tslib_1.__spread([key], options))(c);
|
|
2627
|
-
for (var fieldKey in fields) {
|
|
2628
|
-
if (Object.prototype.hasOwnProperty.call(fields, fieldKey)) {
|
|
2629
|
-
var element = fields[fieldKey];
|
|
2630
|
-
element(c.prototype, fieldKey);
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
exports.BuildEntity = BuildEntity;
|
|
2635
2621
|
/**Decorates classes that should be used as entities.
|
|
2636
2622
|
* Receives a key and an array of EntityOptions.
|
|
2637
2623
|
* @example
|
|
@@ -2738,7 +2724,7 @@ var EntityBase = /** @class */ (function () {
|
|
|
2738
2724
|
exports.EntityBase = EntityBase;
|
|
2739
2725
|
var ControllerBase = /** @class */ (function () {
|
|
2740
2726
|
function ControllerBase(remult) {
|
|
2741
|
-
this.remult = remult;
|
|
2727
|
+
this.remult = remult || RepositoryImplementation.defaultRemult;
|
|
2742
2728
|
}
|
|
2743
2729
|
ControllerBase.prototype.assign = function (values) {
|
|
2744
2730
|
assign_1.assign(this, values);
|
package/src/server-action.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export interface BackendMethodOptions<type> {
|
|
|
33
33
|
queue?: boolean;
|
|
34
34
|
/** EXPERIMENTAL: Determines if the user should be blocked while this `BackendMethod` is running*/
|
|
35
35
|
blockUser?: boolean;
|
|
36
|
+
paramTypes?: any[];
|
|
36
37
|
}
|
|
37
38
|
export declare const actionInfo: {
|
|
38
39
|
allActions: any[];
|
package/src/server-action.js
CHANGED
|
@@ -174,7 +174,6 @@ exports.actionInfo = {
|
|
|
174
174
|
}); }
|
|
175
175
|
};
|
|
176
176
|
exports.serverActionField = Symbol('serverActionField');
|
|
177
|
-
var methodHelpers = new Map();
|
|
178
177
|
var classOptions = new Map();
|
|
179
178
|
function Controller(key) {
|
|
180
179
|
return function (target) {
|
|
@@ -192,6 +191,8 @@ function BackendMethod(options) {
|
|
|
192
191
|
if (target.prototype !== undefined) {
|
|
193
192
|
var originalMethod = descriptor.value;
|
|
194
193
|
var types = Reflect.getMetadata("design:paramtypes", target, key);
|
|
194
|
+
if (options.paramTypes)
|
|
195
|
+
types = options.paramTypes;
|
|
195
196
|
// if types are undefined - you've forgot to set: "emitDecoratorMetadata":true
|
|
196
197
|
var serverAction_1 = new myServerAction(key, types, options, function (args) { return originalMethod.apply(undefined, args); });
|
|
197
198
|
serverAction_1.doWork = function (args, self, url, http) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
@@ -236,14 +237,13 @@ function BackendMethod(options) {
|
|
|
236
237
|
return descriptor;
|
|
237
238
|
}
|
|
238
239
|
var types = Reflect.getMetadata("design:paramtypes", target, key);
|
|
240
|
+
if (options.paramTypes)
|
|
241
|
+
types = options.paramTypes;
|
|
239
242
|
var x = context_1.classHelpers.get(target.constructor);
|
|
240
243
|
if (!x) {
|
|
241
244
|
x = new context_1.ClassHelper();
|
|
242
245
|
context_1.classHelpers.set(target.constructor, x);
|
|
243
246
|
}
|
|
244
|
-
var mh = new context_1.MethodHelper();
|
|
245
|
-
methodHelpers.set(descriptor, mh);
|
|
246
|
-
x.methods.push(mh);
|
|
247
247
|
var originalMethod = descriptor.value;
|
|
248
248
|
var serverAction = {
|
|
249
249
|
__register: function (reg) {
|
|
@@ -251,7 +251,7 @@ function BackendMethod(options) {
|
|
|
251
251
|
var _this = this;
|
|
252
252
|
var c = new context_1.Remult();
|
|
253
253
|
var _loop_1 = function (constructor) {
|
|
254
|
-
var controllerOptions =
|
|
254
|
+
var controllerOptions = x.classes.get(constructor);
|
|
255
255
|
if (!controllerOptions.key) {
|
|
256
256
|
controllerOptions.key = c.repo(constructor).metadata.key;
|
|
257
257
|
}
|
|
@@ -376,7 +376,7 @@ function BackendMethod(options) {
|
|
|
376
376
|
}); });
|
|
377
377
|
};
|
|
378
378
|
try {
|
|
379
|
-
for (var _b = tslib_1.__values(
|
|
379
|
+
for (var _b = tslib_1.__values(x.classes.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
380
380
|
var constructor = _c.value;
|
|
381
381
|
_loop_1(constructor);
|
|
382
382
|
}
|
|
@@ -402,7 +402,7 @@ function BackendMethod(options) {
|
|
|
402
402
|
return [4 /*yield*/, defs.__validateEntity()];
|
|
403
403
|
case 1:
|
|
404
404
|
_h.sent();
|
|
405
|
-
classOptions_1 =
|
|
405
|
+
classOptions_1 = x.classes.get(self.constructor);
|
|
406
406
|
if (!classOptions_1.key) {
|
|
407
407
|
classOptions_1.key = defs.repository.metadata.key + "_methods";
|
|
408
408
|
}
|
|
@@ -451,7 +451,7 @@ function BackendMethod(options) {
|
|
|
451
451
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
452
452
|
}
|
|
453
453
|
return class_2;
|
|
454
|
-
}(Action))(
|
|
454
|
+
}(Action))(x.classes.get(self.constructor).key + "/" + key, options ? options.queue : false, options.allowed)).run;
|
|
455
455
|
_g = {
|
|
456
456
|
args: args
|
|
457
457
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var remult3_1 = require("../remult3");
|
|
5
|
+
var DecoratorReplacer_1 = require("../remult3/DecoratorReplacer");
|
|
5
6
|
var db_tests_setup_1 = require("./db-tests-setup");
|
|
6
7
|
describe("custom id column", function () {
|
|
7
8
|
db_tests_setup_1.testAll("basic test", function (_a) {
|
|
@@ -18,10 +19,10 @@ describe("custom id column", function () {
|
|
|
18
19
|
}
|
|
19
20
|
return class_1;
|
|
20
21
|
}(remult3_1.EntityBase));
|
|
21
|
-
|
|
22
|
+
DecoratorReplacer_1.describeClass(type, remult3_1.Entity('custom', { allowApiCrud: true }), {
|
|
22
23
|
a: remult3_1.Fields.number(),
|
|
23
24
|
b: remult3_1.Fields.number()
|
|
24
|
-
}
|
|
25
|
+
});
|
|
25
26
|
return [4 /*yield*/, createEntity(type)];
|
|
26
27
|
case 1:
|
|
27
28
|
c = _b.sent();
|