Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add SNS support #35

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open

feat: add SNS support #35

wants to merge 34 commits into from

Conversation

skyrpex
Copy link
Contributor

@skyrpex skyrpex commented Mar 6, 2024

Basic implementation adding SNS support.

@sam-goodwin sam-goodwin marked this pull request as ready for review March 9, 2024 23:43
src/index.ts Outdated
Comment on lines 98 to 101
`PublishBatchRequestEntries.${k}.${i}`,
// `PublishBatchRequestEntries.${k}.${i + 1}`,
// `PublishBatchRequestEntry.${i + 1}.${k}`,
// `PublishBatchRequestEntries.${i + 1}.${k}`,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these valid? Are we supporting all possible cases or a subset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the PR was meant to be a draft, there's many things I need to clean up first

Copy link
Contributor Author

@skyrpex skyrpex Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally found the format for arrays. It's literally PublishBatchRequestEntries.member.${i + 1}.${memberKey}.

src/index.ts Outdated Show resolved Hide resolved
return {};
}

const formatResultXmlElement = (element: XmlElement) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a link to the schema we can include here for reference?

How comprehensive is this passing logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've seen, there's two types of responses. The simple ones (eg, Publish):

<PublishResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
    <PublishResult>
        <MessageId>567910cd-659e-55d4-8ccb-5aaf14679dc0</MessageId>
    </PublishResult>
    <ResponseMetadata>
        <RequestId>d74b8436-ae13-5ab4-a9ff-ce54dfea72a0</RequestId>
    </ResponseMetadata>
</PublishResponse>

Which is most of the actions, and they always look like this:

<{action}Response>
  <{action}Result>
    <{key}>{value}</{key}>
  </{action}Result>
</{action}Response>

But there's also GetTopicAttributes which looks like this:

<GetTopicAttributesResponse xmlns="https://sns.amazonaws.com/doc/2010-03-31/">
    <GetTopicAttributesResult>
        <Attributes>
            <entry>
                <key>Owner</key>
                <value>123456789012</value>
            </entry>
            <entry>
                <key>Policy</key>
                <value>...</value>
            </entry>
            <entry>
                <key>TopicArn</key>
                <value>arn:aws:sns:us-east-2:123456789012:My-Topic</value>
            </entry>
        </Attributes>
    </GetTopicAttributesResult>
    <ResponseMetadata>
        <RequestId>057f074c-33a7-11df-9540-99d0768312d3</RequestId>
    </ResponseMetadata>
</GetTopicAttributesResponse> 

Maybe there's more types, though.

test/sns.test.ts Outdated Show resolved Hide resolved
@skyrpex skyrpex marked this pull request as draft March 12, 2024 12:40
@skyrpex
Copy link
Contributor Author

skyrpex commented Mar 12, 2024

Added the following tests:

     ✓ publish
     ✓ publishBatch
     ✓ getTopicAttributes
     ✓ setTopicAttributes
     ✓ subscribe, unsubscribe
     ✓ listTopics

I think all API endpoints will work since it seems pretty consistent.

@skyrpex skyrpex marked this pull request as ready for review March 12, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SNS support
2 participants