remult 0.25.2 → 0.25.4

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.
@@ -1,5 +1,5 @@
1
1
  import { allEntities } from '../src/context.js';
2
- import { dbNamesOf, isDbReadonly, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
2
+ import { dbNamesOf, shouldNotCreateField, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
3
3
  import { remult as defaultRemult } from '../src/remult-proxy.js';
4
4
  import { isAutoIncrement } from '../src/remult3/RepositoryImplementation.js';
5
5
  import { ValueConverters } from '../src/valueConverters.js';
@@ -132,7 +132,7 @@ export class PostgresSchemaBuilder {
132
132
  if (r.rows.length == 0) {
133
133
  let result = '';
134
134
  for (const x of entity.fields) {
135
- if (!isDbReadonly(x, e) || isAutoIncrement(x)) {
135
+ if (!shouldNotCreateField(x, e) || isAutoIncrement(x)) {
136
136
  if (result.length != 0)
137
137
  result += ',';
138
138
  result += '\r\n ';
@@ -155,7 +155,7 @@ CREATE table ${this.schemaAndName(e)} (${result}\r\n)`;
155
155
  }
156
156
  async addColumnIfNotExist(entity, c) {
157
157
  let e = await dbNamesOf(entity, this.pool.wrapIdentifier);
158
- if (isDbReadonly(c(entity), e))
158
+ if (shouldNotCreateField(c(entity), e))
159
159
  return;
160
160
  try {
161
161
  let cmd = this.pool.createCommand();
@@ -181,7 +181,7 @@ CREATE table ${this.schemaAndName(e)} (${result}\r\n)`;
181
181
  let cols = (await cmd.execute(`SELECT column_name FROM information_schema.columns WHERE ` +
182
182
  `${this.whereTableAndSchema(cmd, e)}`)).rows.map((x) => x.column_name.toLocaleLowerCase());
183
183
  for (const col of entity.fields) {
184
- if (!isDbReadonly(col, e)) {
184
+ if (!shouldNotCreateField(col, e)) {
185
185
  let colName = e.$dbNameOf(col).toLocaleLowerCase();
186
186
  if (colName.startsWith('"') && colName.endsWith('"'))
187
187
  colName = colName.substring(1, colName.length - 1);
@@ -1,5 +1,5 @@
1
1
  import { allEntities } from '../src/context.js';
2
- import { dbNamesOf, isDbReadonly, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
2
+ import { dbNamesOf, isDbReadonly, shouldNotCreateField, } from '../src/filter/filter-consumer-bridge-to-sql-request.js';
3
3
  import { customDatabaseFilterToken, Filter, } from '../src/filter/filter-interfaces.js';
4
4
  import { CompoundIdField } from '../src/CompoundIdField.js';
5
5
  import { remult as remultContext } from '../src/remult-proxy.js';
@@ -358,7 +358,7 @@ export class KnexSchemaBuilder {
358
358
  for (const f of entity.fields) {
359
359
  cols.set(f, {
360
360
  name: e.$dbNameOf(f),
361
- readonly: isDbReadonly(f, e),
361
+ readonly: shouldNotCreateField(f, e),
362
362
  });
363
363
  }
364
364
  await logSql(this.knex.schema.createTable(e.$entityName, (b) => {
@@ -378,7 +378,7 @@ export class KnexSchemaBuilder {
378
378
  }
379
379
  async addColumnIfNotExist(entity, c) {
380
380
  let e = await dbNamesOf(entity);
381
- if (isDbReadonly(c(entity), e))
381
+ if (shouldNotCreateField(c(entity), e))
382
382
  return;
383
383
  let col = c(entity);
384
384
  let colName = e.$dbNameOf(col);
@@ -392,7 +392,7 @@ export class KnexSchemaBuilder {
392
392
  let e = await dbNamesOf(entity);
393
393
  try {
394
394
  for (const col of entity.fields.toArray()) {
395
- if (!isDbReadonly(col, e)) {
395
+ if (!shouldNotCreateField(col, e)) {
396
396
  await this.addColumnIfNotExist(entity, () => col);
397
397
  }
398
398
  }
@@ -154,6 +154,10 @@ export function isDbReadonly(field, dbNames) {
154
154
  field.isServerExpression ||
155
155
  (field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
156
156
  }
157
+ export function shouldNotCreateField(field, dbNames) {
158
+ return (field.isServerExpression ||
159
+ (field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
160
+ }
157
161
  export async function dbNamesOf(repo, wrapIdentifier = (x) => x) {
158
162
  var meta = getEntityMetadata(repo);
159
163
  const result = {
@@ -1639,7 +1639,7 @@ export class FieldRefImplementation {
1639
1639
  set error(value) {
1640
1640
  self.error = value;
1641
1641
  },
1642
- isNew: self.rowBase.isNewRow,
1642
+ isNew: this.entityRef?.isNew(),
1643
1643
  load: () => self.load(),
1644
1644
  metadata: self.metadata,
1645
1645
  originalValue: self.originalValue,
@@ -43,6 +43,14 @@ remult.apiClient.url='localhost:3007/api
43
43
 
44
44
 
45
45
  */
46
+ //p1 - investigate angular starter kit init request error
47
+ //p1 - fix angular starter kit await set password
48
+ //p1 - fix angular starter kit to latest version as well
49
+ //p1 -check if checouknt doesn't respect allow read (I think)
50
+ //p1 - fix multiple instances of remult: the defaultRemult and async local hook - and columnsOfType - all can be tests with a vite project loading `remult-admin`
51
+ //p1 - crm demo graphql error
52
+ //p1 - allow api update only for new rows
53
+ //p1 - getFields didn't work for kobi in the home component
46
54
  //p2 - document validators
47
55
  //p2 - and validators to reference
48
56
  //y2 - discuss a default date formatter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.25.2",
3
+ "version": "0.25.4",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -234,7 +234,7 @@ var PostgresSchemaBuilder = /** @class */ (function () {
234
234
  try {
235
235
  for (_a = tslib_1.__values(entity.fields), _b = _a.next(); !_b.done; _b = _a.next()) {
236
236
  x = _b.value;
237
- if (!(0, filter_consumer_bridge_to_sql_request_js_1.isDbReadonly)(x, e) || (0, RepositoryImplementation_js_1.isAutoIncrement)(x)) {
237
+ if (!(0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(x, e) || (0, RepositoryImplementation_js_1.isAutoIncrement)(x)) {
238
238
  if (result.length != 0)
239
239
  result += ',';
240
240
  result += '\r\n ';
@@ -281,7 +281,7 @@ var PostgresSchemaBuilder = /** @class */ (function () {
281
281
  case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, this.pool.wrapIdentifier)];
282
282
  case 1:
283
283
  e = _a.sent();
284
- if ((0, filter_consumer_bridge_to_sql_request_js_1.isDbReadonly)(c(entity), e))
284
+ if ((0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(c(entity), e))
285
285
  return [2 /*return*/];
286
286
  _a.label = 2;
287
287
  case 2:
@@ -335,7 +335,7 @@ var PostgresSchemaBuilder = /** @class */ (function () {
335
335
  case 4:
336
336
  if (!!_b.done) return [3 /*break*/, 7];
337
337
  col = _b.value;
338
- if (!!(0, filter_consumer_bridge_to_sql_request_js_1.isDbReadonly)(col, e)) return [3 /*break*/, 6];
338
+ if (!!(0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(col, e)) return [3 /*break*/, 6];
339
339
  colName = e.$dbNameOf(col).toLocaleLowerCase();
340
340
  if (colName.startsWith('"') && colName.endsWith('"'))
341
341
  colName = colName.substring(1, colName.length - 1);
@@ -719,7 +719,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
719
719
  f = _b.value;
720
720
  cols_1.set(f, {
721
721
  name: e.$dbNameOf(f),
722
- readonly: (0, filter_consumer_bridge_to_sql_request_js_1.isDbReadonly)(f, e),
722
+ readonly: (0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(f, e),
723
723
  });
724
724
  }
725
725
  }
@@ -771,7 +771,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
771
771
  case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
772
772
  case 1:
773
773
  e = _a.sent();
774
- if ((0, filter_consumer_bridge_to_sql_request_js_1.isDbReadonly)(c(entity), e))
774
+ if ((0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(c(entity), e))
775
775
  return [2 /*return*/];
776
776
  col = c(entity);
777
777
  colName = e.$dbNameOf(col);
@@ -805,7 +805,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
805
805
  return tslib_1.__generator(this, function (_e) {
806
806
  switch (_e.label) {
807
807
  case 0:
808
- if (!!(0, filter_consumer_bridge_to_sql_request_js_1.isDbReadonly)(col, e)) return [3 /*break*/, 2];
808
+ if (!!(0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(col, e)) return [3 /*break*/, 2];
809
809
  return [4 /*yield*/, this_2.addColumnIfNotExist(entity, function () { return col; })];
810
810
  case 1:
811
811
  _e.sent();
@@ -40,6 +40,7 @@ export declare class CustomSqlFilterBuilder {
40
40
  filterToRaw<entityType>(repo: RepositoryOverloads<entityType>, condition: EntityFilter<entityType>): Promise<string>;
41
41
  }
42
42
  export declare function isDbReadonly<entityType>(field: FieldMetadata, dbNames: EntityDbNames<entityType>): boolean;
43
+ export declare function shouldNotCreateField<entityType>(field: FieldMetadata, dbNames: EntityDbNames<entityType>): boolean;
43
44
  export declare type EntityDbNamesBase = {
44
45
  $entityName: string;
45
46
  $dbNameOf(field: FieldMetadata<any> | string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fieldDbName = exports.entityDbName = exports.dbNamesOf = exports.isDbReadonly = exports.CustomSqlFilterBuilder = exports.FilterConsumerBridgeToSqlRequest = void 0;
3
+ exports.fieldDbName = exports.entityDbName = exports.dbNamesOf = exports.shouldNotCreateField = exports.isDbReadonly = exports.CustomSqlFilterBuilder = exports.FilterConsumerBridgeToSqlRequest = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var sql_database_js_1 = require("../data-providers/sql-database.js");
6
6
  var RepositoryImplementation_js_1 = require("../remult3/RepositoryImplementation.js");
@@ -263,6 +263,11 @@ function isDbReadonly(field, dbNames) {
263
263
  (field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
264
264
  }
265
265
  exports.isDbReadonly = isDbReadonly;
266
+ function shouldNotCreateField(field, dbNames) {
267
+ return (field.isServerExpression ||
268
+ (field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
269
+ }
270
+ exports.shouldNotCreateField = shouldNotCreateField;
266
271
  function dbNamesOf(repo, wrapIdentifier) {
267
272
  if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
268
273
  return tslib_1.__awaiter(this, void 0, void 0, function () {
@@ -2679,14 +2679,15 @@ var FieldRefImplementation = /** @class */ (function () {
2679
2679
  return (JSON.stringify(this.metadata.valueConverter.toJson(this.rowBase.originalValues[this.metadata.key])) != JSON.stringify(this.metadata.valueConverter.toJson(val)));
2680
2680
  };
2681
2681
  FieldRefImplementation.prototype.__performValidation = function () {
2682
+ var _a;
2682
2683
  return tslib_1.__awaiter(this, void 0, void 0, function () {
2683
- var processValidation, self_1, event_1, _a, _b, v, _c, e_41_1, _d, error_1;
2684
- var e_41, _e;
2684
+ var processValidation, self_1, event_1, _b, _c, v, _d, e_41_1, _e, error_1;
2685
+ var e_41, _f;
2685
2686
  var _this = this;
2686
- return tslib_1.__generator(this, function (_f) {
2687
- switch (_f.label) {
2687
+ return tslib_1.__generator(this, function (_g) {
2688
+ switch (_g.label) {
2688
2689
  case 0:
2689
- _f.trys.push([0, 12, , 13]);
2690
+ _g.trys.push([0, 12, , 13]);
2690
2691
  processValidation = function (result) {
2691
2692
  if (result !== true && result !== undefined && !_this.error) {
2692
2693
  if (typeof result === 'string' && result.length > 0)
@@ -2705,7 +2706,7 @@ var FieldRefImplementation = /** @class */ (function () {
2705
2706
  set error(value) {
2706
2707
  self_1.error = value;
2707
2708
  },
2708
- isNew: self_1.rowBase.isNewRow,
2709
+ isNew: (_a = this.entityRef) === null || _a === void 0 ? void 0 : _a.isNew(),
2709
2710
  load: function () { return self_1.load(); },
2710
2711
  metadata: self_1.metadata,
2711
2712
  originalValue: self_1.originalValue,
@@ -2716,44 +2717,44 @@ var FieldRefImplementation = /** @class */ (function () {
2716
2717
  isBackend: function () { var _a, _b, _c; return !((_c = (_b = (_a = self_1.rowBase) === null || _a === void 0 ? void 0 : _a.remult) === null || _b === void 0 ? void 0 : _b.dataProvider) === null || _c === void 0 ? void 0 : _c.isProxy); },
2717
2718
  };
2718
2719
  if (!Array.isArray(this.settings.validate)) return [3 /*break*/, 9];
2719
- _f.label = 1;
2720
+ _g.label = 1;
2720
2721
  case 1:
2721
- _f.trys.push([1, 6, 7, 8]);
2722
- _a = tslib_1.__values(this.settings.validate), _b = _a.next();
2723
- _f.label = 2;
2722
+ _g.trys.push([1, 6, 7, 8]);
2723
+ _b = tslib_1.__values(this.settings.validate), _c = _b.next();
2724
+ _g.label = 2;
2724
2725
  case 2:
2725
- if (!!_b.done) return [3 /*break*/, 5];
2726
- v = _b.value;
2727
- _c = processValidation;
2726
+ if (!!_c.done) return [3 /*break*/, 5];
2727
+ v = _c.value;
2728
+ _d = processValidation;
2728
2729
  return [4 /*yield*/, v(this.container, event_1)];
2729
2730
  case 3:
2730
- _c.apply(void 0, [_f.sent()]);
2731
- _f.label = 4;
2731
+ _d.apply(void 0, [_g.sent()]);
2732
+ _g.label = 4;
2732
2733
  case 4:
2733
- _b = _a.next();
2734
+ _c = _b.next();
2734
2735
  return [3 /*break*/, 2];
2735
2736
  case 5: return [3 /*break*/, 8];
2736
2737
  case 6:
2737
- e_41_1 = _f.sent();
2738
+ e_41_1 = _g.sent();
2738
2739
  e_41 = { error: e_41_1 };
2739
2740
  return [3 /*break*/, 8];
2740
2741
  case 7:
2741
2742
  try {
2742
- if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
2743
+ if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
2743
2744
  }
2744
2745
  finally { if (e_41) throw e_41.error; }
2745
2746
  return [7 /*endfinally*/];
2746
2747
  case 8: return [3 /*break*/, 11];
2747
2748
  case 9:
2748
2749
  if (!(typeof this.settings.validate === 'function')) return [3 /*break*/, 11];
2749
- _d = processValidation;
2750
+ _e = processValidation;
2750
2751
  return [4 /*yield*/, this.settings.validate(this.container, event_1)];
2751
2752
  case 10:
2752
- _d.apply(void 0, [_f.sent()]);
2753
- _f.label = 11;
2753
+ _e.apply(void 0, [_g.sent()]);
2754
+ _g.label = 11;
2754
2755
  case 11: return [3 /*break*/, 13];
2755
2756
  case 12:
2756
- error_1 = _f.sent();
2757
+ error_1 = _g.sent();
2757
2758
  if (typeof error_1 === 'string')
2758
2759
  this.error = error_1;
2759
2760
  else
@@ -44,6 +44,14 @@ remult.apiClient.url='localhost:3007/api
44
44
 
45
45
 
46
46
  */
47
+ //p1 - investigate angular starter kit init request error
48
+ //p1 - fix angular starter kit await set password
49
+ //p1 - fix angular starter kit to latest version as well
50
+ //p1 -check if checouknt doesn't respect allow read (I think)
51
+ //p1 - fix multiple instances of remult: the defaultRemult and async local hook - and columnsOfType - all can be tests with a vite project loading `remult-admin`
52
+ //p1 - crm demo graphql error
53
+ //p1 - allow api update only for new rows
54
+ //p1 - getFields didn't work for kobi in the home component
47
55
  //p2 - document validators
48
56
  //p2 - and validators to reference
49
57
  //y2 - discuss a default date formatter