@uidu/client 3.16.0 → 3.18.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 (35) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/dist/declarations/src/contacts.d.ts +22 -1
  3. package/dist/declarations/src/courses.d.ts +37 -1
  4. package/dist/declarations/src/events.d.ts +58 -1
  5. package/dist/declarations/src/expenses.d.ts +169 -0
  6. package/dist/declarations/src/generated/index.d.ts +5039 -1610
  7. package/dist/declarations/src/index.d.ts +10 -8
  8. package/dist/declarations/src/mutations.d.ts +89 -1
  9. package/dist/declarations/src/people.d.ts +13 -1
  10. package/dist/uidu-client.cjs.dev.js +219 -1
  11. package/dist/uidu-client.cjs.prod.js +219 -1
  12. package/dist/uidu-client.esm.js +197 -2
  13. package/package.json +1 -1
  14. package/src/contacts.ts +33 -0
  15. package/src/courses.ts +28 -0
  16. package/src/events.ts +42 -0
  17. package/src/expenses.test.ts +155 -0
  18. package/src/expenses.ts +155 -0
  19. package/src/generated/index.ts +4119 -1868
  20. package/src/index.ts +41 -3
  21. package/src/mutations.ts +48 -0
  22. package/src/people.ts +33 -0
  23. package/src/queries/contacts/GetOrganization.graphql +17 -0
  24. package/src/queries/contacts/ListOrganizations.graphql +21 -0
  25. package/src/queries/contacts/OrganizationMutations.graphql +17 -0
  26. package/src/queries/courses/EnrollmentMutations.graphql +27 -0
  27. package/src/queries/events/EventInstanceMutations.graphql +29 -0
  28. package/src/queries/events/UpdateAttendance.graphql +14 -0
  29. package/src/queries/expenses/ExpenseFields.graphql +29 -0
  30. package/src/queries/expenses/ExpenseMutations.graphql +81 -0
  31. package/src/queries/expenses/GetExpenseReport.graphql +14 -0
  32. package/src/queries/expenses/ListAnalyticAccounts.graphql +20 -0
  33. package/src/queries/expenses/ListExpenseReports.graphql +22 -0
  34. package/src/queries/people/EmploymentVariationKindMutations.graphql +51 -0
  35. package/src/queries/people/ListEmploymentVariationKinds.graphql +23 -0
package/src/index.ts CHANGED
@@ -11,6 +11,7 @@ export {
11
11
  } from './utils/fieldValues';
12
12
 
13
13
  export {
14
+ ListAnalyticAccountsDocument,
14
15
  ListApplicationsDocument,
15
16
  ListBookingsDocument,
16
17
  ListCalendarsDocument,
@@ -23,13 +24,16 @@ export {
23
24
  ListDonationCampaignsDocument,
24
25
  ListDonationsDocument,
25
26
  ListEmployeesDocument,
27
+ ListEmploymentVariationKindsDocument,
26
28
  ListEnrollmentsDocument,
27
29
  ListEventsDocument,
30
+ ListExpenseReportsDocument,
28
31
  ListFormsDocument,
29
32
  ListGoalsDocument,
30
33
  ListKbArticlesDocument,
31
34
  ListKbCollectionsDocument,
32
35
  ListLecturesDocument,
36
+ ListOrganizationsDocument,
33
37
  ListPagesDocument,
34
38
  ListStoriesDocument,
35
39
  ListTimeframesDocument,
@@ -85,6 +89,7 @@ export {
85
89
  deleteContact,
86
90
  createDeal,
87
91
  updateDeal,
92
+ createOrganization,
88
93
  createKbCollection,
89
94
  updateKbCollection,
90
95
  deleteKbCollection,
@@ -115,6 +120,8 @@ export {
115
120
  terminateEmployment,
116
121
  createEmploymentTerm,
117
122
  updateEmploymentTerm,
123
+ createEmploymentVariationKind,
124
+ updateEmploymentVariationKind,
118
125
  createCompensation,
119
126
  updateCompensation,
120
127
  deleteCompensation,
@@ -135,7 +142,15 @@ export type { Channel } from './help-center';
135
142
  export { search } from './search';
136
143
  export type { SearchResult } from './search';
137
144
 
138
- export { getEvent, listEvents, createAttendance, createEvent } from './events';
145
+ export {
146
+ getEvent,
147
+ listEvents,
148
+ createAttendance,
149
+ updateAttendance,
150
+ createEvent,
151
+ createEventInstance,
152
+ updateEventInstance,
153
+ } from './events';
139
154
  export type { Event } from './events';
140
155
 
141
156
  export { getCall, listCalls } from './calls';
@@ -176,6 +191,7 @@ export {
176
191
  createCcnl,
177
192
  listEmploymentHistory,
178
193
  contractEvents,
194
+ listEmploymentVariationKinds,
179
195
  } from './people';
180
196
  export type {
181
197
  Employee,
@@ -187,6 +203,7 @@ export type {
187
203
  EmployeeContracts,
188
204
  ContractEvent,
189
205
  ContractEventType,
206
+ EmploymentVariationKind,
190
207
  } from './people';
191
208
 
192
209
  export {
@@ -204,6 +221,8 @@ export {
204
221
  listCourses,
205
222
  getEnrollment,
206
223
  listEnrollments,
224
+ createEnrollment,
225
+ updateEnrollment,
207
226
  getLecture,
208
227
  listLectures,
209
228
  } from './courses';
@@ -212,8 +231,15 @@ export type { Course, Enrollment, Lecture } from './courses';
212
231
  export { getCampaign, listCampaigns, listEmailCampaigns } from './campaigns';
213
232
  export type { Campaign } from './campaigns';
214
233
 
215
- export { getContact, listContacts, getDeal, listDeals } from './contacts';
216
- export type { Contact, Deal } from './contacts';
234
+ export {
235
+ getContact,
236
+ listContacts,
237
+ getDeal,
238
+ listDeals,
239
+ getOrganization,
240
+ listOrganizations,
241
+ } from './contacts';
242
+ export type { Contact, Deal, Organization } from './contacts';
217
243
  export {
218
244
  listGoals,
219
245
  getGoal,
@@ -227,6 +253,18 @@ export {
227
253
  } from './goals';
228
254
  export type { Goal, Timeframe } from './goals';
229
255
 
256
+ export {
257
+ listExpenseReports,
258
+ getExpenseReport,
259
+ createExpenseReport,
260
+ updateExpenseReport,
261
+ createExpense,
262
+ updateExpense,
263
+ listAnalyticAccounts,
264
+ allocateExpense,
265
+ } from './expenses';
266
+ export type { ExpenseReport, Expense, AnalyticAccount } from './expenses';
267
+
230
268
  export {
231
269
  getKbArticle,
232
270
  listKbArticles,
package/src/mutations.ts CHANGED
@@ -25,12 +25,16 @@ import {
25
25
  type CreateEmploymentMutationVariables,
26
26
  CreateEmploymentTermDocument,
27
27
  type CreateEmploymentTermMutationVariables,
28
+ CreateEmploymentVariationKindDocument,
29
+ type CreateEmploymentVariationKindMutationVariables,
28
30
  CreateFormDocument,
29
31
  type CreateFormMutationVariables,
30
32
  CreateKbArticleDocument,
31
33
  type CreateKbArticleMutationVariables,
32
34
  CreateKbCollectionDocument,
33
35
  type CreateKbCollectionMutationVariables,
36
+ CreateOrganizationDocument,
37
+ type CreateOrganizationMutationVariables,
34
38
  CreateTimeClockDocument,
35
39
  type CreateTimeClockMutationVariables,
36
40
  DeleteChannelDocument,
@@ -75,6 +79,8 @@ import {
75
79
  type UpdateEmploymentMutationVariables,
76
80
  UpdateEmploymentTermDocument,
77
81
  type UpdateEmploymentTermMutationVariables,
82
+ UpdateEmploymentVariationKindDocument,
83
+ type UpdateEmploymentVariationKindMutationVariables,
78
84
  UpdateEventDocument,
79
85
  type UpdateEventMutationVariables,
80
86
  UpdateFormDocument,
@@ -168,6 +174,19 @@ export async function createDeal(c: UiduClient, v: CreateDealMutationVariables)
168
174
  export async function updateDeal(c: UiduClient, v: UpdateDealMutationVariables) {
169
175
  return (await c.mutate(UpdateDealDocument, v)).updateDeal ?? null;
170
176
  }
177
+ /**
178
+ * Create an organization (company): `{ input: { attributes: { email,
179
+ * organizationAttributes: { name, … } } } }` — the CRM nests an organization's
180
+ * own fields under `attributes.organizationAttributes`, same as a person
181
+ * contact nests theirs under `attributes.userAttributes`. Returns the payload
182
+ * (with `errors`) or null.
183
+ */
184
+ export async function createOrganization(
185
+ c: UiduClient,
186
+ v: CreateOrganizationMutationVariables,
187
+ ) {
188
+ return (await c.mutate(CreateOrganizationDocument, v)).createOrganization ?? null;
189
+ }
171
190
 
172
191
  // --- People / HR (employees & employments) ---
173
192
  // An Employee is the HR record wrapping a workspace User (`userId`); an
@@ -269,6 +288,35 @@ export async function updateEmploymentTerm(
269
288
  return (await c.mutate(UpdateEmploymentTermDocument, v)).updateEmploymentTerm ?? null;
270
289
  }
271
290
 
291
+ /**
292
+ * Create an employment variation kind — a reusable reason for a contract
293
+ * change (`changesHours`, `changesPay`, `changesLevel`, …), picked by a
294
+ * contract variation's `employmentVariationKindId`. Returns the payload (with
295
+ * `errors`) or null. The new kind is at `employmentVariationKind.node`.
296
+ */
297
+ export async function createEmploymentVariationKind(
298
+ c: UiduClient,
299
+ v: CreateEmploymentVariationKindMutationVariables,
300
+ ) {
301
+ return (
302
+ (await c.mutate(CreateEmploymentVariationKindDocument, v)).createEmploymentVariationKind ??
303
+ null
304
+ );
305
+ }
306
+ /**
307
+ * Update an employment variation kind: `{ input: { id, attributes } }`.
308
+ * Returns the payload (with `errors`) or null.
309
+ */
310
+ export async function updateEmploymentVariationKind(
311
+ c: UiduClient,
312
+ v: UpdateEmploymentVariationKindMutationVariables,
313
+ ) {
314
+ return (
315
+ (await c.mutate(UpdateEmploymentVariationKindDocument, v)).updateEmploymentVariationKind ??
316
+ null
317
+ );
318
+ }
319
+
272
320
  // --- Time clocks (punches) ---
273
321
  /**
274
322
  * Record a time-clock punch (`beginsAt`, optional `finishesAt`, `resourceId`).
package/src/people.ts CHANGED
@@ -12,6 +12,9 @@ import {
12
12
  type ListEmployeesQueryVariables,
13
13
  ListEmploymentHistoryDocument,
14
14
  type ListEmploymentHistoryQueryVariables,
15
+ ListEmploymentVariationKindsDocument,
16
+ type ListEmploymentVariationKindsQuery,
17
+ type ListEmploymentVariationKindsQueryVariables,
15
18
  ListKindsDocument,
16
19
  type ListKindsQuery,
17
20
  type ListKindsQueryVariables,
@@ -44,6 +47,23 @@ export type Office = NonNullable<
44
47
  >[number]
45
48
  >['node']
46
49
  >;
50
+ /**
51
+ * A contract-variation reason (hours change, conversion to open-ended, a pay
52
+ * rise…) configured for the workspace — an employment's `varyAttributes` picks
53
+ * one by `employmentVariationKindId`.
54
+ */
55
+ export type EmploymentVariationKind = NonNullable<
56
+ NonNullable<
57
+ NonNullable<
58
+ NonNullable<
59
+ NonNullable<
60
+ ListEmploymentVariationKindsQuery['currentWorkspace']
61
+ >['employmentVariationKinds']
62
+ >['edges']
63
+ >[number]
64
+ >['node']
65
+ >;
66
+
47
67
  /** A `Kind` record — CCNLs (national collective labor contracts) are Kinds. */
48
68
  export type Kind = NonNullable<
49
69
  NonNullable<
@@ -127,6 +147,19 @@ export async function listRoles(
127
147
  return circles.filter((c) => c.kind === 'role');
128
148
  }
129
149
 
150
+ /**
151
+ * List the workspace's employment variation kinds — the reasons a contract
152
+ * can change (hours, pay, level, place, benefits…), each flagging which
153
+ * aspects it touches. Used for a contract variation's `employmentVariationKindId`.
154
+ */
155
+ export async function listEmploymentVariationKinds(
156
+ client: UiduClient,
157
+ variables: ListEmploymentVariationKindsQueryVariables = {},
158
+ ): Promise<EmploymentVariationKind[]> {
159
+ const result = await client.query(ListEmploymentVariationKindsDocument, variables);
160
+ return nodes(result.currentWorkspace?.employmentVariationKinds);
161
+ }
162
+
130
163
  /** List `Kind` records for the given polymorphic models. */
131
164
  export async function listKinds(
132
165
  client: UiduClient,
@@ -0,0 +1,17 @@
1
+ query GetOrganization($id: ID!) {
2
+ currentWorkspace {
3
+ organization(id: $id) {
4
+ id
5
+ name
6
+ email
7
+ avatar
8
+ avatarData
9
+ fiscalCode
10
+ vatCode
11
+ shortname
12
+ createdAt
13
+ updatedAt
14
+ fieldValuesByShortname
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,21 @@
1
+ query ListOrganizations($first: Int, $after: String, $params: SearchParams) {
2
+ currentWorkspace {
3
+ organizations(first: $first, after: $after, params: $params) {
4
+ pageInfo {
5
+ hasNextPage
6
+ endCursor
7
+ }
8
+ edges {
9
+ node {
10
+ id
11
+ name
12
+ email
13
+ avatar
14
+ fiscalCode
15
+ vatCode
16
+ createdAt
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,17 @@
1
+ mutation CreateOrganization($input: CreateOrganizationInput!) {
2
+ createOrganization(input: $input) {
3
+ organization {
4
+ id
5
+ name
6
+ email
7
+ fiscalCode
8
+ vatCode
9
+ createdAt
10
+ }
11
+ errors {
12
+ key
13
+ name
14
+ type
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,27 @@
1
+ mutation CreateEnrollment($input: CreateEnrollmentInput!) {
2
+ createEnrollment(input: $input) {
3
+ enrollment {
4
+ id
5
+ aasmState
6
+ }
7
+ errors {
8
+ key
9
+ name
10
+ type
11
+ }
12
+ }
13
+ }
14
+
15
+ mutation UpdateEnrollment($input: UpdateEnrollmentInput!) {
16
+ updateEnrollment(input: $input) {
17
+ enrollment {
18
+ id
19
+ aasmState
20
+ }
21
+ errors {
22
+ key
23
+ name
24
+ type
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,29 @@
1
+ mutation CreateEventInstance($input: CreateEventInstanceInput!) {
2
+ createEventInstance(input: $input) {
3
+ eventInstance {
4
+ id
5
+ beginsAt
6
+ finishesAt
7
+ }
8
+ errors {
9
+ key
10
+ name
11
+ type
12
+ }
13
+ }
14
+ }
15
+
16
+ mutation UpdateEventInstance($input: UpdateEventInstanceInput!) {
17
+ updateEventInstance(input: $input) {
18
+ eventInstance {
19
+ id
20
+ beginsAt
21
+ finishesAt
22
+ }
23
+ errors {
24
+ key
25
+ name
26
+ type
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,14 @@
1
+ mutation UpdateAttendance($input: UpdateAttendanceInput!) {
2
+ updateAttendance(input: $input) {
3
+ attendance {
4
+ id
5
+ rsvpStatus
6
+ checkedIn
7
+ }
8
+ errors {
9
+ key
10
+ name
11
+ type
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,29 @@
1
+ # `amount` is in cents of `currency`. `category` is the integer the workspace's
2
+ # expense categories are keyed on. `fieldValuesByShortname` carries the custom
3
+ # fields the workspace added to expenses: `{ shortname: value }`.
4
+ fragment ExpenseFields on Expense {
5
+ id
6
+ amount
7
+ currency
8
+ spentAt
9
+ category
10
+ paymentMethod
11
+ fieldValuesByShortname
12
+ createdAt
13
+ updatedAt
14
+ }
15
+
16
+ # The report is addressed to a `user` (the person it reimburses); `contact` is
17
+ # derived from it inside uidu and not asked for here.
18
+ fragment ExpenseReportFields on ExpenseReport {
19
+ id
20
+ name
21
+ paidAt
22
+ fieldValuesByShortname
23
+ createdAt
24
+ updatedAt
25
+ user {
26
+ id
27
+ name
28
+ }
29
+ }
@@ -0,0 +1,81 @@
1
+ mutation CreateExpenseReport($input: CreateExpenseReportInput!) {
2
+ createExpenseReport(input: $input) {
3
+ expenseReport {
4
+ node {
5
+ ...ExpenseReportFields
6
+ }
7
+ }
8
+ errors {
9
+ key
10
+ name
11
+ type
12
+ }
13
+ }
14
+ }
15
+
16
+ mutation UpdateExpenseReport($input: UpdateExpenseReportInput!) {
17
+ updateExpenseReport(input: $input) {
18
+ expenseReport {
19
+ ...ExpenseReportFields
20
+ }
21
+ errors {
22
+ key
23
+ name
24
+ type
25
+ }
26
+ }
27
+ }
28
+
29
+ mutation CreateExpense($input: CreateExpenseInput!) {
30
+ createExpense(input: $input) {
31
+ expense {
32
+ node {
33
+ ...ExpenseFields
34
+ }
35
+ }
36
+ errors {
37
+ key
38
+ name
39
+ type
40
+ }
41
+ }
42
+ }
43
+
44
+ mutation UpdateExpense($input: UpdateExpenseInput!) {
45
+ updateExpense(input: $input) {
46
+ expense {
47
+ ...ExpenseFields
48
+ }
49
+ errors {
50
+ key
51
+ name
52
+ type
53
+ }
54
+ }
55
+ }
56
+
57
+ mutation CreateAnalyticAccountAllocation(
58
+ $input: CreateAnalyticAccountAllocationInput!
59
+ ) {
60
+ createAnalyticAccountAllocation(input: $input) {
61
+ analyticAccountAllocation {
62
+ node {
63
+ id
64
+ amount
65
+ currency
66
+ kind
67
+ note
68
+ analyticAccount {
69
+ id
70
+ code
71
+ name
72
+ }
73
+ }
74
+ }
75
+ errors {
76
+ key
77
+ name
78
+ type
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,14 @@
1
+ query GetExpenseReport($id: ID!) {
2
+ currentWorkspace {
3
+ expenseReport(id: $id) {
4
+ ...ExpenseReportFields
5
+ expenses {
6
+ edges {
7
+ node {
8
+ ...ExpenseFields
9
+ }
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,20 @@
1
+ # The analytic accounts (commesse, cost centres) an expense can be allocated to.
2
+ query ListAnalyticAccounts($first: Int, $after: String, $parentId: ID) {
3
+ currentWorkspace {
4
+ analyticAccounts(first: $first, after: $after, parentId: $parentId) {
5
+ pageInfo {
6
+ hasNextPage
7
+ endCursor
8
+ }
9
+ edges {
10
+ node {
11
+ id
12
+ code
13
+ name
14
+ status
15
+ currency
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,22 @@
1
+ query ListExpenseReports($first: Int, $after: String) {
2
+ currentWorkspace {
3
+ expenseReports(first: $first, after: $after) {
4
+ pageInfo {
5
+ hasNextPage
6
+ endCursor
7
+ }
8
+ edges {
9
+ node {
10
+ ...ExpenseReportFields
11
+ expenses {
12
+ edges {
13
+ node {
14
+ ...ExpenseFields
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,51 @@
1
+ mutation CreateEmploymentVariationKind($input: CreateEmploymentVariationKindInput!) {
2
+ createEmploymentVariationKind(input: $input) {
3
+ employmentVariationKind {
4
+ node {
5
+ id
6
+ name
7
+ description
8
+ shortname
9
+ color
10
+ position
11
+ changesContract
12
+ changesHours
13
+ changesLevel
14
+ changesPlace
15
+ changesPay
16
+ changesBenefits
17
+ requiresUnilav
18
+ }
19
+ }
20
+ errors {
21
+ key
22
+ name
23
+ type
24
+ }
25
+ }
26
+ }
27
+
28
+ mutation UpdateEmploymentVariationKind($input: UpdateEmploymentVariationKindInput!) {
29
+ updateEmploymentVariationKind(input: $input) {
30
+ employmentVariationKind {
31
+ id
32
+ name
33
+ description
34
+ shortname
35
+ color
36
+ position
37
+ changesContract
38
+ changesHours
39
+ changesLevel
40
+ changesPlace
41
+ changesPay
42
+ changesBenefits
43
+ requiresUnilav
44
+ }
45
+ errors {
46
+ key
47
+ name
48
+ type
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,23 @@
1
+ query ListEmploymentVariationKinds($first: Int, $after: String) {
2
+ currentWorkspace {
3
+ employmentVariationKinds(first: $first, after: $after) {
4
+ edges {
5
+ node {
6
+ id
7
+ name
8
+ description
9
+ shortname
10
+ color
11
+ position
12
+ changesContract
13
+ changesHours
14
+ changesLevel
15
+ changesPlace
16
+ changesPay
17
+ changesBenefits
18
+ requiresUnilav
19
+ }
20
+ }
21
+ }
22
+ }
23
+ }