mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) move data engine code to core
Summary: this moves sandbox/grist to core, and adds a requirements.txt file for reconstructing the content of sandbox/thirdparty. Test Plan: existing tests pass. Tested core functionality manually. Tested docker build manually. Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2563
This commit is contained in:
52
sandbox/gen_js_schema.py
Normal file
52
sandbox/gen_js_schema.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python -B
|
||||
"""
|
||||
Generates a JS schema file from sandbox/grist/schema.py.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), 'grist'))
|
||||
|
||||
import schema # pylint: disable=import-error,wrong-import-position
|
||||
|
||||
# These are the types that appear in Grist metadata columns.
|
||||
_ts_types = {
|
||||
"Bool": "boolean",
|
||||
"DateTime": "number",
|
||||
"Int": "number",
|
||||
"PositionNumber": "number",
|
||||
"Ref": "number",
|
||||
"Text": "string",
|
||||
}
|
||||
|
||||
def get_ts_type(col_type):
|
||||
col_type = col_type.split(':', 1)[0] # Strip suffix for Ref:, DateTime:, etc.
|
||||
return _ts_types.get(col_type, "CellValue")
|
||||
|
||||
def main():
|
||||
print """
|
||||
/*** THIS FILE IS AUTO-GENERATED BY %s ***/
|
||||
// tslint:disable:object-literal-key-quotes
|
||||
|
||||
export const schema = {
|
||||
""" % __file__
|
||||
|
||||
for table in schema.schema_create_actions():
|
||||
print ' "%s": {' % table.table_id
|
||||
for column in table.columns:
|
||||
print ' %-20s: "%s",' % (column['id'], column['type'])
|
||||
print ' },\n'
|
||||
|
||||
print """};
|
||||
|
||||
export interface SchemaTypes {
|
||||
"""
|
||||
for table in schema.schema_create_actions():
|
||||
print ' "%s": {' % table.table_id
|
||||
for column in table.columns:
|
||||
print ' %s: %s;' % (column['id'], get_ts_type(column['type']))
|
||||
print ' };\n'
|
||||
print "}"
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user