All files / realm/blong-access/meta/db db.ts

100% Statements 56/56
100% Branches 1/1
100% Functions 0/0
100% Lines 56/56

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 571x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x  
import {handler} from '@feasibleone/blong';
import {dirname, join} from 'path';
import {fileURLToPath} from 'url';
 
const _schemaDir = join(dirname(fileURLToPath(import.meta.url)), 'schema');
 
export default handler(() => ({
    config: {
        schema: {
            tables: {
                // Resource-backed tables use the generic CRUD's resource +
                // graph-edge handling (`ISchemaTable.resource` / `edges`):
                //   - `access.role` — full generic CRUD (name join, hasCapability
                //     pivot edges, reverse hasRole cleanup on remove).
                //   - browse-only entities — generic find joins resourceName as
                //     `${object}Name` (`resource: true`).
                // `access.user` / `access.capability` keep their custom handlers
                // (credentials, session cleanup, and the CRUD-action pivot).
                'access.user': 200,
                'access.credential': 201,
                'access.action': {order: 202, resource: true},
                'access.capability': {order: 203, resource: true},
                'access.role': {
                    order: 204,
                    resource: true,
                    edges: [
                        {
                            predicate: 'hasCapability',
                            table: 'access_capability',
                            object: 'capability',
                            objectKey: 'capabilityId',
                            nameField: 'capabilityName',
                            granted: true,
                        },
                        {
                            // Reverse edge cleaned up on remove (users → role).
                            predicate: 'hasRole',
                            reverse: true,
                        },
                    ],
                },
                'access.access': {order: 205, resource: true},
                'access.policy': {order: 206, resource: true},
                'access.flow': {order: 207, resource: true},
                'access.session': 208,
                'access.audit': 209,
                // Record-level ACL rules (explicit allow/deny per principal,
                // action and target).  Not resource-backed: a rule is identified
                // by its ULID and displayed through read-time name joins.
                'access.acl': 210,
            },
            procedurePaths: [_schemaDir],
            accessPathRefresh: true,
        },
    },
}));