contracts-hj3415 0.5.0__py3-none-any.whl → 0.5.1__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.
@@ -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
+ ]
@@ -2,45 +2,91 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  from datetime import datetime
5
- from typing import TypedDict
5
+ from typing import Literal, TypedDict
6
6
 
7
7
  from contracts_hj3415.analysis.payloads import AnalysisPayloadDTO
8
- from contracts_hj3415.common.types import EnvelopeMeta, Topic
8
+ from contracts_hj3415.common.types import CodeKey, EnvelopeMeta, Source
9
9
 
10
10
  # topic별 payload 유니온
11
11
  from contracts_hj3415.nfs.payloads import NfsPayloadDTO
12
12
  from contracts_hj3415.universe.payloads import UniversePayloadDTO
13
+ from contracts_hj3415.universe.types import Universe
13
14
 
14
15
 
15
- class EnvelopeDTO(TypedDict):
16
- """
17
- 모노레포 공통 운반 상자 DTO
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
18
30
 
19
- - key: topic별 식별자(문자열). 예)
20
- - nfs: "005930"
21
- - universe: "krx300"
22
- - analysis: "red:005930"
23
- """
24
31
 
25
- topic: Topic
26
- key: str
32
+ class AnalysisEnvelopeDTO(TypedDict):
33
+ topic: Literal["analysis"]
34
+ key: CodeKey
27
35
  asof: datetime
28
- payload: NfsPayloadDTO | UniversePayloadDTO | AnalysisPayloadDTO
36
+ payload: AnalysisPayloadDTO
29
37
  meta: EnvelopeMeta
30
38
 
31
39
 
32
- def make_envelope(
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(
33
80
  *,
34
- topic: Topic,
35
81
  key: str,
36
82
  asof: datetime,
37
- payload: NfsPayloadDTO | UniversePayloadDTO | AnalysisPayloadDTO,
83
+ payload: AnalysisPayloadDTO,
38
84
  meta: EnvelopeMeta | None = None,
39
- ) -> EnvelopeDTO:
85
+ ) -> AnalysisEnvelopeDTO:
40
86
  return {
41
- "topic": topic,
87
+ "topic": "analysis",
42
88
  "key": key,
43
89
  "asof": asof,
44
90
  "payload": payload,
45
- "meta": meta or EnvelopeMeta(),
91
+ "meta": meta or _make_empty_envelope_meta("analyser2"),
46
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,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>
@@ -1,12 +1,12 @@
1
1
  contracts_hj3415/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  contracts_hj3415/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  contracts_hj3415/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- contracts_hj3415/analysis/features.py,sha256=aekf6l0hgwafW01DFPRkK9wGCaM6IbP9oL_UoAoZbtE,761
4
+ contracts_hj3415/analysis/features.py,sha256=Ne59LjflAVLjFCE2dmZYpuJ69RwWfGqLHFgQRAzwnVo,794
5
5
  contracts_hj3415/analysis/payloads.py,sha256=vmPhhAIwF3pyyhc9LL_7Q_ULg9hhsJ8v0Vsphtaiz0s,218
6
6
  contracts_hj3415/analysis/types.py,sha256=1idpQVb0n216u8Uua3bUlVEi-bjdfgd3IrLWSACXB0M,179
7
- contracts_hj3415/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- contracts_hj3415/common/envelope.py,sha256=1o_W06qc6DpVZbdrYxEo9oWvnA9EIb6nuRI_JVymXcM,1133
9
- contracts_hj3415/common/types.py,sha256=TpFKA0POm5eCNA8WMd8CcnHDed7zCoHgtgki7qSMnyU,398
7
+ contracts_hj3415/common/__init__.py,sha256=12izgeKLv63UTzCMdiZPNUTMuLx9ukwh_1Y_LD8xh8o,229
8
+ contracts_hj3415/common/envelope.py,sha256=fofpziHwimf-FTH-sTCgF3OIxmkv8cEpjJuRfUlgr-Q,2186
9
+ contracts_hj3415/common/types.py,sha256=8q1i1YEC9WYUaM1-ZaXcer_7ZY0gSFDEf11PTBmrPnU,424
10
10
  contracts_hj3415/nfs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  contracts_hj3415/nfs/c101.py,sha256=p_qY93mOvKJZTf5RFbcNKIGBSWYG93jcAQwI74XrjyE,759
12
12
  contracts_hj3415/nfs/c103.py,sha256=s_NbUo9PfVzc0pNr9SYp1z7UuqiBZfTQg8cYgZquY8Y,1028
@@ -19,7 +19,7 @@ contracts_hj3415/universe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
19
19
  contracts_hj3415/universe/krx300.py,sha256=TkP8_KfEdGC-bQhIyzL8fydCAvTRjFrevihFhYIo7Xg,470
20
20
  contracts_hj3415/universe/payloads.py,sha256=m4OOEG9J4lU4QBq31DyTSs9YQraE1SuaWpZzrB5AKQE,212
21
21
  contracts_hj3415/universe/types.py,sha256=doAj6MMyRV_Yg-xbp8Tkarb_lg6ttyIjV0wLahjfrSE,153
22
- contracts_hj3415-0.5.0.dist-info/licenses/LICENSE,sha256=QBiVGQuKAESeCfQE344Ik2ex6g2zfYdu9WqrRWydxIs,1068
23
- contracts_hj3415-0.5.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
24
- contracts_hj3415-0.5.0.dist-info/METADATA,sha256=meLstWxmMQbBrQr69PgoxN4VZhphpTFGwgA1YdtgFPU,376
25
- contracts_hj3415-0.5.0.dist-info/RECORD,,
22
+ contracts_hj3415-0.5.1.dist-info/licenses/LICENSE,sha256=QBiVGQuKAESeCfQE344Ik2ex6g2zfYdu9WqrRWydxIs,1068
23
+ contracts_hj3415-0.5.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
24
+ contracts_hj3415-0.5.1.dist-info/METADATA,sha256=CxYqHGNILcTFtOqGty92NpDwoKbA2ry0Ubx4tZs3DQ0,376
25
+ contracts_hj3415-0.5.1.dist-info/RECORD,,