Skip to content

Commit

Permalink
refactor: use record for KindOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Sep 9, 2024
1 parent 69c3f77 commit 063b1a7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/source.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { MarkupSource, MirSource, OutputType, Context, Kind, EventEmitter } from './types.js'
import {
MarkupSource,
MirSource,
OutputType,
Context,
Kind,
EventEmitter,
KindOptions,
} from './types.js'
import { KIND_OPTIONS, CONTENT_TYPE_OPTIONS } from './constants.js'
import { Cache } from './structures.js'
import { Script } from './script.js'
Expand All @@ -7,10 +15,10 @@ import { OutgoingHttpHeaders } from 'http'

export class Source {
public kind: Kind
public kindOptions: { [key in Kind]: string }
public kindOptions: KindOptions
public url: string
public contentType: string
public contentTypeOptions: { [key in Kind]: string }
public contentTypeOptions: KindOptions
public headers: OutgoingHttpHeaders
public body?: object
public script: Script
Expand Down
10 changes: 6 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,16 @@ export type MarkupArgumentScript = {
hierarchicalType: MarkupHierarchicalType.Argument
}

export type KindOptions = Record<Kind, string>

export type MarkupSource = {
kind: Kind
kindOptions: { [key in Kind]: string }
kindOptions: KindOptions
headers: OutgoingHttpHeaders
body?: object
url: string
contentType: string
contentTypeOptions: { [key in Kind]: string }
contentTypeOptions: KindOptions
script: MarkupScript
scriptId: number
}
Expand Down Expand Up @@ -374,10 +376,10 @@ export type MirSource = {
kind: Kind
headers: OutgoingHttpHeaders
body?: object
kindOptions: { [key in Kind]: string }
kindOptions: KindOptions
url: string
contentType: string
contentTypeOptions: { [key in Kind]: string }
contentTypeOptions: KindOptions
script: MirScript
}

Expand Down
1 change: 1 addition & 0 deletions test/src/radon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3616,6 +3616,7 @@ describe('Radon', () => {
expect(updatedSource.kind).toBe(2)
expect(updatedSource.contentType).toBe('JSON API')
})

it('update to rng protocol kind', () => {
const mirRequest: MirRequest = {
timelock: 0,
Expand Down

0 comments on commit 063b1a7

Please sign in to comment.