@budibase/frontend-core 3.3.1 → 3.3.3

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.3.1",
3
+ "version": "3.3.3",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
@@ -20,5 +20,5 @@
20
20
  "devDependencies": {
21
21
  "svelte-check": "^4.1.0"
22
22
  },
23
- "gitHead": "b4b42fa71fec8b50f97ef3662395b22d12571a46"
23
+ "gitHead": "d74dae4e31f56f7a43589fd8d6c8070ed1156cd3"
24
24
  }
@@ -1,5 +1,3 @@
1
- // TODO: datasource and defitions are unions of the different implementations. At this point, the datasource does not know what type is being used, and the assignations will cause TS exceptions. Casting it "as any" for now. This should be fixed improving the type usages.
2
-
3
1
  import { derived, get, Readable, Writable } from "svelte/store"
4
2
  import {
5
3
  DataFetchDefinition,
@@ -10,12 +8,10 @@ import { enrichSchemaWithRelColumns, memo } from "../../../utils"
10
8
  import { cloneDeep } from "lodash"
11
9
  import {
12
10
  SaveRowRequest,
13
- SaveTableRequest,
14
11
  UIDatasource,
15
12
  UIFieldMutation,
16
13
  UIFieldSchema,
17
14
  UIRow,
18
- UpdateViewRequest,
19
15
  ViewV2Type,
20
16
  } from "@budibase/types"
21
17
  import { Store as StoreContext, BaseStoreProps } from "."
@@ -79,7 +75,7 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => {
79
75
  const schema = derived(definition, $definition => {
80
76
  const schema: Record<string, any> | undefined = getDatasourceSchema({
81
77
  API,
82
- datasource: get(datasource) as any, // TODO: see line 1
78
+ datasource: get(datasource),
83
79
  definition: $definition ?? undefined,
84
80
  })
85
81
  if (!schema) {
@@ -137,7 +133,7 @@ export const deriveStores = (context: StoreContext): DerivedDatasourceStore => {
137
133
  let type = $datasource?.type
138
134
  // @ts-expect-error
139
135
  if (type === "provider") {
140
- type = ($datasource as any).value?.datasource?.type // TODO: see line 1
136
+ type = ($datasource as any).value?.datasource?.type
141
137
  }
142
138
  // Handle calculation views
143
139
  if (
@@ -196,15 +192,13 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
196
192
  const refreshDefinition = async () => {
197
193
  const def = await getDatasourceDefinition({
198
194
  API,
199
- datasource: get(datasource) as any, // TODO: see line 1
195
+ datasource: get(datasource),
200
196
  })
201
- definition.set(def as any) // TODO: see line 1
197
+ definition.set(def ?? null)
202
198
  }
203
199
 
204
200
  // Saves the datasource definition
205
- const saveDefinition = async (
206
- newDefinition: SaveTableRequest | UpdateViewRequest
207
- ) => {
201
+ const saveDefinition = async (newDefinition: DataFetchDefinition) => {
208
202
  // Update local state
209
203
  const originalDefinition = get(definition)
210
204
  definition.set(newDefinition)
@@ -245,7 +239,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
245
239
  delete newDefinition.schema[column].default
246
240
  }
247
241
  }
248
- return await saveDefinition(newDefinition as any) // TODO: see line 1
242
+ return await saveDefinition(newDefinition)
249
243
  }
250
244
 
251
245
  // Adds a schema mutation for a single field
@@ -321,7 +315,7 @@ export const createActions = (context: StoreContext): ActionDatasourceStore => {
321
315
  await saveDefinition({
322
316
  ...$definition,
323
317
  schema: newSchema,
324
- } as any) // TODO: see line 1
318
+ })
325
319
  resetSchemaMutations()
326
320
  }
327
321
 
@@ -21,7 +21,7 @@ export default class ViewFetch extends BaseDataFetch<ViewV1Datasource, Table> {
21
21
 
22
22
  getSchema(definition: Table) {
23
23
  const { datasource } = this.options
24
- return definition?.views?.[datasource.name]?.schema
24
+ return definition?.views?.[datasource?.name]?.schema
25
25
  }
26
26
 
27
27
  async getData() {
@@ -101,12 +101,12 @@ export const fetchData = <
101
101
 
102
102
  // Creates an empty fetch instance with no datasource configured, so no data
103
103
  // will initially be loaded
104
- const createEmptyFetchInstance = ({
104
+ const createEmptyFetchInstance = <T extends DataFetchDatasource>({
105
105
  API,
106
106
  datasource,
107
107
  }: {
108
108
  API: APIClient
109
- datasource: DataFetchDatasource
109
+ datasource: T
110
110
  }) => {
111
111
  const handler = DataFetchMap[datasource?.type]
112
112
  if (!handler) {
@@ -114,7 +114,7 @@ const createEmptyFetchInstance = ({
114
114
  }
115
115
  return new handler({
116
116
  API,
117
- datasource: null as never,
117
+ datasource: datasource as any,
118
118
  query: null as any,
119
119
  })
120
120
  }
@@ -8,7 +8,7 @@ export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
8
8
  * Utility to wrap an async function and ensure all invocations happen
9
9
  * sequentially.
10
10
  * @param fn the async function to run
11
- * @return {Promise} a sequential version of the function
11
+ * @return {Function} a sequential version of the function
12
12
  */
13
13
  export const sequential = fn => {
14
14
  let queue = []