@webpieces/core-util 0.3.263 → 0.3.264

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 (67) hide show
  1. package/package.json +1 -1
  2. package/src/http/ContextReader.d.ts +37 -0
  3. package/src/http/ContextReader.js +3 -0
  4. package/src/http/ContextReader.js.map +1 -0
  5. package/src/http/HeaderMethods.d.ts +71 -0
  6. package/src/http/HeaderMethods.js +124 -0
  7. package/src/http/HeaderMethods.js.map +1 -0
  8. package/src/http/HeaderRegistry.d.ts +58 -0
  9. package/src/http/HeaderRegistry.js +121 -0
  10. package/src/http/HeaderRegistry.js.map +1 -0
  11. package/src/http/HeaderTypes.d.ts +29 -0
  12. package/src/http/HeaderTypes.js +33 -0
  13. package/src/http/HeaderTypes.js.map +1 -0
  14. package/src/http/LogApiCall.d.ts +41 -0
  15. package/src/http/LogApiCall.js +83 -0
  16. package/src/http/LogApiCall.js.map +1 -0
  17. package/src/http/PlatformHeader.d.ts +51 -0
  18. package/src/http/PlatformHeader.js +63 -0
  19. package/src/http/PlatformHeader.js.map +1 -0
  20. package/src/http/PlatformHeadersExtension.d.ts +51 -0
  21. package/src/http/PlatformHeadersExtension.js +59 -0
  22. package/src/http/PlatformHeadersExtension.js.map +1 -0
  23. package/src/http/WebpiecesCoreHeaders.d.ts +62 -0
  24. package/src/http/WebpiecesCoreHeaders.js +87 -0
  25. package/src/http/WebpiecesCoreHeaders.js.map +1 -0
  26. package/src/http/datetime.d.ts +284 -0
  27. package/src/http/datetime.js +270 -0
  28. package/src/http/datetime.js.map +1 -0
  29. package/src/http/decorators.d.ts +212 -0
  30. package/src/http/decorators.js +365 -0
  31. package/src/http/decorators.js.map +1 -0
  32. package/src/http/errors.d.ts +118 -0
  33. package/src/http/errors.js +189 -0
  34. package/src/http/errors.js.map +1 -0
  35. package/src/http/recorder/DoNotRecord.d.ts +22 -0
  36. package/src/http/recorder/DoNotRecord.js +39 -0
  37. package/src/http/recorder/DoNotRecord.js.map +1 -0
  38. package/src/http/recorder/RecordSerializer.d.ts +39 -0
  39. package/src/http/recorder/RecordSerializer.js +80 -0
  40. package/src/http/recorder/RecordSerializer.js.map +1 -0
  41. package/src/http/recorder/RecordedEndpoint.d.ts +49 -0
  42. package/src/http/recorder/RecordedEndpoint.js +66 -0
  43. package/src/http/recorder/RecordedEndpoint.js.map +1 -0
  44. package/src/http/recorder/TestCaseRecorder.d.ts +36 -0
  45. package/src/http/recorder/TestCaseRecorder.js +16 -0
  46. package/src/http/recorder/TestCaseRecorder.js.map +1 -0
  47. package/src/http/validators.d.ts +41 -0
  48. package/src/http/validators.js +3 -0
  49. package/src/http/validators.js.map +1 -0
  50. package/src/index.d.ts +22 -0
  51. package/src/index.js +102 -1
  52. package/src/index.js.map +1 -1
  53. package/src/logging/ConsoleLogger.d.ts +25 -0
  54. package/src/logging/ConsoleLogger.js +43 -0
  55. package/src/logging/ConsoleLogger.js.map +1 -0
  56. package/src/logging/ConsoleLoggerFactory.d.ts +13 -0
  57. package/src/logging/ConsoleLoggerFactory.js +24 -0
  58. package/src/logging/ConsoleLoggerFactory.js.map +1 -0
  59. package/src/logging/LogManager.d.ts +36 -0
  60. package/src/logging/LogManager.js +46 -0
  61. package/src/logging/LogManager.js.map +1 -0
  62. package/src/logging/Logger.d.ts +36 -0
  63. package/src/logging/Logger.js +3 -0
  64. package/src/logging/Logger.js.map +1 -0
  65. package/src/logging/LoggerFactory.d.ts +16 -0
  66. package/src/logging/LoggerFactory.js +3 -0
  67. package/src/logging/LoggerFactory.js.map +1 -0
@@ -0,0 +1,36 @@
1
+ import { ContextKey } from '../../ContextKey';
2
+ import { RecordedEndpoint } from './RecordedEndpoint';
3
+ /**
4
+ * TestCaseRecorder - Records every api call made while serving one inbound
5
+ * request (port of Java TestCaseRecorder).
6
+ *
7
+ * The recorder travels in the request's magic context under
8
+ * RecorderKeys.RECORDER (Java: Context RECORDER_KEY). Downstream hooks -
9
+ * the HTTP client proxy and recordable() in-process wrappers - check the
10
+ * context and record into it when present.
11
+ *
12
+ * The contract lives in http-api (browser-safe, no Node imports) so the
13
+ * http-client can reference it; the implementation (TestCaseRecorderImpl)
14
+ * lives in http-server.
15
+ */
16
+ export interface TestCaseRecorder {
17
+ /**
18
+ * Record one downstream api call (outbound HTTP or in-process recordable).
19
+ */
20
+ addEndpointInfo(info: RecordedEndpoint): void;
21
+ /**
22
+ * The most recently recorded downstream call (for hooks that fill in the
23
+ * response after the call completes).
24
+ */
25
+ getLastEndpointInfo(): RecordedEndpoint | undefined;
26
+ }
27
+ /**
28
+ * Context keys for the recording subsystem.
29
+ */
30
+ export declare class RecorderKeys {
31
+ /**
32
+ * Key under which the active TestCaseRecorder travels in the request
33
+ * context. Absent = not recording.
34
+ */
35
+ static readonly RECORDER: ContextKey;
36
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecorderKeys = void 0;
4
+ const ContextKey_1 = require("../../ContextKey");
5
+ /**
6
+ * Context keys for the recording subsystem.
7
+ */
8
+ class RecorderKeys {
9
+ /**
10
+ * Key under which the active TestCaseRecorder travels in the request
11
+ * context. Absent = not recording.
12
+ */
13
+ static RECORDER = new ContextKey_1.ContextKey('webpieces-recorder');
14
+ }
15
+ exports.RecorderKeys = RecorderKeys;
16
+ //# sourceMappingURL=TestCaseRecorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestCaseRecorder.js","sourceRoot":"","sources":["../../../../../../../packages/core/core-util/src/http/recorder/TestCaseRecorder.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AA6B9C;;GAEG;AACH,MAAa,YAAY;IACrB;;;OAGG;IACH,MAAM,CAAU,QAAQ,GAAG,IAAI,uBAAU,CAAC,oBAAoB,CAAC,CAAC;;AALpE,oCAMC","sourcesContent":["import { ContextKey } from '../../ContextKey';\nimport { RecordedEndpoint } from './RecordedEndpoint';\n\n/**\n * TestCaseRecorder - Records every api call made while serving one inbound\n * request (port of Java TestCaseRecorder).\n *\n * The recorder travels in the request's magic context under\n * RecorderKeys.RECORDER (Java: Context RECORDER_KEY). Downstream hooks -\n * the HTTP client proxy and recordable() in-process wrappers - check the\n * context and record into it when present.\n *\n * The contract lives in http-api (browser-safe, no Node imports) so the\n * http-client can reference it; the implementation (TestCaseRecorderImpl)\n * lives in http-server.\n */\nexport interface TestCaseRecorder {\n /**\n * Record one downstream api call (outbound HTTP or in-process recordable).\n */\n addEndpointInfo(info: RecordedEndpoint): void;\n\n /**\n * The most recently recorded downstream call (for hooks that fill in the\n * response after the call completes).\n */\n getLastEndpointInfo(): RecordedEndpoint | undefined;\n}\n\n/**\n * Context keys for the recording subsystem.\n */\nexport class RecorderKeys {\n /**\n * Key under which the active TestCaseRecorder travels in the request\n * context. Absent = not recording.\n */\n static readonly RECORDER = new ContextKey('webpieces-recorder');\n}\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Type-level validator to ensure a class implements all methods from an interface.
3
+ *
4
+ * This validator provides compile-time verification that an implementation
5
+ * (e.g., controller, client, mock) fully implements an API interface.
6
+ *
7
+ * Usage in server-side controllers:
8
+ * ```typescript
9
+ * export class SaveController extends SaveApi implements SaveApi {
10
+ * // Compile-time check: ensures all SaveApi methods are implemented
11
+ * private readonly __validator!: ValidateImplementation<SaveController, SaveApi>;
12
+ *
13
+ * save(request: SaveRequest): Promise<SaveResponse> {
14
+ * // implementation
15
+ * }
16
+ * }
17
+ * ```
18
+ *
19
+ * Usage in client-side implementations:
20
+ * ```typescript
21
+ * export class MockSaveClient implements SaveApi {
22
+ * private readonly __validator!: ValidateImplementation<MockSaveClient, SaveApi>;
23
+ *
24
+ * save(request: SaveRequest): Promise<SaveResponse> {
25
+ * // mock implementation
26
+ * }
27
+ * }
28
+ * ```
29
+ *
30
+ * Benefits:
31
+ * - Compile error if any interface method is missing
32
+ * - Compile error if method signatures don't match
33
+ * - Works with controllers, clients, mocks, stubs, etc.
34
+ * - Type-safe contract enforcement
35
+ *
36
+ * Note: The `!` assertion is safe because this field is never accessed at runtime.
37
+ * It only exists for compile-time type checking.
38
+ */
39
+ export type ValidateImplementation<TImpl, TInterface> = {
40
+ [K in keyof TInterface]: K extends keyof TImpl ? TImpl[K] extends TInterface[K] ? TInterface[K] : never : never;
41
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/http/validators.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Type-level validator to ensure a class implements all methods from an interface.\n *\n * This validator provides compile-time verification that an implementation\n * (e.g., controller, client, mock) fully implements an API interface.\n *\n * Usage in server-side controllers:\n * ```typescript\n * export class SaveController extends SaveApi implements SaveApi {\n * // Compile-time check: ensures all SaveApi methods are implemented\n * private readonly __validator!: ValidateImplementation<SaveController, SaveApi>;\n *\n * save(request: SaveRequest): Promise<SaveResponse> {\n * // implementation\n * }\n * }\n * ```\n *\n * Usage in client-side implementations:\n * ```typescript\n * export class MockSaveClient implements SaveApi {\n * private readonly __validator!: ValidateImplementation<MockSaveClient, SaveApi>;\n *\n * save(request: SaveRequest): Promise<SaveResponse> {\n * // mock implementation\n * }\n * }\n * ```\n *\n * Benefits:\n * - Compile error if any interface method is missing\n * - Compile error if method signatures don't match\n * - Works with controllers, clients, mocks, stubs, etc.\n * - Type-safe contract enforcement\n *\n * Note: The `!` assertion is safe because this field is never accessed at runtime.\n * It only exists for compile-time type checking.\n */\nexport type ValidateImplementation<TImpl, TInterface> = {\n [K in keyof TInterface]: K extends keyof TImpl\n ? TImpl[K] extends TInterface[K]\n ? TInterface[K]\n : never\n : never;\n};\n"]}
package/src/index.d.ts CHANGED
@@ -9,3 +9,25 @@
9
9
  export { toError } from './lib/errorUtils';
10
10
  export { Header } from './Header';
11
11
  export { ContextKey } from './ContextKey';
12
+ export type { Logger, LogLevel } from './logging/Logger';
13
+ export type { LoggerFactory } from './logging/LoggerFactory';
14
+ export { ConsoleLogger } from './logging/ConsoleLogger';
15
+ export { ConsoleLoggerFactory } from './logging/ConsoleLoggerFactory';
16
+ export { LogManager } from './logging/LogManager';
17
+ export { ApiPath, Endpoint, Authentication, AuthenticationConfig, Public, AuthJwt, AuthOidc, AuthSharedSecret, Rpc, PubSub, Queue, getApiPath, getEndpoints, isApiPath, getAuthMeta, getAuthMode, assertEveryEndpointHasAuthMode, getApiKind, assertApiKind, assertPubSubConventions, getQueueName, validateNoConflictingDecorators, AuthMeta, RouteMetadata, METADATA_KEYS, } from './http/decorators';
18
+ export type { AuthMode, ApiKind } from './http/decorators';
19
+ export { ValidateImplementation } from './http/validators';
20
+ export { ProtocolError, HttpError, HttpNotFoundError, EndpointNotFoundError, HttpBadRequestError, HttpUnauthorizedError, HttpForbiddenError, HttpTimeoutError, HttpBadGatewayError, HttpGatewayTimeoutError, HttpInternalServerError, HttpVendorError, HttpUserError, ENTITY_NOT_FOUND, WRONG_LOGIN_TYPE, WRONG_LOGIN, NOT_APPROVED, EMAIL_NOT_CONFIRMED, WRONG_DOMAIN, WRONG_COMPANY, NO_REG_CODE, } from './http/errors';
21
+ export { InstantDto, DateDto, TimeDto, DateTimeDto, InstantUtil, DateUtil, TimeUtil, DateTimeUtil, } from './http/datetime';
22
+ export { PlatformHeader } from './http/PlatformHeader';
23
+ export { PlatformHeadersExtension } from './http/PlatformHeadersExtension';
24
+ export { HeaderRegistry } from './http/HeaderRegistry';
25
+ export { WebpiecesCoreHeaders } from './http/WebpiecesCoreHeaders';
26
+ export { HeaderMethods } from './http/HeaderMethods';
27
+ export { ContextReader } from './http/ContextReader';
28
+ export { HEADER_TYPES } from './http/HeaderTypes';
29
+ export { LogApiCall } from './http/LogApiCall';
30
+ export { TestCaseRecorder, RecorderKeys } from './http/recorder/TestCaseRecorder';
31
+ export { RecordedEndpoint, RecordedError, RecordedTestCase } from './http/recorder/RecordedEndpoint';
32
+ export { DoNotRecord, getDoNotRecordFields } from './http/recorder/DoNotRecord';
33
+ export { RecordSerializer, SerializedMap, SerializedError } from './http/recorder/RecordSerializer';
package/src/index.js CHANGED
@@ -8,9 +8,110 @@
8
8
  * @packageDocumentation
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ContextKey = exports.toError = void 0;
11
+ exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.HttpUserError = exports.HttpVendorError = exports.HttpInternalServerError = exports.HttpGatewayTimeoutError = exports.HttpBadGatewayError = exports.HttpTimeoutError = exports.HttpForbiddenError = exports.HttpUnauthorizedError = exports.HttpBadRequestError = exports.EndpointNotFoundError = exports.HttpNotFoundError = exports.HttpError = exports.ProtocolError = exports.METADATA_KEYS = exports.RouteMetadata = exports.AuthMeta = exports.validateNoConflictingDecorators = exports.getQueueName = exports.assertPubSubConventions = exports.assertApiKind = exports.getApiKind = exports.assertEveryEndpointHasAuthMode = exports.getAuthMode = exports.getAuthMeta = exports.isApiPath = exports.getEndpoints = exports.getApiPath = exports.Queue = exports.PubSub = exports.Rpc = exports.AuthSharedSecret = exports.AuthOidc = exports.AuthJwt = exports.Public = exports.AuthenticationConfig = exports.Authentication = exports.Endpoint = exports.ApiPath = exports.LogManager = exports.ConsoleLoggerFactory = exports.ConsoleLogger = exports.ContextKey = exports.toError = void 0;
12
+ exports.SerializedError = exports.SerializedMap = exports.RecordSerializer = exports.getDoNotRecordFields = exports.DoNotRecord = exports.RecordedTestCase = exports.RecordedError = exports.RecordedEndpoint = exports.RecorderKeys = exports.LogApiCall = exports.HEADER_TYPES = exports.HeaderMethods = exports.WebpiecesCoreHeaders = exports.HeaderRegistry = exports.PlatformHeadersExtension = exports.PlatformHeader = exports.DateTimeUtil = exports.TimeUtil = exports.DateUtil = exports.InstantUtil = exports.NO_REG_CODE = void 0;
12
13
  var errorUtils_1 = require("./lib/errorUtils");
13
14
  Object.defineProperty(exports, "toError", { enumerable: true, get: function () { return errorUtils_1.toError; } });
14
15
  var ContextKey_1 = require("./ContextKey");
15
16
  Object.defineProperty(exports, "ContextKey", { enumerable: true, get: function () { return ContextKey_1.ContextKey; } });
17
+ var ConsoleLogger_1 = require("./logging/ConsoleLogger");
18
+ Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return ConsoleLogger_1.ConsoleLogger; } });
19
+ var ConsoleLoggerFactory_1 = require("./logging/ConsoleLoggerFactory");
20
+ Object.defineProperty(exports, "ConsoleLoggerFactory", { enumerable: true, get: function () { return ConsoleLoggerFactory_1.ConsoleLoggerFactory; } });
21
+ var LogManager_1 = require("./logging/LogManager");
22
+ Object.defineProperty(exports, "LogManager", { enumerable: true, get: function () { return LogManager_1.LogManager; } });
23
+ // HTTP API contract (merged from former @webpieces/http-api).
24
+ // Shared HTTP API definition consumed by both client and server: REST
25
+ // decorators, the HttpError hierarchy, datetime DTOs, platform-header
26
+ // registry/readers, ValidateImplementation, and the test-case recorder
27
+ // contract. Pure definitions — express-free, browser + Node safe.
28
+ // API definition decorators
29
+ var decorators_1 = require("./http/decorators");
30
+ Object.defineProperty(exports, "ApiPath", { enumerable: true, get: function () { return decorators_1.ApiPath; } });
31
+ Object.defineProperty(exports, "Endpoint", { enumerable: true, get: function () { return decorators_1.Endpoint; } });
32
+ Object.defineProperty(exports, "Authentication", { enumerable: true, get: function () { return decorators_1.Authentication; } });
33
+ Object.defineProperty(exports, "AuthenticationConfig", { enumerable: true, get: function () { return decorators_1.AuthenticationConfig; } });
34
+ // Auth mode decorators (clean service-to-service + user JWT model)
35
+ Object.defineProperty(exports, "Public", { enumerable: true, get: function () { return decorators_1.Public; } });
36
+ Object.defineProperty(exports, "AuthJwt", { enumerable: true, get: function () { return decorators_1.AuthJwt; } });
37
+ Object.defineProperty(exports, "AuthOidc", { enumerable: true, get: function () { return decorators_1.AuthOidc; } });
38
+ Object.defineProperty(exports, "AuthSharedSecret", { enumerable: true, get: function () { return decorators_1.AuthSharedSecret; } });
39
+ // API kind (RPC vs PubSub/Cloud Tasks) + queue naming
40
+ Object.defineProperty(exports, "Rpc", { enumerable: true, get: function () { return decorators_1.Rpc; } });
41
+ Object.defineProperty(exports, "PubSub", { enumerable: true, get: function () { return decorators_1.PubSub; } });
42
+ Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return decorators_1.Queue; } });
43
+ Object.defineProperty(exports, "getApiPath", { enumerable: true, get: function () { return decorators_1.getApiPath; } });
44
+ Object.defineProperty(exports, "getEndpoints", { enumerable: true, get: function () { return decorators_1.getEndpoints; } });
45
+ Object.defineProperty(exports, "isApiPath", { enumerable: true, get: function () { return decorators_1.isApiPath; } });
46
+ Object.defineProperty(exports, "getAuthMeta", { enumerable: true, get: function () { return decorators_1.getAuthMeta; } });
47
+ Object.defineProperty(exports, "getAuthMode", { enumerable: true, get: function () { return decorators_1.getAuthMode; } });
48
+ Object.defineProperty(exports, "assertEveryEndpointHasAuthMode", { enumerable: true, get: function () { return decorators_1.assertEveryEndpointHasAuthMode; } });
49
+ Object.defineProperty(exports, "getApiKind", { enumerable: true, get: function () { return decorators_1.getApiKind; } });
50
+ Object.defineProperty(exports, "assertApiKind", { enumerable: true, get: function () { return decorators_1.assertApiKind; } });
51
+ Object.defineProperty(exports, "assertPubSubConventions", { enumerable: true, get: function () { return decorators_1.assertPubSubConventions; } });
52
+ Object.defineProperty(exports, "getQueueName", { enumerable: true, get: function () { return decorators_1.getQueueName; } });
53
+ Object.defineProperty(exports, "validateNoConflictingDecorators", { enumerable: true, get: function () { return decorators_1.validateNoConflictingDecorators; } });
54
+ Object.defineProperty(exports, "AuthMeta", { enumerable: true, get: function () { return decorators_1.AuthMeta; } });
55
+ Object.defineProperty(exports, "RouteMetadata", { enumerable: true, get: function () { return decorators_1.RouteMetadata; } });
56
+ Object.defineProperty(exports, "METADATA_KEYS", { enumerable: true, get: function () { return decorators_1.METADATA_KEYS; } });
57
+ // HTTP errors
58
+ var errors_1 = require("./http/errors");
59
+ Object.defineProperty(exports, "ProtocolError", { enumerable: true, get: function () { return errors_1.ProtocolError; } });
60
+ Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_1.HttpError; } });
61
+ Object.defineProperty(exports, "HttpNotFoundError", { enumerable: true, get: function () { return errors_1.HttpNotFoundError; } });
62
+ Object.defineProperty(exports, "EndpointNotFoundError", { enumerable: true, get: function () { return errors_1.EndpointNotFoundError; } });
63
+ Object.defineProperty(exports, "HttpBadRequestError", { enumerable: true, get: function () { return errors_1.HttpBadRequestError; } });
64
+ Object.defineProperty(exports, "HttpUnauthorizedError", { enumerable: true, get: function () { return errors_1.HttpUnauthorizedError; } });
65
+ Object.defineProperty(exports, "HttpForbiddenError", { enumerable: true, get: function () { return errors_1.HttpForbiddenError; } });
66
+ Object.defineProperty(exports, "HttpTimeoutError", { enumerable: true, get: function () { return errors_1.HttpTimeoutError; } });
67
+ Object.defineProperty(exports, "HttpBadGatewayError", { enumerable: true, get: function () { return errors_1.HttpBadGatewayError; } });
68
+ Object.defineProperty(exports, "HttpGatewayTimeoutError", { enumerable: true, get: function () { return errors_1.HttpGatewayTimeoutError; } });
69
+ Object.defineProperty(exports, "HttpInternalServerError", { enumerable: true, get: function () { return errors_1.HttpInternalServerError; } });
70
+ Object.defineProperty(exports, "HttpVendorError", { enumerable: true, get: function () { return errors_1.HttpVendorError; } });
71
+ Object.defineProperty(exports, "HttpUserError", { enumerable: true, get: function () { return errors_1.HttpUserError; } });
72
+ // Error subtype constants
73
+ Object.defineProperty(exports, "ENTITY_NOT_FOUND", { enumerable: true, get: function () { return errors_1.ENTITY_NOT_FOUND; } });
74
+ Object.defineProperty(exports, "WRONG_LOGIN_TYPE", { enumerable: true, get: function () { return errors_1.WRONG_LOGIN_TYPE; } });
75
+ Object.defineProperty(exports, "WRONG_LOGIN", { enumerable: true, get: function () { return errors_1.WRONG_LOGIN; } });
76
+ Object.defineProperty(exports, "NOT_APPROVED", { enumerable: true, get: function () { return errors_1.NOT_APPROVED; } });
77
+ Object.defineProperty(exports, "EMAIL_NOT_CONFIRMED", { enumerable: true, get: function () { return errors_1.EMAIL_NOT_CONFIRMED; } });
78
+ Object.defineProperty(exports, "WRONG_DOMAIN", { enumerable: true, get: function () { return errors_1.WRONG_DOMAIN; } });
79
+ Object.defineProperty(exports, "WRONG_COMPANY", { enumerable: true, get: function () { return errors_1.WRONG_COMPANY; } });
80
+ Object.defineProperty(exports, "NO_REG_CODE", { enumerable: true, get: function () { return errors_1.NO_REG_CODE; } });
81
+ // Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)
82
+ var datetime_1 = require("./http/datetime");
83
+ Object.defineProperty(exports, "InstantUtil", { enumerable: true, get: function () { return datetime_1.InstantUtil; } });
84
+ Object.defineProperty(exports, "DateUtil", { enumerable: true, get: function () { return datetime_1.DateUtil; } });
85
+ Object.defineProperty(exports, "TimeUtil", { enumerable: true, get: function () { return datetime_1.TimeUtil; } });
86
+ Object.defineProperty(exports, "DateTimeUtil", { enumerable: true, get: function () { return datetime_1.DateTimeUtil; } });
87
+ // Platform Headers
88
+ var PlatformHeader_1 = require("./http/PlatformHeader");
89
+ Object.defineProperty(exports, "PlatformHeader", { enumerable: true, get: function () { return PlatformHeader_1.PlatformHeader; } });
90
+ var PlatformHeadersExtension_1 = require("./http/PlatformHeadersExtension");
91
+ Object.defineProperty(exports, "PlatformHeadersExtension", { enumerable: true, get: function () { return PlatformHeadersExtension_1.PlatformHeadersExtension; } });
92
+ var HeaderRegistry_1 = require("./http/HeaderRegistry");
93
+ Object.defineProperty(exports, "HeaderRegistry", { enumerable: true, get: function () { return HeaderRegistry_1.HeaderRegistry; } });
94
+ var WebpiecesCoreHeaders_1 = require("./http/WebpiecesCoreHeaders");
95
+ Object.defineProperty(exports, "WebpiecesCoreHeaders", { enumerable: true, get: function () { return WebpiecesCoreHeaders_1.WebpiecesCoreHeaders; } });
96
+ var HeaderMethods_1 = require("./http/HeaderMethods");
97
+ Object.defineProperty(exports, "HeaderMethods", { enumerable: true, get: function () { return HeaderMethods_1.HeaderMethods; } });
98
+ var HeaderTypes_1 = require("./http/HeaderTypes");
99
+ Object.defineProperty(exports, "HEADER_TYPES", { enumerable: true, get: function () { return HeaderTypes_1.HEADER_TYPES; } });
100
+ // API-call logging helper (uses LogManager above)
101
+ var LogApiCall_1 = require("./http/LogApiCall");
102
+ Object.defineProperty(exports, "LogApiCall", { enumerable: true, get: function () { return LogApiCall_1.LogApiCall; } });
103
+ // Test-case recording contract (impl lives in http-server; hooks in http-client)
104
+ var TestCaseRecorder_1 = require("./http/recorder/TestCaseRecorder");
105
+ Object.defineProperty(exports, "RecorderKeys", { enumerable: true, get: function () { return TestCaseRecorder_1.RecorderKeys; } });
106
+ var RecordedEndpoint_1 = require("./http/recorder/RecordedEndpoint");
107
+ Object.defineProperty(exports, "RecordedEndpoint", { enumerable: true, get: function () { return RecordedEndpoint_1.RecordedEndpoint; } });
108
+ Object.defineProperty(exports, "RecordedError", { enumerable: true, get: function () { return RecordedEndpoint_1.RecordedError; } });
109
+ Object.defineProperty(exports, "RecordedTestCase", { enumerable: true, get: function () { return RecordedEndpoint_1.RecordedTestCase; } });
110
+ var DoNotRecord_1 = require("./http/recorder/DoNotRecord");
111
+ Object.defineProperty(exports, "DoNotRecord", { enumerable: true, get: function () { return DoNotRecord_1.DoNotRecord; } });
112
+ Object.defineProperty(exports, "getDoNotRecordFields", { enumerable: true, get: function () { return DoNotRecord_1.getDoNotRecordFields; } });
113
+ var RecordSerializer_1 = require("./http/recorder/RecordSerializer");
114
+ Object.defineProperty(exports, "RecordSerializer", { enumerable: true, get: function () { return RecordSerializer_1.RecordSerializer; } });
115
+ Object.defineProperty(exports, "SerializedMap", { enumerable: true, get: function () { return RecordSerializer_1.SerializedMap; } });
116
+ Object.defineProperty(exports, "SerializedError", { enumerable: true, get: function () { return RecordSerializer_1.SerializedError; } });
16
117
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-util/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,+CAA2C;AAAlC,qGAAA,OAAO,OAAA;AAEhB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["/**\n * @webpieces/core-util\n *\n * Utility functions for WebPieces applications.\n * This package works in both browser and Node.js environments.\n *\n * @packageDocumentation\n */\n\nexport { toError } from './lib/errorUtils';\nexport { Header } from './Header';\nexport { ContextKey } from './ContextKey';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/core-util/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;AAEH,+CAA2C;AAAlC,qGAAA,OAAO,OAAA;AAEhB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AAOnB,yDAAwD;AAA/C,8GAAA,aAAa,OAAA;AACtB,uEAAsE;AAA7D,4HAAA,oBAAoB,OAAA;AAC7B,mDAAkD;AAAzC,wGAAA,UAAU,OAAA;AAEnB,8DAA8D;AAC9D,sEAAsE;AACtE,sEAAsE;AACtE,uEAAuE;AACvE,kEAAkE;AAElE,4BAA4B;AAC5B,gDA4B2B;AA3BvB,qGAAA,OAAO,OAAA;AACP,sGAAA,QAAQ,OAAA;AACR,4GAAA,cAAc,OAAA;AACd,kHAAA,oBAAoB,OAAA;AACpB,mEAAmE;AACnE,oGAAA,MAAM,OAAA;AACN,qGAAA,OAAO,OAAA;AACP,sGAAA,QAAQ,OAAA;AACR,8GAAA,gBAAgB,OAAA;AAChB,sDAAsD;AACtD,iGAAA,GAAG,OAAA;AACH,oGAAA,MAAM,OAAA;AACN,mGAAA,KAAK,OAAA;AACL,wGAAA,UAAU,OAAA;AACV,0GAAA,YAAY,OAAA;AACZ,uGAAA,SAAS,OAAA;AACT,yGAAA,WAAW,OAAA;AACX,yGAAA,WAAW,OAAA;AACX,4HAAA,8BAA8B,OAAA;AAC9B,wGAAA,UAAU,OAAA;AACV,2GAAA,aAAa,OAAA;AACb,qHAAA,uBAAuB,OAAA;AACvB,0GAAA,YAAY,OAAA;AACZ,6HAAA,+BAA+B,OAAA;AAC/B,sGAAA,QAAQ,OAAA;AACR,2GAAA,aAAa,OAAA;AACb,2GAAA,aAAa,OAAA;AAOjB,cAAc;AACd,wCAuBuB;AAtBnB,uGAAA,aAAa,OAAA;AACb,mGAAA,SAAS,OAAA;AACT,2GAAA,iBAAiB,OAAA;AACjB,+GAAA,qBAAqB,OAAA;AACrB,6GAAA,mBAAmB,OAAA;AACnB,+GAAA,qBAAqB,OAAA;AACrB,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,6GAAA,mBAAmB,OAAA;AACnB,iHAAA,uBAAuB,OAAA;AACvB,iHAAA,uBAAuB,OAAA;AACvB,yGAAA,eAAe,OAAA;AACf,uGAAA,aAAa,OAAA;AACb,0BAA0B;AAC1B,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAChB,qGAAA,WAAW,OAAA;AACX,sGAAA,YAAY,OAAA;AACZ,6GAAA,mBAAmB,OAAA;AACnB,sGAAA,YAAY,OAAA;AACZ,uGAAA,aAAa,OAAA;AACb,qGAAA,WAAW,OAAA;AAGf,iEAAiE;AACjE,4CASyB;AAJrB,uGAAA,WAAW,OAAA;AACX,oGAAA,QAAQ,OAAA;AACR,oGAAA,QAAQ,OAAA;AACR,wGAAA,YAAY,OAAA;AAGhB,mBAAmB;AACnB,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,4EAA2E;AAAlE,oIAAA,wBAAwB,OAAA;AACjC,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,oEAAmE;AAA1D,4HAAA,oBAAoB,OAAA;AAC7B,sDAAqD;AAA5C,8GAAA,aAAa,OAAA;AAEtB,kDAAkD;AAAzC,2GAAA,YAAY,OAAA;AAErB,kDAAkD;AAClD,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AAEnB,iFAAiF;AACjF,qEAAkF;AAAvD,gHAAA,YAAY,OAAA;AACvC,qEAAqG;AAA5F,oHAAA,gBAAgB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAC1D,2DAAgF;AAAvE,0GAAA,WAAW,OAAA;AAAE,mHAAA,oBAAoB,OAAA;AAC1C,qEAAoG;AAA3F,oHAAA,gBAAgB,OAAA;AAAE,iHAAA,aAAa,OAAA;AAAE,mHAAA,eAAe,OAAA","sourcesContent":["/**\n * @webpieces/core-util\n *\n * Utility functions for WebPieces applications.\n * This package works in both browser and Node.js environments.\n *\n * @packageDocumentation\n */\n\nexport { toError } from './lib/errorUtils';\nexport { Header } from './Header';\nexport { ContextKey } from './ContextKey';\n\n// Logging (merged from former @webpieces/wp-logging).\n// Pluggable logging interface + a browser-safe console default; apps plug in\n// bunyan/winston/pino/etc. via LogManager.setFactory(...). Browser + Node.\nexport type { Logger, LogLevel } from './logging/Logger';\nexport type { LoggerFactory } from './logging/LoggerFactory';\nexport { ConsoleLogger } from './logging/ConsoleLogger';\nexport { ConsoleLoggerFactory } from './logging/ConsoleLoggerFactory';\nexport { LogManager } from './logging/LogManager';\n\n// HTTP API contract (merged from former @webpieces/http-api).\n// Shared HTTP API definition consumed by both client and server: REST\n// decorators, the HttpError hierarchy, datetime DTOs, platform-header\n// registry/readers, ValidateImplementation, and the test-case recorder\n// contract. Pure definitions — express-free, browser + Node safe.\n\n// API definition decorators\nexport {\n ApiPath,\n Endpoint,\n Authentication,\n AuthenticationConfig,\n // Auth mode decorators (clean service-to-service + user JWT model)\n Public,\n AuthJwt,\n AuthOidc,\n AuthSharedSecret,\n // API kind (RPC vs PubSub/Cloud Tasks) + queue naming\n Rpc,\n PubSub,\n Queue,\n getApiPath,\n getEndpoints,\n isApiPath,\n getAuthMeta,\n getAuthMode,\n assertEveryEndpointHasAuthMode,\n getApiKind,\n assertApiKind,\n assertPubSubConventions,\n getQueueName,\n validateNoConflictingDecorators,\n AuthMeta,\n RouteMetadata,\n METADATA_KEYS,\n} from './http/decorators';\nexport type { AuthMode, ApiKind } from './http/decorators';\n\n// Type validators\nexport { ValidateImplementation } from './http/validators';\n\n// HTTP errors\nexport {\n ProtocolError,\n HttpError,\n HttpNotFoundError,\n EndpointNotFoundError,\n HttpBadRequestError,\n HttpUnauthorizedError,\n HttpForbiddenError,\n HttpTimeoutError,\n HttpBadGatewayError,\n HttpGatewayTimeoutError,\n HttpInternalServerError,\n HttpVendorError,\n HttpUserError,\n // Error subtype constants\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './http/errors';\n\n// Date/Time DTOs and Utilities (inspired by Java Time / JSR-310)\nexport {\n InstantDto,\n DateDto,\n TimeDto,\n DateTimeDto,\n InstantUtil,\n DateUtil,\n TimeUtil,\n DateTimeUtil,\n} from './http/datetime';\n\n// Platform Headers\nexport { PlatformHeader } from './http/PlatformHeader';\nexport { PlatformHeadersExtension } from './http/PlatformHeadersExtension';\nexport { HeaderRegistry } from './http/HeaderRegistry';\nexport { WebpiecesCoreHeaders } from './http/WebpiecesCoreHeaders';\nexport { HeaderMethods } from './http/HeaderMethods';\nexport { ContextReader } from './http/ContextReader';\nexport { HEADER_TYPES } from './http/HeaderTypes';\n\n// API-call logging helper (uses LogManager above)\nexport { LogApiCall } from './http/LogApiCall';\n\n// Test-case recording contract (impl lives in http-server; hooks in http-client)\nexport { TestCaseRecorder, RecorderKeys } from './http/recorder/TestCaseRecorder';\nexport { RecordedEndpoint, RecordedError, RecordedTestCase } from './http/recorder/RecordedEndpoint';\nexport { DoNotRecord, getDoNotRecordFields } from './http/recorder/DoNotRecord';\nexport { RecordSerializer, SerializedMap, SerializedError } from './http/recorder/RecordSerializer';\n"]}
@@ -0,0 +1,25 @@
1
+ import { Logger, LogArg } from './Logger';
2
+ /**
3
+ * ConsoleLogger - the default, browser-safe {@link Logger} implementation.
4
+ *
5
+ * Backed purely by `console.*` (no Node imports), so it works unchanged in the
6
+ * browser (Angular/React) and in Node. Each line is prefixed with the logger
7
+ * name so multi-source logs stay greppable; callers that pass their own tag
8
+ * (e.g. `[API-SVR-req] ...`) keep it inside the message.
9
+ *
10
+ * Level → console method mapping:
11
+ * - trace/debug → console.debug
12
+ * - info → console.log (stdout, matching conventional server logging)
13
+ * - warn → console.warn
14
+ * - error → console.error
15
+ */
16
+ export declare class ConsoleLogger implements Logger {
17
+ private readonly name;
18
+ constructor(name: string);
19
+ private prefix;
20
+ trace(message: string, ...args: LogArg[]): void;
21
+ debug(message: string, ...args: LogArg[]): void;
22
+ info(message: string, ...args: LogArg[]): void;
23
+ warn(message: string, ...args: LogArg[]): void;
24
+ error(message: string, ...args: LogArg[]): void;
25
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleLogger = void 0;
4
+ /**
5
+ * ConsoleLogger - the default, browser-safe {@link Logger} implementation.
6
+ *
7
+ * Backed purely by `console.*` (no Node imports), so it works unchanged in the
8
+ * browser (Angular/React) and in Node. Each line is prefixed with the logger
9
+ * name so multi-source logs stay greppable; callers that pass their own tag
10
+ * (e.g. `[API-SVR-req] ...`) keep it inside the message.
11
+ *
12
+ * Level → console method mapping:
13
+ * - trace/debug → console.debug
14
+ * - info → console.log (stdout, matching conventional server logging)
15
+ * - warn → console.warn
16
+ * - error → console.error
17
+ */
18
+ class ConsoleLogger {
19
+ name;
20
+ constructor(name) {
21
+ this.name = name;
22
+ }
23
+ prefix() {
24
+ return `[${this.name}]`;
25
+ }
26
+ trace(message, ...args) {
27
+ console.debug(`${this.prefix()} ${message}`, ...args);
28
+ }
29
+ debug(message, ...args) {
30
+ console.debug(`${this.prefix()} ${message}`, ...args);
31
+ }
32
+ info(message, ...args) {
33
+ console.log(`${this.prefix()} ${message}`, ...args);
34
+ }
35
+ warn(message, ...args) {
36
+ console.warn(`${this.prefix()} ${message}`, ...args);
37
+ }
38
+ error(message, ...args) {
39
+ console.error(`${this.prefix()} ${message}`, ...args);
40
+ }
41
+ }
42
+ exports.ConsoleLogger = ConsoleLogger;
43
+ //# sourceMappingURL=ConsoleLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleLogger.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/logging/ConsoleLogger.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;GAaG;AACH,MAAa,aAAa;IACL,IAAI,CAAS;IAE9B,YAAY,IAAY;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAEO,MAAM;QACV,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAc;QACpC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAc;QACpC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAc;QACnC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAc;QACnC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAc;QACpC,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1D,CAAC;CACJ;AA9BD,sCA8BC","sourcesContent":["import { Logger, LogArg } from './Logger';\n\n/**\n * ConsoleLogger - the default, browser-safe {@link Logger} implementation.\n *\n * Backed purely by `console.*` (no Node imports), so it works unchanged in the\n * browser (Angular/React) and in Node. Each line is prefixed with the logger\n * name so multi-source logs stay greppable; callers that pass their own tag\n * (e.g. `[API-SVR-req] ...`) keep it inside the message.\n *\n * Level → console method mapping:\n * - trace/debug → console.debug\n * - info → console.log (stdout, matching conventional server logging)\n * - warn → console.warn\n * - error → console.error\n */\nexport class ConsoleLogger implements Logger {\n private readonly name: string;\n\n constructor(name: string) {\n this.name = name;\n }\n\n private prefix(): string {\n return `[${this.name}]`;\n }\n\n trace(message: string, ...args: LogArg[]): void {\n console.debug(`${this.prefix()} ${message}`, ...args);\n }\n\n debug(message: string, ...args: LogArg[]): void {\n console.debug(`${this.prefix()} ${message}`, ...args);\n }\n\n info(message: string, ...args: LogArg[]): void {\n console.log(`${this.prefix()} ${message}`, ...args);\n }\n\n warn(message: string, ...args: LogArg[]): void {\n console.warn(`${this.prefix()} ${message}`, ...args);\n }\n\n error(message: string, ...args: LogArg[]): void {\n console.error(`${this.prefix()} ${message}`, ...args);\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Logger } from './Logger';
2
+ import { LoggerFactory } from './LoggerFactory';
3
+ /**
4
+ * ConsoleLoggerFactory - the default {@link LoggerFactory}, browser-safe.
5
+ *
6
+ * Produces (and caches per name) {@link ConsoleLogger}s. This is what
7
+ * {@link LogManager} uses until an app installs a different backend
8
+ * (bunyan/winston/pino/...) via {@link LogManager.setFactory}.
9
+ */
10
+ export declare class ConsoleLoggerFactory implements LoggerFactory {
11
+ private readonly loggers;
12
+ getLogger(name: string): Logger;
13
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConsoleLoggerFactory = void 0;
4
+ const ConsoleLogger_1 = require("./ConsoleLogger");
5
+ /**
6
+ * ConsoleLoggerFactory - the default {@link LoggerFactory}, browser-safe.
7
+ *
8
+ * Produces (and caches per name) {@link ConsoleLogger}s. This is what
9
+ * {@link LogManager} uses until an app installs a different backend
10
+ * (bunyan/winston/pino/...) via {@link LogManager.setFactory}.
11
+ */
12
+ class ConsoleLoggerFactory {
13
+ loggers = new Map();
14
+ getLogger(name) {
15
+ let logger = this.loggers.get(name);
16
+ if (!logger) {
17
+ logger = new ConsoleLogger_1.ConsoleLogger(name);
18
+ this.loggers.set(name, logger);
19
+ }
20
+ return logger;
21
+ }
22
+ }
23
+ exports.ConsoleLoggerFactory = ConsoleLoggerFactory;
24
+ //# sourceMappingURL=ConsoleLoggerFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConsoleLoggerFactory.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/logging/ConsoleLoggerFactory.ts"],"names":[],"mappings":";;;AAEA,mDAAgD;AAEhD;;;;;;GAMG;AACH,MAAa,oBAAoB;IACZ,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAErD,SAAS,CAAC,IAAY;QAClB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,GAAG,IAAI,6BAAa,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAXD,oDAWC","sourcesContent":["import { Logger } from './Logger';\nimport { LoggerFactory } from './LoggerFactory';\nimport { ConsoleLogger } from './ConsoleLogger';\n\n/**\n * ConsoleLoggerFactory - the default {@link LoggerFactory}, browser-safe.\n *\n * Produces (and caches per name) {@link ConsoleLogger}s. This is what\n * {@link LogManager} uses until an app installs a different backend\n * (bunyan/winston/pino/...) via {@link LogManager.setFactory}.\n */\nexport class ConsoleLoggerFactory implements LoggerFactory {\n private readonly loggers = new Map<string, Logger>();\n\n getLogger(name: string): Logger {\n let logger = this.loggers.get(name);\n if (!logger) {\n logger = new ConsoleLogger(name);\n this.loggers.set(name, logger);\n }\n return logger;\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import { Logger } from './Logger';
2
+ import { LoggerFactory } from './LoggerFactory';
3
+ /**
4
+ * LogManager - the global, slf4j-style entry point for logging.
5
+ *
6
+ * Every call site in the codebase does:
7
+ *
8
+ * ```ts
9
+ * const log = LogManager.getLogger('MyClass');
10
+ * log.info('hello', { some: 'context' });
11
+ * ```
12
+ *
13
+ * and never knows which backend is behind it. Apps choose their backend ONCE at
14
+ * startup by installing a {@link LoggerFactory}:
15
+ *
16
+ * ```ts
17
+ * LogManager.setFactory(new BunyanLoggerFactory(...)); // node-only app
18
+ * ```
19
+ *
20
+ * Until a factory is installed, logging goes to the browser-safe
21
+ * {@link ConsoleLoggerFactory}, so libraries can log at import time without any
22
+ * app wiring. This is a data-less coordination holder (all static), which is why
23
+ * it is a class with static members rather than an instance.
24
+ */
25
+ export declare class LogManager {
26
+ private static factory;
27
+ /**
28
+ * Install the process-wide logging backend. Call once at app startup, before
29
+ * other modules fetch their loggers, so early loggers use the chosen backend.
30
+ */
31
+ static setFactory(factory: LoggerFactory): void;
32
+ /** Get a named logger from the currently installed factory. */
33
+ static getLogger(name: string): Logger;
34
+ /** The currently installed factory (mainly for tests / diagnostics). */
35
+ static getFactory(): LoggerFactory;
36
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogManager = void 0;
4
+ const ConsoleLoggerFactory_1 = require("./ConsoleLoggerFactory");
5
+ /**
6
+ * LogManager - the global, slf4j-style entry point for logging.
7
+ *
8
+ * Every call site in the codebase does:
9
+ *
10
+ * ```ts
11
+ * const log = LogManager.getLogger('MyClass');
12
+ * log.info('hello', { some: 'context' });
13
+ * ```
14
+ *
15
+ * and never knows which backend is behind it. Apps choose their backend ONCE at
16
+ * startup by installing a {@link LoggerFactory}:
17
+ *
18
+ * ```ts
19
+ * LogManager.setFactory(new BunyanLoggerFactory(...)); // node-only app
20
+ * ```
21
+ *
22
+ * Until a factory is installed, logging goes to the browser-safe
23
+ * {@link ConsoleLoggerFactory}, so libraries can log at import time without any
24
+ * app wiring. This is a data-less coordination holder (all static), which is why
25
+ * it is a class with static members rather than an instance.
26
+ */
27
+ class LogManager {
28
+ static factory = new ConsoleLoggerFactory_1.ConsoleLoggerFactory();
29
+ /**
30
+ * Install the process-wide logging backend. Call once at app startup, before
31
+ * other modules fetch their loggers, so early loggers use the chosen backend.
32
+ */
33
+ static setFactory(factory) {
34
+ LogManager.factory = factory;
35
+ }
36
+ /** Get a named logger from the currently installed factory. */
37
+ static getLogger(name) {
38
+ return LogManager.factory.getLogger(name);
39
+ }
40
+ /** The currently installed factory (mainly for tests / diagnostics). */
41
+ static getFactory() {
42
+ return LogManager.factory;
43
+ }
44
+ }
45
+ exports.LogManager = LogManager;
46
+ //# sourceMappingURL=LogManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogManager.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/logging/LogManager.ts"],"names":[],"mappings":";;;AAEA,iEAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,UAAU;IACX,MAAM,CAAC,OAAO,GAAkB,IAAI,2CAAoB,EAAE,CAAC;IAEnE;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,OAAsB;QACpC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IACjC,CAAC;IAED,+DAA+D;IAC/D,MAAM,CAAC,SAAS,CAAC,IAAY;QACzB,OAAO,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,wEAAwE;IACxE,MAAM,CAAC,UAAU;QACb,OAAO,UAAU,CAAC,OAAO,CAAC;IAC9B,CAAC;;AAnBL,gCAoBC","sourcesContent":["import { Logger } from './Logger';\nimport { LoggerFactory } from './LoggerFactory';\nimport { ConsoleLoggerFactory } from './ConsoleLoggerFactory';\n\n/**\n * LogManager - the global, slf4j-style entry point for logging.\n *\n * Every call site in the codebase does:\n *\n * ```ts\n * const log = LogManager.getLogger('MyClass');\n * log.info('hello', { some: 'context' });\n * ```\n *\n * and never knows which backend is behind it. Apps choose their backend ONCE at\n * startup by installing a {@link LoggerFactory}:\n *\n * ```ts\n * LogManager.setFactory(new BunyanLoggerFactory(...)); // node-only app\n * ```\n *\n * Until a factory is installed, logging goes to the browser-safe\n * {@link ConsoleLoggerFactory}, so libraries can log at import time without any\n * app wiring. This is a data-less coordination holder (all static), which is why\n * it is a class with static members rather than an instance.\n */\nexport class LogManager {\n private static factory: LoggerFactory = new ConsoleLoggerFactory();\n\n /**\n * Install the process-wide logging backend. Call once at app startup, before\n * other modules fetch their loggers, so early loggers use the chosen backend.\n */\n static setFactory(factory: LoggerFactory): void {\n LogManager.factory = factory;\n }\n\n /** Get a named logger from the currently installed factory. */\n static getLogger(name: string): Logger {\n return LogManager.factory.getLogger(name);\n }\n\n /** The currently installed factory (mainly for tests / diagnostics). */\n static getFactory(): LoggerFactory {\n return LogManager.factory;\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Log severity levels, ordered lowest → highest.
3
+ *
4
+ * Mirrors the common slf4j/bunyan/winston vocabulary so any of those backends
5
+ * can be plugged in behind the {@link Logger} interface.
6
+ */
7
+ export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
8
+ /**
9
+ * A single structured log argument. A logger legitimately accepts arbitrary
10
+ * values (objects, errors, primitives) and lets the backend decide how to
11
+ * render them — mirroring `console.*`/bunyan/winston signatures.
12
+ */
13
+ export type LogArg = unknown;
14
+ /**
15
+ * Logger - the pluggable logging contract for WebPieces.
16
+ *
17
+ * This is a BUSINESS-LOGIC interface (methods with behavior), so per the
18
+ * webpieces guidelines it is an `interface`, not a class. Different projects
19
+ * plug in different backends (bunyan, winston, pino, browser console, a
20
+ * file writer, ...) by supplying an implementation via a {@link LoggerFactory}.
21
+ *
22
+ * Implementations MUST stay browser-safe if they are to be used from Angular /
23
+ * React. Node-only backends (bunyan, file writers, ...) are wired in by
24
+ * `framework:express` apps at startup, never in browser-safe libraries.
25
+ *
26
+ * Each method takes a message plus optional structured args (objects, errors,
27
+ * numbers) that the backend decides how to render — matching `console.*` and
28
+ * bunyan/winston signatures.
29
+ */
30
+ export interface Logger {
31
+ trace(message: string, ...args: LogArg[]): void;
32
+ debug(message: string, ...args: LogArg[]): void;
33
+ info(message: string, ...args: LogArg[]): void;
34
+ warn(message: string, ...args: LogArg[]): void;
35
+ error(message: string, ...args: LogArg[]): void;
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/logging/Logger.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Log severity levels, ordered lowest → highest.\n *\n * Mirrors the common slf4j/bunyan/winston vocabulary so any of those backends\n * can be plugged in behind the {@link Logger} interface.\n */\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';\n\n/**\n * A single structured log argument. A logger legitimately accepts arbitrary\n * values (objects, errors, primitives) and lets the backend decide how to\n * render them — mirroring `console.*`/bunyan/winston signatures.\n */\n// webpieces-disable no-any-unknown -- a logger must accept arbitrary values to render; this is the one intentional widening\nexport type LogArg = unknown;\n\n/**\n * Logger - the pluggable logging contract for WebPieces.\n *\n * This is a BUSINESS-LOGIC interface (methods with behavior), so per the\n * webpieces guidelines it is an `interface`, not a class. Different projects\n * plug in different backends (bunyan, winston, pino, browser console, a\n * file writer, ...) by supplying an implementation via a {@link LoggerFactory}.\n *\n * Implementations MUST stay browser-safe if they are to be used from Angular /\n * React. Node-only backends (bunyan, file writers, ...) are wired in by\n * `framework:express` apps at startup, never in browser-safe libraries.\n *\n * Each method takes a message plus optional structured args (objects, errors,\n * numbers) that the backend decides how to render — matching `console.*` and\n * bunyan/winston signatures.\n */\nexport interface Logger {\n trace(message: string, ...args: LogArg[]): void;\n debug(message: string, ...args: LogArg[]): void;\n info(message: string, ...args: LogArg[]): void;\n warn(message: string, ...args: LogArg[]): void;\n error(message: string, ...args: LogArg[]): void;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { Logger } from './Logger';
2
+ /**
3
+ * LoggerFactory - the pluggable seam that produces named {@link Logger}s.
4
+ *
5
+ * BUSINESS-LOGIC interface (a method with behavior). An app selects its logging
6
+ * backend by installing one implementation of this factory globally via
7
+ * {@link LogManager.setFactory}. Everything else in the codebase asks
8
+ * {@link LogManager.getLogger} for a named logger and never knows which backend
9
+ * is behind it.
10
+ *
11
+ * `name` is conventionally the class or module name (slf4j style), e.g.
12
+ * `LogManager.getLogger('LogApiCall')`.
13
+ */
14
+ export interface LoggerFactory {
15
+ getLogger(name: string): Logger;
16
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LoggerFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoggerFactory.js","sourceRoot":"","sources":["../../../../../../packages/core/core-util/src/logging/LoggerFactory.ts"],"names":[],"mappings":"","sourcesContent":["import { Logger } from './Logger';\n\n/**\n * LoggerFactory - the pluggable seam that produces named {@link Logger}s.\n *\n * BUSINESS-LOGIC interface (a method with behavior). An app selects its logging\n * backend by installing one implementation of this factory globally via\n * {@link LogManager.setFactory}. Everything else in the codebase asks\n * {@link LogManager.getLogger} for a named logger and never knows which backend\n * is behind it.\n *\n * `name` is conventionally the class or module name (slf4j style), e.g.\n * `LogManager.getLogger('LogApiCall')`.\n */\nexport interface LoggerFactory {\n getLogger(name: string): Logger;\n}\n"]}