salesforce-data-customcode 6.0.0__py3-none-any.whl → 6.0.1.dev1__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.
@@ -27,21 +27,11 @@ if TYPE_CHECKING:
27
27
  class WriteMode(str, Enum):
28
28
  APPEND = "append"
29
29
  OVERWRITE = "overwrite"
30
- OVERWRITE_PARTITIONS = "overwrite_partitions" # Deprecated: raises error if used
30
+ OVERWRITE_PARTITIONS = "overwrite_partitions"
31
31
  MERGE = "merge"
32
32
  MERGE_UPSERT_DELETE = "merge_upsert_delete"
33
33
 
34
34
 
35
- class MergeRecordType(str, Enum):
36
- """Values for the _merge_record_type column used by MERGE_UPSERT_DELETE."""
37
-
38
- UPSERT = "UPSERT"
39
- DELETE = "DELETE"
40
-
41
-
42
- MERGE_RECORD_TYPE_COLUMN = "_merge_record_type"
43
-
44
-
45
35
  class BaseDataCloudWriter(BaseDataAccessLayer):
46
36
  """Base class for Data Cloud writers."""
47
37
 
@@ -5,6 +5,6 @@
5
5
  "dockerfile": "../Dockerfile"
6
6
  },
7
7
  "features": {
8
- "ghcr.io/devcontainers/features/git:1": {}
8
+ "ghcr.io/devcontainers/features/git:1": {},
9
9
  }
10
10
  }
@@ -5,6 +5,6 @@
5
5
  "dockerfile": "../Dockerfile"
6
6
  },
7
7
  "features": {
8
- "ghcr.io/devcontainers/features/git:1": {}
8
+ "ghcr.io/devcontainers/features/git:1": {},
9
9
  }
10
10
  }
@@ -101,48 +101,75 @@ class SFCLITokenProvider(TokenProvider):
101
101
 
102
102
  from datacustomcode.deploy import AccessTokenResponse
103
103
 
104
- try:
105
- result = subprocess.run(
106
- ["sf", "org", "display", "--target-org", self.sf_cli_org, "--json"],
107
- capture_output=True,
108
- text=True,
109
- check=True,
110
- timeout=30,
111
- )
112
- except FileNotFoundError as exc:
113
- raise RuntimeError(
114
- "The 'sf' command was not found. "
115
- "Install Salesforce CLI: https://developer.salesforce.com/tools/salesforcecli"
116
- ) from exc
117
- except subprocess.TimeoutExpired as exc:
118
- raise RuntimeError(
119
- f"'sf org display' timed out for org '{self.sf_cli_org}'"
120
- ) from exc
121
- except subprocess.CalledProcessError as exc:
122
- raise RuntimeError(
123
- f"'sf org display' failed for org '{self.sf_cli_org}': {exc.stderr}"
124
- ) from exc
104
+ def _run_sf_command(args: list[str], description: str) -> dict:
105
+ try:
106
+ result = subprocess.run(
107
+ args,
108
+ capture_output=True,
109
+ text=True,
110
+ check=True,
111
+ timeout=30,
112
+ )
113
+ except FileNotFoundError as exc:
114
+ raise RuntimeError(
115
+ "The 'sf' command was not found. "
116
+ "Install Salesforce CLI: "
117
+ "https://developer.salesforce.com/tools/salesforcecli"
118
+ ) from exc
119
+ except subprocess.TimeoutExpired as exc:
120
+ raise RuntimeError(
121
+ f"'{description}' timed out for org '{self.sf_cli_org}'"
122
+ ) from exc
123
+ except subprocess.CalledProcessError as exc:
124
+ raise RuntimeError(
125
+ f"'{description}' failed for org '{self.sf_cli_org}': "
126
+ f"{exc.stderr}"
127
+ ) from exc
125
128
 
126
- try:
127
- data = json.loads(result.stdout)
128
- except json.JSONDecodeError as exc:
129
- raise RuntimeError(
130
- f"Failed to parse JSON from 'sf org display': {result.stdout}"
131
- ) from exc
129
+ try:
130
+ data = json.loads(result.stdout)
131
+ except json.JSONDecodeError as exc:
132
+ raise RuntimeError(
133
+ f"Failed to parse JSON from '{description}': {result.stdout}"
134
+ ) from exc
132
135
 
133
- if data.get("status") != 0:
136
+ if data.get("status") != 0:
137
+ raise RuntimeError(
138
+ f"SF CLI error for org '{self.sf_cli_org}': "
139
+ f"{data.get('message', 'unknown error')}"
140
+ )
141
+ return dict(data)
142
+
143
+ # Get instanceUrl from sf org display
144
+ display_data = _run_sf_command(
145
+ ["sf", "org", "display", "--target-org", self.sf_cli_org, "--json"],
146
+ "sf org display",
147
+ )
148
+ instance_url = display_data.get("result", {}).get("instanceUrl")
149
+ if not instance_url:
134
150
  raise RuntimeError(
135
- f"SF CLI error for org '{self.sf_cli_org}': "
136
- f"{data.get('message', 'unknown error')}"
151
+ f"'sf org display' did not return an instance URL "
152
+ f"for org '{self.sf_cli_org}'"
137
153
  )
138
154
 
139
- result_data = data.get("result", {})
140
- access_token = result_data.get("accessToken")
141
- instance_url = result_data.get("instanceUrl")
142
-
143
- if not access_token or not instance_url:
155
+ # Get access token via show-access-token (newer SF CLI versions
156
+ # redact the token in sf org display)
157
+ token_data = _run_sf_command(
158
+ [
159
+ "sf",
160
+ "org",
161
+ "auth",
162
+ "show-access-token",
163
+ "--target-org",
164
+ self.sf_cli_org,
165
+ "--json",
166
+ ],
167
+ "sf org auth show-access-token",
168
+ )
169
+ access_token = token_data.get("result", {}).get("accessToken")
170
+ if not access_token:
144
171
  raise RuntimeError(
145
- f"'sf org display' did not return an access token or instance URL "
172
+ f"'sf org auth show-access-token' did not return an access token "
146
173
  f"for org '{self.sf_cli_org}'"
147
174
  )
148
175
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: salesforce-data-customcode
3
- Version: 6.0.0
3
+ Version: 6.0.1.dev1
4
4
  Summary: Data Cloud Custom Code SDK
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE.txt
@@ -34,7 +34,7 @@ datacustomcode/io/reader/query_api.py,sha256=eVrohrcnTnhSMsGfPRHu5XltjFtGG0hyHt1
34
34
  datacustomcode/io/reader/sf_cli.py,sha256=x5QacVqRZaZSyph1_wwxo67s8r29wsOcUsOaiF9cDWE,6324
35
35
  datacustomcode/io/reader/utils.py,sha256=HlHhPZoHfmWA3mF8kTnd3m4Nd2exaz4NsOJJfQY7Pew,1656
36
36
  datacustomcode/io/writer/__init__.py,sha256=gamfOD1VnAtEslRBpqh-yKiVjkG_wYWYdSatGIfsN-w,621
37
- datacustomcode/io/writer/base.py,sha256=6e2Yszb6BiuN1zCV2rjvZ5CQ0YikQdUgdYAkutoy9pE,1787
37
+ datacustomcode/io/writer/base.py,sha256=RHafJ-Xmh_TnYcN4QfSh0VdIZeIevKmz9sf05adMgxA,1540
38
38
  datacustomcode/io/writer/csv.py,sha256=asty5teBpNQ1fMGHZ7wA3suLhq0sk0lVQPN5x7TOSRk,1555
39
39
  datacustomcode/io/writer/print.py,sha256=0g2sP_1Wb95UIyEELWJt3dqM18Iv_CWhDW3mDxcIhns,5105
40
40
  datacustomcode/llm_gateway/__init__.py,sha256=xT7J9qZByD80WWk-835JcJSvQx8_NiX6qsBPhq7mU6k,800
@@ -59,7 +59,7 @@ datacustomcode/spark/base.py,sha256=tlGqM4LxuLoDa7OxJF5nVeb7phO5uvD1DHBQeH7NMMs,
59
59
  datacustomcode/spark/default.py,sha256=aMB8CaTPYwHbQE_7XqBLQUZPGRdDJcRL72qTVh0aG7M,1433
60
60
  datacustomcode/template.py,sha256=FNNi8YPfd-JB-hUt1DDWSFK5AqwKnTnRSy_KpqYluaU,3282
61
61
  datacustomcode/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
- datacustomcode/templates/function/.devcontainer/devcontainer.json,sha256=21RNTadhC-rynON2-VOtr5U174Hxnr_MA4RQ4592rsg,166
62
+ datacustomcode/templates/function/.devcontainer/devcontainer.json,sha256=lWMFk-SdTKBlQt_VJrMn8gZPmvT4tfcjRpCNhLdElZc,167
63
63
  datacustomcode/templates/function/Dockerfile.dependencies,sha256=AfHRddm5l3ujv4vdrf0d-SMB-qxPCOa0XQm6ptP2Euw,174
64
64
  datacustomcode/templates/function/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
65
  datacustomcode/templates/function/build_native_dependencies.sh,sha256=dk9vhzlObdsFAO5BtxP7ioOGDBM8JVwJHp_W0712Nlk,222
@@ -77,7 +77,7 @@ datacustomcode/templates/function/payload/config.json,sha256=RBNvo1WzZ4oRRq0W9-h
77
77
  datacustomcode/templates/function/payload/entrypoint.py,sha256=DrH73aAkU_ua6IHBRYr9SkMtX5pEFvNJYew8zXQL5TQ,5705
78
78
  datacustomcode/templates/function/requirements-dev.txt,sha256=qT2-m2FOgiYPTvqaNy0yRzIAXqHgR5b8stccYXsXVi8,88
79
79
  datacustomcode/templates/function/requirements.txt,sha256=qJbqzs5z0Hrx590U3T7dHq_m8UQEx2TdhgrJSz-QHIQ,40
80
- datacustomcode/templates/script/.devcontainer/devcontainer.json,sha256=21RNTadhC-rynON2-VOtr5U174Hxnr_MA4RQ4592rsg,166
80
+ datacustomcode/templates/script/.devcontainer/devcontainer.json,sha256=lWMFk-SdTKBlQt_VJrMn8gZPmvT4tfcjRpCNhLdElZc,167
81
81
  datacustomcode/templates/script/Dockerfile,sha256=l8HEy5X7BsW9Gi7rBYM6G2czwk-1832RRIos7xyFzpI,463
82
82
  datacustomcode/templates/script/Dockerfile.dependencies,sha256=vBbTfgcBkVQVCnrJZE_QEx89ddTQrLZGeyVTZXU8TI8,206
83
83
  datacustomcode/templates/script/README.md,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -90,10 +90,10 @@ datacustomcode/templates/script/payload/config.json,sha256=0d2mEMt4NHIeOUTsgiPMu
90
90
  datacustomcode/templates/script/payload/entrypoint.py,sha256=qpFA-jkhaYYF2CFNQ7_7MZVefU7SxnoMQIQYi7ox2dY,691
91
91
  datacustomcode/templates/script/requirements-dev.txt,sha256=OWwuy1awesqOZOS3Zizmdd6BDnSePpGFN5bq5IrALvc,176
92
92
  datacustomcode/templates/script/requirements.txt,sha256=qJbqzs5z0Hrx590U3T7dHq_m8UQEx2TdhgrJSz-QHIQ,40
93
- datacustomcode/token_provider.py,sha256=KPj_ca6mcBmhXHaPmZjAI4it8QvOWdwKJL8yfqxfYwU,5446
93
+ datacustomcode/token_provider.py,sha256=a16r5xYeCOPR3M3JKvEV7JVIG7DOzDswObRBI33MQOk,6461
94
94
  datacustomcode/version.py,sha256=9LlbVrzwBvut1L308QbwNBgxdQk5CrghH39JARVSxms,989
95
- salesforce_data_customcode-6.0.0.dist-info/METADATA,sha256=9NC9AsBkRbD3T_cvBKgC5jAf1RHCzPvnwmbTlshJdzE,20162
96
- salesforce_data_customcode-6.0.0.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
97
- salesforce_data_customcode-6.0.0.dist-info/entry_points.txt,sha256=WpQ94UB7UuRCYGOLtJV3vAgm1tl7iVf43VYRWIuNu5Y,74
98
- salesforce_data_customcode-6.0.0.dist-info/licenses/LICENSE.txt,sha256=iOi8EmQpfkFhMENi7VYtkl2EqS14pEOccoXHiW2dyPU,11443
99
- salesforce_data_customcode-6.0.0.dist-info/RECORD,,
95
+ salesforce_data_customcode-6.0.1.dev1.dist-info/METADATA,sha256=hY9RnrRP1waD27SGNUEOts2s7D4vpgm8M9a-Mvp9d_8,20167
96
+ salesforce_data_customcode-6.0.1.dev1.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
97
+ salesforce_data_customcode-6.0.1.dev1.dist-info/entry_points.txt,sha256=WpQ94UB7UuRCYGOLtJV3vAgm1tl7iVf43VYRWIuNu5Y,74
98
+ salesforce_data_customcode-6.0.1.dev1.dist-info/licenses/LICENSE.txt,sha256=iOi8EmQpfkFhMENi7VYtkl2EqS14pEOccoXHiW2dyPU,11443
99
+ salesforce_data_customcode-6.0.1.dev1.dist-info/RECORD,,