@forge/bridge 5.17.0 → 5.18.0-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @forge/bridge
2
2
 
3
+ ## 5.18.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8ac7dd3]
8
+ - @forge/manifest@12.10.0-next.1
9
+
10
+ ## 5.18.0-next.0
11
+
12
+ ### Minor Changes
13
+
14
+ - b0b69a2: **Experimental — not yet ready for use.** Add a new `frontendCustomMetrics` namespace providing `frontendCustomMetrics.counter(name)` with `incr()` and `incrBy(value)` for emitting frontend custom metrics. `incrBy(value)` rejects if `value <= 0`. The metric name must exactly match a metric registered in the Forge Dev Console.
15
+
16
+ ### Patch Changes
17
+
18
+ - 561f8f4: Remove "storage" module from "@forge/api"
19
+ - Updated dependencies [814b8fe]
20
+ - Updated dependencies [55c1371]
21
+ - Updated dependencies [1a461c3]
22
+ - @forge/manifest@12.9.1-next.0
23
+
3
24
  ## 5.17.0
4
25
 
5
26
  ### Minor Changes
@@ -0,0 +1,17 @@
1
+ export interface Counter {
2
+ incr: () => Promise<void>;
3
+ incrBy: (value: number) => Promise<void>;
4
+ }
5
+ /**
6
+ * Public namespace for emitting Forge frontend custom metrics from a Forge UI app.
7
+ *
8
+ * @example
9
+ * import { frontendCustomMetrics } from '@forge/bridge';
10
+ * const c = frontendCustomMetrics.counter('button-click');
11
+ * c.incr(); // increment by 1
12
+ * c.incrBy(5); // increment by 5 (rejects if value <= 0)
13
+ */
14
+ export declare const frontendCustomMetrics: {
15
+ counter: (name: string) => Counter;
16
+ };
17
+ //# sourceMappingURL=frontendCustomMetrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontendCustomMetrics.d.ts","sourceRoot":"","sources":["../../src/frontendCustomMetrics/frontendCustomMetrics.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAkDD;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB;oBAvBX,MAAM,KAAG,OAAO;CAuBS,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.frontendCustomMetrics = void 0;
4
+ const bridge_1 = require("../bridge");
5
+ const errors_1 = require("../errors");
6
+ const callBridge = (0, bridge_1.getCallBridge)();
7
+ const emit = async (customMetricName, value) => {
8
+ await callBridge('emitFrontendCustomMetric', {
9
+ customMetricName,
10
+ value
11
+ });
12
+ };
13
+ const MAX_METRIC_NAME_LENGTH = 50;
14
+ // Must start and end with an alphanumeric character and may only contain
15
+ // letters, numbers, dots (.) and hyphens (-) in between.
16
+ const METRIC_NAME_REGEX = /^[a-zA-Z0-9]([a-zA-Z0-9.-]*[a-zA-Z0-9])?$/;
17
+ /**
18
+ * Validates a custom metric name against the same rules enforced when
19
+ * registering a metric in the developer console. Throws synchronously so
20
+ * developer errors fail fast without a wasted bridge round-trip.
21
+ *
22
+ * Note: this is a best-effort, client-side convenience check. The metric name
23
+ * must still match a custom metric registered in the developer console, which
24
+ * remains the source of truth and is validated by the backend.
25
+ */
26
+ const validateMetricName = (name) => {
27
+ if (name.trim().length === 0) {
28
+ throw new errors_1.BridgeAPIError('Custom metric name cannot be empty');
29
+ }
30
+ if (name.length > MAX_METRIC_NAME_LENGTH) {
31
+ throw new errors_1.BridgeAPIError(`Custom metric name cannot exceed ${MAX_METRIC_NAME_LENGTH} characters`);
32
+ }
33
+ if (!METRIC_NAME_REGEX.test(name)) {
34
+ throw new errors_1.BridgeAPIError('Custom metric name must start and end with alphanumeric characters and can only contain letters, numbers, dots (.), and hyphens (-)');
35
+ }
36
+ if (name.includes('..') || name.includes('--')) {
37
+ throw new errors_1.BridgeAPIError('Custom metric name cannot contain consecutive dots or hyphens');
38
+ }
39
+ };
40
+ const counter = (name) => {
41
+ validateMetricName(name);
42
+ return {
43
+ incr: () => emit(name, 1),
44
+ incrBy: (value) => {
45
+ if (value <= 0) {
46
+ throw new errors_1.BridgeAPIError('Counter value must be a positive number');
47
+ }
48
+ return emit(name, value);
49
+ }
50
+ };
51
+ };
52
+ /**
53
+ * Public namespace for emitting Forge frontend custom metrics from a Forge UI app.
54
+ *
55
+ * @example
56
+ * import { frontendCustomMetrics } from '@forge/bridge';
57
+ * const c = frontendCustomMetrics.counter('button-click');
58
+ * c.incr(); // increment by 1
59
+ * c.incrBy(5); // increment by 5 (rejects if value <= 0)
60
+ */
61
+ exports.frontendCustomMetrics = { counter };
@@ -0,0 +1,2 @@
1
+ export * from './frontendCustomMetrics';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/frontendCustomMetrics/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./frontendCustomMetrics"), exports);
package/out/index.d.ts CHANGED
@@ -14,4 +14,5 @@ export * from './permissions';
14
14
  export * from './object-store';
15
15
  export { type FullContext } from './types';
16
16
  export * from './featureFlags';
17
+ export * from './frontendCustomMetrics';
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
package/out/index.js CHANGED
@@ -18,3 +18,4 @@ exports.i18n = tslib_1.__importStar(require("./i18n"));
18
18
  tslib_1.__exportStar(require("./permissions"), exports);
19
19
  tslib_1.__exportStar(require("./object-store"), exports);
20
20
  tslib_1.__exportStar(require("./featureFlags"), exports);
21
+ tslib_1.__exportStar(require("./frontendCustomMetrics"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/bridge",
3
- "version": "5.17.0",
3
+ "version": "5.18.0-next.1",
4
4
  "description": "Forge bridge API for custom UI apps",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -19,7 +19,7 @@
19
19
  "@forge/i18n": "0.0.7",
20
20
  "@forge/resolver": "1.8.0",
21
21
  "@types/history": "^4.7.11",
22
- "@forge/manifest": "12.9.0",
22
+ "@forge/manifest": "12.10.0-next.1",
23
23
  "@types/iframe-resizer": "^3.5.8",
24
24
  "iframe-resizer": "^4.4.5"
25
25
  },