( databaseExecuteCommand: DatabaseExecuteCommand, managedTableNames: string[], querySchema: QuerySchema, onIgnoredError: ((error: any) => void) | undefined, columnType: string, upsert: Upsert = defaultUpsert, encode?: (cellOrValue: any) => string | number, decode?: (field: string | number) => any, )
| 48 | export type Schema = IdSet2; |
| 49 | |
| 50 | export const getCommandFunctions = ( |
| 51 | databaseExecuteCommand: DatabaseExecuteCommand, |
| 52 | managedTableNames: string[], |
| 53 | querySchema: QuerySchema, |
| 54 | onIgnoredError: ((error: any) => void) | undefined, |
| 55 | columnType: string, |
| 56 | upsert: Upsert = defaultUpsert, |
| 57 | encode?: (cellOrValue: any) => string | number, |
| 58 | decode?: (field: string | number) => any, |
| 59 | ): [ |
| 60 | refreshSchema: () => Promise<void>, |
| 61 | loadTable: ( |
| 62 | tableName: string, |
| 63 | rowIdColumnName: string, |
| 64 | condition?: DpcTabularCondition, |
| 65 | contentSubIds?: Ids, |
| 66 | ) => Promise<Table>, |
| 67 | saveTable: ( |
| 68 | tableName: string, |
| 69 | rowIdColumnName: string, |
| 70 | content: |
| 71 | | { |
| 72 | [contentId: Id]: |
| 73 | | {[contentSubId: Id]: CellOrUndefined | ValueOrUndefined} |
| 74 | | undefined; |
| 75 | } |
| 76 | | undefined, |
| 77 | deleteEmptyColumns: boolean, |
| 78 | deleteEmptyTable: boolean, |
| 79 | partial?: boolean, |
| 80 | condition?: DpcTabularCondition, |
| 81 | contentSubIds?: Ids, |
| 82 | ) => Promise<void>, |
| 83 | transaction: <Return>(actions: () => Promise<Return>) => Promise<Return>, |
| 84 | ] => { |
| 85 | const schemaMap: Schema = mapNew(); |
| 86 | |
| 87 | const canSelect = (tableName: string, rowIdColumnName: string): boolean => |
| 88 | collHas(mapGet(schemaMap, tableName), rowIdColumnName); |
| 89 | |
| 90 | const refreshSchema = async (): Promise<void> => { |
| 91 | collClear(schemaMap); |
| 92 | arrayMap( |
| 93 | await querySchema(databaseExecuteCommand, managedTableNames), |
| 94 | ({tn, cn}) => setAdd(mapEnsure(schemaMap, tn, setNew<Id>), cn), |
| 95 | ); |
| 96 | }; |
| 97 | |
| 98 | const loadTable = async ( |
| 99 | tableName: string, |
| 100 | rowIdColumnName: string, |
| 101 | condition?: DpcTabularCondition, |
| 102 | contentSubIds?: Ids, |
| 103 | ): Promise<Table> => { |
| 104 | const contentSubIdSet = isUndefined(contentSubIds) |
| 105 | ? undefined |
| 106 | : setNew(contentSubIds); |
| 107 | const includeContentSubId = (contentSubId: Id): boolean => |
no test coverage detected
searching dependent graphs…