Skip to content

Commit 4e0c691

Browse files
authored
🤖 Merge PR DefinitelyTyped#72060 [@types/oracledb] Add traceHandlerBase class and other types introduced from oracledb@6.7.0 by @sudarshan12s
1 parent 79d7419 commit 4e0c691

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

‎types/oracledb/index.d.ts‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4667,6 +4667,96 @@ declare namespace OracleDB {
46674667
function startup(creds: DBCredentials, opts?: StartupOptions): Promise<void>;
46684668
function startup(creds: DBCredentials, opts: StartupOptions, cb: (err: Error) => void): void;
46694669
function startup(creds: DBCredentials, cb: (err: Error) => void): void;
4670+
4671+
/**
4672+
* Type representing the trace context object.
4673+
*
4674+
* @since 6.7.0
4675+
*/
4676+
type TraceContext = Record<string, any>;
4677+
4678+
/**
4679+
* Base class for handling tracing.
4680+
*
4681+
* @since 6.7.0
4682+
*/
4683+
class TraceHandlerBase {
4684+
constructor();
4685+
4686+
/**
4687+
* Checks if sending traces is enabled.
4688+
*/
4689+
isEnabled(): boolean;
4690+
4691+
/**
4692+
* Enables sending traces.
4693+
*/
4694+
enable(): void;
4695+
4696+
/**
4697+
* Disables sending traces.
4698+
*/
4699+
disable(): void;
4700+
4701+
/**
4702+
* Called before invoking a public async method.
4703+
* @param traceContext input/output trace context object.
4704+
*/
4705+
onEnterFn(traceContext: TraceContext): void;
4706+
4707+
/**
4708+
* Called after invoking a public async method.
4709+
* @param traceContext input/output trace context object.
4710+
*/
4711+
onExitFn(traceContext: TraceContext): void;
4712+
4713+
/**
4714+
* Called when a round trip is begun.
4715+
* @param traceContext input/output trace context object.
4716+
*/
4717+
onBeginRoundTrip(traceContext: TraceContext): void;
4718+
4719+
/**
4720+
* Called when a round trip has ended.
4721+
* @param traceContext input/output trace context object.
4722+
*/
4723+
onEndRoundTrip(traceContext: TraceContext): void;
4724+
}
4725+
4726+
/*
4727+
* Assigns a derived object that implements the hooks in the TraceHandlerBase class.
4728+
* If no argument is provided, it clears the previously assigned instance.
4729+
*
4730+
* @since 6.7.0
4731+
*/
4732+
function setTraceInstance(obj?: TraceHandlerBase): void;
4733+
4734+
/*
4735+
* Retrieves the derived object that implements the hooks in the TraceHandlerBase class.
4736+
*
4737+
* @since 6.7.0
4738+
*/
4739+
function getTraceInstance(): TraceHandlerBase | undefined;
4740+
4741+
/*
4742+
* Verify if Tracing is enabled.
4743+
*
4744+
* @since 6.7.0
4745+
*/
4746+
function isEnabled(): boolean | undefined;
4747+
4748+
/**
4749+
* traceHandler property containing the TraceHandlerBase class.
4750+
*
4751+
* @since 6.7.0
4752+
*/
4753+
interface traceHandler {
4754+
TraceHandlerBase: typeof TraceHandlerBase;
4755+
setTraceInstance(obj?: TraceHandlerBase): void;
4756+
getTraceInstance(): TraceHandlerBase | undefined;
4757+
isEnabled(): boolean | undefined;
4758+
}
4759+
const traceHandler: traceHandler;
46704760
}
46714761

46724762
export = OracleDB;

‎types/oracledb/oracledb-tests.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,10 @@ export const version6Tests = async (): Promise<void> => {
705705

706706
console.log(defaultOracledb.DB_TYPE_VECTOR);
707707
console.log(defaultOracledb.JsonId);
708+
console.log(defaultOracledb.traceHandler.TraceHandlerBase);
709+
console.log(defaultOracledb.traceHandler.setTraceInstance());
710+
console.log(defaultOracledb.traceHandler.getTraceInstance());
711+
console.log(defaultOracledb.traceHandler.isEnabled());
708712

709713
// pass random 12 byte value to JsonId which is generated
710714
// by DB for SODA document.

0 commit comments

Comments
 (0)