diff --git a/core/apirequest/__pycache__/execute.cpython-314.pyc b/core/apirequest/__pycache__/execute.cpython-314.pyc index 0765061..8ce0bd0 100644 Binary files a/core/apirequest/__pycache__/execute.cpython-314.pyc and b/core/apirequest/__pycache__/execute.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/key.cpython-314.pyc b/core/apirequest/__pycache__/key.cpython-314.pyc index b7c97d2..e234161 100644 Binary files a/core/apirequest/__pycache__/key.cpython-314.pyc and b/core/apirequest/__pycache__/key.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/object.cpython-314.pyc b/core/apirequest/__pycache__/object.cpython-314.pyc index 1dcc55d..8718eeb 100644 Binary files a/core/apirequest/__pycache__/object.cpython-314.pyc and b/core/apirequest/__pycache__/object.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/path.cpython-314.pyc b/core/apirequest/__pycache__/path.cpython-314.pyc index 922a492..3414a2d 100644 Binary files a/core/apirequest/__pycache__/path.cpython-314.pyc and b/core/apirequest/__pycache__/path.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/request.cpython-314.pyc b/core/apirequest/__pycache__/request.cpython-314.pyc index b34ea5d..ade297c 100644 Binary files a/core/apirequest/__pycache__/request.cpython-314.pyc and b/core/apirequest/__pycache__/request.cpython-314.pyc differ diff --git a/core/apirequest/execute.py b/core/apirequest/execute.py index 5bf6d96..539b024 100644 --- a/core/apirequest/execute.py +++ b/core/apirequest/execute.py @@ -4,8 +4,8 @@ from .request import buildRequest session = requests.Session() -def executeRequest(action, outputs): - request, outputs = buildRequest(action, outputs) +def executeRequest(action, outputs, resolved): + request, outputs = buildRequest(action, outputs, resolved) response = session.request( method=request["method"], diff --git a/core/apirequest/key.py b/core/apirequest/key.py index ac076a4..0f87297 100644 --- a/core/apirequest/key.py +++ b/core/apirequest/key.py @@ -1,4 +1,4 @@ -def buildKey(key, outputs): +def buildKey(key, outputs, resolved): value = key["keyvalue"] if isinstance(value, dict) and "output" in value: diff --git a/core/apirequest/object.py b/core/apirequest/object.py index 79a1eb3..ff5596a 100644 --- a/core/apirequest/object.py +++ b/core/apirequest/object.py @@ -1,11 +1,11 @@ from .key import buildKey -def buildObject(keys, outputs): +def buildObject(keys, outputs, resolved): object = {} for key in keys: object.update( - buildKey(key, outputs), + buildKey(key, outputs, resolved), ) return object diff --git a/core/apirequest/path.py b/core/apirequest/path.py index 5ae2e57..a2bea18 100644 --- a/core/apirequest/path.py +++ b/core/apirequest/path.py @@ -1,4 +1,4 @@ -def buildPath(path, outputs): +def buildPath(path, outputs, resolved): if isinstance(path, str): return path @@ -6,9 +6,10 @@ def buildPath(path, outputs): for part in path: if isinstance(part, dict): - value = outputs[part["output"]][part["keys"]] - - + for key, val in part.items(): + #value = outputs[part["output"]][part["keys"]] + value = outputs[val] + #print("DEBUG path", value) #for key in part.get("keys", []): #value = value[key] @@ -16,5 +17,26 @@ def buildPath(path, outputs): result += str(value) else: result += part + #print(result) + return result +def buildPath2(path, outputs, resolved): + if isinstance(path, str): + return path + + result = "" + + for part in path: + if isinstance(part, dict): + #value = outputs[part["output"]][part["keys"]] + value = outputs["path"] + #print("DEBUG path", value) + + #for key in part.get("keys", []): + #value = value[key] + + result += str(value) + else: + result += part + #print(result) return result diff --git a/core/apirequest/request.py b/core/apirequest/request.py index 7d1b726..5a42481 100644 --- a/core/apirequest/request.py +++ b/core/apirequest/request.py @@ -1,8 +1,8 @@ from .object import buildObject from .path import buildPath -def buildRequest(definition, outputs): - path = buildPath(definition.path, outputs) +def buildRequest(definition, outputs, resolved): + path = buildPath(definition.path, outputs, resolved) request = { "method": definition.method, @@ -10,7 +10,7 @@ def buildRequest(definition, outputs): } if hasattr(definition, "keys"): - request["object"] = buildObject(definition.keys, outputs) + request["object"] = buildObject(definition.keys, outputs, resolved) if hasattr(definition, "headers"): headers = {} diff --git a/core/execution/action/__pycache__/action.cpython-314.pyc b/core/execution/action/__pycache__/action.cpython-314.pyc index fe04f20..da2779a 100644 Binary files a/core/execution/action/__pycache__/action.cpython-314.pyc and b/core/execution/action/__pycache__/action.cpython-314.pyc differ diff --git a/core/execution/action/action.py b/core/execution/action/action.py index c732f12..f9945f2 100644 --- a/core/execution/action/action.py +++ b/core/execution/action/action.py @@ -3,16 +3,23 @@ from core.runtime.savedata import loadSave, buildSave from core.runtime.outputs import buildOutput from core.runtime.logs import buildLog from core.runtime.runtimecontract import buildRuntimeAttr +from core.runtime.resolver import resolveItem -def buildAction (action, outputs): - +#resolved ={} +def buildAction (action, outputs):#, resolved): + if hasattr(action, "loaddata"): outputs = loadSave(outputs, action) - response, outputs = executeRequest(action, outputs) + resolved = {} + if hasattr(action, "resolve"): + resolved = resolveItem(action, outputs) + + response, outputs = executeRequest(action, outputs, resolved) #print("DEBUG:", outputs) - + #print(resolved) + outputs, response = buildRuntimeAttr(action, outputs, response) return outputs, response diff --git a/core/execution/operation/__pycache__/operation.cpython-314.pyc b/core/execution/operation/__pycache__/operation.cpython-314.pyc index ef6c10b..c100674 100644 Binary files a/core/execution/operation/__pycache__/operation.cpython-314.pyc and b/core/execution/operation/__pycache__/operation.cpython-314.pyc differ diff --git a/core/execution/operation/operation.py b/core/execution/operation/operation.py index de8cc03..f30e270 100644 --- a/core/execution/operation/operation.py +++ b/core/execution/operation/operation.py @@ -6,32 +6,39 @@ from core.runtime.outputs import buildOutput from core.runtime.managefailure import manageFailure from core.execution.action.action import buildAction from .skipstep import skipStep -from core.runtime.resolver import resolveItem +from core.runtime.resolver import resolveItem2 +from core.apirequest import executeRequest def buildOperation(definition): actions = definition.actions #print("DEBUG", actions) responses = [] outputs = {} + #resolved = {} for action in actions: #try: if hasattr(definition, "skipstep"): if skipStep(definition, action, outputs): continue - + #if hasattr(definition, "resolve"): + #resolved = {} + #if hasattr(action, "resolve"): + #print(outputs) + #resolved = resolveItem(action, outputs) + #print(resolved) if hasattr(action, "recursive"): - outputs[action.recursive["target"]] = {} + #outputs[action.recursive["target"]] = {} for item in outputs[action.recursive["source"]]: - resolved = resolveItem(action, item) - print("Resolved value:", resolved) + outputs = resolveItem2(action, item, outputs)#, resolved) + #print("Resolved value:", outputs) #outputs[action.recursive["target"]] = outputs[action.recursive["source"]][][action.recursive["target"]] #print(outputs[action.recursive["target"]]) outputs[action.recursive["target"]] = item - print(outputs[action.recursive["target"]]) + #print(outputs[action.recursive["target"]]) #target = outputs[action.recursive["source"]["target"] - outputs, response = buildAction(action, outputs) - #print(item) + outputs, response = buildAction(action, outputs)#, resolved) + #print(outputs) #return outputs else: outputs, response = buildAction(action, outputs) @@ -39,5 +46,5 @@ def buildOperation(definition): #except Exception as error: #outputs = manageFailure(error, action, outputs) - print(outputs["message"]) + #print(outputs["message"]) return outputs diff --git a/core/runtime/__pycache__/resolver.cpython-314.pyc b/core/runtime/__pycache__/resolver.cpython-314.pyc index 6905c15..aff3d6f 100644 Binary files a/core/runtime/__pycache__/resolver.cpython-314.pyc and b/core/runtime/__pycache__/resolver.cpython-314.pyc differ diff --git a/core/runtime/__pycache__/select.cpython-314.pyc b/core/runtime/__pycache__/select.cpython-314.pyc index 883c62c..5d8d806 100644 Binary files a/core/runtime/__pycache__/select.cpython-314.pyc and b/core/runtime/__pycache__/select.cpython-314.pyc differ diff --git a/core/runtime/resolver.py b/core/runtime/resolver.py index a5cf46a..94d1bca 100644 --- a/core/runtime/resolver.py +++ b/core/runtime/resolver.py @@ -2,8 +2,9 @@ def resolveItem(action, item): resolved = {} label = action.resolve["label"] targetkeys = action.resolve["targetkeys"] - + #print(item) target = item + for key in targetkeys: target = target[key] @@ -20,3 +21,29 @@ def resolveItem(action, item): #print(resolved[label]) return resolved + +def resolveItem2(action, item, outputs): + #resolved = {} + label = action.resolve["label"] + targetkeys = action.resolve["targetkeys"] + #print(item) + target = item + + for key in targetkeys: + target = target[key] + + #resolved[label] = target + + #for label, keys in action.resolve.items(): + #target = item + + #print(target) + #for key in keys: + #target = target[key] + + #resolved[label] = target + #print(resolved[label]) + + outputs[label] = target + #print("Resolver DEBUG", target, outputs[label]) + return outputs diff --git a/core/runtime/select.py b/core/runtime/select.py index 10352bc..10c6bf3 100644 --- a/core/runtime/select.py +++ b/core/runtime/select.py @@ -66,8 +66,41 @@ def buildSelect2(action, outputs): #select_data.append(item) def buildSelect3(action, outputs): + #print(outputs) + try: + select_data = [] + + target = outputs[action.select["source"]] + includekey = action.select["include"]["key"] + includevalue = action.select["include"]["value"] + excludekey = action.select["exclude"]["key"] + excludevalue = action.select["exclude"]["value"] + + + for item in target: + include_match = True + exclude_match = True + + if includekey: + include_match = item[includekey] == includevalue + + if excludekey: + exclude_match = item[excludekey] != excludevalue + + if include_match and exclude_match: + select_data.append(item) + + + outputs[action.select["source"]] = select_data + print(select_data) + return select_data, action, outputs + except (KeyError, TypeError): + return select_data, action, outputs + +def buildSelect4(action, outputs): #print(outputs) select_data = [] + target = outputs[action.select["source"]] #selectmethod = action.select["selectmethod"] includekey = action.select["include"]["key"] diff --git a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc index 17eda7e..913f751 100644 Binary files a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc differ diff --git a/plugins/rmass/actions/getmessage.py b/plugins/rmass/actions/getmessage.py index 57db081..b60802b 100644 --- a/plugins/rmass/actions/getmessage.py +++ b/plugins/rmass/actions/getmessage.py @@ -1,6 +1,5 @@ import os -#getoutputs = {"emails": [0, "id"]} name = "Get message" @@ -12,12 +11,6 @@ showstatus = True method = "GET" -#path = f"https://rentmasseur.com/api/v1/mailbox/{messageid}" -#path = [ -# "https://rentmasseur.com/api/v1/mailbox/", -# {"output": "[messageid][0].id"} -#] - resolve = { "targetkeys": ["id"], "label": "path", @@ -25,11 +18,12 @@ resolve = { path = [ "https://rentmasseur.com/api/v1/mailbox/", - { - "output": "id", - #"keys": [0, "id"] - "keys": "id" - } + {"suffix": "path"} + #{ + # "output": "id", + # #"keys": [0, "id"] + # "keys": "id" + #} ] #path = os.path.join(baseurl.messageid) @@ -43,12 +37,14 @@ headers = { recursive = { "source": "emails", + #Transformation target. dynamic target to be resolved in each iteration "target": "id" } outputs = { - "message": "messages" + "message": "messages", + "profile": "profileData", } select = { diff --git a/pullmessagelist.py b/pullmessagelist.py index 08fb56f..3049ae7 100644 --- a/pullmessagelist.py +++ b/pullmessagelist.py @@ -6,33 +6,3 @@ from core.execution.action import buildAction outputs = buildOperation(rmass.operations.pullmessagelist) -#print(outputs) -#print(messageid) -#user_list = [] -#for item in outputs["message_list"]: -# sender = item["userCard"] -# user_list.append(sender["id"]) -#print(user_list) - -#conversations = [] -#for item in outputs["message_list"]: -# conversation = item["id"] -# conversations.append(conversation) - -#print(conversations) - -#for messageid in conversations: -#outputs = buildAction(rmass.actions.getmessage, outputs) - -#print(outputs) - - -#for messageid in user_list - #outputs = buildOperation(rmass.operations.getmessage) -#id_list = [] -#for user in user_list -# id_list.append -# print - - -#ime.sleep(rmass.operations.setavailable.sleeptime) diff --git a/tokens.json b/tokens.json index a18a94f..0762e38 100644 --- a/tokens.json +++ b/tokens.json @@ -1 +1 @@ -{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE5MDM5MDEsIm5iZiI6MTc5MTkwMzcyMSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTkwMzc4MX0.dwJ10VfIyUSANbKlG0UqzoRqWfZpU0vdU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RVb0xZVkd3ZG9NQkRYY1ZnV0pzdz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTkxODA4MSwic3ViIjoiMjM4MzAyIn0.oWa2PwSyh110MOJ8ypsRCtiXNQWosNv4T_UZ9m0shUjsFTX0Qtr-bSnc7mS8-5TSW-szEnLHT89-T8KzNZApYg"} \ No newline at end of file