pixelarraythirdparty 1.1.6__tar.gz → 1.1.9__tar.gz

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.
Files changed (27) hide show
  1. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/PKG-INFO +1 -1
  2. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/__init__.py +1 -1
  3. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/cron/cron.py +1 -34
  4. pixelarraythirdparty-1.1.9/pixelarraythirdparty/unified_login/__init__.py +20 -0
  5. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/unified_login/unified_login.py +238 -0
  6. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty.egg-info/PKG-INFO +1 -1
  7. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pyproject.toml +1 -1
  8. pixelarraythirdparty-1.1.6/pixelarraythirdparty/unified_login/__init__.py +0 -4
  9. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/LICENSE +0 -0
  10. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/MANIFEST.in +0 -0
  11. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/client.py +0 -0
  12. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/cron/__init__.py +0 -0
  13. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/feedback/__init__.py +0 -0
  14. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/feedback/feedback.py +0 -0
  15. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/order/__init__.py +0 -0
  16. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/order/order.py +0 -0
  17. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/product/__init__.py +0 -0
  18. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/product/product.py +0 -0
  19. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/project/__init__.py +0 -0
  20. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/project/project.py +0 -0
  21. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/user/__init__.py +0 -0
  22. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty/user/user.py +0 -0
  23. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty.egg-info/SOURCES.txt +0 -0
  24. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty.egg-info/dependency_links.txt +0 -0
  25. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty.egg-info/requires.txt +0 -0
  26. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/pixelarraythirdparty.egg-info/top_level.txt +0 -0
  27. {pixelarraythirdparty-1.1.6 → pixelarraythirdparty-1.1.9}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.1.6
3
+ Version: 1.1.9
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -13,7 +13,7 @@ PixelArray 第三方微服务客户端
13
13
  - project: 项目管理模块
14
14
  """
15
15
 
16
- __version__ = "1.1.6"
16
+ __version__ = "1.1.9"
17
17
  __author__ = "Lu qi"
18
18
  __email__ = "qi.lu@pixelarrayai.com"
19
19
 
@@ -2,40 +2,7 @@ from pixelarraythirdparty.client import AsyncClient
2
2
 
3
3
 
4
4
  class CronManagerAsync(AsyncClient):
5
- async def get_cron_status(self):
6
- """
7
- description:
8
- 获取Cron服务状态,包括已注册的任务、工作节点状态等。
9
- return:
10
- data(dict): Cron服务状态信息
11
- - registered_tasks(dict): 已注册的任务列表,按工作节点分组
12
- - worker_stats(dict): 工作节点统计信息
13
- - scheduled_task_count(int): 定时任务数量
14
- - timestamp(str): 状态获取时间
15
- success(bool): 操作是否成功
16
- """
17
- data, success = await self._request("GET", "/api/cron/status")
18
- if not success:
19
- return {}, False
20
- return data, True
21
-
22
- async def get_cron_tasks(self):
23
- """
24
- description:
25
- 获取所有已注册的Cron任务列表。
26
- return:
27
- data(dict): 任务列表信息
28
- - tasks(list): 已注册的任务名称列表
29
- - count(int): 任务数量
30
- - timestamp(str): 获取时间
31
- success(bool): 操作是否成功
32
- """
33
- data, success = await self._request("GET", "/api/cron/tasks")
34
- if not success:
35
- return {}, False
36
- return data, True
37
-
38
- async def get_cron_tasks_scheduled(self):
5
+ async def list_cron_task(self):
39
6
  """
40
7
  description:
41
8
  获取所有配置的定时任务列表,包括任务详情、执行时间、状态等。
@@ -0,0 +1,20 @@
1
+ from .unified_login import (
2
+ GoogleLogin,
3
+ WechatLogin,
4
+ GitHubLogin,
5
+ DouyinLogin,
6
+ GitLabLogin,
7
+ SMSLogin,
8
+ EmailLogin,
9
+ )
10
+
11
+ __all__ = [
12
+ "GoogleLogin",
13
+ "WechatLogin",
14
+ "GitHubLogin",
15
+ "DouyinLogin",
16
+ "GitLabLogin",
17
+ "SMSLogin",
18
+ "EmailLogin",
19
+ ]
20
+
@@ -14,6 +14,15 @@ class GoogleLogin(AsyncClient):
14
14
  ```
15
15
  google = GoogleLogin(api_key="your_api_key")
16
16
  user_info, success = await google.login()
17
+ if success:
18
+ access_token = user_info.get("access_token")
19
+ refresh_token = user_info.get("refresh_token")
20
+
21
+ # 使用refresh_token刷新access_token
22
+ if refresh_token:
23
+ token_data, success = await google.refresh_access_token(refresh_token)
24
+ if success:
25
+ new_access_token = token_data.get("access_token")
17
26
  ```
18
27
  """
19
28
 
@@ -88,6 +97,31 @@ class GoogleLogin(AsyncClient):
88
97
 
89
98
  return {}, False
90
99
 
100
+ async def refresh_access_token(self, refresh_token: str) -> Tuple[Dict, bool]:
101
+ """
102
+ 使用refresh_token刷新access_token
103
+
104
+ :param refresh_token: Google OAuth refresh_token
105
+ :return: 包含新的access_token和可能的refresh_token的字典,以及是否成功的布尔值
106
+
107
+ 使用示例:
108
+ ```
109
+ google = GoogleLogin(api_key="your_api_key")
110
+ token_data, success = await google.refresh_access_token(refresh_token="your_refresh_token")
111
+ if success:
112
+ new_access_token = token_data.get("access_token")
113
+ new_refresh_token = token_data.get("refresh_token") # 可能为None
114
+ ```
115
+ """
116
+ data, success = await self._request(
117
+ "POST",
118
+ "/api/unified-login/google/refresh-token",
119
+ json={"refresh_token": refresh_token},
120
+ )
121
+ if not success:
122
+ return {}, False
123
+ return data, True
124
+
91
125
 
92
126
  class WechatLogin(AsyncClient):
93
127
  """
@@ -459,3 +493,207 @@ class GitLabLogin(AsyncClient):
459
493
  await asyncio.sleep(interval)
460
494
 
461
495
  return {}, False
496
+
497
+
498
+ class SMSLogin(AsyncClient):
499
+ """
500
+ 短信验证码登录客户端
501
+
502
+ 使用示例:
503
+ ```
504
+ sms = SMSLogin(api_key="your_api_key")
505
+ # 发送验证码
506
+ state, success = await sms.send_code(phone="13800138000")
507
+ if success:
508
+ # 验证验证码并登录
509
+ user_info, success = await sms.login(state=state, code="123456")
510
+ ```
511
+ """
512
+
513
+ def __init__(self, api_key: str):
514
+ super().__init__(api_key)
515
+
516
+ async def send_code(self, phone: str) -> Tuple[Optional[str], bool]:
517
+ """
518
+ 发送短信验证码
519
+
520
+ :param phone: 手机号码
521
+ :return: (state, success) state用于后续验证验证码
522
+ """
523
+ data, success = await self._request(
524
+ "POST", "/api/unified-login/sms/send-code", json={"phone": phone}
525
+ )
526
+ if not success:
527
+ return None, False
528
+ state = data.get("state")
529
+ if not state:
530
+ return None, False
531
+ return state, True
532
+
533
+ async def verify_code(self, state: str, code: str) -> Tuple[Optional[str], bool]:
534
+ """
535
+ 验证短信验证码
536
+
537
+ :param state: 发送验证码时返回的state
538
+ :param code: 验证码
539
+ :return: (state, success) state用于后续等待登录结果
540
+ """
541
+ data, success = await self._request(
542
+ "POST",
543
+ "/api/unified-login/sms/verify-code",
544
+ json={"state": state, "code": code},
545
+ )
546
+ if not success:
547
+ return None, False
548
+ new_state = data.get("state")
549
+ if not new_state:
550
+ return None, False
551
+ return new_state, True
552
+
553
+ async def _wait_for_login(
554
+ self, state: str, timeout: int
555
+ ) -> Tuple[Dict, bool]:
556
+ """
557
+ 等待短信登录结果
558
+
559
+ :param state: 验证验证码时返回的state
560
+ :param timeout: 超时时间(秒)
561
+ """
562
+ interval = 2
563
+ total_checks = max(1, timeout // interval) if timeout > 0 else 1
564
+
565
+ for _ in range(total_checks):
566
+ status, response = await self._request_raw(
567
+ "POST",
568
+ "/api/unified-login/sms/wait-sms-login",
569
+ json={"state": state},
570
+ )
571
+
572
+ if status == 200 and response.get("success") is True:
573
+ return response.get("data", {}), True
574
+
575
+ if status in (400, 408):
576
+ break
577
+
578
+ await asyncio.sleep(interval)
579
+
580
+ return {}, False
581
+
582
+ async def login(
583
+ self, state: str, code: str, timeout: int = 180
584
+ ) -> Tuple[Dict, bool]:
585
+ """
586
+ 验证验证码并等待登录结果
587
+
588
+ :param state: 发送验证码时返回的state
589
+ :param code: 验证码
590
+ :param timeout: 等待登录结果的超时时间(秒)
591
+ :return: (用户信息, 是否成功)
592
+ """
593
+ new_state, success = await self.verify_code(state, code)
594
+ if not success or not new_state:
595
+ return {}, False
596
+
597
+ return await self._wait_for_login(new_state, timeout)
598
+
599
+
600
+ class EmailLogin(AsyncClient):
601
+ """
602
+ 邮箱验证码登录客户端
603
+
604
+ 使用示例:
605
+ ```
606
+ email = EmailLogin(api_key="your_api_key")
607
+ # 发送验证码
608
+ state, success = await email.send_code(email="user@example.com")
609
+ if success:
610
+ # 验证验证码并登录
611
+ user_info, success = await email.login(state=state, code="123456")
612
+ ```
613
+ """
614
+
615
+ def __init__(self, api_key: str):
616
+ super().__init__(api_key)
617
+
618
+ async def send_code(self, email: str) -> Tuple[Optional[str], bool]:
619
+ """
620
+ 发送邮箱验证码
621
+
622
+ :param email: 邮箱地址
623
+ :return: (state, success) state用于后续验证验证码
624
+ """
625
+ data, success = await self._request(
626
+ "POST", "/api/unified-login/email/send-code", json={"email": email}
627
+ )
628
+ if not success:
629
+ return None, False
630
+ state = data.get("state")
631
+ if not state:
632
+ return None, False
633
+ return state, True
634
+
635
+ async def verify_code(self, state: str, code: str) -> Tuple[Optional[str], bool]:
636
+ """
637
+ 验证邮箱验证码
638
+
639
+ :param state: 发送验证码时返回的state
640
+ :param code: 验证码
641
+ :return: (state, success) state用于后续等待登录结果
642
+ """
643
+ data, success = await self._request(
644
+ "POST",
645
+ "/api/unified-login/email/verify-code",
646
+ json={"state": state, "code": code},
647
+ )
648
+ if not success:
649
+ return None, False
650
+ new_state = data.get("state")
651
+ if not new_state:
652
+ return None, False
653
+ return new_state, True
654
+
655
+ async def _wait_for_login(
656
+ self, state: str, timeout: int
657
+ ) -> Tuple[Dict, bool]:
658
+ """
659
+ 等待邮箱登录结果
660
+
661
+ :param state: 验证验证码时返回的state
662
+ :param timeout: 超时时间(秒)
663
+ """
664
+ interval = 2
665
+ total_checks = max(1, timeout // interval) if timeout > 0 else 1
666
+
667
+ for _ in range(total_checks):
668
+ status, response = await self._request_raw(
669
+ "POST",
670
+ "/api/unified-login/email/wait-email-login",
671
+ json={"state": state},
672
+ )
673
+
674
+ if status == 200 and response.get("success") is True:
675
+ return response.get("data", {}), True
676
+
677
+ if status in (400, 408):
678
+ break
679
+
680
+ await asyncio.sleep(interval)
681
+
682
+ return {}, False
683
+
684
+ async def login(
685
+ self, state: str, code: str, timeout: int = 180
686
+ ) -> Tuple[Dict, bool]:
687
+ """
688
+ 验证验证码并等待登录结果
689
+
690
+ :param state: 发送验证码时返回的state
691
+ :param code: 验证码
692
+ :param timeout: 等待登录结果的超时时间(秒)
693
+ :return: (用户信息, 是否成功)
694
+ """
695
+ new_state, success = await self.verify_code(state, code)
696
+ if not success or not new_state:
697
+ return {}, False
698
+
699
+ return await self._wait_for_login(new_state, timeout)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.1.6
3
+ Version: 1.1.9
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pixelarraythirdparty"
7
- version = "1.1.6"
7
+ version = "1.1.9"
8
8
  authors = [
9
9
  {name = "Lu qi", email = "qi.lu@pixelarrayai.com"},
10
10
  ]
@@ -1,4 +0,0 @@
1
- from .unified_login import GoogleLogin, WechatLogin, GitHubLogin
2
-
3
- __all__ = ["GoogleLogin", "WechatLogin", "GitHubLogin"]
4
-