@disconetwork/core 0.0.16 → 0.0.18

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.
Files changed (120) hide show
  1. package/README.md +14 -12
  2. package/dist/TrackingManager.d.ts +64 -0
  3. package/dist/TrackingManager.d.ts.map +1 -0
  4. package/dist/TrackingManager.js +114 -0
  5. package/dist/TrackingManager.js.map +1 -0
  6. package/dist/api/generated/events/client/client.gen.js +176 -0
  7. package/dist/api/generated/events/client/client.gen.js.map +1 -0
  8. package/dist/api/generated/events/client/utils.gen.js +179 -0
  9. package/dist/api/generated/events/client/utils.gen.js.map +1 -0
  10. package/dist/api/generated/events/client.gen.js +8 -0
  11. package/dist/api/generated/events/client.gen.js.map +1 -0
  12. package/dist/api/generated/events/core/auth.gen.js +12 -0
  13. package/dist/api/generated/events/core/auth.gen.js.map +1 -0
  14. package/dist/api/generated/events/core/bodySerializer.gen.js +6 -0
  15. package/dist/api/generated/events/core/bodySerializer.gen.js.map +1 -0
  16. package/dist/api/generated/events/core/pathSerializer.gen.js +82 -0
  17. package/dist/api/generated/events/core/pathSerializer.gen.js.map +1 -0
  18. package/dist/api/generated/events/core/serverSentEvents.gen.js +95 -0
  19. package/dist/api/generated/events/core/serverSentEvents.gen.js.map +1 -0
  20. package/dist/api/generated/events/core/utils.gen.js +78 -0
  21. package/dist/api/generated/events/core/utils.gen.js.map +1 -0
  22. package/dist/api/generated/events/sdk.gen.js +31 -0
  23. package/dist/api/generated/events/sdk.gen.js.map +1 -0
  24. package/dist/api/generated/events/zod.gen.js +197 -0
  25. package/dist/api/generated/events/zod.gen.js.map +1 -0
  26. package/dist/api/generated/recommendations/client/client.gen.js +176 -0
  27. package/dist/api/generated/recommendations/client/client.gen.js.map +1 -0
  28. package/dist/api/generated/recommendations/client/utils.gen.js +179 -0
  29. package/dist/api/generated/recommendations/client/utils.gen.js.map +1 -0
  30. package/dist/api/generated/recommendations/client.gen.js +8 -0
  31. package/dist/api/generated/recommendations/client.gen.js.map +1 -0
  32. package/dist/api/generated/recommendations/core/auth.gen.js +12 -0
  33. package/dist/api/generated/recommendations/core/auth.gen.js.map +1 -0
  34. package/dist/api/generated/recommendations/core/bodySerializer.gen.js +6 -0
  35. package/dist/api/generated/recommendations/core/bodySerializer.gen.js.map +1 -0
  36. package/dist/api/generated/recommendations/core/pathSerializer.gen.js +82 -0
  37. package/dist/api/generated/recommendations/core/pathSerializer.gen.js.map +1 -0
  38. package/dist/api/generated/recommendations/core/serverSentEvents.gen.js +95 -0
  39. package/dist/api/generated/recommendations/core/serverSentEvents.gen.js.map +1 -0
  40. package/dist/api/generated/recommendations/core/utils.gen.js +78 -0
  41. package/dist/api/generated/recommendations/core/utils.gen.js.map +1 -0
  42. package/dist/api/generated/recommendations/sdk.gen.js +35 -0
  43. package/dist/api/generated/recommendations/sdk.gen.js.map +1 -0
  44. package/dist/api/generated/recommendations/types.gen.d.ts +32 -0
  45. package/dist/api/generated/recommendations/types.gen.d.ts.map +1 -0
  46. package/dist/api/generated/recommendations/zod.gen.js +407 -0
  47. package/dist/api/generated/recommendations/zod.gen.js.map +1 -0
  48. package/dist/api/index.js +60 -0
  49. package/dist/api/index.js.map +1 -0
  50. package/dist/apiKey.js +13 -0
  51. package/dist/apiKey.js.map +1 -0
  52. package/dist/config.js +38 -0
  53. package/dist/config.js.map +1 -0
  54. package/dist/env.d.ts +5 -0
  55. package/dist/env.d.ts.map +1 -0
  56. package/dist/errors.d.ts +56 -0
  57. package/dist/errors.d.ts.map +1 -0
  58. package/dist/errors.js +76 -0
  59. package/dist/errors.js.map +1 -0
  60. package/dist/events/dedupe.d.ts +15 -0
  61. package/dist/events/dedupe.d.ts.map +1 -0
  62. package/dist/events/dedupe.js +34 -0
  63. package/dist/events/dedupe.js.map +1 -0
  64. package/dist/events/eventMapping.js +88 -0
  65. package/dist/events/eventMapping.js.map +1 -0
  66. package/dist/external/DiscoClient.d.ts +88 -0
  67. package/dist/external/DiscoClient.d.ts.map +1 -0
  68. package/dist/external/DiscoClient.js +122 -0
  69. package/dist/external/DiscoClient.js.map +1 -0
  70. package/dist/external/recommendations.d.ts +186 -0
  71. package/dist/external/recommendations.d.ts.map +1 -0
  72. package/dist/external/recommendationsTransforms.js +209 -0
  73. package/dist/external/recommendationsTransforms.js.map +1 -0
  74. package/dist/index.d.ts +8 -97
  75. package/dist/index.js +3 -1769
  76. package/dist/internal/InternalDiscoClient.d.ts +129 -0
  77. package/dist/internal/InternalDiscoClient.d.ts.map +1 -0
  78. package/dist/internal/InternalDiscoClient.js +137 -0
  79. package/dist/internal/InternalDiscoClient.js.map +1 -0
  80. package/dist/internal/denormalize.d.ts +18 -0
  81. package/dist/internal/denormalize.d.ts.map +1 -0
  82. package/dist/internal/denormalize.js +49 -0
  83. package/dist/internal/denormalize.js.map +1 -0
  84. package/dist/internal/recommendations.d.ts +88 -0
  85. package/dist/internal/recommendations.d.ts.map +1 -0
  86. package/dist/internal/recommendationsMapper.js +68 -0
  87. package/dist/internal/recommendationsMapper.js.map +1 -0
  88. package/dist/internal/recommendationsRequestMapper.js +114 -0
  89. package/dist/internal/recommendationsRequestMapper.js.map +1 -0
  90. package/dist/internal/screens.d.ts +77 -0
  91. package/dist/internal/screens.d.ts.map +1 -0
  92. package/dist/internal/screens.js +79 -0
  93. package/dist/internal/screens.js.map +1 -0
  94. package/dist/internal.d.ts +11 -399
  95. package/dist/internal.js +5 -560
  96. package/dist/lib/case.js +26 -0
  97. package/dist/lib/case.js.map +1 -0
  98. package/dist/lib/http.js +21 -0
  99. package/dist/lib/http.js.map +1 -0
  100. package/dist/lib/primitives.js +23 -0
  101. package/dist/lib/primitives.js.map +1 -0
  102. package/dist/lib/schemas.js +25 -0
  103. package/dist/lib/schemas.js.map +1 -0
  104. package/dist/package.js +7 -0
  105. package/dist/package.js.map +1 -0
  106. package/dist/sdkIdentity.d.ts +9 -0
  107. package/dist/sdkIdentity.d.ts.map +1 -0
  108. package/dist/sdkIdentity.js +16 -0
  109. package/dist/sdkIdentity.js.map +1 -0
  110. package/dist/types.d.ts +91 -0
  111. package/dist/types.d.ts.map +1 -0
  112. package/package.json +3 -3
  113. package/dist/errors-DpKOKpT8.d.ts +0 -363
  114. package/dist/errors-DpKOKpT8.d.ts.map +0 -1
  115. package/dist/index.d.ts.map +0 -1
  116. package/dist/index.js.map +0 -1
  117. package/dist/internal.d.ts.map +0 -1
  118. package/dist/internal.js.map +0 -1
  119. package/dist/recommendationsTransforms-O4CTnnnS.js +0 -748
  120. package/dist/recommendationsTransforms-O4CTnnnS.js.map +0 -1
@@ -0,0 +1,60 @@
1
+ import { createConfig } from "./generated/recommendations/client/utils.gen.js";
2
+ import { createClient } from "./generated/recommendations/client/client.gen.js";
3
+ import { createConfig as createConfig$1 } from "./generated/events/client/utils.gen.js";
4
+ import { createClient as createClient$1 } from "./generated/events/client/client.gen.js";
5
+ //#region src/api/index.ts
6
+ /**
7
+ * Build a dedicated, per-instance recommendations transport client from an
8
+ * already-resolved base URL and auth headers. This is intentionally a pure
9
+ * transport factory: public-key validation, URL selection, and header
10
+ * construction are the caller's responsibility (see `apiKey.ts` / `config.ts`).
11
+ *
12
+ * Pass the **gateway root** as `baseUrl` — the SDK appends the operation path
13
+ * (`/recommendations`), so it must not be included.
14
+ *
15
+ * Pass the returned client to the generated `recommendations()` SDK function
16
+ * via its `client` option, e.g.:
17
+ *
18
+ * ```ts
19
+ * validatePublicApiKey(apiKey);
20
+ * const client = createRecommendationsClient({
21
+ * baseUrl: resolveGatewayBaseUrl(),
22
+ * headers: authHeaders({ apiKey }),
23
+ * });
24
+ * await recommendations({ client, body, throwOnError: true });
25
+ * ```
26
+ *
27
+ * A per-instance client (rather than the SDK's shared global singleton) keeps
28
+ * each key's base URL and auth isolated, so multiple clients can coexist.
29
+ */
30
+ function createRecommendationsClient(config) {
31
+ return createClient(createConfig({
32
+ baseUrl: config.baseUrl,
33
+ headers: config.headers,
34
+ ...config.fetch ? { fetch: config.fetch } : {}
35
+ }));
36
+ }
37
+ /**
38
+ * Build a per-instance events transport client for the generated events SDK,
39
+ * mirroring {@link createRecommendationsClient}. Pure transport: callers own
40
+ * URL/header resolution (see `config.ts`).
41
+ *
42
+ * Unlike recommendations, the events SDK posts to `/`, so pass the **full events
43
+ * URL** as `baseUrl` (e.g. `${resolveGatewayBaseUrl()}/events`), not the gateway
44
+ * origin. The SDK reuses an `x-api-key` header from `headers` for its declared
45
+ * security rather than re-deriving a token.
46
+ *
47
+ * Pass the returned client to the generated `eventsPost()` via its `client`
48
+ * option (this is what `DiscoClient.createTrackingManager` does internally).
49
+ */
50
+ function createEventsClient(config) {
51
+ return createClient$1(createConfig$1({
52
+ baseUrl: config.baseUrl,
53
+ headers: config.headers,
54
+ ...config.fetch ? { fetch: config.fetch } : {}
55
+ }));
56
+ }
57
+ //#endregion
58
+ export { createEventsClient, createRecommendationsClient };
59
+
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["createEventsClientBase","createEventsConfig"],"sources":["../../src/api/index.ts"],"sourcesContent":["import {\n createClient,\n createConfig,\n type Client,\n} from \"./generated/recommendations/client/index.js\";\nimport {\n createClient as createEventsClientBase,\n createConfig as createEventsConfig,\n type Client as EventsClient,\n} from \"./generated/events/client/index.js\";\n\n/**\n * Config for a per-instance generated transport client, shared by the\n * recommendations and events factories. Both are pure transport: the caller\n * resolves the base URL and auth headers (see `config.ts`) and the\n * factory just wires them into the generated client.\n */\ntype TransportClientConfig = {\n /**\n * Base URL the generated SDK builds request URLs from. What to pass depends on\n * the operation path — see each factory's docs. Resolve it from\n * `resolveGatewayBaseUrl` in `config.ts` for the caller's override or default.\n */\n baseUrl: string;\n /**\n * Pre-built auth headers (e.g. `x-api-key`, `X-API-Version`). Build these\n * with `authHeaders()` from `config.ts`.\n */\n headers: Record<string, string>;\n /**\n * Override the `fetch` implementation. Defaults to `globalThis.fetch`.\n * Primarily useful in tests and non-standard runtimes.\n */\n fetch?: typeof fetch;\n};\n\n/**\n * Build a dedicated, per-instance recommendations transport client from an\n * already-resolved base URL and auth headers. This is intentionally a pure\n * transport factory: public-key validation, URL selection, and header\n * construction are the caller's responsibility (see `apiKey.ts` / `config.ts`).\n *\n * Pass the **gateway root** as `baseUrl` — the SDK appends the operation path\n * (`/recommendations`), so it must not be included.\n *\n * Pass the returned client to the generated `recommendations()` SDK function\n * via its `client` option, e.g.:\n *\n * ```ts\n * validatePublicApiKey(apiKey);\n * const client = createRecommendationsClient({\n * baseUrl: resolveGatewayBaseUrl(),\n * headers: authHeaders({ apiKey }),\n * });\n * await recommendations({ client, body, throwOnError: true });\n * ```\n *\n * A per-instance client (rather than the SDK's shared global singleton) keeps\n * each key's base URL and auth isolated, so multiple clients can coexist.\n */\nexport function createRecommendationsClient(\n config: TransportClientConfig,\n): Client {\n return createClient(\n createConfig({\n baseUrl: config.baseUrl,\n headers: config.headers,\n ...(config.fetch ? { fetch: config.fetch } : {}),\n }),\n );\n}\n\n/**\n * Build a per-instance events transport client for the generated events SDK,\n * mirroring {@link createRecommendationsClient}. Pure transport: callers own\n * URL/header resolution (see `config.ts`).\n *\n * Unlike recommendations, the events SDK posts to `/`, so pass the **full events\n * URL** as `baseUrl` (e.g. `${resolveGatewayBaseUrl()}/events`), not the gateway\n * origin. The SDK reuses an `x-api-key` header from `headers` for its declared\n * security rather than re-deriving a token.\n *\n * Pass the returned client to the generated `eventsPost()` via its `client`\n * option (this is what `DiscoClient.createTrackingManager` does internally).\n */\nexport function createEventsClient(\n config: TransportClientConfig,\n): EventsClient {\n return createEventsClientBase(\n createEventsConfig({\n baseUrl: config.baseUrl,\n headers: config.headers,\n ...(config.fetch ? { fetch: config.fetch } : {}),\n }),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,4BACd,QACQ;CACR,OAAO,aACL,aAAa;EACX,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;CAChD,CAAC,CACH;AACF;;;;;;;;;;;;;;AAeA,SAAgB,mBACd,QACc;CACd,OAAOA,eACLC,eAAmB;EACjB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,GAAI,OAAO,QAAQ,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;CAChD,CAAC,CACH;AACF"}
package/dist/apiKey.js ADDED
@@ -0,0 +1,13 @@
1
+ //#region src/apiKey.ts
2
+ /**
3
+ * Validate the public key prefix without selecting an API endpoint.
4
+ * Secret (`disco_sk_…`) keys must never be used in client-side code.
5
+ */
6
+ function validatePublicApiKey(apiKey) {
7
+ if (apiKey.startsWith("disco_pk_live_") || apiKey.startsWith("disco_pk_sandbox_")) return;
8
+ throw new Error("Invalid Disco API key: expected a public key prefixed \"disco_pk_live_\" or \"disco_pk_sandbox_\".");
9
+ }
10
+ //#endregion
11
+ export { validatePublicApiKey };
12
+
13
+ //# sourceMappingURL=apiKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiKey.js","names":[],"sources":["../src/apiKey.ts"],"sourcesContent":["/**\n * Validate the public key prefix without selecting an API endpoint.\n * Secret (`disco_sk_…`) keys must never be used in client-side code.\n */\nexport function validatePublicApiKey(apiKey: string): void {\n if (\n apiKey.startsWith(\"disco_pk_live_\") ||\n apiKey.startsWith(\"disco_pk_sandbox_\")\n ) {\n return;\n }\n throw new Error(\n 'Invalid Disco API key: expected a public key prefixed \"disco_pk_live_\" ' +\n 'or \"disco_pk_sandbox_\".',\n );\n}\n"],"mappings":";;;;;AAIA,SAAgB,qBAAqB,QAAsB;CACzD,IACE,OAAO,WAAW,gBAAgB,KAClC,OAAO,WAAW,mBAAmB,GAErC;CAEF,MAAM,IAAI,MACR,oGAEF;AACF"}
package/dist/config.js ADDED
@@ -0,0 +1,38 @@
1
+ //#region src/config.ts
2
+ /**
3
+ * Per-environment base URL for the partners API gateway. Both the
4
+ * recommendations and events services sit behind this single origin, routed by
5
+ * path. This is the gateway **root** — callers/SDKs append the operation path
6
+ * (`/recommendations`, `/events`), so it must not be included here.
7
+ *
8
+ * Single source of truth for the external gateway hostnames; consumers
9
+ * ({@link DiscoClient}, the generated recommendations client) derive their URLs
10
+ * from this rather than hard-coding their own.
11
+ */
12
+ const GATEWAY_BASE_URL = {
13
+ production: "https://partners.disconetwork.com",
14
+ staging: "https://partners.disconetwork-staging.com"
15
+ };
16
+ /** Apply the gateway default and normalize the caller-provided root. */
17
+ function resolveGatewayBaseUrl(baseUrl = GATEWAY_BASE_URL.production) {
18
+ return baseUrl.trim().replace(/\/+$/, "");
19
+ }
20
+ /**
21
+ * Default value for the required `X-API-Version` header. Overridable per client
22
+ * via `apiVersion`.
23
+ */
24
+ const DEFAULT_API_VERSION = "1.0.0";
25
+ /**
26
+ * Build the auth headers the partners gateway requires from a scoped public API
27
+ * key. The `X-API-Version` defaults to {@link DEFAULT_API_VERSION}.
28
+ */
29
+ function authHeaders(config) {
30
+ return {
31
+ "x-api-key": config.apiKey,
32
+ "X-API-Version": config.apiVersion ?? DEFAULT_API_VERSION
33
+ };
34
+ }
35
+ //#endregion
36
+ export { authHeaders, resolveGatewayBaseUrl };
37
+
38
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":[],"sources":["../src/config.ts"],"sourcesContent":["import type { DiscoEnv } from \"./env.js\";\n\n/**\n * Per-environment base URL for the partners API gateway. Both the\n * recommendations and events services sit behind this single origin, routed by\n * path. This is the gateway **root** — callers/SDKs append the operation path\n * (`/recommendations`, `/events`), so it must not be included here.\n *\n * Single source of truth for the external gateway hostnames; consumers\n * ({@link DiscoClient}, the generated recommendations client) derive their URLs\n * from this rather than hard-coding their own.\n */\nexport const GATEWAY_BASE_URL = {\n production: \"https://partners.disconetwork.com\",\n staging: \"https://partners.disconetwork-staging.com\",\n} as const satisfies Record<DiscoEnv, string>;\n\n/** Apply the gateway default and normalize the caller-provided root. */\nexport function resolveGatewayBaseUrl(\n baseUrl: string = GATEWAY_BASE_URL.production,\n): string {\n return baseUrl.trim().replace(/\\/+$/, \"\");\n}\n\n/**\n * Default value for the required `X-API-Version` header. Overridable per client\n * via `apiVersion`.\n */\nconst DEFAULT_API_VERSION = \"1.0.0\";\n\n/**\n * Build the auth headers the partners gateway requires from a scoped public API\n * key. The `X-API-Version` defaults to {@link DEFAULT_API_VERSION}.\n */\nexport function authHeaders(config: { apiKey: string; apiVersion?: string }): {\n \"x-api-key\": string;\n \"X-API-Version\": string;\n} {\n return {\n \"x-api-key\": config.apiKey,\n \"X-API-Version\": config.apiVersion ?? DEFAULT_API_VERSION,\n };\n}\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,mBAAmB;CAC9B,YAAY;CACZ,SAAS;AACX;;AAGA,SAAgB,sBACd,UAAkB,iBAAiB,YAC3B;CACR,OAAO,QAAQ,KAAK,EAAE,QAAQ,QAAQ,EAAE;AAC1C;;;;;AAMA,MAAM,sBAAsB;;;;;AAM5B,SAAgB,YAAY,QAG1B;CACA,OAAO;EACL,aAAa,OAAO;EACpB,iBAAiB,OAAO,cAAc;CACxC;AACF"}
package/dist/env.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ //#region src/env.d.ts
2
+ type DiscoEnv = "production" | "staging";
3
+ //#endregion
4
+ export { DiscoEnv };
5
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","names":[],"sources":["../src/env.ts"],"mappings":";KAAY,QAAA"}
@@ -0,0 +1,56 @@
1
+ //#region src/errors.d.ts
2
+ /**
3
+ * Base class for every error thrown by the Disco clients. Catch this to handle
4
+ * any SDK-originated failure; narrow to a subclass for specifics.
5
+ *
6
+ * Note: a request aborted via an `AbortSignal` is intentionally *not* a
7
+ * `DiscoError` — the native `AbortError` propagates untouched so callers can
8
+ * detect cancellation idiomatically (`err.name === "AbortError"`).
9
+ */
10
+ declare abstract class DiscoError extends Error {}
11
+ /**
12
+ * Thrown when a recommendations/events request returns a non-2xx status. The
13
+ * HTTP status and an optional parsed body are preserved for error UIs and
14
+ * retry logic. Shared by both the external and internal clients.
15
+ */
16
+ declare class DiscoApiError extends DiscoError {
17
+ readonly status: number;
18
+ readonly statusText: string;
19
+ readonly body: unknown;
20
+ constructor(message: string, info: {
21
+ status: number;
22
+ statusText: string;
23
+ body?: unknown;
24
+ });
25
+ }
26
+ /**
27
+ * Thrown when request or response data fails schema validation.
28
+ *
29
+ * Wraps the underlying Zod error and the offending value for debugging, but
30
+ * presents a plain message so consumers never have to import or pattern-match
31
+ * on Zod's own types. `cause` is typed as the common `Error` base so Zod's
32
+ * types stay out of the public surface; both clients validate with
33
+ * `zod/v4-mini`, so narrow `cause` with `instanceof $ZodError` (from
34
+ * `zod/v4/core`) for the structured `issues` — classic `ZodError` from `zod`
35
+ * does not match it — or read `rawValue` for what was being validated.
36
+ */
37
+ declare class DiscoValidationError extends DiscoError {
38
+ /** The underlying Zod error (a `$ZodError`; narrow to read `.issues`). */
39
+ readonly cause: Error;
40
+ /** The value that failed validation. */
41
+ readonly rawValue: unknown;
42
+ constructor(message: string, cause: Error, rawValue: unknown);
43
+ }
44
+ /**
45
+ * Thrown when a request never completes — a network failure, DNS error,
46
+ * connection reset, timeout, etc. A cancellation via `AbortSignal` is excluded:
47
+ * the native `AbortError` propagates as-is (see {@link isAbortError}).
48
+ */
49
+ declare class DiscoNetworkError extends DiscoError {
50
+ /** The underlying transport error (typically a `TypeError` from `fetch`). */
51
+ readonly cause: unknown;
52
+ constructor(message: string, cause: unknown);
53
+ }
54
+ //#endregion
55
+ export { DiscoApiError, DiscoError, DiscoNetworkError, DiscoValidationError };
56
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;AAQA;;;;AAA8C;AAO9C;;uBAPsB,UAAA,SAAmB,KAAK;;;;;;cAOjC,aAAA,SAAsB,UAAU;EAAA,SAClC,MAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;cAGP,OAAA,UACA,IAAA;IACE,MAAA;IACA,UAAA;IACA,IAAA;EAAA;AAAA;;;;;;;;;;;;cAsBO,oBAAA,SAA6B,UAAA;EAMX;EAAA,SAJpB,KAAA,EAAO,KAAA;EAI4C;EAAA,SAFnD,QAAA;cAEG,OAAA,UAAiB,KAAA,EAAO,KAAA,EAAO,QAAA;AAAA;;;;;;cAahC,iBAAA,SAA0B,UAAU;EAIlB;EAAA,SAFpB,KAAA;cAEG,OAAA,UAAiB,KAAA;AAAA"}
package/dist/errors.js ADDED
@@ -0,0 +1,76 @@
1
+ //#region src/errors.ts
2
+ /**
3
+ * Base class for every error thrown by the Disco clients. Catch this to handle
4
+ * any SDK-originated failure; narrow to a subclass for specifics.
5
+ *
6
+ * Note: a request aborted via an `AbortSignal` is intentionally *not* a
7
+ * `DiscoError` — the native `AbortError` propagates untouched so callers can
8
+ * detect cancellation idiomatically (`err.name === "AbortError"`).
9
+ */
10
+ var DiscoError = class extends Error {};
11
+ /**
12
+ * Thrown when a recommendations/events request returns a non-2xx status. The
13
+ * HTTP status and an optional parsed body are preserved for error UIs and
14
+ * retry logic. Shared by both the external and internal clients.
15
+ */
16
+ var DiscoApiError = class extends DiscoError {
17
+ status;
18
+ statusText;
19
+ body;
20
+ constructor(message, info) {
21
+ super(message);
22
+ this.name = "DiscoApiError";
23
+ this.status = info.status;
24
+ this.statusText = info.statusText;
25
+ this.body = info.body;
26
+ }
27
+ };
28
+ /**
29
+ * Thrown when request or response data fails schema validation.
30
+ *
31
+ * Wraps the underlying Zod error and the offending value for debugging, but
32
+ * presents a plain message so consumers never have to import or pattern-match
33
+ * on Zod's own types. `cause` is typed as the common `Error` base so Zod's
34
+ * types stay out of the public surface; both clients validate with
35
+ * `zod/v4-mini`, so narrow `cause` with `instanceof $ZodError` (from
36
+ * `zod/v4/core`) for the structured `issues` — classic `ZodError` from `zod`
37
+ * does not match it — or read `rawValue` for what was being validated.
38
+ */
39
+ var DiscoValidationError = class extends DiscoError {
40
+ /** The underlying Zod error (a `$ZodError`; narrow to read `.issues`). */
41
+ cause;
42
+ /** The value that failed validation. */
43
+ rawValue;
44
+ constructor(message, cause, rawValue) {
45
+ super(`${message}: ${cause.message}`);
46
+ this.name = "DiscoValidationError";
47
+ this.cause = cause;
48
+ this.rawValue = rawValue;
49
+ }
50
+ };
51
+ /**
52
+ * Thrown when a request never completes — a network failure, DNS error,
53
+ * connection reset, timeout, etc. A cancellation via `AbortSignal` is excluded:
54
+ * the native `AbortError` propagates as-is (see {@link isAbortError}).
55
+ */
56
+ var DiscoNetworkError = class extends DiscoError {
57
+ /** The underlying transport error (typically a `TypeError` from `fetch`). */
58
+ cause;
59
+ constructor(message, cause) {
60
+ super(message);
61
+ this.name = "DiscoNetworkError";
62
+ this.cause = cause;
63
+ }
64
+ };
65
+ /**
66
+ * True for an `AbortController` cancellation. Such errors propagate untouched
67
+ * (never wrapped in `DiscoNetworkError`) so callers can detect cancellation by
68
+ * name. Internal helper — not part of the public surface.
69
+ */
70
+ function isAbortError(error) {
71
+ return error instanceof Error && error.name === "AbortError";
72
+ }
73
+ //#endregion
74
+ export { DiscoApiError, DiscoError, DiscoNetworkError, DiscoValidationError, isAbortError };
75
+
76
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Base class for every error thrown by the Disco clients. Catch this to handle\n * any SDK-originated failure; narrow to a subclass for specifics.\n *\n * Note: a request aborted via an `AbortSignal` is intentionally *not* a\n * `DiscoError` — the native `AbortError` propagates untouched so callers can\n * detect cancellation idiomatically (`err.name === \"AbortError\"`).\n */\nexport abstract class DiscoError extends Error {}\n\n/**\n * Thrown when a recommendations/events request returns a non-2xx status. The\n * HTTP status and an optional parsed body are preserved for error UIs and\n * retry logic. Shared by both the external and internal clients.\n */\nexport class DiscoApiError extends DiscoError {\n readonly status: number;\n readonly statusText: string;\n readonly body: unknown;\n\n constructor(\n message: string,\n info: {\n status: number;\n statusText: string;\n body?: unknown;\n },\n ) {\n super(message);\n this.name = \"DiscoApiError\";\n this.status = info.status;\n this.statusText = info.statusText;\n this.body = info.body;\n }\n}\n\n/**\n * Thrown when request or response data fails schema validation.\n *\n * Wraps the underlying Zod error and the offending value for debugging, but\n * presents a plain message so consumers never have to import or pattern-match\n * on Zod's own types. `cause` is typed as the common `Error` base so Zod's\n * types stay out of the public surface; both clients validate with\n * `zod/v4-mini`, so narrow `cause` with `instanceof $ZodError` (from\n * `zod/v4/core`) for the structured `issues` — classic `ZodError` from `zod`\n * does not match it — or read `rawValue` for what was being validated.\n */\nexport class DiscoValidationError extends DiscoError {\n /** The underlying Zod error (a `$ZodError`; narrow to read `.issues`). */\n readonly cause: Error;\n /** The value that failed validation. */\n readonly rawValue: unknown;\n\n constructor(message: string, cause: Error, rawValue: unknown) {\n super(`${message}: ${cause.message}`);\n this.name = \"DiscoValidationError\";\n this.cause = cause;\n this.rawValue = rawValue;\n }\n}\n\n/**\n * Thrown when a request never completes — a network failure, DNS error,\n * connection reset, timeout, etc. A cancellation via `AbortSignal` is excluded:\n * the native `AbortError` propagates as-is (see {@link isAbortError}).\n */\nexport class DiscoNetworkError extends DiscoError {\n /** The underlying transport error (typically a `TypeError` from `fetch`). */\n readonly cause: unknown;\n\n constructor(message: string, cause: unknown) {\n super(message);\n this.name = \"DiscoNetworkError\";\n this.cause = cause;\n }\n}\n\n/**\n * True for an `AbortController` cancellation. Such errors propagate untouched\n * (never wrapped in `DiscoNetworkError`) so callers can detect cancellation by\n * name. Internal helper — not part of the public surface.\n */\nexport function isAbortError(error: unknown): boolean {\n return error instanceof Error && error.name === \"AbortError\";\n}\n"],"mappings":";;;;;;;;;AAQA,IAAsB,aAAtB,cAAyC,MAAM,CAAC;;;;;;AAOhD,IAAa,gBAAb,cAAmC,WAAW;CAC5C;CACA;CACA;CAEA,YACE,SACA,MAKA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,KAAK;EACnB,KAAK,aAAa,KAAK;EACvB,KAAK,OAAO,KAAK;CACnB;AACF;;;;;;;;;;;;AAaA,IAAa,uBAAb,cAA0C,WAAW;;CAEnD;;CAEA;CAEA,YAAY,SAAiB,OAAc,UAAmB;EAC5D,MAAM,GAAG,QAAQ,IAAI,MAAM,SAAS;EACpC,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,WAAW;CAClB;AACF;;;;;;AAOA,IAAa,oBAAb,cAAuC,WAAW;;CAEhD;CAEA,YAAY,SAAiB,OAAgB;EAC3C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;;;;;;AAOA,SAAgB,aAAa,OAAyB;CACpD,OAAO,iBAAiB,SAAS,MAAM,SAAS;AAClD"}
@@ -0,0 +1,15 @@
1
+ import { EventTracker } from "../types.js";
2
+
3
+ //#region src/events/dedupe.d.ts
4
+ /**
5
+ * Wrap an {@link EventTracker} so repeat impressions are suppressed within the
6
+ * session: a given (event type, insertionId) is forwarded once, then dropped.
7
+ *
8
+ * Dedup is a delivery *policy*, not transport — kept as an explicit, opt-in
9
+ * decorator so suppression is never a surprise. State (the seen-set) lives in
10
+ * the wrapper; create one per session-bound tracker to scope dedup per session.
11
+ */
12
+ declare function withImpressionDedupe(inner: EventTracker): EventTracker;
13
+ //#endregion
14
+ export { withImpressionDedupe };
15
+ //# sourceMappingURL=dedupe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe.d.ts","names":[],"sources":["../../src/events/dedupe.ts"],"mappings":";;;;;AAqBA;;;;;;iBAAgB,oBAAA,CAAqB,KAAA,EAAO,YAAA,GAAe,YAAY"}
@@ -0,0 +1,34 @@
1
+ //#region src/events/dedupe.ts
2
+ /**
3
+ * Impression events that fire repeatedly from rendering surfaces (intersection
4
+ * observers, re-renders) and should be sent at most once per session.
5
+ */
6
+ const DEDUPED_EVENTS = new Set([
7
+ "WIDGET_DISPLAY",
8
+ "WIDGET_VIEW",
9
+ "BRAND_DISPLAY",
10
+ "BRAND_VIEW"
11
+ ]);
12
+ /**
13
+ * Wrap an {@link EventTracker} so repeat impressions are suppressed within the
14
+ * session: a given (event type, insertionId) is forwarded once, then dropped.
15
+ *
16
+ * Dedup is a delivery *policy*, not transport — kept as an explicit, opt-in
17
+ * decorator so suppression is never a surprise. State (the seen-set) lives in
18
+ * the wrapper; create one per session-bound tracker to scope dedup per session.
19
+ */
20
+ function withImpressionDedupe(inner) {
21
+ const seen = /* @__PURE__ */ new Set();
22
+ return { track(event) {
23
+ if (DEDUPED_EVENTS.has(event.type)) {
24
+ const key = event.type + ("brand" in event && event.brand ? event.brand.insertionId : "widget");
25
+ if (seen.has(key)) return;
26
+ seen.add(key);
27
+ }
28
+ inner.track(event);
29
+ } };
30
+ }
31
+ //#endregion
32
+ export { withImpressionDedupe };
33
+
34
+ //# sourceMappingURL=dedupe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dedupe.js","names":[],"sources":["../../src/events/dedupe.ts"],"sourcesContent":["import type { EventPayload, EventTracker } from \"../types.js\";\n\n/**\n * Impression events that fire repeatedly from rendering surfaces (intersection\n * observers, re-renders) and should be sent at most once per session.\n */\nconst DEDUPED_EVENTS = new Set<EventPayload[\"type\"]>([\n \"WIDGET_DISPLAY\",\n \"WIDGET_VIEW\",\n \"BRAND_DISPLAY\",\n \"BRAND_VIEW\",\n]);\n\n/**\n * Wrap an {@link EventTracker} so repeat impressions are suppressed within the\n * session: a given (event type, insertionId) is forwarded once, then dropped.\n *\n * Dedup is a delivery *policy*, not transport — kept as an explicit, opt-in\n * decorator so suppression is never a surprise. State (the seen-set) lives in\n * the wrapper; create one per session-bound tracker to scope dedup per session.\n */\nexport function withImpressionDedupe(inner: EventTracker): EventTracker {\n const seen = new Set<string>();\n return {\n track(event: EventPayload): void {\n if (DEDUPED_EVENTS.has(event.type)) {\n const key =\n event.type +\n (\"brand\" in event && event.brand\n ? event.brand.insertionId\n : \"widget\");\n if (seen.has(key)) return;\n seen.add(key);\n }\n inner.track(event);\n },\n };\n}\n"],"mappings":";;;;;AAMA,MAAM,iBAAiB,IAAI,IAA0B;CACnD;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;AAUD,SAAgB,qBAAqB,OAAmC;CACtE,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,EACL,MAAM,OAA2B;EAC/B,IAAI,eAAe,IAAI,MAAM,IAAI,GAAG;GAClC,MAAM,MACJ,MAAM,QACL,WAAW,SAAS,MAAM,QACvB,MAAM,MAAM,cACZ;GACN,IAAI,KAAK,IAAI,GAAG,GAAG;GACnB,KAAK,IAAI,GAAG;EACd;EACA,MAAM,MAAM,KAAK;CACnB,EACF;AACF"}
@@ -0,0 +1,88 @@
1
+ //#region src/events/eventMapping.ts
2
+ /**
3
+ * Map a friendly camelCase {@link EventPayload} to the snake_case wire body the
4
+ * events service expects ({@link EventRequest}), stamping `session_id` and the
5
+ * occurrence time. Pure: no IO, no state — same input, same output.
6
+ *
7
+ * `event_datetime` is emitted as ISO-8601 with a `Z` suffix, the format the
8
+ * events service validates (`z.iso.datetime()` rejects numeric offsets). This
9
+ * differs from the legacy proxy tracker, which emits `+00:00`; the two services
10
+ * validate datetimes differently, so they don't share this mapper.
11
+ */
12
+ function toEventRequest(event, ctx) {
13
+ const session_id = ctx.sessionId;
14
+ const event_datetime = (ctx.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
15
+ const placement_details = toPlacement(event.placement);
16
+ switch (event.type) {
17
+ case "BRAND_CLICK": return {
18
+ event_name: event.type,
19
+ session_id,
20
+ event_datetime,
21
+ placement_details,
22
+ brand_properties: toBrand(event.brand),
23
+ initiating_target: event.target,
24
+ asset_id: event.assetId
25
+ };
26
+ case "BRAND_DISPLAY":
27
+ case "BRAND_VIEW": return {
28
+ event_name: event.type,
29
+ session_id,
30
+ event_datetime,
31
+ placement_details,
32
+ brand_properties: toBrand(event.brand),
33
+ initiating_target: event.target
34
+ };
35
+ case "PRODUCT_CLICK": return {
36
+ event_name: event.type,
37
+ session_id,
38
+ event_datetime,
39
+ placement_details,
40
+ brand_properties: toBrand(event.brand),
41
+ product_properties: { product_id: event.product.productId },
42
+ initiating_target: event.target
43
+ };
44
+ case "PRODUCT_DISPLAY":
45
+ case "PRODUCT_VIEW": return {
46
+ event_name: event.type,
47
+ session_id,
48
+ event_datetime,
49
+ placement_details,
50
+ brand_properties: toBrand(event.brand),
51
+ product_properties: { product_id: event.product.productId },
52
+ initiating_target: event.target
53
+ };
54
+ case "ELEMENT_CLICK": return {
55
+ event_name: event.type,
56
+ session_id,
57
+ event_datetime,
58
+ placement_details,
59
+ initiating_target: event.target,
60
+ brand_properties: event.brand ? toBrand(event.brand) : void 0
61
+ };
62
+ default: return {
63
+ event_name: event.type,
64
+ session_id,
65
+ event_datetime,
66
+ placement_details
67
+ };
68
+ }
69
+ }
70
+ function toBrand(brand) {
71
+ return {
72
+ offer_id: brand.offerId,
73
+ advertiser_id: brand.advertiserId,
74
+ insertion_id: brand.insertionId
75
+ };
76
+ }
77
+ function toPlacement(placement) {
78
+ if (!placement) return void 0;
79
+ return {
80
+ display_mode: placement.displayMode,
81
+ view: placement.view,
82
+ layout_id: placement.layoutId
83
+ };
84
+ }
85
+ //#endregion
86
+ export { toEventRequest };
87
+
88
+ //# sourceMappingURL=eventMapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventMapping.js","names":[],"sources":["../../src/events/eventMapping.ts"],"sourcesContent":["import type {\n BrandEventProperties,\n EventRequest,\n PlacementDetailsOptional,\n} from \"../api/generated/events/index.js\";\nimport type { BrandProperties, EventPayload } from \"../types.js\";\n\n/**\n * Map a friendly camelCase {@link EventPayload} to the snake_case wire body the\n * events service expects ({@link EventRequest}), stamping `session_id` and the\n * occurrence time. Pure: no IO, no state — same input, same output.\n *\n * `event_datetime` is emitted as ISO-8601 with a `Z` suffix, the format the\n * events service validates (`z.iso.datetime()` rejects numeric offsets). This\n * differs from the legacy proxy tracker, which emits `+00:00`; the two services\n * validate datetimes differently, so they don't share this mapper.\n */\nexport function toEventRequest(\n event: EventPayload,\n ctx: { sessionId: string; now?: () => Date },\n): EventRequest {\n const session_id = ctx.sessionId;\n const event_datetime = (ctx.now?.() ?? new Date()).toISOString();\n const placement_details = toPlacement(event.placement);\n\n switch (event.type) {\n case \"BRAND_CLICK\":\n return {\n event_name: event.type,\n session_id,\n event_datetime,\n placement_details,\n brand_properties: toBrand(event.brand),\n initiating_target: event.target,\n asset_id: event.assetId,\n };\n case \"BRAND_DISPLAY\":\n case \"BRAND_VIEW\":\n return {\n event_name: event.type,\n session_id,\n event_datetime,\n placement_details,\n brand_properties: toBrand(event.brand),\n initiating_target: event.target,\n };\n case \"PRODUCT_CLICK\":\n return {\n event_name: event.type,\n session_id,\n event_datetime,\n placement_details,\n brand_properties: toBrand(event.brand),\n product_properties: { product_id: event.product.productId },\n initiating_target: event.target,\n };\n case \"PRODUCT_DISPLAY\":\n case \"PRODUCT_VIEW\":\n return {\n event_name: event.type,\n session_id,\n event_datetime,\n placement_details,\n brand_properties: toBrand(event.brand),\n product_properties: { product_id: event.product.productId },\n initiating_target: event.target,\n };\n case \"ELEMENT_CLICK\":\n return {\n event_name: event.type,\n session_id,\n event_datetime,\n placement_details,\n initiating_target: event.target,\n brand_properties: event.brand ? toBrand(event.brand) : undefined,\n };\n default:\n // WIDGET_LOAD | WIDGET_DISPLAY | WIDGET_VIEW\n return {\n event_name: event.type,\n session_id,\n event_datetime,\n placement_details,\n };\n }\n}\n\nfunction toBrand(brand: BrandProperties): BrandEventProperties {\n return {\n offer_id: brand.offerId,\n advertiser_id: brand.advertiserId,\n insertion_id: brand.insertionId,\n };\n}\n\nfunction toPlacement(\n placement: EventPayload[\"placement\"],\n): PlacementDetailsOptional | undefined {\n if (!placement) return undefined;\n // The friendly placement type is intentionally open-ended (`string`); the wire\n // type narrows to enums. Validation (zod) is the source of truth at the edge.\n return {\n display_mode:\n placement.displayMode as PlacementDetailsOptional[\"display_mode\"],\n view: placement.view as PlacementDetailsOptional[\"view\"],\n layout_id: placement.layoutId,\n };\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgB,eACd,OACA,KACc;CACd,MAAM,aAAa,IAAI;CACvB,MAAM,kBAAkB,IAAI,MAAM,qBAAK,IAAI,KAAK,GAAG,YAAY;CAC/D,MAAM,oBAAoB,YAAY,MAAM,SAAS;CAErD,QAAQ,MAAM,MAAd;EACE,KAAK,eACH,OAAO;GACL,YAAY,MAAM;GAClB;GACA;GACA;GACA,kBAAkB,QAAQ,MAAM,KAAK;GACrC,mBAAmB,MAAM;GACzB,UAAU,MAAM;EAClB;EACF,KAAK;EACL,KAAK,cACH,OAAO;GACL,YAAY,MAAM;GAClB;GACA;GACA;GACA,kBAAkB,QAAQ,MAAM,KAAK;GACrC,mBAAmB,MAAM;EAC3B;EACF,KAAK,iBACH,OAAO;GACL,YAAY,MAAM;GAClB;GACA;GACA;GACA,kBAAkB,QAAQ,MAAM,KAAK;GACrC,oBAAoB,EAAE,YAAY,MAAM,QAAQ,UAAU;GAC1D,mBAAmB,MAAM;EAC3B;EACF,KAAK;EACL,KAAK,gBACH,OAAO;GACL,YAAY,MAAM;GAClB;GACA;GACA;GACA,kBAAkB,QAAQ,MAAM,KAAK;GACrC,oBAAoB,EAAE,YAAY,MAAM,QAAQ,UAAU;GAC1D,mBAAmB,MAAM;EAC3B;EACF,KAAK,iBACH,OAAO;GACL,YAAY,MAAM;GAClB;GACA;GACA;GACA,mBAAmB,MAAM;GACzB,kBAAkB,MAAM,QAAQ,QAAQ,MAAM,KAAK,IAAI,KAAA;EACzD;EACF,SAEE,OAAO;GACL,YAAY,MAAM;GAClB;GACA;GACA;EACF;CACJ;AACF;AAEA,SAAS,QAAQ,OAA8C;CAC7D,OAAO;EACL,UAAU,MAAM;EAChB,eAAe,MAAM;EACrB,cAAc,MAAM;CACtB;AACF;AAEA,SAAS,YACP,WACsC;CACtC,IAAI,CAAC,WAAW,OAAO,KAAA;CAGvB,OAAO;EACL,cACE,UAAU;EACZ,MAAM,UAAU;EAChB,WAAW,UAAU;CACvB;AACF"}
@@ -0,0 +1,88 @@
1
+ import { SdkIdentity } from "../sdkIdentity.js";
2
+ import { RecommendationsRequest, RecommendationsResponse } from "./recommendations.js";
3
+ import { EventTracker } from "../types.js";
4
+
5
+ //#region src/external/DiscoClient.d.ts
6
+ /**
7
+ * Authenticate with a scoped public API key (`disco_pk_live_…` /
8
+ * `disco_pk_sandbox_…`). Both prefixes default to production. Use `baseUrl`
9
+ * to override the gateway for recommendations and events.
10
+ */
11
+ type DiscoClientConfig = {
12
+ apiKey: string;
13
+ /**
14
+ * Absolute HTTP(S) gateway root, without a query or fragment. The SDK appends
15
+ * `/recommendations` and `/events`. Defaults to `https://partners.disconetwork.com`.
16
+ */
17
+ baseUrl?: string;
18
+ /**
19
+ * Value for the required `X-API-Version` header. Defaults to
20
+ * `DEFAULT_API_VERSION` (see `config.ts`).
21
+ */
22
+ apiVersion?: string;
23
+ fetch?: typeof fetch; /** SDK/renderer identity. Defaults to this core package's name and version. */
24
+ sdk?: SdkIdentity;
25
+ };
26
+ type GetRecommendationsOptions = {
27
+ /** Forwarded to `fetch` so consumers can cancel in-flight requests. */signal?: AbortSignal;
28
+ };
29
+ type CreateTrackingManagerOptions = {
30
+ /** Override the fetch used by the tracker. Defaults to the client's fetch. */fetch?: typeof fetch;
31
+ };
32
+ /**
33
+ * Result of `getRecommendationsWithTracker`: the mapped response plus a tracker
34
+ * already bound to its session.
35
+ */
36
+ type RecommendationsWithTracker = {
37
+ data: RecommendationsResponse;
38
+ tracker: EventTracker;
39
+ };
40
+ /**
41
+ * Typed client for the Disco recommendations API — calls
42
+ * `disco-recommendations-api` **directly** (no proxy) at
43
+ * `/recommendations` on the configured gateway (production by default).
44
+ *
45
+ * This is the recommended, partner-facing client. It maps the friendly
46
+ * camelCase request into the rec-api wire body (sending `x-api-key` +
47
+ * `X-API-Version`) and recases the response into camelCase.
48
+ * Validation is performed by the generated SDK. The wire
49
+ * format is fully encapsulated.
50
+ *
51
+ * Renderer-agnostic: plain HTTP, no React dependency.
52
+ */
53
+ declare class DiscoClient {
54
+ #private;
55
+ get baseUrl(): string;
56
+ constructor(config: DiscoClientConfig);
57
+ /**
58
+ * Fetch recommendations for the given request.
59
+ *
60
+ * Maps the request to the wire body, POSTs it, then recases the response to
61
+ * camelCase (keeping the API's normalized shape). The generated SDK validates
62
+ * both sides. Throws `DiscoValidationError` on a request/response schema
63
+ * failure, `DiscoApiError` on a non-2xx response, and `DiscoNetworkError` if
64
+ * the request can't reach the server. An aborted request rejects with the
65
+ * native `AbortError`.
66
+ */
67
+ getRecommendations: (request: RecommendationsRequest, options?: GetRecommendationsOptions) => Promise<RecommendationsResponse>;
68
+ /**
69
+ * Fetch recommendations and create a session-bound events tracker in one
70
+ * call. The tracker inherits this client's API key and base URL.
71
+ */
72
+ getRecommendationsWithTracker: (request: RecommendationsRequest, options?: GetRecommendationsOptions & CreateTrackingManagerOptions) => Promise<RecommendationsWithTracker>;
73
+ /**
74
+ * Create an events tracker bound to a recommendations session (the
75
+ * `sessionId` from a `getRecommendations` response). Posts to the external
76
+ * `/events` endpoint with this client's `x-api-key`, via the generated events
77
+ * SDK (`eventsPost`).
78
+ *
79
+ * This is the **raw** tracker — it sends every call, fire-and-forget (never
80
+ * throws; failures are logged). Impression dedup is a render-lifecycle policy
81
+ * applied a layer up (the React layer wraps this with `withImpressionDedupe`),
82
+ * not baked into the core client.
83
+ */
84
+ createTrackingManager: (sessionId: string, options?: CreateTrackingManagerOptions) => EventTracker;
85
+ }
86
+ //#endregion
87
+ export { DiscoClient, DiscoClientConfig };
88
+ //# sourceMappingURL=DiscoClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiscoClient.d.ts","names":[],"sources":["../../src/external/DiscoClient.ts"],"mappings":";;;;;;;AAkCA;;;KAAY,iBAAA;EACV,MAAA;EAKA;;;;EAAA,OAAA;EAQM;;AAAW;AAGnB;EANE,UAAA;EACA,KAAA,UAAe,KAAA,EAOf;EALA,GAAA,GAAM,WAAW;AAAA;AAAA,KAGP,yBAAA;yEAEV,MAAA,GAAS,WAAW;AAAA;AAAA,KAGV,4BAAA;EAS0B,8EAPpC,KAAA,UAAe,KAAK;AAAA;;;;;KAOV,0BAAA;EACV,IAAA,EAAM,uBAAA;EACN,OAAA,EAAS,YAAY;AAAA;;;;;;;;;;;;;;cAgBV,WAAA;EAAA;MAMP,OAAA,CAAA;cAIQ,MAAA,EAAQ,iBAAA;;;;;;;;;;;EA8BpB,kBAAA,GACE,OAAA,EAAS,sBAAA,EACT,OAAA,GAAU,yBAAA,KACT,OAAA,CAAQ,uBAAA;EAkDA;;;;EADX,6BAAA,GACE,OAAA,EAAS,sBAAA,EACT,OAAA,GAAU,yBAAA,GAA4B,4BAAA,KACrC,OAAA,CAAQ,0BAAA;EAAR;;;;;;;;AAwBY;;;EAHf,qBAAA,GACE,SAAA,UACA,OAAA,GAAU,4BAAA,KACT,YAAA;AAAA"}