Skip to content

Commit

Permalink
feat: adding example handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSinko committed Oct 5, 2020
1 parent 32007b4 commit 3a705b3
Show file tree
Hide file tree
Showing 9 changed files with 1,178 additions and 27 deletions.
21 changes: 16 additions & 5 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ class ContentFile extends FileBase {
}

const project = new AwsCdkConstructLibrary({
cdkVersion: "1.63.0",
cdkVersion: "1.66.0",
name: "@JordanSinko/the-slack-pipeline-approval",
authorName: "Jordan Sinko",
authorAddress: "jordan5sinko@gmail.com",
repository: "https://github.com/JordanSinko/the-slack-pipeline-approval",
scripts: {
format: "pretty-quick --staged",
"compile:construct": "jsii --silence-warnings=reserved-word --no-fix-peer-dependencies && jsii-docgen",
"compile:handler": "esbuild src/handler/index.ts --outfile=lib/handler/index.js --platform=node --format=cjs",
"compile:handlers": "npm run compile:requester && npm run compile:approver",
"compile:requester": "esbuild src/requester/index.ts --outfile=lib/requester/index.js --platform=node --format=cjs",
"compile:approver": "esbuild src/approver/index.ts --outfile=lib/approver/index.js --platform=node --format=cjs",
},
devDependencies: {
esbuild: "^0.7.9",
Expand All @@ -29,7 +31,16 @@ const project = new AwsCdkConstructLibrary({
"pretty-quick": "^3.0.2",
"npm-run-all": "^4.1.5",
},
cdkDependencies: ["@aws-cdk/core"],
cdkDependencies: [
"@aws-cdk/core",
"@aws-cdk/aws-codepipeline",
"@aws-cdk/aws-codepipeline-actions",
"@aws-cdk/aws-sns",
"@aws-cdk/aws-sns-subscriptions",
"@aws-cdk/aws-iam",
"@aws-cdk/aws-lambda",
"@aws-cdk/aws-apigatewayv2",
],
cdkTestDependencies: ["@aws-cdk/assert"],
eslint: false,
releaseWorkflow: true,
Expand All @@ -38,12 +49,12 @@ const project = new AwsCdkConstructLibrary({
npmRegistry: "npm.pkg.github.com",
});

project.addScript("compile", "npm run compile:construct && npm run compile:handler");
project.addScript("compile", "npm run compile:construct && npm run compile:handlers");

project.addFields({
jsii: {
...project.manifest.jsii,
excludeTypescript: ["src/handler"],
excludeTypescript: ["src/approver", "src/requester"],
},
});

Expand Down
158 changes: 155 additions & 3 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@

Name|Description
----|-----------
[SlackPipelineApproval](#jordansinko-the-slack-pipeline-approval-slackpipelineapproval)|*No description*
[SlackApproval](#jordansinko-the-slack-pipeline-approval-slackapproval)|*No description*
[SlackApprovalAction](#jordansinko-the-slack-pipeline-approval-slackapprovalaction)|*No description*


**Structs**

## class SlackPipelineApproval <a id="jordansinko-the-slack-pipeline-approval-slackpipelineapproval"></a>
Name|Description
----|-----------
[SlackApprovalActionProps](#jordansinko-the-slack-pipeline-approval-slackapprovalactionprops)|*No description*
[SlackApprovalProps](#jordansinko-the-slack-pipeline-approval-slackapprovalprops)|*No description*



## class SlackApproval <a id="jordansinko-the-slack-pipeline-approval-slackapproval"></a>



Expand All @@ -21,12 +30,155 @@ __Extends__: [Construct](#aws-cdk-core-construct)


```ts
new SlackPipelineApproval(scope: Construct, id: string)
new SlackApproval(scope: Construct, id: string, props: SlackApprovalProps)
```

* **scope** (<code>[Construct](#aws-cdk-core-construct)</code>) *No description*
* **id** (<code>string</code>) *No description*
* **props** (<code>[SlackApprovalProps](#jordansinko-the-slack-pipeline-approval-slackapprovalprops)</code>) *No description*
* **slackToken** (<code>string</code>) *No description*



### Properties


Name | Type | Description
-----|------|-------------
**approverHandler** | <code>[Function](#aws-cdk-aws-lambda-function)</code> | <span></span>
**props** | <code>[SlackApprovalProps](#jordansinko-the-slack-pipeline-approval-slackapprovalprops)</code> | <span></span>
**topic** | <code>[Topic](#aws-cdk-aws-sns-topic)</code> | <span></span>

### Methods


#### addApprovalAction(id, props) <a id="jordansinko-the-slack-pipeline-approval-slackapproval-addapprovalaction"></a>



```ts
addApprovalAction(id: string, props: SlackApprovalActionProps): SlackApprovalAction
```

* **id** (<code>string</code>) *No description*
* **props** (<code>[SlackApprovalActionProps](#jordansinko-the-slack-pipeline-approval-slackapprovalactionprops)</code>) *No description*
* **actionName** (<code>string</code>) The physical, human-readable name of the Action.
* **runOrder** (<code>number</code>) The runOrder property for this Action. __*Default*__: 1
* **variablesNamespace** (<code>string</code>) The name of the namespace to use for variables emitted by this action. __*Default*__: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set
* **role** (<code>[IRole](#aws-cdk-aws-iam-irole)</code>) The Role in which context's this Action will be executing in. __*Default*__: a new Role will be generated
* **additionalInformation** (<code>string</code>) Any additional information that you want to include in the notification email message. __*Optional*__
* **externalEntityLink** (<code>string</code>) URL you want to provide to the reviewer as part of the approval request. __*Default*__: the approval request will not have an external link
* **notificationTopic** (<code>[ITopic](#aws-cdk-aws-sns-itopic)</code>) Optional SNS topic to send notifications to when an approval is pending. __*Optional*__
* **notifyEmails** (<code>Array<string></code>) A list of email addresses to subscribe to notifications when this Action is pending approval. __*Optional*__
* **slackChannel** (<code>string</code>) *No description*
* **slackIcon** (<code>string</code>) *No description* __*Optional*__
* **slackUsername** (<code>string</code>) *No description* __*Optional*__

__Returns__:
* <code>[SlackApprovalAction](#jordansinko-the-slack-pipeline-approval-slackapprovalaction)</code>



## class SlackApprovalAction <a id="jordansinko-the-slack-pipeline-approval-slackapprovalaction"></a>



__Implements__: [IAction](#aws-cdk-aws-codepipeline-iaction)
__Extends__: [ManualApprovalAction](#aws-cdk-aws-codepipeline-actions-manualapprovalaction)

### Initializer




```ts
new SlackApprovalAction(approval: SlackApproval, id: string, props: SlackApprovalActionProps)
```

* **approval** (<code>[SlackApproval](#jordansinko-the-slack-pipeline-approval-slackapproval)</code>) *No description*
* **id** (<code>string</code>) *No description*
* **props** (<code>[SlackApprovalActionProps](#jordansinko-the-slack-pipeline-approval-slackapprovalactionprops)</code>) *No description*
* **actionName** (<code>string</code>) The physical, human-readable name of the Action.
* **runOrder** (<code>number</code>) The runOrder property for this Action. __*Default*__: 1
* **variablesNamespace** (<code>string</code>) The name of the namespace to use for variables emitted by this action. __*Default*__: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set
* **role** (<code>[IRole](#aws-cdk-aws-iam-irole)</code>) The Role in which context's this Action will be executing in. __*Default*__: a new Role will be generated
* **additionalInformation** (<code>string</code>) Any additional information that you want to include in the notification email message. __*Optional*__
* **externalEntityLink** (<code>string</code>) URL you want to provide to the reviewer as part of the approval request. __*Default*__: the approval request will not have an external link
* **notificationTopic** (<code>[ITopic](#aws-cdk-aws-sns-itopic)</code>) Optional SNS topic to send notifications to when an approval is pending. __*Optional*__
* **notifyEmails** (<code>Array<string></code>) A list of email addresses to subscribe to notifications when this Action is pending approval. __*Optional*__
* **slackChannel** (<code>string</code>) *No description*
* **slackIcon** (<code>string</code>) *No description* __*Optional*__
* **slackUsername** (<code>string</code>) *No description* __*Optional*__



### Properties


Name | Type | Description
-----|------|-------------
**approval** | <code>[SlackApproval](#jordansinko-the-slack-pipeline-approval-slackapproval)</code> | <span></span>
**id** | <code>string</code> | <span></span>
**slackProps** | <code>[SlackApprovalActionProps](#jordansinko-the-slack-pipeline-approval-slackapprovalactionprops)</code> | <span></span>
**slackAdditionalInformation**? | <code>string</code> | __*Optional*__

### Methods


#### protected bound(_scope, stage, options) <a id="jordansinko-the-slack-pipeline-approval-slackapprovalaction-bound"></a>

The method called when an Action is attached to a Pipeline.

This method is guaranteed to be called only once for each Action instance.

```ts
protected bound(_scope: Construct, stage: IStage, options: ActionBindOptions): ActionConfig
```

* **_scope** (<code>[Construct](#aws-cdk-core-construct)</code>) *No description*
* **stage** (<code>[IStage](#aws-cdk-aws-codepipeline-istage)</code>) *No description*
* **options** (<code>[ActionBindOptions](#aws-cdk-aws-codepipeline-actionbindoptions)</code>) *No description*
* **bucket** (<code>[IBucket](#aws-cdk-aws-s3-ibucket)</code>) *No description*
* **role** (<code>[IRole](#aws-cdk-aws-iam-irole)</code>) *No description*

__Returns__:
* <code>[ActionConfig](#aws-cdk-aws-codepipeline-actionconfig)</code>



## struct SlackApprovalActionProps <a id="jordansinko-the-slack-pipeline-approval-slackapprovalactionprops"></a>






Name | Type | Description
-----|------|-------------
**actionName** | <code>string</code> | The physical, human-readable name of the Action.
**slackChannel** | <code>string</code> | <span></span>
**additionalInformation**? | <code>string</code> | Any additional information that you want to include in the notification email message.<br/>__*Optional*__
**externalEntityLink**? | <code>string</code> | URL you want to provide to the reviewer as part of the approval request.<br/>__*Default*__: the approval request will not have an external link
**notificationTopic**? | <code>[ITopic](#aws-cdk-aws-sns-itopic)</code> | Optional SNS topic to send notifications to when an approval is pending.<br/>__*Optional*__
**notifyEmails**? | <code>Array<string></code> | A list of email addresses to subscribe to notifications when this Action is pending approval.<br/>__*Optional*__
**role**? | <code>[IRole](#aws-cdk-aws-iam-irole)</code> | The Role in which context's this Action will be executing in.<br/>__*Default*__: a new Role will be generated
**runOrder**? | <code>number</code> | The runOrder property for this Action.<br/>__*Default*__: 1
**slackIcon**? | <code>string</code> | __*Optional*__
**slackUsername**? | <code>string</code> | __*Optional*__
**variablesNamespace**? | <code>string</code> | The name of the namespace to use for variables emitted by this action.<br/>__*Default*__: a name will be generated, based on the stage and action names, if any of the action's variables were referenced - otherwise, no namespace will be set



## struct SlackApprovalProps <a id="jordansinko-the-slack-pipeline-approval-slackapprovalprops"></a>






Name | Type | Description
-----|------|-------------
**slackToken** | <code>string</code> | <span></span>



31 changes: 23 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"projen:upgrade": "yarn upgrade -L projen && CI=\"\" yarn projen",
"format": "pretty-quick --staged",
"compile:construct": "jsii --silence-warnings=reserved-word --no-fix-peer-dependencies && jsii-docgen",
"compile:handler": "esbuild src/handler/index.ts --outfile=lib/handler/index.js --platform=node --format=cjs",
"compile": "npm run compile:construct && npm run compile:handler",
"compile:handlers": "npm run compile:requester && npm run compile:approver",
"compile:requester": "esbuild src/requester/index.ts --outfile=lib/requester/index.js --platform=node --format=cjs",
"compile:approver": "esbuild src/approver/index.ts --outfile=lib/approver/index.js --platform=node --format=cjs",
"compile": "npm run compile:construct && npm run compile:handlers",
"watch": "jsii -w --silence-warnings=reserved-word --no-fix-peer-dependencies",
"build": "yarn test && yarn compile && yarn run package",
"package": "jsii-pacmak",
Expand All @@ -32,7 +34,7 @@
"organization": false
},
"devDependencies": {
"@aws-cdk/assert": "^1.63.0",
"@aws-cdk/assert": "^1.66.0",
"@types/jest": "^26.0.7",
"@types/node": "^10.17.0",
"esbuild": "^0.7.9",
Expand All @@ -52,13 +54,25 @@
"typescript": "^3.9.5"
},
"peerDependencies": {
"@aws-cdk/aws-kinesis": "^1.63.0",
"@aws-cdk/core": "^1.63.0",
"@aws-cdk/aws-apigatewayv2": "^1.66.0",
"@aws-cdk/aws-codepipeline": "^1.66.0",
"@aws-cdk/aws-codepipeline-actions": "^1.66.0",
"@aws-cdk/aws-iam": "^1.66.0",
"@aws-cdk/aws-lambda": "^1.66.0",
"@aws-cdk/aws-sns": "^1.66.0",
"@aws-cdk/aws-sns-subscriptions": "^1.66.0",
"@aws-cdk/core": "^1.66.0",
"constructs": "^3.0.4"
},
"dependencies": {
"@aws-cdk/aws-kinesis": "^1.63.0",
"@aws-cdk/core": "^1.63.0"
"@aws-cdk/aws-apigatewayv2": "^1.66.0",
"@aws-cdk/aws-codepipeline": "^1.66.0",
"@aws-cdk/aws-codepipeline-actions": "^1.66.0",
"@aws-cdk/aws-iam": "^1.66.0",
"@aws-cdk/aws-lambda": "^1.66.0",
"@aws-cdk/aws-sns": "^1.66.0",
"@aws-cdk/aws-sns-subscriptions": "^1.66.0",
"@aws-cdk/core": "^1.66.0"
},
"bundledDependencies": [],
"keywords": [
Expand Down Expand Up @@ -153,7 +167,8 @@
"rootDir": "src"
},
"excludeTypescript": [
"src/handler"
"src/approver",
"src/requester"
]
}
}
File renamed without changes.

0 comments on commit 3a705b3

Please sign in to comment.