@geins/core 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.
- package/dist/base/baseApiService.d.ts +28 -3
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
/**
|
|
@@ -21,11 +22,35 @@ export declare abstract class BaseApiService {
|
|
|
21
22
|
destroy(): void;
|
|
22
23
|
/**
|
|
23
24
|
* Merges caller-provided variables with default languageId, marketId, and channelId from settings.
|
|
24
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* Per-request overrides: if `vars` already contains `languageId`, `marketId`, or `channelId`
|
|
27
|
+
* those values are used as-is and the SDK-level settings are ignored for that field.
|
|
28
|
+
* This mirrors the shape of {@link RequestContext} and allows callers to pass a
|
|
29
|
+
* `RequestContext` object directly as part of `vars` to override locale/market on a
|
|
30
|
+
* per-request basis without reinitialising the SDK.
|
|
31
|
+
*
|
|
32
|
+
* @param vars - Variables to enrich with defaults. Pre-existing `languageId`, `marketId`,
|
|
33
|
+
* or `channelId` fields take precedence over the SDK-level settings.
|
|
25
34
|
* @returns The enriched variables object.
|
|
26
|
-
* @throws {GeinsError} If locale or market is missing
|
|
35
|
+
* @throws {GeinsError} If locale or market is missing from both `vars` and the SDK settings.
|
|
27
36
|
*/
|
|
28
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;
|
|
29
54
|
/**
|
|
30
55
|
* Executes a GraphQL query via the API client.
|
|
31
56
|
* @param options - Query and variables to execute.
|