Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/zed.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ require (
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
github.com/xlab/treeprint v1.2.0
go.uber.org/goleak v1.3.0
go.uber.org/mock v0.6.0
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b
golang.org/x/mod v0.32.0
Expand Down Expand Up @@ -406,7 +407,6 @@ require (
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
Expand Down
7 changes: 3 additions & 4 deletions internal/cmd/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/authzed/spicedb/pkg/tuple"
"github.com/authzed/spicedb/pkg/validationfile"

"github.com/authzed/zed/internal/client"
"github.com/authzed/zed/internal/commands"
Expand Down Expand Up @@ -82,12 +81,12 @@ func registerImportCmd(rootCmd *cobra.Command) {

func importCmdFunc(cmd *cobra.Command, schemaClient v1.SchemaServiceClient, relationshipsClient v1.PermissionsServiceClient, prefix string, u *url.URL) error {
prefix = strings.TrimRight(prefix, "/")
decoder, err := decode.DecoderForURL(u)
d, err := decode.DecoderFromURL(u)
if err != nil {
return err
}
var p validationfile.ValidationFile
if _, _, err := decoder(&p); err != nil {
p, err := d.UnmarshalYAMLValidationFile()
if err != nil {
return err
}

Expand Down
9 changes: 6 additions & 3 deletions internal/cmd/preview-test/composable-schema-invalid-root.zed
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use import

import "./composable-schema-user.zed"

definition resource {
relation and: user
permission viewer = and
}
// definition is a keyword, so we expect it to fail here.
relation definition: user
permission viewer = definition
}
4 changes: 3 additions & 1 deletion internal/cmd/preview-test/composable-schema-root.zed
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use import

import "./composable-schema-user.zed"

definition resource {
relation user: user
permission view = user
}
}
24 changes: 6 additions & 18 deletions internal/cmd/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (

v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/authzed/spicedb/pkg/caveats/types"
newcompiler "github.com/authzed/spicedb/pkg/composableschemadsl/compiler"
newinput "github.com/authzed/spicedb/pkg/composableschemadsl/input"
"github.com/authzed/spicedb/pkg/diff"
"github.com/authzed/spicedb/pkg/schemadsl/compiler"
"github.com/authzed/spicedb/pkg/schemadsl/generator"
Expand Down Expand Up @@ -435,27 +433,17 @@ func schemaCompileInner(args []string, writer io.Writer) error {
return errors.New("attempted to compile empty schema")
}

compiled, err := newcompiler.Compile(newcompiler.InputSchema{
Source: newinput.Source(inputFilepath),
compiled, err := compiler.Compile(compiler.InputSchema{
Source: input.Source(inputFilepath),
SchemaString: string(schemaBytes),
}, newcompiler.AllowUnprefixedObjectType(),
newcompiler.SourceFolder(inputSourceFolder))
}, compiler.AllowUnprefixedObjectType(),
compiler.SourceFolder(inputSourceFolder))
if err != nil {
return err
}

// Attempt to cast one kind of OrderedDefinition to another
oldDefinitions := make([]compiler.SchemaDefinition, 0, len(compiled.OrderedDefinitions))
for _, definition := range compiled.OrderedDefinitions {
oldDefinition, ok := definition.(compiler.SchemaDefinition)
if !ok {
return fmt.Errorf("could not convert definition to old schemadefinition: %v", oldDefinition)
}
oldDefinitions = append(oldDefinitions, oldDefinition)
}

// This is where we functionally assert that the two systems are compatible
generated, _, err := generator.GenerateSchema(oldDefinitions)
// Generate the schema, which compiles over import and partial syntax
generated, _, err := generator.GenerateSchema(compiled.OrderedDefinitions)
if err != nil {
return fmt.Errorf("could not generate resulting schema: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"google.golang.org/grpc"

v1 "github.com/authzed/authzed-go/proto/authzed/api/v1"
"github.com/authzed/spicedb/pkg/composableschemadsl/compiler"
"github.com/authzed/spicedb/pkg/schemadsl/compiler"

"github.com/authzed/zed/internal/zedtesting"
)
Expand Down
2 changes: 2 additions & 0 deletions internal/cmd/validate-test/composable-schema-root.zed
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use import

import "./composable-schema-user.zed"

definition resource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use partial

partial edit_partial {
permission edit = edit
}

definition resource {
...edit_partial
}
}
5 changes: 0 additions & 5 deletions internal/cmd/validate-test/only-passes-composable.zed

This file was deleted.

2 changes: 0 additions & 2 deletions internal/cmd/validate-test/only-passes-standard.zed

This file was deleted.

Loading
Loading