@workbuddy/piece-workbuddy-edge 1.0.33 → 1.0.35

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.
Files changed (149) hide show
  1. package/package.json +1 -1
  2. package/src/index.d.ts.map +1 -1
  3. package/src/index.js +98 -14
  4. package/src/index.js.map +1 -1
  5. package/src/index.ts +183 -10
  6. package/src/lib/actions/crm-companies.d.ts +1 -0
  7. package/src/lib/actions/crm-companies.d.ts.map +1 -1
  8. package/src/lib/actions/crm-companies.js +9 -0
  9. package/src/lib/actions/crm-companies.js.map +1 -1
  10. package/src/lib/actions/crm-companies.ts +11 -0
  11. package/src/lib/actions/crm-contacts.d.ts +25 -0
  12. package/src/lib/actions/crm-contacts.d.ts.map +1 -1
  13. package/src/lib/actions/crm-contacts.js +135 -3
  14. package/src/lib/actions/crm-contacts.js.map +1 -1
  15. package/src/lib/actions/crm-contacts.ts +149 -2
  16. package/src/lib/actions/crm-contractors.d.ts +110 -0
  17. package/src/lib/actions/crm-contractors.d.ts.map +1 -1
  18. package/src/lib/actions/crm-contractors.js +585 -2
  19. package/src/lib/actions/crm-contractors.js.map +1 -1
  20. package/src/lib/actions/crm-contractors.ts +631 -1
  21. package/src/lib/actions/crm-customers.d.ts +94 -0
  22. package/src/lib/actions/crm-customers.d.ts.map +1 -1
  23. package/src/lib/actions/crm-customers.js +504 -3
  24. package/src/lib/actions/crm-customers.js.map +1 -1
  25. package/src/lib/actions/crm-customers.ts +545 -2
  26. package/src/lib/actions/crm-external-users.js +1 -1
  27. package/src/lib/actions/crm-external-users.js.map +1 -1
  28. package/src/lib/actions/crm-external-users.ts +1 -1
  29. package/src/lib/actions/crm-invites.d.ts +1 -0
  30. package/src/lib/actions/crm-invites.d.ts.map +1 -1
  31. package/src/lib/actions/crm-invites.js +9 -0
  32. package/src/lib/actions/crm-invites.js.map +1 -1
  33. package/src/lib/actions/crm-invites.ts +11 -0
  34. package/src/lib/actions/crm-sites.d.ts +10 -0
  35. package/src/lib/actions/crm-sites.d.ts.map +1 -1
  36. package/src/lib/actions/crm-sites.js +59 -3
  37. package/src/lib/actions/crm-sites.js.map +1 -1
  38. package/src/lib/actions/crm-sites.ts +70 -2
  39. package/src/lib/actions/crm-suppliers.d.ts +64 -0
  40. package/src/lib/actions/crm-suppliers.d.ts.map +1 -1
  41. package/src/lib/actions/crm-suppliers.js +352 -2
  42. package/src/lib/actions/crm-suppliers.js.map +1 -1
  43. package/src/lib/actions/crm-suppliers.ts +376 -1
  44. package/src/lib/actions/index.d.ts +11 -1
  45. package/src/lib/actions/index.d.ts.map +1 -1
  46. package/src/lib/actions/index.js +11 -1
  47. package/src/lib/actions/index.js.map +1 -1
  48. package/src/lib/actions/index.ts +11 -1
  49. package/src/lib/actions/items.d.ts +8 -0
  50. package/src/lib/actions/items.d.ts.map +1 -0
  51. package/src/lib/actions/items.js +42 -0
  52. package/src/lib/actions/items.js.map +1 -0
  53. package/src/lib/actions/items.ts +45 -0
  54. package/src/lib/actions/jobs-activities.d.ts +4 -3
  55. package/src/lib/actions/jobs-activities.d.ts.map +1 -1
  56. package/src/lib/actions/jobs-activities.js +19 -12
  57. package/src/lib/actions/jobs-activities.js.map +1 -1
  58. package/src/lib/actions/jobs-activities.ts +19 -12
  59. package/src/lib/actions/jobs-tasks.d.ts +0 -2
  60. package/src/lib/actions/jobs-tasks.d.ts.map +1 -1
  61. package/src/lib/actions/jobs-tasks.js +0 -12
  62. package/src/lib/actions/jobs-tasks.js.map +1 -1
  63. package/src/lib/actions/jobs-tasks.ts +0 -12
  64. package/src/lib/actions/jobs.d.ts +89 -3
  65. package/src/lib/actions/jobs.d.ts.map +1 -1
  66. package/src/lib/actions/jobs.js +499 -31
  67. package/src/lib/actions/jobs.js.map +1 -1
  68. package/src/lib/actions/jobs.ts +527 -30
  69. package/src/lib/actions/mcp.d.ts +3 -3
  70. package/src/lib/actions/mcp.d.ts.map +1 -1
  71. package/src/lib/actions/mcp.js +9 -9
  72. package/src/lib/actions/mcp.js.map +1 -1
  73. package/src/lib/actions/mcp.ts +8 -8
  74. package/src/lib/actions/pending-items.d.ts +8 -0
  75. package/src/lib/actions/pending-items.d.ts.map +1 -0
  76. package/src/lib/actions/pending-items.js +42 -0
  77. package/src/lib/actions/pending-items.js.map +1 -0
  78. package/src/lib/actions/pending-items.ts +45 -0
  79. package/src/lib/actions/service-plans-lines-tasks-subtasks.d.ts +52 -0
  80. package/src/lib/actions/service-plans-lines-tasks-subtasks.d.ts.map +1 -0
  81. package/src/lib/actions/service-plans-lines-tasks-subtasks.js +257 -0
  82. package/src/lib/actions/service-plans-lines-tasks-subtasks.js.map +1 -0
  83. package/src/lib/actions/service-plans-lines-tasks-subtasks.ts +274 -0
  84. package/src/lib/actions/service-plans-lines-tasks.d.ts +52 -0
  85. package/src/lib/actions/service-plans-lines-tasks.d.ts.map +1 -0
  86. package/src/lib/actions/service-plans-lines-tasks.js +261 -0
  87. package/src/lib/actions/service-plans-lines-tasks.js.map +1 -0
  88. package/src/lib/actions/service-plans-lines-tasks.ts +278 -0
  89. package/src/lib/actions/service-plans-lines.d.ts +52 -0
  90. package/src/lib/actions/service-plans-lines.d.ts.map +1 -0
  91. package/src/lib/actions/service-plans-lines.js +286 -0
  92. package/src/lib/actions/service-plans-lines.js.map +1 -0
  93. package/src/lib/actions/service-plans-lines.ts +302 -0
  94. package/src/lib/actions/service-plans.d.ts +45 -0
  95. package/src/lib/actions/service-plans.d.ts.map +1 -0
  96. package/src/lib/actions/service-plans.js +229 -0
  97. package/src/lib/actions/service-plans.js.map +1 -0
  98. package/src/lib/actions/service-plans.ts +250 -0
  99. package/src/lib/actions/settings-custom-fields.d.ts +21 -0
  100. package/src/lib/actions/settings-custom-fields.d.ts.map +1 -0
  101. package/src/lib/actions/settings-custom-fields.js +95 -0
  102. package/src/lib/actions/settings-custom-fields.js.map +1 -0
  103. package/src/lib/actions/settings-custom-fields.ts +107 -0
  104. package/src/lib/actions/settings-items.d.ts +136 -0
  105. package/src/lib/actions/settings-items.d.ts.map +1 -0
  106. package/src/lib/actions/settings-items.js +772 -0
  107. package/src/lib/actions/settings-items.js.map +1 -0
  108. package/src/lib/actions/settings-items.ts +818 -0
  109. package/src/lib/actions/{settings.d.ts → settings-reference-data.d.ts} +42 -10
  110. package/src/lib/actions/settings-reference-data.d.ts.map +1 -0
  111. package/src/lib/actions/settings-reference-data.js +505 -0
  112. package/src/lib/actions/settings-reference-data.js.map +1 -0
  113. package/src/lib/actions/settings-reference-data.ts +586 -0
  114. package/src/lib/actions/settings-templates.d.ts +15 -0
  115. package/src/lib/actions/settings-templates.d.ts.map +1 -0
  116. package/src/lib/actions/settings-templates.js +75 -0
  117. package/src/lib/actions/settings-templates.js.map +1 -0
  118. package/src/lib/actions/settings-templates.ts +79 -0
  119. package/src/lib/actions/stages-activities.d.ts +4 -3
  120. package/src/lib/actions/stages-activities.d.ts.map +1 -1
  121. package/src/lib/actions/stages-activities.js +19 -12
  122. package/src/lib/actions/stages-activities.js.map +1 -1
  123. package/src/lib/actions/stages-activities.ts +19 -12
  124. package/src/lib/actions/stages-pending-items.d.ts +75 -0
  125. package/src/lib/actions/stages-pending-items.d.ts.map +1 -0
  126. package/src/lib/actions/stages-pending-items.js +370 -0
  127. package/src/lib/actions/stages-pending-items.js.map +1 -0
  128. package/src/lib/actions/stages-pending-items.ts +404 -0
  129. package/src/lib/actions/stages-resources.d.ts.map +1 -1
  130. package/src/lib/actions/stages-resources.js +5 -8
  131. package/src/lib/actions/stages-resources.js.map +1 -1
  132. package/src/lib/actions/stages-resources.ts +8 -8
  133. package/src/lib/actions/stages-tasks.d.ts +0 -2
  134. package/src/lib/actions/stages-tasks.d.ts.map +1 -1
  135. package/src/lib/actions/stages-tasks.js +0 -12
  136. package/src/lib/actions/stages-tasks.js.map +1 -1
  137. package/src/lib/actions/stages-tasks.ts +0 -12
  138. package/src/lib/actions/stages.d.ts +20 -3
  139. package/src/lib/actions/stages.d.ts.map +1 -1
  140. package/src/lib/actions/stages.js +103 -21
  141. package/src/lib/actions/stages.js.map +1 -1
  142. package/src/lib/actions/stages.ts +116 -20
  143. package/src/lib/actions/webhooks-v2.js +11 -11
  144. package/src/lib/actions/webhooks-v2.js.map +1 -1
  145. package/src/lib/actions/webhooks-v2.ts +11 -11
  146. package/src/lib/actions/settings.d.ts.map +0 -1
  147. package/src/lib/actions/settings.js +0 -257
  148. package/src/lib/actions/settings.js.map +0 -1
  149. package/src/lib/actions/settings.ts +0 -301
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PublicApiJobController_getStageItem = exports.PublicApiJobController_getStageItems = exports.PublicApiJobController_getJobStage = exports.PublicApiJobController_getJobStages = exports.PublicApiJobController_dispatch = exports.PublicApiJobController_update = exports.PublicApiJobController_create = exports.PublicApiJobController_delete = exports.PublicApiJobController_get = exports.PublicApiJobController_search = void 0;
3
+ exports.PublicApiJobController_deleteStageItem = exports.PublicApiJobController_updateStageItem = exports.PublicApiJobController_getStageItem = exports.PublicApiJobController_createStageItems = exports.PublicApiJobController_getStageItems = exports.PublicApiJobController_getJobStage = exports.PublicApiJobController_getJobStages = exports.PublicApiJobController_dispatch = exports.PublicApiJobController_update = exports.PublicApiJobController_updateStatus = exports.PublicApiJobController_createFromTemplate = exports.PublicApiJobController_create = exports.PublicApiJobController_delete = exports.PublicApiJobController_get = exports.PublicApiJobController_search = void 0;
4
4
  const pieces_framework_1 = require("@activepieces/pieces-framework");
5
5
  const pieces_common_1 = require("@activepieces/pieces-common");
6
6
  const auth_1 = require("../auth");
@@ -56,21 +56,11 @@ exports.PublicApiJobController_search = (0, pieces_framework_1.createAction)({
56
56
  ],
57
57
  },
58
58
  }),
59
- status: pieces_framework_1.Property.StaticMultiSelectDropdown({
59
+ status: pieces_framework_1.Property.Json({
60
60
  displayName: 'Status',
61
61
  description: 'Status filter',
62
62
  required: false,
63
- options: {
64
- options: [
65
- { label: 'Open', value: JSON.stringify({ match: 'systemStatus', value: 'Open' }) },
66
- { label: 'In Progress', value: JSON.stringify({ match: 'systemStatus', value: 'In Progress' }) },
67
- { label: 'On Hold', value: JSON.stringify({ match: 'systemStatus', value: 'On Hold' }) },
68
- { label: 'Completed', value: JSON.stringify({ match: 'systemStatus', value: 'Completed' }) },
69
- { label: 'Finalised', value: JSON.stringify({ match: 'systemStatus', value: 'Finalised' }) },
70
- { label: 'Closed', value: JSON.stringify({ match: 'systemStatus', value: 'Closed' }) },
71
- { label: 'Canceled', value: JSON.stringify({ match: 'systemStatus', value: 'Canceled' }) },
72
- ],
73
- },
63
+ defaultValue: [],
74
64
  }),
75
65
  customer: pieces_framework_1.Property.Array({
76
66
  displayName: 'Customer',
@@ -122,6 +112,11 @@ exports.PublicApiJobController_search = (0, pieces_framework_1.createAction)({
122
112
  description: '',
123
113
  required: false,
124
114
  }),
115
+ integrationId: pieces_framework_1.Property.Array({
116
+ displayName: 'Integration Id',
117
+ description: 'integration ID',
118
+ required: false,
119
+ }),
125
120
  resource: pieces_framework_1.Property.Array({
126
121
  displayName: 'Resource',
127
122
  description: '',
@@ -132,21 +127,11 @@ exports.PublicApiJobController_search = (0, pieces_framework_1.createAction)({
132
127
  description: '',
133
128
  required: false,
134
129
  }),
135
- stageStatus: pieces_framework_1.Property.StaticMultiSelectDropdown({
130
+ stageStatus: pieces_framework_1.Property.Json({
136
131
  displayName: 'Stage Status',
137
132
  description: '',
138
133
  required: false,
139
- options: {
140
- options: [
141
- { label: 'Open', value: JSON.stringify({ match: 'systemStatus', value: 'Open' }) },
142
- { label: 'In Progress', value: JSON.stringify({ match: 'systemStatus', value: 'In Progress' }) },
143
- { label: 'On Hold', value: JSON.stringify({ match: 'systemStatus', value: 'On Hold' }) },
144
- { label: 'Completed', value: JSON.stringify({ match: 'systemStatus', value: 'Completed' }) },
145
- { label: 'Finalised', value: JSON.stringify({ match: 'systemStatus', value: 'Finalised' }) },
146
- { label: 'Closed', value: JSON.stringify({ match: 'systemStatus', value: 'Closed' }) },
147
- { label: 'Canceled', value: JSON.stringify({ match: 'systemStatus', value: 'Canceled' }) },
148
- ],
149
- },
134
+ defaultValue: [],
150
135
  }),
151
136
  search: pieces_framework_1.Property.ShortText({
152
137
  displayName: 'Search',
@@ -221,6 +206,7 @@ exports.PublicApiJobController_search = (0, pieces_framework_1.createAction)({
221
206
  tag: context.propsValue.tag,
222
207
  priceBook: context.propsValue.priceBook,
223
208
  billingCompany: context.propsValue.billingCompany,
209
+ integrationId: context.propsValue.integrationId,
224
210
  resource: context.propsValue.resource,
225
211
  workCategory: context.propsValue.workCategory,
226
212
  stageStatus: context.propsValue.stageStatus,
@@ -252,11 +238,11 @@ exports.PublicApiJobController_get = (0, pieces_framework_1.createAction)({
252
238
  name: 'PublicApiJobController_get',
253
239
  auth: auth_1.workbuddyAuth,
254
240
  displayName: 'Get job by ID or job number',
255
- description: 'Retrieve a single job by its ID or human-readable job number.',
241
+ description: 'Retrieve a single job by its ID, human-readable job number, or external integration ID.',
256
242
  props: {
257
243
  identifier: pieces_framework_1.Property.ShortText({
258
244
  displayName: 'Identifier',
259
- description: 'Job ID (MongoDB ObjectId) or job number (e.g., JOB-12345)',
245
+ description: 'Job ID (MongoDB ObjectId), job number (e.g., JOB-12345), or external integration ID',
260
246
  required: true,
261
247
  }),
262
248
  },
@@ -325,6 +311,16 @@ exports.PublicApiJobController_create = (0, pieces_framework_1.createAction)({
325
311
  description: 'Display name',
326
312
  required: false,
327
313
  }),
314
+ integrationId: pieces_framework_1.Property.ShortText({
315
+ displayName: 'Integration Id',
316
+ description: 'integration ID',
317
+ required: false,
318
+ }),
319
+ jobNumber: pieces_framework_1.Property.ShortText({
320
+ displayName: 'Job Number',
321
+ description: '',
322
+ required: false,
323
+ }),
328
324
  description: pieces_framework_1.Property.LongText({
329
325
  displayName: 'Description',
330
326
  description: 'Detailed description',
@@ -335,6 +331,11 @@ exports.PublicApiJobController_create = (0, pieces_framework_1.createAction)({
335
331
  description: 'Site ID — use /crm/sites to look up',
336
332
  required: false,
337
333
  }),
334
+ placeId: pieces_framework_1.Property.ShortText({
335
+ displayName: 'Place Id',
336
+ description: 'place ID',
337
+ required: false,
338
+ }),
338
339
  site: pieces_framework_1.Property.Json({
339
340
  displayName: 'Site',
340
341
  description: 'Inline site object — alternative to siteId',
@@ -405,9 +406,187 @@ exports.PublicApiJobController_create = (0, pieces_framework_1.createAction)({
405
406
  description: 'Customer purchase order reference',
406
407
  required: false,
407
408
  }),
409
+ startDate: pieces_framework_1.Property.DateTime({
410
+ displayName: 'Start Date',
411
+ description: 'Start date (ISO 8601 datetime)',
412
+ required: false,
413
+ }),
414
+ dueDate: pieces_framework_1.Property.DateTime({
415
+ displayName: 'Due Date',
416
+ description: 'Due date (ISO 8601 datetime)',
417
+ required: false,
418
+ }),
419
+ customFields: pieces_framework_1.Property.Json({
420
+ displayName: 'Custom Fields',
421
+ description: 'Custom fields as key-value pairs — validated against tenant field definitions',
422
+ required: false,
423
+ }),
424
+ items: pieces_framework_1.Property.Json({
425
+ displayName: 'Items',
426
+ description: '',
427
+ required: false,
428
+ defaultValue: [],
429
+ }),
430
+ },
431
+ async run(context) {
432
+ const token = await (0, auth_1.getAccessToken)(context.auth);
433
+ const baseUrl = context.auth.props.baseUrl;
434
+ const url = `${baseUrl}/api/v2/public/jobs`;
435
+ const rawBody = {
436
+ name: context.propsValue.name,
437
+ integrationId: context.propsValue.integrationId,
438
+ jobNumber: context.propsValue.jobNumber,
439
+ description: context.propsValue.description,
440
+ customerId: context.propsValue.customerId,
441
+ siteId: context.propsValue.siteId,
442
+ placeId: context.propsValue.placeId,
443
+ site: context.propsValue.site,
444
+ contactId: context.propsValue.contactId,
445
+ contact: context.propsValue.contact,
446
+ typeId: context.propsValue.typeId,
447
+ priorityId: context.propsValue.priorityId,
448
+ priceBookId: context.propsValue.priceBookId,
449
+ ownerId: context.propsValue.ownerId,
450
+ fieldSupervisorId: context.propsValue.fieldSupervisorId,
451
+ zoneId: context.propsValue.zoneId,
452
+ tagIds: context.propsValue.tagIds,
453
+ notes: context.propsValue.notes,
454
+ reference: context.propsValue.reference,
455
+ customerWO: context.propsValue.customerWO,
456
+ customerPO: context.propsValue.customerPO,
457
+ startDate: context.propsValue.startDate,
458
+ dueDate: context.propsValue.dueDate,
459
+ customFields: context.propsValue.customFields,
460
+ items: context.propsValue.items,
461
+ };
462
+ const body = rawBody;
463
+ const response = await pieces_common_1.httpClient.sendRequest({
464
+ method: pieces_common_1.HttpMethod.POST,
465
+ url: `${baseUrl}/api/v2/public/jobs`,
466
+ headers: {
467
+ Authorization: `Bearer ${token}`,
468
+ 'Content-Type': 'application/json',
469
+ 'X-WorkBuddy-Version': '2026-01',
470
+ },
471
+ body: body,
472
+ });
473
+ return response.body;
474
+ },
475
+ });
476
+ exports.PublicApiJobController_createFromTemplate = (0, pieces_framework_1.createAction)({
477
+ name: 'PublicApiJobController_createFromTemplate',
478
+ auth: auth_1.workbuddyAuth,
479
+ displayName: 'Create a new job from template',
480
+ description: 'Create a job using a job template. Template-owned fields win over request values before final job validation.',
481
+ props: {
408
482
  templateId: pieces_framework_1.Property.ShortText({
409
483
  displayName: 'Template Id',
410
- description: 'Template ID to pre-populate fields from a template',
484
+ description: 'Job template ID',
485
+ required: true,
486
+ }),
487
+ customerId: pieces_framework_1.Property.ShortText({
488
+ displayName: 'Customer Id',
489
+ description: 'Customer ID — use /crm/customers to look up',
490
+ required: true,
491
+ }),
492
+ name: pieces_framework_1.Property.ShortText({
493
+ displayName: 'Name',
494
+ description: 'Display name',
495
+ required: false,
496
+ }),
497
+ integrationId: pieces_framework_1.Property.ShortText({
498
+ displayName: 'Integration Id',
499
+ description: 'integration ID',
500
+ required: false,
501
+ }),
502
+ jobNumber: pieces_framework_1.Property.ShortText({
503
+ displayName: 'Job Number',
504
+ description: '',
505
+ required: false,
506
+ }),
507
+ description: pieces_framework_1.Property.LongText({
508
+ displayName: 'Description',
509
+ description: 'Detailed description',
510
+ required: false,
511
+ }),
512
+ siteId: pieces_framework_1.Property.ShortText({
513
+ displayName: 'Site Id',
514
+ description: 'Site ID — use /crm/sites to look up',
515
+ required: false,
516
+ }),
517
+ placeId: pieces_framework_1.Property.ShortText({
518
+ displayName: 'Place Id',
519
+ description: 'place ID',
520
+ required: false,
521
+ }),
522
+ site: pieces_framework_1.Property.Json({
523
+ displayName: 'Site',
524
+ description: 'Inline site object — alternative to siteId',
525
+ required: false,
526
+ }),
527
+ contactId: pieces_framework_1.Property.ShortText({
528
+ displayName: 'Contact Id',
529
+ description: 'Contact ID — use /crm/contacts to look up',
530
+ required: false,
531
+ }),
532
+ contact: pieces_framework_1.Property.Json({
533
+ displayName: 'Contact',
534
+ description: 'Inline contact object — alternative to contactId',
535
+ required: false,
536
+ }),
537
+ typeId: pieces_framework_1.Property.ShortText({
538
+ displayName: 'Type Id',
539
+ description: 'Job type ID — use /settings/job-types to look up',
540
+ required: false,
541
+ }),
542
+ priorityId: pieces_framework_1.Property.ShortText({
543
+ displayName: 'Priority Id',
544
+ description: 'Priority ID — use /settings/priorities to look up',
545
+ required: false,
546
+ }),
547
+ priceBookId: pieces_framework_1.Property.ShortText({
548
+ displayName: 'Price Book Id',
549
+ description: 'Price book ID for job pricing',
550
+ required: false,
551
+ }),
552
+ ownerId: pieces_framework_1.Property.ShortText({
553
+ displayName: 'Owner Id',
554
+ description: 'Owner (employee) ID — use /crm/employees to look up',
555
+ required: false,
556
+ }),
557
+ fieldSupervisorId: pieces_framework_1.Property.ShortText({
558
+ displayName: 'Field Supervisor Id',
559
+ description: 'Field supervisor (employee) ID — use /crm/employees to look up',
560
+ required: false,
561
+ }),
562
+ zoneId: pieces_framework_1.Property.ShortText({
563
+ displayName: 'Zone Id',
564
+ description: 'Zone ID — use /settings/zones to look up',
565
+ required: false,
566
+ }),
567
+ tagIds: pieces_framework_1.Property.Array({
568
+ displayName: 'Tag Ids',
569
+ description: 'Array of tag IDs (comma-separated, e.g. "id1,id2") — use /settings/tags to look up',
570
+ required: false,
571
+ }),
572
+ notes: pieces_framework_1.Property.LongText({
573
+ displayName: 'Notes',
574
+ description: 'Additional notes or comments',
575
+ required: false,
576
+ }),
577
+ reference: pieces_framework_1.Property.ShortText({
578
+ displayName: 'Reference',
579
+ description: 'External reference number',
580
+ required: false,
581
+ }),
582
+ customerWO: pieces_framework_1.Property.ShortText({
583
+ displayName: 'Customer W O',
584
+ description: 'Customer work order reference',
585
+ required: false,
586
+ }),
587
+ customerPO: pieces_framework_1.Property.ShortText({
588
+ displayName: 'Customer P O',
589
+ description: 'Customer purchase order reference',
411
590
  required: false,
412
591
  }),
413
592
  startDate: pieces_framework_1.Property.DateTime({
@@ -425,16 +604,25 @@ exports.PublicApiJobController_create = (0, pieces_framework_1.createAction)({
425
604
  description: 'Custom fields as key-value pairs — validated against tenant field definitions',
426
605
  required: false,
427
606
  }),
607
+ items: pieces_framework_1.Property.Json({
608
+ displayName: 'Items',
609
+ description: '',
610
+ required: false,
611
+ defaultValue: [],
612
+ }),
428
613
  },
429
614
  async run(context) {
430
615
  const token = await (0, auth_1.getAccessToken)(context.auth);
431
616
  const baseUrl = context.auth.props.baseUrl;
432
- const url = `${baseUrl}/api/v2/public/jobs`;
617
+ const url = `${baseUrl}/api/v2/public/jobs/template/${context.propsValue.templateId}`;
433
618
  const rawBody = {
434
619
  name: context.propsValue.name,
620
+ integrationId: context.propsValue.integrationId,
621
+ jobNumber: context.propsValue.jobNumber,
435
622
  description: context.propsValue.description,
436
623
  customerId: context.propsValue.customerId,
437
624
  siteId: context.propsValue.siteId,
625
+ placeId: context.propsValue.placeId,
438
626
  site: context.propsValue.site,
439
627
  contactId: context.propsValue.contactId,
440
628
  contact: context.propsValue.contact,
@@ -449,15 +637,83 @@ exports.PublicApiJobController_create = (0, pieces_framework_1.createAction)({
449
637
  reference: context.propsValue.reference,
450
638
  customerWO: context.propsValue.customerWO,
451
639
  customerPO: context.propsValue.customerPO,
452
- templateId: context.propsValue.templateId,
453
640
  startDate: context.propsValue.startDate,
454
641
  dueDate: context.propsValue.dueDate,
455
642
  customFields: context.propsValue.customFields,
643
+ items: context.propsValue.items,
456
644
  };
457
645
  const body = rawBody;
458
646
  const response = await pieces_common_1.httpClient.sendRequest({
459
647
  method: pieces_common_1.HttpMethod.POST,
460
- url: `${baseUrl}/api/v2/public/jobs`,
648
+ url: `${baseUrl}/api/v2/public/jobs/template/${context.propsValue.templateId}`,
649
+ headers: {
650
+ Authorization: `Bearer ${token}`,
651
+ 'Content-Type': 'application/json',
652
+ 'X-WorkBuddy-Version': '2026-01',
653
+ },
654
+ body: body,
655
+ });
656
+ return response.body;
657
+ },
658
+ });
659
+ exports.PublicApiJobController_updateStatus = (0, pieces_framework_1.createAction)({
660
+ name: 'PublicApiJobController_updateStatus',
661
+ auth: auth_1.workbuddyAuth,
662
+ displayName: 'Update job status',
663
+ description: 'Change an existing job status and cascade the change to stages through the job domain command.',
664
+ props: {
665
+ id: pieces_framework_1.Property.ShortText({
666
+ displayName: 'Id',
667
+ description: 'Job ID',
668
+ required: true,
669
+ }),
670
+ status: pieces_framework_1.Property.StaticDropdown({
671
+ displayName: 'Status',
672
+ description: 'Status filter',
673
+ required: true,
674
+ options: {
675
+ options: [
676
+ { label: 'open', value: 'open' },
677
+ { label: 'in_progress', value: 'in_progress' },
678
+ { label: 'on_hold', value: 'on_hold' },
679
+ { label: 'completed', value: 'completed' },
680
+ { label: 'finalised', value: 'finalised' },
681
+ { label: 'closed', value: 'closed' },
682
+ { label: 'cancelled', value: 'cancelled' },
683
+ ],
684
+ },
685
+ }),
686
+ updatedAt: pieces_framework_1.Property.DateTime({
687
+ displayName: 'Updated At',
688
+ description: 'For optimistic concurrency — update fails if entity was modified after this timestamp',
689
+ required: false,
690
+ }),
691
+ note: pieces_framework_1.Property.ShortText({
692
+ displayName: 'Note',
693
+ description: '',
694
+ required: false,
695
+ }),
696
+ reason: pieces_framework_1.Property.ShortText({
697
+ displayName: 'Reason',
698
+ description: 'Reason for the action (e.g. cancellation reason)',
699
+ required: false,
700
+ }),
701
+ },
702
+ async run(context) {
703
+ const token = await (0, auth_1.getAccessToken)(context.auth);
704
+ const baseUrl = context.auth.props.baseUrl;
705
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/status`;
706
+ // Build body with only defined values (for partial updates)
707
+ const rawBody = {
708
+ updatedAt: context.propsValue.updatedAt,
709
+ status: context.propsValue.status,
710
+ note: context.propsValue.note,
711
+ reason: context.propsValue.reason,
712
+ };
713
+ const body = Object.fromEntries(Object.entries(rawBody).filter(([_, v]) => v !== undefined && v !== null && v !== ''));
714
+ const response = await pieces_common_1.httpClient.sendRequest({
715
+ method: pieces_common_1.HttpMethod.PATCH,
716
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/status`,
461
717
  headers: {
462
718
  Authorization: `Bearer ${token}`,
463
719
  'Content-Type': 'application/json',
@@ -489,6 +745,11 @@ exports.PublicApiJobController_update = (0, pieces_framework_1.createAction)({
489
745
  description: 'Display name',
490
746
  required: false,
491
747
  }),
748
+ integrationId: pieces_framework_1.Property.ShortText({
749
+ displayName: 'Integration Id',
750
+ description: 'integration ID',
751
+ required: false,
752
+ }),
492
753
  description: pieces_framework_1.Property.LongText({
493
754
  displayName: 'Description',
494
755
  description: 'Detailed description',
@@ -593,6 +854,7 @@ exports.PublicApiJobController_update = (0, pieces_framework_1.createAction)({
593
854
  const rawBody = {
594
855
  updatedAt: context.propsValue.updatedAt,
595
856
  name: context.propsValue.name,
857
+ integrationId: context.propsValue.integrationId,
596
858
  description: context.propsValue.description,
597
859
  siteId: context.propsValue.siteId,
598
860
  contactId: context.propsValue.contactId,
@@ -797,6 +1059,56 @@ exports.PublicApiJobController_getStageItems = (0, pieces_framework_1.createActi
797
1059
  return response.body;
798
1060
  },
799
1061
  });
1062
+ exports.PublicApiJobController_createStageItems = (0, pieces_framework_1.createAction)({
1063
+ name: 'PublicApiJobController_createStageItems',
1064
+ auth: auth_1.workbuddyAuth,
1065
+ displayName: 'Create stage items',
1066
+ description: 'Add one or more catalogue-backed line items to a stage.',
1067
+ props: {
1068
+ id: pieces_framework_1.Property.ShortText({
1069
+ displayName: 'Id',
1070
+ description: 'Job ID',
1071
+ required: true,
1072
+ }),
1073
+ stageId: pieces_framework_1.Property.ShortText({
1074
+ displayName: 'Stage Id',
1075
+ description: 'Stage ID',
1076
+ required: true,
1077
+ }),
1078
+ updatedAt: pieces_framework_1.Property.DateTime({
1079
+ displayName: 'Updated At',
1080
+ description: 'For optimistic concurrency — update fails if entity was modified after this timestamp',
1081
+ required: true,
1082
+ }),
1083
+ items: pieces_framework_1.Property.Json({
1084
+ displayName: 'Items',
1085
+ description: '',
1086
+ required: true,
1087
+ defaultValue: [],
1088
+ }),
1089
+ },
1090
+ async run(context) {
1091
+ const token = await (0, auth_1.getAccessToken)(context.auth);
1092
+ const baseUrl = context.auth.props.baseUrl;
1093
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items`;
1094
+ const rawBody = {
1095
+ updatedAt: context.propsValue.updatedAt,
1096
+ items: context.propsValue.items,
1097
+ };
1098
+ const body = rawBody;
1099
+ const response = await pieces_common_1.httpClient.sendRequest({
1100
+ method: pieces_common_1.HttpMethod.POST,
1101
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items`,
1102
+ headers: {
1103
+ Authorization: `Bearer ${token}`,
1104
+ 'Content-Type': 'application/json',
1105
+ 'X-WorkBuddy-Version': '2026-01',
1106
+ },
1107
+ body: body,
1108
+ });
1109
+ return response.body;
1110
+ },
1111
+ });
800
1112
  exports.PublicApiJobController_getStageItem = (0, pieces_framework_1.createAction)({
801
1113
  name: 'PublicApiJobController_getStageItem',
802
1114
  auth: auth_1.workbuddyAuth,
@@ -835,4 +1147,160 @@ exports.PublicApiJobController_getStageItem = (0, pieces_framework_1.createActio
835
1147
  return response.body;
836
1148
  },
837
1149
  });
1150
+ exports.PublicApiJobController_updateStageItem = (0, pieces_framework_1.createAction)({
1151
+ name: 'PublicApiJobController_updateStageItem',
1152
+ auth: auth_1.workbuddyAuth,
1153
+ displayName: 'Update stage item',
1154
+ description: 'Update mutable fields on a stage line item.',
1155
+ props: {
1156
+ id: pieces_framework_1.Property.ShortText({
1157
+ displayName: 'Id',
1158
+ description: 'Job ID',
1159
+ required: true,
1160
+ }),
1161
+ stageId: pieces_framework_1.Property.ShortText({
1162
+ displayName: 'Stage Id',
1163
+ description: 'Stage ID',
1164
+ required: true,
1165
+ }),
1166
+ itemId: pieces_framework_1.Property.ShortText({
1167
+ displayName: 'Item Id',
1168
+ description: 'Item ID',
1169
+ required: true,
1170
+ }),
1171
+ updatedAt: pieces_framework_1.Property.DateTime({
1172
+ displayName: 'Updated At',
1173
+ description: 'For optimistic concurrency — update fails if entity was modified after this timestamp',
1174
+ required: true,
1175
+ }),
1176
+ quantity: pieces_framework_1.Property.Number({
1177
+ displayName: 'Quantity',
1178
+ description: '',
1179
+ required: false,
1180
+ }),
1181
+ unit: pieces_framework_1.Property.ShortText({
1182
+ displayName: 'Unit',
1183
+ description: '',
1184
+ required: false,
1185
+ }),
1186
+ location: pieces_framework_1.Property.ShortText({
1187
+ displayName: 'Location',
1188
+ description: '',
1189
+ required: false,
1190
+ }),
1191
+ note: pieces_framework_1.Property.ShortText({
1192
+ displayName: 'Note',
1193
+ description: '',
1194
+ required: false,
1195
+ }),
1196
+ buyPrice: pieces_framework_1.Property.Number({
1197
+ displayName: 'Buy Price',
1198
+ description: '',
1199
+ required: false,
1200
+ }),
1201
+ sellPrice: pieces_framework_1.Property.Number({
1202
+ displayName: 'Sell Price',
1203
+ description: '',
1204
+ required: false,
1205
+ }),
1206
+ status: pieces_framework_1.Property.StaticDropdown({
1207
+ displayName: 'Status',
1208
+ description: 'Status filter',
1209
+ required: false,
1210
+ options: {
1211
+ options: [
1212
+ { label: 'Normal', value: 'Normal' },
1213
+ { label: 'Variation', value: 'Variation' },
1214
+ { label: 'Cancelled', value: 'Cancelled' },
1215
+ { label: 'Deleted', value: 'Deleted' },
1216
+ ],
1217
+ },
1218
+ }),
1219
+ invoicingStatus: pieces_framework_1.Property.StaticDropdown({
1220
+ displayName: 'Invoicing Status',
1221
+ description: '',
1222
+ required: false,
1223
+ options: {
1224
+ options: [
1225
+ { label: 'Billable', value: 'Billable' },
1226
+ { label: 'No Charge', value: 'No Charge' },
1227
+ { label: 'Not Billable', value: 'Not Billable' },
1228
+ ],
1229
+ },
1230
+ }),
1231
+ suppliedBySubcontractor: pieces_framework_1.Property.Checkbox({
1232
+ displayName: 'Supplied By Subcontractor',
1233
+ description: '',
1234
+ required: false,
1235
+ }),
1236
+ },
1237
+ async run(context) {
1238
+ const token = await (0, auth_1.getAccessToken)(context.auth);
1239
+ const baseUrl = context.auth.props.baseUrl;
1240
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items/${context.propsValue.itemId}`;
1241
+ // Build body with only defined values (for partial updates)
1242
+ const rawBody = {
1243
+ updatedAt: context.propsValue.updatedAt,
1244
+ quantity: context.propsValue.quantity,
1245
+ unit: context.propsValue.unit,
1246
+ location: context.propsValue.location,
1247
+ note: context.propsValue.note,
1248
+ buyPrice: context.propsValue.buyPrice,
1249
+ sellPrice: context.propsValue.sellPrice,
1250
+ status: context.propsValue.status,
1251
+ invoicingStatus: context.propsValue.invoicingStatus,
1252
+ suppliedBySubcontractor: context.propsValue.suppliedBySubcontractor,
1253
+ };
1254
+ const body = Object.fromEntries(Object.entries(rawBody).filter(([_, v]) => v !== undefined && v !== null && v !== ''));
1255
+ const response = await pieces_common_1.httpClient.sendRequest({
1256
+ method: pieces_common_1.HttpMethod.PATCH,
1257
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items/${context.propsValue.itemId}`,
1258
+ headers: {
1259
+ Authorization: `Bearer ${token}`,
1260
+ 'Content-Type': 'application/json',
1261
+ 'X-WorkBuddy-Version': '2026-01',
1262
+ },
1263
+ body: body,
1264
+ });
1265
+ return response.body;
1266
+ },
1267
+ });
1268
+ exports.PublicApiJobController_deleteStageItem = (0, pieces_framework_1.createAction)({
1269
+ name: 'PublicApiJobController_deleteStageItem',
1270
+ auth: auth_1.workbuddyAuth,
1271
+ displayName: 'Delete stage item',
1272
+ description: 'Remove or cancel a stage item depending on tenant deletion settings.',
1273
+ props: {
1274
+ id: pieces_framework_1.Property.ShortText({
1275
+ displayName: 'Id',
1276
+ description: 'Job ID',
1277
+ required: true,
1278
+ }),
1279
+ stageId: pieces_framework_1.Property.ShortText({
1280
+ displayName: 'Stage Id',
1281
+ description: 'Stage ID',
1282
+ required: true,
1283
+ }),
1284
+ itemId: pieces_framework_1.Property.ShortText({
1285
+ displayName: 'Item Id',
1286
+ description: 'Item ID',
1287
+ required: true,
1288
+ }),
1289
+ },
1290
+ async run(context) {
1291
+ const token = await (0, auth_1.getAccessToken)(context.auth);
1292
+ const baseUrl = context.auth.props.baseUrl;
1293
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items/${context.propsValue.itemId}`;
1294
+ const response = await pieces_common_1.httpClient.sendRequest({
1295
+ method: pieces_common_1.HttpMethod.DELETE,
1296
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items/${context.propsValue.itemId}`,
1297
+ headers: {
1298
+ Authorization: `Bearer ${token}`,
1299
+ 'Content-Type': 'application/json',
1300
+ 'X-WorkBuddy-Version': '2026-01',
1301
+ },
1302
+ });
1303
+ return response.body;
1304
+ },
1305
+ });
838
1306
  //# sourceMappingURL=jobs.js.map