openpond-sdk 0.0.5 → 0.0.6

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.
package/dist/index.js CHANGED
@@ -2476,6 +2476,80 @@ function sleep2(milliseconds, signal) {
2476
2476
  });
2477
2477
  }
2478
2478
 
2479
+ // src/project-actions.ts
2480
+ import { promises as fs } from "node:fs";
2481
+ var OpenPondProjectActionsClient = class {
2482
+ #apiKey;
2483
+ #apiBaseUrl;
2484
+ constructor(input) {
2485
+ this.#apiKey = input.apiKey;
2486
+ this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
2487
+ }
2488
+ async list(input) {
2489
+ const response = await apiFetch(
2490
+ this.#apiBaseUrl,
2491
+ this.#apiKey,
2492
+ projectActionPath(input.projectId, "releases", input.teamId)
2493
+ );
2494
+ return (await readApiJson(response, "List Project Action releases")).releases;
2495
+ }
2496
+ async catalog(input) {
2497
+ const response = await apiFetch(
2498
+ this.#apiBaseUrl,
2499
+ this.#apiKey,
2500
+ projectActionPath(input.projectId, "catalog", input.teamId)
2501
+ );
2502
+ return (await readApiJson(response, "Get Project Action catalog")).catalog;
2503
+ }
2504
+ async publish(input) {
2505
+ const [bundle, runner] = await Promise.all([
2506
+ fs.readFile(input.build.bundlePath),
2507
+ fs.readFile(input.build.runnerPath)
2508
+ ]);
2509
+ const response = await apiFetch(
2510
+ this.#apiBaseUrl,
2511
+ this.#apiKey,
2512
+ projectActionPath(input.projectId, "releases", input.teamId),
2513
+ {
2514
+ method: "POST",
2515
+ body: JSON.stringify({
2516
+ sourceRef: input.sourceRef,
2517
+ sourceCommitSha: input.sourceCommitSha,
2518
+ bundleBase64: bundle.toString("base64"),
2519
+ runnerBase64: runner.toString("base64"),
2520
+ registry: input.build.registry,
2521
+ manifest: input.build.manifest,
2522
+ metadata: input.metadata
2523
+ })
2524
+ }
2525
+ );
2526
+ return (await readApiJson(response, "Publish Project Actions")).release;
2527
+ }
2528
+ async run(input) {
2529
+ const response = await apiFetch(
2530
+ this.#apiBaseUrl,
2531
+ this.#apiKey,
2532
+ projectActionPath(input.projectId, `actions/${encodeURIComponent(input.actionId)}`, input.teamId),
2533
+ {
2534
+ method: "POST",
2535
+ body: JSON.stringify({
2536
+ input: input.value ?? {},
2537
+ releaseId: input.releaseId,
2538
+ idempotencyKey: input.idempotencyKey,
2539
+ callerType: input.callerType ?? "sdk",
2540
+ callerId: input.callerId
2541
+ }),
2542
+ signal: input.signal,
2543
+ timeoutMs: 15 * 60 * 1e3
2544
+ }
2545
+ );
2546
+ return (await readApiJson(response, "Run Project Action")).invocation;
2547
+ }
2548
+ };
2549
+ function projectActionPath(projectId, suffix, teamId) {
2550
+ return `/v1/project-actions/${encodeURIComponent(projectId)}/${suffix}?teamId=${encodeURIComponent(teamId)}`;
2551
+ }
2552
+
2479
2553
  // ../cloud/dist/sandbox/types/runtime-profiles.js
2480
2554
  var SANDBOX_RUNTIME_PROFILE_IDS = [
2481
2555
  "openpond-generic-v1",
@@ -2488,6 +2562,7 @@ var SANDBOX_RUNTIME_PROFILE_IDS = [
2488
2562
  var OpenPondClient = class {
2489
2563
  sandboxes;
2490
2564
  work;
2565
+ actions;
2491
2566
  constructor(options) {
2492
2567
  const apiKey = options.apiKey.trim();
2493
2568
  if (!apiKey) throw new Error("OpenPond API key is required");
@@ -2503,6 +2578,7 @@ var OpenPondClient = class {
2503
2578
  chatApiBaseUrl: options.chatApiUrl?.trim() || resolveOpChatApiBaseUrl({ apiBaseUrl, env: {} }),
2504
2579
  sandboxes: this.sandboxes
2505
2580
  });
2581
+ this.actions = new OpenPondProjectActionsClient({ apiKey, apiBaseUrl });
2506
2582
  }
2507
2583
  };
2508
2584
  function createOpenPondClient(options) {
@@ -2511,6 +2587,7 @@ function createOpenPondClient(options) {
2511
2587
  export {
2512
2588
  OpenPondApiError,
2513
2589
  OpenPondClient,
2590
+ OpenPondProjectActionsClient,
2514
2591
  OpenPondSandboxClient,
2515
2592
  OpenPondWorkClient,
2516
2593
  SANDBOX_RUNTIME_PROFILE_IDS,