dq-export-connector 0.1.0.dev37__tar.gz → 0.1.0.dev39__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 (123) hide show
  1. dq_export_connector-0.1.0.dev39/.gitignore +5 -0
  2. dq_export_connector-0.1.0.dev39/PKG-INFO +274 -0
  3. dq_export_connector-0.1.0.dev39/README.md +247 -0
  4. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/export_connector_credentials.py +61 -1
  5. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/export_receipt.py +201 -16
  6. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/export_worker_config.py +233 -0
  7. dq_export_connector-0.1.0.dev39/dq_export_connector/audience/classify.py +84 -0
  8. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/audience/export.py +19 -4
  9. dq_export_connector-0.1.0.dev39/dq_export_connector/audience/http.py +272 -0
  10. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/audience/identifiers.py +15 -2
  11. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/audience/sync.py +35 -5
  12. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/errors.py +7 -0
  13. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_dv360/destination.py +1 -0
  14. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/meta/destination.py +1 -0
  15. dq_export_connector-0.1.0.dev39/dq_export_connector/models/one_dsp.py +29 -0
  16. dq_export_connector-0.1.0.dev39/dq_export_connector/models/snap.py +37 -0
  17. dq_export_connector-0.1.0.dev39/dq_export_connector/models/tiktok.py +37 -0
  18. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/oauth.py +6 -2
  19. dq_export_connector-0.1.0.dev39/dq_export_connector/one_dsp/export.py +111 -0
  20. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/redact.py +49 -5
  21. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/runner.py +103 -3
  22. dq_export_connector-0.1.0.dev39/dq_export_connector/snap/client.py +169 -0
  23. dq_export_connector-0.1.0.dev39/dq_export_connector/snap/destination.py +116 -0
  24. dq_export_connector-0.1.0.dev39/dq_export_connector/snap/export.py +96 -0
  25. dq_export_connector-0.1.0.dev39/dq_export_connector/snap/session.py +46 -0
  26. dq_export_connector-0.1.0.dev39/dq_export_connector/snap/validate.py +27 -0
  27. dq_export_connector-0.1.0.dev39/dq_export_connector/tiktok/__init__.py +0 -0
  28. dq_export_connector-0.1.0.dev39/dq_export_connector/tiktok/client.py +251 -0
  29. dq_export_connector-0.1.0.dev39/dq_export_connector/tiktok/destination.py +248 -0
  30. dq_export_connector-0.1.0.dev39/dq_export_connector/tiktok/export.py +101 -0
  31. dq_export_connector-0.1.0.dev39/dq_export_connector/tiktok/session.py +46 -0
  32. dq_export_connector-0.1.0.dev39/dq_export_connector/tiktok/validate.py +43 -0
  33. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/pyproject.toml +16 -3
  34. dq_export_connector-0.1.0.dev39/scripts/_local.py +148 -0
  35. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/scripts/codegen-models.sh +1 -1
  36. dq_export_connector-0.1.0.dev39/scripts/run_local.py +55 -0
  37. dq_export_connector-0.1.0.dev39/tests/__init__.py +0 -0
  38. dq_export_connector-0.1.0.dev39/tests/conftest.py +37 -0
  39. dq_export_connector-0.1.0.dev39/tests/fakes/__init__.py +0 -0
  40. dq_export_connector-0.1.0.dev39/tests/fakes/snap_fake.py +340 -0
  41. dq_export_connector-0.1.0.dev39/tests/fakes/tiktok_fake.py +324 -0
  42. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/support.py +77 -0
  43. dq_export_connector-0.1.0.dev39/tests/test_adform_runner.py +72 -0
  44. dq_export_connector-0.1.0.dev39/tests/test_audience_http.py +284 -0
  45. dq_export_connector-0.1.0.dev39/tests/test_file_naming.py +25 -0
  46. dq_export_connector-0.1.0.dev39/tests/test_google_ad_manager_runner.py +169 -0
  47. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_identifiers_and_inputs.py +27 -0
  48. dq_export_connector-0.1.0.dev39/tests/test_live_adform.py +50 -0
  49. dq_export_connector-0.1.0.dev39/tests/test_live_google_ad_manager.py +51 -0
  50. dq_export_connector-0.1.0.dev39/tests/test_live_one_dsp.py +53 -0
  51. dq_export_connector-0.1.0.dev39/tests/test_live_snap.py +137 -0
  52. dq_export_connector-0.1.0.dev39/tests/test_live_tiktok.py +110 -0
  53. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_oauth.py +12 -1
  54. dq_export_connector-0.1.0.dev39/tests/test_one_dsp_runner.py +74 -0
  55. dq_export_connector-0.1.0.dev39/tests/test_redact.py +119 -0
  56. dq_export_connector-0.1.0.dev39/tests/test_scripts.py +22 -0
  57. dq_export_connector-0.1.0.dev39/tests/test_snap_runner.py +737 -0
  58. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_sync_input.py +36 -4
  59. dq_export_connector-0.1.0.dev39/tests/test_tiktok_runner.py +624 -0
  60. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/uv.lock +16 -4
  61. dq_export_connector-0.1.0.dev37/.gitignore +0 -63
  62. dq_export_connector-0.1.0.dev37/PKG-INFO +0 -100
  63. dq_export_connector-0.1.0.dev37/README.md +0 -79
  64. dq_export_connector-0.1.0.dev37/tests/test_file_kinds_runner.py +0 -275
  65. dq_export_connector-0.1.0.dev37/tests/test_live_file_kinds.py +0 -106
  66. dq_export_connector-0.1.0.dev37/tests/test_redact.py +0 -47
  67. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/.python-version +0 -0
  68. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/__init__.py +0 -0
  69. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/__init__.py +0 -0
  70. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/application_error.py +0 -0
  71. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/application_warning.py +0 -0
  72. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/_models/destination_account_listing.py +0 -0
  73. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/adform/__init__.py +0 -0
  74. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/adform/export.py +0 -0
  75. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/audience/__init__.py +0 -0
  76. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/audience/inputs.py +0 -0
  77. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/bucket/__init__.py +0 -0
  78. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/bucket/export.py +0 -0
  79. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/bucket/paths.py +0 -0
  80. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/bucket/store.py +0 -0
  81. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/bucket/upload.py +0 -0
  82. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/bucket/validate.py +0 -0
  83. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/datasets.py +0 -0
  84. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/files/__init__.py +0 -0
  85. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/files/export.py +0 -0
  86. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/files/naming.py +0 -0
  87. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_ad_manager/__init__.py +0 -0
  88. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_ad_manager/export.py +0 -0
  89. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_ad_manager/store.py +0 -0
  90. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_auth.py +0 -0
  91. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_dv360/__init__.py +0 -0
  92. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_dv360/clients.py +0 -0
  93. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_dv360/export.py +0 -0
  94. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_dv360/validate.py +0 -0
  95. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/google_oauth.py +0 -0
  96. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/log.py +0 -0
  97. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/meta/__init__.py +0 -0
  98. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/meta/client.py +0 -0
  99. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/meta/export.py +0 -0
  100. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/meta/validate.py +0 -0
  101. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/__init__.py +0 -0
  102. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/adform.py +0 -0
  103. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/audience.py +0 -0
  104. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/bucket.py +0 -0
  105. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/google.py +0 -0
  106. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/google_ad_manager.py +0 -0
  107. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/google_dv360.py +0 -0
  108. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/models/meta.py +0 -0
  109. {dq_export_connector-0.1.0.dev37/tests → dq_export_connector-0.1.0.dev39/dq_export_connector/one_dsp}/__init__.py +0 -0
  110. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/dq_export_connector/outcome.py +0 -0
  111. {dq_export_connector-0.1.0.dev37/tests/fakes → dq_export_connector-0.1.0.dev39/dq_export_connector/snap}/__init__.py +0 -0
  112. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/fakes/google_dv360_fake.py +0 -0
  113. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/fakes/meta_fake.py +0 -0
  114. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_google_dv360_runner.py +0 -0
  115. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_live_buckets.py +0 -0
  116. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_live_google_dv360.py +0 -0
  117. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_live_meta.py +0 -0
  118. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_meta_runner.py +0 -0
  119. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_models_are_current.py +0 -0
  120. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_paths.py +0 -0
  121. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_runner.py +0 -0
  122. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_store.py +0 -0
  123. {dq_export_connector-0.1.0.dev37 → dq_export_connector-0.1.0.dev39}/tests/test_upload.py +0 -0
@@ -0,0 +1,5 @@
1
+ # Local secrets for the local runner.
2
+ credentials*.json
3
+ platform_secrets*.json
4
+ local/
5
+ /config*.json
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.5
2
+ Name: dq-export-connector
3
+ Version: 0.1.0.dev39
4
+ Summary: Worker logic for the Export Connector DCR.
5
+ Author: Decentriq
6
+ Requires-Python: >=3.12
7
+ Requires-Dist: pydantic<3,>=2.14
8
+ Provides-Extra: adform
9
+ Requires-Dist: obstore<0.12,>=0.11.1; extra == 'adform'
10
+ Provides-Extra: bucket
11
+ Requires-Dist: obstore<0.12,>=0.11.1; extra == 'bucket'
12
+ Provides-Extra: google-ad-manager
13
+ Requires-Dist: obstore<0.12,>=0.11.1; extra == 'google-ad-manager'
14
+ Provides-Extra: google-dv360
15
+ Requires-Dist: google-ads-datamanager<0.10,>=0.9.5; extra == 'google-dv360'
16
+ Requires-Dist: google-auth<3,>=2.63; extra == 'google-dv360'
17
+ Requires-Dist: requests<3,>=2.32; extra == 'google-dv360'
18
+ Provides-Extra: meta
19
+ Requires-Dist: facebook-business<28,>=27.0.1; extra == 'meta'
20
+ Provides-Extra: one-dsp
21
+ Requires-Dist: obstore<0.12,>=0.11.1; extra == 'one-dsp'
22
+ Provides-Extra: snap
23
+ Requires-Dist: requests<3,>=2.32; extra == 'snap'
24
+ Provides-Extra: tiktok
25
+ Requires-Dist: requests<3,>=2.32; extra == 'tiktok'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # dq-export-connector
29
+
30
+ Worker logic for the **Export Connector DCR**: one package for every
31
+ Connector Kind, each in its own sub-package with an extra of the same name for
32
+ its dependencies:
33
+
34
+ | Kind | Extra | What a run does | Through |
35
+ | --- | --- | --- | --- |
36
+ | Bucket | `bucket` | Uploads each Input's dataset to S3, Azure Blob or GCS | [`obstore`](https://developmentseed.org/obstore/) |
37
+ | Meta | `meta` | Fills a customer list custom audience per Input | Meta's [`facebook-business`](https://github.com/facebook/facebook-python-business-sdk) SDK |
38
+ | Google DV360 | `google-dv360` | Fills a Customer Match user list per Input | Google's [`google-ads-datamanager`](https://github.com/googleads/data-manager-python) client |
39
+ | Google Ad Manager | `google-ad-manager` | Writes a batch upload file per Input to the network's GCS bucket | `obstore` |
40
+ | Adform | `adform` | Writes an identifier file per Input to Adform's S3 bucket | `obstore` |
41
+ | OneDSP | `one-dsp` | Writes an identifier file per Input to the S3 bucket of OneLog's Adform seat | `obstore` |
42
+ | Snap | `snap` | Fills a Snap Segment per Input with hashed identifiers | Snap's Marketing API, over `requests` |
43
+ | TikTok | `tiktok` | Fills a TikTok Segment (a Custom Audience) per Input with hashed identifiers | TikTok's API for Business, over `requests` |
44
+
45
+ ddc pins this package by hash in a fully locked `requirements.txt` and runs
46
+ `dq_export_connector.runner.main` in the task's Python environment. It is
47
+ published to PyPI, since the compiled graph installs it from there.
48
+
49
+ - `dq_export_connector.runner`: the entry point. Reads `/input/config.json`
50
+ and `/input/credentials.json`, sets up logging, and dispatches on the
51
+ Connector Kind and the action, then writes what the action reports under
52
+ `/internal`: an export's receipt, and either action's warnings and error, as
53
+ the task's Task Report, Application Warnings and Application Error. An action
54
+ with an error also writes it as `/internal/safe_error`, `CODE: message`,
55
+ which the container worker shows as the task's `error`, and exits with 1.
56
+ - `dq_export_connector.errors`: the error and warning codes the worker
57
+ reports, `ExportConnectorError`, which stops an action with an error code,
58
+ and `ExportConnectorWarning`. Each becomes an Application Error or Warning
59
+ with its credentials masked, its message cut to 1,000 characters and a
60
+ provider's own error to 4,000.
61
+ - `dq_export_connector.outcome`: collects a run's error, warnings and receipt
62
+ while it runs.
63
+ - `dq_export_connector.redact`: keeps every value from the sealed half, and
64
+ URL query strings, out of log lines and result messages. For Snap and
65
+ TikTok it also masks tokens, `key=secret` pairs, JWTs and SHA-256 or MD5 hex,
66
+ which their APIs may echo back.
67
+ - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
68
+ `Export`).
69
+ - `dq_export_connector.audience`: what the kinds that fill Segments share.
70
+ An Input is one value per line, which `identifiers` and `inputs` normalise,
71
+ hash where the platform takes hashes, and count when invalid. `sync` runs
72
+ an Input into its Segment through a kind's `AudienceDestination`: find the
73
+ Segment by name or create it, stage the values in batches, commit. `export`
74
+ loops over the Inputs and keeps the receipt. `http` and `classify` are the
75
+ HTTPS client of the kinds without a provider library: an allowlist of hosts,
76
+ retries by idempotency class, and the verdict on each answer.
77
+ - `dq_export_connector.meta`, `google_dv360`, `snap` and `tiktok`: the
78
+ Segment kinds, each an `AudienceDestination` over its provider's API, with a
79
+ `ValidateConnection` that checks the connector's Destination Account or lists
80
+ the accounts the credentials reach.
81
+ - `dq_export_connector.files`: what the kinds that upload identifier files
82
+ share: the file's name, its rows and its upload.
83
+ - `dq_export_connector.google_ad_manager`, `dq_export_connector.adform` and
84
+ `dq_export_connector.one_dsp`: the file kinds, which format an Input's rows
85
+ and name its object.
86
+ - `dq_export_connector.oauth`, `google_auth` and `google_oauth`: Access Tokens
87
+ from an OAuth Grant, and Google credentials from either Credential Scheme.
88
+ - `dq_export_connector.models`: the types the worker reads and writes, those
89
+ of every Connector Kind directly in it and a kind's own in its submodule,
90
+ such as `models.bucket`. They are pydantic models generated in
91
+ `dq_export_connector._models` from ddc's JSON schemas, so the config the
92
+ worker reads and the receipt, warnings and errors it writes match
93
+ ddc's Rust types. Regenerate them with `scripts/codegen-models.sh` after the
94
+ types change and `decentriq_dcr_compiler` has been rebuilt; a test fails
95
+ while they are stale.
96
+
97
+ ```sh
98
+ uv run pytest # unit tests, against obstore's in-memory store and fakes of the providers' APIs
99
+ uv run pytest -m live # against real buckets and accounts, credentials from the environment
100
+ uv run mypy dq_export_connector tests
101
+ ```
102
+
103
+ A live test skips when its credentials are missing; each test file's
104
+ docstring names the variables it reads.
105
+
106
+ ## Snap
107
+
108
+ A Snap connector's config names the ad account (set after consent, from a
109
+ `ValidateConnection` in `list` mode) and, per Input, a Segment, the identifier type its
110
+ lines hold and a Merge Mode. ddc validates it. The credentials are the OAuth
111
+ Grant of the Snap user who consented; each run turns it into an Access Token
112
+ with `dq_export_connector.oauth`. Decentriq's Snap app is the
113
+ `export_connector_snap_app` platform secret (`{"clientId", "clientSecret"}`),
114
+ mounted at `/input/oauth_app.json`. `ValidateConnection` in `list` mode lists
115
+ the ad accounts of every organization the grant reaches; in `check` mode it
116
+ reads the picked one.
117
+
118
+ A run looks each Segment up by name in the ad account and creates it when
119
+ there is none, marked `Managed by Decentriq`. It writes into a same-named
120
+ Segment whoever made it, with a `SEGMENT_NOT_MANAGED` warning when Decentriq
121
+ didn't. ADD adds the Input's values; REPLACE empties the Segment first, so it
122
+ is briefly empty. A run stops at the first Input that fails. When the failure
123
+ came after the Segment changed, the error says so; a rerun is safe in both
124
+ modes. Don't run one connector twice at the same time.
125
+
126
+ An Input is one file of values, or a stored ZIP holding one: one value per
127
+ line, UTF-8, optional BOM, LF or CRLF, surrounding double quotes removed,
128
+ empty lines skipped, no header.
129
+
130
+ ### Identifiers
131
+
132
+ | Type | Normalisation before SHA-256 | Snap schema |
133
+ |---|---|---|
134
+ | `EMAIL` | trim, lowercase; exactly one `@` with text on both sides | `EMAIL_SHA256` |
135
+ | `PHONE` | drop a `(0)` right after the country code (`+44 (0)20…`, `+44-(0)20…`), keep digits (any script's, as ASCII; drops `+`), drop a leading `00`; 8–15 digits, not starting with `0` | `PHONE_SHA256` |
136
+ | `IDFA`, `GAID` | UUID form with hyphens, lowercased | `MOBILE_AD_ID_SHA256` |
137
+ | `*_SHA256` | must be 64 hex characters; lowercased, otherwise unchanged | as above |
138
+
139
+ Snap takes SHA-256 only, so the `*_MD5` types are rejected when the config is
140
+ compiled. A pre-hashed value only matches if it was hashed from the same form: for
141
+ `PHONE_SHA256`, the digits with country code and no `+` (`41791234567`).
142
+
143
+ Up to 25% invalid rows gives an `INVALID_ROWS` warning; more fails the run
144
+ before the Segment changes. An empty Input gives an `EMPTY_DATASET` warning
145
+ and leaves its Segment as it was, in both modes.
146
+
147
+ The receipt counts invalid rows by reason (`counts.invalidReasons`, and in the
148
+ warning or error message), never with the values themselves:
149
+
150
+ | Reason | Meaning |
151
+ |---|---|
152
+ | `EMAIL_NO_AT_SIGN`, `EMAIL_MULTIPLE_AT_SIGNS` | not exactly one `@` |
153
+ | `EMAIL_EMPTY_LOCAL_PART`, `EMAIL_EMPTY_DOMAIN` | nothing before or after the `@` |
154
+ | `PHONE_NO_DIGITS` | no digits at all |
155
+ | `PHONE_NATIONAL_FORMAT` | starts with `0` after dropping `00`, i.e. no country code |
156
+ | `PHONE_TOO_SHORT`, `PHONE_TOO_LONG` | fewer than 8 or more than 15 digits |
157
+ | `NOT_A_MOBILE_AD_ID` | not a UUID with hyphens |
158
+ | `NOT_SHA256_HEX` | a `*_SHA256` value that isn't 64 hex characters |
159
+ | `NOT_MD5_HEX` | a `*_MD5` value that isn't 32 hex characters |
160
+ | `NOT_UTF8` | the line isn't valid UTF-8 |
161
+ | `CONTROL_CHARACTERS` | the value holds control characters or a byte order mark, usually because the file is UTF-16 |
162
+
163
+ ### Testing against Snap
164
+
165
+ The local files are gitignored in this directory:
166
+
167
+ - `platform_secrets.json`: `{"export_connector_snap_app": {"clientId": …, "clientSecret": …}}`, the dev app.
168
+ - `credentials.json`: `{"type": "snap", "credentials": {"refreshToken": …}}`, a refresh token the owner got through consent on a dev environment. Snap doesn't rotate it, so it can be reused.
169
+ - `config.json`: `{"connector": {"type": "snap", "adAccountId": …, "inputs": [{"leafId": "segA", "segmentName": …, "identifierType": "EMAIL", "mergeMode": "ADD", "retentionDays": 180}]}}`.
170
+
171
+ 1. Run:
172
+
173
+ ```sh
174
+ mkdir -p local/inputs && printf 'a@example.com\nb@example.com\n' > local/inputs/segA
175
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
176
+ --platform-secrets platform_secrets.json --mode validate
177
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
178
+ --platform-secrets platform_secrets.json
179
+ ```
180
+ 2. Live tests, including the check that Snap doesn't rotate refresh tokens:
181
+
182
+ ```sh
183
+ DQ_EXPORT_LIVE_SNAP_DIR=$PWD uv run pytest -m live -s tests/test_live_snap.py
184
+ ```
185
+
186
+ ## TikTok
187
+
188
+ A TikTok connector's config names the advertiser (set after consent, from a
189
+ `ValidateConnection` in `list` mode) and, per Input, a Segment, the identifier
190
+ type its lines hold, a Merge Mode, and `replaceExistingSegment`. ddc validates
191
+ it. The credentials are the OAuth Grant of the TikTok user who consented, and
192
+ its Access Token is long-lived: TikTok neither expires nor refreshes it, so
193
+ a refused token ends the run with `UNAUTHENTICATED`, and the owner connects
194
+ again. Decentriq's app is the `export_connector_tiktok_app` platform secret
195
+ (`{"clientId", "clientSecret"}`), mounted at `/input/oauth_app.json`. Every
196
+ call carries the token as the `Access-Token` header, and the client waits one
197
+ second between calls to the same Segment endpoint. `ValidateConnection` in
198
+ `list` mode lists the advertisers the grant reaches; in `check` mode it checks
199
+ the picked one is among them and that its Segments can be listed.
200
+
201
+ A run looks each Segment up by name in the advertiser, listing them once
202
+ before the first Input, and creates it at the end of the Input when there is
203
+ none. TikTok has no description to mark a Segment with, so the run can tell
204
+ only that the advertiser created it through the API and every change to it
205
+ went through the API. A Segment that fails this, such as one edited in Ads
206
+ Manager, is written with a `SEGMENT_NOT_MANAGED` warning.
207
+
208
+ Each Input's values are uploaded as files first, which changes no Segment. The
209
+ run then makes one create, or one update with `APPEND` or `REPLACE`, over all
210
+ the files, because TikTok allows one REPLACE a day per Segment. Before
211
+ uploading, a run waits up to 10 minutes for TikTok to make the Segment
212
+ editable again, then fails with `SEGMENT_BUSY`.
213
+
214
+ REPLACE on a Segment the run didn't create needs `replaceExistingSegment: true`
215
+ on that Input, which confirms only this connector writes to it; without it the
216
+ run fails with `REPLACE_NOT_CONFIRMED` before any upload. TikTok can't tell
217
+ which API client made a Segment, so the confirmation is the only guard.
218
+ A Segment under 1,000 matched users can't be updated by TikTok, which gives a
219
+ `SEGMENT_TOO_SMALL` warning. An empty Input gives an `EMPTY_DATASET` warning
220
+ and leaves its Segment as it was, in both modes.
221
+
222
+ The identifiers are normalised for TikTok's `calculate_type`s:
223
+
224
+ | Type | Normalisation before SHA-256 | TikTok `calculate_type` |
225
+ |---|---|---|
226
+ | `EMAIL` | trim, lowercase | `EMAIL_SHA256` |
227
+ | `PHONE` | as for Snap, then E.164 with the `+` (`+442071838750`) | `PHONE_SHA256` |
228
+ | `IDFA`, `GAID` | UUID form with hyphens, lowercased | `IDFA_SHA256`, `GAID_SHA256` |
229
+ | `*_SHA256` | must be 64 hex characters; lowercased, otherwise unchanged | as above |
230
+ | `IDFA_MD5`, `GAID_MD5` | already hashed with MD5: must be 32 hex characters; lowercased, otherwise unchanged | `IDFA_MD5`, `GAID_MD5` |
231
+
232
+ Raw mobile ad IDs are always sent as SHA-256; the MD5 types are for IDs that
233
+ were only kept hashed with MD5. Such a value only matches if it was hashed from
234
+ the ID in its UUID form with hyphens, upper or lower case
235
+ (`AECE52E7-03EE-455A-B3C4-E57283966239`). The worker can't check that: an ID
236
+ with its hyphens removed is also 32 hex characters, so it is sent as it is and
237
+ matches nobody.
238
+
239
+ ### Testing against TikTok
240
+
241
+ The local files are gitignored in this directory. Give them to `run_local.py`
242
+ as paths, as for Snap:
243
+
244
+ - `platform_secrets.json`: `{"export_connector_tiktok_app": {"clientId": …, "clientSecret": …}}`, the dev app.
245
+ - `credentials.json`: `{"type": "tiktok", "credentials": {"accessToken": …}}`, the access token a consent on a dev environment issued. The worker wraps it in an OAuth Grant whose `clientId` is the app's `clientId`, so the two always match.
246
+ - `config.json`: `{"connector": {"type": "tiktok", "advertiserId": …, "inputs": [{"leafId": "segA", "segmentName": …, "identifierType": "EMAIL", "mergeMode": "ADD", "retentionDays": 30}]}}`.
247
+
248
+ 1. Run:
249
+
250
+ ```sh
251
+ mkdir -p local/inputs && printf 'a@example.com\nb@example.com\n' > local/inputs/segA
252
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
253
+ --platform-secrets platform_secrets.json --mode validate
254
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
255
+ --platform-secrets platform_secrets.json
256
+ ```
257
+
258
+ 2. Live tests, against a test advertiser in production:
259
+
260
+ ```sh
261
+ DQ_EXPORT_LIVE_TIKTOK_DIR=$PWD uv run pytest -m live -s tests/test_live_tiktok.py
262
+ ```
263
+
264
+ The directory holds the three files above, with the same names.
265
+
266
+ ## Releasing
267
+
268
+ Bump the version with `uv version <version> --no-sync`, which also updates
269
+ `uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
270
+ commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
271
+ uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
272
+ ddc then pins the new version, as
273
+ [ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
274
+ describes.
@@ -0,0 +1,247 @@
1
+ # dq-export-connector
2
+
3
+ Worker logic for the **Export Connector DCR**: one package for every
4
+ Connector Kind, each in its own sub-package with an extra of the same name for
5
+ its dependencies:
6
+
7
+ | Kind | Extra | What a run does | Through |
8
+ | --- | --- | --- | --- |
9
+ | Bucket | `bucket` | Uploads each Input's dataset to S3, Azure Blob or GCS | [`obstore`](https://developmentseed.org/obstore/) |
10
+ | Meta | `meta` | Fills a customer list custom audience per Input | Meta's [`facebook-business`](https://github.com/facebook/facebook-python-business-sdk) SDK |
11
+ | Google DV360 | `google-dv360` | Fills a Customer Match user list per Input | Google's [`google-ads-datamanager`](https://github.com/googleads/data-manager-python) client |
12
+ | Google Ad Manager | `google-ad-manager` | Writes a batch upload file per Input to the network's GCS bucket | `obstore` |
13
+ | Adform | `adform` | Writes an identifier file per Input to Adform's S3 bucket | `obstore` |
14
+ | OneDSP | `one-dsp` | Writes an identifier file per Input to the S3 bucket of OneLog's Adform seat | `obstore` |
15
+ | Snap | `snap` | Fills a Snap Segment per Input with hashed identifiers | Snap's Marketing API, over `requests` |
16
+ | TikTok | `tiktok` | Fills a TikTok Segment (a Custom Audience) per Input with hashed identifiers | TikTok's API for Business, over `requests` |
17
+
18
+ ddc pins this package by hash in a fully locked `requirements.txt` and runs
19
+ `dq_export_connector.runner.main` in the task's Python environment. It is
20
+ published to PyPI, since the compiled graph installs it from there.
21
+
22
+ - `dq_export_connector.runner`: the entry point. Reads `/input/config.json`
23
+ and `/input/credentials.json`, sets up logging, and dispatches on the
24
+ Connector Kind and the action, then writes what the action reports under
25
+ `/internal`: an export's receipt, and either action's warnings and error, as
26
+ the task's Task Report, Application Warnings and Application Error. An action
27
+ with an error also writes it as `/internal/safe_error`, `CODE: message`,
28
+ which the container worker shows as the task's `error`, and exits with 1.
29
+ - `dq_export_connector.errors`: the error and warning codes the worker
30
+ reports, `ExportConnectorError`, which stops an action with an error code,
31
+ and `ExportConnectorWarning`. Each becomes an Application Error or Warning
32
+ with its credentials masked, its message cut to 1,000 characters and a
33
+ provider's own error to 4,000.
34
+ - `dq_export_connector.outcome`: collects a run's error, warnings and receipt
35
+ while it runs.
36
+ - `dq_export_connector.redact`: keeps every value from the sealed half, and
37
+ URL query strings, out of log lines and result messages. For Snap and
38
+ TikTok it also masks tokens, `key=secret` pairs, JWTs and SHA-256 or MD5 hex,
39
+ which their APIs may echo back.
40
+ - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
41
+ `Export`).
42
+ - `dq_export_connector.audience`: what the kinds that fill Segments share.
43
+ An Input is one value per line, which `identifiers` and `inputs` normalise,
44
+ hash where the platform takes hashes, and count when invalid. `sync` runs
45
+ an Input into its Segment through a kind's `AudienceDestination`: find the
46
+ Segment by name or create it, stage the values in batches, commit. `export`
47
+ loops over the Inputs and keeps the receipt. `http` and `classify` are the
48
+ HTTPS client of the kinds without a provider library: an allowlist of hosts,
49
+ retries by idempotency class, and the verdict on each answer.
50
+ - `dq_export_connector.meta`, `google_dv360`, `snap` and `tiktok`: the
51
+ Segment kinds, each an `AudienceDestination` over its provider's API, with a
52
+ `ValidateConnection` that checks the connector's Destination Account or lists
53
+ the accounts the credentials reach.
54
+ - `dq_export_connector.files`: what the kinds that upload identifier files
55
+ share: the file's name, its rows and its upload.
56
+ - `dq_export_connector.google_ad_manager`, `dq_export_connector.adform` and
57
+ `dq_export_connector.one_dsp`: the file kinds, which format an Input's rows
58
+ and name its object.
59
+ - `dq_export_connector.oauth`, `google_auth` and `google_oauth`: Access Tokens
60
+ from an OAuth Grant, and Google credentials from either Credential Scheme.
61
+ - `dq_export_connector.models`: the types the worker reads and writes, those
62
+ of every Connector Kind directly in it and a kind's own in its submodule,
63
+ such as `models.bucket`. They are pydantic models generated in
64
+ `dq_export_connector._models` from ddc's JSON schemas, so the config the
65
+ worker reads and the receipt, warnings and errors it writes match
66
+ ddc's Rust types. Regenerate them with `scripts/codegen-models.sh` after the
67
+ types change and `decentriq_dcr_compiler` has been rebuilt; a test fails
68
+ while they are stale.
69
+
70
+ ```sh
71
+ uv run pytest # unit tests, against obstore's in-memory store and fakes of the providers' APIs
72
+ uv run pytest -m live # against real buckets and accounts, credentials from the environment
73
+ uv run mypy dq_export_connector tests
74
+ ```
75
+
76
+ A live test skips when its credentials are missing; each test file's
77
+ docstring names the variables it reads.
78
+
79
+ ## Snap
80
+
81
+ A Snap connector's config names the ad account (set after consent, from a
82
+ `ValidateConnection` in `list` mode) and, per Input, a Segment, the identifier type its
83
+ lines hold and a Merge Mode. ddc validates it. The credentials are the OAuth
84
+ Grant of the Snap user who consented; each run turns it into an Access Token
85
+ with `dq_export_connector.oauth`. Decentriq's Snap app is the
86
+ `export_connector_snap_app` platform secret (`{"clientId", "clientSecret"}`),
87
+ mounted at `/input/oauth_app.json`. `ValidateConnection` in `list` mode lists
88
+ the ad accounts of every organization the grant reaches; in `check` mode it
89
+ reads the picked one.
90
+
91
+ A run looks each Segment up by name in the ad account and creates it when
92
+ there is none, marked `Managed by Decentriq`. It writes into a same-named
93
+ Segment whoever made it, with a `SEGMENT_NOT_MANAGED` warning when Decentriq
94
+ didn't. ADD adds the Input's values; REPLACE empties the Segment first, so it
95
+ is briefly empty. A run stops at the first Input that fails. When the failure
96
+ came after the Segment changed, the error says so; a rerun is safe in both
97
+ modes. Don't run one connector twice at the same time.
98
+
99
+ An Input is one file of values, or a stored ZIP holding one: one value per
100
+ line, UTF-8, optional BOM, LF or CRLF, surrounding double quotes removed,
101
+ empty lines skipped, no header.
102
+
103
+ ### Identifiers
104
+
105
+ | Type | Normalisation before SHA-256 | Snap schema |
106
+ |---|---|---|
107
+ | `EMAIL` | trim, lowercase; exactly one `@` with text on both sides | `EMAIL_SHA256` |
108
+ | `PHONE` | drop a `(0)` right after the country code (`+44 (0)20…`, `+44-(0)20…`), keep digits (any script's, as ASCII; drops `+`), drop a leading `00`; 8–15 digits, not starting with `0` | `PHONE_SHA256` |
109
+ | `IDFA`, `GAID` | UUID form with hyphens, lowercased | `MOBILE_AD_ID_SHA256` |
110
+ | `*_SHA256` | must be 64 hex characters; lowercased, otherwise unchanged | as above |
111
+
112
+ Snap takes SHA-256 only, so the `*_MD5` types are rejected when the config is
113
+ compiled. A pre-hashed value only matches if it was hashed from the same form: for
114
+ `PHONE_SHA256`, the digits with country code and no `+` (`41791234567`).
115
+
116
+ Up to 25% invalid rows gives an `INVALID_ROWS` warning; more fails the run
117
+ before the Segment changes. An empty Input gives an `EMPTY_DATASET` warning
118
+ and leaves its Segment as it was, in both modes.
119
+
120
+ The receipt counts invalid rows by reason (`counts.invalidReasons`, and in the
121
+ warning or error message), never with the values themselves:
122
+
123
+ | Reason | Meaning |
124
+ |---|---|
125
+ | `EMAIL_NO_AT_SIGN`, `EMAIL_MULTIPLE_AT_SIGNS` | not exactly one `@` |
126
+ | `EMAIL_EMPTY_LOCAL_PART`, `EMAIL_EMPTY_DOMAIN` | nothing before or after the `@` |
127
+ | `PHONE_NO_DIGITS` | no digits at all |
128
+ | `PHONE_NATIONAL_FORMAT` | starts with `0` after dropping `00`, i.e. no country code |
129
+ | `PHONE_TOO_SHORT`, `PHONE_TOO_LONG` | fewer than 8 or more than 15 digits |
130
+ | `NOT_A_MOBILE_AD_ID` | not a UUID with hyphens |
131
+ | `NOT_SHA256_HEX` | a `*_SHA256` value that isn't 64 hex characters |
132
+ | `NOT_MD5_HEX` | a `*_MD5` value that isn't 32 hex characters |
133
+ | `NOT_UTF8` | the line isn't valid UTF-8 |
134
+ | `CONTROL_CHARACTERS` | the value holds control characters or a byte order mark, usually because the file is UTF-16 |
135
+
136
+ ### Testing against Snap
137
+
138
+ The local files are gitignored in this directory:
139
+
140
+ - `platform_secrets.json`: `{"export_connector_snap_app": {"clientId": …, "clientSecret": …}}`, the dev app.
141
+ - `credentials.json`: `{"type": "snap", "credentials": {"refreshToken": …}}`, a refresh token the owner got through consent on a dev environment. Snap doesn't rotate it, so it can be reused.
142
+ - `config.json`: `{"connector": {"type": "snap", "adAccountId": …, "inputs": [{"leafId": "segA", "segmentName": …, "identifierType": "EMAIL", "mergeMode": "ADD", "retentionDays": 180}]}}`.
143
+
144
+ 1. Run:
145
+
146
+ ```sh
147
+ mkdir -p local/inputs && printf 'a@example.com\nb@example.com\n' > local/inputs/segA
148
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
149
+ --platform-secrets platform_secrets.json --mode validate
150
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
151
+ --platform-secrets platform_secrets.json
152
+ ```
153
+ 2. Live tests, including the check that Snap doesn't rotate refresh tokens:
154
+
155
+ ```sh
156
+ DQ_EXPORT_LIVE_SNAP_DIR=$PWD uv run pytest -m live -s tests/test_live_snap.py
157
+ ```
158
+
159
+ ## TikTok
160
+
161
+ A TikTok connector's config names the advertiser (set after consent, from a
162
+ `ValidateConnection` in `list` mode) and, per Input, a Segment, the identifier
163
+ type its lines hold, a Merge Mode, and `replaceExistingSegment`. ddc validates
164
+ it. The credentials are the OAuth Grant of the TikTok user who consented, and
165
+ its Access Token is long-lived: TikTok neither expires nor refreshes it, so
166
+ a refused token ends the run with `UNAUTHENTICATED`, and the owner connects
167
+ again. Decentriq's app is the `export_connector_tiktok_app` platform secret
168
+ (`{"clientId", "clientSecret"}`), mounted at `/input/oauth_app.json`. Every
169
+ call carries the token as the `Access-Token` header, and the client waits one
170
+ second between calls to the same Segment endpoint. `ValidateConnection` in
171
+ `list` mode lists the advertisers the grant reaches; in `check` mode it checks
172
+ the picked one is among them and that its Segments can be listed.
173
+
174
+ A run looks each Segment up by name in the advertiser, listing them once
175
+ before the first Input, and creates it at the end of the Input when there is
176
+ none. TikTok has no description to mark a Segment with, so the run can tell
177
+ only that the advertiser created it through the API and every change to it
178
+ went through the API. A Segment that fails this, such as one edited in Ads
179
+ Manager, is written with a `SEGMENT_NOT_MANAGED` warning.
180
+
181
+ Each Input's values are uploaded as files first, which changes no Segment. The
182
+ run then makes one create, or one update with `APPEND` or `REPLACE`, over all
183
+ the files, because TikTok allows one REPLACE a day per Segment. Before
184
+ uploading, a run waits up to 10 minutes for TikTok to make the Segment
185
+ editable again, then fails with `SEGMENT_BUSY`.
186
+
187
+ REPLACE on a Segment the run didn't create needs `replaceExistingSegment: true`
188
+ on that Input, which confirms only this connector writes to it; without it the
189
+ run fails with `REPLACE_NOT_CONFIRMED` before any upload. TikTok can't tell
190
+ which API client made a Segment, so the confirmation is the only guard.
191
+ A Segment under 1,000 matched users can't be updated by TikTok, which gives a
192
+ `SEGMENT_TOO_SMALL` warning. An empty Input gives an `EMPTY_DATASET` warning
193
+ and leaves its Segment as it was, in both modes.
194
+
195
+ The identifiers are normalised for TikTok's `calculate_type`s:
196
+
197
+ | Type | Normalisation before SHA-256 | TikTok `calculate_type` |
198
+ |---|---|---|
199
+ | `EMAIL` | trim, lowercase | `EMAIL_SHA256` |
200
+ | `PHONE` | as for Snap, then E.164 with the `+` (`+442071838750`) | `PHONE_SHA256` |
201
+ | `IDFA`, `GAID` | UUID form with hyphens, lowercased | `IDFA_SHA256`, `GAID_SHA256` |
202
+ | `*_SHA256` | must be 64 hex characters; lowercased, otherwise unchanged | as above |
203
+ | `IDFA_MD5`, `GAID_MD5` | already hashed with MD5: must be 32 hex characters; lowercased, otherwise unchanged | `IDFA_MD5`, `GAID_MD5` |
204
+
205
+ Raw mobile ad IDs are always sent as SHA-256; the MD5 types are for IDs that
206
+ were only kept hashed with MD5. Such a value only matches if it was hashed from
207
+ the ID in its UUID form with hyphens, upper or lower case
208
+ (`AECE52E7-03EE-455A-B3C4-E57283966239`). The worker can't check that: an ID
209
+ with its hyphens removed is also 32 hex characters, so it is sent as it is and
210
+ matches nobody.
211
+
212
+ ### Testing against TikTok
213
+
214
+ The local files are gitignored in this directory. Give them to `run_local.py`
215
+ as paths, as for Snap:
216
+
217
+ - `platform_secrets.json`: `{"export_connector_tiktok_app": {"clientId": …, "clientSecret": …}}`, the dev app.
218
+ - `credentials.json`: `{"type": "tiktok", "credentials": {"accessToken": …}}`, the access token a consent on a dev environment issued. The worker wraps it in an OAuth Grant whose `clientId` is the app's `clientId`, so the two always match.
219
+ - `config.json`: `{"connector": {"type": "tiktok", "advertiserId": …, "inputs": [{"leafId": "segA", "segmentName": …, "identifierType": "EMAIL", "mergeMode": "ADD", "retentionDays": 30}]}}`.
220
+
221
+ 1. Run:
222
+
223
+ ```sh
224
+ mkdir -p local/inputs && printf 'a@example.com\nb@example.com\n' > local/inputs/segA
225
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
226
+ --platform-secrets platform_secrets.json --mode validate
227
+ uv run python scripts/run_local.py --config config.json --credentials credentials.json \
228
+ --platform-secrets platform_secrets.json
229
+ ```
230
+
231
+ 2. Live tests, against a test advertiser in production:
232
+
233
+ ```sh
234
+ DQ_EXPORT_LIVE_TIKTOK_DIR=$PWD uv run pytest -m live -s tests/test_live_tiktok.py
235
+ ```
236
+
237
+ The directory holds the three files above, with the same names.
238
+
239
+ ## Releasing
240
+
241
+ Bump the version with `uv version <version> --no-sync`, which also updates
242
+ `uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
243
+ commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
244
+ uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
245
+ ddc then pins the new version, as
246
+ [ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
247
+ describes.
@@ -117,6 +117,36 @@ class OAuthGrant(BaseModel):
117
117
  token: GrantToken
118
118
 
119
119
 
120
+ class SnapSealedCredentialsOauth(BaseModel):
121
+ model_config = ConfigDict(
122
+ populate_by_name=True,
123
+ )
124
+ grant: OAuthGrant
125
+ type: Literal['oauth']
126
+
127
+
128
+ class SnapSealedCredentials(RootModel[SnapSealedCredentialsOauth]):
129
+ root: Annotated[
130
+ SnapSealedCredentialsOauth,
131
+ Field(description='What is sealed, tagged like what was sent.'),
132
+ ]
133
+
134
+
135
+ class TiktokSealedCredentialsOauth(BaseModel):
136
+ model_config = ConfigDict(
137
+ populate_by_name=True,
138
+ )
139
+ grant: OAuthGrant
140
+ type: Literal['oauth']
141
+
142
+
143
+ class TiktokSealedCredentials(RootModel[TiktokSealedCredentialsOauth]):
144
+ root: Annotated[
145
+ TiktokSealedCredentialsOauth,
146
+ Field(description='What is sealed, tagged like what was sent.'),
147
+ ]
148
+
149
+
120
150
  class ExportConnectorCredentialsBucket(BaseModel):
121
151
  model_config = ConfigDict(
122
152
  populate_by_name=True,
@@ -133,6 +163,30 @@ class ExportConnectorCredentialsAdform(BaseModel):
133
163
  type: Literal['adform']
134
164
 
135
165
 
166
+ class ExportConnectorCredentialsOneDsp(BaseModel):
167
+ model_config = ConfigDict(
168
+ populate_by_name=True,
169
+ )
170
+ credentials: AdformExportCredentials
171
+ type: Literal['oneDsp']
172
+
173
+
174
+ class ExportConnectorCredentialsSnap(BaseModel):
175
+ model_config = ConfigDict(
176
+ populate_by_name=True,
177
+ )
178
+ credentials: SnapSealedCredentials
179
+ type: Literal['snap']
180
+
181
+
182
+ class ExportConnectorCredentialsTiktok(BaseModel):
183
+ model_config = ConfigDict(
184
+ populate_by_name=True,
185
+ )
186
+ credentials: TiktokSealedCredentials
187
+ type: Literal['tiktok']
188
+
189
+
136
190
  class GoogleSealedCredentialsOauth(BaseModel):
137
191
  model_config = ConfigDict(
138
192
  populate_by_name=True,
@@ -198,6 +252,9 @@ class ExportConnectorCredentials(
198
252
  | ExportConnectorCredentialsGoogleDv360
199
253
  | ExportConnectorCredentialsGoogleAdManager
200
254
  | ExportConnectorCredentialsAdform
255
+ | ExportConnectorCredentialsOneDsp
256
+ | ExportConnectorCredentialsSnap
257
+ | ExportConnectorCredentialsTiktok
201
258
  ]
202
259
  ):
203
260
  root: Annotated[
@@ -205,7 +262,10 @@ class ExportConnectorCredentials(
205
262
  | ExportConnectorCredentialsMeta
206
263
  | ExportConnectorCredentialsGoogleDv360
207
264
  | ExportConnectorCredentialsGoogleAdManager
208
- | ExportConnectorCredentialsAdform,
265
+ | ExportConnectorCredentialsAdform
266
+ | ExportConnectorCredentialsOneDsp
267
+ | ExportConnectorCredentialsSnap
268
+ | ExportConnectorCredentialsTiktok,
209
269
  Field(
210
270
  description='Keyed by Connector Kind, in step with [`ExportConnectorKind`]. The worker\nreads it at `/input/credentials.json`.',
211
271
  title='ExportConnectorCredentials',