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

TCORE-252 Refactor and Test AWS SQS Plugin for Monorepo #73

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,335 changes: 1,335 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

File renamed without changes.
24 changes: 24 additions & 0 deletions plugins/aws-sqs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@tago-io/tcore-plugin-amazon-sqs",
"version": "0.7.0",
"private": false,
"main": "./src/index.ts",
"type": "module",
"tcore": {
"name": "Amazon SQS",
"short_description": "Integrates the Amazon SQS queue with TagoCore",
"full_description": "./README.md",
"icon": "./assets/icon.png",
"types": ["queue"],
"permissions": ["device-data"],
"publisher": {
"name": "TagoIO",
"domain": "tago.io"
}
},
"dependencies": {
"@aws-sdk/client-sqs": "3.675.0",
"@rxfork/sqs-consumer": "^6.0.0"
},
"devDependencies": {}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IPluginConfigField } from "@tago-io/tcore-sdk/build/Types";
import type { IPluginConfigField } from "@tago-io/tcore-sdk/Types";

const configs: IPluginConfigField[] = [
{
Expand Down Expand Up @@ -36,15 +36,19 @@ const configs: IPluginConfigField[] = [
type: "password",
icon: "key",
required: true,
visibility_conditions: [{ condition: "=", field: "type", value: "config" }],
visibility_conditions: [
{ condition: "=", field: "type", value: "config" },
],
},
{
name: "AWS Secret Access Key",
field: "aws_secret_access_key",
type: "password",
icon: "key",
required: true,
visibility_conditions: [{ condition: "=", field: "type", value: "config" }],
visibility_conditions: [
{ condition: "=", field: "type", value: "config" },
],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { IDatabaseDeviceDataCreate } from "@tago-io/tcore-sdk/build/Types";
import { SQSClient, SQSClientConfig, SendMessageCommand, GetQueueAttributesCommand } from "@aws-sdk/client-sqs";
import {
GetQueueAttributesCommand,
SQSClient,
type SQSClientConfig,
SendMessageCommand,
} from "@aws-sdk/client-sqs";
import { Consumer } from "@rxfork/sqs-consumer";
import { QueueModule } from "@tago-io/tcore-sdk";
import { Config } from "./types";
import { consumeData } from "./consume-data";
import type { QueueModule } from "@tago-io/tcore-sdk";
import type { IDatabaseDeviceDataCreate } from "@tago-io/tcore-sdk/Types";
import { consumeData } from "./consume-data.ts";
import type { Config } from "./types.ts";

let client: SQSClient;

Expand All @@ -17,8 +22,12 @@ async function createConnection(this: QueueModule, config: Config) {
credentials:
config.type === "config"
? {
accessKeyId: config.aws_access_key_id || process.env?.AWS_ACCESS_KEY_ID!,
secretAccessKey: config.aws_secret_access_key || process.env?.AWS_SECRET_ACCESS_KEY!,
accessKeyId:
config.aws_access_key_id || process.env.AWS_ACCESS_KEY_ID || "",
secretAccessKey:
config.aws_secret_access_key ||
process.env.AWS_SECRET_ACCESS_KEY ||
"",
}
: undefined,
};
Expand Down Expand Up @@ -57,7 +66,10 @@ async function createConnection(this: QueueModule, config: Config) {
});
const result = await client.send(attributesCommand);

this.showMessage("info", `Queue running! Messages on queue ≈ ${result?.Attributes?.ApproximateNumberOfMessages}`);
this.showMessage(
"info",
`Queue running! Messages on queue ≈ ${result?.Attributes?.ApproximateNumberOfMessages}`,
);
}, 5000);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message } from "@aws-sdk/client-sqs";
import type { Message } from "@aws-sdk/client-sqs";
import { core } from "@tago-io/tcore-sdk";

async function consumeData(messages: Message[]): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QueueModule } from "@tago-io/tcore-sdk";
import { configs } from "./configurations";
import { addToQueue, closeConnection, createConnection } from "./connection";
import { configs } from "./configurations.ts";
import { addToQueue, closeConnection, createConnection } from "./connection.ts";

const amazonSQS = new QueueModule({
id: "amazon-sqs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ type Config = {
}
);

export { Config };
export type { Config };
12 changes: 0 additions & 12 deletions standalone-plugins/aws-sqs/.editorconfig

This file was deleted.

10 changes: 0 additions & 10 deletions standalone-plugins/aws-sqs/.eslintignore

This file was deleted.

29 changes: 0 additions & 29 deletions standalone-plugins/aws-sqs/.eslintrc.js

This file was deleted.

5 changes: 0 additions & 5 deletions standalone-plugins/aws-sqs/.gitignore

This file was deleted.

11 changes: 0 additions & 11 deletions standalone-plugins/aws-sqs/.prettierrc

This file was deleted.

10 changes: 0 additions & 10 deletions standalone-plugins/aws-sqs/.vscode/settings.json

This file was deleted.

29 changes: 0 additions & 29 deletions standalone-plugins/aws-sqs/esbuild/build.js

This file was deleted.

Loading
Loading