remult 0.25.2 → 0.25.3
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/postgres/schema-builder.js +4 -4
- package/esm/remult-knex/index.js +4 -4
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +4 -0
- package/esm/src/remult3/remult3.js +5 -0
- package/package.json +1 -1
- package/postgres/schema-builder.js +3 -3
- package/remult-knex/index.js +3 -3
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +1 -0
- package/src/filter/filter-consumer-bridge-to-sql-request.js +6 -1
- package/src/remult3/remult3.js +5 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { allEntities } from '../src/context.js';
|
|
2
|
-
import { dbNamesOf,
|
|
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 (!
|
|
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 (
|
|
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 (!
|
|
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);
|
package/esm/remult-knex/index.js
CHANGED
|
@@ -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:
|
|
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 (
|
|
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 (!
|
|
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 = {
|
|
@@ -43,6 +43,11 @@ remult.apiClient.url='localhost:3007/api
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
*/
|
|
46
|
+
//p1 -check if checouknt doesn't respect allow read (I think)
|
|
47
|
+
//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`
|
|
48
|
+
//p1 - crm demo graphql error
|
|
49
|
+
//p1 - allow api update only for new rows
|
|
50
|
+
//p1 - getFields didn't work for kobi in the home component
|
|
46
51
|
//p2 - document validators
|
|
47
52
|
//p2 - and validators to reference
|
|
48
53
|
//y2 - discuss a default date formatter
|
package/package.json
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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);
|
package/remult-knex/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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 () {
|
package/src/remult3/remult3.js
CHANGED
|
@@ -44,6 +44,11 @@ remult.apiClient.url='localhost:3007/api
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
*/
|
|
47
|
+
//p1 -check if checouknt doesn't respect allow read (I think)
|
|
48
|
+
//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`
|
|
49
|
+
//p1 - crm demo graphql error
|
|
50
|
+
//p1 - allow api update only for new rows
|
|
51
|
+
//p1 - getFields didn't work for kobi in the home component
|
|
47
52
|
//p2 - document validators
|
|
48
53
|
//p2 - and validators to reference
|
|
49
54
|
//y2 - discuss a default date formatter
|