From db8d942eaff54f1e11c4d6d18bbed55d99cd811d Mon Sep 17 00:00:00 2001 From: "xiaozhe.ma" Date: Fri, 13 Sep 2024 14:29:38 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=87=E3=83=97=E3=83=AD=E3=82=A4=E9=9A=9B?= =?UTF-8?q?=E3=80=81=E3=81=93=E3=81=AE=E3=82=A2=E3=83=97=E3=83=AA=E3=81=A7?= =?UTF-8?q?=E7=94=9F=E6=88=90=E3=81=97=E3=81=9FJavaScript=E3=81=8A?= =?UTF-8?q?=E3=82=88=E3=81=B3CSS=E4=BB=A5=E5=A4=96=E3=81=AE=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=8C=E5=89=8A=E9=99=A4=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/api_v1/routers/kintone.py | 48 ++++++++++++++++--- .../src/types/action-process.ts | 2 +- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/backend/app/api/api_v1/routers/kintone.py b/backend/app/api/api_v1/routers/kintone.py index d10885d..40ccac4 100644 --- a/backend/app/api/api_v1/routers/kintone.py +++ b/backend/app/api/api_v1/routers/kintone.py @@ -381,23 +381,49 @@ def uploadkintonefiles(file,c:config.KINTONE_ENV): headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE} data ={'name':'file','filename':os.path.basename(file)} url = f"{c.BASE_URL}/k/v1/file.json" - r = httpx.post(url,headers=headers,data=data,files=upload_files) + r = httpx.post(url,headers=headers,data=data,files=upload_files) + #{"name":data['filename'],'fileKey':r['fileKey']} return r.json() def updateappjscss(app,uploads,c:config.KINTONE_ENV): dsjs = [] dscss = [] + #mobile側 + mbjs = [] + mbcss = [] + customize = getappcustomize(app, c) + current_js = customize['desktop'].get('js', []) + current_css = customize['desktop'].get('css', []) + current_mobile_js = customize['mobile'].get('js', []) + current_mobile_css = customize['mobile'].get('css', []) + current_js = [item for item in current_js if not (item.get('type') == 'URL' and item.get('url', '').endswith('alc_runtime.js'))] + for upload in uploads: for key in upload: + filename = os.path.basename(key) if key.endswith('.js'): - if (key.endswith('alc_runtime.js') and config.DEPLOY_MODE == "DEV"): - dsjs.append({'type':'URL','url':config.DEPLOY_JS_URL}) + existing_js = next((item for item in current_js if item['file']['name'] == filename), None) + if existing_js: + existing_js['file']['fileKey'] = upload[key] else: - dsjs.append({'type':'FILE','file':{'fileKey':upload[key]}}) + if (key.endswith('alc_runtime.js') and config.DEPLOY_MODE == "DEV"): + dsjs.append({'type':'URL','url':config.DEPLOY_JS_URL}) + else: + dsjs.append({'type':'FILE','file':{'fileKey':upload[key]}}) elif key.endswith('.css'): - dscss.append({'type':'FILE','file':{'fileKey':upload[key]}}) + existing_css = next((item for item in current_css if item['file']['name'] == key), None) + if existing_css: + existing_css['file']['fileKey'] = upload[key] + else: + dscss.append({'type': 'FILE', 'file': {'fileKey': upload[key]}}) + #現在のJSとCSSがdsjsに追加する + dsjs.extend(current_js) + dscss.extend(current_css) + mbjs.extend(current_mobile_js) + mbcss.extend(current_mobile_css) + ds ={'js':dsjs,'css':dscss} - mb ={'js':[],'css':[]} + mb ={'js':mbjs,'css':mbcss} data = {'app':app,'scope':'ALL','desktop':ds,'mobile':mb} headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE,"Content-Type": "application/json"} url = f"{c.BASE_URL}{config.API_V1_STR}/preview/app/customize.json" @@ -405,6 +431,15 @@ def updateappjscss(app,uploads,c:config.KINTONE_ENV): r = httpx.put(url,headers=headers,data=json.dumps(data)) return r.json() +#kintone カスタマイズ情報 +def getappcustomize(app,c:config.KINTONE_ENV): + headers={config.API_V1_AUTH_KEY:c.API_V1_AUTH_VALUE} + url = f"{c.BASE_URL}{config.API_V1_STR}/app/customize.json" + params = {"app":app} + r = httpx.get(url,headers=headers,params=params) + return r.json() + + def getTempPath(filename): scriptdir = Path(__file__).resolve().parent rootdir = scriptdir.parent.parent.parent.parent @@ -727,6 +762,7 @@ async def createjstokintone(request:Request,app:str,env:config.KINTONE_ENV = Dep for file in files: upload = uploadkintonefiles(file,env) if upload.get('fileKey') != None: + print(upload) jscs.append({ file :upload['fileKey']}) appjscs = updateappjscss(app,jscs,env) if appjscs.get("revision") != None: diff --git a/plugin/kintone-addins/src/types/action-process.ts b/plugin/kintone-addins/src/types/action-process.ts index 4ac88b8..acc6a40 100644 --- a/plugin/kintone-addins/src/types/action-process.ts +++ b/plugin/kintone-addins/src/types/action-process.ts @@ -66,7 +66,7 @@ export class ActionProcess{ result = await action.process(nextAction,this.event,this.context); } let nextInput = ''; - //outputPoints一㝤以上㝮場坈〝次㝮InputPoint㝯戻り値を設定㝙る + //outputPoints一つ以上の場合、次のInputPointは戻り値を設定する if(nextAction.outputPoints && nextAction.outputPoints.length>1){ nextInput = result.result||''; }