Skip to content

Commit

Permalink
Make it so the type for seed_type call.function is explicit about bei…
Browse files Browse the repository at this point in the history
…ng a seedReference.

Part of #20.
  • Loading branch information
jkomoros committed Jul 29, 2023
1 parent ed8f4f7 commit 6b8ee6a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
31 changes: 13 additions & 18 deletions seed-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2967,7 +2967,7 @@
"arguments": {
"anyOf": [
{
"$ref": "#/definitions/seedData"
"$ref": "#/definitions/seedData/anyOf/27/properties/properties/additionalProperties/anyOf/0"
},
{
"$ref": "#/definitions/seedData/anyOf/0/properties/prompt/anyOf/1"
Expand Down Expand Up @@ -2995,25 +2995,20 @@
]
},
"function": {
"anyOf": [
{
"$ref": "#/definitions/seedData"
},
{
"$ref": "#/definitions/seedData/anyOf/0/properties/prompt/anyOf/1"
"type": "object",
"properties": {
"packet": {
"$ref": "#/definitions/seedData/anyOf/0/properties/prompt/anyOf/1/properties/packet"
},
{
"anyOf": [
{
"$ref": "#/definitions/seedData/anyOf/5/properties/value/anyOf/2/anyOf/0"
},
{
"$ref": "#/definitions/seedData/anyOf/5/properties/value/anyOf/2/anyOf/1/additionalProperties/anyOf/2/anyOf/2"
}
],
"description": "The seed reference of the function to call"
"seed": {
"$ref": "#/definitions/seedData/anyOf/0/properties/id"
}
]
},
"required": [
"seed"
],
"additionalProperties": false,
"description": "The function to call"
}
},
"required": [
Expand Down
32 changes: 19 additions & 13 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,21 +960,27 @@ const seedDataFunction = makeSeedData(seedDataConfigFunction);

export type SeedDataFunction = z.infer<typeof seedDataFunction>;

const seedDataConfigCall = {
const seedDataCallArguments = z.record(argVarName, z.union([
lazySeedData,
seedReference,
inputValue
])).describe('The map of name -> variables to set');

const seedDataCall = seedDataBase.extend({
type: z.literal('call'),
properties: {
arguments: z.record(argVarName, z.union([
lazySeedData,
seedReference,
inputValue
])).describe('The map of name -> variables to set'),
//TODO: shouldn't this be typed to just be a seed function only?
function: inputNonObjectValue.describe('The seed reference of the function to call')
}
};
arguments: makeSeedReferenceProperty(seedDataCallArguments),
function: seedReference.describe('The function to call')
});

const nestedSeedDataCall = makeNestedSeedData(seedDataConfigCall);
const seedDataCall = makeSeedData(seedDataConfigCall);
export const nestedSeedDataCall = seedDataBase.extend({
type: z.literal('call'),
arguments: z.union([
lazySeedData,
seedReference,
seedDataCallArguments
]),
function: seedReference.describe('The function to call')
});

export type SeedDataCall = z.infer<typeof seedDataCall>;

Expand Down

0 comments on commit 6b8ee6a

Please sign in to comment.