Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
samwho committed Dec 10, 2024
1 parent e6705e5 commit fec9b44
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/backend-core/src/cache/tests/user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe("user cache", () => {
jest.spyOn(UserDB, "bulkGet")

await config.doInTenant(() =>
getUsers([userIdsToRequest[0], userIdsToRequest[3]])
getUsers([userIdsToRequest[0]!, userIdsToRequest[3]!])
)
;(UserDB.bulkGet as jest.Mock).mockClear()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("plugins", () => {
const plugin = structures.plugins.plugin()

function getEnrichedPluginUrls() {
const enriched = plugins.enrichPluginURLs([plugin])[0]
const enriched = plugins.enrichPluginURLs([plugin])[0]!
return {
jsUrl: enriched.jsUrl!,
iconUrl: enriched.iconUrl!,
Expand Down
3 changes: 2 additions & 1 deletion packages/backend-core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"noUncheckedIndexedAccess": true
},
"exclude": [
"node_modules",
Expand Down
2 changes: 1 addition & 1 deletion packages/pro
Submodule pro updated from 9d88d3 to 965640
26 changes: 0 additions & 26 deletions packages/server/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
<<<<<<< HEAD
"target": "es6",
"module": "commonjs",
"lib": ["es2020"],
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"types": ["node", "jest"],
"outDir": "dist/src",
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@budibase/types": ["../types/src"],
"@budibase/backend-core": ["../backend-core/src"],
"@budibase/backend-core/*": ["../backend-core/*"],
"@budibase/shared-core": ["../shared-core/src"],
"@budibase/pro": ["../pro/src"],
"@budibase/string-templates": ["../string-templates/src"],
"@budibase/string-templates/*": ["../string-templates/*"]
},
"allowArbitraryExtensions": true,
"noUncheckedIndexedAccess": true
=======
"target": "es2020",
"allowArbitraryExtensions": true,
"isolatedModules": false
>>>>>>> c66c8de8258d98358e33ea566f4074afbd2e8b9e
},
"include": ["src/**/*"],
"exclude": [
Expand Down
3 changes: 2 additions & 1 deletion packages/shared-core/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"rootDir": "src/",
"outDir": "dist"
"outDir": "dist",
"noUncheckedIndexedAccess": true
},
"include": ["src/**/*.ts"],
"exclude": ["**/*.spec.ts", "**/*.spec.js", "__mocks__", "src/tests"]
Expand Down
9 changes: 4 additions & 5 deletions packages/string-templates/src/conversion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ function splitBySpace(layer: string) {
}
}
const continuationChars = ["[", "'", '"']
for (let index = 0; index < layer.length; index++) {
const char = layer[index]
for (const [index, char] of layer.split("").entries()) {
if (continuationChars.indexOf(char) !== -1 && started == null) {
started = index
endChar = char === "[" ? "]" : char
Expand Down Expand Up @@ -114,16 +113,16 @@ export function convertHBSBlock(block: string, blockNumber: number) {
const list = getJsHelperList()
for (let layer of layers) {
const parts = splitBySpace(layer)
if (value || parts.length > 1 || list[parts[0]]) {
if (value || parts.length > 1 || list[parts[0]!]) {
// first of layer should always be the helper
const [helper] = parts.splice(0, 1)
if (list[helper]) {
if (list[helper!]) {
value = `helpers.${helper}(${buildList(parts, value)})`
}
}
// no helpers
else {
value = getVariable(parts[0])
value = getVariable(parts[0]!)
}
}
// split by space will remove square brackets
Expand Down
6 changes: 3 additions & 3 deletions packages/string-templates/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export function decodeJSBinding(handlebars: string): string | null {
if (!match || match.length < 2) {
return null
}
return atob(match[1])
return atob(match[1]!)
}

/**
Expand Down Expand Up @@ -437,9 +437,9 @@ export function convertToJS(hbs: string) {
for (let block of blocks) {
let stringPart = hbs
if (prevBlock) {
stringPart = stringPart.split(prevBlock)[1]
stringPart = stringPart.split(prevBlock)[1]!
}
stringPart = stringPart.split(block)[0]
stringPart = stringPart.split(block)[0]!
prevBlock = block
const { variable, value } = convertHBSBlock(block, count++)
variables[variable] = value
Expand Down
26 changes: 14 additions & 12 deletions packages/string-templates/src/processors/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,21 @@ export const processors = [
insideStatement = insideStatement.slice(0, insideStatement.length - 1)
}
const possibleHelper = insideStatement.split(" ")[0]
// function helpers can't be wrapped
for (let specialCase of FUNCTION_CASES) {
if (possibleHelper.includes(specialCase)) {
return statement
if (possibleHelper) {
// function helpers can't be wrapped
for (let specialCase of FUNCTION_CASES) {
if (possibleHelper.includes(specialCase)) {
return statement
}
}
const testHelper = possibleHelper.trim().toLowerCase()
if (
helpersEnabled &&
!opts?.disabledHelpers?.includes(testHelper) &&
HelperNames().some(option => testHelper === option.toLowerCase())
) {
insideStatement = `(${insideStatement})`
}
}
const testHelper = possibleHelper.trim().toLowerCase()
if (
helpersEnabled &&
!opts?.disabledHelpers?.includes(testHelper) &&
HelperNames().some(option => testHelper === option.toLowerCase())
) {
insideStatement = `(${insideStatement})`
}
return `{{ all ${insideStatement} }}`
}
Expand Down
3 changes: 2 additions & 1 deletion packages/types/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"rootDir": "src/",
"outDir": "dist"
"outDir": "dist",
"noUncheckedIndexedAccess": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
Expand Down
3 changes: 2 additions & 1 deletion packages/worker/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.build.json",
"compilerOptions": {
"target": "es2020"
"target": "es2020",
"noUncheckedIndexedAccess": true
},
"include": ["src/**/*"],
"exclude": [
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@budibase/string-templates": ["./packages/string-templates/src"],
"@budibase/string-templates/*": ["./packages/string-templates/*"],
"@budibase/frontend-core": ["./packages/frontend-core/src"]
},
"noUncheckedIndexedAccess": true
}
// "noUncheckedIndexedAccess": true
},
"exclude": []
}

0 comments on commit fec9b44

Please sign in to comment.