Package: dm-cli
Data Modelling CLI ToolRequirementsThis package requires Python >=3.11InstallingTo install this CLI tool you can run the below command$pip3installdm-cliAlternatively, you clone this repo and then run this command from within the repository folder$pip3install.Both the above commands would install the package globally anddmwill be available on your system.Usage$ dm --help
Usage: dm [OPTIONS] COMMAND [ARGS]...

Options:
--version         Show the version and exit.
-t, --token TEXT  Token for authentication against DMSS.
-u, --url TEXT    URL to the Data Modelling Storage Service (DMSS).
-h, --help        Show this message and exit.

Commands:
create-lookup             Create a named Ui-/StorageRecipe-lookup-table...
ds                        Subcommand for working with data sources
entity                    Subcommand for working with entities
import-plugin-blueprints  Import blueprints from a plugin into the...
init                      Initialize the data sources and import all...
pkg                       Subcommand for working with packages
reset                     Reset all data sources (deletes and reuploads...For each of thecommandslisted above, you can rundm <COMMAND> --helpto see subcommand-specific help messages, e.g.dm ds import --helpordm pkg --helpExpected directory structureCertain commands expect a specific directory structure, such as the commandsdm reset,dm ds init, anddm ds reset.
For these commands, thepathargument must be the path to a directory with two subdirectories,data_sourcesanddata.$treeapp
app
├──data└──DemoApplicationDataSource├──instances
│└──demoApplication.json|└──models|└──DemoApplication.json
└──data_sources└──DemoApplicationDataSource.jsonTo add meta information to a package (for example to the models root package), a file with name "package.json" can be placed inside the folder.Supported reference syntaxThe CLI tool will understand and resolve these kind of type reference schemas during import.
All values with one of these keys;("type", "attributeType", "extends", "_blueprintPath_")will be evaluated for resolution.# URI - Full absolute path prefixed with protocoldmss://datasource/package/entity
dmss://datasource/package/subfolder/entity# Alias - Require dependencies to be defined somewhere in the source treeALIAS:packge/entity
ALIAS:entity# Data Source - Relative from the destination data source/package/entity
/package/subfolder/entity# Package - Relative from the source packageentity
subfolder/entity# Dotted - Relative from the file (UNIX directory traversal)./../entity
../subfolder/entity
../../subfolder/entityGeneralInitialize the data sourcesi.e. import datasources and their packages$dmdsinit[<path>]$dmdsinitapp/By default, the init command will also validate all entities that are uploaded to the database. This feature can be turned off with the flag--no-validate-entities:$dmdsinitapp/--no-validate-entitiesReset all data sourcesi.e. delete all datasources and packages, before reuploading them# Reset all datasources and their packages$dmreset[<path>]# By default, the `path` argument is set to the current working directory$dmreset# Optionally specify a path to the directory containing data sources and data$dmresetapp/By default, the reset command will also validate all entities that are uploaded to the database. This feature can be turned off with the flag--no-validate-entities:$dmresetapp--no-validate-entitiesDatasourcesImport a datasource# Import a datasource, where <path> is the path to a data source definition (JSON)$dmdsimport<path>
$dmdsimportapp/data_sources/DemoApplicationDataSource.jsonImport all datasources# Import all datasources found in the directory given by 'path'$dmdsimport-all<path>
$dmdsimport-allapp/data_sourcesReset a datasourcei.e. reset the given data source, deleting all packages and reuploading them$dmdsreset<data_source>[<path>]# By default, the `path` argument is set to the current working directory$dmdsresetDemoApplicationDataSource# Optionally specify a path to the directory containing data sources and data$dmdsresetDemoApplicationDataSourceapp/Plugin blueprintsImport blueprints from a plugin into the default plugin blueprint path (`system/Plugins/)dmimport-plugin-blueprints./node_modules/@development-framework/dm-core-pluginsNote that this is the same as;dm entity import ./node_modules/@development-framework/dm-core-plugins/blueprints/ system/Plugins/dm-core-pluginsPackagesImport a packageNote that importing a package will delete any preexisting package with the same name, if present in DMSS# Import the package <path> to the given data source$dmpkgimport<path><data_source># Import the package 'models' from app/data/DemoApplicationDataSource'$dmpkgimportapp/data/DemoApplicationDataSource/modelsDemoApplicationDataSourceImport all packages# Import all packages found in the directory given by <path>$dmpkgimport-all<path><data_source># Import all packages in 'app/data/DemoApplicationDataSource'$dmpkgimport-allapp/data/DemoApplicationDataSourceDemoApplicationDataSourceExporting packages and single documents# export document(s) by a given <data_source>/<path>$dmpkgexport<data_source>/<path>
$dmpkgexport<data_source>/<path><destination_path>
$dmpkgexport<data_source>/<path><destination_path>--unpack# Export all documents in 'DemoApplicationDataSource/models/CarPackage'$dmpkgexportDemoApplicationDataSource/models/CarPackageOptional arguments and flags:
<destination_path> : specifies where to save the downloaded file(s) on the local disk
unpack: whether or not to unpack the zip fileDelete a package# Delete the package from the datasource in DMSS$dmpkgdelete<data_source><package_name># Delete the package 'models' from 'DemoApplicationDataSource'$dmpkgdeleteDemoApplicationDataSourcemodelsDelete all packagesNote that this will only delete packages which are present in the directory , so any package present in DMSS but absent in the given directory will not be removed.# Delete all packages found in the directory given by <path>$dmpkgdelete-all<data_source><path>
$dmpkgdelete-allDemoApplicationDataSourceapp/data/DemoApplicationDataSourceEntitiesUpload a single entity$dmentityimport<local_path><destination_path>Recipe LookupCreate a named Ui-/StorageRecipe Lookup table from a package. Tell DMSS to look through a package,
gather all RecipeLinks, and create a named lookup from that. The lookup can be used to associate recipes with an application.dmcreate-lookupmyApplicationNamepath/To/A/Package/With/RecipeLinksDevelopmentYou need to have DMSS running locally.$python3-mvenv.venv
$source.venv/bin/activate
$pip3install-e.
$dmdsinitGenerating the DMSS API clientThe DMSS API client, found indm_cli/dmss_api/, can be regenerated by running the scriptgenerate-dmss-api.sh. Note that an instance of DMSS must be running locally prior to executing the script../generate-dmss-api.shNB: Due to incorrect import paths in the generated API client, you must do a search and replace after generating the new client. Replace all occurrences of 'from dmss_api' with 'from dm_cli.dmss_api' in all files underdm_cli/dmss_api/TestingInstall the dependencies:pip3 install -r requirements.txtInstall the dev dependencies:pip3 install -r dev-requirements.txtRun the tests:pytestFeedbackPlease feel free to leave feedback in issues/PRs.:+1: ContributingIf you would like to contribute, please read ourContribution guide.