jaseci 1.4.2.5__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jaseci might be problematic. Click here for more details.
- jaseci/__init__.py +3 -37
- jaseci-2.0.0.dist-info/METADATA +65 -0
- jaseci-2.0.0.dist-info/RECORD +4 -0
- {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
- jaseci/VERSION +0 -1
- jaseci/cli_tools/__init__.py +0 -0
- jaseci/cli_tools/book_tools.py +0 -457
- jaseci/cli_tools/jsctl.py +0 -500
- jaseci/cli_tools/tests/__init__.py +0 -0
- jaseci/cli_tools/tests/test_jsctl.py +0 -556
- jaseci/extens/__init__.py +0 -0
- jaseci/extens/act_lib/__init__.py +0 -0
- jaseci/extens/act_lib/date.py +0 -117
- jaseci/extens/act_lib/elastic.py +0 -87
- jaseci/extens/act_lib/file.py +0 -76
- jaseci/extens/act_lib/file_handler.py +0 -189
- jaseci/extens/act_lib/internal.py +0 -18
- jaseci/extens/act_lib/jaseci.py +0 -61
- jaseci/extens/act_lib/mail.py +0 -10
- jaseci/extens/act_lib/maths.py +0 -168
- jaseci/extens/act_lib/net.py +0 -191
- jaseci/extens/act_lib/rand.py +0 -82
- jaseci/extens/act_lib/regex.py +0 -85
- jaseci/extens/act_lib/request.py +0 -169
- jaseci/extens/act_lib/std.py +0 -235
- jaseci/extens/act_lib/storage.py +0 -53
- jaseci/extens/act_lib/stripe.py +0 -337
- jaseci/extens/act_lib/task.py +0 -13
- jaseci/extens/act_lib/tests/__init__.py +0 -0
- jaseci/extens/act_lib/tests/std_test_code.py +0 -37
- jaseci/extens/act_lib/tests/test_date.py +0 -26
- jaseci/extens/act_lib/tests/test_elastic.py +0 -159
- jaseci/extens/act_lib/tests/test_file.py +0 -116
- jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
- jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
- jaseci/extens/act_lib/tests/test_maths.py +0 -147
- jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
- jaseci/extens/act_lib/tests/test_regex.py +0 -61
- jaseci/extens/act_lib/tests/test_std.py +0 -51
- jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
- jaseci/extens/act_lib/tests/test_url.py +0 -32
- jaseci/extens/act_lib/tests/test_vector.py +0 -36
- jaseci/extens/act_lib/tests/test_webtool.py +0 -44
- jaseci/extens/act_lib/tests/test_zlib.py +0 -24
- jaseci/extens/act_lib/url.py +0 -79
- jaseci/extens/act_lib/vector.py +0 -157
- jaseci/extens/act_lib/webtool.py +0 -28
- jaseci/extens/act_lib/zip.py +0 -33
- jaseci/extens/api/__init__.py +0 -0
- jaseci/extens/api/actions_api.py +0 -170
- jaseci/extens/api/alias_api.py +0 -139
- jaseci/extens/api/architype_api.py +0 -196
- jaseci/extens/api/config_api.py +0 -129
- jaseci/extens/api/global_api.py +0 -84
- jaseci/extens/api/graph_api.py +0 -167
- jaseci/extens/api/health_api.py +0 -20
- jaseci/extens/api/interface.py +0 -268
- jaseci/extens/api/jac_api.py +0 -171
- jaseci/extens/api/jsorc_api.py +0 -316
- jaseci/extens/api/logger_api.py +0 -89
- jaseci/extens/api/master_api.py +0 -133
- jaseci/extens/api/object_api.py +0 -101
- jaseci/extens/api/prometheus_api.py +0 -74
- jaseci/extens/api/queue_api.py +0 -140
- jaseci/extens/api/sentinel_api.py +0 -270
- jaseci/extens/api/super_api.py +0 -64
- jaseci/extens/api/tests/__init__.py +0 -0
- jaseci/extens/api/tests/test_architype_api.py +0 -66
- jaseci/extens/api/tests/test_global_api.py +0 -179
- jaseci/extens/api/tests/test_graph_api.py +0 -64
- jaseci/extens/api/tests/test_logger_api.py +0 -43
- jaseci/extens/api/tests/test_object_api.py +0 -20
- jaseci/extens/api/tests/test_sentinel_api.py +0 -66
- jaseci/extens/api/tests/test_uncommon.py +0 -107
- jaseci/extens/api/tests/test_user_api.py +0 -32
- jaseci/extens/api/tests/test_walker_api.py +0 -316
- jaseci/extens/api/user_api.py +0 -144
- jaseci/extens/api/walker_api.py +0 -298
- jaseci/extens/api/webhook_api.py +0 -74
- jaseci/extens/svc/__init__.py +0 -0
- jaseci/extens/svc/elastic_svc.py +0 -366
- jaseci/extens/svc/kube_svc.py +0 -432
- jaseci/extens/svc/mail_svc.py +0 -156
- jaseci/extens/svc/prome_svc.py +0 -378
- jaseci/extens/svc/redis_svc.py +0 -63
- jaseci/extens/svc/storage_svc.py +0 -193
- jaseci/extens/svc/stripe_svc.py +0 -51
- jaseci/extens/svc/task_svc.py +0 -155
- jaseci/extens/svc/tasks.py +0 -302
- jaseci/jac/__init__.py +0 -0
- jaseci/jac/interpreter/__init__.py +0 -0
- jaseci/jac/interpreter/architype_interp.py +0 -214
- jaseci/jac/interpreter/interp.py +0 -1783
- jaseci/jac/interpreter/sentinel_interp.py +0 -257
- jaseci/jac/interpreter/tests/__init__.py +0 -0
- jaseci/jac/interpreter/tests/test_interp.py +0 -42
- jaseci/jac/interpreter/walker_interp.py +0 -248
- jaseci/jac/ir/__init__.py +0 -0
- jaseci/jac/ir/ast.py +0 -73
- jaseci/jac/ir/ast_builder.py +0 -249
- jaseci/jac/ir/jac_code.py +0 -152
- jaseci/jac/ir/passes/__init__.py +0 -6
- jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
- jaseci/jac/ir/passes/codegen_pass.py +0 -244
- jaseci/jac/ir/passes/ir_pass.py +0 -29
- jaseci/jac/ir/passes/printer_pass.py +0 -23
- jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
- jaseci/jac/ir/passes/schedule.py +0 -23
- jaseci/jac/ir/passes/stats_pass.py +0 -16
- jaseci/jac/jac.g4 +0 -450
- jaseci/jac/jac_parse/__init__.py +0 -0
- jaseci/jac/jac_parse/jacLexer.py +0 -809
- jaseci/jac/jac_parse/jacListener.py +0 -853
- jaseci/jac/jac_parse/jacParser.py +0 -9192
- jaseci/jac/jac_set.py +0 -119
- jaseci/jac/jsci_vm/__init__.py +0 -0
- jaseci/jac/jsci_vm/disasm.py +0 -94
- jaseci/jac/jsci_vm/inst_ptr.py +0 -31
- jaseci/jac/jsci_vm/machine.py +0 -188
- jaseci/jac/jsci_vm/op_codes.py +0 -82
- jaseci/jac/jsci_vm/tests/__init__.py +0 -0
- jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
- jaseci/jac/machine/__init__.py +0 -0
- jaseci/jac/machine/jac_scope.py +0 -85
- jaseci/jac/machine/jac_value.py +0 -226
- jaseci/jac/machine/machine_state.py +0 -383
- jaseci/jac/tests/__init__.py +0 -0
- jaseci/jac/tests/book_code.py +0 -624
- jaseci/jac/tests/test_book.py +0 -380
- jaseci/jac/tests/test_lang_14.py +0 -49
- jaseci/jsorc/__init__.py +0 -7
- jaseci/jsorc/jsorc.py +0 -642
- jaseci/jsorc/jsorc_settings.py +0 -211
- jaseci/jsorc/jsorc_utils.py +0 -298
- jaseci/jsorc/live_actions.py +0 -364
- jaseci/jsorc/manifests/__init__.py +0 -0
- jaseci/jsorc/manifests/database.yaml +0 -109
- jaseci/jsorc/manifests/elastic.yaml +0 -6024
- jaseci/jsorc/manifests/prometheus.yaml +0 -1383
- jaseci/jsorc/manifests/redis.yaml +0 -64
- jaseci/jsorc/memory.py +0 -258
- jaseci/jsorc/redis.py +0 -139
- jaseci/jsorc/remote_actions.py +0 -157
- jaseci/jsorc/tests/__init__.py +0 -0
- jaseci/jsorc/tests/test_actions.py +0 -542
- jaseci/jsorc/tests/test_jsorc.py +0 -112
- jaseci/prim/__init__.py +0 -0
- jaseci/prim/ability.py +0 -93
- jaseci/prim/architype.py +0 -89
- jaseci/prim/edge.py +0 -172
- jaseci/prim/element.py +0 -233
- jaseci/prim/graph.py +0 -26
- jaseci/prim/master.py +0 -64
- jaseci/prim/node.py +0 -532
- jaseci/prim/obj_mixins.py +0 -235
- jaseci/prim/sentinel.py +0 -281
- jaseci/prim/super_master.py +0 -31
- jaseci/prim/walker.py +0 -261
- jaseci/svc/__init__.py +0 -0
- jaseci/tests/__init__.py +0 -0
- jaseci/tests/infer.py +0 -39
- jaseci/tests/jac_test_code.py +0 -1293
- jaseci/tests/jac_test_progs.py +0 -774
- jaseci/tests/test_core.py +0 -153
- jaseci/tests/test_jac.py +0 -824
- jaseci/tests/test_node.py +0 -89
- jaseci/tests/test_progs.py +0 -702
- jaseci/tests/test_stack.py +0 -220
- jaseci/tests/test_stripe.py +0 -225
- jaseci/utils/__init__.py +0 -0
- jaseci/utils/actions/__init__.py +0 -0
- jaseci/utils/actions/actions_manager.py +0 -254
- jaseci/utils/actions/actions_optimizer.py +0 -516
- jaseci/utils/actions/actions_state.py +0 -95
- jaseci/utils/file_handler.py +0 -171
- jaseci/utils/gprof2dot.py +0 -3786
- jaseci/utils/id_list.py +0 -168
- jaseci/utils/json_handler.py +0 -70
- jaseci/utils/log_utils.py +0 -57
- jaseci/utils/test_core.py +0 -62
- jaseci/utils/utils.py +0 -387
- jaseci-1.4.2.5.dist-info/LICENSE +0 -21
- jaseci-1.4.2.5.dist-info/METADATA +0 -39
- jaseci-1.4.2.5.dist-info/RECORD +0 -184
- jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
- jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
jaseci/extens/act_lib/std.py
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"""Built in actions for Jaseci"""
|
|
2
|
-
from operator import itemgetter
|
|
3
|
-
from jaseci.utils.utils import app_logger, json_out
|
|
4
|
-
from datetime import datetime
|
|
5
|
-
from jaseci.jac.machine.jac_value import jac_wrap_value as jwv
|
|
6
|
-
from jaseci.jsorc.live_actions import jaseci_action
|
|
7
|
-
from jaseci.utils.utils import master_from_meta
|
|
8
|
-
from jaseci.prim.element import Element
|
|
9
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
10
|
-
from jaseci.extens.svc.elastic_svc import Elastic
|
|
11
|
-
|
|
12
|
-
import sys
|
|
13
|
-
import json
|
|
14
|
-
import time
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@jaseci_action()
|
|
18
|
-
def log(*args):
|
|
19
|
-
"""Standard built in for printing output to log"""
|
|
20
|
-
result = ""
|
|
21
|
-
for i in args:
|
|
22
|
-
result += json_out(jwv(i))
|
|
23
|
-
app_logger.info(result)
|
|
24
|
-
return result
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@jaseci_action()
|
|
28
|
-
def out(*args):
|
|
29
|
-
"""Standard built in for printing output"""
|
|
30
|
-
args = [json_out(jwv(x)) for x in args]
|
|
31
|
-
print(*args)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@jaseci_action(aliases=["input"])
|
|
35
|
-
def js_input(prompt: str = ""):
|
|
36
|
-
"""Standard built in for printing output"""
|
|
37
|
-
return input(prompt)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@jaseci_action(aliases=["round"])
|
|
41
|
-
def js_round(num: float, digits: int = 0):
|
|
42
|
-
"""Standard built in for rounding floats"""
|
|
43
|
-
return round(num, digits)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
@jaseci_action()
|
|
47
|
-
def err(*args):
|
|
48
|
-
"""Standard built in for printing to stderr"""
|
|
49
|
-
args = [json_out(jwv(x)) for x in args]
|
|
50
|
-
print(*args, file=sys.stderr)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@jaseci_action()
|
|
54
|
-
def sleep(secs: float):
|
|
55
|
-
"""Standard built in for sleep"""
|
|
56
|
-
return time.sleep(secs)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
@jaseci_action()
|
|
60
|
-
def sort_by_col(lst: list, col_num: int, reverse: bool = False):
|
|
61
|
-
"""
|
|
62
|
-
Sorts in place list of lists by column
|
|
63
|
-
Param 1 - list
|
|
64
|
-
Param 2 - col number
|
|
65
|
-
Param 3 - boolean as to whether things should be reversed
|
|
66
|
-
|
|
67
|
-
Return - Sorted list
|
|
68
|
-
"""
|
|
69
|
-
return sorted(lst, key=itemgetter(col_num), reverse=reverse)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
# moved to date
|
|
73
|
-
@jaseci_action()
|
|
74
|
-
def time_now():
|
|
75
|
-
"""Get utc date time for now in iso format"""
|
|
76
|
-
return datetime.utcnow().isoformat()
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
@jaseci_action()
|
|
80
|
-
def set_global(name: str, value, meta):
|
|
81
|
-
"""
|
|
82
|
-
Set global variable visible to all walkers/users
|
|
83
|
-
Param 1 - name
|
|
84
|
-
Param 2 - value (must be json serializable)
|
|
85
|
-
"""
|
|
86
|
-
mast = master_from_meta(meta)
|
|
87
|
-
if not mast.is_master(super_check=True, silent=False):
|
|
88
|
-
return False
|
|
89
|
-
mast.global_set(name, json.dumps(value))
|
|
90
|
-
return json.loads(mast.global_get(name)["value"])
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@jaseci_action()
|
|
94
|
-
def get_global(name: str, meta):
|
|
95
|
-
"""
|
|
96
|
-
Set global variable visible to all walkers/users
|
|
97
|
-
Param 1 - name
|
|
98
|
-
"""
|
|
99
|
-
mast = master_from_meta(meta)
|
|
100
|
-
val = mast.global_get(name)["value"]
|
|
101
|
-
if val:
|
|
102
|
-
return json.loads(val)
|
|
103
|
-
else:
|
|
104
|
-
return None
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
@jaseci_action()
|
|
108
|
-
def actload_local(filename: str, meta):
|
|
109
|
-
"""
|
|
110
|
-
Load local actions to Jaseci
|
|
111
|
-
"""
|
|
112
|
-
mast = master_from_meta(meta)
|
|
113
|
-
if not mast.is_master(super_check=True, silent=True):
|
|
114
|
-
raise Exception("Only super master can load actions.")
|
|
115
|
-
|
|
116
|
-
return mast.actions_load_local(file=filename)["success"]
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
@jaseci_action()
|
|
120
|
-
def actload_remote(url: str, meta):
|
|
121
|
-
"""
|
|
122
|
-
Load remote actions to Jaseci
|
|
123
|
-
"""
|
|
124
|
-
mast = master_from_meta(meta)
|
|
125
|
-
if not mast.is_master(super_check=True, silent=True):
|
|
126
|
-
meta["interp"].rt_error(
|
|
127
|
-
"Only super master can load actions.", meta["interp"]._cur_jac_ast
|
|
128
|
-
)
|
|
129
|
-
return mast.actions_load_remote(url=url)["success"]
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
@jaseci_action()
|
|
133
|
-
def actload_module(module: str, meta):
|
|
134
|
-
"""
|
|
135
|
-
Load module actions to Jaseci
|
|
136
|
-
"""
|
|
137
|
-
mast = master_from_meta(meta)
|
|
138
|
-
if not mast.is_master(super_check=True, silent=True):
|
|
139
|
-
meta["interp"].rt_error(
|
|
140
|
-
"Only super master can load actions.", meta["interp"]._cur_jac_ast
|
|
141
|
-
)
|
|
142
|
-
return mast.actions_load_module(mod=module)["success"]
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
@jaseci_action()
|
|
146
|
-
def destroy_global(name: str, meta):
|
|
147
|
-
"""Get utc date time for now in iso format"""
|
|
148
|
-
mast = master_from_meta(meta)
|
|
149
|
-
if not mast.is_master(super_check=True, silent=False):
|
|
150
|
-
return False
|
|
151
|
-
return mast.global_delete(name)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
@jaseci_action()
|
|
155
|
-
def set_perms(obj: Element, mode: str, meta):
|
|
156
|
-
"""
|
|
157
|
-
Sets object access mode for any Jaseci object
|
|
158
|
-
Param 1 - target element
|
|
159
|
-
Param 2 - valid permission (public, private, read_only)
|
|
160
|
-
|
|
161
|
-
Return - true/false whether successful
|
|
162
|
-
"""
|
|
163
|
-
mast = master_from_meta(meta)
|
|
164
|
-
return mast.object_perms_set(obj=obj, mode=mode)["success"]
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@jaseci_action()
|
|
168
|
-
def get_perms(obj: Element):
|
|
169
|
-
"""
|
|
170
|
-
Returns object access mode for any Jaseci object
|
|
171
|
-
Param 1 - target element
|
|
172
|
-
|
|
173
|
-
Return - Sorted list
|
|
174
|
-
"""
|
|
175
|
-
return obj.j_access
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
@jaseci_action()
|
|
179
|
-
def grant_perms(obj: Element, mast: Element, read_only: bool, meta):
|
|
180
|
-
"""
|
|
181
|
-
Grants another user permissions to access a Jaseci object
|
|
182
|
-
Param 1 - target element
|
|
183
|
-
Param 2 - master to be granted permission
|
|
184
|
-
Param 3 - Boolean read_only flag
|
|
185
|
-
|
|
186
|
-
Return - Sorted list
|
|
187
|
-
"""
|
|
188
|
-
mast = master_from_meta(meta)
|
|
189
|
-
return mast.object_perms_grant(obj=obj, mast=mast, read_only=read_only)["success"]
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
@jaseci_action()
|
|
193
|
-
def revoke_perms(obj: Element, mast: Element, meta):
|
|
194
|
-
"""
|
|
195
|
-
Remove permissions for user to access a Jaseci object
|
|
196
|
-
Param 1 - target element
|
|
197
|
-
Param 2 - master to be revoked permission
|
|
198
|
-
|
|
199
|
-
Return - Sorted list
|
|
200
|
-
"""
|
|
201
|
-
mast = master_from_meta(meta)
|
|
202
|
-
return mast.object_perms_revoke(obj=obj, mast=mast)["success"]
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
@jaseci_action()
|
|
206
|
-
def get_report(meta):
|
|
207
|
-
"""
|
|
208
|
-
Get current report so far for walker run
|
|
209
|
-
"""
|
|
210
|
-
return meta["interp"].report
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
@jaseci_action()
|
|
214
|
-
def clear_report(meta):
|
|
215
|
-
"""
|
|
216
|
-
Clear report so far
|
|
217
|
-
"""
|
|
218
|
-
meta["interp"].report = []
|
|
219
|
-
if hasattr(meta["interp"], "save"):
|
|
220
|
-
meta["interp"].save()
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
@jaseci_action()
|
|
224
|
-
def log_activity(
|
|
225
|
-
log: dict = {}, action: str = "", query: str = "", suffix: str = "", meta: dict = {}
|
|
226
|
-
):
|
|
227
|
-
elastic = JsOrc.svc("elastic").poke(Elastic)
|
|
228
|
-
activity = elastic.generate_from_meta(meta, log, action)
|
|
229
|
-
|
|
230
|
-
return elastic.doc_activity(activity, query, suffix)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
@jaseci_action()
|
|
234
|
-
def clear_cache(all: bool = True, meta: dict = {}):
|
|
235
|
-
meta["h"].clear_cache(all)
|
jaseci/extens/act_lib/storage.py
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
from jaseci.jsorc.live_actions import jaseci_action
|
|
2
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
3
|
-
from jaseci.extens.svc.storage_svc import StorageService
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def storage():
|
|
7
|
-
return JsOrc.svc("store", StorageService)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@jaseci_action()
|
|
11
|
-
def upload(file: str, provider: str = None, container: str = None, meta: dict = {}):
|
|
12
|
-
"""temp"""
|
|
13
|
-
from jaseci.utils.file_handler import FileHandler
|
|
14
|
-
|
|
15
|
-
file_handler: FileHandler = meta["h"].get_file_handler(file)
|
|
16
|
-
|
|
17
|
-
return storage().upload(file=file_handler, provider=provider, container=container)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@jaseci_action()
|
|
21
|
-
def download(file: str, provider: str = None, container: str = None, meta: dict = {}):
|
|
22
|
-
"""temp"""
|
|
23
|
-
return meta["h"].add_file_handler(storage().download(file, provider, container))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@jaseci_action()
|
|
27
|
-
def cdn_url(file: str, provider: str = None, container: str = None, **kwargs):
|
|
28
|
-
"""temp"""
|
|
29
|
-
return storage().cdn_url(file, provider, container, **kwargs)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
@jaseci_action()
|
|
33
|
-
def delete(file: str, provider: str = None, container: str = None):
|
|
34
|
-
"""temp"""
|
|
35
|
-
return storage().delete(file, provider, container)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
@jaseci_action()
|
|
39
|
-
def create_container(name: str, provider: str = None):
|
|
40
|
-
"""temp"""
|
|
41
|
-
return storage().create_container(name, provider) != None
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@jaseci_action()
|
|
45
|
-
def has_container(name: str, provider: str = None):
|
|
46
|
-
"""temp"""
|
|
47
|
-
return storage().has_container(name, provider)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
@jaseci_action()
|
|
51
|
-
def delete_container(name: str, provider: str = None):
|
|
52
|
-
"""temp"""
|
|
53
|
-
return storage().delete_container(name, provider)
|
jaseci/extens/act_lib/stripe.py
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
"""Built in actions for Jaseci"""
|
|
2
|
-
import stripe as s
|
|
3
|
-
|
|
4
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
5
|
-
from jaseci.utils.utils import logger
|
|
6
|
-
from jaseci.extens.svc.stripe_svc import StripeService
|
|
7
|
-
from jaseci.jsorc.live_actions import jaseci_action
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def stripe() -> s:
|
|
11
|
-
_stripe = JsOrc.svc("stripe", StripeService)
|
|
12
|
-
if _stripe.is_running():
|
|
13
|
-
return _stripe.app
|
|
14
|
-
else:
|
|
15
|
-
logger.info(
|
|
16
|
-
"Stripe service is not running! Fallback to direct stripe call with required api key params."
|
|
17
|
-
)
|
|
18
|
-
return s
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@jaseci_action()
|
|
22
|
-
def product_create(name: str, **kwargs):
|
|
23
|
-
"""create product"""
|
|
24
|
-
|
|
25
|
-
return stripe().Product.create(name=name, **kwargs)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@jaseci_action()
|
|
29
|
-
def price_create(
|
|
30
|
-
product: str,
|
|
31
|
-
unit_amount: int,
|
|
32
|
-
currency: str,
|
|
33
|
-
**kwargs,
|
|
34
|
-
):
|
|
35
|
-
"""create product price"""
|
|
36
|
-
|
|
37
|
-
return stripe().Price.create(
|
|
38
|
-
product=product, unit_amount=unit_amount, currency=currency, **kwargs
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@jaseci_action()
|
|
43
|
-
def product_list(**kwargs):
|
|
44
|
-
"""retrieve all producs"""
|
|
45
|
-
|
|
46
|
-
return stripe().Product.list(**kwargs)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@jaseci_action()
|
|
50
|
-
def customer_create(**kwargs):
|
|
51
|
-
"""create customer"""
|
|
52
|
-
|
|
53
|
-
return stripe().Customer.create(**kwargs)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
@jaseci_action()
|
|
57
|
-
def customer_modify(customer_id: str, **kwargs):
|
|
58
|
-
"""update customer"""
|
|
59
|
-
|
|
60
|
-
return stripe().Customer.modify(customer_id, **kwargs)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@jaseci_action()
|
|
64
|
-
def customer_retrieve(customer_id: str, **kwargs):
|
|
65
|
-
"""retrieve customer information"""
|
|
66
|
-
|
|
67
|
-
return stripe().Customer.retrieve(customer_id, **kwargs)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
@jaseci_action()
|
|
71
|
-
def customer_delete(customer_id: str, **kwargs):
|
|
72
|
-
"""delete customer"""
|
|
73
|
-
|
|
74
|
-
return stripe().Customer.delete(customer_id, **kwargs)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
@jaseci_action()
|
|
78
|
-
def payment_method_attach(payment_method_id: str, customer_id: str, **kwargs):
|
|
79
|
-
"""retrieve customer list of invoices"""
|
|
80
|
-
|
|
81
|
-
return stripe().PaymentMethod.attach(
|
|
82
|
-
payment_method_id, customer=customer_id, **kwargs
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
@jaseci_action()
|
|
87
|
-
def payment_method_detach(payment_method_id: str, **kwargs):
|
|
88
|
-
"""detach payment method from customer"""
|
|
89
|
-
|
|
90
|
-
return stripe().PaymentMethod.detach(payment_method_id, **kwargs)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@jaseci_action()
|
|
94
|
-
def payment_method_list(**kwargs):
|
|
95
|
-
"""get customer list of payment methods"""
|
|
96
|
-
|
|
97
|
-
return stripe().PaymentMethod.list(**kwargs)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@jaseci_action()
|
|
101
|
-
def invoice_create(**kwargs):
|
|
102
|
-
"""create customer invoice"""
|
|
103
|
-
|
|
104
|
-
return stripe().Invoice.create(**kwargs)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
@jaseci_action()
|
|
108
|
-
def invoice_list(**kwargs):
|
|
109
|
-
"""retrieve customer list of invoices"""
|
|
110
|
-
|
|
111
|
-
return stripe().Invoice.list(**kwargs)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
@jaseci_action()
|
|
115
|
-
def payment_intent_list(**kwargs):
|
|
116
|
-
"""get customer payment intents"""
|
|
117
|
-
|
|
118
|
-
return stripe().PaymentIntent.list(**kwargs)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
@jaseci_action()
|
|
122
|
-
def payment_intent_create(amount: int, currency: str, **kwargs):
|
|
123
|
-
"""Create customer payment"""
|
|
124
|
-
|
|
125
|
-
return stripe().PaymentIntent.create(amount=amount, currency=currency, **kwargs)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
@jaseci_action()
|
|
129
|
-
def subscription_create(customer: str, items: list, **kwargs):
|
|
130
|
-
"""create subcriptions"""
|
|
131
|
-
|
|
132
|
-
return stripe().Subscription.create(customer=customer, items=items, **kwargs)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
@jaseci_action()
|
|
136
|
-
def subscription_modify(subscription_id: str, **kwargs):
|
|
137
|
-
"""modify subcriptions"""
|
|
138
|
-
|
|
139
|
-
return stripe().Subscription.modify(subscription_id, **kwargs)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
@jaseci_action()
|
|
143
|
-
def subscription_list(**kwargs):
|
|
144
|
-
"""list all customer's subcriptions"""
|
|
145
|
-
|
|
146
|
-
return stripe().Subscription.list(**kwargs)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
@jaseci_action()
|
|
150
|
-
def subscription_retrieve(subscription_id: str, **kwargs):
|
|
151
|
-
"""retrieve customer subcription details"""
|
|
152
|
-
|
|
153
|
-
return stripe().Subscription.retrieve(subscription_id, **kwargs)
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
@jaseci_action()
|
|
157
|
-
def payment_method_create(type: str, **kwargs):
|
|
158
|
-
"""create payment method"""
|
|
159
|
-
|
|
160
|
-
return stripe().PaymentMethod.create(type=type, **kwargs)
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
@jaseci_action()
|
|
164
|
-
def subscription_delete(subscription_id: str, **kwargs):
|
|
165
|
-
"""cancel customer subscription"""
|
|
166
|
-
|
|
167
|
-
return stripe().Subscription.delete(subscription_id, **kwargs)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
@jaseci_action()
|
|
171
|
-
def invoice_retrieve(invoice_id: str, **kwargs):
|
|
172
|
-
"""get invoice information"""
|
|
173
|
-
|
|
174
|
-
return stripe().Invoice.retrieve(invoice_id, **kwargs)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
@jaseci_action()
|
|
178
|
-
def subscription_item_list_usage_record_summaries(subscription_item_id: str, **kwargs):
|
|
179
|
-
"""Create usage record"""
|
|
180
|
-
|
|
181
|
-
return stripe().SubscriptionItem.list_usage_record_summaries(
|
|
182
|
-
subscription_item_id, **kwargs
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
@jaseci_action()
|
|
187
|
-
def subscription_item_create_usage_record(
|
|
188
|
-
subscription_item_id: str, quantity: int, **kwargs
|
|
189
|
-
):
|
|
190
|
-
"""Create usage record"""
|
|
191
|
-
|
|
192
|
-
return stripe().SubscriptionItem.create_usage_record(
|
|
193
|
-
subscription_item_id, quantity=quantity, timestamp="now", **kwargs
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
@jaseci_action()
|
|
198
|
-
def subscription_item_retrieve(subscription_item_id: str, **kwargs):
|
|
199
|
-
"""retrieve subscription item"""
|
|
200
|
-
|
|
201
|
-
return stripe().SubscriptionItem.retrieve(subscription_item_id, **kwargs)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
@jaseci_action()
|
|
205
|
-
def checkout_session_create(success_url: str, mode: str, **kwargs):
|
|
206
|
-
return stripe().checkout.Session.create(
|
|
207
|
-
success_url=success_url,
|
|
208
|
-
mode=mode,
|
|
209
|
-
**kwargs,
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
@jaseci_action()
|
|
214
|
-
def billing_portal_session_create(customer: str, **kwargs):
|
|
215
|
-
return stripe().billing_portal.Session.create(
|
|
216
|
-
customer=customer,
|
|
217
|
-
**kwargs,
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
#################################################
|
|
222
|
-
# WITH PRE CUSTOM PROCESS #
|
|
223
|
-
#################################################
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
@jaseci_action()
|
|
227
|
-
def update_default_payment_method(customer_id: str, payment_method_id: str, **kwargs):
|
|
228
|
-
"""update default payment method of customer"""
|
|
229
|
-
|
|
230
|
-
return customer_modify(
|
|
231
|
-
customer_id,
|
|
232
|
-
invoice_settings={"default_payment_method": payment_method_id},
|
|
233
|
-
**kwargs,
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
@jaseci_action()
|
|
238
|
-
def attach_payment_method(payment_method_id: str, customer_id: str, **kwargs):
|
|
239
|
-
"""attach payment method to customer"""
|
|
240
|
-
|
|
241
|
-
paymentMethods = payment_method_list(customer=customer_id)
|
|
242
|
-
|
|
243
|
-
paymentMethod = payment_method_attach(payment_method_id, customer_id, **kwargs)
|
|
244
|
-
|
|
245
|
-
is_default = True
|
|
246
|
-
if paymentMethods.get("data"):
|
|
247
|
-
update_default_payment_method(customer_id, payment_method_id)
|
|
248
|
-
is_default = False
|
|
249
|
-
|
|
250
|
-
paymentMethod["is_default"] = is_default
|
|
251
|
-
|
|
252
|
-
return paymentMethod
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
@jaseci_action()
|
|
256
|
-
def create_trial_subscription(
|
|
257
|
-
customer_id: str,
|
|
258
|
-
items: list,
|
|
259
|
-
payment_method_id: str = "",
|
|
260
|
-
trial_period_days: int = 14,
|
|
261
|
-
**kwargs,
|
|
262
|
-
):
|
|
263
|
-
"""create customer trial subscription"""
|
|
264
|
-
|
|
265
|
-
if payment_method_id != "":
|
|
266
|
-
# attach payment method to customer
|
|
267
|
-
attach_payment_method(payment_method_id, customer_id)
|
|
268
|
-
|
|
269
|
-
# set card to default payment method
|
|
270
|
-
update_default_payment_method(customer_id, payment_method_id)
|
|
271
|
-
|
|
272
|
-
return subscription_create(
|
|
273
|
-
customer_id,
|
|
274
|
-
items,
|
|
275
|
-
trial_period_days=trial_period_days,
|
|
276
|
-
**kwargs,
|
|
277
|
-
)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
@jaseci_action()
|
|
281
|
-
def create_subscription(
|
|
282
|
-
customer_id: str,
|
|
283
|
-
items: list,
|
|
284
|
-
payment_method_id: str = "",
|
|
285
|
-
**kwargs,
|
|
286
|
-
):
|
|
287
|
-
"""create customer subscription"""
|
|
288
|
-
|
|
289
|
-
if payment_method_id != "":
|
|
290
|
-
# attach payment method to customer
|
|
291
|
-
attach_payment_method(payment_method_id, customer_id)
|
|
292
|
-
|
|
293
|
-
# set card to default payment method
|
|
294
|
-
update_default_payment_method(customer_id, payment_method_id)
|
|
295
|
-
|
|
296
|
-
return subscription_create(customer_id, items, **kwargs)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
@jaseci_action()
|
|
300
|
-
def update_subscription_item(
|
|
301
|
-
subscription_id: str, subscription_item_id: str, price_id: str, **kwargs
|
|
302
|
-
):
|
|
303
|
-
"""update subcription details"""
|
|
304
|
-
|
|
305
|
-
return subscription_modify(
|
|
306
|
-
subscription_id,
|
|
307
|
-
cancel_at_period_end=False,
|
|
308
|
-
items=[
|
|
309
|
-
{
|
|
310
|
-
"id": subscription_item_id,
|
|
311
|
-
"price": price_id,
|
|
312
|
-
},
|
|
313
|
-
],
|
|
314
|
-
**kwargs,
|
|
315
|
-
)
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
#################################################
|
|
319
|
-
# EXECUTE CUSTOM PROCESS #
|
|
320
|
-
#################################################
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
@jaseci_action()
|
|
324
|
-
def exec(api: str, *args, **kwargs):
|
|
325
|
-
apis = api.split(".")
|
|
326
|
-
|
|
327
|
-
if not apis:
|
|
328
|
-
raise Exception("API is required!")
|
|
329
|
-
|
|
330
|
-
mod = stripe()
|
|
331
|
-
|
|
332
|
-
for api in apis:
|
|
333
|
-
mod = getattr(mod, api, None)
|
|
334
|
-
if not mod:
|
|
335
|
-
raise Exception("Not a valid stripe API!")
|
|
336
|
-
|
|
337
|
-
return mod(*args, **kwargs)
|
jaseci/extens/act_lib/task.py
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"""Built in actions for Jaseci"""
|
|
2
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
3
|
-
from jaseci.jsorc.live_actions import jaseci_action
|
|
4
|
-
from jaseci.extens.svc.task_svc import TaskService
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@jaseci_action()
|
|
8
|
-
def get_result(task_id, wait=False, timeout=30):
|
|
9
|
-
"""
|
|
10
|
-
Get task result by task_id
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
return JsOrc.svc("task").poke(TaskService).get_by_task_id(task_id, wait, timeout)
|
|
File without changes
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
rand_std = """
|
|
2
|
-
walker init
|
|
3
|
-
{
|
|
4
|
-
report rand.word();
|
|
5
|
-
report rand.sentence();
|
|
6
|
-
report rand.paragraph();
|
|
7
|
-
report rand.text();
|
|
8
|
-
}
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
file_io = """
|
|
12
|
-
walker init {
|
|
13
|
-
fn="fileiotest.txt";
|
|
14
|
-
a = {'a': 5};
|
|
15
|
-
file.dump_json(fn, a);
|
|
16
|
-
b=file.load_json(fn);
|
|
17
|
-
b['a']+=b['a'];
|
|
18
|
-
file.dump_json(fn, b);
|
|
19
|
-
c=file.load_str(fn);
|
|
20
|
-
file.append_str(fn, c);
|
|
21
|
-
c=file.load_str(fn);
|
|
22
|
-
report c;
|
|
23
|
-
file.delete(fn);
|
|
24
|
-
}
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
std_used_in_node_has_var = """
|
|
28
|
-
node testnode {has a=rand.sentence();}
|
|
29
|
-
|
|
30
|
-
walker init
|
|
31
|
-
{
|
|
32
|
-
a = spawn here ++> node::testnode;
|
|
33
|
-
a = spawn here ++> node::testnode;
|
|
34
|
-
a = spawn --> ++> node::testnode;
|
|
35
|
-
report a[0].a;
|
|
36
|
-
}
|
|
37
|
-
"""
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest, jac_testcase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class DateTest(CoreTest):
|
|
5
|
-
fixture_src = __file__
|
|
6
|
-
|
|
7
|
-
@jac_testcase("date.jac", "sample")
|
|
8
|
-
def test_date_syntax(self, ret):
|
|
9
|
-
self.assertEqual(
|
|
10
|
-
ret["report"],
|
|
11
|
-
[
|
|
12
|
-
{
|
|
13
|
-
"day": 26,
|
|
14
|
-
"hour": 7,
|
|
15
|
-
"microsecond": 93606,
|
|
16
|
-
"minute": 42,
|
|
17
|
-
"month": 4,
|
|
18
|
-
"second": 53,
|
|
19
|
-
"weekday": 3,
|
|
20
|
-
"year": 2023,
|
|
21
|
-
"iso": "2023-04-26T07:42:53.093606",
|
|
22
|
-
},
|
|
23
|
-
"2023-06-05T07:42:53.093606",
|
|
24
|
-
"2023-04-26T00:42:53.093606",
|
|
25
|
-
],
|
|
26
|
-
)
|