- Add provider contract (src/providers/provider.js): query() -> {rows,
rowsAffected, insertId}, callback transaction(fn), exec() for stored
procs, initialize/purge lifecycle
- Add MssqlProvider (src/providers/mssql/index.js) wrapping an mssql
ConnectionPool with normalized results, tx commit/rollback and
constraint-error classifiers (unique 2627/2601, FK 547)
- LibDashStore constructor now takes a provider instead of a pool
(breaking); adds LibDashStore.create() async factory; keeps pool as
transitional bridge until store modules are converted (see TODO.md)
- Move MSSQL-specific code into the provider: src/sql/* ->
src/providers/mssql/queries/*, src/schema.js ->
src/providers/mssql/schema.js, purge SQL -> purgeSql.js
- Update scripts, generate-schema-graph.js and package.json exports
(./providers/mssql, ./providers/provider)
- Add TODO.md with the remaining provider/SQLite migration plan
No SQL or behavioral changes.
23 lines
679 B
JavaScript
23 lines
679 B
JavaScript
import { CHECK_MANIFEST_ACCESS } from '../../providers/mssql/queries/manifestattachment.js';
|
|
import request from '../request.js';
|
|
|
|
/** Ensure manifest belongs to company. Throws Manifest not found. */
|
|
export default function resolveManifestAccess(pool) {
|
|
return async (companyId, manifestId, tx) => {
|
|
if (!Number.isFinite(manifestId)) {
|
|
throw new Error('Manifest not found');
|
|
}
|
|
|
|
const result = await request(pool, tx)
|
|
.input('manifestId', manifestId)
|
|
.input('companyId', companyId)
|
|
.query(CHECK_MANIFEST_ACCESS);
|
|
|
|
const row = result.recordset[0];
|
|
if (!row) {
|
|
throw new Error('Manifest not found');
|
|
}
|
|
return row;
|
|
};
|
|
}
|