0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 08:40:03 +01:00
posthog/bin/build-schema-json.mjs
Michael Matloka d7d03b5985
feat(insights): HogQL calculation of saved legacy insights v4 (#21781)
* Revert "revert(insights): HogQL calculation of saved legacy insights v3 (#21778)"

This reverts commit c0be1d1412.

* Move HogQL in insight serialization to its own flag
2024-04-24 13:39:43 +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
}
})