Skip to content

Commit a31e06b

Browse files
committed
Merge branch 'feat/aws-sqs' into feat/aws-integration-batch
2 parents f2636a2 + 04d1921 commit a31e06b

59 files changed

Lines changed: 5671 additions & 156 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/content/docs/integrations/sqs.mdx‎

Lines changed: 469 additions & 2 deletions
Large diffs are not rendered by default.

‎apps/sim/blocks/blocks/sqs.ts‎

Lines changed: 836 additions & 31 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { z } from 'zod'
2+
import { sqsConnectionFields } from '@/lib/api/contracts/tools/aws/sqs-shared'
3+
import type {
4+
ContractBody,
5+
ContractBodyInput,
6+
ContractJsonResponse,
7+
} from '@/lib/api/contracts/types'
8+
import { defineRouteContract } from '@/lib/api/contracts/types'
9+
10+
const CancelMessageMoveTaskSchema = z.object({
11+
...sqsConnectionFields,
12+
taskHandle: z.string().min(1, 'Task handle is required'),
13+
})
14+
15+
const CancelMessageMoveTaskResponseSchema = z.object({
16+
message: z.string(),
17+
approximateNumberOfMessagesMoved: z.number().nullable(),
18+
})
19+
20+
export const awsSqsCancelMessageMoveTaskContract = defineRouteContract({
21+
method: 'POST',
22+
path: '/api/tools/sqs/cancel-message-move-task',
23+
body: CancelMessageMoveTaskSchema,
24+
response: { mode: 'json', schema: CancelMessageMoveTaskResponseSchema },
25+
})
26+
export type AwsSqsCancelMessageMoveTaskRequest = ContractBodyInput<
27+
typeof awsSqsCancelMessageMoveTaskContract
28+
>
29+
export type AwsSqsCancelMessageMoveTaskBody = ContractBody<
30+
typeof awsSqsCancelMessageMoveTaskContract
31+
>
32+
export type AwsSqsCancelMessageMoveTaskResponse = ContractJsonResponse<
33+
typeof awsSqsCancelMessageMoveTaskContract
34+
>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { z } from 'zod'
2+
import {
3+
SQS_MAX_BATCH_ENTRIES,
4+
sqsBatchEntryIdSchema,
5+
sqsBatchResultErrorEntrySchema,
6+
sqsConnectionFields,
7+
sqsQueueUrlField,
8+
} from '@/lib/api/contracts/tools/aws/sqs-shared'
9+
import type {
10+
ContractBody,
11+
ContractBodyInput,
12+
ContractJsonResponse,
13+
} from '@/lib/api/contracts/types'
14+
import { defineRouteContract } from '@/lib/api/contracts/types'
15+
16+
const ChangeMessageVisibilityBatchSchema = z.object({
17+
...sqsConnectionFields,
18+
queueUrl: sqsQueueUrlField,
19+
entries: z
20+
.array(
21+
z.object({
22+
id: sqsBatchEntryIdSchema,
23+
receiptHandle: z.string().min(1, 'Receipt handle is required'),
24+
visibilityTimeout: z
25+
.number()
26+
.int()
27+
.min(0, 'visibilityTimeout must be at least 0')
28+
.max(43200, 'visibilityTimeout cannot exceed 43200 seconds (12 hours)')
29+
.nullish(),
30+
})
31+
)
32+
.min(1, 'At least one entry is required')
33+
.max(SQS_MAX_BATCH_ENTRIES, `A batch can hold at most ${SQS_MAX_BATCH_ENTRIES} entries`),
34+
})
35+
36+
const ChangeMessageVisibilityBatchResponseSchema = z.object({
37+
message: z.string(),
38+
successful: z.array(z.object({ id: z.string().nullable() })),
39+
failed: z.array(sqsBatchResultErrorEntrySchema),
40+
successCount: z.number(),
41+
failureCount: z.number(),
42+
})
43+
44+
export const awsSqsChangeMessageVisibilityBatchContract = defineRouteContract({
45+
method: 'POST',
46+
path: '/api/tools/sqs/change-message-visibility-batch',
47+
body: ChangeMessageVisibilityBatchSchema,
48+
response: { mode: 'json', schema: ChangeMessageVisibilityBatchResponseSchema },
49+
})
50+
export type AwsSqsChangeMessageVisibilityBatchRequest = ContractBodyInput<
51+
typeof awsSqsChangeMessageVisibilityBatchContract
52+
>
53+
export type AwsSqsChangeMessageVisibilityBatchBody = ContractBody<
54+
typeof awsSqsChangeMessageVisibilityBatchContract
55+
>
56+
export type AwsSqsChangeMessageVisibilityBatchResponse = ContractJsonResponse<
57+
typeof awsSqsChangeMessageVisibilityBatchContract
58+
>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { z } from 'zod'
2+
import { sqsConnectionFields, sqsQueueUrlField } from '@/lib/api/contracts/tools/aws/sqs-shared'
3+
import type {
4+
ContractBody,
5+
ContractBodyInput,
6+
ContractJsonResponse,
7+
} from '@/lib/api/contracts/types'
8+
import { defineRouteContract } from '@/lib/api/contracts/types'
9+
10+
const ChangeMessageVisibilitySchema = z.object({
11+
...sqsConnectionFields,
12+
queueUrl: sqsQueueUrlField,
13+
receiptHandle: z.string().min(1, 'Receipt handle is required'),
14+
visibilityTimeout: z
15+
.number()
16+
.int()
17+
.min(0, 'visibilityTimeout must be at least 0')
18+
.max(43200, 'visibilityTimeout cannot exceed 43200 seconds (12 hours)'),
19+
})
20+
21+
const ChangeMessageVisibilityResponseSchema = z.object({
22+
message: z.string(),
23+
})
24+
25+
export const awsSqsChangeMessageVisibilityContract = defineRouteContract({
26+
method: 'POST',
27+
path: '/api/tools/sqs/change-message-visibility',
28+
body: ChangeMessageVisibilitySchema,
29+
response: { mode: 'json', schema: ChangeMessageVisibilityResponseSchema },
30+
})
31+
export type AwsSqsChangeMessageVisibilityRequest = ContractBodyInput<
32+
typeof awsSqsChangeMessageVisibilityContract
33+
>
34+
export type AwsSqsChangeMessageVisibilityBody = ContractBody<
35+
typeof awsSqsChangeMessageVisibilityContract
36+
>
37+
export type AwsSqsChangeMessageVisibilityResponse = ContractJsonResponse<
38+
typeof awsSqsChangeMessageVisibilityContract
39+
>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { z } from 'zod'
2+
import {
3+
sqsConnectionFields,
4+
sqsQueueAttributesSchema,
5+
sqsQueueNameField,
6+
sqsTagsSchema,
7+
} from '@/lib/api/contracts/tools/aws/sqs-shared'
8+
import type {
9+
ContractBody,
10+
ContractBodyInput,
11+
ContractJsonResponse,
12+
} from '@/lib/api/contracts/types'
13+
import { defineRouteContract } from '@/lib/api/contracts/types'
14+
15+
const CreateQueueSchema = z.object({
16+
...sqsConnectionFields,
17+
queueName: sqsQueueNameField,
18+
attributes: sqsQueueAttributesSchema.nullish(),
19+
tags: sqsTagsSchema.nullish(),
20+
})
21+
22+
const CreateQueueResponseSchema = z.object({
23+
message: z.string(),
24+
queueUrl: z.string().nullable(),
25+
})
26+
27+
export const awsSqsCreateQueueContract = defineRouteContract({
28+
method: 'POST',
29+
path: '/api/tools/sqs/create-queue',
30+
body: CreateQueueSchema,
31+
response: { mode: 'json', schema: CreateQueueResponseSchema },
32+
})
33+
export type AwsSqsCreateQueueRequest = ContractBodyInput<typeof awsSqsCreateQueueContract>
34+
export type AwsSqsCreateQueueBody = ContractBody<typeof awsSqsCreateQueueContract>
35+
export type AwsSqsCreateQueueResponse = ContractJsonResponse<typeof awsSqsCreateQueueContract>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { z } from 'zod'
2+
import {
3+
SQS_MAX_BATCH_ENTRIES,
4+
sqsBatchEntryIdSchema,
5+
sqsBatchResultErrorEntrySchema,
6+
sqsConnectionFields,
7+
sqsQueueUrlField,
8+
} from '@/lib/api/contracts/tools/aws/sqs-shared'
9+
import type {
10+
ContractBody,
11+
ContractBodyInput,
12+
ContractJsonResponse,
13+
} from '@/lib/api/contracts/types'
14+
import { defineRouteContract } from '@/lib/api/contracts/types'
15+
16+
const DeleteMessageBatchSchema = z.object({
17+
...sqsConnectionFields,
18+
queueUrl: sqsQueueUrlField,
19+
entries: z
20+
.array(
21+
z.object({
22+
id: sqsBatchEntryIdSchema,
23+
receiptHandle: z.string().min(1, 'Receipt handle is required'),
24+
})
25+
)
26+
.min(1, 'At least one entry is required')
27+
.max(SQS_MAX_BATCH_ENTRIES, `A batch can hold at most ${SQS_MAX_BATCH_ENTRIES} entries`),
28+
})
29+
30+
const DeleteMessageBatchResponseSchema = z.object({
31+
message: z.string(),
32+
successful: z.array(z.object({ id: z.string().nullable() })),
33+
failed: z.array(sqsBatchResultErrorEntrySchema),
34+
successCount: z.number(),
35+
failureCount: z.number(),
36+
})
37+
38+
export const awsSqsDeleteMessageBatchContract = defineRouteContract({
39+
method: 'POST',
40+
path: '/api/tools/sqs/delete-message-batch',
41+
body: DeleteMessageBatchSchema,
42+
response: { mode: 'json', schema: DeleteMessageBatchResponseSchema },
43+
})
44+
export type AwsSqsDeleteMessageBatchRequest = ContractBodyInput<
45+
typeof awsSqsDeleteMessageBatchContract
46+
>
47+
export type AwsSqsDeleteMessageBatchBody = ContractBody<typeof awsSqsDeleteMessageBatchContract>
48+
export type AwsSqsDeleteMessageBatchResponse = ContractJsonResponse<
49+
typeof awsSqsDeleteMessageBatchContract
50+
>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { z } from 'zod'
2+
import { sqsConnectionFields, sqsQueueUrlField } from '@/lib/api/contracts/tools/aws/sqs-shared'
3+
import type {
4+
ContractBody,
5+
ContractBodyInput,
6+
ContractJsonResponse,
7+
} from '@/lib/api/contracts/types'
8+
import { defineRouteContract } from '@/lib/api/contracts/types'
9+
10+
const DeleteMessageSchema = z.object({
11+
...sqsConnectionFields,
12+
queueUrl: sqsQueueUrlField,
13+
receiptHandle: z.string().min(1, 'Receipt handle is required'),
14+
})
15+
16+
const DeleteMessageResponseSchema = z.object({
17+
message: z.string(),
18+
})
19+
20+
export const awsSqsDeleteMessageContract = defineRouteContract({
21+
method: 'POST',
22+
path: '/api/tools/sqs/delete-message',
23+
body: DeleteMessageSchema,
24+
response: { mode: 'json', schema: DeleteMessageResponseSchema },
25+
})
26+
export type AwsSqsDeleteMessageRequest = ContractBodyInput<typeof awsSqsDeleteMessageContract>
27+
export type AwsSqsDeleteMessageBody = ContractBody<typeof awsSqsDeleteMessageContract>
28+
export type AwsSqsDeleteMessageResponse = ContractJsonResponse<typeof awsSqsDeleteMessageContract>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { z } from 'zod'
2+
import { sqsConnectionFields, sqsQueueUrlField } from '@/lib/api/contracts/tools/aws/sqs-shared'
3+
import type {
4+
ContractBody,
5+
ContractBodyInput,
6+
ContractJsonResponse,
7+
} from '@/lib/api/contracts/types'
8+
import { defineRouteContract } from '@/lib/api/contracts/types'
9+
10+
const DeleteQueueSchema = z.object({
11+
...sqsConnectionFields,
12+
queueUrl: sqsQueueUrlField,
13+
})
14+
15+
const DeleteQueueResponseSchema = z.object({
16+
message: z.string(),
17+
})
18+
19+
export const awsSqsDeleteQueueContract = defineRouteContract({
20+
method: 'POST',
21+
path: '/api/tools/sqs/delete-queue',
22+
body: DeleteQueueSchema,
23+
response: { mode: 'json', schema: DeleteQueueResponseSchema },
24+
})
25+
export type AwsSqsDeleteQueueRequest = ContractBodyInput<typeof awsSqsDeleteQueueContract>
26+
export type AwsSqsDeleteQueueBody = ContractBody<typeof awsSqsDeleteQueueContract>
27+
export type AwsSqsDeleteQueueResponse = ContractJsonResponse<typeof awsSqsDeleteQueueContract>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { z } from 'zod'
2+
import {
3+
sqsConnectionFields,
4+
sqsQueueAttributeNameSchema,
5+
sqsQueueUrlField,
6+
} from '@/lib/api/contracts/tools/aws/sqs-shared'
7+
import type {
8+
ContractBody,
9+
ContractBodyInput,
10+
ContractJsonResponse,
11+
} from '@/lib/api/contracts/types'
12+
import { defineRouteContract } from '@/lib/api/contracts/types'
13+
14+
const GetQueueAttributesSchema = z.object({
15+
...sqsConnectionFields,
16+
queueUrl: sqsQueueUrlField,
17+
attributeNames: z.array(sqsQueueAttributeNameSchema).nullish(),
18+
})
19+
20+
const GetQueueAttributesResponseSchema = z.object({
21+
attributes: z.record(z.string(), z.string()),
22+
})
23+
24+
export const awsSqsGetQueueAttributesContract = defineRouteContract({
25+
method: 'POST',
26+
path: '/api/tools/sqs/get-queue-attributes',
27+
body: GetQueueAttributesSchema,
28+
response: { mode: 'json', schema: GetQueueAttributesResponseSchema },
29+
})
30+
export type AwsSqsGetQueueAttributesRequest = ContractBodyInput<
31+
typeof awsSqsGetQueueAttributesContract
32+
>
33+
export type AwsSqsGetQueueAttributesBody = ContractBody<typeof awsSqsGetQueueAttributesContract>
34+
export type AwsSqsGetQueueAttributesResponse = ContractJsonResponse<
35+
typeof awsSqsGetQueueAttributesContract
36+
>

0 commit comments

Comments
 (0)