@salesforce/webapp-experimental 1.8.1 → 1.10.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.
@@ -4,6 +4,7 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
  export interface WebAppManifest {
7
+ name?: string;
7
8
  outputDir: string;
8
9
  routing?: RoutingConfig;
9
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/app/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,cAAc;IAE9B,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,EAAE,aAAa,CAAC;CACxB;AAGD,MAAM,WAAW,aAAa;IAE7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAE3B,aAAa,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAE5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,WAAW;IAE3B,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,YAAY;IAE5B,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAClC;AAsBD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAchF"}
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/app/manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,cAAc;IAE9B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;IAElB,OAAO,CAAC,EAAE,aAAa,CAAC;CACxB;AAGD,MAAM,WAAW,aAAa;IAE7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IAEzB,SAAS,CAAC,EAAE,YAAY,EAAE,CAAC;IAE3B,aAAa,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;IAE5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,MAAM,WAAW,WAAW;IAE3B,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;CACf;AAGD,MAAM,WAAW,YAAY;IAE5B,KAAK,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAClC;AAsBD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAchF"}
@@ -5,6 +5,14 @@
5
5
  */
6
6
  import type { IncomingMessage, ServerResponse } from "node:http";
7
7
  import type { OrgInfo, WebAppManifest } from "../app/index.js";
8
+ /**
9
+ * URL parameter to trigger health check response
10
+ */
11
+ export declare const WEBAPP_HEALTH_CHECK_PARAM = "sfProxyHealthCheck";
12
+ /**
13
+ * Response header indicating the proxy is active
14
+ */
15
+ export declare const WEBAPP_PROXY_HEADER = "X-Salesforce-WebApp-Proxy";
8
16
  /**
9
17
  * Configuration options for the WebApp proxy handler
10
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/proxy/handler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG/D;;GAEG;AACH,MAAM,WAAW,YAAY;IAE5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,cAA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AAM,EACjB,OAAO,CAAC,EAAE,YAAY,GACpB,YAAY,CAGd"}
@@ -3,8 +3,19 @@
3
3
  * All rights reserved.
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
+ import { createRequire } from "node:module";
6
7
  import { applyTrailingSlash, matchRoute } from "./routing.js";
7
8
  import { refreshOrgAuth } from "../app/index.js";
9
+ const require = createRequire(import.meta.url);
10
+ const { version: proxyVersion } = require("../../package.json");
11
+ /**
12
+ * URL parameter to trigger health check response
13
+ */
14
+ export const WEBAPP_HEALTH_CHECK_PARAM = "sfProxyHealthCheck";
15
+ /**
16
+ * Response header indicating the proxy is active
17
+ */
18
+ export const WEBAPP_PROXY_HEADER = "X-Salesforce-WebApp-Proxy";
8
19
  /**
9
20
  * Handles all proxy routing and forwarding for WebApps
10
21
  */
@@ -14,6 +25,7 @@ class WebAppProxyHandler {
14
25
  target;
15
26
  basePath;
16
27
  options;
28
+ startTime = Date.now();
17
29
  constructor(manifest, orgInfo, target, basePath, options) {
18
30
  this.manifest = manifest;
19
31
  this.orgInfo = orgInfo;
@@ -23,6 +35,11 @@ class WebAppProxyHandler {
23
35
  }
24
36
  async handle(req, res, next) {
25
37
  const url = new URL(req.url ?? "/", `http://${req.headers.host}`);
38
+ // Health check via URL parameter - respond immediately
39
+ if (url.searchParams.get(WEBAPP_HEALTH_CHECK_PARAM) === "true") {
40
+ this.handleHealthCheck(res);
41
+ return;
42
+ }
26
43
  let pathname = url.pathname;
27
44
  if (this.options?.debug) {
28
45
  console.log(`[webapps-proxy] ${req.method} ${pathname}`);
@@ -61,6 +78,25 @@ class WebAppProxyHandler {
61
78
  res.writeHead(statusCode, { Location: location });
62
79
  res.end();
63
80
  }
81
+ handleHealthCheck(res) {
82
+ const response = {
83
+ proxyName: "@salesforce/webapp-experimental",
84
+ proxyVersion,
85
+ port: this.target ? new URL(this.target).port : undefined,
86
+ org: this.orgInfo?.orgAlias ?? this.orgInfo?.username,
87
+ apiVersion: this.orgInfo?.apiVersion,
88
+ webappName: this.manifest.name,
89
+ webappFolderPath: this.basePath,
90
+ uptime: Date.now() - this.startTime,
91
+ timestamp: new Date().toISOString(),
92
+ debugMode: this.options?.debug ?? false,
93
+ };
94
+ res.writeHead(200, {
95
+ "Content-Type": "application/json",
96
+ [WEBAPP_PROXY_HEADER]: "true",
97
+ });
98
+ res.end(JSON.stringify(response, null, 2));
99
+ }
64
100
  sendNoOrgError(res) {
65
101
  res.writeHead(401, { "Content-Type": "application/json" });
66
102
  res.end(JSON.stringify({
@@ -4,5 +4,5 @@
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
6
  export type { ProxyOptions, ProxyHandler } from "./handler.js";
7
- export { createProxyHandler } from "./handler.js";
7
+ export { createProxyHandler, WEBAPP_HEALTH_CHECK_PARAM, WEBAPP_PROXY_HEADER } from "./handler.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/proxy/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
@@ -3,4 +3,4 @@
3
3
  * All rights reserved.
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
- export { createProxyHandler } from "./handler.js";
6
+ export { createProxyHandler, WEBAPP_HEALTH_CHECK_PARAM, WEBAPP_PROXY_HEADER } from "./handler.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/webapp-experimental",
3
3
  "description": "[experimental] Core package for Salesforce Web Applications",
4
- "version": "1.8.1",
4
+ "version": "1.10.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -54,5 +54,5 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  },
57
- "gitHead": "b5c1d465570de3857bf4036ec055e1d8556c4612"
57
+ "gitHead": "841b3229286b09a45f6f98af1674dc6edaab6807"
58
58
  }