[IMPLEMENTED] Seed a model / schema to an app from a design tool through events

Hi folks,
I wonder if anyone has a workflow or concept to model a schema outside squidex without UI and import it into squidex as the creation of a more complex model is quiet time consuming especially in the design / drop and recreate phase. I checked a backup file and in there are all events from creating my schema manually. So would it be an approach to write a kind of “UML” to events converter. Any thoughts or inputs on this?

Thanks and have a nice day.
Mirko

https://docs.squidex.io/02-documentation/developer-guides/automation-tools

1 Like

Hi,

I also see the demand but at the moment you have only 2 options:

  1. Write your own automation scripts
  2. Use the JSON editor for schemas:

But this is not the most comfortable way to do that.

I have this idea since a while now and this might be a good point of time to work on that.

The idea is to provide a declarative sync with the CLI.

What you create as a user is a folder with json files, e.g.

<root>
    config.json // clients, contributors
    rules
        <rule-name>.json
    schemas
        <schema-name>.json
    contens
        <schema-name>.json
    workflows
        <workflow-name>.json

For all different scripts we create json schemas, so you get auto completion with VSCode and other editors.

Then you run the CLI which updates the app based on the folder.

For each entity we need a unique name that we use for the sync:

  1. Schemas: schema name (unique)
  2. Rules: rule name (not unique, but the best we have)
  3. Clients: name (unique)
  4. Contributors: email (unique)
  5. Workflows: workflow name (not unique, but the best we have)
  6. Roles: unique
  7. Content: You define per content item which fields are unique.

Of course we can also create a folder template with the CLI.

I would also introduce additional parameters like we have them for the schema sync, e.g. to prevent deletions.

1 Like

I want to share some progress:

I am extending the CLI for 2 commands for now:

  1. sq sync template {folder}

Seeds a folder with template files and json schemas.

  1. sq sync import {folder}

Makes a sync from the folder.

Later sq sync export {folder} might come as well.

With the generated schemas you get intellisense / autocompletion in VS Code and basic validation.

1 Like

Salü Sebastian,
thanks for the CLI improvements. The complete folder export is a nice. I will check how difficult it is to export a diagram from https://www.diagrams.net/ into the squidex schema.

Have a nice evening.
Cheers
Mirko

I am not done yet, but the code is available https://github.com/Squidex/squidex-samples/pull/42

Hi @Sebastian,

Happy Weekend :slight_smile:

Is this functionality live ? I mean is it part of Mac OSX sq cli version 4.3 release. I tried the commands but it seems to not recognise it.

$sq sync template [folder-name]

Specify --help for a list of available options and commands.
Unrecognized command or argument 'sync'

Usage: dotnet Squidex.CLI.dll [options] [command]

Options:

  -v | --version          
  Show version information

  -h | --help             
  Show help information


Commands:

  backup   Manage backups.
  config   Manage configurations.
  content  Manage contents.
  info     Shows information about the CLI.
  schemas  Manage schemas.
  twitter  Manage twitter.

Use "dotnet Squidex.CLI.dll [command] --help" for more information about a command.

Usecase: I want to replicate instances in the Cloud by just exporting and importing the schemas to further create test, staging and prod instances. I see this to be the easiest way to automate replication without causing much manual intervention.

Not yet…It is also based on this feature which is not stable yet: [INPROGRESS] Support for batch operation for update (patch) and delete

This is implemented: https://docs.squidex.io/02-documentation/developer-guides/automation-tools#synchronize-all-app-settings-beta

1 Like

Is the restore functionality now live from backups in CLI ?

The sync is integrated into CLI but it requires a bulk import endpoint that is not published yet.