@contentful/optimization-node 0.1.0-alpha9 → 1.0.1
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 +245 -252
- package/THIRD_PARTY_NOTICES.txt +2096 -0
- package/dist/260.mjs +1 -1
- package/dist/260.mjs.map +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/core-sdk.cjs +15 -2
- package/dist/core-sdk.cjs.map +1 -1
- package/dist/core-sdk.d.cts +13 -0
- package/dist/core-sdk.d.mts +13 -0
- package/dist/core-sdk.d.ts +13 -0
- package/dist/core-sdk.mjs +1 -0
- package/dist/index.cjs +24 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -16
- package/dist/index.d.mts +36 -16
- package/dist/index.d.ts +36 -16
- package/dist/index.mjs +23 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -4
package/dist/index.mjs
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { merge } from "es-toolkit";
|
|
2
1
|
import { __rspack_external__contentful_optimization_core_7d4758c6 } from "./987.mjs";
|
|
3
2
|
import { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
13
23
|
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
return merge(defaultConfig, restConfig);
|
|
17
|
-
}
|
|
18
|
-
class Optimization extends __rspack_external__contentful_optimization_core_7d4758c6.CoreStateless {
|
|
19
|
-
constructor(config){
|
|
20
|
-
const mergedConfig = mergeConfig(config);
|
|
21
|
-
super(mergedConfig);
|
|
24
|
+
});
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
|
-
const
|
|
25
|
-
const src =
|
|
27
|
+
const src_ContentfulOptimization = ContentfulOptimization;
|
|
28
|
+
const src = src_ContentfulOptimization;
|
|
26
29
|
export { OPTIMIZATION_NODE_SDK_NAME, OPTIMIZATION_NODE_SDK_VERSION } from "./260.mjs";
|
|
27
30
|
export default src;
|
|
28
31
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/optimization-node",
|
|
3
|
-
"
|
|
3
|
+
"description": "Node.js SDK for Contentful Optimization",
|
|
4
|
+
"version": "1.0.1",
|
|
4
5
|
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/contentful/optimization.git",
|
|
9
|
+
"directory": "packages/node/node-sdk"
|
|
10
|
+
},
|
|
5
11
|
"type": "module",
|
|
6
12
|
"main": "./dist/index.cjs",
|
|
7
13
|
"module": "./dist/index.mjs",
|
|
@@ -70,10 +76,18 @@
|
|
|
70
76
|
"./package.json": "./package.json"
|
|
71
77
|
},
|
|
72
78
|
"files": [
|
|
73
|
-
"dist/**/*"
|
|
79
|
+
"dist/**/*",
|
|
80
|
+
"THIRD_PARTY_NOTICES.txt"
|
|
74
81
|
],
|
|
82
|
+
"buildTools": {
|
|
83
|
+
"bundleSize": {
|
|
84
|
+
"gzipBudgets": {
|
|
85
|
+
"index.cjs": 2000,
|
|
86
|
+
"index.mjs": 1500
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
75
90
|
"dependencies": {
|
|
76
|
-
"
|
|
77
|
-
"@contentful/optimization-core": "0.1.0-alpha9"
|
|
91
|
+
"@contentful/optimization-core": "1.0.1"
|
|
78
92
|
}
|
|
79
93
|
}
|