@automate.ax/integration-contracts 0.110.0 → 0.111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,318 @@
1
+ import * as z from "zod";
2
+ import { ASANA_PROVIDER_RESOURCE_SCHEMA, ASANA_RESOURCE_SCHEMA, toAsanaResource, } from "./base.js";
3
+ export const ASANA_ATTACHMENT_SCHEMA = ASANA_RESOURCE_SCHEMA.extend({
4
+ /** RFC 3339 creation timestamp. */
5
+ createdAt: z.string().optional(),
6
+ /** Temporary authenticated download URL. */
7
+ downloadUrl: z.string().optional(),
8
+ /** Attachment host, such as `asana`, `dropbox`, or `gdrive`. */
9
+ host: z.string().optional(),
10
+ /** Resource containing the attachment. */
11
+ parent: ASANA_RESOURCE_SCHEMA.optional(),
12
+ /** Stable provider URL for the attachment. */
13
+ permanentUrl: z.string().optional(),
14
+ /** File size in bytes. */
15
+ size: z.number().int().nonnegative().optional(),
16
+ /** Browser URL for viewing the attachment. */
17
+ viewUrl: z.string().optional(),
18
+ });
19
+ export const ASANA_TAG_SCHEMA = ASANA_RESOURCE_SCHEMA.extend({
20
+ /** Provider color token. */
21
+ color: z.string().optional(),
22
+ /** RFC 3339 creation timestamp. */
23
+ createdAt: z.string().optional(),
24
+ /** Users following this tag. */
25
+ followers: ASANA_RESOURCE_SCHEMA.array(),
26
+ /** Tag description. */
27
+ notes: z.string().optional(),
28
+ /** Workspace containing the tag. */
29
+ workspace: ASANA_RESOURCE_SCHEMA.optional(),
30
+ });
31
+ export const ASANA_TEAM_SCHEMA = ASANA_RESOURCE_SCHEMA.extend({
32
+ /** Plain-text team description. */
33
+ description: z.string().optional(),
34
+ /** Rich-text team description. */
35
+ htmlDescription: z.string().optional(),
36
+ /** Organization containing the team. */
37
+ organization: ASANA_RESOURCE_SCHEMA.optional(),
38
+ /** Browser URL for the team. */
39
+ permalinkUrl: z.string().optional(),
40
+ });
41
+ export const ASANA_ENUM_OPTION_SCHEMA = ASANA_RESOURCE_SCHEMA.extend({
42
+ /** Provider color token. */
43
+ color: z.string().optional(),
44
+ /** Whether users may select this option. */
45
+ enabled: z.boolean(),
46
+ });
47
+ export const ASANA_CUSTOM_FIELD_DATE_VALUE_SCHEMA = z.object({
48
+ /** Calendar date in YYYY-MM-DD format. */
49
+ date: z.string(),
50
+ /** RFC 3339 timestamp when the field includes a time. */
51
+ dateTime: z.string().optional(),
52
+ });
53
+ const ASANA_CUSTOM_FIELD_DATE_INPUT_VALUE_SCHEMA = z
54
+ .object({
55
+ /** Calendar date in YYYY-MM-DD format. */
56
+ date: z.string().optional(),
57
+ /** RFC 3339 timestamp when the field includes a time. */
58
+ dateTime: z.string().optional(),
59
+ })
60
+ .refine(({ date, dateTime }) => Boolean(date) !== Boolean(dateTime), {
61
+ message: "Provide exactly one custom-field date value.",
62
+ });
63
+ export const ASANA_CUSTOM_FIELD_SCHEMA = ASANA_RESOURCE_SCHEMA.extend({
64
+ /** Custom currency label. */
65
+ customLabel: z.string().optional(),
66
+ /** ISO currency code. */
67
+ currencyCode: z.string().optional(),
68
+ /** Field description. */
69
+ description: z.string().optional(),
70
+ /** Selectable enum options. */
71
+ enumOptions: ASANA_ENUM_OPTION_SCHEMA.array(),
72
+ /** Numeric display format. */
73
+ format: z.string().optional(),
74
+ /** Decimal precision for number fields. */
75
+ precision: z.number().int().nonnegative().optional(),
76
+ /** Custom field subtype. */
77
+ subtype: z.string(),
78
+ });
79
+ export const ASANA_CUSTOM_FIELD_VALUE_SCHEMA = ASANA_CUSTOM_FIELD_SCHEMA.extend({
80
+ /** Structured date value. */
81
+ dateValue: ASANA_CUSTOM_FIELD_DATE_VALUE_SCHEMA.optional(),
82
+ /** Human-readable value rendered by Asana. */
83
+ displayValue: z.string().optional(),
84
+ /** Selected single-enum option. */
85
+ enumValue: ASANA_ENUM_OPTION_SCHEMA.optional(),
86
+ /** Selected multi-enum options. */
87
+ multiEnumValues: ASANA_ENUM_OPTION_SCHEMA.array(),
88
+ /** Numeric value. */
89
+ numberValue: z.number().optional(),
90
+ /** Selected people. */
91
+ peopleValue: ASANA_RESOURCE_SCHEMA.array(),
92
+ /** Selected referenced resources. */
93
+ referenceValue: ASANA_RESOURCE_SCHEMA.array(),
94
+ /** Text value. */
95
+ textValue: z.string().optional(),
96
+ });
97
+ export const ASANA_CUSTOM_FIELD_INPUT_VALUE_SCHEMA = z.union([
98
+ z.string(),
99
+ z.number(),
100
+ z.string().array(),
101
+ ASANA_CUSTOM_FIELD_DATE_INPUT_VALUE_SCHEMA,
102
+ z.null(),
103
+ ]);
104
+ export const ASANA_PROJECT_TASK_COUNTS_SCHEMA = z.object({
105
+ numCompletedMilestones: z.number().int().nonnegative(),
106
+ numCompletedTasks: z.number().int().nonnegative(),
107
+ numIncompleteMilestones: z.number().int().nonnegative(),
108
+ numIncompleteTasks: z.number().int().nonnegative(),
109
+ numMilestones: z.number().int().nonnegative(),
110
+ numTasks: z.number().int().nonnegative(),
111
+ });
112
+ export const ASANA_JOB_SCHEMA = ASANA_RESOURCE_SCHEMA.extend({
113
+ /** Newly created project, when the job duplicates a project. */
114
+ newProject: ASANA_RESOURCE_SCHEMA.optional(),
115
+ /** Newly created task, when the job duplicates a task. */
116
+ newTask: ASANA_RESOURCE_SCHEMA.optional(),
117
+ /** Current asynchronous job state. */
118
+ status: z.enum(["failed", "in_progress", "not_started", "succeeded"]),
119
+ /** Provider job subtype. */
120
+ subtype: z.string().optional(),
121
+ });
122
+ export const ASANA_PROVIDER_ATTACHMENT_SCHEMA = ASANA_PROVIDER_RESOURCE_SCHEMA.extend({
123
+ created_at: z.string().optional(),
124
+ download_url: z.string().nullish(),
125
+ host: z.string().optional(),
126
+ parent: ASANA_PROVIDER_RESOURCE_SCHEMA.nullish(),
127
+ permanent_url: z.string().nullish(),
128
+ size: z.number().int().nonnegative().nullish(),
129
+ view_url: z.string().nullish(),
130
+ });
131
+ export const ASANA_PROVIDER_TAG_SCHEMA = ASANA_PROVIDER_RESOURCE_SCHEMA.extend({
132
+ color: z.string().nullish(),
133
+ created_at: z.string().optional(),
134
+ followers: ASANA_PROVIDER_RESOURCE_SCHEMA.array().optional(),
135
+ notes: z.string().optional(),
136
+ workspace: ASANA_PROVIDER_RESOURCE_SCHEMA.nullish(),
137
+ });
138
+ export const ASANA_PROVIDER_TEAM_SCHEMA = ASANA_PROVIDER_RESOURCE_SCHEMA.extend({
139
+ description: z.string().optional(),
140
+ html_description: z.string().optional(),
141
+ organization: ASANA_PROVIDER_RESOURCE_SCHEMA.nullish(),
142
+ permalink_url: z.string().optional(),
143
+ });
144
+ export const ASANA_PROVIDER_ENUM_OPTION_SCHEMA = ASANA_PROVIDER_RESOURCE_SCHEMA.extend({
145
+ color: z.string().nullish(),
146
+ enabled: z.boolean(),
147
+ });
148
+ export const ASANA_PROVIDER_CUSTOM_FIELD_SCHEMA = ASANA_PROVIDER_RESOURCE_SCHEMA.extend({
149
+ custom_label: z.string().nullish(),
150
+ currency_code: z.string().nullish(),
151
+ description: z.string().optional(),
152
+ enum_options: ASANA_PROVIDER_ENUM_OPTION_SCHEMA.array().optional(),
153
+ format: z.string().nullish(),
154
+ precision: z.number().int().nonnegative().nullish(),
155
+ resource_subtype: z.string(),
156
+ });
157
+ export const ASANA_PROVIDER_CUSTOM_FIELD_VALUE_SCHEMA = ASANA_PROVIDER_CUSTOM_FIELD_SCHEMA.extend({
158
+ date_value: z
159
+ .looseObject({
160
+ date: z.string(),
161
+ date_time: z.string().nullish(),
162
+ })
163
+ .nullish(),
164
+ display_value: z.string().nullish(),
165
+ enum_value: ASANA_PROVIDER_ENUM_OPTION_SCHEMA.nullish(),
166
+ multi_enum_values: ASANA_PROVIDER_ENUM_OPTION_SCHEMA.array().optional(),
167
+ number_value: z.number().nullish(),
168
+ people_value: ASANA_PROVIDER_RESOURCE_SCHEMA.array().optional(),
169
+ reference_value: ASANA_PROVIDER_RESOURCE_SCHEMA.array().optional(),
170
+ text_value: z.string().nullish(),
171
+ });
172
+ export const ASANA_PROVIDER_PROJECT_TASK_COUNTS_SCHEMA = z.looseObject({
173
+ num_completed_milestones: z.number().int().nonnegative(),
174
+ num_completed_tasks: z.number().int().nonnegative(),
175
+ num_incomplete_milestones: z.number().int().nonnegative(),
176
+ num_incomplete_tasks: z.number().int().nonnegative(),
177
+ num_milestones: z.number().int().nonnegative(),
178
+ num_tasks: z.number().int().nonnegative(),
179
+ });
180
+ export const ASANA_PROVIDER_JOB_SCHEMA = ASANA_PROVIDER_RESOURCE_SCHEMA.extend({
181
+ new_project: ASANA_PROVIDER_RESOURCE_SCHEMA.nullish(),
182
+ new_task: ASANA_PROVIDER_RESOURCE_SCHEMA.nullish(),
183
+ resource_subtype: z.string().optional(),
184
+ status: z.enum(["failed", "in_progress", "not_started", "succeeded"]),
185
+ });
186
+ /**
187
+ * Converts a provider attachment to the public shape.
188
+ *
189
+ * @param value - Provider attachment.
190
+ */
191
+ export function toAsanaAttachment(value) {
192
+ return {
193
+ ...toAsanaResource(value),
194
+ createdAt: value.created_at,
195
+ downloadUrl: value.download_url ?? undefined,
196
+ host: value.host,
197
+ parent: value.parent ? toAsanaResource(value.parent) : undefined,
198
+ permanentUrl: value.permanent_url ?? undefined,
199
+ size: value.size ?? undefined,
200
+ viewUrl: value.view_url ?? undefined,
201
+ };
202
+ }
203
+ /**
204
+ * Converts a provider tag to the public shape.
205
+ *
206
+ * @param value - Provider tag.
207
+ */
208
+ export function toAsanaTag(value) {
209
+ return {
210
+ ...toAsanaResource(value),
211
+ color: value.color ?? undefined,
212
+ createdAt: value.created_at,
213
+ followers: (value.followers ?? []).map(toAsanaResource),
214
+ notes: value.notes,
215
+ workspace: value.workspace ? toAsanaResource(value.workspace) : undefined,
216
+ };
217
+ }
218
+ /**
219
+ * Converts a provider team to the public shape.
220
+ *
221
+ * @param value - Provider team.
222
+ */
223
+ export function toAsanaTeam(value) {
224
+ return {
225
+ ...toAsanaResource(value),
226
+ description: value.description,
227
+ htmlDescription: value.html_description,
228
+ organization: value.organization
229
+ ? toAsanaResource(value.organization)
230
+ : undefined,
231
+ permalinkUrl: value.permalink_url,
232
+ };
233
+ }
234
+ /**
235
+ * Converts a provider enum option to the public shape.
236
+ *
237
+ * @param value - Provider enum option.
238
+ */
239
+ export function toAsanaEnumOption(value) {
240
+ return {
241
+ ...toAsanaResource(value),
242
+ color: value.color ?? undefined,
243
+ enabled: value.enabled,
244
+ };
245
+ }
246
+ /**
247
+ * Converts a provider custom field to the public shape.
248
+ *
249
+ * @param value - Provider custom field.
250
+ */
251
+ export function toAsanaCustomField(value) {
252
+ return {
253
+ ...toAsanaResource(value),
254
+ customLabel: value.custom_label ?? undefined,
255
+ currencyCode: value.currency_code ?? undefined,
256
+ description: value.description,
257
+ enumOptions: (value.enum_options ?? []).map(toAsanaEnumOption),
258
+ format: value.format ?? undefined,
259
+ precision: value.precision ?? undefined,
260
+ subtype: value.resource_subtype,
261
+ };
262
+ }
263
+ /**
264
+ * Converts a provider custom-field value to the public shape.
265
+ *
266
+ * @param value - Provider field value.
267
+ */
268
+ export function toAsanaCustomFieldValue(value) {
269
+ return {
270
+ ...toAsanaCustomField(value),
271
+ dateValue: value.date_value
272
+ ? {
273
+ date: value.date_value.date,
274
+ dateTime: value.date_value.date_time ?? undefined,
275
+ }
276
+ : undefined,
277
+ displayValue: value.display_value ?? undefined,
278
+ enumValue: value.enum_value
279
+ ? toAsanaEnumOption(value.enum_value)
280
+ : undefined,
281
+ multiEnumValues: (value.multi_enum_values ?? []).map(toAsanaEnumOption),
282
+ numberValue: value.number_value ?? undefined,
283
+ peopleValue: (value.people_value ?? []).map(toAsanaResource),
284
+ referenceValue: (value.reference_value ?? []).map(toAsanaResource),
285
+ textValue: value.text_value ?? undefined,
286
+ };
287
+ }
288
+ /**
289
+ * Converts provider project task counts to the public shape.
290
+ *
291
+ * @param value - Provider counts.
292
+ */
293
+ export function toAsanaProjectTaskCounts(value) {
294
+ return {
295
+ numCompletedMilestones: value.num_completed_milestones,
296
+ numCompletedTasks: value.num_completed_tasks,
297
+ numIncompleteMilestones: value.num_incomplete_milestones,
298
+ numIncompleteTasks: value.num_incomplete_tasks,
299
+ numMilestones: value.num_milestones,
300
+ numTasks: value.num_tasks,
301
+ };
302
+ }
303
+ /**
304
+ * Converts a provider asynchronous job to the public shape.
305
+ *
306
+ * @param value - Provider job.
307
+ */
308
+ export function toAsanaJob(value) {
309
+ return {
310
+ ...toAsanaResource(value),
311
+ newProject: value.new_project
312
+ ? toAsanaResource(value.new_project)
313
+ : undefined,
314
+ newTask: value.new_task ? toAsanaResource(value.new_task) : undefined,
315
+ status: value.status,
316
+ subtype: value.resource_subtype,
317
+ };
318
+ }