contracts-hj3415 0.5.0__tar.gz → 0.5.1__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. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/PKG-INFO +1 -1
  2. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/pyproject.toml +1 -1
  3. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/analysis/features.py +1 -0
  4. contracts_hj3415-0.5.1/src/contracts_hj3415/common/__init__.py +7 -0
  5. contracts_hj3415-0.5.1/src/contracts_hj3415/common/envelope.py +92 -0
  6. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/common/types.py +3 -1
  7. contracts_hj3415-0.5.0/src/contracts_hj3415/common/envelope.py +0 -46
  8. contracts_hj3415-0.5.0/src/contracts_hj3415/universe/__init__.py +0 -0
  9. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/LICENSE +0 -0
  10. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/README.md +0 -0
  11. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/__init__.py +0 -0
  12. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/analysis/__init__.py +0 -0
  13. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/analysis/payloads.py +0 -0
  14. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/analysis/types.py +0 -0
  15. {contracts_hj3415-0.5.0/src/contracts_hj3415/common → contracts_hj3415-0.5.1/src/contracts_hj3415/nfs}/__init__.py +0 -0
  16. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/c101.py +0 -0
  17. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/c103.py +0 -0
  18. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/c104.py +0 -0
  19. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/c106.py +0 -0
  20. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/c108.py +0 -0
  21. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/payloads.py +0 -0
  22. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/nfs/types.py +0 -0
  23. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/py.typed +0 -0
  24. {contracts_hj3415-0.5.0/src/contracts_hj3415/nfs → contracts_hj3415-0.5.1/src/contracts_hj3415/universe}/__init__.py +0 -0
  25. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/universe/krx300.py +0 -0
  26. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/universe/payloads.py +0 -0
  27. {contracts_hj3415-0.5.0 → contracts_hj3415-0.5.1}/src/contracts_hj3415/universe/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contracts-hj3415
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: DTO pakages for hj3415
5
5
  Keywords: example,demo
6
6
  Author-email: Hyungjin Kim <hj3415@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi"
4
4
 
5
5
  [project]
6
6
  name = "contracts-hj3415" # PyPI 이름 (하이픈 허용)
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  description = "DTO pakages for hj3415"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -30,5 +30,6 @@ class LatestAndTtm(TypedDict):
30
30
 
31
31
 
32
32
  class FeaturesPayload(TypedDict):
33
+ service: Literal["features"]
33
34
  endpoint: Endpoint
34
35
  blocks: dict[MetricKey, LatestAndTtm]
@@ -0,0 +1,7 @@
1
+ from .envelope import make_nfs_envelope, make_analysis_envelope, make_universe_envelope
2
+
3
+ __all__ = [ # pyright: ignore[reportUnsupportedDunderAll]
4
+ make_nfs_envelope,
5
+ make_analysis_envelope,
6
+ make_universe_envelope,
7
+ ]
@@ -0,0 +1,92 @@
1
+ # contracts_hj3415/common/envelope.py
2
+ from __future__ import annotations
3
+
4
+ from datetime import datetime
5
+ from typing import Literal, TypedDict
6
+
7
+ from contracts_hj3415.analysis.payloads import AnalysisPayloadDTO
8
+ from contracts_hj3415.common.types import CodeKey, EnvelopeMeta, Source
9
+
10
+ # topic별 payload 유니온
11
+ from contracts_hj3415.nfs.payloads import NfsPayloadDTO
12
+ from contracts_hj3415.universe.payloads import UniversePayloadDTO
13
+ from contracts_hj3415.universe.types import Universe
14
+
15
+
16
+ class NfsEnvelopeDTO(TypedDict):
17
+ topic: Literal["nfs"]
18
+ key: CodeKey
19
+ asof: datetime
20
+ payload: NfsPayloadDTO
21
+ meta: EnvelopeMeta
22
+
23
+
24
+ class UniverseEnvelopeDTO(TypedDict):
25
+ topic: Literal["universe"]
26
+ key: Universe
27
+ asof: datetime
28
+ payload: UniversePayloadDTO
29
+ meta: EnvelopeMeta
30
+
31
+
32
+ class AnalysisEnvelopeDTO(TypedDict):
33
+ topic: Literal["analysis"]
34
+ key: CodeKey
35
+ asof: datetime
36
+ payload: AnalysisPayloadDTO
37
+ meta: EnvelopeMeta
38
+
39
+
40
+ def _make_empty_envelope_meta(source: Source = "") -> EnvelopeMeta:
41
+ return {"source": source, "trace_id": "", "note": "", "tags": []}
42
+
43
+
44
+ # ---------- topic별 convenience wrappers ----------
45
+
46
+
47
+ def make_nfs_envelope(
48
+ *,
49
+ key: CodeKey,
50
+ asof: datetime,
51
+ payload: NfsPayloadDTO,
52
+ meta: EnvelopeMeta | None = None,
53
+ ) -> NfsEnvelopeDTO:
54
+ return {
55
+ "topic": "nfs",
56
+ "key": key,
57
+ "asof": asof,
58
+ "payload": payload,
59
+ "meta": meta or _make_empty_envelope_meta("scraper2"),
60
+ }
61
+
62
+
63
+ def make_universe_envelope(
64
+ *,
65
+ key: Universe,
66
+ asof: datetime,
67
+ payload: UniversePayloadDTO,
68
+ meta: EnvelopeMeta | None = None,
69
+ ) -> UniverseEnvelopeDTO:
70
+ return {
71
+ "topic": "universe",
72
+ "key": key,
73
+ "asof": asof,
74
+ "payload": payload,
75
+ "meta": meta or _make_empty_envelope_meta("krx"),
76
+ }
77
+
78
+
79
+ def make_analysis_envelope(
80
+ *,
81
+ key: str,
82
+ asof: datetime,
83
+ payload: AnalysisPayloadDTO,
84
+ meta: EnvelopeMeta | None = None,
85
+ ) -> AnalysisEnvelopeDTO:
86
+ return {
87
+ "topic": "analysis",
88
+ "key": key,
89
+ "asof": asof,
90
+ "payload": payload,
91
+ "meta": meta or _make_empty_envelope_meta("analyser2"),
92
+ }
@@ -9,9 +9,11 @@ CodeKey: TypeAlias = str
9
9
 
10
10
  Num: TypeAlias = float | int | None
11
11
 
12
+ Source: TypeAlias = Literal["", "scraper2", "krx", "analyser2"]
13
+
12
14
 
13
15
  class EnvelopeMeta(TypedDict, total=False):
14
- source: str # "scraper2" / "krx" / "analyser2" / ...
16
+ source: Source
15
17
  trace_id: str
16
18
  note: str
17
19
  tags: list[str]
@@ -1,46 +0,0 @@
1
- # contracts_hj3415/common/envelope.py
2
- from __future__ import annotations
3
-
4
- from datetime import datetime
5
- from typing import TypedDict
6
-
7
- from contracts_hj3415.analysis.payloads import AnalysisPayloadDTO
8
- from contracts_hj3415.common.types import EnvelopeMeta, Topic
9
-
10
- # topic별 payload 유니온
11
- from contracts_hj3415.nfs.payloads import NfsPayloadDTO
12
- from contracts_hj3415.universe.payloads import UniversePayloadDTO
13
-
14
-
15
- class EnvelopeDTO(TypedDict):
16
- """
17
- 모노레포 공통 운반 상자 DTO
18
-
19
- - key: topic별 식별자(문자열). 예)
20
- - nfs: "005930"
21
- - universe: "krx300"
22
- - analysis: "red:005930"
23
- """
24
-
25
- topic: Topic
26
- key: str
27
- asof: datetime
28
- payload: NfsPayloadDTO | UniversePayloadDTO | AnalysisPayloadDTO
29
- meta: EnvelopeMeta
30
-
31
-
32
- def make_envelope(
33
- *,
34
- topic: Topic,
35
- key: str,
36
- asof: datetime,
37
- payload: NfsPayloadDTO | UniversePayloadDTO | AnalysisPayloadDTO,
38
- meta: EnvelopeMeta | None = None,
39
- ) -> EnvelopeDTO:
40
- return {
41
- "topic": topic,
42
- "key": key,
43
- "asof": asof,
44
- "payload": payload,
45
- "meta": meta or EnvelopeMeta(),
46
- }