@abapify/adt-locks
v0.3.6
Published
ADT lock/unlock operations and lock store management
Downloads
503
Readme
@abapify/adt-locks
ADT lock/unlock operations and lock-store management. This is the single
lock implementation used across the abapify/adt-cli monorepo: it wraps the
SAP ADT lock/unlock REST endpoints, parses their XML responses, and persists
lock handles in a pluggable store so multi-object operations can release
locks reliably on failure.
Install
npm i @abapify/adt-locks
# or
bun add @abapify/adt-locksUsage
Single lock / unlock via the service, backed by a file-based lock store:
import { createLockService, FileLockStore } from '@abapify/adt-locks';
const locks = createLockService(client, { store: new FileLockStore() });
const handle = await locks.lock('/sap/bc/adt/oo/classes/zcl_test');
try {
// ... make changes via the ADT client ...
} finally {
await locks.unlock('/sap/bc/adt/oo/classes/zcl_test', {
lockHandle: handle.handle,
});
}Batch session for N objects with best-effort rollback on failure:
import { createBatchLockSession } from '@abapify/adt-locks';
const session = createBatchLockSession(locks, {
targets: [
{ uri: '/sap/bc/adt/oo/classes/zcl_a' },
{ uri: '/sap/bc/adt/oo/classes/zcl_b' },
],
});
const acquired = await session.acquireAll();
// ... do work ...
await session.releaseAll();Role in the monorepo
- Single source of truth for ADT locks.
@abapify/adk(save flow),@abapify/adt-export, and CLI commands all delegate toLockServicerather than reimplementing lock/unlock. - Depends only on
@abapify/adt-clientfor transport; it does not know about specific object types, which keeps it reusable across plugins. - Lock handles are bound to the client's security session; see the
monorepo
AGENTS.mdfor the 3-step CSRF / security-session protocol that must be in place before any call here will succeed.
Related
License
MIT
