-
Notifications
You must be signed in to change notification settings - Fork 4
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
add type json-schemas for all data models #124
Conversation
agents/components/Profile.js
Outdated
@@ -105,11 +105,6 @@ export default compose( | |||
toggleEdit: ({ setEditing }) => () => setEditing(not) | |||
}), | |||
connectForm({ | |||
form: 'profile', | |||
initialValues: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahdinosaur How can I fill the form with data from props? When I remove the initialValues the form is empty. I'm needing this to fill the Profile story with fake data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, we pass in initivalValues
and enableReinitialize
. can either cherry-pick from there, merge that pull request as is and rebase on top, or add those lines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ahdinosaur Thanks! Added those lines (see below commit)
tasks/util/validateTaskPlan.test.js
Outdated
|
||
const Ajv = require('ajv') | ||
const { validateSchema } = require('feathers-hooks-common') | ||
const schema = require('../schemas/taskPlan') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ahdinosaur Would love some help here as I've been working on this problem for a while with no luck.
I'm getting this error when running this test:
[SyntaxError: Error resolving $ref pointer "http://localhost:3000/tasks/schemas/taskRecipe.json#/id".
Token "id" does not exist.]
Even when the id property is in the schema
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems the library expects to find referenced schemas at a particular remote URL, according to the JSON schema standard. we want to somehow locally pass in all the schemas up front and tell it not to look remotely.
tasks/schemas/taskRecipe.json
Outdated
"type": "object", | ||
"properties": { | ||
"id": { | ||
"$ref": "#/id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe this should be #/definitions/id
?
f2bb8df
to
4f81f6a
Compare
@@ -226,6 +226,12 @@ cp cobuy-config/*.js cobuy/config | |||
heroku run npm run db migrate:latest --app=cobuy | |||
``` | |||
|
|||
### JSON schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 yay docs 📔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
agents/schemas/profile.json
Outdated
"required": [ | ||
"id", | ||
"agentId", | ||
"name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure if name
is required. or at least, at the moment i think we create "empty" profiles when we create a group agent to be updated later.
avatar: 'http://dinosaur.is/images/mikey-small.jpg' | ||
} | ||
} | ||
const profile = jsf(schema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fk ya
"description": "Id referencing profile" | ||
}, | ||
"agentId": { | ||
"type": "integer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be
{
"$ref": "/agents/Agent#/definitions/id"
}
oh wait nevermind, we don't have a schema for Agent. all good!
"description": "Person or group or related agents (e.g. admins) being assigned" | ||
}, | ||
"taskRecipeId": { | ||
"$ref": "/tasks/taskRecipe#/definitions/id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet. 🍈
{ | ||
"id": "/tasks/taskPlan", | ||
"title": "Task Plan", | ||
"description": "An assignment of the task to an agent", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! thanks you.
tasks/schemas/taskPlan.json
Outdated
"description": "Id referencing task plan" | ||
}, | ||
"parentTaskPlanID": { | ||
"type": "integer", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be a $ref
like taskRecipeId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch
tasks/services/plans.js
Outdated
const Ajv = require('ajv') | ||
const taskPlanSchema = require('../schemas/taskPlan') | ||
const taskRecipeSchema = require('../schemas/taskRecipe') | ||
const ajv = new Ajv({$data: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if this should be a singleton somewhere in a module. like we export the ajv
object with all the schemas added in app/schema.js
. then we'd require that here.
tasks/services/plans.js
Outdated
all: [ | ||
// encodeParams | ||
] | ||
create: [validateSchema(taskPlanSchema, ajv), encodeParams], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very legit.
minor nit: maybe format for each hook to be on its own line.
@@ -46,11 +51,11 @@ function createChildTaskPlans (hook) { | |||
parentTaskPlanId: hook.result.id, | |||
assigneeId: hook.data.assigneeId, | |||
taskRecipeId: childTaskRecipe.id, | |||
params: hook.data.params | |||
params: hook.result.params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
@@ -0,0 +1,34 @@ | |||
import test from 'ava' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woo hoo tests 😊
Have not tested internal $ref yet
Still need to write tests to test the self referencing taskRecipe
commiting to recieve feedback
90b9312
to
662ba60
Compare
@ahdinosaur Changes and rebase made ready for merge |
In this PR:
Not in this PR
closes #118