Compare commits

..

3 Commits

Author SHA1 Message Date
Jeff McCune
79e8ab639a (#161) Fix the FormGroup & Refactor API
The way we were organizing fields into section broke Formly validation.
This patch fixes the problem by using the recommended approach of
[Nested Forms][1].

This patch also refactors the PlatformService API to clean it up.
GetForm / PutForm are separated from the Platform methods.  Similarly
GetModel / PutModel are separated out and are specific to get and put
the model data.

NOTE: I'm not sure we should have separated out the platform service
into it's own protobuf package.  Seems maybe unnecessary.

❯ grpcurl -H "x-oidc-id-token: $(holos token)" -d '{"platform_id":"018f36fb-e3ff-7f7f-a5d1-7ca2bf499e94"}' jeff.app.dev.k2.holos.run:443 holos.platform.v1alpha1.PlatformService.GetModel
{
  "model": {
    "org": {
      "contactEmail": "platform@openinfrastructure.co",
      "displayName": "Open Infrastructure Services LLC",
      "domain": "ois.run",
      "name": "ois"
    },
    "privacy": {
      "country": "earth",
      "regions": [
        "us-east-2",
        "us-west-2"
      ]
    },
    "terms": {
      "didAgree": true
    }
  }
}

[1]: https://formly.dev/docs/examples/other/nested-formly-forms
2024-05-04 10:14:37 -07:00
Jeff McCune
a0cc673736 (#150) Wire up select and multi select boxes
This patch wires up a Select and a Multi Select box.  This patch also
establishes a decision as it relates to Formly TypeScript / gRPC Proto3
/ CUE definitions of the form data structure.  The decision is to use
gRPC as a transport for any JSON to avoid friction trying to fit Formly
types into Proto3 messages.

Note when using google.protobuf.Value messages with bufbuild/connect-es,
we need to round trip them one last time through JSON to get the
original JSON on the other side.  This is because connect-es preserves
the type discriminators in the case and value fields of the message.

Refer to: [Accessing oneof
groups](https://github.com/bufbuild/protobuf-es/blob/main/docs/runtime_api.md#accessing-oneof-groups)

NOTE: On the wire, carry any JSON as field configs for expedience.  I
attempted to reflect FormlyFieldConfig in protobuf, but it was too time
consuming.  The loosely defined Formly json data API creates significant
friction when joined with a well defined protobuf API.  Therefore, we do
not specify anything about the Forms API, convey any valid JSON, and
leave it up to CUE and Formly on the sending and receiving side of the
API.

We use CUE to define our own holos form elements as a subset of the loose
Formly definitions.  We further hope Formly will move toward a better JSON
data API, but it's unlikely.  Consider replacing Formly entirely and
building on top of the strongly typed Angular Dyanmic Forms API.

Refer to: https://github.com/ngx-formly/ngx-formly/blob/v6.3.0/src/core/src/lib/models/fieldconfig.ts#L15
Consider: https://angular.io/guide/dynamic-form

Usage:

Generate the form from CUE

    cue export ./forms/platform/ --out json | jq -cM | pbcopy

Store the form JSON in the config_values column of the platforms table.

View the form, and submit some data. Then get the data back out for use rendering the platform:

    grpcurl -H "x-oidc-id-token: $(holos token)" -d '{"platform_id":"'${platformId}'"}' $holos holos.v1alpha1.PlatformService.GetConfig

```json
{
  "platform": {
    "spec": {
      "config": {
        "user": {
          "sections": {
            "org": {
              "fields": {
                "contactEmail": "jeff@openinfrastructure.co",
                "displayName": "Open Infrastructure Services LLC",
                "domain": "ois.run",
                "name": "ois"
              }
            },
            "privacy": {
              "fields": {
                "country": "earth",
                "regions": [
                  "us-east-2",
                  "us-west-2"
                ]
              }
            },
            "terms": {
              "fields": {
                "didAgree": true
              }
            }
          }
        }
      }
    }
  }
}
```
2024-05-03 10:42:03 -07:00
Jeff McCune
d06ecfadc8 (#150) Refactor PlatformService.GetConfig for use with CUE
Problem:
The GetConfig response value isn't directly usable with CUE without some
gymnastics.

Solution:
Refactor the protobuf definition and response output to make the user
defined and supplied config values provided by the API directly usable
in the CUE code that defines the platform.

Result:

The top level platform config is directly usable in the
`internal/platforms/bare` directory:

    grpcurl -H "x-oidc-id-token: $(holos token)" -d '{"platform_id":"'${platformID}'"}' $host \
      holos.v1alpha1.PlatformService.GetConfig \
      > platform.holos.json

Vet the user supplied data:

    cue vet ./ -d '#PlatformConfig' platform.holos.json

Build the holos component.  The ConfigMap consumes the user supplied
data:

    cue export --out yaml -t cluster=k2 ./components/configmap platform.holos.json \
      | yq .spec.components

Note the data provided by the input form is embedded into the
ConfigMap managed by Holos:

```yaml
KubernetesObjectsList:
  - metadata:
      name: platform-configmap
    apiObjectMap:
      ConfigMap:
        platform: |
          metadata:
            name: platform
            namespace: default
            labels:
              app.holos.run/managed: "true"
          data:
            platform: |
              kind: Platform
              spec:
                config:
                  user:
                    sections:
                      org:
                        fields:
                          contactEmail: jeff@openinfrastructure.co
                          displayName: Open Infrastructure Services LLC
                          domain: ois.run
                          name: ois
              apiVersion: app.holos.run/v1alpha1
              metadata:
                name: bare
                labels: {}
                annotations: {}
              holos:
                flags:
                  cluster: k2
          kind: ConfigMap
          apiVersion: v1
    Skip: false
```
2024-05-02 06:39:33 -07:00
45 changed files with 2747 additions and 1746 deletions

View File

@@ -17,7 +17,7 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -365,7 +365,7 @@ func (c *OrganizationClient) QueryPlatforms(o *Organization) *PlatformQuery {
id := o.ID
step := sqlgraph.NewStep(
sqlgraph.From(organization.Table, organization.FieldID, id),
sqlgraph.To(platform.Table, platform.FieldID),
sqlgraph.To(entplatform.Table, entplatform.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, organization.PlatformsTable, organization.PlatformsColumn),
)
fromV = sqlgraph.Neighbors(o.driver.Dialect(), step)
@@ -410,13 +410,13 @@ func NewPlatformClient(c config) *PlatformClient {
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `platform.Hooks(f(g(h())))`.
// A call to `Use(f, g, h)` equals to `entplatform.Hooks(f(g(h())))`.
func (c *PlatformClient) Use(hooks ...Hook) {
c.hooks.Platform = append(c.hooks.Platform, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `platform.Intercept(f(g(h())))`.
// A call to `Intercept(f, g, h)` equals to `entplatform.Intercept(f(g(h())))`.
func (c *PlatformClient) Intercept(interceptors ...Interceptor) {
c.inters.Platform = append(c.inters.Platform, interceptors...)
}
@@ -478,7 +478,7 @@ func (c *PlatformClient) DeleteOne(pl *Platform) *PlatformDeleteOne {
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *PlatformClient) DeleteOneID(id uuid.UUID) *PlatformDeleteOne {
builder := c.Delete().Where(platform.ID(id))
builder := c.Delete().Where(entplatform.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &PlatformDeleteOne{builder}
@@ -495,7 +495,7 @@ func (c *PlatformClient) Query() *PlatformQuery {
// Get returns a Platform entity by its id.
func (c *PlatformClient) Get(ctx context.Context, id uuid.UUID) (*Platform, error) {
return c.Query().Where(platform.ID(id)).Only(ctx)
return c.Query().Where(entplatform.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
@@ -513,9 +513,9 @@ func (c *PlatformClient) QueryCreator(pl *Platform) *UserQuery {
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := pl.ID
step := sqlgraph.NewStep(
sqlgraph.From(platform.Table, platform.FieldID, id),
sqlgraph.From(entplatform.Table, entplatform.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, platform.CreatorTable, platform.CreatorColumn),
sqlgraph.Edge(sqlgraph.M2O, false, entplatform.CreatorTable, entplatform.CreatorColumn),
)
fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step)
return fromV, nil
@@ -529,9 +529,9 @@ func (c *PlatformClient) QueryOrganization(pl *Platform) *OrganizationQuery {
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := pl.ID
step := sqlgraph.NewStep(
sqlgraph.From(platform.Table, platform.FieldID, id),
sqlgraph.From(entplatform.Table, entplatform.FieldID, id),
sqlgraph.To(organization.Table, organization.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, platform.OrganizationTable, platform.OrganizationColumn),
sqlgraph.Edge(sqlgraph.M2O, false, entplatform.OrganizationTable, entplatform.OrganizationColumn),
)
fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step)
return fromV, nil

View File

@@ -13,7 +13,8 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -76,7 +77,7 @@ func checkColumn(table, column string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
organization.Table: organization.ValidColumn,
platform.Table: platform.ValidColumn,
entplatform.Table: entplatform.ValidColumn,
user.Table: user.ValidColumn,
})
})

View File

@@ -38,10 +38,10 @@ var (
{Name: "updated_at", Type: field.TypeTime},
{Name: "name", Type: field.TypeString},
{Name: "display_name", Type: field.TypeString},
{Name: "config_form", Type: field.TypeJSON, Nullable: true},
{Name: "config_values", Type: field.TypeJSON, Nullable: true},
{Name: "config_cue", Type: field.TypeBytes, Nullable: true},
{Name: "config_definition", Type: field.TypeString, Nullable: true},
{Name: "form", Type: field.TypeJSON, Nullable: true},
{Name: "model", Type: field.TypeJSON, Nullable: true},
{Name: "cue", Type: field.TypeBytes, Nullable: true},
{Name: "cue_definition", Type: field.TypeString, Nullable: true},
{Name: "creator_id", Type: field.TypeUUID},
{Name: "org_id", Type: field.TypeUUID},
}

View File

@@ -13,10 +13,10 @@ import (
"entgo.io/ent/dialect/sql"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/predicate"
"github.com/holos-run/holos/internal/ent/user"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
platform "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
)
const (
@@ -813,10 +813,10 @@ type PlatformMutation struct {
updated_at *time.Time
name *string
display_name *string
config_form **holos.PlatformForm
config_values **holos.ConfigValues
config_cue *[]byte
config_definition *string
form **platform.Form
model **platform.Model
cue *[]byte
cue_definition *string
clearedFields map[string]struct{}
creator *uuid.UUID
clearedcreator bool
@@ -1147,206 +1147,206 @@ func (m *PlatformMutation) ResetCreatorID() {
m.creator = nil
}
// SetConfigForm sets the "config_form" field.
func (m *PlatformMutation) SetConfigForm(hf *holos.PlatformForm) {
m.config_form = &hf
// SetForm sets the "form" field.
func (m *PlatformMutation) SetForm(pl *platform.Form) {
m.form = &pl
}
// ConfigForm returns the value of the "config_form" field in the mutation.
func (m *PlatformMutation) ConfigForm() (r *holos.PlatformForm, exists bool) {
v := m.config_form
// Form returns the value of the "form" field in the mutation.
func (m *PlatformMutation) Form() (r *platform.Form, exists bool) {
v := m.form
if v == nil {
return
}
return *v, true
}
// OldConfigForm returns the old "config_form" field's value of the Platform entity.
// OldForm returns the old "form" field's value of the Platform entity.
// If the Platform object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlatformMutation) OldConfigForm(ctx context.Context) (v *holos.PlatformForm, err error) {
func (m *PlatformMutation) OldForm(ctx context.Context) (v *platform.Form, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldConfigForm is only allowed on UpdateOne operations")
return v, errors.New("OldForm is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldConfigForm requires an ID field in the mutation")
return v, errors.New("OldForm requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldConfigForm: %w", err)
return v, fmt.Errorf("querying old value for OldForm: %w", err)
}
return oldValue.ConfigForm, nil
return oldValue.Form, nil
}
// ClearConfigForm clears the value of the "config_form" field.
func (m *PlatformMutation) ClearConfigForm() {
m.config_form = nil
m.clearedFields[platform.FieldConfigForm] = struct{}{}
// ClearForm clears the value of the "form" field.
func (m *PlatformMutation) ClearForm() {
m.form = nil
m.clearedFields[entplatform.FieldForm] = struct{}{}
}
// ConfigFormCleared returns if the "config_form" field was cleared in this mutation.
func (m *PlatformMutation) ConfigFormCleared() bool {
_, ok := m.clearedFields[platform.FieldConfigForm]
// FormCleared returns if the "form" field was cleared in this mutation.
func (m *PlatformMutation) FormCleared() bool {
_, ok := m.clearedFields[entplatform.FieldForm]
return ok
}
// ResetConfigForm resets all changes to the "config_form" field.
func (m *PlatformMutation) ResetConfigForm() {
m.config_form = nil
delete(m.clearedFields, platform.FieldConfigForm)
// ResetForm resets all changes to the "form" field.
func (m *PlatformMutation) ResetForm() {
m.form = nil
delete(m.clearedFields, entplatform.FieldForm)
}
// SetConfigValues sets the "config_values" field.
func (m *PlatformMutation) SetConfigValues(hv *holos.ConfigValues) {
m.config_values = &hv
// SetModel sets the "model" field.
func (m *PlatformMutation) SetModel(pl *platform.Model) {
m.model = &pl
}
// ConfigValues returns the value of the "config_values" field in the mutation.
func (m *PlatformMutation) ConfigValues() (r *holos.ConfigValues, exists bool) {
v := m.config_values
// Model returns the value of the "model" field in the mutation.
func (m *PlatformMutation) Model() (r *platform.Model, exists bool) {
v := m.model
if v == nil {
return
}
return *v, true
}
// OldConfigValues returns the old "config_values" field's value of the Platform entity.
// OldModel returns the old "model" field's value of the Platform entity.
// If the Platform object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlatformMutation) OldConfigValues(ctx context.Context) (v *holos.ConfigValues, err error) {
func (m *PlatformMutation) OldModel(ctx context.Context) (v *platform.Model, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldConfigValues is only allowed on UpdateOne operations")
return v, errors.New("OldModel is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldConfigValues requires an ID field in the mutation")
return v, errors.New("OldModel requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldConfigValues: %w", err)
return v, fmt.Errorf("querying old value for OldModel: %w", err)
}
return oldValue.ConfigValues, nil
return oldValue.Model, nil
}
// ClearConfigValues clears the value of the "config_values" field.
func (m *PlatformMutation) ClearConfigValues() {
m.config_values = nil
m.clearedFields[platform.FieldConfigValues] = struct{}{}
// ClearModel clears the value of the "model" field.
func (m *PlatformMutation) ClearModel() {
m.model = nil
m.clearedFields[entplatform.FieldModel] = struct{}{}
}
// ConfigValuesCleared returns if the "config_values" field was cleared in this mutation.
func (m *PlatformMutation) ConfigValuesCleared() bool {
_, ok := m.clearedFields[platform.FieldConfigValues]
// ModelCleared returns if the "model" field was cleared in this mutation.
func (m *PlatformMutation) ModelCleared() bool {
_, ok := m.clearedFields[entplatform.FieldModel]
return ok
}
// ResetConfigValues resets all changes to the "config_values" field.
func (m *PlatformMutation) ResetConfigValues() {
m.config_values = nil
delete(m.clearedFields, platform.FieldConfigValues)
// ResetModel resets all changes to the "model" field.
func (m *PlatformMutation) ResetModel() {
m.model = nil
delete(m.clearedFields, entplatform.FieldModel)
}
// SetConfigCue sets the "config_cue" field.
func (m *PlatformMutation) SetConfigCue(b []byte) {
m.config_cue = &b
// SetCue sets the "cue" field.
func (m *PlatformMutation) SetCue(b []byte) {
m.cue = &b
}
// ConfigCue returns the value of the "config_cue" field in the mutation.
func (m *PlatformMutation) ConfigCue() (r []byte, exists bool) {
v := m.config_cue
// Cue returns the value of the "cue" field in the mutation.
func (m *PlatformMutation) Cue() (r []byte, exists bool) {
v := m.cue
if v == nil {
return
}
return *v, true
}
// OldConfigCue returns the old "config_cue" field's value of the Platform entity.
// OldCue returns the old "cue" field's value of the Platform entity.
// If the Platform object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlatformMutation) OldConfigCue(ctx context.Context) (v []byte, err error) {
func (m *PlatformMutation) OldCue(ctx context.Context) (v []byte, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldConfigCue is only allowed on UpdateOne operations")
return v, errors.New("OldCue is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldConfigCue requires an ID field in the mutation")
return v, errors.New("OldCue requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldConfigCue: %w", err)
return v, fmt.Errorf("querying old value for OldCue: %w", err)
}
return oldValue.ConfigCue, nil
return oldValue.Cue, nil
}
// ClearConfigCue clears the value of the "config_cue" field.
func (m *PlatformMutation) ClearConfigCue() {
m.config_cue = nil
m.clearedFields[platform.FieldConfigCue] = struct{}{}
// ClearCue clears the value of the "cue" field.
func (m *PlatformMutation) ClearCue() {
m.cue = nil
m.clearedFields[entplatform.FieldCue] = struct{}{}
}
// ConfigCueCleared returns if the "config_cue" field was cleared in this mutation.
func (m *PlatformMutation) ConfigCueCleared() bool {
_, ok := m.clearedFields[platform.FieldConfigCue]
// CueCleared returns if the "cue" field was cleared in this mutation.
func (m *PlatformMutation) CueCleared() bool {
_, ok := m.clearedFields[entplatform.FieldCue]
return ok
}
// ResetConfigCue resets all changes to the "config_cue" field.
func (m *PlatformMutation) ResetConfigCue() {
m.config_cue = nil
delete(m.clearedFields, platform.FieldConfigCue)
// ResetCue resets all changes to the "cue" field.
func (m *PlatformMutation) ResetCue() {
m.cue = nil
delete(m.clearedFields, entplatform.FieldCue)
}
// SetConfigDefinition sets the "config_definition" field.
func (m *PlatformMutation) SetConfigDefinition(s string) {
m.config_definition = &s
// SetCueDefinition sets the "cue_definition" field.
func (m *PlatformMutation) SetCueDefinition(s string) {
m.cue_definition = &s
}
// ConfigDefinition returns the value of the "config_definition" field in the mutation.
func (m *PlatformMutation) ConfigDefinition() (r string, exists bool) {
v := m.config_definition
// CueDefinition returns the value of the "cue_definition" field in the mutation.
func (m *PlatformMutation) CueDefinition() (r string, exists bool) {
v := m.cue_definition
if v == nil {
return
}
return *v, true
}
// OldConfigDefinition returns the old "config_definition" field's value of the Platform entity.
// OldCueDefinition returns the old "cue_definition" field's value of the Platform entity.
// If the Platform object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *PlatformMutation) OldConfigDefinition(ctx context.Context) (v string, err error) {
func (m *PlatformMutation) OldCueDefinition(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldConfigDefinition is only allowed on UpdateOne operations")
return v, errors.New("OldCueDefinition is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldConfigDefinition requires an ID field in the mutation")
return v, errors.New("OldCueDefinition requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldConfigDefinition: %w", err)
return v, fmt.Errorf("querying old value for OldCueDefinition: %w", err)
}
return oldValue.ConfigDefinition, nil
return oldValue.CueDefinition, nil
}
// ClearConfigDefinition clears the value of the "config_definition" field.
func (m *PlatformMutation) ClearConfigDefinition() {
m.config_definition = nil
m.clearedFields[platform.FieldConfigDefinition] = struct{}{}
// ClearCueDefinition clears the value of the "cue_definition" field.
func (m *PlatformMutation) ClearCueDefinition() {
m.cue_definition = nil
m.clearedFields[entplatform.FieldCueDefinition] = struct{}{}
}
// ConfigDefinitionCleared returns if the "config_definition" field was cleared in this mutation.
func (m *PlatformMutation) ConfigDefinitionCleared() bool {
_, ok := m.clearedFields[platform.FieldConfigDefinition]
// CueDefinitionCleared returns if the "cue_definition" field was cleared in this mutation.
func (m *PlatformMutation) CueDefinitionCleared() bool {
_, ok := m.clearedFields[entplatform.FieldCueDefinition]
return ok
}
// ResetConfigDefinition resets all changes to the "config_definition" field.
func (m *PlatformMutation) ResetConfigDefinition() {
m.config_definition = nil
delete(m.clearedFields, platform.FieldConfigDefinition)
// ResetCueDefinition resets all changes to the "cue_definition" field.
func (m *PlatformMutation) ResetCueDefinition() {
m.cue_definition = nil
delete(m.clearedFields, entplatform.FieldCueDefinition)
}
// ClearCreator clears the "creator" edge to the User entity.
func (m *PlatformMutation) ClearCreator() {
m.clearedcreator = true
m.clearedFields[platform.FieldCreatorID] = struct{}{}
m.clearedFields[entplatform.FieldCreatorID] = struct{}{}
}
// CreatorCleared reports if the "creator" edge to the User entity was cleared.
@@ -1378,7 +1378,7 @@ func (m *PlatformMutation) SetOrganizationID(id uuid.UUID) {
// ClearOrganization clears the "organization" edge to the Organization entity.
func (m *PlatformMutation) ClearOrganization() {
m.clearedorganization = true
m.clearedFields[platform.FieldOrgID] = struct{}{}
m.clearedFields[entplatform.FieldOrgID] = struct{}{}
}
// OrganizationCleared reports if the "organization" edge to the Organization entity was cleared.
@@ -1446,34 +1446,34 @@ func (m *PlatformMutation) Type() string {
func (m *PlatformMutation) Fields() []string {
fields := make([]string, 0, 10)
if m.created_at != nil {
fields = append(fields, platform.FieldCreatedAt)
fields = append(fields, entplatform.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, platform.FieldUpdatedAt)
fields = append(fields, entplatform.FieldUpdatedAt)
}
if m.organization != nil {
fields = append(fields, platform.FieldOrgID)
fields = append(fields, entplatform.FieldOrgID)
}
if m.name != nil {
fields = append(fields, platform.FieldName)
fields = append(fields, entplatform.FieldName)
}
if m.display_name != nil {
fields = append(fields, platform.FieldDisplayName)
fields = append(fields, entplatform.FieldDisplayName)
}
if m.creator != nil {
fields = append(fields, platform.FieldCreatorID)
fields = append(fields, entplatform.FieldCreatorID)
}
if m.config_form != nil {
fields = append(fields, platform.FieldConfigForm)
if m.form != nil {
fields = append(fields, entplatform.FieldForm)
}
if m.config_values != nil {
fields = append(fields, platform.FieldConfigValues)
if m.model != nil {
fields = append(fields, entplatform.FieldModel)
}
if m.config_cue != nil {
fields = append(fields, platform.FieldConfigCue)
if m.cue != nil {
fields = append(fields, entplatform.FieldCue)
}
if m.config_definition != nil {
fields = append(fields, platform.FieldConfigDefinition)
if m.cue_definition != nil {
fields = append(fields, entplatform.FieldCueDefinition)
}
return fields
}
@@ -1483,26 +1483,26 @@ func (m *PlatformMutation) Fields() []string {
// schema.
func (m *PlatformMutation) Field(name string) (ent.Value, bool) {
switch name {
case platform.FieldCreatedAt:
case entplatform.FieldCreatedAt:
return m.CreatedAt()
case platform.FieldUpdatedAt:
case entplatform.FieldUpdatedAt:
return m.UpdatedAt()
case platform.FieldOrgID:
case entplatform.FieldOrgID:
return m.OrgID()
case platform.FieldName:
case entplatform.FieldName:
return m.Name()
case platform.FieldDisplayName:
case entplatform.FieldDisplayName:
return m.DisplayName()
case platform.FieldCreatorID:
case entplatform.FieldCreatorID:
return m.CreatorID()
case platform.FieldConfigForm:
return m.ConfigForm()
case platform.FieldConfigValues:
return m.ConfigValues()
case platform.FieldConfigCue:
return m.ConfigCue()
case platform.FieldConfigDefinition:
return m.ConfigDefinition()
case entplatform.FieldForm:
return m.Form()
case entplatform.FieldModel:
return m.Model()
case entplatform.FieldCue:
return m.Cue()
case entplatform.FieldCueDefinition:
return m.CueDefinition()
}
return nil, false
}
@@ -1512,26 +1512,26 @@ func (m *PlatformMutation) Field(name string) (ent.Value, bool) {
// database failed.
func (m *PlatformMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case platform.FieldCreatedAt:
case entplatform.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case platform.FieldUpdatedAt:
case entplatform.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
case platform.FieldOrgID:
case entplatform.FieldOrgID:
return m.OldOrgID(ctx)
case platform.FieldName:
case entplatform.FieldName:
return m.OldName(ctx)
case platform.FieldDisplayName:
case entplatform.FieldDisplayName:
return m.OldDisplayName(ctx)
case platform.FieldCreatorID:
case entplatform.FieldCreatorID:
return m.OldCreatorID(ctx)
case platform.FieldConfigForm:
return m.OldConfigForm(ctx)
case platform.FieldConfigValues:
return m.OldConfigValues(ctx)
case platform.FieldConfigCue:
return m.OldConfigCue(ctx)
case platform.FieldConfigDefinition:
return m.OldConfigDefinition(ctx)
case entplatform.FieldForm:
return m.OldForm(ctx)
case entplatform.FieldModel:
return m.OldModel(ctx)
case entplatform.FieldCue:
return m.OldCue(ctx)
case entplatform.FieldCueDefinition:
return m.OldCueDefinition(ctx)
}
return nil, fmt.Errorf("unknown Platform field %s", name)
}
@@ -1541,75 +1541,75 @@ func (m *PlatformMutation) OldField(ctx context.Context, name string) (ent.Value
// type.
func (m *PlatformMutation) SetField(name string, value ent.Value) error {
switch name {
case platform.FieldCreatedAt:
case entplatform.FieldCreatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatedAt(v)
return nil
case platform.FieldUpdatedAt:
case entplatform.FieldUpdatedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUpdatedAt(v)
return nil
case platform.FieldOrgID:
case entplatform.FieldOrgID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOrgID(v)
return nil
case platform.FieldName:
case entplatform.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case platform.FieldDisplayName:
case entplatform.FieldDisplayName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDisplayName(v)
return nil
case platform.FieldCreatorID:
case entplatform.FieldCreatorID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreatorID(v)
return nil
case platform.FieldConfigForm:
v, ok := value.(*holos.PlatformForm)
case entplatform.FieldForm:
v, ok := value.(*platform.Form)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetConfigForm(v)
m.SetForm(v)
return nil
case platform.FieldConfigValues:
v, ok := value.(*holos.ConfigValues)
case entplatform.FieldModel:
v, ok := value.(*platform.Model)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetConfigValues(v)
m.SetModel(v)
return nil
case platform.FieldConfigCue:
case entplatform.FieldCue:
v, ok := value.([]byte)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetConfigCue(v)
m.SetCue(v)
return nil
case platform.FieldConfigDefinition:
case entplatform.FieldCueDefinition:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetConfigDefinition(v)
m.SetCueDefinition(v)
return nil
}
return fmt.Errorf("unknown Platform field %s", name)
@@ -1641,17 +1641,17 @@ func (m *PlatformMutation) AddField(name string, value ent.Value) error {
// mutation.
func (m *PlatformMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(platform.FieldConfigForm) {
fields = append(fields, platform.FieldConfigForm)
if m.FieldCleared(entplatform.FieldForm) {
fields = append(fields, entplatform.FieldForm)
}
if m.FieldCleared(platform.FieldConfigValues) {
fields = append(fields, platform.FieldConfigValues)
if m.FieldCleared(entplatform.FieldModel) {
fields = append(fields, entplatform.FieldModel)
}
if m.FieldCleared(platform.FieldConfigCue) {
fields = append(fields, platform.FieldConfigCue)
if m.FieldCleared(entplatform.FieldCue) {
fields = append(fields, entplatform.FieldCue)
}
if m.FieldCleared(platform.FieldConfigDefinition) {
fields = append(fields, platform.FieldConfigDefinition)
if m.FieldCleared(entplatform.FieldCueDefinition) {
fields = append(fields, entplatform.FieldCueDefinition)
}
return fields
}
@@ -1667,17 +1667,17 @@ func (m *PlatformMutation) FieldCleared(name string) bool {
// error if the field is not defined in the schema.
func (m *PlatformMutation) ClearField(name string) error {
switch name {
case platform.FieldConfigForm:
m.ClearConfigForm()
case entplatform.FieldForm:
m.ClearForm()
return nil
case platform.FieldConfigValues:
m.ClearConfigValues()
case entplatform.FieldModel:
m.ClearModel()
return nil
case platform.FieldConfigCue:
m.ClearConfigCue()
case entplatform.FieldCue:
m.ClearCue()
return nil
case platform.FieldConfigDefinition:
m.ClearConfigDefinition()
case entplatform.FieldCueDefinition:
m.ClearCueDefinition()
return nil
}
return fmt.Errorf("unknown Platform nullable field %s", name)
@@ -1687,35 +1687,35 @@ func (m *PlatformMutation) ClearField(name string) error {
// It returns an error if the field is not defined in the schema.
func (m *PlatformMutation) ResetField(name string) error {
switch name {
case platform.FieldCreatedAt:
case entplatform.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case platform.FieldUpdatedAt:
case entplatform.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
case platform.FieldOrgID:
case entplatform.FieldOrgID:
m.ResetOrgID()
return nil
case platform.FieldName:
case entplatform.FieldName:
m.ResetName()
return nil
case platform.FieldDisplayName:
case entplatform.FieldDisplayName:
m.ResetDisplayName()
return nil
case platform.FieldCreatorID:
case entplatform.FieldCreatorID:
m.ResetCreatorID()
return nil
case platform.FieldConfigForm:
m.ResetConfigForm()
case entplatform.FieldForm:
m.ResetForm()
return nil
case platform.FieldConfigValues:
m.ResetConfigValues()
case entplatform.FieldModel:
m.ResetModel()
return nil
case platform.FieldConfigCue:
m.ResetConfigCue()
case entplatform.FieldCue:
m.ResetCue()
return nil
case platform.FieldConfigDefinition:
m.ResetConfigDefinition()
case entplatform.FieldCueDefinition:
m.ResetCueDefinition()
return nil
}
return fmt.Errorf("unknown Platform field %s", name)
@@ -1725,10 +1725,10 @@ func (m *PlatformMutation) ResetField(name string) error {
func (m *PlatformMutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.creator != nil {
edges = append(edges, platform.EdgeCreator)
edges = append(edges, entplatform.EdgeCreator)
}
if m.organization != nil {
edges = append(edges, platform.EdgeOrganization)
edges = append(edges, entplatform.EdgeOrganization)
}
return edges
}
@@ -1737,11 +1737,11 @@ func (m *PlatformMutation) AddedEdges() []string {
// name in this mutation.
func (m *PlatformMutation) AddedIDs(name string) []ent.Value {
switch name {
case platform.EdgeCreator:
case entplatform.EdgeCreator:
if id := m.creator; id != nil {
return []ent.Value{*id}
}
case platform.EdgeOrganization:
case entplatform.EdgeOrganization:
if id := m.organization; id != nil {
return []ent.Value{*id}
}
@@ -1765,10 +1765,10 @@ func (m *PlatformMutation) RemovedIDs(name string) []ent.Value {
func (m *PlatformMutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedcreator {
edges = append(edges, platform.EdgeCreator)
edges = append(edges, entplatform.EdgeCreator)
}
if m.clearedorganization {
edges = append(edges, platform.EdgeOrganization)
edges = append(edges, entplatform.EdgeOrganization)
}
return edges
}
@@ -1777,9 +1777,9 @@ func (m *PlatformMutation) ClearedEdges() []string {
// was cleared in this mutation.
func (m *PlatformMutation) EdgeCleared(name string) bool {
switch name {
case platform.EdgeCreator:
case entplatform.EdgeCreator:
return m.clearedcreator
case platform.EdgeOrganization:
case entplatform.EdgeOrganization:
return m.clearedorganization
}
return false
@@ -1789,10 +1789,10 @@ func (m *PlatformMutation) EdgeCleared(name string) bool {
// if that edge is not defined in the schema.
func (m *PlatformMutation) ClearEdge(name string) error {
switch name {
case platform.EdgeCreator:
case entplatform.EdgeCreator:
m.ClearCreator()
return nil
case platform.EdgeOrganization:
case entplatform.EdgeOrganization:
m.ClearOrganization()
return nil
}
@@ -1803,10 +1803,10 @@ func (m *PlatformMutation) ClearEdge(name string) error {
// It returns an error if the edge is not defined in the schema.
func (m *PlatformMutation) ResetEdge(name string) error {
switch name {
case platform.EdgeCreator:
case entplatform.EdgeCreator:
m.ResetCreator()
return nil
case platform.EdgeOrganization:
case entplatform.EdgeOrganization:
m.ResetOrganization()
return nil
}

View File

@@ -48,7 +48,7 @@ const (
// PlatformsTable is the table that holds the platforms relation/edge.
PlatformsTable = "platforms"
// PlatformsInverseTable is the table name for the Platform entity.
// It exists in this package in order to avoid circular dependency with the "platform" package.
// It exists in this package in order to avoid circular dependency with the "entplatform" package.
PlatformsInverseTable = "platforms"
// PlatformsColumn is the table column denoting the platforms relation/edge.
PlatformsColumn = "org_id"

View File

@@ -14,7 +14,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -288,7 +288,7 @@ func (oc *OrganizationCreate) createSpec() (*Organization, *sqlgraph.CreateSpec)
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -13,7 +13,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/predicate"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -121,7 +121,7 @@ func (oq *OrganizationQuery) QueryPlatforms() *PlatformQuery {
}
step := sqlgraph.NewStep(
sqlgraph.From(organization.Table, organization.FieldID, selector),
sqlgraph.To(platform.Table, platform.FieldID),
sqlgraph.To(entplatform.Table, entplatform.FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, organization.PlatformsTable, organization.PlatformsColumn),
)
fromU = sqlgraph.SetNeighbors(oq.driver.Dialect(), step)
@@ -590,7 +590,7 @@ func (oq *OrganizationQuery) loadPlatforms(ctx context.Context, query *PlatformQ
}
}
if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(platform.FieldOrgID)
query.ctx.AppendFieldOnce(entplatform.FieldOrgID)
}
query.Where(predicate.Platform(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(organization.PlatformsColumn), fks...))

View File

@@ -13,7 +13,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/predicate"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -319,7 +319,7 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -332,7 +332,7 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -348,7 +348,7 @@ func (ou *OrganizationUpdate) sqlSave(ctx context.Context) (n int, err error) {
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -694,7 +694,7 @@ func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizat
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
@@ -707,7 +707,7 @@ func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizat
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {
@@ -723,7 +723,7 @@ func (ouo *OrganizationUpdateOne) sqlSave(ctx context.Context) (_node *Organizat
Columns: []string{organization.PlatformsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID),
IDSpec: sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID),
},
}
for _, k := range nodes {

View File

@@ -12,9 +12,9 @@ import (
"entgo.io/ent/dialect/sql"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/user"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
platform "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
)
// Platform is the model entity for the Platform schema.
@@ -34,14 +34,14 @@ type Platform struct {
DisplayName string `json:"display_name,omitempty"`
// CreatorID holds the value of the "creator_id" field.
CreatorID uuid.UUID `json:"creator_id,omitempty"`
// JSON holos.PlatformForm representing the platform data entry form.
ConfigForm *holos.PlatformForm `json:"config_form,omitempty"`
// JSON holos.ConfigValues representing the platform config values.
ConfigValues *holos.ConfigValues `json:"config_values,omitempty"`
// Opaque bytes representing the CUE definition of the config struct.
ConfigCue []byte `json:"config_cue,omitempty"`
// JSON representation of FormlyFormConfig[] refer to https://github.com/holos-run/holos/issues/161
Form *platform.Form `json:"form,omitempty"`
// JSON representation of the form model which holds user input values refer to https://github.com/holos-run/holos/issues/161
Model *platform.Model `json:"model,omitempty"`
// CUE definition to vet the model against e.g. #PlatformConfig
Cue []byte `json:"cue,omitempty"`
// The definition name to vet config_values against config_cue e.g. '#PlatformSpec'
ConfigDefinition string `json:"config_definition,omitempty"`
CueDefinition string `json:"cue_definition,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PlatformQuery when eager-loading is set.
Edges PlatformEdges `json:"edges"`
@@ -86,13 +86,13 @@ func (*Platform) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case platform.FieldConfigForm, platform.FieldConfigValues, platform.FieldConfigCue:
case entplatform.FieldForm, entplatform.FieldModel, entplatform.FieldCue:
values[i] = new([]byte)
case platform.FieldName, platform.FieldDisplayName, platform.FieldConfigDefinition:
case entplatform.FieldName, entplatform.FieldDisplayName, entplatform.FieldCueDefinition:
values[i] = new(sql.NullString)
case platform.FieldCreatedAt, platform.FieldUpdatedAt:
case entplatform.FieldCreatedAt, entplatform.FieldUpdatedAt:
values[i] = new(sql.NullTime)
case platform.FieldID, platform.FieldOrgID, platform.FieldCreatorID:
case entplatform.FieldID, entplatform.FieldOrgID, entplatform.FieldCreatorID:
values[i] = new(uuid.UUID)
default:
values[i] = new(sql.UnknownType)
@@ -109,75 +109,75 @@ func (pl *Platform) assignValues(columns []string, values []any) error {
}
for i := range columns {
switch columns[i] {
case platform.FieldID:
case entplatform.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
pl.ID = *value
}
case platform.FieldCreatedAt:
case entplatform.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
pl.CreatedAt = value.Time
}
case platform.FieldUpdatedAt:
case entplatform.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
pl.UpdatedAt = value.Time
}
case platform.FieldOrgID:
case entplatform.FieldOrgID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field org_id", values[i])
} else if value != nil {
pl.OrgID = *value
}
case platform.FieldName:
case entplatform.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
pl.Name = value.String
}
case platform.FieldDisplayName:
case entplatform.FieldDisplayName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field display_name", values[i])
} else if value.Valid {
pl.DisplayName = value.String
}
case platform.FieldCreatorID:
case entplatform.FieldCreatorID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field creator_id", values[i])
} else if value != nil {
pl.CreatorID = *value
}
case platform.FieldConfigForm:
case entplatform.FieldForm:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field config_form", values[i])
return fmt.Errorf("unexpected type %T for field form", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &pl.ConfigForm); err != nil {
return fmt.Errorf("unmarshal field config_form: %w", err)
if err := json.Unmarshal(*value, &pl.Form); err != nil {
return fmt.Errorf("unmarshal field form: %w", err)
}
}
case platform.FieldConfigValues:
case entplatform.FieldModel:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field config_values", values[i])
return fmt.Errorf("unexpected type %T for field model", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &pl.ConfigValues); err != nil {
return fmt.Errorf("unmarshal field config_values: %w", err)
if err := json.Unmarshal(*value, &pl.Model); err != nil {
return fmt.Errorf("unmarshal field model: %w", err)
}
}
case platform.FieldConfigCue:
case entplatform.FieldCue:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field config_cue", values[i])
return fmt.Errorf("unexpected type %T for field cue", values[i])
} else if value != nil {
pl.ConfigCue = *value
pl.Cue = *value
}
case platform.FieldConfigDefinition:
case entplatform.FieldCueDefinition:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field config_definition", values[i])
return fmt.Errorf("unexpected type %T for field cue_definition", values[i])
} else if value.Valid {
pl.ConfigDefinition = value.String
pl.CueDefinition = value.String
}
default:
pl.selectValues.Set(columns[i], values[i])
@@ -243,17 +243,17 @@ func (pl *Platform) String() string {
builder.WriteString("creator_id=")
builder.WriteString(fmt.Sprintf("%v", pl.CreatorID))
builder.WriteString(", ")
builder.WriteString("config_form=")
builder.WriteString(fmt.Sprintf("%v", pl.ConfigForm))
builder.WriteString("form=")
builder.WriteString(fmt.Sprintf("%v", pl.Form))
builder.WriteString(", ")
builder.WriteString("config_values=")
builder.WriteString(fmt.Sprintf("%v", pl.ConfigValues))
builder.WriteString("model=")
builder.WriteString(fmt.Sprintf("%v", pl.Model))
builder.WriteString(", ")
builder.WriteString("config_cue=")
builder.WriteString(fmt.Sprintf("%v", pl.ConfigCue))
builder.WriteString("cue=")
builder.WriteString(fmt.Sprintf("%v", pl.Cue))
builder.WriteString(", ")
builder.WriteString("config_definition=")
builder.WriteString(pl.ConfigDefinition)
builder.WriteString("cue_definition=")
builder.WriteString(pl.CueDefinition)
builder.WriteByte(')')
return builder.String()
}

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package platform
package entplatform
import (
"time"
@@ -27,14 +27,14 @@ const (
FieldDisplayName = "display_name"
// FieldCreatorID holds the string denoting the creator_id field in the database.
FieldCreatorID = "creator_id"
// FieldConfigForm holds the string denoting the config_form field in the database.
FieldConfigForm = "config_form"
// FieldConfigValues holds the string denoting the config_values field in the database.
FieldConfigValues = "config_values"
// FieldConfigCue holds the string denoting the config_cue field in the database.
FieldConfigCue = "config_cue"
// FieldConfigDefinition holds the string denoting the config_definition field in the database.
FieldConfigDefinition = "config_definition"
// FieldForm holds the string denoting the form field in the database.
FieldForm = "form"
// FieldModel holds the string denoting the model field in the database.
FieldModel = "model"
// FieldCue holds the string denoting the cue field in the database.
FieldCue = "cue"
// FieldCueDefinition holds the string denoting the cue_definition field in the database.
FieldCueDefinition = "cue_definition"
// EdgeCreator holds the string denoting the creator edge name in mutations.
EdgeCreator = "creator"
// EdgeOrganization holds the string denoting the organization edge name in mutations.
@@ -66,10 +66,10 @@ var Columns = []string{
FieldName,
FieldDisplayName,
FieldCreatorID,
FieldConfigForm,
FieldConfigValues,
FieldConfigCue,
FieldConfigDefinition,
FieldForm,
FieldModel,
FieldCue,
FieldCueDefinition,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -133,9 +133,9 @@ func ByCreatorID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatorID, opts...).ToFunc()
}
// ByConfigDefinition orders the results by the config_definition field.
func ByConfigDefinition(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldConfigDefinition, opts...).ToFunc()
// ByCueDefinition orders the results by the cue_definition field.
func ByCueDefinition(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCueDefinition, opts...).ToFunc()
}
// ByCreatorField orders the results by creator field.

View File

@@ -1,6 +1,6 @@
// Code generated by ent, DO NOT EDIT.
package platform
package entplatform
import (
"time"
@@ -86,14 +86,14 @@ func CreatorID(v uuid.UUID) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldCreatorID, v))
}
// ConfigCue applies equality check predicate on the "config_cue" field. It's identical to ConfigCueEQ.
func ConfigCue(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldConfigCue, v))
// Cue applies equality check predicate on the "cue" field. It's identical to CueEQ.
func Cue(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldCue, v))
}
// ConfigDefinition applies equality check predicate on the "config_definition" field. It's identical to ConfigDefinitionEQ.
func ConfigDefinition(v string) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldConfigDefinition, v))
// CueDefinition applies equality check predicate on the "cue_definition" field. It's identical to CueDefinitionEQ.
func CueDefinition(v string) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldCueDefinition, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
@@ -346,149 +346,149 @@ func CreatorIDNotIn(vs ...uuid.UUID) predicate.Platform {
return predicate.Platform(sql.FieldNotIn(FieldCreatorID, vs...))
}
// ConfigFormIsNil applies the IsNil predicate on the "config_form" field.
func ConfigFormIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldConfigForm))
// FormIsNil applies the IsNil predicate on the "form" field.
func FormIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldForm))
}
// ConfigFormNotNil applies the NotNil predicate on the "config_form" field.
func ConfigFormNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldConfigForm))
// FormNotNil applies the NotNil predicate on the "form" field.
func FormNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldForm))
}
// ConfigValuesIsNil applies the IsNil predicate on the "config_values" field.
func ConfigValuesIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldConfigValues))
// ModelIsNil applies the IsNil predicate on the "model" field.
func ModelIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldModel))
}
// ConfigValuesNotNil applies the NotNil predicate on the "config_values" field.
func ConfigValuesNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldConfigValues))
// ModelNotNil applies the NotNil predicate on the "model" field.
func ModelNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldModel))
}
// ConfigCueEQ applies the EQ predicate on the "config_cue" field.
func ConfigCueEQ(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldConfigCue, v))
// CueEQ applies the EQ predicate on the "cue" field.
func CueEQ(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldCue, v))
}
// ConfigCueNEQ applies the NEQ predicate on the "config_cue" field.
func ConfigCueNEQ(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldNEQ(FieldConfigCue, v))
// CueNEQ applies the NEQ predicate on the "cue" field.
func CueNEQ(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldNEQ(FieldCue, v))
}
// ConfigCueIn applies the In predicate on the "config_cue" field.
func ConfigCueIn(vs ...[]byte) predicate.Platform {
return predicate.Platform(sql.FieldIn(FieldConfigCue, vs...))
// CueIn applies the In predicate on the "cue" field.
func CueIn(vs ...[]byte) predicate.Platform {
return predicate.Platform(sql.FieldIn(FieldCue, vs...))
}
// ConfigCueNotIn applies the NotIn predicate on the "config_cue" field.
func ConfigCueNotIn(vs ...[]byte) predicate.Platform {
return predicate.Platform(sql.FieldNotIn(FieldConfigCue, vs...))
// CueNotIn applies the NotIn predicate on the "cue" field.
func CueNotIn(vs ...[]byte) predicate.Platform {
return predicate.Platform(sql.FieldNotIn(FieldCue, vs...))
}
// ConfigCueGT applies the GT predicate on the "config_cue" field.
func ConfigCueGT(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldGT(FieldConfigCue, v))
// CueGT applies the GT predicate on the "cue" field.
func CueGT(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldGT(FieldCue, v))
}
// ConfigCueGTE applies the GTE predicate on the "config_cue" field.
func ConfigCueGTE(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldGTE(FieldConfigCue, v))
// CueGTE applies the GTE predicate on the "cue" field.
func CueGTE(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldGTE(FieldCue, v))
}
// ConfigCueLT applies the LT predicate on the "config_cue" field.
func ConfigCueLT(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldLT(FieldConfigCue, v))
// CueLT applies the LT predicate on the "cue" field.
func CueLT(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldLT(FieldCue, v))
}
// ConfigCueLTE applies the LTE predicate on the "config_cue" field.
func ConfigCueLTE(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldLTE(FieldConfigCue, v))
// CueLTE applies the LTE predicate on the "cue" field.
func CueLTE(v []byte) predicate.Platform {
return predicate.Platform(sql.FieldLTE(FieldCue, v))
}
// ConfigCueIsNil applies the IsNil predicate on the "config_cue" field.
func ConfigCueIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldConfigCue))
// CueIsNil applies the IsNil predicate on the "cue" field.
func CueIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldCue))
}
// ConfigCueNotNil applies the NotNil predicate on the "config_cue" field.
func ConfigCueNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldConfigCue))
// CueNotNil applies the NotNil predicate on the "cue" field.
func CueNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldCue))
}
// ConfigDefinitionEQ applies the EQ predicate on the "config_definition" field.
func ConfigDefinitionEQ(v string) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldConfigDefinition, v))
// CueDefinitionEQ applies the EQ predicate on the "cue_definition" field.
func CueDefinitionEQ(v string) predicate.Platform {
return predicate.Platform(sql.FieldEQ(FieldCueDefinition, v))
}
// ConfigDefinitionNEQ applies the NEQ predicate on the "config_definition" field.
func ConfigDefinitionNEQ(v string) predicate.Platform {
return predicate.Platform(sql.FieldNEQ(FieldConfigDefinition, v))
// CueDefinitionNEQ applies the NEQ predicate on the "cue_definition" field.
func CueDefinitionNEQ(v string) predicate.Platform {
return predicate.Platform(sql.FieldNEQ(FieldCueDefinition, v))
}
// ConfigDefinitionIn applies the In predicate on the "config_definition" field.
func ConfigDefinitionIn(vs ...string) predicate.Platform {
return predicate.Platform(sql.FieldIn(FieldConfigDefinition, vs...))
// CueDefinitionIn applies the In predicate on the "cue_definition" field.
func CueDefinitionIn(vs ...string) predicate.Platform {
return predicate.Platform(sql.FieldIn(FieldCueDefinition, vs...))
}
// ConfigDefinitionNotIn applies the NotIn predicate on the "config_definition" field.
func ConfigDefinitionNotIn(vs ...string) predicate.Platform {
return predicate.Platform(sql.FieldNotIn(FieldConfigDefinition, vs...))
// CueDefinitionNotIn applies the NotIn predicate on the "cue_definition" field.
func CueDefinitionNotIn(vs ...string) predicate.Platform {
return predicate.Platform(sql.FieldNotIn(FieldCueDefinition, vs...))
}
// ConfigDefinitionGT applies the GT predicate on the "config_definition" field.
func ConfigDefinitionGT(v string) predicate.Platform {
return predicate.Platform(sql.FieldGT(FieldConfigDefinition, v))
// CueDefinitionGT applies the GT predicate on the "cue_definition" field.
func CueDefinitionGT(v string) predicate.Platform {
return predicate.Platform(sql.FieldGT(FieldCueDefinition, v))
}
// ConfigDefinitionGTE applies the GTE predicate on the "config_definition" field.
func ConfigDefinitionGTE(v string) predicate.Platform {
return predicate.Platform(sql.FieldGTE(FieldConfigDefinition, v))
// CueDefinitionGTE applies the GTE predicate on the "cue_definition" field.
func CueDefinitionGTE(v string) predicate.Platform {
return predicate.Platform(sql.FieldGTE(FieldCueDefinition, v))
}
// ConfigDefinitionLT applies the LT predicate on the "config_definition" field.
func ConfigDefinitionLT(v string) predicate.Platform {
return predicate.Platform(sql.FieldLT(FieldConfigDefinition, v))
// CueDefinitionLT applies the LT predicate on the "cue_definition" field.
func CueDefinitionLT(v string) predicate.Platform {
return predicate.Platform(sql.FieldLT(FieldCueDefinition, v))
}
// ConfigDefinitionLTE applies the LTE predicate on the "config_definition" field.
func ConfigDefinitionLTE(v string) predicate.Platform {
return predicate.Platform(sql.FieldLTE(FieldConfigDefinition, v))
// CueDefinitionLTE applies the LTE predicate on the "cue_definition" field.
func CueDefinitionLTE(v string) predicate.Platform {
return predicate.Platform(sql.FieldLTE(FieldCueDefinition, v))
}
// ConfigDefinitionContains applies the Contains predicate on the "config_definition" field.
func ConfigDefinitionContains(v string) predicate.Platform {
return predicate.Platform(sql.FieldContains(FieldConfigDefinition, v))
// CueDefinitionContains applies the Contains predicate on the "cue_definition" field.
func CueDefinitionContains(v string) predicate.Platform {
return predicate.Platform(sql.FieldContains(FieldCueDefinition, v))
}
// ConfigDefinitionHasPrefix applies the HasPrefix predicate on the "config_definition" field.
func ConfigDefinitionHasPrefix(v string) predicate.Platform {
return predicate.Platform(sql.FieldHasPrefix(FieldConfigDefinition, v))
// CueDefinitionHasPrefix applies the HasPrefix predicate on the "cue_definition" field.
func CueDefinitionHasPrefix(v string) predicate.Platform {
return predicate.Platform(sql.FieldHasPrefix(FieldCueDefinition, v))
}
// ConfigDefinitionHasSuffix applies the HasSuffix predicate on the "config_definition" field.
func ConfigDefinitionHasSuffix(v string) predicate.Platform {
return predicate.Platform(sql.FieldHasSuffix(FieldConfigDefinition, v))
// CueDefinitionHasSuffix applies the HasSuffix predicate on the "cue_definition" field.
func CueDefinitionHasSuffix(v string) predicate.Platform {
return predicate.Platform(sql.FieldHasSuffix(FieldCueDefinition, v))
}
// ConfigDefinitionIsNil applies the IsNil predicate on the "config_definition" field.
func ConfigDefinitionIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldConfigDefinition))
// CueDefinitionIsNil applies the IsNil predicate on the "cue_definition" field.
func CueDefinitionIsNil() predicate.Platform {
return predicate.Platform(sql.FieldIsNull(FieldCueDefinition))
}
// ConfigDefinitionNotNil applies the NotNil predicate on the "config_definition" field.
func ConfigDefinitionNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldConfigDefinition))
// CueDefinitionNotNil applies the NotNil predicate on the "cue_definition" field.
func CueDefinitionNotNil() predicate.Platform {
return predicate.Platform(sql.FieldNotNull(FieldCueDefinition))
}
// ConfigDefinitionEqualFold applies the EqualFold predicate on the "config_definition" field.
func ConfigDefinitionEqualFold(v string) predicate.Platform {
return predicate.Platform(sql.FieldEqualFold(FieldConfigDefinition, v))
// CueDefinitionEqualFold applies the EqualFold predicate on the "cue_definition" field.
func CueDefinitionEqualFold(v string) predicate.Platform {
return predicate.Platform(sql.FieldEqualFold(FieldCueDefinition, v))
}
// ConfigDefinitionContainsFold applies the ContainsFold predicate on the "config_definition" field.
func ConfigDefinitionContainsFold(v string) predicate.Platform {
return predicate.Platform(sql.FieldContainsFold(FieldConfigDefinition, v))
// CueDefinitionContainsFold applies the ContainsFold predicate on the "cue_definition" field.
func CueDefinitionContainsFold(v string) predicate.Platform {
return predicate.Platform(sql.FieldContainsFold(FieldCueDefinition, v))
}
// HasCreator applies the HasEdge predicate on the "creator" edge.

View File

@@ -14,9 +14,9 @@ import (
"entgo.io/ent/schema/field"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/user"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
platform "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
)
// PlatformCreate is the builder for creating a Platform entity.
@@ -79,34 +79,34 @@ func (pc *PlatformCreate) SetCreatorID(u uuid.UUID) *PlatformCreate {
return pc
}
// SetConfigForm sets the "config_form" field.
func (pc *PlatformCreate) SetConfigForm(hf *holos.PlatformForm) *PlatformCreate {
pc.mutation.SetConfigForm(hf)
// SetForm sets the "form" field.
func (pc *PlatformCreate) SetForm(pl *platform.Form) *PlatformCreate {
pc.mutation.SetForm(pl)
return pc
}
// SetConfigValues sets the "config_values" field.
func (pc *PlatformCreate) SetConfigValues(hv *holos.ConfigValues) *PlatformCreate {
pc.mutation.SetConfigValues(hv)
// SetModel sets the "model" field.
func (pc *PlatformCreate) SetModel(pl *platform.Model) *PlatformCreate {
pc.mutation.SetModel(pl)
return pc
}
// SetConfigCue sets the "config_cue" field.
func (pc *PlatformCreate) SetConfigCue(b []byte) *PlatformCreate {
pc.mutation.SetConfigCue(b)
// SetCue sets the "cue" field.
func (pc *PlatformCreate) SetCue(b []byte) *PlatformCreate {
pc.mutation.SetCue(b)
return pc
}
// SetConfigDefinition sets the "config_definition" field.
func (pc *PlatformCreate) SetConfigDefinition(s string) *PlatformCreate {
pc.mutation.SetConfigDefinition(s)
// SetCueDefinition sets the "cue_definition" field.
func (pc *PlatformCreate) SetCueDefinition(s string) *PlatformCreate {
pc.mutation.SetCueDefinition(s)
return pc
}
// SetNillableConfigDefinition sets the "config_definition" field if the given value is not nil.
func (pc *PlatformCreate) SetNillableConfigDefinition(s *string) *PlatformCreate {
// SetNillableCueDefinition sets the "cue_definition" field if the given value is not nil.
func (pc *PlatformCreate) SetNillableCueDefinition(s *string) *PlatformCreate {
if s != nil {
pc.SetConfigDefinition(*s)
pc.SetCueDefinition(*s)
}
return pc
}
@@ -177,15 +177,15 @@ func (pc *PlatformCreate) ExecX(ctx context.Context) {
// defaults sets the default values of the builder before save.
func (pc *PlatformCreate) defaults() {
if _, ok := pc.mutation.CreatedAt(); !ok {
v := platform.DefaultCreatedAt()
v := entplatform.DefaultCreatedAt()
pc.mutation.SetCreatedAt(v)
}
if _, ok := pc.mutation.UpdatedAt(); !ok {
v := platform.DefaultUpdatedAt()
v := entplatform.DefaultUpdatedAt()
pc.mutation.SetUpdatedAt(v)
}
if _, ok := pc.mutation.ID(); !ok {
v := platform.DefaultID()
v := entplatform.DefaultID()
pc.mutation.SetID(v)
}
}
@@ -205,7 +205,7 @@ func (pc *PlatformCreate) check() error {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Platform.name"`)}
}
if v, ok := pc.mutation.Name(); ok {
if err := platform.NameValidator(v); err != nil {
if err := entplatform.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Platform.name": %w`, err)}
}
}
@@ -250,7 +250,7 @@ func (pc *PlatformCreate) sqlSave(ctx context.Context) (*Platform, error) {
func (pc *PlatformCreate) createSpec() (*Platform, *sqlgraph.CreateSpec) {
var (
_node = &Platform{config: pc.config}
_spec = sqlgraph.NewCreateSpec(platform.Table, sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID))
_spec = sqlgraph.NewCreateSpec(entplatform.Table, sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID))
)
_spec.OnConflict = pc.conflict
if id, ok := pc.mutation.ID(); ok {
@@ -258,43 +258,43 @@ func (pc *PlatformCreate) createSpec() (*Platform, *sqlgraph.CreateSpec) {
_spec.ID.Value = &id
}
if value, ok := pc.mutation.CreatedAt(); ok {
_spec.SetField(platform.FieldCreatedAt, field.TypeTime, value)
_spec.SetField(entplatform.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := pc.mutation.UpdatedAt(); ok {
_spec.SetField(platform.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entplatform.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := pc.mutation.Name(); ok {
_spec.SetField(platform.FieldName, field.TypeString, value)
_spec.SetField(entplatform.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := pc.mutation.DisplayName(); ok {
_spec.SetField(platform.FieldDisplayName, field.TypeString, value)
_spec.SetField(entplatform.FieldDisplayName, field.TypeString, value)
_node.DisplayName = value
}
if value, ok := pc.mutation.ConfigForm(); ok {
_spec.SetField(platform.FieldConfigForm, field.TypeJSON, value)
_node.ConfigForm = value
if value, ok := pc.mutation.Form(); ok {
_spec.SetField(entplatform.FieldForm, field.TypeJSON, value)
_node.Form = value
}
if value, ok := pc.mutation.ConfigValues(); ok {
_spec.SetField(platform.FieldConfigValues, field.TypeJSON, value)
_node.ConfigValues = value
if value, ok := pc.mutation.Model(); ok {
_spec.SetField(entplatform.FieldModel, field.TypeJSON, value)
_node.Model = value
}
if value, ok := pc.mutation.ConfigCue(); ok {
_spec.SetField(platform.FieldConfigCue, field.TypeBytes, value)
_node.ConfigCue = value
if value, ok := pc.mutation.Cue(); ok {
_spec.SetField(entplatform.FieldCue, field.TypeBytes, value)
_node.Cue = value
}
if value, ok := pc.mutation.ConfigDefinition(); ok {
_spec.SetField(platform.FieldConfigDefinition, field.TypeString, value)
_node.ConfigDefinition = value
if value, ok := pc.mutation.CueDefinition(); ok {
_spec.SetField(entplatform.FieldCueDefinition, field.TypeString, value)
_node.CueDefinition = value
}
if nodes := pc.mutation.CreatorIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.CreatorTable,
Columns: []string{platform.CreatorColumn},
Table: entplatform.CreatorTable,
Columns: []string{entplatform.CreatorColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
@@ -310,8 +310,8 @@ func (pc *PlatformCreate) createSpec() (*Platform, *sqlgraph.CreateSpec) {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.OrganizationTable,
Columns: []string{platform.OrganizationColumn},
Table: entplatform.OrganizationTable,
Columns: []string{entplatform.OrganizationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID),
@@ -377,133 +377,133 @@ type (
// SetUpdatedAt sets the "updated_at" field.
func (u *PlatformUpsert) SetUpdatedAt(v time.Time) *PlatformUpsert {
u.Set(platform.FieldUpdatedAt, v)
u.Set(entplatform.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateUpdatedAt() *PlatformUpsert {
u.SetExcluded(platform.FieldUpdatedAt)
u.SetExcluded(entplatform.FieldUpdatedAt)
return u
}
// SetOrgID sets the "org_id" field.
func (u *PlatformUpsert) SetOrgID(v uuid.UUID) *PlatformUpsert {
u.Set(platform.FieldOrgID, v)
u.Set(entplatform.FieldOrgID, v)
return u
}
// UpdateOrgID sets the "org_id" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateOrgID() *PlatformUpsert {
u.SetExcluded(platform.FieldOrgID)
u.SetExcluded(entplatform.FieldOrgID)
return u
}
// SetName sets the "name" field.
func (u *PlatformUpsert) SetName(v string) *PlatformUpsert {
u.Set(platform.FieldName, v)
u.Set(entplatform.FieldName, v)
return u
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateName() *PlatformUpsert {
u.SetExcluded(platform.FieldName)
u.SetExcluded(entplatform.FieldName)
return u
}
// SetDisplayName sets the "display_name" field.
func (u *PlatformUpsert) SetDisplayName(v string) *PlatformUpsert {
u.Set(platform.FieldDisplayName, v)
u.Set(entplatform.FieldDisplayName, v)
return u
}
// UpdateDisplayName sets the "display_name" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateDisplayName() *PlatformUpsert {
u.SetExcluded(platform.FieldDisplayName)
u.SetExcluded(entplatform.FieldDisplayName)
return u
}
// SetCreatorID sets the "creator_id" field.
func (u *PlatformUpsert) SetCreatorID(v uuid.UUID) *PlatformUpsert {
u.Set(platform.FieldCreatorID, v)
u.Set(entplatform.FieldCreatorID, v)
return u
}
// UpdateCreatorID sets the "creator_id" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateCreatorID() *PlatformUpsert {
u.SetExcluded(platform.FieldCreatorID)
u.SetExcluded(entplatform.FieldCreatorID)
return u
}
// SetConfigForm sets the "config_form" field.
func (u *PlatformUpsert) SetConfigForm(v *holos.PlatformForm) *PlatformUpsert {
u.Set(platform.FieldConfigForm, v)
// SetForm sets the "form" field.
func (u *PlatformUpsert) SetForm(v *platform.Form) *PlatformUpsert {
u.Set(entplatform.FieldForm, v)
return u
}
// UpdateConfigForm sets the "config_form" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateConfigForm() *PlatformUpsert {
u.SetExcluded(platform.FieldConfigForm)
// UpdateForm sets the "form" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateForm() *PlatformUpsert {
u.SetExcluded(entplatform.FieldForm)
return u
}
// ClearConfigForm clears the value of the "config_form" field.
func (u *PlatformUpsert) ClearConfigForm() *PlatformUpsert {
u.SetNull(platform.FieldConfigForm)
// ClearForm clears the value of the "form" field.
func (u *PlatformUpsert) ClearForm() *PlatformUpsert {
u.SetNull(entplatform.FieldForm)
return u
}
// SetConfigValues sets the "config_values" field.
func (u *PlatformUpsert) SetConfigValues(v *holos.ConfigValues) *PlatformUpsert {
u.Set(platform.FieldConfigValues, v)
// SetModel sets the "model" field.
func (u *PlatformUpsert) SetModel(v *platform.Model) *PlatformUpsert {
u.Set(entplatform.FieldModel, v)
return u
}
// UpdateConfigValues sets the "config_values" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateConfigValues() *PlatformUpsert {
u.SetExcluded(platform.FieldConfigValues)
// UpdateModel sets the "model" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateModel() *PlatformUpsert {
u.SetExcluded(entplatform.FieldModel)
return u
}
// ClearConfigValues clears the value of the "config_values" field.
func (u *PlatformUpsert) ClearConfigValues() *PlatformUpsert {
u.SetNull(platform.FieldConfigValues)
// ClearModel clears the value of the "model" field.
func (u *PlatformUpsert) ClearModel() *PlatformUpsert {
u.SetNull(entplatform.FieldModel)
return u
}
// SetConfigCue sets the "config_cue" field.
func (u *PlatformUpsert) SetConfigCue(v []byte) *PlatformUpsert {
u.Set(platform.FieldConfigCue, v)
// SetCue sets the "cue" field.
func (u *PlatformUpsert) SetCue(v []byte) *PlatformUpsert {
u.Set(entplatform.FieldCue, v)
return u
}
// UpdateConfigCue sets the "config_cue" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateConfigCue() *PlatformUpsert {
u.SetExcluded(platform.FieldConfigCue)
// UpdateCue sets the "cue" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateCue() *PlatformUpsert {
u.SetExcluded(entplatform.FieldCue)
return u
}
// ClearConfigCue clears the value of the "config_cue" field.
func (u *PlatformUpsert) ClearConfigCue() *PlatformUpsert {
u.SetNull(platform.FieldConfigCue)
// ClearCue clears the value of the "cue" field.
func (u *PlatformUpsert) ClearCue() *PlatformUpsert {
u.SetNull(entplatform.FieldCue)
return u
}
// SetConfigDefinition sets the "config_definition" field.
func (u *PlatformUpsert) SetConfigDefinition(v string) *PlatformUpsert {
u.Set(platform.FieldConfigDefinition, v)
// SetCueDefinition sets the "cue_definition" field.
func (u *PlatformUpsert) SetCueDefinition(v string) *PlatformUpsert {
u.Set(entplatform.FieldCueDefinition, v)
return u
}
// UpdateConfigDefinition sets the "config_definition" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateConfigDefinition() *PlatformUpsert {
u.SetExcluded(platform.FieldConfigDefinition)
// UpdateCueDefinition sets the "cue_definition" field to the value that was provided on create.
func (u *PlatformUpsert) UpdateCueDefinition() *PlatformUpsert {
u.SetExcluded(entplatform.FieldCueDefinition)
return u
}
// ClearConfigDefinition clears the value of the "config_definition" field.
func (u *PlatformUpsert) ClearConfigDefinition() *PlatformUpsert {
u.SetNull(platform.FieldConfigDefinition)
// ClearCueDefinition clears the value of the "cue_definition" field.
func (u *PlatformUpsert) ClearCueDefinition() *PlatformUpsert {
u.SetNull(entplatform.FieldCueDefinition)
return u
}
@@ -514,7 +514,7 @@ func (u *PlatformUpsert) ClearConfigDefinition() *PlatformUpsert {
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(platform.FieldID)
// u.SetIgnore(entplatform.FieldID)
// }),
// ).
// Exec(ctx)
@@ -522,10 +522,10 @@ func (u *PlatformUpsertOne) UpdateNewValues() *PlatformUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.ID(); exists {
s.SetIgnore(platform.FieldID)
s.SetIgnore(entplatform.FieldID)
}
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(platform.FieldCreatedAt)
s.SetIgnore(entplatform.FieldCreatedAt)
}
}))
return u
@@ -628,87 +628,87 @@ func (u *PlatformUpsertOne) UpdateCreatorID() *PlatformUpsertOne {
})
}
// SetConfigForm sets the "config_form" field.
func (u *PlatformUpsertOne) SetConfigForm(v *holos.PlatformForm) *PlatformUpsertOne {
// SetForm sets the "form" field.
func (u *PlatformUpsertOne) SetForm(v *platform.Form) *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigForm(v)
s.SetForm(v)
})
}
// UpdateConfigForm sets the "config_form" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateConfigForm() *PlatformUpsertOne {
// UpdateForm sets the "form" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateForm() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigForm()
s.UpdateForm()
})
}
// ClearConfigForm clears the value of the "config_form" field.
func (u *PlatformUpsertOne) ClearConfigForm() *PlatformUpsertOne {
// ClearForm clears the value of the "form" field.
func (u *PlatformUpsertOne) ClearForm() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigForm()
s.ClearForm()
})
}
// SetConfigValues sets the "config_values" field.
func (u *PlatformUpsertOne) SetConfigValues(v *holos.ConfigValues) *PlatformUpsertOne {
// SetModel sets the "model" field.
func (u *PlatformUpsertOne) SetModel(v *platform.Model) *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigValues(v)
s.SetModel(v)
})
}
// UpdateConfigValues sets the "config_values" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateConfigValues() *PlatformUpsertOne {
// UpdateModel sets the "model" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateModel() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigValues()
s.UpdateModel()
})
}
// ClearConfigValues clears the value of the "config_values" field.
func (u *PlatformUpsertOne) ClearConfigValues() *PlatformUpsertOne {
// ClearModel clears the value of the "model" field.
func (u *PlatformUpsertOne) ClearModel() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigValues()
s.ClearModel()
})
}
// SetConfigCue sets the "config_cue" field.
func (u *PlatformUpsertOne) SetConfigCue(v []byte) *PlatformUpsertOne {
// SetCue sets the "cue" field.
func (u *PlatformUpsertOne) SetCue(v []byte) *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigCue(v)
s.SetCue(v)
})
}
// UpdateConfigCue sets the "config_cue" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateConfigCue() *PlatformUpsertOne {
// UpdateCue sets the "cue" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateCue() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigCue()
s.UpdateCue()
})
}
// ClearConfigCue clears the value of the "config_cue" field.
func (u *PlatformUpsertOne) ClearConfigCue() *PlatformUpsertOne {
// ClearCue clears the value of the "cue" field.
func (u *PlatformUpsertOne) ClearCue() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigCue()
s.ClearCue()
})
}
// SetConfigDefinition sets the "config_definition" field.
func (u *PlatformUpsertOne) SetConfigDefinition(v string) *PlatformUpsertOne {
// SetCueDefinition sets the "cue_definition" field.
func (u *PlatformUpsertOne) SetCueDefinition(v string) *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigDefinition(v)
s.SetCueDefinition(v)
})
}
// UpdateConfigDefinition sets the "config_definition" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateConfigDefinition() *PlatformUpsertOne {
// UpdateCueDefinition sets the "cue_definition" field to the value that was provided on create.
func (u *PlatformUpsertOne) UpdateCueDefinition() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigDefinition()
s.UpdateCueDefinition()
})
}
// ClearConfigDefinition clears the value of the "config_definition" field.
func (u *PlatformUpsertOne) ClearConfigDefinition() *PlatformUpsertOne {
// ClearCueDefinition clears the value of the "cue_definition" field.
func (u *PlatformUpsertOne) ClearCueDefinition() *PlatformUpsertOne {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigDefinition()
s.ClearCueDefinition()
})
}
@@ -884,7 +884,7 @@ type PlatformUpsertBulk struct {
// OnConflict(
// sql.ResolveWithNewValues(),
// sql.ResolveWith(func(u *sql.UpdateSet) {
// u.SetIgnore(platform.FieldID)
// u.SetIgnore(entplatform.FieldID)
// }),
// ).
// Exec(ctx)
@@ -893,10 +893,10 @@ func (u *PlatformUpsertBulk) UpdateNewValues() *PlatformUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders {
if _, exists := b.mutation.ID(); exists {
s.SetIgnore(platform.FieldID)
s.SetIgnore(entplatform.FieldID)
}
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(platform.FieldCreatedAt)
s.SetIgnore(entplatform.FieldCreatedAt)
}
}
}))
@@ -1000,87 +1000,87 @@ func (u *PlatformUpsertBulk) UpdateCreatorID() *PlatformUpsertBulk {
})
}
// SetConfigForm sets the "config_form" field.
func (u *PlatformUpsertBulk) SetConfigForm(v *holos.PlatformForm) *PlatformUpsertBulk {
// SetForm sets the "form" field.
func (u *PlatformUpsertBulk) SetForm(v *platform.Form) *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigForm(v)
s.SetForm(v)
})
}
// UpdateConfigForm sets the "config_form" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateConfigForm() *PlatformUpsertBulk {
// UpdateForm sets the "form" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateForm() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigForm()
s.UpdateForm()
})
}
// ClearConfigForm clears the value of the "config_form" field.
func (u *PlatformUpsertBulk) ClearConfigForm() *PlatformUpsertBulk {
// ClearForm clears the value of the "form" field.
func (u *PlatformUpsertBulk) ClearForm() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigForm()
s.ClearForm()
})
}
// SetConfigValues sets the "config_values" field.
func (u *PlatformUpsertBulk) SetConfigValues(v *holos.ConfigValues) *PlatformUpsertBulk {
// SetModel sets the "model" field.
func (u *PlatformUpsertBulk) SetModel(v *platform.Model) *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigValues(v)
s.SetModel(v)
})
}
// UpdateConfigValues sets the "config_values" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateConfigValues() *PlatformUpsertBulk {
// UpdateModel sets the "model" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateModel() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigValues()
s.UpdateModel()
})
}
// ClearConfigValues clears the value of the "config_values" field.
func (u *PlatformUpsertBulk) ClearConfigValues() *PlatformUpsertBulk {
// ClearModel clears the value of the "model" field.
func (u *PlatformUpsertBulk) ClearModel() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigValues()
s.ClearModel()
})
}
// SetConfigCue sets the "config_cue" field.
func (u *PlatformUpsertBulk) SetConfigCue(v []byte) *PlatformUpsertBulk {
// SetCue sets the "cue" field.
func (u *PlatformUpsertBulk) SetCue(v []byte) *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigCue(v)
s.SetCue(v)
})
}
// UpdateConfigCue sets the "config_cue" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateConfigCue() *PlatformUpsertBulk {
// UpdateCue sets the "cue" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateCue() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigCue()
s.UpdateCue()
})
}
// ClearConfigCue clears the value of the "config_cue" field.
func (u *PlatformUpsertBulk) ClearConfigCue() *PlatformUpsertBulk {
// ClearCue clears the value of the "cue" field.
func (u *PlatformUpsertBulk) ClearCue() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigCue()
s.ClearCue()
})
}
// SetConfigDefinition sets the "config_definition" field.
func (u *PlatformUpsertBulk) SetConfigDefinition(v string) *PlatformUpsertBulk {
// SetCueDefinition sets the "cue_definition" field.
func (u *PlatformUpsertBulk) SetCueDefinition(v string) *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.SetConfigDefinition(v)
s.SetCueDefinition(v)
})
}
// UpdateConfigDefinition sets the "config_definition" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateConfigDefinition() *PlatformUpsertBulk {
// UpdateCueDefinition sets the "cue_definition" field to the value that was provided on create.
func (u *PlatformUpsertBulk) UpdateCueDefinition() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.UpdateConfigDefinition()
s.UpdateCueDefinition()
})
}
// ClearConfigDefinition clears the value of the "config_definition" field.
func (u *PlatformUpsertBulk) ClearConfigDefinition() *PlatformUpsertBulk {
// ClearCueDefinition clears the value of the "cue_definition" field.
func (u *PlatformUpsertBulk) ClearCueDefinition() *PlatformUpsertBulk {
return u.Update(func(s *PlatformUpsert) {
s.ClearConfigDefinition()
s.ClearCueDefinition()
})
}

View File

@@ -8,8 +8,9 @@ import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/predicate"
entplatform "github.com/holos-run/holos/internal/ent/platform"
)
// PlatformDelete is the builder for deleting a Platform entity.
@@ -40,7 +41,7 @@ func (pd *PlatformDelete) ExecX(ctx context.Context) int {
}
func (pd *PlatformDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(platform.Table, sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID))
_spec := sqlgraph.NewDeleteSpec(entplatform.Table, sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID))
if ps := pd.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -74,7 +75,7 @@ func (pdo *PlatformDeleteOne) Exec(ctx context.Context) error {
case err != nil:
return err
case n == 0:
return &NotFoundError{platform.Label}
return &NotFoundError{entplatform.Label}
default:
return nil
}

View File

@@ -12,7 +12,7 @@ import (
"entgo.io/ent/schema/field"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/predicate"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -21,7 +21,7 @@ import (
type PlatformQuery struct {
config
ctx *QueryContext
order []platform.OrderOption
order []entplatform.OrderOption
inters []Interceptor
predicates []predicate.Platform
withCreator *UserQuery
@@ -57,7 +57,7 @@ func (pq *PlatformQuery) Unique(unique bool) *PlatformQuery {
}
// Order specifies how the records should be ordered.
func (pq *PlatformQuery) Order(o ...platform.OrderOption) *PlatformQuery {
func (pq *PlatformQuery) Order(o ...entplatform.OrderOption) *PlatformQuery {
pq.order = append(pq.order, o...)
return pq
}
@@ -74,9 +74,9 @@ func (pq *PlatformQuery) QueryCreator() *UserQuery {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(platform.Table, platform.FieldID, selector),
sqlgraph.From(entplatform.Table, entplatform.FieldID, selector),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, platform.CreatorTable, platform.CreatorColumn),
sqlgraph.Edge(sqlgraph.M2O, false, entplatform.CreatorTable, entplatform.CreatorColumn),
)
fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step)
return fromU, nil
@@ -96,9 +96,9 @@ func (pq *PlatformQuery) QueryOrganization() *OrganizationQuery {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(platform.Table, platform.FieldID, selector),
sqlgraph.From(entplatform.Table, entplatform.FieldID, selector),
sqlgraph.To(organization.Table, organization.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, platform.OrganizationTable, platform.OrganizationColumn),
sqlgraph.Edge(sqlgraph.M2O, false, entplatform.OrganizationTable, entplatform.OrganizationColumn),
)
fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step)
return fromU, nil
@@ -114,7 +114,7 @@ func (pq *PlatformQuery) First(ctx context.Context) (*Platform, error) {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{platform.Label}
return nil, &NotFoundError{entplatform.Label}
}
return nodes[0], nil
}
@@ -136,7 +136,7 @@ func (pq *PlatformQuery) FirstID(ctx context.Context) (id uuid.UUID, err error)
return
}
if len(ids) == 0 {
err = &NotFoundError{platform.Label}
err = &NotFoundError{entplatform.Label}
return
}
return ids[0], nil
@@ -163,9 +163,9 @@ func (pq *PlatformQuery) Only(ctx context.Context) (*Platform, error) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{platform.Label}
return nil, &NotFoundError{entplatform.Label}
default:
return nil, &NotSingularError{platform.Label}
return nil, &NotSingularError{entplatform.Label}
}
}
@@ -190,9 +190,9 @@ func (pq *PlatformQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{platform.Label}
err = &NotFoundError{entplatform.Label}
default:
err = &NotSingularError{platform.Label}
err = &NotSingularError{entplatform.Label}
}
return
}
@@ -231,7 +231,7 @@ func (pq *PlatformQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
pq.Unique(true)
}
ctx = setContextOp(ctx, pq.ctx, "IDs")
if err = pq.Select(platform.FieldID).Scan(ctx, &ids); err != nil {
if err = pq.Select(entplatform.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
@@ -295,7 +295,7 @@ func (pq *PlatformQuery) Clone() *PlatformQuery {
return &PlatformQuery{
config: pq.config,
ctx: pq.ctx.Clone(),
order: append([]platform.OrderOption{}, pq.order...),
order: append([]entplatform.OrderOption{}, pq.order...),
inters: append([]Interceptor{}, pq.inters...),
predicates: append([]predicate.Platform{}, pq.predicates...),
withCreator: pq.withCreator.Clone(),
@@ -339,14 +339,14 @@ func (pq *PlatformQuery) WithOrganization(opts ...func(*OrganizationQuery)) *Pla
// }
//
// client.Platform.Query().
// GroupBy(platform.FieldCreatedAt).
// GroupBy(entplatform.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (pq *PlatformQuery) GroupBy(field string, fields ...string) *PlatformGroupBy {
pq.ctx.Fields = append([]string{field}, fields...)
grbuild := &PlatformGroupBy{build: pq}
grbuild.flds = &pq.ctx.Fields
grbuild.label = platform.Label
grbuild.label = entplatform.Label
grbuild.scan = grbuild.Scan
return grbuild
}
@@ -361,12 +361,12 @@ func (pq *PlatformQuery) GroupBy(field string, fields ...string) *PlatformGroupB
// }
//
// client.Platform.Query().
// Select(platform.FieldCreatedAt).
// Select(entplatform.FieldCreatedAt).
// Scan(ctx, &v)
func (pq *PlatformQuery) Select(fields ...string) *PlatformSelect {
pq.ctx.Fields = append(pq.ctx.Fields, fields...)
sbuild := &PlatformSelect{PlatformQuery: pq}
sbuild.label = platform.Label
sbuild.label = entplatform.Label
sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan
return sbuild
}
@@ -388,7 +388,7 @@ func (pq *PlatformQuery) prepareQuery(ctx context.Context) error {
}
}
for _, f := range pq.ctx.Fields {
if !platform.ValidColumn(f) {
if !entplatform.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
@@ -513,7 +513,7 @@ func (pq *PlatformQuery) sqlCount(ctx context.Context) (int, error) {
}
func (pq *PlatformQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(platform.Table, platform.Columns, sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID))
_spec := sqlgraph.NewQuerySpec(entplatform.Table, entplatform.Columns, sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID))
_spec.From = pq.sql
if unique := pq.ctx.Unique; unique != nil {
_spec.Unique = *unique
@@ -522,17 +522,17 @@ func (pq *PlatformQuery) querySpec() *sqlgraph.QuerySpec {
}
if fields := pq.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, platform.FieldID)
_spec.Node.Columns = append(_spec.Node.Columns, entplatform.FieldID)
for i := range fields {
if fields[i] != platform.FieldID {
if fields[i] != entplatform.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
if pq.withCreator != nil {
_spec.Node.AddColumnOnce(platform.FieldCreatorID)
_spec.Node.AddColumnOnce(entplatform.FieldCreatorID)
}
if pq.withOrganization != nil {
_spec.Node.AddColumnOnce(platform.FieldOrgID)
_spec.Node.AddColumnOnce(entplatform.FieldOrgID)
}
}
if ps := pq.predicates; len(ps) > 0 {
@@ -560,10 +560,10 @@ func (pq *PlatformQuery) querySpec() *sqlgraph.QuerySpec {
func (pq *PlatformQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(pq.driver.Dialect())
t1 := builder.Table(platform.Table)
t1 := builder.Table(entplatform.Table)
columns := pq.ctx.Fields
if len(columns) == 0 {
columns = platform.Columns
columns = entplatform.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if pq.sql != nil {

View File

@@ -13,10 +13,10 @@ import (
"entgo.io/ent/schema/field"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/predicate"
"github.com/holos-run/holos/internal/ent/user"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
platform "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
)
// PlatformUpdate is the builder for updating Platform entities.
@@ -94,59 +94,59 @@ func (pu *PlatformUpdate) SetNillableCreatorID(u *uuid.UUID) *PlatformUpdate {
return pu
}
// SetConfigForm sets the "config_form" field.
func (pu *PlatformUpdate) SetConfigForm(hf *holos.PlatformForm) *PlatformUpdate {
pu.mutation.SetConfigForm(hf)
// SetForm sets the "form" field.
func (pu *PlatformUpdate) SetForm(pl *platform.Form) *PlatformUpdate {
pu.mutation.SetForm(pl)
return pu
}
// ClearConfigForm clears the value of the "config_form" field.
func (pu *PlatformUpdate) ClearConfigForm() *PlatformUpdate {
pu.mutation.ClearConfigForm()
// ClearForm clears the value of the "form" field.
func (pu *PlatformUpdate) ClearForm() *PlatformUpdate {
pu.mutation.ClearForm()
return pu
}
// SetConfigValues sets the "config_values" field.
func (pu *PlatformUpdate) SetConfigValues(hv *holos.ConfigValues) *PlatformUpdate {
pu.mutation.SetConfigValues(hv)
// SetModel sets the "model" field.
func (pu *PlatformUpdate) SetModel(pl *platform.Model) *PlatformUpdate {
pu.mutation.SetModel(pl)
return pu
}
// ClearConfigValues clears the value of the "config_values" field.
func (pu *PlatformUpdate) ClearConfigValues() *PlatformUpdate {
pu.mutation.ClearConfigValues()
// ClearModel clears the value of the "model" field.
func (pu *PlatformUpdate) ClearModel() *PlatformUpdate {
pu.mutation.ClearModel()
return pu
}
// SetConfigCue sets the "config_cue" field.
func (pu *PlatformUpdate) SetConfigCue(b []byte) *PlatformUpdate {
pu.mutation.SetConfigCue(b)
// SetCue sets the "cue" field.
func (pu *PlatformUpdate) SetCue(b []byte) *PlatformUpdate {
pu.mutation.SetCue(b)
return pu
}
// ClearConfigCue clears the value of the "config_cue" field.
func (pu *PlatformUpdate) ClearConfigCue() *PlatformUpdate {
pu.mutation.ClearConfigCue()
// ClearCue clears the value of the "cue" field.
func (pu *PlatformUpdate) ClearCue() *PlatformUpdate {
pu.mutation.ClearCue()
return pu
}
// SetConfigDefinition sets the "config_definition" field.
func (pu *PlatformUpdate) SetConfigDefinition(s string) *PlatformUpdate {
pu.mutation.SetConfigDefinition(s)
// SetCueDefinition sets the "cue_definition" field.
func (pu *PlatformUpdate) SetCueDefinition(s string) *PlatformUpdate {
pu.mutation.SetCueDefinition(s)
return pu
}
// SetNillableConfigDefinition sets the "config_definition" field if the given value is not nil.
func (pu *PlatformUpdate) SetNillableConfigDefinition(s *string) *PlatformUpdate {
// SetNillableCueDefinition sets the "cue_definition" field if the given value is not nil.
func (pu *PlatformUpdate) SetNillableCueDefinition(s *string) *PlatformUpdate {
if s != nil {
pu.SetConfigDefinition(*s)
pu.SetCueDefinition(*s)
}
return pu
}
// ClearConfigDefinition clears the value of the "config_definition" field.
func (pu *PlatformUpdate) ClearConfigDefinition() *PlatformUpdate {
pu.mutation.ClearConfigDefinition()
// ClearCueDefinition clears the value of the "cue_definition" field.
func (pu *PlatformUpdate) ClearCueDefinition() *PlatformUpdate {
pu.mutation.ClearCueDefinition()
return pu
}
@@ -214,7 +214,7 @@ func (pu *PlatformUpdate) ExecX(ctx context.Context) {
// defaults sets the default values of the builder before save.
func (pu *PlatformUpdate) defaults() {
if _, ok := pu.mutation.UpdatedAt(); !ok {
v := platform.UpdateDefaultUpdatedAt()
v := entplatform.UpdateDefaultUpdatedAt()
pu.mutation.SetUpdatedAt(v)
}
}
@@ -222,7 +222,7 @@ func (pu *PlatformUpdate) defaults() {
// check runs all checks and user-defined validators on the builder.
func (pu *PlatformUpdate) check() error {
if v, ok := pu.mutation.Name(); ok {
if err := platform.NameValidator(v); err != nil {
if err := entplatform.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Platform.name": %w`, err)}
}
}
@@ -239,7 +239,7 @@ func (pu *PlatformUpdate) sqlSave(ctx context.Context) (n int, err error) {
if err := pu.check(); err != nil {
return n, err
}
_spec := sqlgraph.NewUpdateSpec(platform.Table, platform.Columns, sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID))
_spec := sqlgraph.NewUpdateSpec(entplatform.Table, entplatform.Columns, sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID))
if ps := pu.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
@@ -248,44 +248,44 @@ func (pu *PlatformUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
}
if value, ok := pu.mutation.UpdatedAt(); ok {
_spec.SetField(platform.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entplatform.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := pu.mutation.Name(); ok {
_spec.SetField(platform.FieldName, field.TypeString, value)
_spec.SetField(entplatform.FieldName, field.TypeString, value)
}
if value, ok := pu.mutation.DisplayName(); ok {
_spec.SetField(platform.FieldDisplayName, field.TypeString, value)
_spec.SetField(entplatform.FieldDisplayName, field.TypeString, value)
}
if value, ok := pu.mutation.ConfigForm(); ok {
_spec.SetField(platform.FieldConfigForm, field.TypeJSON, value)
if value, ok := pu.mutation.Form(); ok {
_spec.SetField(entplatform.FieldForm, field.TypeJSON, value)
}
if pu.mutation.ConfigFormCleared() {
_spec.ClearField(platform.FieldConfigForm, field.TypeJSON)
if pu.mutation.FormCleared() {
_spec.ClearField(entplatform.FieldForm, field.TypeJSON)
}
if value, ok := pu.mutation.ConfigValues(); ok {
_spec.SetField(platform.FieldConfigValues, field.TypeJSON, value)
if value, ok := pu.mutation.Model(); ok {
_spec.SetField(entplatform.FieldModel, field.TypeJSON, value)
}
if pu.mutation.ConfigValuesCleared() {
_spec.ClearField(platform.FieldConfigValues, field.TypeJSON)
if pu.mutation.ModelCleared() {
_spec.ClearField(entplatform.FieldModel, field.TypeJSON)
}
if value, ok := pu.mutation.ConfigCue(); ok {
_spec.SetField(platform.FieldConfigCue, field.TypeBytes, value)
if value, ok := pu.mutation.Cue(); ok {
_spec.SetField(entplatform.FieldCue, field.TypeBytes, value)
}
if pu.mutation.ConfigCueCleared() {
_spec.ClearField(platform.FieldConfigCue, field.TypeBytes)
if pu.mutation.CueCleared() {
_spec.ClearField(entplatform.FieldCue, field.TypeBytes)
}
if value, ok := pu.mutation.ConfigDefinition(); ok {
_spec.SetField(platform.FieldConfigDefinition, field.TypeString, value)
if value, ok := pu.mutation.CueDefinition(); ok {
_spec.SetField(entplatform.FieldCueDefinition, field.TypeString, value)
}
if pu.mutation.ConfigDefinitionCleared() {
_spec.ClearField(platform.FieldConfigDefinition, field.TypeString)
if pu.mutation.CueDefinitionCleared() {
_spec.ClearField(entplatform.FieldCueDefinition, field.TypeString)
}
if pu.mutation.CreatorCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.CreatorTable,
Columns: []string{platform.CreatorColumn},
Table: entplatform.CreatorTable,
Columns: []string{entplatform.CreatorColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
@@ -297,8 +297,8 @@ func (pu *PlatformUpdate) sqlSave(ctx context.Context) (n int, err error) {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.CreatorTable,
Columns: []string{platform.CreatorColumn},
Table: entplatform.CreatorTable,
Columns: []string{entplatform.CreatorColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
@@ -313,8 +313,8 @@ func (pu *PlatformUpdate) sqlSave(ctx context.Context) (n int, err error) {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.OrganizationTable,
Columns: []string{platform.OrganizationColumn},
Table: entplatform.OrganizationTable,
Columns: []string{entplatform.OrganizationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID),
@@ -326,8 +326,8 @@ func (pu *PlatformUpdate) sqlSave(ctx context.Context) (n int, err error) {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.OrganizationTable,
Columns: []string{platform.OrganizationColumn},
Table: entplatform.OrganizationTable,
Columns: []string{entplatform.OrganizationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID),
@@ -340,7 +340,7 @@ func (pu *PlatformUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{platform.Label}
err = &NotFoundError{entplatform.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
@@ -420,59 +420,59 @@ func (puo *PlatformUpdateOne) SetNillableCreatorID(u *uuid.UUID) *PlatformUpdate
return puo
}
// SetConfigForm sets the "config_form" field.
func (puo *PlatformUpdateOne) SetConfigForm(hf *holos.PlatformForm) *PlatformUpdateOne {
puo.mutation.SetConfigForm(hf)
// SetForm sets the "form" field.
func (puo *PlatformUpdateOne) SetForm(pl *platform.Form) *PlatformUpdateOne {
puo.mutation.SetForm(pl)
return puo
}
// ClearConfigForm clears the value of the "config_form" field.
func (puo *PlatformUpdateOne) ClearConfigForm() *PlatformUpdateOne {
puo.mutation.ClearConfigForm()
// ClearForm clears the value of the "form" field.
func (puo *PlatformUpdateOne) ClearForm() *PlatformUpdateOne {
puo.mutation.ClearForm()
return puo
}
// SetConfigValues sets the "config_values" field.
func (puo *PlatformUpdateOne) SetConfigValues(hv *holos.ConfigValues) *PlatformUpdateOne {
puo.mutation.SetConfigValues(hv)
// SetModel sets the "model" field.
func (puo *PlatformUpdateOne) SetModel(pl *platform.Model) *PlatformUpdateOne {
puo.mutation.SetModel(pl)
return puo
}
// ClearConfigValues clears the value of the "config_values" field.
func (puo *PlatformUpdateOne) ClearConfigValues() *PlatformUpdateOne {
puo.mutation.ClearConfigValues()
// ClearModel clears the value of the "model" field.
func (puo *PlatformUpdateOne) ClearModel() *PlatformUpdateOne {
puo.mutation.ClearModel()
return puo
}
// SetConfigCue sets the "config_cue" field.
func (puo *PlatformUpdateOne) SetConfigCue(b []byte) *PlatformUpdateOne {
puo.mutation.SetConfigCue(b)
// SetCue sets the "cue" field.
func (puo *PlatformUpdateOne) SetCue(b []byte) *PlatformUpdateOne {
puo.mutation.SetCue(b)
return puo
}
// ClearConfigCue clears the value of the "config_cue" field.
func (puo *PlatformUpdateOne) ClearConfigCue() *PlatformUpdateOne {
puo.mutation.ClearConfigCue()
// ClearCue clears the value of the "cue" field.
func (puo *PlatformUpdateOne) ClearCue() *PlatformUpdateOne {
puo.mutation.ClearCue()
return puo
}
// SetConfigDefinition sets the "config_definition" field.
func (puo *PlatformUpdateOne) SetConfigDefinition(s string) *PlatformUpdateOne {
puo.mutation.SetConfigDefinition(s)
// SetCueDefinition sets the "cue_definition" field.
func (puo *PlatformUpdateOne) SetCueDefinition(s string) *PlatformUpdateOne {
puo.mutation.SetCueDefinition(s)
return puo
}
// SetNillableConfigDefinition sets the "config_definition" field if the given value is not nil.
func (puo *PlatformUpdateOne) SetNillableConfigDefinition(s *string) *PlatformUpdateOne {
// SetNillableCueDefinition sets the "cue_definition" field if the given value is not nil.
func (puo *PlatformUpdateOne) SetNillableCueDefinition(s *string) *PlatformUpdateOne {
if s != nil {
puo.SetConfigDefinition(*s)
puo.SetCueDefinition(*s)
}
return puo
}
// ClearConfigDefinition clears the value of the "config_definition" field.
func (puo *PlatformUpdateOne) ClearConfigDefinition() *PlatformUpdateOne {
puo.mutation.ClearConfigDefinition()
// ClearCueDefinition clears the value of the "cue_definition" field.
func (puo *PlatformUpdateOne) ClearCueDefinition() *PlatformUpdateOne {
puo.mutation.ClearCueDefinition()
return puo
}
@@ -553,7 +553,7 @@ func (puo *PlatformUpdateOne) ExecX(ctx context.Context) {
// defaults sets the default values of the builder before save.
func (puo *PlatformUpdateOne) defaults() {
if _, ok := puo.mutation.UpdatedAt(); !ok {
v := platform.UpdateDefaultUpdatedAt()
v := entplatform.UpdateDefaultUpdatedAt()
puo.mutation.SetUpdatedAt(v)
}
}
@@ -561,7 +561,7 @@ func (puo *PlatformUpdateOne) defaults() {
// check runs all checks and user-defined validators on the builder.
func (puo *PlatformUpdateOne) check() error {
if v, ok := puo.mutation.Name(); ok {
if err := platform.NameValidator(v); err != nil {
if err := entplatform.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Platform.name": %w`, err)}
}
}
@@ -578,7 +578,7 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
if err := puo.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(platform.Table, platform.Columns, sqlgraph.NewFieldSpec(platform.FieldID, field.TypeUUID))
_spec := sqlgraph.NewUpdateSpec(entplatform.Table, entplatform.Columns, sqlgraph.NewFieldSpec(entplatform.FieldID, field.TypeUUID))
id, ok := puo.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Platform.id" for update`)}
@@ -586,12 +586,12 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
_spec.Node.ID.Value = id
if fields := puo.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, platform.FieldID)
_spec.Node.Columns = append(_spec.Node.Columns, entplatform.FieldID)
for _, f := range fields {
if !platform.ValidColumn(f) {
if !entplatform.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != platform.FieldID {
if f != entplatform.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
@@ -604,44 +604,44 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
}
}
if value, ok := puo.mutation.UpdatedAt(); ok {
_spec.SetField(platform.FieldUpdatedAt, field.TypeTime, value)
_spec.SetField(entplatform.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := puo.mutation.Name(); ok {
_spec.SetField(platform.FieldName, field.TypeString, value)
_spec.SetField(entplatform.FieldName, field.TypeString, value)
}
if value, ok := puo.mutation.DisplayName(); ok {
_spec.SetField(platform.FieldDisplayName, field.TypeString, value)
_spec.SetField(entplatform.FieldDisplayName, field.TypeString, value)
}
if value, ok := puo.mutation.ConfigForm(); ok {
_spec.SetField(platform.FieldConfigForm, field.TypeJSON, value)
if value, ok := puo.mutation.Form(); ok {
_spec.SetField(entplatform.FieldForm, field.TypeJSON, value)
}
if puo.mutation.ConfigFormCleared() {
_spec.ClearField(platform.FieldConfigForm, field.TypeJSON)
if puo.mutation.FormCleared() {
_spec.ClearField(entplatform.FieldForm, field.TypeJSON)
}
if value, ok := puo.mutation.ConfigValues(); ok {
_spec.SetField(platform.FieldConfigValues, field.TypeJSON, value)
if value, ok := puo.mutation.Model(); ok {
_spec.SetField(entplatform.FieldModel, field.TypeJSON, value)
}
if puo.mutation.ConfigValuesCleared() {
_spec.ClearField(platform.FieldConfigValues, field.TypeJSON)
if puo.mutation.ModelCleared() {
_spec.ClearField(entplatform.FieldModel, field.TypeJSON)
}
if value, ok := puo.mutation.ConfigCue(); ok {
_spec.SetField(platform.FieldConfigCue, field.TypeBytes, value)
if value, ok := puo.mutation.Cue(); ok {
_spec.SetField(entplatform.FieldCue, field.TypeBytes, value)
}
if puo.mutation.ConfigCueCleared() {
_spec.ClearField(platform.FieldConfigCue, field.TypeBytes)
if puo.mutation.CueCleared() {
_spec.ClearField(entplatform.FieldCue, field.TypeBytes)
}
if value, ok := puo.mutation.ConfigDefinition(); ok {
_spec.SetField(platform.FieldConfigDefinition, field.TypeString, value)
if value, ok := puo.mutation.CueDefinition(); ok {
_spec.SetField(entplatform.FieldCueDefinition, field.TypeString, value)
}
if puo.mutation.ConfigDefinitionCleared() {
_spec.ClearField(platform.FieldConfigDefinition, field.TypeString)
if puo.mutation.CueDefinitionCleared() {
_spec.ClearField(entplatform.FieldCueDefinition, field.TypeString)
}
if puo.mutation.CreatorCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.CreatorTable,
Columns: []string{platform.CreatorColumn},
Table: entplatform.CreatorTable,
Columns: []string{entplatform.CreatorColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
@@ -653,8 +653,8 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.CreatorTable,
Columns: []string{platform.CreatorColumn},
Table: entplatform.CreatorTable,
Columns: []string{entplatform.CreatorColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
@@ -669,8 +669,8 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.OrganizationTable,
Columns: []string{platform.OrganizationColumn},
Table: entplatform.OrganizationTable,
Columns: []string{entplatform.OrganizationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID),
@@ -682,8 +682,8 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: platform.OrganizationTable,
Columns: []string{platform.OrganizationColumn},
Table: entplatform.OrganizationTable,
Columns: []string{entplatform.OrganizationColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(organization.FieldID, field.TypeUUID),
@@ -699,7 +699,7 @@ func (puo *PlatformUpdateOne) sqlSave(ctx context.Context) (_node *Platform, err
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{platform.Label}
err = &NotFoundError{entplatform.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}

View File

@@ -9,7 +9,7 @@ import (
// Organization is the predicate function for organization builders.
type Organization func(*sql.Selector)
// Platform is the predicate function for platform builders.
// Platform is the predicate function for entplatform builders.
type Platform func(*sql.Selector)
// User is the predicate function for user builders.

View File

@@ -7,7 +7,7 @@ import (
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/schema"
"github.com/holos-run/holos/internal/ent/user"
)
@@ -41,31 +41,31 @@ func init() {
organizationDescID := organizationMixinFields0[0].Descriptor()
// organization.DefaultID holds the default value on creation for the id field.
organization.DefaultID = organizationDescID.Default.(func() uuid.UUID)
platformMixin := schema.Platform{}.Mixin()
platformMixinFields0 := platformMixin[0].Fields()
_ = platformMixinFields0
platformMixinFields1 := platformMixin[1].Fields()
_ = platformMixinFields1
platformFields := schema.Platform{}.Fields()
_ = platformFields
// platformDescCreatedAt is the schema descriptor for created_at field.
platformDescCreatedAt := platformMixinFields1[0].Descriptor()
// platform.DefaultCreatedAt holds the default value on creation for the created_at field.
platform.DefaultCreatedAt = platformDescCreatedAt.Default.(func() time.Time)
// platformDescUpdatedAt is the schema descriptor for updated_at field.
platformDescUpdatedAt := platformMixinFields1[1].Descriptor()
// platform.DefaultUpdatedAt holds the default value on creation for the updated_at field.
platform.DefaultUpdatedAt = platformDescUpdatedAt.Default.(func() time.Time)
// platform.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
platform.UpdateDefaultUpdatedAt = platformDescUpdatedAt.UpdateDefault.(func() time.Time)
// platformDescName is the schema descriptor for name field.
platformDescName := platformFields[1].Descriptor()
// platform.NameValidator is a validator for the "name" field. It is called by the builders before save.
platform.NameValidator = platformDescName.Validators[0].(func(string) error)
// platformDescID is the schema descriptor for id field.
platformDescID := platformMixinFields0[0].Descriptor()
// platform.DefaultID holds the default value on creation for the id field.
platform.DefaultID = platformDescID.Default.(func() uuid.UUID)
entplatformMixin := schema.Platform{}.Mixin()
entplatformMixinFields0 := entplatformMixin[0].Fields()
_ = entplatformMixinFields0
entplatformMixinFields1 := entplatformMixin[1].Fields()
_ = entplatformMixinFields1
entplatformFields := schema.Platform{}.Fields()
_ = entplatformFields
// entplatformDescCreatedAt is the schema descriptor for created_at field.
entplatformDescCreatedAt := entplatformMixinFields1[0].Descriptor()
// entplatform.DefaultCreatedAt holds the default value on creation for the created_at field.
entplatform.DefaultCreatedAt = entplatformDescCreatedAt.Default.(func() time.Time)
// entplatformDescUpdatedAt is the schema descriptor for updated_at field.
entplatformDescUpdatedAt := entplatformMixinFields1[1].Descriptor()
// entplatform.DefaultUpdatedAt holds the default value on creation for the updated_at field.
entplatform.DefaultUpdatedAt = entplatformDescUpdatedAt.Default.(func() time.Time)
// entplatform.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
entplatform.UpdateDefaultUpdatedAt = entplatformDescUpdatedAt.UpdateDefault.(func() time.Time)
// entplatformDescName is the schema descriptor for name field.
entplatformDescName := entplatformFields[1].Descriptor()
// entplatform.NameValidator is a validator for the "name" field. It is called by the builders before save.
entplatform.NameValidator = entplatformDescName.Validators[0].(func(string) error)
// entplatformDescID is the schema descriptor for id field.
entplatformDescID := entplatformMixinFields0[0].Descriptor()
// entplatform.DefaultID holds the default value on creation for the id field.
entplatform.DefaultID = entplatformDescID.Default.(func() uuid.UUID)
userMixin := schema.User{}.Mixin()
userMixinFields0 := userMixin[0].Fields()
_ = userMixinFields0

View File

@@ -6,7 +6,7 @@ import (
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/gofrs/uuid"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
platform "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
)
type Platform struct {
@@ -26,16 +26,16 @@ func (Platform) Fields() []ent.Field {
field.String("name").NotEmpty(),
field.String("display_name"),
field.UUID("creator_id", uuid.UUID{}),
field.JSON("config_form", &holos.PlatformForm{}).
field.JSON("form", &platform.Form{}).
Optional().
Comment("JSON holos.PlatformForm representing the platform data entry form."),
field.JSON("config_values", &holos.ConfigValues{}).
Comment("JSON representation of FormlyFormConfig[] refer to https://github.com/holos-run/holos/issues/161"),
field.JSON("model", &platform.Model{}).
Optional().
Comment("JSON holos.ConfigValues representing the platform config values."),
field.Bytes("config_cue").
Comment("JSON representation of the form model which holds user input values refer to https://github.com/holos-run/holos/issues/161"),
field.Bytes("cue").
Optional().
Comment("Opaque bytes representing the CUE definition of the config struct."),
field.String("config_definition").
Comment("CUE definition to vet the model against e.g. #PlatformConfig"),
field.String("cue_definition").
Optional().
Comment("The definition name to vet config_values against config_cue e.g. '#PlatformSpec'"),
}

View File

@@ -9,6 +9,7 @@ import { provideClient } from "../connect/client.provider";
import { UserService } from './gen/holos/v1alpha1/user_connect';
import { OrganizationService } from './gen/holos/v1alpha1/organization_connect';
import { PlatformService } from './gen/holos/v1alpha1/platform_connect';
import { HolosPanelWrapperComponent } from '../wrappers/holos-panel-wrapper/holos-panel-wrapper.component';
export const appConfig: ApplicationConfig = {
providers: [
@@ -22,7 +23,9 @@ export const appConfig: ApplicationConfig = {
ConnectModule.forRoot({
baseUrl: window.location.origin
}),
FormlyModule.forRoot(),
FormlyModule.forRoot({
wrappers: [{ name: 'holos-panel', component: HolosPanelWrapperComponent }],
}),
),
]
};

View File

@@ -0,0 +1,105 @@
// @generated by protoc-gen-connect-query v1.3.1 with parameter "target=ts"
// @generated from file holos/platform/v1alpha1/platform.proto (package holos.platform.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { MethodKind } from "@bufbuild/protobuf";
import { AddPlatformRequest, AddPlatformResponse, GetFormRequest, GetFormResponse, GetModelRequest, GetModelResponse, GetPlatformRequest, GetPlatformResponse, ListPlatformsRequest, ListPlatformsResponse, PutFormRequest, PutFormResponse, PutModelRequest, PutModelResponse } from "./platform_pb.js";
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.AddPlatform
*/
export const addPlatform = {
localName: "addPlatform",
name: "AddPlatform",
kind: MethodKind.Unary,
I: AddPlatformRequest,
O: AddPlatformResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetPlatform
*/
export const getPlatform = {
localName: "getPlatform",
name: "GetPlatform",
kind: MethodKind.Unary,
I: GetPlatformRequest,
O: GetPlatformResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.ListPlatforms
*/
export const listPlatforms = {
localName: "listPlatforms",
name: "ListPlatforms",
kind: MethodKind.Unary,
I: ListPlatformsRequest,
O: ListPlatformsResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetForm
*/
export const getForm = {
localName: "getForm",
name: "GetForm",
kind: MethodKind.Unary,
I: GetFormRequest,
O: GetFormResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.PutForm
*/
export const putForm = {
localName: "putForm",
name: "PutForm",
kind: MethodKind.Unary,
I: PutFormRequest,
O: PutFormResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetModel
*/
export const getModel = {
localName: "getModel",
name: "GetModel",
kind: MethodKind.Unary,
I: GetModelRequest,
O: GetModelResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.PutModel
*/
export const putModel = {
localName: "putModel",
name: "PutModel",
kind: MethodKind.Unary,
I: PutModelRequest,
O: PutModelResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;

View File

@@ -0,0 +1,80 @@
// @generated by protoc-gen-connect-es v1.4.0 with parameter "target=ts"
// @generated from file holos/platform/v1alpha1/platform.proto (package holos.platform.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { AddPlatformRequest, AddPlatformResponse, GetFormRequest, GetFormResponse, GetModelRequest, GetModelResponse, GetPlatformRequest, GetPlatformResponse, ListPlatformsRequest, ListPlatformsResponse, PutFormRequest, PutFormResponse, PutModelRequest, PutModelResponse } from "./platform_pb.js";
import { MethodKind } from "@bufbuild/protobuf";
/**
* @generated from service holos.platform.v1alpha1.PlatformService
*/
export const PlatformService = {
typeName: "holos.platform.v1alpha1.PlatformService",
methods: {
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.AddPlatform
*/
addPlatform: {
name: "AddPlatform",
I: AddPlatformRequest,
O: AddPlatformResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetPlatform
*/
getPlatform: {
name: "GetPlatform",
I: GetPlatformRequest,
O: GetPlatformResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.ListPlatforms
*/
listPlatforms: {
name: "ListPlatforms",
I: ListPlatformsRequest,
O: ListPlatformsResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetForm
*/
getForm: {
name: "GetForm",
I: GetFormRequest,
O: GetFormResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.PutForm
*/
putForm: {
name: "PutForm",
I: PutFormRequest,
O: PutFormResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetModel
*/
getModel: {
name: "GetModel",
I: GetModelRequest,
O: GetModelResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.PutModel
*/
putModel: {
name: "PutModel",
I: PutModelRequest,
O: PutModelResponse,
kind: MethodKind.Unary,
},
}
} as const;

View File

@@ -0,0 +1,732 @@
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts"
// @generated from file holos/platform/v1alpha1/platform.proto (package holos.platform.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3, Struct } from "@bufbuild/protobuf";
/**
* @generated from message holos.platform.v1alpha1.Platform
*/
export class Platform extends Message<Platform> {
/**
* Unique id assigned by the server.
*
* @generated from field: string id = 1;
*/
id = "";
/**
* Organization ID resource owner.
*
* @generated from field: string org_id = 2;
*/
orgId = "";
/**
* name is the platform short name as a dns label.
*
* @generated from field: string name = 3;
*/
name = "";
/**
* @generated from field: string display_name = 4;
*/
displayName = "";
/**
* @generated from field: holos.platform.v1alpha1.PlatformSpec spec = 5;
*/
spec?: PlatformSpec;
constructor(data?: PartialMessage<Platform>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.Platform";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "org_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 4, name: "display_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 5, name: "spec", kind: "message", T: PlatformSpec },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Platform {
return new Platform().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Platform {
return new Platform().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Platform {
return new Platform().fromJsonString(jsonString, options);
}
static equals(a: Platform | PlainMessage<Platform> | undefined, b: Platform | PlainMessage<Platform> | undefined): boolean {
return proto3.util.equals(Platform, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.PlatformSpec
*/
export class PlatformSpec extends Message<PlatformSpec> {
/**
* model represents the user-defined and user-supplied form field values.
*
* @generated from field: google.protobuf.Struct model = 1;
*/
model?: Struct;
constructor(data?: PartialMessage<PlatformSpec>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.PlatformSpec";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "model", kind: "message", T: Struct },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PlatformSpec {
return new PlatformSpec().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PlatformSpec {
return new PlatformSpec().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PlatformSpec {
return new PlatformSpec().fromJsonString(jsonString, options);
}
static equals(a: PlatformSpec | PlainMessage<PlatformSpec> | undefined, b: PlatformSpec | PlainMessage<PlatformSpec> | undefined): boolean {
return proto3.util.equals(PlatformSpec, a, b);
}
}
/**
* Form represents the Formly input form.
*
* @generated from message holos.platform.v1alpha1.Form
*/
export class Form extends Message<Form> {
/**
* fields represents FormlyFieldConfig[] encoded as a JSON array.
*
* @generated from field: repeated google.protobuf.Struct fields = 1;
*/
fields: Struct[] = [];
constructor(data?: PartialMessage<Form>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.Form";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "fields", kind: "message", T: Struct, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Form {
return new Form().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Form {
return new Form().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Form {
return new Form().fromJsonString(jsonString, options);
}
static equals(a: Form | PlainMessage<Form> | undefined, b: Form | PlainMessage<Form> | undefined): boolean {
return proto3.util.equals(Form, a, b);
}
}
/**
* Model represents the values entered into the form, stored in the form's model
* in the web app, and persisted into the backend database. The model is
* ultimately intended as the input to platform rendering.
*
* @generated from message holos.platform.v1alpha1.Model
*/
export class Model extends Message<Model> {
/**
* @generated from field: google.protobuf.Struct model = 1;
*/
model?: Struct;
constructor(data?: PartialMessage<Model>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.Model";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "model", kind: "message", T: Struct },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Model {
return new Model().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Model {
return new Model().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Model {
return new Model().fromJsonString(jsonString, options);
}
static equals(a: Model | PlainMessage<Model> | undefined, b: Model | PlainMessage<Model> | undefined): boolean {
return proto3.util.equals(Model, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.ListPlatformsRequest
*/
export class ListPlatformsRequest extends Message<ListPlatformsRequest> {
/**
* @generated from field: string org_id = 1;
*/
orgId = "";
constructor(data?: PartialMessage<ListPlatformsRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.ListPlatformsRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "org_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ListPlatformsRequest {
return new ListPlatformsRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ListPlatformsRequest {
return new ListPlatformsRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ListPlatformsRequest {
return new ListPlatformsRequest().fromJsonString(jsonString, options);
}
static equals(a: ListPlatformsRequest | PlainMessage<ListPlatformsRequest> | undefined, b: ListPlatformsRequest | PlainMessage<ListPlatformsRequest> | undefined): boolean {
return proto3.util.equals(ListPlatformsRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.ListPlatformsResponse
*/
export class ListPlatformsResponse extends Message<ListPlatformsResponse> {
/**
* @generated from field: repeated holos.platform.v1alpha1.Platform platforms = 1;
*/
platforms: Platform[] = [];
constructor(data?: PartialMessage<ListPlatformsResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.ListPlatformsResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platforms", kind: "message", T: Platform, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ListPlatformsResponse {
return new ListPlatformsResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ListPlatformsResponse {
return new ListPlatformsResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ListPlatformsResponse {
return new ListPlatformsResponse().fromJsonString(jsonString, options);
}
static equals(a: ListPlatformsResponse | PlainMessage<ListPlatformsResponse> | undefined, b: ListPlatformsResponse | PlainMessage<ListPlatformsResponse> | undefined): boolean {
return proto3.util.equals(ListPlatformsResponse, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.AddPlatformRequest
*/
export class AddPlatformRequest extends Message<AddPlatformRequest> {
/**
* @generated from field: holos.platform.v1alpha1.Platform platform = 1;
*/
platform?: Platform;
constructor(data?: PartialMessage<AddPlatformRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.AddPlatformRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform", kind: "message", T: Platform },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): AddPlatformRequest {
return new AddPlatformRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): AddPlatformRequest {
return new AddPlatformRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): AddPlatformRequest {
return new AddPlatformRequest().fromJsonString(jsonString, options);
}
static equals(a: AddPlatformRequest | PlainMessage<AddPlatformRequest> | undefined, b: AddPlatformRequest | PlainMessage<AddPlatformRequest> | undefined): boolean {
return proto3.util.equals(AddPlatformRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.AddPlatformResponse
*/
export class AddPlatformResponse extends Message<AddPlatformResponse> {
/**
* @generated from field: repeated holos.platform.v1alpha1.Platform platforms = 1;
*/
platforms: Platform[] = [];
constructor(data?: PartialMessage<AddPlatformResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.AddPlatformResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platforms", kind: "message", T: Platform, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): AddPlatformResponse {
return new AddPlatformResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): AddPlatformResponse {
return new AddPlatformResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): AddPlatformResponse {
return new AddPlatformResponse().fromJsonString(jsonString, options);
}
static equals(a: AddPlatformResponse | PlainMessage<AddPlatformResponse> | undefined, b: AddPlatformResponse | PlainMessage<AddPlatformResponse> | undefined): boolean {
return proto3.util.equals(AddPlatformResponse, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.GetPlatformRequest
*/
export class GetPlatformRequest extends Message<GetPlatformRequest> {
/**
* @generated from field: string platform_id = 1;
*/
platformId = "";
constructor(data?: PartialMessage<GetPlatformRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.GetPlatformRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetPlatformRequest {
return new GetPlatformRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetPlatformRequest {
return new GetPlatformRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetPlatformRequest {
return new GetPlatformRequest().fromJsonString(jsonString, options);
}
static equals(a: GetPlatformRequest | PlainMessage<GetPlatformRequest> | undefined, b: GetPlatformRequest | PlainMessage<GetPlatformRequest> | undefined): boolean {
return proto3.util.equals(GetPlatformRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.GetPlatformResponse
*/
export class GetPlatformResponse extends Message<GetPlatformResponse> {
/**
* @generated from field: holos.platform.v1alpha1.Platform platform = 1;
*/
platform?: Platform;
constructor(data?: PartialMessage<GetPlatformResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.GetPlatformResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform", kind: "message", T: Platform },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetPlatformResponse {
return new GetPlatformResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetPlatformResponse {
return new GetPlatformResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetPlatformResponse {
return new GetPlatformResponse().fromJsonString(jsonString, options);
}
static equals(a: GetPlatformResponse | PlainMessage<GetPlatformResponse> | undefined, b: GetPlatformResponse | PlainMessage<GetPlatformResponse> | undefined): boolean {
return proto3.util.equals(GetPlatformResponse, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.GetFormRequest
*/
export class GetFormRequest extends Message<GetFormRequest> {
/**
* @generated from field: string platform_id = 1;
*/
platformId = "";
constructor(data?: PartialMessage<GetFormRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.GetFormRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetFormRequest {
return new GetFormRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetFormRequest {
return new GetFormRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetFormRequest {
return new GetFormRequest().fromJsonString(jsonString, options);
}
static equals(a: GetFormRequest | PlainMessage<GetFormRequest> | undefined, b: GetFormRequest | PlainMessage<GetFormRequest> | undefined): boolean {
return proto3.util.equals(GetFormRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.GetFormResponse
*/
export class GetFormResponse extends Message<GetFormResponse> {
/**
* @generated from field: repeated google.protobuf.Struct fields = 1;
*/
fields: Struct[] = [];
/**
* @generated from field: google.protobuf.Struct model = 2;
*/
model?: Struct;
constructor(data?: PartialMessage<GetFormResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.GetFormResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "fields", kind: "message", T: Struct, repeated: true },
{ no: 2, name: "model", kind: "message", T: Struct },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetFormResponse {
return new GetFormResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetFormResponse {
return new GetFormResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetFormResponse {
return new GetFormResponse().fromJsonString(jsonString, options);
}
static equals(a: GetFormResponse | PlainMessage<GetFormResponse> | undefined, b: GetFormResponse | PlainMessage<GetFormResponse> | undefined): boolean {
return proto3.util.equals(GetFormResponse, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.GetModelRequest
*/
export class GetModelRequest extends Message<GetModelRequest> {
/**
* @generated from field: string platform_id = 1;
*/
platformId = "";
constructor(data?: PartialMessage<GetModelRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.GetModelRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetModelRequest {
return new GetModelRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetModelRequest {
return new GetModelRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetModelRequest {
return new GetModelRequest().fromJsonString(jsonString, options);
}
static equals(a: GetModelRequest | PlainMessage<GetModelRequest> | undefined, b: GetModelRequest | PlainMessage<GetModelRequest> | undefined): boolean {
return proto3.util.equals(GetModelRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.GetModelResponse
*/
export class GetModelResponse extends Message<GetModelResponse> {
/**
* @generated from field: google.protobuf.Struct model = 1;
*/
model?: Struct;
constructor(data?: PartialMessage<GetModelResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.GetModelResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "model", kind: "message", T: Struct },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetModelResponse {
return new GetModelResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): GetModelResponse {
return new GetModelResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): GetModelResponse {
return new GetModelResponse().fromJsonString(jsonString, options);
}
static equals(a: GetModelResponse | PlainMessage<GetModelResponse> | undefined, b: GetModelResponse | PlainMessage<GetModelResponse> | undefined): boolean {
return proto3.util.equals(GetModelResponse, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.PutModelRequest
*/
export class PutModelRequest extends Message<PutModelRequest> {
/**
* @generated from field: string platform_id = 1;
*/
platformId = "";
/**
* @generated from field: google.protobuf.Struct model = 2;
*/
model?: Struct;
constructor(data?: PartialMessage<PutModelRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.PutModelRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "model", kind: "message", T: Struct },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PutModelRequest {
return new PutModelRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PutModelRequest {
return new PutModelRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PutModelRequest {
return new PutModelRequest().fromJsonString(jsonString, options);
}
static equals(a: PutModelRequest | PlainMessage<PutModelRequest> | undefined, b: PutModelRequest | PlainMessage<PutModelRequest> | undefined): boolean {
return proto3.util.equals(PutModelRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.PutModelResponse
*/
export class PutModelResponse extends Message<PutModelResponse> {
/**
* @generated from field: google.protobuf.Struct model = 1;
*/
model?: Struct;
constructor(data?: PartialMessage<PutModelResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.PutModelResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "model", kind: "message", T: Struct },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PutModelResponse {
return new PutModelResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PutModelResponse {
return new PutModelResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PutModelResponse {
return new PutModelResponse().fromJsonString(jsonString, options);
}
static equals(a: PutModelResponse | PlainMessage<PutModelResponse> | undefined, b: PutModelResponse | PlainMessage<PutModelResponse> | undefined): boolean {
return proto3.util.equals(PutModelResponse, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.PutFormRequest
*/
export class PutFormRequest extends Message<PutFormRequest> {
/**
* @generated from field: string platform_id = 1;
*/
platformId = "";
/**
* @generated from field: repeated google.protobuf.Struct fields = 2;
*/
fields: Struct[] = [];
constructor(data?: PartialMessage<PutFormRequest>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.PutFormRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "platform_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "fields", kind: "message", T: Struct, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PutFormRequest {
return new PutFormRequest().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PutFormRequest {
return new PutFormRequest().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PutFormRequest {
return new PutFormRequest().fromJsonString(jsonString, options);
}
static equals(a: PutFormRequest | PlainMessage<PutFormRequest> | undefined, b: PutFormRequest | PlainMessage<PutFormRequest> | undefined): boolean {
return proto3.util.equals(PutFormRequest, a, b);
}
}
/**
* @generated from message holos.platform.v1alpha1.PutFormResponse
*/
export class PutFormResponse extends Message<PutFormResponse> {
/**
* @generated from field: repeated google.protobuf.Struct fields = 1;
*/
fields: Struct[] = [];
constructor(data?: PartialMessage<PutFormResponse>) {
super();
proto3.util.initPartial(data, this);
}
static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "holos.platform.v1alpha1.PutFormResponse";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "fields", kind: "message", T: Struct, repeated: true },
]);
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PutFormResponse {
return new PutFormResponse().fromBinary(bytes, options);
}
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PutFormResponse {
return new PutFormResponse().fromJson(jsonValue, options);
}
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PutFormResponse {
return new PutFormResponse().fromJsonString(jsonString, options);
}
static equals(a: PutFormResponse | PlainMessage<PutFormResponse> | undefined, b: PutFormResponse | PlainMessage<PutFormResponse> | undefined): boolean {
return proto3.util.equals(PutFormResponse, a, b);
}
}

View File

@@ -1,41 +1,27 @@
// @generated by protoc-gen-connect-query v1.3.1 with parameter "target=ts"
// @generated from file holos/v1alpha1/platform.proto (package holos.v1alpha1, syntax proto3)
// @generated from file holos/v1alpha1/platform.proto (package holos.platform.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { MethodKind } from "@bufbuild/protobuf";
import { AddPlatformRequest, ConfigValues, GetPlatformConfigRequest, GetPlatformRequest, GetPlatformResponse, GetPlatformsRequest, GetPlatformsResponse, PutPlatformConfigRequest } from "./platform_pb.js";
import { AddPlatformRequest, AddPlatformResponse, GetFormRequest, GetFormResponse, GetModelRequest, GetModelResponse, GetPlatformRequest, GetPlatformResponse, ListPlatformsRequest, ListPlatformsResponse, PutModelRequest, PutModelResponse } from "./platform_pb.js";
/**
* @generated from rpc holos.v1alpha1.PlatformService.AddPlatform
* @generated from rpc holos.platform.v1alpha1.PlatformService.AddPlatform
*/
export const addPlatform = {
localName: "addPlatform",
name: "AddPlatform",
kind: MethodKind.Unary,
I: AddPlatformRequest,
O: GetPlatformsResponse,
O: AddPlatformResponse,
service: {
typeName: "holos.v1alpha1.PlatformService"
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.v1alpha1.PlatformService.GetPlatforms
*/
export const getPlatforms = {
localName: "getPlatforms",
name: "GetPlatforms",
kind: MethodKind.Unary,
I: GetPlatformsRequest,
O: GetPlatformsResponse,
service: {
typeName: "holos.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.v1alpha1.PlatformService.GetPlatform
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetPlatform
*/
export const getPlatform = {
localName: "getPlatform",
@@ -44,36 +30,62 @@ export const getPlatform = {
I: GetPlatformRequest,
O: GetPlatformResponse,
service: {
typeName: "holos.v1alpha1.PlatformService"
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.v1alpha1.PlatformService.PutPlatformConfig
* @generated from rpc holos.platform.v1alpha1.PlatformService.ListPlatforms
*/
export const putPlatformConfig = {
localName: "putPlatformConfig",
name: "PutPlatformConfig",
export const listPlatforms = {
localName: "listPlatforms",
name: "ListPlatforms",
kind: MethodKind.Unary,
I: PutPlatformConfigRequest,
O: GetPlatformResponse,
I: ListPlatformsRequest,
O: ListPlatformsResponse,
service: {
typeName: "holos.v1alpha1.PlatformService"
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* GetConfig provides the unmarshalled config values for use with CUE
*
* @generated from rpc holos.v1alpha1.PlatformService.GetConfig
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetForm
*/
export const getConfig = {
localName: "getConfig",
name: "GetConfig",
export const getForm = {
localName: "getForm",
name: "GetForm",
kind: MethodKind.Unary,
I: GetPlatformConfigRequest,
O: ConfigValues,
I: GetFormRequest,
O: GetFormResponse,
service: {
typeName: "holos.v1alpha1.PlatformService"
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetModel
*/
export const getModel = {
localName: "getModel",
name: "GetModel",
kind: MethodKind.Unary,
I: GetModelRequest,
O: GetModelResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.PutModel
*/
export const putModel = {
localName: "putModel",
name: "PutModel",
kind: MethodKind.Unary,
I: PutModelRequest,
O: PutModelResponse,
service: {
typeName: "holos.platform.v1alpha1.PlatformService"
}
} as const;

View File

@@ -1,37 +1,28 @@
// @generated by protoc-gen-connect-es v1.4.0 with parameter "target=ts"
// @generated from file holos/v1alpha1/platform.proto (package holos.v1alpha1, syntax proto3)
// @generated from file holos/v1alpha1/platform.proto (package holos.platform.v1alpha1, syntax proto3)
/* eslint-disable */
// @ts-nocheck
import { AddPlatformRequest, ConfigValues, GetPlatformConfigRequest, GetPlatformRequest, GetPlatformResponse, GetPlatformsRequest, GetPlatformsResponse, PutPlatformConfigRequest } from "./platform_pb.js";
import { AddPlatformRequest, AddPlatformResponse, GetFormRequest, GetFormResponse, GetModelRequest, GetModelResponse, GetPlatformRequest, GetPlatformResponse, ListPlatformsRequest, ListPlatformsResponse, PutModelRequest, PutModelResponse } from "./platform_pb.js";
import { MethodKind } from "@bufbuild/protobuf";
/**
* @generated from service holos.v1alpha1.PlatformService
* @generated from service holos.platform.v1alpha1.PlatformService
*/
export const PlatformService = {
typeName: "holos.v1alpha1.PlatformService",
typeName: "holos.platform.v1alpha1.PlatformService",
methods: {
/**
* @generated from rpc holos.v1alpha1.PlatformService.AddPlatform
* @generated from rpc holos.platform.v1alpha1.PlatformService.AddPlatform
*/
addPlatform: {
name: "AddPlatform",
I: AddPlatformRequest,
O: GetPlatformsResponse,
O: AddPlatformResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.v1alpha1.PlatformService.GetPlatforms
*/
getPlatforms: {
name: "GetPlatforms",
I: GetPlatformsRequest,
O: GetPlatformsResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.v1alpha1.PlatformService.GetPlatform
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetPlatform
*/
getPlatform: {
name: "GetPlatform",
@@ -40,23 +31,39 @@ export const PlatformService = {
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.v1alpha1.PlatformService.PutPlatformConfig
* @generated from rpc holos.platform.v1alpha1.PlatformService.ListPlatforms
*/
putPlatformConfig: {
name: "PutPlatformConfig",
I: PutPlatformConfigRequest,
O: GetPlatformResponse,
listPlatforms: {
name: "ListPlatforms",
I: ListPlatformsRequest,
O: ListPlatformsResponse,
kind: MethodKind.Unary,
},
/**
* GetConfig provides the unmarshalled config values for use with CUE
*
* @generated from rpc holos.v1alpha1.PlatformService.GetConfig
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetForm
*/
getConfig: {
name: "GetConfig",
I: GetPlatformConfigRequest,
O: ConfigValues,
getForm: {
name: "GetForm",
I: GetFormRequest,
O: GetFormResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.GetModel
*/
getModel: {
name: "GetModel",
I: GetModelRequest,
O: GetModelResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc holos.platform.v1alpha1.PlatformService.PutModel
*/
putModel: {
name: "PutModel",
I: PutModelRequest,
O: PutModelResponse,
kind: MethodKind.Unary,
},
}

View File

@@ -13,7 +13,7 @@
.mat-toolbar.mat-primary {
position: sticky;
top: 0;
z-index: 1;
z-index: 1000;
}
.toolbar-spacer {

View File

@@ -2,60 +2,39 @@ import { Inject, Injectable } from '@angular/core';
import { PlatformService as ConnectPlatformService } from '../gen/holos/v1alpha1/platform_connect';
import { Observable, filter, of, switchMap } from 'rxjs';
import { ObservableClient } from '../../connect/observable-client';
import { Config, ConfigSection, ConfigValues, GetPlatformsRequest, Platform, PutPlatformConfigRequest } from '../gen/holos/v1alpha1/platform_pb';
import { Platform, GetFormResponse, ListPlatformsRequest, PutModelRequest, PutModelResponse } from '../gen/holos/v1alpha1/platform_pb';
import { Organization } from '../gen/holos/v1alpha1/organization_pb';
import { Struct, Value } from '@bufbuild/protobuf';
export interface Section {
[field: string]: any;
}
export interface Model {
[section: string]: Section;
}
import { JsonValue, Struct, } from '@bufbuild/protobuf';
@Injectable({
providedIn: 'root'
})
export class PlatformService {
getPlatforms(org: Observable<Organization>): Observable<Platform[]> {
listPlatforms(org: Observable<Organization>): Observable<Platform[]> {
return org.pipe(
switchMap(org => {
const req = new GetPlatformsRequest({ orgId: org.id })
return this.client.getPlatforms(req).pipe(
const req = new ListPlatformsRequest({ orgId: org.id })
return this.client.listPlatforms(req).pipe(
switchMap(resp => { return of(resp.platforms) })
)
})
)
}
getPlatform(id: string): Observable<Platform> {
return this.client.getPlatform({ platformId: id }).pipe(
switchMap(resp => {
return of(resp.platform);
}),
filter((platform): platform is Platform => platform !== undefined),
)
getForm(id: string): Observable<GetFormResponse> {
return this.client.getForm({ platformId: id })
}
putConfig(id: string, model: Model): Observable<Platform> {
const values = new ConfigValues
// Set string values from the model
Object.keys(model).forEach(sectionName => {
values.sections[sectionName] = new ConfigSection
Object.keys(model[sectionName]).forEach(fieldName => {
const val = new Value
val.fromJson(model[sectionName][fieldName])
values.sections[sectionName].fields[fieldName] = val
})
putModel(id: string, model: JsonValue): Observable<PutModelResponse> {
const req = new PutModelRequest({
platformId: id,
// "We recommend to use fromJson() to construct Struct literals" refer to
// https://github.com/bufbuild/protobuf-es/blob/main/docs/runtime_api.md#struct
model: Struct.fromJson(model),
})
const req = new PutPlatformConfigRequest({ platformId: id, values: values })
return this.client.putPlatformConfig(req).pipe(
switchMap(resp => { return of(resp.platform) }),
filter((platform): platform is Platform => platform !== undefined),
)
return this.client.putModel(req)
}
constructor(@Inject(ConnectPlatformService) private client: ObservableClient<typeof ConnectPlatformService>) { }
}

View File

@@ -1,25 +1,23 @@
<mat-tab-group>
<mat-tab label="Detail">
<div class="grid-container">
@if (platform$ | async; as platform) {
<form [formGroup]="form" (ngSubmit)="onSubmit(model)">
@for (section of platform.config?.form?.spec?.sections; track section.name) {
<h2>{{section.displayName ? section.displayName : section.name }}</h2>
<p>{{ section.description }}</p>
<formly-form [form]="form" [fields]="section.fieldConfigs" [model]="model[section.name]"></formly-form>
}
<p></p>
<button type="submit" mat-flat-button color="primary">Submit</button>
</form>
}
</div>
</mat-tab>
<div class="content-container">
<mat-tab-group>
<mat-tab label="Detail">
<div class="grid-container">
<form [formGroup]="form" (ngSubmit)="onSubmit(model)">
<formly-form [model]="model" [form]="form" [fields]="fields"></formly-form>
<button type="submit" mat-flat-button color="primary">Submit</button>
</form>
</div>
</mat-tab>
<mat-tab label="Raw">
<div class="grid-container">
@if (platform$ | async; as platform) {
<pre>{{ platform | json }}</pre>
}
</div>
</mat-tab>
</mat-tab-group>
<mat-tab label="Model">
<div class="grid-container">
<pre>{{ model | json }}</pre>
</div>
</mat-tab>
<mat-tab label="Fields">
<div class="grid-container">
<pre>{{ fields | json }}</pre>
</div>
</mat-tab>
</mat-tab-group>
</div>

View File

@@ -1,69 +1,78 @@
import { Component, Input, inject } from '@angular/core';
import { Observable, map, shareReplay } from 'rxjs';
import { Model, PlatformService } from '../../services/platform.service';
import { Platform } from '../../gen/holos/v1alpha1/platform_pb';
import { Component, Input, OnDestroy, inject } from '@angular/core';
import { Observable, Subject, shareReplay, takeUntil } from 'rxjs';
import { PlatformService } from '../../services/platform.service';
import { GetFormResponse } from '../../gen/holos/v1alpha1/platform_pb';
import { MatTab, MatTabGroup } from '@angular/material/tabs';
import { AsyncPipe, CommonModule } from '@angular/common';
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
import { FormlyMaterialModule } from '@ngx-formly/material';
import { FormlyModule } from '@ngx-formly/core';
import { FormlyFieldConfig, FormlyFormOptions, FormlyModule } from '@ngx-formly/core';
import { MatButton } from '@angular/material/button';
import { MatDivider } from '@angular/material/divider';
import { JsonObject, JsonValue } from '@bufbuild/protobuf';
@Component({
selector: 'app-platform-detail',
standalone: true,
imports: [
MatTabGroup,
MatTab,
AsyncPipe,
CommonModule,
FormlyModule,
ReactiveFormsModule,
FormlyMaterialModule,
FormlyModule,
MatButton,
MatDivider,
MatTab,
MatTabGroup,
ReactiveFormsModule,
],
templateUrl: './platform-detail.component.html',
styleUrl: './platform-detail.component.scss'
})
export class PlatformDetailComponent {
private service = inject(PlatformService);
export class PlatformDetailComponent implements OnDestroy {
private platformService = inject(PlatformService);
private platformId: string = "";
platform$!: Observable<Platform>;
private destroy$: Subject<any> = new Subject<any>();
form = new FormGroup({});
model: Model = {};
model: JsonValue = {};
options: FormlyFormOptions = {};
fields: FormlyFieldConfig[] = [];
onSubmit(model: Model) {
console.log(model)
onSubmit(model: JsonValue) {
// if (this.form.valid) {
this.service.putConfig(this.platformId, model).pipe(shareReplay(1)).subscribe()
console.log(model)
this.platformService
.putModel(this.platformId, model)
.pipe(takeUntil(this.destroy$))
.subscribe(resp => {
const model = JSON.parse(JSON.stringify(resp.model))
if (model) {
this.model = model
}
})
// }
}
@Input()
set id(platformId: string) {
this.platformId = platformId;
this.platform$ = this.service.getPlatform(platformId).pipe(
map(project => {
// Initialize the model container for each section of the form config
project.config?.form?.spec?.sections.forEach(section => {
this.model[section.name] = {}
})
// Load existing values into the form
const sections = project.config?.values?.sections
if (sections !== undefined) {
Object.keys(sections).forEach(sectionName => {
Object.keys(sections[sectionName].fields).forEach(fieldName => {
this.model[sectionName][fieldName] = sections[sectionName].fields[fieldName].toJson()
})
})
this.platformService
.getForm(platformId)
.pipe(takeUntil(this.destroy$))
.subscribe(resp => {
if (resp.fields !== undefined) {
// NOTE: We could map fields to mix in javascript functions. Refer to
// https://formly.dev/docs/examples/other/json-powered
this.fields = resp.fields.map(field => field.toJson() as FormlyFieldConfig)
}
return project
}),
shareReplay(1)
)
if (resp.model !== undefined) {
this.model = resp.model.toJson()
}
})
}
public ngOnDestroy(): void {
this.destroy$.next(true);
this.destroy$.complete();
}
}

View File

@@ -30,7 +30,7 @@ export class PlatformsComponent {
ngOnInit(): void {
this.org$ = this.orgSvc.activeOrg();
this.platforms$ = this.platformSvc.getPlatforms(this.org$.pipe(
this.platforms$ = this.platformSvc.listPlatforms(this.org$.pipe(
filter((org): org is Organization => org !== undefined)
))
}

View File

@@ -0,0 +1,7 @@
<div class="card">
<h2 class="card-header">{{ props.label }}</h2>
<div class="card-body">
<p>{{ props.description }}</p>
<ng-container #fieldComponent></ng-container>
</div>
</div>

View File

@@ -0,0 +1,3 @@
.card {
margin-bottom: 20px;
}

View File

@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HolosPanelWrapperComponent } from './holos-panel-wrapper.component';
describe('HolosPanelWrapperComponent', () => {
let component: HolosPanelWrapperComponent;
let fixture: ComponentFixture<HolosPanelWrapperComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HolosPanelWrapperComponent]
})
.compileComponents();
fixture = TestBed.createComponent(HolosPanelWrapperComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { FieldWrapper } from '@ngx-formly/core';
@Component({
selector: 'formly-wrapper-holos-panel',
standalone: true,
imports: [],
templateUrl: './holos-panel-wrapper.component.html',
styleUrl: './holos-panel-wrapper.component.scss'
})
export class HolosPanelWrapperComponent extends FieldWrapper { }

View File

@@ -11,29 +11,121 @@ let Platform = formsv1.#Platform & {
description: "Organization config values are used to derive more specific configuration values throughout the platform."
fieldConfigs: {
// platform.org.name
name: props: {
label: "Name"
placeholder: "example"
description: "DNS label, e.g. 'example'"
// platform.spec.config.user.sections.org.fields.name
name: {
type: "input"
props: {
label: "Name"
// placeholder: "example" placeholder cannot be used with validation?
description: "DNS label, e.g. 'example'"
pattern: "^[a-z]([0-9a-z]|-){1,28}[0-9a-z]$"
minLength: 3
maxLength: 30
required: true
}
validation: messages: {
pattern: "It must be 3 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited."
}
}
// platform.org.domain
domain: props: {
label: "Domain"
placeholder: "example.com"
description: "DNS domain, e.g. 'example.com'"
// platform.spec.config.user.sections.org.fields.domain
domain: {
type: "input"
props: {
label: "Domain"
placeholder: "example.com"
minLength: 3
maxLength: 100
description: "DNS domain, e.g. 'example.com'"
required: true
}
}
// platform.org.displayName
displayName: props: {
label: "Display Name"
placeholder: "Example Organization"
description: "Display name, e.g. 'Example Organization'"
// platform.spec.config.user.sections.org.fields.displayName
displayName: {
type: "input"
props: {
label: "Display Name"
placeholder: "Example Organization"
description: "Display name, e.g. 'Example Organization'"
maxLength: 100
required: true
}
}
// platform.org.contactEmail
contactEmail: props: {
label: "Contact Email"
placeholder: "platform-team@example.com"
description: "Technical contact email address"
// platform.spec.config.user.sections.org.fields.contactEmail
contactEmail: {
type: "input"
props: {
label: "Contact Email"
placeholder: "platform-team@example.com"
description: "Technical contact email address"
required: true
}
}
}
}
sections: privacy: {
displayName: "Data Privacy"
description: "Configure data privacy aspects of the platform."
fieldConfigs: {
country: {
// https://formly.dev/docs/api/ui/material/select/
type: "select"
props: {
label: "Select Planet"
description: "Juridiction of applicable data privacy laws."
options: [
{value: "mercury", label: "Mercury"},
{value: "venus", label: "Venus"},
{value: "earth", label: "Earth"},
{value: "mars", label: "Mars"},
{value: "jupiter", label: "Jupiter"},
{value: "saturn", label: "Saturn"},
{value: "uranus", label: "Uranus"},
{value: "neptune", label: "Neptune"},
]
}
}
regions: {
// https://formly.dev/docs/api/ui/material/select/
type: "select"
props: {
label: "Select Regions"
description: "Select the regions this platform operates in."
multiple: true
selectAllOption: "Select All"
options: [
{value: "us-east-2", label: "Ohio"},
{value: "us-west-2", label: "Oregon"},
{value: "eu-west-1", label: "Ireland"},
{value: "eu-west-2", label: "London", disabled: true},
]
}
}
}
}
// https://v5.formly.dev/ui/material
sections: terms: {
displayName: "Terms and Conditions"
description: "Example of a boolean checkbox."
fieldConfigs: {
// platform.spec.config.user.sections.terms.fields.didAgree
didAgree: {
type: "checkbox"
props: {
label: "Accept terms"
description: "In order to proceed, please accept terms"
pattern: "true"
required: true
}
validation: {
messages: {
pattern: "Please accept the terms"
}
}
}
}
}

View File

@@ -22,4 +22,18 @@ package holos
// #PlatformSpec represents configuration values defined by the platform
// designer. Config values are organized by section, then simple strings for
// each section.
#PlatformSpec: {[string]: {[string]: string | bool | [...string]}}
#PlatformSpec: {
config: [string]: _
config: user: #UserDefinedConfig
}
// #PlatformUserConfig represents configuration fields and values defined by the
// user.
#UserDefinedConfig: {
sections: [string]: fields: [string]: _
}
// #PlatformConfig represents the platform config data returned from the Holos API. Useful for cue vet.
#PlatformConfig: {
platform: spec: #PlatformSpec
}

View File

@@ -1 +1,20 @@
{"platform":{"spec":{"org":{"name":"ois"}}}}
{
"platform": {
"spec": {
"config": {
"user": {
"sections": {
"org": {
"fields": {
"contactEmail": "jeff@openinfrastructure.co",
"displayName": "Open Infrastructure Services LLC",
"domain": "ois.run",
"name": "ois"
}
}
}
}
}
}
}
}

View File

@@ -16,11 +16,14 @@ package v1alpha1
}
let Sections = sections
Form: spec: sections: [for s in Sections {s.output}]
// Collapse all sections into one fields list.
// Refer to https://formly.dev/docs/examples/other/nested-formly-forms
Form: spec: fields: [for s in Sections {s.wrapper}]
}
#PlatformFormSpec: {
sections: [...#ConfigSectionOutput]
fields: [...#FieldConfig]
}
// #ConfigSection represents a configuration section of the front end UI. For
@@ -32,19 +35,20 @@ package v1alpha1
description: string
fieldConfigs: {[NAME=string]: #FieldConfig & {key: NAME}}
let Name = name
let DisplayName = displayName
let Description = description
let FieldConfigs = fieldConfigs
output: #ConfigSectionOutput & {
name: Name
displayName: DisplayName
description: Description
fieldConfigs: [for fc in FieldConfigs {fc}]
// Wrap the fields of the section into one FormlyFieldConfig
wrapper: #FieldConfig & {
key: name
// See our custom wrappers registered in app.config.ts
wrappers: ["holos-panel"]
props: label: displayName
props: description: Description
fieldGroup: [for fc in fieldConfigs {fc}]
}
}
// REMOVE
#ConfigSectionOutput: {
name: string
displayName: string
@@ -53,13 +57,63 @@ package v1alpha1
}
// Refer to https://formly.dev/docs/api/core#formlyfieldconfig
// Refer to https://formly.dev/docs/api/ui/material/select
#FieldConfig: {
key: string
type: "input"
key: string
// type is optional, may be a nested form which has no type field
type?: string | "input" | "select" | "checkbox"
// For nested forms, refer: to https://formly.dev/docs/examples/other/nested-formly-forms
wrappers?: [...string]
// Refer to: https://formly.dev/docs/api/ui/material/select#formlyselectprops
// and other input field select props.
props: {
label: string
placeholder: string
description: string
required: *true | false
#FormlySelectProps
label: string
placeholder?: string
description: string
required?: *true | false
pattern?: string
minLength?: number
maxLength?: number
}
// Refer to: https://github.com/ngx-formly/ngx-formly/blob/v6.3.0/src/core/src/lib/models/fieldconfig.ts#L49-L64
// We support only the string form.
validation?: {
// Note, you can set messages for pattern, minLength, maxLength here.
messages?: [string]: string
}
// Refer to: https://github.com/ngx-formly/ngx-formly/blob/v6.3.0/src/core/src/lib/models/fieldconfig.ts#L115-L120
expressions?: [string]: string
hide?: true | false
// Required to populate protobuf value.
resetOnHide: *true | false
defaultValue?: _
className?: string
fieldGroup?: [...#FieldConfig]
focus?: true | *false
modelOptions?: {
debounce?: {
default: number
}
updateOn?: "change" | "blur" | "submit"
}
}
// Refer to https://formly.dev/docs/api/ui/material/select#formlyselectprops
#FormlySelectProps: {
disableOptionCentering?: true | false
multiple?: true | false
panelClass?: string
selectAllOption?: string
typeaheadDebounceInterval?: number
options?: [...{value: string | number | bool, label: string, disabled?: true | *false}]
// These could be used to set different keys for value and label in the
// options list, but we don't support that level of customization.
// They're here for documentation purposes only.
labelProp?: "label"
valueProp?: "value"
}

View File

@@ -2,7 +2,6 @@ package handler
import (
"context"
"encoding/json"
"fmt"
"log/slog"
@@ -10,12 +9,11 @@ import (
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent"
"github.com/holos-run/holos/internal/ent/organization"
"github.com/holos-run/holos/internal/ent/platform"
entplatform "github.com/holos-run/holos/internal/ent/platform"
"github.com/holos-run/holos/internal/ent/user"
"github.com/holos-run/holos/internal/errors"
"github.com/holos-run/holos/internal/server/middleware/authn"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
"google.golang.org/protobuf/types/known/timestamppb"
psvc "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
)
// NewPlatformHandler returns a new PlatformService implementation.
@@ -28,59 +26,42 @@ type PlatformHandler struct {
db *ent.Client
}
func (h *PlatformHandler) GetPlatforms(
func (h *PlatformHandler) ListPlatforms(
ctx context.Context,
req *connect.Request[holos.GetPlatformsRequest],
) (*connect.Response[holos.GetPlatformsResponse], error) {
req *connect.Request[psvc.ListPlatformsRequest],
) (*connect.Response[psvc.ListPlatformsResponse], error) {
_, reqDBOrg, err := getAuthnUsersOrg(ctx, req.Msg.OrgId, h.db)
if err != nil {
return nil, errors.Wrap(err)
}
return getPlatformsResponse(reqDBOrg), nil
resp := &psvc.ListPlatformsResponse{Platforms: rpcPlatforms(reqDBOrg)}
return connect.NewResponse(resp), nil
}
func (h *PlatformHandler) AddPlatform(
ctx context.Context,
req *connect.Request[holos.AddPlatformRequest],
) (*connect.Response[holos.GetPlatformsResponse], error) {
req *connect.Request[psvc.AddPlatformRequest],
) (*connect.Response[psvc.AddPlatformResponse], error) {
dbUser, dbOrg, err := getAuthnUsersOrg(ctx, req.Msg.Platform.OrgId, h.db)
if err != nil {
return nil, errors.Wrap(err)
}
var hf holos.PlatformForm
if len(req.Msg.Platform.RawConfig.Form) > 0 {
if err := json.Unmarshal(req.Msg.Platform.RawConfig.Form, &hf); err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrap(err))
}
}
var hv holos.ConfigValues
if len(req.Msg.Platform.RawConfig.Values) > 0 {
if err := json.Unmarshal(req.Msg.Platform.RawConfig.Values, &hv); err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrap(err))
}
}
platform, err := h.db.Platform.Create().
SetOrgID(dbOrg.ID).
SetCreatorID(dbUser.ID).
SetName(req.Msg.Platform.Name).
SetDisplayName(req.Msg.Platform.DisplayName).
SetConfigForm(&hf).
SetConfigValues(&hv).
SetConfigCue(req.Msg.Platform.RawConfig.Cue).
SetConfigDefinition(req.Msg.Platform.RawConfig.Definition).
Save(ctx)
if err != nil {
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Wrap(err))
}
resp := getPlatformsResponse(dbOrg)
resp.Msg.Platforms = append(resp.Msg.Platforms, PlatformToRPC(platform))
resp := &psvc.AddPlatformResponse{Platforms: rpcPlatforms(dbOrg)}
resp.Platforms = append(resp.Platforms, PlatformToRPC(platform))
return resp, nil
return connect.NewResponse(resp), nil
}
func (h *PlatformHandler) getPlatform(ctx context.Context, id string, uid authn.Identity) (*ent.Platform, error) {
@@ -90,8 +71,8 @@ func (h *PlatformHandler) getPlatform(ctx context.Context, id string, uid authn.
}
p, err := h.db.Platform.Query().
Where(platform.ID(platformID)).
Where(platform.HasOrganizationWith(
Where(entplatform.ID(platformID)).
Where(entplatform.HasOrganizationWith(
organization.HasUsersWith(
user.Iss(uid.Issuer()),
user.Sub(uid.Subject()),
@@ -108,7 +89,7 @@ func (h *PlatformHandler) getPlatform(ctx context.Context, id string, uid authn.
return p, nil
}
func (h *PlatformHandler) GetPlatform(ctx context.Context, req *connect.Request[holos.GetPlatformRequest]) (*connect.Response[holos.GetPlatformResponse], error) {
func (h *PlatformHandler) GetPlatform(ctx context.Context, req *connect.Request[psvc.GetPlatformRequest]) (*connect.Response[psvc.GetPlatformResponse], error) {
authnID, err := authn.FromContext(ctx)
if err != nil {
return nil, connect.NewError(connect.CodePermissionDenied, errors.Wrap(err))
@@ -119,55 +100,33 @@ func (h *PlatformHandler) GetPlatform(ctx context.Context, req *connect.Request[
return nil, errors.Wrap(err)
}
return connect.NewResponse(&holos.GetPlatformResponse{Platform: PlatformToRPC(p)}), nil
return connect.NewResponse(&psvc.GetPlatformResponse{Platform: PlatformToRPC(p)}), nil
}
func (h *PlatformHandler) PutPlatformConfig(ctx context.Context, req *connect.Request[holos.PutPlatformConfigRequest]) (*connect.Response[holos.GetPlatformResponse], error) {
func (h *PlatformHandler) PutModel(ctx context.Context, req *connect.Request[psvc.PutModelRequest]) (*connect.Response[psvc.PutModelResponse], error) {
authnID, err := authn.FromContext(ctx)
if err != nil {
return nil, connect.NewError(connect.CodePermissionDenied, errors.Wrap(err))
}
id, err := uuid.FromString(req.Msg.PlatformId)
p, err := h.getPlatform(ctx, req.Msg.GetPlatformId(), authnID)
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Wrap(err))
return nil, errors.Wrap(err)
}
// Get the platform so we can validate the values.
p, err := h.db.Platform.Query().
Where(platform.ID(id)).
Where(platform.HasOrganizationWith(
organization.HasUsersWith(
user.Iss(authnID.Issuer()),
user.Sub(authnID.Subject()),
))).
Only(ctx)
if err != nil {
if ent.MaskNotFound(err) == nil {
return nil, connect.NewError(connect.CodeNotFound, errors.Wrap(err))
} else {
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Wrap(err))
}
}
slog.WarnContext(ctx, "todo: validate the platform config against cue definitions", "action", "todo", "cue", len(p.Cue))
slog.WarnContext(ctx, "todo: validate the platform config against cue definitions", "action", "todo", "cue", len(p.ConfigCue))
up, err := h.db.Platform.UpdateOneID(id).
Where(platform.HasOrganizationWith(
organization.HasUsersWith(
user.Iss(authnID.Issuer()),
user.Sub(authnID.Subject()),
))).
SetConfigValues(req.Msg.Values).
_, err = p.Update().
SetModel(&psvc.Model{Model: req.Msg.GetModel()}).
Save(ctx)
if err != nil {
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Wrap(err))
}
return connect.NewResponse(&holos.GetPlatformResponse{Platform: PlatformToRPC(up)}), nil
return connect.NewResponse(&psvc.PutModelResponse{Model: req.Msg.Model}), nil
}
func (h *PlatformHandler) GetConfig(ctx context.Context, req *connect.Request[holos.GetPlatformConfigRequest]) (*connect.Response[holos.ConfigValues], error) {
func (h *PlatformHandler) GetModel(ctx context.Context, req *connect.Request[psvc.GetModelRequest]) (*connect.Response[psvc.GetModelResponse], error) {
authnID, err := authn.FromContext(ctx)
if err != nil {
return nil, connect.NewError(connect.CodePermissionDenied, errors.Wrap(err))
@@ -178,26 +137,52 @@ func (h *PlatformHandler) GetConfig(ctx context.Context, req *connect.Request[ho
return nil, errors.Wrap(err)
}
return connect.NewResponse(p.ConfigValues), nil
return connect.NewResponse(&psvc.GetModelResponse{Model: p.Model.Model}), nil
}
func PlatformToRPC(platform *ent.Platform) *holos.Platform {
return &holos.Platform{
func (h *PlatformHandler) GetForm(ctx context.Context, req *connect.Request[psvc.GetFormRequest]) (*connect.Response[psvc.GetFormResponse], error) {
authnID, err := authn.FromContext(ctx)
if err != nil {
return nil, connect.NewError(connect.CodePermissionDenied, errors.Wrap(err))
}
p, err := h.getPlatform(ctx, req.Msg.GetPlatformId(), authnID)
if err != nil {
return nil, errors.Wrap(err)
}
return connect.NewResponse(&psvc.GetFormResponse{Fields: p.Form.GetFields(), Model: p.Model.GetModel()}), nil
}
func (h *PlatformHandler) PutForm(ctx context.Context, req *connect.Request[psvc.PutFormRequest]) (*connect.Response[psvc.PutFormResponse], error) {
authnID, err := authn.FromContext(ctx)
if err != nil {
return nil, connect.NewError(connect.CodePermissionDenied, errors.Wrap(err))
}
p, err := h.getPlatform(ctx, req.Msg.GetPlatformId(), authnID)
if err != nil {
return nil, errors.Wrap(err)
}
_, err = p.Update().
SetForm(&psvc.Form{Fields: req.Msg.GetFields()}).
Save(ctx)
if err != nil {
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Wrap(err))
}
resp := &psvc.PutFormResponse{Fields: req.Msg.GetFields()}
return connect.NewResponse(resp), nil
}
func PlatformToRPC(platform *ent.Platform) *psvc.Platform {
return &psvc.Platform{
Id: platform.ID.String(),
Name: platform.Name,
DisplayName: platform.DisplayName,
OrgId: platform.OrgID.String(),
Config: &holos.Config{
Form: platform.ConfigForm,
Values: platform.ConfigValues,
},
Timestamps: &holos.Timestamps{
CreatedAt: timestamppb.New(platform.CreatedAt),
UpdatedAt: timestamppb.New(platform.UpdatedAt),
},
Creator: &holos.Creator{
Id: platform.CreatorID.String(),
},
Spec: &psvc.PlatformSpec{Model: platform.Model.GetModel()},
}
}
@@ -249,14 +234,14 @@ func getAuthnUsersOrg(ctx context.Context, orgID string, db *ent.Client) (*ent.U
return dbUser, reqDBOrg, nil
}
func getPlatformsResponse(reqDBOrg *ent.Organization) *connect.Response[holos.GetPlatformsResponse] {
// one extra in case a new platform is appended.
rpcPlatforms := make([]*holos.Platform, 0, 1+len(reqDBOrg.Edges.Platforms))
for _, platform := range reqDBOrg.Edges.Platforms {
rpcPlatforms = append(rpcPlatforms, PlatformToRPC(platform))
func rpcPlatforms(reqDBOrg *ent.Organization) []*psvc.Platform {
if reqDBOrg == nil {
return nil
}
return connect.NewResponse(&holos.GetPlatformsResponse{
Platforms: rpcPlatforms,
})
// one extra in case a new platform is appended.
platforms := make([]*psvc.Platform, 0, 1+len(reqDBOrg.Edges.Platforms))
for _, platform := range reqDBOrg.Edges.Platforms {
platforms = append(platforms, PlatformToRPC(platform))
}
return platforms
}

View File

@@ -7,10 +7,12 @@ import (
"strings"
"connectrpc.com/connect"
"github.com/gofrs/uuid"
"github.com/holos-run/holos/internal/ent"
"github.com/holos-run/holos/internal/errors"
"github.com/holos-run/holos/internal/server/middleware/authn"
"github.com/holos-run/holos/internal/server/middleware/logger"
psvc "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1"
holos "github.com/holos-run/holos/service/gen/holos/v1alpha1"
)
@@ -73,6 +75,7 @@ func (h *SystemHandler) SeedDatabase(ctx context.Context, req *connect.Request[h
if err := WithTx(ctx, h.db, func(tx *ent.Tx) (err error) {
jeff, err := tx.User.Create().
SetID(uuid.FromStringOrNil("018f36fb-e3f2-7f7f-a72f-ce48eb16c82d")).
SetEmail("jeff@openinfrastructure.co").
SetIss("https://login.ois.run").
SetSub("261773693724656988").
@@ -102,6 +105,7 @@ func (h *SystemHandler) SeedDatabase(ctx context.Context, req *connect.Request[h
// Create the org
org, err := tx.Organization.Create().
SetID(uuid.FromStringOrNil("018f36fb-e3f7-7f7f-a1c5-c85fb735d215")).
SetName("ois").
SetDisplayName("Open Infrastructure Services").
SetCreator(jeff).
@@ -116,16 +120,23 @@ func (h *SystemHandler) SeedDatabase(ctx context.Context, req *connect.Request[h
return errors.Wrap(err)
}
var hf holos.PlatformForm
if err := json.Unmarshal([]byte(BareForm), &hf); err != nil {
var form psvc.Form
if err := json.Unmarshal([]byte(BareForm), &form); err != nil {
return errors.Wrap(err)
}
var model psvc.Model
if err := json.Unmarshal([]byte(Model), &model); err != nil {
return errors.Wrap(err)
}
// Add a platform
err = tx.Platform.Create().
SetID(uuid.FromStringOrNil("018f36fb-e3ff-7f7f-a5d1-7ca2bf499e94")).
SetName("bare").
SetDisplayName("Bare Platform").
SetConfigForm(&hf).
SetForm(&form).
SetModel(&model).
SetCreator(jeff).
SetOrgID(org.ID).
Exec(ctx)
@@ -138,7 +149,8 @@ func (h *SystemHandler) SeedDatabase(ctx context.Context, req *connect.Request[h
err := tx.Platform.Create().
SetName(strings.ToLower(name)).
SetDisplayName(name + "'s Platform").
SetConfigForm(&hf).
SetForm(&form).
SetModel(&model).
SetCreator(jeff).
SetOrgID(org.ID).
Exec(ctx)
@@ -155,61 +167,185 @@ func (h *SystemHandler) SeedDatabase(ctx context.Context, req *connect.Request[h
return connect.NewResponse(&holos.EmptyResponse{}), nil
}
const BareForm = `{
"kind": "PlatformForm",
"spec": {
"sections": [
{
"name": "org",
"description": "Organization config values are used to derive more specific configuration values throughout the platform.",
"displayName": "Organization",
"fieldConfigs": [
{
"key": "name",
"type": "input",
"props": {
"label": "Name",
"required": true,
"description": "DNS label, e.g. 'example'",
"placeholder": "example"
const Model = `{"model":{}}`
const BareForm = `
{
"fields": [
{
"key": "org",
"wrappers": [
"holos-panel"
],
"props": {
"label": "Organization",
"description": "Organization config values are used to derive more specific configuration values throughout the platform."
},
"resetOnHide": true,
"fieldGroup": [
{
"key": "name",
"type": "input",
"props": {
"label": "Name",
"description": "DNS label, e.g. 'example'",
"pattern": "[a-z][0-9a-z]{4,29}",
"required": true
},
"validation": {
"messages": {
"pattern": "It must be 6 to 30 lowercase letters, digits, or hyphens. It must start with a letter. Trailing hyphens are prohibited."
}
},
{
"key": "domain",
"type": "input",
"props": {
"label": "Domain",
"required": true,
"description": "DNS domain, e.g. 'example.com'",
"placeholder": "example.com"
"resetOnHide": true
},
{
"key": "domain",
"type": "input",
"props": {
"label": "Domain",
"placeholder": "example.com",
"description": "DNS domain, e.g. 'example.com'"
},
"resetOnHide": true
},
{
"key": "displayName",
"type": "input",
"props": {
"label": "Display Name",
"placeholder": "Example Organization",
"description": "Display name, e.g. 'Example Organization'"
},
"resetOnHide": true
},
{
"key": "contactEmail",
"type": "input",
"props": {
"label": "Contact Email",
"placeholder": "platform-team@example.com",
"description": "Technical contact email address"
},
"resetOnHide": true
}
]
},
{
"key": "privacy",
"wrappers": [
"holos-panel"
],
"props": {
"label": "Data Privacy",
"description": "Configure data privacy aspects of the platform."
},
"resetOnHide": true,
"fieldGroup": [
{
"key": "country",
"type": "select",
"props": {
"label": "Select Planet",
"description": "Juridiction of applicable data privacy laws.",
"options": [
{
"value": "mercury",
"label": "Mercury"
},
{
"value": "venus",
"label": "Venus"
},
{
"value": "earth",
"label": "Earth"
},
{
"value": "mars",
"label": "Mars"
},
{
"value": "jupiter",
"label": "Jupiter"
},
{
"value": "saturn",
"label": "Saturn"
},
{
"value": "uranus",
"label": "Uranus"
},
{
"value": "neptune",
"label": "Neptune"
}
]
},
"resetOnHide": true
},
{
"key": "regions",
"type": "select",
"props": {
"label": "Select Regions",
"description": "Select the regions this platform operates in.",
"multiple": true,
"selectAllOption": "Select All",
"options": [
{
"value": "us-east-2",
"label": "Ohio"
},
{
"value": "us-west-2",
"label": "Oregon"
},
{
"value": "eu-west-1",
"label": "Ireland"
},
{
"value": "eu-west-2",
"label": "London",
"disabled": true
}
]
},
"resetOnHide": true
}
]
},
{
"key": "terms",
"wrappers": [
"holos-panel"
],
"props": {
"label": "Terms and Conditions",
"description": "Example of a boolean checkbox."
},
"resetOnHide": true,
"fieldGroup": [
{
"key": "didAgree",
"type": "checkbox",
"props": {
"label": "Accept terms",
"description": "In order to proceed, please accept terms",
"pattern": "true",
"required": true
},
"validation": {
"messages": {
"pattern": "Please accept the terms"
}
},
{
"key": "displayName",
"type": "input",
"props": {
"label": "Display Name",
"required": true,
"description": "Display name, e.g. 'Example Organization'",
"placeholder": "Example Organization"
}
},
{
"key": "contactEmail",
"type": "input",
"props": {
"label": "Contact Email",
"required": true,
"description": "Technical contact email address",
"placeholder": "platform-team@example.com"
}
}
]
}
]
},
"metadata": {
"name": "bare"
},
"apiVersion": "forms.holos.run/v1alpha1"
}`
"resetOnHide": true
}
]
}
]
}
`

View File

@@ -17,6 +17,7 @@ import (
"github.com/holos-run/holos/internal/server/handler"
"github.com/holos-run/holos/internal/server/middleware/authn"
"github.com/holos-run/holos/internal/server/middleware/logger"
"github.com/holos-run/holos/service/gen/holos/platform/v1alpha1/platformconnect"
"github.com/holos-run/holos/service/gen/holos/v1alpha1/holosconnect"
"github.com/prometheus/client_golang/prometheus/promhttp"
"golang.org/x/net/http2"
@@ -114,13 +115,13 @@ func (s *Server) registerConnectRpc() error {
s.handle(holosconnect.NewUserServiceHandler(handler.NewUserHandler(s.db), opts))
s.handle(holosconnect.NewOrganizationServiceHandler(handler.NewOrganizationHandler(s.db), opts))
s.handle(holosconnect.NewPlatformServiceHandler(handler.NewPlatformHandler(s.db), opts))
s.handle(platformconnect.NewPlatformServiceHandler(handler.NewPlatformHandler(s.db), opts))
s.handle(holosconnect.NewSystemServiceHandler(handler.NewSystemHandler(s.db), opts))
reflector := grpcreflect.NewStaticReflector(
holosconnect.UserServiceName,
holosconnect.OrganizationServiceName,
holosconnect.PlatformServiceName,
platformconnect.PlatformServiceName,
holosconnect.SystemServiceName,
)

View File

@@ -0,0 +1,111 @@
syntax = "proto3";
package holos.platform.v1alpha1;
option go_package = "github.com/holos-run/holos/service/gen/holos/platform/v1alpha1;platform";
// git clone https://github.com/bufbuild/protovalidate then add <parent>/protovalidate/proto/protovalidate to your editor proto search path
import "buf/validate/validate.proto";
import "google/protobuf/struct.proto";
// For validation, see the [Standard constraints](https://github.com/bufbuild/protovalidate/blob/main/docs/standard-constraints.md)
message Platform {
// Unique id assigned by the server.
string id = 1;
// Organization ID resource owner.
string org_id = 2 [(buf.validate.field).string.uuid = true];
// name is the platform short name as a dns label.
string name = 3 [(buf.validate.field).string.max_len = 100];
string display_name = 4 [(buf.validate.field).string.max_len = 100];
PlatformSpec spec = 5;
}
message PlatformSpec {
// model represents the user-defined and user-supplied form field values.
google.protobuf.Struct model = 1;
}
// Form represents the Formly input form.
message Form {
// fields represents FormlyFieldConfig[] encoded as a JSON array.
repeated google.protobuf.Struct fields = 1;
}
// Model represents the values entered into the form, stored in the form's model
// in the web app, and persisted into the backend database. The model is
// ultimately intended as the input to platform rendering.
message Model {
google.protobuf.Struct model = 1;
}
message ListPlatformsRequest {
string org_id = 1 [(buf.validate.field).string.uuid = true];
}
message ListPlatformsResponse {
repeated Platform platforms = 1;
}
message AddPlatformRequest {
Platform platform = 1;
}
message AddPlatformResponse {
repeated Platform platforms = 1;
}
message GetPlatformRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
}
message GetPlatformResponse {
Platform platform = 1;
}
message GetFormRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
}
message GetFormResponse {
repeated google.protobuf.Struct fields = 1;
google.protobuf.Struct model = 2;
}
message GetModelRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
}
message GetModelResponse {
google.protobuf.Struct model = 1;
}
message PutModelRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
google.protobuf.Struct model = 2;
}
message PutModelResponse {
google.protobuf.Struct model = 1;
}
message PutFormRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
repeated google.protobuf.Struct fields = 2;
}
message PutFormResponse {
repeated google.protobuf.Struct fields = 1;
}
service PlatformService {
rpc AddPlatform(AddPlatformRequest) returns (AddPlatformResponse) {}
rpc GetPlatform(GetPlatformRequest) returns (GetPlatformResponse) {}
rpc ListPlatforms(ListPlatformsRequest) returns (ListPlatformsResponse) {}
rpc GetForm(GetFormRequest) returns (GetFormResponse) {}
rpc PutForm(PutFormRequest) returns (PutFormResponse) {}
rpc GetModel(GetModelRequest) returns (GetModelResponse) {}
rpc PutModel(PutModelRequest) returns (PutModelResponse) {}
}

View File

@@ -1,128 +0,0 @@
syntax = "proto3";
package holos.v1alpha1;
option go_package = "github.com/holos-run/holos/service/gen/holos/v1alpha1;holos";
// git clone https://github.com/bufbuild/protovalidate then add <parent>/protovalidate/proto/protovalidate to your editor proto search path
import "buf/validate/validate.proto";
import "holos/v1alpha1/timestamps.proto";
import "holos/v1alpha1/organization.proto";
import "holos/v1alpha1/user.proto";
import "google/protobuf/any.proto";
import "google/protobuf/struct.proto";
// For validation, see the [Standard constraints](https://github.com/bufbuild/protovalidate/blob/main/docs/standard-constraints.md)
// RawConfig represents the raw form configuration as opaque bytes. Used for input.
message RawConfig {
bytes form = 1;
bytes values = 2;
bytes cue = 3;
string definition = 4;
}
message Config {
PlatformForm form = 1;
// Values are the user supplied config values organized by section.
ConfigValues values = 2;
}
message ConfigSection {
map<string, google.protobuf.Value> fields = 1;
}
// ConfigValues represents user defined configuration values.
message ConfigValues {
map<string, ConfigSection> sections = 1;
}
message Platform {
// Unique id assigned by the server.
string id = 1;
Timestamps timestamps = 2;
// Organization ID resource owner.
string org_id = 3 [(buf.validate.field).string.uuid = true];
// name is the platform short name as a dns label.
string name = 4 [(buf.validate.field).string.max_len = 100];
string display_name = 5 [(buf.validate.field).string.max_len = 100];
Creator creator = 6;
// config represents the platform config form and values. Read only.
Config config = 7;
// raw_config represents the platform config form and values. Write only.
RawConfig raw_config = 8;
}
message FieldConfigProps {
string label = 1;
string placeholder = 2;
string description = 3;
bool required = 4;
}
message FieldConfig {
string key = 1;
string type = 2;
FieldConfigProps props = 3;
}
message ConfigFormSection {
string name = 1;
string displayName = 2;
string description = 3;
repeated FieldConfig fieldConfigs = 4;
}
message PlatformFormSpec {
repeated ConfigFormSection sections = 1;
}
message GetPlatformsRequest {
string org_id = 1 [(buf.validate.field).string.uuid = true];
}
message GetPlatformsResponse {
repeated Platform platforms = 1;
}
message GetPlatformResponse {
Platform platform = 1;
}
message AddPlatformRequest {
Platform platform = 1;
}
message GetPlatformRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
}
message MetadataName {
string name = 1;
}
message PlatformForm {
string apiVersion = 1;
string kind = 2;
MetadataName metadata = 3;
PlatformFormSpec spec = 4;
}
message PutPlatformConfigRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
ConfigValues values = 2;
}
message GetPlatformConfigRequest {
string platform_id = 1 [(buf.validate.field).string.uuid = true];
}
service PlatformService {
rpc AddPlatform(AddPlatformRequest) returns (GetPlatformsResponse) {}
rpc GetPlatforms(GetPlatformsRequest) returns (GetPlatformsResponse) {}
rpc GetPlatform(GetPlatformRequest) returns (GetPlatformResponse) {}
rpc PutPlatformConfig(PutPlatformConfigRequest) returns (GetPlatformResponse) {}
// GetConfig provides the unmarshalled config values for use with CUE
rpc GetConfig(GetPlatformConfigRequest) returns (ConfigValues) {}
}

View File

@@ -1 +1 @@
72
73

View File

@@ -1 +1 @@
1
0