remult 0.25.5-exp.6 → 0.25.5-exp.8
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/graphql.js +5 -2
- package/esm/remult-knex/index.js +11 -4
- package/esm/src/remult3/remult3.js +11 -0
- package/graphql.js +5 -2
- package/package.json +1 -1
- package/remult-knex/index.js +11 -4
- package/src/remult3/remult3.js +11 -0
package/esm/graphql.js
CHANGED
|
@@ -413,6 +413,9 @@ export function remultGraphql(options) {
|
|
|
413
413
|
const refType = ri.toEntity;
|
|
414
414
|
ref = entities.find((i) => i.entityType === refType);
|
|
415
415
|
}
|
|
416
|
+
if (!ref) {
|
|
417
|
+
throw new Error(`Entity "${ri.toEntity.name}" that is used by the relation "${f.key}" in "${meta.entityType.name}" was not found in the 'entities' array.`);
|
|
418
|
+
}
|
|
416
419
|
notARealField = ri.type === 'toOne' || ri.type === 'toMany';
|
|
417
420
|
const refKey = ref.key;
|
|
418
421
|
switch (ri.type) {
|
|
@@ -448,11 +451,11 @@ export function remultGraphql(options) {
|
|
|
448
451
|
order: 10,
|
|
449
452
|
comment: `List all \`${getMetaType(meta)}\` of \`${refKey}\``,
|
|
450
453
|
});
|
|
451
|
-
currentType.query.resultProcessors.push((r) => {
|
|
454
|
+
currentType.query.resultProcessors.push((r, y) => {
|
|
452
455
|
r[f.key] = async (args, req, gqlInfo) => {
|
|
453
456
|
const remult = await options.getRemultFromRequest(req);
|
|
454
457
|
const myRepo = remult.repo(meta.entityType);
|
|
455
|
-
const item = myRepo.fromJson(
|
|
458
|
+
const item = myRepo.fromJson(y);
|
|
456
459
|
let relRepo = myRepo.relations(item)[f.key];
|
|
457
460
|
return handleRequestWithDataApiContextBasedOnRepo(relRepo, async (dApi, response, setResult, arg1, meta) => {
|
|
458
461
|
return await connectionImplementation(setResult, itemsKey, createResultPromise, dApi, upsertTypes(getMetaType(ref)), arg1, meta, totalCountKey);
|
package/esm/remult-knex/index.js
CHANGED
|
@@ -20,7 +20,7 @@ export class KnexDataProvider {
|
|
|
20
20
|
return r.knex;
|
|
21
21
|
}
|
|
22
22
|
getEntityDataProvider(entity) {
|
|
23
|
-
if (!
|
|
23
|
+
if (!supportsJsonLoadingAndSaving(this.knex))
|
|
24
24
|
for (const f of entity.fields.toArray()) {
|
|
25
25
|
if (f.valueConverter.fieldTypeInDb === 'json') {
|
|
26
26
|
//@ts-ignore
|
|
@@ -367,7 +367,7 @@ export class KnexSchemaBuilder {
|
|
|
367
367
|
if (isAutoIncrement(x))
|
|
368
368
|
b.increments(cols.get(x).name);
|
|
369
369
|
else {
|
|
370
|
-
buildColumn(x, cols.get(x).name, b,
|
|
370
|
+
buildColumn(x, cols.get(x).name, b, supportsJsonDataStorage(this.knex));
|
|
371
371
|
if (x == entity.idMetadata.field)
|
|
372
372
|
b.primary([cols.get(x).name]);
|
|
373
373
|
}
|
|
@@ -384,7 +384,7 @@ export class KnexSchemaBuilder {
|
|
|
384
384
|
let colName = e.$dbNameOf(col);
|
|
385
385
|
if (!(await this.knex.schema.hasColumn(e.$entityName, colName))) {
|
|
386
386
|
await logSql(this.knex.schema.alterTable(e.$entityName, (b) => {
|
|
387
|
-
buildColumn(col, colName, b,
|
|
387
|
+
buildColumn(col, colName, b, supportsJsonDataStorage(this.knex));
|
|
388
388
|
}));
|
|
389
389
|
}
|
|
390
390
|
}
|
|
@@ -406,10 +406,17 @@ export class KnexSchemaBuilder {
|
|
|
406
406
|
this.knex = knex;
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function supportsJsonDataStorage(knex) {
|
|
410
|
+
const client = knex.client.config.client;
|
|
411
|
+
if (client?.includes('sqlite3') || client?.includes('mssql'))
|
|
412
|
+
return false;
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
415
|
+
function supportsJsonLoadingAndSaving(knex) {
|
|
410
416
|
const client = knex.client.config.client;
|
|
411
417
|
if (client?.includes('sqlite3') ||
|
|
412
418
|
client?.includes('mssql') ||
|
|
419
|
+
client?.includes('mysql2') ||
|
|
413
420
|
client?.includes('mysql'))
|
|
414
421
|
return false;
|
|
415
422
|
return true;
|
|
@@ -2,6 +2,17 @@ export {};
|
|
|
2
2
|
//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
|
|
3
3
|
//y1 - talk about the parameter issue with backend methods
|
|
4
4
|
//y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
|
|
5
|
+
//p1 - live query with include
|
|
6
|
+
//p1 - relation from order details to order gave a compound id info - and it is not true - same for the relation to product
|
|
7
|
+
//p1 - include admin in remult
|
|
8
|
+
//p1 - new row when there are relations, looks funny (see product)
|
|
9
|
+
//p1 - the + row in the bottom should extend to the full width
|
|
10
|
+
//p1 - adjust angular starter kit for latest angular (as is in tutorial)
|
|
11
|
+
/*y2 -
|
|
12
|
+
@Fields.string<Category>({
|
|
13
|
+
allowApiUpdate: (c) => getEntityRef(c).isNew(),
|
|
14
|
+
})
|
|
15
|
+
Description = ""*/
|
|
5
16
|
//y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
|
|
6
17
|
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
7
18
|
//y2 - how to run a transaction as a user
|
package/graphql.js
CHANGED
|
@@ -505,6 +505,9 @@ function remultGraphql(options) {
|
|
|
505
505
|
var refType_1 = ri.toEntity;
|
|
506
506
|
ref = entities.find(function (i) { return i.entityType === refType_1; });
|
|
507
507
|
}
|
|
508
|
+
if (!ref) {
|
|
509
|
+
throw new Error("Entity \"".concat(ri.toEntity.name, "\" that is used by the relation \"").concat(f.key, "\" in \"").concat(meta.entityType.name, "\" was not found in the 'entities' array."));
|
|
510
|
+
}
|
|
508
511
|
notARealField = ri.type === 'toOne' || ri.type === 'toMany';
|
|
509
512
|
var refKey = ref.key;
|
|
510
513
|
switch (ri.type) {
|
|
@@ -557,7 +560,7 @@ function remultGraphql(options) {
|
|
|
557
560
|
order: 10,
|
|
558
561
|
comment: "List all `".concat(getMetaType(meta), "` of `").concat(refKey, "`"),
|
|
559
562
|
});
|
|
560
|
-
currentType.query.resultProcessors.push(function (r) {
|
|
563
|
+
currentType.query.resultProcessors.push(function (r, y) {
|
|
561
564
|
r[f.key] = function (args, req, gqlInfo) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
562
565
|
var remult, myRepo, item, relRepo;
|
|
563
566
|
var _this = this;
|
|
@@ -567,7 +570,7 @@ function remultGraphql(options) {
|
|
|
567
570
|
case 1:
|
|
568
571
|
remult = _a.sent();
|
|
569
572
|
myRepo = remult.repo(meta.entityType);
|
|
570
|
-
item = myRepo.fromJson(
|
|
573
|
+
item = myRepo.fromJson(y);
|
|
571
574
|
relRepo = myRepo.relations(item)[f.key];
|
|
572
575
|
return [2 /*return*/, handleRequestWithDataApiContextBasedOnRepo_1(relRepo, function (dApi, response, setResult, arg1, meta) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
573
576
|
return tslib_1.__generator(this, function (_a) {
|
package/package.json
CHANGED
package/remult-knex/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
24
24
|
};
|
|
25
25
|
KnexDataProvider.prototype.getEntityDataProvider = function (entity) {
|
|
26
26
|
var e_1, _a;
|
|
27
|
-
if (!
|
|
27
|
+
if (!supportsJsonLoadingAndSaving(this.knex))
|
|
28
28
|
try {
|
|
29
29
|
for (var _b = tslib_1.__values(entity.fields.toArray()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
30
30
|
var f = _c.value;
|
|
@@ -739,7 +739,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
739
739
|
if ((0, RepositoryImplementation_js_1.isAutoIncrement)(x))
|
|
740
740
|
b.increments(cols_1.get(x).name);
|
|
741
741
|
else {
|
|
742
|
-
buildColumn(x, cols_1.get(x).name, b,
|
|
742
|
+
buildColumn(x, cols_1.get(x).name, b, supportsJsonDataStorage(_this.knex));
|
|
743
743
|
if (x == entity.idMetadata.field)
|
|
744
744
|
b.primary([cols_1.get(x).name]);
|
|
745
745
|
}
|
|
@@ -779,7 +779,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
779
779
|
case 2:
|
|
780
780
|
if (!!(_a.sent())) return [3 /*break*/, 4];
|
|
781
781
|
return [4 /*yield*/, logSql(this.knex.schema.alterTable(e.$entityName, function (b) {
|
|
782
|
-
buildColumn(col, colName, b,
|
|
782
|
+
buildColumn(col, colName, b, supportsJsonDataStorage(_this.knex));
|
|
783
783
|
}))];
|
|
784
784
|
case 3:
|
|
785
785
|
_a.sent();
|
|
@@ -856,10 +856,17 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
856
856
|
return KnexSchemaBuilder;
|
|
857
857
|
}());
|
|
858
858
|
exports.KnexSchemaBuilder = KnexSchemaBuilder;
|
|
859
|
-
function
|
|
859
|
+
function supportsJsonDataStorage(knex) {
|
|
860
|
+
var client = knex.client.config.client;
|
|
861
|
+
if ((client === null || client === void 0 ? void 0 : client.includes('sqlite3')) || (client === null || client === void 0 ? void 0 : client.includes('mssql')))
|
|
862
|
+
return false;
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
function supportsJsonLoadingAndSaving(knex) {
|
|
860
866
|
var client = knex.client.config.client;
|
|
861
867
|
if ((client === null || client === void 0 ? void 0 : client.includes('sqlite3')) ||
|
|
862
868
|
(client === null || client === void 0 ? void 0 : client.includes('mssql')) ||
|
|
869
|
+
(client === null || client === void 0 ? void 0 : client.includes('mysql2')) ||
|
|
863
870
|
(client === null || client === void 0 ? void 0 : client.includes('mysql')))
|
|
864
871
|
return false;
|
|
865
872
|
return true;
|
package/src/remult3/remult3.js
CHANGED
|
@@ -3,6 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
//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
|
|
4
4
|
//y1 - talk about the parameter issue with backend methods
|
|
5
5
|
//y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
|
|
6
|
+
//p1 - live query with include
|
|
7
|
+
//p1 - relation from order details to order gave a compound id info - and it is not true - same for the relation to product
|
|
8
|
+
//p1 - include admin in remult
|
|
9
|
+
//p1 - new row when there are relations, looks funny (see product)
|
|
10
|
+
//p1 - the + row in the bottom should extend to the full width
|
|
11
|
+
//p1 - adjust angular starter kit for latest angular (as is in tutorial)
|
|
12
|
+
/*y2 -
|
|
13
|
+
@Fields.string<Category>({
|
|
14
|
+
allowApiUpdate: (c) => getEntityRef(c).isNew(),
|
|
15
|
+
})
|
|
16
|
+
Description = ""*/
|
|
6
17
|
//y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
|
|
7
18
|
//y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
|
|
8
19
|
//y2 - how to run a transaction as a user
|