-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DC-789] adds subscription sync modes support in destination-kit #2065
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,8 @@ export interface ExecuteInput< | |
hookOutputs?: Partial<Record<ActionHookType, ActionHookOutputs>> | ||
/** The page used in dynamic field requests */ | ||
page?: string | ||
/** The subscription sync mode */ | ||
syncMode?: SyncMode | ||
/** The data needed in OAuth requests */ | ||
readonly auth?: AuthTokens | ||
/** | ||
|
@@ -191,18 +193,35 @@ export interface InputField extends InputFieldJSONSchema { | |
depends_on?: DependsOnConditions | ||
} | ||
|
||
/** Base interface for conditions */ | ||
interface BaseCondition { | ||
operator: 'is' | 'is_not' | ||
} | ||
|
||
/** | ||
* A single condition defining whether a field should be shown. | ||
* A single condition defining whether a field should be shown based on the value of the field specified by `fieldKey`. | ||
* fieldKey: The field key in the fields object to look at | ||
* operator: The operator to use when comparing the field value | ||
* value: The value we expect that field to have, if undefined, we will match based on whether the field contains a value or not | ||
*/ | ||
export interface Condition { | ||
export interface FieldCondition extends BaseCondition { | ||
fieldKey: string | ||
operator: 'is' | 'is_not' | ||
type?: 'field' // optional for backwards compatibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'd be worth it to make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting. I found that I'd need to make changes in app and this repo. And that's just what I could find quickly. Is it possible to break compatibility anywhere else? Can you help round up all the places this could break? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Example of code that seems like it would break if |
||
value: Omit<FieldValue, 'Directive'> | Array<Omit<FieldValue, 'Directive'>> | undefined | ||
} | ||
|
||
/** | ||
* A single condition defining whether a field should be shown based on the current sync mode. | ||
* operator: The operator to use when comparing the sync mode | ||
* value: The value to compare against, if undefined, we will match based on whether a sync mode is set or not | ||
*/ | ||
export interface SyncModeCondition extends BaseCondition { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering how this will be used, is there some example code of a destination that implements There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good question! There is no example code as of now. This is a completely new thing. And it's going to be used exactly as you described to hide fields in app e.g Action editor. Any concerns? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also it's good to point out that the type itself might not be used directly outside this module so maybe an export is not justified? |
||
type: 'syncMode' | ||
value: SyncMode | ||
} | ||
|
||
export type Condition = FieldCondition | SyncModeCondition | ||
|
||
/** | ||
* If match is not set, it will default to 'all' | ||
* If match = 'any', then meeting any of the conditions defined will result in the field being shown. | ||
|
@@ -263,3 +282,26 @@ export type Deletion<Settings, Return = any> = ( | |
request: RequestClient, | ||
data: ExecuteInput<Settings, DeletionPayload> | ||
) => MaybePromise<Return> | ||
|
||
/** The supported sync mode values */ | ||
export const syncModeTypes = ['add', 'update', 'upsert', 'delete'] as const | ||
export type SyncMode = typeof syncModeTypes[number] | ||
|
||
export interface SyncModeOption { | ||
/** The human-readable label for this option */ | ||
label: string | ||
/** The value of this option */ | ||
value: SyncMode | ||
} | ||
|
||
/** An action sync mode definition */ | ||
export interface SyncModes { | ||
/** The default sync mode that will be selected */ | ||
default: SyncMode | ||
/** The human-readable label for this setting */ | ||
label: string | ||
/** The human-friendly description of the setting */ | ||
description: string | ||
/** The available sync mode choices */ | ||
choices: SyncModeOption[] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to implement a similar logic for executeBatch as well.