Skip to content

Commit

Permalink
Merge pull request #79 from bywhitebird/75-manage-component-transform…
Browse files Browse the repository at this point in the history
…ation-in-alakazam

75 manage component transformation in alakazam
  • Loading branch information
arthur-fontaine authored Jan 3, 2024
2 parents 8055215 + 63638ca commit 032bf6b
Show file tree
Hide file tree
Showing 94 changed files with 2,790 additions and 923 deletions.
84 changes: 0 additions & 84 deletions apps/alakazam/dbschema/default.esdl

This file was deleted.

97 changes: 87 additions & 10 deletions apps/alakazam/dbschema/migrations/00001.edgeql
Original file line number Diff line number Diff line change
@@ -1,24 +1,101 @@
CREATE MIGRATION m1xrvw7ei4qeqrwdbvtsdab4b7mb7xadnreyfj4b25wngj5zze5ewa
CREATE MIGRATION m1x4wfcgz4mrazao5yij7mrcug7657vvmvyftg2bisqts2chc7xvlq
ONTO initial
{
CREATE TYPE default::User {
CREATE MODULE organizations IF NOT EXISTS;
CREATE MODULE projects IF NOT EXISTS;
CREATE MODULE transformations IF NOT EXISTS;
CREATE MODULE users IF NOT EXISTS;
CREATE TYPE organizations::Organization {
CREATE REQUIRED PROPERTY name: std::str;
};
CREATE TYPE default::UserGitHubConnection {
CREATE REQUIRED PROPERTY githubId: std::int32 {
CREATE SCALAR TYPE transformations::ParserName EXTENDING enum<kaz>;
CREATE TYPE transformations::Parser {
CREATE REQUIRED PROPERTY parserName: transformations::ParserName;
CREATE OPTIONAL PROPERTY parserParameters: std::json;
};
CREATE SCALAR TYPE transformations::TransformerName EXTENDING enum<react, vue>;
CREATE TYPE transformations::Transformer {
CREATE REQUIRED PROPERTY transformerName: transformations::TransformerName;
CREATE OPTIONAL PROPERTY transformerParameters: std::json;
};
CREATE TYPE projects::Project {
CREATE MULTI LINK parsers: transformations::Parser;
CREATE MULTI LINK transformers: transformations::Transformer;
CREATE REQUIRED PROPERTY name: std::str;
};
ALTER TYPE organizations::Organization {
CREATE REQUIRED MULTI LINK projects: projects::Project {
CREATE CONSTRAINT std::exclusive;
};
CREATE REQUIRED PROPERTY githubUsername: std::str {
};
ALTER TYPE projects::Project {
CREATE REQUIRED SINGLE LINK organization := (std::assert_exists(.<projects[IS organizations::Organization]));
};
CREATE TYPE users::User {
CREATE REQUIRED PROPERTY name: std::str;
};
ALTER TYPE organizations::Organization {
CREATE REQUIRED MULTI LINK users: users::User {
CREATE CONSTRAINT std::exclusive;
CREATE PROPERTY isAdmin: std::bool {
SET default := false;
};
CREATE PROPERTY isOwner: std::bool {
SET default := false;
};
};
};
ALTER TYPE users::User {
CREATE MULTI LINK organizations := (.<users[IS organizations::Organization]);
CREATE MULTI LINK projects := (.organizations.projects);
};
CREATE ABSTRACT TYPE projects::ProjectSource;
CREATE TYPE projects::GitHubRepository EXTENDING projects::ProjectSource {
CREATE REQUIRED PROPERTY url: std::str;
CREATE CONSTRAINT std::regexp(r'^https:\/\/github\.com.*$') ON (.url);
CREATE REQUIRED PROPERTY rootDir: std::str {
SET default := '/';
};
};
ALTER TYPE projects::Project {
CREATE MULTI LINK sources: projects::ProjectSource {
CREATE CONSTRAINT std::exclusive;
};
};
ALTER TYPE default::User {
CREATE SINGLE LINK githubConnection: default::UserGitHubConnection {
SET readonly := true;
ALTER TYPE projects::ProjectSource {
CREATE REQUIRED SINGLE LINK project := (std::assert_exists(std::assert_single(.<sources[IS projects::Project])));
};
CREATE TYPE transformations::TransformationFolder {
CREATE REQUIRED SINGLE LINK project: projects::Project;
CREATE REQUIRED SINGLE LINK transformer: transformations::Transformer;
CREATE CONSTRAINT std::exclusive ON ((.project, .transformer));
CREATE REQUIRED PROPERTY date: std::datetime;
};
ALTER TYPE projects::Project {
CREATE MULTI LINK transformationFolder := (.<project[IS transformations::TransformationFolder]);
};
CREATE TYPE transformations::Transformation {
CREATE REQUIRED SINGLE LINK folder: transformations::TransformationFolder;
CREATE REQUIRED PROPERTY path: std::str;
CREATE CONSTRAINT std::exclusive ON ((.folder, .path));
CREATE REQUIRED PROPERTY content: std::str;
};
ALTER TYPE transformations::TransformationFolder {
CREATE MULTI LINK transformations := (.<folder[IS transformations::Transformation]);
};
CREATE ABSTRACT TYPE users::Identity;
CREATE TYPE users::GitHubIdentity EXTENDING users::Identity {
CREATE REQUIRED PROPERTY githubId: std::int32 {
CREATE CONSTRAINT std::exclusive;
};
CREATE REQUIRED PROPERTY githubUsername: std::str {
CREATE CONSTRAINT std::exclusive;
};
};
ALTER TYPE default::UserGitHubConnection {
CREATE SINGLE LINK user := (.<githubConnection[IS default::User]);
ALTER TYPE users::User {
CREATE MULTI LINK identities: users::Identity;
};
ALTER TYPE users::Identity {
CREATE REQUIRED SINGLE LINK user := (std::assert_single(std::assert_exists(.<identities[IS users::User])));
};
};
22 changes: 5 additions & 17 deletions apps/alakazam/dbschema/migrations/00002.edgeql
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
CREATE MIGRATION m1t4s2ey54eij2tqiule2cgysjta4qdtok6mv2g6lfjqhutubdls6q
ONTO m1xrvw7ei4qeqrwdbvtsdab4b7mb7xadnreyfj4b25wngj5zze5ewa
CREATE MIGRATION m1phwgee7mrqcajsra7xi3qcw63w2lndfnh6vo77xzwofdtig52nma
ONTO m1x4wfcgz4mrazao5yij7mrcug7657vvmvyftg2bisqts2chc7xvlq
{
CREATE TYPE default::Organization {
CREATE REQUIRED PROPERTY name: std::str;
};
CREATE TYPE default::OrganizationMember {
CREATE REQUIRED SINGLE LINK organization: default::Organization;
CREATE REQUIRED SINGLE LINK user: default::User;
CREATE CONSTRAINT std::exclusive ON ((.organization, .user));
CREATE REQUIRED PROPERTY isAdministrator: std::bool {
SET default := false;
ALTER TYPE organizations::Organization {
ALTER LINK projects {
RESET OPTIONALITY;
};
};
ALTER TYPE default::Organization {
CREATE MULTI LINK members := (.<organization[IS default::OrganizationMember]);
};
ALTER TYPE default::User {
CREATE MULTI LINK organizations := (.<user[IS default::OrganizationMember]);
};
};
17 changes: 5 additions & 12 deletions apps/alakazam/dbschema/migrations/00003.edgeql
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
CREATE MIGRATION m16aaj63lzt6n4sfmqerswsti74xr6jftgiimfafmen55o35sn5b4q
ONTO m1t4s2ey54eij2tqiule2cgysjta4qdtok6mv2g6lfjqhutubdls6q
CREATE MIGRATION m16cwt2x3aeyjwnuxkxduf6vi6jluxhtqn3zsopdjz3dlzymblnxxa
ONTO m1phwgee7mrqcajsra7xi3qcw63w2lndfnh6vo77xzwofdtig52nma
{
CREATE TYPE default::Project {
CREATE REQUIRED PROPERTY name: std::str;
};
ALTER TYPE default::Organization {
CREATE MULTI LINK projects: default::Project {
CREATE CONSTRAINT std::exclusive;
};
};
ALTER TYPE default::Project {
CREATE SINGLE LINK organization := (.<projects[IS default::Organization]);
CREATE GLOBAL users::currentUser -> std::uuid;
ALTER TYPE projects::GitHubRepository {
CREATE ANNOTATION std::title := 'GitHub';
};
};
28 changes: 7 additions & 21 deletions apps/alakazam/dbschema/migrations/00004.edgeql
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
CREATE MIGRATION m13upjhjcylvj2xg6tkbukfqbqzmwst2awsnnbreevejh5wkzhv3ja
ONTO m16aaj63lzt6n4sfmqerswsti74xr6jftgiimfafmen55o35sn5b4q
CREATE MIGRATION m1vvb2mc53ktpxioq6kad57atda5il2yoskyu3jhutvbrqgcohzccq
ONTO m16cwt2x3aeyjwnuxkxduf6vi6jluxhtqn3zsopdjz3dlzymblnxxa
{
CREATE TYPE default::GitHubRepository {
CREATE REQUIRED PROPERTY url: std::str {
CREATE CONSTRAINT std::regexp(r'^https:\/\/github\.com.*$');
ALTER TYPE projects::GitHubRepository {
DROP ANNOTATION std::title;
CREATE REQUIRED PROPERTY _type: std::str {
SET default := 'GitHubRepository';
CREATE CONSTRAINT std::regexp('^GitHubRepository$');
};
};
CREATE TYPE default::ProjectSource {
CREATE SINGLE LINK githubRepository: default::GitHubRepository {
CREATE CONSTRAINT std::exclusive;
};
};
ALTER TYPE default::GitHubRepository {
CREATE SINGLE LINK projectSource := (.<githubRepository[IS default::ProjectSource]);
};
ALTER TYPE default::Project {
CREATE MULTI LINK sources: default::ProjectSource {
CREATE CONSTRAINT std::exclusive;
};
};
ALTER TYPE default::ProjectSource {
CREATE SINGLE LINK project := (.<sources[IS default::Project]);
};
};
9 changes: 9 additions & 0 deletions apps/alakazam/dbschema/migrations/00005.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE MIGRATION m1iuvwwqmcni6ghyokeqli7ybesq7aih6j57upscxcqxsbnhkcozzq
ONTO m1vvb2mc53ktpxioq6kad57atda5il2yoskyu3jhutvbrqgcohzccq
{
ALTER TYPE organizations::Organization {
ALTER LINK users {
DROP CONSTRAINT std::exclusive;
};
};
};
9 changes: 9 additions & 0 deletions apps/alakazam/dbschema/migrations/00006.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE MIGRATION m13sgpaddg6ajliirqdy2lnma5csyktt2d2bgv7ydvmcxu2tlsghwa
ONTO m1iuvwwqmcni6ghyokeqli7ybesq7aih6j57upscxcqxsbnhkcozzq
{
ALTER TYPE projects::GitHubRepository {
CREATE REQUIRED PROPERTY installationId: std::str {
SET REQUIRED USING (<std::str>'1');
};
};
};
7 changes: 7 additions & 0 deletions apps/alakazam/dbschema/migrations/00007.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE MIGRATION m13ihmvxx6c3hup65iv5y5q6pli3y6t5gjzm4bgemvgultjexr2tnq
ONTO m13sgpaddg6ajliirqdy2lnma5csyktt2d2bgv7ydvmcxu2tlsghwa
{
ALTER TYPE projects::GitHubRepository {
DROP PROPERTY installationId;
};
};
13 changes: 13 additions & 0 deletions apps/alakazam/dbschema/organizations.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module organizations {
type Organization {
# Properties
required name: str;

# Relations
multi projects: projects::Project { constraint exclusive; }
required multi users: users::User {
isOwner: bool { default := false; }
isAdmin: bool { default := false; }
}
}
}
34 changes: 34 additions & 0 deletions apps/alakazam/dbschema/projects.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module projects {
type Project {
# Properties
required name: str;

# Relations
multi parsers: transformations::Parser;
multi transformers: transformations::Transformer;
multi sources: ProjectSource { constraint exclusive; }

# Backlinks
required single link organization := assert_exists(.<projects[is organizations::Organization]);
multi link transformationFolder := .<project[is transformations::TransformationFolder];
}

abstract type ProjectSource {
# Backlinks
required single link project := assert_exists(assert_single(.<sources[is Project]));
}

type GitHubRepository extending ProjectSource {
required _type: str {
default := 'GitHubRepository';
constraint regexp(r'^GitHubRepository$');
}

# Properties
required url: str;
required rootDir: str { default := '/'; };

# Constraints
constraint regexp(r'^https:\/\/github\.com.*$') on (.url);
}
}
42 changes: 42 additions & 0 deletions apps/alakazam/dbschema/transformations.esdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module transformations {
scalar type ParserName extending enum<kaz>;
type Parser {
# Properties
required parserName: ParserName;
optional parserParameters: json;
}

scalar type TransformerName extending enum<react, vue>;
type Transformer {
# Properties
required transformerName: TransformerName;
optional transformerParameters: json;
}

type Transformation {
# Properties
required path: str;
required content: str;

# Relations
required single folder: TransformationFolder;

# Constraints
constraint exclusive on ((.folder, .path));
}

type TransformationFolder {
# Properties
required date: datetime;

# Relations
required single transformer: Transformer;
required single project: projects::Project;

# Backlinks
multi link transformations := .<folder[is Transformation];

# Constraints
constraint exclusive on ((.project, .transformer)); # Keep one folder per project/transformer
}
}
Loading

0 comments on commit 032bf6b

Please sign in to comment.