Skip to content

Commit

Permalink
fix: allowing secrets and password types
Browse files Browse the repository at this point in the history
  • Loading branch information
davenewza committed Oct 29, 2023
1 parent 6fa0fad commit f97cc88
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
Binary file added schema/completions/__debug_bin4018105356
Binary file not shown.
3 changes: 0 additions & 3 deletions schema/completions/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,6 @@ func getFieldNamesAtPath(asts []*parser.AST, model *parser.ModelNode, idents []s
func getModelFieldCompletions(model *parser.ModelNode) []*CompletionItem {
completions := []*CompletionItem{}
for _, field := range query.ModelFields(model) {
if field.Type.Value == parser.FieldTypeSecret || field.Type.Value == parser.FieldTypePassword {
continue
}
completions = append(completions, &CompletionItem{
Label: field.Name.Value,
Description: field.Type.Value,
Expand Down
43 changes: 6 additions & 37 deletions schema/completions/completions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,6 @@ func TestCompositeUniqueCompletions(t *testing.T) {
`,
expected: []string{"subTitle", "title", "date"},
},
{
name: "available-fields-badly-formed-schema",
schema: `
model A {
oops
fields {
title Text
subTitle Text
date Date
timestamp Timestamp
}
@unique([<Cursor>
`,
expected: []string{"subTitle", "title", "date"},
},
{
name: "existing-composite",
schema: `
Expand Down Expand Up @@ -801,7 +782,7 @@ func TestWhereAttributeCompletions(t *testing.T) {
}
}
}`,
expected: []string{"createdAt", "email", "emailVerified", "externalId", "id", "issuer", "updatedAt", "user"},
expected: []string{"createdAt", "email", "emailVerified", "externalId", "id", "issuer", "password", "updatedAt", "user"},
},

{
Expand Down Expand Up @@ -997,41 +978,29 @@ func TestWhereAttributeCompletions(t *testing.T) {
func TestSetAttributeCompletions(t *testing.T) {
cases := []testCase{
{
name: "set-expression-nested",
name: "set-expression",
schema: `
model User {
fields {
identity Identity
name Text
}
actions {
create createUser() with (name) {
@set(user.identity = ctx.identity)
@permission(expression: ctx.isAuthenticated)
}
}
}
model Team {
fields {
name Text
}
}
model UserTeam {
fields {
user User
team Team
}
actions {
create createTeam() with (team.name) {
@set(<Cursor>)
}
}
}
`,
}`,
expected: []string{"ctx", "userTeam"},
},
{
Expand Down Expand Up @@ -1074,7 +1043,7 @@ func TestSetAttributeCompletions(t *testing.T) {
}
}
}`,
expected: []string{"createdAt", "email", "emailVerified", "externalId", "id", "issuer", "updatedAt", "user"},
expected: []string{"createdAt", "email", "emailVerified", "externalId", "id", "issuer", "password", "updatedAt", "user"},
},
{
name: "set-attribute-ctx-identity-user",
Expand Down Expand Up @@ -1112,11 +1081,11 @@ func TestSetAttributeCompletions(t *testing.T) {
}
actions {
list create() {
@set(ctx.identity.<Cursor>)
@set(user.owner = ctx.identity.<Cursor>)
}
}
}`,
expected: []string{"createdAt", "email", "emailVerified", "externalId", "id", "issuer", "updatedAt", "user"},
expected: []string{"createdAt", "email", "emailVerified", "externalId", "id", "issuer", "password", "updatedAt", "user"},
},
}

Expand Down

0 comments on commit f97cc88

Please sign in to comment.