@workbuddy/piece-workbuddy-vnext 1.0.9 → 1.0.11

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