@workbuddy/piece-workbuddy-edge 1.0.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.
Files changed (222) hide show
  1. package/package.json +24 -0
  2. package/src/index.d.ts +8 -0
  3. package/src/index.d.ts.map +1 -0
  4. package/src/index.js +199 -0
  5. package/src/index.js.map +1 -0
  6. package/src/index.ts +354 -0
  7. package/src/lib/actions/attachments.d.ts +17 -0
  8. package/src/lib/actions/attachments.d.ts.map +1 -0
  9. package/src/lib/actions/attachments.js +79 -0
  10. package/src/lib/actions/attachments.js.map +1 -0
  11. package/src/lib/actions/attachments.ts +85 -0
  12. package/src/lib/actions/crm->-companies.d.ts +16 -0
  13. package/src/lib/actions/crm->-companies.d.ts.map +1 -0
  14. package/src/lib/actions/crm->-companies.js +77 -0
  15. package/src/lib/actions/crm->-companies.js.map +1 -0
  16. package/src/lib/actions/crm->-companies.ts +84 -0
  17. package/src/lib/actions/crm->-contacts.d.ts +16 -0
  18. package/src/lib/actions/crm->-contacts.d.ts.map +1 -0
  19. package/src/lib/actions/crm->-contacts.js +77 -0
  20. package/src/lib/actions/crm->-contacts.js.map +1 -0
  21. package/src/lib/actions/crm->-contacts.ts +84 -0
  22. package/src/lib/actions/crm->-contractors.d.ts +16 -0
  23. package/src/lib/actions/crm->-contractors.d.ts.map +1 -0
  24. package/src/lib/actions/crm->-contractors.js +77 -0
  25. package/src/lib/actions/crm->-contractors.js.map +1 -0
  26. package/src/lib/actions/crm->-contractors.ts +84 -0
  27. package/src/lib/actions/crm->-customers.d.ts +35 -0
  28. package/src/lib/actions/crm->-customers.d.ts.map +1 -0
  29. package/src/lib/actions/crm->-customers.js +180 -0
  30. package/src/lib/actions/crm->-customers.js.map +1 -0
  31. package/src/lib/actions/crm->-customers.ts +203 -0
  32. package/src/lib/actions/crm->-employees.d.ts +16 -0
  33. package/src/lib/actions/crm->-employees.d.ts.map +1 -0
  34. package/src/lib/actions/crm->-employees.js +77 -0
  35. package/src/lib/actions/crm->-employees.js.map +1 -0
  36. package/src/lib/actions/crm->-employees.ts +84 -0
  37. package/src/lib/actions/crm->-external-users.d.ts +16 -0
  38. package/src/lib/actions/crm->-external-users.d.ts.map +1 -0
  39. package/src/lib/actions/crm->-external-users.js +77 -0
  40. package/src/lib/actions/crm->-external-users.js.map +1 -0
  41. package/src/lib/actions/crm->-external-users.ts +84 -0
  42. package/src/lib/actions/crm->-invites.d.ts +16 -0
  43. package/src/lib/actions/crm->-invites.d.ts.map +1 -0
  44. package/src/lib/actions/crm->-invites.js +77 -0
  45. package/src/lib/actions/crm->-invites.js.map +1 -0
  46. package/src/lib/actions/crm->-invites.ts +84 -0
  47. package/src/lib/actions/crm->-sites.d.ts +17 -0
  48. package/src/lib/actions/crm->-sites.d.ts.map +1 -0
  49. package/src/lib/actions/crm->-sites.js +86 -0
  50. package/src/lib/actions/crm->-sites.js.map +1 -0
  51. package/src/lib/actions/crm->-sites.ts +95 -0
  52. package/src/lib/actions/crm->-suppliers.d.ts +16 -0
  53. package/src/lib/actions/crm->-suppliers.d.ts.map +1 -0
  54. package/src/lib/actions/crm->-suppliers.js +77 -0
  55. package/src/lib/actions/crm->-suppliers.js.map +1 -0
  56. package/src/lib/actions/crm->-suppliers.ts +84 -0
  57. package/src/lib/actions/data-export.d.ts +11 -0
  58. package/src/lib/actions/data-export.d.ts.map +1 -0
  59. package/src/lib/actions/data-export.js +78 -0
  60. package/src/lib/actions/data-export.js.map +1 -0
  61. package/src/lib/actions/data-export.ts +82 -0
  62. package/src/lib/actions/index.d.ts +25 -0
  63. package/src/lib/actions/index.d.ts.map +1 -0
  64. package/src/lib/actions/index.js +41 -0
  65. package/src/lib/actions/index.js.map +1 -0
  66. package/src/lib/actions/index.ts +24 -0
  67. package/src/lib/actions/jobs->-activities.d.ts +87 -0
  68. package/src/lib/actions/jobs->-activities.d.ts.map +1 -0
  69. package/src/lib/actions/jobs->-activities.js +445 -0
  70. package/src/lib/actions/jobs->-activities.js.map +1 -0
  71. package/src/lib/actions/jobs->-activities.ts +473 -0
  72. package/src/lib/actions/jobs->-contacts.d.ts +31 -0
  73. package/src/lib/actions/jobs->-contacts.d.ts.map +1 -0
  74. package/src/lib/actions/jobs->-contacts.js +129 -0
  75. package/src/lib/actions/jobs->-contacts.js.map +1 -0
  76. package/src/lib/actions/jobs->-contacts.ts +141 -0
  77. package/src/lib/actions/jobs->-files.d.ts +31 -0
  78. package/src/lib/actions/jobs->-files.d.ts.map +1 -0
  79. package/src/lib/actions/jobs->-files.js +129 -0
  80. package/src/lib/actions/jobs->-files.js.map +1 -0
  81. package/src/lib/actions/jobs->-files.ts +141 -0
  82. package/src/lib/actions/jobs->-tasks.d.ts +75 -0
  83. package/src/lib/actions/jobs->-tasks.d.ts.map +1 -0
  84. package/src/lib/actions/jobs->-tasks.js +395 -0
  85. package/src/lib/actions/jobs->-tasks.js.map +1 -0
  86. package/src/lib/actions/jobs->-tasks.ts +417 -0
  87. package/src/lib/actions/jobs.d.ts +148 -0
  88. package/src/lib/actions/jobs.d.ts.map +1 -0
  89. package/src/lib/actions/jobs.js +800 -0
  90. package/src/lib/actions/jobs.js.map +1 -0
  91. package/src/lib/actions/jobs.ts +846 -0
  92. package/src/lib/actions/mcp-context.d.ts +16 -0
  93. package/src/lib/actions/mcp-context.d.ts.map +1 -0
  94. package/src/lib/actions/mcp-context.js +82 -0
  95. package/src/lib/actions/mcp-context.js.map +1 -0
  96. package/src/lib/actions/mcp-context.ts +86 -0
  97. package/src/lib/actions/mcp.d.ts +21 -0
  98. package/src/lib/actions/mcp.d.ts.map +1 -0
  99. package/src/lib/actions/mcp.js +104 -0
  100. package/src/lib/actions/mcp.js.map +1 -0
  101. package/src/lib/actions/mcp.ts +112 -0
  102. package/src/lib/actions/settings.d.ts +57 -0
  103. package/src/lib/actions/settings.d.ts.map +1 -0
  104. package/src/lib/actions/settings.js +257 -0
  105. package/src/lib/actions/settings.js.map +1 -0
  106. package/src/lib/actions/settings.ts +301 -0
  107. package/src/lib/actions/stages->-activities.d.ts +87 -0
  108. package/src/lib/actions/stages->-activities.d.ts.map +1 -0
  109. package/src/lib/actions/stages->-activities.js +445 -0
  110. package/src/lib/actions/stages->-activities.js.map +1 -0
  111. package/src/lib/actions/stages->-activities.ts +473 -0
  112. package/src/lib/actions/stages->-files.d.ts +31 -0
  113. package/src/lib/actions/stages->-files.d.ts.map +1 -0
  114. package/src/lib/actions/stages->-files.js +129 -0
  115. package/src/lib/actions/stages->-files.js.map +1 -0
  116. package/src/lib/actions/stages->-files.ts +141 -0
  117. package/src/lib/actions/stages->-resources.d.ts +58 -0
  118. package/src/lib/actions/stages->-resources.d.ts.map +1 -0
  119. package/src/lib/actions/stages->-resources.js +279 -0
  120. package/src/lib/actions/stages->-resources.js.map +1 -0
  121. package/src/lib/actions/stages->-resources.ts +302 -0
  122. package/src/lib/actions/stages->-tasks.d.ts +77 -0
  123. package/src/lib/actions/stages->-tasks.d.ts.map +1 -0
  124. package/src/lib/actions/stages->-tasks.js +405 -0
  125. package/src/lib/actions/stages->-tasks.js.map +1 -0
  126. package/src/lib/actions/stages->-tasks.ts +427 -0
  127. package/src/lib/actions/stages.d.ts +85 -0
  128. package/src/lib/actions/stages.d.ts.map +1 -0
  129. package/src/lib/actions/stages.js +417 -0
  130. package/src/lib/actions/stages.js.map +1 -0
  131. package/src/lib/actions/stages.ts +452 -0
  132. package/src/lib/actions/webhooks-v2.d.ts +72 -0
  133. package/src/lib/actions/webhooks-v2.d.ts.map +1 -0
  134. package/src/lib/actions/webhooks-v2.js +297 -0
  135. package/src/lib/actions/webhooks-v2.js.map +1 -0
  136. package/src/lib/actions/webhooks-v2.ts +337 -0
  137. package/src/lib/actions/webhooks.d.ts +48 -0
  138. package/src/lib/actions/webhooks.d.ts.map +1 -0
  139. package/src/lib/actions/webhooks.js +292 -0
  140. package/src/lib/actions/webhooks.js.map +1 -0
  141. package/src/lib/actions/webhooks.ts +318 -0
  142. package/src/lib/auth.d.ts +18 -0
  143. package/src/lib/auth.d.ts.map +1 -0
  144. package/src/lib/auth.js +77 -0
  145. package/src/lib/auth.js.map +1 -0
  146. package/src/lib/auth.ts +84 -0
  147. package/src/lib/common/index.d.ts +11 -0
  148. package/src/lib/common/index.d.ts.map +1 -0
  149. package/src/lib/common/index.js +8 -0
  150. package/src/lib/common/index.js.map +1 -0
  151. package/src/lib/common/index.ts +12 -0
  152. package/src/lib/triggers/activity.d.ts +77 -0
  153. package/src/lib/triggers/activity.d.ts.map +1 -0
  154. package/src/lib/triggers/activity.js +241 -0
  155. package/src/lib/triggers/activity.js.map +1 -0
  156. package/src/lib/triggers/activity.ts +261 -0
  157. package/src/lib/triggers/allocation.d.ts +53 -0
  158. package/src/lib/triggers/allocation.d.ts.map +1 -0
  159. package/src/lib/triggers/allocation.js +181 -0
  160. package/src/lib/triggers/allocation.js.map +1 -0
  161. package/src/lib/triggers/allocation.ts +198 -0
  162. package/src/lib/triggers/bill.d.ts +102 -0
  163. package/src/lib/triggers/bill.d.ts.map +1 -0
  164. package/src/lib/triggers/bill.js +327 -0
  165. package/src/lib/triggers/bill.js.map +1 -0
  166. package/src/lib/triggers/bill.ts +355 -0
  167. package/src/lib/triggers/form.d.ts +19 -0
  168. package/src/lib/triggers/form.d.ts.map +1 -0
  169. package/src/lib/triggers/form.js +65 -0
  170. package/src/lib/triggers/form.js.map +1 -0
  171. package/src/lib/triggers/form.ts +68 -0
  172. package/src/lib/triggers/index.d.ts +10 -0
  173. package/src/lib/triggers/index.d.ts.map +1 -0
  174. package/src/lib/triggers/index.js +26 -0
  175. package/src/lib/triggers/index.js.map +1 -0
  176. package/src/lib/triggers/index.ts +9 -0
  177. package/src/lib/triggers/invoice.d.ts +102 -0
  178. package/src/lib/triggers/invoice.d.ts.map +1 -0
  179. package/src/lib/triggers/invoice.js +327 -0
  180. package/src/lib/triggers/invoice.js.map +1 -0
  181. package/src/lib/triggers/invoice.ts +355 -0
  182. package/src/lib/triggers/item.d.ts +53 -0
  183. package/src/lib/triggers/item.d.ts.map +1 -0
  184. package/src/lib/triggers/item.js +181 -0
  185. package/src/lib/triggers/item.js.map +1 -0
  186. package/src/lib/triggers/item.ts +198 -0
  187. package/src/lib/triggers/job.d.ts +102 -0
  188. package/src/lib/triggers/job.d.ts.map +1 -0
  189. package/src/lib/triggers/job.js +419 -0
  190. package/src/lib/triggers/job.js.map +1 -0
  191. package/src/lib/triggers/job.ts +447 -0
  192. package/src/lib/triggers/lead.d.ts +102 -0
  193. package/src/lib/triggers/lead.d.ts.map +1 -0
  194. package/src/lib/triggers/lead.js +319 -0
  195. package/src/lib/triggers/lead.js.map +1 -0
  196. package/src/lib/triggers/lead.ts +347 -0
  197. package/src/lib/triggers/opportunity.d.ts +102 -0
  198. package/src/lib/triggers/opportunity.d.ts.map +1 -0
  199. package/src/lib/triggers/opportunity.js +319 -0
  200. package/src/lib/triggers/opportunity.js.map +1 -0
  201. package/src/lib/triggers/opportunity.ts +347 -0
  202. package/src/lib/triggers/quote.d.ts +102 -0
  203. package/src/lib/triggers/quote.d.ts.map +1 -0
  204. package/src/lib/triggers/quote.js +327 -0
  205. package/src/lib/triggers/quote.js.map +1 -0
  206. package/src/lib/triggers/quote.ts +355 -0
  207. package/src/lib/triggers/site.d.ts +19 -0
  208. package/src/lib/triggers/site.d.ts.map +1 -0
  209. package/src/lib/triggers/site.js +65 -0
  210. package/src/lib/triggers/site.js.map +1 -0
  211. package/src/lib/triggers/site.ts +68 -0
  212. package/src/lib/triggers/stage.d.ts +102 -0
  213. package/src/lib/triggers/stage.d.ts.map +1 -0
  214. package/src/lib/triggers/stage.js +487 -0
  215. package/src/lib/triggers/stage.js.map +1 -0
  216. package/src/lib/triggers/stage.ts +515 -0
  217. package/src/lib/triggers/task.d.ts +102 -0
  218. package/src/lib/triggers/task.d.ts.map +1 -0
  219. package/src/lib/triggers/task.js +323 -0
  220. package/src/lib/triggers/task.js.map +1 -0
  221. package/src/lib/triggers/task.ts +351 -0
  222. package/src/lib/workbuddy.svg +5 -0
@@ -0,0 +1,846 @@
1
+ import { createAction, Property } from '@activepieces/pieces-framework';
2
+ import { HttpMethod, httpClient } from '@activepieces/pieces-common';
3
+ import { workbuddyAuth, getAccessToken } from '../auth';
4
+
5
+ export const PublicApiJobController_search = createAction({
6
+ name: 'PublicApiJobController_search',
7
+ auth: workbuddyAuth,
8
+ displayName: 'Search jobs or stages with complex filters',
9
+ description:
10
+ "Advanced search endpoint for complex queries. Use mode='jobs' (default) to search jobs, or mode='stages' to search stages with embedded job context. Supports multiple filters, date ranges, and field projection via JSON body.",
11
+ props: {
12
+ mode: Property.StaticDropdown({
13
+ displayName: 'Mode',
14
+ description: '',
15
+ required: false,
16
+ options: {
17
+ options: [
18
+ { label: 'jobs', value: 'jobs' },
19
+ { label: 'stages', value: 'stages' },
20
+ ],
21
+ },
22
+ }),
23
+ limit: Property.Number({
24
+ displayName: 'Limit',
25
+ description: '',
26
+ required: false,
27
+ defaultValue: 50,
28
+ }),
29
+ cursor: Property.ShortText({
30
+ displayName: 'Cursor',
31
+ description: '',
32
+ required: false,
33
+ }),
34
+ sortBy: Property.StaticDropdown({
35
+ displayName: 'Sort By',
36
+ description: '',
37
+ required: false,
38
+ options: {
39
+ options: [
40
+ { label: 'created_at', value: 'created_at' },
41
+ { label: 'due_date', value: 'due_date' },
42
+ { label: 'completed_date', value: 'completed_date' },
43
+ { label: 'priority', value: 'priority' },
44
+ ],
45
+ },
46
+ }),
47
+ sortDirection: Property.StaticDropdown({
48
+ displayName: 'Sort Direction',
49
+ description: '',
50
+ required: false,
51
+ options: {
52
+ options: [
53
+ { label: 'asc', value: 'asc' },
54
+ { label: 'desc', value: 'desc' },
55
+ ],
56
+ },
57
+ }),
58
+ status: Property.Json({
59
+ displayName: 'Status',
60
+ description: '',
61
+ required: false,
62
+ defaultValue: [],
63
+ }),
64
+ customer: Property.Array({
65
+ displayName: 'Customer',
66
+ description: '',
67
+ required: false,
68
+ }),
69
+ site: Property.Array({
70
+ displayName: 'Site',
71
+ description: '',
72
+ required: false,
73
+ }),
74
+ type: Property.Array({
75
+ displayName: 'Type',
76
+ description: '',
77
+ required: false,
78
+ }),
79
+ priority: Property.Array({
80
+ displayName: 'Priority',
81
+ description: '',
82
+ required: false,
83
+ }),
84
+ owner: Property.Array({
85
+ displayName: 'Owner',
86
+ description: '',
87
+ required: false,
88
+ }),
89
+ fieldSupervisor: Property.Array({
90
+ displayName: 'Field Supervisor',
91
+ description: '',
92
+ required: false,
93
+ }),
94
+ zone: Property.Array({
95
+ displayName: 'Zone',
96
+ description: '',
97
+ required: false,
98
+ }),
99
+ tag: Property.Array({
100
+ displayName: 'Tag',
101
+ description: '',
102
+ required: false,
103
+ }),
104
+ priceBook: Property.Array({
105
+ displayName: 'Price Book',
106
+ description: '',
107
+ required: false,
108
+ }),
109
+ billingCompany: Property.Array({
110
+ displayName: 'Billing Company',
111
+ description: '',
112
+ required: false,
113
+ }),
114
+ resource: Property.Array({
115
+ displayName: 'Resource',
116
+ description: '',
117
+ required: false,
118
+ }),
119
+ workCategory: Property.Array({
120
+ displayName: 'Work Category',
121
+ description: '',
122
+ required: false,
123
+ }),
124
+ stageStatus: Property.Json({
125
+ displayName: 'Stage Status',
126
+ description: '',
127
+ required: false,
128
+ defaultValue: [],
129
+ }),
130
+ search: Property.ShortText({
131
+ displayName: 'Search',
132
+ description: '',
133
+ required: false,
134
+ }),
135
+ createdDate: Property.Json({
136
+ displayName: 'Created Date',
137
+ description: '',
138
+ required: false,
139
+ }),
140
+ dueDate: Property.Json({
141
+ displayName: 'Due Date',
142
+ description: '',
143
+ required: false,
144
+ }),
145
+ completedDate: Property.Json({
146
+ displayName: 'Completed Date',
147
+ description: '',
148
+ required: false,
149
+ }),
150
+ finalisedDate: Property.Json({
151
+ displayName: 'Finalised Date',
152
+ description: '',
153
+ required: false,
154
+ }),
155
+ stageDueDate: Property.Json({
156
+ displayName: 'Stage Due Date',
157
+ description: '',
158
+ required: false,
159
+ }),
160
+ stageCompletedDate: Property.Json({
161
+ displayName: 'Stage Completed Date',
162
+ description: '',
163
+ required: false,
164
+ }),
165
+ fields: Property.Array({
166
+ displayName: 'Fields',
167
+ description: '',
168
+ required: false,
169
+ }),
170
+ include: Property.StaticMultiSelectDropdown({
171
+ displayName: 'Include',
172
+ description: '',
173
+ required: false,
174
+ options: {
175
+ options: [
176
+ { label: 'items', value: 'items' },
177
+ { label: 'stages', value: 'stages' },
178
+ ],
179
+ },
180
+ }),
181
+ },
182
+ async run(context) {
183
+ const token = await getAccessToken(context.auth);
184
+ const baseUrl = context.auth.props.baseUrl;
185
+
186
+ const url = `${baseUrl}/api/v2/public/jobs/search`;
187
+
188
+ const body = {
189
+ mode: context.propsValue.mode,
190
+ limit: context.propsValue.limit,
191
+ cursor: context.propsValue.cursor,
192
+ sortBy: context.propsValue.sortBy,
193
+ sortDirection: context.propsValue.sortDirection,
194
+ status: context.propsValue.status,
195
+ customer: context.propsValue.customer,
196
+ site: context.propsValue.site,
197
+ type: context.propsValue.type,
198
+ priority: context.propsValue.priority,
199
+ owner: context.propsValue.owner,
200
+ fieldSupervisor: context.propsValue.fieldSupervisor,
201
+ zone: context.propsValue.zone,
202
+ tag: context.propsValue.tag,
203
+ priceBook: context.propsValue.priceBook,
204
+ billingCompany: context.propsValue.billingCompany,
205
+ resource: context.propsValue.resource,
206
+ workCategory: context.propsValue.workCategory,
207
+ stageStatus: context.propsValue.stageStatus,
208
+ search: context.propsValue.search,
209
+ createdDate: context.propsValue.createdDate,
210
+ dueDate: context.propsValue.dueDate,
211
+ completedDate: context.propsValue.completedDate,
212
+ finalisedDate: context.propsValue.finalisedDate,
213
+ stageDueDate: context.propsValue.stageDueDate,
214
+ stageCompletedDate: context.propsValue.stageCompletedDate,
215
+ fields: context.propsValue.fields,
216
+ include: context.propsValue.include,
217
+ };
218
+ const response = await httpClient.sendRequest({
219
+ method: HttpMethod.POST,
220
+ url: `${baseUrl}/api/v2/public/jobs/search`,
221
+ headers: {
222
+ Authorization: `Bearer ${token}`,
223
+ 'Content-Type': 'application/json',
224
+ 'X-WorkBuddy-Version': '2026-01',
225
+ },
226
+ body: body,
227
+ });
228
+
229
+ return response.body;
230
+ },
231
+ });
232
+
233
+ export const PublicApiJobController_get = createAction({
234
+ name: 'PublicApiJobController_get',
235
+ auth: workbuddyAuth,
236
+ displayName: 'Get job by ID or job number',
237
+ description: 'Retrieve a single job by its ID or human-readable job number.',
238
+ props: {
239
+ identifier: Property.ShortText({
240
+ displayName: 'Identifier',
241
+ description: 'Job ID (MongoDB ObjectId) or job number (e.g., JOB-12345)',
242
+ required: true,
243
+ }),
244
+ },
245
+ async run(context) {
246
+ const token = await getAccessToken(context.auth);
247
+ const baseUrl = context.auth.props.baseUrl;
248
+
249
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.identifier}`;
250
+
251
+ const response = await httpClient.sendRequest({
252
+ method: HttpMethod.GET,
253
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.identifier}`,
254
+ headers: {
255
+ Authorization: `Bearer ${token}`,
256
+ 'Content-Type': 'application/json',
257
+ 'X-WorkBuddy-Version': '2026-01',
258
+ },
259
+ });
260
+
261
+ return response.body;
262
+ },
263
+ });
264
+
265
+ export const PublicApiJobController_delete = createAction({
266
+ name: 'PublicApiJobController_delete',
267
+ auth: workbuddyAuth,
268
+ displayName: 'Cancel a job',
269
+ description:
270
+ "Cancel a job by ID or job number. Jobs cannot be permanently deleted, only cancelled. This changes the job status to 'cancelled'. A reason must be provided.",
271
+ props: {
272
+ identifier: Property.ShortText({
273
+ displayName: 'Identifier',
274
+ description: 'Job ID or job number (e.g., JOB-00001)',
275
+ required: true,
276
+ }),
277
+ reason: Property.ShortText({
278
+ displayName: 'Reason',
279
+ description: '',
280
+ required: true,
281
+ }),
282
+ },
283
+ async run(context) {
284
+ const token = await getAccessToken(context.auth);
285
+ const baseUrl = context.auth.props.baseUrl;
286
+
287
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.identifier}`;
288
+
289
+ const response = await httpClient.sendRequest({
290
+ method: HttpMethod.DELETE,
291
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.identifier}`,
292
+ headers: {
293
+ Authorization: `Bearer ${token}`,
294
+ 'Content-Type': 'application/json',
295
+ 'X-WorkBuddy-Version': '2026-01',
296
+ },
297
+ });
298
+
299
+ return response.body;
300
+ },
301
+ });
302
+
303
+ export const PublicApiJobController_create = createAction({
304
+ name: 'PublicApiJobController_create',
305
+ auth: workbuddyAuth,
306
+ displayName: 'Create a new job',
307
+ description: 'Create a new job with the specified details. Requires either customerId or inline customer object.',
308
+ props: {
309
+ name: Property.ShortText({
310
+ displayName: 'Name',
311
+ description: '',
312
+ required: false,
313
+ }),
314
+ description: Property.LongText({
315
+ displayName: 'Description',
316
+ description: '',
317
+ required: false,
318
+ }),
319
+ customerId: Property.ShortText({
320
+ displayName: 'Customer Id',
321
+ description: '',
322
+ required: false,
323
+ }),
324
+ customer: Property.Json({
325
+ displayName: 'Customer',
326
+ description: '',
327
+ required: false,
328
+ }),
329
+ siteId: Property.ShortText({
330
+ displayName: 'Site Id',
331
+ description: '',
332
+ required: false,
333
+ }),
334
+ site: Property.Json({
335
+ displayName: 'Site',
336
+ description: '',
337
+ required: false,
338
+ }),
339
+ contactId: Property.ShortText({
340
+ displayName: 'Contact Id',
341
+ description: '',
342
+ required: false,
343
+ }),
344
+ contact: Property.Json({
345
+ displayName: 'Contact',
346
+ description: '',
347
+ required: false,
348
+ }),
349
+ typeId: Property.ShortText({
350
+ displayName: 'Type Id',
351
+ description: '',
352
+ required: false,
353
+ }),
354
+ priorityId: Property.ShortText({
355
+ displayName: 'Priority Id',
356
+ description: '',
357
+ required: false,
358
+ }),
359
+ priceBookId: Property.ShortText({
360
+ displayName: 'Price Book Id',
361
+ description: '',
362
+ required: false,
363
+ }),
364
+ ownerId: Property.ShortText({
365
+ displayName: 'Owner Id',
366
+ description: '',
367
+ required: false,
368
+ }),
369
+ fieldSupervisorId: Property.ShortText({
370
+ displayName: 'Field Supervisor Id',
371
+ description: '',
372
+ required: false,
373
+ }),
374
+ zoneId: Property.ShortText({
375
+ displayName: 'Zone Id',
376
+ description: '',
377
+ required: false,
378
+ }),
379
+ tagIds: Property.Array({
380
+ displayName: 'Tag Ids',
381
+ description: '',
382
+ required: false,
383
+ }),
384
+ notes: Property.LongText({
385
+ displayName: 'Notes',
386
+ description: '',
387
+ required: false,
388
+ }),
389
+ reference: Property.ShortText({
390
+ displayName: 'Reference',
391
+ description: '',
392
+ required: false,
393
+ }),
394
+ customerWO: Property.ShortText({
395
+ displayName: 'Customer W O',
396
+ description: '',
397
+ required: false,
398
+ }),
399
+ customerPO: Property.ShortText({
400
+ displayName: 'Customer P O',
401
+ description: '',
402
+ required: false,
403
+ }),
404
+ templateId: Property.ShortText({
405
+ displayName: 'Template Id',
406
+ description: '',
407
+ required: false,
408
+ }),
409
+ startDate: Property.DateTime({
410
+ displayName: 'Start Date',
411
+ description: '',
412
+ required: false,
413
+ }),
414
+ dueDate: Property.DateTime({
415
+ displayName: 'Due Date',
416
+ description: '',
417
+ required: false,
418
+ }),
419
+ customFields: Property.Json({
420
+ displayName: 'Custom Fields',
421
+ description: '',
422
+ required: false,
423
+ }),
424
+ },
425
+ async run(context) {
426
+ const token = await getAccessToken(context.auth);
427
+ const baseUrl = context.auth.props.baseUrl;
428
+
429
+ const url = `${baseUrl}/api/v2/public/jobs`;
430
+
431
+ const body = {
432
+ name: context.propsValue.name,
433
+ description: context.propsValue.description,
434
+ customerId: context.propsValue.customerId,
435
+ customer: context.propsValue.customer,
436
+ siteId: context.propsValue.siteId,
437
+ site: context.propsValue.site,
438
+ contactId: context.propsValue.contactId,
439
+ contact: context.propsValue.contact,
440
+ typeId: context.propsValue.typeId,
441
+ priorityId: context.propsValue.priorityId,
442
+ priceBookId: context.propsValue.priceBookId,
443
+ ownerId: context.propsValue.ownerId,
444
+ fieldSupervisorId: context.propsValue.fieldSupervisorId,
445
+ zoneId: context.propsValue.zoneId,
446
+ tagIds: context.propsValue.tagIds,
447
+ notes: context.propsValue.notes,
448
+ reference: context.propsValue.reference,
449
+ customerWO: context.propsValue.customerWO,
450
+ customerPO: context.propsValue.customerPO,
451
+ templateId: context.propsValue.templateId,
452
+ startDate: context.propsValue.startDate,
453
+ dueDate: context.propsValue.dueDate,
454
+ customFields: context.propsValue.customFields,
455
+ };
456
+ const response = await httpClient.sendRequest({
457
+ method: HttpMethod.POST,
458
+ url: `${baseUrl}/api/v2/public/jobs`,
459
+ headers: {
460
+ Authorization: `Bearer ${token}`,
461
+ 'Content-Type': 'application/json',
462
+ 'X-WorkBuddy-Version': '2026-01',
463
+ },
464
+ body: body,
465
+ });
466
+
467
+ return response.body;
468
+ },
469
+ });
470
+
471
+ export const PublicApiJobController_update = createAction({
472
+ name: 'PublicApiJobController_update',
473
+ auth: workbuddyAuth,
474
+ displayName: 'Update a job',
475
+ description: 'Partially update a job. Only provided fields will be modified.',
476
+ props: {
477
+ id: Property.ShortText({
478
+ displayName: 'Id',
479
+ description: 'Job ID',
480
+ required: true,
481
+ }),
482
+ updatedAt: Property.DateTime({
483
+ displayName: 'Updated At',
484
+ description: '',
485
+ required: false,
486
+ }),
487
+ name: Property.ShortText({
488
+ displayName: 'Name',
489
+ description: '',
490
+ required: false,
491
+ }),
492
+ description: Property.LongText({
493
+ displayName: 'Description',
494
+ description: '',
495
+ required: false,
496
+ }),
497
+ siteId: Property.ShortText({
498
+ displayName: 'Site Id',
499
+ description: '',
500
+ required: false,
501
+ }),
502
+ contactId: Property.ShortText({
503
+ displayName: 'Contact Id',
504
+ description: '',
505
+ required: false,
506
+ }),
507
+ typeId: Property.ShortText({
508
+ displayName: 'Type Id',
509
+ description: '',
510
+ required: false,
511
+ }),
512
+ priorityId: Property.ShortText({
513
+ displayName: 'Priority Id',
514
+ description: '',
515
+ required: false,
516
+ }),
517
+ priceBookId: Property.ShortText({
518
+ displayName: 'Price Book Id',
519
+ description: '',
520
+ required: false,
521
+ }),
522
+ ownerId: Property.ShortText({
523
+ displayName: 'Owner Id',
524
+ description: '',
525
+ required: false,
526
+ }),
527
+ fieldSupervisorId: Property.ShortText({
528
+ displayName: 'Field Supervisor Id',
529
+ description: '',
530
+ required: false,
531
+ }),
532
+ zoneId: Property.ShortText({
533
+ displayName: 'Zone Id',
534
+ description: '',
535
+ required: false,
536
+ }),
537
+ tagIds: Property.Array({
538
+ displayName: 'Tag Ids',
539
+ description: '',
540
+ required: false,
541
+ }),
542
+ notes: Property.LongText({
543
+ displayName: 'Notes',
544
+ description: '',
545
+ required: false,
546
+ }),
547
+ reference: Property.ShortText({
548
+ displayName: 'Reference',
549
+ description: '',
550
+ required: false,
551
+ }),
552
+ customerWO: Property.ShortText({
553
+ displayName: 'Customer W O',
554
+ description: '',
555
+ required: false,
556
+ }),
557
+ customerPO: Property.ShortText({
558
+ displayName: 'Customer P O',
559
+ description: '',
560
+ required: false,
561
+ }),
562
+ startDate: Property.DateTime({
563
+ displayName: 'Start Date',
564
+ description: '',
565
+ required: false,
566
+ }),
567
+ dueDate: Property.DateTime({
568
+ displayName: 'Due Date',
569
+ description: '',
570
+ required: false,
571
+ }),
572
+ customFields: Property.Json({
573
+ displayName: 'Custom Fields',
574
+ description: '',
575
+ required: false,
576
+ }),
577
+ },
578
+ async run(context) {
579
+ const token = await getAccessToken(context.auth);
580
+ const baseUrl = context.auth.props.baseUrl;
581
+
582
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}`;
583
+
584
+ // Build body with only defined values (for partial updates)
585
+ const rawBody: Record<string, unknown> = {
586
+ updatedAt: context.propsValue.updatedAt,
587
+ name: context.propsValue.name,
588
+ description: context.propsValue.description,
589
+ siteId: context.propsValue.siteId,
590
+ contactId: context.propsValue.contactId,
591
+ typeId: context.propsValue.typeId,
592
+ priorityId: context.propsValue.priorityId,
593
+ priceBookId: context.propsValue.priceBookId,
594
+ ownerId: context.propsValue.ownerId,
595
+ fieldSupervisorId: context.propsValue.fieldSupervisorId,
596
+ zoneId: context.propsValue.zoneId,
597
+ tagIds: context.propsValue.tagIds,
598
+ notes: context.propsValue.notes,
599
+ reference: context.propsValue.reference,
600
+ customerWO: context.propsValue.customerWO,
601
+ customerPO: context.propsValue.customerPO,
602
+ startDate: context.propsValue.startDate,
603
+ dueDate: context.propsValue.dueDate,
604
+ customFields: context.propsValue.customFields,
605
+ };
606
+ const body = Object.fromEntries(
607
+ Object.entries(rawBody).filter(([_, v]) => v !== undefined && v !== null && v !== '')
608
+ );
609
+ const response = await httpClient.sendRequest({
610
+ method: HttpMethod.PATCH,
611
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}`,
612
+ headers: {
613
+ Authorization: `Bearer ${token}`,
614
+ 'Content-Type': 'application/json',
615
+ 'X-WorkBuddy-Version': '2026-01',
616
+ },
617
+ body: body,
618
+ });
619
+
620
+ return response.body;
621
+ },
622
+ });
623
+
624
+ export const PublicApiJobController_dispatch = createAction({
625
+ name: 'PublicApiJobController_dispatch',
626
+ auth: workbuddyAuth,
627
+ displayName: 'Dispatch a job',
628
+ description: 'Change job status to dispatched, making it ready for field work.',
629
+ props: {
630
+ id: Property.ShortText({
631
+ displayName: 'Id',
632
+ description: 'Job ID',
633
+ required: true,
634
+ }),
635
+ },
636
+ async run(context) {
637
+ const token = await getAccessToken(context.auth);
638
+ const baseUrl = context.auth.props.baseUrl;
639
+
640
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/dispatch`;
641
+
642
+ const response = await httpClient.sendRequest({
643
+ method: HttpMethod.POST,
644
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/dispatch`,
645
+ headers: {
646
+ Authorization: `Bearer ${token}`,
647
+ 'Content-Type': 'application/json',
648
+ 'X-WorkBuddy-Version': '2026-01',
649
+ },
650
+ });
651
+
652
+ return response.body;
653
+ },
654
+ });
655
+
656
+ export const PublicApiJobController_getJobStages = createAction({
657
+ name: 'PublicApiJobController_getJobStages',
658
+ auth: workbuddyAuth,
659
+ displayName: 'List job stages',
660
+ description: 'Get all stages (work orders) for a job.',
661
+ props: {
662
+ id: Property.ShortText({
663
+ displayName: 'Id',
664
+ description: 'Job ID',
665
+ required: true,
666
+ }),
667
+ cursor: Property.ShortText({
668
+ displayName: 'Cursor',
669
+ description: 'Pagination cursor from previous response',
670
+ required: false,
671
+ }),
672
+ limit: Property.Number({
673
+ displayName: 'Limit',
674
+ description: 'Maximum results to return (1-200)',
675
+ required: false,
676
+ }),
677
+ },
678
+ async run(context) {
679
+ const token = await getAccessToken(context.auth);
680
+ const baseUrl = context.auth.props.baseUrl;
681
+
682
+ const url = `${baseUrl}/jobs/{id}/stages`;
683
+
684
+ const queryParams = new URLSearchParams();
685
+ if (
686
+ context.propsValue.cursor !== undefined &&
687
+ context.propsValue.cursor !== null &&
688
+ context.propsValue.cursor !== ''
689
+ )
690
+ queryParams.append('cursor', String(context.propsValue.cursor));
691
+ if (context.propsValue.limit !== undefined && context.propsValue.limit !== null)
692
+ queryParams.append('limit', String(context.propsValue.limit));
693
+ const queryString = queryParams.toString();
694
+ const urlWithQuery = queryString ? `${url}?${queryString}` : url;
695
+
696
+ const response = await httpClient.sendRequest({
697
+ method: HttpMethod.GET,
698
+ url: urlWithQuery,
699
+ headers: {
700
+ Authorization: `Bearer ${token}`,
701
+ 'Content-Type': 'application/json',
702
+ 'X-WorkBuddy-Version': '2026-01',
703
+ },
704
+ });
705
+
706
+ return response.body;
707
+ },
708
+ });
709
+
710
+ export const PublicApiJobController_getJobStage = createAction({
711
+ name: 'PublicApiJobController_getJobStage',
712
+ auth: workbuddyAuth,
713
+ displayName: 'Get job stage',
714
+ description: 'Get a specific stage within a job.',
715
+ props: {
716
+ id: Property.ShortText({
717
+ displayName: 'Id',
718
+ description: 'Job ID',
719
+ required: true,
720
+ }),
721
+ stageId: Property.ShortText({
722
+ displayName: 'Stage Id',
723
+ description: 'Stage ID',
724
+ required: true,
725
+ }),
726
+ },
727
+ async run(context) {
728
+ const token = await getAccessToken(context.auth);
729
+ const baseUrl = context.auth.props.baseUrl;
730
+
731
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}`;
732
+
733
+ const response = await httpClient.sendRequest({
734
+ method: HttpMethod.GET,
735
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}`,
736
+ headers: {
737
+ Authorization: `Bearer ${token}`,
738
+ 'Content-Type': 'application/json',
739
+ 'X-WorkBuddy-Version': '2026-01',
740
+ },
741
+ });
742
+
743
+ return response.body;
744
+ },
745
+ });
746
+
747
+ export const PublicApiJobController_getStageItems = createAction({
748
+ name: 'PublicApiJobController_getStageItems',
749
+ auth: workbuddyAuth,
750
+ displayName: 'List stage items',
751
+ description: 'Get all items (line items) for a stage.',
752
+ props: {
753
+ id: Property.ShortText({
754
+ displayName: 'Id',
755
+ description: 'Job ID',
756
+ required: true,
757
+ }),
758
+ stageId: Property.ShortText({
759
+ displayName: 'Stage Id',
760
+ description: 'Stage ID',
761
+ required: true,
762
+ }),
763
+ cursor: Property.ShortText({
764
+ displayName: 'Cursor',
765
+ description: 'Pagination cursor from previous response',
766
+ required: false,
767
+ }),
768
+ limit: Property.Number({
769
+ displayName: 'Limit',
770
+ description: 'Maximum results to return (1-200)',
771
+ required: false,
772
+ }),
773
+ },
774
+ async run(context) {
775
+ const token = await getAccessToken(context.auth);
776
+ const baseUrl = context.auth.props.baseUrl;
777
+
778
+ const url = `${baseUrl}/jobs/{id}/stages/{stageId}/items`;
779
+
780
+ const queryParams = new URLSearchParams();
781
+ if (
782
+ context.propsValue.cursor !== undefined &&
783
+ context.propsValue.cursor !== null &&
784
+ context.propsValue.cursor !== ''
785
+ )
786
+ queryParams.append('cursor', String(context.propsValue.cursor));
787
+ if (context.propsValue.limit !== undefined && context.propsValue.limit !== null)
788
+ queryParams.append('limit', String(context.propsValue.limit));
789
+ const queryString = queryParams.toString();
790
+ const urlWithQuery = queryString ? `${url}?${queryString}` : url;
791
+
792
+ const response = await httpClient.sendRequest({
793
+ method: HttpMethod.GET,
794
+ url: urlWithQuery,
795
+ headers: {
796
+ Authorization: `Bearer ${token}`,
797
+ 'Content-Type': 'application/json',
798
+ 'X-WorkBuddy-Version': '2026-01',
799
+ },
800
+ });
801
+
802
+ return response.body;
803
+ },
804
+ });
805
+
806
+ export const PublicApiJobController_getStageItem = createAction({
807
+ name: 'PublicApiJobController_getStageItem',
808
+ auth: workbuddyAuth,
809
+ displayName: 'Get stage item',
810
+ description: 'Get a specific item within a stage.',
811
+ props: {
812
+ id: Property.ShortText({
813
+ displayName: 'Id',
814
+ description: 'Job ID',
815
+ required: true,
816
+ }),
817
+ stageId: Property.ShortText({
818
+ displayName: 'Stage Id',
819
+ description: 'Stage ID',
820
+ required: true,
821
+ }),
822
+ itemId: Property.ShortText({
823
+ displayName: 'Item Id',
824
+ description: 'Item ID',
825
+ required: true,
826
+ }),
827
+ },
828
+ async run(context) {
829
+ const token = await getAccessToken(context.auth);
830
+ const baseUrl = context.auth.props.baseUrl;
831
+
832
+ const url = `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items/${context.propsValue.itemId}`;
833
+
834
+ const response = await httpClient.sendRequest({
835
+ method: HttpMethod.GET,
836
+ url: `${baseUrl}/api/v2/public/jobs/${context.propsValue.id}/stages/${context.propsValue.stageId}/items/${context.propsValue.itemId}`,
837
+ headers: {
838
+ Authorization: `Bearer ${token}`,
839
+ 'Content-Type': 'application/json',
840
+ 'X-WorkBuddy-Version': '2026-01',
841
+ },
842
+ });
843
+
844
+ return response.body;
845
+ },
846
+ });