@uidu/client 3.0.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 (74) hide show
  1. package/.env.example +9 -0
  2. package/CHANGELOG.md +7 -0
  3. package/codegen.ts +42 -0
  4. package/dist/uidu-client.cjs.d.ts +2 -0
  5. package/dist/uidu-client.cjs.js +16 -0
  6. package/package.json +45 -0
  7. package/src/bookings.ts +77 -0
  8. package/src/calls.ts +29 -0
  9. package/src/campaigns.ts +39 -0
  10. package/src/client.ts +60 -0
  11. package/src/cms.ts +46 -0
  12. package/src/contacts.ts +49 -0
  13. package/src/courses.ts +77 -0
  14. package/src/donations.ts +39 -0
  15. package/src/events.ts +39 -0
  16. package/src/forms.ts +49 -0
  17. package/src/generated/index.ts +47209 -0
  18. package/src/help-center.ts +18 -0
  19. package/src/index.ts +106 -0
  20. package/src/kb.ts +53 -0
  21. package/src/people.ts +43 -0
  22. package/src/queries/bookings/GetBooking.graphql +26 -0
  23. package/src/queries/bookings/GetCalendar.graphql +13 -0
  24. package/src/queries/bookings/GetCalendarEvent.graphql +29 -0
  25. package/src/queries/bookings/ListBookings.graphql +30 -0
  26. package/src/queries/bookings/ListCalendarEvents.graphql +45 -0
  27. package/src/queries/bookings/ListCalendars.graphql +19 -0
  28. package/src/queries/calls/GetCall.graphql +31 -0
  29. package/src/queries/calls/ListCalls.graphql +32 -0
  30. package/src/queries/campaigns/GetCampaign.graphql +19 -0
  31. package/src/queries/campaigns/ListCampaigns.graphql +27 -0
  32. package/src/queries/campaigns/ListEmailCampaigns.graphql +34 -0
  33. package/src/queries/cms/GetPage.graphql +80 -0
  34. package/src/queries/cms/GetTemplate.graphql +41 -0
  35. package/src/queries/cms/ListPages.graphql +20 -0
  36. package/src/queries/contacts/GetContact.graphql +15 -0
  37. package/src/queries/contacts/GetDeal.graphql +30 -0
  38. package/src/queries/contacts/ListContacts.graphql +12 -0
  39. package/src/queries/contacts/ListDeals.graphql +30 -0
  40. package/src/queries/courses/GetCourse.graphql +22 -0
  41. package/src/queries/courses/GetEnrollment.graphql +25 -0
  42. package/src/queries/courses/GetLecture.graphql +36 -0
  43. package/src/queries/courses/ListCourses.graphql +27 -0
  44. package/src/queries/courses/ListEnrollments.graphql +31 -0
  45. package/src/queries/courses/ListLectures.graphql +45 -0
  46. package/src/queries/donations/CreateDonation.graphql +18 -0
  47. package/src/queries/donations/GetDonationCampaign.graphql +28 -0
  48. package/src/queries/donations/ListDonationCampaigns.graphql +24 -0
  49. package/src/queries/events/CreateAttendance.graphql +16 -0
  50. package/src/queries/events/GetEvent.graphql +43 -0
  51. package/src/queries/events/ListEvents.graphql +32 -0
  52. package/src/queries/forms/CreateFormResponse.graphql +12 -0
  53. package/src/queries/forms/FormFields.graphql +35 -0
  54. package/src/queries/forms/FormResponseFields.graphql +15 -0
  55. package/src/queries/forms/GetForm.graphql +7 -0
  56. package/src/queries/forms/ListForms.graphql +20 -0
  57. package/src/queries/forms/UpdateFormResponse.graphql +12 -0
  58. package/src/queries/help-center/GetChannel.graphql +45 -0
  59. package/src/queries/kb/GetKbArticle.graphql +17 -0
  60. package/src/queries/kb/GetKbCollection.graphql +28 -0
  61. package/src/queries/kb/ListKbArticles.graphql +29 -0
  62. package/src/queries/kb/ListKbCollections.graphql +26 -0
  63. package/src/queries/people/GetEmployee.graphql +47 -0
  64. package/src/queries/people/ListEmployees.graphql +30 -0
  65. package/src/queries/search/Search.graphql +29 -0
  66. package/src/queries/stories/GetStory.graphql +15 -0
  67. package/src/queries/stories/ListStories.graphql +21 -0
  68. package/src/queries/system/CurrentUser.graphql +6 -0
  69. package/src/search.ts +18 -0
  70. package/src/stories.ts +29 -0
  71. package/src/types.ts +28 -0
  72. package/src/utils/paginate.ts +64 -0
  73. package/src/utils/relay.ts +8 -0
  74. package/tsconfig.json +8 -0
@@ -0,0 +1,18 @@
1
+ import type { UiduClient } from './client';
2
+ import {
3
+ GetChannelDocument,
4
+ type GetChannelQuery,
5
+ type GetChannelQueryVariables,
6
+ } from './generated';
7
+
8
+ export type Channel = NonNullable<
9
+ NonNullable<GetChannelQuery['currentWorkspace']>['channel']
10
+ >;
11
+
12
+ export async function getChannel(
13
+ client: UiduClient,
14
+ variables: GetChannelQueryVariables,
15
+ ): Promise<Channel | null> {
16
+ const result = await client.query(GetChannelDocument, variables);
17
+ return result.currentWorkspace?.channel ?? null;
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,106 @@
1
+ export { UiduClient, createClient } from './client';
2
+ export { UiduError } from './types';
3
+ export type { UiduClientConfig, UiduErrorOptions } from './types';
4
+
5
+ export { paginate } from './utils/paginate';
6
+ export type { PaginateOptions } from './utils/paginate';
7
+
8
+ export {
9
+ ListBookingsDocument,
10
+ ListCalendarsDocument,
11
+ ListCalendarEventsDocument,
12
+ ListCallsDocument,
13
+ ListCampaignsDocument,
14
+ ListEmailCampaignsDocument,
15
+ ListCoursesDocument,
16
+ ListDealsDocument,
17
+ ListDonationCampaignsDocument,
18
+ ListEmployeesDocument,
19
+ ListEnrollmentsDocument,
20
+ ListEventsDocument,
21
+ ListFormsDocument,
22
+ ListKbArticlesDocument,
23
+ ListKbCollectionsDocument,
24
+ ListLecturesDocument,
25
+ ListPagesDocument,
26
+ ListStoriesDocument,
27
+ } from './generated';
28
+
29
+ export { getPage, listPages, getTemplate } from './cms';
30
+ export type { Page, Template } from './cms';
31
+
32
+ export {
33
+ getForm,
34
+ listForms,
35
+ createFormResponse,
36
+ updateFormResponse,
37
+ } from './forms';
38
+ export type { Form } from './forms';
39
+
40
+ export { getChannel } from './help-center';
41
+ export type { Channel } from './help-center';
42
+
43
+ export { search } from './search';
44
+ export type { SearchResult } from './search';
45
+
46
+ export { getEvent, listEvents, createAttendance } from './events';
47
+ export type { Event } from './events';
48
+
49
+ export { getCall, listCalls } from './calls';
50
+ export type { Call } from './calls';
51
+
52
+ export {
53
+ getDonationCampaign,
54
+ listDonationCampaigns,
55
+ createDonation,
56
+ } from './donations';
57
+ export type { DonationCampaign } from './donations';
58
+
59
+ export { getStory, listStories } from './stories';
60
+ export type { Story } from './stories';
61
+
62
+ export { listEmployees, getEmployee, weekStartFor } from './people';
63
+ export type { Employee } from './people';
64
+
65
+ export {
66
+ getBooking,
67
+ listBookings,
68
+ getCalendar,
69
+ listCalendars,
70
+ getCalendarEvent,
71
+ listCalendarEvents,
72
+ } from './bookings';
73
+ export type { Booking, Calendar, CalendarEvent } from './bookings';
74
+
75
+ export {
76
+ getCourse,
77
+ listCourses,
78
+ getEnrollment,
79
+ listEnrollments,
80
+ getLecture,
81
+ listLectures,
82
+ } from './courses';
83
+ export type { Course, Enrollment, Lecture } from './courses';
84
+
85
+ export {
86
+ getCampaign,
87
+ listCampaigns,
88
+ listEmailCampaigns,
89
+ } from './campaigns';
90
+ export type { Campaign } from './campaigns';
91
+
92
+ export {
93
+ getContact,
94
+ listContacts,
95
+ getDeal,
96
+ listDeals,
97
+ } from './contacts';
98
+ export type { Contact, Deal } from './contacts';
99
+
100
+ export {
101
+ getKbArticle,
102
+ listKbArticles,
103
+ getKbCollection,
104
+ listKbCollections,
105
+ } from './kb';
106
+ export type { KbArticle, KbCollection } from './kb';
package/src/kb.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { UiduClient } from './client';
2
+ import {
3
+ GetKbArticleDocument,
4
+ type GetKbArticleQuery,
5
+ type GetKbArticleQueryVariables,
6
+ GetKbCollectionDocument,
7
+ type GetKbCollectionQuery,
8
+ type GetKbCollectionQueryVariables,
9
+ ListKbArticlesDocument,
10
+ type ListKbArticlesQueryVariables,
11
+ ListKbCollectionsDocument,
12
+ type ListKbCollectionsQueryVariables,
13
+ } from './generated';
14
+ import { nodes } from './utils/relay';
15
+
16
+ export type KbArticle = NonNullable<
17
+ NonNullable<GetKbArticleQuery['currentWorkspace']>['kbArticle']
18
+ >;
19
+ export type KbCollection = NonNullable<
20
+ NonNullable<GetKbCollectionQuery['currentWorkspace']>['kbCollection']
21
+ >;
22
+
23
+ export async function getKbArticle(
24
+ client: UiduClient,
25
+ variables: GetKbArticleQueryVariables,
26
+ ): Promise<KbArticle | null> {
27
+ const result = await client.query(GetKbArticleDocument, variables);
28
+ return result.currentWorkspace?.kbArticle ?? null;
29
+ }
30
+
31
+ export async function listKbArticles(
32
+ client: UiduClient,
33
+ variables: ListKbArticlesQueryVariables = {},
34
+ ) {
35
+ const result = await client.query(ListKbArticlesDocument, variables);
36
+ return nodes(result.currentWorkspace?.kbArticles);
37
+ }
38
+
39
+ export async function getKbCollection(
40
+ client: UiduClient,
41
+ variables: GetKbCollectionQueryVariables,
42
+ ): Promise<KbCollection | null> {
43
+ const result = await client.query(GetKbCollectionDocument, variables);
44
+ return result.currentWorkspace?.kbCollection ?? null;
45
+ }
46
+
47
+ export async function listKbCollections(
48
+ client: UiduClient,
49
+ variables: ListKbCollectionsQueryVariables = {},
50
+ ) {
51
+ const result = await client.query(ListKbCollectionsDocument, variables);
52
+ return nodes(result.currentWorkspace?.kbCollections);
53
+ }
package/src/people.ts ADDED
@@ -0,0 +1,43 @@
1
+ import type { UiduClient } from './client';
2
+ import {
3
+ GetEmployeeDocument,
4
+ type GetEmployeeQuery,
5
+ type GetEmployeeQueryVariables,
6
+ ListEmployeesDocument,
7
+ type ListEmployeesQueryVariables,
8
+ } from './generated';
9
+ import { nodes } from './utils/relay';
10
+
11
+ export type Employee = NonNullable<
12
+ NonNullable<GetEmployeeQuery['currentWorkspace']>['employee']
13
+ >;
14
+
15
+ export async function listEmployees(
16
+ client: UiduClient,
17
+ variables: ListEmployeesQueryVariables = {},
18
+ ) {
19
+ const result = await client.query(ListEmployeesDocument, variables);
20
+ return nodes(result.currentWorkspace?.employees);
21
+ }
22
+
23
+ export async function getEmployee(
24
+ client: UiduClient,
25
+ variables: GetEmployeeQueryVariables,
26
+ ): Promise<Employee | null> {
27
+ const result = await client.query(GetEmployeeDocument, variables);
28
+ return result.currentWorkspace?.employee ?? null;
29
+ }
30
+
31
+ /**
32
+ * Compute the Monday of the week containing `date` as an ISO8601 date string.
33
+ * Useful for the `weekStartingAt` argument required by `getEmployee` (and any
34
+ * other weekly-aggregated employee fields).
35
+ */
36
+ export function weekStartFor(date: Date = new Date()): string {
37
+ const d = new Date(date);
38
+ d.setUTCHours(0, 0, 0, 0);
39
+ const day = d.getUTCDay(); // 0 = Sunday, 1 = Monday, …
40
+ const diff = (day + 6) % 7; // days since Monday
41
+ d.setUTCDate(d.getUTCDate() - diff);
42
+ return d.toISOString().slice(0, 10);
43
+ }
@@ -0,0 +1,26 @@
1
+ query GetBooking($id: ID!) {
2
+ currentWorkspace {
3
+ booking(id: $id) {
4
+ id
5
+ kind
6
+ status
7
+ number
8
+ currency
9
+ itemsCount
10
+ itemsTotal
11
+ paymentIntentId
12
+ createdAt
13
+ updatedAt
14
+ paidAt
15
+ refundedAt
16
+ expiredAt
17
+ willExpireAt
18
+ fieldValuesByShortname
19
+ contact {
20
+ id
21
+ name
22
+ email
23
+ }
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,13 @@
1
+ query GetCalendar($id: ID!) {
2
+ currentWorkspace {
3
+ calendar(id: $id) {
4
+ id
5
+ name
6
+ description
7
+ color
8
+ timeZone
9
+ createdAt
10
+ updatedAt
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,29 @@
1
+ query GetCalendarEvent($id: ID!) {
2
+ currentWorkspace {
3
+ calendarEvent(id: $id) {
4
+ id
5
+ name
6
+ body
7
+ startTime
8
+ endTime
9
+ allDay
10
+ timeZone
11
+ url
12
+ createdAt
13
+ updatedAt
14
+ calendar {
15
+ id
16
+ name
17
+ color
18
+ timeZone
19
+ }
20
+ primaryAddress {
21
+ id
22
+ formattedAddress
23
+ name
24
+ city
25
+ countryCode
26
+ }
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,30 @@
1
+ query ListBookings($first: Int, $after: String, $before: String, $last: Int) {
2
+ currentWorkspace {
3
+ bookings(first: $first, after: $after, before: $before, last: $last) {
4
+ pageInfo {
5
+ hasNextPage
6
+ endCursor
7
+ }
8
+ edges {
9
+ node {
10
+ id
11
+ kind
12
+ status
13
+ number
14
+ currency
15
+ itemsCount
16
+ itemsTotal
17
+ createdAt
18
+ paidAt
19
+ expiredAt
20
+ willExpireAt
21
+ contact {
22
+ id
23
+ name
24
+ email
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,45 @@
1
+ query ListCalendarEvents(
2
+ $first: Int
3
+ $after: String
4
+ $before: String
5
+ $last: Int
6
+ $calendarIds: [ID!]
7
+ $scopes: [String!]
8
+ ) {
9
+ currentWorkspace {
10
+ calendarEvents(
11
+ first: $first
12
+ after: $after
13
+ before: $before
14
+ last: $last
15
+ calendarIds: $calendarIds
16
+ scopes: $scopes
17
+ ) {
18
+ pageInfo {
19
+ hasNextPage
20
+ endCursor
21
+ }
22
+ edges {
23
+ node {
24
+ id
25
+ name
26
+ startTime
27
+ endTime
28
+ allDay
29
+ timeZone
30
+ url
31
+ calendar {
32
+ id
33
+ name
34
+ color
35
+ }
36
+ primaryAddress {
37
+ id
38
+ formattedAddress
39
+ city
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,19 @@
1
+ query ListCalendars($first: Int, $after: String, $before: String, $last: Int) {
2
+ currentWorkspace {
3
+ calendars(first: $first, after: $after, before: $before, last: $last) {
4
+ pageInfo {
5
+ hasNextPage
6
+ endCursor
7
+ }
8
+ edges {
9
+ node {
10
+ id
11
+ name
12
+ description
13
+ color
14
+ timeZone
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,31 @@
1
+ query GetCall($id: ID!) {
2
+ currentWorkspace {
3
+ call(id: $id) {
4
+ id
5
+ name
6
+ body
7
+ cover
8
+ coverData
9
+ kind
10
+ status
11
+ quantity
12
+ salaryMin
13
+ salaryMax
14
+ publishedAt
15
+ expiresAt
16
+ completedAt
17
+ publicUrl
18
+ publicPath
19
+ primaryAddress {
20
+ id
21
+ formattedAddress
22
+ name
23
+ city
24
+ countryCode
25
+ }
26
+ form {
27
+ ...FormFields
28
+ }
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,32 @@
1
+ query ListCalls($first: Int, $after: String) {
2
+ currentWorkspace {
3
+ calls(first: $first, after: $after) {
4
+ pageInfo {
5
+ hasNextPage
6
+ endCursor
7
+ }
8
+ edges {
9
+ node {
10
+ id
11
+ name
12
+ cover
13
+ coverData
14
+ kind
15
+ status
16
+ quantity
17
+ salaryMin
18
+ salaryMax
19
+ publishedAt
20
+ expiresAt
21
+ publicPath
22
+ published
23
+ primaryAddress {
24
+ id
25
+ formattedAddress
26
+ city
27
+ }
28
+ }
29
+ }
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,19 @@
1
+ query GetCampaign($id: ID!) {
2
+ currentWorkspace {
3
+ campaign(id: $id) {
4
+ id
5
+ name
6
+ innerName
7
+ status
8
+ scheduledAt
9
+ sentAt
10
+ createdAt
11
+ updatedAt
12
+ preferences
13
+ list {
14
+ id
15
+ name
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,27 @@
1
+ query ListCampaigns(
2
+ $first: Int
3
+ $after: String
4
+ $kind: String
5
+ $status: String
6
+ ) {
7
+ currentWorkspace {
8
+ campaigns(first: $first, after: $after, kind: $kind, status: $status) {
9
+ pageInfo {
10
+ hasNextPage
11
+ endCursor
12
+ }
13
+ edges {
14
+ node {
15
+ id
16
+ name
17
+ innerName
18
+ status
19
+ scheduledAt
20
+ sentAt
21
+ createdAt
22
+ updatedAt
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,34 @@
1
+ query ListEmailCampaigns($first: Int, $after: String, $status: String) {
2
+ currentWorkspace {
3
+ emailCampaigns(first: $first, after: $after, status: $status) {
4
+ pageInfo {
5
+ hasNextPage
6
+ endCursor
7
+ }
8
+ edges {
9
+ node {
10
+ id
11
+ subject
12
+ replyTo
13
+ sentCount
14
+ deliveredCount
15
+ openedCount
16
+ clickedCount
17
+ openRate
18
+ clickRate
19
+ uniqueOpens
20
+ uniqueClicks
21
+ lastOpenedAt
22
+ lastClickedAt
23
+ createdAt
24
+ updatedAt
25
+ campaign {
26
+ id
27
+ name
28
+ status
29
+ }
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,80 @@
1
+ query GetPage($projectId: ID!, $slug: String!) {
2
+ currentWorkspace {
3
+ name
4
+ project(id: $projectId) {
5
+ id
6
+ name
7
+ page(slug: $slug) {
8
+ id
9
+ name
10
+ slug
11
+ metadata {
12
+ metaTitle
13
+ metaDescription
14
+ metaKeywords
15
+ metaImage
16
+ }
17
+ pageBlocks {
18
+ id
19
+ shortname
20
+ templateBlock {
21
+ id
22
+ name
23
+ shortname
24
+ block {
25
+ id
26
+ shortname
27
+ name
28
+ }
29
+ }
30
+ fieldValues {
31
+ id
32
+ content
33
+ field {
34
+ id
35
+ name
36
+ shortname
37
+ kind
38
+ }
39
+ linkedRecord {
40
+ ... on Form {
41
+ id
42
+ inputs: formQuestions {
43
+ edges {
44
+ node {
45
+ id
46
+ position
47
+ label
48
+ required
49
+ hidden
50
+ placeholder
51
+ hint
52
+ fieldKind
53
+ rules
54
+ preferences
55
+ field {
56
+ id
57
+ kind
58
+ name
59
+ accessor
60
+ type
61
+ shortname
62
+ uploadPresignedUrl
63
+ uploadUrl
64
+ uploadParams
65
+ options: optionList {
66
+ id
67
+ name
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,41 @@
1
+ query GetTemplate($projectId: ID!, $templateId: ID!) {
2
+ currentWorkspace {
3
+ name
4
+ project(id: $projectId) {
5
+ id
6
+ name
7
+ template(id: $templateId) {
8
+ id
9
+ name
10
+ pages {
11
+ id
12
+ name
13
+ slug
14
+ pageBlocks {
15
+ id
16
+ shortname
17
+ templateBlock {
18
+ id
19
+ name
20
+ shortname
21
+ block {
22
+ id
23
+ shortname
24
+ }
25
+ }
26
+ fieldValues {
27
+ id
28
+ content
29
+ field {
30
+ id
31
+ name
32
+ kind
33
+ shortname
34
+ }
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,20 @@
1
+ query ListPages($projectId: ID!, $first: Int, $after: String) {
2
+ currentWorkspace {
3
+ project(id: $projectId) {
4
+ id
5
+ pages(first: $first, after: $after) {
6
+ pageInfo {
7
+ hasNextPage
8
+ endCursor
9
+ }
10
+ edges {
11
+ node {
12
+ id
13
+ name
14
+ slug
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,15 @@
1
+ query GetContact($id: ID!) {
2
+ currentWorkspace {
3
+ contact(id: $id) {
4
+ id
5
+ name
6
+ email
7
+ avatar
8
+ avatarData
9
+ formattedPrimaryAddress
10
+ createdAt
11
+ updatedAt
12
+ fieldValuesByShortname
13
+ }
14
+ }
15
+ }