cap-copilot-sdk 0.2.5 → 0.2.8

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/cds-plugin.js CHANGED
@@ -158,6 +158,17 @@ function _registerWidgetMiddleware(app) {
158
158
  log("Serving widget bundle at /__btp-copilot-widget/btp-copilot.js");
159
159
  }
160
160
 
161
+ app.get("/__btp-copilot/config", (_req, res) => {
162
+ res.setHeader("Cache-Control", "no-store");
163
+ res.json({
164
+ iframeUrl: iframeUrl || null,
165
+ backendUrl: backendUrl || null,
166
+ appId,
167
+ appName,
168
+ widgetPosition,
169
+ });
170
+ });
171
+
161
172
  // Auto-inject widget into HTML responses only when iframeUrl is configured
162
173
  if (!injectWidget || !iframeUrl) {
163
174
  if (!iframeUrl)
package/package.json CHANGED
@@ -1,17 +1,29 @@
1
1
  {
2
2
  "name": "cap-copilot-sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.8",
4
4
  "description": "CDS plugin: auto-extracts entity schemas, relationships, project structure and registers with BTP Copilot backend",
5
5
  "main": "cds-plugin.js",
6
6
  "exports": {
7
7
  ".": "./cds-plugin.js",
8
8
  "./cds-plugin": "./cds-plugin.js"
9
9
  },
10
- "files": ["src", "cds-plugin.js", "postinstall.js"],
10
+ "files": [
11
+ "src",
12
+ "cds-plugin.js",
13
+ "postinstall.js"
14
+ ],
11
15
  "scripts": {
12
16
  "postinstall": "node postinstall.js"
13
17
  },
14
- "keywords": ["sap", "cap", "cds", "btp", "ai", "chatbot", "plugin"],
18
+ "keywords": [
19
+ "sap",
20
+ "cap",
21
+ "cds",
22
+ "btp",
23
+ "ai",
24
+ "chatbot",
25
+ "plugin"
26
+ ],
15
27
  "license": "MIT",
16
28
  "cds": {
17
29
  "plugin": true
package/postinstall.js CHANGED
@@ -67,10 +67,17 @@ const changed =
67
67
  existing.backendUrl !== undefined ||
68
68
  existing.iframeUrl !== undefined;
69
69
 
70
- const pluginsArr = Array.isArray(cdsSection.plugins) ? cdsSection.plugins : [];
71
- const needsPlugin = !pluginsArr.includes("cap-copilot-sdk");
70
+ // CDS 8 auto-discovers plugins via "cds": { "plugin": true } in the package itself —
71
+ // no explicit cds.plugins entry is needed. Clean up any stale entry written by older
72
+ // versions of this postinstall, since a stale/malformed entry causes CDS to crash.
73
+ const hadStalePlugin = Array.isArray(cdsSection.plugins) &&
74
+ cdsSection.plugins.includes("cap-copilot-sdk");
75
+ if (hadStalePlugin) {
76
+ cdsSection.plugins = cdsSection.plugins.filter(p => p !== "cap-copilot-sdk");
77
+ if (cdsSection.plugins.length === 0) delete cdsSection.plugins;
78
+ }
72
79
 
73
- if (!changed && !needsPlugin) {
80
+ if (!changed && !hadStalePlugin) {
74
81
  process.exit(0);
75
82
  }
76
83
 
@@ -81,23 +88,14 @@ delete requires["btp-copilot"].backendUrl;
81
88
  delete requires["btp-copilot"].iframeUrl;
82
89
 
83
90
  cdsSection.requires = requires;
84
-
85
- // Ensure cap-copilot-sdk is listed in cds.plugins so CDS loads it automatically
86
- const plugins = Array.isArray(cdsSection.plugins) ? cdsSection.plugins : [];
87
- const pluginAlreadyListed = plugins.includes("cap-copilot-sdk");
88
- if (!pluginAlreadyListed) {
89
- plugins.push("cap-copilot-sdk");
90
- cdsSection.plugins = plugins;
91
- }
92
-
93
91
  pkg.cds = cdsSection;
94
92
 
95
93
  try {
96
94
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
97
95
  console.log(`\x1b[36m[cap-copilot-sdk]\x1b[0m \u2714 Configured cds.requires["btp-copilot"] in package.json`);
98
96
  console.log(`\x1b[36m[cap-copilot-sdk]\x1b[0m appId="${appDefaults.appId}" | appName="${appDefaults.appName}"`);
99
- if (!pluginAlreadyListed) {
100
- console.log(`\x1b[36m[cap-copilot-sdk]\x1b[0m \u2714 Registered "cap-copilot-sdk" in cds.plugins`);
97
+ if (hadStalePlugin) {
98
+ console.log(`\x1b[36m[cap-copilot-sdk]\x1b[0m \u2714 Removed stale cds.plugins entry (CDS auto-discovers this plugin)`);
101
99
  }
102
100
  } catch {
103
101
  // Non-fatal