contextbase-plugin-intercom 0.2.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,9 @@
1
+ Metadata-Version: 2.3
2
+ Name: contextbase-plugin-intercom
3
+ Version: 0.2.0
4
+ Summary: Intercom plugin for ContextBase (PyAirbyte-backed)
5
+ Author: Alizain Feerasta
6
+ Author-email: Alizain Feerasta <alizain.feerasta@gmail.com>
7
+ Requires-Dist: contextbase-shared-plugins==0.2.0
8
+ Requires-Dist: dagster==1.12.14
9
+ Requires-Python: >=3.14, <3.15
@@ -0,0 +1,9 @@
1
+ plugin_intercom/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
2
+ plugin_intercom/binding_config.py,sha256=Q6ELI6sjrPD5zit4P1kAl_8KSuObsOYwQP4EYAz94HE,296
3
+ plugin_intercom/component.py,sha256=1w3zPozVQrQ_d9tT6TLiiveznjuPsEzSn_SRMkEtjPo,3478
4
+ plugin_intercom/defs/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ plugin_intercom/defs/defs.yaml,sha256=5rlRz0VeFzW1h7GA1nfs6fhW9CuTlr5ayKxbbxSDzTk,54
6
+ plugin_intercom/plugin.json,sha256=LZOdayJ6X-J4GK6hSbgD1HO9vVy3DxgN4Eqg4p61RYc,84
7
+ contextbase_plugin_intercom-0.2.0.dist-info/WHEEL,sha256=fWriCkzqm-pffF5af4gJC9iI5FMFaJTuN9UxxxzOmdY,81
8
+ contextbase_plugin_intercom-0.2.0.dist-info/METADATA,sha256=mdpIOwzum-YJ1O-e3tZ8zWt4dEsF_ybgdmYmpOlgrmE,328
9
+ contextbase_plugin_intercom-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.11.14
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,12 @@
1
+ from __future__ import annotations
2
+
3
+ from shared_plugins.bindings import (
4
+ BaseBindingConfigModel,
5
+ StrictNonNegativeInt,
6
+ UtcTimestampText,
7
+ )
8
+
9
+
10
+ class IntercomBindingConfig(BaseBindingConfigModel):
11
+ start_date: UtcTimestampText
12
+ lookback_window: StrictNonNegativeInt | None = None
@@ -0,0 +1,101 @@
1
+ import dagster as dg
2
+ from dagster import AssetExecutionContext
3
+ from shared_plugins.automation import non_overlapping_automation_condition
4
+ from shared_plugins.bindings import (
5
+ parse_binding_config,
6
+ require_api_key,
7
+ )
8
+ from shared_plugins.control_plane import ControlPlaneClient
9
+ from shared_plugins.dlt import resolve_partition_binding
10
+ from shared_plugins.naming import (
11
+ dagster_airbyte_sync_asset_key,
12
+ dagster_asset_group_name,
13
+ dagster_asset_tags,
14
+ dagster_partition_def_name,
15
+ dagster_pool_name,
16
+ plugin_id_from_module,
17
+ )
18
+ from shared_plugins.pyairbyte import (
19
+ build_pyairbyte_source,
20
+ require_pyairbyte_selected_stream_names,
21
+ run_pyairbyte_sync,
22
+ )
23
+ from shared_types.api_key_auth import ApiKeyAuth
24
+
25
+ from .binding_config import IntercomBindingConfig
26
+
27
+ PLUGIN_ID = plugin_id_from_module(__file__)
28
+ DOCKER_IMAGE = "airbyte/source-intercom:0.13.18"
29
+ SOURCE_UPDATED_AT_FIELDS = {
30
+ "contacts": "updated_at",
31
+ "conversations": "updated_at",
32
+ }
33
+
34
+
35
+ def _build_connector_config(
36
+ cfg: IntercomBindingConfig,
37
+ auth: ApiKeyAuth,
38
+ ) -> dict[str, object]:
39
+ return {
40
+ "access_token": auth.api_key,
41
+ **cfg.model_dump(mode="json", exclude_none=True),
42
+ }
43
+
44
+
45
+ class IntercomSyncComponent(dg.Component):
46
+ def build_defs(self, context: dg.ComponentLoadContext) -> dg.Definitions:
47
+ partitions_def = dg.DynamicPartitionsDefinition(
48
+ name=dagster_partition_def_name(PLUGIN_ID)
49
+ )
50
+
51
+ @dg.asset(
52
+ key=dagster_airbyte_sync_asset_key(PLUGIN_ID),
53
+ group_name=dagster_asset_group_name(PLUGIN_ID),
54
+ tags=dagster_asset_tags(PLUGIN_ID),
55
+ automation_condition=non_overlapping_automation_condition(
56
+ dg.AutomationCondition.on_missing()
57
+ | dg.AutomationCondition.on_cron("*/15 * * * *")
58
+ ),
59
+ partitions_def=partitions_def,
60
+ pool=dagster_pool_name(PLUGIN_ID),
61
+ )
62
+ def intercom_sync_asset(
63
+ context: AssetExecutionContext,
64
+ control_plane: dg.ResourceParam[ControlPlaneClient],
65
+ ):
66
+ binding = resolve_partition_binding(
67
+ context=context,
68
+ control_plane=control_plane,
69
+ plugin_id=PLUGIN_ID,
70
+ )
71
+ binding_id = str(binding.binding_id)
72
+ cfg = parse_binding_config(binding, IntercomBindingConfig)
73
+ auth = require_api_key(binding)
74
+ selected_stream_names = require_pyairbyte_selected_stream_names(binding)
75
+
76
+ connector_config = _build_connector_config(cfg, auth)
77
+ source = build_pyairbyte_source(
78
+ docker_image=DOCKER_IMAGE,
79
+ connector_config=connector_config,
80
+ )
81
+
82
+ return run_pyairbyte_sync(
83
+ context=context,
84
+ plugin_id=PLUGIN_ID,
85
+ binding_id=binding_id,
86
+ selected_stream_names=selected_stream_names,
87
+ source_updated_at_fields=SOURCE_UPDATED_AT_FIELDS,
88
+ source=source,
89
+ )
90
+
91
+ automation_sensor = dg.AutomationConditionSensorDefinition(
92
+ name="intercom_automation_sensor",
93
+ target=dg.AssetSelection.assets(intercom_sync_asset),
94
+ default_status=dg.DefaultSensorStatus.RUNNING,
95
+ minimum_interval_seconds=30,
96
+ )
97
+
98
+ return dg.Definitions(
99
+ assets=[intercom_sync_asset],
100
+ sensors=[automation_sensor],
101
+ )
@@ -0,0 +1 @@
1
+
@@ -0,0 +1 @@
1
+ type: plugin_intercom.component.IntercomSyncComponent
@@ -0,0 +1,7 @@
1
+ {
2
+ "auth": {
3
+ "type": "api_key"
4
+ },
5
+ "mode": "dagster",
6
+ "plugin_id": "intercom"
7
+ }