contextbase-plugin-microsoft-calendar 0.5.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.
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.3
2
+ Name: contextbase-plugin-microsoft-calendar
3
+ Version: 0.5.0
4
+ Summary: Microsoft Calendar plugin for ContextBase
5
+ Author: Alizain Feerasta
6
+ Author-email: Alizain Feerasta <alizain.feerasta@gmail.com>
7
+ Requires-Dist: azure-identity>=1.25.1
8
+ Requires-Dist: dagster==1.12.14
9
+ Requires-Dist: dagster-dlt==0.28.14
10
+ Requires-Dist: dlt[duckdb]>=1.26.0
11
+ Requires-Dist: msgraph-beta-sdk>=1.59.0
12
+ Requires-Dist: pydantic>=2.12.0
13
+ Requires-Dist: contextbase-shared-plugins==0.5.0
14
+ Requires-Python: >=3.12, <3.13
@@ -0,0 +1,16 @@
1
+ plugin_microsoft_calendar/__init__.py,sha256=lHKUHWlw_OzYGpygFYyeENy5Z8Ex2wKXcHDokONpTzI,41
2
+ plugin_microsoft_calendar/binding_config.py,sha256=GHhAXcmuSkSbKCSKKAFPeA8YIZCbDAP86qdz_gITM2g,235
3
+ plugin_microsoft_calendar/component.py,sha256=9F3xuTPYccdUoADQ-ilBJ2dfwDDMFe8NiyjbWTH_JKw,4084
4
+ plugin_microsoft_calendar/models/__init__.py,sha256=lnbXYLwz1CncE7srQad9rxuV8upNrA9yzfWqgTG6sXg,53
5
+ plugin_microsoft_calendar/models/ctx.py,sha256=CyChavg1FXWbWyxINkpgPnw8AYH3g49f2KsUpnZnLKg,21522
6
+ plugin_microsoft_calendar/models/ingress.py,sha256=R_9mOMaV69pIBouxaMstL3KRf_daRO1HZrpQ_m0ftVM,11437
7
+ plugin_microsoft_calendar/models/translators.py,sha256=POAwJYz0Ha17lgyZhxStMcH-bj7aAfJlz95dlJvqDQc,8639
8
+ plugin_microsoft_calendar/plugin.json,sha256=SmGTdp6eSzKt8uk-BrWNT2K0DHYazmeYXaGVQMFI9O0,105
9
+ plugin_microsoft_calendar/sources/__init__.py,sha256=a6Vtc3DWBf1OglF6UdCTwNtrUJ-eiybC_6qAKZnWv18,53
10
+ plugin_microsoft_calendar/sources/sync.py,sha256=pfF5wEeMweF8HdU1abM_Cs4qb7Nv-PI5x6Rype6xKqs,12721
11
+ plugin_microsoft_calendar/utils/__init__.py,sha256=CjzjKMbRq4S7OUZuQ_M9U_b8W0uGtW3tkgVewb8tGWE,57
12
+ plugin_microsoft_calendar/utils/client.py,sha256=Uz7h5AYyCmyBopjRliW23vriYqGL2aWhv4NM5_DUqxM,4612
13
+ contextbase_plugin_microsoft_calendar-0.5.0.dist-info/WHEEL,sha256=i9aSRDivn5iP9LaR1BLQX2GNAuriQWPsFwbbWygTX2k,81
14
+ contextbase_plugin_microsoft_calendar-0.5.0.dist-info/entry_points.txt,sha256=FVqaBtkD9T61fUfiLj9m7Y2SsZY47FKQ7hDp7Lzfsmk,108
15
+ contextbase_plugin_microsoft_calendar-0.5.0.dist-info/METADATA,sha256=G_qfOQEniqCd3Z_V2JQnk0G64JBI-QmmA4AcqqQ34sU,510
16
+ contextbase_plugin_microsoft_calendar-0.5.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.11.15
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [contextlayer.plugins]
2
+ microsoft_calendar = plugin_microsoft_calendar.component:MicrosoftCalendarComponent
3
+
@@ -0,0 +1 @@
1
+ """Microsoft Calendar plugin package."""
@@ -0,0 +1,8 @@
1
+ from __future__ import annotations
2
+
3
+ from shared_plugins.bindings import BaseBindingConfigModel, NonEmptyText
4
+
5
+
6
+ class MicrosoftCalendarBindingConfig(BaseBindingConfigModel):
7
+ tenant_id: NonEmptyText
8
+ mailbox_user_id: NonEmptyText
@@ -0,0 +1,113 @@
1
+ import dagster as dg
2
+ from dagster import AssetExecutionContext
3
+ from dagster_dlt import DagsterDltResource
4
+ from shared_plugins.automation import non_overlapping_automation_condition
5
+ from shared_plugins.base_platform import BasePlatformClient
6
+ from shared_plugins.bindings import parse_binding_config, require_client_credentials
7
+ from shared_plugins.dlt import resolve_partition_binding, run_dlt_pipeline
8
+ from shared_plugins.naming import (
9
+ dagster_asset_group_name,
10
+ dagster_asset_tags,
11
+ dagster_dlt_asset_key,
12
+ dagster_partition_def_name,
13
+ dagster_pool_name,
14
+ dlt_source_name,
15
+ plugin_id_from_module,
16
+ )
17
+ from shared_plugins.resources import DLT_RESOURCE
18
+
19
+ from .binding_config import MicrosoftCalendarBindingConfig
20
+ from .sources.sync import microsoft_calendar_source
21
+ from .utils.client import SyncGraphCalendarClient
22
+
23
+ PLUGIN_ID = plugin_id_from_module(__file__)
24
+ SYNC_JOB = "sync"
25
+
26
+ SYNC_SOURCE_NAME = dlt_source_name(PLUGIN_ID, SYNC_JOB)
27
+
28
+ CALENDARS_ASSET_KEY = dagster_dlt_asset_key(SYNC_SOURCE_NAME, "calendars")
29
+ EVENTS_ASSET_KEY = dagster_dlt_asset_key(SYNC_SOURCE_NAME, "events")
30
+
31
+
32
+ def _build_sync_specs(
33
+ partitions_def: dg.PartitionsDefinition,
34
+ automation_condition: dg.AutomationCondition,
35
+ ) -> list[dg.AssetSpec]:
36
+ shared = dict(
37
+ group_name=dagster_asset_group_name(PLUGIN_ID),
38
+ tags=dagster_asset_tags(PLUGIN_ID, extra_tags={"ctx_primary": "true"}),
39
+ automation_condition=automation_condition,
40
+ partitions_def=partitions_def,
41
+ )
42
+ return [
43
+ dg.AssetSpec(key=CALENDARS_ASSET_KEY, **shared),
44
+ dg.AssetSpec(key=EVENTS_ASSET_KEY, deps=[CALENDARS_ASSET_KEY], **shared),
45
+ ]
46
+
47
+
48
+ class MicrosoftCalendarComponent(dg.Component):
49
+ def build_defs(self, context: dg.ComponentLoadContext) -> dg.Definitions:
50
+ partitions_def = dg.DynamicPartitionsDefinition(
51
+ name=dagster_partition_def_name(PLUGIN_ID)
52
+ )
53
+
54
+ sync_specs = _build_sync_specs(
55
+ partitions_def,
56
+ non_overlapping_automation_condition(
57
+ dg.AutomationCondition.on_missing()
58
+ | dg.AutomationCondition.on_cron("*/15 * * * *")
59
+ ),
60
+ )
61
+
62
+ @dg.multi_asset(
63
+ specs=sync_specs,
64
+ can_subset=False,
65
+ name="microsoft_calendar_sync",
66
+ pool=dagster_pool_name(PLUGIN_ID),
67
+ )
68
+ def microsoft_calendar_sync_assets(
69
+ context: AssetExecutionContext,
70
+ dlt_resource: DagsterDltResource,
71
+ base_platform: dg.ResourceParam[BasePlatformClient],
72
+ ):
73
+ binding = resolve_partition_binding(
74
+ context=context,
75
+ base_platform=base_platform,
76
+ plugin_id=PLUGIN_ID,
77
+ )
78
+ binding_id = binding.binding_id
79
+ cfg = parse_binding_config(binding, MicrosoftCalendarBindingConfig)
80
+ auth = require_client_credentials(binding)
81
+
82
+ with SyncGraphCalendarClient(
83
+ auth=auth,
84
+ tenant_id=cfg.tenant_id,
85
+ mailbox_user_id=cfg.mailbox_user_id,
86
+ ) as client:
87
+ source = microsoft_calendar_source(
88
+ binding_id,
89
+ client=client,
90
+ )
91
+ yield from run_dlt_pipeline(
92
+ context=context,
93
+ dlt_resource=dlt_resource,
94
+ source=source,
95
+ plugin_id=PLUGIN_ID,
96
+ binding_id=binding_id,
97
+ job_name=SYNC_JOB,
98
+ )
99
+
100
+ automation_sensor = dg.AutomationConditionSensorDefinition(
101
+ name="microsoft_calendar_automation_sensor",
102
+ target=dg.AssetSelection.assets(microsoft_calendar_sync_assets),
103
+ default_status=dg.DefaultSensorStatus.RUNNING,
104
+ minimum_interval_seconds=30,
105
+ )
106
+
107
+ return dg.Definitions(
108
+ assets=[microsoft_calendar_sync_assets],
109
+ sensors=[automation_sensor],
110
+ resources={
111
+ "dlt_resource": DLT_RESOURCE,
112
+ },
113
+ )
@@ -0,0 +1 @@
1
+ """Data models for the Microsoft Calendar plugin."""