@saltcorn/data 1.5.0-beta.8 → 1.5.0-rc.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/dist/base-plugin/actions.d.ts +221 -145
- package/dist/base-plugin/actions.d.ts.map +1 -1
- package/dist/base-plugin/actions.js +80 -12
- package/dist/base-plugin/actions.js.map +1 -1
- package/dist/base-plugin/fileviews.d.ts +3 -3
- package/dist/base-plugin/fileviews.js +20 -9
- package/dist/base-plugin/fileviews.js.map +1 -1
- package/dist/base-plugin/index.d.ts +2 -2
- package/dist/base-plugin/index.d.ts.map +1 -1
- package/dist/base-plugin/types.d.ts.map +1 -1
- package/dist/base-plugin/types.js +8 -5
- package/dist/base-plugin/types.js.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts +6 -2
- package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.js +17 -341
- package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.js +9 -3
- package/dist/base-plugin/viewtemplates/filter.js.map +1 -1
- package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/show.js +1 -0
- package/dist/base-plugin/viewtemplates/show.js.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts +16 -0
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.js +340 -3
- package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
- package/dist/base-plugin/viewtemplates/workflow-room.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/workflow-room.js +1 -1
- package/dist/base-plugin/viewtemplates/workflow-room.js.map +1 -1
- package/dist/db/connect.d.ts.map +1 -1
- package/dist/db/connect.js +4 -1
- package/dist/db/connect.js.map +1 -1
- package/dist/db/state.d.ts +11 -7
- package/dist/db/state.d.ts.map +1 -1
- package/dist/db/state.js +78 -12
- package/dist/db/state.js.map +1 -1
- package/dist/mobile-mocks/npm/dockerode.d.ts +1 -0
- package/dist/mobile-mocks/npm/dockerode.d.ts.map +1 -0
- package/dist/mobile-mocks/npm/dockerode.js +2 -0
- package/dist/mobile-mocks/npm/dockerode.js.map +1 -0
- package/dist/models/config.d.ts.map +1 -1
- package/dist/models/config.js +55 -12
- package/dist/models/config.js.map +1 -1
- package/dist/models/email.js.map +1 -1
- package/dist/models/expression.d.ts.map +1 -1
- package/dist/models/expression.js +29 -0
- package/dist/models/expression.js.map +1 -1
- package/dist/models/field.d.ts +5 -3
- package/dist/models/field.d.ts.map +1 -1
- package/dist/models/field.js +8 -2
- package/dist/models/field.js.map +1 -1
- package/dist/models/file.d.ts +18 -1
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +361 -43
- package/dist/models/file.js.map +1 -1
- package/dist/models/form.d.ts.map +1 -1
- package/dist/models/form.js.map +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/internal/push_message_helper.d.ts +42 -12
- package/dist/models/internal/push_message_helper.d.ts.map +1 -1
- package/dist/models/internal/push_message_helper.js +117 -50
- package/dist/models/internal/push_message_helper.js.map +1 -1
- package/dist/models/internal/s3_helpers.d.ts +54 -0
- package/dist/models/internal/s3_helpers.d.ts.map +1 -0
- package/dist/models/internal/s3_helpers.js +561 -0
- package/dist/models/internal/s3_helpers.js.map +1 -0
- package/dist/models/model.d.ts +1 -1
- package/dist/models/model.d.ts.map +1 -1
- package/dist/models/model.js.map +1 -1
- package/dist/models/notification.d.ts.map +1 -1
- package/dist/models/notification.js +2 -5
- package/dist/models/notification.js.map +1 -1
- package/dist/models/page.d.ts +1 -0
- package/dist/models/page.d.ts.map +1 -1
- package/dist/models/page.js +27 -24
- package/dist/models/page.js.map +1 -1
- package/dist/models/plugin.d.ts +11 -3
- package/dist/models/plugin.d.ts.map +1 -1
- package/dist/models/plugin.js +51 -12
- package/dist/models/plugin.js.map +1 -1
- package/dist/models/s3_helpers.d.ts +54 -0
- package/dist/models/s3_helpers.d.ts.map +1 -0
- package/dist/models/s3_helpers.js +505 -0
- package/dist/models/s3_helpers.js.map +1 -0
- package/dist/models/scheduler.d.ts.map +1 -1
- package/dist/models/scheduler.js +4 -1
- package/dist/models/scheduler.js.map +1 -1
- package/dist/models/table.d.ts +8 -3
- package/dist/models/table.d.ts.map +1 -1
- package/dist/models/table.js +121 -32
- package/dist/models/table.js.map +1 -1
- package/dist/models/user.d.ts +4 -4
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/user.js.map +1 -1
- package/dist/models/view.js +1 -1
- package/dist/models/view.js.map +1 -1
- package/dist/models/workflow_run.d.ts +1 -1
- package/dist/models/workflow_run.d.ts.map +1 -1
- package/dist/models/workflow_run.js +8 -2
- package/dist/models/workflow_run.js.map +1 -1
- package/dist/models/workflow_step.js +1 -1
- package/dist/models/workflow_step.js.map +1 -1
- package/dist/plugin-helper.d.ts.map +1 -1
- package/dist/plugin-helper.js +139 -15
- package/dist/plugin-helper.js.map +1 -1
- package/dist/standard-menu.js +2 -2
- package/dist/standard-menu.js.map +1 -1
- package/dist/test-utils/mocks.d.ts +203 -0
- package/dist/test-utils/mocks.d.ts.map +1 -0
- package/dist/test-utils/mocks.js +329 -0
- package/dist/test-utils/mocks.js.map +1 -0
- package/dist/tests/assertions.d.ts.map +1 -1
- package/dist/tests/assertions.js +10 -9
- package/dist/tests/assertions.js.map +1 -1
- package/dist/tests/auth.test.js +0 -68
- package/dist/tests/auth.test.js.map +1 -1
- package/dist/tests/calc.test.js +3 -62
- package/dist/tests/calc.test.js.map +1 -1
- package/dist/tests/exact_views.test.js +14 -14
- package/dist/tests/exact_views.test.js.map +1 -1
- package/dist/tests/show.test.js +1 -1
- package/dist/tests/show.test.js.map +1 -1
- package/dist/tests/table.test.js +0 -37
- package/dist/tests/table.test.js.map +1 -1
- package/dist/tests/table_sync_info.test.d.ts +2 -0
- package/dist/tests/table_sync_info.test.d.ts.map +1 -0
- package/dist/tests/table_sync_info.test.js +62 -0
- package/dist/tests/table_sync_info.test.js.map +1 -0
- package/dist/tests/user.test.js +4 -29
- package/dist/tests/user.test.js.map +1 -1
- package/dist/tests/view.test.js +0 -3
- package/dist/tests/view.test.js.map +1 -1
- package/dist/utils.d.ts +11 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +33 -3
- package/dist/utils.js.map +1 -1
- package/dist/viewable_fields.d.ts +172 -0
- package/dist/viewable_fields.d.ts.map +1 -0
- package/dist/viewable_fields.js +1562 -0
- package/dist/viewable_fields.js.map +1 -0
- package/dist/web-mobile-commons.d.ts +1 -1
- package/dist/web-mobile-commons.d.ts.map +1 -1
- package/dist/web-mobile-commons.js +19 -3
- package/dist/web-mobile-commons.js.map +1 -1
- package/package.json +14 -9
- package/webpack.config.js +3 -0
package/dist/plugin-helper.js
CHANGED
|
@@ -2400,6 +2400,10 @@ const json_list_to_external_table = (get_json_list, fields0, methods = {}) => {
|
|
|
2400
2400
|
return await getRows(where || {}, rest || {});
|
|
2401
2401
|
},
|
|
2402
2402
|
async getJoinedRow(opts = {}) {
|
|
2403
|
+
if (methods?.getJoinedRows) {
|
|
2404
|
+
const rows = await methods.getJoinedRows(opts);
|
|
2405
|
+
return rows.length > 0 ? rows[0] : null;
|
|
2406
|
+
}
|
|
2403
2407
|
const { where, ...rest } = opts;
|
|
2404
2408
|
const rows = await getRows(where || {}, rest || {});
|
|
2405
2409
|
return rows.length > 0 ? rows[0] : null;
|
|
@@ -2418,10 +2422,11 @@ const json_list_to_external_table = (get_json_list, fields0, methods = {}) => {
|
|
|
2418
2422
|
let data_in = await get_json_list(where, opts);
|
|
2419
2423
|
return data_in.length;
|
|
2420
2424
|
},
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
const
|
|
2424
|
-
|
|
2425
|
+
//copied from table
|
|
2426
|
+
async get_child_relations(allow_join_aggregations) {
|
|
2427
|
+
const cfields = await Field.find({ reftable_name: tbl.name }, { cached: true });
|
|
2428
|
+
let child_relations = [];
|
|
2429
|
+
let child_field_list = [];
|
|
2425
2430
|
for (const f of cfields) {
|
|
2426
2431
|
if (f.is_fkey) {
|
|
2427
2432
|
const table = Table.findOne({ id: f.table_id });
|
|
@@ -2433,9 +2438,24 @@ const json_list_to_external_table = (get_json_list, fields0, methods = {}) => {
|
|
|
2433
2438
|
child_relations.push({ key_field: f, table });
|
|
2434
2439
|
}
|
|
2435
2440
|
}
|
|
2436
|
-
|
|
2441
|
+
if (allow_join_aggregations) {
|
|
2442
|
+
for (const f of fields) {
|
|
2443
|
+
if (f.is_fkey && f.type !== "File") {
|
|
2444
|
+
const refTable = Table.findOne({ name: f.reftable_name });
|
|
2445
|
+
if (!refTable)
|
|
2446
|
+
throw new Error(`Unable to find table '${f.reftable_name}`);
|
|
2447
|
+
const join_crels = await refTable.get_child_relations(false);
|
|
2448
|
+
join_crels.child_relations.forEach(({ key_field, table }) => {
|
|
2449
|
+
child_field_list.push(`${f.name}->${table.name}.${key_field.name}`);
|
|
2450
|
+
child_relations.push({ key_field, table, through: f });
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
return { child_relations, child_field_list };
|
|
2437
2456
|
},
|
|
2438
|
-
|
|
2457
|
+
//copied from table
|
|
2458
|
+
async get_parent_relations(allow_double, allow_triple) {
|
|
2439
2459
|
let parent_relations = [];
|
|
2440
2460
|
let parent_field_list = [];
|
|
2441
2461
|
for (const f of fields) {
|
|
@@ -2443,39 +2463,143 @@ const json_list_to_external_table = (get_json_list, fields0, methods = {}) => {
|
|
|
2443
2463
|
const table = Table.findOne({ name: f.reftable_name });
|
|
2444
2464
|
if (!table)
|
|
2445
2465
|
throw new Error(`Unable to find table '${f.reftable_name}`);
|
|
2466
|
+
table.getFields();
|
|
2446
2467
|
if (!table.fields)
|
|
2447
2468
|
throw new Error(`The table '${f.reftable_name} has no fields.`);
|
|
2448
2469
|
for (const pf of table.fields.filter((f) => !f.calculated || f.stored)) {
|
|
2449
2470
|
parent_field_list.push(`${f.name}.${pf.name}`);
|
|
2450
|
-
|
|
2471
|
+
if (pf.is_fkey && pf.type !== "File" && allow_double) {
|
|
2472
|
+
const table1 = Table.findOne({ name: pf.reftable_name });
|
|
2473
|
+
if (!table1)
|
|
2474
|
+
throw new Error(`Unable to find table '${pf.reftable_name}`);
|
|
2475
|
+
await table1.getFields();
|
|
2476
|
+
if (!table1.fields)
|
|
2477
|
+
throw new Error(`The table '${pf.reftable_name} has no fields.`);
|
|
2478
|
+
if (table1.fields)
|
|
2479
|
+
for (const gpf of table1.fields.filter((f) => !f.calculated || f.stored)) {
|
|
2480
|
+
parent_field_list.push(`${f.name}.${pf.name}.${gpf.name}`);
|
|
2481
|
+
if (allow_triple && gpf.is_fkey && gpf.type !== "File") {
|
|
2482
|
+
const gpfTbl = Table.findOne({
|
|
2483
|
+
name: gpf.reftable_name,
|
|
2484
|
+
});
|
|
2485
|
+
if (gpfTbl) {
|
|
2486
|
+
const gpfFields = await gpfTbl.getFields();
|
|
2487
|
+
for (const ggpf of gpfFields.filter((f) => !f.calculated || f.stored)) {
|
|
2488
|
+
parent_field_list.push(`${f.name}.${pf.name}.${gpf.name}.${ggpf.name}`);
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
parent_relations.push({
|
|
2494
|
+
key_field: pf,
|
|
2495
|
+
through: f,
|
|
2496
|
+
table: table1,
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
parent_relations.push({ key_field: f, table });
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
const o2o_rels = await Field.find({
|
|
2504
|
+
reftable_name: tbl.name,
|
|
2505
|
+
is_unique: true,
|
|
2506
|
+
}, { cached: true });
|
|
2507
|
+
for (const relation of o2o_rels) {
|
|
2508
|
+
const related_table = Table.findOne({ id: relation.table_id });
|
|
2509
|
+
if (related_table) {
|
|
2510
|
+
const relfields = await related_table.getFields();
|
|
2511
|
+
for (const relfield of relfields) {
|
|
2512
|
+
parent_field_list.push(`${related_table.name}.${relation.name}->${relfield.name}`);
|
|
2513
|
+
parent_relations.push({
|
|
2514
|
+
key_field: relation,
|
|
2515
|
+
ontable: related_table,
|
|
2516
|
+
});
|
|
2451
2517
|
}
|
|
2452
2518
|
}
|
|
2453
2519
|
}
|
|
2454
2520
|
return { parent_relations, parent_field_list };
|
|
2455
2521
|
},
|
|
2456
|
-
|
|
2457
|
-
|
|
2522
|
+
//copied from table
|
|
2523
|
+
async get_relation_options() {
|
|
2524
|
+
return await Promise.all((await tbl.get_relation_data()).map(async ({ relationTable, relationField }) => {
|
|
2525
|
+
const path = `${relationTable.name}.${relationField.name}`;
|
|
2526
|
+
const relFields = await relationTable.getFields();
|
|
2527
|
+
const names = relFields
|
|
2528
|
+
.filter((f) => f.type !== "Key")
|
|
2529
|
+
.map((f) => f.name);
|
|
2530
|
+
return { relationPath: path, relationFields: names };
|
|
2531
|
+
}));
|
|
2458
2532
|
},
|
|
2459
|
-
|
|
2460
|
-
|
|
2533
|
+
//copied from table
|
|
2534
|
+
async get_relation_data(unique = true) {
|
|
2535
|
+
const result = [];
|
|
2536
|
+
const o2o_rels = await Field.find({
|
|
2537
|
+
reftable_name: tbl.name,
|
|
2538
|
+
is_unique: unique,
|
|
2539
|
+
}, { cached: true });
|
|
2540
|
+
for (const field of o2o_rels) {
|
|
2541
|
+
const relTbl = Table.findOne({ id: field.table_id });
|
|
2542
|
+
if (relTbl)
|
|
2543
|
+
result.push({ relationTable: relTbl, relationField: field });
|
|
2544
|
+
}
|
|
2545
|
+
return result;
|
|
2461
2546
|
},
|
|
2462
|
-
|
|
2547
|
+
//copied from table
|
|
2548
|
+
async get_join_field_options(allow_double, allow_triple) {
|
|
2463
2549
|
const result = [];
|
|
2464
2550
|
for (const f of fields) {
|
|
2465
2551
|
if (f.is_fkey && f.type !== "File") {
|
|
2466
2552
|
const table = Table.findOne({ name: f.reftable_name });
|
|
2553
|
+
if (!table)
|
|
2554
|
+
throw new Error(`Unable to find table '${f.reftable_name}`);
|
|
2555
|
+
table.getFields();
|
|
2556
|
+
if (!table.fields)
|
|
2557
|
+
throw new Error(`The table '${f.reftable_name} has no fields.`);
|
|
2467
2558
|
const subOne = {
|
|
2468
2559
|
name: f.name,
|
|
2469
2560
|
table: table.name,
|
|
2470
|
-
subFields:
|
|
2561
|
+
subFields: [],
|
|
2471
2562
|
fieldPath: f.name,
|
|
2472
2563
|
};
|
|
2473
2564
|
for (const pf of table.fields.filter((f) => !f.calculated || f.stored)) {
|
|
2474
2565
|
const subTwo = {
|
|
2475
2566
|
name: pf.name,
|
|
2476
|
-
subFields:
|
|
2567
|
+
subFields: [],
|
|
2477
2568
|
fieldPath: `${f.name}.${pf.name}`,
|
|
2478
2569
|
};
|
|
2570
|
+
if (pf.is_fkey && pf.type !== "File" && allow_double) {
|
|
2571
|
+
const table1 = Table.findOne({ name: pf.reftable_name });
|
|
2572
|
+
if (!table1)
|
|
2573
|
+
throw new Error(`Unable to find table '${pf.reftable_name}`);
|
|
2574
|
+
await table1.getFields();
|
|
2575
|
+
subTwo.table = table1.name;
|
|
2576
|
+
if (!table1.fields)
|
|
2577
|
+
throw new Error(`The table '${pf.reftable_name} has no fields.`);
|
|
2578
|
+
if (table1.fields)
|
|
2579
|
+
for (const gpf of table1.fields.filter((f) => !f.calculated || f.stored)) {
|
|
2580
|
+
const subThree = {
|
|
2581
|
+
name: gpf.name,
|
|
2582
|
+
subFields: [],
|
|
2583
|
+
fieldPath: `${f.name}.${pf.name}.${gpf.name}`,
|
|
2584
|
+
};
|
|
2585
|
+
if (allow_triple && gpf.is_fkey && gpf.type !== "File") {
|
|
2586
|
+
const gpfTbl = Table.findOne({
|
|
2587
|
+
name: gpf.reftable_name,
|
|
2588
|
+
});
|
|
2589
|
+
if (gpfTbl) {
|
|
2590
|
+
subThree.table = gpfTbl.name;
|
|
2591
|
+
const gpfFields = await gpfTbl.getFields();
|
|
2592
|
+
for (const ggpf of gpfFields.filter((f) => !f.calculated || f.stored)) {
|
|
2593
|
+
subThree.subFields.push({
|
|
2594
|
+
name: ggpf.name,
|
|
2595
|
+
fieldPath: `${f.name}.${pf.name}.${gpf.name}.${ggpf.name}`,
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
subTwo.subFields.push(subThree);
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2479
2603
|
subOne.subFields.push(subTwo);
|
|
2480
2604
|
}
|
|
2481
2605
|
result.push(subOne);
|
|
@@ -2601,7 +2725,7 @@ const run_action_column = async ({ col, req, ...rest }) => {
|
|
|
2601
2725
|
};
|
|
2602
2726
|
const failureAsyncHandler = (err) => {
|
|
2603
2727
|
const state = getState();
|
|
2604
|
-
state.log(2, `Asynchronous action error
|
|
2728
|
+
state.log(2, `Asynchronous action error`, err);
|
|
2605
2729
|
if (req.headers["page-load-tag"]) {
|
|
2606
2730
|
state.emitDynamicUpdate(db.getTenantSchema(), {
|
|
2607
2731
|
error: err.message || err,
|