Skip to content

Commit

Permalink
Merge pull request #4622 from AbdullahBitar/queue
Browse files Browse the repository at this point in the history
feat(queue): clear queue action
  • Loading branch information
abuaboud committed May 3, 2024
2 parents 4ff6dbb + f36d92e commit 5823f0c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/community/queue/package.json
@@ -1,4 +1,4 @@
{
"name": "@activepieces/piece-queue",
"version": "0.0.2"
"version": "0.0.3"
}
3 changes: 2 additions & 1 deletion packages/pieces/community/queue/src/index.ts
@@ -1,6 +1,7 @@
import { createPiece, PieceAuth } from "@activepieces/pieces-framework";
import { pushToQueue } from "./lib/actions/push-to-queue";
import { pullFromQueue } from "./lib/actions/pull-from-queue";
import { clearQueue } from "./lib/actions/clear-queue";

export const queue = createPiece({
displayName: "Queue",
Expand All @@ -9,6 +10,6 @@ export const queue = createPiece({
minimumSupportedRelease: '0.20.0',
logoUrl: 'https://cdn.activepieces.com/pieces/queue.svg',
authors: ['AbdullahBitar'],
actions: [pushToQueue, pullFromQueue],
actions: [pushToQueue, pullFromQueue, clearQueue],
triggers: [],
});
33 changes: 33 additions & 0 deletions packages/pieces/community/queue/src/lib/actions/clear-queue.ts
@@ -0,0 +1,33 @@
import {
Property,
StoreScope,
createAction,
} from '@activepieces/pieces-framework';
import { constructQueueName } from '../common';

export const clearQueue = createAction({
name: 'clear-queue',
description: 'Clears all items inside a queue',
displayName: 'Clear queue',
props: {
info: Property.MarkDown({
value: `
**Note:**
- This deletes all items inside the queue permanently.
- The testing step work in isolation and doesn't affect the actual queue after publishing.
`,
}),
queueName: Property.ShortText({
displayName: 'Queue Name',
required: true,
})
},
async run(context) {
const queueName = constructQueueName(context.propsValue.queueName, false)
await context.store.delete(queueName, StoreScope.PROJECT)
},
async test(context) {
const queueName = constructQueueName(context.propsValue.queueName, true)
await context.store.delete(queueName, StoreScope.PROJECT)
}
});

0 comments on commit 5823f0c

Please sign in to comment.