@adobe-commerce/aio-toolkit 1.2.6 → 1.2.7

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.d.mts CHANGED
@@ -450,6 +450,16 @@ declare class JsonMessageProcessor implements LogRecordProcessor {
450
450
  shutdown(): Promise<void>;
451
451
  }
452
452
 
453
+ declare class LogSanitizer {
454
+ private readonly additionalSensitiveKeys;
455
+ private readonly maxDepth;
456
+ constructor(additionalSensitiveKeys?: ReadonlySet<string>, maxDepth?: number);
457
+ static parseSensitiveKeys(raw: unknown): ReadonlySet<string>;
458
+ execute(data: unknown): unknown;
459
+ private isSensitiveKey;
460
+ private sanitize;
461
+ }
462
+
453
463
  interface BearerTokenInfo {
454
464
  token: string | null;
455
465
  tokenLength: number;
@@ -1182,4 +1192,4 @@ declare class AdminUiSdk {
1182
1192
  getRegistration(): AdminUiSdkRegistration;
1183
1193
  }
1184
1194
 
1185
- export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbFindOptions, type AbdbFindSort, type AbdbFindSortDirection, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, AmazonSQSClient, type AmazonSQSConfig, type ConsumeStats as AmazonSQSConsumeStats, type MessageHandler as AmazonSQSMessageHandler, type PublishStats as AmazonSQSPublishStats, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type ConsumeStats$1 as ConsumeStats, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, type MessageHandler$1 as MessageHandler, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type PublishStats$1 as PublishStats, RabbitMQClient, type RabbitMQConsumeOptions, type RabbitMQCredentials, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
1195
+ export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbFindOptions, type AbdbFindSort, type AbdbFindSortDirection, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, AmazonSQSClient, type AmazonSQSConfig, type ConsumeStats as AmazonSQSConsumeStats, type MessageHandler as AmazonSQSMessageHandler, type PublishStats as AmazonSQSPublishStats, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type ConsumeStats$1 as ConsumeStats, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, LogSanitizer, type MenuItem, type MessageHandler$1 as MessageHandler, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type PublishStats$1 as PublishStats, RabbitMQClient, type RabbitMQConsumeOptions, type RabbitMQCredentials, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
package/dist/index.d.ts CHANGED
@@ -450,6 +450,16 @@ declare class JsonMessageProcessor implements LogRecordProcessor {
450
450
  shutdown(): Promise<void>;
451
451
  }
452
452
 
453
+ declare class LogSanitizer {
454
+ private readonly additionalSensitiveKeys;
455
+ private readonly maxDepth;
456
+ constructor(additionalSensitiveKeys?: ReadonlySet<string>, maxDepth?: number);
457
+ static parseSensitiveKeys(raw: unknown): ReadonlySet<string>;
458
+ execute(data: unknown): unknown;
459
+ private isSensitiveKey;
460
+ private sanitize;
461
+ }
462
+
453
463
  interface BearerTokenInfo {
454
464
  token: string | null;
455
465
  tokenLength: number;
@@ -1182,4 +1192,4 @@ declare class AdminUiSdk {
1182
1192
  getRegistration(): AdminUiSdkRegistration;
1183
1193
  }
1184
1194
 
1185
- export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbFindOptions, type AbdbFindSort, type AbdbFindSortDirection, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, AmazonSQSClient, type AmazonSQSConfig, type ConsumeStats as AmazonSQSConsumeStats, type MessageHandler as AmazonSQSMessageHandler, type PublishStats as AmazonSQSPublishStats, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type ConsumeStats$1 as ConsumeStats, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, type MenuItem, type MessageHandler$1 as MessageHandler, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type PublishStats$1 as PublishStats, RabbitMQClient, type RabbitMQConsumeOptions, type RabbitMQCredentials, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
1195
+ export { AbdbCollection, type AbdbCollectionCallback, AbdbColumn, type AbdbColumnJson, type AbdbColumnOptions, AbdbColumnType, type AbdbFindOptions, type AbdbFindSort, type AbdbFindSortDirection, type AbdbRecord, AbdbRepository, type AbdbRepositoryFilter, type AbdbRunCallback, type AddColumnOptions, AdminUiSdk, type AdminUiSdkRegistration, AdobeAuth, AdobeCommerceClient, type AdobeIMSConfig, AmazonSQSClient, type AmazonSQSConfig, type ConsumeStats as AmazonSQSConsumeStats, type MessageHandler as AmazonSQSMessageHandler, type PublishStats as AmazonSQSPublishStats, type BaseTelemetry, type BaseTelemetryValidator, BasicAuthConnection, BearerToken, type BearerTokenInfo, type CommerceEvent, type CommerceEventConfig, type CommerceEventField, type Connection, type ConsumeStats$1 as ConsumeStats, type CreateEventResult, CreateEvents, type CreateProviderParams, type CreateProviderResult, type CreateRegistrationResult, CreateRegistrations, type ErrorResponse, EventConsumerAction, type EventData, type EventMetadata, type EventMetadataInputModel, type EventMetadataListResponse, EventMetadataManager, type ExtendedRequestError, type FileMetadata, type FileRecord, FileRepository, GenerateBasicAuthToken, type GetProviderQueryParams, type GetRegistrationQueryParams, GraphQlAction, type HALLink, type Headers, HttpMethod, HttpStatus, IOEventsApiError, type IOEventsError, ImsConnection, ImsToken, type ImsTokenResult, InfiniteLoopBreaker, type InfiniteLoopData, IoEventsGlobals, JsonMessageProcessor, type ListProvidersQueryParams, type ListRegistrationQueryParams, LogSanitizer, type MenuItem, type MessageHandler$1 as MessageHandler, Oauth1aConnection, OnboardCommerce, type OnboardCommerceConfig, type OnboardCommerceResult, OnboardEvents, type OnboardEventsInput, type OnboardEventsResponse, OnboardEvents as OnboardIOEvents, Openwhisk, OpenwhiskAction, type OpenwhiskConfig, type Page, Parameters, type Provider, type ProviderInputModel, ProviderManager, PublishEvent, type PublishEventResult, type PublishStats$1 as PublishStats, RabbitMQClient, type RabbitMQConsumeOptions, type RabbitMQCredentials, type Registration, type RegistrationCreateModel, type RegistrationListResponse, RegistrationManager, RestClient, RuntimeAction, RuntimeActionResponse, type RuntimeActionResponseType, RuntimeApiGatewayService, ShippingCarrier, type ShippingCarrierData, ShippingCarrierMethod, type ShippingCarrierMethodAdditionalData, type ShippingCarrierMethodData, ShippingCarrierResponse, SignatureVerification, SuccessChecker, type SuccessResponse, Telemetry, TelemetryInputError, type TokenResult, Validator, WebhookAction, type WebhookActionAddResponse, type WebhookActionExceptionResponse, WebhookActionOperation, type WebhookActionRemoveResponse, type WebhookActionReplaceResponse, WebhookActionResponse, type WebhookActionResponseType, type WebhookActionSuccessResponse, type WorkspaceConfig };
package/dist/index.js CHANGED
@@ -56,6 +56,7 @@ __export(index_exports, {
56
56
  InfiniteLoopBreaker: () => infinite_loop_breaker_default,
57
57
  IoEventsGlobals: () => IoEventsGlobals,
58
58
  JsonMessageProcessor: () => JsonMessageProcessor,
59
+ LogSanitizer: () => LogSanitizer,
59
60
  Oauth1aConnection: () => oauth1a_connection_default,
60
61
  OnboardCommerce: () => onboard_commerce_default,
61
62
  OnboardEvents: () => onboard_events_default,
@@ -214,7 +215,7 @@ var validator_default = Validator;
214
215
 
215
216
  // src/framework/telemetry/index.ts
216
217
  var import_aio_sdk = require("@adobe/aio-sdk");
217
- var import_aio_lib_telemetry3 = require("@adobe/aio-lib-telemetry");
218
+ var import_aio_lib_telemetry4 = require("@adobe/aio-lib-telemetry");
218
219
 
219
220
  // src/framework/telemetry/new-relic/index.ts
220
221
  var import_aio_lib_telemetry2 = require("@adobe/aio-lib-telemetry");
@@ -768,6 +769,334 @@ __name(_NewRelicTelemetry, "NewRelicTelemetry");
768
769
  var NewRelicTelemetry = _NewRelicTelemetry;
769
770
  var new_relic_default = NewRelicTelemetry;
770
771
 
772
+ // src/framework/telemetry/grafana/index.ts
773
+ var import_aio_lib_telemetry3 = require("@adobe/aio-lib-telemetry");
774
+
775
+ // src/framework/telemetry/grafana/validator/index.ts
776
+ var _GrafanaTelemetryValidator = class _GrafanaTelemetryValidator {
777
+ /**
778
+ * Checks if Grafana telemetry is configured
779
+ *
780
+ * Returns true when:
781
+ * - ENABLE_TELEMETRY is explicitly set to true
782
+ * - GRAFANA_TELEMETRY is explicitly set to true
783
+ *
784
+ * This method does NOT validate configuration completeness —
785
+ * it only checks whether the provider should be active.
786
+ *
787
+ * @param params - Runtime parameters to check
788
+ * @returns true if Grafana telemetry is enabled, false otherwise
789
+ *
790
+ * @example
791
+ * ```typescript
792
+ * const validator = new GrafanaTelemetryValidator();
793
+ * const params = { ENABLE_TELEMETRY: true, GRAFANA_TELEMETRY: true };
794
+ * if (validator.isConfigured(params)) {
795
+ * // Grafana telemetry is enabled, proceed with initialization
796
+ * }
797
+ * ```
798
+ */
799
+ isConfigured(params) {
800
+ return params.ENABLE_TELEMETRY === true && params.GRAFANA_TELEMETRY === true;
801
+ }
802
+ /**
803
+ * Validates Grafana-specific parameters
804
+ *
805
+ * IMPORTANT: Only call this method after isConfigured() returns true.
806
+ *
807
+ * Validation rules by mode:
808
+ * - GRAFANA_DEV=true → all parameters optional; localhost defaults are used
809
+ * - GRAFANA_CLOUD=true → GRAFANA_ENDPOINT, GRAFANA_SERVICE_NAME, GRAFANA_INSTANCE_ID,
810
+ * and GRAFANA_API_KEY are all required
811
+ * - Default (tunnel) → GRAFANA_ENDPOINT and GRAFANA_SERVICE_NAME are required;
812
+ * no credentials needed
813
+ *
814
+ * @param params - Runtime parameters to validate
815
+ * @throws {TelemetryInputError} If required parameters are missing for the selected mode
816
+ *
817
+ * @example Dev mode — all optional
818
+ * ```typescript
819
+ * validator.validateConfiguration({ GRAFANA_DEV: true }); // passes
820
+ * ```
821
+ *
822
+ * @example Grafana Cloud — credentials required
823
+ * ```typescript
824
+ * validator.validateConfiguration({
825
+ * GRAFANA_CLOUD: true,
826
+ * GRAFANA_ENDPOINT: 'https://otlp-gateway-prod-us-east-0.grafana.net/otlp',
827
+ * GRAFANA_SERVICE_NAME: 'my-app',
828
+ * GRAFANA_INSTANCE_ID: '123456',
829
+ * GRAFANA_API_KEY: 'glc_xxx',
830
+ * }); // passes
831
+ * ```
832
+ *
833
+ * @example Tunnel (deployed) mode — endpoint + service name required
834
+ * ```typescript
835
+ * validator.validateConfiguration({
836
+ * GRAFANA_ENDPOINT: 'https://abc123.trycloudflare.com',
837
+ * GRAFANA_SERVICE_NAME: 'my-app',
838
+ * }); // passes
839
+ * ```
840
+ */
841
+ validateConfiguration(params) {
842
+ if (params.GRAFANA_DEV === true) {
843
+ return;
844
+ }
845
+ if (!params.GRAFANA_ENDPOINT) {
846
+ throw new TelemetryInputError(
847
+ "GRAFANA_ENDPOINT is required when GRAFANA_DEV is not true. Provide a reachable OTLP/HTTP collector URL."
848
+ );
849
+ }
850
+ if (!params.GRAFANA_SERVICE_NAME) {
851
+ throw new TelemetryInputError(
852
+ "GRAFANA_SERVICE_NAME is required when GRAFANA_DEV is not true."
853
+ );
854
+ }
855
+ if (params.GRAFANA_CLOUD === true) {
856
+ if (!params.GRAFANA_INSTANCE_ID) {
857
+ throw new TelemetryInputError(
858
+ "GRAFANA_INSTANCE_ID is required when GRAFANA_CLOUD is true."
859
+ );
860
+ }
861
+ if (!params.GRAFANA_API_KEY) {
862
+ throw new TelemetryInputError("GRAFANA_API_KEY is required when GRAFANA_CLOUD is true.");
863
+ }
864
+ }
865
+ }
866
+ };
867
+ __name(_GrafanaTelemetryValidator, "GrafanaTelemetryValidator");
868
+ var GrafanaTelemetryValidator = _GrafanaTelemetryValidator;
869
+
870
+ // src/framework/telemetry/grafana/index.ts
871
+ var import_otel2 = require("@adobe/aio-lib-telemetry/otel");
872
+ var DEFAULT_DEV_URL = "http://localhost:4318";
873
+ var DEFAULT_SERVICE_NAME = "app-builder-app";
874
+ var _GrafanaTelemetry = class _GrafanaTelemetry {
875
+ constructor() {
876
+ this.validator = new GrafanaTelemetryValidator();
877
+ this.successChecker = new SuccessChecker();
878
+ }
879
+ /**
880
+ * Checks if Grafana telemetry can be initialized
881
+ *
882
+ * Returns true when ENABLE_TELEMETRY=true and GRAFANA_TELEMETRY=true.
883
+ *
884
+ * @param params - Runtime parameters to check
885
+ * @returns true if Grafana telemetry is enabled and can be initialized
886
+ *
887
+ * @example
888
+ * ```typescript
889
+ * const telemetry = new GrafanaTelemetry();
890
+ * if (telemetry.canInitialize(params)) {
891
+ * // Grafana is configured, use it
892
+ * } else {
893
+ * // Skip to next provider
894
+ * }
895
+ * ```
896
+ */
897
+ canInitialize(params) {
898
+ return this.validator.isConfigured(params);
899
+ }
900
+ /**
901
+ * Get the OpenTelemetry instrumentation configuration for Grafana
902
+ *
903
+ * Builds and returns the complete instrumentation configuration:
904
+ * - Service name (from GRAFANA_SERVICE_NAME or default)
905
+ * - Preset simple instrumentations
906
+ * - Adobe I/O Runtime resource attributes
907
+ * - OTLP/HTTP exporters (localhost in dev, GRAFANA_ENDPOINT in deployed)
908
+ * - Success/failure detection for actions
909
+ *
910
+ * @returns Complete entrypoint instrumentation configuration
911
+ * @throws {TelemetryInputError} If GRAFANA_ENDPOINT or GRAFANA_SERVICE_NAME is missing in non-dev mode
912
+ */
913
+ getConfig() {
914
+ return {
915
+ ...(0, import_aio_lib_telemetry3.defineTelemetryConfig)((params) => {
916
+ this.validator.validateConfiguration(params);
917
+ const serviceName = params.GRAFANA_DEV === true ? params.GRAFANA_SERVICE_NAME || DEFAULT_SERVICE_NAME : params.GRAFANA_SERVICE_NAME;
918
+ return {
919
+ sdkConfig: {
920
+ serviceName,
921
+ instrumentations: (0, import_aio_lib_telemetry3.getPresetInstrumentations)("simple"),
922
+ resource: (0, import_aio_lib_telemetry3.getAioRuntimeResource)(),
923
+ ...this.buildExportersConfig(params)
924
+ }
925
+ };
926
+ }),
927
+ isSuccessful: this.successChecker.execute.bind(this.successChecker)
928
+ };
929
+ }
930
+ /**
931
+ * Build OTLP/HTTP exporters for traces, metrics, and logs
932
+ *
933
+ * Selects the collector base URL and optional auth header based on mode:
934
+ * - GRAFANA_DEV=true → http://localhost:4318, no auth
935
+ * - GRAFANA_CLOUD=true → GRAFANA_ENDPOINT with Basic auth (instance ID + API key)
936
+ * - Default (tunnel) → GRAFANA_ENDPOINT, no auth
937
+ *
938
+ * All three signal types share the same factory that appends the signal-specific
939
+ * path (/v1/traces, /v1/metrics, /v1/logs) to the base URL.
940
+ *
941
+ * @param params - Runtime parameters
942
+ * @returns Configuration object with traceExporter, metricReaders, logRecordProcessors
943
+ * @private
944
+ */
945
+ buildExportersConfig(params) {
946
+ const exportUrl = (params.GRAFANA_DEV === true ? DEFAULT_DEV_URL : params.GRAFANA_ENDPOINT).replace(/\/$/, "");
947
+ const authHeader = params.GRAFANA_CLOUD === true ? {
948
+ Authorization: `Basic ${Buffer.from(
949
+ `${params.GRAFANA_INSTANCE_ID}:${params.GRAFANA_API_KEY}`
950
+ ).toString("base64")}`
951
+ } : void 0;
952
+ const makeExporterConfig = /* @__PURE__ */ __name((path) => authHeader ? { url: `${exportUrl}/${path}`, headers: authHeader } : { url: `${exportUrl}/${path}` }, "makeExporterConfig");
953
+ return {
954
+ traceExporter: new import_otel2.OTLPTraceExporterProto(makeExporterConfig("v1/traces")),
955
+ metricReaders: [
956
+ new import_otel2.PeriodicExportingMetricReader({
957
+ exporter: new import_otel2.OTLPMetricExporterProto(makeExporterConfig("v1/metrics"))
958
+ })
959
+ ],
960
+ logRecordProcessors: [
961
+ new import_otel2.SimpleLogRecordProcessor(new import_otel2.OTLPLogExporterProto(makeExporterConfig("v1/logs")))
962
+ ]
963
+ };
964
+ }
965
+ /**
966
+ * Initialize telemetry instrumentation for a runtime action
967
+ *
968
+ * Wraps the provided action with OpenTelemetry instrumentation using
969
+ * the Grafana LGTM stack as the backend.
970
+ *
971
+ * @param action - The runtime action function to instrument
972
+ * @returns The instrumented action function with Grafana telemetry enabled
973
+ * @throws {TelemetryInputError} If required configuration is missing
974
+ *
975
+ * @example
976
+ * ```typescript
977
+ * async function myAction(params: Record<string, unknown>) {
978
+ * return { statusCode: 200, body: { success: true } };
979
+ * }
980
+ *
981
+ * const telemetry = new GrafanaTelemetry();
982
+ * export const main = telemetry.initialize(myAction);
983
+ * ```
984
+ */
985
+ initialize(action) {
986
+ return (0, import_aio_lib_telemetry3.instrumentEntrypoint)(action, this.getConfig());
987
+ }
988
+ };
989
+ __name(_GrafanaTelemetry, "GrafanaTelemetry");
990
+ var GrafanaTelemetry = _GrafanaTelemetry;
991
+ var grafana_default = GrafanaTelemetry;
992
+
993
+ // src/framework/telemetry/helpers/log-sanitizer/types.ts
994
+ var EXACT_SENSITIVE_KEYS = /* @__PURE__ */ new Set([
995
+ "authorization",
996
+ "x-api-key",
997
+ "cookie",
998
+ "set-cookie"
999
+ ]);
1000
+ var SENSITIVE_KEY_SUFFIXES = [
1001
+ "_api_key",
1002
+ "_secret",
1003
+ "_token",
1004
+ "_password",
1005
+ "_key",
1006
+ "-token",
1007
+ "-secret",
1008
+ "-key"
1009
+ ];
1010
+
1011
+ // src/framework/telemetry/helpers/log-sanitizer/index.ts
1012
+ var _LogSanitizer = class _LogSanitizer {
1013
+ constructor(additionalSensitiveKeys = /* @__PURE__ */ new Set(), maxDepth = 10) {
1014
+ this.additionalSensitiveKeys = additionalSensitiveKeys;
1015
+ this.maxDepth = maxDepth;
1016
+ }
1017
+ /**
1018
+ * Parses the `SENSITIVE_KEYS` runtime param into a `ReadonlySet<string>`.
1019
+ *
1020
+ * Accepts three forms:
1021
+ * - **Array** — each string element becomes a key (`["my_key", "x-secret"]`)
1022
+ * - **Comma-separated string** — split on `,`, each trimmed segment becomes a key (`"my_key, x-secret"`)
1023
+ * - **Single string** — treated as one key (`"my_key"`)
1024
+ *
1025
+ * Non-string array elements and non-string / non-array values are silently ignored.
1026
+ * All keys are lowercased for case-insensitive matching.
1027
+ *
1028
+ * @param raw - The raw `params.SENSITIVE_KEYS` value
1029
+ * @returns A set of lowercased key strings safe to pass to the constructor
1030
+ */
1031
+ static parseSensitiveKeys(raw) {
1032
+ if (Array.isArray(raw)) {
1033
+ return new Set(
1034
+ raw.filter((v) => typeof v === "string").map((v) => v.trim().toLowerCase()).filter(Boolean)
1035
+ );
1036
+ }
1037
+ if (typeof raw === "string") {
1038
+ return new Set(
1039
+ raw.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean)
1040
+ );
1041
+ }
1042
+ return /* @__PURE__ */ new Set();
1043
+ }
1044
+ /**
1045
+ * Sanitizes `data` and returns a deep copy with sensitive values replaced.
1046
+ *
1047
+ * @param data - The value to sanitize
1048
+ * @returns A sanitized deep copy of `data`
1049
+ */
1050
+ execute(data) {
1051
+ return this.sanitize(data, this.maxDepth);
1052
+ }
1053
+ /**
1054
+ * Returns `true` when `key` should have its value replaced with `"[REDACTED]"`.
1055
+ *
1056
+ * Matches exact keys from {@link EXACT_SENSITIVE_KEYS} and the caller's
1057
+ * `additionalSensitiveKeys`, then falls back to suffix matching via
1058
+ * {@link SENSITIVE_KEY_SUFFIXES}. All comparisons are case-insensitive.
1059
+ *
1060
+ * @param key - Object property name to evaluate
1061
+ */
1062
+ isSensitiveKey(key) {
1063
+ const lower = key.toLowerCase();
1064
+ if (EXACT_SENSITIVE_KEYS.has(lower) || this.additionalSensitiveKeys.has(lower)) {
1065
+ return true;
1066
+ }
1067
+ return SENSITIVE_KEY_SUFFIXES.some((suffix) => lower.endsWith(suffix));
1068
+ }
1069
+ /**
1070
+ * Recursively sanitizes `data` up to `depth` levels deep.
1071
+ *
1072
+ * Arrays are mapped element-by-element; plain objects have each value checked
1073
+ * with {@link isSensitiveKey} and replaced or recursed accordingly. All other
1074
+ * value types (primitives, `null`, `undefined`) are returned unchanged.
1075
+ * When `depth` reaches zero the node is returned as-is to cap recursion.
1076
+ *
1077
+ * @param data - Value to sanitize
1078
+ * @param depth - Remaining recursion budget
1079
+ */
1080
+ sanitize(data, depth) {
1081
+ if (depth === 0 || data === null || data === void 0) {
1082
+ return data;
1083
+ }
1084
+ if (Array.isArray(data)) {
1085
+ return data.map((item) => this.sanitize(item, depth - 1));
1086
+ }
1087
+ if (typeof data === "object") {
1088
+ const sanitized = {};
1089
+ for (const [key, value] of Object.entries(data)) {
1090
+ sanitized[key] = this.isSensitiveKey(key) ? "[REDACTED]" : this.sanitize(value, depth - 1);
1091
+ }
1092
+ return sanitized;
1093
+ }
1094
+ return data;
1095
+ }
1096
+ };
1097
+ __name(_LogSanitizer, "LogSanitizer");
1098
+ var LogSanitizer = _LogSanitizer;
1099
+
771
1100
  // src/framework/telemetry/index.ts
772
1101
  var _Telemetry = class _Telemetry {
773
1102
  /**
@@ -886,7 +1215,7 @@ var _Telemetry = class _Telemetry {
886
1215
  level: this.params?.LOG_LEVEL || "info"
887
1216
  });
888
1217
  if (this.params?.ENABLE_TELEMETRY === true) {
889
- const helpers = (0, import_aio_lib_telemetry3.getInstrumentationHelpers)();
1218
+ const helpers = (0, import_aio_lib_telemetry4.getInstrumentationHelpers)();
890
1219
  baseLogger = helpers.logger;
891
1220
  }
892
1221
  const metadata = {};
@@ -899,38 +1228,24 @@ var _Telemetry = class _Telemetry {
899
1228
  if (actionType && actionType !== "") {
900
1229
  metadata["action.type"] = actionType;
901
1230
  }
1231
+ const logSanitizer = new LogSanitizer(
1232
+ LogSanitizer.parseSensitiveKeys(this.params?.SENSITIVE_KEYS)
1233
+ );
902
1234
  if (Object.keys(metadata).length === 0) {
1235
+ this.logger = baseLogger;
903
1236
  return baseLogger;
904
1237
  }
1238
+ const sanitizeAndMerge = /* @__PURE__ */ __name((message) => {
1239
+ if (typeof message === "object" && message !== null) {
1240
+ return logSanitizer.execute({ ...metadata, ...message });
1241
+ }
1242
+ return message;
1243
+ }, "sanitizeAndMerge");
905
1244
  const wrapper = {
906
- debug: /* @__PURE__ */ __name((message) => {
907
- if (typeof message === "object" && message !== null) {
908
- baseLogger.debug({ ...metadata, ...message });
909
- } else {
910
- baseLogger.debug(message);
911
- }
912
- }, "debug"),
913
- info: /* @__PURE__ */ __name((message) => {
914
- if (typeof message === "object" && message !== null) {
915
- baseLogger.info({ ...metadata, ...message });
916
- } else {
917
- baseLogger.info(message);
918
- }
919
- }, "info"),
920
- warn: /* @__PURE__ */ __name((message) => {
921
- if (typeof message === "object" && message !== null) {
922
- baseLogger.warn({ ...metadata, ...message });
923
- } else {
924
- baseLogger.warn(message);
925
- }
926
- }, "warn"),
927
- error: /* @__PURE__ */ __name((message) => {
928
- if (typeof message === "object" && message !== null) {
929
- baseLogger.error({ ...metadata, ...message });
930
- } else {
931
- baseLogger.error(message);
932
- }
933
- }, "error")
1245
+ debug: /* @__PURE__ */ __name((message) => baseLogger.debug(sanitizeAndMerge(message)), "debug"),
1246
+ info: /* @__PURE__ */ __name((message) => baseLogger.info(sanitizeAndMerge(message)), "info"),
1247
+ warn: /* @__PURE__ */ __name((message) => baseLogger.warn(sanitizeAndMerge(message)), "warn"),
1248
+ error: /* @__PURE__ */ __name((message) => baseLogger.error(sanitizeAndMerge(message)), "error")
934
1249
  };
935
1250
  this.logger = {
936
1251
  ...baseLogger,
@@ -993,7 +1308,7 @@ var _Telemetry = class _Telemetry {
993
1308
  */
994
1309
  getCurrentSpan() {
995
1310
  if (this.params?.ENABLE_TELEMETRY === true) {
996
- const helpers = (0, import_aio_lib_telemetry3.getInstrumentationHelpers)();
1311
+ const helpers = (0, import_aio_lib_telemetry4.getInstrumentationHelpers)();
997
1312
  return helpers?.currentSpan || null;
998
1313
  }
999
1314
  return null;
@@ -1031,7 +1346,7 @@ var _Telemetry = class _Telemetry {
1031
1346
  * ```
1032
1347
  */
1033
1348
  instrument(spanName, fn) {
1034
- return (0, import_aio_lib_telemetry3.instrument)(fn, {
1349
+ return (0, import_aio_lib_telemetry4.instrument)(fn, {
1035
1350
  spanConfig: {
1036
1351
  spanName
1037
1352
  }
@@ -1042,7 +1357,7 @@ var _Telemetry = class _Telemetry {
1042
1357
  *
1043
1358
  * Attempts to initialize telemetry providers in the following order:
1044
1359
  * 1. New Relic (if NEW_RELIC_TELEMETRY=true)
1045
- * 2. Grafana (if GRAFANA_TELEMETRY=true) - Future support
1360
+ * 2. Grafana LGTM (if GRAFANA_TELEMETRY=true)
1046
1361
  * 3. Original action (no telemetry)
1047
1362
  *
1048
1363
  * Telemetry initialization is deferred to runtime when params are available.
@@ -1057,13 +1372,30 @@ var _Telemetry = class _Telemetry {
1057
1372
  * @param action - The runtime action function to instrument
1058
1373
  * @returns The instrumented action ready for export
1059
1374
  *
1060
- * @example
1375
+ * @example New Relic provider
1061
1376
  * ```typescript
1062
1377
  * const telemetry = new Telemetry();
1063
1378
  * export const main = telemetry.initialize(myAction);
1064
1379
  * // Environment: ENABLE_TELEMETRY=true, NEW_RELIC_TELEMETRY=true
1065
1380
  * // Result: Uses New Relic telemetry with full distributed tracing
1066
1381
  * ```
1382
+ *
1383
+ * @example Grafana LGTM provider (dev mode)
1384
+ * ```typescript
1385
+ * const telemetry = new Telemetry();
1386
+ * export const main = telemetry.initialize(myAction);
1387
+ * // Environment: ENABLE_TELEMETRY=true, GRAFANA_TELEMETRY=true, GRAFANA_DEV=true
1388
+ * // Result: Sends all signals to http://localhost:4318 (Grafana LGTM Docker stack)
1389
+ * ```
1390
+ *
1391
+ * @example Grafana LGTM provider (deployed mode)
1392
+ * ```typescript
1393
+ * const telemetry = new Telemetry();
1394
+ * export const main = telemetry.initialize(myAction);
1395
+ * // Environment: ENABLE_TELEMETRY=true, GRAFANA_TELEMETRY=true,
1396
+ * // GRAFANA_ENDPOINT=https://abc123.trycloudflare.com
1397
+ * // Result: Sends all signals to the Cloudflare tunnel URL
1398
+ * ```
1067
1399
  */
1068
1400
  initialize(action) {
1069
1401
  return async (params) => {
@@ -1081,6 +1413,19 @@ var _Telemetry = class _Telemetry {
1081
1413
  );
1082
1414
  }
1083
1415
  }
1416
+ const grafanaTelemetry = new grafana_default();
1417
+ if (grafanaTelemetry.canInitialize(params)) {
1418
+ try {
1419
+ const instrumentedAction = grafanaTelemetry.initialize(action);
1420
+ return await instrumentedAction(params);
1421
+ } catch (error) {
1422
+ const errorMessage = error instanceof Error ? error.message : "Telemetry initialization failed";
1423
+ return response_default.error(
1424
+ 500 /* INTERNAL_ERROR */,
1425
+ `Telemetry configuration error: ${errorMessage}`
1426
+ );
1427
+ }
1428
+ }
1084
1429
  return action(params);
1085
1430
  };
1086
1431
  }
@@ -1191,6 +1536,7 @@ var _RuntimeAction = class _RuntimeAction {
1191
1536
  }
1192
1537
  telemetry.setParams(params);
1193
1538
  const logger = telemetry.createLogger(name);
1539
+ const logSanitizer = new LogSanitizer(LogSanitizer.parseSensitiveKeys(params.SENSITIVE_KEYS));
1194
1540
  try {
1195
1541
  logger.debug({
1196
1542
  message: `${_RuntimeAction.getActionTypeName()} execution started`
@@ -1198,13 +1544,13 @@ var _RuntimeAction = class _RuntimeAction {
1198
1544
  logger.debug(
1199
1545
  JSON.stringify({
1200
1546
  message: `${_RuntimeAction.getActionTypeName()} headers received`,
1201
- headers: params.__ow_headers || {}
1547
+ headers: logSanitizer.execute(params.__ow_headers || {})
1202
1548
  })
1203
1549
  );
1204
1550
  logger.debug(
1205
1551
  JSON.stringify({
1206
1552
  message: `${_RuntimeAction.getActionTypeName()} body received`,
1207
- body: params.__ow_body || {}
1553
+ body: logSanitizer.execute(params.__ow_body || {})
1208
1554
  })
1209
1555
  );
1210
1556
  const validationError = _RuntimeAction.validateRequestWithInstrumentation(
@@ -1230,7 +1576,7 @@ var _RuntimeAction = class _RuntimeAction {
1230
1576
  logger.debug(
1231
1577
  JSON.stringify({
1232
1578
  message: `${_RuntimeAction.getActionTypeName()} execution completed`,
1233
- result
1579
+ result: logSanitizer.execute(result)
1234
1580
  })
1235
1581
  );
1236
1582
  return result;
@@ -1488,17 +1834,18 @@ var _EventConsumerAction = class _EventConsumerAction {
1488
1834
  const eventConsumerAction = /* @__PURE__ */ __name(async (params) => {
1489
1835
  params.action_type = "event-consumer-action";
1490
1836
  const logger = telemetry.createLogger(name);
1837
+ const logSanitizer = new LogSanitizer(LogSanitizer.parseSensitiveKeys(params.SENSITIVE_KEYS));
1491
1838
  try {
1492
1839
  logger.debug({
1493
1840
  message: "Event consumer action execution started"
1494
1841
  });
1495
1842
  logger.debug({
1496
1843
  message: "Event consumer action headers received",
1497
- headers: params.__ow_headers || {}
1844
+ headers: logSanitizer.execute(params.__ow_headers || {})
1498
1845
  });
1499
1846
  logger.debug({
1500
1847
  message: "Event consumer action parameters received",
1501
- parameters: params
1848
+ parameters: logSanitizer.execute(params)
1502
1849
  });
1503
1850
  const errorMessage = _EventConsumerAction.validateWithInstrumentation(
1504
1851
  name,
@@ -1524,7 +1871,7 @@ var _EventConsumerAction = class _EventConsumerAction {
1524
1871
  );
1525
1872
  logger.debug({
1526
1873
  message: "Event consumer action execution completed",
1527
- result
1874
+ result: logSanitizer.execute(result)
1528
1875
  });
1529
1876
  return result;
1530
1877
  } catch (error) {
@@ -2152,13 +2499,14 @@ var _OpenwhiskAction = class _OpenwhiskAction {
2152
2499
  const openwhiskAction = /* @__PURE__ */ __name(async (params) => {
2153
2500
  params.action_type = "openwhisk-action";
2154
2501
  const logger = telemetry.createLogger(name);
2502
+ const logSanitizer = new LogSanitizer(LogSanitizer.parseSensitiveKeys(params.SENSITIVE_KEYS));
2155
2503
  try {
2156
2504
  logger.debug({
2157
2505
  message: "OpenWhisk action execution started"
2158
2506
  });
2159
2507
  logger.debug({
2160
2508
  message: "OpenWhisk action parameters received",
2161
- params
2509
+ params: logSanitizer.execute(params)
2162
2510
  });
2163
2511
  const result = await _OpenwhiskAction.executeActionWithInstrumentation(
2164
2512
  name,
@@ -2170,7 +2518,7 @@ var _OpenwhiskAction = class _OpenwhiskAction {
2170
2518
  );
2171
2519
  logger.debug({
2172
2520
  message: "OpenWhisk action execution completed",
2173
- result
2521
+ result: logSanitizer.execute(result)
2174
2522
  });
2175
2523
  return result;
2176
2524
  } catch (error) {
@@ -13160,6 +13508,7 @@ var AdminUiSdk = _AdminUiSdk;
13160
13508
  InfiniteLoopBreaker,
13161
13509
  IoEventsGlobals,
13162
13510
  JsonMessageProcessor,
13511
+ LogSanitizer,
13163
13512
  Oauth1aConnection,
13164
13513
  OnboardCommerce,
13165
13514
  OnboardEvents,