remult 0.25.6-exp.7 → 0.25.7-exp.0

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.
@@ -435,7 +435,7 @@ function supportsJsonLoadingAndSaving(knex) {
435
435
  export function buildColumn(x, dbName, b, supportsJson = true) {
436
436
  if (x.valueType == Number) {
437
437
  if (!x.valueConverter.fieldTypeInDb) {
438
- let c = b.decimal(dbName);
438
+ let c = b.decimal(dbName, 18, 2);
439
439
  if (!x.allowNull) {
440
440
  c.defaultTo(0).notNullable();
441
441
  }
@@ -286,32 +286,37 @@ export class RemultServerImplementation {
286
286
  }
287
287
  let myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
288
288
  let myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
289
- await this.runWithRemult(async (remult) => {
290
- if (req) {
291
- let user;
292
- if (this.options.getUser)
293
- user = await this.options.getUser(req);
294
- else {
295
- user = req['user'];
296
- if (!user)
297
- user = req['auth'];
298
- }
299
- if (user)
300
- remult.user = user;
301
- if (this.options.initRequest) {
302
- await this.options.initRequest(req, {
303
- remult,
304
- get liveQueryStorage() {
305
- return remult.liveQueryStorage;
306
- },
307
- set liveQueryStorage(value) {
308
- remult.liveQueryStorage = value;
309
- },
310
- });
289
+ try {
290
+ await this.runWithRemult(async (remult) => {
291
+ if (req) {
292
+ let user;
293
+ if (this.options.getUser)
294
+ user = await this.options.getUser(req);
295
+ else {
296
+ user = req['user'];
297
+ if (!user)
298
+ user = req['auth'];
299
+ }
300
+ if (user)
301
+ remult.user = user;
302
+ if (this.options.initRequest) {
303
+ await this.options.initRequest(req, {
304
+ remult,
305
+ get liveQueryStorage() {
306
+ return remult.liveQueryStorage;
307
+ },
308
+ set liveQueryStorage(value) {
309
+ remult.liveQueryStorage = value;
310
+ },
311
+ });
312
+ }
311
313
  }
312
- }
313
- await what(remult, myReq, myRes, genReq, origRes, req);
314
- });
314
+ await what(remult, myReq, myRes, genReq, origRes, req);
315
+ });
316
+ }
317
+ catch (err) {
318
+ myRes.error(serializeError(err));
319
+ }
315
320
  };
316
321
  }
317
322
  async getRemult(req) {
@@ -10,8 +10,18 @@ export {};
10
10
  #
11
11
 
12
12
  //y1 - getFields didn't work for kobi in the home component
13
- //y1 - talk about export api is not possible in +server - how did we face that in others, and how do we doc it - ended up using _api
14
- //y1 - number default storage in knex is decimal and it by default has 8,2 - meaning only 999,999 - I think it should be way bigger than that. in firefly we do at least 18 - https://discord.com/channels/975754286384418847/1195162533447876658
13
+ //p1 - JYC - change name of add parameter and .... to token - param
14
+ //p1 - Hint names for sql parameters
15
+ //p1 - add section to Fields doc, explaining field type in db
16
+ /*p1 - JYC - Delete many, update many, insert many
17
+ - post + __action=delet
18
+ */
19
+ //p1 - JYC - there should be a required that says not null or undefined, but space, 0 etc... should be ok - NOAM- check if removing zero is good enough
20
+ /*y1 - Talk JYC - JYC - add some integrity checks on delete
21
+ - soft delete
22
+ - delete restrict (implicit, or user selected - and if so, how) (delete & update of id)
23
+
24
+ */
15
25
  //y1 - admin url!
16
26
  //y1 - consider sql expression gets a dbnames of it's own (that already has the "tableName" defined correctly) maybe also the filter translator
17
27
  //y1 - talk about modules in init express with entities/controllers,initRequest,initApi
@@ -20,9 +30,9 @@ export {};
20
30
  //y1 - support get with backend method, with url search params as the first parameter, & url as second parameter
21
31
  //y1 - talk about the parameter issue with backend methods
22
32
  //y1 - select data provider per entity https://discord.com/channels/975754286384418847/976006081748807690/1201415305885397003
33
+ //y1 - migrations
23
34
  //y2 - live query refresh of view on table update
24
35
  //y2 - livequery for findfirst (@JY)
25
-
26
36
  /*y2 -
27
37
  //y2 - allow api update only for new rows
28
38
  @Fields.string<Category>({
@@ -12,7 +12,7 @@ export class Validators {
12
12
  return true;
13
13
  }, 'already exists');
14
14
  /**
15
- * @deprecated is `unique` instead - it also runs only on the backend
15
+ * @deprecated use `unique` instead - it also runs only on the backend
16
16
  */
17
17
  static uniqueOnBackend = createValidator(async (_, e) => {
18
18
  if (e.isBackend() && (e.isNew || e.valueChanged())) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.25.6-exp.7",
3
+ "version": "0.25.7-exp.0",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -894,7 +894,7 @@ function buildColumn(x, dbName, b, supportsJson) {
894
894
  if (supportsJson === void 0) { supportsJson = true; }
895
895
  if (x.valueType == Number) {
896
896
  if (!x.valueConverter.fieldTypeInDb) {
897
- var c = b.decimal(dbName);
897
+ var c = b.decimal(dbName, 18, 2);
898
898
  if (!x.allowNull) {
899
899
  c.defaultTo(0).notNullable();
900
900
  }
@@ -527,7 +527,7 @@ var RemultServerImplementation = /** @class */ (function () {
527
527
  RemultServerImplementation.prototype.process = function (what) {
528
528
  var _this = this;
529
529
  return function (req, origRes) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
530
- var genReq, myReq, myRes;
530
+ var genReq, myReq, myRes, err_1;
531
531
  var _this = this;
532
532
  return tslib_1.__generator(this, function (_a) {
533
533
  switch (_a.label) {
@@ -544,6 +544,9 @@ var RemultServerImplementation = /** @class */ (function () {
544
544
  }
545
545
  myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
546
546
  myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
547
+ _a.label = 1;
548
+ case 1:
549
+ _a.trys.push([1, 3, , 4]);
547
550
  return [4 /*yield*/, this.runWithRemult(function (remult) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
548
551
  var user;
549
552
  return tslib_1.__generator(this, function (_a) {
@@ -584,9 +587,14 @@ var RemultServerImplementation = /** @class */ (function () {
584
587
  }
585
588
  });
586
589
  }); })];
587
- case 1:
590
+ case 2:
588
591
  _a.sent();
589
- return [2 /*return*/];
592
+ return [3 /*break*/, 4];
593
+ case 3:
594
+ err_1 = _a.sent();
595
+ myRes.error((0, data_api_js_1.serializeError)(err_1));
596
+ return [3 /*break*/, 4];
597
+ case 4: return [2 /*return*/];
590
598
  }
591
599
  });
592
600
  }); };
package/src/context.d.ts CHANGED
@@ -132,8 +132,9 @@ export interface ApiClient {
132
132
  subscriptionClient?: SubscriptionClient;
133
133
  /**
134
134
  * A function that wraps message handling for subscriptions. This is useful for executing some code before
135
- * or after any message arrives from the subscription. For example, in Angular, this can be used to trigger
136
- * a render by calling the `NgZone` run method.
135
+ * or after any message arrives from the subscription.
136
+ * For example, in Angular, to refresh a specific part of the UI,
137
+ * you can call the `NgZone` run method at this time.
137
138
  *
138
139
  * @example
139
140
  * // Angular example
@@ -194,7 +194,7 @@ export interface EntityMetadata<entityType = any> {
194
194
  */
195
195
  readonly dbName: string;
196
196
  /** The options send to the `Entity`'s decorator */
197
- readonly options: EntityOptions<entityType>;
197
+ readonly options: EntityOptions;
198
198
  /** The class type of the entity */
199
199
  readonly entityType: ClassType<entityType>;
200
200
  /** true if the current user is allowed to update an entity instance
@@ -347,7 +347,7 @@ export interface Repository<entityType> {
347
347
  */
348
348
  metadata: EntityMetadata<entityType>;
349
349
  addEventListener(listener: entityEventListener<entityType>): Unsubscribe;
350
- relations: (item: entityType) => RepositoryRelations<entityType>;
350
+ relations(item: entityType): RepositoryRelations<entityType>;
351
351
  }
352
352
  /**
353
353
  * The `LiveQuery` interface represents a live query that allows subscribing to changes in the query results.
@@ -11,8 +11,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  #
12
12
 
13
13
  //y1 - getFields didn't work for kobi in the home component
14
- //y1 - talk about export api is not possible in +server - how did we face that in others, and how do we doc it - ended up using _api
15
- //y1 - number default storage in knex is decimal and it by default has 8,2 - meaning only 999,999 - I think it should be way bigger than that. in firefly we do at least 18 - https://discord.com/channels/975754286384418847/1195162533447876658
14
+ //p1 - JYC - change name of add parameter and .... to token - param
15
+ //p1 - Hint names for sql parameters
16
+ //p1 - add section to Fields doc, explaining field type in db
17
+ /*p1 - JYC - Delete many, update many, insert many
18
+ - post + __action=delet
19
+ */
20
+ //p1 - JYC - there should be a required that says not null or undefined, but space, 0 etc... should be ok - NOAM- check if removing zero is good enough
21
+ /*y1 - Talk JYC - JYC - add some integrity checks on delete
22
+ - soft delete
23
+ - delete restrict (implicit, or user selected - and if so, how) (delete & update of id)
24
+
25
+ */
16
26
  //y1 - admin url!
17
27
  //y1 - consider sql expression gets a dbnames of it's own (that already has the "tableName" defined correctly) maybe also the filter translator
18
28
  //y1 - talk about modules in init express with entities/controllers,initRequest,initApi
@@ -21,9 +31,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
31
  //y1 - support get with backend method, with url search params as the first parameter, & url as second parameter
22
32
  //y1 - talk about the parameter issue with backend methods
23
33
  //y1 - select data provider per entity https://discord.com/channels/975754286384418847/976006081748807690/1201415305885397003
34
+ //y1 - migrations
24
35
  //y2 - live query refresh of view on table update
25
36
  //y2 - livequery for findfirst (@JY)
26
-
27
37
  /*y2 -
28
38
  //y2 - allow api update only for new rows
29
39
  @Fields.string<Category>({
@@ -4,7 +4,7 @@ export declare class Validators {
4
4
  static required: Validator<any>;
5
5
  static unique: Validator<any>;
6
6
  /**
7
- * @deprecated is `unique` instead - it also runs only on the backend
7
+ * @deprecated use `unique` instead - it also runs only on the backend
8
8
  */
9
9
  static uniqueOnBackend: Validator<any>;
10
10
  static regex: ValidatorWithArgs<string, RegExp> & {
package/src/validators.js CHANGED
@@ -27,7 +27,7 @@ var Validators = /** @class */ (function () {
27
27
  });
28
28
  }); }, 'already exists');
29
29
  /**
30
- * @deprecated is `unique` instead - it also runs only on the backend
30
+ * @deprecated use `unique` instead - it also runs only on the backend
31
31
  */
32
32
  Validators.uniqueOnBackend = createValidator(function (_, e) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
33
33
  var _b;