@budibase/frontend-core 3.2.29 → 3.2.31

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 (106) hide show
  1. package/package.json +9 -3
  2. package/src/api/ai.ts +17 -0
  3. package/src/api/analytics.ts +39 -0
  4. package/src/api/{app.js → app.ts} +84 -5
  5. package/src/api/attachments.ts +121 -0
  6. package/src/api/auditLogs.ts +35 -0
  7. package/src/api/{auth.js → auth.ts} +44 -7
  8. package/src/api/automations.ts +158 -0
  9. package/src/api/backups.ts +50 -0
  10. package/src/api/{configs.js → configs.ts} +31 -3
  11. package/src/api/datasources.ts +132 -0
  12. package/src/api/environmentVariables.ts +58 -0
  13. package/src/api/events.ts +21 -0
  14. package/src/api/flags.ts +48 -0
  15. package/src/api/{groups.js → groups.ts} +73 -17
  16. package/src/api/{index.js → index.ts} +89 -102
  17. package/src/api/layouts.ts +35 -0
  18. package/src/api/licensing.ts +107 -0
  19. package/src/api/{logs.js → logs.ts} +7 -1
  20. package/src/api/migrations.ts +19 -0
  21. package/src/api/{other.js → other.ts} +19 -12
  22. package/src/api/{permissions.js → permissions.ts} +31 -5
  23. package/src/api/{plugins.js → plugins.ts} +18 -1
  24. package/src/api/{queries.js → queries.ts} +39 -14
  25. package/src/api/relationships.ts +31 -0
  26. package/src/api/{roles.js → roles.ts} +22 -5
  27. package/src/api/routes.ts +30 -0
  28. package/src/api/{rowActions.js → rowActions.ts} +45 -27
  29. package/src/api/rows.ts +120 -0
  30. package/src/api/screens.ts +35 -0
  31. package/src/api/{self.js → self.ts} +20 -4
  32. package/src/api/tables.ts +192 -0
  33. package/src/api/templates.ts +57 -0
  34. package/src/api/types.ts +136 -0
  35. package/src/api/{user.js → user.ts} +111 -119
  36. package/src/api/{views.js → views.ts} +18 -7
  37. package/src/api/{viewsV2.js → viewsV2.ts} +30 -27
  38. package/src/components/grid/cells/AICell.svelte +1 -0
  39. package/src/components/grid/cells/LongFormCell.svelte +1 -0
  40. package/src/components/grid/cells/RelationshipCell.svelte +1 -2
  41. package/src/components/grid/cells/TextCell.svelte +3 -0
  42. package/src/components/grid/controls/MigrationModal.svelte +5 -5
  43. package/src/components/grid/layout/Grid.svelte +5 -8
  44. package/src/components/grid/lib/constants.js +1 -1
  45. package/src/components/grid/lib/{events.js → events.ts} +3 -3
  46. package/src/components/grid/lib/utils.js +2 -0
  47. package/src/components/grid/lib/utils.ts +32 -0
  48. package/src/components/grid/stores/bounds.ts +29 -0
  49. package/src/components/grid/stores/{cache.js → cache.ts} +21 -6
  50. package/src/components/grid/stores/{clipboard.js → clipboard.ts} +55 -19
  51. package/src/components/grid/stores/{columns.js → columns.ts} +47 -19
  52. package/src/components/grid/stores/{conditions.js → conditions.ts} +32 -12
  53. package/src/components/grid/stores/{config.js → config.ts} +16 -6
  54. package/src/components/grid/stores/{datasource.js → datasource.ts} +86 -36
  55. package/src/components/grid/stores/datasources/index.ts +31 -0
  56. package/src/components/grid/stores/datasources/{nonPlus.js → nonPlus.ts} +21 -11
  57. package/src/components/grid/stores/datasources/{table.js → table.ts} +39 -21
  58. package/src/components/grid/stores/datasources/{viewV2.js → viewV2.ts} +74 -28
  59. package/src/components/grid/stores/{filter.js → filter.ts} +39 -16
  60. package/src/components/grid/stores/index.ts +143 -0
  61. package/src/components/grid/stores/{menu.js → menu.ts} +31 -6
  62. package/src/components/grid/stores/{notifications.js → notifications.ts} +12 -2
  63. package/src/components/grid/stores/{pagination.js → pagination.ts} +2 -1
  64. package/src/components/grid/stores/{reorder.js → reorder.ts} +47 -15
  65. package/src/components/grid/stores/{resize.js → resize.ts} +28 -10
  66. package/src/components/grid/stores/{rows.js → rows.ts} +167 -53
  67. package/src/components/grid/stores/{scroll.js → scroll.ts} +28 -5
  68. package/src/components/grid/stores/{sort.js → sort.ts} +13 -3
  69. package/src/components/grid/stores/{ui.js → ui.ts} +77 -20
  70. package/src/components/grid/stores/{users.js → users.ts} +36 -9
  71. package/src/components/grid/stores/{validation.js → validation.ts} +35 -12
  72. package/src/components/grid/stores/{viewport.js → viewport.ts} +14 -3
  73. package/src/{constants.js → constants.ts} +2 -2
  74. package/src/fetch/QueryFetch.js +2 -2
  75. package/src/fetch/RelationshipFetch.js +9 -6
  76. package/src/fetch/TableFetch.js +1 -2
  77. package/src/fetch/ViewFetch.js +1 -1
  78. package/src/fetch/ViewV2Fetch.js +1 -2
  79. package/src/utils/memo.d.ts +10 -0
  80. package/src/utils/relatedColumns.ts +126 -0
  81. package/tsconfig.json +14 -0
  82. package/src/api/ai.js +0 -11
  83. package/src/api/analytics.js +0 -17
  84. package/src/api/attachments.js +0 -78
  85. package/src/api/auditLogs.js +0 -63
  86. package/src/api/automations.js +0 -111
  87. package/src/api/backups.js +0 -46
  88. package/src/api/datasources.js +0 -92
  89. package/src/api/environmentVariables.js +0 -36
  90. package/src/api/events.js +0 -13
  91. package/src/api/flags.js +0 -34
  92. package/src/api/hosting.js +0 -19
  93. package/src/api/layouts.js +0 -23
  94. package/src/api/licensing.js +0 -75
  95. package/src/api/migrations.js +0 -10
  96. package/src/api/relationships.js +0 -21
  97. package/src/api/routes.js +0 -19
  98. package/src/api/rows.js +0 -117
  99. package/src/api/screens.js +0 -23
  100. package/src/api/tables.js +0 -152
  101. package/src/api/templates.js +0 -35
  102. package/src/components/grid/stores/bounds.js +0 -16
  103. package/src/components/grid/stores/index.js +0 -73
  104. package/src/utils/relatedColumns.js +0 -103
  105. /package/src/{index.js → index.ts} +0 -0
  106. /package/src/utils/{index.js → index.ts} +0 -0
@@ -0,0 +1,57 @@
1
+ import {
2
+ FetchGlobalTemplateByTypeResponse,
3
+ FetchGlobalTemplateDefinitionResponse,
4
+ FetchTemplateResponse,
5
+ SaveGlobalTemplateRequest,
6
+ SaveGlobalTemplateResponse,
7
+ } from "@budibase/types"
8
+ import { BaseAPIClient } from "./types"
9
+
10
+ export interface TemplateEndpoints {
11
+ getEmailTemplates: () => Promise<FetchGlobalTemplateByTypeResponse>
12
+ getAppTemplates: () => Promise<FetchTemplateResponse>
13
+ getEmailTemplateDefinitions: () => Promise<FetchGlobalTemplateDefinitionResponse>
14
+ saveEmailTemplate: (
15
+ template: SaveGlobalTemplateRequest
16
+ ) => Promise<SaveGlobalTemplateResponse>
17
+ }
18
+
19
+ export const buildTemplateEndpoints = (
20
+ API: BaseAPIClient
21
+ ): TemplateEndpoints => ({
22
+ /**
23
+ * Gets the list of email template definitions.
24
+ */
25
+ getEmailTemplateDefinitions: async () => {
26
+ return await API.get({ url: "/api/global/template/definitions" })
27
+ },
28
+
29
+ /**
30
+ * Gets the list of email templates.
31
+ */
32
+ getEmailTemplates: async () => {
33
+ return await API.get({
34
+ url: "/api/global/template/email",
35
+ })
36
+ },
37
+
38
+ /**
39
+ * Saves an email template.
40
+ * @param template the template to save
41
+ */
42
+ saveEmailTemplate: async template => {
43
+ return await API.post({
44
+ url: "/api/global/template",
45
+ body: template,
46
+ })
47
+ },
48
+
49
+ /**
50
+ * Gets a list of app templates.
51
+ */
52
+ getAppTemplates: async () => {
53
+ return await API.get({
54
+ url: "/api/templates",
55
+ })
56
+ },
57
+ })
@@ -0,0 +1,136 @@
1
+ import { AIEndpoints } from "./ai"
2
+ import { AnalyticsEndpoints } from "./analytics"
3
+ import { AppEndpoints } from "./app"
4
+ import { AttachmentEndpoints } from "./attachments"
5
+ import { AuditLogEndpoints } from "./auditLogs"
6
+ import { AuthEndpoints } from "./auth"
7
+ import { AutomationEndpoints } from "./automations"
8
+ import { BackupEndpoints } from "./backups"
9
+ import { ConfigEndpoints } from "./configs"
10
+ import { DatasourceEndpoints } from "./datasources"
11
+ import { EnvironmentVariableEndpoints } from "./environmentVariables"
12
+ import { EventEndpoints } from "./events"
13
+ import { FlagEndpoints } from "./flags"
14
+ import { GroupEndpoints } from "./groups"
15
+ import { LayoutEndpoints } from "./layouts"
16
+ import { LicensingEndpoints } from "./licensing"
17
+ import { LogEndpoints } from "./logs"
18
+ import { MigrationEndpoints } from "./migrations"
19
+ import { OtherEndpoints } from "./other"
20
+ import { PermissionEndpoints } from "./permissions"
21
+ import { PluginEndpoins } from "./plugins"
22
+ import { QueryEndpoints } from "./queries"
23
+ import { RelationshipEndpoints } from "./relationships"
24
+ import { RoleEndpoints } from "./roles"
25
+ import { RouteEndpoints } from "./routes"
26
+ import { RowActionEndpoints } from "./rowActions"
27
+ import { RowEndpoints } from "./rows"
28
+ import { ScreenEndpoints } from "./screens"
29
+ import { SelfEndpoints } from "./self"
30
+ import { TableEndpoints } from "./tables"
31
+ import { TemplateEndpoints } from "./templates"
32
+ import { UserEndpoints } from "./user"
33
+ import { ViewEndpoints } from "./views"
34
+ import { ViewV2Endpoints } from "./viewsV2"
35
+
36
+ export enum HTTPMethod {
37
+ POST = "POST",
38
+ PATCH = "PATCH",
39
+ GET = "GET",
40
+ PUT = "PUT",
41
+ DELETE = "DELETE",
42
+ }
43
+
44
+ export type Headers = Record<string, string>
45
+
46
+ export type APIClientConfig = {
47
+ enableCaching?: boolean
48
+ attachHeaders?: (headers: Headers) => void
49
+ onError?: (error: any) => void
50
+ onMigrationDetected?: (migration: string) => void
51
+ }
52
+
53
+ export type APICallConfig<RequestT, ResponseT> = {
54
+ method: HTTPMethod
55
+ url: string
56
+ json: boolean
57
+ external: boolean
58
+ suppressErrors: boolean
59
+ cache: boolean
60
+ body?: RequestT
61
+ parseResponse?: (response: Response) => Promise<ResponseT> | ResponseT
62
+ }
63
+
64
+ export type APICallParams<
65
+ RequestT = null,
66
+ ResponseT = void
67
+ > = RequestT extends null
68
+ ? Pick<APICallConfig<RequestT, ResponseT>, "url"> &
69
+ Partial<APICallConfig<RequestT, ResponseT>>
70
+ : Pick<APICallConfig<RequestT, ResponseT>, "url" | "body"> &
71
+ Partial<APICallConfig<RequestT, ResponseT>>
72
+
73
+ export type BaseAPIClient = {
74
+ post: <RequestT = null, ResponseT = void>(
75
+ params: APICallParams<RequestT, ResponseT>
76
+ ) => Promise<ResponseT>
77
+ get: <ResponseT = void>(
78
+ params: APICallParams<undefined | null, ResponseT>
79
+ ) => Promise<ResponseT>
80
+ put: <RequestT = null, ResponseT = void>(
81
+ params: APICallParams<RequestT, ResponseT>
82
+ ) => Promise<ResponseT>
83
+ delete: <RequestT = null, ResponseT = void>(
84
+ params: APICallParams<RequestT, ResponseT>
85
+ ) => Promise<ResponseT>
86
+ patch: <RequestT = null, ResponseT = void>(
87
+ params: APICallParams<RequestT, ResponseT>
88
+ ) => Promise<ResponseT>
89
+ error: (message: string) => void
90
+ invalidateCache: () => void
91
+ getAppID: () => string
92
+ }
93
+
94
+ export type APIError = {
95
+ message?: string
96
+ url?: string
97
+ method?: HTTPMethod
98
+ json: any
99
+ status: number
100
+ handled: boolean
101
+ suppressErrors: boolean
102
+ }
103
+
104
+ export type APIClient = BaseAPIClient &
105
+ AIEndpoints &
106
+ AnalyticsEndpoints &
107
+ AppEndpoints &
108
+ AttachmentEndpoints &
109
+ AuditLogEndpoints &
110
+ AuthEndpoints &
111
+ AutomationEndpoints &
112
+ BackupEndpoints &
113
+ ConfigEndpoints &
114
+ DatasourceEndpoints &
115
+ EnvironmentVariableEndpoints &
116
+ EventEndpoints &
117
+ FlagEndpoints &
118
+ GroupEndpoints &
119
+ LayoutEndpoints &
120
+ LicensingEndpoints &
121
+ LogEndpoints &
122
+ MigrationEndpoints &
123
+ OtherEndpoints &
124
+ PermissionEndpoints &
125
+ PluginEndpoins &
126
+ QueryEndpoints &
127
+ RelationshipEndpoints &
128
+ RoleEndpoints &
129
+ RouteEndpoints &
130
+ RowEndpoints &
131
+ ScreenEndpoints &
132
+ SelfEndpoints &
133
+ TableEndpoints &
134
+ TemplateEndpoints &
135
+ UserEndpoints &
136
+ ViewEndpoints & { rowActions: RowActionEndpoints; viewV2: ViewV2Endpoints }
@@ -1,4 +1,82 @@
1
- export const buildUserEndpoints = API => ({
1
+ import {
2
+ AcceptUserInviteRequest,
3
+ AcceptUserInviteResponse,
4
+ BulkUserCreated,
5
+ BulkUserDeleted,
6
+ BulkUserRequest,
7
+ BulkUserResponse,
8
+ CheckInviteResponse,
9
+ CountUserResponse,
10
+ CreateAdminUserRequest,
11
+ CreateAdminUserResponse,
12
+ DeleteInviteUsersRequest,
13
+ DeleteInviteUsersResponse,
14
+ DeleteUserResponse,
15
+ FetchUsersResponse,
16
+ FindUserResponse,
17
+ GetUserInvitesResponse,
18
+ InviteUsersRequest,
19
+ InviteUsersResponse,
20
+ LookupAccountHolderResponse,
21
+ SaveUserResponse,
22
+ SearchUsersRequest,
23
+ SearchUsersResponse,
24
+ UpdateInviteRequest,
25
+ UpdateInviteResponse,
26
+ UpdateSelfMetadataRequest,
27
+ UpdateSelfMetadataResponse,
28
+ User,
29
+ } from "@budibase/types"
30
+ import { BaseAPIClient } from "./types"
31
+
32
+ export interface UserEndpoints {
33
+ getUsers: () => Promise<FetchUsersResponse>
34
+ getUser: (userId: string) => Promise<FindUserResponse>
35
+ updateOwnMetadata: (
36
+ metadata: UpdateSelfMetadataRequest
37
+ ) => Promise<UpdateSelfMetadataResponse>
38
+ createAdminUser: (
39
+ user: CreateAdminUserRequest
40
+ ) => Promise<CreateAdminUserResponse>
41
+ saveUser: (user: User) => Promise<SaveUserResponse>
42
+ deleteUser: (userId: string) => Promise<DeleteUserResponse>
43
+ deleteUsers: (
44
+ users: Array<{
45
+ userId: string
46
+ email: string
47
+ }>
48
+ ) => Promise<BulkUserDeleted | undefined>
49
+ onboardUsers: (data: InviteUsersRequest) => Promise<InviteUsersResponse>
50
+ getUserInvite: (code: string) => Promise<CheckInviteResponse>
51
+ getUserInvites: () => Promise<GetUserInvitesResponse>
52
+ inviteUsers: (users: InviteUsersRequest) => Promise<InviteUsersResponse>
53
+ removeUserInvites: (
54
+ data: DeleteInviteUsersRequest
55
+ ) => Promise<DeleteInviteUsersResponse>
56
+ acceptInvite: (
57
+ data: AcceptUserInviteRequest
58
+ ) => Promise<AcceptUserInviteResponse>
59
+ getUserCountByApp: (appId: string) => Promise<number>
60
+ getAccountHolder: () => Promise<LookupAccountHolderResponse>
61
+ searchUsers: (data: SearchUsersRequest) => Promise<SearchUsersResponse>
62
+ createUsers: (
63
+ users: User[],
64
+ groups: any[]
65
+ ) => Promise<BulkUserCreated | undefined>
66
+ updateUserInvite: (
67
+ code: string,
68
+ data: UpdateInviteRequest
69
+ ) => Promise<UpdateInviteResponse>
70
+
71
+ // Missing request or response types
72
+ addAppBuilder: (userId: string, appId: string) => Promise<{ message: string }>
73
+ removeAppBuilder: (
74
+ userId: string,
75
+ appId: string
76
+ ) => Promise<{ message: string }>
77
+ }
78
+
79
+ export const buildUserEndpoints = (API: BaseAPIClient): UserEndpoints => ({
2
80
  /**
3
81
  * Gets a list of users in the current tenant.
4
82
  */
@@ -9,33 +87,12 @@ export const buildUserEndpoints = API => ({
9
87
  },
10
88
 
11
89
  /**
12
- * Gets a list of users in the current tenant.
13
- * @param {string} bookmark The page to retrieve
14
- * @param {object} query search filters for lookup by user (all operators not supported).
15
- * @param {string} appId Facilitate app/role based user searching
16
- * @param {boolean} paginate Allow the disabling of pagination
17
- * @param {number} limit How many users to retrieve in a single search
90
+ * Searches a list of users in the current tenant.
18
91
  */
19
- searchUsers: async ({ paginate, bookmark, query, appId, limit } = {}) => {
20
- const opts = {}
21
- if (bookmark) {
22
- opts.bookmark = bookmark
23
- }
24
- if (query) {
25
- opts.query = query
26
- }
27
- if (appId) {
28
- opts.appId = appId
29
- }
30
- if (typeof paginate === "boolean") {
31
- opts.paginate = paginate
32
- }
33
- if (limit) {
34
- opts.limit = limit
35
- }
92
+ searchUsers: async data => {
36
93
  return await API.post({
37
94
  url: `/api/global/users/search`,
38
- body: opts,
95
+ body: data,
39
96
  })
40
97
  },
41
98
 
@@ -48,17 +105,6 @@ export const buildUserEndpoints = API => ({
48
105
  })
49
106
  },
50
107
 
51
- /**
52
- * Creates a user for an app.
53
- * @param user the user to create
54
- */
55
- createAppUser: async user => {
56
- return await API.post({
57
- url: "/api/users/metadata",
58
- body: user,
59
- })
60
- },
61
-
62
108
  /**
63
109
  * Updates the current user metadata.
64
110
  * @param metadata the metadata to save
@@ -72,12 +118,12 @@ export const buildUserEndpoints = API => ({
72
118
 
73
119
  /**
74
120
  * Creates an admin user.
75
- * @param adminUser the admin user to create
121
+ * @param user the admin user to create
76
122
  */
77
- createAdminUser: async adminUser => {
123
+ createAdminUser: async user => {
78
124
  return await API.post({
79
125
  url: "/api/global/users/init",
80
- body: adminUser,
126
+ body: user,
81
127
  })
82
128
  },
83
129
 
@@ -97,8 +143,8 @@ export const buildUserEndpoints = API => ({
97
143
  * @param users the array of user objects to create
98
144
  * @param groups the array of group ids to add all users to
99
145
  */
100
- createUsers: async ({ users, groups }) => {
101
- const res = await API.post({
146
+ createUsers: async (users, groups) => {
147
+ const res = await API.post<BulkUserRequest, BulkUserResponse>({
102
148
  url: "/api/global/users/bulk",
103
149
  body: {
104
150
  create: {
@@ -125,7 +171,7 @@ export const buildUserEndpoints = API => ({
125
171
  * @param users the ID/email pair of the user to delete
126
172
  */
127
173
  deleteUsers: async users => {
128
- const res = await API.post({
174
+ const res = await API.post<BulkUserRequest, BulkUserResponse>({
129
175
  url: `/api/global/users/bulk`,
130
176
  body: {
131
177
  delete: {
@@ -137,54 +183,23 @@ export const buildUserEndpoints = API => ({
137
183
  },
138
184
 
139
185
  /**
140
- * Invites a user to the current tenant.
141
- * @param email the email address to send the invitation to
142
- * @param builder whether the user should be a global builder
143
- * @param admin whether the user should be a global admin
186
+ * Onboards multiple users
144
187
  */
145
- inviteUser: async ({ email, builder, admin, apps }) => {
146
- return await API.post({
147
- url: "/api/global/users/invite",
148
- body: {
149
- email,
150
- userInfo: {
151
- admin: admin?.global ? { global: true } : undefined,
152
- builder: builder?.global ? { global: true } : undefined,
153
- apps: apps ? apps : undefined,
154
- },
155
- },
156
- })
157
- },
158
-
159
- onboardUsers: async payload => {
188
+ onboardUsers: async data => {
160
189
  return await API.post({
161
190
  url: "/api/global/users/onboard",
162
- body: payload.map(invite => {
163
- const { email, admin, builder, apps } = invite
164
- return {
165
- email,
166
- userInfo: {
167
- admin,
168
- builder,
169
- apps: apps ? apps : undefined,
170
- },
171
- }
172
- }),
191
+ body: data,
173
192
  })
174
193
  },
175
194
 
176
195
  /**
177
196
  * Accepts a user invite as a body and will update the associated app roles.
178
197
  * for an existing invite
179
- * @param invite the invite code sent in the email
180
198
  */
181
- updateUserInvite: async invite => {
182
- await API.post({
183
- url: `/api/global/users/invite/update/${invite.code}`,
184
- body: {
185
- apps: invite.apps,
186
- builder: invite.builder,
187
- },
199
+ updateUserInvite: async (code, data) => {
200
+ return await API.post<UpdateInviteRequest, UpdateInviteResponse>({
201
+ url: `/api/global/users/invite/update/${code}`,
202
+ body: data,
188
203
  })
189
204
  },
190
205
 
@@ -214,72 +229,46 @@ export const buildUserEndpoints = API => ({
214
229
  inviteUsers: async users => {
215
230
  return await API.post({
216
231
  url: "/api/global/users/multi/invite",
217
- body: users.map(user => {
218
- let builder = undefined
219
- if (user.admin || user.builder) {
220
- builder = { global: true }
221
- } else if (user.creator) {
222
- builder = { creator: true }
223
- }
224
- return {
225
- email: user.email,
226
- userInfo: {
227
- admin: user.admin ? { global: true } : undefined,
228
- builder,
229
- userGroups: user.groups,
230
- roles: user.apps ? user.apps : undefined,
231
- },
232
- }
233
- }),
232
+ body: users,
234
233
  })
235
234
  },
236
235
 
237
236
  /**
238
237
  * Removes multiple user invites from Redis cache
239
238
  */
240
- removeUserInvites: async inviteCodes => {
239
+ removeUserInvites: async data => {
241
240
  return await API.post({
242
241
  url: "/api/global/users/multi/invite/delete",
243
- body: inviteCodes,
242
+ body: data,
244
243
  })
245
244
  },
246
245
 
247
246
  /**
248
247
  * Accepts an invite to join the platform and creates a user.
249
- * @param inviteCode the invite code sent in the email
250
- * @param password the password for the newly created user
251
- * @param firstName the first name of the new user
252
- * @param lastName the last name of the new user
253
248
  */
254
- acceptInvite: async ({ inviteCode, password, firstName, lastName }) => {
249
+ acceptInvite: async data => {
255
250
  return await API.post({
256
251
  url: "/api/global/users/invite/accept",
257
- body: {
258
- inviteCode,
259
- password,
260
- firstName,
261
- lastName,
262
- },
252
+ body: data,
263
253
  })
264
254
  },
265
255
 
266
256
  /**
267
- * Accepts an invite to join the platform and creates a user.
268
- * @param inviteCode the invite code sent in the email
269
- * @param password the password for the newly created user
257
+ * Counts the number of users in an app
270
258
  */
271
- getUserCountByApp: async ({ appId }) => {
272
- return await API.get({
259
+ getUserCountByApp: async appId => {
260
+ const res = await API.get<CountUserResponse>({
273
261
  url: `/api/global/users/count/${appId}`,
274
262
  })
263
+ return res.userCount
275
264
  },
276
265
 
277
266
  /**
278
267
  * Adds a per app builder to the selected app
279
- * @param appId the applications id
280
268
  * @param userId The id of the user to add as a builder
269
+ * @param appId the applications id
281
270
  */
282
- addAppBuilder: async ({ userId, appId }) => {
271
+ addAppBuilder: async (userId, appId) => {
283
272
  return await API.post({
284
273
  url: `/api/global/users/${userId}/app/${appId}/builder`,
285
274
  })
@@ -287,15 +276,18 @@ export const buildUserEndpoints = API => ({
287
276
 
288
277
  /**
289
278
  * Removes a per app builder to the selected app
290
- * @param appId the applications id
291
279
  * @param userId The id of the user to remove as a builder
280
+ * @param appId the applications id
292
281
  */
293
- removeAppBuilder: async ({ userId, appId }) => {
282
+ removeAppBuilder: async (userId, appId) => {
294
283
  return await API.delete({
295
284
  url: `/api/global/users/${userId}/app/${appId}/builder`,
296
285
  })
297
286
  },
298
287
 
288
+ /**
289
+ * Gets the account holder of the current tenant
290
+ */
299
291
  getAccountHolder: async () => {
300
292
  return await API.get({
301
293
  url: `/api/global/users/accountholder`,
@@ -1,4 +1,15 @@
1
- export const buildViewEndpoints = API => ({
1
+ import { Row } from "@budibase/types"
2
+ import { BaseAPIClient } from "./types"
3
+
4
+ export interface ViewEndpoints {
5
+ // Missing request or response types
6
+ fetchViewData: (name: string, opts: any) => Promise<Row[]>
7
+ exportView: (name: string, format: string) => Promise<any>
8
+ saveView: (view: any) => Promise<any>
9
+ deleteView: (name: string) => Promise<any>
10
+ }
11
+
12
+ export const buildViewEndpoints = (API: BaseAPIClient): ViewEndpoints => ({
2
13
  /**
3
14
  * Fetches all rows in a view
4
15
  * @param name the name of the view
@@ -6,7 +17,7 @@ export const buildViewEndpoints = API => ({
6
17
  * @param groupBy the field to group by
7
18
  * @param calculation the calculation to perform
8
19
  */
9
- fetchViewData: async ({ name, field, groupBy, calculation }) => {
20
+ fetchViewData: async (name, { field, groupBy, calculation }) => {
10
21
  const params = new URLSearchParams()
11
22
  if (calculation) {
12
23
  params.set("field", field)
@@ -23,11 +34,11 @@ export const buildViewEndpoints = API => ({
23
34
 
24
35
  /**
25
36
  * Exports a view for download
26
- * @param viewName the view to export
37
+ * @param name the view to export
27
38
  * @param format the format to download
28
39
  */
29
- exportView: async ({ viewName, format }) => {
30
- const safeViewName = encodeURIComponent(viewName)
40
+ exportView: async (name, format) => {
41
+ const safeViewName = encodeURIComponent(name)
31
42
  return await API.get({
32
43
  url: `/api/views/export?view=${safeViewName}&format=${format}`,
33
44
  parseResponse: async response => {
@@ -51,9 +62,9 @@ export const buildViewEndpoints = API => ({
51
62
  * Deletes a view.
52
63
  * @param viewName the name of the view to delete
53
64
  */
54
- deleteView: async viewName => {
65
+ deleteView: async name => {
55
66
  return await API.delete({
56
- url: `/api/views/${encodeURIComponent(viewName)}`,
67
+ url: `/api/views/${encodeURIComponent(name)}`,
57
68
  })
58
69
  },
59
70
  })
@@ -1,4 +1,26 @@
1
- export const buildViewV2Endpoints = API => ({
1
+ import {
2
+ CreateViewRequest,
3
+ CreateViewResponse,
4
+ SearchRowResponse,
5
+ SearchViewRowRequest,
6
+ UpdateViewRequest,
7
+ UpdateViewResponse,
8
+ ViewResponseEnriched,
9
+ } from "@budibase/types"
10
+ import { BaseAPIClient } from "./types"
11
+
12
+ export interface ViewV2Endpoints {
13
+ fetchDefinition: (viewId: string) => Promise<ViewResponseEnriched>
14
+ create: (view: CreateViewRequest) => Promise<CreateViewResponse>
15
+ update: (view: UpdateViewRequest) => Promise<UpdateViewResponse>
16
+ fetch: (
17
+ viewId: string,
18
+ opts: SearchViewRowRequest
19
+ ) => Promise<SearchRowResponse>
20
+ delete: (viewId: string) => Promise<void>
21
+ }
22
+
23
+ export const buildViewV2Endpoints = (API: BaseAPIClient): ViewV2Endpoints => ({
2
24
  /**
3
25
  * Fetches the definition of a view
4
26
  * @param viewId the ID of the view to fetch
@@ -9,6 +31,7 @@ export const buildViewV2Endpoints = API => ({
9
31
  cache: true,
10
32
  })
11
33
  },
34
+
12
35
  /**
13
36
  * Create a new view
14
37
  * @param view the view object
@@ -19,6 +42,7 @@ export const buildViewV2Endpoints = API => ({
19
42
  body: view,
20
43
  })
21
44
  },
45
+
22
46
  /**
23
47
  * Updates a view
24
48
  * @param view the view object
@@ -29,40 +53,19 @@ export const buildViewV2Endpoints = API => ({
29
53
  body: view,
30
54
  })
31
55
  },
56
+
32
57
  /**
33
58
  * Fetches all rows in a view
34
59
  * @param viewId the id of the view
35
- * @param query the search query
36
- * @param paginate whether to paginate or not
37
- * @param limit page size
38
- * @param bookmark pagination cursor
39
- * @param sort sort column
40
- * @param sortOrder sort order
41
- * @param sortType sort type (text or numeric)
60
+ * @param opts the search options
42
61
  */
43
- fetch: async ({
44
- viewId,
45
- query,
46
- paginate,
47
- limit,
48
- bookmark,
49
- sort,
50
- sortOrder,
51
- sortType,
52
- }) => {
62
+ fetch: async (viewId, opts) => {
53
63
  return await API.post({
54
64
  url: `/api/v2/views/${encodeURIComponent(viewId)}/search`,
55
- body: {
56
- query,
57
- paginate,
58
- limit,
59
- bookmark,
60
- sort,
61
- sortOrder,
62
- sortType,
63
- },
65
+ body: opts,
64
66
  })
65
67
  },
68
+
66
69
  /**
67
70
  * Delete a view
68
71
  * @param viewId the id of the view
@@ -73,6 +73,7 @@
73
73
  .value {
74
74
  display: -webkit-box;
75
75
  -webkit-line-clamp: var(--content-lines);
76
+ line-clamp: var(--content-lines);
76
77
  -webkit-box-orient: vertical;
77
78
  overflow: hidden;
78
79
  line-height: 20px;
@@ -93,6 +93,7 @@
93
93
  .value {
94
94
  display: -webkit-box;
95
95
  -webkit-line-clamp: var(--content-lines);
96
+ line-clamp: var(--content-lines);
96
97
  -webkit-box-orient: vertical;
97
98
  overflow: hidden;
98
99
  line-height: 20px;
@@ -102,9 +102,8 @@
102
102
  lastSearchId = Math.random()
103
103
  searching = true
104
104
  const thisSearchId = lastSearchId
105
- const results = await searchFunction({
105
+ const results = await searchFunction(schema.tableId, {
106
106
  paginate: false,
107
- tableId: schema.tableId,
108
107
  limit: 20,
109
108
  query: {
110
109
  string: {