-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: generate JSON payloads for discretionary services #3184
Conversation
Removed vultr server and associated DNS entries |
…ss/discretionary-payload
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.
Apologies for the slow turnaround time here!
Approved - very happy for this to progress as is - pragmatic and lightweight solution which is great ✅
Two non-blocking comments which may be worth a discussion -
Skipping all validation
What we're doing by skipping all validation is potentially sending anything or nothing across, and we can't describe the object to recipients easily (e.g. by sharing the schema). I think currently{}
and {"hello": "world"}
could be posted here. This is obviously massively unlikely / effectively impossible as it's going through our current transformer which we know works very well and is validated.
Longer term, once we have multiple schemas in the schema repo, or other utils functions, I think we could validate a discretionary payload against the schema derived from on optional schema. Something like -
import type { PartialDeep } from "type-fest";
type Discretionary = PartialDeep<Schema>
This should mean all fields are optional, but still have to conform to expectations where present - sort of a best of both worlds?
This means we could also share something (a json schema doc or a single simple payload) with consumers to say "you're going to get one of these objects". As I've said above, this isn't super pressing as we're using our current payload generation - this means failures are unlikely and we already have the existing schema to share 👍
Missing passport
Currently we're just sending a subset of the ODP schema with this approach. If a discretionary service is mostly concerned with another domain area, there's potentially a lot of data not being passed on (outside the QuestionAndResponses[]
structure).
I think it's worth considering adding the user's passport in a discretionary service payload which gives Editors and consumers full power to ask questions, and then build integrations based on these responses.
The passport could be a separate JSON file, or even better just attached to the payload -
type Discretionary = Schema & { passport?: Record<string, string, string[], boolean, number, object>
This would obviously be untyped, unstructured, and unvalidated beyond the simple example above, but would allow Editors to set a random data field, and allow these fields to be consumed by integrations.
*/ | ||
export function isApplicationTypeSupported(passport: Passport): boolean { | ||
// Prefixes of application types that are supported by the ODP Schema | ||
// TODO in future look up via schema type definitions |
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.
👍
@DafyddLlyr - thanks for taking a look at this one! re your two points:
|
Changes:
Open questions:
data
already has defined representations for some of our most common component types (FindProperty, ContactInput) &responses
is already generic enough to support a service that literally sets zero data fieldsTesting: