Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(triggers): keep polling state through piece-upgrade republishes (#16719)

Amr Elmohamady67cdf5b8e943
diff --git a/.agents/skills/piece-builder/trigger-patterns.md b/.agents/skills/piece-builder/trigger-patterns.md
index 0611f27ad45..013ef1ec9cb 100644
--- a/.agents/skills/piece-builder/trigger-patterns.md
+++ b/.agents/skills/piece-builder/trigger-patterns.md
@@ -16,7 +16,7 @@ Two deduplication strategies:
**Always pass the whole `context`** to `pollingHelper.onEnable` / `onDisable` / `poll` / `test` -- never a subset like `{ store, auth, propsValue }`. Every field on the helper's param type is optional, so a partial object type-checks and whatever you left out is dropped in silence, and the set grows over time.
-**Republishing doesn't touch an unchanged polling trigger.** If the piece, its version, the trigger and its inputs are all the same, `onDisable` and `onEnable` are skipped and the store is left as is, so you don't need anything for the common republish. On a piece-version upgrade with the same inputs, both hooks run with `context.isRepublish` set: handle it if your stored state can be kept. See [Polling Trigger → Republishing a running flow](https://www.activepieces.com/docs/build-pieces/piece-reference/triggers/polling-trigger#republishing-a-running-flow).
+**Republishing doesn't touch an unchanged polling trigger.** If the piece, its version, the trigger and its inputs are all the same, `onDisable` and `onEnable` are skipped and the store is left as is, so you don't need anything for the common republish. On a piece-version upgrade with the same inputs, the old `onDisable` is skipped and the new `onEnable` runs with `context.isRepublish` set. If your stored state is still valid, keep it by returning before you overwrite it, with `if (context.isRepublish && !isNil(await context.store.get(KEY))) return;`. See [Polling Trigger → Republishing a running flow](https://www.activepieces.com/docs/build-pieces/piece-reference/triggers/polling-trigger#republishing-a-running-flow) and [When the hooks run](https://www.activepieces.com/docs/build-pieces/piece-reference/triggers/overview#when-the-hooks-run) for every case.
**Lint enforces this.** A `no-restricted-syntax` rule in the root `.eslintrc.json` rejects an object literal as the second argument to `pollingHelper.*`. To override a field, spread the context: `{ ...context, propsValue: … }`.
diff --git a/brain/knowledge/flows-execution/triggers.md b/brain/knowledge/flows-execution/triggers.md
index ac2ffb53916..f7d5df90279 100644
--- a/brain/knowledge/flows-execution/triggers.md
+++ b/brain/knowledge/flows-execution/triggers.md
@@ -21,7 +21,7 @@ Triggers define how and when a flow starts. The module handles registration, eve
### Gotchas
- **Deduplication** (polling): extracts `__DEDUPE_KEY_PROPERTY`, Redis INCR with 30s TTL — first passes, duplicates filtered; the dedupe key is stripped from returned payloads.
-- **Republishing leaves an unchanged polling trigger running** (`isTriggerUnchanged`): a publish runs `onDisable(old) → onEnable(new)`, which reset `lastPoll`/`lastItem` (and every custom checkpoint) to now and silently dropped events created in between. When the flow was already `ENABLED`, stays enabled, and the trigger keeps the same piece, **piece version**, trigger name and deep-equal `settings.input` (`flowPublishUtils.isTriggerUnchanged`), `flowTriggerSideEffect` skips both engine hooks for a POLLING trigger: the store is untouched and only the poll job is re-pointed to the new flow version with the previous trigger source's schedule (no previous schedule → hooks run). The hooks are skipped, not run against a guarded store, because any store-wrapping rule changes what piece code sees mid-hook and broke real pieces (pinterest's mid-pagination bookmark, azure-ad's stale delta link failing the publish); skipping makes the trigger indistinguishable from a flow nobody republished, which is safe for custom pieces too. Skipping both is required — skipping only `onDisable` would let `onEnable` register a second copy of anything external. With the same inputs but a **new piece version** both hooks run with `isRepublish=true` (`flowPublishUtils.isRepublish`, ON_DISABLE and ON_ENABLE jobs → `context.isRepublish`), and `pollingHelper.onEnable` keeps the checkpoint only if the piece passes the whole `context`. A trigger swap, any props change, or an off→on toggle runs the hooks normally and starts fresh; off→on is the way to reset a polling trigger whose state has gone bad (e.g. an expired sync token), since a republish no longer does. The props check is not cosmetic: a checkpoint kept across a props change points at a resource that is no longer being polled, and `pollingHelper.poll` treats a `LAST_ITEM` id it cannot find (`findIndex → -1`) as "no checkpoint", emitting **every** item. Both publish paths — `flowService.updatedPublishedVersionId` and `flowApprovalRequestService.approve` (its own disable→enable) — use these two decisions; any new publish path must too.
+- **Republishing leaves an unchanged polling trigger running** (`isTriggerUnchanged`): a publish runs `onDisable(old) → onEnable(new)`, which reset `lastPoll`/`lastItem` (and every custom checkpoint) to now and silently dropped events created in between. When the flow was already `ENABLED`, stays enabled, and the trigger keeps the same piece, **piece version**, trigger name and deep-equal `settings.input` (`flowPublishUtils.isTriggerUnchanged`), `flowTriggerSideEffect` skips both engine hooks for a POLLING trigger: the store is untouched and only the poll job is re-pointed to the new flow version with the previous trigger source's schedule (no previous schedule → hooks run). The hooks are skipped, not run against a guarded store, because any store-wrapping rule changes what piece code sees mid-hook and broke real pieces (pinterest's mid-pagination bookmark, azure-ad's stale delta link failing the publish); skipping makes the trigger indistinguishable from a flow nobody republished, which is safe for custom pieces too. With the same inputs but a **new piece version** only the new version's `onEnable` runs, with `isRepublish=true` (`flowPublishUtils.isRepublish` → `context.isRepublish`); the old version's `onDisable` is skipped for POLLING, because pre-guard versions delete their checkpoint unconditionally and the old code can't be fixed after it ships. `pollingHelper.onEnable` keeps the checkpoint only if the piece passes the whole `context`, and custom state needs its own `isRepublish` guard in `onEnable`. The cost: a polling `onDisable` that cleans up something external (none in the repo) won't run on an upgrade, so that object leaks while the new `onEnable` creates a fresh one. A trigger swap, any props change, or an off→on toggle runs the hooks normally and starts fresh; off→on is the way to reset a polling trigger whose state has gone bad (e.g. an expired sync token), since a republish no longer does. The props check is not cosmetic: a checkpoint kept across a props change points at a resource that is no longer being polled, and `pollingHelper.poll` treats a `LAST_ITEM` id it cannot find (`findIndex → -1`) as "no checkpoint", emitting **every** item. Both publish paths — `flowService.updatedPublishedVersionId` and `flowApprovalRequestService.approve` (its own disable→enable) — use these two decisions; any new publish path must too.
- **A missing timestamp permanently kills a TIMEBASED polling trigger** — `pollingHelper.poll` advances the checkpoint with `items.reduce((acc, i) => Math.max(acc, i.epochMilliSeconds), lastPoll)`, and `Math.max(n, NaN)` is `NaN`, so a single item whose date field was never requested (`dayjs(undefined).valueOf()` → `NaN`) writes `NaN` into `lastPoll`; every later poll then filters on `> NaN` → false and the trigger silently never fires again, with no error anywhere. Two guards, both needed: request the date in the API's `fields`/select mask, and drop items with an unusable date before mapping to `epochMilliSeconds`. The filter must check the raw value, not just `.isValid()` — `dayjs(undefined)` is *now* and reports valid.
- **The timestamp you poll on may be client-supplied, and a future one is fatal.** Google Drive sets `modifiedTime` from the *local file mtime* on upload, not the upload moment, so it can be older than `createdTime` — or years ahead if the uploader's clock is fast. A TIMEBASED watermark is `max(epochMilliSeconds)` over the emitted items, so one future-dated row pushes `lastPoll` into the future and the trigger emits nothing until wall-clock catches up. Hold back items timestamped after `Date.now()` — they fire once the clock passes them. Do **not** clamp the watermark instead: a clamped watermark re-emits that same row on every poll forever.
- The **simulate flag** lets a production source and a test source coexist independently.
diff --git a/bun.lock b/bun.lock
index 0fd9194a4b4..8a6872701c1 100644
--- a/bun.lock
+++ b/bun.lock
@@ -10296,6 +10296,7 @@
"devDependencies": {
"@types/feedparser": "2.2.8",
"tslib": "2.6.2",
+ "vitest": "3.2.6",
},
},
"packages/pieces/community/zagomail": {
diff --git a/docs/build-pieces/piece-reference/triggers/overview.mdx b/docs/build-pieces/piece-reference/triggers/overview.mdx
index 68b0d980f88..2f686a30426 100755
--- a/docs/build-pieces/piece-reference/triggers/overview.mdx
+++ b/docs/build-pieces/piece-reference/triggers/overview.mdx
@@ -32,11 +32,9 @@ export const createNewIssue = createTrigger({
type: TriggerStrategy.WEBHOOK | TriggerStrategy.POLLING | TriggerStrategy.APP_WEBHOOK,
props: {}; // Required properties from the user.
- // Run when the user enable or publish the flow.
-
+ // Set up the trigger. See "When the hooks run" below.
onEnable: (ctx) => {},
- // Run when the user disable the flow or
- // the old flow is deleted after new one is published.
+ // Tear the trigger down. See "When the hooks run" below.
onDisable: (ctx) => {},
// Trigger implementation, It takes context as parameter.
@@ -51,6 +49,23 @@ export const createNewIssue = createTrigger({
the array will trigger the flow to run.
</Tip>
+## When the hooks run
+
+| What the user does | Polling trigger | Webhook / app webhook trigger |
+| --- | --- | --- |
+| Turns the flow on | new `onEnable` | new `onEnable` |
+| Turns the flow off, or deletes it | `onDisable` | `onDisable` |
+| Publishes a flow that is off, turning it on | new `onEnable` | new `onEnable` |
+| Republishes a running flow with the same piece, piece version, trigger and inputs | nothing, keeps polling on the same schedule | old `onDisable`, then new `onEnable`, both with `isRepublish: true` |
+| Republishes a running flow with the same trigger and inputs on a newer piece version | new `onEnable` with `isRepublish: true` (the old `onDisable` is skipped) | old `onDisable`, then new `onEnable`, both with `isRepublish: true` |
+| Republishes a running flow with a different trigger or changed inputs | old `onDisable`, then new `onEnable` | old `onDisable`, then new `onEnable` |
+
+- A failing `onDisable` is logged and ignored, so the flow still turns off. A failing `onEnable` fails the publish or the turn-on.
+- A patch upgrade in the builder (e.g. 0.5.1 → 0.5.3) keeps the trigger's inputs. A minor or major upgrade resets them to the new version's defaults. Which row applies depends on the inputs that get published: if they match the running flow, `context.isRepublish` is still `true`; if they differ, the trigger starts fresh. Don't rely on an upgrade to clear stored state.
+- `context.isRepublish` is `true` only in the rows that say so. Use it to keep stored state that is still valid, rather than starting fresh. See [Polling Trigger → Republishing a running flow](/build-pieces/piece-reference/triggers/polling-trigger#republishing-a-running-flow).
+- Don't count on a polling trigger's `onDisable` to clean up anything outside the store: on an upgrade it doesn't run.
+- `test` runs when the user loads sample data in the builder, and `run` runs on every poll or incoming event. Neither is part of turning the flow on or off.
+
## Context Object
The Context object contains multiple helpful pieces of information and tools that can be useful while developing.
diff --git a/docs/build-pieces/piece-reference/triggers/polling-trigger.mdx b/docs/build-pieces/piece-reference/triggers/polling-trigger.mdx
index 265b1a1b7ef..67f51edf51f 100644
--- a/docs/build-pieces/piece-reference/triggers/polling-trigger.mdx
+++ b/docs/build-pieces/piece-reference/triggers/polling-trigger.mdx
@@ -105,8 +105,22 @@ export const newTicketInView = createTrigger({
When an enabled flow is published again and its polling trigger is unchanged (same piece, same piece version, same trigger, same inputs), Activepieces leaves the trigger running exactly as it was: `onDisable` and `onEnable` are not called, the trigger's store is untouched, and polling continues on the same schedule. Events that arrive around the republish are picked up by the next poll as usual.
-Everything else runs the hooks as normal:
+In the other cases ([full table](/build-pieces/piece-reference/triggers/overview#when-the-hooks-run)):
-- **Upgrading the piece version** with the same inputs runs the old version's `onDisable` and the new version's `onEnable`, with `context.isRepublish` set to `true` in both. Use it to keep your checkpoint when your stored state is still valid.
+- **Upgrading the piece version** with the same inputs skips the old version's `onDisable` and runs the new version's `onEnable` with `context.isRepublish` set to `true`. Use it to keep your checkpoint when your stored state is still valid. Don't rely on `onDisable` to clean up anything outside the store, since it doesn't run on an upgrade.
- **Changing the trigger or its inputs** runs both hooks without `isRepublish`, so the trigger starts fresh.
- **Turning the flow off and on** also starts fresh. This is how to reset a polling trigger whose stored state has gone bad, such as an expired sync token.
+
+If your trigger keeps its own state, return early on a republish when that state already exists, so `onEnable` doesn't overwrite it:
+
+```typescript
+onEnable: async (context) => {
+ if (context.isRepublish && !isNil(await context.store.get('_seenIds'))) {
+ return;
+ }
+ const items = await fetchCurrentItems(context.auth);
+ await context.store.put('_seenIds', items.map((item) => item.id));
+},
+```
+
+If the trigger also calls `pollingHelper.onEnable` and saves a snapshot built from the polled items, put this check before the helper call. On a republish the helper still fetches the items, so a snapshot saved after it would replace the one you meant to keep.
diff --git a/packages/pieces/community/assembled/package.json b/packages/pieces/community/assembled/package.json
index 31e14a9cad1..0d8f0394640 100644
--- a/packages/pieces/community/assembled/package.json
+++ b/packages/pieces/community/assembled/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-assembled",
- "version": "0.1.9",
+ "version": "0.1.10",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/assembled/src/lib/triggers/OOO-status-changed.ts b/packages/pieces/community/assembled/src/lib/triggers/OOO-status-changed.ts
index 2ca8e73c9aa..03455e05d04 100644
--- a/packages/pieces/community/assembled/src/lib/triggers/OOO-status-changed.ts
+++ b/packages/pieces/community/assembled/src/lib/triggers/OOO-status-changed.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { assembledCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { assembledAuth } from '../common/auth';
@@ -32,6 +32,9 @@ export const timeOffStatusChanged = createTrigger({
}
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('lastStatusCheck'))) {
+ return;
+ }
await context.store.put('lastStatusCheck', Math.floor(Date.now() / 1000));
},
async onDisable() {
diff --git a/packages/pieces/community/assembled/src/lib/triggers/new-OOO-request.ts b/packages/pieces/community/assembled/src/lib/triggers/new-OOO-request.ts
index 7967a12a3dd..0726eb1467f 100644
--- a/packages/pieces/community/assembled/src/lib/triggers/new-OOO-request.ts
+++ b/packages/pieces/community/assembled/src/lib/triggers/new-OOO-request.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { assembledCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { assembledAuth } from '../common/auth';
@@ -25,6 +25,9 @@ export const newTimeOffRequest = createTrigger({
activity_type_id: '<uuid>',
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('lastCheck'))) {
+ return;
+ }
await context.store.put('lastCheck', Math.floor(Date.now() / 1000));
},
async onDisable() {
diff --git a/packages/pieces/community/assembled/src/lib/triggers/schedule-updated.ts b/packages/pieces/community/assembled/src/lib/triggers/schedule-updated.ts
index 67240b7babd..5b7a63dc520 100644
--- a/packages/pieces/community/assembled/src/lib/triggers/schedule-updated.ts
+++ b/packages/pieces/community/assembled/src/lib/triggers/schedule-updated.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { assembledCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { assembledAuth } from '../common/auth';
@@ -21,6 +21,9 @@ export const scheduleUpdated = createTrigger({
updated_at: '2025-01-15T10:00:00Z',
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('lastScheduleCheck'))) {
+ return;
+ }
await context.store.put('lastScheduleCheck', new Date().toISOString());
},
async onDisable() {
diff --git a/packages/pieces/community/azure-ad/package.json b/packages/pieces/community/azure-ad/package.json
index d414114d93c..c64172c5bd3 100644
--- a/packages/pieces/community/azure-ad/package.json
+++ b/packages/pieces/community/azure-ad/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-azure-ad",
- "version": "0.3.3",
+ "version": "0.3.4",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/azure-ad/src/lib/triggers/new-deleted-user.ts b/packages/pieces/community/azure-ad/src/lib/triggers/new-deleted-user.ts
index 43a2809c53a..4f26800609e 100644
--- a/packages/pieces/community/azure-ad/src/lib/triggers/new-deleted-user.ts
+++ b/packages/pieces/community/azure-ad/src/lib/triggers/new-deleted-user.ts
@@ -1,5 +1,5 @@
import { HttpMethod } from '@activepieces/pieces-common';
-import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
+import { TriggerStrategy, createTrigger, isNil } from '@activepieces/pieces-framework';
import { azureAdAuth } from '../auth';
import { callGraphApi, fetchGraphDeltaChanges } from '../common';
@@ -22,6 +22,9 @@ export const newDeletedUserTrigger = createTrigger({
'@removed': { reason: 'changed' },
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get(STORE_KEY))) {
+ return;
+ }
await fetchGraphDeltaChanges({
accessToken: context.auth.access_token,
store: context.store,
@@ -32,6 +35,9 @@ export const newDeletedUserTrigger = createTrigger({
});
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(STORE_KEY);
},
async test(context) {
diff --git a/packages/pieces/community/azure-ad/src/lib/triggers/new-group.ts b/packages/pieces/community/azure-ad/src/lib/triggers/new-group.ts
index 9593192bc8d..f80bb39ef4d 100644
--- a/packages/pieces/community/azure-ad/src/lib/triggers/new-group.ts
+++ b/packages/pieces/community/azure-ad/src/lib/triggers/new-group.ts
@@ -40,6 +40,9 @@ export const newGroupTrigger = createTrigger({
await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await pollingHelper.onDisable(polling, context);
await context.store.delete(STORE_KEY);
},
diff --git a/packages/pieces/community/azure-ad/src/lib/triggers/new-user.ts b/packages/pieces/community/azure-ad/src/lib/triggers/new-user.ts
index 2f034b48e3c..255cb2bcd01 100644
--- a/packages/pieces/community/azure-ad/src/lib/triggers/new-user.ts
+++ b/packages/pieces/community/azure-ad/src/lib/triggers/new-user.ts
@@ -39,6 +39,9 @@ export const newUserTrigger = createTrigger({
await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await pollingHelper.onDisable(polling, context);
await context.store.delete(STORE_KEY);
},
diff --git a/packages/pieces/community/bamboohr/package.json b/packages/pieces/community/bamboohr/package.json
index e26ba2267be..5e9821a469a 100644
--- a/packages/pieces/community/bamboohr/package.json
+++ b/packages/pieces/community/bamboohr/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-bamboohr",
- "version": "0.3.1",
+ "version": "0.3.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/bamboohr/src/lib/triggers/report-field-changed.ts b/packages/pieces/community/bamboohr/src/lib/triggers/report-field-changed.ts
index 60329fa38c5..2e41e614299 100644
--- a/packages/pieces/community/bamboohr/src/lib/triggers/report-field-changed.ts
+++ b/packages/pieces/community/bamboohr/src/lib/triggers/report-field-changed.ts
@@ -177,6 +177,13 @@ export const reportFieldChanged = createTrigger({
throw new Error(`Field "${fieldToMonitor}" not found in report.`);
}
+ if (
+ context.isRepublish &&
+ !isNil(await context.store.get('lastReportState'))
+ ) {
+ return;
+ }
+
// Store all field values per employee (employee may appear multiple times due to duplicate records)
const currentState: Record<string, string[]> = {};
@@ -192,6 +199,9 @@ export const reportFieldChanged = createTrigger({
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('lastReportState');
},
diff --git a/packages/pieces/community/bitly/package.json b/packages/pieces/community/bitly/package.json
index d663486b432..3ba63ef0b75 100644
--- a/packages/pieces/community/bitly/package.json
+++ b/packages/pieces/community/bitly/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-bitly",
- "version": "0.2.0",
+ "version": "0.2.1",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/bitly/src/lib/triggers/new-bitlink-created.ts b/packages/pieces/community/bitly/src/lib/triggers/new-bitlink-created.ts
index d2321bfc3a8..b2eccc335a8 100644
--- a/packages/pieces/community/bitly/src/lib/triggers/new-bitlink-created.ts
+++ b/packages/pieces/community/bitly/src/lib/triggers/new-bitlink-created.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy, Property } from '@activepieces/pieces-framework';
+import { createTrigger, TriggerStrategy, Property, isNil } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { bitlyAuth } from '../common/auth';
import { bitlyApiCall } from '../common/client';
@@ -71,6 +71,10 @@ export const newBitlinkCreatedTrigger = createTrigger({
},
});
+ if (context.isRepublish && !isNil(await context.store.get(LAST_BITLINK_IDS_KEY))) {
+ return;
+ }
+
const linkIds = response.links.map((link) => link.id);
await context.store.put<string[]>(LAST_BITLINK_IDS_KEY, linkIds);
diff --git a/packages/pieces/community/bluesky/package.json b/packages/pieces/community/bluesky/package.json
index 512927b9bfb..d5ca284c22d 100644
--- a/packages/pieces/community/bluesky/package.json
+++ b/packages/pieces/community/bluesky/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-bluesky",
- "version": "0.2.0",
+ "version": "0.2.1",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/bluesky/src/lib/common/polling.ts b/packages/pieces/community/bluesky/src/lib/common/polling.ts
index fd41925976c..001fdd4cf35 100644
--- a/packages/pieces/community/bluesky/src/lib/common/polling.ts
+++ b/packages/pieces/community/bluesky/src/lib/common/polling.ts
@@ -101,7 +101,10 @@ async function onEnable<T>({ store, storeKey, fetchPage, isRepublish, seenCap, s
await seed({ store, storeKey, fetchPage, seenCap, seedPages });
}
-async function onDisable({ store, storeKey }: { store: PollStore; storeKey: string }): Promise<void> {
+async function onDisable({ store, storeKey, isRepublish }: { store: PollStore; storeKey: string; isRepublish?: boolean }): Promise<void> {
+ if (isRepublish) {
+ return;
+ }
await store.delete(storeKey);
}
diff --git a/packages/pieces/community/bluesky/src/lib/triggers/new-follower-on-account.ts b/packages/pieces/community/bluesky/src/lib/triggers/new-follower-on-account.ts
index 4c3acabefe6..a3cd746aeea 100644
--- a/packages/pieces/community/bluesky/src/lib/triggers/new-follower-on-account.ts
+++ b/packages/pieces/community/bluesky/src/lib/triggers/new-follower-on-account.ts
@@ -67,7 +67,7 @@ export const newFollowerOnAccount = createTrigger({
});
},
async onDisable(context) {
- await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY });
+ await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY, isRepublish: context.isRepublish });
},
async run(context) {
return blueskyClient.withBluesky({
diff --git a/packages/pieces/community/bluesky/src/lib/triggers/new-mention.ts b/packages/pieces/community/bluesky/src/lib/triggers/new-mention.ts
index 02132de781d..bb53cfa4a55 100644
--- a/packages/pieces/community/bluesky/src/lib/triggers/new-mention.ts
+++ b/packages/pieces/community/bluesky/src/lib/triggers/new-mention.ts
@@ -65,7 +65,7 @@ export const newMention = createTrigger({
});
},
async onDisable(context) {
- await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY });
+ await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY, isRepublish: context.isRepublish });
},
async run(context) {
return blueskyClient.withBluesky({
diff --git a/packages/pieces/community/bluesky/src/lib/triggers/new-notification.ts b/packages/pieces/community/bluesky/src/lib/triggers/new-notification.ts
index d770cebd659..83657721f94 100644
--- a/packages/pieces/community/bluesky/src/lib/triggers/new-notification.ts
+++ b/packages/pieces/community/bluesky/src/lib/triggers/new-notification.ts
@@ -70,7 +70,7 @@ export const newNotification = createTrigger({
});
},
async onDisable(context) {
- await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY });
+ await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY, isRepublish: context.isRepublish });
},
async run(context) {
const reasons = reasonsFrom(context.propsValue.reasons);
diff --git a/packages/pieces/community/bluesky/src/lib/triggers/new-post.ts b/packages/pieces/community/bluesky/src/lib/triggers/new-post.ts
index 47980be48d9..7e2854b9376 100644
--- a/packages/pieces/community/bluesky/src/lib/triggers/new-post.ts
+++ b/packages/pieces/community/bluesky/src/lib/triggers/new-post.ts
@@ -116,7 +116,7 @@ export const newPost = createTrigger({
});
},
async onDisable(context) {
- await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY });
+ await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY, isRepublish: context.isRepublish });
},
async run(context) {
const config = searchConfig(context.propsValue);
diff --git a/packages/pieces/community/bluesky/src/lib/triggers/new-posts-by-author.ts b/packages/pieces/community/bluesky/src/lib/triggers/new-posts-by-author.ts
index 19aaca548f1..ce1c4d4d608 100644
--- a/packages/pieces/community/bluesky/src/lib/triggers/new-posts-by-author.ts
+++ b/packages/pieces/community/bluesky/src/lib/triggers/new-posts-by-author.ts
@@ -113,7 +113,7 @@ export const newPostsByAuthor = createTrigger({
});
},
async onDisable(context) {
- await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY });
+ await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY, isRepublish: context.isRepublish });
},
async run(context) {
const config = authorConfig(context.propsValue);
diff --git a/packages/pieces/community/bluesky/src/lib/triggers/new-timeline-posts.ts b/packages/pieces/community/bluesky/src/lib/triggers/new-timeline-posts.ts
index 9395cc6484f..9c815389e75 100644
--- a/packages/pieces/community/bluesky/src/lib/triggers/new-timeline-posts.ts
+++ b/packages/pieces/community/bluesky/src/lib/triggers/new-timeline-posts.ts
@@ -62,7 +62,7 @@ export const newTimelinePosts = createTrigger({
});
},
async onDisable(context) {
- await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY });
+ await blueskyPolling.onDisable({ store: context.store, storeKey: STORE_KEY, isRepublish: context.isRepublish });
},
async run(context) {
return blueskyClient.withBluesky({
diff --git a/packages/pieces/community/campaign-monitor/package.json b/packages/pieces/community/campaign-monitor/package.json
index 4d8dfd77ce1..43275f0123f 100644
--- a/packages/pieces/community/campaign-monitor/package.json
+++ b/packages/pieces/community/campaign-monitor/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-campaign-monitor",
- "version": "0.1.8",
+ "version": "0.1.9",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/campaign-monitor/src/lib/triggers/new-client.ts b/packages/pieces/community/campaign-monitor/src/lib/triggers/new-client.ts
index 3f86c6f4876..14561af2897 100644
--- a/packages/pieces/community/campaign-monitor/src/lib/triggers/new-client.ts
+++ b/packages/pieces/community/campaign-monitor/src/lib/triggers/new-client.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { makeRequest } from '../common/client';
import { campaignMonitorAuth } from '../auth';
@@ -20,6 +20,9 @@ export const newClientTrigger = createTrigger({
Name: 'New Client',
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('existing_clients'))) {
+ return;
+ }
// Store the list of existing clients
const response = await makeRequest(
{ apiKey: context.auth.secret_text },
@@ -34,6 +37,9 @@ export const newClientTrigger = createTrigger({
});
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
// No cleanup needed for polling trigger
await context.store.delete('existing_clients');
},
diff --git a/packages/pieces/community/coralogix/package.json b/packages/pieces/community/coralogix/package.json
index 272f894ea33..e822b2148cd 100644
--- a/packages/pieces/community/coralogix/package.json
+++ b/packages/pieces/community/coralogix/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-coralogix",
- "version": "0.2.3",
+ "version": "0.2.4",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/coralogix/src/lib/triggers/new-incident.ts b/packages/pieces/community/coralogix/src/lib/triggers/new-incident.ts
index b892b9e2819..45d4043d4bb 100644
--- a/packages/pieces/community/coralogix/src/lib/triggers/new-incident.ts
+++ b/packages/pieces/community/coralogix/src/lib/triggers/new-incident.ts
@@ -1,5 +1,6 @@
import {
createTrigger,
+ isNil,
Property,
TriggerStrategy,
} from '@activepieces/pieces-framework';
@@ -46,6 +47,9 @@ export const newIncident = createTrigger({
subsystemName: ['payments'],
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get(STORE_KEY))) {
+ return;
+ }
const response = (await makeRequest(
context.auth,
'management',
diff --git a/packages/pieces/community/cursor/package.json b/packages/pieces/community/cursor/package.json
index 749e2649606..ac7241c3964 100644
--- a/packages/pieces/community/cursor/package.json
+++ b/packages/pieces/community/cursor/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-cursor",
- "version": "0.1.8",
+ "version": "0.1.9",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/cursor/src/lib/triggers/agent-pull-request-created.ts b/packages/pieces/community/cursor/src/lib/triggers/agent-pull-request-created.ts
index 49722e9bd32..1e1a77fb9ee 100644
--- a/packages/pieces/community/cursor/src/lib/triggers/agent-pull-request-created.ts
+++ b/packages/pieces/community/cursor/src/lib/triggers/agent-pull-request-created.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy, PiecePropValueSchema, AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy, PiecePropValueSchema, AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
import { DedupeStrategy, Polling, pollingHelper, HttpMethod } from '@activepieces/pieces-common';
import { cursorAuth } from '../common/auth';
import { makeCursorRequest } from '../common/client';
@@ -114,10 +114,16 @@ export const agentPullRequestCreatedTrigger = createTrigger({
},
async onEnable(context) {
const { store } = context;
- await store.put('agents_with_prs', JSON.stringify([]));
await pollingHelper.onEnable(polling, context);
+ if (context.isRepublish && !isNil(await store.get('agents_with_prs'))) {
+ return;
+ }
+ await store.put('agents_with_prs', JSON.stringify([]));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
const { store } = context;
await store.delete('agents_with_prs');
await pollingHelper.onDisable(polling, context);
diff --git a/packages/pieces/community/cursor/src/lib/triggers/agent-status-equals.ts b/packages/pieces/community/cursor/src/lib/triggers/agent-status-equals.ts
index df63a304cb8..cb5c4872cfd 100644
--- a/packages/pieces/community/cursor/src/lib/triggers/agent-status-equals.ts
+++ b/packages/pieces/community/cursor/src/lib/triggers/agent-status-equals.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy, PiecePropValueSchema, Property, AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy, PiecePropValueSchema, Property, AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
import { DedupeStrategy, Polling, pollingHelper, HttpMethod } from '@activepieces/pieces-common';
import { cursorAuth } from '../common/auth';
import { makeCursorRequest } from '../common/client';
@@ -114,6 +114,11 @@ export const agentStatusEqualsTrigger = createTrigger({
const { agentId } = propsValue;
const storeKey = `agent_status_${agentId}`;
+ await pollingHelper.onEnable(polling, context);
+ if (context.isRepublish && !isNil(await store.get(storeKey))) {
+ return;
+ }
+
try {
const agent = await makeCursorRequest<Agent>(
auth,
@@ -124,10 +129,11 @@ export const agentStatusEqualsTrigger = createTrigger({
} catch (error) {
await store.put(storeKey, null);
}
-
- await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
const { store, propsValue } = context;
const { agentId } = propsValue;
const storeKey = `agent_status_${agentId}`;
diff --git a/packages/pieces/community/dropbox/package.json b/packages/pieces/community/dropbox/package.json
index 80d38c90c6e..1b6eaa08bf7 100644
--- a/packages/pieces/community/dropbox/package.json
+++ b/packages/pieces/community/dropbox/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-dropbox",
- "version": "0.10.0",
+ "version": "0.10.1",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/dropbox/src/lib/triggers/new-folder.ts b/packages/pieces/community/dropbox/src/lib/triggers/new-folder.ts
index 8f03895494e..8db0c310d73 100644
--- a/packages/pieces/community/dropbox/src/lib/triggers/new-folder.ts
+++ b/packages/pieces/community/dropbox/src/lib/triggers/new-folder.ts
@@ -1,5 +1,6 @@
import {
createTrigger,
+ isNil,
Property,
TriggerStrategy,
} from '@activepieces/pieces-framework';
@@ -152,10 +153,16 @@ export const dropboxNewFolder = createTrigger({
dropboxCommon.toApiPath(context.propsValue.path || ''),
context.propsValue.recursive ?? false,
);
+ if (context.isRepublish && !isNil(await context.store.get('cursor'))) {
+ return;
+ }
await context.store.put('cursor', cursor);
},
onDisable: async (context) => {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('cursor');
},
diff --git a/packages/pieces/community/fireberry/package.json b/packages/pieces/community/fireberry/package.json
index 1eab0b039d7..76eb8c2f1ae 100644
--- a/packages/pieces/community/fireberry/package.json
+++ b/packages/pieces/community/fireberry/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-fireberry",
- "version": "0.1.7",
+ "version": "0.1.8",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/fireberry/src/lib/triggers/record-created-updated.trigger.ts b/packages/pieces/community/fireberry/src/lib/triggers/record-created-updated.trigger.ts
index ead21ef8b45..b4a83ebbf8a 100644
--- a/packages/pieces/community/fireberry/src/lib/triggers/record-created-updated.trigger.ts
+++ b/packages/pieces/community/fireberry/src/lib/triggers/record-created-updated.trigger.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy, Property } from '@activepieces/pieces-framework';
+import { createTrigger, TriggerStrategy, Property, isNil } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { fireberryAuth } from '../auth';
import { objectTypeDropdown } from '../common/props';
@@ -129,10 +129,16 @@ export const recordCreatedOrUpdatedTrigger = createTrigger({
}];
}
},
- async onEnable({ store }) {
+ async onEnable({ store, isRepublish }) {
+ if (isRepublish && !isNil(await store.get('lastPollTime'))) {
+ return;
+ }
await store.put('lastPollTime', new Date().toISOString());
},
- async onDisable({ store }) {
+ async onDisable({ store, isRepublish }) {
+ if (isRepublish) {
+ return;
+ }
await store.delete('lastPollTime');
},
async run({ auth, propsValue, store }) {
diff --git a/packages/pieces/community/flowlu/package.json b/packages/pieces/community/flowlu/package.json
index b8f6d69591b..a6269547b86 100644
--- a/packages/pieces/community/flowlu/package.json
+++ b/packages/pieces/community/flowlu/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-flowlu",
- "version": "0.2.1",
+ "version": "0.2.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/flowlu/src/lib/common/polling-trigger.ts b/packages/pieces/community/flowlu/src/lib/common/polling-trigger.ts
index 895fbb81d81..2cc1b4474c0 100644
--- a/packages/pieces/community/flowlu/src/lib/common/polling-trigger.ts
+++ b/packages/pieces/community/flowlu/src/lib/common/polling-trigger.ts
@@ -1,4 +1,4 @@
-import { Store } from '@activepieces/pieces-framework';
+import { isNil, Store } from '@activepieces/pieces-framework';
import { makeClient } from '.';
import { FormValue } from './client';
import { flowluPolling, PollSource } from './polling';
@@ -16,9 +16,18 @@ export function flowluPollingHooks({
client: makeClient(context.auth),
source,
});
+ if (
+ context.isRepublish &&
+ !isNil(await context.store.get(flowluPolling.storeKey))
+ ) {
+ return;
+ }
await context.store.put(flowluPolling.storeKey, checkpoint);
},
async onDisable(context: HookContext): Promise<void> {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(flowluPolling.storeKey);
},
async test(context: HookContext): Promise<unknown[]> {
@@ -54,4 +63,5 @@ type HookContext = {
auth: Parameters<typeof makeClient>[0];
propsValue: Record<string, unknown>;
store: Store;
+ isRepublish?: boolean;
};
diff --git a/packages/pieces/community/flowlu/test/triggers.test.ts b/packages/pieces/community/flowlu/test/triggers.test.ts
index ca0043e2659..421e012227d 100644
--- a/packages/pieces/community/flowlu/test/triggers.test.ts
+++ b/packages/pieces/community/flowlu/test/triggers.test.ts
@@ -294,6 +294,30 @@ describe('polling triggers', () => {
});
});
+describe('republish', () => {
+ it('keeps the checkpoint through onDisable and onEnable, so records created in between still fire', async () => {
+ const { store, data } = memoryStore({ [KEY]: 10 });
+ fakeFlowlu({ records: [{ id: 10 }, { id: 11 }] });
+
+ await runHook({ trigger: asRecord(newTaskTrigger), hook: 'onDisable', context: { store, isRepublish: true } });
+ await runHook({ trigger: asRecord(newTaskTrigger), hook: 'onEnable', context: { store, isRepublish: true } });
+ expect(data.get(KEY)).toBe(10);
+
+ const emitted = await runHook({ trigger: asRecord(newTaskTrigger), hook: 'run', context: { store } });
+ expect(emitted).toEqual([expect.objectContaining({ id: 11 })]);
+ });
+
+ it('still starts fresh when the flow is turned off and on', async () => {
+ const { store, data } = memoryStore({ [KEY]: 10 });
+ fakeFlowlu({ records: [{ id: 10 }, { id: 11 }] });
+
+ await runHook({ trigger: asRecord(newTaskTrigger), hook: 'onDisable', context: { store } });
+ expect(data.has(KEY)).toBe(false);
+ await runHook({ trigger: asRecord(newTaskTrigger), hook: 'onEnable', context: { store } });
+ expect(data.get(KEY)).toBe(11);
+ });
+});
+
function poll({
trigger,
store,
diff --git a/packages/pieces/community/gmail/package.json b/packages/pieces/community/gmail/package.json
index 7d7e317b585..4ed5aca14ad 100644
--- a/packages/pieces/community/gmail/package.json
+++ b/packages/pieces/community/gmail/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-gmail",
- "version": "0.18.2",
+ "version": "0.18.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/gmail/src/lib/triggers/new-attachment.ts b/packages/pieces/community/gmail/src/lib/triggers/new-attachment.ts
index bda825a5f0e..636b40dc869 100644
--- a/packages/pieces/community/gmail/src/lib/triggers/new-attachment.ts
+++ b/packages/pieces/community/gmail/src/lib/triggers/new-attachment.ts
@@ -3,6 +3,7 @@ import {
TriggerStrategy,
Property,
FilesService,
+ isNil,
} from '@activepieces/pieces-framework';
import { GmailProps } from '../common/props';
import { gmailAuth, createGoogleClient, GmailAuthValue } from '../auth';
@@ -51,6 +52,9 @@ export const gmailNewAttachmentTrigger = createTrigger({
sampleData: {},
type: TriggerStrategy.POLLING,
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('lastPoll'))) {
+ return;
+ }
await context.store.put('lastPoll', Date.now());
},
async onDisable(context) {
diff --git a/packages/pieces/community/gmail/src/lib/triggers/new-conversation.ts b/packages/pieces/community/gmail/src/lib/triggers/new-conversation.ts
index 06b0aa95387..030235ca504 100644
--- a/packages/pieces/community/gmail/src/lib/triggers/new-conversation.ts
+++ b/packages/pieces/community/gmail/src/lib/triggers/new-conversation.ts
@@ -3,6 +3,7 @@ import {
TriggerStrategy,
FilesService,
Property,
+ isNil,
} from '@activepieces/pieces-framework';
import { GmailProps } from '../common/props';
import { gmailAuth, createGoogleClient } from '../auth';
@@ -162,6 +163,12 @@ export const gmailNewConversationTrigger = createTrigger({
sampleData: {},
type: TriggerStrategy.POLLING,
onEnable: async (context) => {
+ if (
+ context.isRepublish &&
+ !isNil(await context.store.get('lastHistoryId'))
+ ) {
+ return;
+ }
const authClient = await createGoogleClient(context.auth);
const gmail = googleGmail({ version: 'v1', auth: authClient });
@@ -170,6 +177,9 @@ export const gmailNewConversationTrigger = createTrigger({
await context.store.put('processedThreads', []);
},
onDisable: async (context) => {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('lastHistoryId');
await context.store.delete('processedThreads');
},
diff --git a/packages/pieces/community/gmail/src/lib/triggers/new-email.ts b/packages/pieces/community/gmail/src/lib/triggers/new-email.ts
index 2bc9686d0f2..1ec91769ffa 100644
--- a/packages/pieces/community/gmail/src/lib/triggers/new-email.ts
+++ b/packages/pieces/community/gmail/src/lib/triggers/new-email.ts
@@ -2,6 +2,7 @@ import {
createTrigger,
TriggerStrategy,
FilesService,
+ isNil,
} from '@activepieces/pieces-framework';
import { GmailLabel } from '../common/models';
import { GmailProps } from '../common/props';
@@ -35,6 +36,9 @@ export const gmailNewEmailTrigger = createTrigger({
sampleData: {},
type: TriggerStrategy.POLLING,
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('lastPoll'))) {
+ return;
+ }
await context.store.put('lastPoll', Date.now());
},
async onDisable(context) {
diff --git a/packages/pieces/community/gmail/src/lib/triggers/new-label.ts b/packages/pieces/community/gmail/src/lib/triggers/new-label.ts
index 525062290a8..17cfc4707c2 100644
--- a/packages/pieces/community/gmail/src/lib/triggers/new-label.ts
+++ b/packages/pieces/community/gmail/src/lib/triggers/new-label.ts
@@ -22,6 +22,9 @@ export const gmailNewLabelTrigger = createTrigger({
sampleData: {},
type: TriggerStrategy.POLLING,
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get(TRIGGER_KEY))) {
+ return;
+ }
const authClient = await createGoogleClient(context.auth);
const gmail = googleGmail({ version: 'v1', auth: authClient });
@@ -35,6 +38,9 @@ export const gmailNewLabelTrigger = createTrigger({
await context.store.put(TRIGGER_KEY, JSON.stringify(existingLabelIds));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(TRIGGER_KEY);
},
async test(context) {
diff --git a/packages/pieces/community/gmail/src/lib/triggers/new-labeled-email.ts b/packages/pieces/community/gmail/src/lib/triggers/new-labeled-email.ts
index f72aee67fb9..412a8d0417d 100644
--- a/packages/pieces/community/gmail/src/lib/triggers/new-labeled-email.ts
+++ b/packages/pieces/community/gmail/src/lib/triggers/new-labeled-email.ts
@@ -3,6 +3,7 @@ import {
TriggerStrategy,
FilesService,
tryCatch,
+ isNil,
} from '@activepieces/pieces-framework';
import { GmailProps } from '../common/props';
import { gmailAuth, createGoogleClient } from '../auth';
@@ -84,6 +85,12 @@ export const gmailNewLabeledEmailTrigger = createTrigger({
sampleData: {},
type: TriggerStrategy.POLLING,
onEnable: async (context) => {
+ if (
+ context.isRepublish &&
+ !isNil(await context.store.get('lastHistoryId'))
+ ) {
+ return;
+ }
const authClient = await createGoogleClient(context.auth);
const gmail = googleGmail({ version: 'v1', auth: authClient });
@@ -94,6 +101,9 @@ export const gmailNewLabeledEmailTrigger = createTrigger({
await context.store.put('lastHistoryId', profile.data.historyId);
},
onDisable: async (context) => {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('lastHistoryId');
},
run: async (context) => {
diff --git a/packages/pieces/community/google-ads/package.json b/packages/pieces/community/google-ads/package.json
index aaa0e249850..de80468b0d1 100644
--- a/packages/pieces/community/google-ads/package.json
+++ b/packages/pieces/community/google-ads/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-google-ads",
- "version": "0.0.2",
+ "version": "0.0.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/google-ads/src/lib/triggers/new-record.ts b/packages/pieces/community/google-ads/src/lib/triggers/new-record.ts
index 2072fea87c4..3d919be5dd4 100644
--- a/packages/pieces/community/google-ads/src/lib/triggers/new-record.ts
+++ b/packages/pieces/community/google-ads/src/lib/triggers/new-record.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { googleAdsAuth } from '../auth';
import { googleAdsApi } from '../common/api';
@@ -43,9 +43,16 @@ export const newRecord = createTrigger({
},
async onEnable(context) {
const { customerId, resourceType } = context.propsValue;
- await saveBaseline({ auth: context.auth, customerId, def: googleAdsUtils.resourceDefinition(resourceType), store: context.store });
+ const def = googleAdsUtils.resourceDefinition(resourceType);
+ if (context.isRepublish && !isNil(await context.store.get(def.changeEventType ? EVENTS_KEY : LAST_ID_KEY))) {
+ return;
+ }
+ await saveBaseline({ auth: context.auth, customerId, def, store: context.store });
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(LAST_ID_KEY);
await context.store.delete(EVENTS_KEY);
},
diff --git a/packages/pieces/community/google-calendar/package.json b/packages/pieces/community/google-calendar/package.json
index 05d0a3d7c34..6efd303df0b 100644
--- a/packages/pieces/community/google-calendar/package.json
+++ b/packages/pieces/community/google-calendar/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-google-calendar",
- "version": "0.13.2",
+ "version": "0.13.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/google-calendar/src/lib/triggers/new-calendar.ts b/packages/pieces/community/google-calendar/src/lib/triggers/new-calendar.ts
index 8795fd45404..228df6d3a3a 100644
--- a/packages/pieces/community/google-calendar/src/lib/triggers/new-calendar.ts
+++ b/packages/pieces/community/google-calendar/src/lib/triggers/new-calendar.ts
@@ -1,6 +1,7 @@
import {
createTrigger,
AppConnectionValueForAuthProperty,
+ isNil,
Property,
} from '@activepieces/pieces-framework';
import { TriggerStrategy } from '@activepieces/pieces-framework';
@@ -140,6 +141,9 @@ export const newCalendar = createTrigger({
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('calendars'))) {
+ return;
+ }
const calendars = await getCalendars(context.auth);
const { access_role_filter, calendar_name_filter, exclude_shared } =
diff --git a/packages/pieces/community/google-calendar/test/new-calendar-republish.test.ts b/packages/pieces/community/google-calendar/test/new-calendar-republish.test.ts
new file mode 100644
index 00000000000..c829681e089
--- /dev/null
+++ b/packages/pieces/community/google-calendar/test/new-calendar-republish.test.ts
@@ -0,0 +1,78 @@
+/// <reference types="vitest/globals" />
+
+import { Store } from '@activepieces/pieces-framework';
+
+const calendarsInAccount: { id: string; summary: string; accessRole: string; primary: boolean }[] = [];
+const getCalendarsMock = vi.fn(async () => calendarsInAccount);
+
+vi.mock('../src/lib/common/helper', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../src/lib/common/helper')>();
+ return { ...actual, getCalendars: () => getCalendarsMock() };
+});
+
+import { newCalendar } from '../src/lib/triggers/new-calendar';
+
+describe('newCalendar republish', () => {
+ beforeEach(() => {
+ calendarsInAccount.length = 0;
+ getCalendarsMock.mockClear();
+ });
+
+ it('keeps the calendar snapshot, so a calendar created just before the republish still fires', async () => {
+ calendarsInAccount.push(calendar('work'), calendar('personal'));
+ const { store, data } = memoryStore();
+ await newCalendar.onEnable(hookContext({ store }));
+ expect(data.get('calendars')).toEqual(['work', 'personal']);
+
+ calendarsInAccount.push(calendar('travel'));
+ await newCalendar.onDisable(hookContext({ store, isRepublish: true }));
+ await newCalendar.onEnable(hookContext({ store, isRepublish: true }));
+ expect(data.get('calendars')).toEqual(['work', 'personal']);
+
+ const emitted = await newCalendar.run(hookContext({ store }));
+ expect(emitted.map((item) => (item as { id: string }).id)).toEqual(['travel']);
+ });
+
+ it('starts from the current calendars when the flow is turned off and on', async () => {
+ calendarsInAccount.push(calendar('work'));
+ const { store, data } = memoryStore();
+ await newCalendar.onEnable(hookContext({ store }));
+
+ calendarsInAccount.push(calendar('travel'));
+ await newCalendar.onDisable(hookContext({ store }));
+ await newCalendar.onEnable(hookContext({ store }));
+
+ expect(data.get('calendars')).toEqual(['work', 'travel']);
+ });
+});
+
+function calendar(id: string): { id: string; summary: string; accessRole: string; primary: boolean } {
+ return { id, summary: id, accessRole: 'owner', primary: false };
+}
+
+function hookContext({ store, isRepublish }: { store: Store; isRepublish?: boolean }): Parameters<typeof newCalendar.run>[0] {
+ return {
+ store,
+ isRepublish,
+ auth: {},
+ propsValue: { access_role_filter: undefined, calendar_name_filter: undefined, exclude_shared: false },
+ files: {},
+ } as unknown as Parameters<typeof newCalendar.run>[0];
+}
+
+function memoryStore(): { store: Store; data: Map<string, unknown> } {
+ const data = new Map<string, unknown>();
+ const store: Store = {
+ async put<T>(key: string, value: T): Promise<T> {
+ data.set(key, value);
+ return value;
+ },
+ async get<T>(key: string): Promise<T | null> {
+ return (data.get(key) as T) ?? null;
+ },
+ async delete(key: string): Promise<void> {
+ data.delete(key);
+ },
+ };
+ return { store, data };
+}
diff --git a/packages/pieces/community/google-sheets/package.json b/packages/pieces/community/google-sheets/package.json
index 8a6a1e383e2..6186930325f 100644
--- a/packages/pieces/community/google-sheets/package.json
+++ b/packages/pieces/community/google-sheets/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-google-sheets",
- "version": "0.19.2",
+ "version": "0.19.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/google-sheets/src/lib/triggers/new-worksheet.ts b/packages/pieces/community/google-sheets/src/lib/triggers/new-worksheet.ts
index 17c101e2638..7416e8fca41 100644
--- a/packages/pieces/community/google-sheets/src/lib/triggers/new-worksheet.ts
+++ b/packages/pieces/community/google-sheets/src/lib/triggers/new-worksheet.ts
@@ -37,9 +37,15 @@ export const newWorksheetTrigger = createTrigger({
}
}
}
+ if (context.isRepublish && !isNil(await context.store.get('worksheets'))) {
+ return;
+ }
await context.store.put('worksheets', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('worksheets');
},
async test(context) {
diff --git a/packages/pieces/community/insightly/package.json b/packages/pieces/community/insightly/package.json
index 70ef33b3502..0476f809ebd 100644
--- a/packages/pieces/community/insightly/package.json
+++ b/packages/pieces/community/insightly/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-insightly",
- "version": "0.1.7",
+ "version": "0.1.8",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/insightly/src/lib/triggers/deleted-record.ts b/packages/pieces/community/insightly/src/lib/triggers/deleted-record.ts
index b58c019ae0f..580ac3eb50c 100644
--- a/packages/pieces/community/insightly/src/lib/triggers/deleted-record.ts
+++ b/packages/pieces/community/insightly/src/lib/triggers/deleted-record.ts
@@ -1,5 +1,6 @@
import {
createTrigger,
+ isNil,
Property,
TriggerStrategy
} from '@activepieces/pieces-framework';
@@ -45,9 +46,15 @@ export const deletedRecord = createTrigger({
})
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get(`known_records_${context.propsValue.objectType}`))) {
+ return;
+ }
await context.store.put(`known_records_${context.propsValue.objectType}`, {});
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(`known_records_${context.propsValue.objectType}`);
},
async run(context) {
diff --git a/packages/pieces/community/insighto-ai/package.json b/packages/pieces/community/insighto-ai/package.json
index 7a736ffd815..e948a5d0fa2 100644
--- a/packages/pieces/community/insighto-ai/package.json
+++ b/packages/pieces/community/insighto-ai/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-insighto-ai",
- "version": "0.1.7",
+ "version": "0.1.8",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/insighto-ai/src/lib/triggers/new-contact.ts b/packages/pieces/community/insighto-ai/src/lib/triggers/new-contact.ts
index 87e3b53d870..fd14633716e 100644
--- a/packages/pieces/community/insighto-ai/src/lib/triggers/new-contact.ts
+++ b/packages/pieces/community/insighto-ai/src/lib/triggers/new-contact.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { ContactItemSchema, ContactItem } from '../schemas';
import { insightoAuth } from '../..';
@@ -32,10 +32,16 @@ export const newContact = createTrigger({
},
type: TriggerStrategy.POLLING,
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('seen_contacts'))) {
+ return;
+ }
// Initialize with empty seen contacts
await context.store.put('seen_contacts', []);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('seen_contacts');
},
async run(context) {
diff --git a/packages/pieces/community/jira-cloud/package.json b/packages/pieces/community/jira-cloud/package.json
index 9f0b3b0cc1e..16236bcea79 100644
--- a/packages/pieces/community/jira-cloud/package.json
+++ b/packages/pieces/community/jira-cloud/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-jira-cloud",
- "version": "0.6.1",
+ "version": "0.6.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/jira-cloud/src/lib/triggers/new-issue-type.ts b/packages/pieces/community/jira-cloud/src/lib/triggers/new-issue-type.ts
index 72a46d7d599..86958830201 100644
--- a/packages/pieces/community/jira-cloud/src/lib/triggers/new-issue-type.ts
+++ b/packages/pieces/community/jira-cloud/src/lib/triggers/new-issue-type.ts
@@ -46,6 +46,9 @@ export const newIssueType = createTrigger({
await context.store.put('issueTypeIds', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('issueTypeIds');
},
async run(context) {
diff --git a/packages/pieces/community/jira-cloud/src/lib/triggers/new-priority.ts b/packages/pieces/community/jira-cloud/src/lib/triggers/new-priority.ts
index 31e5b92deb9..d4c9040b262 100644
--- a/packages/pieces/community/jira-cloud/src/lib/triggers/new-priority.ts
+++ b/packages/pieces/community/jira-cloud/src/lib/triggers/new-priority.ts
@@ -34,6 +34,9 @@ export const newPriority = createTrigger({
await context.store.put('priorityIds', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('priorityIds');
},
async run(context) {
diff --git a/packages/pieces/community/jira-cloud/src/lib/triggers/new-project.ts b/packages/pieces/community/jira-cloud/src/lib/triggers/new-project.ts
index 62c62cd2b27..35da0f8ca0b 100644
--- a/packages/pieces/community/jira-cloud/src/lib/triggers/new-project.ts
+++ b/packages/pieces/community/jira-cloud/src/lib/triggers/new-project.ts
@@ -35,6 +35,9 @@ export const newProject = createTrigger({
await context.store.put('projectIds', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('projectIds');
},
async run(context) {
diff --git a/packages/pieces/community/mailgun/package.json b/packages/pieces/community/mailgun/package.json
index ffb0fa991a2..ba4e74da305 100644
--- a/packages/pieces/community/mailgun/package.json
+++ b/packages/pieces/community/mailgun/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-mailgun",
- "version": "0.1.1",
+ "version": "0.1.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/mailgun/src/lib/triggers/bulk-bounce-threshold-exceeded.ts b/packages/pieces/community/mailgun/src/lib/triggers/bulk-bounce-threshold-exceeded.ts
index f4c12a01a91..588905e9059 100644
--- a/packages/pieces/community/mailgun/src/lib/triggers/bulk-bounce-threshold-exceeded.ts
+++ b/packages/pieces/community/mailgun/src/lib/triggers/bulk-bounce-threshold-exceeded.ts
@@ -76,10 +76,16 @@ export const bulkBounceThresholdExceeded = createTrigger({
type: TriggerStrategy.POLLING,
async onEnable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(LAST_ALERT_STORE_KEY);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(LAST_ALERT_STORE_KEY);
},
diff --git a/packages/pieces/community/ntfy/package.json b/packages/pieces/community/ntfy/package.json
index 13bd15b6872..66ff6dd5bd0 100644
--- a/packages/pieces/community/ntfy/package.json
+++ b/packages/pieces/community/ntfy/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-ntfy",
- "version": "0.4.1",
+ "version": "0.4.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/ntfy/src/lib/triggers/new-message.ts b/packages/pieces/community/ntfy/src/lib/triggers/new-message.ts
index f810a39e027..3e821a8ef31 100644
--- a/packages/pieces/community/ntfy/src/lib/triggers/new-message.ts
+++ b/packages/pieces/community/ntfy/src/lib/triggers/new-message.ts
@@ -54,6 +54,9 @@ export const newMessage = createTrigger({
await context.store.put(CURSOR_KEY, cursor);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(CURSOR_KEY);
},
async test(context) {
diff --git a/packages/pieces/community/nuelink/package.json b/packages/pieces/community/nuelink/package.json
index df65d683e1e..b46a5249010 100644
--- a/packages/pieces/community/nuelink/package.json
+++ b/packages/pieces/community/nuelink/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-nuelink",
- "version": "0.2.1",
+ "version": "0.2.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/nuelink/src/lib/triggers/new-published-post.ts b/packages/pieces/community/nuelink/src/lib/triggers/new-published-post.ts
index 0e7ee716f27..ce444f24503 100644
--- a/packages/pieces/community/nuelink/src/lib/triggers/new-published-post.ts
+++ b/packages/pieces/community/nuelink/src/lib/triggers/new-published-post.ts
@@ -53,6 +53,9 @@ export const newPublishedPost = createTrigger({
await seed({ query, store: context.store });
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(STORE_KEY);
},
async test(context) {
diff --git a/packages/pieces/community/odoo/package.json b/packages/pieces/community/odoo/package.json
index c23fa1f79e5..c97f9b45c9c 100644
--- a/packages/pieces/community/odoo/package.json
+++ b/packages/pieces/community/odoo/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-odoo",
- "version": "0.3.2",
+ "version": "0.3.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/odoo/src/lib/common/polling.ts b/packages/pieces/community/odoo/src/lib/common/polling.ts
index 9bd2918526c..57cb77e7bfd 100644
--- a/packages/pieces/community/odoo/src/lib/common/polling.ts
+++ b/packages/pieces/community/odoo/src/lib/common/polling.ts
@@ -352,7 +352,8 @@ async function onEnable({ client, source, store, isRepublish }: HookParams & { i
await seed({ client, source, store });
}
-async function onDisable({ store }: { store: Store }): Promise<void> {
+async function onDisable({ store, isRepublish }: { store: Store; isRepublish?: boolean }): Promise<void> {
+ if (isRepublish) return;
await store.delete(CURSOR_KEY);
await store.delete(EMITTED_KEY);
await store.delete(ENABLED_AT_KEY);
diff --git a/packages/pieces/community/odoo/src/lib/triggers/new-contact.ts b/packages/pieces/community/odoo/src/lib/triggers/new-contact.ts
index ea9f1e95e24..692ae5517f0 100644
--- a/packages/pieces/community/odoo/src/lib/triggers/new-contact.ts
+++ b/packages/pieces/community/odoo/src/lib/triggers/new-contact.ts
@@ -86,7 +86,7 @@ export const newContactTrigger = createTrigger({
});
},
async onDisable(context) {
- await odooPolling.onDisable({ store: context.store });
+ await odooPolling.onDisable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
return odooPolling.run({
diff --git a/packages/pieces/community/odoo/src/lib/triggers/new-lead.ts b/packages/pieces/community/odoo/src/lib/triggers/new-lead.ts
index fe38a5cc78d..0edc56cb725 100644
--- a/packages/pieces/community/odoo/src/lib/triggers/new-lead.ts
+++ b/packages/pieces/community/odoo/src/lib/triggers/new-lead.ts
@@ -102,7 +102,7 @@ export const newLeadTrigger = createTrigger({
});
},
async onDisable(context) {
- await odooPolling.onDisable({ store: context.store });
+ await odooPolling.onDisable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
const enabledAt = await odooPolling.enabledAt({ store: context.store });
diff --git a/packages/pieces/community/odoo/src/lib/triggers/new-or-updated-record.ts b/packages/pieces/community/odoo/src/lib/triggers/new-or-updated-record.ts
index 77a0eb14639..7f6fde1147a 100644
--- a/packages/pieces/community/odoo/src/lib/triggers/new-or-updated-record.ts
+++ b/packages/pieces/community/odoo/src/lib/triggers/new-or-updated-record.ts
@@ -57,7 +57,7 @@ export const newOrUpdatedRecordTrigger = createTrigger({
});
},
async onDisable(context) {
- await odooPolling.onDisable({ store: context.store });
+ await odooPolling.onDisable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
return odooPolling.run({
diff --git a/packages/pieces/community/odoo/src/lib/triggers/new-record.ts b/packages/pieces/community/odoo/src/lib/triggers/new-record.ts
index 3b7b7fbba7f..cc005427ca0 100644
--- a/packages/pieces/community/odoo/src/lib/triggers/new-record.ts
+++ b/packages/pieces/community/odoo/src/lib/triggers/new-record.ts
@@ -57,7 +57,7 @@ export const newRecordTrigger = createTrigger({
});
},
async onDisable(context) {
- await odooPolling.onDisable({ store: context.store });
+ await odooPolling.onDisable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
return odooPolling.run({
diff --git a/packages/pieces/community/odoo/src/lib/triggers/new-sales-order.ts b/packages/pieces/community/odoo/src/lib/triggers/new-sales-order.ts
index 92afc00c1e9..99645cb4281 100644
--- a/packages/pieces/community/odoo/src/lib/triggers/new-sales-order.ts
+++ b/packages/pieces/community/odoo/src/lib/triggers/new-sales-order.ts
@@ -77,7 +77,7 @@ export const newSalesOrderTrigger = createTrigger({
});
},
async onDisable(context) {
- await odooPolling.onDisable({ store: context.store });
+ await odooPolling.onDisable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
const enabledAt = await odooPolling.enabledAt({ store: context.store });
diff --git a/packages/pieces/community/pastefy/package.json b/packages/pieces/community/pastefy/package.json
index 5b7459956e8..0fab1b2cd73 100644
--- a/packages/pieces/community/pastefy/package.json
+++ b/packages/pieces/community/pastefy/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-pastefy",
- "version": "0.3.1",
+ "version": "0.3.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/pastefy/src/lib/triggers/paste-changed.ts b/packages/pieces/community/pastefy/src/lib/triggers/paste-changed.ts
index dd4b58c7fcc..bbb4ad5fa0a 100644
--- a/packages/pieces/community/pastefy/src/lib/triggers/paste-changed.ts
+++ b/packages/pieces/community/pastefy/src/lib/triggers/paste-changed.ts
@@ -1,5 +1,6 @@
import {
createTrigger,
+ isNil,
Property,
StoreScope,
TriggerStrategy,
@@ -30,6 +31,12 @@ export default createTrigger({
},
sampleData: {},
onEnable: async (context) => {
+ if (
+ context.isRepublish &&
+ !isNil(await context.store.get('paste_changed_trigger_hash', StoreScope.FLOW))
+ ) {
+ return;
+ }
const client = makeClient(context.auth, context.propsValue);
const paste = await client.getPaste(context.propsValue.paste_id);
const hash = createHash('md5')
@@ -44,6 +51,9 @@ export default createTrigger({
);
},
onDisable: async (context) => {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('paste_changed_trigger_hash', StoreScope.FLOW);
},
run: async (context) => {
diff --git a/packages/pieces/community/pinterest/package.json b/packages/pieces/community/pinterest/package.json
index a90395364f4..9812c3173f7 100644
--- a/packages/pieces/community/pinterest/package.json
+++ b/packages/pieces/community/pinterest/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-pinterest",
- "version": "0.2.3",
+ "version": "0.2.4",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/pinterest/src/lib/triggers/new-pin-on-board.ts b/packages/pieces/community/pinterest/src/lib/triggers/new-pin-on-board.ts
index aef716c531b..e743bcf525d 100644
--- a/packages/pieces/community/pinterest/src/lib/triggers/new-pin-on-board.ts
+++ b/packages/pieces/community/pinterest/src/lib/triggers/new-pin-on-board.ts
@@ -215,11 +215,17 @@ export const newPinOnBoard = createTrigger({
.slice(0, 5);
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get(LAST_POLL_KEY))) {
+ return;
+ }
await context.store.put(LAST_POLL_KEY, Date.now());
await context.store.delete(PENDING_BOOKMARK_KEY);
await context.store.delete(PENDING_MAX_EPOCH_KEY);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(PENDING_BOOKMARK_KEY);
await context.store.delete(PENDING_MAX_EPOCH_KEY);
},
diff --git a/packages/pieces/community/pinterest/test/new-pin-on-board-republish.test.ts b/packages/pieces/community/pinterest/test/new-pin-on-board-republish.test.ts
new file mode 100644
index 00000000000..fa293fa2bc6
--- /dev/null
+++ b/packages/pieces/community/pinterest/test/new-pin-on-board-republish.test.ts
@@ -0,0 +1,46 @@
+import { Store } from '@activepieces/pieces-framework';
+import { describe, expect, test } from 'vitest';
+import { newPinOnBoard } from '../src/lib/triggers/new-pin-on-board';
+
+describe('newPinOnBoard republish', () => {
+ test('keeps the checkpoint and the pending page bookmark through onDisable and onEnable', async () => {
+ const { store, data } = memoryStore({ lastPoll: 1000, pendingBookmark: 'page-11', pendingMaxEpoch: 2000 });
+
+ await newPinOnBoard.onDisable(hookContext({ store, isRepublish: true }));
+ await newPinOnBoard.onEnable(hookContext({ store, isRepublish: true }));
+
+ expect(Object.fromEntries(data)).toEqual({ lastPoll: 1000, pendingBookmark: 'page-11', pendingMaxEpoch: 2000 });
+ });
+
+ test('starts fresh when the flow is turned off and on', async () => {
+ const { store, data } = memoryStore({ lastPoll: 1000, pendingBookmark: 'page-11', pendingMaxEpoch: 2000 });
+
+ await newPinOnBoard.onDisable(hookContext({ store }));
+ await newPinOnBoard.onEnable(hookContext({ store }));
+
+ expect(data.has('pendingBookmark')).toBe(false);
+ expect(data.has('pendingMaxEpoch')).toBe(false);
+ expect(data.get('lastPoll')).toBeGreaterThan(1000);
+ });
+});
+
+function hookContext({ store, isRepublish }: { store: Store; isRepublish?: boolean }): Parameters<typeof newPinOnBoard.onEnable>[0] {
+ return { store, isRepublish, auth: {}, propsValue: {} } as unknown as Parameters<typeof newPinOnBoard.onEnable>[0];
+}
+
+function memoryStore(initial: Record<string, unknown>): { store: Store; data: Map<string, unknown> } {
+ const data = new Map<string, unknown>(Object.entries(initial));
+ const store: Store = {
+ async put<T>(key: string, value: T): Promise<T> {
+ data.set(key, value);
+ return value;
+ },
+ async get<T>(key: string): Promise<T | null> {
+ return (data.get(key) as T) ?? null;
+ },
+ async delete(key: string): Promise<void> {
+ data.delete(key);
+ },
+ };
+ return { store, data };
+}
diff --git a/packages/pieces/community/pipedrive/package.json b/packages/pieces/community/pipedrive/package.json
index 60cfc6c1949..51dbbb39db1 100644
--- a/packages/pieces/community/pipedrive/package.json
+++ b/packages/pieces/community/pipedrive/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-pipedrive",
- "version": "0.10.2",
+ "version": "0.10.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/pipedrive/src/lib/trigger/activity-matching-filter.ts b/packages/pieces/community/pipedrive/src/lib/trigger/activity-matching-filter.ts
index 646f683e9b6..4a908716c24 100644
--- a/packages/pieces/community/pipedrive/src/lib/trigger/activity-matching-filter.ts
+++ b/packages/pieces/community/pipedrive/src/lib/trigger/activity-matching-filter.ts
@@ -23,6 +23,9 @@ export const activityMatchingFilterTrigger = createTrigger({
filterId: filterIdProp('activity', true),
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('activities'))) {
+ return;
+ }
const ids: number[] = [];
const response = await pipedrivePaginatedV2ApiCall<{ id: number }>({
@@ -42,6 +45,9 @@ export const activityMatchingFilterTrigger = createTrigger({
await context.store.put('activities', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('activities');
},
async test(context) {
diff --git a/packages/pieces/community/pipedrive/src/lib/trigger/deal-matching-filter.ts b/packages/pieces/community/pipedrive/src/lib/trigger/deal-matching-filter.ts
index 5dba3b56480..4f1082bd5a1 100644
--- a/packages/pieces/community/pipedrive/src/lib/trigger/deal-matching-filter.ts
+++ b/packages/pieces/community/pipedrive/src/lib/trigger/deal-matching-filter.ts
@@ -59,6 +59,9 @@ export const dealMatchingFilterTrigger = createTrigger({
}),
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('deals'))) {
+ return;
+ }
const ids: number[] = [];
const response = await pipedrivePaginatedV2ApiCall<{ id: number }>({
@@ -81,6 +84,9 @@ export const dealMatchingFilterTrigger = createTrigger({
await context.store.put('deals', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('deals');
},
async test(context) {
diff --git a/packages/pieces/community/pipedrive/src/lib/trigger/organization-matching-filter.ts b/packages/pieces/community/pipedrive/src/lib/trigger/organization-matching-filter.ts
index adfe36f4a7a..078754c2d14 100644
--- a/packages/pieces/community/pipedrive/src/lib/trigger/organization-matching-filter.ts
+++ b/packages/pieces/community/pipedrive/src/lib/trigger/organization-matching-filter.ts
@@ -89,6 +89,9 @@ export const organizationMatchingFilterTrigger = createTrigger({
filterId: filterIdProp('org', true),
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('organizations'))) {
+ return;
+ }
const ids: number[] = [];
const response = await pipedrivePaginatedV2ApiCall<{ id: number }>({
accessToken: context.auth.access_token,
@@ -109,6 +112,9 @@ export const organizationMatchingFilterTrigger = createTrigger({
await context.store.put('organizations', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('organizations');
},
async test(context) {
diff --git a/packages/pieces/community/pipedrive/src/lib/trigger/person-matching-filter.ts b/packages/pieces/community/pipedrive/src/lib/trigger/person-matching-filter.ts
index d09c3ff30f1..a64cf9cf066 100644
--- a/packages/pieces/community/pipedrive/src/lib/trigger/person-matching-filter.ts
+++ b/packages/pieces/community/pipedrive/src/lib/trigger/person-matching-filter.ts
@@ -94,6 +94,9 @@ export const personMatchingFilterTrigger = createTrigger({
filterId: filterIdProp('people', true),
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('persons'))) {
+ return;
+ }
const ids: number[] = [];
const response = await pipedrivePaginatedV2ApiCall<{ id: number }>({
accessToken: context.auth.access_token,
@@ -114,6 +117,9 @@ export const personMatchingFilterTrigger = createTrigger({
await context.store.put('persons', JSON.stringify(ids));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('persons');
},
async test(context) {
diff --git a/packages/pieces/community/plausible/package.json b/packages/pieces/community/plausible/package.json
index b173d1f6568..eb440efd559 100644
--- a/packages/pieces/community/plausible/package.json
+++ b/packages/pieces/community/plausible/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-plausible",
- "version": "0.2.0",
+ "version": "0.2.1",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/plausible/src/lib/triggers/traffic-spike.trigger.ts b/packages/pieces/community/plausible/src/lib/triggers/traffic-spike.trigger.ts
index 3f87b796f26..e43e7cac4bf 100644
--- a/packages/pieces/community/plausible/src/lib/triggers/traffic-spike.trigger.ts
+++ b/packages/pieces/community/plausible/src/lib/triggers/traffic-spike.trigger.ts
@@ -3,6 +3,7 @@ import {
TriggerStrategy,
StoreScope,
Property,
+ isNil,
} from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { plausibleAuth } from '../..';
@@ -27,10 +28,19 @@ export const trafficSpike = createTrigger({
defaultValue: 100,
}),
},
- async onEnable({ store }) {
+ async onEnable({ store, isRepublish }) {
+ if (
+ isRepublish &&
+ !isNil(await store.get('wasAboveThreshold', StoreScope.FLOW))
+ ) {
+ return;
+ }
await store.put('wasAboveThreshold', false, StoreScope.FLOW);
},
- async onDisable({ store }) {
+ async onDisable({ store, isRepublish }) {
+ if (isRepublish) {
+ return;
+ }
await store.delete('wasAboveThreshold', StoreScope.FLOW);
},
async run({ auth, propsValue, store }) {
diff --git a/packages/pieces/community/rss/package.json b/packages/pieces/community/rss/package.json
index d16a4065d98..ef561de02a8 100644
--- a/packages/pieces/community/rss/package.json
+++ b/packages/pieces/community/rss/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-rss",
- "version": "0.7.1",
+ "version": "0.7.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/rss/src/lib/triggers/new-item-list-triggers.ts b/packages/pieces/community/rss/src/lib/triggers/new-item-list-triggers.ts
index f17dce08701..7031f194cde 100644
--- a/packages/pieces/community/rss/src/lib/triggers/new-item-list-triggers.ts
+++ b/packages/pieces/community/rss/src/lib/triggers/new-item-list-triggers.ts
@@ -49,6 +49,9 @@ export const rssNewItemListTrigger = createTrigger({
},
async onDisable(context): Promise<void> {
+ if (context.isRepublish) {
+ return;
+ }
const { propsValue, store } = context;
const lastFetchDate = await store.get<number>('_lastRssPublishDate');
if (!isNil(lastFetchDate)) {
diff --git a/packages/pieces/community/rss/src/lib/triggers/new-item-trigger.ts b/packages/pieces/community/rss/src/lib/triggers/new-item-trigger.ts
index 9c2ff5a3357..d1d31bc079d 100644
--- a/packages/pieces/community/rss/src/lib/triggers/new-item-trigger.ts
+++ b/packages/pieces/community/rss/src/lib/triggers/new-item-trigger.ts
@@ -44,6 +44,9 @@ export const rssNewItemTrigger = createTrigger({
},
async onDisable(context): Promise<void> {
+ if (context.isRepublish) {
+ return;
+ }
const { store } = context;
const lastFetchDate = await store.get<number>('_lastRssPublishDate');
if (!isNil(lastFetchDate)) {
diff --git a/packages/pieces/community/sendpulse/package.json b/packages/pieces/community/sendpulse/package.json
index a6c2374dd8c..967dc0513f0 100644
--- a/packages/pieces/community/sendpulse/package.json
+++ b/packages/pieces/community/sendpulse/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-sendpulse",
- "version": "0.2.1",
+ "version": "0.2.2",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/sendpulse/src/lib/triggers/updated-subscriber.ts b/packages/pieces/community/sendpulse/src/lib/triggers/updated-subscriber.ts
index 0326cdc6d2e..274ede1bad8 100644
--- a/packages/pieces/community/sendpulse/src/lib/triggers/updated-subscriber.ts
+++ b/packages/pieces/community/sendpulse/src/lib/triggers/updated-subscriber.ts
@@ -1,5 +1,6 @@
import {
createTrigger,
+ isNil,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import { sendpulseAuth } from '../common/auth';
@@ -39,11 +40,17 @@ export const updatedSubscriberTrigger = createTrigger({
},
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('last_check'))) {
+ return;
+ }
await context.store.put('mailing_list_id', String(context.propsValue.mailingListId));
await context.store.put('last_check', Date.now().toString());
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete('mailing_list_id');
await context.store.delete('last_check');
await context.store.delete('subscribers_cache');
diff --git a/packages/pieces/community/short-io/package.json b/packages/pieces/community/short-io/package.json
index 19e0e767371..ae10401261e 100644
--- a/packages/pieces/community/short-io/package.json
+++ b/packages/pieces/community/short-io/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-short-io",
- "version": "0.3.1",
+ "version": "0.3.2",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/short-io/src/lib/triggers/new-link-created.ts b/packages/pieces/community/short-io/src/lib/triggers/new-link-created.ts
index 190825017f7..2211fc36b55 100644
--- a/packages/pieces/community/short-io/src/lib/triggers/new-link-created.ts
+++ b/packages/pieces/community/short-io/src/lib/triggers/new-link-created.ts
@@ -1,4 +1,4 @@
-import { createTrigger, Property, Store, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, Property, Store, TriggerStrategy } from '@activepieces/pieces-framework';
import { shortIoAuth } from '../common/auth';
import { ShortIoAuthValue } from '../common/client';
import { shortIoLinkQueries } from '../common/link-queries';
@@ -220,10 +220,16 @@ export const newLinkCreatedTrigger = createTrigger({
},
async onEnable(context) {
const domain = shortIoLinks.parseDomainProp(context.propsValue.domain);
+ if (context.isRepublish && (!isNil(await context.store.get(STATE_KEY)) || !isNil(await context.store.get(LEGACY_IDS_KEY)))) {
+ return;
+ }
await context.store.delete(LEGACY_IDS_KEY);
await baseline({ auth: context.auth, domain, store: context.store });
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(STATE_KEY);
await context.store.delete(LEGACY_IDS_KEY);
},
diff --git a/packages/pieces/community/spotify/package.json b/packages/pieces/community/spotify/package.json
index 0bdc304b595..986617a453b 100644
--- a/packages/pieces/community/spotify/package.json
+++ b/packages/pieces/community/spotify/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-spotify",
- "version": "0.6.1",
+ "version": "0.6.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/spotify/src/lib/triggers/playlist-items-changed.ts b/packages/pieces/community/spotify/src/lib/triggers/playlist-items-changed.ts
index afb3687ecbf..aa4debc7eb4 100644
--- a/packages/pieces/community/spotify/src/lib/triggers/playlist-items-changed.ts
+++ b/packages/pieces/community/spotify/src/lib/triggers/playlist-items-changed.ts
@@ -1,5 +1,6 @@
import {
createTrigger,
+ isNil,
StoreScope,
TriggerStrategy,
} from '@activepieces/pieces-framework';
@@ -20,7 +21,13 @@ export default createTrigger({
playlist_id: spotifyCommon.playlist_id(true),
},
sampleData: {},
- onEnable: async ({ store, auth, propsValue }) => {
+ onEnable: async ({ store, auth, propsValue, isRepublish }) => {
+ if (
+ isRepublish &&
+ !isNil(await store.get('playlist_changed_trigger_hash', StoreScope.FLOW))
+ ) {
+ return;
+ }
const client = makeClient({ auth });
const items = await client.getAllPlaylistItems(
propsValue.playlist_id as string
@@ -30,7 +37,10 @@ export default createTrigger({
.digest('hex');
await store.put('playlist_changed_trigger_hash', hash, StoreScope.FLOW);
},
- onDisable: async ({ store, auth, propsValue }) => {
+ onDisable: async ({ store, auth, propsValue, isRepublish }) => {
+ if (isRepublish) {
+ return;
+ }
await store.delete('playlist_changed_trigger_hash', StoreScope.FLOW);
},
run: async ({ store, auth, propsValue }) => {
diff --git a/packages/pieces/community/ticktick/package.json b/packages/pieces/community/ticktick/package.json
index f2776d26e8a..87401712bcd 100644
--- a/packages/pieces/community/ticktick/package.json
+++ b/packages/pieces/community/ticktick/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-ticktick",
- "version": "0.3.0",
+ "version": "0.3.1",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/ticktick/src/lib/triggers/new-task-created.ts b/packages/pieces/community/ticktick/src/lib/triggers/new-task-created.ts
index 124c97bc9d9..1b2d973348c 100644
--- a/packages/pieces/community/ticktick/src/lib/triggers/new-task-created.ts
+++ b/packages/pieces/community/ticktick/src/lib/triggers/new-task-created.ts
@@ -1,5 +1,5 @@
import { HttpMethod } from '@activepieces/pieces-common';
-import { TriggerStrategy, createTrigger } from '@activepieces/pieces-framework';
+import { TriggerStrategy, createTrigger, isNil } from '@activepieces/pieces-framework';
import { ticktickAuth } from '../auth';
import { tickTickApiCall } from '../common/client';
import { TICKTICK_TASK_STATUS_INCOMPLETE } from '../common/constants';
@@ -43,11 +43,18 @@ export const newTaskCreatedTrigger = createTrigger({
resourceUri: `/project/${propsValue.projectId}/data`,
});
+ if (context.isRepublish && !isNil(await store.get(TRIGGER_KEY))) {
+ return;
+ }
+
const taskIds = response.tasks.map((task) => task.id);
await store.put(TRIGGER_KEY, JSON.stringify(taskIds));
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.delete(TRIGGER_KEY);
},
async test(context) {
diff --git a/packages/pieces/community/totalcms/package.json b/packages/pieces/community/totalcms/package.json
index 26a46ad8c6b..b46d1695ec5 100644
--- a/packages/pieces/community/totalcms/package.json
+++ b/packages/pieces/community/totalcms/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-totalcms",
- "version": "1.0.1",
+ "version": "1.0.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/totalcms/src/lib/common/polling.ts b/packages/pieces/community/totalcms/src/lib/common/polling.ts
index adf67fdbcf4..bff7aedb964 100644
--- a/packages/pieces/community/totalcms/src/lib/common/polling.ts
+++ b/packages/pieces/community/totalcms/src/lib/common/polling.ts
@@ -24,7 +24,10 @@ async function enable({ auth, store, collection, field, isRepublish }: PollParam
await store.put(STORE_KEY, checkpointFrom({ objects: newest, field, previous: { ts: 0, ids: [] } }));
}
-async function disable({ store }: { store: Store }): Promise<void> {
+async function disable({ store, isRepublish }: { store: Store; isRepublish?: boolean }): Promise<void> {
+ if (isRepublish) {
+ return;
+ }
await store.delete(STORE_KEY);
}
diff --git a/packages/pieces/community/totalcms/src/lib/triggers/new-blog-post.ts b/packages/pieces/community/totalcms/src/lib/triggers/new-blog-post.ts
index 816cf746acb..8fc0e2ba305 100644
--- a/packages/pieces/community/totalcms/src/lib/triggers/new-blog-post.ts
+++ b/packages/pieces/community/totalcms/src/lib/triggers/new-blog-post.ts
@@ -37,7 +37,7 @@ export const newBlogPost = createTrigger({
});
},
async onDisable(context) {
- await totalcmsPolling.disable({ store: context.store });
+ await totalcmsPolling.disable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
const posts = await totalcmsPolling.poll({
diff --git a/packages/pieces/community/totalcms/src/lib/triggers/new-object.ts b/packages/pieces/community/totalcms/src/lib/triggers/new-object.ts
index 3a6d349ebe2..64dcb6c72c6 100644
--- a/packages/pieces/community/totalcms/src/lib/triggers/new-object.ts
+++ b/packages/pieces/community/totalcms/src/lib/triggers/new-object.ts
@@ -31,7 +31,7 @@ export const newObjectTrigger = createTrigger({
});
},
async onDisable(context) {
- await totalcmsPolling.disable({ store: context.store });
+ await totalcmsPolling.disable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
return totalcmsPolling.poll({
diff --git a/packages/pieces/community/totalcms/src/lib/triggers/updated-object.ts b/packages/pieces/community/totalcms/src/lib/triggers/updated-object.ts
index 21826e2c775..150b52cf17b 100644
--- a/packages/pieces/community/totalcms/src/lib/triggers/updated-object.ts
+++ b/packages/pieces/community/totalcms/src/lib/triggers/updated-object.ts
@@ -37,7 +37,7 @@ export const updatedObjectTrigger = createTrigger({
});
},
async onDisable(context) {
- await totalcmsPolling.disable({ store: context.store });
+ await totalcmsPolling.disable({ store: context.store, isRepublish: context.isRepublish });
},
async run(context) {
const objects = await totalcmsPolling.poll({
diff --git a/packages/pieces/community/twilio/package.json b/packages/pieces/community/twilio/package.json
index 527ac1aae97..b31f77041fe 100644
--- a/packages/pieces/community/twilio/package.json
+++ b/packages/pieces/community/twilio/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-twilio",
- "version": "0.7.1",
+ "version": "0.7.2",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/twilio/src/lib/trigger/new-incoming-sms.ts b/packages/pieces/community/twilio/src/lib/trigger/new-incoming-sms.ts
index f5f4d0a03ae..2d1e15e92a7 100644
--- a/packages/pieces/community/twilio/src/lib/trigger/new-incoming-sms.ts
+++ b/packages/pieces/community/twilio/src/lib/trigger/new-incoming-sms.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
+import { createTrigger, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import {
HttpMethod,
HttpResponse,
@@ -53,6 +53,9 @@ export const twilioNewIncomingSms = createTrigger({
// Twilio API only allows one webhook per phone number, so we need to poll
type: TriggerStrategy.POLLING,
async onEnable(context) {
+ if (context.isRepublish && !isNil(await context.store.get('_new_incoming_sms_trigger'))) {
+ return;
+ }
const { phone_number } = context.propsValue;
const account_sid = context.auth.username;
const auth_token = context.auth.password;
@@ -70,6 +73,9 @@ export const twilioNewIncomingSms = createTrigger({
});
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await context.store.put('_new_incoming_sms_trigger', null);
},
async run(context) {
diff --git a/packages/pieces/community/wufoo/package.json b/packages/pieces/community/wufoo/package.json
index fa564a25665..63ecaa14c19 100644
--- a/packages/pieces/community/wufoo/package.json
+++ b/packages/pieces/community/wufoo/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-wufoo",
- "version": "0.2.0",
+ "version": "0.2.1",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/wufoo/src/lib/triggers/new-form.ts b/packages/pieces/community/wufoo/src/lib/triggers/new-form.ts
index f5945fc1efc..796ecf2a26f 100644
--- a/packages/pieces/community/wufoo/src/lib/triggers/new-form.ts
+++ b/packages/pieces/community/wufoo/src/lib/triggers/new-form.ts
@@ -1,4 +1,4 @@
-import { createTrigger, TriggerStrategy, Property } from '@activepieces/pieces-framework';
+import { createTrigger, TriggerStrategy, Property, isNil } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { wufooAuth } from '../auth';
import { wufooApiCall } from '../common/client';
@@ -62,6 +62,7 @@ export const newFormTrigger = createTrigger({
async onEnable(context) {
const { responseFormat } = context.propsValue;
+ const keepExistingState = context.isRepublish === true && !isNil(await context.store.get(LAST_FORM_IDS_KEY));
try {
const response = await wufooApiCall<{ Forms: WufooForm[] }>({
@@ -70,6 +71,10 @@ export const newFormTrigger = createTrigger({
resourceUri: `/forms.${responseFormat || 'json'}`,
});
+ if (keepExistingState) {
+ return;
+ }
+
const hashes = response.Forms.map((form) => form.Hash);
await context.store.put<string[]>(LAST_FORM_IDS_KEY, hashes);
diff --git a/packages/pieces/community/youtube/package.json b/packages/pieces/community/youtube/package.json
index e29297e43b1..1235a82f98d 100644
--- a/packages/pieces/community/youtube/package.json
+++ b/packages/pieces/community/youtube/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-youtube",
- "version": "0.9.2",
+ "version": "0.9.3",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
@@ -15,10 +15,12 @@
"scripts": {
"build": "tsc -p tsconfig.lib.json && cp package.json dist/",
"bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",
- "lint": "eslint 'src/**/*.ts'"
+ "lint": "eslint 'src/**/*.ts'",
+ "test": "vitest run"
},
"devDependencies": {
"@types/feedparser": "2.2.8",
- "tslib": "2.6.2"
+ "tslib": "2.6.2",
+ "vitest": "3.2.6"
}
}
diff --git a/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts b/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts
index 83cab0396a6..c38985719af 100644
--- a/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts
+++ b/packages/pieces/community/youtube/src/lib/triggers/new-video.trigger.ts
@@ -235,18 +235,22 @@ export const youtubeNewVideoTrigger = createTrigger({
async test(context): Promise<unknown[]> {
return pollingHelper.test(polling, context);
},
- async onEnable({ propsValue, store }): Promise<void> {
+ async onEnable({ propsValue, store, isRepublish }): Promise<void> {
+ if (isRepublish && !isNil(await store.get('_seenVideoIds'))) {
+ return;
+ }
let channelId = await store.get<string>('channelId');
if (isNil(channelId)) {
channelId = await getChannelId(propsValue.channel_identifier);
await store.put('channelId', channelId);
}
const items = await getRssItems(channelId);
- if (items.length > 0) {
- await store.put('_seenVideoIds', items.map((item) => getId(item)));
- }
+ await store.put('_seenVideoIds', items.map((item) => getId(item)));
},
- async onDisable({ store }): Promise<void> {
+ async onDisable({ store, isRepublish }): Promise<void> {
+ if (isRepublish) {
+ return;
+ }
await store.delete('_seenVideoIds');
await store.delete('channelId');
},
diff --git a/packages/pieces/community/youtube/test/new-video-republish.test.ts b/packages/pieces/community/youtube/test/new-video-republish.test.ts
new file mode 100644
index 00000000000..3bbfc5cdf27
--- /dev/null
+++ b/packages/pieces/community/youtube/test/new-video-republish.test.ts
@@ -0,0 +1,73 @@
+/// <reference types="vitest/globals" />
+
+import { Store } from '@activepieces/pieces-framework';
+
+const feedVideos: string[] = [];
+const sendRequestMock = vi.fn(async () => ({ status: 200, headers: {}, body: Buffer.from(atomFeed(feedVideos)) }));
+
+vi.mock('@activepieces/pieces-common', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('@activepieces/pieces-common')>();
+ return { ...actual, httpClient: { sendRequest: () => sendRequestMock() } };
+});
+
+import { youtubeNewVideoTrigger } from '../src/lib/triggers/new-video.trigger';
+
+describe('youtubeNewVideoTrigger republish', () => {
+ beforeEach(() => {
+ feedVideos.length = 0;
+ });
+
+ it('fires the first video of an empty channel even when it arrives just before a republish', async () => {
+ const { store } = memoryStore({ channelId: 'UC123' });
+ await youtubeNewVideoTrigger.onEnable(hookContext({ store }));
+
+ feedVideos.push('yt:video:first');
+ await youtubeNewVideoTrigger.onDisable(hookContext({ store, isRepublish: true }));
+ await youtubeNewVideoTrigger.onEnable(hookContext({ store, isRepublish: true }));
+
+ const emitted = await youtubeNewVideoTrigger.run(hookContext({ store }));
+ expect(emitted).toHaveLength(1);
+ });
+
+ it('does not re-emit videos that were in the feed when the trigger was enabled', async () => {
+ feedVideos.push('yt:video:old');
+ const { store } = memoryStore({ channelId: 'UC123' });
+ await youtubeNewVideoTrigger.onEnable(hookContext({ store }));
+
+ expect(await youtubeNewVideoTrigger.run(hookContext({ store }))).toEqual([]);
+ });
+});
+
+function atomFeed(videoIds: string[]): string {
+ const entries = videoIds
+ .map((id) => `<entry><id>${id}</id><title>${id}</title><link rel="alternate" href="https://www.youtube.com/watch?v=${id}"/><published>2026-10-01T00:00:00+00:00</published></entry>`)
+ .join('');
+ return `<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>channel</title><id>yt:channel:UC123</id>${entries}</feed>`;
+}
+
+function hookContext({ store, isRepublish }: { store: Store; isRepublish?: boolean }): Parameters<typeof youtubeNewVideoTrigger.run>[0] {
+ return {
+ store,
+ isRepublish,
+ auth: undefined,
+ propsValue: { channel_identifier: 'https://www.youtube.com/channel/UC123' },
+ files: {},
+ } as unknown as Parameters<typeof youtubeNewVideoTrigger.run>[0];
+}
+
+function memoryStore(initial: Record<string, unknown>): { store: Store; data: Map<string, unknown> } {
+ const data = new Map<string, unknown>(Object.entries(initial));
+ const store: Store = {
+ async put<T>(key: string, value: T): Promise<T> {
+ data.set(key, value);
+ return value;
+ },
+ async get<T>(key: string): Promise<T | null> {
+ return (data.get(key) as T) ?? null;
+ },
+ async delete(key: string): Promise<void> {
+ data.delete(key);
+ },
+ };
+ return { store, data };
+}
diff --git a/packages/pieces/community/youtube/vitest.config.ts b/packages/pieces/community/youtube/vitest.config.ts
new file mode 100644
index 00000000000..f520fc14113
--- /dev/null
+++ b/packages/pieces/community/youtube/vitest.config.ts
@@ -0,0 +1,18 @@
+import path from 'path'
+import { defineConfig } from 'vitest/config'
+
+const repoRoot = path.resolve(__dirname, '../../../..')
+
+export default defineConfig({
+ test: {
+ globals: true,
+ environment: 'node',
+ },
+ resolve: {
+ alias: {
+ '@activepieces/shared': path.resolve(repoRoot, 'packages/core/shared/src/index.ts'),
+ '@activepieces/pieces-framework': path.resolve(repoRoot, 'packages/pieces/framework/src/index.ts'),
+ '@activepieces/pieces-common': path.resolve(repoRoot, 'packages/pieces/common/src/index.ts'),
+ },
+ },
+})
diff --git a/packages/pieces/community/zendesk-sell/package.json b/packages/pieces/community/zendesk-sell/package.json
index 6026ce9811c..49f340b0f25 100644
--- a/packages/pieces/community/zendesk-sell/package.json
+++ b/packages/pieces/community/zendesk-sell/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-zendesk-sell",
- "version": "0.2.2",
+ "version": "0.2.3",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/zendesk-sell/src/lib/triggers/deal_enters_stage.ts b/packages/pieces/community/zendesk-sell/src/lib/triggers/deal_enters_stage.ts
index dc3e8e0df6c..8293897b1db 100644
--- a/packages/pieces/community/zendesk-sell/src/lib/triggers/deal_enters_stage.ts
+++ b/packages/pieces/community/zendesk-sell/src/lib/triggers/deal_enters_stage.ts
@@ -2,7 +2,8 @@ import {
createTrigger,
TriggerStrategy,
PiecePropValueSchema,
- AppConnectionValueForAuthProperty
+ AppConnectionValueForAuthProperty,
+ isNil
} from '@activepieces/pieces-framework';
import { HttpMethod, DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';
import { zendeskSellAuth } from '../common/auth';
@@ -85,12 +86,18 @@ export const dealEntersStage = createTrigger({
async onEnable(context) {
await pollingHelper.onEnable(polling, context);
+ if (context.isRepublish && !isNil(await context.store.get(PREVIOUS_DEAL_STAGES_STORE_KEY))) {
+ return;
+ }
// Initialize custom state for stage tracking
await context.store.put<PreviousDealStagesMap>(PREVIOUS_DEAL_STAGES_STORE_KEY, {});
console.log(`Initialized store for dealEntersStage`);
},
async onDisable(context) {
+ if (context.isRepublish) {
+ return;
+ }
await pollingHelper.onDisable(polling, context);
await context.store.delete(PREVIOUS_DEAL_STAGES_STORE_KEY);
console.log(`Cleaned up store for dealEntersStage`);
diff --git a/packages/server/api/src/app/trigger/trigger-source/flow-trigger-side-effect.ts b/packages/server/api/src/app/trigger/trigger-source/flow-trigger-side-effect.ts
index ee0cb93a985..a3a782de7fc 100644
--- a/packages/server/api/src/app/trigger/trigger-source/flow-trigger-side-effect.ts
+++ b/packages/server/api/src/app/trigger/trigger-source/flow-trigger-side-effect.ts
@@ -80,8 +80,8 @@ export const flowTriggerSideEffect = (log: FastifyBaseLogger) => {
if (environment === ApEnvironment.TESTING) {
return
}
- const { flowId, flowVersionId, projectId, pieceTrigger, isTriggerUnchanged } = params
- if (pieceTrigger.type !== TriggerStrategy.POLLING || isTriggerUnchanged !== true) {
+ const { flowId, flowVersionId, projectId, pieceTrigger, isRepublish } = params
+ if (pieceTrigger.type !== TriggerStrategy.POLLING || isRepublish !== true) {
await runDisableHook({ params, log })
}
switch (pieceTrigger.type) {
diff --git a/packages/server/api/test/unit/app/flows/trigger/flow-trigger-side-effect.test.ts b/packages/server/api/test/unit/app/flows/trigger/flow-trigger-side-effect.test.ts
index 44891eb095b..60cb6a9c7ba 100644
--- a/packages/server/api/test/unit/app/flows/trigger/flow-trigger-side-effect.test.ts
+++ b/packages/server/api/test/unit/app/flows/trigger/flow-trigger-side-effect.test.ts
@@ -1,6 +1,6 @@
import { ActivepiecesError, ErrorCode } from '@activepieces/core-utils'
import { TriggerStrategy } from '@activepieces/pieces-framework'
-import { ApEnvironment, EngineResponseStatus, TriggerSourceScheduleType } from '@activepieces/shared'
+import { ApEnvironment, EngineResponseStatus, TriggerHookType, TriggerSourceScheduleType } from '@activepieces/shared'
import { beforeEach, describe, expect, it, vi } from 'vitest'
const mockSubmitAndWaitForResponse = vi.fn()
@@ -430,7 +430,7 @@ describe('flowTriggerSideEffect', () => {
expect(mockSubmitAndWaitForResponse).toHaveBeenCalledOnce()
})
- it('runs both hooks with isRepublish when only the inputs match, such as a piece upgrade', async () => {
+ it('skips the old onDisable but runs onEnable with isRepublish on a piece upgrade', async () => {
mockSubmitAndWaitForResponse.mockResolvedValue(okEngineResponse())
await flowTriggerSideEffect(mockLog).disable({
@@ -448,9 +448,21 @@ describe('flowTriggerSideEffect', () => {
previousSchedule,
})
- expect(mockSubmitAndWaitForResponse).toHaveBeenCalledTimes(2)
- expect(mockSubmitAndWaitForResponse).toHaveBeenNthCalledWith(1, expect.objectContaining({ isRepublish: true }), mockLog)
- expect(mockSubmitAndWaitForResponse).toHaveBeenNthCalledWith(2, expect.objectContaining({ isRepublish: true }), mockLog)
+ expect(mockRemoveRepeatingJob).toHaveBeenCalledWith({ flowVersionId: BASE_PARAMS.flowVersionId })
+ expect(mockSubmitAndWaitForResponse).toHaveBeenCalledOnce()
+ expect(mockSubmitAndWaitForResponse).toHaveBeenCalledWith(expect.objectContaining({ hookType: TriggerHookType.ON_ENABLE, isRepublish: true }), mockLog)
+ })
+
+ it('runs onDisable for a polling trigger when the flow is not republished', async () => {
+ mockSubmitAndWaitForResponse.mockResolvedValue(okEngineResponse())
+
+ await flowTriggerSideEffect(mockLog).disable({
+ ...BASE_PARAMS,
+ pieceTrigger: makePollingTrigger(),
+ ignoreError: true,
+ })
+
+ expect(mockSubmitAndWaitForResponse).toHaveBeenCalledWith(expect.objectContaining({ hookType: TriggerHookType.ON_DISABLE }), mockLog)
})
it('still runs the hooks for a trigger that is not polling', async () => {
@@ -460,6 +472,7 @@ describe('flowTriggerSideEffect', () => {
...BASE_PARAMS,
pieceTrigger: makeManualTrigger(),
ignoreError: true,
+ isRepublish: true,
isTriggerUnchanged: true,
})