@djust-b2b/djust-front-sdk 3.0.0 → 3.1.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.
Files changed (45) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/.tsbuildinfo-esm +1 -1
  3. package/dist/index.cjs +12 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.mjs +248 -1
  7. package/dist/monitoring/index.d.ts +7 -0
  8. package/dist/monitoring/index.d.ts.map +1 -0
  9. package/dist/monitoring/observability.d.ts +60 -0
  10. package/dist/monitoring/observability.d.ts.map +1 -0
  11. package/dist/monitoring/sentry.d.ts +72 -0
  12. package/dist/monitoring/sentry.d.ts.map +1 -0
  13. package/dist/monitoring/utils.d.ts +3 -0
  14. package/dist/monitoring/utils.d.ts.map +1 -0
  15. package/dist/monitoring/w3c-trace.d.ts +13 -0
  16. package/dist/monitoring/w3c-trace.d.ts.map +1 -0
  17. package/dist/settings/sdk-version.d.ts +1 -1
  18. package/lib/.tsbuildinfo +1 -1
  19. package/lib/index.d.ts +2 -0
  20. package/lib/index.d.ts.map +1 -1
  21. package/lib/index.js +12 -1
  22. package/lib/index.js.map +1 -1
  23. package/lib/monitoring/index.d.ts +7 -0
  24. package/lib/monitoring/index.d.ts.map +1 -0
  25. package/lib/monitoring/index.js +14 -0
  26. package/lib/monitoring/index.js.map +1 -0
  27. package/lib/monitoring/observability.d.ts +60 -0
  28. package/lib/monitoring/observability.d.ts.map +1 -0
  29. package/lib/monitoring/observability.js +115 -0
  30. package/lib/monitoring/observability.js.map +1 -0
  31. package/lib/monitoring/sentry.d.ts +72 -0
  32. package/lib/monitoring/sentry.d.ts.map +1 -0
  33. package/lib/monitoring/sentry.js +142 -0
  34. package/lib/monitoring/sentry.js.map +1 -0
  35. package/lib/monitoring/utils.d.ts +3 -0
  36. package/lib/monitoring/utils.d.ts.map +1 -0
  37. package/lib/monitoring/utils.js +13 -0
  38. package/lib/monitoring/utils.js.map +1 -0
  39. package/lib/monitoring/w3c-trace.d.ts +13 -0
  40. package/lib/monitoring/w3c-trace.d.ts.map +1 -0
  41. package/lib/monitoring/w3c-trace.js +23 -0
  42. package/lib/monitoring/w3c-trace.js.map +1 -0
  43. package/lib/settings/sdk-version.d.ts +1 -1
  44. package/lib/settings/sdk-version.js +1 -1
  45. package/package.json +6 -1
package/lib/index.d.ts CHANGED
@@ -263,5 +263,7 @@ export { createDjustClient } from "./client";
263
263
  export type { DjustClientConfig, DjustClient, DjustScopedClient, RequestContext, RetryConfig, TransportHooks, } from "./client";
264
264
  export { SDKError, SDKErrorCode, RETRIABLE_ERROR_CODES, RETRIABLE_HTTP_STATUS_CODES, ValidationError, AuthError, ForbiddenError, NotFoundError, RateLimitError, NetworkError, TimeoutError, ServerError, UnexpectedError, createErrorFromResponse, createErrorFromException, isSDKError, isAuthError, isForbiddenError, isNetworkError, isTimeoutError, isServerError, isValidationError, isNotFoundError, isRateLimitError, isUnexpectedError, isRetryable, getRetryDelay, shouldReauthenticate, isClientError, isTransientError, extractStatusCode, extractErrorCode, getUserFriendlyMessage, toLegacyError, fromLegacyError, isLegacyError, parseLegacyError, withLegacyErrors, withStructuredErrors, isApiError, getHttpStatus, } from "./errors";
265
265
  export type { SDKErrorCodeType, SDKErrorOptions, RequestMetadata, ErrorFactoryOptions, SerializedError, ClientSafeError, } from "./errors";
266
+ export { buildDjustSentryTags, captureDjustError, createDjustSentryHooks, buildDjustErrorEvent, createDjustErrorHooks, mergeTransportHooks, getW3CTraceFromHeaders, } from "./monitoring";
267
+ export type { DjustErrorCaptureContext, DjustSentryMonitoringOptions, SentryLike, SentryScope, DjustErrorEvent, DjustErrorHooksOptions, DjustErrorListener, DjustMonitoringTier, W3CTraceFields, } from "./monitoring";
266
268
  export * from "./interfaces";
267
269
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.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AM,UAAU,CAAC;AAElB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,eAAe,GAChB,MAAM,UAAU,CAAC;AAMlB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EACV,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,cAAc,CAAC;AAMtB,cAAc,cAAc,CAAC"}
package/lib/index.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @packageDocumentation
25
25
  */
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.getHttpStatus = exports.isApiError = exports.withStructuredErrors = exports.withLegacyErrors = exports.parseLegacyError = exports.isLegacyError = exports.fromLegacyError = exports.toLegacyError = exports.getUserFriendlyMessage = exports.extractErrorCode = exports.extractStatusCode = exports.isTransientError = exports.isClientError = exports.shouldReauthenticate = exports.getRetryDelay = exports.isRetryable = exports.isUnexpectedError = exports.isRateLimitError = exports.isNotFoundError = exports.isValidationError = exports.isServerError = exports.isTimeoutError = exports.isNetworkError = exports.isForbiddenError = exports.isAuthError = exports.isSDKError = exports.createErrorFromException = exports.createErrorFromResponse = exports.UnexpectedError = exports.ServerError = exports.TimeoutError = exports.NetworkError = exports.RateLimitError = exports.NotFoundError = exports.ForbiddenError = exports.AuthError = exports.ValidationError = exports.RETRIABLE_HTTP_STATUS_CODES = exports.RETRIABLE_ERROR_CODES = exports.SDKErrorCode = exports.SDKError = exports.createDjustClient = exports.DjustSDK = void 0;
27
+ exports.getW3CTraceFromHeaders = exports.mergeTransportHooks = exports.createDjustErrorHooks = exports.buildDjustErrorEvent = exports.createDjustSentryHooks = exports.captureDjustError = exports.buildDjustSentryTags = exports.getHttpStatus = exports.isApiError = exports.withStructuredErrors = exports.withLegacyErrors = exports.parseLegacyError = exports.isLegacyError = exports.fromLegacyError = exports.toLegacyError = exports.getUserFriendlyMessage = exports.extractErrorCode = exports.extractStatusCode = exports.isTransientError = exports.isClientError = exports.shouldReauthenticate = exports.getRetryDelay = exports.isRetryable = exports.isUnexpectedError = exports.isRateLimitError = exports.isNotFoundError = exports.isValidationError = exports.isServerError = exports.isTimeoutError = exports.isNetworkError = exports.isForbiddenError = exports.isAuthError = exports.isSDKError = exports.createErrorFromException = exports.createErrorFromResponse = exports.UnexpectedError = exports.ServerError = exports.TimeoutError = exports.NetworkError = exports.RateLimitError = exports.NotFoundError = exports.ForbiddenError = exports.AuthError = exports.ValidationError = exports.RETRIABLE_HTTP_STATUS_CODES = exports.RETRIABLE_ERROR_CODES = exports.SDKErrorCode = exports.SDKError = exports.createDjustClient = exports.DjustSDK = void 0;
28
28
  const tslib_1 = require("tslib");
29
29
  const AuthServices = tslib_1.__importStar(require("./services/auth"));
30
30
  const CartServices = tslib_1.__importStar(require("./services/cart"));
@@ -176,6 +176,17 @@ Object.defineProperty(exports, "withStructuredErrors", { enumerable: true, get:
176
176
  Object.defineProperty(exports, "isApiError", { enumerable: true, get: function () { return errors_1.isApiError; } });
177
177
  Object.defineProperty(exports, "getHttpStatus", { enumerable: true, get: function () { return errors_1.getHttpStatus; } });
178
178
  // ============================================================================
179
+ // MONITORING (Sentry helpers — @sentry/node is a host-app peer)
180
+ // ============================================================================
181
+ var monitoring_1 = require("./monitoring");
182
+ Object.defineProperty(exports, "buildDjustSentryTags", { enumerable: true, get: function () { return monitoring_1.buildDjustSentryTags; } });
183
+ Object.defineProperty(exports, "captureDjustError", { enumerable: true, get: function () { return monitoring_1.captureDjustError; } });
184
+ Object.defineProperty(exports, "createDjustSentryHooks", { enumerable: true, get: function () { return monitoring_1.createDjustSentryHooks; } });
185
+ Object.defineProperty(exports, "buildDjustErrorEvent", { enumerable: true, get: function () { return monitoring_1.buildDjustErrorEvent; } });
186
+ Object.defineProperty(exports, "createDjustErrorHooks", { enumerable: true, get: function () { return monitoring_1.createDjustErrorHooks; } });
187
+ Object.defineProperty(exports, "mergeTransportHooks", { enumerable: true, get: function () { return monitoring_1.mergeTransportHooks; } });
188
+ Object.defineProperty(exports, "getW3CTraceFromHeaders", { enumerable: true, get: function () { return monitoring_1.getW3CTraceFromHeaders; } });
189
+ // ============================================================================
179
190
  // INTERFACES (unchanged)
180
191
  // ============================================================================
181
192
  tslib_1.__exportStar(require("./interfaces"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;;AAEH,sEAAgD;AAChD,sEAAgD;AAChD,6FAAuE;AACvE,uFAAiE;AACjE,mGAA6E;AAC7E,4EAAsD;AACtD,2FAAqE;AACrE,wEAAkD;AAClD,8EAAwD;AACxD,6FAAuE;AACvE,yFAAmE;AACnE,8EAAwD;AACxD,oFAA8D;AAC9D,qFAA+D;AAC/D,4EAAsD;AACtD,gFAA0D;AAC1D,8DAA4E;AAE5E,+EAA+E;AAC/E,mCAAmC;AACnC,+EAA+E;AAE/E;;;;;;;;;;;;;;GAcG;AACU,QAAA,QAAQ,GAAG;IACtB,GAAG,YAAY;IACf,GAAG,YAAY;IACf,GAAG,uBAAuB;IAC1B,GAAG,oBAAoB;IACvB,GAAG,0BAA0B;IAC7B,GAAG,eAAe;IAClB,GAAG,sBAAsB;IACzB,GAAG,aAAa;IAChB,GAAG,gBAAgB;IACnB,GAAG,qBAAqB;IACxB,GAAG,uBAAuB;IAC1B,GAAG,gBAAgB;IACnB,GAAG,aAAa;IAChB,GAAG,mBAAmB;IACtB,GAAG,eAAe;IAClB,GAAG,iBAAiB;IACpB;;OAEG;IACH,UAAU,EAAV,2BAAU;IACV;;OAEG;IACH,mBAAmB,EAAnB,oCAAmB;CACpB,CAAC;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AAA,iBAAiB,OAAA;AACjB,oHAAA,sBAAsB,OAAA;AACtB,kHAAA,oBAAoB,OAAA;AACpB,mHAAA,qBAAqB,OAAA;AACrB,iHAAA,mBAAmB,OAAA;AACnB,oHAAA,sBAAsB,OAAA;AAexB,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E,uDAA6B"}
@@ -0,0 +1,7 @@
1
+ export { buildDjustSentryTags, captureDjustError, createDjustSentryHooks, } from "./sentry";
2
+ export { buildDjustErrorEvent, createDjustErrorHooks, mergeTransportHooks, } from "./observability";
3
+ export { getW3CTraceFromHeaders } from "./w3c-trace";
4
+ export type { W3CTraceFields } from "./w3c-trace";
5
+ export type { DjustErrorCaptureContext, DjustSentryMonitoringOptions, SentryLike, SentryScope, } from "./sentry";
6
+ export type { DjustErrorEvent, DjustErrorHooksOptions, DjustErrorListener, DjustMonitoringTier, } from "./observability";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/monitoring/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,YAAY,EACV,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EACV,WAAW,GACZ,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getW3CTraceFromHeaders = exports.mergeTransportHooks = exports.createDjustErrorHooks = exports.buildDjustErrorEvent = exports.createDjustSentryHooks = exports.captureDjustError = exports.buildDjustSentryTags = void 0;
4
+ var sentry_1 = require("./sentry");
5
+ Object.defineProperty(exports, "buildDjustSentryTags", { enumerable: true, get: function () { return sentry_1.buildDjustSentryTags; } });
6
+ Object.defineProperty(exports, "captureDjustError", { enumerable: true, get: function () { return sentry_1.captureDjustError; } });
7
+ Object.defineProperty(exports, "createDjustSentryHooks", { enumerable: true, get: function () { return sentry_1.createDjustSentryHooks; } });
8
+ var observability_1 = require("./observability");
9
+ Object.defineProperty(exports, "buildDjustErrorEvent", { enumerable: true, get: function () { return observability_1.buildDjustErrorEvent; } });
10
+ Object.defineProperty(exports, "createDjustErrorHooks", { enumerable: true, get: function () { return observability_1.createDjustErrorHooks; } });
11
+ Object.defineProperty(exports, "mergeTransportHooks", { enumerable: true, get: function () { return observability_1.mergeTransportHooks; } });
12
+ var w3c_trace_1 = require("./w3c-trace");
13
+ Object.defineProperty(exports, "getW3CTraceFromHeaders", { enumerable: true, get: function () { return w3c_trace_1.getW3CTraceFromHeaders; } });
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/monitoring/index.ts"],"names":[],"mappings":";;;AAAA,mCAIkB;AAHhB,8GAAA,oBAAoB,OAAA;AACpB,2GAAA,iBAAiB,OAAA;AACjB,gHAAA,sBAAsB,OAAA;AAGxB,iDAIyB;AAHvB,qHAAA,oBAAoB,OAAA;AACpB,sHAAA,qBAAqB,OAAA;AACrB,oHAAA,mBAAmB,OAAA;AAGrB,yCAAqD;AAA5C,mHAAA,sBAAsB,OAAA"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Vendor-neutral observability primitives.
3
+ * DJUST Sentry and client monitoring (Sentry, DataDog, …) run in parallel.
4
+ *
5
+ * @module monitoring/observability
6
+ * @since 3.0.1
7
+ */
8
+ import type { TransportHooks } from "../client/transport";
9
+ import type { SerializedError } from "../errors/types";
10
+ import type { DjustErrorCaptureContext } from "./sentry";
11
+ export type DjustMonitoringTier = "djust" | "client";
12
+ export interface DjustErrorEvent {
13
+ /** Normalized error payload — safe for logs and third-party tools */
14
+ code: string;
15
+ httpStatus: number;
16
+ retriable: boolean;
17
+ message: string;
18
+ source: DjustErrorCaptureContext["source"];
19
+ monitoringTier?: DjustMonitoringTier;
20
+ clientId?: string;
21
+ clientName?: string;
22
+ environment?: string;
23
+ /** W3C trace id — aligns with `getSDKTraceFields(event).requestId` */
24
+ traceId?: string;
25
+ traceparent?: string;
26
+ spanId?: string;
27
+ requestId?: string;
28
+ method?: string;
29
+ endpoint?: string;
30
+ bffRoute?: string;
31
+ willRetry?: boolean;
32
+ /** Present when the original error is an SDKError */
33
+ serialized?: SerializedError;
34
+ /** Original error reference (do not send to external tools verbatim) */
35
+ error: unknown;
36
+ }
37
+ export type DjustErrorListener = (event: DjustErrorEvent) => void | Promise<void>;
38
+ export interface DjustErrorHooksOptions {
39
+ clientId?: string;
40
+ clientName?: string;
41
+ environment?: string;
42
+ monitoringTier?: DjustMonitoringTier;
43
+ skipRetryingErrors?: boolean;
44
+ ignoredHttpStatuses?: number[];
45
+ }
46
+ /**
47
+ * Builds a vendor-neutral error event from an SDKError (or legacy error).
48
+ * Use for DataDog, custom loggers, or a client-owned Sentry project.
49
+ */
50
+ export declare function buildDjustErrorEvent(error: unknown, context: DjustErrorCaptureContext): DjustErrorEvent;
51
+ /**
52
+ * Generic transport hooks for any monitoring backend.
53
+ * Compose in parallel with `createDjustSentryHooks` via `mergeTransportHooks`.
54
+ */
55
+ export declare function createDjustErrorHooks(onError: DjustErrorListener, options?: DjustErrorHooksOptions): Pick<TransportHooks, "onError">;
56
+ /**
57
+ * Runs multiple hook sets in parallel — DJUST Sentry + client Sentry + DataDog, etc.
58
+ */
59
+ export declare function mergeTransportHooks(...hookSets: TransportHooks[]): TransportHooks;
60
+ //# sourceMappingURL=observability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAUD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,wBAAwB,GAChC,eAAe,CA4BjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,GAAE,sBAA2B,GACnC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAsCjC;AAYD;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,QAAQ,EAAE,cAAc,EAAE,GAC5B,cAAc,CAuBhB"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ /**
3
+ * Vendor-neutral observability primitives.
4
+ * DJUST Sentry and client monitoring (Sentry, DataDog, …) run in parallel.
5
+ *
6
+ * @module monitoring/observability
7
+ * @since 3.0.1
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.buildDjustErrorEvent = buildDjustErrorEvent;
11
+ exports.createDjustErrorHooks = createDjustErrorHooks;
12
+ exports.mergeTransportHooks = mergeTransportHooks;
13
+ const errors_1 = require("../errors");
14
+ const w3c_trace_1 = require("./w3c-trace");
15
+ const utils_1 = require("./utils");
16
+ function resolveMessage(error) {
17
+ if (error instanceof Error) {
18
+ return error.message;
19
+ }
20
+ return String(error);
21
+ }
22
+ /**
23
+ * Builds a vendor-neutral error event from an SDKError (or legacy error).
24
+ * Use for DataDog, custom loggers, or a client-owned Sentry project.
25
+ */
26
+ function buildDjustErrorEvent(error, context) {
27
+ const sdkError = (0, errors_1.isSDKError)(error) ? error : (0, errors_1.fromLegacyError)(error);
28
+ const endpoint = context.endpoint ??
29
+ ((0, errors_1.isSDKError)(error) ? error.metadata.endpoint : undefined);
30
+ return {
31
+ code: sdkError ? String(sdkError.code) : errors_1.SDKErrorCode.UNEXPECTED_ERROR,
32
+ httpStatus: sdkError?.httpStatus ?? 500,
33
+ retriable: sdkError?.retriable ?? false,
34
+ message: resolveMessage(error),
35
+ source: context.source,
36
+ monitoringTier: context.monitoringTier,
37
+ clientId: context.clientId,
38
+ clientName: context.clientName,
39
+ environment: context.environment,
40
+ traceId: context.traceId ?? context.requestId,
41
+ traceparent: context.traceparent,
42
+ spanId: context.spanId,
43
+ requestId: context.requestId,
44
+ method: context.method,
45
+ endpoint,
46
+ bffRoute: context.bffRoute,
47
+ willRetry: context.willRetry,
48
+ serialized: (0, errors_1.isSDKError)(error) ? error.toJSON() : undefined,
49
+ error,
50
+ };
51
+ }
52
+ /**
53
+ * Generic transport hooks for any monitoring backend.
54
+ * Compose in parallel with `createDjustSentryHooks` via `mergeTransportHooks`.
55
+ */
56
+ function createDjustErrorHooks(onError, options = {}) {
57
+ const skipRetrying = options.skipRetryingErrors ?? true;
58
+ const ignoredHttpStatuses = options.ignoredHttpStatuses ?? [];
59
+ return {
60
+ onError(ctx) {
61
+ if (skipRetrying && ctx.willRetry) {
62
+ return;
63
+ }
64
+ const httpStatus = (0, errors_1.isSDKError)(ctx.error)
65
+ ? ctx.error.httpStatus
66
+ : (0, errors_1.fromLegacyError)(ctx.error)?.httpStatus ?? 500;
67
+ if (ignoredHttpStatuses.includes(httpStatus)) {
68
+ return;
69
+ }
70
+ const w3c = (0, w3c_trace_1.getW3CTraceFromHeaders)(ctx.headers);
71
+ const event = buildDjustErrorEvent(ctx.error, {
72
+ source: "sdk",
73
+ monitoringTier: options.monitoringTier,
74
+ clientId: options.clientId,
75
+ clientName: options.clientName,
76
+ environment: options.environment,
77
+ requestId: ctx.requestId,
78
+ traceId: w3c.traceId ?? ctx.requestId,
79
+ traceparent: w3c.traceparent,
80
+ spanId: w3c.spanId,
81
+ method: ctx.method,
82
+ endpoint: (0, utils_1.getEndpoint)(ctx.url),
83
+ willRetry: ctx.willRetry,
84
+ });
85
+ return onError(event);
86
+ },
87
+ };
88
+ }
89
+ const TRANSPORT_HOOK_NAMES = [
90
+ "onRequestStart",
91
+ "onRequestEnd",
92
+ "onError",
93
+ "onRetry",
94
+ "onCacheHit",
95
+ ];
96
+ /**
97
+ * Runs multiple hook sets in parallel — DJUST Sentry + client Sentry + DataDog, etc.
98
+ */
99
+ function mergeTransportHooks(...hookSets) {
100
+ const merged = {};
101
+ for (const hookName of TRANSPORT_HOOK_NAMES) {
102
+ const handlers = hookSets
103
+ .map((set) => set[hookName])
104
+ .filter((handler) => Boolean(handler));
105
+ if (handlers.length === 0) {
106
+ continue;
107
+ }
108
+ const runHandlers = async (ctx) => {
109
+ await Promise.allSettled(handlers.map(async (handler) => handler(ctx)));
110
+ };
111
+ Object.assign(merged, { [hookName]: runHandlers });
112
+ }
113
+ return merged;
114
+ }
115
+ //# sourceMappingURL=observability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observability.js","sourceRoot":"","sources":["../../src/monitoring/observability.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAkEH,oDA+BC;AAMD,sDAyCC;AAeD,kDAyBC;AAhLD,sCAAsE;AAEtE,2CAAqD;AACrD,mCAAsC;AA2CtC,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;IACvB,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB,CAClC,KAAc,EACd,OAAiC;IAEjC,MAAM,QAAQ,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,wBAAe,EAAC,KAAc,CAAC,CAAC;IAE7E,MAAM,QAAQ,GACZ,OAAO,CAAC,QAAQ;QAChB,CAAC,IAA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EG;AACH,SAAgB,mBAAmB,CACjC,GAAG,QAA0B;IAE7B,MAAM,MAAM,GAAmB,EAAE,CAAC;IAElC,KAAK,MAAM,QAAQ,IAAI,oBAAoB,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,QAAQ;aACtB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aAC3B,MAAM,CAAC,CAAC,OAAO,EAA0C,EAAE,CAC1D,OAAO,CAAC,OAAO,CAAC,CACjB,CAAC;QAEJ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,SAAS;QACX,CAAC;QAED,MAAM,WAAW,GAAG,KAAK,EAAE,GAAY,EAAE,EAAE;YACzC,MAAM,OAAO,CAAC,UAAU,CACtB,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAY,CAAC,CAAC,CACvD,CAAC;QACJ,CAAC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Sentry helpers for DJUST SDK and Auth BFF monitoring.
3
+ * Uses a minimal interface so @sentry/node stays a host-app peer dependency.
4
+ *
5
+ * @module monitoring/sentry
6
+ * @since 3.0.1
7
+ */
8
+ import type { TransportHooks } from "../client/transport";
9
+ export interface SentryScope {
10
+ setTag(key: string, value: string): void;
11
+ setContext(name: string, context: Record<string, unknown> | null): void;
12
+ captureException(exception: unknown): string;
13
+ }
14
+ export interface SentryLike {
15
+ withScope(callback: (scope: SentryScope) => void): void;
16
+ addBreadcrumb(breadcrumb: {
17
+ category?: string;
18
+ message?: string;
19
+ level?: "debug" | "info" | "warning" | "error" | "fatal";
20
+ data?: Record<string, unknown>;
21
+ }): void;
22
+ }
23
+ export interface DjustErrorCaptureContext {
24
+ /** `sdk` for commerce API calls, `auth` for Auth BFF routes */
25
+ source: "sdk" | "auth";
26
+ /** `djust` = DJUST org Sentry; `client` = portal-owned monitoring */
27
+ monitoringTier?: "djust" | "client";
28
+ clientId?: string;
29
+ clientName?: string;
30
+ environment?: string;
31
+ /** W3C trace id (same as `requestId` when `getSDKTraceFields` is wired) */
32
+ traceId?: string;
33
+ /** W3C `traceparent` header propagated to the Ecom API */
34
+ traceparent?: string;
35
+ /** W3C parent span id for the current SSR request */
36
+ spanId?: string;
37
+ requestId?: string;
38
+ method?: string;
39
+ /** Backend API path (from SDKError.metadata.endpoint) */
40
+ endpoint?: string;
41
+ /** BFF route, e.g. `POST /api/auth/login` */
42
+ bffRoute?: string;
43
+ willRetry?: boolean;
44
+ }
45
+ export interface DjustSentryMonitoringOptions {
46
+ clientId?: string;
47
+ clientName?: string;
48
+ environment?: string;
49
+ /** Defaults to `djust` — set `client` for a portal-owned Sentry project */
50
+ monitoringTier?: "djust" | "client";
51
+ /** Skip capture while the transport will retry (default: true) */
52
+ skipRetryingErrors?: boolean;
53
+ /** HTTP statuses excluded from capture (e.g. 404, 422) */
54
+ ignoredHttpStatuses?: number[];
55
+ }
56
+ /**
57
+ * Builds stable Sentry tags from an SDKError (or legacy error) and request context.
58
+ * Use the same tags across SDK commerce calls and Auth BFF routes for cross-client dashboards.
59
+ */
60
+ export declare function buildDjustSentryTags(error: unknown, context: DjustErrorCaptureContext): Record<string, string>;
61
+ /**
62
+ * Captures a DJUST error in Sentry with SDKError-aligned tags and context.
63
+ */
64
+ export declare function captureDjustError(sentry: SentryLike, error: unknown, context: DjustErrorCaptureContext, options?: Pick<DjustSentryMonitoringOptions, "ignoredHttpStatuses"> & {
65
+ skipIfRetrying?: boolean;
66
+ }): void;
67
+ /**
68
+ * Creates Transport hooks that report SDK commerce errors to Sentry.
69
+ * Wire in the host `createDjustClient({ hooks: createDjustSentryHooks(Sentry, opts) })`.
70
+ */
71
+ export declare function createDjustSentryHooks(sentry: SentryLike, options?: DjustSentryMonitoringOptions): TransportHooks;
72
+ //# sourceMappingURL=sentry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../src/monitoring/sentry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,qBAAqB,CAAC;AAK7B,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IACxE,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;CAC9C;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,IAAI,CAAC;IACxD,aAAa,CAAC,UAAU,EAAE;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;QACzD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAChC,GAAG,IAAI,CAAC;CACV;AAED,MAAM,WAAW,wBAAwB;IACvC,+DAA+D;IAC/D,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,qEAAqE;IACrE,cAAc,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,OAAO,CA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+ * Uses a minimal interface so @sentry/node stays a host-app peer dependency.
5
+ *
6
+ * @module monitoring/sentry
7
+ * @since 3.0.1
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.buildDjustSentryTags = buildDjustSentryTags;
11
+ exports.captureDjustError = captureDjustError;
12
+ exports.createDjustSentryHooks = createDjustSentryHooks;
13
+ const errors_1 = require("../errors");
14
+ const w3c_trace_1 = require("./w3c-trace");
15
+ const utils_1 = require("./utils");
16
+ function resolveErrorCode(error) {
17
+ if ((0, errors_1.isSDKError)(error)) {
18
+ return String(error.code);
19
+ }
20
+ const legacy = (0, errors_1.fromLegacyError)(error);
21
+ return legacy ? String(legacy.code) : errors_1.SDKErrorCode.UNEXPECTED_ERROR;
22
+ }
23
+ function resolveHttpStatus(error) {
24
+ if ((0, errors_1.isSDKError)(error)) {
25
+ return error.httpStatus;
26
+ }
27
+ const legacy = (0, errors_1.fromLegacyError)(error);
28
+ return legacy?.httpStatus ?? 500;
29
+ }
30
+ /**
31
+ * Builds stable Sentry tags from an SDKError (or legacy error) and request context.
32
+ * Use the same tags across SDK commerce calls and Auth BFF routes for cross-client dashboards.
33
+ */
34
+ function buildDjustSentryTags(error, context) {
35
+ const tags = {
36
+ "djust.source": context.source,
37
+ "djust.error_code": resolveErrorCode(error),
38
+ "djust.http_status": String(resolveHttpStatus(error)),
39
+ "djust.retriable": String((0, errors_1.isSDKError)(error) ? error.retriable : false),
40
+ };
41
+ if (context.clientId)
42
+ tags["djust.client_id"] = context.clientId;
43
+ if (context.clientName)
44
+ tags["djust.client_name"] = context.clientName;
45
+ if (context.environment)
46
+ tags["djust.env"] = context.environment;
47
+ if (context.requestId)
48
+ tags["djust.request_id"] = context.requestId;
49
+ if (context.traceId)
50
+ tags["djust.trace_id"] = context.traceId;
51
+ if (context.traceparent)
52
+ tags["djust.traceparent"] = context.traceparent;
53
+ if (context.spanId)
54
+ tags["djust.span_id"] = context.spanId;
55
+ if (context.method)
56
+ tags["djust.method"] = context.method;
57
+ if (context.endpoint)
58
+ tags["djust.endpoint"] = context.endpoint;
59
+ if (context.bffRoute)
60
+ tags["djust.bff_route"] = context.bffRoute;
61
+ if (context.monitoringTier) {
62
+ tags["djust.monitoring_tier"] = context.monitoringTier;
63
+ }
64
+ if (context.willRetry !== undefined) {
65
+ tags["djust.will_retry"] = String(context.willRetry);
66
+ }
67
+ return tags;
68
+ }
69
+ /**
70
+ * Captures a DJUST error in Sentry with SDKError-aligned tags and context.
71
+ */
72
+ function captureDjustError(sentry, error, context, options) {
73
+ if (options?.skipIfRetrying && context.willRetry) {
74
+ return;
75
+ }
76
+ const httpStatus = resolveHttpStatus(error);
77
+ const ignored = options?.ignoredHttpStatuses ?? [];
78
+ if (ignored.includes(httpStatus)) {
79
+ return;
80
+ }
81
+ const endpoint = context.endpoint ??
82
+ ((0, errors_1.isSDKError)(error) ? error.metadata.endpoint : undefined);
83
+ const tags = buildDjustSentryTags(error, { ...context, endpoint });
84
+ sentry.withScope((scope) => {
85
+ for (const [key, value] of Object.entries(tags)) {
86
+ scope.setTag(key, value);
87
+ }
88
+ if ((0, errors_1.isSDKError)(error)) {
89
+ scope.setContext("djust_error", error.toJSON());
90
+ }
91
+ if (context.traceparent || context.traceId || context.spanId) {
92
+ scope.setContext("w3c_trace", {
93
+ traceId: context.traceId ?? context.requestId,
94
+ spanId: context.spanId,
95
+ traceparent: context.traceparent,
96
+ });
97
+ }
98
+ scope.captureException(error);
99
+ });
100
+ }
101
+ /**
102
+ * Creates Transport hooks that report SDK commerce errors to Sentry.
103
+ * Wire in the host `createDjustClient({ hooks: createDjustSentryHooks(Sentry, opts) })`.
104
+ */
105
+ function createDjustSentryHooks(sentry, options = {}) {
106
+ const skipRetrying = options.skipRetryingErrors ?? true;
107
+ const ignoredHttpStatuses = options.ignoredHttpStatuses ?? [];
108
+ return {
109
+ onError(ctx) {
110
+ const w3c = (0, w3c_trace_1.getW3CTraceFromHeaders)(ctx.headers);
111
+ captureDjustError(sentry, ctx.error, {
112
+ source: "sdk",
113
+ monitoringTier: options.monitoringTier ?? "djust",
114
+ clientId: options.clientId,
115
+ clientName: options.clientName,
116
+ environment: options.environment,
117
+ requestId: ctx.requestId,
118
+ traceId: w3c.traceId ?? ctx.requestId,
119
+ traceparent: w3c.traceparent,
120
+ spanId: w3c.spanId,
121
+ method: ctx.method,
122
+ endpoint: (0, utils_1.getEndpoint)(ctx.url),
123
+ willRetry: ctx.willRetry,
124
+ }, { skipIfRetrying: skipRetrying, ignoredHttpStatuses });
125
+ },
126
+ onRetry(ctx) {
127
+ sentry.addBreadcrumb({
128
+ category: "djust.retry",
129
+ message: `Retry ${ctx.attempt}/${ctx.maxAttempts} for ${ctx.requestId}`,
130
+ level: "warning",
131
+ data: {
132
+ requestId: ctx.requestId,
133
+ attempt: ctx.attempt,
134
+ delayMs: ctx.delayMs,
135
+ reason: ctx.reason,
136
+ errorCode: resolveErrorCode(ctx.error),
137
+ },
138
+ });
139
+ },
140
+ };
141
+ }
142
+ //# sourceMappingURL=sentry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/monitoring/sentry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAoFH,oDA6BC;AAKD,8CA8CC;AAMD,wDA+CC;AAlND,sCAAsE;AACtE,2CAAqD;AACrD,mCAAsC;AAqDtC,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,IAAA,mBAAU,EAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,wBAAe,EAAC,KAAc,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,qBAAY,CAAC,gBAAgB,CAAC;AACtE,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,IAAA,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C1B,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,SAAS,EAAE,GAAG,CAAC,SAAS;gBACxB,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,SAAS;gBACrC,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,QAAQ,EAAE,IAAA,mBAAW,EAAC,GAAG,CAAC,GAAG,CAAC;gBAC9B,SAAS,EAAE,GAAG,CAAC,SAAS;aACzB,EACD,EAAE,cAAc,EAAE,YAAY,EAAE,mBAAmB,EAAE,CACtD,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAqB;YAC3B,MAAM,CAAC,aAAa,CAAC;gBACnB,QAAQ,EAAE,aAAa;gBACvB,OAAO,EAAE,SAAS,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,WAAW,QAAQ,GAAG,CAAC,SAAS,EAAE;gBACvE,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE;oBACJ,SAAS,EAAE,GAAG,CAAC,SAAS;oBACxB,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,MAAM,EAAE,GAAG,CAAC,MAAM;oBAClB,SAAS,EAAE,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC;iBACvC;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Extracts the pathname from a request URL for monitoring tags. */
2
+ export declare function getEndpoint(url: string): string;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/monitoring/utils.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM/C"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEndpoint = getEndpoint;
4
+ /** Extracts the pathname from a request URL for monitoring tags. */
5
+ function getEndpoint(url) {
6
+ try {
7
+ return new URL(url).pathname;
8
+ }
9
+ catch {
10
+ return url;
11
+ }
12
+ }
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/monitoring/utils.ts"],"names":[],"mappings":";;AACA,kCAMC;AAPD,oEAAoE;AACpE,SAAgB,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * W3C Trace Context fields ([trace-context](https://www.w3.org/TR/trace-context/)).
3
+ */
4
+ export interface W3CTraceFields {
5
+ traceparent?: string;
6
+ traceId?: string;
7
+ spanId?: string;
8
+ }
9
+ /**
10
+ * Parses W3C `traceparent` from outbound SDK request headers.
11
+ */
12
+ export declare function getW3CTraceFromHeaders(headers: Record<string, string>): W3CTraceFields;
13
+ //# sourceMappingURL=w3c-trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"w3c-trace.d.ts","sourceRoot":"","sources":["../../src/monitoring/w3c-trace.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,cAAc,CAoBhB"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getW3CTraceFromHeaders = getW3CTraceFromHeaders;
4
+ /**
5
+ * Parses W3C `traceparent` from outbound SDK request headers.
6
+ */
7
+ function getW3CTraceFromHeaders(headers) {
8
+ const traceparent = headers.traceparent ?? headers.Traceparent;
9
+ if (!traceparent) {
10
+ return {};
11
+ }
12
+ const parts = traceparent.trim().split("-");
13
+ if (parts.length !== 4 || parts[0] !== "00") {
14
+ return { traceparent };
15
+ }
16
+ const [, traceId, spanId] = parts;
17
+ const isHex = (value, length) => value.length === length && /^[0-9a-f]+$/i.test(value);
18
+ if (!isHex(traceId, 32) || !isHex(spanId, 16)) {
19
+ return { traceparent };
20
+ }
21
+ return { traceparent, traceId, spanId };
22
+ }
23
+ //# sourceMappingURL=w3c-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"w3c-trace.js","sourceRoot":"","sources":["../../src/monitoring/w3c-trace.ts"],"names":[],"mappings":";;AAYA,wDAsBC;AAzBD;;GAEG;AACH,SAAgB,sBAAsB,CACpC,OAA+B;IAE/B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAC/D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO,EAAE,WAAW,EAAE,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;IAClC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,MAAc,EAAE,EAAE,CAC9C,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAExD,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAC9C,OAAO,EAAE,WAAW,EAAE,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC"}
@@ -1,3 +1,3 @@
1
1
  /** Auto-generated by scripts/sync-sdk-version.js — do not edit */
2
- export declare const SDK_VERSION = "3.0.0";
2
+ export declare const SDK_VERSION = "3.1.0";
3
3
  //# sourceMappingURL=sdk-version.d.ts.map
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
4
  /** Auto-generated by scripts/sync-sdk-version.js — do not edit */
5
- exports.SDK_VERSION = "3.0.0";
5
+ exports.SDK_VERSION = "3.1.0";
6
6
  //# sourceMappingURL=sdk-version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "DJUST Front SDK - Universal TypeScript SDK for DJUST B2B API. SSR-safe, type-safe, production-ready.",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -49,6 +49,11 @@
49
49
  "semantic-release:debug": "semantic-release --debug",
50
50
  "verify-version": "node scripts/verify-version.js",
51
51
  "preversion": "npm run verify-version",
52
+ "docs:generate": "cd docs && npm install --no-audit --no-fund && npm run generate",
53
+ "docs:validate": "cd docs && npm install --no-audit --no-fund && npm run validate",
54
+ "docs:check-sync": "node scripts/check-docs-sync.mjs",
55
+ "docs:sync": "node scripts/check-docs-sync.mjs --write",
56
+ "check-before-commit": "bash scripts/check-before-commit.sh",
52
57
  "commit": "cz",
53
58
  "prepack": "npmignore --auto",
54
59
  "perf:test": "node --expose-gc scripts/perf-test.js"