mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -58,6 +58,7 @@ export interface AclMatchInput {
|
||||
user: UserInfo;
|
||||
rec?: InfoView;
|
||||
newRec?: InfoView;
|
||||
docId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -200,17 +200,20 @@ export async function handleSandboxErrorOnPlatform<T>(
|
||||
platform.throwError('', `Invalid row id ${match[1]}`, 400);
|
||||
}
|
||||
match = message.match(
|
||||
/\[Sandbox] (?:KeyError u?'(?:Table \w+ has no column )?|ValueError No such table: )(\w+)/
|
||||
// eslint-disable-next-line max-len
|
||||
/\[Sandbox] (?:KeyError u?'(?:Table \w+ has no column )?|ValueError No such table: |ValueError No such column: )([\w.]+)/
|
||||
);
|
||||
if (match) {
|
||||
if (match[1] === tableId) {
|
||||
platform.throwError('', `Table not found "${tableId}"`, 404);
|
||||
} else if (colNames.includes(match[1])) {
|
||||
platform.throwError('', `Invalid column "${match[1]}"`, 400);
|
||||
} else if (colNames.includes(match[1].replace(`${tableId}.`, ''))) {
|
||||
platform.throwError('', `Table or column not found "${match[1]}"`, 404);
|
||||
}
|
||||
}
|
||||
platform.throwError('', `Error manipulating data: ${message}`, 400);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,8 +55,8 @@ function _compileNode(parsedAclFormula: ParsedAclFormula): AclEvalFunc {
|
||||
case 'GtE': return _compileAndCombine(args, ([a, b]) => a >= b);
|
||||
case 'Is': return _compileAndCombine(args, ([a, b]) => a === b);
|
||||
case 'IsNot': return _compileAndCombine(args, ([a, b]) => a !== b);
|
||||
case 'In': return _compileAndCombine(args, ([a, b]) => b.includes(a));
|
||||
case 'NotIn': return _compileAndCombine(args, ([a, b]) => !b.includes(a));
|
||||
case 'In': return _compileAndCombine(args, ([a, b]) => Boolean(b?.includes(a)));
|
||||
case 'NotIn': return _compileAndCombine(args, ([a, b]) => !b?.includes(a));
|
||||
case 'List': return _compileAndCombine(args, (values) => values);
|
||||
case 'Const': return constant(parsedAclFormula[1] as CellValue);
|
||||
case 'Name': {
|
||||
|
||||
@@ -746,6 +746,17 @@ export class DocWorkerApi {
|
||||
})
|
||||
);
|
||||
|
||||
this._app.delete('/api/docs/:docId/tables/:tableId/columns/:colId', canEdit,
|
||||
withDoc(async (activeDoc, req, res) => {
|
||||
const {tableId, colId} = req.params;
|
||||
const actions = [ [ 'RemoveColumn', tableId, colId ] ];
|
||||
await handleSandboxError(tableId, [colId],
|
||||
activeDoc.applyUserActions(docSessionFromRequest(req), actions)
|
||||
);
|
||||
res.json(null);
|
||||
})
|
||||
);
|
||||
|
||||
// Add a new webhook and trigger
|
||||
this._app.post('/api/docs/:docId/webhooks', isOwner, validate(WebhookSubscribeCollection),
|
||||
withDoc(async (activeDoc, req, res) => {
|
||||
|
||||
@@ -342,6 +342,7 @@ export class GranularAccess implements GranularAccessForBundle {
|
||||
public async inputs(docSession: OptDocSession): Promise<AclMatchInput> {
|
||||
return {
|
||||
user: await this._getUser(docSession),
|
||||
docId: this._docId
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,8 @@ function evaluateRule(ruleSet: RuleSet, input: AclMatchInput): PartialPermission
|
||||
// Anything it would explicitly allow, no longer allow through this rule.
|
||||
// Anything it would explicitly deny, go ahead and deny.
|
||||
pset = mergePartialPermissions(pset, mapValues(rule.permissions, val => (val === 'allow' ? "" : val)));
|
||||
log.warn("ACLRule for %s failed: %s", ruleSet.tableId, e.message);
|
||||
const prefixedTableName = input.docId ? `${input.docId}.${ruleSet.tableId}` : ruleSet.tableId;
|
||||
log.warn("ACLRule for %s (`%s`) failed: %s", prefixedTableName, rule.aclFormula, e.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,3 +224,14 @@ export function sanitizeWorksheetName(tableName: string): string {
|
||||
.replace(/^['\s]+/, '')
|
||||
.replace(/['\s]+$/, '');
|
||||
}
|
||||
|
||||
// This method exists only to make Piscina happier. With it,
|
||||
// Piscina will load this file using a regular require(),
|
||||
// which under Electron will deal fine with Electron's ASAR
|
||||
// app bundle. Without it, Piscina will try fancier methods
|
||||
// that aren't at the time of writing correctly patched to
|
||||
// deal with an ASAR app bundle, and so report that this
|
||||
// file doesn't exist instead of exporting an XLSX file.
|
||||
// https://github.com/gristlabs/grist-electron/issues/9
|
||||
export default function doNothing() {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user