@workbuddy/piece-workbuddy-edge 1.0.32 → 1.0.34

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 (129) hide show
  1. package/package.json +1 -1
  2. package/src/index.d.ts.map +1 -1
  3. package/src/index.js +76 -14
  4. package/src/index.js.map +1 -1
  5. package/src/index.ts +139 -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 +7 -1
  45. package/src/lib/actions/index.d.ts.map +1 -1
  46. package/src/lib/actions/index.js +7 -1
  47. package/src/lib/actions/index.js.map +1 -1
  48. package/src/lib/actions/index.ts +7 -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 +87 -1
  65. package/src/lib/actions/jobs.d.ts.map +1 -1
  66. package/src/lib/actions/jobs.js +495 -7
  67. package/src/lib/actions/jobs.js.map +1 -1
  68. package/src/lib/actions/jobs.ts +523 -6
  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/settings-custom-fields.d.ts +21 -0
  80. package/src/lib/actions/settings-custom-fields.d.ts.map +1 -0
  81. package/src/lib/actions/settings-custom-fields.js +95 -0
  82. package/src/lib/actions/settings-custom-fields.js.map +1 -0
  83. package/src/lib/actions/settings-custom-fields.ts +107 -0
  84. package/src/lib/actions/settings-items.d.ts +136 -0
  85. package/src/lib/actions/settings-items.d.ts.map +1 -0
  86. package/src/lib/actions/settings-items.js +772 -0
  87. package/src/lib/actions/settings-items.js.map +1 -0
  88. package/src/lib/actions/settings-items.ts +818 -0
  89. package/src/lib/actions/{settings.d.ts → settings-reference-data.d.ts} +33 -10
  90. package/src/lib/actions/settings-reference-data.d.ts.map +1 -0
  91. package/src/lib/actions/settings-reference-data.js +423 -0
  92. package/src/lib/actions/settings-reference-data.js.map +1 -0
  93. package/src/lib/actions/settings-reference-data.ts +496 -0
  94. package/src/lib/actions/settings-templates.d.ts +15 -0
  95. package/src/lib/actions/settings-templates.d.ts.map +1 -0
  96. package/src/lib/actions/settings-templates.js +75 -0
  97. package/src/lib/actions/settings-templates.js.map +1 -0
  98. package/src/lib/actions/settings-templates.ts +79 -0
  99. package/src/lib/actions/stages-activities.d.ts +4 -3
  100. package/src/lib/actions/stages-activities.d.ts.map +1 -1
  101. package/src/lib/actions/stages-activities.js +19 -12
  102. package/src/lib/actions/stages-activities.js.map +1 -1
  103. package/src/lib/actions/stages-activities.ts +19 -12
  104. package/src/lib/actions/stages-pending-items.d.ts +75 -0
  105. package/src/lib/actions/stages-pending-items.d.ts.map +1 -0
  106. package/src/lib/actions/stages-pending-items.js +370 -0
  107. package/src/lib/actions/stages-pending-items.js.map +1 -0
  108. package/src/lib/actions/stages-pending-items.ts +404 -0
  109. package/src/lib/actions/stages-resources.d.ts.map +1 -1
  110. package/src/lib/actions/stages-resources.js +5 -8
  111. package/src/lib/actions/stages-resources.js.map +1 -1
  112. package/src/lib/actions/stages-resources.ts +8 -8
  113. package/src/lib/actions/stages-tasks.d.ts +0 -2
  114. package/src/lib/actions/stages-tasks.d.ts.map +1 -1
  115. package/src/lib/actions/stages-tasks.js +0 -12
  116. package/src/lib/actions/stages-tasks.js.map +1 -1
  117. package/src/lib/actions/stages-tasks.ts +0 -12
  118. package/src/lib/actions/stages.d.ts +20 -3
  119. package/src/lib/actions/stages.d.ts.map +1 -1
  120. package/src/lib/actions/stages.js +103 -21
  121. package/src/lib/actions/stages.js.map +1 -1
  122. package/src/lib/actions/stages.ts +116 -20
  123. package/src/lib/actions/webhooks-v2.js +11 -11
  124. package/src/lib/actions/webhooks-v2.js.map +1 -1
  125. package/src/lib/actions/webhooks-v2.ts +11 -11
  126. package/src/lib/actions/settings.d.ts.map +0 -1
  127. package/src/lib/actions/settings.js +0 -257
  128. package/src/lib/actions/settings.js.map +0 -1
  129. package/src/lib/actions/settings.ts +0 -301
@@ -0,0 +1,818 @@
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 PublicApiItemController_list = createAction({
6
+ name: 'PublicApiItemController_list',
7
+ auth: workbuddyAuth,
8
+ displayName: 'List items',
9
+ description: 'Retrieve paginated editable settings items.',
10
+ props: {},
11
+ async run(context) {
12
+ const token = await getAccessToken(context.auth);
13
+ const baseUrl = context.auth.props.baseUrl;
14
+
15
+ const url = `${baseUrl}/api/v2/public/settings/items`;
16
+
17
+ const response = await httpClient.sendRequest({
18
+ method: HttpMethod.GET,
19
+ url: `${baseUrl}/api/v2/public/settings/items`,
20
+ headers: {
21
+ Authorization: `Bearer ${token}`,
22
+ 'Content-Type': 'application/json',
23
+ 'X-WorkBuddy-Version': '2026-01',
24
+ },
25
+ });
26
+
27
+ return response.body;
28
+ },
29
+ });
30
+
31
+ export const PublicApiItemController_create = createAction({
32
+ name: 'PublicApiItemController_create',
33
+ auth: workbuddyAuth,
34
+ displayName: 'Create item',
35
+ description: 'Create a settings item. This endpoint does not upsert.',
36
+ props: {},
37
+ async run(context) {
38
+ const token = await getAccessToken(context.auth);
39
+ const baseUrl = context.auth.props.baseUrl;
40
+
41
+ const url = `${baseUrl}/api/v2/public/settings/items`;
42
+
43
+ const response = await httpClient.sendRequest({
44
+ method: HttpMethod.POST,
45
+ url: `${baseUrl}/api/v2/public/settings/items`,
46
+ headers: {
47
+ Authorization: `Bearer ${token}`,
48
+ 'Content-Type': 'application/json',
49
+ 'X-WorkBuddy-Version': '2026-01',
50
+ },
51
+ });
52
+
53
+ return response.body;
54
+ },
55
+ });
56
+
57
+ export const PublicApiItemController_upsert = createAction({
58
+ name: 'PublicApiItemController_upsert',
59
+ auth: workbuddyAuth,
60
+ displayName: 'Upsert item',
61
+ description:
62
+ 'Create or partially update a settings item using integrationId when supplied, otherwise name. Create still requires mandatory item fields.',
63
+ props: {
64
+ name: Property.ShortText({
65
+ displayName: 'Name',
66
+ description: 'Display name',
67
+ required: true,
68
+ }),
69
+ type: Property.StaticDropdown({
70
+ displayName: 'Type',
71
+ description: '',
72
+ required: false,
73
+ options: {
74
+ options: [
75
+ { label: 'SERVICE', value: 'SERVICE' },
76
+ { label: 'INVENTORY', value: 'INVENTORY' },
77
+ { label: 'NON-INVENTORY', value: 'NON-INVENTORY' },
78
+ { label: 'INCENTIVE', value: 'INCENTIVE' },
79
+ { label: 'KIT', value: 'KIT' },
80
+ { label: 'BUNDLE', value: 'BUNDLE' },
81
+ { label: 'SOR', value: 'SOR' },
82
+ ],
83
+ },
84
+ }),
85
+ baseUomId: Property.ShortText({
86
+ displayName: 'Base Uom Id',
87
+ description: 'base uom ID',
88
+ required: false,
89
+ }),
90
+ baseUomName: Property.ShortText({
91
+ displayName: 'Base Uom Name',
92
+ description: '',
93
+ required: false,
94
+ }),
95
+ description: Property.LongText({
96
+ displayName: 'Description',
97
+ description: 'Detailed description',
98
+ required: false,
99
+ }),
100
+ category: Property.Dropdown({
101
+ displayName: 'Flag Category',
102
+ description: 'Select a flag category',
103
+ required: false,
104
+ refreshers: [],
105
+ auth: workbuddyAuth,
106
+ options: async ({ auth }) => {
107
+ const authValue = auth as unknown as { props: { baseUrl: string; clientId: string; clientSecret: string } };
108
+ const token = await getAccessToken(authValue);
109
+ const baseUrl = authValue.props.baseUrl;
110
+ const response = await httpClient.sendRequest<{ items: Array<{ id: string; name: string }> }>({
111
+ method: HttpMethod.GET,
112
+ url: `${baseUrl}/api/v2/public/settings/tags?type=flag-category`,
113
+ headers: {
114
+ Authorization: `Bearer ${token}`,
115
+ 'X-WorkBuddy-Version': '2026-01',
116
+ },
117
+ });
118
+ const items = response.body?.items || [];
119
+ return {
120
+ options: items.map((item) => ({
121
+ label: item.name,
122
+ value: JSON.stringify({ id: item.id, name: item.name }),
123
+ })),
124
+ };
125
+ },
126
+ }),
127
+ active: Property.Checkbox({
128
+ displayName: 'Active',
129
+ description: 'Whether the entity is active',
130
+ required: false,
131
+ }),
132
+ integrationId: Property.ShortText({
133
+ displayName: 'Integration Id',
134
+ description: 'integration ID',
135
+ required: false,
136
+ }),
137
+ canOverrideDesc: Property.Checkbox({
138
+ displayName: 'Can Override Desc',
139
+ description: '',
140
+ required: false,
141
+ }),
142
+ longDescription: Property.LongText({
143
+ displayName: 'Long Description',
144
+ description: '',
145
+ required: false,
146
+ }),
147
+ manufacturer: Property.ShortText({
148
+ displayName: 'Manufacturer',
149
+ description: '',
150
+ required: false,
151
+ }),
152
+ retailPrice: Property.Number({
153
+ displayName: 'Retail Price',
154
+ description: '',
155
+ required: false,
156
+ }),
157
+ tradePrice: Property.Number({
158
+ displayName: 'Trade Price',
159
+ description: '',
160
+ required: false,
161
+ }),
162
+ standardCost: Property.Number({
163
+ displayName: 'Standard Cost',
164
+ description: '',
165
+ required: false,
166
+ }),
167
+ economicOrderQty: Property.Number({
168
+ displayName: 'Economic Order Qty',
169
+ description: '',
170
+ required: false,
171
+ }),
172
+ safetyStockQty: Property.Number({
173
+ displayName: 'Safety Stock Qty',
174
+ description: '',
175
+ required: false,
176
+ }),
177
+ leadTimeDays: Property.Number({
178
+ displayName: 'Lead Time Days',
179
+ description: '',
180
+ required: false,
181
+ }),
182
+ upc: Property.ShortText({
183
+ displayName: 'Upc',
184
+ description: '',
185
+ required: false,
186
+ }),
187
+ itemSold: Property.Checkbox({
188
+ displayName: 'Item Sold',
189
+ description: '',
190
+ required: false,
191
+ }),
192
+ saleGlCode: Property.ShortText({
193
+ displayName: 'Sale Gl Code',
194
+ description: '',
195
+ required: false,
196
+ }),
197
+ saleTaxRateId: Property.ShortText({
198
+ displayName: 'Sale Tax Rate Id',
199
+ description: 'sale tax rate ID',
200
+ required: false,
201
+ }),
202
+ saleTaxRateName: Property.ShortText({
203
+ displayName: 'Sale Tax Rate Name',
204
+ description: '',
205
+ required: false,
206
+ }),
207
+ itemPurchased: Property.Checkbox({
208
+ displayName: 'Item Purchased',
209
+ description: '',
210
+ required: false,
211
+ }),
212
+ purchaseGlCode: Property.ShortText({
213
+ displayName: 'Purchase Gl Code',
214
+ description: '',
215
+ required: false,
216
+ }),
217
+ purchaseTaxRateId: Property.ShortText({
218
+ displayName: 'Purchase Tax Rate Id',
219
+ description: 'purchase tax rate ID',
220
+ required: false,
221
+ }),
222
+ purchaseTaxRateName: Property.ShortText({
223
+ displayName: 'Purchase Tax Rate Name',
224
+ description: '',
225
+ required: false,
226
+ }),
227
+ codeInvoicingStatus: Property.StaticDropdown({
228
+ displayName: 'Code Invoicing Status',
229
+ description: '',
230
+ required: false,
231
+ options: {
232
+ options: [
233
+ { label: 'Billable', value: 'Billable' },
234
+ { label: 'No Charge', value: 'No Charge' },
235
+ { label: 'Not Billable', value: 'Not Billable' },
236
+ ],
237
+ },
238
+ }),
239
+ suppliedBySubcontractor: Property.Checkbox({
240
+ displayName: 'Supplied By Subcontractor',
241
+ description: '',
242
+ required: false,
243
+ }),
244
+ autoCreateTask: Property.Checkbox({
245
+ displayName: 'Auto Create Task',
246
+ description: '',
247
+ required: false,
248
+ }),
249
+ customFields: Property.ShortText({
250
+ displayName: 'Custom Fields',
251
+ description: 'Custom fields as key-value pairs — validated against tenant field definitions',
252
+ required: false,
253
+ }),
254
+ trackingCategory1: Property.ShortText({
255
+ displayName: 'Tracking Category1',
256
+ description: '',
257
+ required: false,
258
+ }),
259
+ trackingCategory2: Property.ShortText({
260
+ displayName: 'Tracking Category2',
261
+ description: '',
262
+ required: false,
263
+ }),
264
+ uoms: Property.Json({
265
+ displayName: 'Uoms',
266
+ description: '',
267
+ required: false,
268
+ defaultValue: [],
269
+ }),
270
+ },
271
+ async run(context) {
272
+ const token = await getAccessToken(context.auth);
273
+ const baseUrl = context.auth.props.baseUrl;
274
+
275
+ const url = `${baseUrl}/api/v2/public/settings/items`;
276
+
277
+ // Build body with only defined values (for partial updates)
278
+ const rawBody: Record<string, unknown> = {
279
+ type: context.propsValue.type,
280
+ name: context.propsValue.name,
281
+ baseUomId: context.propsValue.baseUomId,
282
+ baseUomName: context.propsValue.baseUomName,
283
+ description: context.propsValue.description,
284
+ category:
285
+ typeof context.propsValue.category === 'string'
286
+ ? JSON.parse(context.propsValue.category)
287
+ : context.propsValue.category,
288
+ active: context.propsValue.active,
289
+ integrationId: context.propsValue.integrationId,
290
+ canOverrideDesc: context.propsValue.canOverrideDesc,
291
+ longDescription: context.propsValue.longDescription,
292
+ manufacturer: context.propsValue.manufacturer,
293
+ retailPrice: context.propsValue.retailPrice,
294
+ tradePrice: context.propsValue.tradePrice,
295
+ standardCost: context.propsValue.standardCost,
296
+ economicOrderQty: context.propsValue.economicOrderQty,
297
+ safetyStockQty: context.propsValue.safetyStockQty,
298
+ leadTimeDays: context.propsValue.leadTimeDays,
299
+ upc: context.propsValue.upc,
300
+ itemSold: context.propsValue.itemSold,
301
+ saleGlCode: context.propsValue.saleGlCode,
302
+ saleTaxRateId: context.propsValue.saleTaxRateId,
303
+ saleTaxRateName: context.propsValue.saleTaxRateName,
304
+ itemPurchased: context.propsValue.itemPurchased,
305
+ purchaseGlCode: context.propsValue.purchaseGlCode,
306
+ purchaseTaxRateId: context.propsValue.purchaseTaxRateId,
307
+ purchaseTaxRateName: context.propsValue.purchaseTaxRateName,
308
+ codeInvoicingStatus: context.propsValue.codeInvoicingStatus,
309
+ suppliedBySubcontractor: context.propsValue.suppliedBySubcontractor,
310
+ autoCreateTask: context.propsValue.autoCreateTask,
311
+ customFields: context.propsValue.customFields,
312
+ trackingCategory1: context.propsValue.trackingCategory1,
313
+ trackingCategory2: context.propsValue.trackingCategory2,
314
+ uoms: context.propsValue.uoms,
315
+ };
316
+
317
+ const body = Object.fromEntries(
318
+ Object.entries(rawBody).filter(([_, v]) => v !== undefined && v !== null && v !== '')
319
+ );
320
+ const response = await httpClient.sendRequest({
321
+ method: HttpMethod.PUT,
322
+ url: `${baseUrl}/api/v2/public/settings/items`,
323
+ headers: {
324
+ Authorization: `Bearer ${token}`,
325
+ 'Content-Type': 'application/json',
326
+ 'X-WorkBuddy-Version': '2026-01',
327
+ },
328
+ body: body,
329
+ });
330
+
331
+ return response.body;
332
+ },
333
+ });
334
+
335
+ export const PublicApiItemController_getById = createAction({
336
+ name: 'PublicApiItemController_getById',
337
+ auth: workbuddyAuth,
338
+ displayName: 'Get item',
339
+ description: 'Retrieve a settings item by ID, name, or integration ID.',
340
+ props: {
341
+ id: Property.ShortText({
342
+ displayName: 'Id',
343
+ description: 'Entity ID',
344
+ required: true,
345
+ }),
346
+ },
347
+ async run(context) {
348
+ const token = await getAccessToken(context.auth);
349
+ const baseUrl = context.auth.props.baseUrl;
350
+
351
+ const url = `${baseUrl}/api/v2/public/settings/items/${context.propsValue.id}`;
352
+
353
+ const response = await httpClient.sendRequest({
354
+ method: HttpMethod.GET,
355
+ url: `${baseUrl}/api/v2/public/settings/items/${context.propsValue.id}`,
356
+ headers: {
357
+ Authorization: `Bearer ${token}`,
358
+ 'Content-Type': 'application/json',
359
+ 'X-WorkBuddy-Version': '2026-01',
360
+ },
361
+ });
362
+
363
+ return response.body;
364
+ },
365
+ });
366
+
367
+ export const PublicApiItemController_update = createAction({
368
+ name: 'PublicApiItemController_update',
369
+ auth: workbuddyAuth,
370
+ displayName: 'Update item',
371
+ description: 'Update a settings item by ID.',
372
+ props: {
373
+ id: Property.ShortText({
374
+ displayName: 'Id',
375
+ description: 'Entity ID',
376
+ required: true,
377
+ }),
378
+ type: Property.StaticDropdown({
379
+ displayName: 'Type',
380
+ description: '',
381
+ required: false,
382
+ options: {
383
+ options: [
384
+ { label: 'SERVICE', value: 'SERVICE' },
385
+ { label: 'INVENTORY', value: 'INVENTORY' },
386
+ { label: 'NON-INVENTORY', value: 'NON-INVENTORY' },
387
+ { label: 'INCENTIVE', value: 'INCENTIVE' },
388
+ { label: 'KIT', value: 'KIT' },
389
+ { label: 'BUNDLE', value: 'BUNDLE' },
390
+ { label: 'SOR', value: 'SOR' },
391
+ ],
392
+ },
393
+ }),
394
+ name: Property.ShortText({
395
+ displayName: 'Name',
396
+ description: 'Display name',
397
+ required: false,
398
+ }),
399
+ baseUomId: Property.ShortText({
400
+ displayName: 'Base Uom Id',
401
+ description: 'base uom ID',
402
+ required: false,
403
+ }),
404
+ baseUomName: Property.ShortText({
405
+ displayName: 'Base Uom Name',
406
+ description: '',
407
+ required: false,
408
+ }),
409
+ description: Property.LongText({
410
+ displayName: 'Description',
411
+ description: 'Detailed description',
412
+ required: false,
413
+ }),
414
+ category: Property.Dropdown({
415
+ displayName: 'Flag Category',
416
+ description: 'Select a flag category',
417
+ required: false,
418
+ refreshers: [],
419
+ auth: workbuddyAuth,
420
+ options: async ({ auth }) => {
421
+ const authValue = auth as unknown as { props: { baseUrl: string; clientId: string; clientSecret: string } };
422
+ const token = await getAccessToken(authValue);
423
+ const baseUrl = authValue.props.baseUrl;
424
+ const response = await httpClient.sendRequest<{ items: Array<{ id: string; name: string }> }>({
425
+ method: HttpMethod.GET,
426
+ url: `${baseUrl}/api/v2/public/settings/tags?type=flag-category`,
427
+ headers: {
428
+ Authorization: `Bearer ${token}`,
429
+ 'X-WorkBuddy-Version': '2026-01',
430
+ },
431
+ });
432
+ const items = response.body?.items || [];
433
+ return {
434
+ options: items.map((item) => ({
435
+ label: item.name,
436
+ value: JSON.stringify({ id: item.id, name: item.name }),
437
+ })),
438
+ };
439
+ },
440
+ }),
441
+ active: Property.Checkbox({
442
+ displayName: 'Active',
443
+ description: 'Whether the entity is active',
444
+ required: false,
445
+ }),
446
+ integrationId: Property.ShortText({
447
+ displayName: 'Integration Id',
448
+ description: 'integration ID',
449
+ required: false,
450
+ }),
451
+ canOverrideDesc: Property.Checkbox({
452
+ displayName: 'Can Override Desc',
453
+ description: '',
454
+ required: false,
455
+ }),
456
+ longDescription: Property.LongText({
457
+ displayName: 'Long Description',
458
+ description: '',
459
+ required: false,
460
+ }),
461
+ manufacturer: Property.ShortText({
462
+ displayName: 'Manufacturer',
463
+ description: '',
464
+ required: false,
465
+ }),
466
+ retailPrice: Property.Number({
467
+ displayName: 'Retail Price',
468
+ description: '',
469
+ required: false,
470
+ }),
471
+ tradePrice: Property.Number({
472
+ displayName: 'Trade Price',
473
+ description: '',
474
+ required: false,
475
+ }),
476
+ standardCost: Property.Number({
477
+ displayName: 'Standard Cost',
478
+ description: '',
479
+ required: false,
480
+ }),
481
+ economicOrderQty: Property.Number({
482
+ displayName: 'Economic Order Qty',
483
+ description: '',
484
+ required: false,
485
+ }),
486
+ safetyStockQty: Property.Number({
487
+ displayName: 'Safety Stock Qty',
488
+ description: '',
489
+ required: false,
490
+ }),
491
+ leadTimeDays: Property.Number({
492
+ displayName: 'Lead Time Days',
493
+ description: '',
494
+ required: false,
495
+ }),
496
+ upc: Property.ShortText({
497
+ displayName: 'Upc',
498
+ description: '',
499
+ required: false,
500
+ }),
501
+ itemSold: Property.Checkbox({
502
+ displayName: 'Item Sold',
503
+ description: '',
504
+ required: false,
505
+ }),
506
+ saleGlCode: Property.ShortText({
507
+ displayName: 'Sale Gl Code',
508
+ description: '',
509
+ required: false,
510
+ }),
511
+ saleTaxRateId: Property.ShortText({
512
+ displayName: 'Sale Tax Rate Id',
513
+ description: 'sale tax rate ID',
514
+ required: false,
515
+ }),
516
+ saleTaxRateName: Property.ShortText({
517
+ displayName: 'Sale Tax Rate Name',
518
+ description: '',
519
+ required: false,
520
+ }),
521
+ itemPurchased: Property.Checkbox({
522
+ displayName: 'Item Purchased',
523
+ description: '',
524
+ required: false,
525
+ }),
526
+ purchaseGlCode: Property.ShortText({
527
+ displayName: 'Purchase Gl Code',
528
+ description: '',
529
+ required: false,
530
+ }),
531
+ purchaseTaxRateId: Property.ShortText({
532
+ displayName: 'Purchase Tax Rate Id',
533
+ description: 'purchase tax rate ID',
534
+ required: false,
535
+ }),
536
+ purchaseTaxRateName: Property.ShortText({
537
+ displayName: 'Purchase Tax Rate Name',
538
+ description: '',
539
+ required: false,
540
+ }),
541
+ codeInvoicingStatus: Property.StaticDropdown({
542
+ displayName: 'Code Invoicing Status',
543
+ description: '',
544
+ required: false,
545
+ options: {
546
+ options: [
547
+ { label: 'Billable', value: 'Billable' },
548
+ { label: 'No Charge', value: 'No Charge' },
549
+ { label: 'Not Billable', value: 'Not Billable' },
550
+ ],
551
+ },
552
+ }),
553
+ suppliedBySubcontractor: Property.Checkbox({
554
+ displayName: 'Supplied By Subcontractor',
555
+ description: '',
556
+ required: false,
557
+ }),
558
+ autoCreateTask: Property.Checkbox({
559
+ displayName: 'Auto Create Task',
560
+ description: '',
561
+ required: false,
562
+ }),
563
+ customFields: Property.ShortText({
564
+ displayName: 'Custom Fields',
565
+ description: 'Custom fields as key-value pairs — validated against tenant field definitions',
566
+ required: false,
567
+ }),
568
+ trackingCategory1: Property.ShortText({
569
+ displayName: 'Tracking Category1',
570
+ description: '',
571
+ required: false,
572
+ }),
573
+ trackingCategory2: Property.ShortText({
574
+ displayName: 'Tracking Category2',
575
+ description: '',
576
+ required: false,
577
+ }),
578
+ uoms: Property.Json({
579
+ displayName: 'Uoms',
580
+ description: '',
581
+ required: false,
582
+ defaultValue: [],
583
+ }),
584
+ },
585
+ async run(context) {
586
+ const token = await getAccessToken(context.auth);
587
+ const baseUrl = context.auth.props.baseUrl;
588
+
589
+ const url = `${baseUrl}/api/v2/public/settings/items/${context.propsValue.id}`;
590
+
591
+ // Build body with only defined values (for partial updates)
592
+ const rawBody: Record<string, unknown> = {
593
+ type: context.propsValue.type,
594
+ name: context.propsValue.name,
595
+ baseUomId: context.propsValue.baseUomId,
596
+ baseUomName: context.propsValue.baseUomName,
597
+ description: context.propsValue.description,
598
+ category:
599
+ typeof context.propsValue.category === 'string'
600
+ ? JSON.parse(context.propsValue.category)
601
+ : context.propsValue.category,
602
+ active: context.propsValue.active,
603
+ integrationId: context.propsValue.integrationId,
604
+ canOverrideDesc: context.propsValue.canOverrideDesc,
605
+ longDescription: context.propsValue.longDescription,
606
+ manufacturer: context.propsValue.manufacturer,
607
+ retailPrice: context.propsValue.retailPrice,
608
+ tradePrice: context.propsValue.tradePrice,
609
+ standardCost: context.propsValue.standardCost,
610
+ economicOrderQty: context.propsValue.economicOrderQty,
611
+ safetyStockQty: context.propsValue.safetyStockQty,
612
+ leadTimeDays: context.propsValue.leadTimeDays,
613
+ upc: context.propsValue.upc,
614
+ itemSold: context.propsValue.itemSold,
615
+ saleGlCode: context.propsValue.saleGlCode,
616
+ saleTaxRateId: context.propsValue.saleTaxRateId,
617
+ saleTaxRateName: context.propsValue.saleTaxRateName,
618
+ itemPurchased: context.propsValue.itemPurchased,
619
+ purchaseGlCode: context.propsValue.purchaseGlCode,
620
+ purchaseTaxRateId: context.propsValue.purchaseTaxRateId,
621
+ purchaseTaxRateName: context.propsValue.purchaseTaxRateName,
622
+ codeInvoicingStatus: context.propsValue.codeInvoicingStatus,
623
+ suppliedBySubcontractor: context.propsValue.suppliedBySubcontractor,
624
+ autoCreateTask: context.propsValue.autoCreateTask,
625
+ customFields: context.propsValue.customFields,
626
+ trackingCategory1: context.propsValue.trackingCategory1,
627
+ trackingCategory2: context.propsValue.trackingCategory2,
628
+ uoms: context.propsValue.uoms,
629
+ };
630
+
631
+ const body = Object.fromEntries(
632
+ Object.entries(rawBody).filter(([_, v]) => v !== undefined && v !== null && v !== '')
633
+ );
634
+ const response = await httpClient.sendRequest({
635
+ method: HttpMethod.PATCH,
636
+ url: `${baseUrl}/api/v2/public/settings/items/${context.propsValue.id}`,
637
+ headers: {
638
+ Authorization: `Bearer ${token}`,
639
+ 'Content-Type': 'application/json',
640
+ 'X-WorkBuddy-Version': '2026-01',
641
+ },
642
+ body: body,
643
+ });
644
+
645
+ return response.body;
646
+ },
647
+ });
648
+
649
+ export const PublicApiItemController_delete = createAction({
650
+ name: 'PublicApiItemController_delete',
651
+ auth: workbuddyAuth,
652
+ displayName: 'Delete item',
653
+ description: 'Deactivate a settings item by ID.',
654
+ props: {
655
+ id: Property.ShortText({
656
+ displayName: 'Id',
657
+ description: 'Entity ID',
658
+ required: true,
659
+ }),
660
+ },
661
+ async run(context) {
662
+ const token = await getAccessToken(context.auth);
663
+ const baseUrl = context.auth.props.baseUrl;
664
+
665
+ const url = `${baseUrl}/api/v2/public/settings/items/${context.propsValue.id}`;
666
+
667
+ const response = await httpClient.sendRequest({
668
+ method: HttpMethod.DELETE,
669
+ url: `${baseUrl}/api/v2/public/settings/items/${context.propsValue.id}`,
670
+ headers: {
671
+ Authorization: `Bearer ${token}`,
672
+ 'Content-Type': 'application/json',
673
+ 'X-WorkBuddy-Version': '2026-01',
674
+ },
675
+ });
676
+
677
+ return response.body;
678
+ },
679
+ });
680
+
681
+ export const PublicApiItemCategoryController_list = createAction({
682
+ name: 'PublicApiItemCategoryController_list',
683
+ auth: workbuddyAuth,
684
+ displayName: 'List item categories',
685
+ description:
686
+ 'Retrieve active item categories and sub-categories. Use search, name, or id to filter by category/sub-category name or id.',
687
+ props: {
688
+ id: Property.ShortText({
689
+ displayName: 'Id',
690
+ description: 'Alias for search',
691
+ required: false,
692
+ }),
693
+ name: Property.ShortText({
694
+ displayName: 'Name',
695
+ description: 'Alias for search',
696
+ required: false,
697
+ }),
698
+ search: Property.ShortText({
699
+ displayName: 'Search',
700
+ description: 'Filter by category/sub-category name or id',
701
+ required: false,
702
+ }),
703
+ },
704
+ async run(context) {
705
+ const token = await getAccessToken(context.auth);
706
+ const baseUrl = context.auth.props.baseUrl;
707
+
708
+ const url = `${baseUrl}/settings/item-categories`;
709
+
710
+ const queryParams = new URLSearchParams();
711
+ if (context.propsValue.id !== undefined && context.propsValue.id !== null && context.propsValue.id !== '')
712
+ queryParams.append('id', String(context.propsValue.id));
713
+ if (context.propsValue.name !== undefined && context.propsValue.name !== null && context.propsValue.name !== '')
714
+ queryParams.append('name', String(context.propsValue.name));
715
+ if (
716
+ context.propsValue.search !== undefined &&
717
+ context.propsValue.search !== null &&
718
+ context.propsValue.search !== ''
719
+ )
720
+ queryParams.append('search', String(context.propsValue.search));
721
+ const queryString = queryParams.toString();
722
+ const urlWithQuery = queryString ? `${url}?${queryString}` : url;
723
+
724
+ const response = await httpClient.sendRequest({
725
+ method: HttpMethod.GET,
726
+ url: urlWithQuery,
727
+ headers: {
728
+ Authorization: `Bearer ${token}`,
729
+ 'Content-Type': 'application/json',
730
+ 'X-WorkBuddy-Version': '2026-01',
731
+ },
732
+ });
733
+
734
+ return response.body;
735
+ },
736
+ });
737
+
738
+ export const PublicApiItemCategoryController_upsert = createAction({
739
+ name: 'PublicApiItemCategoryController_upsert',
740
+ auth: workbuddyAuth,
741
+ displayName: 'Upsert item category',
742
+ description: 'Create a category/sub-category pair if it does not already exist.',
743
+ props: {
744
+ categoryId: Property.ShortText({
745
+ displayName: 'Category Id',
746
+ description: 'category ID',
747
+ required: false,
748
+ }),
749
+ categoryName: Property.ShortText({
750
+ displayName: 'Category Name',
751
+ description: '',
752
+ required: false,
753
+ }),
754
+ subCategoryId: Property.ShortText({
755
+ displayName: 'Sub Category Id',
756
+ description: 'sub category ID',
757
+ required: false,
758
+ }),
759
+ subCategoryName: Property.ShortText({
760
+ displayName: 'Sub Category Name',
761
+ description: '',
762
+ required: false,
763
+ }),
764
+ },
765
+ async run(context) {
766
+ const token = await getAccessToken(context.auth);
767
+ const baseUrl = context.auth.props.baseUrl;
768
+
769
+ const url = `${baseUrl}/api/v2/public/settings/item-categories/upsert`;
770
+
771
+ const rawBody: Record<string, unknown> = {
772
+ categoryId: context.propsValue.categoryId,
773
+ categoryName: context.propsValue.categoryName,
774
+ subCategoryId: context.propsValue.subCategoryId,
775
+ subCategoryName: context.propsValue.subCategoryName,
776
+ };
777
+
778
+ const body = rawBody;
779
+ const response = await httpClient.sendRequest({
780
+ method: HttpMethod.POST,
781
+ url: `${baseUrl}/api/v2/public/settings/item-categories/upsert`,
782
+ headers: {
783
+ Authorization: `Bearer ${token}`,
784
+ 'Content-Type': 'application/json',
785
+ 'X-WorkBuddy-Version': '2026-01',
786
+ },
787
+ body: body,
788
+ });
789
+
790
+ return response.body;
791
+ },
792
+ });
793
+
794
+ export const PublicApiUoMController_list = createAction({
795
+ name: 'PublicApiUoMController_list',
796
+ auth: workbuddyAuth,
797
+ displayName: 'List UOMs',
798
+ description: 'Retrieve active units of measure for item create/update.',
799
+ props: {},
800
+ async run(context) {
801
+ const token = await getAccessToken(context.auth);
802
+ const baseUrl = context.auth.props.baseUrl;
803
+
804
+ const url = `${baseUrl}/api/v2/public/settings/uoms`;
805
+
806
+ const response = await httpClient.sendRequest({
807
+ method: HttpMethod.GET,
808
+ url: `${baseUrl}/api/v2/public/settings/uoms`,
809
+ headers: {
810
+ Authorization: `Bearer ${token}`,
811
+ 'Content-Type': 'application/json',
812
+ 'X-WorkBuddy-Version': '2026-01',
813
+ },
814
+ });
815
+
816
+ return response.body;
817
+ },
818
+ });