@automate.ax/integration-contracts 0.90.0 → 0.91.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,308 @@
1
+ import * as z from "zod";
2
+ import { JOB_NIMBUS_VALUE_SCHEMA } from "./api.js";
3
+ export const JOB_NIMBUS_ID_SCHEMA = z.string().trim().min(1);
4
+ const NULLABLE_STRING_SCHEMA = z.string().nullable().optional();
5
+ const NULLABLE_NUMBER_SCHEMA = z.number().nullable().optional();
6
+ const DATE_SCHEMA = z.date().nullable().optional();
7
+ export const JOB_NIMBUS_CUSTOM_FIELDS_SCHEMA = z.record(z.string().min(1), z.union([z.boolean(), z.number(), z.string(), z.null()]));
8
+ export const JOB_NIMBUS_REFERENCE_SCHEMA = z
9
+ .object({
10
+ id: JOB_NIMBUS_ID_SCHEMA,
11
+ name: NULLABLE_STRING_SCHEMA,
12
+ number: NULLABLE_STRING_SCHEMA,
13
+ type: NULLABLE_STRING_SCHEMA,
14
+ })
15
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
16
+ export const JOB_NIMBUS_OWNER_SCHEMA = z
17
+ .object({
18
+ id: JOB_NIMBUS_ID_SCHEMA,
19
+ })
20
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
21
+ export const JOB_NIMBUS_LOCATION_SCHEMA = z
22
+ .object({
23
+ id: z.number(),
24
+ name: NULLABLE_STRING_SCHEMA,
25
+ parentId: z.number().nullable().optional(),
26
+ })
27
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
28
+ export const JOB_NIMBUS_GEO_SCHEMA = z.object({
29
+ lat: z.number(),
30
+ lon: z.number(),
31
+ });
32
+ const CRM_BASE_FIELDS = {
33
+ dateCreated: DATE_SCHEMA,
34
+ createdBy: NULLABLE_STRING_SCHEMA,
35
+ createdByName: NULLABLE_STRING_SCHEMA,
36
+ customer: NULLABLE_STRING_SCHEMA,
37
+ customFields: JOB_NIMBUS_CUSTOM_FIELDS_SCHEMA.optional(),
38
+ id: JOB_NIMBUS_ID_SCHEMA,
39
+ isActive: z.boolean().optional(),
40
+ isArchived: z.boolean().optional(),
41
+ location: JOB_NIMBUS_LOCATION_SCHEMA.nullable().optional(),
42
+ owners: JOB_NIMBUS_OWNER_SCHEMA.array().optional(),
43
+ recordId: z.number().optional(),
44
+ recordType: NULLABLE_NUMBER_SCHEMA,
45
+ recordTypeName: NULLABLE_STRING_SCHEMA,
46
+ related: JOB_NIMBUS_REFERENCE_SCHEMA.array().optional(),
47
+ tags: z.string().array().optional(),
48
+ type: NULLABLE_STRING_SCHEMA,
49
+ dateUpdated: DATE_SCHEMA,
50
+ };
51
+ const ADDRESS_FIELDS = {
52
+ addressLine1: NULLABLE_STRING_SCHEMA,
53
+ addressLine2: NULLABLE_STRING_SCHEMA,
54
+ city: NULLABLE_STRING_SCHEMA,
55
+ countryName: NULLABLE_STRING_SCHEMA,
56
+ stateText: NULLABLE_STRING_SCHEMA,
57
+ zip: NULLABLE_STRING_SCHEMA,
58
+ };
59
+ const WORKFLOW_FIELDS = {
60
+ isClosed: z.boolean().optional(),
61
+ isLead: z.boolean().optional(),
62
+ salesRep: NULLABLE_STRING_SCHEMA,
63
+ salesRepName: NULLABLE_STRING_SCHEMA,
64
+ source: NULLABLE_NUMBER_SCHEMA,
65
+ sourceName: NULLABLE_STRING_SCHEMA,
66
+ status: NULLABLE_NUMBER_SCHEMA,
67
+ statusName: NULLABLE_STRING_SCHEMA,
68
+ };
69
+ export const JOB_NIMBUS_CONTACT_SCHEMA = z
70
+ .object({
71
+ ...CRM_BASE_FIELDS,
72
+ ...ADDRESS_FIELDS,
73
+ ...WORKFLOW_FIELDS,
74
+ company: NULLABLE_STRING_SCHEMA,
75
+ description: NULLABLE_STRING_SCHEMA,
76
+ displayName: NULLABLE_STRING_SCHEMA,
77
+ email: NULLABLE_STRING_SCHEMA,
78
+ faxNumber: NULLABLE_STRING_SCHEMA,
79
+ firstName: NULLABLE_STRING_SCHEMA,
80
+ geo: JOB_NIMBUS_GEO_SCHEMA.nullable().optional(),
81
+ homePhone: NULLABLE_STRING_SCHEMA,
82
+ lastName: NULLABLE_STRING_SCHEMA,
83
+ mobilePhone: NULLABLE_STRING_SCHEMA,
84
+ website: NULLABLE_STRING_SCHEMA,
85
+ workPhone: NULLABLE_STRING_SCHEMA,
86
+ })
87
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
88
+ export const JOB_NIMBUS_JOB_SCHEMA = z
89
+ .object({
90
+ ...CRM_BASE_FIELDS,
91
+ ...ADDRESS_FIELDS,
92
+ ...WORKFLOW_FIELDS,
93
+ description: NULLABLE_STRING_SCHEMA,
94
+ geo: JOB_NIMBUS_GEO_SCHEMA.nullable().optional(),
95
+ name: z.string(),
96
+ number: NULLABLE_STRING_SCHEMA,
97
+ primary: JOB_NIMBUS_REFERENCE_SCHEMA.nullable().optional(),
98
+ })
99
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
100
+ export const JOB_NIMBUS_TASK_SCHEMA = z
101
+ .object({
102
+ ...CRM_BASE_FIELDS,
103
+ actualTime: NULLABLE_NUMBER_SCHEMA,
104
+ dateEnd: DATE_SCHEMA,
105
+ dateStart: DATE_SCHEMA,
106
+ description: NULLABLE_STRING_SCHEMA,
107
+ estimatedTime: NULLABLE_NUMBER_SCHEMA,
108
+ isCompleted: z.boolean().optional(),
109
+ number: NULLABLE_STRING_SCHEMA,
110
+ priority: NULLABLE_NUMBER_SCHEMA,
111
+ primary: JOB_NIMBUS_REFERENCE_SCHEMA.nullable().optional(),
112
+ title: z.string(),
113
+ })
114
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
115
+ export const JOB_NIMBUS_PRODUCT_UOM_SCHEMA = z
116
+ .object({
117
+ labor: z
118
+ .object({ cost: z.number().optional(), price: z.number().optional() })
119
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA)
120
+ .optional(),
121
+ material: z
122
+ .object({ cost: z.number().optional(), price: z.number().optional() })
123
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA)
124
+ .optional(),
125
+ uom: z.string(),
126
+ })
127
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
128
+ export const JOB_NIMBUS_PRODUCT_SCHEMA = z
129
+ .object({
130
+ ...CRM_BASE_FIELDS,
131
+ description: NULLABLE_STRING_SCHEMA,
132
+ externalId: NULLABLE_STRING_SCHEMA,
133
+ itemType: z.enum(["labor", "labor+material", "material"]).optional(),
134
+ locationId: z.number().nullable().optional(),
135
+ name: z.string(),
136
+ suppliers: z.array(JOB_NIMBUS_VALUE_SCHEMA).optional(),
137
+ taxExempt: z.boolean().optional(),
138
+ uoms: JOB_NIMBUS_PRODUCT_UOM_SCHEMA.array().optional(),
139
+ })
140
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
141
+ export const JOB_NIMBUS_FILE_SCHEMA = z
142
+ .object({
143
+ ...CRM_BASE_FIELDS,
144
+ description: NULLABLE_STRING_SCHEMA,
145
+ filename: NULLABLE_STRING_SCHEMA,
146
+ isPrivate: z.boolean().optional(),
147
+ name: NULLABLE_STRING_SCHEMA,
148
+ size: NULLABLE_NUMBER_SCHEMA,
149
+ })
150
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
151
+ /**
152
+ * Wraps a legacy item schema in JobNimbus's offset-page response.
153
+ *
154
+ * @param itemSchema - Schema for one legacy result.
155
+ */
156
+ export function jobNimbusPageSchema(itemSchema) {
157
+ return z
158
+ .object({
159
+ count: z.number().int().nonnegative(),
160
+ results: itemSchema.array(),
161
+ })
162
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
163
+ }
164
+ export const JOB_NIMBUS_ACTIVITY_RECORD_INPUT_SCHEMA = z.object({
165
+ id: JOB_NIMBUS_ID_SCHEMA,
166
+ type: z.string().trim().min(1),
167
+ });
168
+ export const JOB_NIMBUS_ACTIVITY_RECORD_SCHEMA = z.object({
169
+ ...JOB_NIMBUS_ACTIVITY_RECORD_INPUT_SCHEMA.shape,
170
+ name: z.string().nullable().optional(),
171
+ });
172
+ export const JOB_NIMBUS_ACTIVITY_ACTOR_SCHEMA = z
173
+ .object({
174
+ id: JOB_NIMBUS_ID_SCHEMA,
175
+ name: z.string(),
176
+ })
177
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
178
+ export const JOB_NIMBUS_ACTIVITY_SCHEMA = z
179
+ .object({
180
+ activityAction: z.string(),
181
+ activityTypeId: z.number().int(),
182
+ content: z.string(),
183
+ createdAt: z
184
+ .union([z.date(), z.iso.datetime({ offset: true })])
185
+ .transform((value) => (value instanceof Date ? value : new Date(value))),
186
+ createdBy: JOB_NIMBUS_ACTIVITY_ACTOR_SCHEMA,
187
+ hasFiles: z.boolean(),
188
+ id: JOB_NIMBUS_ID_SCHEMA,
189
+ isEditable: z.boolean(),
190
+ isPrivate: z.boolean(),
191
+ primaryRecord: JOB_NIMBUS_ACTIVITY_RECORD_SCHEMA,
192
+ relatedRecords: JOB_NIMBUS_ACTIVITY_RECORD_SCHEMA.array(),
193
+ updatedAt: z
194
+ .union([z.date(), z.iso.datetime({ offset: true })])
195
+ .transform((value) => (value instanceof Date ? value : new Date(value))),
196
+ })
197
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
198
+ export const JOB_NIMBUS_ACTIVITY_TYPE_SCHEMA = z.object({
199
+ displayName: z.string(),
200
+ id: z.number().int(),
201
+ isArchived: z.boolean(),
202
+ isSystem: z.boolean(),
203
+ });
204
+ /**
205
+ * Wraps a Platform response schema in JobNimbus's data envelope.
206
+ *
207
+ * @param dataSchema - Schema for the enveloped data value.
208
+ */
209
+ export function jobNimbusDataSchema(dataSchema) {
210
+ return z.object({ data: dataSchema }).catchall(JOB_NIMBUS_VALUE_SCHEMA);
211
+ }
212
+ export const JOB_NIMBUS_ACTIVITY_PAGE_SCHEMA = z
213
+ .object({
214
+ data: JOB_NIMBUS_ACTIVITY_SCHEMA.array(),
215
+ pagination: z.object({
216
+ nextCursor: z.string().nullable(),
217
+ pageSize: z.number().int().positive(),
218
+ }),
219
+ })
220
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
221
+ export const JOB_NIMBUS_WORKFLOW_STATUS_SCHEMA = z
222
+ .object({
223
+ id: z.number().int(),
224
+ isActive: z.boolean(),
225
+ isArchived: z.boolean(),
226
+ isClosed: z.boolean(),
227
+ isLead: z.boolean(),
228
+ name: z.string(),
229
+ order: z.number().int(),
230
+ })
231
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
232
+ export const JOB_NIMBUS_WORKFLOW_SCHEMA = z
233
+ .object({
234
+ id: z.number().int(),
235
+ isActive: z.boolean(),
236
+ name: z.string(),
237
+ objectType: z.enum(["contact", "job", "workorder"]),
238
+ order: z.number().int(),
239
+ status: JOB_NIMBUS_WORKFLOW_STATUS_SCHEMA.array(),
240
+ })
241
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
242
+ export const JOB_NIMBUS_FILE_TYPE_SCHEMA = z.object({
243
+ fileTypeId: z.number().int(),
244
+ isActive: z.boolean(),
245
+ typeName: z.string(),
246
+ });
247
+ export const JOB_NIMBUS_TASK_TYPE_SCHEMA = z.object({
248
+ defaultName: z.string(),
249
+ hideFromCalendarView: z.boolean(),
250
+ hideFromTaskList: z.boolean(),
251
+ icon: z.string(),
252
+ isActive: z.boolean(),
253
+ taskTypeId: z.number().int(),
254
+ typeName: z.string(),
255
+ });
256
+ export const JOB_NIMBUS_LEGACY_ACTIVITY_TYPE_SCHEMA = z.object({
257
+ activityTypeId: z.number().int(),
258
+ isActive: z.boolean(),
259
+ showInJobShare: z.boolean(),
260
+ typeName: z.string(),
261
+ });
262
+ export const JOB_NIMBUS_SOURCE_SCHEMA = z.object({
263
+ isActive: z.boolean(),
264
+ jobSourceId: z.number().int(),
265
+ sourceName: z.string(),
266
+ });
267
+ export const JOB_NIMBUS_ACCOUNT_SETTINGS_SCHEMA = z
268
+ .object({
269
+ activityTypes: JOB_NIMBUS_LEGACY_ACTIVITY_TYPE_SCHEMA.array().optional(),
270
+ fileTypes: JOB_NIMBUS_FILE_TYPE_SCHEMA.array().optional(),
271
+ sources: JOB_NIMBUS_SOURCE_SCHEMA.array().optional(),
272
+ taskTypes: JOB_NIMBUS_TASK_TYPE_SCHEMA.array().optional(),
273
+ workflows: JOB_NIMBUS_WORKFLOW_SCHEMA.array().optional(),
274
+ })
275
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
276
+ export const JOB_NIMBUS_GROUP_SCHEMA = z
277
+ .object({
278
+ managers: JOB_NIMBUS_ID_SCHEMA.array(),
279
+ members: JOB_NIMBUS_ID_SCHEMA.array(),
280
+ name: z.string(),
281
+ })
282
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
283
+ export const JOB_NIMBUS_USER_SCHEMA = z
284
+ .object({
285
+ calendarColor: NULLABLE_STRING_SCHEMA,
286
+ email: z.email(),
287
+ firstName: z.string(),
288
+ id: JOB_NIMBUS_ID_SCHEMA,
289
+ imageUrl: NULLABLE_STRING_SCHEMA,
290
+ isActive: z.boolean(),
291
+ lastName: z.string(),
292
+ })
293
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
294
+ export const JOB_NIMBUS_USERS_RESPONSE_SCHEMA = z
295
+ .object({
296
+ dateUpdated: z.date().optional(),
297
+ users: JOB_NIMBUS_USER_SCHEMA.array(),
298
+ })
299
+ .catchall(JOB_NIMBUS_VALUE_SCHEMA);
300
+ export const JOB_NIMBUS_COMPANY_SCHEMA = z.object({
301
+ companyId: JOB_NIMBUS_ID_SCHEMA,
302
+ companyLogoUrl: z.string().nullable(),
303
+ companyName: z.string(),
304
+ isCurrent: z.boolean(),
305
+ isPrimary: z.boolean(),
306
+ lastAccessedAt: z.iso.datetime({ offset: true }).nullable(),
307
+ userAvatarUrl: z.string().nullable(),
308
+ });
@@ -330,11 +330,11 @@ export declare const whatsappTriggerContracts: {
330
330
  video: "video";
331
331
  location: "location";
332
332
  system: "system";
333
+ order: "order";
333
334
  reaction: "reaction";
334
335
  button: "button";
335
336
  contacts: "contacts";
336
337
  interactive: "interactive";
337
- order: "order";
338
338
  sticker: "sticker";
339
339
  unsupported: "unsupported";
340
340
  }>;
@@ -425,11 +425,11 @@ export declare const whatsappTriggerContracts: {
425
425
  video: "video";
426
426
  location: "location";
427
427
  system: "system";
428
+ order: "order";
428
429
  reaction: "reaction";
429
430
  button: "button";
430
431
  contacts: "contacts";
431
432
  interactive: "interactive";
432
- order: "order";
433
433
  sticker: "sticker";
434
434
  unsupported: "unsupported";
435
435
  }>;
@@ -96,11 +96,11 @@ export declare const WHATSAPP_WEBHOOK_SCHEMA: z.ZodObject<{
96
96
  video: "video";
97
97
  location: "location";
98
98
  system: "system";
99
+ order: "order";
99
100
  reaction: "reaction";
100
101
  button: "button";
101
102
  contacts: "contacts";
102
103
  interactive: "interactive";
103
- order: "order";
104
104
  sticker: "sticker";
105
105
  unsupported: "unsupported";
106
106
  }>;
@@ -189,11 +189,11 @@ export declare const WHATSAPP_MESSAGE_RECEIVED_EVENT_SCHEMA: z.ZodObject<{
189
189
  video: "video";
190
190
  location: "location";
191
191
  system: "system";
192
+ order: "order";
192
193
  reaction: "reaction";
193
194
  button: "button";
194
195
  contacts: "contacts";
195
196
  interactive: "interactive";
196
- order: "order";
197
197
  sticker: "sticker";
198
198
  unsupported: "unsupported";
199
199
  }>;
@@ -284,11 +284,11 @@ export declare const WHATSAPP_MESSAGE_RECEIVED_EVENT_SCHEMA: z.ZodObject<{
284
284
  video: "video";
285
285
  location: "location";
286
286
  system: "system";
287
+ order: "order";
287
288
  reaction: "reaction";
288
289
  button: "button";
289
290
  contacts: "contacts";
290
291
  interactive: "interactive";
291
- order: "order";
292
292
  sticker: "sticker";
293
293
  unsupported: "unsupported";
294
294
  }>;
@@ -768,7 +768,7 @@ export declare function normalizeWhatsAppWebhook(input: unknown): {
768
768
  message: {
769
769
  id: string;
770
770
  timestamp: string;
771
- type: "unknown" | "text" | "document" | "audio" | "image" | "video" | "location" | "system" | "reaction" | "button" | "contacts" | "interactive" | "order" | "sticker" | "unsupported";
771
+ type: "unknown" | "text" | "document" | "audio" | "image" | "video" | "location" | "system" | "order" | "reaction" | "button" | "contacts" | "interactive" | "sticker" | "unsupported";
772
772
  content?: z.core.util.JSONType | undefined;
773
773
  context?: {
774
774
  messageId: string;
@@ -781,7 +781,7 @@ export declare function normalizeWhatsAppWebhook(input: unknown): {
781
781
  from: string;
782
782
  id: string;
783
783
  timestamp: string;
784
- type: "unknown" | "text" | "document" | "audio" | "image" | "video" | "location" | "system" | "reaction" | "button" | "contacts" | "interactive" | "order" | "sticker" | "unsupported";
784
+ type: "unknown" | "text" | "document" | "audio" | "image" | "video" | "location" | "system" | "order" | "reaction" | "button" | "contacts" | "interactive" | "sticker" | "unsupported";
785
785
  audio?: {
786
786
  id: string;
787
787
  mime_type?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automate.ax/integration-contracts",
3
- "version": "0.90.0",
3
+ "version": "0.91.0",
4
4
  "description": "Shared integration payload contracts and provider primitives for Automate.ax.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,6 +28,7 @@
28
28
  "./google-forms": "./src/google-forms/index.ts",
29
29
  "./google-meet": "./src/google-meet/index.ts",
30
30
  "./github": "./src/github/index.ts",
31
+ "./jobnimbus": "./src/jobnimbus/index.ts",
31
32
  "./linear": "./src/linear/index.ts",
32
33
  "./notion": "./src/notion/index.ts",
33
34
  "./outlook": "./src/outlook/index.ts",
@@ -47,7 +48,7 @@
47
48
  }
48
49
  },
49
50
  "dependencies": {
50
- "@automate.ax/codec": "0.90.0",
51
+ "@automate.ax/codec": "0.91.0",
51
52
  "@cfworker/json-schema": "^4.1.1",
52
53
  "@googleapis/calendar": "^15.0.0",
53
54
  "@googleapis/forms": "^6.0.1",
@@ -148,6 +149,11 @@
148
149
  "types": "./dist/github/index.d.ts",
149
150
  "default": "./dist/github/index.js"
150
151
  },
152
+ "./jobnimbus": {
153
+ "bun": "./src/jobnimbus/index.ts",
154
+ "types": "./dist/jobnimbus/index.d.ts",
155
+ "default": "./dist/jobnimbus/index.js"
156
+ },
151
157
  "./linear": {
152
158
  "bun": "./src/linear/index.ts",
153
159
  "types": "./dist/linear/index.d.ts",