@cuylabs/agent-runtime-dapr 0.8.0 → 0.10.0

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.
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/client.ts
2
8
  var _otelClient = null;
3
9
  async function tryGetOtelPropagation() {
@@ -144,7 +150,7 @@ var DaprSidecarClient = class {
144
150
  }
145
151
  return {
146
152
  value: parseJson(text),
147
- etag: response.headers.get("etag")?.trim() || response.headers.get("ETag")?.trim() || void 0
153
+ etag: response.headers.get("etag")?.trim() || void 0
148
154
  };
149
155
  }
150
156
  async getState(key) {
@@ -170,11 +176,16 @@ var DaprSidecarClient = class {
170
176
  true
171
177
  );
172
178
  }
173
- async deleteState(key) {
179
+ async deleteState(key, options = {}) {
174
180
  const stateStoreName = this.requireStateStoreName();
181
+ const headers = new Headers();
182
+ if (options.etag) {
183
+ headers.set("If-Match", options.etag);
184
+ }
185
+ const concurrencyParam = options.concurrency ? `?concurrency=${options.concurrency}` : "";
175
186
  await this.request(
176
- `/v1.0/state/${encodeURIComponent(stateStoreName)}/${encodeURIComponent(key)}`,
177
- { method: "DELETE" },
187
+ `/v1.0/state/${encodeURIComponent(stateStoreName)}/${encodeURIComponent(key)}${concurrencyParam}`,
188
+ { method: "DELETE", headers },
178
189
  [200, 204, 404]
179
190
  );
180
191
  }
@@ -189,6 +200,20 @@ var DaprSidecarClient = class {
189
200
  [200, 204]
190
201
  );
191
202
  }
203
+ async publish(pubsubName, topic, data, metadata) {
204
+ const params = metadata ? "?" + new URLSearchParams(Object.entries(metadata).map(
205
+ ([k, v]) => [`metadata.${k}`, v]
206
+ )).toString() : "";
207
+ await this.request(
208
+ `/v1.0/publish/${encodeURIComponent(pubsubName)}/${encodeURIComponent(topic)}${params}`,
209
+ {
210
+ method: "POST",
211
+ body: JSON.stringify(data)
212
+ },
213
+ [200, 204],
214
+ true
215
+ );
216
+ }
192
217
  async requestJson(path, init, allowedStatusCodes) {
193
218
  const response = await this.request(path, init, allowedStatusCodes, true);
194
219
  const text = await response.text();
@@ -278,6 +303,7 @@ var DaprSidecarClient = class {
278
303
  };
279
304
 
280
305
  export {
306
+ __export,
281
307
  isDaprConflictError,
282
308
  DaprSidecarClient
283
309
  };