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