@contentful/optimization-node 0.1.0-alpha → 0.1.0-alpha11
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/README.md +168 -78
- package/dist/260.mjs +6 -0
- package/dist/260.mjs.map +1 -0
- package/dist/987.mjs +2 -0
- package/dist/api-client.cjs +60 -0
- package/dist/api-client.cjs.map +1 -0
- package/dist/api-client.d.cts +4 -0
- package/dist/api-client.d.mts +4 -0
- package/dist/api-client.d.ts +4 -0
- package/dist/api-client.mjs +2 -0
- package/dist/api-schemas.cjs +60 -0
- package/dist/api-schemas.cjs.map +1 -0
- package/dist/api-schemas.d.cts +4 -0
- package/dist/api-schemas.d.mts +4 -0
- package/dist/api-schemas.d.ts +4 -0
- package/dist/api-schemas.mjs +2 -0
- package/dist/constants.cjs +49 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +26 -0
- package/dist/constants.d.mts +26 -0
- package/dist/constants.d.ts +26 -0
- package/dist/constants.mjs +1 -0
- package/dist/core-sdk.cjs +60 -0
- package/dist/core-sdk.cjs.map +1 -0
- package/dist/core-sdk.d.cts +4 -0
- package/dist/core-sdk.d.mts +4 -0
- package/dist/core-sdk.d.ts +4 -0
- package/dist/core-sdk.mjs +2 -0
- package/dist/index.cjs +36 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -0
- package/dist/index.d.mts +113 -0
- package/dist/index.d.ts +62 -24
- package/dist/index.mjs +7 -9
- package/dist/index.mjs.map +1 -1
- package/dist/logger.cjs +67 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +8 -0
- package/dist/logger.d.mts +8 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.mjs +4 -0
- package/package.json +76 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../src/constants.ts"],"sourcesContent":["__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};","// 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"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__"],"mappings":";;;IAAAA,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;;;;;;;;;;;ACMO,MAAMI,gCACoCC;AAS1C,MAAMC,6BAEPC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core/constants';
|
|
2
|
+
import { ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants';
|
|
3
|
+
|
|
4
|
+
export { ANONYMOUS_ID_COOKIE }
|
|
5
|
+
|
|
6
|
+
export { ANONYMOUS_ID_KEY }
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
25
|
+
|
|
26
|
+
export { }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core/constants';
|
|
2
|
+
import { ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants';
|
|
3
|
+
|
|
4
|
+
export { ANONYMOUS_ID_COOKIE }
|
|
5
|
+
|
|
6
|
+
export { ANONYMOUS_ID_KEY }
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
25
|
+
|
|
26
|
+
export { }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ANONYMOUS_ID_COOKIE } from '@contentful/optimization-core/constants';
|
|
2
|
+
import { ANONYMOUS_ID_KEY } from '@contentful/optimization-core/constants';
|
|
3
|
+
|
|
4
|
+
export { ANONYMOUS_ID_COOKIE }
|
|
5
|
+
|
|
6
|
+
export { ANONYMOUS_ID_KEY }
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
10
|
+
*
|
|
11
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
25
|
+
|
|
26
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ANONYMOUS_ID_COOKIE, ANONYMOUS_ID_KEY, OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"@contentful/optimization-core" (module) {
|
|
4
|
+
module.exports = require("@contentful/optimization-core");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
20
|
+
__webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
});
|
|
23
|
+
return getter;
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
28
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: definition[key]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
+
})();
|
|
37
|
+
(()=>{
|
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
|
39
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
40
|
+
value: 'Module'
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __webpack_exports__ = {};
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
var _contentful_optimization_core__rspack_import_0 = __webpack_require__("@contentful/optimization-core");
|
|
51
|
+
var __rspack_reexport = {};
|
|
52
|
+
for(const __rspack_import_key in _contentful_optimization_core__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_contentful_optimization_core__rspack_import_0[__rspack_import_key];
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
54
|
+
})();
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=core-sdk.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-sdk.cjs","sources":["webpack/runtime/compat_get_default_export","webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object"],"sourcesContent":["// 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":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol"],"mappings":";;;;;;;;;;;;;;;;;IACAA,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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,44 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"./src/
|
|
3
|
+
"./src/constants.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
4
|
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
|
|
5
|
+
OPTIMIZATION_NODE_SDK_NAME: ()=>OPTIMIZATION_NODE_SDK_NAME,
|
|
6
|
+
OPTIMIZATION_NODE_SDK_VERSION: ()=>OPTIMIZATION_NODE_SDK_VERSION
|
|
6
7
|
});
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
function mergeConfig(config) {
|
|
11
|
-
const { app, ...restConfig } = config;
|
|
12
|
-
const defaultConfig = {
|
|
13
|
-
eventBuilder: {
|
|
14
|
-
app,
|
|
15
|
-
channel: 'server',
|
|
16
|
-
library: {
|
|
17
|
-
name: 'Optimization Node API',
|
|
18
|
-
version: global_constants.R
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
return (0, external_es_toolkit_namespaceObject.merge)(defaultConfig, restConfig);
|
|
23
|
-
}
|
|
24
|
-
class Optimization extends optimization_core_.CoreStateless {
|
|
25
|
-
constructor(config){
|
|
26
|
-
const mergedConfig = mergeConfig(config);
|
|
27
|
-
super(mergedConfig);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const src_Optimization = Optimization;
|
|
31
|
-
},
|
|
32
|
-
"./src/global-constants.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
33
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
-
R: ()=>OPTIMIZATION_NODE_SDK_VERSION,
|
|
35
|
-
T: ()=>_contentful_optimization_core__rspack_import_0.ANONYMOUS_ID_COOKIE
|
|
36
|
-
});
|
|
37
|
-
var _contentful_optimization_core__rspack_import_0 = __webpack_require__("@contentful/optimization-core");
|
|
38
|
-
const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha";
|
|
39
|
-
},
|
|
40
|
-
"@contentful/optimization-core" (module) {
|
|
41
|
-
module.exports = require("@contentful/optimization-core");
|
|
8
|
+
require("@contentful/optimization-core/constants");
|
|
9
|
+
const OPTIMIZATION_NODE_SDK_VERSION = "0.1.0-alpha11";
|
|
10
|
+
const OPTIMIZATION_NODE_SDK_NAME = "@contentful/optimization-node";
|
|
42
11
|
}
|
|
43
12
|
};
|
|
44
13
|
var __webpack_module_cache__ = {};
|
|
@@ -51,15 +20,6 @@ function __webpack_require__(moduleId) {
|
|
|
51
20
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
52
21
|
return module.exports;
|
|
53
22
|
}
|
|
54
|
-
(()=>{
|
|
55
|
-
__webpack_require__.n = (module)=>{
|
|
56
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
57
|
-
__webpack_require__.d(getter, {
|
|
58
|
-
a: getter
|
|
59
|
-
});
|
|
60
|
-
return getter;
|
|
61
|
-
};
|
|
62
|
-
})();
|
|
63
23
|
(()=>{
|
|
64
24
|
__webpack_require__.d = (exports1, definition)=>{
|
|
65
25
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -85,23 +45,41 @@ var __webpack_exports__ = {};
|
|
|
85
45
|
(()=>{
|
|
86
46
|
__webpack_require__.r(__webpack_exports__);
|
|
87
47
|
__webpack_require__.d(__webpack_exports__, {
|
|
88
|
-
|
|
89
|
-
OPTIMIZATION_NODE_SDK_VERSION: ()=>
|
|
90
|
-
default: ()=>
|
|
48
|
+
OPTIMIZATION_NODE_SDK_NAME: ()=>constants.OPTIMIZATION_NODE_SDK_NAME,
|
|
49
|
+
OPTIMIZATION_NODE_SDK_VERSION: ()=>constants.OPTIMIZATION_NODE_SDK_VERSION,
|
|
50
|
+
default: ()=>src
|
|
91
51
|
});
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
52
|
+
const optimization_core_namespaceObject = require("@contentful/optimization-core");
|
|
53
|
+
const external_es_toolkit_namespaceObject = require("es-toolkit");
|
|
54
|
+
var constants = __webpack_require__("./src/constants.ts");
|
|
55
|
+
function mergeConfig(config) {
|
|
56
|
+
const { app, ...restConfig } = config;
|
|
57
|
+
const defaultConfig = {
|
|
58
|
+
eventBuilder: {
|
|
59
|
+
app,
|
|
60
|
+
channel: 'server',
|
|
61
|
+
library: {
|
|
62
|
+
name: constants.OPTIMIZATION_NODE_SDK_NAME,
|
|
63
|
+
version: constants.OPTIMIZATION_NODE_SDK_VERSION
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return (0, external_es_toolkit_namespaceObject.merge)(defaultConfig, restConfig);
|
|
68
|
+
}
|
|
69
|
+
class ContentfulOptimization extends optimization_core_namespaceObject.CoreStateless {
|
|
70
|
+
constructor(config){
|
|
71
|
+
const mergedConfig = mergeConfig(config);
|
|
72
|
+
super(mergedConfig);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const src_ContentfulOptimization = ContentfulOptimization;
|
|
76
|
+
const src = src_ContentfulOptimization;
|
|
99
77
|
})();
|
|
100
|
-
exports.
|
|
78
|
+
exports.OPTIMIZATION_NODE_SDK_NAME = __webpack_exports__.OPTIMIZATION_NODE_SDK_NAME;
|
|
101
79
|
exports.OPTIMIZATION_NODE_SDK_VERSION = __webpack_exports__.OPTIMIZATION_NODE_SDK_VERSION;
|
|
102
80
|
exports["default"] = __webpack_exports__["default"];
|
|
103
81
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
104
|
-
"
|
|
82
|
+
"OPTIMIZATION_NODE_SDK_NAME",
|
|
105
83
|
"OPTIMIZATION_NODE_SDK_VERSION",
|
|
106
84
|
"default"
|
|
107
85
|
].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/
|
|
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 { type CoreStatelessConfig, CoreStateless } from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { merge } from 'es-toolkit'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\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 * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a 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 CoreStatelessConfig} object suitable for\n * constructing the core runtime.\n *\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 *\n * @internal\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 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 request = sdk.forRequest({ locale: 'en-US' })\n *\n * await request.track({ event: 'server_event', properties: { id: 1 } })\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(config: OptimizationNodeConfig) {\n const mergedConfig: CoreStatelessConfig = mergeConfig(config)\n\n super(mergedConfig)\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","mergeConfig","config","app","restConfig","defaultConfig","merge","ContentfulOptimization","CoreStateless","mergedConfig"],"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;;;;;;;;;;;;;IC4CA,SAASI,YAAYC,MAA8B;QACjD,MAAM,EAAEC,GAAG,EAAE,GAAGC,YAAY,GAAGF;QAE/B,MAAMG,gBAA8C;YAClD,cAAc;gBACZF;gBACA,SAAS;gBACT,SAAS;oBAAE,MAAMX,UAAAA,0BAA0BA;oBAAE,SAASF,UAAAA,6BAA6BA;gBAAC;YACtF;QACF;QACA,OAAOgB,AAAAA,IAAAA,oCAAAA,KAAAA,AAAAA,EAAMD,eAAeD;IAC9B;IA8BA,MAAMG,+BAA+BC,kCAAAA,aAAaA;QAchD,YAAYN,MAA8B,CAAE;YAC1C,MAAMO,eAAoCR,YAAYC;YAEtD,KAAK,CAACO;QACR;IACF;IAEA,mCAAeF;IC9Ff,YAAeA"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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';
|
|
15
|
+
import { CoreStateless } from '@contentful/optimization-core';
|
|
16
|
+
import { CoreStatelessConfig } from '@contentful/optimization-core';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This class adapts the stateless ContentfulOptimization Core for Node runtimes by
|
|
23
|
+
* applying environment-appropriate defaults (e.g., server channel, Node SDK
|
|
24
|
+
* library metadata). No core runtime behavior is modified; only configuration
|
|
25
|
+
* defaults differ.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
30
|
+
*
|
|
31
|
+
* const sdk = new ContentfulOptimization({
|
|
32
|
+
* clientId: 'abc-123',
|
|
33
|
+
* environment: 'main',
|
|
34
|
+
* logLevel: 'info',
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const request = sdk.forRequest({ locale: 'en-US' })
|
|
38
|
+
*
|
|
39
|
+
* await request.track({ event: 'server_event', properties: { id: 1 } })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see {@link CoreStateless}
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
declare class ContentfulOptimization extends CoreStateless {
|
|
47
|
+
/**
|
|
48
|
+
* Create an instance of the Node SDK with merged defaults.
|
|
49
|
+
*
|
|
50
|
+
* @param config - Partial Node-specific configuration. Any eventBuilder
|
|
51
|
+
* fields provided are merged with Node's defaults.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
56
|
+
*
|
|
57
|
+
* const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
constructor(config: OptimizationNodeConfig);
|
|
61
|
+
}
|
|
62
|
+
export default ContentfulOptimization;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
75
|
+
*
|
|
76
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Configuration for the Node-specific ContentfulOptimization SDK.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* This configuration extends {@link CoreStatelessConfig} but allows partial
|
|
87
|
+
* overrides of the event-builder configuration. SDKs commonly inject their own
|
|
88
|
+
* library metadata or channel definitions.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link CoreStatelessConfig}
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
|
|
95
|
+
/**
|
|
96
|
+
* The application definition used to attribute events to a specific consumer app.
|
|
97
|
+
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* When not provided, events will not contain app metadata in their context.
|
|
100
|
+
*/
|
|
101
|
+
app?: App;
|
|
102
|
+
/**
|
|
103
|
+
* Partial overrides for the event builder configuration.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* Any provided fields are merged with the default Node SDK metadata.
|
|
107
|
+
* This differs from {@link CoreStatelessConfig} eventBuilder, which expects
|
|
108
|
+
* a full configuration object.
|
|
109
|
+
*/
|
|
110
|
+
eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { }
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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';
|
|
15
|
+
import { CoreStateless } from '@contentful/optimization-core';
|
|
16
|
+
import { CoreStatelessConfig } from '@contentful/optimization-core';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* This class adapts the stateless ContentfulOptimization Core for Node runtimes by
|
|
23
|
+
* applying environment-appropriate defaults (e.g., server channel, Node SDK
|
|
24
|
+
* library metadata). No core runtime behavior is modified; only configuration
|
|
25
|
+
* defaults differ.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
30
|
+
*
|
|
31
|
+
* const sdk = new ContentfulOptimization({
|
|
32
|
+
* clientId: 'abc-123',
|
|
33
|
+
* environment: 'main',
|
|
34
|
+
* logLevel: 'info',
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const request = sdk.forRequest({ locale: 'en-US' })
|
|
38
|
+
*
|
|
39
|
+
* await request.track({ event: 'server_event', properties: { id: 1 } })
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @see {@link CoreStateless}
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
*/
|
|
46
|
+
declare class ContentfulOptimization extends CoreStateless {
|
|
47
|
+
/**
|
|
48
|
+
* Create an instance of the Node SDK with merged defaults.
|
|
49
|
+
*
|
|
50
|
+
* @param config - Partial Node-specific configuration. Any eventBuilder
|
|
51
|
+
* fields provided are merged with Node's defaults.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
56
|
+
*
|
|
57
|
+
* const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
constructor(config: OptimizationNodeConfig);
|
|
61
|
+
}
|
|
62
|
+
export default ContentfulOptimization;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
66
|
+
*
|
|
67
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
75
|
+
*
|
|
76
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Configuration for the Node-specific ContentfulOptimization SDK.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* This configuration extends {@link CoreStatelessConfig} but allows partial
|
|
87
|
+
* overrides of the event-builder configuration. SDKs commonly inject their own
|
|
88
|
+
* library metadata or channel definitions.
|
|
89
|
+
*
|
|
90
|
+
* @see {@link CoreStatelessConfig}
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
|
|
95
|
+
/**
|
|
96
|
+
* The application definition used to attribute events to a specific consumer app.
|
|
97
|
+
*
|
|
98
|
+
* @remarks
|
|
99
|
+
* When not provided, events will not contain app metadata in their context.
|
|
100
|
+
*/
|
|
101
|
+
app?: App;
|
|
102
|
+
/**
|
|
103
|
+
* Partial overrides for the event builder configuration.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* Any provided fields are merged with the default Node SDK metadata.
|
|
107
|
+
* This differs from {@link CoreStatelessConfig} eventBuilder, which expects
|
|
108
|
+
* a full configuration object.
|
|
109
|
+
*/
|
|
110
|
+
eventBuilder?: Partial<Omit<CoreStatelessConfig['eventBuilder'], 'app'>>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { }
|