@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/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @uidu/client
2
2
 
3
+ ## 3.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 461a151: Expense reports. `@uidu/client` adds `listExpenseReports` and
8
+ `getExpenseReport` (each report with its person — `user { id name }` —,
9
+ `paidAt`, custom fields as `fieldValuesByShortname`, and its `expenses` as a
10
+ flat array), `createExpenseReport` / `updateExpenseReport` (addressed by
11
+ `userId`) and `createExpense` / `updateExpense`, both taking custom fields as
12
+ `fieldValues`, a map of the Field's GlobalID to the value. `listAnalyticAccounts`
13
+ and `allocateExpense` book an expense on an analytic account (commessa). Reads
14
+ and writes need an account Bearer token.
15
+ - b26a635: CRM organizations (companies). `@uidu/client` adds `getOrganization`,
16
+ `listOrganizations` and `createOrganization` — an organization is the
17
+ contactable a `Contact` wraps, so its own fields (`name`, `vatCode`,
18
+ `fiscalCode`…) nest under `attributes.organizationAttributes`, same shape as a
19
+ person contact's `userAttributes`. The CLI gets an `organizations` resource
20
+ (`list` / `get` / `create` — no `update`/`delete` yet, the backend doesn't
21
+ flag them as tool keys).
22
+ - a65aac7: Employment variation kinds — the reusable reasons a contract can change
23
+ (hours, pay, level, place, contract, benefits…), picked by a variation's
24
+ `employmentVariationKindId`. `@uidu/client` adds
25
+ `listEmploymentVariationKinds`, `createEmploymentVariationKind` and
26
+ `updateEmploymentVariationKind`. The CLI gets an `employment-variation-kinds`
27
+ resource (`list` / `create` / `update`).
28
+
29
+ ## 3.17.0
30
+
31
+ ### Minor Changes
32
+
33
+ - e4ffc15: Add `updateAttendance` to `@uidu/client` — change an attendance's `rsvpStatus`,
34
+ check it in, or edit its other attributes; returns the payload as-is,
35
+ `{ errors, attendance }`. Adds `update` to the `attendances` resource
36
+ (`uidu attendances update <id>`) in `@uidu/cli`. Demoed with a "Cancel RSVP"
37
+ action on the event RSVP form in `apps/demo`.
38
+ - 20e1713: Add `createEnrollment` / `updateEnrollment` to `@uidu/client` — enroll a
39
+ contact in a course, or update an enrollment's `aasmState`, `outcome` or
40
+ `certificateStatus`; both return the payload as-is, `{ errors, enrollment }`.
41
+ Adds an `enrollments` resource (`list`, `get`, `create`, `update`) to
42
+ `@uidu/cli`, pairing the existing `getEnrollment` / `listEnrollments` reads
43
+ with their writes. Demoed on a new "Enrollments" admin page in `apps/demo`.
44
+ - 440536f: Add `createEventInstance` / `updateEventInstance` to `@uidu/client` — add a new
45
+ occurrence (date/time) to a recurring event, or update one's schedule or
46
+ venue; both return the payload as-is, `{ errors, eventInstance }`. Adds an
47
+ `event-instances` resource (`create`, `update`) to `@uidu/cli`. Demoed on a new
48
+ "Event instances" admin page in `apps/demo`.
49
+
3
50
  ## 3.16.0
4
51
 
5
52
  ### Minor Changes
@@ -1,7 +1,9 @@
1
1
  import type { UiduClient } from "./client.js";
2
- import { type GetContactQuery, type GetContactQueryVariables, type GetDealQuery, type GetDealQueryVariables, type ListDealsQueryVariables } from "./generated/index.js";
2
+ import { type GetContactQuery, type GetContactQueryVariables, type GetDealQuery, type GetDealQueryVariables, type GetOrganizationQuery, type GetOrganizationQueryVariables, type ListDealsQueryVariables, type ListOrganizationsQueryVariables } from "./generated/index.js";
3
3
  export type Contact = NonNullable<NonNullable<GetContactQuery['currentWorkspace']>['contact']>;
4
4
  export type Deal = NonNullable<NonNullable<GetDealQuery['currentWorkspace']>['deal']>;
5
+ /** A CRM organization (company) — the contactable a `Contact` wraps. */
6
+ export type Organization = NonNullable<NonNullable<GetOrganizationQuery['currentWorkspace']>['organization']>;
5
7
  /**
6
8
  * One contact with its address and custom fields (`fieldValuesByShortname`),
7
9
  * or null; a public token sees none.
@@ -50,3 +52,22 @@ export declare function listDeals(client: UiduClient, variables?: ListDealsQuery
50
52
  name?: string | null;
51
53
  } | null;
52
54
  }[]>;
55
+ /**
56
+ * One organization (company) with its fiscal/VAT codes and custom fields, or
57
+ * null.
58
+ */
59
+ export declare function getOrganization(client: UiduClient, variables: GetOrganizationQueryVariables): Promise<Organization | null>;
60
+ /**
61
+ * The workspace's organizations as a flat array, optionally filtered with
62
+ * search `params`; page with `first`/`after`.
63
+ */
64
+ export declare function listOrganizations(client: UiduClient, variables?: ListOrganizationsQueryVariables): Promise<{
65
+ __typename?: "Organization";
66
+ id: string;
67
+ name?: string | null;
68
+ email?: string | null;
69
+ avatar?: string | null;
70
+ fiscalCode?: string | null;
71
+ vatCode?: string | null;
72
+ createdAt: any;
73
+ }[]>;
@@ -1,5 +1,5 @@
1
1
  import type { UiduClient } from "./client.js";
2
- import { type GetCourseQuery, type GetCourseQueryVariables, type GetEnrollmentQuery, type GetEnrollmentQueryVariables, type GetLectureQuery, type GetLectureQueryVariables, type ListCoursesQueryVariables, type ListEnrollmentsQueryVariables, type ListLecturesQueryVariables } from "./generated/index.js";
2
+ import { type CreateEnrollmentMutationVariables, type GetCourseQuery, type GetCourseQueryVariables, type GetEnrollmentQuery, type GetEnrollmentQueryVariables, type GetLectureQuery, type GetLectureQueryVariables, type ListCoursesQueryVariables, type ListEnrollmentsQueryVariables, type ListLecturesQueryVariables, type UpdateEnrollmentMutationVariables } from "./generated/index.js";
3
3
  export type Course = NonNullable<NonNullable<GetCourseQuery['currentWorkspace']>['course']>;
4
4
  export type Enrollment = NonNullable<NonNullable<GetEnrollmentQuery['currentWorkspace']>['enrollment']>;
5
5
  export type Lecture = NonNullable<NonNullable<GetLectureQuery['currentWorkspace']>['lecture']>;
@@ -59,6 +59,42 @@ export declare function listEnrollments(client: UiduClient, variables?: ListEnro
59
59
  name?: string | null;
60
60
  } | null;
61
61
  }[]>;
62
+ /**
63
+ * Enroll a contact in a course; returns the payload as-is,
64
+ * `{ errors, enrollment }`, validation failures included.
65
+ */
66
+ export declare function createEnrollment(client: UiduClient, variables: CreateEnrollmentMutationVariables): Promise<{
67
+ __typename?: "CreateEnrollmentPayload";
68
+ enrollment?: {
69
+ __typename?: "Enrollment";
70
+ id: string;
71
+ aasmState?: string | null;
72
+ } | null;
73
+ errors: Array<{
74
+ __typename?: "Error";
75
+ key: string;
76
+ name: string;
77
+ type: string;
78
+ }>;
79
+ } | null>;
80
+ /**
81
+ * Update an enrollment — its `aasmState`, `outcome`, `certificateStatus` or
82
+ * other attributes; returns the payload as-is, `{ errors, enrollment }`.
83
+ */
84
+ export declare function updateEnrollment(client: UiduClient, variables: UpdateEnrollmentMutationVariables): Promise<{
85
+ __typename?: "UpdateEnrollmentPayload";
86
+ enrollment?: {
87
+ __typename?: "Enrollment";
88
+ id: string;
89
+ aasmState?: string | null;
90
+ } | null;
91
+ errors: Array<{
92
+ __typename?: "Error";
93
+ key: string;
94
+ name: string;
95
+ type: string;
96
+ }>;
97
+ } | null>;
62
98
  /**
63
99
  * One lecture with its `body`, its course and its `nextLecture` /
64
100
  * `previousLecture` for navigation, or null.
@@ -1,5 +1,5 @@
1
1
  import type { UiduClient } from "./client.js";
2
- import { type CreateAttendanceMutationVariables, type CreateEventMutationVariables, type GetEventQuery, type GetEventQueryVariables, type ListEventsQueryVariables } from "./generated/index.js";
2
+ import { type CreateAttendanceMutationVariables, type CreateEventMutationVariables, type CreateEventInstanceMutationVariables, type GetEventQuery, type GetEventQueryVariables, type ListEventsQueryVariables, type UpdateAttendanceMutationVariables, type UpdateEventInstanceMutationVariables } from "./generated/index.js";
3
3
  export type Event = NonNullable<NonNullable<GetEventQuery['currentWorkspace']>['event']>;
4
4
  /**
5
5
  * One event with its primary address, its next or current `instance` and all
@@ -58,6 +58,25 @@ export declare function createAttendance(client: UiduClient, variables: CreateAt
58
58
  } | null;
59
59
  } | null;
60
60
  } | null>;
61
+ /**
62
+ * Update an attendance — change its `rsvpStatus`, check it in, or edit its
63
+ * other attributes; returns the payload as-is, `{ errors, attendance }`.
64
+ */
65
+ export declare function updateAttendance(client: UiduClient, variables: UpdateAttendanceMutationVariables): Promise<{
66
+ __typename?: "UpdateAttendancePayload";
67
+ attendance?: {
68
+ __typename?: "Attendance";
69
+ id: string;
70
+ rsvpStatus?: string | null;
71
+ checkedIn?: boolean | null;
72
+ } | null;
73
+ errors: Array<{
74
+ __typename?: "Error";
75
+ key: string;
76
+ name: string;
77
+ type: string;
78
+ }>;
79
+ } | null>;
61
80
  /**
62
81
  * Create an event; returns the payload as-is, `{ errors, event }`, validation
63
82
  * failures included.
@@ -76,3 +95,41 @@ export declare function createEvent(client: UiduClient, variables: CreateEventMu
76
95
  type: string;
77
96
  }>;
78
97
  } | null>;
98
+ /**
99
+ * Create a new occurrence (date/time) of a recurring event; returns the
100
+ * payload as-is, `{ errors, eventInstance }`.
101
+ */
102
+ export declare function createEventInstance(client: UiduClient, variables: CreateEventInstanceMutationVariables): Promise<{
103
+ __typename?: "CreateEventInstancePayload";
104
+ eventInstance?: {
105
+ __typename?: "EventInstance";
106
+ id: string;
107
+ beginsAt?: any | null;
108
+ finishesAt?: any | null;
109
+ } | null;
110
+ errors: Array<{
111
+ __typename?: "Error";
112
+ key: string;
113
+ name: string;
114
+ type: string;
115
+ }>;
116
+ } | null>;
117
+ /**
118
+ * Update an event instance's schedule or venue; returns the payload as-is,
119
+ * `{ errors, eventInstance }`.
120
+ */
121
+ export declare function updateEventInstance(client: UiduClient, variables: UpdateEventInstanceMutationVariables): Promise<{
122
+ __typename?: "UpdateEventInstancePayload";
123
+ eventInstance?: {
124
+ __typename?: "EventInstance";
125
+ id: string;
126
+ beginsAt?: any | null;
127
+ finishesAt?: any | null;
128
+ } | null;
129
+ errors: Array<{
130
+ __typename?: "Error";
131
+ key: string;
132
+ name: string;
133
+ type: string;
134
+ }>;
135
+ } | null>;
@@ -0,0 +1,169 @@
1
+ import type { UiduClient } from "./client.js";
2
+ import { type CreateAnalyticAccountAllocationMutationVariables, type CreateExpenseMutationVariables, type CreateExpenseReportMutationVariables, type GetExpenseReportQuery, type GetExpenseReportQueryVariables, type ListAnalyticAccountsQuery, type ListAnalyticAccountsQueryVariables, type ListExpenseReportsQueryVariables, type UpdateExpenseMutationVariables, type UpdateExpenseReportMutationVariables } from "./generated/index.js";
3
+ type ExpenseReportRecord = NonNullable<NonNullable<GetExpenseReportQuery['currentWorkspace']>['expenseReport']>;
4
+ export type ExpenseReport = Omit<ExpenseReportRecord, 'expenses'> & {
5
+ expenses: Expense[];
6
+ };
7
+ export type Expense = NonNullable<NonNullable<NonNullable<NonNullable<ExpenseReportRecord['expenses']>['edges']>[number]>['node']>;
8
+ export type AnalyticAccount = NonNullable<NonNullable<NonNullable<NonNullable<ListAnalyticAccountsQuery['currentWorkspace']>['analyticAccounts']>['edges']>[number]>['node'];
9
+ /**
10
+ * The workspace's expense reports, newest first, each with its `expenses` as a
11
+ * flat array; page with `first`/`after`.
12
+ */
13
+ export declare function listExpenseReports(client: UiduClient, variables?: ListExpenseReportsQueryVariables): Promise<ExpenseReport[]>;
14
+ /** One expense report with its `expenses` as a flat array, or null. */
15
+ export declare function getExpenseReport(client: UiduClient, variables: GetExpenseReportQueryVariables): Promise<ExpenseReport | null>;
16
+ /**
17
+ * Create an expense report for a person: `{ input: { attributes: { userId,
18
+ * name, fieldValues } } }`. Returns the payload (with `errors`) or null.
19
+ */
20
+ export declare function createExpenseReport(client: UiduClient, variables: CreateExpenseReportMutationVariables): Promise<{
21
+ __typename?: "CreateExpenseReportPayload";
22
+ expenseReport?: {
23
+ __typename?: "ExpenseReportEdge";
24
+ node?: {
25
+ __typename?: "ExpenseReport";
26
+ id: string;
27
+ name?: string | null;
28
+ paidAt?: any | null;
29
+ fieldValuesByShortname?: any | null;
30
+ createdAt: any;
31
+ updatedAt: any;
32
+ user?: {
33
+ __typename?: "User";
34
+ id: string;
35
+ name?: string | null;
36
+ } | null;
37
+ } | null;
38
+ } | null;
39
+ errors: Array<{
40
+ __typename?: "Error";
41
+ key: string;
42
+ name: string;
43
+ type: string;
44
+ }>;
45
+ } | null>;
46
+ /**
47
+ * Update an expense report — rename it, set `paidAt`, change its custom
48
+ * `fieldValues`. Returns the payload (with `errors`) or null.
49
+ */
50
+ export declare function updateExpenseReport(client: UiduClient, variables: UpdateExpenseReportMutationVariables): Promise<{
51
+ __typename?: "UpdateExpenseReportPayload";
52
+ expenseReport?: {
53
+ __typename?: "ExpenseReport";
54
+ id: string;
55
+ name?: string | null;
56
+ paidAt?: any | null;
57
+ fieldValuesByShortname?: any | null;
58
+ createdAt: any;
59
+ updatedAt: any;
60
+ user?: {
61
+ __typename?: "User";
62
+ id: string;
63
+ name?: string | null;
64
+ } | null;
65
+ } | null;
66
+ errors: Array<{
67
+ __typename?: "Error";
68
+ key: string;
69
+ name: string;
70
+ type: string;
71
+ }>;
72
+ } | null>;
73
+ /**
74
+ * Add an expense to a report: `{ input: { attributes: { expenseReportId,
75
+ * amount, currency, spentAt, category, paymentMethod, fieldValues } } }`, with
76
+ * `amount` in cents. Returns the payload (with `errors`) or null.
77
+ */
78
+ export declare function createExpense(client: UiduClient, variables: CreateExpenseMutationVariables): Promise<{
79
+ __typename?: "CreateExpensePayload";
80
+ expense?: {
81
+ __typename?: "ExpenseEdge";
82
+ node?: {
83
+ __typename?: "Expense";
84
+ id: string;
85
+ amount?: any | null;
86
+ currency?: string | null;
87
+ spentAt?: any | null;
88
+ category?: number | null;
89
+ paymentMethod?: string | null;
90
+ fieldValuesByShortname?: any | null;
91
+ createdAt: any;
92
+ updatedAt: any;
93
+ } | null;
94
+ } | null;
95
+ errors: Array<{
96
+ __typename?: "Error";
97
+ key: string;
98
+ name: string;
99
+ type: string;
100
+ }>;
101
+ } | null>;
102
+ /** Update an expense. Returns the payload (with `errors`) or null. */
103
+ export declare function updateExpense(client: UiduClient, variables: UpdateExpenseMutationVariables): Promise<{
104
+ __typename?: "UpdateExpensePayload";
105
+ expense?: {
106
+ __typename?: "Expense";
107
+ id: string;
108
+ amount?: any | null;
109
+ currency?: string | null;
110
+ spentAt?: any | null;
111
+ category?: number | null;
112
+ paymentMethod?: string | null;
113
+ fieldValuesByShortname?: any | null;
114
+ createdAt: any;
115
+ updatedAt: any;
116
+ } | null;
117
+ errors: Array<{
118
+ __typename?: "Error";
119
+ key: string;
120
+ name: string;
121
+ type: string;
122
+ }>;
123
+ } | null>;
124
+ /**
125
+ * The workspace's analytic accounts (commesse, cost centres) as a flat array —
126
+ * what `allocateExpense` books an expense on. `parentId` narrows to the
127
+ * children of one account; page with `first`/`after`.
128
+ */
129
+ export declare function listAnalyticAccounts(client: UiduClient, variables?: ListAnalyticAccountsQueryVariables): Promise<{
130
+ __typename?: "AnalyticAccount";
131
+ id: string;
132
+ code: string;
133
+ name: string;
134
+ status: import("./generated/index.js").AnalyticAccountStatusEnum;
135
+ currency: string;
136
+ }[]>;
137
+ /**
138
+ * Book an expense (or part of it) on an analytic account: `{ input: {
139
+ * attributes: { allocatableId: expense.id, analyticAccountId, amount } } }`,
140
+ * `amount` in cents, `currency` defaulting to the expense's. Call it once per
141
+ * account to split an expense. Returns the payload (with `errors`) or null.
142
+ */
143
+ export declare function allocateExpense(client: UiduClient, variables: CreateAnalyticAccountAllocationMutationVariables): Promise<{
144
+ __typename?: "CreateAnalyticAccountAllocationPayload";
145
+ analyticAccountAllocation?: {
146
+ __typename?: "AnalyticAccountAllocationEdge";
147
+ node?: {
148
+ __typename?: "AnalyticAccountAllocation";
149
+ id: string;
150
+ amount: number;
151
+ currency: string;
152
+ kind: import("./generated/index.js").AnalyticAccountAllocationKindEnum;
153
+ note?: string | null;
154
+ analyticAccount: {
155
+ __typename?: "AnalyticAccount";
156
+ id: string;
157
+ code: string;
158
+ name: string;
159
+ };
160
+ } | null;
161
+ } | null;
162
+ errors: Array<{
163
+ __typename?: "Error";
164
+ key: string;
165
+ name: string;
166
+ type: string;
167
+ }>;
168
+ } | null>;
169
+ export {};