Skip to content

Commit 006359a

Browse files
committed
feat(frontend): Orval generated react-query helpers from API
1 parent 1797251 commit 006359a

File tree

450 files changed

+26768
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

450 files changed

+26768
-18
lines changed

jsapp/js/api.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ export interface FetchDataOptions {
118118
includeHeaders?: boolean
119119
}
120120

121-
const fetchData = async <T>(
121+
export const fetchDataRaw = async <T>(
122122
/**
123123
* If you have full url to be called, remember to use `prependRootUrl` option.
124124
*/
125125
path: string,
126126
method: FetchHttpMethod,
127-
data?: Json,
127+
data?: string,
128128
options?: FetchDataOptions,
129129
) => {
130130
// Prepare options
@@ -158,7 +158,7 @@ const fetchData = async <T>(
158158
}
159159

160160
if (data) {
161-
fetchOptions['body'] = JSON.stringify(data)
161+
fetchOptions['body'] = data
162162
}
163163

164164
const response = await fetch(url, fetchOptions)
@@ -210,9 +210,22 @@ const fetchData = async <T>(
210210
} as { headers: Headers } & T
211211
}
212212

213-
return responseJson as T
213+
return { data: responseJson, status: response.status, headers: response.headers } as T
214214
}
215215

216+
const fetchData = async <T>(
217+
/**
218+
* If you have full url to be called, remember to use `prependRootUrl` option.
219+
*/
220+
path: string,
221+
method: FetchHttpMethod,
222+
data?: Json,
223+
options?: FetchDataOptions,
224+
) => {
225+
const body = data ? JSON.stringify(data) : undefined
226+
const response = await fetchDataRaw<{ data: T; status: number; headers: unknown }>(path, method, body, options)
227+
return response.data
228+
}
216229
/** GET Kobo API at path */
217230
export const fetchGet = async <T>(path: string, options?: FetchDataOptions) =>
218231
fetchData<T>(path, 'GET', undefined, options)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type _DataResponseAttachments = {
10+
download_url?: string
11+
download_large_url?: string
12+
download_medium_url?: string
13+
download_small_url?: string
14+
mimetype?: string
15+
filename?: string
16+
uid?: string
17+
question_xpath?: string
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type _ExportCreatePayloadQueryAndItemSubmissionTime = {
10+
$gte?: string
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type _ExportSettingCreatePayloadExportSettingsQueryAndItemSubmissionTime = {
10+
$gte?: string
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type _PermissionAssignmentCreateRequestOneOfTwoPartialPermissionItemFilterItemSubmittedBy = {
10+
$in?: string[]
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type AccessLogsListParams = {
10+
/**
11+
* Number of results to return per page.
12+
*/
13+
limit?: number
14+
/**
15+
* The initial index from which to return the results.
16+
*/
17+
offset?: number
18+
q?: string
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type AccessLogsMeListParams = {
10+
/**
11+
* Number of results to return per page.
12+
*/
13+
limit?: number
14+
/**
15+
* The initial index from which to return the results.
16+
*/
17+
offset?: number
18+
q?: string
19+
}

jsapp/js/api/models/asset.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import type { AssetAdvancedFeatures } from './assetAdvancedFeatures'
2+
import type { AssetAdvancedSubmissionSchema } from './assetAdvancedSubmissionSchema'
3+
import type { AssetAnalysisFormJson } from './assetAnalysisFormJson'
4+
import type { AssetAssignablePermissionsItem } from './assetAssignablePermissionsItem'
5+
import type { AssetChildren } from './assetChildren'
6+
import type { AssetContent } from './assetContent'
7+
import type { AssetDataSharing } from './assetDataSharing'
8+
import type { AssetDeployedVersions } from './assetDeployedVersions'
9+
import type { AssetDeploymentDataDownloadLinks } from './assetDeploymentDataDownloadLinks'
10+
import type { AssetDeploymentLinks } from './assetDeploymentLinks'
11+
import type { AssetDownloadsItem } from './assetDownloadsItem'
12+
import type { AssetEffectivePermissionsItem } from './assetEffectivePermissionsItem'
13+
import type { AssetEmbedsItem } from './assetEmbedsItem'
14+
import type { AssetExportSettings } from './assetExportSettings'
15+
import type { AssetMapCustom } from './assetMapCustom'
16+
import type { AssetMapStyles } from './assetMapStyles'
17+
import type { AssetProjectOwnership } from './assetProjectOwnership'
18+
import type { AssetReportCustom } from './assetReportCustom'
19+
import type { AssetReportStyles } from './assetReportStyles'
20+
/**
21+
* Generated by orval v7.10.0 🍺
22+
* Do not edit manually.
23+
* KoboToolbox API
24+
* Powerful and intuitive data collection tools to make an impact
25+
* OpenAPI spec version: 2.0.0 (api_v2)
26+
*/
27+
import type { AssetSettings } from './assetSettings'
28+
import type { AssetSummary } from './assetSummary'
29+
import type { AssetTypeEnum } from './assetTypeEnum'
30+
31+
export interface Asset {
32+
readonly url: string
33+
readonly owner: string
34+
/** Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only. */
35+
readonly owner__username: string
36+
/** @nullable */
37+
parent?: string | null
38+
settings?: AssetSettings
39+
asset_type: AssetTypeEnum
40+
readonly files: readonly string[]
41+
readonly summary: AssetSummary
42+
date_created?: string
43+
date_modified?: string
44+
/** @nullable */
45+
date_deployed?: string | null
46+
readonly version_id: string
47+
readonly version__content_hash: string
48+
readonly version_count: number
49+
readonly has_deployment: boolean
50+
readonly deployed_version_id: string
51+
readonly deployed_versions: AssetDeployedVersions
52+
readonly deployment__links: AssetDeploymentLinks
53+
readonly deployment__active: boolean
54+
readonly deployment__data_download_links: AssetDeploymentDataDownloadLinks
55+
readonly deployment__submission_count: number
56+
readonly deployment__last_submission_time: string
57+
readonly deployment__encrypted: boolean
58+
readonly deployment__uuid: string
59+
readonly deployment_status: string
60+
report_styles?: AssetReportStyles
61+
report_custom?: AssetReportCustom
62+
advanced_features?: AssetAdvancedFeatures
63+
readonly advanced_submission_schema: AssetAdvancedSubmissionSchema
64+
readonly analysis_form_json: AssetAnalysisFormJson
65+
map_styles?: AssetMapStyles
66+
map_custom?: AssetMapCustom
67+
content?: AssetContent
68+
readonly downloads: readonly AssetDownloadsItem[]
69+
readonly embeds: readonly AssetEmbedsItem[]
70+
readonly xform_link: string
71+
readonly hooks_link: string
72+
tag_string?: string
73+
readonly uid: string
74+
readonly kind: string
75+
readonly xls_link: string
76+
/** @maxLength 255 */
77+
name?: string
78+
readonly assignable_permissions: readonly AssetAssignablePermissionsItem[]
79+
readonly permissions: readonly string[]
80+
readonly effective_permissions: readonly AssetEffectivePermissionsItem[]
81+
readonly exports: string
82+
readonly export_settings: readonly AssetExportSettings[]
83+
readonly data: string
84+
readonly children: AssetChildren
85+
readonly subscribers_count: number
86+
readonly status: string
87+
readonly access_types: readonly string[]
88+
data_sharing?: AssetDataSharing
89+
readonly paired_data: string
90+
/** @nullable */
91+
readonly project_ownership: AssetProjectOwnership
92+
readonly owner_label: string
93+
/** @nullable */
94+
readonly last_modified_by: string | null
95+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type AssetAdvancedFeatures = { [key: string]: unknown }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Generated by orval v7.10.0 🍺
3+
* Do not edit manually.
4+
* KoboToolbox API
5+
* Powerful and intuitive data collection tools to make an impact
6+
* OpenAPI spec version: 2.0.0 (api_v2)
7+
*/
8+
9+
export type AssetAdvancedSubmissionSchema = {
10+
readonly type?: string
11+
readonly $description?: string
12+
}

0 commit comments

Comments
 (0)