Skip to content

Commit

Permalink
Merge pull request #93 from smartcontractkit/ml/update-gql
Browse files Browse the repository at this point in the history
Add StreamSpec
  • Loading branch information
samsondav authored Nov 6, 2024
2 parents f0865ab + f5cedac commit 7c02aca
Show file tree
Hide file tree
Showing 4 changed files with 8,952 additions and 8,950 deletions.
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

0 comments on commit 7c02aca

Please sign in to comment.