Skip to content

Commit 537b7aa

Browse files
authored
Merge branch 'main' into jc/hackathon_ci
2 parents 618b4a6 + 25cef47 commit 537b7aa

File tree

19 files changed

+14093
-7379
lines changed

19 files changed

+14093
-7379
lines changed

packages/hackathon/src/authToken/extensionProxyTransport.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export class ExtensionProxyTransport extends BaseTransport {
133133
// const responseBody =
134134
// mode === ResponseMode.binary ? await res.body : await res.body.toString()
135135
return {
136+
method,
136137
url: requestPath,
137138
body: res.body,
138139
contentType,

packages/run-it/src/components/ResponseExplorer/ResponseExplorer.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import userEvent from '@testing-library/user-event'
3131
import { ResponseExplorer, ResponseHeaders } from '.'
3232

3333
const response: IRawResponse = {
34+
method: 'GET',
3435
url: '/sample/url',
3536
ok: true,
3637
statusCode: 200,

packages/run-it/src/test-data/responses.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import type { IRawResponse } from '@looker/sdk-rtl'
2828

2929
export const testJsonResponse: IRawResponse = {
30+
method: 'GET',
3031
url: 'https://some/json/data',
3132
headers: { 'content-type': 'application/json' },
3233
contentType: 'application/json',
@@ -37,6 +38,7 @@ export const testJsonResponse: IRawResponse = {
3738
}
3839

3940
export const testOneRowComplexJson: IRawResponse = {
41+
method: 'GET',
4042
url: 'https://some/json/data',
4143
headers: { 'content-type': 'application/json' },
4244
contentType: 'application/json',
@@ -98,6 +100,7 @@ export const testOneRowComplexJson: IRawResponse = {
98100
}
99101

100102
export const testTextResponse: IRawResponse = {
103+
method: 'GET',
101104
url: 'https://some/text/data',
102105
headers: { 'content-type': 'text/plain;charset=utf-8' },
103106
contentType: 'text/plain;charset=utf-8',
@@ -108,6 +111,7 @@ export const testTextResponse: IRawResponse = {
108111
}
109112

110113
export const testHtmlResponse: IRawResponse = {
114+
method: 'GET',
111115
url: `https://some/html`,
112116
headers: { 'content-type': 'text/html;charset=utf-8' },
113117
contentType: 'text/html;charset=utf-8',
@@ -123,6 +127,7 @@ export const testHtmlResponse: IRawResponse = {
123127
}
124128

125129
export const testSqlResponse: IRawResponse = {
130+
method: 'GET',
126131
url: `https://some/sql`,
127132
headers: { 'content-type': 'application/sql' },
128133
contentType: 'application/sql',
@@ -137,6 +142,7 @@ LIMIT 500`),
137142
}
138143

139144
export const testImageResponse = (contentType = 'image/png'): IRawResponse => ({
145+
method: 'GET',
140146
url: `http://${contentType}`,
141147
headers: { 'content-type': contentType },
142148
contentType,
@@ -147,6 +153,7 @@ export const testImageResponse = (contentType = 'image/png'): IRawResponse => ({
147153
})
148154

149155
export const testUnknownResponse: IRawResponse = {
156+
method: 'GET',
150157
url: 'http://bogus',
151158
headers: {},
152159
contentType: 'bogus',
@@ -157,6 +164,7 @@ export const testUnknownResponse: IRawResponse = {
157164
}
158165

159166
export const testErrorResponse: IRawResponse = {
167+
method: 'GET',
160168
url: 'http://error',
161169
headers: {},
162170
body: Buffer.from(
@@ -169,6 +177,7 @@ export const testErrorResponse: IRawResponse = {
169177
}
170178

171179
export const testBogusJsonResponse: IRawResponse = {
180+
method: 'GET',
172181
url: 'https://some/json/data',
173182
headers: {},
174183
contentType: 'application/json',

packages/sdk-codegen-scripts/src/legacyGenerator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
*/
2626

2727
import { log } from '@looker/sdk-codegen-utils'
28-
import type { IGeneratorSpec } from '@looker/sdk-codegen'
28+
import type { IGeneratorSpec, IApiVersion } from '@looker/sdk-codegen'
2929
import { getSpecsFromVersions, legacyLanguages } from '@looker/sdk-codegen'
30-
import type { IApiVersion } from '@looker/sdk'
3130
import type { ISDKConfigProps } from './sdkConfig'
3231
import { run } from './nodeUtils'
3332
import { fetchLookerVersions, logConvertSpec } from './fetchSpec'

packages/sdk-codegen-scripts/src/prettify.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,5 @@ const prettierTs: prettier.Options = {
4545
*/
4646
export const prettify = (code: string, options: prettier.Options = {}) => {
4747
const merged: prettier.Options = { ...prettierTs, ...{ options } }
48-
const source = prettier.format(code, merged)
49-
return source.trimRight()
48+
return prettier.format(code, merged)
5049
}

packages/sdk-codegen-scripts/src/specConvert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
import * as path from 'path'
2727
import { log } from '@looker/sdk-codegen-utils'
28-
import type { IApiVersion } from '@looker/sdk'
28+
import type { IApiVersion } from '@looker/sdk-codegen'
2929
import { getSpecsFromVersions } from '@looker/sdk-codegen'
3030
import type { ISDKConfigProps } from './sdkConfig'
3131
import { SDKConfig } from './sdkConfig'

packages/sdk-codegen/src/specConverter.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
import isEmpty from 'lodash/isEmpty'
28-
import type { APIMethods, Url } from '@looker/sdk-rtl'
28+
import type { APIMethods } from '@looker/sdk-rtl'
2929
import type { ArgValues, IApiModel, KeyedCollection } from './sdkModels'
3030
import { ApiModel } from './sdkModels'
3131

@@ -35,7 +35,7 @@ const warn = (warning: string) => {
3535

3636
const appJson = 'application/json'
3737

38-
/** This declaration is duplicated DIRECTLY from @looker/sdk to detach dependency */
38+
/** This declaration is duplicated DIRECTLY from @looker/sdk API 4.0 models to detach dependency */
3939
export interface IApiVersion {
4040
/**
4141
* Current Looker release version number (read-only)
@@ -50,28 +50,30 @@ export interface IApiVersion {
5050
* API server base url (read-only)
5151
*/
5252
api_server_url?: string
53-
/** Web server url */
53+
/**
54+
* Web server base url (read-only)
55+
*/
5456
web_server_url?: string
5557
}
5658

57-
/** This declaration is duplicated DIRECTLY from @looker/sdk to detach dependency */
59+
/** This declaration is duplicated DIRECTLY from @looker/sdk API 4.0 models to detach dependency */
5860
export interface IApiVersionElement {
5961
/**
6062
* Version number as it appears in '/api/xxx/' urls (read-only)
6163
*/
62-
version?: string
64+
version?: string | null
6365
/**
6466
* Full version number including minor version (read-only)
6567
*/
66-
full_version?: string
68+
full_version?: string | null
6769
/**
6870
* Status of this version (read-only)
6971
*/
70-
status?: string
72+
status?: string | null
7173
/**
7274
* Url for swagger.json for this version (read-only)
7375
*/
74-
swagger_url?: Url
76+
swagger_url?: string | null
7577
}
7678

7779
/**

packages/sdk-codegen/src/typescript.gen.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ body: ICreateDashboardRenderTask`)
911911
/**
912912
* The local state of each project in the workspace (read-only)
913913
*/
914-
projects?: IProject[]
914+
projects?: IProject[] | null
915915
}`)
916916
})
917917
it('with refs, arrays and nullable', () => {
@@ -921,12 +921,12 @@ body: ICreateDashboardRenderTask`)
921921
/**
922922
* Current Looker release version number (read-only)
923923
*/
924-
looker_release_version?: string
924+
looker_release_version?: string | null
925925
current_version?: IApiVersionElement
926926
/**
927927
* Array of versions supported by this Looker instance (read-only)
928928
*/
929-
supported_versions?: IApiVersionElement[]
929+
supported_versions?: IApiVersionElement[] | null
930930
}`)
931931
})
932932
it('required properties', () => {
@@ -941,27 +941,27 @@ body: ICreateDashboardRenderTask`)
941941
/**
942942
* Id of query to run
943943
*/
944-
query_id: number
944+
query_id: number | null
945945
/**
946946
* Desired async query result format. Valid values are: "inline_json", "json", "json_detail", "json_fe", "csv", "html", "md", "txt", "xlsx", "gsxml".
947947
*/
948-
result_format: ${name}
948+
result_format: ${name} | null
949949
/**
950950
* Source of query task
951951
*/
952-
source?: string
952+
source?: string | null
953953
/**
954954
* Create the task but defer execution
955955
*/
956956
deferred?: boolean
957957
/**
958958
* Id of look associated with query.
959959
*/
960-
look_id?: number
960+
look_id?: number | null
961961
/**
962962
* Id of dashboard associated with query.
963963
*/
964-
dashboard_id?: string
964+
dashboard_id?: string | null
965965
}`)
966966
})
967967

@@ -1072,11 +1072,11 @@ export enum Align {
10721072
/**
10731073
* Id of query to run
10741074
*/
1075-
query_id: number
1075+
query_id: number | null
10761076
/**
10771077
* Desired async query result format. Valid values are: "inline_json", "json", "json_detail", "json_fe", "csv", "html", "md", "txt", "xlsx", "gsxml".
10781078
*/
1079-
result_format: ResultFormat
1079+
result_format: ResultFormat | null
10801080
/**
10811081
* An array of user attribute types that are allowed to be used in filters on this field. Valid values are: "advanced_filter_string", "advanced_filter_number", "advanced_filter_datetime", "string", "number", "datetime", "relative_url", "yesno", "zipcode". (read-only)
10821082
*/
@@ -1085,7 +1085,7 @@ export enum Align {
10851085
/**
10861086
* Roles assigned to group (read-only)
10871087
*/
1088-
roles?: IRole[]
1088+
roles?: IRole[] | null
10891089
}`)
10901090
})
10911091

@@ -1116,15 +1116,15 @@ export enum Align {
11161116
/**
11171117
* Id of query to run
11181118
*/
1119-
query_id: number
1119+
query_id: number | null
11201120
/**
11211121
* Desired async query result format. Valid values are: "inline_json", "json", "json_detail", "json_fe", "csv", "html", "md", "txt", "xlsx", "gsxml".
11221122
*/
1123-
result_format: SecondResponseWithEnumsResultFormat
1123+
result_format: SecondResponseWithEnumsResultFormat | null
11241124
/**
11251125
* Desired async query result format. Valid values are: "inline_json", "json", "json_detail", "json_fe", "csv", "html", "md", "txt", "xlsx", "gsxml".
11261126
*/
1127-
another_format?: AnotherFormat
1127+
another_format?: AnotherFormat | null
11281128
/**
11291129
* An array of user attribute types that are allowed to be used in filters on this field. Valid values are: "advanced_filter_string", "advanced_filter_number", "advanced_filter_datetime", "string", "number", "datetime", "relative_url", "yesno", "zipcode". (read-only)
11301130
*/
@@ -1133,7 +1133,7 @@ export enum Align {
11331133
/**
11341134
* Roles assigned to group (read-only)
11351135
*/
1136-
roles?: IRole[]
1136+
roles?: IRole[] | null
11371137
}`)
11381138
})
11391139
})

packages/sdk-codegen/src/typescript.gen.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ export class ${this.packageName}Stream extends APIMethods {
230230

231231
declareProperty(indent: string, property: IProperty) {
232232
const optional = !property.required ? '?' : ''
233+
const nullify = property.nullable ? ' | null' : ''
233234
if (property.name === strBody) {
234235
// TODO refactor this hack to track context when the body parameter is created for the request type
235236
property.type.refCount++
@@ -239,13 +240,17 @@ export class ${this.packageName}Stream extends APIMethods {
239240
property.description ||
240241
'body parameter for dynamically created request type'
241242
) +
242-
`${indent}${property.name}${optional}: ${this.typeName(property.type)}`
243+
`${indent}${property.name}${optional}: ${this.typeName(
244+
property.type
245+
)}${nullify}`
243246
)
244247
}
245248
const mapped = this.typeMap(property.type)
246249
return (
247250
this.commentHeader(indent, this.describeProperty(property)) +
248-
`${indent}${this.reserve(property.name)}${optional}: ${mapped.name}`
251+
`${indent}${this.reserve(property.name)}${optional}: ${
252+
mapped.name
253+
}${nullify}`
249254
)
250255
}
251256

packages/sdk-node/src/nodeTransport.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('NodeTransport', () => {
4040
const response = await xp.rawRequest('GET', fullPath)
4141
expect(response).toBeDefined()
4242
expect(response.ok).toEqual(true)
43+
expect(response.method).toEqual('GET')
4344
expect(response.statusCode).toEqual(200)
4445
expect(response.statusMessage).toEqual('OK')
4546
expect(response.contentType).toContain('text/html')
@@ -56,6 +57,7 @@ describe('NodeTransport', () => {
5657
const errorMessage = `GET ${badPath}`
5758
expect(response).toBeDefined()
5859
expect(response.ok).toEqual(false)
60+
expect(response.method).toEqual('GET')
5961
expect(response.statusCode).toEqual(404)
6062
expect(response.body).toBeDefined()
6163
expect(response.statusMessage.indexOf('"type":"Buffer"')).toEqual(-1)
@@ -77,6 +79,7 @@ describe('NodeTransport', () => {
7779

7880
describe('ok check', () => {
7981
const raw: IRawResponse = {
82+
method: 'GET',
8083
contentType: 'application/json',
8184
headers: {},
8285
url: 'bogus',

0 commit comments

Comments
 (0)