|
| 1 | +import {OpenAPIRegistry} from '@asteasolutions/zod-to-openapi'; |
| 2 | + |
| 3 | +import { |
| 4 | + deleteConnectionArgsSchema, |
| 5 | + deleteConnectionResultSchema, |
| 6 | +} from '../../../../shared/schema/bi/schemas/connections'; |
| 7 | +import { |
| 8 | + createDatasetArgsSchema, |
| 9 | + createDatasetResultSchema, |
| 10 | + deleteDatasetArgsSchema, |
| 11 | + deleteDatasetResultSchema, |
| 12 | + getDatasetByVersionArgsSchema, |
| 13 | + getDatasetByVersionResultSchema, |
| 14 | + updateDatasetArgsSchema, |
| 15 | + updateDatasetResultSchema, |
| 16 | +} from '../../../../shared/schema/bi/schemas/datasets'; |
| 17 | +import { |
| 18 | + createDashArgsSchema, |
| 19 | + createDashResultSchema, |
| 20 | + deleteDashArgsSchema, |
| 21 | + deleteDashResultSchema, |
| 22 | + getDashArgsSchema, |
| 23 | + getDashResultSchema, |
| 24 | + updateDashArgsSchema, |
| 25 | + updateDashResultSchema, |
| 26 | +} from '../../../../shared/schema/mix/schemas/dash'; |
| 27 | +import { |
| 28 | + deleteEditorChartArgsSchema, |
| 29 | + deleteEditorChartResultSchema, |
| 30 | +} from '../../../../shared/schema/mix/schemas/editor'; |
| 31 | +import { |
| 32 | + deleteWizardChartArgsSchema, |
| 33 | + deleteWizardChartResultSchema, |
| 34 | +} from '../../../../shared/schema/mix/schemas/wizard'; |
| 35 | +import {ApiTag} from '../constants'; |
| 36 | +import type {PublicApiVersionConfig} from '../types'; |
| 37 | +import {makeAction} from '../utils/make-action'; |
| 38 | + |
| 39 | +export const PUBLIC_API_V0_CONFIG = { |
| 40 | + openApi: { |
| 41 | + registry: new OpenAPIRegistry(), |
| 42 | + }, |
| 43 | + |
| 44 | + actions: { |
| 45 | + // Connection |
| 46 | + deleteConnection: makeAction({ |
| 47 | + schemas: { |
| 48 | + args: deleteConnectionArgsSchema, |
| 49 | + result: deleteConnectionResultSchema, |
| 50 | + }, |
| 51 | + resolve: (api) => async (args) => { |
| 52 | + const {responseData} = await api.bi.deleteConnection(args); |
| 53 | + |
| 54 | + return responseData; |
| 55 | + }, |
| 56 | + openApi: { |
| 57 | + summary: 'Delete connection', |
| 58 | + tags: [ApiTag.Connection], |
| 59 | + }, |
| 60 | + }), |
| 61 | + |
| 62 | + // Dataset |
| 63 | + getDataset: makeAction({ |
| 64 | + schemas: { |
| 65 | + args: getDatasetByVersionArgsSchema, |
| 66 | + result: getDatasetByVersionResultSchema, |
| 67 | + }, |
| 68 | + resolve: (api) => async (args) => { |
| 69 | + const {responseData} = await api.bi.getDatasetByVersion(args); |
| 70 | + |
| 71 | + return responseData; |
| 72 | + }, |
| 73 | + openApi: { |
| 74 | + summary: 'Get dataset', |
| 75 | + tags: [ApiTag.Dataset], |
| 76 | + }, |
| 77 | + }), |
| 78 | + updateDataset: makeAction({ |
| 79 | + schemas: { |
| 80 | + args: updateDatasetArgsSchema, |
| 81 | + result: updateDatasetResultSchema, |
| 82 | + }, |
| 83 | + resolve: (api) => async (args) => { |
| 84 | + const {responseData} = await api.bi.updateDataset(args); |
| 85 | + |
| 86 | + return responseData; |
| 87 | + }, |
| 88 | + openApi: { |
| 89 | + summary: 'Update dataset', |
| 90 | + tags: [ApiTag.Dataset], |
| 91 | + }, |
| 92 | + }), |
| 93 | + createDataset: makeAction({ |
| 94 | + schemas: { |
| 95 | + args: createDatasetArgsSchema, |
| 96 | + result: createDatasetResultSchema, |
| 97 | + }, |
| 98 | + resolve: (api) => async (args) => { |
| 99 | + const {responseData} = await api.bi.createDataset(args); |
| 100 | + |
| 101 | + return responseData; |
| 102 | + }, |
| 103 | + openApi: { |
| 104 | + summary: 'Create dataset', |
| 105 | + tags: [ApiTag.Dataset], |
| 106 | + }, |
| 107 | + }), |
| 108 | + deleteDataset: makeAction({ |
| 109 | + schemas: { |
| 110 | + args: deleteDatasetArgsSchema, |
| 111 | + result: deleteDatasetResultSchema, |
| 112 | + }, |
| 113 | + resolve: (api) => async (args) => { |
| 114 | + const {responseData} = await api.bi.deleteDataset(args); |
| 115 | + |
| 116 | + return responseData; |
| 117 | + }, |
| 118 | + openApi: { |
| 119 | + summary: 'Delete dataset', |
| 120 | + tags: [ApiTag.Dataset], |
| 121 | + }, |
| 122 | + }), |
| 123 | + |
| 124 | + // Wizard |
| 125 | + deleteWizardChart: makeAction({ |
| 126 | + schemas: { |
| 127 | + args: deleteWizardChartArgsSchema, |
| 128 | + result: deleteWizardChartResultSchema, |
| 129 | + }, |
| 130 | + resolve: (api) => async (args) => { |
| 131 | + const {responseData} = await api.mix.__deleteWizardChart__(args); |
| 132 | + |
| 133 | + return responseData; |
| 134 | + }, |
| 135 | + openApi: { |
| 136 | + summary: 'Delete wizard chart', |
| 137 | + tags: [ApiTag.Wizard], |
| 138 | + }, |
| 139 | + }), |
| 140 | + |
| 141 | + // Editor |
| 142 | + deleteEditorChart: makeAction({ |
| 143 | + schemas: { |
| 144 | + args: deleteEditorChartArgsSchema, |
| 145 | + result: deleteEditorChartResultSchema, |
| 146 | + }, |
| 147 | + resolve: (api) => async (args) => { |
| 148 | + const {responseData} = await api.mix.__deleteEditorChart__(args); |
| 149 | + |
| 150 | + return responseData; |
| 151 | + }, |
| 152 | + openApi: { |
| 153 | + summary: 'Delete editor chart', |
| 154 | + tags: [ApiTag.Editor], |
| 155 | + }, |
| 156 | + }), |
| 157 | + |
| 158 | + // Dashboard |
| 159 | + getDashboard: makeAction({ |
| 160 | + schemas: { |
| 161 | + args: getDashArgsSchema, |
| 162 | + result: getDashResultSchema, |
| 163 | + }, |
| 164 | + resolve: (api) => async (args) => { |
| 165 | + const {responseData} = await api.mix.__getDashboard__(args); |
| 166 | + |
| 167 | + return responseData; |
| 168 | + }, |
| 169 | + openApi: { |
| 170 | + summary: 'Get dashboard', |
| 171 | + tags: [ApiTag.Dashboard], |
| 172 | + }, |
| 173 | + }), |
| 174 | + updateDashboard: makeAction({ |
| 175 | + schemas: { |
| 176 | + args: updateDashArgsSchema, |
| 177 | + result: updateDashResultSchema, |
| 178 | + }, |
| 179 | + resolve: (api) => async (args) => { |
| 180 | + const {responseData} = await api.mix.__updateDashboard__(args); |
| 181 | + |
| 182 | + return responseData; |
| 183 | + }, |
| 184 | + openApi: { |
| 185 | + summary: 'Update dashboard', |
| 186 | + tags: [ApiTag.Dashboard], |
| 187 | + }, |
| 188 | + }), |
| 189 | + createDashboard: makeAction({ |
| 190 | + schemas: { |
| 191 | + args: createDashArgsSchema, |
| 192 | + result: createDashResultSchema, |
| 193 | + }, |
| 194 | + resolve: (api) => async (args) => { |
| 195 | + const {responseData} = await api.mix.__createDashboard__(args); |
| 196 | + |
| 197 | + return responseData; |
| 198 | + }, |
| 199 | + openApi: { |
| 200 | + summary: 'Create dashboard', |
| 201 | + tags: [ApiTag.Dashboard], |
| 202 | + }, |
| 203 | + }), |
| 204 | + deleteDashboard: makeAction({ |
| 205 | + schemas: { |
| 206 | + args: deleteDashArgsSchema, |
| 207 | + result: deleteDashResultSchema, |
| 208 | + }, |
| 209 | + resolve: (api) => async (args) => { |
| 210 | + const {responseData} = await api.mix.__deleteDashboard__(args); |
| 211 | + |
| 212 | + return responseData; |
| 213 | + }, |
| 214 | + openApi: { |
| 215 | + summary: 'Delete dashboard', |
| 216 | + tags: [ApiTag.Dashboard], |
| 217 | + }, |
| 218 | + }), |
| 219 | + }, |
| 220 | +} satisfies PublicApiVersionConfig; |
0 commit comments