graphlit-client 1.0.20260220001 → 1.0.20260220004

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/client.d.ts CHANGED
@@ -2629,3 +2629,5 @@ declare class Graphlit {
2629
2629
  }
2630
2630
  export { Graphlit };
2631
2631
  export * as Types from "./generated/graphql-types.js";
2632
+ export { getPartialErrors, PARTIAL_ERRORS_KEY } from "./partial-errors.js";
2633
+ export type { PartialGraphQLError } from "./partial-errors.js";
package/dist/client.js CHANGED
@@ -3,6 +3,7 @@ import jwt from "jsonwebtoken";
3
3
  import { ApolloClient, InMemoryCache, createHttpLink, ApolloLink, ApolloError, } from "@apollo/client/core/index.js";
4
4
  // Apollo retry link for resilient error handling
5
5
  import { RetryLink } from "@apollo/client/link/retry/index.js";
6
+ import { attachPartialErrors } from "./partial-errors.js";
6
7
  import * as Types from "./generated/graphql-types.js";
7
8
  import * as Documents from "./generated/graphql-documents.js";
8
9
  import { getServiceType, getModelName, getModelEnum } from "./model-mapping.js";
@@ -6125,6 +6126,7 @@ class Graphlit {
6125
6126
  console.warn("GraphQL mutation returned partial data with errors:", result.errors
6126
6127
  .map((err) => this.prettyPrintGraphQLError(err))
6127
6128
  .join("\n"));
6129
+ attachPartialErrors(result.data, result.errors);
6128
6130
  }
6129
6131
  if (!result.data) {
6130
6132
  throw new Error("No data returned from mutation.");
@@ -6141,6 +6143,7 @@ class Graphlit {
6141
6143
  console.warn("GraphQL mutation returned partial data with errors:", error.graphQLErrors
6142
6144
  .map((err) => this.prettyPrintGraphQLError(err))
6143
6145
  .join("\n"));
6146
+ attachPartialErrors(networkResult.data, error.graphQLErrors);
6144
6147
  return networkResult.data;
6145
6148
  }
6146
6149
  }
@@ -6179,6 +6182,7 @@ class Graphlit {
6179
6182
  console.warn("GraphQL query returned partial data with errors:", result.errors
6180
6183
  .map((err) => this.prettyPrintGraphQLError(err))
6181
6184
  .join("\n"));
6185
+ attachPartialErrors(result.data, result.errors);
6182
6186
  }
6183
6187
  if (!result.data) {
6184
6188
  throw new Error("No data returned from query.");
@@ -6195,6 +6199,7 @@ class Graphlit {
6195
6199
  console.warn("GraphQL query returned partial data with errors:", error.graphQLErrors
6196
6200
  .map((err) => this.prettyPrintGraphQLError(err))
6197
6201
  .join("\n"));
6202
+ attachPartialErrors(networkResult.data, error.graphQLErrors);
6198
6203
  return networkResult.data;
6199
6204
  }
6200
6205
  }
@@ -6216,3 +6221,4 @@ class Graphlit {
6216
6221
  }
6217
6222
  export { Graphlit };
6218
6223
  export * as Types from "./generated/graphql-types.js";
6224
+ export { getPartialErrors, PARTIAL_ERRORS_KEY } from "./partial-errors.js";
@@ -16333,6 +16333,7 @@ export const GetSpecification = gql `
16333
16333
  }
16334
16334
  twelveLabs {
16335
16335
  model
16336
+ key
16336
16337
  embeddingOptions
16337
16338
  embeddingScopes
16338
16339
  segmentationMethod
@@ -16739,6 +16740,7 @@ export const QuerySpecifications = gql `
16739
16740
  }
16740
16741
  twelveLabs {
16741
16742
  model
16743
+ key
16742
16744
  embeddingOptions
16743
16745
  embeddingScopes
16744
16746
  segmentationMethod
@@ -20864,6 +20864,8 @@ export type TwelveLabsModelProperties = {
20864
20864
  embeddingOptions?: Maybe<Array<TwelveLabsEmbeddingOptions>>;
20865
20865
  /** The embedding scopes, e.g. clip (per-segment) and/or asset (whole-video). */
20866
20866
  embeddingScopes?: Maybe<Array<TwelveLabsEmbeddingScopes>>;
20867
+ /** The TwelveLabs API key, if using developer's own account. */
20868
+ key?: Maybe<Scalars['String']['output']>;
20867
20869
  /** The TwelveLabs model. */
20868
20870
  model: TwelveLabsModels;
20869
20871
  /** The segmentation duration in seconds, when using fixed segmentation method. Range: 1-10. */
@@ -41099,6 +41101,7 @@ export type GetSpecificationQuery = {
41099
41101
  twelveLabs?: {
41100
41102
  __typename?: 'TwelveLabsModelProperties';
41101
41103
  model: TwelveLabsModels;
41104
+ key?: string | null;
41102
41105
  embeddingOptions?: Array<TwelveLabsEmbeddingOptions> | null;
41103
41106
  embeddingScopes?: Array<TwelveLabsEmbeddingScopes> | null;
41104
41107
  segmentationMethod?: TwelveLabsSegmentationMethods | null;
@@ -41554,6 +41557,7 @@ export type QuerySpecificationsQuery = {
41554
41557
  twelveLabs?: {
41555
41558
  __typename?: 'TwelveLabsModelProperties';
41556
41559
  model: TwelveLabsModels;
41560
+ key?: string | null;
41557
41561
  embeddingOptions?: Array<TwelveLabsEmbeddingOptions> | null;
41558
41562
  embeddingScopes?: Array<TwelveLabsEmbeddingScopes> | null;
41559
41563
  segmentationMethod?: TwelveLabsSegmentationMethods | null;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Partial GraphQL error surfacing.
3
+ *
4
+ * When a GraphQL response contains both `data` and `errors`, the SDK returns
5
+ * the partial data so callers don't break. This module lets callers opt-in to
6
+ * inspecting the errors that came alongside that partial data.
7
+ *
8
+ * Errors are attached as a non-enumerable, Symbol-keyed property so they are
9
+ * invisible to JSON.stringify, Object.keys, for…in, and spread — no breaking
10
+ * changes for any existing consumer.
11
+ */
12
+ export declare const PARTIAL_ERRORS_KEY: unique symbol;
13
+ /**
14
+ * Simplified representation of a GraphQL error that doesn't require consumers
15
+ * to depend on the `graphql` package.
16
+ */
17
+ export interface PartialGraphQLError {
18
+ message: string;
19
+ path?: ReadonlyArray<string | number>;
20
+ extensions?: Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Retrieve partial errors attached to an SDK result, if any.
24
+ *
25
+ * @returns The array of errors, or `undefined` if the result had no errors.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const result = await client.queryGitHubRepositories(input);
30
+ * const errors = getPartialErrors(result);
31
+ * if (errors) {
32
+ * console.warn("Partial errors:", errors);
33
+ * }
34
+ * ```
35
+ */
36
+ export declare function getPartialErrors(result: unknown): PartialGraphQLError[] | undefined;
37
+ /**
38
+ * Attach partial errors to an SDK result object. The property is
39
+ * non-enumerable so it won't appear in serialisation or iteration.
40
+ *
41
+ * @internal — only called from client.ts
42
+ */
43
+ export declare function attachPartialErrors<T>(data: T, errors: ReadonlyArray<{
44
+ message: string;
45
+ path?: ReadonlyArray<string | number>;
46
+ extensions?: Record<string, unknown>;
47
+ }>): T;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Partial GraphQL error surfacing.
3
+ *
4
+ * When a GraphQL response contains both `data` and `errors`, the SDK returns
5
+ * the partial data so callers don't break. This module lets callers opt-in to
6
+ * inspecting the errors that came alongside that partial data.
7
+ *
8
+ * Errors are attached as a non-enumerable, Symbol-keyed property so they are
9
+ * invisible to JSON.stringify, Object.keys, for…in, and spread — no breaking
10
+ * changes for any existing consumer.
11
+ */
12
+ // Symbol.for() is globally shared, so even if two copies of the SDK are loaded
13
+ // (e.g. CJS + ESM, or different versions) they will share the same key.
14
+ export const PARTIAL_ERRORS_KEY = Symbol.for("graphlit.partialErrors");
15
+ /**
16
+ * Retrieve partial errors attached to an SDK result, if any.
17
+ *
18
+ * @returns The array of errors, or `undefined` if the result had no errors.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const result = await client.queryGitHubRepositories(input);
23
+ * const errors = getPartialErrors(result);
24
+ * if (errors) {
25
+ * console.warn("Partial errors:", errors);
26
+ * }
27
+ * ```
28
+ */
29
+ export function getPartialErrors(result) {
30
+ if (result != null &&
31
+ typeof result === "object" &&
32
+ PARTIAL_ERRORS_KEY in result) {
33
+ return result[PARTIAL_ERRORS_KEY];
34
+ }
35
+ return undefined;
36
+ }
37
+ /**
38
+ * Attach partial errors to an SDK result object. The property is
39
+ * non-enumerable so it won't appear in serialisation or iteration.
40
+ *
41
+ * @internal — only called from client.ts
42
+ */
43
+ export function attachPartialErrors(data, errors) {
44
+ if (data != null && typeof data === "object" && errors.length > 0) {
45
+ const simplified = errors.map((e) => ({
46
+ message: e.message,
47
+ ...(e.path ? { path: e.path } : {}),
48
+ ...(e.extensions ? { extensions: e.extensions } : {}),
49
+ }));
50
+ Object.defineProperty(data, PARTIAL_ERRORS_KEY, {
51
+ value: simplified,
52
+ enumerable: false,
53
+ writable: false,
54
+ configurable: true,
55
+ });
56
+ }
57
+ return data;
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20260220001",
3
+ "version": "1.0.20260220004",
4
4
  "description": "Graphlit API Client for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/client.js",