Skip to content

Commit

Permalink
feat: typed enums
Browse files Browse the repository at this point in the history
Use forked version of wsdl-tsclient to make use of enumerable strings
  • Loading branch information
johngeorgewright committed May 13, 2024
1 parent 79b53c7 commit 650280a
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 1,522 deletions.
896 changes: 61 additions & 835 deletions .pnp.cjs

Large diffs are not rendered by default.

39 changes: 35 additions & 4 deletions .pnp.loader.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"ts-jest": "29.1.2",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"wsdl-tsclient": "1.5.0"
"wsdl-tsclient": "johngeorgewright/wsdl-tsclient#enum"
},
"lint-staged": {
"*.{md,json,js,jsx,ts,tsx,yml,yaml}": [
Expand Down
4 changes: 3 additions & 1 deletion src/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export function query<
Args extends unknown[],
>(
client: C,
methodName: Parameters<C[M]> extends [GetByStatement, ...Args] ? M : never,
methodName: Parameters<C[M]> extends [GetByStatement, ...unknown[]]
? M
: never,
query: PQLOptions<GetByStatementResponseResult<C[M]>>,
...args: Args
): ReturnType<C[M]> {
Expand Down
8 changes: 4 additions & 4 deletions src/report/runReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GoogleAdManager, ReportService } from '..'
import { prioritiseKeys } from '../lang/Object'

export interface RunAndDownloadReportOpts {
exportFormat: 'TSV' | 'TSV_EXCEL' | 'CSV_DUMP' | 'XML' | 'XLSX'
exportFormat: ReportService.GetReportDownloadUrl['exportFormat']
statusCheckInterval?: number
query: ReportService.ReportQuery
}
Expand Down Expand Up @@ -74,7 +74,7 @@ export function ensureCorrectOrderOfReportQueryParameters(
export async function runReport(
client: ReportService.ReportServiceClient,
query: ReportService.ReportQuery,
): Promise<string> {
): Promise<number> {
const [reportJob] = await client.runReportJobAsync({
reportJob: {
reportQuery: ensureCorrectOrderOfReportQueryParameters(query),
Expand All @@ -88,7 +88,7 @@ export async function runReport(

export async function waitForReportToFinish(
client: ReportService.ReportServiceClient,
jobId: string,
jobId: number,
statusCheckInterval: number,
): Promise<void> {
let status = 'IN_PROGRESS'
Expand All @@ -110,7 +110,7 @@ export async function waitForReportToFinish(

export async function streamReportResult(
client: ReportService.ReportServiceClient,
jobId: string,
jobId: number,
exportFormat: RunAndDownloadReportOpts['exportFormat'],
): Promise<IncomingMessage> {
const [urlResult] = await client.getReportDownloadURLAsync({
Expand Down
2 changes: 0 additions & 2 deletions test/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ test('ensureCorrectOrderOfReportQueryParameters()', () => {
],

columns: [
'AD_UNIT_CODE',
'TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS',
'TOTAL_ACTIVE_VIEW_MEASURABLE_IMPRESSIONS',
'AD_SERVER_ACTIVE_VIEW_VIEWABLE_IMPRESSIONS',
Expand All @@ -39,7 +38,6 @@ test('ensureCorrectOrderOfReportQueryParameters()', () => {
],
"adUnitView": "HIERARCHICAL",
"columns": [
"AD_UNIT_CODE",
"TOTAL_LINE_ITEM_LEVEL_IMPRESSIONS",
"TOTAL_ACTIVE_VIEW_MEASURABLE_IMPRESSIONS",
"AD_SERVER_ACTIVE_VIEW_VIEWABLE_IMPRESSIONS",
Expand Down
Loading

0 comments on commit 650280a

Please sign in to comment.