@workbuddy/piece-workbuddy-vnext 1.0.91 → 1.0.93

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 (50) hide show
  1. package/package.json +1 -1
  2. package/src/index.d.ts.map +1 -1
  3. package/src/index.js +21 -0
  4. package/src/index.js.map +1 -1
  5. package/src/index.ts +42 -0
  6. package/src/lib/actions/crm-contractors.d.ts +1 -0
  7. package/src/lib/actions/crm-contractors.d.ts.map +1 -1
  8. package/src/lib/actions/crm-contractors.js +6 -0
  9. package/src/lib/actions/crm-contractors.js.map +1 -1
  10. package/src/lib/actions/crm-contractors.ts +6 -0
  11. package/src/lib/actions/crm-customers.d.ts +1 -0
  12. package/src/lib/actions/crm-customers.d.ts.map +1 -1
  13. package/src/lib/actions/crm-customers.js +6 -0
  14. package/src/lib/actions/crm-customers.js.map +1 -1
  15. package/src/lib/actions/crm-customers.ts +6 -0
  16. package/src/lib/actions/crm-suppliers.d.ts +1 -0
  17. package/src/lib/actions/crm-suppliers.d.ts.map +1 -1
  18. package/src/lib/actions/crm-suppliers.js +6 -0
  19. package/src/lib/actions/crm-suppliers.js.map +1 -1
  20. package/src/lib/actions/crm-suppliers.ts +6 -0
  21. package/src/lib/actions/index.d.ts +4 -0
  22. package/src/lib/actions/index.d.ts.map +1 -1
  23. package/src/lib/actions/index.js +4 -0
  24. package/src/lib/actions/index.js.map +1 -1
  25. package/src/lib/actions/index.ts +4 -0
  26. package/src/lib/actions/jobs.d.ts +2 -2
  27. package/src/lib/actions/jobs.d.ts.map +1 -1
  28. package/src/lib/actions/jobs.js +4 -24
  29. package/src/lib/actions/jobs.js.map +1 -1
  30. package/src/lib/actions/jobs.ts +4 -24
  31. package/src/lib/actions/service-plans-lines-tasks-subtasks.d.ts +52 -0
  32. package/src/lib/actions/service-plans-lines-tasks-subtasks.d.ts.map +1 -0
  33. package/src/lib/actions/service-plans-lines-tasks-subtasks.js +257 -0
  34. package/src/lib/actions/service-plans-lines-tasks-subtasks.js.map +1 -0
  35. package/src/lib/actions/service-plans-lines-tasks-subtasks.ts +274 -0
  36. package/src/lib/actions/service-plans-lines-tasks.d.ts +51 -0
  37. package/src/lib/actions/service-plans-lines-tasks.d.ts.map +1 -0
  38. package/src/lib/actions/service-plans-lines-tasks.js +255 -0
  39. package/src/lib/actions/service-plans-lines-tasks.js.map +1 -0
  40. package/src/lib/actions/service-plans-lines-tasks.ts +272 -0
  41. package/src/lib/actions/service-plans-lines.d.ts +48 -0
  42. package/src/lib/actions/service-plans-lines.d.ts.map +1 -0
  43. package/src/lib/actions/service-plans-lines.js +262 -0
  44. package/src/lib/actions/service-plans-lines.js.map +1 -0
  45. package/src/lib/actions/service-plans-lines.ts +278 -0
  46. package/src/lib/actions/service-plans.d.ts +47 -0
  47. package/src/lib/actions/service-plans.d.ts.map +1 -0
  48. package/src/lib/actions/service-plans.js +241 -0
  49. package/src/lib/actions/service-plans.js.map +1 -0
  50. package/src/lib/actions/service-plans.ts +262 -0
@@ -0,0 +1,262 @@
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 PublicServicePlanController_create = createAction({
6
+ name: 'PublicServicePlanController_create',
7
+ auth: workbuddyAuth,
8
+ displayName: 'Create a Service Plan',
9
+ description:
10
+ 'Creates only the Service Plan contract header. Lines and Tasks are added through their nested endpoints.',
11
+ props: {
12
+ integrationId: Property.ShortText({
13
+ displayName: 'Integration Id',
14
+ description: 'integration ID',
15
+ required: true,
16
+ }),
17
+ name: Property.ShortText({
18
+ displayName: 'Name',
19
+ description: 'Display name',
20
+ required: true,
21
+ }),
22
+ customerId: Property.ShortText({
23
+ displayName: 'Customer Id',
24
+ description: 'Customer ID — use /crm/customers to look up',
25
+ required: true,
26
+ }),
27
+ siteId: Property.ShortText({
28
+ displayName: 'Site Id',
29
+ description: 'Site ID — use /crm/sites to look up',
30
+ required: true,
31
+ }),
32
+ serviceTypeId: Property.ShortText({
33
+ displayName: 'Service Type Id',
34
+ description: 'service type ID',
35
+ required: true,
36
+ }),
37
+ serviceScopeId: Property.ShortText({
38
+ displayName: 'Service Scope Id',
39
+ description: 'service scope ID',
40
+ required: true,
41
+ }),
42
+ dateStart: Property.ShortText({
43
+ displayName: 'Date Start',
44
+ description: '',
45
+ required: true,
46
+ }),
47
+ dateEnd: Property.ShortText({
48
+ displayName: 'Date End',
49
+ description: '',
50
+ required: false,
51
+ }),
52
+ workingDays: Property.StaticMultiSelectDropdown({
53
+ displayName: 'Working Days',
54
+ description: '',
55
+ required: false,
56
+ options: {
57
+ options: [
58
+ { label: 'Mon', value: 'Mon' },
59
+ { label: 'Tue', value: 'Tue' },
60
+ { label: 'Wed', value: 'Wed' },
61
+ { label: 'Thu', value: 'Thu' },
62
+ { label: 'Fri', value: 'Fri' },
63
+ { label: 'Sat', value: 'Sat' },
64
+ { label: 'Sun', value: 'Sun' },
65
+ ],
66
+ },
67
+ }),
68
+ },
69
+ async run(context) {
70
+ const token = await getAccessToken(context.auth);
71
+ const baseUrl = context.auth.props.baseUrl;
72
+
73
+ const url = `${baseUrl}/api/v2/public/service-plans`;
74
+
75
+ const rawBody: Record<string, unknown> = {
76
+ integrationId: context.propsValue.integrationId,
77
+ name: context.propsValue.name,
78
+ customerId: context.propsValue.customerId,
79
+ siteId: context.propsValue.siteId,
80
+ serviceTypeId: context.propsValue.serviceTypeId,
81
+ serviceScopeId: context.propsValue.serviceScopeId,
82
+ dateStart: context.propsValue.dateStart,
83
+ dateEnd: context.propsValue.dateEnd,
84
+ workingDays: context.propsValue.workingDays,
85
+ };
86
+
87
+ const body = rawBody;
88
+ const response = await httpClient.sendRequest({
89
+ method: HttpMethod.POST,
90
+ url: `${baseUrl}/api/v2/public/service-plans`,
91
+ headers: {
92
+ Authorization: `Bearer ${token}`,
93
+ 'Content-Type': 'application/json',
94
+ 'X-WorkBuddy-Version': '2026-01',
95
+ },
96
+ body: body,
97
+ });
98
+
99
+ return response.body;
100
+ },
101
+ });
102
+
103
+ export const PublicServicePlanController_get = createAction({
104
+ name: 'PublicServicePlanController_get',
105
+ auth: workbuddyAuth,
106
+ displayName: 'Get a Service Plan',
107
+ description: "Resolves a WorkBuddy ID first, then the authenticated caller's integrationId.",
108
+ props: {
109
+ identifier: Property.ShortText({
110
+ displayName: 'Identifier',
111
+ description: 'WorkBuddy Service Plan ID or caller integrationId',
112
+ required: true,
113
+ }),
114
+ },
115
+ async run(context) {
116
+ const token = await getAccessToken(context.auth);
117
+ const baseUrl = context.auth.props.baseUrl;
118
+
119
+ const url = `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}`;
120
+
121
+ const response = await httpClient.sendRequest({
122
+ method: HttpMethod.GET,
123
+ url: `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}`,
124
+ headers: {
125
+ Authorization: `Bearer ${token}`,
126
+ 'Content-Type': 'application/json',
127
+ 'X-WorkBuddy-Version': '2026-01',
128
+ },
129
+ });
130
+
131
+ return response.body;
132
+ },
133
+ });
134
+
135
+ export const PublicServicePlanController_activate = createAction({
136
+ name: 'PublicServicePlanController_activate',
137
+ auth: workbuddyAuth,
138
+ displayName: 'Activate a Service Plan',
139
+ description: 'Validates and publishes a fully assembled Service Plan.',
140
+ props: {
141
+ identifier: Property.ShortText({
142
+ displayName: 'Identifier',
143
+ description: 'Entity ID or human-readable number',
144
+ required: true,
145
+ }),
146
+ reason: Property.ShortText({
147
+ displayName: 'Reason',
148
+ description: 'Reason for the action (e.g. cancellation reason)',
149
+ required: false,
150
+ }),
151
+ },
152
+ async run(context) {
153
+ const token = await getAccessToken(context.auth);
154
+ const baseUrl = context.auth.props.baseUrl;
155
+
156
+ const url = `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}/activate`;
157
+
158
+ const rawBody: Record<string, unknown> = {
159
+ reason: context.propsValue.reason,
160
+ };
161
+
162
+ const body = rawBody;
163
+ const response = await httpClient.sendRequest({
164
+ method: HttpMethod.POST,
165
+ url: `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}/activate`,
166
+ headers: {
167
+ Authorization: `Bearer ${token}`,
168
+ 'Content-Type': 'application/json',
169
+ 'X-WorkBuddy-Version': '2026-01',
170
+ },
171
+ body: body,
172
+ });
173
+
174
+ return response.body;
175
+ },
176
+ });
177
+
178
+ export const PublicServicePlanController_suspend = createAction({
179
+ name: 'PublicServicePlanController_suspend',
180
+ auth: workbuddyAuth,
181
+ displayName: 'Suspend a Service Plan',
182
+ description: 'Stops future scheduled work while preserving history.',
183
+ props: {
184
+ identifier: Property.ShortText({
185
+ displayName: 'Identifier',
186
+ description: 'Entity ID or human-readable number',
187
+ required: true,
188
+ }),
189
+ reason: Property.ShortText({
190
+ displayName: 'Reason',
191
+ description: 'Reason for the action (e.g. cancellation reason)',
192
+ required: false,
193
+ }),
194
+ },
195
+ async run(context) {
196
+ const token = await getAccessToken(context.auth);
197
+ const baseUrl = context.auth.props.baseUrl;
198
+
199
+ const url = `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}/suspend`;
200
+
201
+ const rawBody: Record<string, unknown> = {
202
+ reason: context.propsValue.reason,
203
+ };
204
+
205
+ const body = rawBody;
206
+ const response = await httpClient.sendRequest({
207
+ method: HttpMethod.POST,
208
+ url: `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}/suspend`,
209
+ headers: {
210
+ Authorization: `Bearer ${token}`,
211
+ 'Content-Type': 'application/json',
212
+ 'X-WorkBuddy-Version': '2026-01',
213
+ },
214
+ body: body,
215
+ });
216
+
217
+ return response.body;
218
+ },
219
+ });
220
+
221
+ export const PublicServicePlanController_archive = createAction({
222
+ name: 'PublicServicePlanController_archive',
223
+ auth: workbuddyAuth,
224
+ displayName: 'Archive a Service Plan',
225
+ description: 'Archives a suspended Service Plan and reconciles future scheduled work.',
226
+ props: {
227
+ identifier: Property.ShortText({
228
+ displayName: 'Identifier',
229
+ description: 'Entity ID or human-readable number',
230
+ required: true,
231
+ }),
232
+ reason: Property.ShortText({
233
+ displayName: 'Reason',
234
+ description: 'Reason for the action (e.g. cancellation reason)',
235
+ required: false,
236
+ }),
237
+ },
238
+ async run(context) {
239
+ const token = await getAccessToken(context.auth);
240
+ const baseUrl = context.auth.props.baseUrl;
241
+
242
+ const url = `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}/archive`;
243
+
244
+ const rawBody: Record<string, unknown> = {
245
+ reason: context.propsValue.reason,
246
+ };
247
+
248
+ const body = rawBody;
249
+ const response = await httpClient.sendRequest({
250
+ method: HttpMethod.POST,
251
+ url: `${baseUrl}/api/v2/public/service-plans/${context.propsValue.identifier}/archive`,
252
+ headers: {
253
+ Authorization: `Bearer ${token}`,
254
+ 'Content-Type': 'application/json',
255
+ 'X-WorkBuddy-Version': '2026-01',
256
+ },
257
+ body: body,
258
+ });
259
+
260
+ return response.body;
261
+ },
262
+ });