@budibase/frontend-core 3.20.2 → 3.20.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "3.20.2",
3
+ "version": "3.20.4",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -17,5 +17,5 @@
17
17
  "shortid": "2.2.15",
18
18
  "socket.io-client": "^4.7.5"
19
19
  },
20
- "gitHead": "3582592cff6b755c0e6f5cf7d04f32be18d7a9a8"
20
+ "gitHead": "00bd6ef4645dfb893f5a83ec78571181ead1f084"
21
21
  }
package/src/constants.ts CHANGED
@@ -2,13 +2,13 @@
2
2
  * Operator options for lucene queries
3
3
  */
4
4
  export {
5
+ DEFAULT_BB_DATASOURCE_ID,
5
6
  OperatorOptions,
6
7
  SqlNumberTypeRangeMap,
7
- DEFAULT_BB_DATASOURCE_ID,
8
8
  } from "@budibase/shared-core"
9
9
  export { Feature as Features } from "@budibase/types"
10
10
  import { BpmCorrelationKey } from "@budibase/shared-core"
11
- import { FieldType, BBReferenceFieldSubType } from "@budibase/types"
11
+ import { BBReferenceFieldSubType, FieldType } from "@budibase/types"
12
12
 
13
13
  export const BannedSearchTypes = [
14
14
  FieldType.LINK,
@@ -1,7 +1,3 @@
1
- import { writable, derived, get, Writable, Readable } from "svelte/store"
2
- import cloneDeep from "lodash/fp/cloneDeep"
3
- import { QueryUtils } from "../utils"
4
- import { convertJSONSchemaToTableSchema } from "../utils/json"
5
1
  import {
6
2
  DataFetchOptions,
7
3
  FieldType,
@@ -11,13 +7,17 @@ import {
11
7
  SortType,
12
8
  TableSchema,
13
9
  } from "@budibase/types"
14
- import { APIClient } from "../api/types"
10
+ import cloneDeep from "lodash/fp/cloneDeep"
11
+ import { derived, get, Readable, writable, Writable } from "svelte/store"
15
12
  import { DataFetchType } from "."
13
+ import { APIClient } from "../api/types"
14
+ import { QueryUtils } from "../utils"
15
+ import { convertJSONSchemaToTableSchema } from "../utils/json"
16
16
 
17
17
  const { buildQuery, limit: queryLimit, runQuery, sort } = QueryUtils
18
18
 
19
- interface DataFetchStore<TDefinition, TQuery> {
20
- rows: Row[]
19
+ interface DataFetchStore<TDefinition, TQuery, TRow extends Row> {
20
+ rows: TRow[]
21
21
  info: any
22
22
  schema: TableSchema | null
23
23
  loading: boolean
@@ -35,8 +35,8 @@ interface DataFetchStore<TDefinition, TQuery> {
35
35
  definition?: TDefinition | null
36
36
  }
37
37
 
38
- interface DataFetchDerivedStore<TDefinition, TQuery>
39
- extends DataFetchStore<TDefinition, TQuery> {
38
+ interface DataFetchDerivedStore<TDefinition, TQuery, TRow extends Row>
39
+ extends DataFetchStore<TDefinition, TQuery, TRow> {
40
40
  hasNextPage: boolean
41
41
  hasPrevPage: boolean
42
42
  supportsSearch: boolean
@@ -63,6 +63,7 @@ export default abstract class BaseDataFetch<
63
63
  primaryDisplay?: string
64
64
  },
65
65
  TQuery extends {} = SearchFilters,
66
+ TRow extends Row = Row,
66
67
  > {
67
68
  API: APIClient
68
69
  features: {
@@ -80,8 +81,8 @@ export default abstract class BaseDataFetch<
80
81
  clientSideSorting: boolean
81
82
  clientSideLimiting: boolean
82
83
  }
83
- store: Writable<DataFetchStore<TDefinition, TQuery>>
84
- derivedStore: Readable<DataFetchDerivedStore<TDefinition, TQuery>>
84
+ store: Writable<DataFetchStore<TDefinition, TQuery, TRow>>
85
+ derivedStore: Readable<DataFetchDerivedStore<TDefinition, TQuery, TRow>>
85
86
 
86
87
  /**
87
88
  * Constructs a new DataFetch instance.
@@ -331,7 +332,7 @@ export default abstract class BaseDataFetch<
331
332
  }
332
333
 
333
334
  abstract getData(): Promise<{
334
- rows: Row[]
335
+ rows: TRow[]
335
336
  info?: any
336
337
  hasNextPage?: boolean
337
338
  cursor?: any
@@ -492,7 +493,9 @@ export default abstract class BaseDataFetch<
492
493
  * @param state the current store state
493
494
  * @return {boolean} whether there is a next page of data or not
494
495
  */
495
- private hasNextPage(state: DataFetchStore<TDefinition, TQuery>): boolean {
496
+ private hasNextPage(
497
+ state: DataFetchStore<TDefinition, TQuery, TRow>
498
+ ): boolean {
496
499
  return state.cursors[state.pageNumber + 1] != null
497
500
  }
498
501
 
@@ -1,6 +1,6 @@
1
+ import { GroupUserDatasource } from "@budibase/types"
1
2
  import { get } from "svelte/store"
2
3
  import BaseDataFetch, { DataFetchParams } from "./DataFetch"
3
- import { GroupUserDatasource, InternalTable } from "@budibase/types"
4
4
 
5
5
  interface GroupUserQuery {
6
6
  groupId: string
@@ -22,7 +22,6 @@ export default class GroupUserFetch extends BaseDataFetch<
22
22
  ...opts,
23
23
  datasource: {
24
24
  type: "groupUser",
25
- tableId: InternalTable.USER_METADATA,
26
25
  },
27
26
  })
28
27
  }
@@ -1,12 +1,13 @@
1
- import { get } from "svelte/store"
2
- import BaseDataFetch, { DataFetchParams } from "./DataFetch"
3
1
  import { utils } from "@budibase/shared-core"
4
2
  import {
5
- InternalTable,
6
3
  SearchFilters,
7
4
  SearchUsersRequest,
5
+ StrippedUser,
6
+ User,
8
7
  UserDatasource,
9
8
  } from "@budibase/types"
9
+ import { get } from "svelte/store"
10
+ import BaseDataFetch, { DataFetchParams } from "./DataFetch"
10
11
 
11
12
  interface UserFetchQuery {
12
13
  appId?: string
@@ -24,14 +25,14 @@ interface UserDefinition {
24
25
  export default class UserFetch extends BaseDataFetch<
25
26
  UserDatasource,
26
27
  UserDefinition,
27
- UserFetchQuery
28
+ UserFetchQuery,
29
+ User | StrippedUser
28
30
  > {
29
31
  constructor(opts: DataFetchParams<UserDatasource, UserFetchQuery>) {
30
32
  super({
31
33
  ...opts,
32
34
  datasource: {
33
35
  type: "user",
34
- tableId: InternalTable.USER_METADATA,
35
36
  },
36
37
  })
37
38
  }
@@ -1,17 +1,17 @@
1
- import TableFetch from "./TableFetch"
2
- import ViewFetch from "./ViewFetch"
3
- import ViewV2Fetch from "./ViewV2Fetch"
4
- import QueryFetch from "./QueryFetch"
5
- import RelationshipFetch from "./RelationshipFetch"
6
- import NestedProviderFetch from "./NestedProviderFetch"
1
+ import { DataFetchDatasource, Table, ViewV2Enriched } from "@budibase/types"
2
+ import { APIClient } from "../api/types"
3
+ import CustomFetch from "./CustomFetch"
7
4
  import FieldFetch from "./FieldFetch"
8
- import JSONArrayFetch from "./JSONArrayFetch"
9
- import UserFetch from "./UserFetch"
10
5
  import GroupUserFetch from "./GroupUserFetch"
11
- import CustomFetch from "./CustomFetch"
6
+ import JSONArrayFetch from "./JSONArrayFetch"
7
+ import NestedProviderFetch from "./NestedProviderFetch"
12
8
  import QueryArrayFetch from "./QueryArrayFetch"
13
- import { APIClient } from "../api/types"
14
- import { DataFetchDatasource, Table, ViewV2Enriched } from "@budibase/types"
9
+ import QueryFetch from "./QueryFetch"
10
+ import RelationshipFetch from "./RelationshipFetch"
11
+ import TableFetch from "./TableFetch"
12
+ import UserFetch from "./UserFetch"
13
+ import ViewFetch from "./ViewFetch"
14
+ import ViewV2Fetch from "./ViewV2Fetch"
15
15
 
16
16
  export type DataFetchType = keyof typeof DataFetchMap
17
17
 
@@ -86,7 +86,7 @@ export const fetchData = <
86
86
  }: {
87
87
  API: APIClient
88
88
  datasource: T
89
- options: any
89
+ options?: any
90
90
  }): Type extends keyof DataFetchClassMap
91
91
  ? DataFetchClassMap[Type]
92
92
  : TableFetch => {