1
0
Fork 0
mirror of synced 2024-06-01 18:20:18 +12:00

Update remaining dependency issues in client

This commit is contained in:
Andrew Kingston 2022-01-20 10:16:13 +00:00
parent 1d217a23b7
commit e3b8e44eeb
15 changed files with 86 additions and 77 deletions

View file

@ -1,51 +0,0 @@
/**
* Returns the valid operator options for a certain data type
* @param type the data type
*/
export const getValidOperatorsForType = type => {
const Op = OperatorOptions
if (type === "string") {
return [
Op.Equals,
Op.NotEquals,
Op.StartsWith,
Op.Like,
Op.Empty,
Op.NotEmpty,
]
} else if (type === "number") {
return [
Op.Equals,
Op.NotEquals,
Op.MoreThan,
Op.LessThan,
Op.Empty,
Op.NotEmpty,
]
} else if (type === "options") {
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
} else if (type === "array") {
return [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty]
} else if (type === "boolean") {
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
} else if (type === "longform") {
return [
Op.Equals,
Op.NotEquals,
Op.StartsWith,
Op.Like,
Op.Empty,
Op.NotEmpty,
]
} else if (type === "datetime") {
return [
Op.Equals,
Op.NotEquals,
Op.MoreThan,
Op.LessThan,
Op.Empty,
Op.NotEmpty,
]
}
return []
}

View file

@ -20,7 +20,7 @@
},
"dependencies": {
"@budibase/bbui": "^1.0.44-alpha.7",
"@budibase/frontend-core": "^1.0.44-alpha.2",
"@budibase/frontend-core": "^1.0.44-alpha.7",
"@budibase/standard-components": "^0.9.139",
"@budibase/string-templates": "^1.0.44-alpha.7",
"regexparam": "^1.3.0",

View file

@ -1,7 +1,6 @@
import { createAPIClient } from "@budibase/frontend-core"
import { createAPIClient, Constants } from "@budibase/frontend-core"
import { notificationStore } from "./stores"
import { FieldTypes } from "./constants"
import { TableNames } from "@budibase/frontend-core/src/constants.js"
export const API = createAPIClient({
// Attach client specific headers
@ -32,7 +31,7 @@ export const API = createAPIClient({
// Don't try to enrich a public user as it will 403
return user
} else {
return (await enrichRows([user], TableNames.USERS))[0]
return (await enrichRows([user], Constants.TableNames.USERS))[0]
}
} else {
return null

View file

@ -9,7 +9,7 @@
import Router from "./Router.svelte"
import { enrichProps, propsAreSame } from "utils/componentProps"
import { builderStore } from "stores"
import { Helpers } from "@budibase/frontend-core"
import { Helpers } from "@budibase/bbui"
import Manifest from "manifest.json"
import { getActiveConditions, reduceConditionActions } from "utils/conditions"
import Placeholder from "components/app/Placeholder.svelte"

View file

@ -1,7 +1,7 @@
<script>
import { getContext } from "svelte"
import InnerForm from "./InnerForm.svelte"
import { Helpers } from "@budibase/frontend-core"
import { Helpers } from "@budibase/bbui"
export let dataSource
export let theme

View file

@ -2,8 +2,7 @@
import { setContext, getContext } from "svelte"
import { derived, get, writable } from "svelte/store"
import { createValidatorFromConstraints } from "./validation"
import { Helpers } from "@budibase/frontend-core"
import { deepGet, deepSet } from "@budibase/bbui"
import { Helpers } from "@budibase/bbui"
import { cloneDeep } from "lodash/fp"
export let dataSource
@ -115,10 +114,10 @@
// Merge all values and enrichments into a single value
sortedFields.forEach(({ key, value }) => {
deepSet(formValue, key, value)
Helpers.deepSet(formValue, key, value)
})
Object.entries(enrichments || {}).forEach(([key, value]) => {
deepSet(formValue, key, value)
Helpers.deepSet(formValue, key, value)
})
return formValue
}
@ -151,7 +150,7 @@
)
// If we've already registered this field then keep some existing state
let initialValue = deepGet(initialValues, field) ?? defaultValue
let initialValue = Helpers.deepGet(initialValues, field) ?? defaultValue
let initialError = null
let fieldId = `id-${Helpers.uuid()}`
const existingField = getField(field)

View file

@ -1,7 +1,8 @@
<script>
import Provider from "./Provider.svelte"
import { authStore } from "stores"
import { ActionTypes, TableNames } from "constants"
import { ActionTypes } from "constants"
import { Constants } from "@budibase/frontend-core"
// Register this as a refreshable datasource so that user changes cause
// the user object to be refreshed
@ -9,7 +10,9 @@
{
type: ActionTypes.RefreshDatasource,
callback: () => authStore.actions.fetchUser(),
metadata: { dataSource: { type: "table", tableId: TableNames.USERS } },
metadata: {
dataSource: { type: "table", tableId: Constants.TableNames.USERS },
},
},
]
</script>

View file

@ -1,5 +1,5 @@
import { writable, derived } from "svelte/store"
import { Helpers } from "@budibase/frontend-core"
import { Helpers } from "@budibase/bbui"
export const createContextStore = oldContext => {
const newContext = writable({})

View file

@ -11,7 +11,7 @@ import {
import { API } from "api"
import { ActionTypes } from "constants"
import { enrichDataBindings } from "./enrichDataBinding"
import { deepSet } from "@budibase/bbui"
import { Helpers } from "@budibase/bbui"
const saveRowHandler = async (action, context) => {
const { fields, providerId, tableId } = action.parameters
@ -23,7 +23,7 @@ const saveRowHandler = async (action, context) => {
}
if (fields) {
for (let [field, value] of Object.entries(fields)) {
deepSet(payload, field, value)
Helpers.deepSet(payload, field, value)
}
}
if (tableId) {
@ -49,7 +49,7 @@ const duplicateRowHandler = async (action, context) => {
let payload = { ...context[providerId] }
if (fields) {
for (let [field, value] of Object.entries(fields)) {
deepSet(payload, field, value)
Helpers.deepSet(payload, field, value)
}
}
if (tableId) {

View file

@ -34,7 +34,7 @@ export const getActiveConditions = conditions => {
}
const query = LuceneUtils.buildLuceneQuery([luceneCondition])
const result = LuceneUtils.luceneQuery([luceneCondition], query)
const result = LuceneUtils.runLuceneQuery([luceneCondition], query)
return result.length > 0
})
}

5
packages/frontend-core/.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.DS_Store
node_modules
package-lock.json
release/
dist/

View file

@ -1,11 +1,12 @@
{
"name": "@budibase/frontend-core",
"version": "1.0.44-alpha.2",
"version": "1.0.44-alpha.7",
"description": "Budibase frontend core libraries used in builder and client",
"author": "Budibase",
"license": "GPL-3.0",
"svelte": "src/index.js",
"dependencies": {
"@budibase/bbui": "^1.0.44-alpha.7",
"lodash": "^4.17.21",
"svelte": "^3.46.2"
}

View file

@ -154,7 +154,9 @@ export const createAPIClient = config => {
get: requestApiCall("GET"),
patch: requestApiCall("PATCH"),
delete: requestApiCall("DELETE"),
error: message => throw makeError(message),
error: message => {
throw makeError(message)
},
}
// Attach all other endpoints

View file

@ -1,9 +1,8 @@
export * as API from "./api"
export { createAPIClient } from "./api"
export { createLocalStorageStore } from "./stores/localStorage"
export { fetchData } from "./fetch/fetchData"
export * as Constants from "./constants"
export * as Helpers from "./utils/helpers"
export * as LuceneUtils from "./utils/lucene"
export * as JSONUtils from "./utils/json"
export * as CookieUtils from "./utils/cookies"
export * as SchemaUtils from "./utils/schema"
export { createLocalStorageStore } from "./stores/localStorage"
export { fetchData } from "./fetch/fetchData"

View file

@ -1,4 +1,4 @@
import { deepGet } from "./helpers"
import { Helpers } from "@budibase/bbui"
/**
* Operator options for lucene queries
@ -46,6 +46,58 @@ export const OperatorOptions = {
},
}
/**
* Returns the valid operator options for a certain data type
* @param type the data type
*/
export const getValidOperatorsForType = type => {
const Op = OperatorOptions
if (type === "string") {
return [
Op.Equals,
Op.NotEquals,
Op.StartsWith,
Op.Like,
Op.Empty,
Op.NotEmpty,
]
} else if (type === "number") {
return [
Op.Equals,
Op.NotEquals,
Op.MoreThan,
Op.LessThan,
Op.Empty,
Op.NotEmpty,
]
} else if (type === "options") {
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
} else if (type === "array") {
return [Op.Contains, Op.NotContains, Op.Empty, Op.NotEmpty]
} else if (type === "boolean") {
return [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty]
} else if (type === "longform") {
return [
Op.Equals,
Op.NotEquals,
Op.StartsWith,
Op.Like,
Op.Empty,
Op.NotEmpty,
]
} else if (type === "datetime") {
return [
Op.Equals,
Op.NotEquals,
Op.MoreThan,
Op.LessThan,
Op.Empty,
Op.NotEmpty,
]
}
return []
}
/**
* Operators which do not support empty strings as values
*/
@ -169,7 +221,7 @@ export const runLuceneQuery = (docs, query) => {
const filters = Object.entries(query[type] || {})
for (let i = 0; i < filters.length; i++) {
const [key, testValue] = filters[i]
const docValue = deepGet(doc, key)
const docValue = Helpers.deepGet(doc, key)
if (failFn(docValue, testValue)) {
return false
}