@contentful/optimization-node 0.1.0-alpha7 → 0.1.0-alpha8

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/index.cjs CHANGED
@@ -36,7 +36,7 @@ var __webpack_modules__ = {
36
36
  TF: ()=>_contentful_optimization_core__rspack_import_0.ANONYMOUS_ID_COOKIE
37
37
  });
38
38
  var _contentful_optimization_core__rspack_import_0 = __webpack_require__("@contentful/optimization-core");
39
- const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha7";
39
+ const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha8";
40
40
  const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
41
41
  },
42
42
  "@contentful/optimization-core" (module) {
@@ -90,27 +90,25 @@ var __webpack_exports__ = {};
90
90
  ANONYMOUS_ID_COOKIE: ()=>_global_constants__rspack_import_2.TF,
91
91
  OPTIMIZATION_NODE_SDK_NAME: ()=>_global_constants__rspack_import_2.EH,
92
92
  OPTIMIZATION_NODE_SDK_VERSION: ()=>_global_constants__rspack_import_2.RS,
93
- Optimization: ()=>_Optimization__rspack_import_0.A
93
+ default: ()=>__rspack_default_export
94
94
  });
95
95
  var _Optimization__rspack_import_0 = __webpack_require__("./src/Optimization.ts");
96
96
  var _contentful_optimization_core__rspack_import_1 = __webpack_require__("@contentful/optimization-core");
97
97
  var __rspack_reexport = {};
98
- for(const __rspack_import_key in _contentful_optimization_core__rspack_import_1)if ([
99
- "Optimization",
100
- "default"
101
- ].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_core__rspack_import_1[__rspack_import_key];
98
+ for(const __rspack_import_key in _contentful_optimization_core__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_core__rspack_import_1[__rspack_import_key];
102
99
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
103
100
  var _global_constants__rspack_import_2 = __webpack_require__("./src/global-constants.ts");
101
+ const __rspack_default_export = _Optimization__rspack_import_0.A;
104
102
  })();
105
103
  exports.ANONYMOUS_ID_COOKIE = __webpack_exports__.ANONYMOUS_ID_COOKIE;
106
104
  exports.OPTIMIZATION_NODE_SDK_NAME = __webpack_exports__.OPTIMIZATION_NODE_SDK_NAME;
107
105
  exports.OPTIMIZATION_NODE_SDK_VERSION = __webpack_exports__.OPTIMIZATION_NODE_SDK_VERSION;
108
- exports.Optimization = __webpack_exports__.Optimization;
106
+ exports["default"] = __webpack_exports__["default"];
109
107
  for(var __rspack_i in __webpack_exports__)if (-1 === [
110
108
  "ANONYMOUS_ID_COOKIE",
111
109
  "OPTIMIZATION_NODE_SDK_NAME",
112
110
  "OPTIMIZATION_NODE_SDK_VERSION",
113
- "Optimization"
111
+ "default"
114
112
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
115
113
  Object.defineProperty(exports, '__esModule', {
116
114
  value: true
@@ -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"],"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};"],"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"}
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"}
@@ -0,0 +1,77 @@
1
+ import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core';
2
+ import { App } from '@contentful/optimization-core';
3
+ import { CoreStateless } from '@contentful/optimization-core';
4
+ import { CoreStatelessConfig } from '@contentful/optimization-core';
5
+
6
+ export { ANONYMOUS_ID_COOKIE }
7
+
8
+ /**
9
+ * Node-specific Optimization SDK built on {@link CoreStateless}.
10
+ *
11
+ * @public
12
+ * @remarks
13
+ * This class adapts the stateless Optimization Core for Node runtimes by
14
+ * 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.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import Optimization from '@contentful/optimization-node'
21
+ *
22
+ * const sdk = new Optimization({
23
+ * clientId: 'abc-123',
24
+ * environment: 'main',
25
+ * logLevel: 'info',
26
+ * })
27
+ *
28
+ * await sdk.track({ event: 'server_event', properties: { id: 1 } })
29
+ * ```
30
+ */
31
+ declare class Optimization extends CoreStateless {
32
+ /**
33
+ * Create an instance of the Node SDK with merged defaults.
34
+ *
35
+ * @param config - Partial Node-specific configuration. Any eventBuilder
36
+ * fields provided are merged with Node's defaults.
37
+ */
38
+ constructor(config: OptimizationNodeConfig);
39
+ }
40
+ export default Optimization;
41
+
42
+ export declare const OPTIMIZATION_NODE_SDK_NAME: string;
43
+
44
+ export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
45
+
46
+ /**
47
+ * Configuration for the Node-specific Optimization SDK.
48
+ *
49
+ * @public
50
+ * @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.
54
+ */
55
+ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
56
+ /**
57
+ * The application definition used to attribute events to a specific consumer app.
58
+ *
59
+ * @remarks
60
+ * When not provided, events will not contain app metadata in their context.
61
+ */
62
+ app?: App;
63
+ /**
64
+ * Partial overrides for the event builder configuration.
65
+ *
66
+ * @remarks
67
+ * 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.
70
+ */
71
+ eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
72
+ }
73
+
74
+
75
+ export * from "@contentful/optimization-core";
76
+
77
+ export { }
@@ -0,0 +1,77 @@
1
+ import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core';
2
+ import { App } from '@contentful/optimization-core';
3
+ import { CoreStateless } from '@contentful/optimization-core';
4
+ import { CoreStatelessConfig } from '@contentful/optimization-core';
5
+
6
+ export { ANONYMOUS_ID_COOKIE }
7
+
8
+ /**
9
+ * Node-specific Optimization SDK built on {@link CoreStateless}.
10
+ *
11
+ * @public
12
+ * @remarks
13
+ * This class adapts the stateless Optimization Core for Node runtimes by
14
+ * 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.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import Optimization from '@contentful/optimization-node'
21
+ *
22
+ * const sdk = new Optimization({
23
+ * clientId: 'abc-123',
24
+ * environment: 'main',
25
+ * logLevel: 'info',
26
+ * })
27
+ *
28
+ * await sdk.track({ event: 'server_event', properties: { id: 1 } })
29
+ * ```
30
+ */
31
+ declare class Optimization extends CoreStateless {
32
+ /**
33
+ * Create an instance of the Node SDK with merged defaults.
34
+ *
35
+ * @param config - Partial Node-specific configuration. Any eventBuilder
36
+ * fields provided are merged with Node's defaults.
37
+ */
38
+ constructor(config: OptimizationNodeConfig);
39
+ }
40
+ export default Optimization;
41
+
42
+ export declare const OPTIMIZATION_NODE_SDK_NAME: string;
43
+
44
+ export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
45
+
46
+ /**
47
+ * Configuration for the Node-specific Optimization SDK.
48
+ *
49
+ * @public
50
+ * @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.
54
+ */
55
+ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
56
+ /**
57
+ * The application definition used to attribute events to a specific consumer app.
58
+ *
59
+ * @remarks
60
+ * When not provided, events will not contain app metadata in their context.
61
+ */
62
+ app?: App;
63
+ /**
64
+ * Partial overrides for the event builder configuration.
65
+ *
66
+ * @remarks
67
+ * 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.
70
+ */
71
+ eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
72
+ }
73
+
74
+
75
+ export * from "@contentful/optimization-core";
76
+
77
+ export { }
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export { ANONYMOUS_ID_COOKIE }
28
28
  * await sdk.track({ event: 'server_event', properties: { id: 1 } })
29
29
  * ```
30
30
  */
31
- export declare class Optimization extends CoreStateless {
31
+ declare class Optimization extends CoreStateless {
32
32
  /**
33
33
  * Create an instance of the Node SDK with merged defaults.
34
34
  *
@@ -37,6 +37,7 @@ export declare class Optimization extends CoreStateless {
37
37
  */
38
38
  constructor(config: OptimizationNodeConfig);
39
39
  }
40
+ export default Optimization;
40
41
 
41
42
  export declare const OPTIMIZATION_NODE_SDK_NAME: string;
42
43
 
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as __rspack_external__contentful_optimization_core_7d4758c6 from "@contentful/optimization-core";
2
2
  import { merge } from "es-toolkit";
3
- const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha7";
3
+ const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha8";
4
4
  const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
5
5
  function mergeConfig(config) {
6
6
  const { app, ...restConfig } = config;
@@ -23,8 +23,10 @@ class Optimization extends __rspack_external__contentful_optimization_core_7d475
23
23
  }
24
24
  }
25
25
  const src_Optimization = Optimization;
26
+ const src = src_Optimization;
26
27
  var ANONYMOUS_ID_COOKIE = __rspack_external__contentful_optimization_core_7d4758c6.ANONYMOUS_ID_COOKIE;
27
28
  export * from "@contentful/optimization-core";
28
- export { ANONYMOUS_ID_COOKIE, OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION, src_Optimization as Optimization };
29
+ export default src;
30
+ export { ANONYMOUS_ID_COOKIE, OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION };
29
31
 
30
32
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/global-constants.ts","../src/Optimization.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"],"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"}
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"}
package/package.json CHANGED
@@ -1,16 +1,21 @@
1
1
  {
2
2
  "name": "@contentful/optimization-node",
3
- "version": "0.1.0-alpha7",
3
+ "version": "0.1.0-alpha8",
4
4
  "license": "MIT",
5
- "type": "commonjs",
5
+ "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
8
+ "types": "./dist/index.d.mts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
12
- "require": "./dist/index.cjs",
13
- "import": "./dist/index.mjs"
11
+ "import": {
12
+ "types": "./dist/index.d.mts",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
14
19
  },
15
20
  "./package.json": "./package.json"
16
21
  },
@@ -19,6 +24,6 @@
19
24
  ],
20
25
  "dependencies": {
21
26
  "es-toolkit": "^1.39.10",
22
- "@contentful/optimization-core": "0.1.0-alpha7"
27
+ "@contentful/optimization-core": "0.1.0-alpha8"
23
28
  }
24
29
  }