@geins/core 0.9.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,6 +1,7 @@
1
- import type { GeinsSettings } from '@geins/types';
1
+ import type { GeinsSettings, RequestContext } from '@geins/types';
2
2
  import type { MerchantApiClient } from '../api-client/merchantApiClient';
3
3
  import { GraphQLQueryOptions } from '../api-client/merchantApiClient';
4
+ import type { DocumentNode } from '@apollo/client/core';
4
5
  /** Function that returns a MerchantApiClient instance. */
5
6
  export type ApiClientGetter = () => MerchantApiClient;
6
7
  /**
@@ -34,6 +35,22 @@ export declare abstract class BaseApiService {
34
35
  * @throws {GeinsError} If locale or market is missing from both `vars` and the SDK settings.
35
36
  */
36
37
  protected createVariables(vars: Record<string, unknown>): Record<string, unknown>;
38
+ /**
39
+ * Builds a complete {@link GraphQLQueryOptions} object from a query, caller variables,
40
+ * and an optional {@link RequestContext}.
41
+ *
42
+ * - Extracts `userToken` from the request context and routes it to the
43
+ * {@link GraphQLQueryOptions.userToken} field (which becomes an `Authorization: Bearer`
44
+ * header via {@link MerchantApiClient.buildContext}).
45
+ * - Merges remaining context fields (`languageId`, `marketId`, `channelId`) into the
46
+ * GraphQL variables via {@link createVariables}.
47
+ *
48
+ * @param query - The GraphQL document or string to execute.
49
+ * @param vars - Caller-provided variables (e.g. `{ alias: '/about' }`).
50
+ * @param requestContext - Optional per-request overrides including auth token.
51
+ * @returns A ready-to-execute query options object.
52
+ */
53
+ protected createQueryOptions(query: DocumentNode | string, vars: Record<string, unknown>, requestContext?: RequestContext): GraphQLQueryOptions;
37
54
  /**
38
55
  * Executes a GraphQL query via the API client.
39
56
  * @param options - Query and variables to execute.