@contentful/optimization-node 0.1.0-alpha8 → 1.0.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 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/Optimization.ts","../src/global-constants.ts","webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/index.ts"],"sourcesContent":["import { type App, type CoreStatelessConfig, CoreStateless } from '@contentful/optimization-core'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './global-constants'\n\n/**\n * Configuration for the Node-specific Optimization SDK.\n *\n * @public\n * @remarks\n * This configuration extends {@link CoreConfig} but allows partial overrides\n * of the event-builder configuration. SDKs commonly inject their own library\n * metadata or channel definitions.\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * This differs from {@link CoreConfig.eventBuilder}, which expects a\n * full configuration object.\n */\n eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>\n}\n\n/**\n * Merge user-supplied configuration with defaults for the Node SDK.\n *\n * @param config - The input configuration supplied by the caller.\n * @returns A fully composed {@link CoreConfig} object suitable for\n * constructing the core runtime.\n *\n * @internal\n * @remarks\n * Ensures that the Node SDK always identifies itself via a `server` channel\n * and a `library` metadata block unless explicitly overridden.\n */\nfunction mergeConfig(config: OptimizationNodeConfig): CoreStatelessConfig {\n const { app, ...restConfig } = config\n\n const defaultConfig: Partial<CoreStatelessConfig> = {\n eventBuilder: {\n app,\n channel: 'server',\n library: { name: OPTIMIZATION_NODE_SDK_NAME, version: OPTIMIZATION_NODE_SDK_VERSION },\n },\n }\n return merge(defaultConfig, restConfig)\n}\n\n/**\n * Node-specific Optimization SDK built on {@link CoreStateless}.\n *\n * @public\n * @remarks\n * This class adapts the stateless Optimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No analytics or personalization behavior is modified—\n * only configuration defaults differ.\n *\n * @example\n * ```ts\n * import Optimization from '@contentful/optimization-node'\n *\n * const sdk = new Optimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * await sdk.track({ event: 'server_event', properties: { id: 1 } })\n * ```\n */\nclass Optimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n */\n constructor(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\n }\n}\n\nexport default Optimization\n","// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-export of the anonymous-ID cookie name used by the Optimization Core.\n *\n * @public\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking personalization and analytics\n * events when no explicit profile is known.\n *\n * @see {@link ANONYMOUS_ID_COOKIE} in `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-node'\n * const id = request.cookies[ANONYMOUS_ID_COOKIE]\n * ```\n */\nexport { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core'\n","// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import Optimization from './Optimization'\n\nexport * from '@contentful/optimization-core'\n\nexport * from './global-constants'\nexport * from './Optimization'\n\nexport default Optimization\n"],"names":["mergeConfig","config","app","restConfig","defaultConfig","OPTIMIZATION_NODE_SDK_NAME","OPTIMIZATION_NODE_SDK_VERSION","merge","Optimization","CoreStateless","mergedConfig","__OPTIMIZATION_VERSION__","__OPTIMIZATION_PACKAGE_NAME__","__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;QA6CA,SAASA,YAAYC,MAA8B;YACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;YAE/B,MAAMG,gBAA8C;gBAClD,cAAc;oBACZF;oBACA,SAAS;oBACT,SAAS;wBAAE,MAAMG,iBAAAA,EAA0BA;wBAAE,SAASC,iBAAAA,EAA6BA;oBAAC;gBACtF;YACF;YACA,OAAOC,AAAAA,IAAAA,oCAAAA,KAAAA,AAAAA,EAAMH,eAAeD;QAC9B;QAyBA,MAAMK,qBAAqBC,mBAAAA,aAAaA;YAOtC,YAAYR,MAA8B,CAAE;gBAC1C,MAAMS,eAAoCV,YAAYC;gBAEtD,KAAK,CAACS;YACR;QACF;QAEA,yBAAeF;;;;;;;;;QC1FR,MAAMF,gCACoCK;QAC1C,MAAMN,6BAEPO;;;;;;;;;;;;;;;;;ICRNC,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFP,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOQ,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;ICCA,gCAAeV,+BAAAA,CAAYA"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/constants.ts","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/ContentfulOptimization.ts","../src/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\n/**\n * The current version of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\n\n/**\n * The package name of the Optimization Node SDK, injected at build-time.\n *\n * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.\n *\n * @public\n */\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-exports of anonymous identifier constants used by the Optimization Core.\n *\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking optimization and insights\n * events when no explicit profile is known.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-node/constants'\n * const cookieId = request.cookies[ANONYMOUS_ID_COOKIE]\n * const storageId = localStorage.getItem(ANONYMOUS_ID_KEY)\n * ```\n *\n * @see {@link ANONYMOUS_ID_COOKIE} and {@link ANONYMOUS_ID_KEY} in\n * `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @public\n */\nexport { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants'\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {\n CoreStateless,\n type CoreStatelessConfig,\n type EventType,\n} from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\nconst DEFAULT_NODE_ALLOWED_EVENT_TYPES: EventType[] = ['identify', 'page']\n\n/**\n * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.\n *\n * @remarks\n * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`\n * is intentionally omitted from singleton SDK configuration.\n *\n * @public\n */\nexport type PublicNodeEventBuilderConfig = Partial<\n Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>\n>\n\n/**\n * Configuration for the Node-specific ContentfulOptimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * Request-scoped consent should be bound with `forRequest()`, not configured\n * on the SDK singleton.\n *\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: PublicNodeEventBuilderConfig\n}\n\n/**\n * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless ContentfulOptimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No core runtime behavior is modified; only configuration\n * defaults differ.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const sdk = new ContentfulOptimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * const requestOptimization = sdk.forRequest({\n * consent: true,\n * locale: 'fr-CA',\n * profile: { id: 'profile-id' },\n * })\n *\n * const { accepted, data } = await requestOptimization.page()\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass ContentfulOptimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig) {\n const { library, ...eventBuilderConfig } = eventBuilder ?? {}\n\n super({\n ...config,\n allowedEventTypes: allowedEventTypes ?? DEFAULT_NODE_ALLOWED_EVENT_TYPES,\n eventBuilder: {\n app,\n channel: 'server',\n ...eventBuilderConfig,\n library: {\n name: OPTIMIZATION_NODE_SDK_NAME,\n version: OPTIMIZATION_NODE_SDK_VERSION,\n ...library,\n },\n getConsent: () => false,\n },\n })\n }\n}\n\nexport default ContentfulOptimization\n","/**\n * Contentful ContentfulOptimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link ContentfulOptimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport ContentfulOptimization from './ContentfulOptimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './ContentfulOptimization'\n\nexport default ContentfulOptimization\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__","__webpack_require__","definition","key","Object","obj","prop","Symbol","DEFAULT_NODE_ALLOWED_EVENT_TYPES","ContentfulOptimization","CoreStateless","app","allowedEventTypes","eventBuilder","config","library","eventBuilderConfig"],"mappings":";;;;;;;;QAYO,MAAMA,gCACoCC;QAS1C,MAAMC,6BAEPC;;;;;;;;;;;;;;ICxBNC,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;ICEA,MAAMI,mCAAgD;QAAC;QAAY;KAAO;IAkF1E,MAAMC,+BAA+BC,kCAAAA,aAAaA;QAchD,YAAY,EAAEC,GAAG,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGC,QAAgC,CAAE;YACvF,MAAM,EAAEC,OAAO,EAAE,GAAGC,oBAAoB,GAAGH,gBAAgB,CAAC;YAE5D,KAAK,CAAC;gBACJ,GAAGC,MAAM;gBACT,mBAAmBF,qBAAqBJ;gBACxC,cAAc;oBACZG;oBACA,SAAS;oBACT,GAAGK,kBAAkB;oBACrB,SAAS;wBACP,MAAMjB,UAAAA,0BAA0BA;wBAChC,SAASF,UAAAA,6BAA6BA;wBACtC,GAAGkB,OAAO;oBACZ;oBACA,YAAY,IAAM;gBACpB;YACF;QACF;IACF;IAEA,mCAAeN;IC3Gf,YAAeA"}
package/dist/index.d.cts CHANGED
@@ -1,56 +1,99 @@
1
- import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core';
2
- import { App } from '@contentful/optimization-core';
1
+ /**
2
+ * Contentful ContentfulOptimization Node SDK.
3
+ *
4
+ * @remarks
5
+ * Adds Node-specific defaults via the {@link ContentfulOptimization} class.
6
+ * Core and transitive API exports are available from dedicated entrypoints:
7
+ * `@contentful/optimization-node/core-sdk`,
8
+ * `@contentful/optimization-node/api-client`,
9
+ * and `@contentful/optimization-node/api-schemas`.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ import type { App } from '@contentful/optimization-core/api-schemas';
3
15
  import { CoreStateless } from '@contentful/optimization-core';
4
16
  import { CoreStatelessConfig } from '@contentful/optimization-core';
5
17
 
6
- export { ANONYMOUS_ID_COOKIE }
7
-
8
18
  /**
9
- * Node-specific Optimization SDK built on {@link CoreStateless}.
19
+ * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
10
20
  *
11
- * @public
12
21
  * @remarks
13
- * This class adapts the stateless Optimization Core for Node runtimes by
22
+ * This class adapts the stateless ContentfulOptimization Core for Node runtimes by
14
23
  * applying environment-appropriate defaults (e.g., server channel, Node SDK
15
- * library metadata). No analytics or personalization behavior is modified—
16
- * only configuration defaults differ.
24
+ * library metadata). No core runtime behavior is modified; only configuration
25
+ * defaults differ.
17
26
  *
18
27
  * @example
19
28
  * ```ts
20
- * import Optimization from '@contentful/optimization-node'
29
+ * import ContentfulOptimization from '@contentful/optimization-node'
21
30
  *
22
- * const sdk = new Optimization({
31
+ * const sdk = new ContentfulOptimization({
23
32
  * clientId: 'abc-123',
24
33
  * environment: 'main',
25
34
  * logLevel: 'info',
26
35
  * })
27
36
  *
28
- * await sdk.track({ event: 'server_event', properties: { id: 1 } })
37
+ * const requestOptimization = sdk.forRequest({
38
+ * consent: true,
39
+ * locale: 'fr-CA',
40
+ * profile: { id: 'profile-id' },
41
+ * })
42
+ *
43
+ * const { accepted, data } = await requestOptimization.page()
29
44
  * ```
45
+ *
46
+ * @see {@link CoreStateless}
47
+ *
48
+ * @public
30
49
  */
31
- declare class Optimization extends CoreStateless {
50
+ declare class ContentfulOptimization extends CoreStateless {
32
51
  /**
33
52
  * Create an instance of the Node SDK with merged defaults.
34
53
  *
35
54
  * @param config - Partial Node-specific configuration. Any eventBuilder
36
55
  * fields provided are merged with Node's defaults.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import ContentfulOptimization from '@contentful/optimization-node'
60
+ *
61
+ * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
62
+ * ```
37
63
  */
38
- constructor(config: OptimizationNodeConfig);
64
+ constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig);
39
65
  }
40
- export default Optimization;
66
+ export default ContentfulOptimization;
41
67
 
68
+ /**
69
+ * The package name of the Optimization Node SDK, injected at build-time.
70
+ *
71
+ * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
72
+ *
73
+ * @public
74
+ */
42
75
  export declare const OPTIMIZATION_NODE_SDK_NAME: string;
43
76
 
77
+ /**
78
+ * The current version of the Optimization Node SDK, injected at build-time.
79
+ *
80
+ * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
81
+ *
82
+ * @public
83
+ */
44
84
  export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
45
85
 
46
86
  /**
47
- * Configuration for the Node-specific Optimization SDK.
87
+ * Configuration for the Node-specific ContentfulOptimization SDK.
48
88
  *
49
- * @public
50
89
  * @remarks
51
- * This configuration extends {@link CoreConfig} but allows partial overrides
52
- * of the event-builder configuration. SDKs commonly inject their own library
53
- * metadata or channel definitions.
90
+ * This configuration extends {@link CoreStatelessConfig} but allows partial
91
+ * overrides of the event-builder configuration. SDKs commonly inject their own
92
+ * library metadata or channel definitions.
93
+ *
94
+ * @see {@link CoreStatelessConfig}
95
+ *
96
+ * @public
54
97
  */
55
98
  export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
56
99
  /**
@@ -65,13 +108,24 @@ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig
65
108
  *
66
109
  * @remarks
67
110
  * Any provided fields are merged with the default Node SDK metadata.
68
- * This differs from {@link CoreConfig.eventBuilder}, which expects a
69
- * full configuration object.
111
+ * Request-scoped consent should be bound with `forRequest()`, not configured
112
+ * on the SDK singleton.
113
+ *
114
+ * This differs from {@link CoreStatelessConfig} eventBuilder, which expects
115
+ * a full configuration object.
70
116
  */
71
- eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
117
+ eventBuilder?: PublicNodeEventBuilderConfig;
72
118
  }
73
119
 
74
-
75
- export * from "@contentful/optimization-core";
120
+ /**
121
+ * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.
122
+ *
123
+ * @remarks
124
+ * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`
125
+ * is intentionally omitted from singleton SDK configuration.
126
+ *
127
+ * @public
128
+ */
129
+ export declare type PublicNodeEventBuilderConfig = Partial<Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>>;
76
130
 
77
131
  export { }
package/dist/index.d.mts CHANGED
@@ -1,56 +1,99 @@
1
- import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core';
2
- import { App } from '@contentful/optimization-core';
1
+ /**
2
+ * Contentful ContentfulOptimization Node SDK.
3
+ *
4
+ * @remarks
5
+ * Adds Node-specific defaults via the {@link ContentfulOptimization} class.
6
+ * Core and transitive API exports are available from dedicated entrypoints:
7
+ * `@contentful/optimization-node/core-sdk`,
8
+ * `@contentful/optimization-node/api-client`,
9
+ * and `@contentful/optimization-node/api-schemas`.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ import type { App } from '@contentful/optimization-core/api-schemas';
3
15
  import { CoreStateless } from '@contentful/optimization-core';
4
16
  import { CoreStatelessConfig } from '@contentful/optimization-core';
5
17
 
6
- export { ANONYMOUS_ID_COOKIE }
7
-
8
18
  /**
9
- * Node-specific Optimization SDK built on {@link CoreStateless}.
19
+ * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
10
20
  *
11
- * @public
12
21
  * @remarks
13
- * This class adapts the stateless Optimization Core for Node runtimes by
22
+ * This class adapts the stateless ContentfulOptimization Core for Node runtimes by
14
23
  * applying environment-appropriate defaults (e.g., server channel, Node SDK
15
- * library metadata). No analytics or personalization behavior is modified—
16
- * only configuration defaults differ.
24
+ * library metadata). No core runtime behavior is modified; only configuration
25
+ * defaults differ.
17
26
  *
18
27
  * @example
19
28
  * ```ts
20
- * import Optimization from '@contentful/optimization-node'
29
+ * import ContentfulOptimization from '@contentful/optimization-node'
21
30
  *
22
- * const sdk = new Optimization({
31
+ * const sdk = new ContentfulOptimization({
23
32
  * clientId: 'abc-123',
24
33
  * environment: 'main',
25
34
  * logLevel: 'info',
26
35
  * })
27
36
  *
28
- * await sdk.track({ event: 'server_event', properties: { id: 1 } })
37
+ * const requestOptimization = sdk.forRequest({
38
+ * consent: true,
39
+ * locale: 'fr-CA',
40
+ * profile: { id: 'profile-id' },
41
+ * })
42
+ *
43
+ * const { accepted, data } = await requestOptimization.page()
29
44
  * ```
45
+ *
46
+ * @see {@link CoreStateless}
47
+ *
48
+ * @public
30
49
  */
31
- declare class Optimization extends CoreStateless {
50
+ declare class ContentfulOptimization extends CoreStateless {
32
51
  /**
33
52
  * Create an instance of the Node SDK with merged defaults.
34
53
  *
35
54
  * @param config - Partial Node-specific configuration. Any eventBuilder
36
55
  * fields provided are merged with Node's defaults.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import ContentfulOptimization from '@contentful/optimization-node'
60
+ *
61
+ * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
62
+ * ```
37
63
  */
38
- constructor(config: OptimizationNodeConfig);
64
+ constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig);
39
65
  }
40
- export default Optimization;
66
+ export default ContentfulOptimization;
41
67
 
68
+ /**
69
+ * The package name of the Optimization Node SDK, injected at build-time.
70
+ *
71
+ * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
72
+ *
73
+ * @public
74
+ */
42
75
  export declare const OPTIMIZATION_NODE_SDK_NAME: string;
43
76
 
77
+ /**
78
+ * The current version of the Optimization Node SDK, injected at build-time.
79
+ *
80
+ * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
81
+ *
82
+ * @public
83
+ */
44
84
  export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
45
85
 
46
86
  /**
47
- * Configuration for the Node-specific Optimization SDK.
87
+ * Configuration for the Node-specific ContentfulOptimization SDK.
48
88
  *
49
- * @public
50
89
  * @remarks
51
- * This configuration extends {@link CoreConfig} but allows partial overrides
52
- * of the event-builder configuration. SDKs commonly inject their own library
53
- * metadata or channel definitions.
90
+ * This configuration extends {@link CoreStatelessConfig} but allows partial
91
+ * overrides of the event-builder configuration. SDKs commonly inject their own
92
+ * library metadata or channel definitions.
93
+ *
94
+ * @see {@link CoreStatelessConfig}
95
+ *
96
+ * @public
54
97
  */
55
98
  export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
56
99
  /**
@@ -65,13 +108,24 @@ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig
65
108
  *
66
109
  * @remarks
67
110
  * Any provided fields are merged with the default Node SDK metadata.
68
- * This differs from {@link CoreConfig.eventBuilder}, which expects a
69
- * full configuration object.
111
+ * Request-scoped consent should be bound with `forRequest()`, not configured
112
+ * on the SDK singleton.
113
+ *
114
+ * This differs from {@link CoreStatelessConfig} eventBuilder, which expects
115
+ * a full configuration object.
70
116
  */
71
- eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
117
+ eventBuilder?: PublicNodeEventBuilderConfig;
72
118
  }
73
119
 
74
-
75
- export * from "@contentful/optimization-core";
120
+ /**
121
+ * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.
122
+ *
123
+ * @remarks
124
+ * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`
125
+ * is intentionally omitted from singleton SDK configuration.
126
+ *
127
+ * @public
128
+ */
129
+ export declare type PublicNodeEventBuilderConfig = Partial<Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>>;
76
130
 
77
131
  export { }
package/dist/index.d.ts CHANGED
@@ -1,56 +1,99 @@
1
- import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core';
2
- import { App } from '@contentful/optimization-core';
1
+ /**
2
+ * Contentful ContentfulOptimization Node SDK.
3
+ *
4
+ * @remarks
5
+ * Adds Node-specific defaults via the {@link ContentfulOptimization} class.
6
+ * Core and transitive API exports are available from dedicated entrypoints:
7
+ * `@contentful/optimization-node/core-sdk`,
8
+ * `@contentful/optimization-node/api-client`,
9
+ * and `@contentful/optimization-node/api-schemas`.
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+
14
+ import type { App } from '@contentful/optimization-core/api-schemas';
3
15
  import { CoreStateless } from '@contentful/optimization-core';
4
16
  import { CoreStatelessConfig } from '@contentful/optimization-core';
5
17
 
6
- export { ANONYMOUS_ID_COOKIE }
7
-
8
18
  /**
9
- * Node-specific Optimization SDK built on {@link CoreStateless}.
19
+ * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
10
20
  *
11
- * @public
12
21
  * @remarks
13
- * This class adapts the stateless Optimization Core for Node runtimes by
22
+ * This class adapts the stateless ContentfulOptimization Core for Node runtimes by
14
23
  * applying environment-appropriate defaults (e.g., server channel, Node SDK
15
- * library metadata). No analytics or personalization behavior is modified—
16
- * only configuration defaults differ.
24
+ * library metadata). No core runtime behavior is modified; only configuration
25
+ * defaults differ.
17
26
  *
18
27
  * @example
19
28
  * ```ts
20
- * import Optimization from '@contentful/optimization-node'
29
+ * import ContentfulOptimization from '@contentful/optimization-node'
21
30
  *
22
- * const sdk = new Optimization({
31
+ * const sdk = new ContentfulOptimization({
23
32
  * clientId: 'abc-123',
24
33
  * environment: 'main',
25
34
  * logLevel: 'info',
26
35
  * })
27
36
  *
28
- * await sdk.track({ event: 'server_event', properties: { id: 1 } })
37
+ * const requestOptimization = sdk.forRequest({
38
+ * consent: true,
39
+ * locale: 'fr-CA',
40
+ * profile: { id: 'profile-id' },
41
+ * })
42
+ *
43
+ * const { accepted, data } = await requestOptimization.page()
29
44
  * ```
45
+ *
46
+ * @see {@link CoreStateless}
47
+ *
48
+ * @public
30
49
  */
31
- declare class Optimization extends CoreStateless {
50
+ declare class ContentfulOptimization extends CoreStateless {
32
51
  /**
33
52
  * Create an instance of the Node SDK with merged defaults.
34
53
  *
35
54
  * @param config - Partial Node-specific configuration. Any eventBuilder
36
55
  * fields provided are merged with Node's defaults.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import ContentfulOptimization from '@contentful/optimization-node'
60
+ *
61
+ * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
62
+ * ```
37
63
  */
38
- constructor(config: OptimizationNodeConfig);
64
+ constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig);
39
65
  }
40
- export default Optimization;
66
+ export default ContentfulOptimization;
41
67
 
68
+ /**
69
+ * The package name of the Optimization Node SDK, injected at build-time.
70
+ *
71
+ * @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
72
+ *
73
+ * @public
74
+ */
42
75
  export declare const OPTIMIZATION_NODE_SDK_NAME: string;
43
76
 
77
+ /**
78
+ * The current version of the Optimization Node SDK, injected at build-time.
79
+ *
80
+ * @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
81
+ *
82
+ * @public
83
+ */
44
84
  export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
45
85
 
46
86
  /**
47
- * Configuration for the Node-specific Optimization SDK.
87
+ * Configuration for the Node-specific ContentfulOptimization SDK.
48
88
  *
49
- * @public
50
89
  * @remarks
51
- * This configuration extends {@link CoreConfig} but allows partial overrides
52
- * of the event-builder configuration. SDKs commonly inject their own library
53
- * metadata or channel definitions.
90
+ * This configuration extends {@link CoreStatelessConfig} but allows partial
91
+ * overrides of the event-builder configuration. SDKs commonly inject their own
92
+ * library metadata or channel definitions.
93
+ *
94
+ * @see {@link CoreStatelessConfig}
95
+ *
96
+ * @public
54
97
  */
55
98
  export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
56
99
  /**
@@ -65,13 +108,24 @@ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig
65
108
  *
66
109
  * @remarks
67
110
  * Any provided fields are merged with the default Node SDK metadata.
68
- * This differs from {@link CoreConfig.eventBuilder}, which expects a
69
- * full configuration object.
111
+ * Request-scoped consent should be bound with `forRequest()`, not configured
112
+ * on the SDK singleton.
113
+ *
114
+ * This differs from {@link CoreStatelessConfig} eventBuilder, which expects
115
+ * a full configuration object.
70
116
  */
71
- eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
117
+ eventBuilder?: PublicNodeEventBuilderConfig;
72
118
  }
73
119
 
74
-
75
- export * from "@contentful/optimization-core";
120
+ /**
121
+ * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.
122
+ *
123
+ * @remarks
124
+ * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`
125
+ * is intentionally omitted from singleton SDK configuration.
126
+ *
127
+ * @public
128
+ */
129
+ export declare type PublicNodeEventBuilderConfig = Partial<Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>>;
76
130
 
77
131
  export { }
package/dist/index.mjs CHANGED
@@ -1,32 +1,32 @@
1
- import * as __rspack_external__contentful_optimization_core_7d4758c6 from "@contentful/optimization-core";
2
- import { merge } from "es-toolkit";
3
- const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha8";
4
- const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
5
- function mergeConfig(config) {
6
- const { app, ...restConfig } = config;
7
- const defaultConfig = {
8
- eventBuilder: {
9
- app,
10
- channel: 'server',
11
- library: {
12
- name: OPTIMIZATION_NODE_SDK_NAME,
13
- version: OPTIMIZATION_NODE_SDK_VERSION
1
+ import { __rspack_external__contentful_optimization_core_7d4758c6 } from "./987.mjs";
2
+ import { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
3
+ const DEFAULT_NODE_ALLOWED_EVENT_TYPES = [
4
+ 'identify',
5
+ 'page'
6
+ ];
7
+ class ContentfulOptimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
8
+ constructor({ app, allowedEventTypes, eventBuilder, ...config }){
9
+ const { library, ...eventBuilderConfig } = eventBuilder ?? {};
10
+ super({
11
+ ...config,
12
+ allowedEventTypes: allowedEventTypes ?? DEFAULT_NODE_ALLOWED_EVENT_TYPES,
13
+ eventBuilder: {
14
+ app,
15
+ channel: 'server',
16
+ ...eventBuilderConfig,
17
+ library: {
18
+ name: OPTIMIZATION_NODE_SDK_NAME,
19
+ version: OPTIMIZATION_NODE_SDK_VERSION,
20
+ ...library
21
+ },
22
+ getConsent: ()=>false
14
23
  }
15
- }
16
- };
17
- return merge(defaultConfig, restConfig);
18
- }
19
- class Optimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
20
- constructor(config){
21
- const mergedConfig = mergeConfig(config);
22
- super(mergedConfig);
24
+ });
23
25
  }
24
26
  }
25
- const src_Optimization = Optimization;
26
- const src = src_Optimization;
27
- var ANONYMOUS_ID_COOKIE = __rspack_external__contentful_optimization_core_7d4758c6.ANONYMOUS_ID_COOKIE;
28
- export * from "@contentful/optimization-core";
27
+ const src_ContentfulOptimization = ContentfulOptimization;
28
+ const src = src_ContentfulOptimization;
29
+ export { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
29
30
  export default src;
30
- export { ANONYMOUS_ID_COOKIE, OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION };
31
31
 
32
32
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/global-constants.ts","../src/Optimization.ts","../src/index.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_VERSION__: string | undefined\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Replaced at build-time\ndeclare const __OPTIMIZATION_PACKAGE_NAME__: string | undefined\n\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\nexport const OPTIMIZATION_NODE_SDK_NAME =\n typeof __OPTIMIZATION_PACKAGE_NAME__ === 'string'\n ? __OPTIMIZATION_PACKAGE_NAME__\n : '@contentful/optimization-node'\n\n/**\n * Re-export of the anonymous-ID cookie name used by the Optimization Core.\n *\n * @public\n * @remarks\n * This constant is surfaced here to provide a stable import path for Node SDK\n * consumers. It represents the cookie key used by the Optimization Framework\n * to persist an anonymous identifier for tracking personalization and analytics\n * events when no explicit profile is known.\n *\n * @see {@link ANONYMOUS_ID_COOKIE} in `@contentful/optimization-core` for the\n * authoritative definition and documentation.\n *\n * @example\n * ```ts\n * import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-node'\n * const id = request.cookies[ANONYMOUS_ID_COOKIE]\n * ```\n */\nexport { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core'\n","import { type App, type CoreStatelessConfig, CoreStateless } from '@contentful/optimization-core'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './global-constants'\n\n/**\n * Configuration for the Node-specific Optimization SDK.\n *\n * @public\n * @remarks\n * This configuration extends {@link CoreConfig} but allows partial overrides\n * of the event-builder configuration. SDKs commonly inject their own library\n * metadata or channel definitions.\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * This differs from {@link CoreConfig.eventBuilder}, which expects a\n * full configuration object.\n */\n eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>\n}\n\n/**\n * Merge user-supplied configuration with defaults for the Node SDK.\n *\n * @param config - The input configuration supplied by the caller.\n * @returns A fully composed {@link CoreConfig} object suitable for\n * constructing the core runtime.\n *\n * @internal\n * @remarks\n * Ensures that the Node SDK always identifies itself via a `server` channel\n * and a `library` metadata block unless explicitly overridden.\n */\nfunction mergeConfig(config: OptimizationNodeConfig): CoreStatelessConfig {\n const { app, ...restConfig } = config\n\n const defaultConfig: Partial<CoreStatelessConfig> = {\n eventBuilder: {\n app,\n channel: 'server',\n library: { name: OPTIMIZATION_NODE_SDK_NAME, version: OPTIMIZATION_NODE_SDK_VERSION },\n },\n }\n return merge(defaultConfig, restConfig)\n}\n\n/**\n * Node-specific Optimization SDK built on {@link CoreStateless}.\n *\n * @public\n * @remarks\n * This class adapts the stateless Optimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No analytics or personalization behavior is modified—\n * only configuration defaults differ.\n *\n * @example\n * ```ts\n * import Optimization from '@contentful/optimization-node'\n *\n * const sdk = new Optimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * await sdk.track({ event: 'server_event', properties: { id: 1 } })\n * ```\n */\nclass Optimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n */\n constructor(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\n }\n}\n\nexport default Optimization\n","import Optimization from './Optimization'\n\nexport * from '@contentful/optimization-core'\n\nexport * from './global-constants'\nexport * from './Optimization'\n\nexport default Optimization\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__","mergeConfig","config","app","restConfig","defaultConfig","merge","Optimization","CoreStateless","mergedConfig"],"mappings":";;AAKO,MAAMA,gCACoCC;AAC1C,MAAMC,6BAEPC;ACoCN,SAASC,YAAYC,MAA8B;IACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;IAE/B,MAAMG,gBAA8C;QAClD,cAAc;YACZF;YACA,SAAS;YACT,SAAS;gBAAE,MAAMJ;gBAA4B,SAASF;YAA8B;QACtF;IACF;IACA,OAAOS,MAAMD,eAAeD;AAC9B;AAyBA,MAAMG,qBAAqBC,yDAAAA,aAAaA;IAOtC,YAAYN,MAA8B,CAAE;QAC1C,MAAMO,eAAoCR,YAAYC;QAEtD,KAAK,CAACO;IACR;AACF;AAEA,yBAAeF;ACxFf,YAAeA"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/ContentfulOptimization.ts","../src/index.ts"],"sourcesContent":["import {\n CoreStateless,\n type CoreStatelessConfig,\n type EventType,\n} from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\nconst DEFAULT_NODE_ALLOWED_EVENT_TYPES: EventType[] = ['identify', 'page']\n\n/**\n * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.\n *\n * @remarks\n * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`\n * is intentionally omitted from singleton SDK configuration.\n *\n * @public\n */\nexport type PublicNodeEventBuilderConfig = Partial<\n Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>\n>\n\n/**\n * Configuration for the Node-specific ContentfulOptimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * Request-scoped consent should be bound with `forRequest()`, not configured\n * on the SDK singleton.\n *\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: PublicNodeEventBuilderConfig\n}\n\n/**\n * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless ContentfulOptimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No core runtime behavior is modified; only configuration\n * defaults differ.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const sdk = new ContentfulOptimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * const requestOptimization = sdk.forRequest({\n * consent: true,\n * locale: 'fr-CA',\n * profile: { id: 'profile-id' },\n * })\n *\n * const { accepted, data } = await requestOptimization.page()\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass ContentfulOptimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig) {\n const { library, ...eventBuilderConfig } = eventBuilder ?? {}\n\n super({\n ...config,\n allowedEventTypes: allowedEventTypes ?? DEFAULT_NODE_ALLOWED_EVENT_TYPES,\n eventBuilder: {\n app,\n channel: 'server',\n ...eventBuilderConfig,\n library: {\n name: OPTIMIZATION_NODE_SDK_NAME,\n version: OPTIMIZATION_NODE_SDK_VERSION,\n ...library,\n },\n getConsent: () => false,\n },\n })\n }\n}\n\nexport default ContentfulOptimization\n","/**\n * Contentful ContentfulOptimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link ContentfulOptimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport ContentfulOptimization from './ContentfulOptimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './ContentfulOptimization'\n\nexport default ContentfulOptimization\n"],"names":["DEFAULT_NODE_ALLOWED_EVENT_TYPES","ContentfulOptimization","CoreStateless","app","allowedEventTypes","eventBuilder","config","library","eventBuilderConfig","OPTIMIZATION_NODE_SDK_NAME","OPTIMIZATION_NODE_SDK_VERSION"],"mappings":";;AAQA,MAAMA,mCAAgD;IAAC;IAAY;CAAO;AAkF1E,MAAMC,+BAA+BC,yDAAAA,aAAaA;IAchD,YAAY,EAAEC,GAAG,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGC,QAAgC,CAAE;QACvF,MAAM,EAAEC,OAAO,EAAE,GAAGC,oBAAoB,GAAGH,gBAAgB,CAAC;QAE5D,KAAK,CAAC;YACJ,GAAGC,MAAM;YACT,mBAAmBF,qBAAqBJ;YACxC,cAAc;gBACZG;gBACA,SAAS;gBACT,GAAGK,kBAAkB;gBACrB,SAAS;oBACP,MAAMC;oBACN,SAASC;oBACT,GAAGH,OAAO;gBACZ;gBACA,YAAY,IAAM;YACpB;QACF;IACF;AACF;AAEA,mCAAeN;AC3Gf,YAAeA"}