@arizeai/phoenix-client 7.12.0 → 7.13.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @arizeai/phoenix-client
2
2
 
3
+ ## 7.13.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c282563: Add an `upsertOrDeleteSecrets` helper to the new `secrets` subpath. It atomically creates, updates, or deletes ordered key/value-or-null batches through `PUT /v1/secrets`, returns only the affected key names, and keeps submitted values out of helper output and error messages.
8
+
3
9
  ## 7.12.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -797,6 +797,33 @@ await setProjectRetentionPolicy({
797
797
 
798
798
  This helper only changes a project's assignment to an existing policy. Creating, reading, updating, and deleting retention policies is outside the scope of the TypeScript projects helper.
799
799
 
800
+ ## Secrets
801
+
802
+ Use the `secrets` entrypoint to atomically create, update, or delete encrypted
803
+ provider credentials. A string value creates or updates a key, while `null`
804
+ deletes it. Duplicate keys use the last occurrence in the batch. The result
805
+ contains only changed key names and never returns secret values.
806
+
807
+ ```ts
808
+ import { upsertOrDeleteSecrets } from "@arizeai/phoenix-client/secrets";
809
+
810
+ const apiKey = process.env.OPENAI_API_KEY;
811
+ if (!apiKey) throw new Error("OPENAI_API_KEY is required");
812
+
813
+ const result = await upsertOrDeleteSecrets({
814
+ secrets: [
815
+ { key: "OPENAI_API_KEY", value: apiKey },
816
+ { key: "OLD_PROVIDER_API_KEY", value: null },
817
+ ],
818
+ });
819
+
820
+ console.log(result.upsertedKeys);
821
+ console.log(result.deletedKeys);
822
+ ```
823
+
824
+ Managing secrets requires an administrator when Phoenix authentication is
825
+ enabled. Avoid logging the request batch or otherwise retaining its values.
826
+
800
827
  ## Examples
801
828
 
802
829
  To run examples, install dependencies using `pnpm` and run:
@@ -0,0 +1,2 @@
1
+ export * from "./upsertOrDeleteSecrets.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/secrets/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./upsertOrDeleteSecrets.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/secrets/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { ClientFn } from "../types/core.js";
2
+ /**
3
+ * A secret to create, update, or delete.
4
+ */
5
+ export interface SecretInput {
6
+ /** The environment-style key used to identify the secret. */
7
+ key: string;
8
+ /** A value to create or update, or `null` to delete the key. */
9
+ value: string | null;
10
+ }
11
+ /**
12
+ * Parameters for atomically updating secrets.
13
+ */
14
+ export interface UpsertOrDeleteSecretsParams extends ClientFn {
15
+ /**
16
+ * Ordered secret updates. When a key occurs more than once, the server
17
+ * applies only its last occurrence.
18
+ */
19
+ secrets: SecretInput[];
20
+ }
21
+ /**
22
+ * The names of the keys changed by a secrets update.
23
+ *
24
+ * Secret values are intentionally excluded.
25
+ */
26
+ export interface UpsertOrDeleteSecretsResult {
27
+ /** Keys that were created or updated. */
28
+ upsertedKeys: string[];
29
+ /** Keys that were deleted. */
30
+ deletedKeys: string[];
31
+ }
32
+ /**
33
+ * Atomically create, update, or delete a batch of Phoenix secrets.
34
+ *
35
+ * A non-null value creates or updates a secret, while `null` deletes it.
36
+ * Duplicate keys use the last occurrence in the batch. The result contains
37
+ * key names only; submitted values are never returned or logged.
38
+ *
39
+ * @param params - The secrets update.
40
+ * @param params.client - Optional Phoenix client instance.
41
+ * @param params.secrets - Ordered key/value-or-null updates.
42
+ * @returns The names of the keys that were upserted and deleted.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * import { upsertOrDeleteSecrets } from "@arizeai/phoenix-client/secrets";
47
+ *
48
+ * const apiKey = process.env.OPENAI_API_KEY;
49
+ * if (!apiKey) throw new Error("OPENAI_API_KEY is required");
50
+ *
51
+ * const result = await upsertOrDeleteSecrets({
52
+ * secrets: [
53
+ * { key: "OPENAI_API_KEY", value: apiKey },
54
+ * { key: "OLD_PROVIDER_API_KEY", value: null },
55
+ * ],
56
+ * });
57
+ * ```
58
+ */
59
+ export declare function upsertOrDeleteSecrets({ client: _client, secrets, }: UpsertOrDeleteSecretsParams): Promise<UpsertOrDeleteSecretsResult>;
60
+ //# sourceMappingURL=upsertOrDeleteSecrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upsertOrDeleteSecrets.d.ts","sourceRoot":"","sources":["../../../src/secrets/upsertOrDeleteSecrets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,QAAQ;IAC3D;;;OAGG;IACH,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C,yCAAyC;IACzC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,MAAM,EAAE,OAAO,EACf,OAAO,GACR,EAAE,2BAA2B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAoBpE"}
@@ -0,0 +1,47 @@
1
+ import { createClient } from "../client.js";
2
+ /**
3
+ * Atomically create, update, or delete a batch of Phoenix secrets.
4
+ *
5
+ * A non-null value creates or updates a secret, while `null` deletes it.
6
+ * Duplicate keys use the last occurrence in the batch. The result contains
7
+ * key names only; submitted values are never returned or logged.
8
+ *
9
+ * @param params - The secrets update.
10
+ * @param params.client - Optional Phoenix client instance.
11
+ * @param params.secrets - Ordered key/value-or-null updates.
12
+ * @returns The names of the keys that were upserted and deleted.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { upsertOrDeleteSecrets } from "@arizeai/phoenix-client/secrets";
17
+ *
18
+ * const apiKey = process.env.OPENAI_API_KEY;
19
+ * if (!apiKey) throw new Error("OPENAI_API_KEY is required");
20
+ *
21
+ * const result = await upsertOrDeleteSecrets({
22
+ * secrets: [
23
+ * { key: "OPENAI_API_KEY", value: apiKey },
24
+ * { key: "OLD_PROVIDER_API_KEY", value: null },
25
+ * ],
26
+ * });
27
+ * ```
28
+ */
29
+ export async function upsertOrDeleteSecrets({ client: _client, secrets, }) {
30
+ const client = _client ?? createClient();
31
+ const { data, error } = await client.PUT("/v1/secrets", {
32
+ body: { secrets },
33
+ });
34
+ // Do not include the server error payload here: validation responses can be
35
+ // influenced by submitted data, which must never enter helper error text.
36
+ if (error) {
37
+ throw new Error("Failed to upsert or delete secrets");
38
+ }
39
+ if (!data?.data) {
40
+ throw new Error("Failed to upsert or delete secrets: no data returned");
41
+ }
42
+ return {
43
+ upsertedKeys: data.data.upserted_keys,
44
+ deletedKeys: data.data.deleted_keys,
45
+ };
46
+ }
47
+ //# sourceMappingURL=upsertOrDeleteSecrets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upsertOrDeleteSecrets.js","sourceRoot":"","sources":["../../../src/secrets/upsertOrDeleteSecrets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAoCzC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,MAAM,EAAE,OAAO,EACf,OAAO,GACqB;IAC5B,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IACzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE;QACtD,IAAI,EAAE,EAAE,OAAO,EAAE;KAClB,CAAC,CAAC;IAEH,4EAA4E;IAC5E,0EAA0E;IAC1E,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO;QACL,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa;QACrC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY;KACpC,CAAC;AACJ,CAAC"}