Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
eladcon committed May 19, 2024
1 parent e0acf87 commit 2a9b097
Show file tree
Hide file tree
Showing 18 changed files with 1,575 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,39 @@ jobs:
cd simtools
wing test
timeout_minutes: 5
canary-sns:
name: Test 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 and dependencies
uses: nick-fields/retry@v3
with:
max_attempts: 3
command: npm i -g winglang --loglevel verbose
timeout_minutes: 3
- name: Install dependencies
uses: nick-fields/retry@v3
with:
max_attempts: 3
command: cd sns && npm i --include=dev --loglevel verbose
timeout_minutes: 3
- name: Run tests
uses: nick-fields/retry@v3
with:
max_attempts: 3
command: |-
cd sns
wing test
timeout_minutes: 5
canary-tf:
name: Test tf
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull-request-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
redis
sagemaker
simtools
sns
tf
tsoa
vite
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/sns-pull.yaml
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
54 changes: 54 additions & 0 deletions .github/workflows/sns-release.yaml
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 }}
6 changes: 6 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ pull_request_rules:
- -check-failure=build-simtools
- -check-pending=build-simtools
- -check-stale=build-simtools
- -check-failure=build-sns
- -check-pending=build-sns
- -check-stale=build-sns
- -check-failure=build-tf
- -check-pending=build-tf
- -check-stale=build-tf
Expand Down Expand Up @@ -186,6 +189,9 @@ pull_request_rules:
- -check-failure=build-simtools
- -check-pending=build-simtools
- -check-stale=build-simtools
- -check-failure=build-sns
- -check-pending=build-sns
- -check-stale=build-sns
- -check-failure=build-tf
- -check-pending=build-tf
- -check-stale=build-tf
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ publishing them for you.
| [redis](./redis) | [@winglibs/redis](https://www.npmjs.com/package/@winglibs/redis) | sim |
| [sagemaker](./sagemaker) | [@winglibs/sagemaker](https://www.npmjs.com/package/@winglibs/sagemaker) | sim, tf-aws |
| [simtools](./simtools) | [@winglibs/simtools](https://www.npmjs.com/package/@winglibs/simtools) | sim |
| [sns](./sns) | [@winglibs/sns](https://www.npmjs.com/package/@winglibs/sns) | sim, tf-aws |
| [tf](./tf) | [@winglibs/tf](https://www.npmjs.com/package/@winglibs/tf) | sim, tf-aws |
| [tsoa](./tsoa) | [@winglibs/tsoa](https://www.npmjs.com/package/@winglibs/tsoa) | sim |
| [vite](./vite) | [@winglibs/vite](https://www.npmjs.com/package/@winglibs/vite) | sim, tf-aws |
Expand Down
2 changes: 2 additions & 0 deletions sns/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
node_modules/
21 changes: 21 additions & 0 deletions sns/LICENSE
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.
25 changes: 25 additions & 0 deletions sns/README.md
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).
18 changes: 18 additions & 0 deletions sns/aws.extern.d.ts
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;
}
24 changes: 24 additions & 0 deletions sns/aws.ts
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,
};
};
7 changes: 7 additions & 0 deletions sns/lib.test.w
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");
}
22 changes: 22 additions & 0 deletions sns/lib.w
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);
}
}
Loading

0 comments on commit 2a9b097

Please sign in to comment.