remult 0.16.2 → 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/README.md CHANGED
@@ -3,51 +3,71 @@
3
3
  <img src="https://github.com/remult/remult/raw/master/docs/.vuepress/public/logo.png" width="140" height="140">
4
4
  </a>
5
5
  <h1>Remult</h1>
6
- <a href="https://circleci.com/gh/remult/remult/tree/master">
6
+ <a href="https://circleci.com/gh/remult/remult/tree/master" rel="nofollow">
7
7
  <img alt="CircleCI" src="https://circleci.com/gh/remult/remult/tree/master.svg?style=shield">
8
8
  </a>
9
- <a href="https://codecov.io/gh/remult/remult">
9
+ <a href="https://codecov.io/gh/remult/remult" rel="nofollow">
10
10
  <img src="https://codecov.io/gh/remult/remult/branch/master/graph/badge.svg?token=LYWQRUN3D1"/>
11
11
  </a>
12
- <a href="https://raw.githubusercontent.com/remult/remult/master/LICENSE">
12
+ <a href="https://raw.githubusercontent.com/remult/remult/master/LICENSE" rel="nofollow">
13
13
  <img alt="GitHub license" src="https://img.shields.io/badge/license-MIT-blue.svg">
14
14
  </a>
15
- <a href="https://www.npmjs.com/package/remult">
15
+ <a href="https://www.npmjs.com/package/remult" rel="nofollow">
16
16
  <img alt="npm version" src="https://badge.fury.io/js/remult.svg">
17
17
  </a>
18
- <a href="https://www.npmjs.com/package/remult">
18
+ <a href="https://www.npmjs.com/package/remult" rel="nofollow">
19
19
  <img alt="npm downloads" src="https://img.shields.io/npm/dm/remult">
20
20
  </a>
21
- <a href="https://discord.gg/GXHk7ZfuG5">
22
- <img alt="chat on discord" src="https://img.shields.io/badge/chat-on%20discord-blueviolet"/>
21
+ <a href="https://discord.gg/GXHk7ZfuG5" rel="nofollow">
22
+ <img alt="Join Discord" src="https://badgen.net/discord/online-members/GXHk7ZfuG5?icon=discord&label=Discord"/>
23
23
  </a>
24
- <a href="https://twitter.com/remultjs">
25
- <img alt="Twitter Follow" src="https://img.shields.io/twitter/follow/remultjs?style=social">
24
+ <a href="https://twitter.com/intent/tweet?text=Remult%20-%20open-source%20CRUD%20framework%20for%20full-stack%20TypeScript%0A%0A%40remultjs%0A&url=https%3A%2F%2Fgithub.com%2Fremult%2Fremult">
25
+ <img alt="Twitter URL" src="https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fintent%2Ftweet%3Ftext%3DRemult%2520-%2520open-source%2520CRUD%2520framework%2520for%2520full-stack%2520TypeScript%250A%250A%2540remultjs%250A%26url%3Dhttps%253A%252F%252Fgithub.com%252Fremult%252Fremult">
26
+ </a>
27
+ <a href="https://twitter.com/remultjs" rel="nofollow">
28
+ <img alt="Twitter Follow" src="https://img.shields.io/twitter/url.svg?label=Follow%20%40remultjs&style=social&url=https%3A%2F%2Ftwitter.com%2FRemultJs">
26
29
  </a>
27
30
  </div>
28
31
  <hr/>
29
32
 
30
- [Getting Started](#getting-started) | [Documentation](#documentation) | [Example Apps](#example-apps)
33
+ [Getting Started](#getting-started) | [Documentation](#documentation) |
34
+ [Example Apps](#example-apps)
31
35
 
32
36
  ## What is Remult?
33
37
 
34
- **Remult** is a full-stack CRUD framework that uses your **TypeScript entities as a single source of truth for your API, frontend type-safe API client and backend ORM**.
38
+ **Remult** is a full-stack CRUD framework that uses your **TypeScript entities
39
+ as a single source of truth for your API, frontend type-safe API client and
40
+ backend ORM**.
35
41
 
36
42
  ### Status
37
43
 
38
- Remult is **production-ready** and, in fact, used in production apps since 2018. However, we’re keeping the major version at zero so we can use community feedback to finalize the v1 API.
44
+ Remult is **production-ready** and, in fact, used in production apps since 2018.
45
+ However, we’re keeping the major version at zero so we can use community
46
+ feedback to finalize the v1 API.
39
47
 
40
48
  ## Motivation
41
49
 
42
- Full-stack web development is (still) too complicated. **Simple CRUD, a common requirement of any business application, should be simple to build, maintain, and extend** when the need arises.
50
+ Full-stack web development is (still) too complicated. **Simple CRUD, a common
51
+ requirement of any business application, should be simple to build, maintain,
52
+ and extend** when the need arises.
43
53
 
44
- Remult abstracts away repetitive, boilerplate, error-prone, and poorly designed code on the one hand, and enables total flexibility and control on the other. **Remult helps building fullstack apps using only TypeScript code you can easily follow and safely refactor**, and fits nicely into any existing or new project by being minimalistic and completely unopinionated regarding the developer’s choice of other frameworks and tools.
54
+ Remult abstracts away repetitive, boilerplate, error-prone, and poorly designed
55
+ code on the one hand, and enables total flexibility and control on the other.
56
+ **Remult helps building fullstack apps using only TypeScript code you can easily
57
+ follow and safely refactor**, and fits nicely into any existing or new project
58
+ by being minimalistic and completely unopinionated regarding the developer’s
59
+ choice of other frameworks and tools.
45
60
 
46
- Other frameworks tend to fall into either too much abstraction (no-code, low-code, BaaS) or partial abstraction (MVC frameworks, GraphQL, ORMs, API generators, code generators), and tend to be opinionated regarding the development tool-chain, deployment environment, configuration/conventions or DSL. Remult attempts to strike a better balance.
61
+ Other frameworks tend to fall into either too much abstraction (no-code,
62
+ low-code, BaaS) or partial abstraction (MVC frameworks, GraphQL, ORMs, API
63
+ generators, code generators), and tend to be opinionated regarding the
64
+ development tool-chain, deployment environment, configuration/conventions or
65
+ DSL. Remult attempts to strike a better balance.
47
66
 
48
67
  ## Installation
49
68
 
50
- The *remult* package is one and the same for both the frontend bundle and the backend. Install it once for a monolith project or per-repo in a monorepo.
69
+ The _remult_ package is one and the same for both the frontend bundle and the
70
+ backend. Install it once for a monolith project or per-repo in a monorepo.
51
71
 
52
72
  ```sh
53
73
  npm i remult
@@ -56,17 +76,18 @@ npm i remult
56
76
  ## Usage
57
77
 
58
78
  ### Define model classes
79
+
59
80
  ```ts
60
81
  // shared/product.ts
61
82
 
62
- import { Entity, Fields } from 'remult';
83
+ import { Entity, Fields } from "remult";
63
84
 
64
- @Entity('products', {
65
- allowApiCrud: true
85
+ @Entity("products", {
86
+ allowApiCrud: true,
66
87
  })
67
88
  export class Product {
68
89
  @Fields.string()
69
- name = '';
90
+ name = "";
70
91
 
71
92
  @Fields.number()
72
93
  unitPrice = 0;
@@ -74,18 +95,19 @@ export class Product {
74
95
  ```
75
96
 
76
97
  ### Setup API backend using an Express middleware
98
+
77
99
  ```ts
78
100
  // backend/index.ts
79
101
 
80
- import express from 'express';
81
- import { remultExpress } from 'remult/remult-express';
82
- import { Product } from '../shared/product';
102
+ import express from "express";
103
+ import { remultExpress } from "remult/remult-express";
104
+ import { Product } from "../shared/product";
83
105
 
84
106
  const port = 3001;
85
107
  const app = express();
86
108
 
87
109
  app.use(remultExpress({
88
- entities: [Product]
110
+ entities: [Product],
89
111
  }));
90
112
 
91
113
  app.listen(port, () => {
@@ -94,6 +116,7 @@ app.listen(port, () => {
94
116
  ```
95
117
 
96
118
  ### :rocket: API Ready
119
+
97
120
  ```sh
98
121
  > curl http://localhost:3001/api/products
99
122
 
@@ -101,24 +124,26 @@ app.listen(port, () => {
101
124
  ```
102
125
 
103
126
  ### Find and manipulate data in type-safe frontend code
127
+
104
128
  ```ts
105
129
  // frontend/code.ts
106
130
 
107
- import { Remult } from 'remult';
108
- import { Product } from '../shared/product';
131
+ import { Remult } from "remult";
132
+ import { Product } from "../shared/product";
109
133
 
110
134
  const remult = new Remult();
111
135
 
112
136
  async function increasePriceOfTofu(priceIncrease: number) {
113
137
  const productsRepo = remult.repo(Product);
114
138
 
115
- const product = await productsRepo.findFirst({ name: 'Tofu' }); // filter is passed through API request all the way to the db
139
+ const product = await productsRepo.findFirst({ name: "Tofu" }); // filter is passed through API request all the way to the db
116
140
  product.unitPrice += priceIncrease;
117
141
  productsRepo.save(product); // mutation request updates the db with no boilerplate code
118
142
  }
119
143
  ```
120
144
 
121
- ### ...*exactly* the same way as in backend code
145
+ ### ..._exactly_ the same way as in backend code
146
+
122
147
  ```ts
123
148
  @BackendMethod({ allowed: Allow.authenticated })
124
149
  static async increasePriceOfTofu(priceIncrease: number, remult?: Remult) {
@@ -133,48 +158,51 @@ static async increasePriceOfTofu(priceIncrease: number, remult?: Remult) {
133
158
  ### :ballot_box_with_check: Data validation and constraints - defined once
134
159
 
135
160
  ```ts
136
- import { Entity, Fields, Validators } from 'remult';
161
+ import { Entity, Fields, Validators } from "remult";
137
162
 
138
- @Entity('products', {
139
- allowApiCrud: true
163
+ @Entity("products", {
164
+ allowApiCrud: true,
140
165
  })
141
166
  export class Product {
142
- @Fields.string({
143
- validate: Validators.required
144
- })
145
- name = '';
146
-
147
- @Fields.string<Product>({
148
- validate: product => {
149
- if (product.description.trim().length < 50)
150
- throw "too short";
151
- }
152
- })
153
- description = '';
154
-
155
- @Fields.number({
156
- validate: (_, field) => {
157
- if (field.value < 0)
158
- field.error = "must not be less than 0"; // or: throw "must not be less than 0";
159
- }
160
- })
161
- unitPrice = 0;
167
+ @Fields.string({
168
+ validate: Validators.required,
169
+ })
170
+ name = "";
171
+
172
+ @Fields.string<Product>({
173
+ validate: (product) => {
174
+ if (product.description.trim().length < 50) {
175
+ throw "too short";
176
+ }
177
+ },
178
+ })
179
+ description = "";
180
+
181
+ @Fields.number({
182
+ validate: (_, field) => {
183
+ if (field.value < 0) {
184
+ field.error = "must not be less than 0"; // or: throw "must not be less than 0";
185
+ }
186
+ },
187
+ })
188
+ unitPrice = 0;
162
189
  }
163
190
  ```
164
191
 
165
192
  ### Enforced in frontend:
193
+
166
194
  ```ts
167
195
  const product = productsRepo.create();
168
196
 
169
197
  try {
170
198
  await productsRepo.save(product);
171
- }
172
- catch (e: any) {
199
+ } catch (e: any) {
173
200
  console.error(e.message); // Browser console will display - "Name: required"
174
201
  }
175
202
  ```
176
203
 
177
204
  ### Enforced in backend:
205
+
178
206
  ```sh
179
207
  > curl http://localhost:3001/api/products -H "Content-Type: application/json" -d "{""unitPrice"":-1}"
180
208
 
@@ -182,58 +210,78 @@ catch (e: any) {
182
210
  ```
183
211
 
184
212
  ### :lock: Secure the API with fine-grained authorization
213
+
185
214
  ```ts
186
- @Entity<Article>('Articles', {
187
- allowApiRead: true,
188
- allowApiInsert: remult => remult.authenticated(),
189
- allowApiUpdate: (remult, article) => article.author.id == remult.user.id
215
+ @Entity<Article>("Articles", {
216
+ allowApiRead: true,
217
+ allowApiInsert: (remult) => remult.authenticated(),
218
+ allowApiUpdate: (remult, article) => article.author.id == remult.user.id,
190
219
  })
191
220
  export class Article {
192
- @Fields.string({ allowApiUpdate: false })
193
- slug = '';
194
-
195
- @Field(() => Profile, { allowApiUpdate: false })
196
- author!: Profile;
197
-
198
- @Fields.string()
199
- content = '';
221
+ @Fields.string({ allowApiUpdate: false })
222
+ slug = "";
223
+
224
+ @Field(() => Profile, { allowApiUpdate: false })
225
+ author!: Profile;
226
+
227
+ @Fields.string()
228
+ content = "";
200
229
  }
201
230
  ```
202
231
 
203
232
  ## What about complex CRUD?
204
233
 
205
- While simple CRUD shouldn’t require any backend coding, using Remult means having the ability to handle any complex scenario by controlling the backend in numerous ways:
206
-
207
- * Backend computed (read-only) fields - from simple [expressions](https://remult.dev/docs/ref_field.html#serverexpression) to complex data lookups or even direct db access (SQL)
208
- * Custom side-effects with [entity lifecycle hooks](https://remult.dev/docs/ref_entity.html#saving) (before/after saving/deleting)
209
- * Backend only updatable fields (e.g. “last updated at”)
210
- * Many-to-one [relations](https://remult.dev/docs/entity-relations.html) with [lazy/eager loading](https://remult.dev/docs/lazy-loading-of-related-entities.html)
211
- * Roll-your-own type-safe endpoints with [Backend Methods](https://remult.dev/docs/backendMethods.html)
212
- * Roll-your-own low-level endpoints (Express, Fastify, koa, others…)
234
+ While simple CRUD shouldn’t require any backend coding, using Remult means
235
+ having the ability to handle any complex scenario by controlling the backend in
236
+ numerous ways:
237
+
238
+ - Backend computed (read-only) fields - from simple
239
+ [expressions](https://remult.dev/docs/ref_field.html#serverexpression) to
240
+ complex data lookups or even direct db access (SQL)
241
+ - Custom side-effects with
242
+ [entity lifecycle hooks](https://remult.dev/docs/ref_entity.html#saving)
243
+ (before/after saving/deleting)
244
+ - Backend only updatable fields (e.g. “last updated at”)
245
+ - Many-to-one [relations](https://remult.dev/docs/entity-relations.html) with
246
+ [lazy/eager loading](https://remult.dev/docs/lazy-loading-of-related-entities.html)
247
+ - Roll-your-own type-safe endpoints with
248
+ [Backend Methods](https://remult.dev/docs/backendMethods.html)
249
+ - Roll-your-own low-level endpoints (Express, Fastify, koa, others…)
213
250
 
214
251
  ## Getting started
215
- The best way to learn Remult is by following a tutorial of a simple Todo web app with a Node.js Express backend.
216
252
 
217
- * [Tutorial with React](https://remult.dev/tutorials/react/)
218
- * [Tutorial with Angular](https://remult.dev/tutorials/angular/)
219
- * [Tutorial with Vue](https://remult.dev/tutorials/vue/)
220
- * [Tutorial with Next.js](https://remult.dev/tutorials/react-next/)
253
+ The best way to learn Remult is by following a tutorial of a simple Todo web app
254
+ with a Node.js Express backend.
255
+
256
+ - [Tutorial with React](https://remult.dev/tutorials/react/)
257
+ - [Tutorial with Angular](https://remult.dev/tutorials/angular/)
258
+ - [Tutorial with Vue](https://remult.dev/tutorials/vue/)
259
+ - [Tutorial with Next.js](https://remult.dev/tutorials/react-next/)
221
260
 
222
261
  ## Documentation
223
- The [documentation](https://remult.dev/docs) covers the main features of Remult. However, it is still a work-in-progress.
262
+
263
+ The [documentation](https://remult.dev/docs) covers the main features of Remult.
264
+ However, it is still a work-in-progress.
224
265
 
225
266
  ## Example Apps
226
267
 
227
- * Fullstack TodoMVC example with React and Express. ([Source code](https://github.com/remult/TodoMVC-eample) | [CodeSandbox](https://codesandbox.io/s/github/remult/TodoMVC-example?file=/src/frontend/App.tsx))
268
+ - Fullstack TodoMVC example with React and Express.
269
+ ([Source code](https://github.com/remult/TodoMVC-eample) |
270
+ [CodeSandbox](https://codesandbox.io/s/github/remult/TodoMVC-example?file=/src/frontend/App.tsx))
228
271
 
229
- * [CRM demo](https://github.com/remult/crm-demo) with a React + [MUI](https://mui.com) front-end and Postgres database.
272
+ - [CRM demo](https://github.com/remult/crm-demo) with a React +
273
+ [MUI](https://mui.com) front-end and Postgres database.
230
274
 
231
275
  ## Contributing
276
+
232
277
  Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
233
278
 
234
- * :speech_balloon: Any feedback or suggestions? Start a [discussion](https://github.com/remult/remult/discussions).
235
- * :muscle: Want to help out? Look for "help wanted" labeled [issues](https://github.com/remult/remult/issues).
236
- * :star: Give this repo a star.
279
+ - :speech_balloon: Any feedback or suggestions? Start a
280
+ [discussion](https://github.com/remult/remult/discussions).
281
+ - :muscle: Want to help out? Look for "help wanted" labeled
282
+ [issues](https://github.com/remult/remult/issues).
283
+ - :star: Give this repo a star.
237
284
 
238
285
  ## License
286
+
239
287
  Remult is [MIT Licensed](LICENSE).
package/esm/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export { Field, Fields, StringFieldOptions, FieldsMetadata, Entity, BuildEntity, 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';
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, BuildEntity, EntityBase, ControllerBase, FieldType, getFields, getEntityRef, ValueListFieldType, getValueList, ValueListInfo, CaptionTransformer } from './src/remult3';
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
@@ -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;
@@ -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
- for (const m of helper.methods) {
246
- m.classes.set(target, options);
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
@@ -310,7 +306,7 @@ export declare class EntityBase {
310
306
  }
311
307
  export declare class ControllerBase {
312
308
  protected remult: Remult;
313
- constructor(remult: Remult);
309
+ constructor(remult?: Remult);
314
310
  assign(values: Partial<Omit<this, keyof EntityBase>>): this;
315
311
  get $(): FieldsRef<this>;
316
312
  get _(): ControllerRef<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,14 +1658,14 @@ 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);
1674
1665
  return this;
1675
1666
  }
1676
- get $() { return getFields(this); }
1677
- get _() { return getControllerRef(this); }
1667
+ get $() { return getFields(this, this.remult); }
1668
+ get _() { return getControllerRef(this, this.remult); }
1678
1669
  }
1679
1670
  class QueryResultImpl {
1680
1671
  constructor(options, repo) {
@@ -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[];
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { Remult, allEntities, classHelpers, ClassHelper, MethodHelper, setControllerSettings, buildRestDataProvider } from './context';
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 mh.classes.keys()) {
154
- let controllerOptions = mh.classes.get(constructor);
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 = mh.classes.get(self.constructor);
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
- }(mh.classes.get(self.constructor).key + "/" + key, options ? options.queue : false, options.allowed).run({
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, BuildEntity, Fields } from '../remult3';
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
- BuildEntity(type, 'custom', {
8
+ describeClass(type, Entity('custom', { allowApiCrud: true }), {
8
9
  a: Fields.number(),
9
10
  b: Fields.number()
10
- }, { allowApiCrud: true });
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, BuildEntity, 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';
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.BuildEntity = exports.Entity = exports.Fields = exports.Field = void 0;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.16.2",
3
+ "version": "0.16.3-exp.1",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
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.MethodHelper = exports.ClassHelper = exports.classHelpers = exports.allEntities = exports.Remult = exports.isBackend = exports.processHttpException = exports.toPromise = exports.retry = exports.HttpProviderBridgeToRestDataProviderHttpProvider = void 0;
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.methods = [];
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
- try {
335
- for (var _b = (e_3 = void 0, tslib_1.__values(helper.methods)), _c = _b.next(); !_c.done; _c = _b.next()) {
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, e_4_1;
391
- var e_4, _c;
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
- e_4_1 = _d.sent();
411
- e_4 = { error: e_4_1 };
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 (e_4) throw e_4.error; }
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
@@ -310,7 +306,7 @@ export declare class EntityBase {
310
306
  }
311
307
  export declare class ControllerBase {
312
308
  protected remult: Remult;
313
- constructor(remult: Remult);
309
+ constructor(remult?: Remult);
314
310
  assign(values: Partial<Omit<this, keyof EntityBase>>): this;
315
311
  get $(): FieldsRef<this>;
316
312
  get _(): ControllerRef<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.BuildEntity = 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;
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,19 +2724,19 @@ 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);
2745
2731
  return this;
2746
2732
  };
2747
2733
  Object.defineProperty(ControllerBase.prototype, "$", {
2748
- get: function () { return getFields(this); },
2734
+ get: function () { return getFields(this, this.remult); },
2749
2735
  enumerable: false,
2750
2736
  configurable: true
2751
2737
  });
2752
2738
  Object.defineProperty(ControllerBase.prototype, "_", {
2753
- get: function () { return getControllerRef(this); },
2739
+ get: function () { return getControllerRef(this, this.remult); },
2754
2740
  enumerable: false,
2755
2741
  configurable: true
2756
2742
  });
@@ -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[];
@@ -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 = mh.classes.get(constructor);
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(mh.classes.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
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 = mh.classes.get(self.constructor);
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))(mh.classes.get(self.constructor).key + "/" + key, options ? options.queue : false, options.allowed)).run;
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
- remult3_1.BuildEntity(type, 'custom', {
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
- }, { allowApiCrud: true });
25
+ });
25
26
  return [4 /*yield*/, createEntity(type)];
26
27
  case 1:
27
28
  c = _b.sent();