-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,575 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ jobs: | |
redis | ||
sagemaker | ||
simtools | ||
sns | ||
tf | ||
tsoa | ||
vite | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: sns-pull | ||
on: | ||
pull_request: | ||
paths: | ||
- sns/** | ||
jobs: | ||
build-sns: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: sns | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
registry-url: https://registry.npmjs.org | ||
- name: Install winglang | ||
run: npm i -g winglang | ||
- name: Install dependencies | ||
run: npm install --include=dev | ||
working-directory: sns | ||
- name: Test | ||
run: wing test | ||
working-directory: sns | ||
- name: Pack | ||
run: wing pack | ||
working-directory: sns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: sns-release | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- sns/** | ||
- "!sns/package-lock.json" | ||
jobs: | ||
build-sns: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
sparse-checkout: sns | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
registry-url: https://registry.npmjs.org | ||
- name: Install winglang | ||
run: npm i -g winglang | ||
- name: Install dependencies | ||
run: npm install --include=dev | ||
working-directory: sns | ||
- name: Test | ||
run: wing test | ||
working-directory: sns | ||
- name: Pack | ||
run: wing pack | ||
working-directory: sns | ||
- name: Get package version | ||
run: echo WINGLIB_VERSION=$(node -p "require('./package.json').version") >> | ||
"$GITHUB_ENV" | ||
working-directory: sns | ||
- name: Publish | ||
run: npm publish --access=public --registry https://registry.npmjs.org --tag | ||
latest *.tgz | ||
working-directory: sns | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Tag commit | ||
uses: tvdias/[email protected] | ||
with: | ||
repo-token: ${{ secrets.PROJEN_GITHUB_TOKEN }} | ||
tag: sns-v${{ env.WINGLIB_VERSION }} | ||
- name: GitHub release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: sns v${{ env.WINGLIB_VERSION }} | ||
tag_name: sns-v${{ env.WINGLIB_VERSION }} | ||
files: "*.tgz" | ||
token: ${{ secrets.PROJEN_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Wing | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# sns | ||
|
||
This library allows you to interact with the AWS SNS Service | ||
|
||
## Prerequisites | ||
|
||
* [winglang](https://winglang.io). | ||
|
||
## Installation | ||
|
||
```sh | ||
npm i @winglibs/sns | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
bring sns; | ||
|
||
let client = new sns.MobileClient(); | ||
``` | ||
|
||
## License | ||
|
||
This library is licensed under the [MIT License](./LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default interface extern { | ||
_publish: (options: PublishOptions) => Promise<PublishResult>, | ||
} | ||
export interface MessageAttributeValue { | ||
readonly DataType?: (string) | undefined; | ||
readonly StringValue?: (string) | undefined; | ||
} | ||
export interface PublishOptions { | ||
readonly Message?: (string) | undefined; | ||
readonly MessageAttributes?: (Readonly<Record<string, MessageAttributeValue>>) | undefined; | ||
readonly PhoneNumber?: (string) | undefined; | ||
readonly Subject?: (string) | undefined; | ||
readonly TopicArn?: (string) | undefined; | ||
} | ||
export interface PublishResult { | ||
readonly MessageId?: (string) | undefined; | ||
readonly SequenceNumber?: (string) | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { PublishCommand, SNSClient } from "@aws-sdk/client-sns"; | ||
import type extern from "./aws.extern"; | ||
|
||
export const _publish: extern["_publish"] = async ({ | ||
Message, | ||
MessageAttributes, | ||
PhoneNumber, | ||
Subject, | ||
TopicArn, | ||
}) => { | ||
const client = new SNSClient(); | ||
const command = new PublishCommand({ | ||
Message, | ||
MessageAttributes: MessageAttributes as any, | ||
PhoneNumber, | ||
Subject, | ||
TopicArn, | ||
}); | ||
const { MessageId, SequenceNumber } = await client.send(command); | ||
return { | ||
MessageId, | ||
SequenceNumber, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
bring "./lib.w" as sns; | ||
|
||
let client = new sns.MobileClient(); | ||
|
||
test "will send an SMS" { | ||
client.publish(PhoneNumber: "+14155552671", Message: "Hello"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
bring util; | ||
bring "./types.w" as types; | ||
bring "./sim.w" as sim; | ||
bring "./tfaws.w" as tfaws; | ||
|
||
pub class MobileClient impl types.IMobileClient { | ||
inner: types.IMobileClient; | ||
new() { | ||
let target = util.env("WING_TARGET"); | ||
if target == "sim" { | ||
this.inner = new sim.MobileClient(); | ||
} elif target == "tf-aws" { | ||
this.inner = new tfaws.MobileClient(); | ||
} else { | ||
throw "Unsupported target {target}"; | ||
} | ||
} | ||
|
||
pub inflight publish(options: types.PublishOptions): types.PublishResult { | ||
return this.inner.publish(options); | ||
} | ||
} |
Oops, something went wrong.