added support for sqs sample ripper when creating new products (#167)

This commit is contained in:
Arwid Thornström
2024-10-10 14:34:29 +02:00
committed by GitHub
parent 3101e04b66
commit 549046096c
8 changed files with 54 additions and 22 deletions
+21
View File
@@ -0,0 +1,21 @@
import {
SQSClient,
SendMessageCommand,
SendMessageCommandOutput,
SendMessageCommandInput,
} from '@aws-sdk/client-sqs';
export async function sendMessage(
body: string,
queueUrl: string,
): Promise<SendMessageCommandOutput | undefined> {
const client = new SQSClient({ region: 'eu-west-1' });
const params: SendMessageCommandInput = {
MessageBody: body,
QueueUrl: queueUrl,
};
const sendMessageCommand = new SendMessageCommand(params);
return client.send(sendMessageCommand);
}
+1 -21
View File
@@ -1,9 +1,4 @@
import {
SQSClient,
SendMessageCommand,
SendMessageCommandOutput,
SendMessageCommandInput,
} from '@aws-sdk/client-sqs';
import { sendMessage } from '../aws/sqs';
export async function sendPathChangedCmd(
oldPath: string,
@@ -20,18 +15,3 @@ export async function sendPathChangedCmd(
};
await sendMessage(JSON.stringify(msg), process.env.BERNARD_QUEUE_URL);
}
export async function sendMessage(
body: string,
queueUrl: string,
): Promise<SendMessageCommandOutput | undefined> {
const client = new SQSClient({ region: 'eu-west-1' });
const params: SendMessageCommandInput = {
MessageBody: body,
QueueUrl: queueUrl,
};
const sendMessageCommand = new SendMessageCommand(params);
return client.send(sendMessageCommand);
}
+11 -1
View File
@@ -23,6 +23,7 @@ import { PrintProductDefaultsAPI } from '../datasources/printproduct-defaults-ap
import { PrintProductDefaults } from '../types/printproduct-defaults-types';
import { GraphQLError } from 'graphql';
import { getOrientationString, isRepeatingPattern } from '../datasources/utils';
import { sendMessage } from '../aws/sqs';
const ProductBlacklist = {
async market(parent, _args, { dataSources }) {
@@ -223,7 +224,16 @@ export const productMutationTypeDefs = {
batch,
designerId,
);
return (<ProductAPI>dataSources.productApi).getProduct(id);
const product = await (<ProductAPI>dataSources.productApi).getProduct(id);
// Send sqs message to trigger sample ripper
await sendMessage(
JSON.stringify({ productId: id, artNo: product.fields.artNo }),
process.env.SAMPLE_SQS_QUEUE_URL,
);
return product;
},
/**