Skip to content

Commit

Permalink
fix: validation for unsupported job input types (#1289)
Browse files Browse the repository at this point in the history
  • Loading branch information
davenewza authored Nov 9, 2023
1 parent 8ff92d0 commit a3406f1
Show file tree
Hide file tree
Showing 11 changed files with 550 additions and 33 deletions.
4 changes: 2 additions & 2 deletions integration/testdata/audit_logs/schema.keel
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ model WeddingInvitee {

job UpdateHeadCount {
inputs {
weddingId Id
weddingId ID
}

@permission(expression: true)
}

job UpdateHeadCountWithKysely {
inputs {
weddingId Id
weddingId ID
}

@permission(expression: true)
Expand Down
10 changes: 5 additions & 5 deletions node/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,7 @@ job JobWithoutInputs {
job AdHocJobWithInputs {
inputs {
nameField Text
someBool Bool?
someBool Boolean?
}
@permission(roles: [Admin])
}
Expand Down Expand Up @@ -1960,7 +1960,7 @@ job JobWithoutInputs {
job AdHocJobWithInputs {
inputs {
nameField Text
someBool Bool?
someBool Boolean?
}
@permission(roles: [Admin])
}
Expand All @@ -1972,7 +1972,7 @@ role Admin {}`
expected := `
export interface AdHocJobWithInputsMessage {
nameField: string;
someBool?: any;
someBool?: boolean;
}`

runWriterTest(t, schema, expected, func(s *proto.Schema, w *codegen.Writer) {
Expand Down Expand Up @@ -2080,7 +2080,7 @@ job JobWithoutInputs {
job AdHocJobWithInputs {
inputs {
nameField Text
someBool Bool?
someBool Boolean?
}
@permission(roles: [Admin])
}
Expand All @@ -2096,7 +2096,7 @@ import "@teamkeel/testing-runtime";
export interface AdHocJobWithInputsMessage {
nameField: string;
someBool?: any;
someBool?: boolean;
}
export interface EmailPasswordInput {
email: string;
Expand Down
313 changes: 313 additions & 0 deletions schema/testdata/proto_job_fields/proto.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
{
"models": [
{
"name": "Identity",
"fields": [
{
"modelName": "Identity",
"name": "email",
"type": {
"type": "TYPE_STRING"
},
"optional": true,
"uniqueWith": [
"issuer"
]
},
{
"modelName": "Identity",
"name": "emailVerified",
"type": {
"type": "TYPE_BOOL"
},
"defaultValue": {
"expression": {
"source": "false"
}
}
},
{
"modelName": "Identity",
"name": "password",
"type": {
"type": "TYPE_PASSWORD"
},
"optional": true
},
{
"modelName": "Identity",
"name": "externalId",
"type": {
"type": "TYPE_STRING"
},
"optional": true
},
{
"modelName": "Identity",
"name": "issuer",
"type": {
"type": "TYPE_STRING"
},
"optional": true,
"uniqueWith": [
"email"
]
},
{
"modelName": "Identity",
"name": "id",
"type": {
"type": "TYPE_ID"
},
"primaryKey": true,
"defaultValue": {
"useZeroValue": true
}
},
{
"modelName": "Identity",
"name": "createdAt",
"type": {
"type": "TYPE_DATETIME"
},
"defaultValue": {
"useZeroValue": true
}
},
{
"modelName": "Identity",
"name": "updatedAt",
"type": {
"type": "TYPE_DATETIME"
},
"defaultValue": {
"useZeroValue": true
}
}
],
"actions": [
{
"modelName": "Identity",
"name": "authenticate",
"type": "ACTION_TYPE_WRITE",
"implementation": "ACTION_IMPLEMENTATION_RUNTIME",
"inputMessageName": "AuthenticateInput",
"responseMessageName": "AuthenticateResponse"
},
{
"modelName": "Identity",
"name": "requestPasswordReset",
"type": "ACTION_TYPE_WRITE",
"implementation": "ACTION_IMPLEMENTATION_RUNTIME",
"inputMessageName": "RequestPasswordResetInput",
"responseMessageName": "RequestPasswordResetResponse"
},
{
"modelName": "Identity",
"name": "resetPassword",
"type": "ACTION_TYPE_WRITE",
"implementation": "ACTION_IMPLEMENTATION_RUNTIME",
"inputMessageName": "ResetPasswordInput",
"responseMessageName": "ResetPasswordResponse"
}
]
}
],
"roles": [
{
"name": "Admin"
}
],
"apis": [
{
"name": "Api",
"apiModels": [
{
"modelName": "Identity"
}
]
}
],
"enums": [
{
"name": "MyEnum",
"values": [
{
"name": "One"
},
{
"name": "Two"
}
]
}
],
"messages": [
{
"name": "Any"
},
{
"name": "MyJobMessage",
"fields": [
{
"messageName": "MyJobMessage",
"name": "id",
"type": {
"type": "TYPE_ID"
}
},
{
"messageName": "MyJobMessage",
"name": "text",
"type": {
"type": "TYPE_STRING"
}
},
{
"messageName": "MyJobMessage",
"name": "number",
"type": {
"type": "TYPE_INT"
}
},
{
"messageName": "MyJobMessage",
"name": "bool",
"type": {
"type": "TYPE_BOOL"
}
},
{
"messageName": "MyJobMessage",
"name": "array",
"type": {
"type": "TYPE_STRING"
}
},
{
"messageName": "MyJobMessage",
"name": "enum",
"type": {
"type": "TYPE_ENUM",
"enumName": "MyEnum"
}
}
]
},
{
"name": "EmailPasswordInput",
"fields": [
{
"messageName": "EmailPasswordInput",
"name": "email",
"type": {
"type": "TYPE_STRING"
}
},
{
"messageName": "EmailPasswordInput",
"name": "password",
"type": {
"type": "TYPE_STRING"
}
}
]
},
{
"name": "AuthenticateInput",
"fields": [
{
"messageName": "AuthenticateInput",
"name": "createIfNotExists",
"type": {
"type": "TYPE_BOOL"
},
"optional": true
},
{
"messageName": "AuthenticateInput",
"name": "emailPassword",
"type": {
"type": "TYPE_MESSAGE",
"messageName": "EmailPasswordInput"
}
}
]
},
{
"name": "AuthenticateResponse",
"fields": [
{
"messageName": "AuthenticateResponse",
"name": "identityCreated",
"type": {
"type": "TYPE_BOOL"
}
},
{
"messageName": "AuthenticateResponse",
"name": "token",
"type": {
"type": "TYPE_STRING"
}
}
]
},
{
"name": "RequestPasswordResetInput",
"fields": [
{
"messageName": "RequestPasswordResetInput",
"name": "email",
"type": {
"type": "TYPE_STRING"
}
},
{
"messageName": "RequestPasswordResetInput",
"name": "redirectUrl",
"type": {
"type": "TYPE_STRING"
}
}
]
},
{
"name": "RequestPasswordResetResponse"
},
{
"name": "ResetPasswordInput",
"fields": [
{
"messageName": "ResetPasswordInput",
"name": "token",
"type": {
"type": "TYPE_STRING"
}
},
{
"messageName": "ResetPasswordInput",
"name": "password",
"type": {
"type": "TYPE_STRING"
}
}
]
},
{
"name": "ResetPasswordResponse"
}
],
"jobs": [
{
"name": "MyJob",
"inputMessageName": "MyJobMessage",
"permissions": [
{
"roleNames": [
"Admin"
]
}
]
}
]
}
19 changes: 19 additions & 0 deletions schema/testdata/proto_job_fields/schema.keel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
job MyJob {
inputs {
id ID
text Text
number Number
bool Boolean
array Text[]
enum MyEnum
}

@permission(roles: [Admin])
}

role Admin {}

enum MyEnum {
One
Two
}
Loading

0 comments on commit a3406f1

Please sign in to comment.