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.

Files changed (186) hide show
  1. jaseci/__init__.py +3 -37
  2. jaseci-2.0.0.dist-info/METADATA +65 -0
  3. jaseci-2.0.0.dist-info/RECORD +4 -0
  4. {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
  5. jaseci/VERSION +0 -1
  6. jaseci/cli_tools/__init__.py +0 -0
  7. jaseci/cli_tools/book_tools.py +0 -457
  8. jaseci/cli_tools/jsctl.py +0 -500
  9. jaseci/cli_tools/tests/__init__.py +0 -0
  10. jaseci/cli_tools/tests/test_jsctl.py +0 -556
  11. jaseci/extens/__init__.py +0 -0
  12. jaseci/extens/act_lib/__init__.py +0 -0
  13. jaseci/extens/act_lib/date.py +0 -117
  14. jaseci/extens/act_lib/elastic.py +0 -87
  15. jaseci/extens/act_lib/file.py +0 -76
  16. jaseci/extens/act_lib/file_handler.py +0 -189
  17. jaseci/extens/act_lib/internal.py +0 -18
  18. jaseci/extens/act_lib/jaseci.py +0 -61
  19. jaseci/extens/act_lib/mail.py +0 -10
  20. jaseci/extens/act_lib/maths.py +0 -168
  21. jaseci/extens/act_lib/net.py +0 -191
  22. jaseci/extens/act_lib/rand.py +0 -82
  23. jaseci/extens/act_lib/regex.py +0 -85
  24. jaseci/extens/act_lib/request.py +0 -169
  25. jaseci/extens/act_lib/std.py +0 -235
  26. jaseci/extens/act_lib/storage.py +0 -53
  27. jaseci/extens/act_lib/stripe.py +0 -337
  28. jaseci/extens/act_lib/task.py +0 -13
  29. jaseci/extens/act_lib/tests/__init__.py +0 -0
  30. jaseci/extens/act_lib/tests/std_test_code.py +0 -37
  31. jaseci/extens/act_lib/tests/test_date.py +0 -26
  32. jaseci/extens/act_lib/tests/test_elastic.py +0 -159
  33. jaseci/extens/act_lib/tests/test_file.py +0 -116
  34. jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
  35. jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
  36. jaseci/extens/act_lib/tests/test_maths.py +0 -147
  37. jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
  38. jaseci/extens/act_lib/tests/test_regex.py +0 -61
  39. jaseci/extens/act_lib/tests/test_std.py +0 -51
  40. jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
  41. jaseci/extens/act_lib/tests/test_url.py +0 -32
  42. jaseci/extens/act_lib/tests/test_vector.py +0 -36
  43. jaseci/extens/act_lib/tests/test_webtool.py +0 -44
  44. jaseci/extens/act_lib/tests/test_zlib.py +0 -24
  45. jaseci/extens/act_lib/url.py +0 -79
  46. jaseci/extens/act_lib/vector.py +0 -157
  47. jaseci/extens/act_lib/webtool.py +0 -28
  48. jaseci/extens/act_lib/zip.py +0 -33
  49. jaseci/extens/api/__init__.py +0 -0
  50. jaseci/extens/api/actions_api.py +0 -170
  51. jaseci/extens/api/alias_api.py +0 -139
  52. jaseci/extens/api/architype_api.py +0 -196
  53. jaseci/extens/api/config_api.py +0 -129
  54. jaseci/extens/api/global_api.py +0 -84
  55. jaseci/extens/api/graph_api.py +0 -167
  56. jaseci/extens/api/health_api.py +0 -20
  57. jaseci/extens/api/interface.py +0 -268
  58. jaseci/extens/api/jac_api.py +0 -171
  59. jaseci/extens/api/jsorc_api.py +0 -316
  60. jaseci/extens/api/logger_api.py +0 -89
  61. jaseci/extens/api/master_api.py +0 -133
  62. jaseci/extens/api/object_api.py +0 -101
  63. jaseci/extens/api/prometheus_api.py +0 -74
  64. jaseci/extens/api/queue_api.py +0 -140
  65. jaseci/extens/api/sentinel_api.py +0 -270
  66. jaseci/extens/api/super_api.py +0 -64
  67. jaseci/extens/api/tests/__init__.py +0 -0
  68. jaseci/extens/api/tests/test_architype_api.py +0 -66
  69. jaseci/extens/api/tests/test_global_api.py +0 -179
  70. jaseci/extens/api/tests/test_graph_api.py +0 -64
  71. jaseci/extens/api/tests/test_logger_api.py +0 -43
  72. jaseci/extens/api/tests/test_object_api.py +0 -20
  73. jaseci/extens/api/tests/test_sentinel_api.py +0 -66
  74. jaseci/extens/api/tests/test_uncommon.py +0 -107
  75. jaseci/extens/api/tests/test_user_api.py +0 -32
  76. jaseci/extens/api/tests/test_walker_api.py +0 -316
  77. jaseci/extens/api/user_api.py +0 -144
  78. jaseci/extens/api/walker_api.py +0 -298
  79. jaseci/extens/api/webhook_api.py +0 -74
  80. jaseci/extens/svc/__init__.py +0 -0
  81. jaseci/extens/svc/elastic_svc.py +0 -366
  82. jaseci/extens/svc/kube_svc.py +0 -432
  83. jaseci/extens/svc/mail_svc.py +0 -156
  84. jaseci/extens/svc/prome_svc.py +0 -378
  85. jaseci/extens/svc/redis_svc.py +0 -63
  86. jaseci/extens/svc/storage_svc.py +0 -193
  87. jaseci/extens/svc/stripe_svc.py +0 -51
  88. jaseci/extens/svc/task_svc.py +0 -155
  89. jaseci/extens/svc/tasks.py +0 -302
  90. jaseci/jac/__init__.py +0 -0
  91. jaseci/jac/interpreter/__init__.py +0 -0
  92. jaseci/jac/interpreter/architype_interp.py +0 -214
  93. jaseci/jac/interpreter/interp.py +0 -1783
  94. jaseci/jac/interpreter/sentinel_interp.py +0 -257
  95. jaseci/jac/interpreter/tests/__init__.py +0 -0
  96. jaseci/jac/interpreter/tests/test_interp.py +0 -42
  97. jaseci/jac/interpreter/walker_interp.py +0 -248
  98. jaseci/jac/ir/__init__.py +0 -0
  99. jaseci/jac/ir/ast.py +0 -73
  100. jaseci/jac/ir/ast_builder.py +0 -249
  101. jaseci/jac/ir/jac_code.py +0 -152
  102. jaseci/jac/ir/passes/__init__.py +0 -6
  103. jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
  104. jaseci/jac/ir/passes/codegen_pass.py +0 -244
  105. jaseci/jac/ir/passes/ir_pass.py +0 -29
  106. jaseci/jac/ir/passes/printer_pass.py +0 -23
  107. jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
  108. jaseci/jac/ir/passes/schedule.py +0 -23
  109. jaseci/jac/ir/passes/stats_pass.py +0 -16
  110. jaseci/jac/jac.g4 +0 -450
  111. jaseci/jac/jac_parse/__init__.py +0 -0
  112. jaseci/jac/jac_parse/jacLexer.py +0 -809
  113. jaseci/jac/jac_parse/jacListener.py +0 -853
  114. jaseci/jac/jac_parse/jacParser.py +0 -9192
  115. jaseci/jac/jac_set.py +0 -119
  116. jaseci/jac/jsci_vm/__init__.py +0 -0
  117. jaseci/jac/jsci_vm/disasm.py +0 -94
  118. jaseci/jac/jsci_vm/inst_ptr.py +0 -31
  119. jaseci/jac/jsci_vm/machine.py +0 -188
  120. jaseci/jac/jsci_vm/op_codes.py +0 -82
  121. jaseci/jac/jsci_vm/tests/__init__.py +0 -0
  122. jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
  123. jaseci/jac/machine/__init__.py +0 -0
  124. jaseci/jac/machine/jac_scope.py +0 -85
  125. jaseci/jac/machine/jac_value.py +0 -226
  126. jaseci/jac/machine/machine_state.py +0 -383
  127. jaseci/jac/tests/__init__.py +0 -0
  128. jaseci/jac/tests/book_code.py +0 -624
  129. jaseci/jac/tests/test_book.py +0 -380
  130. jaseci/jac/tests/test_lang_14.py +0 -49
  131. jaseci/jsorc/__init__.py +0 -7
  132. jaseci/jsorc/jsorc.py +0 -642
  133. jaseci/jsorc/jsorc_settings.py +0 -211
  134. jaseci/jsorc/jsorc_utils.py +0 -298
  135. jaseci/jsorc/live_actions.py +0 -364
  136. jaseci/jsorc/manifests/__init__.py +0 -0
  137. jaseci/jsorc/manifests/database.yaml +0 -109
  138. jaseci/jsorc/manifests/elastic.yaml +0 -6024
  139. jaseci/jsorc/manifests/prometheus.yaml +0 -1383
  140. jaseci/jsorc/manifests/redis.yaml +0 -64
  141. jaseci/jsorc/memory.py +0 -258
  142. jaseci/jsorc/redis.py +0 -139
  143. jaseci/jsorc/remote_actions.py +0 -157
  144. jaseci/jsorc/tests/__init__.py +0 -0
  145. jaseci/jsorc/tests/test_actions.py +0 -542
  146. jaseci/jsorc/tests/test_jsorc.py +0 -112
  147. jaseci/prim/__init__.py +0 -0
  148. jaseci/prim/ability.py +0 -93
  149. jaseci/prim/architype.py +0 -89
  150. jaseci/prim/edge.py +0 -172
  151. jaseci/prim/element.py +0 -233
  152. jaseci/prim/graph.py +0 -26
  153. jaseci/prim/master.py +0 -64
  154. jaseci/prim/node.py +0 -532
  155. jaseci/prim/obj_mixins.py +0 -235
  156. jaseci/prim/sentinel.py +0 -281
  157. jaseci/prim/super_master.py +0 -31
  158. jaseci/prim/walker.py +0 -261
  159. jaseci/svc/__init__.py +0 -0
  160. jaseci/tests/__init__.py +0 -0
  161. jaseci/tests/infer.py +0 -39
  162. jaseci/tests/jac_test_code.py +0 -1293
  163. jaseci/tests/jac_test_progs.py +0 -774
  164. jaseci/tests/test_core.py +0 -153
  165. jaseci/tests/test_jac.py +0 -824
  166. jaseci/tests/test_node.py +0 -89
  167. jaseci/tests/test_progs.py +0 -702
  168. jaseci/tests/test_stack.py +0 -220
  169. jaseci/tests/test_stripe.py +0 -225
  170. jaseci/utils/__init__.py +0 -0
  171. jaseci/utils/actions/__init__.py +0 -0
  172. jaseci/utils/actions/actions_manager.py +0 -254
  173. jaseci/utils/actions/actions_optimizer.py +0 -516
  174. jaseci/utils/actions/actions_state.py +0 -95
  175. jaseci/utils/file_handler.py +0 -171
  176. jaseci/utils/gprof2dot.py +0 -3786
  177. jaseci/utils/id_list.py +0 -168
  178. jaseci/utils/json_handler.py +0 -70
  179. jaseci/utils/log_utils.py +0 -57
  180. jaseci/utils/test_core.py +0 -62
  181. jaseci/utils/utils.py +0 -387
  182. jaseci-1.4.2.5.dist-info/LICENSE +0 -21
  183. jaseci-1.4.2.5.dist-info/METADATA +0 -39
  184. jaseci-1.4.2.5.dist-info/RECORD +0 -184
  185. jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
  186. jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
@@ -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)
@@ -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)
@@ -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)
@@ -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
- )