Commit 0752d657 authored by Robert-K's avatar Robert-K
Browse files

Merge branch 'new_interface' of...

Merge branch 'new_interface' of https://git.scc.kit.edu/scc-net/net-suite/net-suite into new_interface
parents 9e2c3f28 8255e5a4
import json
import re
import requests
import os
......@@ -44,6 +45,9 @@ if not request.status_code == 200:
print("Is the NETDB_AUTH environment variable correct?")
exit(1)
func_index = request.json()[0]
data_types = {k['name']: k for k in sess.get(
"{scheme}://{base_host}{base_url}/cntl/data_type/list".format(scheme=API_SCHEME, base_host=API_HOST,
base_url=API_BASE_URL)).json()[0]}
for f in func_index:
fname = '{system}.{object_type}.js'.format(system=f['system'], object_type=f['object_type'])
f_handle = files.get(fname, None)
......@@ -65,28 +69,41 @@ export default {
params_dict_new = '{'
params_dict_old = '{'
for (p, v) in f['parameters'].items():
old_def_def = False
new_def_def = False
old_default = None
new_default = None
p_esc = p
for (unesc, esc) in keyword_replacements.items():
p_esc = p_esc.replace(unesc, esc)
if 'old' in v:
old_default = v['old']['dataDefault']
old_def_def = 'dataDefault' in v['old']
if old_def_def:
old_default = v['old']['dataDefault']
if 'new' in v:
new_default = v['new']['dataDefault']
if v['dataType']['jsonName'] == 'string':
new_def_def = 'dataDefault' in v['new']
if new_def_def:
new_default = v['new']['dataDefault']
v['dataType'] = data_types[v['dataType']]
if v['dataType']['json_name'] == 'string':
if old_default is not None:
old_default = '"{}"'.format(old_default)
if new_default is not None:
new_default = '"{}"'.format(new_default)
if 'old' in v:
if not f['is_data_manipulating'] and v['dataType']['jsonName'] == 'array':
if not f['is_data_manipulating'] and v['dataType']['json_name'] == 'array':
params_dict_old += '\'{p}\': ({p_esc}_old===null)?null:JSON.stringify({p}_old), '.format(p_esc=p, p=p)
else:
params_dict_old += '\'{p}\': {p_esc}_old, '.format(p=p, p_esc=p_esc)
params_str += '{p_esc}_old={d}, '.format(p_esc=p_esc, p=p, d=old_default)
if old_def_def:
params_str += '{p_esc}_old={d}, '.format(p_esc=p_esc, p=p, d=old_default)
else:
params_str += '{p_esc}_old, '.format(p_esc=p_esc, p=p)
if 'new' in v:
params_str += '{p}_new={d}, '.format(p=p, d=new_default)
if new_def_def:
params_str += '{p}_new={d}, '.format(p=p, d=new_default)
else:
params_str += '{p}_new, '.format(p=p)
params_dict_new += '\'{p}\': {p}_new, '.format(p=p)
params_dict_new += '}'
......@@ -134,40 +151,62 @@ for f in files.values():
f.close()
def setDef(tmp):
res = []
for r in tmp:
if 'schema' in r:
if not r['schema']['has_def']:
del (r['schema']['default'])
del (r['schema']['has_def'])
res.append(r)
else:
if not r['has_def']:
del (r['default'])
del (r['has_def'])
res.append(r)
return res
def generateParamters(f):
if not f['is_data_manipulating']:
return [
tmp = [
{
'name': p, 'description': d['description'],
'required': d['old']['isRequired'] if 'old' in d else d['new']['isRequired'],
'schema': {
'type': d['dataType']['jsonName'],
'default': d['old']['dataDefault'],
'type': d['dataType']['json_name'],
'nullable': d['old']['isNullable'],
'has_def': 'dataDefault' in d['old'],
'default': d['old'].get('dataDefault', None)
},
'in': 'query'
}
for p, d in f['parameters'].items()]
return setDef(tmp)
new_params = {
p: {
'type': d['dataType']['jsonName'],
'type': d['dataType']['json_name'],
'description': d['description'],
'required': d['new']['isRequired'],
'nullable': d['new']['isNullable'],
'default': d['new']['dataDefault']
'has_def': 'dataDefault' in d['new'],
'default': d['new'].get('dataDefault', None)
}
for p, d in f['parameters'].items() if 'new' in d
}
old_params = {
p: {
'type': d['dataType']['jsonName'],
'type': d['dataType']['json_name'],
'description': d['description'],
'required': d['old']['isRequired'],
'nullable': d['old']['isNullable'],
'default': d['old']['dataDefault']
'has_def': 'dataDefault' in d['old'],
'default': d['old'].get('dataDefault', None)
}
for p, d in f['parameters'].items() if 'old' in d
}
old_params = {k: setDef([v])[0] for k, v in old_params.items()}
new_params = {k: setDef([v])[0] for k, v in new_params.items()}
props = {}
if len(old_params) > 0:
props['old'] = {
......@@ -213,7 +252,7 @@ swagger['paths'] = {f"/{f['system']}/{f['object_type']}/{f['name']}":
'schema': {
'type': 'array',
'items': {
'$ref': '#/definitions/' + f['object_type']
'$ref': '#/definitions/' + f['system'] + '.' + f['object_type']
}
} if f['is_returning'] else None
},
......@@ -232,17 +271,27 @@ swagger['paths'] = {f"/{f['system']}/{f['object_type']}/{f['name']}":
def renderDataType(d):
dat = {'type': d['dataType']['jsonName'],
'description': d['description']
dat = {'type': d['dataType']['json_name'],
'description': d['description'],
}
if d['dataType']['apiName'] == 'text_array':
if d['dataType']['format_literal'] is not None and d['dataType']['json_name'] == 'string':
dat['format'] = d['dataType']['format_literal']
if d['dataType']['name'] == 'text_array':
dat['items'] = {
'type': 'string'
}
if re.match(r'^integer.*_array$', d['dataType']['name']) is not None:
dat['items'] = {
'type': 'integer'
}
return dat
swagger['definitions'] = {o['name']:
for o in objects:
for a,d in o['attributes'].items():
d['dataType'] = data_types[d['dataType']]
swagger['definitions'] = {o['fq_name']:
{
'type': 'object',
'description': o['description'],
......
......@@ -7017,6 +7017,12 @@
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
"dev": true
},
"infer-owner": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz",
"integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
......@@ -8605,9 +8611,9 @@
"dev": true
},
"npm": {
"version": "6.13.2",
"resolved": "https://registry.npmjs.org/npm/-/npm-6.13.2.tgz",
"integrity": "sha512-TG7AFkKpjBNJh8OVJYcGaAbW0PZxEkjew51Lc6TRdhQpNjSSEnAOEpidApqEuciB7cs09C8mxbo8NbuPs4QDzg==",
"version": "6.13.4",
"resolved": "https://registry.npmjs.org/npm/-/npm-6.13.4.tgz",
"integrity": "sha512-vTcUL4SCg3AzwInWTbqg1OIaOXlzKSS8Mb8kc5avwrJpcvevDA5J9BhYSuei+fNs3pwOp4lzA5x2FVDXACvoXA==",
"requires": {
"JSONStream": "^1.3.5",
"abbrev": "~1.1.1",
......@@ -8615,7 +8621,7 @@
"ansistyles": "~0.1.3",
"aproba": "^2.0.0",
"archy": "~1.0.0",
"bin-links": "^1.1.3",
"bin-links": "^1.1.6",
"bluebird": "^3.5.5",
"byte-size": "^5.0.1",
"cacache": "^12.0.3",
......@@ -8636,7 +8642,7 @@
"find-npm-prefix": "^1.0.2",
"fs-vacuum": "~1.2.10",
"fs-write-stream-atomic": "~1.0.10",
"gentle-fs": "^2.2.1",
"gentle-fs": "^2.3.0",
"glob": "^7.1.4",
"graceful-fs": "^4.2.3",
"has-unicode": "~2.0.1",
......@@ -8685,7 +8691,7 @@
"npm-install-checks": "^3.0.2",
"npm-lifecycle": "^3.1.4",
"npm-package-arg": "^6.1.1",
"npm-packlist": "^1.4.6",
"npm-packlist": "^1.4.7",
"npm-pick-manifest": "^3.0.2",
"npm-profile": "^4.0.2",
"npm-registry-fetch": "^4.0.2",
......@@ -8694,7 +8700,7 @@
"once": "~1.4.0",
"opener": "^1.5.1",
"osenv": "^0.1.5",
"pacote": "^9.5.9",
"pacote": "^9.5.11",
"path-is-inside": "~1.0.2",
"promise-inflight": "~1.0.1",
"qrcode-terminal": "^0.12.0",
......@@ -8703,7 +8709,7 @@
"read": "~1.0.7",
"read-cmd-shim": "^1.0.5",
"read-installed": "~4.0.3",
"read-package-json": "^2.1.0",
"read-package-json": "^2.1.1",
"read-package-tree": "^5.3.1",
"readable-stream": "^3.4.0",
"readdir-scoped-modules": "^1.1.0",
......@@ -8874,13 +8880,14 @@
}
},
"bin-links": {
"version": "1.1.3",
"version": "1.1.6",
"bundled": true,
"requires": {
"bluebird": "^3.5.3",
"cmd-shim": "^3.0.0",
"gentle-fs": "^2.0.1",
"gentle-fs": "^2.3.0",
"graceful-fs": "^4.1.15",
"npm-normalize-package-bin": "^1.0.0",
"write-file-atomic": "^2.3.0"
}
},
......@@ -9629,11 +9636,12 @@
"bundled": true
},
"gentle-fs": {
"version": "2.2.1",
"version": "2.3.0",
"bundled": true,
"requires": {
"aproba": "^1.1.2",
"chownr": "^1.1.2",
"cmd-shim": "^3.0.3",
"fs-vacuum": "^1.2.10",
"graceful-fs": "^4.1.11",
"iferr": "^0.1.5",
......@@ -10478,8 +10486,11 @@
}
},
"npm-bundled": {
"version": "1.0.6",
"bundled": true
"version": "1.1.1",
"bundled": true,
"requires": {
"npm-normalize-package-bin": "^1.0.1"
}
},
"npm-cache-filename": {
"version": "1.0.2",
......@@ -10510,6 +10521,10 @@
"version": "1.2.1",
"bundled": true
},
"npm-normalize-package-bin": {
"version": "1.0.1",
"bundled": true
},
"npm-package-arg": {
"version": "6.1.1",
"bundled": true,
......@@ -10521,7 +10536,7 @@
}
},
"npm-packlist": {
"version": "1.4.6",
"version": "1.4.7",
"bundled": true,
"requires": {
"ignore-walk": "^3.0.1",
......@@ -10679,7 +10694,7 @@
}
},
"pacote": {
"version": "9.5.9",
"version": "9.5.11",
"bundled": true,
"requires": {
"bluebird": "^3.5.3",
......@@ -10696,6 +10711,7 @@
"mississippi": "^3.0.0",
"mkdirp": "^0.5.1",
"normalize-package-data": "^2.4.0",
"npm-normalize-package-bin": "^1.0.0",
"npm-package-arg": "^6.1.0",
"npm-packlist": "^1.1.12",
"npm-pick-manifest": "^3.0.0",
......@@ -10934,14 +10950,14 @@
}
},
"read-package-json": {
"version": "2.1.0",
"version": "2.1.1",
"bundled": true,
"requires": {
"glob": "^7.1.1",
"graceful-fs": "^4.1.2",
"json-parse-better-errors": "^1.0.1",
"normalize-package-data": "^2.0.0",
"slash": "^1.0.0"
"npm-normalize-package-bin": "^1.0.0"
}
},
"read-package-tree": {
......@@ -11094,10 +11110,6 @@
"version": "3.0.2",
"bundled": true
},
"slash": {
"version": "1.0.0",
"bundled": true
},
"slide": {
"version": "1.1.6",
"bundled": true
......@@ -14718,70 +14730,58 @@
"inherits": "2"
}
},
"terser": {
"version": "3.17.0",
"resolved": "https://registry.npmjs.org/terser/-/terser-3.17.0.tgz",
"integrity": "sha512-/FQzzPJmCpjAH9Xvk2paiWrFq+5M6aVOf+2KRbwhByISDX/EujxsK+BAvrhb6H+2rtrLCHK9N01wO014vrIwVQ==",
"dev": true,
"requires": {
"commander": "^2.19.0",
"source-map": "~0.6.1",
"source-map-support": "~0.5.10"
},
"dependencies": {
"commander": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
},
"terser-webpack-plugin": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.2.4.tgz",
"integrity": "sha512-64IiILNQlACWZLzFlpzNaG0bpQ4ytaB7fwOsbpsdIV70AfLUmIGGeuKL0YV2WmtcrURjE2aOvHD4/lrFV3Rg+Q==",
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz",
"integrity": "sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA==",
"dev": true,
"requires": {
"cacache": "^11.3.2",
"find-cache-dir": "^2.0.0",
"cacache": "^12.0.2",
"find-cache-dir": "^2.1.0",
"is-wsl": "^1.1.0",
"schema-utils": "^1.0.0",
"serialize-javascript": "^1.7.0",
"serialize-javascript": "^2.1.2",
"source-map": "^0.6.1",
"terser": "^3.17.0",
"webpack-sources": "^1.3.0",
"terser": "^4.1.2",
"webpack-sources": "^1.4.0",
"worker-farm": "^1.7.0"
},
"dependencies": {
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==",
"dev": true
},
"cacache": {
"version": "11.3.2",
"resolved": "https://registry.npmjs.org/cacache/-/cacache-11.3.2.tgz",
"integrity": "sha512-E0zP4EPGDOaT2chM08Als91eYnf8Z+eH1awwwVsngUmgppfM5jjJ8l3z5vO5p5w/I3LsiXawb1sW0VY65pQABg==",
"version": "12.0.3",
"resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.3.tgz",
"integrity": "sha512-kqdmfXEGFepesTuROHMs3MpFLWrPkSSpRqOw80RCflZXy/khxaArvFrQ7uJxSUduzAufc6G0g1VUCOZXxWavPw==",
"dev": true,
"requires": {
"bluebird": "^3.5.3",
"bluebird": "^3.5.5",
"chownr": "^1.1.1",
"figgy-pudding": "^3.5.1",
"glob": "^7.1.3",
"glob": "^7.1.4",
"graceful-fs": "^4.1.15",
"infer-owner": "^1.0.3",
"lru-cache": "^5.1.1",
"mississippi": "^3.0.0",
"mkdirp": "^0.5.1",
"move-concurrently": "^1.0.1",
"promise-inflight": "^1.0.1",
"rimraf": "^2.6.2",
"rimraf": "^2.6.3",
"ssri": "^6.0.1",
"unique-filename": "^1.1.1",
"y18n": "^4.0.0"
}
},
"commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true
},
"find-cache-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz",
......@@ -14802,6 +14802,20 @@
"locate-path": "^3.0.0"
}
},
"glob": {
"version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"locate-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
......@@ -14841,9 +14855,9 @@
}
},
"p-limit": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz",
"integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz",
"integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==",
"dev": true,
"requires": {
"p-try": "^2.0.0"
......@@ -14879,11 +14893,38 @@
"find-up": "^3.0.0"
}
},
"serialize-javascript": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz",
"integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==",
"dev": true
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"terser": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-4.4.2.tgz",
"integrity": "sha512-Uufrsvhj9O1ikwgITGsZ5EZS6qPokUOkCegS7fYOdGTv+OA90vndUbU6PEjr5ePqHfNUbGyMO7xyIZv2MhsALQ==",
"dev": true,
"requires": {
"commander": "^2.20.0",
"source-map": "~0.6.1",
"source-map-support": "~0.5.12"
}
},
"webpack-sources": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz",
"integrity": "sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==",
"dev": true,
"requires": {
"source-list-map": "^2.0.0",
"source-map": "~0.6.1"
}
}
}
},
......
......@@ -19,7 +19,7 @@
"http-proxy-middleware": "^0.19.1",
"i": "^0.3.6",
"node-sass": "^4.11.0",
"npm": "^6.13.2",
"npm": "^6.13.4",
"popper.js": "^1.14.7",
"sass-loader": "^7.1.0",
"swagger-ui": "^3.24.3",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment