Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: secrets in modelapi as string #1682

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
8 changes: 3 additions & 5 deletions node/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func writeWhereConditionsInterface(w *codegen.Writer, model *proto.Model) {
w.Writef("export interface %sWhereConditions {\n", model.Name)
w.Indent()
for _, field := range model.Fields {
if field.Type.Type == proto.Type_TYPE_FILE {
if field.Type.Type == proto.Type_TYPE_FILE || field.Type.Type == proto.Type_TYPE_SECRET {
continue
}

Expand Down Expand Up @@ -734,7 +734,7 @@ func writeModelAPIDeclaration(w *codegen.Writer, model *proto.Model) {
}

switch f.Type.Type {
case proto.Type_TYPE_STRING, proto.Type_TYPE_MARKDOWN:
case proto.Type_TYPE_ID, proto.Type_TYPE_STRING, proto.Type_TYPE_MARKDOWN, proto.Type_TYPE_SECRET:
w.Write("''")
case proto.Type_TYPE_BOOL:
w.Write("false")
Expand Down Expand Up @@ -1833,9 +1833,7 @@ func toResponseTypescriptType(t *proto.TypeInfo, isTestingPackage bool, isClient

func toTypeScriptType(t *proto.TypeInfo, includeCompatibleTypes bool, isTestingPackage bool, isClientPackage bool) (ret string) {
switch t.Type {
case proto.Type_TYPE_ID:
ret = "string"
case proto.Type_TYPE_STRING, proto.Type_TYPE_MARKDOWN:
case proto.Type_TYPE_ID, proto.Type_TYPE_STRING, proto.Type_TYPE_MARKDOWN, proto.Type_TYPE_SECRET:
ret = "string"
case proto.Type_TYPE_BOOL:
ret = "boolean"
Expand Down
6 changes: 6 additions & 0 deletions node/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ model Person {
height Decimal
bio Markdown
file File
secret Secret
canHoldBreath Duration
heightInMetres Decimal @computed(person.height * 0.3048)
}
Expand All @@ -61,6 +62,7 @@ export interface PersonTable {
height: number
bio: string
file: FileDbRecord
secret: string
canHoldBreath: runtime.Duration
heightInMetres: number
id: Generated<string>
Expand Down Expand Up @@ -110,6 +112,7 @@ export interface Person {
height: number
bio: string
file: runtime.File
secret: string
canHoldBreath: runtime.Duration
heightInMetres: number
id: string
Expand All @@ -136,6 +139,8 @@ export type PersonCreateValues = {
tags: string[]
height: number
bio: string
file: runtime.InlineFile | runtime.File
secret: string
file: FileWriteTypes
canHoldBreath: runtime.Duration
id?: string
Expand Down Expand Up @@ -286,6 +291,7 @@ export type PersonAPI = {
height: 0,
bio: '',
file: inputs.profilePhoto,
secret: ''
canHoldBreath: undefined
});
%[1]s
Expand Down
Loading