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

Add StreamSpec #93

Merged
merged 6 commits into from
Nov 6, 2024
Merged
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
3 changes: 3 additions & 0 deletions src/screens/Job/JobView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ const JOB_PAYLOAD__SPEC = gql`
config
createdAt
}
... on StreamSpec {
streamID
}
}
`

Expand Down
70 changes: 70 additions & 0 deletions src/screens/Job/generateJobDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,74 @@ config = "<config>"
const output = generateJobDefinition(job)
expect(output.definition).toEqual(expectedOutput)
})

it('generates a valid Stream definition', () => {
const job: JobPayload_Fields = {
id: '1',
type: 'stream',
schemaVersion: 1,
name: 'stream test',
externalJobID: '00000000-0000-0000-0000-0000000000001',
maxTaskDuration: '10s',
spec: {
__typename: 'StreamSpec',
streamID: '1001',
},
observationSource: '',
...otherJobFields,
}

const expectedOutput = `type = "stream"
schemaVersion = 1
name = "stream test"
externalJobID = "00000000-0000-0000-0000-0000000000001"
maxTaskDuration = "10s"
streamID = "1001"
`
const output = generateJobDefinition(job)
expect(output.definition).toEqual(expectedOutput)
})

it('generates an empty definition for unspecified type', () => {
const job: JobPayload_Fields = {
id: '',
name: '',
externalJobID: '',
observationSource: '',
createdAt: undefined,
schemaVersion: 0,
type: '',
maxTaskDuration: '',
spec: {
__typename: <any>'Undefined',
coordinatorV1Address: undefined,
coordinatorV2Address: undefined,
waitBlocks: 0,
lookbackBlocks: 0,
blockhashStoreAddress: '',
batchBlockhashStoreAddress: '',
pollPeriod: '',
runTimeout: '',
evmChainID: undefined,
fromAddresses: undefined,
getBlockhashesBatchSize: 0,
storeBlockhashesBatchSize: 0,
coordinatorV2PlusAddress: undefined,
},
runs: {
__typename: undefined,
results: [],
metadata: {
__typename: undefined,
total: 0,
},
},
errors: [],
}

const expectedOutput = ``

const output = generateJobDefinition(job)
expect(output.definition).toEqual(expectedOutput)
})
})
14 changes: 12 additions & 2 deletions src/screens/Job/generateJobDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,25 @@ export const generateJobDefinition = (

break

default:
return { definition: '' }
case 'WebhookSpec':
values = {
...extractJobFields(job),
...extractObservationSourceField(job),
}

break

case 'StreamSpec':
values = {
...extractJobFields(job, 'maxTaskDuration'),
...extractSpecFields(job.spec, 'streamID'),
...extractObservationSourceField(job),
}

break

default:
return { definition: '' }
}

return {
Expand Down
Loading
Loading