@contentful/optimization-node 0.1.0-alpha6 → 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 +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -0
- package/dist/index.d.mts +77 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -7
package/dist/index.cjs
CHANGED
|
@@ -14,8 +14,8 @@ var __webpack_modules__ = {
|
|
|
14
14
|
app,
|
|
15
15
|
channel: 'server',
|
|
16
16
|
library: {
|
|
17
|
-
name:
|
|
18
|
-
version: global_constants.
|
|
17
|
+
name: global_constants.EH,
|
|
18
|
+
version: global_constants.RS
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -31,11 +31,13 @@ var __webpack_modules__ = {
|
|
|
31
31
|
},
|
|
32
32
|
"./src/global-constants.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
33
33
|
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
EH: ()=>OPTIMIZATION_NODE_SDK_NAME,
|
|
35
|
+
RS: ()=>OPTIMIZATION_NODE_SDK_VERSION,
|
|
36
|
+
TF: ()=>_contentful_optimization_core__rspack_import_0.ANONYMOUS_ID_COOKIE
|
|
36
37
|
});
|
|
37
38
|
var _contentful_optimization_core__rspack_import_0 = __webpack_require__("@contentful/optimization-core");
|
|
38
|
-
const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-
|
|
39
|
+
const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha8";
|
|
40
|
+
const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
|
|
39
41
|
},
|
|
40
42
|
"@contentful/optimization-core" (module) {
|
|
41
43
|
module.exports = require("@contentful/optimization-core");
|
|
@@ -85,8 +87,9 @@ var __webpack_exports__ = {};
|
|
|
85
87
|
(()=>{
|
|
86
88
|
__webpack_require__.r(__webpack_exports__);
|
|
87
89
|
__webpack_require__.d(__webpack_exports__, {
|
|
88
|
-
ANONYMOUS_ID_COOKIE: ()=>_global_constants__rspack_import_2.
|
|
89
|
-
|
|
90
|
+
ANONYMOUS_ID_COOKIE: ()=>_global_constants__rspack_import_2.TF,
|
|
91
|
+
OPTIMIZATION_NODE_SDK_NAME: ()=>_global_constants__rspack_import_2.EH,
|
|
92
|
+
OPTIMIZATION_NODE_SDK_VERSION: ()=>_global_constants__rspack_import_2.RS,
|
|
90
93
|
default: ()=>__rspack_default_export
|
|
91
94
|
});
|
|
92
95
|
var _Optimization__rspack_import_0 = __webpack_require__("./src/Optimization.ts");
|
|
@@ -98,10 +101,12 @@ var __webpack_exports__ = {};
|
|
|
98
101
|
const __rspack_default_export = _Optimization__rspack_import_0.A;
|
|
99
102
|
})();
|
|
100
103
|
exports.ANONYMOUS_ID_COOKIE = __webpack_exports__.ANONYMOUS_ID_COOKIE;
|
|
104
|
+
exports.OPTIMIZATION_NODE_SDK_NAME = __webpack_exports__.OPTIMIZATION_NODE_SDK_NAME;
|
|
101
105
|
exports.OPTIMIZATION_NODE_SDK_VERSION = __webpack_exports__.OPTIMIZATION_NODE_SDK_VERSION;
|
|
102
106
|
exports["default"] = __webpack_exports__["default"];
|
|
103
107
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
104
108
|
"ANONYMOUS_ID_COOKIE",
|
|
109
|
+
"OPTIMIZATION_NODE_SDK_NAME",
|
|
105
110
|
"OPTIMIZATION_NODE_SDK_VERSION",
|
|
106
111
|
"default"
|
|
107
112
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
package/dist/index.cjs.map
CHANGED
|
@@ -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_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:
|
|
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"}
|
package/dist/index.d.cts
ADDED
|
@@ -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.mts
ADDED
|
@@ -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
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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-
|
|
3
|
+
const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha8";
|
|
4
|
+
const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
|
|
4
5
|
function mergeConfig(config) {
|
|
5
6
|
const { app, ...restConfig } = config;
|
|
6
7
|
const defaultConfig = {
|
|
@@ -8,7 +9,7 @@ function mergeConfig(config) {
|
|
|
8
9
|
app,
|
|
9
10
|
channel: 'server',
|
|
10
11
|
library: {
|
|
11
|
-
name:
|
|
12
|
+
name: OPTIMIZATION_NODE_SDK_NAME,
|
|
12
13
|
version: OPTIMIZATION_NODE_SDK_VERSION
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -26,6 +27,6 @@ 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
29
|
export default src;
|
|
29
|
-
export { ANONYMOUS_ID_COOKIE, OPTIMIZATION_NODE_SDK_VERSION };
|
|
30
|
+
export { ANONYMOUS_ID_COOKIE, OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION };
|
|
30
31
|
|
|
31
32
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -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\nexport const OPTIMIZATION_NODE_SDK_VERSION =\n typeof __OPTIMIZATION_VERSION__ === 'string' ? __OPTIMIZATION_VERSION__ : '0.0.0'\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_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:
|
|
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-
|
|
3
|
+
"version": "0.1.0-alpha8",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
|
-
"types": "./dist/index.d.
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
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-
|
|
27
|
+
"@contentful/optimization-core": "0.1.0-alpha8"
|
|
23
28
|
}
|
|
24
29
|
}
|