(core) Use MetaTableData more

Summary:
Add more method overrides to MetaTableData for extra type safety.

Use MetaTableData, MetaRowRecord, and getMetaTable in more places.

Test Plan: Mostly it just has to compile. Tested manually that types are being checked more strictly now, e.g. by adding a typo to property names. Some type casting has also been removed.

Reviewers: dsagal

Reviewed By: dsagal

Subscribers: dsagal

Differential Revision: https://phab.getgrist.com/D3168
This commit is contained in:
Alex Hall
2021-12-07 13:21:16 +02:00
parent 116fb15eda
commit faec8177ab
18 changed files with 157 additions and 126 deletions

View File

@@ -675,7 +675,7 @@ export class GristDoc extends DisposableWithEvents {
}
public hasGranularAccessRules(): boolean {
const rulesTable = this.docData.getTable('_grist_ACLRules')!;
const rulesTable = this.docData.getMetaTable('_grist_ACLRules');
// To check if there are rules, ignore the default no-op rule created for an older incarnation
// of ACLs. It exists in older documents, and is still created for new ones. We detect it by
// the use of the deprecated 'permissions' field, and not the new 'permissionsText' field.

View File

@@ -90,7 +90,7 @@ async function updateViewSections(gristDoc: GristDoc, destViewSections: ViewSect
const records: RowRecord[] = [];
for (const srcViewSection of srcViewSections) {
const viewSectionLayoutSpec = patchLayoutSpec(srcViewSection.layoutSpecObj.peek(), fieldsMap);
const record = gristDoc.docData.getTable('_grist_Views_section')!.getRecord(srcViewSection.getRowId())!;
const record = gristDoc.docData.getMetaTable('_grist_Views_section').getRecord(srcViewSection.getRowId())!;
records.push({
...record,
layoutSpec: JSON.stringify(viewSectionLayoutSpec),
@@ -126,7 +126,7 @@ async function updateViewFields(gristDoc: GristDoc, destViewSections: ViewSectio
const srcViewFields: ViewFieldRec[] = srcViewSection!.viewFields.peek().peek();
const parentId = destViewSection!.getRowId();
for (const field of srcViewFields) {
const record = docData.getTable('_grist_Views_section_field')!.getRecord(field.getRowId())!;
const record = docData.getMetaTable('_grist_Views_section_field').getRecord(field.getRowId())!;
fieldsToAdd.push({...record, parentId});
}
}