Skip to content

Commit 7c02aca

Browse files
authored
Merge pull request #93 from smartcontractkit/ml/update-gql
Add StreamSpec
2 parents f0865ab + f5cedac commit 7c02aca

File tree

4 files changed

+8952
-8950
lines changed

4 files changed

+8952
-8950
lines changed

src/screens/Job/JobView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ const JOB_PAYLOAD__SPEC = gql`
144144
config
145145
createdAt
146146
}
147+
... on StreamSpec {
148+
streamID
149+
}
147150
}
148151
`
149152

src/screens/Job/generateJobDefinition.test.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,4 +691,74 @@ config = "<config>"
691691
const output = generateJobDefinition(job)
692692
expect(output.definition).toEqual(expectedOutput)
693693
})
694+
695+
it('generates a valid Stream definition', () => {
696+
const job: JobPayload_Fields = {
697+
id: '1',
698+
type: 'stream',
699+
schemaVersion: 1,
700+
name: 'stream test',
701+
externalJobID: '00000000-0000-0000-0000-0000000000001',
702+
maxTaskDuration: '10s',
703+
spec: {
704+
__typename: 'StreamSpec',
705+
streamID: '1001',
706+
},
707+
observationSource: '',
708+
...otherJobFields,
709+
}
710+
711+
const expectedOutput = `type = "stream"
712+
schemaVersion = 1
713+
name = "stream test"
714+
externalJobID = "00000000-0000-0000-0000-0000000000001"
715+
maxTaskDuration = "10s"
716+
streamID = "1001"
717+
`
718+
const output = generateJobDefinition(job)
719+
expect(output.definition).toEqual(expectedOutput)
720+
})
721+
722+
it('generates an empty definition for unspecified type', () => {
723+
const job: JobPayload_Fields = {
724+
id: '',
725+
name: '',
726+
externalJobID: '',
727+
observationSource: '',
728+
createdAt: undefined,
729+
schemaVersion: 0,
730+
type: '',
731+
maxTaskDuration: '',
732+
spec: {
733+
__typename: <any>'Undefined',
734+
coordinatorV1Address: undefined,
735+
coordinatorV2Address: undefined,
736+
waitBlocks: 0,
737+
lookbackBlocks: 0,
738+
blockhashStoreAddress: '',
739+
batchBlockhashStoreAddress: '',
740+
pollPeriod: '',
741+
runTimeout: '',
742+
evmChainID: undefined,
743+
fromAddresses: undefined,
744+
getBlockhashesBatchSize: 0,
745+
storeBlockhashesBatchSize: 0,
746+
coordinatorV2PlusAddress: undefined,
747+
},
748+
runs: {
749+
__typename: undefined,
750+
results: [],
751+
metadata: {
752+
__typename: undefined,
753+
total: 0,
754+
},
755+
},
756+
errors: [],
757+
}
758+
759+
const expectedOutput = ``
760+
761+
const output = generateJobDefinition(job)
762+
expect(output.definition).toEqual(expectedOutput)
763+
})
694764
})

src/screens/Job/generateJobDefinition.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,25 @@ export const generateJobDefinition = (
274274

275275
break
276276

277-
default:
278-
return { definition: '' }
279277
case 'WebhookSpec':
280278
values = {
281279
...extractJobFields(job),
282280
...extractObservationSourceField(job),
283281
}
284282

285283
break
284+
285+
case 'StreamSpec':
286+
values = {
287+
...extractJobFields(job, 'maxTaskDuration'),
288+
...extractSpecFields(job.spec, 'streamID'),
289+
...extractObservationSourceField(job),
290+
}
291+
292+
break
293+
294+
default:
295+
return { definition: '' }
286296
}
287297

288298
return {

0 commit comments

Comments
 (0)