@venizia/ignis-helpers 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/types/field-mapping.d.ts +13 -1
- package/dist/cjs/common/types/field-mapping.d.ts.map +1 -1
- package/dist/cjs/common/types/field-mapping.js +20 -0
- package/dist/cjs/common/types/field-mapping.js.map +1 -1
- package/dist/cjs/core.d.ts +2 -1
- package/dist/cjs/core.d.ts.map +1 -1
- package/dist/cjs/core.js +6 -1
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.d.ts +2 -2
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.d.ts.map +1 -1
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.js +3 -1
- package/dist/cjs/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
- package/dist/cjs/modules/crypto/algorithms/aes.constants.d.ts +11 -0
- package/dist/cjs/modules/crypto/algorithms/aes.constants.d.ts.map +1 -0
- package/dist/cjs/modules/crypto/algorithms/aes.constants.js +14 -0
- package/dist/cjs/modules/crypto/algorithms/aes.constants.js.map +1 -0
- package/dist/cjs/modules/error/index.d.ts +1 -1
- package/dist/cjs/modules/error/index.d.ts.map +1 -1
- package/dist/cjs/modules/error/index.js +2 -1
- package/dist/cjs/modules/error/index.js.map +1 -1
- package/dist/cjs/modules/logger/hf/common/types.d.ts +3 -1
- package/dist/cjs/modules/logger/hf/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/logger/hf/common/types.js.map +1 -1
- package/dist/cjs/modules/logger/pino/common/constants.d.ts +10 -1
- package/dist/cjs/modules/logger/pino/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/logger/pino/common/constants.js +11 -1
- package/dist/cjs/modules/logger/pino/common/constants.js.map +1 -1
- package/dist/cjs/modules/logger/pino/destination.d.ts.map +1 -1
- package/dist/cjs/modules/logger/pino/destination.js +4 -3
- package/dist/cjs/modules/logger/pino/destination.js.map +1 -1
- package/dist/cjs/modules/network/http-request/common/constants.d.ts +11 -0
- package/dist/cjs/modules/network/http-request/common/constants.d.ts.map +1 -0
- package/dist/cjs/modules/network/http-request/common/constants.js +14 -0
- package/dist/cjs/modules/network/http-request/common/constants.js.map +1 -0
- package/dist/cjs/modules/network/http-request/common/index.d.ts +1 -0
- package/dist/cjs/modules/network/http-request/common/index.d.ts.map +1 -1
- package/dist/cjs/modules/network/http-request/common/index.js +1 -0
- package/dist/cjs/modules/network/http-request/common/index.js.map +1 -1
- package/dist/cjs/modules/network/http-request/common/types.d.ts +1 -1
- package/dist/cjs/modules/network/http-request/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/network/http-request/common/types.js.map +1 -1
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.d.ts +13 -2
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +1 -1
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.js +23 -6
- package/dist/cjs/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/cjs/modules/queue/common/constants.d.ts +11 -0
- package/dist/cjs/modules/queue/common/constants.d.ts.map +1 -0
- package/dist/cjs/modules/queue/common/constants.js +14 -0
- package/dist/cjs/modules/queue/common/constants.js.map +1 -0
- package/dist/cjs/modules/queue/common/index.d.ts +1 -0
- package/dist/cjs/modules/queue/common/index.d.ts.map +1 -1
- package/dist/cjs/modules/queue/common/index.js +1 -0
- package/dist/cjs/modules/queue/common/index.js.map +1 -1
- package/dist/cjs/modules/queue/common/types.d.ts +1 -1
- package/dist/cjs/modules/queue/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/queue/common/types.js.map +1 -1
- package/dist/cjs/modules/queue/kafka/common/constants.d.ts +9 -0
- package/dist/cjs/modules/queue/kafka/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/queue/kafka/common/constants.js +11 -1
- package/dist/cjs/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/cjs/modules/queue/kafka/consumer.d.ts +2 -1
- package/dist/cjs/modules/queue/kafka/consumer.d.ts.map +1 -1
- package/dist/cjs/modules/queue/kafka/consumer.js +2 -2
- package/dist/cjs/modules/queue/kafka/consumer.js.map +1 -1
- package/dist/cjs/modules/temporal/common/constants.d.ts +21 -0
- package/dist/cjs/modules/temporal/common/constants.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/common/constants.js +22 -1
- package/dist/cjs/modules/temporal/common/constants.js.map +1 -1
- package/dist/cjs/modules/temporal/locale/locale.d.ts +4 -3
- package/dist/cjs/modules/temporal/locale/locale.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/locale/locale.js +2 -1
- package/dist/cjs/modules/temporal/locale/locale.js.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/constants.d.ts +43 -0
- package/dist/cjs/modules/temporal/pattern/common/constants.d.ts.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/constants.js +74 -0
- package/dist/cjs/modules/temporal/pattern/common/constants.js.map +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.d.ts +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/index.js +1 -0
- package/dist/cjs/modules/temporal/pattern/common/index.js.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/types.d.ts +2 -11
- package/dist/cjs/modules/temporal/pattern/common/types.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/pattern/common/types.js.map +1 -1
- package/dist/cjs/modules/temporal/pattern/tokens.d.ts +2 -1
- package/dist/cjs/modules/temporal/pattern/tokens.d.ts.map +1 -1
- package/dist/cjs/modules/temporal/pattern/tokens.js +2 -14
- package/dist/cjs/modules/temporal/pattern/tokens.js.map +1 -1
- package/dist/cjs/utilities/request.utility.d.ts +21 -2
- package/dist/cjs/utilities/request.utility.d.ts.map +1 -1
- package/dist/cjs/utilities/request.utility.js +25 -5
- package/dist/cjs/utilities/request.utility.js.map +1 -1
- package/dist/esm/common/types/field-mapping.d.ts +13 -1
- package/dist/esm/common/types/field-mapping.d.ts.map +1 -1
- package/dist/esm/common/types/field-mapping.js +18 -1
- package/dist/esm/common/types/field-mapping.js.map +1 -1
- package/dist/esm/core.d.ts +2 -1
- package/dist/esm/core.d.ts.map +1 -1
- package/dist/esm/core.js +4 -0
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts +2 -2
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js +2 -0
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts +11 -0
- package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts.map +1 -0
- package/dist/esm/modules/crypto/algorithms/aes.constants.js +10 -0
- package/dist/esm/modules/crypto/algorithms/aes.constants.js.map +1 -0
- package/dist/esm/modules/error/index.d.ts +1 -1
- package/dist/esm/modules/error/index.d.ts.map +1 -1
- package/dist/esm/modules/error/index.js +1 -1
- package/dist/esm/modules/error/index.js.map +1 -1
- package/dist/esm/modules/logger/hf/common/types.d.ts +3 -1
- package/dist/esm/modules/logger/hf/common/types.d.ts.map +1 -1
- package/dist/esm/modules/logger/hf/common/types.js.map +1 -1
- package/dist/esm/modules/logger/pino/common/constants.d.ts +10 -1
- package/dist/esm/modules/logger/pino/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/logger/pino/common/constants.js +9 -0
- package/dist/esm/modules/logger/pino/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/pino/destination.d.ts.map +1 -1
- package/dist/esm/modules/logger/pino/destination.js +4 -3
- package/dist/esm/modules/logger/pino/destination.js.map +1 -1
- package/dist/esm/modules/network/http-request/common/constants.d.ts +11 -0
- package/dist/esm/modules/network/http-request/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/network/http-request/common/constants.js +10 -0
- package/dist/esm/modules/network/http-request/common/constants.js.map +1 -0
- package/dist/esm/modules/network/http-request/common/index.d.ts +1 -0
- package/dist/esm/modules/network/http-request/common/index.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/common/index.js +1 -0
- package/dist/esm/modules/network/http-request/common/index.js.map +1 -1
- package/dist/esm/modules/network/http-request/common/types.d.ts +1 -1
- package/dist/esm/modules/network/http-request/common/types.d.ts.map +1 -1
- package/dist/esm/modules/network/http-request/common/types.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +13 -2
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +21 -5
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/queue/common/constants.d.ts +11 -0
- package/dist/esm/modules/queue/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/queue/common/constants.js +10 -0
- package/dist/esm/modules/queue/common/constants.js.map +1 -0
- package/dist/esm/modules/queue/common/index.d.ts +1 -0
- package/dist/esm/modules/queue/common/index.d.ts.map +1 -1
- package/dist/esm/modules/queue/common/index.js +1 -0
- package/dist/esm/modules/queue/common/index.js.map +1 -1
- package/dist/esm/modules/queue/common/types.d.ts +1 -1
- package/dist/esm/modules/queue/common/types.d.ts.map +1 -1
- package/dist/esm/modules/queue/common/types.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/constants.d.ts +9 -0
- package/dist/esm/modules/queue/kafka/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/common/constants.js +9 -0
- package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/esm/modules/queue/kafka/consumer.d.ts +2 -1
- package/dist/esm/modules/queue/kafka/consumer.d.ts.map +1 -1
- package/dist/esm/modules/queue/kafka/consumer.js +3 -3
- package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
- package/dist/esm/modules/temporal/common/constants.d.ts +21 -0
- package/dist/esm/modules/temporal/common/constants.d.ts.map +1 -1
- package/dist/esm/modules/temporal/common/constants.js +19 -0
- package/dist/esm/modules/temporal/common/constants.js.map +1 -1
- package/dist/esm/modules/temporal/locale/locale.d.ts +4 -3
- package/dist/esm/modules/temporal/locale/locale.d.ts.map +1 -1
- package/dist/esm/modules/temporal/locale/locale.js +2 -1
- package/dist/esm/modules/temporal/locale/locale.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/constants.d.ts +43 -0
- package/dist/esm/modules/temporal/pattern/common/constants.d.ts.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/constants.js +70 -0
- package/dist/esm/modules/temporal/pattern/common/constants.js.map +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.d.ts +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/index.js +1 -0
- package/dist/esm/modules/temporal/pattern/common/index.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/types.d.ts +2 -11
- package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +1 -1
- package/dist/esm/modules/temporal/pattern/common/types.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/tokens.d.ts +2 -1
- package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +1 -1
- package/dist/esm/modules/temporal/pattern/tokens.js +2 -14
- package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -1
- package/dist/esm/utilities/request.utility.d.ts +21 -2
- package/dist/esm/utilities/request.utility.d.ts.map +1 -1
- package/dist/esm/utilities/request.utility.js +22 -4
- package/dist/esm/utilities/request.utility.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qBAAa,kBAAkB;IAC7B,MAAM,CAA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G;AAC9G,qBAAa,uBAAuB;IAClC,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAElC,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAqD;IAE/E,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,8CAA8C;AAC9C,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
|
|
@@ -61,4 +61,13 @@ export class KafkaDefaults {
|
|
|
61
61
|
static { this.SHUTDOWN_TIMEOUT = 30_000; }
|
|
62
62
|
static { this.LAG_MONITOR_INTERVAL = 30_000; }
|
|
63
63
|
}
|
|
64
|
+
/** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */
|
|
65
|
+
export class KafkaBrokersDownReasons {
|
|
66
|
+
static { this.DISCONNECTED = 'disconnected'; }
|
|
67
|
+
static { this.FAILED = 'failed'; }
|
|
68
|
+
static { this.SCHEME_SET = new Set([this.DISCONNECTED, this.FAILED]); }
|
|
69
|
+
static isValid(value) {
|
|
70
|
+
return this.SCHEME_SET.has(value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
64
73
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../src/modules/queue/kafka/common/constants.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAkB;aACb,YAAO,GAAG,SAAS,CAAC;aACpB,aAAQ,GAAG,UAAU,CAAC;aAEtB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEpE,MAAM,CAAC,OAAO,CAAC,IAAY;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;;AAK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CAAC;aACZ,gBAAW,GAAG,KAAK,CAAC;IAEpC,WAAW;aACK,WAAM,GAAG,IAAI,CAAC;aACd,sBAAiB,GAAG,KAAK,CAAC;IAE1C,WAAW;aACK,eAAU,GAAG,KAAK,CAAC;aACnB,oBAAe,GAAG,MAAM,CAAC;aACzB,uBAAkB,GAAG,MAAM,CAAC;aAC5B,oBAAe,GAAG,IAAI,CAAC;aACvB,cAAS,GAAG,CAAC,CAAC;aACd,cAAS,GAAG,SAAS,GAAG,EAAE,CAAC,GAAC,QAAQ;aACpC,kBAAa,GAAG,KAAK,CAAC;aACtB,qBAAgB,GAAG,OAAO,CAAC;aAC3B,mBAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;aAE5C,iBAAY,GAAG,WAAW,CAAC;aAC3B,0BAAqB,GAAG,QAAQ,CAAC;aAEjC,oBAAe,GAAG,KAAK,CAAC;aACxB,2BAAsB,GAAG,CAAC,CAAC;aAC3B,qBAAgB,GAAG,MAAM,CAAC;aAC1B,yBAAoB,GAAG,MAAM,CAAC","sourcesContent":["import { type TConstValue } from '@/common';\n\nexport class KafkaGroupProtocol {\n static readonly CLASSIC = 'classic';\n static readonly CONSUMER = 'consumer';\n\n static readonly SCHEME_SET = new Set([this.CLASSIC, this.CONSUMER]);\n\n static isValid(mode: string): boolean {\n return this.SCHEME_SET.has(mode);\n }\n}\n\nexport type TKafkaGroupProtocol = TConstValue<typeof KafkaGroupProtocol>;\n\nexport class KafkaAcks {\n static readonly NONE = 0; // No acknowledgment — fire-and-forget\n static readonly LEADER = 1; // Leader acknowledgment only\n static readonly ALL = -1; // Full ISR acknowledgment\n\n static readonly SCHEME_SET = new Set([this.NONE, this.LEADER, this.ALL]);\n\n static isValid(ack: number): boolean {\n return this.SCHEME_SET.has(ack);\n }\n}\n\nexport type TKafkaAcks = TConstValue<typeof KafkaAcks>;\n\nexport class KafkaHealthStatuses {\n static readonly CONNECTED = 'connected';\n static readonly DISCONNECTED = 'disconnected';\n static readonly UNKNOWN = 'unknown';\n\n static readonly SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]);\n\n static isValid(status: string): boolean {\n return this.SCHEME_SET.has(status);\n }\n}\n\nexport type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;\n\nexport class KafkaClientEvents {\n static readonly BROKER_CONNECT = 'client:broker:connect';\n static readonly BROKER_DISCONNECT = 'client:broker:disconnect';\n static readonly BROKER_FAILED = 'client:broker:failed';\n\n static readonly CONSUMER_GROUP_JOIN = 'consumer:group:join';\n static readonly CONSUMER_GROUP_LEAVE = 'consumer:group:leave';\n static readonly CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance';\n static readonly CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error';\n static readonly CONSUMER_LAG = 'consumer:lag';\n static readonly CONSUMER_LAG_ERROR = 'consumer:lag:error';\n\n static readonly STREAM_DATA = 'data';\n static readonly STREAM_ERROR = 'error';\n}\n\nexport class KafkaDefaults {\n // Shared\n static readonly RETRIES = 3;\n static readonly RETRY_DELAY = 1_000;\n\n // Producer\n static readonly STRICT = true;\n static readonly AUTOCREATE_TOPICS = false;\n\n // Consumer\n static readonly AUTOCOMMIT = false;\n static readonly SESSION_TIMEOUT = 60_000;\n static readonly HEARTBEAT_INTERVAL = 10_000;\n static readonly HIGH_WATER_MARK = 1024;\n static readonly MIN_BYTES = 1;\n static readonly MAX_BYTES = 1_048_576 * 10; // 10 MB\n static readonly MAX_WAIT_TIME = 5_000;\n static readonly METADATA_MAX_AGE = 300_000;\n static readonly GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC;\n\n static readonly CONSUME_MODE = 'committed';\n static readonly CONSUME_FALLBACK_MODE = 'latest';\n\n static readonly RECONNECT_DELAY = 2_000;\n static readonly MAX_RECONNECT_ATTEMPTS = 5;\n static readonly SHUTDOWN_TIMEOUT = 30_000;\n static readonly LAG_MONITOR_INTERVAL = 30_000;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"const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IAE/E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import { type TConstValue } from '@/common';\n\nexport class KafkaGroupProtocol {\n static readonly CLASSIC = 'classic';\n static readonly CONSUMER = 'consumer';\n\n static readonly SCHEME_SET = new Set([this.CLASSIC, this.CONSUMER]);\n\n static isValid(mode: string): boolean {\n return this.SCHEME_SET.has(mode);\n }\n}\n\nexport type TKafkaGroupProtocol = TConstValue<typeof KafkaGroupProtocol>;\n\nexport class KafkaAcks {\n static readonly NONE = 0; // No acknowledgment — fire-and-forget\n static readonly LEADER = 1; // Leader acknowledgment only\n static readonly ALL = -1; // Full ISR acknowledgment\n\n static readonly SCHEME_SET = new Set([this.NONE, this.LEADER, this.ALL]);\n\n static isValid(ack: number): boolean {\n return this.SCHEME_SET.has(ack);\n }\n}\n\nexport type TKafkaAcks = TConstValue<typeof KafkaAcks>;\n\nexport class KafkaHealthStatuses {\n static readonly CONNECTED = 'connected';\n static readonly DISCONNECTED = 'disconnected';\n static readonly UNKNOWN = 'unknown';\n\n static readonly SCHEME_SET = new Set([this.CONNECTED, this.DISCONNECTED, this.UNKNOWN]);\n\n static isValid(status: string): boolean {\n return this.SCHEME_SET.has(status);\n }\n}\n\nexport type TKafkaHealthStatus = TConstValue<typeof KafkaHealthStatuses>;\n\nexport class KafkaClientEvents {\n static readonly BROKER_CONNECT = 'client:broker:connect';\n static readonly BROKER_DISCONNECT = 'client:broker:disconnect';\n static readonly BROKER_FAILED = 'client:broker:failed';\n\n static readonly CONSUMER_GROUP_JOIN = 'consumer:group:join';\n static readonly CONSUMER_GROUP_LEAVE = 'consumer:group:leave';\n static readonly CONSUMER_GROUP_REBALANCE = 'consumer:group:rebalance';\n static readonly CONSUMER_HEARTBEAT_ERROR = 'consumer:heartbeat:error';\n static readonly CONSUMER_LAG = 'consumer:lag';\n static readonly CONSUMER_LAG_ERROR = 'consumer:lag:error';\n\n static readonly STREAM_DATA = 'data';\n static readonly STREAM_ERROR = 'error';\n}\n\nexport class KafkaDefaults {\n // Shared\n static readonly RETRIES = 3;\n static readonly RETRY_DELAY = 1_000;\n\n // Producer\n static readonly STRICT = true;\n static readonly AUTOCREATE_TOPICS = false;\n\n // Consumer\n static readonly AUTOCOMMIT = false;\n static readonly SESSION_TIMEOUT = 60_000;\n static readonly HEARTBEAT_INTERVAL = 10_000;\n static readonly HIGH_WATER_MARK = 1024;\n static readonly MIN_BYTES = 1;\n static readonly MAX_BYTES = 1_048_576 * 10; // 10 MB\n static readonly MAX_WAIT_TIME = 5_000;\n static readonly METADATA_MAX_AGE = 300_000;\n static readonly GROUP_PROTOCOL = KafkaGroupProtocol.CLASSIC;\n\n static readonly CONSUME_MODE = 'committed';\n static readonly CONSUME_FALLBACK_MODE = 'latest';\n\n static readonly RECONNECT_DELAY = 2_000;\n static readonly MAX_RECONNECT_ATTEMPTS = 5;\n static readonly SHUTDOWN_TIMEOUT = 30_000;\n static readonly LAG_MONITOR_INTERVAL = 30_000;\n}\n\n/** Why every broker of a consumer is gone: DISCONNECTED (the connections closed) or FAILED (they errored). */\nexport class KafkaBrokersDownReasons {\n static readonly DISCONNECTED = 'disconnected';\n static readonly FAILED = 'failed';\n\n static readonly SCHEME_SET = new Set<string>([this.DISCONNECTED, this.FAILED]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid Kafka brokers-down reason values. */\nexport type TKafkaBrokersDownReason = TConstValue<typeof KafkaBrokersDownReasons>;\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MessagesStream } from '@platformatic/kafka';
|
|
2
2
|
import { Consumer } from '@platformatic/kafka';
|
|
3
3
|
import { BaseKafkaHelper } from './base.js';
|
|
4
|
+
import { type TKafkaBrokersDownReason } from './common/constants.js';
|
|
4
5
|
import type { IKafkaConsumeStartOptions, IKafkaConsumerOptions, TKafkaGroupJoinCallback, TKafkaGroupLeaveCallback, TKafkaGroupRebalanceCallback, TKafkaHeartbeatErrorCallback, TKafkaLagCallback, TKafkaLagErrorCallback, TKafkaMessageCallback, TKafkaMessageDoneCallback, TKafkaMessageErrorCallback, TKafkaReconnectErrorCallback, TKafkaStreamErrorCallback } from './common/types/index.js';
|
|
5
6
|
/**
|
|
6
7
|
* Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.
|
|
@@ -78,7 +79,7 @@ export declare class KafkaConsumerHelper<KeyType = string, ValueType = string, H
|
|
|
78
79
|
}): Promise<void>;
|
|
79
80
|
protected rebuildClient(): Promise<void>;
|
|
80
81
|
protected closeOldClient(oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>): Promise<void>;
|
|
81
|
-
protected handleAllBrokersDown(reason:
|
|
82
|
+
protected handleAllBrokersDown(reason: TKafkaBrokersDownReason): void;
|
|
82
83
|
protected destroyDeadStream(): void;
|
|
83
84
|
protected closeStream(): Promise<void>;
|
|
84
85
|
protected unconfigureBrokerEvents(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAKV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"consumer.d.ts","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAKV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAKL,KAAK,uBA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Hook } from '../common/index.js';
|
|
6
6
|
import { BaseKafkaHelper } from './base.js';
|
|
7
|
-
import { KafkaClientEvents, KafkaDefaults, KafkaHealthStatuses } from './common/constants.js';
|
|
7
|
+
import { KafkaBrokersDownReasons, KafkaClientEvents, KafkaDefaults, KafkaHealthStatuses, } from './common/constants.js';
|
|
8
8
|
/**
|
|
9
9
|
* Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.
|
|
10
10
|
*
|
|
@@ -394,10 +394,10 @@ export class KafkaConsumerHelper extends BaseKafkaHelper {
|
|
|
394
394
|
configureBrokerEvents() {
|
|
395
395
|
super.configureBrokerEvents();
|
|
396
396
|
this.client.on(KafkaClientEvents.BROKER_DISCONNECT, () => {
|
|
397
|
-
this.handleAllBrokersDown(
|
|
397
|
+
this.handleAllBrokersDown(KafkaBrokersDownReasons.DISCONNECTED);
|
|
398
398
|
});
|
|
399
399
|
this.client.on(KafkaClientEvents.BROKER_FAILED, () => {
|
|
400
|
-
this.handleAllBrokersDown(
|
|
400
|
+
this.handleAllBrokersDown(KafkaBrokersDownReasons.FAILED);
|
|
401
401
|
});
|
|
402
402
|
this.client.on(KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload) => {
|
|
403
403
|
this.logger.info('[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d', payload.groupId, payload.memberId, payload.generationId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consumer.js","sourceRoot":"","sources":["../../../../../src/modules/queue/kafka/consumer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAStD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,W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AAC,EAAE,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,GAAY,EAAE,EAAE;YAC9D,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC,KAAY,EAAE,EAAE;YACpE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,KAAK,CAAC,CAAC;YAC/E,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { sleep } from '@/utilities/sleep.utility';\nimport { toError } from '@/utilities/promise.utility';\nimport type {\n ConsumerGroupJoinPayload,\n ConsumerGroupLeavePayload,\n ConsumerGroupRebalancePayload,\n ConsumerHeartbeatErrorPayload,\n MessagesStream,\n Offsets,\n} from '@platformatic/kafka';\nimport { Consumer } from '@platformatic/kafka';\nimport { invokeHook } from '../common';\nimport { BaseKafkaHelper } from './base';\nimport { KafkaClientEvents, KafkaDefaults, KafkaHealthStatuses } from './common/constants';\nimport type {\n IKafkaConsumeStartOptions,\n IKafkaConsumerOptions,\n TKafkaGroupJoinCallback,\n TKafkaGroupLeaveCallback,\n TKafkaGroupRebalanceCallback,\n TKafkaHeartbeatErrorCallback,\n TKafkaLagCallback,\n TKafkaLagErrorCallback,\n TKafkaMessageCallback,\n TKafkaMessageDoneCallback,\n TKafkaMessageErrorCallback,\n TKafkaReconnectErrorCallback,\n TKafkaStreamErrorCallback,\n} from './common/types';\n\n/**\n * Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.\n *\n * Every member below is `protected`, not `private`, so a consumer extends this class instead of forking it. That visibility is not a stable contract between minor versions.\n */\nexport class KafkaConsumerHelper<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n> extends BaseKafkaHelper<Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>> {\n protected stream: MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null =\n null;\n protected consumeLoop: Promise<void> | null = null;\n protected consumeStartOptions: IKafkaConsumeStartOptions | null = null;\n protected lagMonitoringActive = false;\n protected lagMonitoringOptions: { topics: string[]; interval?: number } | null = null;\n protected sessionLikelyStale = false;\n\n protected readonly onMessage?: TKafkaMessageCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageDone?: TKafkaMessageDoneCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageError?: TKafkaMessageErrorCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onStreamError?: TKafkaStreamErrorCallback;\n protected readonly onReconnectError?: TKafkaReconnectErrorCallback;\n\n protected readonly onGroupJoin?: TKafkaGroupJoinCallback;\n protected readonly onGroupLeave?: TKafkaGroupLeaveCallback;\n protected readonly onGroupRebalance?: TKafkaGroupRebalanceCallback;\n protected readonly onHeartbeatError?: TKafkaHeartbeatErrorCallback;\n\n protected readonly onLag?: TKafkaLagCallback;\n protected readonly onLagError?: TKafkaLagErrorCallback;\n\n protected readonly initialOptions: IKafkaConsumerOptions<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n\n constructor(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n super({\n scope: KafkaConsumerHelper.name,\n identifier: opts.identifier ?? 'kafka-consumer',\n shutdownTimeout: opts.shutdownTimeout,\n client: KafkaConsumerHelper.buildConsumerClient(opts),\n onBrokerConnect: opts.onBrokerConnect,\n onBrokerDisconnect: opts.onBrokerDisconnect,\n });\n\n this.initialOptions = opts;\n this.onMessage = opts.onMessage;\n this.onMessageDone = opts.onMessageDone;\n this.onMessageError = opts.onMessageError;\n this.onStreamError = opts.onStreamError;\n this.onReconnectError = opts.onReconnectError;\n this.onGroupJoin = opts.onGroupJoin;\n this.onGroupLeave = opts.onGroupLeave;\n this.onGroupRebalance = opts.onGroupRebalance;\n this.onHeartbeatError = opts.onHeartbeatError;\n this.onLag = opts.onLag;\n this.onLagError = opts.onLagError;\n\n this.configureBrokerEvents();\n\n this.logger.info(\n '[constructor] Kafka Consumer CREATED | ClientId: %s | GroupId: %s | Brokers: %j',\n opts.clientId,\n opts.groupId,\n opts.bootstrapBrokers,\n );\n }\n\n static newInstance<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n return new KafkaConsumerHelper<KeyType, ValueType, HeaderKeyType, HeaderValueType>(opts);\n }\n\n /** The instance seam every rebuild goes through; the constructor alone uses the static factory because no instance exists yet. Override this to hand a rebuilt consumer different options or a test double. */\n protected buildClient(opts: {\n options: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return KafkaConsumerHelper.buildConsumerClient(opts.options);\n }\n\n protected static buildConsumerClient<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(\n opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return new Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>({\n clientId: opts.clientId,\n bootstrapBrokers: opts.bootstrapBrokers,\n sasl: opts.sasl,\n tls: opts.tls,\n ssl: opts.ssl,\n connectTimeout: opts.connectTimeout,\n requestTimeout: opts.requestTimeout,\n groupId: opts.groupId,\n groupInstanceId: opts.groupInstanceId,\n groupProtocol: opts.groupProtocol ?? KafkaDefaults.GROUP_PROTOCOL,\n deserializers: opts.deserializers,\n autocommit: opts.autocommit ?? KafkaDefaults.AUTOCOMMIT,\n sessionTimeout: opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n heartbeatInterval: opts.heartbeatInterval ?? KafkaDefaults.HEARTBEAT_INTERVAL,\n rebalanceTimeout:\n opts.rebalanceTimeout ?? opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n highWaterMark: opts.highWaterMark ?? KafkaDefaults.HIGH_WATER_MARK,\n minBytes: opts.minBytes ?? KafkaDefaults.MIN_BYTES,\n maxBytes: opts.maxBytes ?? KafkaDefaults.MAX_BYTES,\n maxWaitTime: opts.maxWaitTime ?? KafkaDefaults.MAX_WAIT_TIME,\n metadataMaxAge: opts.metadataMaxAge ?? KafkaDefaults.METADATA_MAX_AGE,\n retries: opts.retries ?? KafkaDefaults.RETRIES,\n retryDelay: opts.retryDelay ?? KafkaDefaults.RETRY_DELAY,\n registry: opts.registry,\n });\n }\n\n getConsumer(): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return this.client;\n }\n\n getStream(): MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null {\n return this.stream;\n }\n\n override isReady(): boolean {\n return this.healthStatus === KafkaHealthStatuses.CONNECTED && this.client.isActive();\n }\n\n async start(opts: IKafkaConsumeStartOptions): Promise<void> {\n if (this.stream) {\n this.logger.warn('[start] Consumer already started, ignoring duplicate start call');\n return;\n }\n\n this.logger.info('[start] Starting consumer | Topics: %j', opts.topics);\n\n this.consumeStartOptions = opts;\n this.stream = await this.client.consume({\n topics: opts.topics,\n mode: opts.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: opts.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Successful consume() means we're freshly joined to the group; clear any stale-session flag set during initial broker negotiation (e.g. a transient BROKER_DISCONNECT during bootstrap).\n this.sessionLikelyStale = false;\n\n // Always attached, hook or not: a stream 'error' with ZERO listeners is rethrown by EventEmitter as an uncaught exception, so a pull-style consumer (start() + getStream(), no onMessage/onMessageError) would take the whole process down on the first broker drop.\n const startedStream = this.stream;\n startedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('start').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({ error: streamError, scope: 'start', stream: startedStream });\n });\n\n if (this.onMessage) {\n const loop = this.startConsumeLoop({\n messageHandler: this.onMessage,\n doneHandler: this.onMessageDone,\n errorHandler: this.onMessageError,\n reconnectDelayMs: opts.reconnectDelayMs ?? KafkaDefaults.RECONNECT_DELAY,\n maxReconnectAttempts: opts.maxReconnectAttempts ?? KafkaDefaults.MAX_RECONNECT_ATTEMPTS,\n }).finally(() => {\n // A finished loop (exhausted reconnects or shutdown) no longer reports stream errors; the listeners take over.\n if (this.consumeLoop === loop) {\n this.consumeLoop = null;\n }\n });\n this.consumeLoop = loop;\n }\n\n this.logger.info('[start] Consumer started | Topics: %j', opts.topics);\n }\n\n startLagMonitoring(opts: { topics: string[]; interval?: number }): void {\n if (this.lagMonitoringActive) {\n this.logger.warn(\n '[startLagMonitoring] Lag monitoring already active, ignoring duplicate call',\n );\n return;\n }\n\n const interval = opts.interval ?? KafkaDefaults.LAG_MONITOR_INTERVAL;\n this.client.startLagMonitoring({ topics: opts.topics }, interval);\n this.lagMonitoringActive = true;\n this.lagMonitoringOptions = { topics: opts.topics, interval };\n\n this.logger.info(\n '[startLagMonitoring] Lag monitoring STARTED | Topics: %j | Interval: %dms',\n opts.topics,\n interval,\n );\n }\n\n stopLagMonitoring(): void {\n if (!this.lagMonitoringActive) {\n return;\n }\n\n this.client.stopLagMonitoring();\n this.lagMonitoringActive = false;\n this.lagMonitoringOptions = null;\n\n this.logger.info('[stopLagMonitoring] Lag monitoring STOPPED');\n }\n\n protected override closeClient(): Promise<void> {\n return this.closeClientWithCallback();\n }\n\n async close(opts?: { isForce?: boolean }): Promise<void> {\n const force = opts?.isForce ?? false;\n\n this.stopLagMonitoring();\n await this.closeStream();\n\n if (force) {\n await this.closeClient();\n } else {\n try {\n await this.gracefulCloseClient();\n } catch (error) {\n this.logger.warn('[close] Graceful shutdown timed out, forcing close | Error: %s', error);\n await this.closeClient();\n }\n }\n\n this.resetHealthState();\n this.logger.info('[close] Consumer closed | Force: %s', force);\n }\n\n protected async startConsumeLoop(opts: {\n messageHandler: TKafkaMessageCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n doneHandler?: TKafkaMessageDoneCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n }): Promise<void> {\n const { messageHandler, doneHandler, errorHandler, reconnectDelayMs, maxReconnectAttempts } =\n opts;\n\n const messages = this.consumeMessages({\n reconnectDelayMs,\n maxReconnectAttempts,\n errorHandler,\n });\n for await (const message of messages) {\n try {\n await messageHandler({ message });\n await doneHandler?.({ message });\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[startConsumeLoop] Message processing error: %s',\n normalizedError.message,\n );\n invokeHook({\n logger: this.logger,\n scope: 'startConsumeLoop',\n execution: () => errorHandler?.({ error: normalizedError, message }),\n });\n }\n }\n }\n\n protected async *consumeMessages(opts: {\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n const { reconnectDelayMs, maxReconnectAttempts, errorHandler } = opts;\n let consecutiveErrors = 0;\n\n while (true) {\n if (this.stream) {\n yield* this.drainStream({ errorHandler });\n }\n\n if (!this.consumeStartOptions) {\n this.logger.info('[consumeMessages] Shutdown requested, exiting consume loop');\n return;\n }\n\n consecutiveErrors++;\n if (consecutiveErrors > maxReconnectAttempts) {\n this.logger.error(\n '[consumeMessages] All %d reconnect attempts exhausted | Topics: %j',\n maxReconnectAttempts,\n this.consumeStartOptions?.topics,\n );\n return;\n }\n\n await this.attemptReconnect({\n attempt: consecutiveErrors,\n maxAttempts: maxReconnectAttempts,\n delayMs: reconnectDelayMs,\n errorHandler,\n });\n\n if (!this.consumeStartOptions) {\n this.logger.info(\n '[consumeMessages] Shutdown requested during reconnect, exiting consume loop',\n );\n return;\n }\n\n if (this.stream) {\n consecutiveErrors = 0;\n }\n }\n }\n\n /** Silent only while the consume loop is alive AND the erroring stream is the one it drains - the iterator then reports the same error once. A dead or replaced stream, or pull mode, reports here. */\n protected reportStreamError(opts: { error: Error; scope: string; stream: unknown }): void {\n if (this.consumeLoop && this.stream === opts.stream) {\n return;\n }\n\n invokeHook({\n logger: this.logger,\n scope: opts.scope,\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: opts.error })\n : this.onMessageError?.({ error: opts.error }),\n });\n }\n\n protected async *drainStream(opts: {\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n this.logger.debug('[drainStream] Consuming | Topics: %j', this.consumeStartOptions?.topics);\n\n try {\n yield* this.stream!;\n this.logger.warn(\n '[drainStream] Stream ended normally | Topics: %j',\n this.consumeStartOptions?.topics,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[drainStream] Stream error: %s | Topics: %j',\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'drainStream',\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: normalizedError })\n : opts.errorHandler?.({ error: normalizedError }),\n });\n }\n\n this.destroyDeadStream();\n }\n\n protected async attemptReconnect(opts: {\n attempt: number;\n maxAttempts: number;\n delayMs: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Promise<void> {\n const { attempt, maxAttempts, delayMs, errorHandler } = opts;\n\n this.logger.info(\n '[attemptReconnect] Reconnecting %d/%d in %dms | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n delayMs,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n await sleep(delayMs);\n\n if (!this.consumeStartOptions) {\n return;\n }\n\n const shouldRebuildClient = this.sessionLikelyStale;\n\n if (shouldRebuildClient) {\n this.logger.warn(\n '[attemptReconnect] Session stale flag is set, will rebuild client | Attempt: %d',\n attempt,\n );\n }\n\n if (shouldRebuildClient) {\n try {\n await this.rebuildClient();\n this.sessionLikelyStale = false;\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Client rebuild failed (%d/%d): %s | Topics: %j',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n return;\n }\n }\n\n try {\n this.stream = await this.client.consume({\n topics: this.consumeStartOptions.topics,\n mode: this.consumeStartOptions.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: this.consumeStartOptions.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Always attached, hook or not, like the listener in start(): a stream 'error' with ZERO listeners is rethrown by EventEmitter and takes the process down.\n const reconnectedStream = this.stream;\n reconnectedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('attemptReconnect').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({\n error: streamError,\n scope: 'attemptReconnect',\n stream: reconnectedStream,\n });\n });\n\n this.sessionLikelyStale = false;\n\n this.logger.info(\n '[attemptReconnect] Reconnected successfully | Topics: %j | Attempt: %d | Rebuilt: %s',\n this.consumeStartOptions.topics,\n attempt,\n shouldRebuildClient,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Failed (%d/%d): %s | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n }\n }\n\n protected async rebuildClient(): Promise<void> {\n this.logger.warn(\n '[rebuildClient] All brokers were disconnected; rebuilding @platformatic/kafka ' +\n 'Consumer to force a clean group rejoin (cached session state is stale)',\n );\n\n const oldClient = this.client;\n const newClient = this.buildClient({ options: this.initialOptions });\n\n this.swapClient(newClient);\n\n if (this.lagMonitoringOptions) {\n const opts = this.lagMonitoringOptions;\n this.lagMonitoringActive = false; // reset so startLagMonitoring won't refuse\n try {\n this.startLagMonitoring(opts);\n this.logger.info(\n '[rebuildClient] Lag monitoring re-armed on new client | Topics: %j',\n opts.topics,\n );\n } catch (error) {\n this.logger.warn(\n '[rebuildClient] Failed to restart lag monitoring on new client | Error: %s',\n toError(error).message,\n );\n }\n }\n\n this.closeOldClient(oldClient).catch((error) => {\n this.logger.warn(\n '[rebuildClient] background close of old client failed (ignored) | Error: %s',\n toError(error).message,\n );\n });\n }\n\n protected async closeOldClient(\n oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Promise<void> {\n let timeoutHandle: NodeJS.Timeout | null = null;\n try {\n await Promise.race([\n new Promise<void>((resolve, reject) => {\n oldClient.close(true, (normalizedError?: Error | null) => {\n if (normalizedError) {\n reject(normalizedError);\n } else {\n resolve();\n }\n });\n }),\n new Promise<void>((resolve) => {\n timeoutHandle = setTimeout(resolve, this.shutdownTimeout);\n }),\n ]);\n } finally {\n if (timeoutHandle !== null) {\n clearTimeout(timeoutHandle);\n }\n }\n }\n\n protected handleAllBrokersDown(reason: 'disconnected' | 'failed'): void {\n if (this.getConnectedBrokerCount() !== 0) {\n return;\n }\n this.sessionLikelyStale = true;\n if (this.stream) {\n this.logger.warn(\n '[configureBrokerEvents] All brokers %s, destroying stream to trigger reconnect',\n reason,\n );\n this.destroyDeadStream();\n }\n }\n\n protected destroyDeadStream(): void {\n this.stream?.destroy(getError({ message: '[destroyDeadStream] All brokers disconnected' }));\n this.stream = null;\n }\n\n protected async closeStream(): Promise<void> {\n const stream = this.stream;\n this.stream = null;\n this.consumeStartOptions = null;\n\n try {\n await stream?.close();\n } catch (error) {\n this.logger.warn('[closeStream] Error closing stream: %s', toError(error).message);\n }\n\n await this.consumeLoop;\n this.consumeLoop = null;\n }\n\n protected override unconfigureBrokerEvents(): void {\n super.unconfigureBrokerEvents();\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_JOIN);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_LEAVE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_REBALANCE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG_ERROR);\n }\n\n protected override configureBrokerEvents(): void {\n super.configureBrokerEvents();\n\n this.client.on(KafkaClientEvents.BROKER_DISCONNECT, () => {\n this.handleAllBrokersDown('disconnected');\n });\n this.client.on(KafkaClientEvents.BROKER_FAILED, () => {\n this.handleAllBrokersDown('failed');\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload: ConsumerGroupJoinPayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d',\n payload.groupId,\n payload.memberId,\n payload.generationId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupJoin?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n generationId: payload.generationId,\n }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_LEAVE, (payload: ConsumerGroupLeavePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group LEFT | GroupId: %s | MemberId: %s',\n payload.groupId,\n payload.memberId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupLeave?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n });\n\n this.client.on(\n KafkaClientEvents.CONSUMER_GROUP_REBALANCE,\n (payload: ConsumerGroupRebalancePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group REBALANCE | GroupId: %s',\n payload.groupId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onGroupRebalance?.({ groupId: payload.groupId }),\n });\n },\n );\n\n this.client.on(\n KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR,\n (payload: ConsumerHeartbeatErrorPayload) => {\n this.logger.error(\n '[configureConsumerEvents] Heartbeat ERROR | GroupId: %s | MemberId: %s | Error: %s',\n payload.groupId,\n payload.memberId,\n payload.error,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onHeartbeatError?.({\n error: payload.error,\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n },\n );\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG, (lag: Offsets) => {\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLag?.({ lag }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG_ERROR, (error: Error) => {\n this.logger.error('[configureConsumerEvents] Lag monitoring ERROR: %s', error);\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLagError?.({ error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f,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,KAAK,CACd,CAAC;YACF,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CACd,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACtB,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;iBAC3B,CAAC;aACL,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,YAAY,EAAE,CAAC,GAAY,EAAE,EAAE;YAC9D,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;aACvC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,EAAE,CAAC,KAAY,EAAE,EAAE;YACpE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,KAAK,CAAC,CAAC;YAC/E,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAuB;gBAC9B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;aAC9C,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { sleep } from '@/utilities/sleep.utility';\nimport { toError } from '@/utilities/promise.utility';\nimport type {\n ConsumerGroupJoinPayload,\n ConsumerGroupLeavePayload,\n ConsumerGroupRebalancePayload,\n ConsumerHeartbeatErrorPayload,\n MessagesStream,\n Offsets,\n} from '@platformatic/kafka';\nimport { Consumer } from '@platformatic/kafka';\nimport { invokeHook } from '../common';\nimport { BaseKafkaHelper } from './base';\nimport {\n KafkaBrokersDownReasons,\n KafkaClientEvents,\n KafkaDefaults,\n KafkaHealthStatuses,\n type TKafkaBrokersDownReason,\n} from './common/constants';\nimport type {\n IKafkaConsumeStartOptions,\n IKafkaConsumerOptions,\n TKafkaGroupJoinCallback,\n TKafkaGroupLeaveCallback,\n TKafkaGroupRebalanceCallback,\n TKafkaHeartbeatErrorCallback,\n TKafkaLagCallback,\n TKafkaLagErrorCallback,\n TKafkaMessageCallback,\n TKafkaMessageDoneCallback,\n TKafkaMessageErrorCallback,\n TKafkaReconnectErrorCallback,\n TKafkaStreamErrorCallback,\n} from './common/types';\n\n/**\n * Wrapper around `@platformatic/kafka` Consumer with lifecycle management, health tracking, graceful shutdown, message callbacks, and lag monitoring.\n *\n * Every member below is `protected`, not `private`, so a consumer extends this class instead of forking it. That visibility is not a stable contract between minor versions.\n */\nexport class KafkaConsumerHelper<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n> extends BaseKafkaHelper<Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>> {\n protected stream: MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null =\n null;\n protected consumeLoop: Promise<void> | null = null;\n protected consumeStartOptions: IKafkaConsumeStartOptions | null = null;\n protected lagMonitoringActive = false;\n protected lagMonitoringOptions: { topics: string[]; interval?: number } | null = null;\n protected sessionLikelyStale = false;\n\n protected readonly onMessage?: TKafkaMessageCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageDone?: TKafkaMessageDoneCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onMessageError?: TKafkaMessageErrorCallback<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n protected readonly onStreamError?: TKafkaStreamErrorCallback;\n protected readonly onReconnectError?: TKafkaReconnectErrorCallback;\n\n protected readonly onGroupJoin?: TKafkaGroupJoinCallback;\n protected readonly onGroupLeave?: TKafkaGroupLeaveCallback;\n protected readonly onGroupRebalance?: TKafkaGroupRebalanceCallback;\n protected readonly onHeartbeatError?: TKafkaHeartbeatErrorCallback;\n\n protected readonly onLag?: TKafkaLagCallback;\n protected readonly onLagError?: TKafkaLagErrorCallback;\n\n protected readonly initialOptions: IKafkaConsumerOptions<\n KeyType,\n ValueType,\n HeaderKeyType,\n HeaderValueType\n >;\n\n constructor(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n super({\n scope: KafkaConsumerHelper.name,\n identifier: opts.identifier ?? 'kafka-consumer',\n shutdownTimeout: opts.shutdownTimeout,\n client: KafkaConsumerHelper.buildConsumerClient(opts),\n onBrokerConnect: opts.onBrokerConnect,\n onBrokerDisconnect: opts.onBrokerDisconnect,\n });\n\n this.initialOptions = opts;\n this.onMessage = opts.onMessage;\n this.onMessageDone = opts.onMessageDone;\n this.onMessageError = opts.onMessageError;\n this.onStreamError = opts.onStreamError;\n this.onReconnectError = opts.onReconnectError;\n this.onGroupJoin = opts.onGroupJoin;\n this.onGroupLeave = opts.onGroupLeave;\n this.onGroupRebalance = opts.onGroupRebalance;\n this.onHeartbeatError = opts.onHeartbeatError;\n this.onLag = opts.onLag;\n this.onLagError = opts.onLagError;\n\n this.configureBrokerEvents();\n\n this.logger.info(\n '[constructor] Kafka Consumer CREATED | ClientId: %s | GroupId: %s | Brokers: %j',\n opts.clientId,\n opts.groupId,\n opts.bootstrapBrokers,\n );\n }\n\n static newInstance<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>) {\n return new KafkaConsumerHelper<KeyType, ValueType, HeaderKeyType, HeaderValueType>(opts);\n }\n\n /** The instance seam every rebuild goes through; the constructor alone uses the static factory because no instance exists yet. Override this to hand a rebuilt consumer different options or a test double. */\n protected buildClient(opts: {\n options: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return KafkaConsumerHelper.buildConsumerClient(opts.options);\n }\n\n protected static buildConsumerClient<\n KeyType = string,\n ValueType = string,\n HeaderKeyType = string,\n HeaderValueType = string,\n >(\n opts: IKafkaConsumerOptions<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return new Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>({\n clientId: opts.clientId,\n bootstrapBrokers: opts.bootstrapBrokers,\n sasl: opts.sasl,\n tls: opts.tls,\n ssl: opts.ssl,\n connectTimeout: opts.connectTimeout,\n requestTimeout: opts.requestTimeout,\n groupId: opts.groupId,\n groupInstanceId: opts.groupInstanceId,\n groupProtocol: opts.groupProtocol ?? KafkaDefaults.GROUP_PROTOCOL,\n deserializers: opts.deserializers,\n autocommit: opts.autocommit ?? KafkaDefaults.AUTOCOMMIT,\n sessionTimeout: opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n heartbeatInterval: opts.heartbeatInterval ?? KafkaDefaults.HEARTBEAT_INTERVAL,\n rebalanceTimeout:\n opts.rebalanceTimeout ?? opts.sessionTimeout ?? KafkaDefaults.SESSION_TIMEOUT,\n highWaterMark: opts.highWaterMark ?? KafkaDefaults.HIGH_WATER_MARK,\n minBytes: opts.minBytes ?? KafkaDefaults.MIN_BYTES,\n maxBytes: opts.maxBytes ?? KafkaDefaults.MAX_BYTES,\n maxWaitTime: opts.maxWaitTime ?? KafkaDefaults.MAX_WAIT_TIME,\n metadataMaxAge: opts.metadataMaxAge ?? KafkaDefaults.METADATA_MAX_AGE,\n retries: opts.retries ?? KafkaDefaults.RETRIES,\n retryDelay: opts.retryDelay ?? KafkaDefaults.RETRY_DELAY,\n registry: opts.registry,\n });\n }\n\n getConsumer(): Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType> {\n return this.client;\n }\n\n getStream(): MessagesStream<KeyType, ValueType, HeaderKeyType, HeaderValueType> | null {\n return this.stream;\n }\n\n override isReady(): boolean {\n return this.healthStatus === KafkaHealthStatuses.CONNECTED && this.client.isActive();\n }\n\n async start(opts: IKafkaConsumeStartOptions): Promise<void> {\n if (this.stream) {\n this.logger.warn('[start] Consumer already started, ignoring duplicate start call');\n return;\n }\n\n this.logger.info('[start] Starting consumer | Topics: %j', opts.topics);\n\n this.consumeStartOptions = opts;\n this.stream = await this.client.consume({\n topics: opts.topics,\n mode: opts.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: opts.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Successful consume() means we're freshly joined to the group; clear any stale-session flag set during initial broker negotiation (e.g. a transient BROKER_DISCONNECT during bootstrap).\n this.sessionLikelyStale = false;\n\n // Always attached, hook or not: a stream 'error' with ZERO listeners is rethrown by EventEmitter as an uncaught exception, so a pull-style consumer (start() + getStream(), no onMessage/onMessageError) would take the whole process down on the first broker drop.\n const startedStream = this.stream;\n startedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('start').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({ error: streamError, scope: 'start', stream: startedStream });\n });\n\n if (this.onMessage) {\n const loop = this.startConsumeLoop({\n messageHandler: this.onMessage,\n doneHandler: this.onMessageDone,\n errorHandler: this.onMessageError,\n reconnectDelayMs: opts.reconnectDelayMs ?? KafkaDefaults.RECONNECT_DELAY,\n maxReconnectAttempts: opts.maxReconnectAttempts ?? KafkaDefaults.MAX_RECONNECT_ATTEMPTS,\n }).finally(() => {\n // A finished loop (exhausted reconnects or shutdown) no longer reports stream errors; the listeners take over.\n if (this.consumeLoop === loop) {\n this.consumeLoop = null;\n }\n });\n this.consumeLoop = loop;\n }\n\n this.logger.info('[start] Consumer started | Topics: %j', opts.topics);\n }\n\n startLagMonitoring(opts: { topics: string[]; interval?: number }): void {\n if (this.lagMonitoringActive) {\n this.logger.warn(\n '[startLagMonitoring] Lag monitoring already active, ignoring duplicate call',\n );\n return;\n }\n\n const interval = opts.interval ?? KafkaDefaults.LAG_MONITOR_INTERVAL;\n this.client.startLagMonitoring({ topics: opts.topics }, interval);\n this.lagMonitoringActive = true;\n this.lagMonitoringOptions = { topics: opts.topics, interval };\n\n this.logger.info(\n '[startLagMonitoring] Lag monitoring STARTED | Topics: %j | Interval: %dms',\n opts.topics,\n interval,\n );\n }\n\n stopLagMonitoring(): void {\n if (!this.lagMonitoringActive) {\n return;\n }\n\n this.client.stopLagMonitoring();\n this.lagMonitoringActive = false;\n this.lagMonitoringOptions = null;\n\n this.logger.info('[stopLagMonitoring] Lag monitoring STOPPED');\n }\n\n protected override closeClient(): Promise<void> {\n return this.closeClientWithCallback();\n }\n\n async close(opts?: { isForce?: boolean }): Promise<void> {\n const force = opts?.isForce ?? false;\n\n this.stopLagMonitoring();\n await this.closeStream();\n\n if (force) {\n await this.closeClient();\n } else {\n try {\n await this.gracefulCloseClient();\n } catch (error) {\n this.logger.warn('[close] Graceful shutdown timed out, forcing close | Error: %s', error);\n await this.closeClient();\n }\n }\n\n this.resetHealthState();\n this.logger.info('[close] Consumer closed | Force: %s', force);\n }\n\n protected async startConsumeLoop(opts: {\n messageHandler: TKafkaMessageCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n doneHandler?: TKafkaMessageDoneCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n }): Promise<void> {\n const { messageHandler, doneHandler, errorHandler, reconnectDelayMs, maxReconnectAttempts } =\n opts;\n\n const messages = this.consumeMessages({\n reconnectDelayMs,\n maxReconnectAttempts,\n errorHandler,\n });\n for await (const message of messages) {\n try {\n await messageHandler({ message });\n await doneHandler?.({ message });\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[startConsumeLoop] Message processing error: %s',\n normalizedError.message,\n );\n invokeHook({\n logger: this.logger,\n scope: 'startConsumeLoop',\n execution: () => errorHandler?.({ error: normalizedError, message }),\n });\n }\n }\n }\n\n protected async *consumeMessages(opts: {\n reconnectDelayMs: number;\n maxReconnectAttempts: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n const { reconnectDelayMs, maxReconnectAttempts, errorHandler } = opts;\n let consecutiveErrors = 0;\n\n while (true) {\n if (this.stream) {\n yield* this.drainStream({ errorHandler });\n }\n\n if (!this.consumeStartOptions) {\n this.logger.info('[consumeMessages] Shutdown requested, exiting consume loop');\n return;\n }\n\n consecutiveErrors++;\n if (consecutiveErrors > maxReconnectAttempts) {\n this.logger.error(\n '[consumeMessages] All %d reconnect attempts exhausted | Topics: %j',\n maxReconnectAttempts,\n this.consumeStartOptions?.topics,\n );\n return;\n }\n\n await this.attemptReconnect({\n attempt: consecutiveErrors,\n maxAttempts: maxReconnectAttempts,\n delayMs: reconnectDelayMs,\n errorHandler,\n });\n\n if (!this.consumeStartOptions) {\n this.logger.info(\n '[consumeMessages] Shutdown requested during reconnect, exiting consume loop',\n );\n return;\n }\n\n if (this.stream) {\n consecutiveErrors = 0;\n }\n }\n }\n\n /** Silent only while the consume loop is alive AND the erroring stream is the one it drains - the iterator then reports the same error once. A dead or replaced stream, or pull mode, reports here. */\n protected reportStreamError(opts: { error: Error; scope: string; stream: unknown }): void {\n if (this.consumeLoop && this.stream === opts.stream) {\n return;\n }\n\n invokeHook({\n logger: this.logger,\n scope: opts.scope,\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: opts.error })\n : this.onMessageError?.({ error: opts.error }),\n });\n }\n\n protected async *drainStream(opts: {\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }) {\n this.logger.debug('[drainStream] Consuming | Topics: %j', this.consumeStartOptions?.topics);\n\n try {\n yield* this.stream!;\n this.logger.warn(\n '[drainStream] Stream ended normally | Topics: %j',\n this.consumeStartOptions?.topics,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[drainStream] Stream error: %s | Topics: %j',\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'drainStream',\n execution: () =>\n this.onStreamError\n ? this.onStreamError({ error: normalizedError })\n : opts.errorHandler?.({ error: normalizedError }),\n });\n }\n\n this.destroyDeadStream();\n }\n\n protected async attemptReconnect(opts: {\n attempt: number;\n maxAttempts: number;\n delayMs: number;\n errorHandler?: TKafkaMessageErrorCallback<KeyType, ValueType, HeaderKeyType, HeaderValueType>;\n }): Promise<void> {\n const { attempt, maxAttempts, delayMs, errorHandler } = opts;\n\n this.logger.info(\n '[attemptReconnect] Reconnecting %d/%d in %dms | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n delayMs,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n await sleep(delayMs);\n\n if (!this.consumeStartOptions) {\n return;\n }\n\n const shouldRebuildClient = this.sessionLikelyStale;\n\n if (shouldRebuildClient) {\n this.logger.warn(\n '[attemptReconnect] Session stale flag is set, will rebuild client | Attempt: %d',\n attempt,\n );\n }\n\n if (shouldRebuildClient) {\n try {\n await this.rebuildClient();\n this.sessionLikelyStale = false;\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Client rebuild failed (%d/%d): %s | Topics: %j',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n return;\n }\n }\n\n try {\n this.stream = await this.client.consume({\n topics: this.consumeStartOptions.topics,\n mode: this.consumeStartOptions.mode ?? KafkaDefaults.CONSUME_MODE,\n fallbackMode: this.consumeStartOptions.fallbackMode ?? KafkaDefaults.CONSUME_FALLBACK_MODE,\n });\n\n // Always attached, hook or not, like the listener in start(): a stream 'error' with ZERO listeners is rethrown by EventEmitter and takes the process down.\n const reconnectedStream = this.stream;\n reconnectedStream.on(KafkaClientEvents.STREAM_ERROR, (streamError: Error) => {\n this.logger.for('attemptReconnect').error('Kafka stream ERROR | Error: %s', streamError);\n this.reportStreamError({\n error: streamError,\n scope: 'attemptReconnect',\n stream: reconnectedStream,\n });\n });\n\n this.sessionLikelyStale = false;\n\n this.logger.info(\n '[attemptReconnect] Reconnected successfully | Topics: %j | Attempt: %d | Rebuilt: %s',\n this.consumeStartOptions.topics,\n attempt,\n shouldRebuildClient,\n );\n } catch (error) {\n const normalizedError = toError(error);\n this.logger.error(\n '[attemptReconnect] Failed (%d/%d): %s | Topics: %j | ConnectedBrokers: %d',\n attempt,\n maxAttempts,\n normalizedError.message,\n this.consumeStartOptions?.topics,\n this.getConnectedBrokerCount(),\n );\n invokeHook({\n logger: this.logger,\n scope: 'attemptReconnect',\n execution: () =>\n this.onReconnectError\n ? this.onReconnectError({ error: normalizedError, attempt, maxAttempts })\n : errorHandler?.({ error: normalizedError }),\n });\n }\n }\n\n protected async rebuildClient(): Promise<void> {\n this.logger.warn(\n '[rebuildClient] All brokers were disconnected; rebuilding @platformatic/kafka ' +\n 'Consumer to force a clean group rejoin (cached session state is stale)',\n );\n\n const oldClient = this.client;\n const newClient = this.buildClient({ options: this.initialOptions });\n\n this.swapClient(newClient);\n\n if (this.lagMonitoringOptions) {\n const opts = this.lagMonitoringOptions;\n this.lagMonitoringActive = false; // reset so startLagMonitoring won't refuse\n try {\n this.startLagMonitoring(opts);\n this.logger.info(\n '[rebuildClient] Lag monitoring re-armed on new client | Topics: %j',\n opts.topics,\n );\n } catch (error) {\n this.logger.warn(\n '[rebuildClient] Failed to restart lag monitoring on new client | Error: %s',\n toError(error).message,\n );\n }\n }\n\n this.closeOldClient(oldClient).catch((error) => {\n this.logger.warn(\n '[rebuildClient] background close of old client failed (ignored) | Error: %s',\n toError(error).message,\n );\n });\n }\n\n protected async closeOldClient(\n oldClient: Consumer<KeyType, ValueType, HeaderKeyType, HeaderValueType>,\n ): Promise<void> {\n let timeoutHandle: NodeJS.Timeout | null = null;\n try {\n await Promise.race([\n new Promise<void>((resolve, reject) => {\n oldClient.close(true, (normalizedError?: Error | null) => {\n if (normalizedError) {\n reject(normalizedError);\n } else {\n resolve();\n }\n });\n }),\n new Promise<void>((resolve) => {\n timeoutHandle = setTimeout(resolve, this.shutdownTimeout);\n }),\n ]);\n } finally {\n if (timeoutHandle !== null) {\n clearTimeout(timeoutHandle);\n }\n }\n }\n\n protected handleAllBrokersDown(reason: TKafkaBrokersDownReason): void {\n if (this.getConnectedBrokerCount() !== 0) {\n return;\n }\n this.sessionLikelyStale = true;\n if (this.stream) {\n this.logger.warn(\n '[configureBrokerEvents] All brokers %s, destroying stream to trigger reconnect',\n reason,\n );\n this.destroyDeadStream();\n }\n }\n\n protected destroyDeadStream(): void {\n this.stream?.destroy(getError({ message: '[destroyDeadStream] All brokers disconnected' }));\n this.stream = null;\n }\n\n protected async closeStream(): Promise<void> {\n const stream = this.stream;\n this.stream = null;\n this.consumeStartOptions = null;\n\n try {\n await stream?.close();\n } catch (error) {\n this.logger.warn('[closeStream] Error closing stream: %s', toError(error).message);\n }\n\n await this.consumeLoop;\n this.consumeLoop = null;\n }\n\n protected override unconfigureBrokerEvents(): void {\n super.unconfigureBrokerEvents();\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_JOIN);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_LEAVE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_GROUP_REBALANCE);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG);\n this.client.removeAllListeners(KafkaClientEvents.CONSUMER_LAG_ERROR);\n }\n\n protected override configureBrokerEvents(): void {\n super.configureBrokerEvents();\n\n this.client.on(KafkaClientEvents.BROKER_DISCONNECT, () => {\n this.handleAllBrokersDown(KafkaBrokersDownReasons.DISCONNECTED);\n });\n this.client.on(KafkaClientEvents.BROKER_FAILED, () => {\n this.handleAllBrokersDown(KafkaBrokersDownReasons.FAILED);\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_JOIN, (payload: ConsumerGroupJoinPayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group JOINED | GroupId: %s | MemberId: %s | GenerationId: %d',\n payload.groupId,\n payload.memberId,\n payload.generationId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupJoin?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n generationId: payload.generationId,\n }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_GROUP_LEAVE, (payload: ConsumerGroupLeavePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group LEFT | GroupId: %s | MemberId: %s',\n payload.groupId,\n payload.memberId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onGroupLeave?.({\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n });\n\n this.client.on(\n KafkaClientEvents.CONSUMER_GROUP_REBALANCE,\n (payload: ConsumerGroupRebalancePayload) => {\n this.logger.info(\n '[configureConsumerEvents] Group REBALANCE | GroupId: %s',\n payload.groupId,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onGroupRebalance?.({ groupId: payload.groupId }),\n });\n },\n );\n\n this.client.on(\n KafkaClientEvents.CONSUMER_HEARTBEAT_ERROR,\n (payload: ConsumerHeartbeatErrorPayload) => {\n this.logger.error(\n '[configureConsumerEvents] Heartbeat ERROR | GroupId: %s | MemberId: %s | Error: %s',\n payload.groupId,\n payload.memberId,\n payload.error,\n );\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () =>\n this.onHeartbeatError?.({\n error: payload.error,\n groupId: payload.groupId,\n memberId: payload.memberId,\n }),\n });\n },\n );\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG, (lag: Offsets) => {\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLag?.({ lag }),\n });\n });\n\n this.client.on(KafkaClientEvents.CONSUMER_LAG_ERROR, (error: Error) => {\n this.logger.error('[configureConsumerEvents] Lag monitoring ERROR: %s', error);\n invokeHook({\n logger: this.logger,\n scope: 'configureBrokerEvents',\n execution: () => this.onLagError?.({ error }),\n });\n });\n }\n}\n"]}
|
|
@@ -40,4 +40,25 @@ export declare class TemporalInclusivities {
|
|
|
40
40
|
static isValid(input: string): input is TTemporalInclusivity;
|
|
41
41
|
}
|
|
42
42
|
export type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;
|
|
43
|
+
/** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */
|
|
44
|
+
export declare class TemporalNameWidths {
|
|
45
|
+
static readonly NARROW = "narrow";
|
|
46
|
+
static readonly SHORT = "short";
|
|
47
|
+
static readonly LONG = "long";
|
|
48
|
+
static readonly SCHEME_SET: Set<string>;
|
|
49
|
+
static isValid(value: string): boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Valid name width values. */
|
|
52
|
+
export type TTemporalNameWidth = TConstValue<typeof TemporalNameWidths>;
|
|
53
|
+
/** A month name has no narrow form here: SHORT or LONG. */
|
|
54
|
+
export type TTemporalMonthNameWidth = Exclude<TTemporalNameWidth, typeof TemporalNameWidths.NARROW>;
|
|
55
|
+
/** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */
|
|
56
|
+
export declare class TemporalWrittenDateStyles {
|
|
57
|
+
static readonly NUMERIC = "numeric";
|
|
58
|
+
static readonly LONG = "long";
|
|
59
|
+
static readonly SCHEME_SET: Set<string>;
|
|
60
|
+
static isValid(value: string): boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Valid written date style values. */
|
|
63
|
+
export type TTemporalWrittenDateStyle = TConstValue<typeof TemporalWrittenDateStyles>;
|
|
43
64
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,kLAAkL;AAClL,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,WAAW,iBAAiB;IAC5C,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAUvB;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa;CAGtD;AAED,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,aAAa,CAAC,CAAC;AAE9D,2GAA2G;AAC3G,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,wGAAwG;AACxG,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,UAAU,CAAC;AAE/C,uGAAuG;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AM,GAAG,KAAK,IAAI,oBAAoB;CAG7D;AAED,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE7E,mGAAmG;AACnG,qBAAa,kBAAkB;IAC7B,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,KAAK,WAAW;IAChC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAAyD;IAEnF,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExE,2DAA2D;AAC3D,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,EAAE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAEpG,4FAA4F;AAC5F,qBAAa,yBAAyB;IACpC,MAAM,CAAC,QAAQ,CAAC,OAAO,aAAa;IACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU;IAE9B,MAAM,CAAC,QAAQ,CAAC,UAAU,cAA8C;IAExE,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED,uCAAuC;AACvC,MAAM,MAAM,yBAAyB,GAAG,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -57,4 +57,23 @@ export class TemporalInclusivities {
|
|
|
57
57
|
return this.SCHEME_SET.has(input);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
/** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */
|
|
61
|
+
export class TemporalNameWidths {
|
|
62
|
+
static { this.NARROW = 'narrow'; }
|
|
63
|
+
static { this.SHORT = 'short'; }
|
|
64
|
+
static { this.LONG = 'long'; }
|
|
65
|
+
static { this.SCHEME_SET = new Set([this.NARROW, this.SHORT, this.LONG]); }
|
|
66
|
+
static isValid(value) {
|
|
67
|
+
return this.SCHEME_SET.has(value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */
|
|
71
|
+
export class TemporalWrittenDateStyles {
|
|
72
|
+
static { this.NUMERIC = 'numeric'; }
|
|
73
|
+
static { this.LONG = 'long'; }
|
|
74
|
+
static { this.SCHEME_SET = new Set([this.NUMERIC, this.LONG]); }
|
|
75
|
+
static isValid(value) {
|
|
76
|
+
return this.SCHEME_SET.has(value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
60
79
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,YAAO,GAAG,SAAS,CAAC;aACpB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAE/C,uGAAuG;AACvG,MAAM,OAAO,sBAAsB;aACjB,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,0FAA0F;AAC1F,MAAM,OAAO,qBAAqB;aAChB,cAAS,GAAG,IAAI,CAAC;aACjB,cAAS,GAAG,IAAI,CAAC;aACjB,eAAU,GAAG,IAAI,CAAC;aAClB,aAAQ,GAAG,IAAI,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,UAAU;QACf,IAAI,CAAC,QAAQ;KACd,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday; a quarter is three calendar months from January, April, July or October. */\nexport class TemporalUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly QUARTER = 'quarter';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.QUARTER,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TTemporalUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalUnit = TConstValue<typeof TemporalUnits>;\n\n/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */\nexport const DEFAULT_TEMPORAL_TZ = 'UTC';\n\n/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */\nexport const DEFAULT_TEMPORAL_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';\n\n/** The locale name tokens and `formatIntl` write in when a helper is built without one. */\nexport const DEFAULT_TEMPORAL_LOCALE = 'en-US';\n\n/** How `formatDuration` writes: `compact` is `1d1h30m`; the others are the locale's own unit words. */\nexport class TemporalDurationStyles {\n static readonly COMPACT = 'compact';\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set([this.COMPACT, this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(input: string): input is TTemporalDurationStyle {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;\n\n/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */\nexport class TemporalInclusivities {\n static readonly EXCLUSIVE = '()';\n static readonly INCLUSIVE = '[]';\n static readonly START_ONLY = '[)';\n static readonly END_ONLY = '(]';\n\n static readonly SCHEME_SET = new Set([\n this.EXCLUSIVE,\n this.INCLUSIVE,\n this.START_ONLY,\n this.END_ONLY,\n ]);\n\n static isValid(input: string): input is TTemporalInclusivity {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,YAAO,GAAG,SAAS,CAAC;aACpB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,wGAAwG;AACxG,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAE/C,uGAAuG;AACvG,MAAM,OAAO,sBAAsB;aACjB,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,C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GAAG,CAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday; a quarter is three calendar months from January, April, July or October. */\nexport class TemporalUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly QUARTER = 'quarter';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.QUARTER,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TTemporalUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalUnit = TConstValue<typeof TemporalUnits>;\n\n/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */\nexport const DEFAULT_TEMPORAL_TZ = 'UTC';\n\n/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */\nexport const DEFAULT_TEMPORAL_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';\n\n/** The locale name tokens and `formatIntl` write in when a helper is built without one. */\nexport const DEFAULT_TEMPORAL_LOCALE = 'en-US';\n\n/** How `formatDuration` writes: `compact` is `1d1h30m`; the others are the locale's own unit words. */\nexport class TemporalDurationStyles {\n static readonly COMPACT = 'compact';\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set([this.COMPACT, this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(input: string): input is TTemporalDurationStyle {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;\n\n/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */\nexport class TemporalInclusivities {\n static readonly EXCLUSIVE = '()';\n static readonly INCLUSIVE = '[]';\n static readonly START_ONLY = '[)';\n static readonly END_ONLY = '(]';\n\n static readonly SCHEME_SET = new Set([\n this.EXCLUSIVE,\n this.INCLUSIVE,\n this.START_ONLY,\n this.END_ONLY,\n ]);\n\n static isValid(input: string): input is TTemporalInclusivity {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;\n\n/** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */\nexport class TemporalNameWidths {\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set<string>([this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid name width values. */\nexport type TTemporalNameWidth = TConstValue<typeof TemporalNameWidths>;\n\n/** A month name has no narrow form here: SHORT or LONG. */\nexport type TTemporalMonthNameWidth = Exclude<TTemporalNameWidth, typeof TemporalNameWidths.NARROW>;\n\n/** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */\nexport class TemporalWrittenDateStyles {\n static readonly NUMERIC = 'numeric';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set<string>([this.NUMERIC, this.LONG]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid written date style values. */\nexport type TTemporalWrittenDateStyle = TConstValue<typeof TemporalWrittenDateStyles>;\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TTemporalMonthNameWidth, type TTemporalNameWidth, type TTemporalWrittenDateStyle } from '../common/constants.js';
|
|
1
2
|
import type { ITemporalParts } from '../common/types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Month and weekday names, the AM/PM marker and the written date of one locale, as `Intl` spells
|
|
@@ -19,12 +20,12 @@ export declare class TemporalLocale {
|
|
|
19
20
|
/** `month` is 1-12. */
|
|
20
21
|
monthName(opts: {
|
|
21
22
|
month: number;
|
|
22
|
-
width:
|
|
23
|
+
width: TTemporalMonthNameWidth;
|
|
23
24
|
}): string;
|
|
24
25
|
/** `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */
|
|
25
26
|
weekdayName(opts: {
|
|
26
27
|
dayOfWeek: number;
|
|
27
|
-
width:
|
|
28
|
+
width: TTemporalNameWidth;
|
|
28
29
|
}): string;
|
|
29
30
|
/** The AM or PM marker the locale writes for `hour` (0-23), lower-cased by the locale's own rules when asked. */
|
|
30
31
|
dayPeriod(opts: {
|
|
@@ -35,7 +36,7 @@ export declare class TemporalLocale {
|
|
|
35
36
|
/** The wall-clock date the way the locale writes it: `numeric` is `10/14/2026`, `long` is `October 14, 2026`. */
|
|
36
37
|
writtenDate(opts: {
|
|
37
38
|
parts: ITemporalParts;
|
|
38
|
-
style:
|
|
39
|
+
style: TTemporalWrittenDateStyle;
|
|
39
40
|
}): string;
|
|
40
41
|
}
|
|
41
42
|
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../../../../src/modules/temporal/locale/locale.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAatD;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAqC;IAEpE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,UA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,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACrC,WAAW,CAAC,EAAE,OAAO,CAAC;KACvB,GAAG,MAAM;IAcV,iHAAiH;IACjH,WAAW,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,yBAAyB,CAAA;KAAE,GAAG,MAAM;CAWvF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HTTP } from '../../../common/constants/http.js';
|
|
2
2
|
import { getError } from '../../error/index.js';
|
|
3
|
+
import { TemporalWrittenDateStyles, } from '../common/constants.js';
|
|
3
4
|
/** A service writes a handful of locales; capped so caller-fed locales cannot grow it. */
|
|
4
5
|
const MAX_CACHED_LOCALES = 32;
|
|
5
6
|
const MONTHS = 12;
|
|
@@ -109,7 +110,7 @@ export class TemporalLocale {
|
|
|
109
110
|
/** The wall-clock date the way the locale writes it: `numeric` is `10/14/2026`, `long` is `October 14, 2026`. */
|
|
110
111
|
writtenDate(opts) {
|
|
111
112
|
const { parts, style } = opts;
|
|
112
|
-
const formatter = style ===
|
|
113
|
+
const formatter = style === TemporalWrittenDateStyles.NUMERIC
|
|
113
114
|
? this.formatterOf({ year: 'numeric', month: '2-digit', day: '2-digit' })
|
|
114
115
|
: this.formatterOf({ dateStyle: 'long' });
|
|
115
116
|
const date = new Date(0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/locale/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,IAAI,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ACzB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport type { ITemporalParts } from '../common/types';\n\n/** A service writes a handful of locales; capped so caller-fed locales cannot grow it. */\nconst MAX_CACHED_LOCALES = 32;\n\nconst MONTHS = 12;\nconst WEEKDAYS = 7;\nconst NOON = 12;\n\n/** A Monday: ISO weekday `n` is this date plus `n - 1` days. */\nconst MONDAY = Date.UTC(2024, 0, 1);\nconst DAY_MILLISECONDS = 86_400_000;\n\n/**\n * Month and weekday names, the AM/PM marker and the written date of one locale, as `Intl` spells\n * them. Every table is read once, on first use, from a fixed UTC date: the names belong to the\n * calendar, not to a time zone, so the wall clock is formatted as if it were UTC.\n */\nexport class TemporalLocale {\n private static readonly locales = new Map<string, TemporalLocale>();\n\n private readonly locale: string;\n private readonly tables = new Map<string, Array<string>>();\n private readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private constructor(opts: { locale: string }) {\n this.locale = opts.locale;\n }\n\n /** The locale's names; a malformed tag is a 400. */\n static of(opts: { locale: string }): TemporalLocale {\n const { locale } = opts;\n const cached = TemporalLocale.locales.get(locale);\n if (cached) {\n return cached;\n }\n\n try {\n Intl.getCanonicalLocales(locale);\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalLocale] invalid locale '${locale}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Full: the oldest locale makes room, so the 33rd locale is not rebuilt on every call.\n if (TemporalLocale.locales.size >= MAX_CACHED_LOCALES) {\n const oldest = TemporalLocale.locales.keys().next().value;\n if (oldest !== undefined) {\n TemporalLocale.locales.delete(oldest);\n }\n }\n const created = new TemporalLocale({ locale });\n TemporalLocale.locales.set(locale, created);\n return created;\n }\n\n private formatterOf(opts: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n const key = JSON.stringify(opts);\n const cached = this.formatters.get(key);\n if (cached) {\n return cached;\n }\n\n // Gregorian always: the numeric tokens are, and a name from another calendar would sit beside them.\n const formatter = new Intl.DateTimeFormat(this.locale, {\n ...opts,\n calendar: 'gregory',\n timeZone: 'UTC',\n });\n this.formatters.set(key, formatter);\n return formatter;\n }\n\n private tableOf(opts: {\n key: string;\n size: number;\n read: (index: number) => string;\n }): Array<string> {\n const cached = this.tables.get(opts.key);\n if (cached) {\n return cached;\n }\n\n const table = Array.from({ length: opts.size }, (_, index) => opts.read(index));\n this.tables.set(opts.key, table);\n return table;\n }\n\n /** `month` is 1-12. */\n monthName(opts: { month: number; width: 'short' | 'long' }): string {\n const { month, width } = opts;\n const formatter = this.formatterOf({ month: width });\n const table = this.tableOf({\n key: `month-${width}`,\n size: MONTHS,\n read: (index) => formatter.format(Date.UTC(2024, index, 15)),\n });\n return table[month - 1];\n }\n\n /** `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */\n weekdayName(opts: { dayOfWeek: number; width: 'narrow' | 'short' | 'long' }): string {\n const { dayOfWeek, width } = opts;\n const formatter = this.formatterOf({ weekday: width });\n const table = this.tableOf({\n key: `weekday-${width}`,\n size: WEEKDAYS,\n read: (index) => formatter.format(MONDAY + index * DAY_MILLISECONDS),\n });\n return table[dayOfWeek - 1];\n }\n\n /** The AM or PM marker the locale writes for `hour` (0-23), lower-cased by the locale's own rules when asked. */\n dayPeriod(opts: {\n hour: number;\n meridiem?: readonly [string, string];\n isLowerCase?: boolean;\n }): string {\n const formatter = this.formatterOf({ hour: 'numeric', hourCycle: 'h12' });\n const table = this.tableOf({\n key: 'day-period',\n size: 2,\n read: (index) =>\n formatter\n .formatToParts(Date.UTC(2024, 0, 1, index === 0 ? 1 : NOON + 1))\n .find((part) => part.type === 'dayPeriod')?.value ?? (index === 0 ? 'AM' : 'PM'),\n });\n const marker = (opts.meridiem ?? table)[opts.hour < NOON ? 0 : 1];\n return opts.isLowerCase ? marker.toLocaleLowerCase(this.locale) : marker;\n }\n\n /** The wall-clock date the way the locale writes it: `numeric` is `10/14/2026`, `long` is `October 14, 2026`. */\n writtenDate(opts: { parts: ITemporalParts; style: 'numeric' | 'long' }): string {\n const { parts, style } = opts;\n const formatter =\n style === 'numeric'\n ? this.formatterOf({ year: 'numeric', month: '2-digit', day: '2-digit' })\n : this.formatterOf({ dateStyle: 'long' });\n\n const date = new Date(0);\n date.setUTCFullYear(parts.year, parts.month - 1, parts.day);\n return formatter.format(date);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"locale.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/locale/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,yBAAyB,GAI1B,MAAM,qBAAqB,CAAC;AAG7B,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,IAAI,GAAG,EAAE,CAAC;AAEhB,gEAAgE;AAChE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC;;;;GAIG;AACH,MAAM,OAAO,cAAc;aACD,YAAO,GAAG,IAAI,GAAG,EAA0B,AAApC,CAAqC;IAMpE,YAAoB,IAAwB;QAH3B,WAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC1C,eAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;QAGnE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC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,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;SACrF,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3E,CAAC;IAED,iHAAiH;IACjH,WAAW,CAAC,IAAiE;QAC3E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,MAAM,SAAS,GACb,KAAK,KAAK,yBAAyB,CAAC,OAAO;YACzC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACzE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport {\n TemporalWrittenDateStyles,\n type TTemporalMonthNameWidth,\n type TTemporalNameWidth,\n type TTemporalWrittenDateStyle,\n} from '../common/constants';\nimport type { ITemporalParts } from '../common/types';\n\n/** A service writes a handful of locales; capped so caller-fed locales cannot grow it. */\nconst MAX_CACHED_LOCALES = 32;\n\nconst MONTHS = 12;\nconst WEEKDAYS = 7;\nconst NOON = 12;\n\n/** A Monday: ISO weekday `n` is this date plus `n - 1` days. */\nconst MONDAY = Date.UTC(2024, 0, 1);\nconst DAY_MILLISECONDS = 86_400_000;\n\n/**\n * Month and weekday names, the AM/PM marker and the written date of one locale, as `Intl` spells\n * them. Every table is read once, on first use, from a fixed UTC date: the names belong to the\n * calendar, not to a time zone, so the wall clock is formatted as if it were UTC.\n */\nexport class TemporalLocale {\n private static readonly locales = new Map<string, TemporalLocale>();\n\n private readonly locale: string;\n private readonly tables = new Map<string, Array<string>>();\n private readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private constructor(opts: { locale: string }) {\n this.locale = opts.locale;\n }\n\n /** The locale's names; a malformed tag is a 400. */\n static of(opts: { locale: string }): TemporalLocale {\n const { locale } = opts;\n const cached = TemporalLocale.locales.get(locale);\n if (cached) {\n return cached;\n }\n\n try {\n Intl.getCanonicalLocales(locale);\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalLocale] invalid locale '${locale}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Full: the oldest locale makes room, so the 33rd locale is not rebuilt on every call.\n if (TemporalLocale.locales.size >= MAX_CACHED_LOCALES) {\n const oldest = TemporalLocale.locales.keys().next().value;\n if (oldest !== undefined) {\n TemporalLocale.locales.delete(oldest);\n }\n }\n const created = new TemporalLocale({ locale });\n TemporalLocale.locales.set(locale, created);\n return created;\n }\n\n private formatterOf(opts: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n const key = JSON.stringify(opts);\n const cached = this.formatters.get(key);\n if (cached) {\n return cached;\n }\n\n // Gregorian always: the numeric tokens are, and a name from another calendar would sit beside them.\n const formatter = new Intl.DateTimeFormat(this.locale, {\n ...opts,\n calendar: 'gregory',\n timeZone: 'UTC',\n });\n this.formatters.set(key, formatter);\n return formatter;\n }\n\n private tableOf(opts: {\n key: string;\n size: number;\n read: (index: number) => string;\n }): Array<string> {\n const cached = this.tables.get(opts.key);\n if (cached) {\n return cached;\n }\n\n const table = Array.from({ length: opts.size }, (_, index) => opts.read(index));\n this.tables.set(opts.key, table);\n return table;\n }\n\n /** `month` is 1-12. */\n monthName(opts: { month: number; width: TTemporalMonthNameWidth }): string {\n const { month, width } = opts;\n const formatter = this.formatterOf({ month: width });\n const table = this.tableOf({\n key: `month-${width}`,\n size: MONTHS,\n read: (index) => formatter.format(Date.UTC(2024, index, 15)),\n });\n return table[month - 1];\n }\n\n /** `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */\n weekdayName(opts: { dayOfWeek: number; width: TTemporalNameWidth }): string {\n const { dayOfWeek, width } = opts;\n const formatter = this.formatterOf({ weekday: width });\n const table = this.tableOf({\n key: `weekday-${width}`,\n size: WEEKDAYS,\n read: (index) => formatter.format(MONDAY + index * DAY_MILLISECONDS),\n });\n return table[dayOfWeek - 1];\n }\n\n /** The AM or PM marker the locale writes for `hour` (0-23), lower-cased by the locale's own rules when asked. */\n dayPeriod(opts: {\n hour: number;\n meridiem?: readonly [string, string];\n isLowerCase?: boolean;\n }): string {\n const formatter = this.formatterOf({ hour: 'numeric', hourCycle: 'h12' });\n const table = this.tableOf({\n key: 'day-period',\n size: 2,\n read: (index) =>\n formatter\n .formatToParts(Date.UTC(2024, 0, 1, index === 0 ? 1 : NOON + 1))\n .find((part) => part.type === 'dayPeriod')?.value ?? (index === 0 ? 'AM' : 'PM'),\n });\n const marker = (opts.meridiem ?? table)[opts.hour < NOON ? 0 : 1];\n return opts.isLowerCase ? marker.toLocaleLowerCase(this.locale) : marker;\n }\n\n /** The wall-clock date the way the locale writes it: `numeric` is `10/14/2026`, `long` is `October 14, 2026`. */\n writtenDate(opts: { parts: ITemporalParts; style: TTemporalWrittenDateStyle }): string {\n const { parts, style } = opts;\n const formatter =\n style === TemporalWrittenDateStyles.NUMERIC\n ? this.formatterOf({ year: 'numeric', month: '2-digit', day: '2-digit' })\n : this.formatterOf({ dateStyle: 'long' });\n\n const date = new Date(0);\n date.setUTCFullYear(parts.year, parts.month - 1, parts.day);\n return formatter.format(date);\n }\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TConstValue } from '../../../../common/types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The pattern dialect: `YYYY YY MM M DD D HH H mm m ss s SSS Z ZZ` both ways, plus
|
|
4
|
+
* `MMMM MMM dddd ddd dd A a hh h LL L Q` for writing only, with text in `[brackets]`.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PatternTokens {
|
|
7
|
+
static readonly YEAR_4 = "YYYY";
|
|
8
|
+
static readonly YEAR_2 = "YY";
|
|
9
|
+
static readonly MONTH_2 = "MM";
|
|
10
|
+
static readonly MONTH = "M";
|
|
11
|
+
static readonly DAY_2 = "DD";
|
|
12
|
+
static readonly DAY = "D";
|
|
13
|
+
static readonly HOUR_24_2 = "HH";
|
|
14
|
+
static readonly HOUR_24 = "H";
|
|
15
|
+
static readonly MINUTE_2 = "mm";
|
|
16
|
+
static readonly MINUTE = "m";
|
|
17
|
+
static readonly SECOND_2 = "ss";
|
|
18
|
+
static readonly SECOND = "s";
|
|
19
|
+
static readonly MILLISECOND = "SSS";
|
|
20
|
+
static readonly OFFSET_COLON = "Z";
|
|
21
|
+
static readonly OFFSET = "ZZ";
|
|
22
|
+
/** Written only: names and the written date come from a locale, the quarter from the month. */
|
|
23
|
+
static readonly MONTH_NAME_LONG = "MMMM";
|
|
24
|
+
static readonly MONTH_NAME_SHORT = "MMM";
|
|
25
|
+
static readonly WEEKDAY_LONG = "dddd";
|
|
26
|
+
static readonly WEEKDAY_SHORT = "ddd";
|
|
27
|
+
static readonly WEEKDAY_MIN = "dd";
|
|
28
|
+
static readonly MERIDIEM_UPPER = "A";
|
|
29
|
+
static readonly MERIDIEM_LOWER = "a";
|
|
30
|
+
static readonly HOUR_12_2 = "hh";
|
|
31
|
+
static readonly HOUR_12 = "h";
|
|
32
|
+
static readonly DATE_LONG = "LL";
|
|
33
|
+
static readonly DATE_NUMERIC = "L";
|
|
34
|
+
static readonly QUARTER = "Q";
|
|
35
|
+
static readonly WRITE_ONLY_SET: ReadonlySet<TWriteOnlyToken>;
|
|
36
|
+
static readonly SCHEME_SET: Set<string>;
|
|
37
|
+
static isValid(value: string): boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Tokens a pattern can write but never read: names and the written date come from a locale, the quarter from the month, and a parse stays numeric and strict. */
|
|
40
|
+
export type TWriteOnlyToken = typeof PatternTokens.MONTH_NAME_LONG | typeof PatternTokens.MONTH_NAME_SHORT | typeof PatternTokens.WEEKDAY_LONG | typeof PatternTokens.WEEKDAY_SHORT | typeof PatternTokens.WEEKDAY_MIN | typeof PatternTokens.MERIDIEM_UPPER | typeof PatternTokens.MERIDIEM_LOWER | typeof PatternTokens.HOUR_12_2 | typeof PatternTokens.HOUR_12 | typeof PatternTokens.DATE_LONG | typeof PatternTokens.DATE_NUMERIC | typeof PatternTokens.QUARTER;
|
|
41
|
+
/** Every token of the pattern dialect, one for every adapter. */
|
|
42
|
+
export type TPatternToken = TConstValue<typeof PatternTokens>;
|
|
43
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/temporal/pattern/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,MAAM,UAAU;IAChC,MAAM,CAAC,QAAQ,CAAC,MAAM,QAAQ;IAC9B,MAAM,CAAC,QAAQ,CAAC,OAAO,QAAQ;IAC/B,MAAM,CAAC,QAAQ,CAAC,KAAK,OAAO;IAC5B,MAAM,CAAC,QAAQ,CAAC,KAAK,QAAQ;IAC7B,MAAM,CAAC,QAAQ,CAAC,GAAG,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