-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: allowed FE features in browser * chore: added `postinstall` hook
- Loading branch information
1 parent
dc9f31e
commit 89630c6
Showing
8 changed files
with
153 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { generateScript } = require('../forward_engineering/generateScript'); | ||
const { generateContainerScript } = require('../forward_engineering/generateContainerScript'); | ||
|
||
module.exports = { | ||
generateScript, | ||
generateContainerScript, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { get } = require('lodash'); | ||
const logHelper = require('../shared/helpers/logHelper'); | ||
const ForwardEngineeringScriptBuilder = require('./services/forwardEngineeringScriptBuilder'); | ||
const { GENERATING_CONTAINER_SCRIPT } = require('../shared/enums/staticMessages'); | ||
const { includeSamples } = require('./utils/includeSamples'); | ||
|
||
/** | ||
* @param {ConnectionInfo} connectionInfo | ||
* @param {AppLogger} appLogger | ||
* @param {Callback} callback | ||
* @param {App} app | ||
*/ | ||
const generateContainerScript = async (connectionInfo, appLogger, callback, app) => { | ||
const logger = logHelper.createLogger({ | ||
title: GENERATING_CONTAINER_SCRIPT, | ||
hiddenKeys: connectionInfo.hiddenKeys, | ||
logger: appLogger, | ||
}); | ||
|
||
try { | ||
const scriptBuilder = new ForwardEngineeringScriptBuilder(); | ||
|
||
const { jsonData, collections, options } = connectionInfo; | ||
const { origin, additionalOptions } = options; | ||
const rawScope = get(connectionInfo.containerData, '[0]', {}); | ||
const scope = { | ||
...rawScope, | ||
bucketName: rawScope?.bucket ?? '', | ||
}; | ||
const collectionsData = collections.map(schema => ({ | ||
...JSON.parse(schema), | ||
namespace: scope?.namespace, | ||
bucketName: scope?.bucketName, | ||
scopeName: scope?.name, | ||
})); | ||
|
||
scriptBuilder.addScopeScript(scope); | ||
collectionsData.forEach(collection => scriptBuilder.addCollectionScripts(collection)); | ||
|
||
if (!includeSamples(additionalOptions)) { | ||
const { script } = scriptBuilder.buildScriptSeparateFromInsertScripts(); | ||
return callback(null, script); | ||
} | ||
|
||
scriptBuilder.addContainerInsertScripts({ collections: collectionsData, jsonData }); | ||
|
||
if (origin !== 'ui') { | ||
return callback(null, scriptBuilder.buildScriptConcatenatedWithInsertScripts('\n\n')); | ||
} | ||
|
||
const { script, insertScripts } = scriptBuilder.buildScriptSeparateFromInsertScripts(); | ||
callback(null, [ | ||
{ title: 'Couchbase script', script }, | ||
{ | ||
title: 'Sample data', | ||
script: insertScripts, | ||
}, | ||
]); | ||
} catch (error) { | ||
logger.error(error); | ||
|
||
callback({ message: error.message, stack: error.stack }); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
generateContainerScript, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const { get } = require('lodash'); | ||
const logHelper = require('../shared/helpers/logHelper'); | ||
const { GENERATING_ENTITY_SCRIPT } = require('../shared/enums/staticMessages'); | ||
const ForwardEngineeringScriptBuilder = require('./services/forwardEngineeringScriptBuilder'); | ||
const { includeSamples } = require('./utils/includeSamples'); | ||
|
||
/** | ||
* @param {ConnectionInfo} connectionInfo | ||
* @param {AppLogger} appLogger | ||
* @param {Callback} callback | ||
* @param {App} app | ||
*/ | ||
const generateScript = async (connectionInfo, appLogger, callback, app) => { | ||
const logger = logHelper.createLogger({ | ||
title: GENERATING_ENTITY_SCRIPT, | ||
hiddenKeys: connectionInfo.hiddenKeys, | ||
logger: appLogger, | ||
}); | ||
|
||
try { | ||
const scriptBuilder = new ForwardEngineeringScriptBuilder(); | ||
|
||
const { jsonData, jsonSchema, containerData, options } = connectionInfo; | ||
const { additionalOptions } = options; | ||
const scope = get(containerData, '[0]', {}); | ||
const rawCollectionData = JSON.parse(jsonSchema); | ||
const collectionData = { | ||
...rawCollectionData, | ||
namespace: scope?.namespace, | ||
bucketName: scope?.bucket, | ||
scopeName: scope?.name, | ||
collectionName: rawCollectionData.title, | ||
}; | ||
|
||
scriptBuilder.addCollectionScripts(collectionData); | ||
if (!includeSamples(additionalOptions)) { | ||
const { script } = scriptBuilder.buildScriptSeparateFromInsertScripts(); | ||
return callback(null, script); | ||
} | ||
|
||
scriptBuilder.addCollectionInsertScripts({ | ||
jsonData, | ||
collection: collectionData, | ||
}); | ||
|
||
const { script, insertScripts } = scriptBuilder.buildScriptSeparateFromInsertScripts(); | ||
callback(null, [ | ||
{ title: 'Couchbase script', script }, | ||
{ | ||
title: 'Sample data', | ||
script: insertScripts, | ||
}, | ||
]); | ||
} catch (error) { | ||
logger.error(error); | ||
|
||
callback({ message: error.message, stack: error.stack }); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
generateScript, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const includeSamples = (additionalOptions = []) => | ||
Boolean(additionalOptions.find(option => option.id === 'INCLUDE_SAMPLES' && option.value)); | ||
|
||
module.exports = { | ||
includeSamples, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters