@contentful/optimization-node 0.1.0-alpha8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -216
- package/THIRD_PARTY_NOTICES.txt +2096 -0
- 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 +73 -0
- package/dist/core-sdk.cjs.map +1 -0
- package/dist/core-sdk.d.cts +17 -0
- package/dist/core-sdk.d.mts +17 -0
- package/dist/core-sdk.d.ts +17 -0
- package/dist/core-sdk.mjs +3 -0
- package/dist/index.cjs +36 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -25
- package/dist/index.d.mts +79 -25
- package/dist/index.d.ts +79 -25
- package/dist/index.mjs +26 -26
- 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 +67 -4
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 {\n CoreStateless,\n type CoreStatelessConfig,\n type EventType,\n} from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\nconst DEFAULT_NODE_ALLOWED_EVENT_TYPES: EventType[] = ['identify', 'page']\n\n/**\n * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.\n *\n * @remarks\n * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`\n * is intentionally omitted from singleton SDK configuration.\n *\n * @public\n */\nexport type PublicNodeEventBuilderConfig = Partial<\n Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>\n>\n\n/**\n * Configuration for the Node-specific ContentfulOptimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * Request-scoped consent should be bound with `forRequest()`, not configured\n * on the SDK singleton.\n *\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: PublicNodeEventBuilderConfig\n}\n\n/**\n * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless ContentfulOptimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No core runtime behavior is modified; only configuration\n * defaults differ.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const sdk = new ContentfulOptimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * const requestOptimization = sdk.forRequest({\n * consent: true,\n * locale: 'fr-CA',\n * profile: { id: 'profile-id' },\n * })\n *\n * const { accepted, data } = await requestOptimization.page()\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass ContentfulOptimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig) {\n const { library, ...eventBuilderConfig } = eventBuilder ?? {}\n\n super({\n ...config,\n allowedEventTypes: allowedEventTypes ?? DEFAULT_NODE_ALLOWED_EVENT_TYPES,\n eventBuilder: {\n app,\n channel: 'server',\n ...eventBuilderConfig,\n library: {\n name: OPTIMIZATION_NODE_SDK_NAME,\n version: OPTIMIZATION_NODE_SDK_VERSION,\n ...library,\n },\n getConsent: () => false,\n },\n })\n }\n}\n\nexport default ContentfulOptimization\n","/**\n * Contentful ContentfulOptimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link ContentfulOptimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport ContentfulOptimization from './ContentfulOptimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './ContentfulOptimization'\n\nexport default ContentfulOptimization\n"],"names":["OPTIMIZATION_NODE_SDK_VERSION","__OPTIMIZATION_VERSION__","OPTIMIZATION_NODE_SDK_NAME","__OPTIMIZATION_PACKAGE_NAME__","__webpack_require__","definition","key","Object","obj","prop","Symbol","DEFAULT_NODE_ALLOWED_EVENT_TYPES","ContentfulOptimization","CoreStateless","app","allowedEventTypes","eventBuilder","config","library","eventBuilderConfig"],"mappings":";;;;;;;;QAYO,MAAMA,gCACoCC;QAS1C,MAAMC,6BAEPC;;;;;;;;;;;;;;ICxBNC,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;ICEA,MAAMI,mCAAgD;QAAC;QAAY;KAAO;IAkF1E,MAAMC,+BAA+BC,kCAAAA,aAAaA;QAchD,YAAY,EAAEC,GAAG,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGC,QAAgC,CAAE;YACvF,MAAM,EAAEC,OAAO,EAAE,GAAGC,oBAAoB,GAAGH,gBAAgB,CAAC;YAE5D,KAAK,CAAC;gBACJ,GAAGC,MAAM;gBACT,mBAAmBF,qBAAqBJ;gBACxC,cAAc;oBACZG;oBACA,SAAS;oBACT,GAAGK,kBAAkB;oBACrB,SAAS;wBACP,MAAMjB,UAAAA,0BAA0BA;wBAChC,SAASF,UAAAA,6BAA6BA;wBACtC,GAAGkB,OAAO;oBACZ;oBACA,YAAY,IAAM;gBACpB;YACF;QACF;IACF;IAEA,mCAAeN;IC3Gf,YAAeA"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,56 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Contentful ContentfulOptimization Node SDK.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Adds Node-specific defaults via the {@link ContentfulOptimization} class.
|
|
6
|
+
* Core and transitive API exports are available from dedicated entrypoints:
|
|
7
|
+
* `@contentful/optimization-node/core-sdk`,
|
|
8
|
+
* `@contentful/optimization-node/api-client`,
|
|
9
|
+
* and `@contentful/optimization-node/api-schemas`.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { App } from '@contentful/optimization-core/api-schemas';
|
|
3
15
|
import { CoreStateless } from '@contentful/optimization-core';
|
|
4
16
|
import { CoreStatelessConfig } from '@contentful/optimization-core';
|
|
5
17
|
|
|
6
|
-
export { ANONYMOUS_ID_COOKIE }
|
|
7
|
-
|
|
8
18
|
/**
|
|
9
|
-
* Node-specific
|
|
19
|
+
* Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
|
|
10
20
|
*
|
|
11
|
-
* @public
|
|
12
21
|
* @remarks
|
|
13
|
-
* This class adapts the stateless
|
|
22
|
+
* This class adapts the stateless ContentfulOptimization Core for Node runtimes by
|
|
14
23
|
* applying environment-appropriate defaults (e.g., server channel, Node SDK
|
|
15
|
-
* library metadata). No
|
|
16
|
-
*
|
|
24
|
+
* library metadata). No core runtime behavior is modified; only configuration
|
|
25
|
+
* defaults differ.
|
|
17
26
|
*
|
|
18
27
|
* @example
|
|
19
28
|
* ```ts
|
|
20
|
-
* import
|
|
29
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
21
30
|
*
|
|
22
|
-
* const sdk = new
|
|
31
|
+
* const sdk = new ContentfulOptimization({
|
|
23
32
|
* clientId: 'abc-123',
|
|
24
33
|
* environment: 'main',
|
|
25
34
|
* logLevel: 'info',
|
|
26
35
|
* })
|
|
27
36
|
*
|
|
28
|
-
*
|
|
37
|
+
* const requestOptimization = sdk.forRequest({
|
|
38
|
+
* consent: true,
|
|
39
|
+
* locale: 'fr-CA',
|
|
40
|
+
* profile: { id: 'profile-id' },
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* const { accepted, data } = await requestOptimization.page()
|
|
29
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* @see {@link CoreStateless}
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
30
49
|
*/
|
|
31
|
-
declare class
|
|
50
|
+
declare class ContentfulOptimization extends CoreStateless {
|
|
32
51
|
/**
|
|
33
52
|
* Create an instance of the Node SDK with merged defaults.
|
|
34
53
|
*
|
|
35
54
|
* @param config - Partial Node-specific configuration. Any eventBuilder
|
|
36
55
|
* fields provided are merged with Node's defaults.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
60
|
+
*
|
|
61
|
+
* const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
|
|
62
|
+
* ```
|
|
37
63
|
*/
|
|
38
|
-
constructor(config: OptimizationNodeConfig);
|
|
64
|
+
constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig);
|
|
39
65
|
}
|
|
40
|
-
export default
|
|
66
|
+
export default ContentfulOptimization;
|
|
41
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
70
|
+
*
|
|
71
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
42
75
|
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
43
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
79
|
+
*
|
|
80
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
44
84
|
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
45
85
|
|
|
46
86
|
/**
|
|
47
|
-
* Configuration for the Node-specific
|
|
87
|
+
* Configuration for the Node-specific ContentfulOptimization SDK.
|
|
48
88
|
*
|
|
49
|
-
* @public
|
|
50
89
|
* @remarks
|
|
51
|
-
* This configuration extends {@link
|
|
52
|
-
* of the event-builder configuration. SDKs commonly inject their own
|
|
53
|
-
* metadata or channel definitions.
|
|
90
|
+
* This configuration extends {@link CoreStatelessConfig} but allows partial
|
|
91
|
+
* overrides of the event-builder configuration. SDKs commonly inject their own
|
|
92
|
+
* library metadata or channel definitions.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link CoreStatelessConfig}
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
54
97
|
*/
|
|
55
98
|
export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
|
|
56
99
|
/**
|
|
@@ -65,13 +108,24 @@ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig
|
|
|
65
108
|
*
|
|
66
109
|
* @remarks
|
|
67
110
|
* Any provided fields are merged with the default Node SDK metadata.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
111
|
+
* Request-scoped consent should be bound with `forRequest()`, not configured
|
|
112
|
+
* on the SDK singleton.
|
|
113
|
+
*
|
|
114
|
+
* This differs from {@link CoreStatelessConfig} eventBuilder, which expects
|
|
115
|
+
* a full configuration object.
|
|
70
116
|
*/
|
|
71
|
-
eventBuilder?:
|
|
117
|
+
eventBuilder?: PublicNodeEventBuilderConfig;
|
|
72
118
|
}
|
|
73
119
|
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`
|
|
125
|
+
* is intentionally omitted from singleton SDK configuration.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare type PublicNodeEventBuilderConfig = Partial<Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>>;
|
|
76
130
|
|
|
77
131
|
export { }
|
package/dist/index.d.mts
CHANGED
|
@@ -1,56 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Contentful ContentfulOptimization Node SDK.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Adds Node-specific defaults via the {@link ContentfulOptimization} class.
|
|
6
|
+
* Core and transitive API exports are available from dedicated entrypoints:
|
|
7
|
+
* `@contentful/optimization-node/core-sdk`,
|
|
8
|
+
* `@contentful/optimization-node/api-client`,
|
|
9
|
+
* and `@contentful/optimization-node/api-schemas`.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { App } from '@contentful/optimization-core/api-schemas';
|
|
3
15
|
import { CoreStateless } from '@contentful/optimization-core';
|
|
4
16
|
import { CoreStatelessConfig } from '@contentful/optimization-core';
|
|
5
17
|
|
|
6
|
-
export { ANONYMOUS_ID_COOKIE }
|
|
7
|
-
|
|
8
18
|
/**
|
|
9
|
-
* Node-specific
|
|
19
|
+
* Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
|
|
10
20
|
*
|
|
11
|
-
* @public
|
|
12
21
|
* @remarks
|
|
13
|
-
* This class adapts the stateless
|
|
22
|
+
* This class adapts the stateless ContentfulOptimization Core for Node runtimes by
|
|
14
23
|
* applying environment-appropriate defaults (e.g., server channel, Node SDK
|
|
15
|
-
* library metadata). No
|
|
16
|
-
*
|
|
24
|
+
* library metadata). No core runtime behavior is modified; only configuration
|
|
25
|
+
* defaults differ.
|
|
17
26
|
*
|
|
18
27
|
* @example
|
|
19
28
|
* ```ts
|
|
20
|
-
* import
|
|
29
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
21
30
|
*
|
|
22
|
-
* const sdk = new
|
|
31
|
+
* const sdk = new ContentfulOptimization({
|
|
23
32
|
* clientId: 'abc-123',
|
|
24
33
|
* environment: 'main',
|
|
25
34
|
* logLevel: 'info',
|
|
26
35
|
* })
|
|
27
36
|
*
|
|
28
|
-
*
|
|
37
|
+
* const requestOptimization = sdk.forRequest({
|
|
38
|
+
* consent: true,
|
|
39
|
+
* locale: 'fr-CA',
|
|
40
|
+
* profile: { id: 'profile-id' },
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* const { accepted, data } = await requestOptimization.page()
|
|
29
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* @see {@link CoreStateless}
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
30
49
|
*/
|
|
31
|
-
declare class
|
|
50
|
+
declare class ContentfulOptimization extends CoreStateless {
|
|
32
51
|
/**
|
|
33
52
|
* Create an instance of the Node SDK with merged defaults.
|
|
34
53
|
*
|
|
35
54
|
* @param config - Partial Node-specific configuration. Any eventBuilder
|
|
36
55
|
* fields provided are merged with Node's defaults.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
60
|
+
*
|
|
61
|
+
* const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
|
|
62
|
+
* ```
|
|
37
63
|
*/
|
|
38
|
-
constructor(config: OptimizationNodeConfig);
|
|
64
|
+
constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig);
|
|
39
65
|
}
|
|
40
|
-
export default
|
|
66
|
+
export default ContentfulOptimization;
|
|
41
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
70
|
+
*
|
|
71
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
42
75
|
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
43
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
79
|
+
*
|
|
80
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
44
84
|
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
45
85
|
|
|
46
86
|
/**
|
|
47
|
-
* Configuration for the Node-specific
|
|
87
|
+
* Configuration for the Node-specific ContentfulOptimization SDK.
|
|
48
88
|
*
|
|
49
|
-
* @public
|
|
50
89
|
* @remarks
|
|
51
|
-
* This configuration extends {@link
|
|
52
|
-
* of the event-builder configuration. SDKs commonly inject their own
|
|
53
|
-
* metadata or channel definitions.
|
|
90
|
+
* This configuration extends {@link CoreStatelessConfig} but allows partial
|
|
91
|
+
* overrides of the event-builder configuration. SDKs commonly inject their own
|
|
92
|
+
* library metadata or channel definitions.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link CoreStatelessConfig}
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
54
97
|
*/
|
|
55
98
|
export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
|
|
56
99
|
/**
|
|
@@ -65,13 +108,24 @@ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig
|
|
|
65
108
|
*
|
|
66
109
|
* @remarks
|
|
67
110
|
* Any provided fields are merged with the default Node SDK metadata.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
111
|
+
* Request-scoped consent should be bound with `forRequest()`, not configured
|
|
112
|
+
* on the SDK singleton.
|
|
113
|
+
*
|
|
114
|
+
* This differs from {@link CoreStatelessConfig} eventBuilder, which expects
|
|
115
|
+
* a full configuration object.
|
|
70
116
|
*/
|
|
71
|
-
eventBuilder?:
|
|
117
|
+
eventBuilder?: PublicNodeEventBuilderConfig;
|
|
72
118
|
}
|
|
73
119
|
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`
|
|
125
|
+
* is intentionally omitted from singleton SDK configuration.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare type PublicNodeEventBuilderConfig = Partial<Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>>;
|
|
76
130
|
|
|
77
131
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -1,56 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Contentful ContentfulOptimization Node SDK.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Adds Node-specific defaults via the {@link ContentfulOptimization} class.
|
|
6
|
+
* Core and transitive API exports are available from dedicated entrypoints:
|
|
7
|
+
* `@contentful/optimization-node/core-sdk`,
|
|
8
|
+
* `@contentful/optimization-node/api-client`,
|
|
9
|
+
* and `@contentful/optimization-node/api-schemas`.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { App } from '@contentful/optimization-core/api-schemas';
|
|
3
15
|
import { CoreStateless } from '@contentful/optimization-core';
|
|
4
16
|
import { CoreStatelessConfig } from '@contentful/optimization-core';
|
|
5
17
|
|
|
6
|
-
export { ANONYMOUS_ID_COOKIE }
|
|
7
|
-
|
|
8
18
|
/**
|
|
9
|
-
* Node-specific
|
|
19
|
+
* Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.
|
|
10
20
|
*
|
|
11
|
-
* @public
|
|
12
21
|
* @remarks
|
|
13
|
-
* This class adapts the stateless
|
|
22
|
+
* This class adapts the stateless ContentfulOptimization Core for Node runtimes by
|
|
14
23
|
* applying environment-appropriate defaults (e.g., server channel, Node SDK
|
|
15
|
-
* library metadata). No
|
|
16
|
-
*
|
|
24
|
+
* library metadata). No core runtime behavior is modified; only configuration
|
|
25
|
+
* defaults differ.
|
|
17
26
|
*
|
|
18
27
|
* @example
|
|
19
28
|
* ```ts
|
|
20
|
-
* import
|
|
29
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
21
30
|
*
|
|
22
|
-
* const sdk = new
|
|
31
|
+
* const sdk = new ContentfulOptimization({
|
|
23
32
|
* clientId: 'abc-123',
|
|
24
33
|
* environment: 'main',
|
|
25
34
|
* logLevel: 'info',
|
|
26
35
|
* })
|
|
27
36
|
*
|
|
28
|
-
*
|
|
37
|
+
* const requestOptimization = sdk.forRequest({
|
|
38
|
+
* consent: true,
|
|
39
|
+
* locale: 'fr-CA',
|
|
40
|
+
* profile: { id: 'profile-id' },
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* const { accepted, data } = await requestOptimization.page()
|
|
29
44
|
* ```
|
|
45
|
+
*
|
|
46
|
+
* @see {@link CoreStateless}
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
30
49
|
*/
|
|
31
|
-
declare class
|
|
50
|
+
declare class ContentfulOptimization extends CoreStateless {
|
|
32
51
|
/**
|
|
33
52
|
* Create an instance of the Node SDK with merged defaults.
|
|
34
53
|
*
|
|
35
54
|
* @param config - Partial Node-specific configuration. Any eventBuilder
|
|
36
55
|
* fields provided are merged with Node's defaults.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import ContentfulOptimization from '@contentful/optimization-node'
|
|
60
|
+
*
|
|
61
|
+
* const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })
|
|
62
|
+
* ```
|
|
37
63
|
*/
|
|
38
|
-
constructor(config: OptimizationNodeConfig);
|
|
64
|
+
constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig);
|
|
39
65
|
}
|
|
40
|
-
export default
|
|
66
|
+
export default ContentfulOptimization;
|
|
41
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The package name of the Optimization Node SDK, injected at build-time.
|
|
70
|
+
*
|
|
71
|
+
* @defaultValue `'@contentful/optimization-node'` when the build-time replacement is unavailable.
|
|
72
|
+
*
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
42
75
|
export declare const OPTIMIZATION_NODE_SDK_NAME: string;
|
|
43
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The current version of the Optimization Node SDK, injected at build-time.
|
|
79
|
+
*
|
|
80
|
+
* @defaultValue `'0.0.0'` when the build-time replacement is unavailable.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
44
84
|
export declare const OPTIMIZATION_NODE_SDK_VERSION: string;
|
|
45
85
|
|
|
46
86
|
/**
|
|
47
|
-
* Configuration for the Node-specific
|
|
87
|
+
* Configuration for the Node-specific ContentfulOptimization SDK.
|
|
48
88
|
*
|
|
49
|
-
* @public
|
|
50
89
|
* @remarks
|
|
51
|
-
* This configuration extends {@link
|
|
52
|
-
* of the event-builder configuration. SDKs commonly inject their own
|
|
53
|
-
* metadata or channel definitions.
|
|
90
|
+
* This configuration extends {@link CoreStatelessConfig} but allows partial
|
|
91
|
+
* overrides of the event-builder configuration. SDKs commonly inject their own
|
|
92
|
+
* library metadata or channel definitions.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link CoreStatelessConfig}
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
54
97
|
*/
|
|
55
98
|
export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {
|
|
56
99
|
/**
|
|
@@ -65,13 +108,24 @@ export declare interface OptimizationNodeConfig extends Omit<CoreStatelessConfig
|
|
|
65
108
|
*
|
|
66
109
|
* @remarks
|
|
67
110
|
* Any provided fields are merged with the default Node SDK metadata.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
111
|
+
* Request-scoped consent should be bound with `forRequest()`, not configured
|
|
112
|
+
* on the SDK singleton.
|
|
113
|
+
*
|
|
114
|
+
* This differs from {@link CoreStatelessConfig} eventBuilder, which expects
|
|
115
|
+
* a full configuration object.
|
|
70
116
|
*/
|
|
71
|
-
eventBuilder?:
|
|
117
|
+
eventBuilder?: PublicNodeEventBuilderConfig;
|
|
72
118
|
}
|
|
73
119
|
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
/**
|
|
121
|
+
* Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`
|
|
125
|
+
* is intentionally omitted from singleton SDK configuration.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare type PublicNodeEventBuilderConfig = Partial<Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>>;
|
|
76
130
|
|
|
77
131
|
export { }
|
package/dist/index.mjs
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { __rspack_external__contentful_optimization_core_7d4758c6 } from "./987.mjs";
|
|
2
|
+
import { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
|
|
3
|
+
const DEFAULT_NODE_ALLOWED_EVENT_TYPES = [
|
|
4
|
+
'identify',
|
|
5
|
+
'page'
|
|
6
|
+
];
|
|
7
|
+
class ContentfulOptimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
|
|
8
|
+
constructor({ app, allowedEventTypes, eventBuilder, ...config }){
|
|
9
|
+
const { library, ...eventBuilderConfig } = eventBuilder ?? {};
|
|
10
|
+
super({
|
|
11
|
+
...config,
|
|
12
|
+
allowedEventTypes: allowedEventTypes ?? DEFAULT_NODE_ALLOWED_EVENT_TYPES,
|
|
13
|
+
eventBuilder: {
|
|
14
|
+
app,
|
|
15
|
+
channel: 'server',
|
|
16
|
+
...eventBuilderConfig,
|
|
17
|
+
library: {
|
|
18
|
+
name: OPTIMIZATION_NODE_SDK_NAME,
|
|
19
|
+
version: OPTIMIZATION_NODE_SDK_VERSION,
|
|
20
|
+
...library
|
|
21
|
+
},
|
|
22
|
+
getConsent: ()=>false
|
|
14
23
|
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
return merge(defaultConfig, restConfig);
|
|
18
|
-
}
|
|
19
|
-
class Optimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
|
|
20
|
-
constructor(config){
|
|
21
|
-
const mergedConfig = mergeConfig(config);
|
|
22
|
-
super(mergedConfig);
|
|
24
|
+
});
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
const
|
|
26
|
-
const src =
|
|
27
|
-
|
|
28
|
-
export * from "@contentful/optimization-core";
|
|
27
|
+
const src_ContentfulOptimization = ContentfulOptimization;
|
|
28
|
+
const src = src_ContentfulOptimization;
|
|
29
|
+
export { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
|
|
29
30
|
export default src;
|
|
30
|
-
export { ANONYMOUS_ID_COOKIE, OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION };
|
|
31
31
|
|
|
32
32
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/ContentfulOptimization.ts","../src/index.ts"],"sourcesContent":["import {\n CoreStateless,\n type CoreStatelessConfig,\n type EventType,\n} from '@contentful/optimization-core'\nimport type { App } from '@contentful/optimization-core/api-schemas'\nimport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\n\nconst DEFAULT_NODE_ALLOWED_EVENT_TYPES: EventType[] = ['identify', 'page']\n\n/**\n * Public Node event-builder overrides accepted by {@link OptimizationNodeConfig.eventBuilder}.\n *\n * @remarks\n * Request-scoped consent is bound with {@link ContentfulOptimization.forRequest}, so `getConsent`\n * is intentionally omitted from singleton SDK configuration.\n *\n * @public\n */\nexport type PublicNodeEventBuilderConfig = Partial<\n Omit<NonNullable<CoreStatelessConfig['eventBuilder']>, 'app' | 'getConsent'>\n>\n\n/**\n * Configuration for the Node-specific ContentfulOptimization SDK.\n *\n * @remarks\n * This configuration extends {@link CoreStatelessConfig} but allows partial\n * overrides of the event-builder configuration. SDKs commonly inject their own\n * library metadata or channel definitions.\n *\n * @see {@link CoreStatelessConfig}\n *\n * @public\n */\nexport interface OptimizationNodeConfig extends Omit<CoreStatelessConfig, 'eventBuilder'> {\n /**\n * The application definition used to attribute events to a specific consumer app.\n *\n * @remarks\n * When not provided, events will not contain app metadata in their context.\n */\n app?: App\n\n /**\n * Partial overrides for the event builder configuration.\n *\n * @remarks\n * Any provided fields are merged with the default Node SDK metadata.\n * Request-scoped consent should be bound with `forRequest()`, not configured\n * on the SDK singleton.\n *\n * This differs from {@link CoreStatelessConfig} eventBuilder, which expects\n * a full configuration object.\n */\n eventBuilder?: PublicNodeEventBuilderConfig\n}\n\n/**\n * Node-specific ContentfulOptimization SDK built on {@link CoreStateless}.\n *\n * @remarks\n * This class adapts the stateless ContentfulOptimization Core for Node runtimes by\n * applying environment-appropriate defaults (e.g., server channel, Node SDK\n * library metadata). No core runtime behavior is modified; only configuration\n * defaults differ.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const sdk = new ContentfulOptimization({\n * clientId: 'abc-123',\n * environment: 'main',\n * logLevel: 'info',\n * })\n *\n * const requestOptimization = sdk.forRequest({\n * consent: true,\n * locale: 'fr-CA',\n * profile: { id: 'profile-id' },\n * })\n *\n * const { accepted, data } = await requestOptimization.page()\n * ```\n *\n * @see {@link CoreStateless}\n *\n * @public\n */\nclass ContentfulOptimization extends CoreStateless {\n /**\n * Create an instance of the Node SDK with merged defaults.\n *\n * @param config - Partial Node-specific configuration. Any eventBuilder\n * fields provided are merged with Node's defaults.\n *\n * @example\n * ```ts\n * import ContentfulOptimization from '@contentful/optimization-node'\n *\n * const optimization = new ContentfulOptimization({ clientId: 'my-client-id' })\n * ```\n */\n constructor({ app, allowedEventTypes, eventBuilder, ...config }: OptimizationNodeConfig) {\n const { library, ...eventBuilderConfig } = eventBuilder ?? {}\n\n super({\n ...config,\n allowedEventTypes: allowedEventTypes ?? DEFAULT_NODE_ALLOWED_EVENT_TYPES,\n eventBuilder: {\n app,\n channel: 'server',\n ...eventBuilderConfig,\n library: {\n name: OPTIMIZATION_NODE_SDK_NAME,\n version: OPTIMIZATION_NODE_SDK_VERSION,\n ...library,\n },\n getConsent: () => false,\n },\n })\n }\n}\n\nexport default ContentfulOptimization\n","/**\n * Contentful ContentfulOptimization Node SDK.\n *\n * @remarks\n * Adds Node-specific defaults via the {@link ContentfulOptimization} class.\n * Core and transitive API exports are available from dedicated entrypoints:\n * `@contentful/optimization-node/core-sdk`,\n * `@contentful/optimization-node/api-client`,\n * and `@contentful/optimization-node/api-schemas`.\n *\n * @packageDocumentation\n */\n\nimport ContentfulOptimization from './ContentfulOptimization'\n\nexport { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from './constants'\nexport * from './ContentfulOptimization'\n\nexport default ContentfulOptimization\n"],"names":["DEFAULT_NODE_ALLOWED_EVENT_TYPES","ContentfulOptimization","CoreStateless","app","allowedEventTypes","eventBuilder","config","library","eventBuilderConfig","OPTIMIZATION_NODE_SDK_NAME","OPTIMIZATION_NODE_SDK_VERSION"],"mappings":";;AAQA,MAAMA,mCAAgD;IAAC;IAAY;CAAO;AAkF1E,MAAMC,+BAA+BC,yDAAAA,aAAaA;IAchD,YAAY,EAAEC,GAAG,EAAEC,iBAAiB,EAAEC,YAAY,EAAE,GAAGC,QAAgC,CAAE;QACvF,MAAM,EAAEC,OAAO,EAAE,GAAGC,oBAAoB,GAAGH,gBAAgB,CAAC;QAE5D,KAAK,CAAC;YACJ,GAAGC,MAAM;YACT,mBAAmBF,qBAAqBJ;YACxC,cAAc;gBACZG;gBACA,SAAS;gBACT,GAAGK,kBAAkB;gBACrB,SAAS;oBACP,MAAMC;oBACN,SAASC;oBACT,GAAGH,OAAO;gBACZ;gBACA,YAAY,IAAM;YACpB;QACF;IACF;AACF;AAEA,mCAAeN;AC3Gf,YAAeA"}
|