Merge pull request #12927 from ToolJet/fix/server-side-query

Server side query resolver fixes
This commit is contained in:
Johnson Cherian 2025-06-25 13:34:39 +05:30 committed by GitHub
commit fffe03a074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 25 additions and 22 deletions

View file

@ -58,7 +58,7 @@ const MultiLineCodeEditor = (props) => {
const replaceIdsWithName = useStore((state) => state.replaceIdsWithName, shallow);
const wrapperRef = useRef(null);
const getSuggestions = useStore((state) => state.getSuggestions, shallow);
const getServerSideGlobalSuggestions = useStore((state) => state.getServerSideGlobalSuggestions, shallow);
const getServerSideGlobalResolveSuggestions = useStore((state) => state.getServerSideGlobalResolveSuggestions, shallow);
const isInsideQueryPane = !!document.querySelector('.code-hinter-wrapper')?.closest('.query-details');
const isInsideQueryManager = useMemo(
@ -116,7 +116,7 @@ const MultiLineCodeEditor = (props) => {
const hints = getSuggestions();
const serverHints = getServerSideGlobalSuggestions(isInsideQueryManager);
const serverHints = getServerSideGlobalResolveSuggestions(isInsideQueryManager);
const allHints = {
...hints,

View file

@ -98,7 +98,7 @@ export const PreviewBox = ({
const [largeDataset, setLargeDataset] = useState(false);
const globals = useStore((state) => state.getAllExposedValues(moduleId).constants || {}, shallow);
const secrets = useStore((state) => state.getSecrets(), shallow);
const globalServerConstantsRegex = /^\{\{.*globals\.server.*\}\}$/;
const globalServerConstantsRegex = /\{\{.*globals\.server.*\}\}/;
const getPreviewContent = (content, type) => {
if (content === undefined || content === null) return currentValue;
@ -251,7 +251,10 @@ const RenderResolvedValue = ({
isServerConstant = false,
isLargeDataset,
}) => {
const isServerSideGlobalEnabled = useStore((state) => !!state?.license?.featureAccess?.serverSideGlobal, shallow);
const isServerSideGlobalResolveEnabled = useStore(
(state) => !!state?.license?.featureAccess?.serverSideGlobalResolve,
shallow
);
const computeCoersionPreview = (resolvedValue, coersionData) => {
if (coersionData?.typeBeforeCoercion === coersionData?.typeAfterCoercion) return resolvedValue;
@ -276,7 +279,7 @@ const RenderResolvedValue = ({
: previewType;
const previewContent = isServerConstant
? isServerSideGlobalEnabled
? isServerSideGlobalResolveEnabled
? 'Server variables would be resolved at runtime'
: 'Server variables are only available in paid plans'
: isSecretConstant

View file

@ -216,7 +216,7 @@ const EditorInput = ({
const getSuggestions = useStore((state) => state.getSuggestions, shallow);
const [codeMirrorView, setCodeMirrorView] = useState(undefined);
const getServerSideGlobalSuggestions = useStore((state) => state.getServerSideGlobalSuggestions, shallow);
const getServerSideGlobalResolveSuggestions = useStore((state) => state.getServerSideGlobalResolveSuggestions, shallow);
const { queryPanelKeybindings } = useQueryPanelKeyHooks(onBlurUpdate, currentValue, 'singleline');
@ -226,7 +226,7 @@ const EditorInput = ({
);
function autoCompleteExtensionConfig(context) {
const hintsWithoutParamHints = getSuggestions();
const serverHints = getServerSideGlobalSuggestions(isInsideQueryManager);
const serverHints = getServerSideGlobalResolveSuggestions(isInsideQueryManager);
let word = context.matchBefore(/\w*/);

View file

@ -36,11 +36,11 @@ export const createCodeHinterSlice = (set, get) => ({
setSuggestions({ appHints: suggestionList, jsHints: jsHints });
},
getSuggestions: () => get().suggestions,
getServerSideGlobalSuggestions: (isInsideQueryManager) => {
const isServerSideGlobalEnabled = !!get()?.license?.featureAccess?.serverSideGlobal;
getServerSideGlobalResolveSuggestions: (isInsideQueryManager) => {
const isServerSideGlobalResolveEnabled = !!get()?.license?.featureAccess?.serverSideGlobalResolve;
const serverHints = [];
const hints = get().getSuggestions();
if (isInsideQueryManager && isServerSideGlobalEnabled) {
if (isInsideQueryManager && isServerSideGlobalResolveEnabled) {
serverHints.push({ hint: 'globals.server', type: 'Object' });
hints?.appHints?.forEach((appHint) => {
if (appHint?.hint?.startsWith('globals.currentUser')) {

View file

@ -19,7 +19,7 @@ export default class LicenseBase {
private _isCustomStyling: boolean;
private _isWhiteLabelling: boolean;
private _isCustomThemes: boolean;
private _isServerSideGlobal: boolean;
private _isServerSideGlobalResolve: boolean;
private _isMultiEnvironment: boolean;
private _isMultiPlayerEdit: boolean;
private _isComments: boolean;
@ -65,7 +65,7 @@ export default class LicenseBase {
this._isCustomStyling = true;
this._isWhiteLabelling = true;
this._isCustomThemes = true;
this._isServerSideGlobal = true;
this._isServerSideGlobalResolve = true;
this._isLicenseValid = true;
this._isMultiEnvironment = true;
this._isAi = true;
@ -108,7 +108,7 @@ export default class LicenseBase {
this._isWhiteLabelling = this.getFeatureValue('whiteLabelling');
this._isAppWhiteLabelling = this.getFeatureValue('appWhiteLabelling');
this._isCustomThemes = this.getFeatureValue('customThemes');
this._isServerSideGlobal = this.getFeatureValue('serverSideGlobal');
this._isServerSideGlobalResolve = this.getFeatureValue('serverSideGlobalResolve');
this._isMultiEnvironment = this.getFeatureValue('multiEnvironment');
this._isMultiPlayerEdit = this.getFeatureValue('multiPlayerEdit');
this._isComments = this.getFeatureValue('comments');
@ -285,11 +285,11 @@ export default class LicenseBase {
return this._isCustomThemes;
}
public get serverSideGlobal(): boolean {
public get serverSideGlobalResolve(): boolean {
if (this.IsBasicPlan) {
return !!this.BASIC_PLAN_TERMS.features?.serverSideGlobal;
return !!this.BASIC_PLAN_TERMS.features?.serverSideGlobalResolve;
}
return this._isServerSideGlobal;
return this._isServerSideGlobalResolve;
}
public get externalApis(): boolean {
if (this.IsBasicPlan) {
@ -340,7 +340,7 @@ export default class LicenseBase {
customStyling: this.customStyling,
whiteLabelling: this.whiteLabelling,
customThemes: this.customThemes,
serverSideGlobal: this.serverSideGlobal,
serverSideGlobalResolve: this.serverSideGlobalResolve,
multiEnvironment: this.multiEnvironment,
multiPlayerEdit: this.multiPlayerEdit,
gitSync: this.gitSync,
@ -370,7 +370,7 @@ export default class LicenseBase {
samlEnabled: this.saml,
customStylingEnabled: this.customStyling,
customThemesEnabled: this.customThemes,
serverSideGlobalEnabled: this.serverSideGlobal,
serverSideGlobalResolveEnabled: this.serverSideGlobalResolve,
multiEnvironmentEnabled: this.multiEnvironment,
multiPlayerEditEnabled: this.multiPlayerEdit,
commentsEnabled: this.comments,

View file

@ -25,7 +25,7 @@ export const BASIC_PLAN_TERMS: Partial<Terms> = {
gitSync: false,
comments: false,
customThemes: false,
serverSideGlobal: false,
serverSideGlobalResolve: false,
},
domains: [],
workflows: {

View file

@ -104,7 +104,7 @@ export enum LICENSE_FIELD {
CUSTOM_STYLE = 'customStylingEnabled',
WHITE_LABEL = 'whitelabellingEnabled',
CUSTOM_THEMES = 'customThemeEnabled',
SERVER_SIDE_GLOBAL = 'serverSideGlobalEnabled',
SERVER_SIDE_GLOBAL = 'serverSideGlobalResolveEnabled',
AUDIT_LOGS = 'auditLogsEnabled',
MAX_DURATION_FOR_AUDIT_LOGS = 'maxDaysForAuditLogs',
MULTI_ENVIRONMENT = 'multiEnvironmentEnabled',

View file

@ -60,7 +60,7 @@ export function getLicenseFieldValue(type: LICENSE_FIELD, licenseInstance: Licen
return licenseInstance.customThemes;
case LICENSE_FIELD.SERVER_SIDE_GLOBAL:
return licenseInstance.serverSideGlobal;
return licenseInstance.serverSideGlobalResolve;
case LICENSE_FIELD.EXTERNAL_API:
return licenseInstance.externalApis;

View file

@ -27,7 +27,7 @@ export interface Terms {
gitSync?: boolean;
comments?: boolean;
customThemes?: boolean;
serverSideGlobal?: boolean;
serverSideGlobalResolve?: boolean;
ai?: boolean;
externalApi?: boolean;
appWhiteLabelling?: boolean;