You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inline script isn't working in the http.yaml (src/eventsources/http.yaml). Identified while using 'jwt' and accessing secretKey from config.
While debugging the inline script "<%%>" is all considered as a string value to a key.
Solution
Need to check the core code for event sources implementation.
Identify why the inline script is all alone considered as a string by debugging.
compare the event sources core code with the data sources core code and check how the inline script is handled in data source.
Fix the missing code in the event sources core and test it.
Implementation
Identify the missing code..
datasourceLoader.ts
exportdefaultasyncfunction(pathString: string): Promise<{[key: string]: GSDataSource}>{letyamlDatasources=awaitloadYaml(pathString,false);constprismaDatasources=awaitloadPrismaDsFileNames(pathString);constdatasourcesConfigs={ ...yamlDatasources, ...prismaDatasources};if(datasourcesConfigs&&!Object.keys(datasourcesConfigs).length){thrownewError(`There are no datasources defined in datasource dir: ${pathString}`);}constdatasources: {[key: string]: GSDataSource}={};forawait(letdsNameofObject.keys(datasourcesConfigs)){logger.debug('evaluating datasource %s',dsName);datasourcesConfigs[dsName]=expandVariables(datasourcesConfigs[dsName]);logger.debug('evaluated datasource %s %o',dsName,datasourcesConfigs[dsName]);// let's load the loadFn and executeFn// there is an assumption that for each datasource, the type's .ts file should be inside /datasources/types folderconstfileName=datasourcesConfigs[dsName].type;
eventsourceLoader.ts
exportdefaultasyncfunction(eventsourcesFolderPath: string,datasources: PlainObject): Promise<{[key: string]: GSEventSource|GSDataSourceAsEventSource}>{consteventsourcesConfigs=awaitloadYaml(eventsourcesFolderPath,false);if(eventsourcesConfigs&&!Object.keys(eventsourcesConfigs).length){thrownewError(`There are no event sources defined in eventsource dir: ${eventsourcesFolderPath}`);}consteventSources: {[key: string]: GSEventSource|GSDataSourceAsEventSource}={};forawait(letesNameofObject.keys(eventsourcesConfigs)){// let's load the event sourceconsteventSourceConfig=eventsourcesConfigs[esName];try{constModule=awaitimport(path.join(eventsourcesFolderPath,'types',eventSourceConfig.type));constisPureEventSource='initClient'inModule.default.prototype;// const isPureEventSource = !!Object.hasOwnProperty.call(Module.default.prototype, 'initClient');leteventSourceInatance: GSEventSource|GSDataSourceAsEventSource;letConstructor=Module.default;if(isPureEventSource){eventSourceInatance=newConstructor(eventsourcesConfigs[esName],datasources)asGSEventSource;if('init'ineventSourceInatance){awaiteventSourceInatance.init();}}else{letcorrespondingDatasource=datasources[esName];// By design, datasource and event source need to share the same name.if(!correspondingDatasource){thrownewError(`Corresponding data source for event source ${esName} is not defined. Please ensure a data source type exists with the same file name in /datasources directory`);}else{eventSourceInatance=newConstructor(eventsourcesConfigs[esName],correspondingDatasource.client)asGSDataSourceAsEventSource;}}eventSources[esName]=eventSourceInatance;}catch(error){logger.error(error);}}
The expandVariable function is missing in eventsource and its responsibility to identify the inline script in <%%> and replace the data with requested data.
Checks
After implementing the missing code check its functionality using jwt in http.yaml.
define jwt secret key in the .env and access this variable from config/custom-environment-variables.
Use the jwt token to execute the apis which required AuthorizationBearer. If the jwt token is correct the api executes successfully which means the jwt_secret key is been accessed from config and inline script is working as expected in the eventsource yaml.
The text was updated successfully, but these errors were encountered:
Problem
Solution
Implementation
datasourceLoader.ts
eventsourceLoader.ts
expandVariable
function is missing in eventsource and its responsibility to identify the inline script in<%%>
and replace the data with requested data.Checks
jwt
in http.yaml.http.yaml
config/custom-environment-variables
.The text was updated successfully, but these errors were encountered: