0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-21 21:49:51 +01:00
posthog/bin/build-schema-json.mjs
Michael Matloka 3ffa9acd75
fix(insights): HogQL calculation of saved legacy insights v3 (#21720)
* Revert "revert(insights): HogQL calculation of saved legacy insights v2 (#21718)"

This reverts commit 2f019a39ec.

* Fix `CACHE_ONLY` in place of `CALCULATION_ONLY_IF_STALE`

* Make `ExecutionMode` naming unmistakable

* Reset UI snapshots

* Account for #21707's `apply_dashboard_filters` change

* Make `QueryRunner` generic
2024-04-23 16:50:56 +02:00

29 lines
911 B
JavaScript

#!/usr/bin/env node
// replaces ts-json-schema-generator -f tsconfig.json --path 'frontend/src/queries/schema.ts' --no-type-check > frontend/src/queries/schema.json
import fs from 'fs'
import stableStringify from 'safe-stable-stringify'
import tsj from 'ts-json-schema-generator'
/** @type {import('ts-json-schema-generator/dist/src/Config').Config} */
const config = {
...tsj.DEFAULT_CONFIG,
path: 'frontend/src/queries/schema.ts',
tsconfig: 'tsconfig.json',
discriminatorType: 'open-api',
skipTypeCheck: true,
}
const output_path = 'frontend/src/queries/schema.json'
const schema = tsj.createGenerator(config).createSchema(config.type)
const stringify = config.sortProps ? stableStringify : JSON.stringify
const schemaString = config.minify ? stringify(schema) : stringify(schema, null, 2)
fs.writeFile(output_path, schemaString, (err) => {
if (err) {
throw err
}
})