@collaborne/custom-cloudformation-resources
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -27,2 +27,3 @@ import type { ObjectSchema, SchemaType } from '@collaborne/json-schema-to-type'; | ||
private requestQueue; | ||
private currentRequest?; | ||
constructor(schema: S, logicalResourceId: string, logger: Logger); | ||
@@ -33,2 +34,12 @@ abstract createResource(physicalResourceId: string, params: SchemaType<S>, continuationAttributes?: ContinuationAttributes): Promise<Response<ResourceAttributes> | ContinuationRequired<ContinuationAttributes>>; | ||
handleRequest(request: CustomResourceRequest | ContinuedCustomResourceRequest<ContinuationAttributes>): Promise<ResponseStatus>; | ||
/** | ||
* Get the request that is currently being processed | ||
* | ||
* This is mostly intended for integrations that want to watch the state of their | ||
* resources, the returned value should not be changed in any way. | ||
* | ||
* @returns the current request when called during an execution of {@link handleRequest}, otherwise `undefined` | ||
*/ | ||
get request(): undefined | CustomResourceRequest | ContinuedCustomResourceRequest<ContinuationAttributes>; | ||
protected handleRequestInner(request: CustomResourceRequest | ContinuedCustomResourceRequest<ContinuationAttributes>): Promise<ResponseStatus>; | ||
protected processRequest(request: CustomResourceRequest | ContinuedCustomResourceRequest<ContinuationAttributes>): Promise<{ | ||
@@ -35,0 +46,0 @@ status: ResponseStatus; |
@@ -22,3 +22,23 @@ "use strict"; | ||
} | ||
handleRequest(request) { | ||
async handleRequest(request) { | ||
try { | ||
this.currentRequest = request; | ||
return await this.handleRequestInner(request); | ||
} | ||
finally { | ||
this.currentRequest = undefined; | ||
} | ||
} | ||
/** | ||
* Get the request that is currently being processed | ||
* | ||
* This is mostly intended for integrations that want to watch the state of their | ||
* resources, the returned value should not be changed in any way. | ||
* | ||
* @returns the current request when called during an execution of {@link handleRequest}, otherwise `undefined` | ||
*/ | ||
get request() { | ||
return this.currentRequest; | ||
} | ||
handleRequestInner(request) { | ||
let resolveRequest; | ||
@@ -130,3 +150,3 @@ let rejectRequest; | ||
const cronExpression = `${Math.max(now.getMinutes() + 1, when.getMinutes())} ${when.getHours()} ${when.getDate()} ${when.getMonth() + 1} ? ${when.getFullYear()}`; | ||
this.logger.log(`Scheduling continuation using CWE rule ${continuationRuleName} after ${continuationAfter}s (at ${cronExpression}) `); | ||
this.logger.log(`Scheduling continuation using CWE rule ${continuationRuleName} after ${continuationAfter}s (at ${cronExpression})`); | ||
const schedulePutRuleParams = { | ||
@@ -133,0 +153,0 @@ Name: continuationRuleName, |
{ | ||
"name": "@collaborne/custom-cloudformation-resources", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Custom CloudFormation resources", | ||
@@ -45,3 +45,4 @@ "main": "dist/index.js", | ||
"engines": { | ||
"node": ">=14.14.0" | ||
"node": ">=14.14.0", | ||
"npm": ">=7" | ||
}, | ||
@@ -48,0 +49,0 @@ "dependencies": { |
@@ -60,2 +60,6 @@ import { CloudWatchEvents } from 'aws-sdk'; | ||
private currentRequest?: | ||
| CustomResourceRequest | ||
| ContinuedCustomResourceRequest<ContinuationAttributes>; | ||
constructor( | ||
@@ -92,3 +96,3 @@ protected readonly schema: S, | ||
public handleRequest( | ||
public async handleRequest( | ||
request: | ||
@@ -98,2 +102,30 @@ | CustomResourceRequest | ||
): Promise<ResponseStatus> { | ||
try { | ||
this.currentRequest = request; | ||
return await this.handleRequestInner(request); | ||
} finally { | ||
this.currentRequest = undefined; | ||
} | ||
} | ||
/** | ||
* Get the request that is currently being processed | ||
* | ||
* This is mostly intended for integrations that want to watch the state of their | ||
* resources, the returned value should not be changed in any way. | ||
* | ||
* @returns the current request when called during an execution of {@link handleRequest}, otherwise `undefined` | ||
*/ | ||
public get request(): | ||
| undefined | ||
| CustomResourceRequest | ||
| ContinuedCustomResourceRequest<ContinuationAttributes> { | ||
return this.currentRequest; | ||
} | ||
protected handleRequestInner( | ||
request: | ||
| CustomResourceRequest | ||
| ContinuedCustomResourceRequest<ContinuationAttributes>, | ||
): Promise<ResponseStatus> { | ||
let resolveRequest: (response: ResponseStatus) => void; | ||
@@ -248,3 +280,3 @@ let rejectRequest: (error: Error) => void; | ||
this.logger.log( | ||
`Scheduling continuation using CWE rule ${continuationRuleName} after ${continuationAfter}s (at ${cronExpression}) `, | ||
`Scheduling continuation using CWE rule ${continuationRuleName} after ${continuationAfter}s (at ${cronExpression})`, | ||
); | ||
@@ -251,0 +283,0 @@ const schedulePutRuleParams: CloudWatchEvents.PutRuleRequest = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
167006
2030