Skip to content

Commit a1c7c24

Browse files
authored
fix(specs): correct types for Tasks trigger (#1279)
1 parent e4b318b commit a1c7c24

File tree

1 file changed

+74
-28
lines changed

1 file changed

+74
-28
lines changed

specs/ingestion/common/schemas/task.yml

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Task:
99
destinationID:
1010
$ref: './common.yml#/destinationID'
1111
trigger:
12-
$ref: '#/TaskTrigger'
12+
$ref: '#/Trigger'
1313
enabled:
1414
type: boolean
1515
default: true
@@ -31,10 +31,11 @@ Task:
3131
- action
3232
- createdAt
3333

34-
TaskTrigger:
34+
Trigger:
3535
oneOf:
36-
- $ref: '#/Trigger'
36+
- $ref: '#/OnDemandTrigger'
3737
- $ref: '#/ScheduleTrigger'
38+
- $ref: '#/SubscriptionTrigger'
3839

3940
TaskCreate:
4041
type: object
@@ -131,60 +132,105 @@ TriggerInput:
131132
required:
132133
- type
133134

135+
TriggerType:
136+
type: string
137+
description: >
138+
The type of the task reflect how it can be used:
139+
- on_demand: a task that runs manually
140+
- schedule: a task that runs regularly, following a given cron expression
141+
- subscription: a task that runs after a subscription event is received from an integration (e.g. Webhook).
142+
enum: ['on_demand', 'schedule', 'subscription']
143+
144+
# schedule trigger
145+
146+
LastRun:
147+
description: The last time the scheduled task ran.
148+
type: string
149+
150+
Cron:
151+
type: string
152+
description: A cron expression that represent at which regularity the task should run.
153+
example: '* * 1 * *'
154+
155+
ScheduleTriggerType:
156+
type: string
157+
description: A task which is triggered by a schedule (cron expression).
158+
enum: ['schedule']
159+
134160
ScheduleTriggerInput:
135161
type: object
136162
additionalProperties: false
137163
description: The trigger input for a task of type 'schedule'.
138164
properties:
139165
type:
140-
$ref: '#/TriggerType'
166+
$ref: '#/ScheduleTriggerType'
141167
cron:
142168
$ref: '#/Cron'
143169
required:
144170
- type
145171
- cron
146172

147-
Trigger:
148-
type: object
149-
additionalProperties: false
150-
description: The trigger information of a task.
151-
properties:
152-
type:
153-
$ref: '#/TriggerType'
154-
required:
155-
- type
156-
157173
ScheduleTrigger:
158174
type: object
159175
additionalProperties: false
160176
description: The trigger information for a task of type 'schedule'.
161177
properties:
162178
type:
163-
$ref: '#/TriggerType'
179+
$ref: '#/ScheduleTriggerType'
164180
cron:
165181
$ref: '#/Cron'
166182
lastRun:
167-
description: The last time the scheduled task ran.
168-
type: string
183+
$ref: '#/LastRun'
169184
nextRun:
170185
description: The next scheduled run of the task.
171186
type: string
172187
required:
173188
- type
174189
- cron
175-
- lastRun
176190
- nextRun
177191

178-
TriggerType:
192+
# on demand trigger
193+
194+
OnDemandTriggerType:
179195
type: string
180-
description: >
181-
The type of the task reflect how it can be used:
182-
- on_demand: a task that runs manually
183-
- schedule: a task that runs regularly, following a given cron expression
184-
- subscription: a task that runs after a subscription event is received from an integration (e.g. Webhook).
185-
enum: ['on_demand', 'schedule', 'subscription']
196+
description: A task which is manually executed via the run task endpoint.
197+
enum: ['on_demand']
186198

187-
Cron:
199+
OnDemandTriggerInput:
200+
type: object
201+
additionalProperties: false
202+
description: The trigger information of a task of type `on-demand`.
203+
properties:
204+
type:
205+
$ref: '#/OnDemandTriggerType'
206+
required:
207+
- type
208+
209+
OnDemandTrigger:
210+
type: object
211+
additionalProperties: false
212+
description: The trigger information of a task of type `on-demand`.
213+
properties:
214+
type:
215+
$ref: '#/OnDemandTriggerType'
216+
lastRun:
217+
$ref: '#/LastRun'
218+
required:
219+
- type
220+
221+
# subscription trigger
222+
223+
SubscriptionTriggerType:
188224
type: string
189-
description: A cron expression that represent at which regularity the task should run.
190-
example: '* * 1 * *'
225+
description: A task which is triggered by an external subscription (e.g. Webhook).
226+
enum: ['subscription']
227+
228+
SubscriptionTrigger:
229+
type: object
230+
additionalProperties: false
231+
description: The trigger input for a task of type 'subscription'.
232+
properties:
233+
type:
234+
$ref: '#/TriggerType'
235+
required:
236+
- type

0 commit comments

Comments
 (0)