@nextera.one/axis-server-sdk 2.3.1 → 2.3.3

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/dist/index.mjs CHANGED
@@ -2382,10 +2382,7 @@ var intent_router_exports = {};
2382
2382
  __export(intent_router_exports, {
2383
2383
  IntentRouter: () => IntentRouter
2384
2384
  });
2385
- import {
2386
- decodeChainEnvelope,
2387
- decodeChainRequest
2388
- } from "@nextera.one/axis-protocol";
2385
+ import { decodeChainEnvelope, decodeChainRequest } from "@nextera.one/axis-protocol";
2389
2386
  function observerRefKey(ref) {
2390
2387
  return typeof ref === "string" ? ref : ref.name;
2391
2388
  }
@@ -2513,6 +2510,8 @@ var init_intent_router = __esm({
2513
2510
  this.cceHandlers = /* @__PURE__ */ new Map();
2514
2511
  /** CCE pipeline configuration (set via configureCce) */
2515
2512
  this.ccePipelineConfig = null;
2513
+ /** Reverse index: handler class name → list of registered intents */
2514
+ this.handlerIntents = /* @__PURE__ */ new Map();
2516
2515
  this.dependencyResolver = dependencyResolver;
2517
2516
  this.observerDispatcher = observerDispatcher;
2518
2517
  this.sensorRegistry = sensorRegistry;
@@ -2602,6 +2601,7 @@ var init_intent_router = __esm({
2602
2601
  intentName,
2603
2602
  `${instance.constructor.name}.${String(route.methodName)}`
2604
2603
  );
2604
+ this.trackHandlerIntent(instance.constructor.name, intentName);
2605
2605
  this.registerIntentMeta(
2606
2606
  intentName,
2607
2607
  proto,
@@ -2625,6 +2625,7 @@ var init_intent_router = __esm({
2625
2625
  handlerSensors,
2626
2626
  handlerObservers
2627
2627
  );
2628
+ this.trackHandlerIntent(instance.constructor.name, intentName);
2628
2629
  }
2629
2630
  }
2630
2631
  /**
@@ -2976,6 +2977,99 @@ var init_intent_router = __esm({
2976
2977
  getRateLimit(intent) {
2977
2978
  return this.intentRateLimits.get(intent);
2978
2979
  }
2980
+ // ─── Handler-level Getters ─────────────────────────────────────────────────
2981
+ /** All intents registered under the given handler class name. */
2982
+ getHandlerIntents(handlerName) {
2983
+ return this.handlerIntents.get(handlerName) ?? [];
2984
+ }
2985
+ /** All registered handler class names. */
2986
+ getRegisteredHandlers() {
2987
+ return Array.from(this.handlerIntents.keys());
2988
+ }
2989
+ /** The system/builtin intents (ping, time, echo, chain, intent.exec). */
2990
+ getSystemIntents() {
2991
+ return [..._IntentRouter.BUILTIN_INTENTS];
2992
+ }
2993
+ /** True if every intent in the handler is public, or any one is public — returns true if ANY intent is @AxisPublic. */
2994
+ isHandlerPublic(handlerName) {
2995
+ return this.getHandlerIntents(handlerName).some((i) => this.isPublic(i));
2996
+ }
2997
+ /** True if any intent in the handler is @AxisAnonymous. */
2998
+ isHandlerAnonymous(handlerName) {
2999
+ return this.getHandlerIntents(handlerName).some((i) => this.isAnonymous(i));
3000
+ }
3001
+ /** True if any intent in the handler is @AxisAuthorized. */
3002
+ isHandlerAuthorized(handlerName) {
3003
+ return this.getHandlerIntents(handlerName).some(
3004
+ (i) => this.isAuthorized(i)
3005
+ );
3006
+ }
3007
+ /** Union of all required proof kinds across the handler's intents (deduplicated). */
3008
+ getHandlerProof(handlerName) {
3009
+ const all = this.getHandlerIntents(handlerName).flatMap(
3010
+ (i) => this.getRequiredProof(i) ?? []
3011
+ );
3012
+ if (all.length === 0) return void 0;
3013
+ return [...new Set(all)];
3014
+ }
3015
+ /** Contract from the first intent that has one (class-level contracts propagate to all intents). */
3016
+ getHandlerContract(handlerName) {
3017
+ for (const intent of this.getHandlerIntents(handlerName)) {
3018
+ const contract = this.getContract(intent);
3019
+ if (contract) return contract;
3020
+ }
3021
+ return void 0;
3022
+ }
3023
+ /** Sensitivity from the first intent that has one. */
3024
+ getHandlerSensitivity(handlerName) {
3025
+ for (const intent of this.getHandlerIntents(handlerName)) {
3026
+ const sensitivity = this.getSensitivity(intent);
3027
+ if (sensitivity) return sensitivity;
3028
+ }
3029
+ return void 0;
3030
+ }
3031
+ /** Rate limit from the first intent that has one. */
3032
+ getHandlerRateLimit(handlerName) {
3033
+ for (const intent of this.getHandlerIntents(handlerName)) {
3034
+ const rateLimit = this.getRateLimit(intent);
3035
+ if (rateLimit) return rateLimit;
3036
+ }
3037
+ return void 0;
3038
+ }
3039
+ /** Capsule policy from the first intent that has one. */
3040
+ getHandlerCapsulePolicy(handlerName) {
3041
+ for (const intent of this.getHandlerIntents(handlerName)) {
3042
+ const policy = this.intentCapsulePolicies.get(intent);
3043
+ if (policy) return policy;
3044
+ }
3045
+ return void 0;
3046
+ }
3047
+ /** Full summary of a handler's registered intents and aggregated policies. Returns null if unknown. */
3048
+ getHandlerSummary(handlerName) {
3049
+ const intents = this.getHandlerIntents(handlerName);
3050
+ if (intents.length === 0) return null;
3051
+ return {
3052
+ handler: handlerName,
3053
+ intents,
3054
+ isPublic: this.isHandlerPublic(handlerName),
3055
+ isAnonymous: this.isHandlerAnonymous(handlerName),
3056
+ isAuthorized: this.isHandlerAuthorized(handlerName),
3057
+ requiredProof: this.getHandlerProof(handlerName),
3058
+ contract: this.getHandlerContract(handlerName),
3059
+ sensitivity: this.getHandlerSensitivity(handlerName),
3060
+ rateLimit: this.getHandlerRateLimit(handlerName),
3061
+ capsulePolicy: this.getHandlerCapsulePolicy(handlerName)
3062
+ };
3063
+ }
3064
+ /** Summary of all registered handlers keyed by handler class name. */
3065
+ getAllHandlerSummaries() {
3066
+ const result = /* @__PURE__ */ new Map();
3067
+ for (const handlerName of this.handlerIntents.keys()) {
3068
+ const summary = this.getHandlerSummary(handlerName);
3069
+ if (summary) result.set(handlerName, summary);
3070
+ }
3071
+ return result;
3072
+ }
2979
3073
  async emitIntentObservers(bindings, context) {
2980
3074
  if (!this.observerDispatcher) return;
2981
3075
  await this.observerDispatcher.dispatch(
@@ -3022,6 +3116,14 @@ var init_intent_router = __esm({
3022
3116
  }
3023
3117
  }
3024
3118
  }
3119
+ trackHandlerIntent(handlerName, intent) {
3120
+ const existing = this.handlerIntents.get(handlerName);
3121
+ if (existing) {
3122
+ if (!existing.includes(intent)) existing.push(intent);
3123
+ } else {
3124
+ this.handlerIntents.set(handlerName, [intent]);
3125
+ }
3126
+ }
3025
3127
  resolveIntentSensor(ref) {
3026
3128
  const registered = this.sensorRegistry?.resolve(ref);
3027
3129
  if (registered) {