Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/Runtime/InvokeContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class InvokeContext {
this.headers = _enforceLowercaseKeys(headers);
}

private getHeaderValue(key: string): string | undefined {
#getHeaderValue(key: string): string | undefined {
const headerVal = this.headers[key];

switch (typeof headerVal) {
Expand All @@ -48,7 +48,7 @@ export default class InvokeContext {
* The invokeId for this request.
*/
get invokeId(): string {
const id = this.getHeaderValue(INVOKE_HEADER.AWSRequestId);
const id = this.#getHeaderValue(INVOKE_HEADER.AWSRequestId);
assert.ok(id, "invocation id is missing or invalid");
return id;
}
Expand All @@ -57,7 +57,7 @@ export default class InvokeContext {
* The header data for this request.
*/
get headerData(): IHeaderData {
return this._headerData();
return this.#headerData();
}

/**
Expand All @@ -80,19 +80,19 @@ export default class InvokeContext {
attachEnvironmentData(
callbackContext: ICallbackContext
): ICallbackContext & IEnvironmentData & IHeaderData {
this._forwardXRay();
this.#forwardXRay();
return Object.assign(
callbackContext,
this._environmentalData(),
this._headerData()
this.#environmentalData(),
this.#headerData()
);
}

/**
* All parts of the user-facing context object which are provided through
* environment variables.
*/
private _environmentalData(): IEnvironmentData {
#environmentalData(): IEnvironmentData {
return {
functionVersion: process.env["AWS_LAMBDA_FUNCTION_VERSION"],
functionName: process.env["AWS_LAMBDA_FUNCTION_NAME"],
Expand All @@ -106,21 +106,21 @@ export default class InvokeContext {
* All parts of the user-facing context object which are provided through
* request headers.
*/
private _headerData(): IHeaderData {
#headerData(): IHeaderData {
const deadline = parseInt(
this.getHeaderValue(INVOKE_HEADER.DeadlineMs) || ""
this.#getHeaderValue(INVOKE_HEADER.DeadlineMs) || ""
);
return {
clientContext: _parseJson(
this.getHeaderValue(INVOKE_HEADER.ClientContext),
this.#getHeaderValue(INVOKE_HEADER.ClientContext),
"ClientContext"
),
identity: _parseJson(
this.getHeaderValue(INVOKE_HEADER.CognitoIdentity),
this.#getHeaderValue(INVOKE_HEADER.CognitoIdentity),
"CognitoIdentity"
),
invokedFunctionArn: this.getHeaderValue(INVOKE_HEADER.ARN),
awsRequestId: this.getHeaderValue(INVOKE_HEADER.AWSRequestId),
invokedFunctionArn: this.#getHeaderValue(INVOKE_HEADER.ARN),
awsRequestId: this.#getHeaderValue(INVOKE_HEADER.AWSRequestId),
getRemainingTimeInMillis: function () {
return deadline - Date.now();
},
Expand All @@ -130,9 +130,9 @@ export default class InvokeContext {
/**
* Forward the XRay header into the environment variable.
*/
private _forwardXRay(): void {
if (this.getHeaderValue(INVOKE_HEADER.XRayTrace)) {
process.env["_X_AMZN_TRACE_ID"] = this.getHeaderValue(
#forwardXRay(): void {
if (this.#getHeaderValue(INVOKE_HEADER.XRayTrace)) {
process.env["_X_AMZN_TRACE_ID"] = this.#getHeaderValue(
INVOKE_HEADER.XRayTrace
);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/Runtime/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export default class Runtime {
);

try {
this._setErrorCallbacks(invokeContext.invokeId);
this._setDefaultExitListener(invokeContext.invokeId);
this.#setErrorCallbacks(invokeContext.invokeId);
this.#setDefaultExitListener(invokeContext.invokeId);

const result = this.handler(
JSON.parse(bodyJson),
Expand All @@ -94,7 +94,7 @@ export default class Runtime {
* Replace the error handler callbacks.
* @param {String} invokeId
*/
private _setErrorCallbacks(invokeId: string): void {
#setErrorCallbacks(invokeId: string): void {
this.errorCallbacks.uncaughtException = (error: Error): void => {
this.client.postInvocationError(error, invokeId, () => {
process.exit(129);
Expand All @@ -112,7 +112,7 @@ export default class Runtime {
* called and the handler is not async.
* CallbackContext replaces the listener if a callback is invoked.
*/
private _setDefaultExitListener(invokeId: string): void {
#setDefaultExitListener(invokeId: string): void {
BeforeExitListener.set(() => {
this.client.postInvocationResponse(null, invokeId, () =>
this.scheduleIteration()
Expand Down
28 changes: 14 additions & 14 deletions test/utils/StdoutReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ const {
* patch.
*/
module.exports = class StdoutReporter extends reporters.Base {
private _alreadyWritten: boolean;
private _report: string;
private _indents: number;
#alreadyWritten: boolean;
#report: string;
#indents: number;

public constructor(runner: Runner, options: MochaOptions) {
constructor(runner: Runner, options: MochaOptions) {
super(runner, options);

this._alreadyWritten = false;
this._report = "";
this._indents = 0;
this.#alreadyWritten = false;
this.#report = "";
this.#indents = 0;
const stats = runner.stats;

runner
Expand Down Expand Up @@ -66,25 +66,25 @@ module.exports = class StdoutReporter extends reporters.Base {
}

indent() {
return Array(this._indents).join(" ");
return Array(this.#indents).join(" ");
}

increaseIndent() {
this._indents++;
this.#indents++;
}

decreaseIndent() {
this._indents--;
this.#indents--;
}

log(line) {
this._report += `${this.indent()}${line}\n`;
this.#report += `${this.indent()}${line}\n`;
}

dumpReport() {
if (!this._alreadyWritten) {
process.stdout.write(this._report);
this._alreadyWritten = true;
if (!this.#alreadyWritten) {
process.stdout.write(this.#report);
this.#alreadyWritten = true;
}
}
};