@canonmsg/backend-contracts 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/messageText.js +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/messageText.d.ts +6 -0
- package/dist/messageText.js +11 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./diffRedaction.js"), exports);
|
|
|
18
18
|
__exportStar(require("./environment.js"), exports);
|
|
19
19
|
__exportStar(require("./media.js"), exports);
|
|
20
20
|
__exportStar(require("./message.js"), exports);
|
|
21
|
+
__exportStar(require("./messageText.js"), exports);
|
|
21
22
|
__exportStar(require("./runtimeCardFields.js"), exports);
|
|
22
23
|
__exportStar(require("./runtimeCardStorage.js"), exports);
|
|
23
24
|
__exportStar(require("./turnProtocol.js"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HUMAN_MESSAGE_TEXT_MAX_BYTES = void 0;
|
|
4
|
+
exports.messageTextUtf8ByteLength = messageTextUtf8ByteLength;
|
|
5
|
+
exports.isHumanMessageTextWithinLimit = isHumanMessageTextWithinLimit;
|
|
6
|
+
/** Maximum UTF-8 payload size for a human-authored message. */
|
|
7
|
+
exports.HUMAN_MESSAGE_TEXT_MAX_BYTES = 32 * 1024;
|
|
8
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
9
|
+
/** Returns the encoded UTF-8 size used by the message API. */
|
|
10
|
+
function messageTextUtf8ByteLength(value) {
|
|
11
|
+
return UTF8_ENCODER.encode(value).byteLength;
|
|
12
|
+
}
|
|
13
|
+
/** Whether human-authored message text fits the API's UTF-8 byte budget. */
|
|
14
|
+
function isHumanMessageTextWithinLimit(value) {
|
|
15
|
+
return messageTextUtf8ByteLength(value) <= exports.HUMAN_MESSAGE_TEXT_MAX_BYTES;
|
|
16
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './diffRedaction.js';
|
|
|
2
2
|
export * from './environment.js';
|
|
3
3
|
export * from './media.js';
|
|
4
4
|
export * from './message.js';
|
|
5
|
+
export * from './messageText.js';
|
|
5
6
|
export * from './runtimeCardFields.js';
|
|
6
7
|
export * from './runtimeCardStorage.js';
|
|
7
8
|
export * from './turnProtocol.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './diffRedaction.js';
|
|
|
2
2
|
export * from './environment.js';
|
|
3
3
|
export * from './media.js';
|
|
4
4
|
export * from './message.js';
|
|
5
|
+
export * from './messageText.js';
|
|
5
6
|
export * from './runtimeCardFields.js';
|
|
6
7
|
export * from './runtimeCardStorage.js';
|
|
7
8
|
export * from './turnProtocol.js';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Maximum UTF-8 payload size for a human-authored message. */
|
|
2
|
+
export declare const HUMAN_MESSAGE_TEXT_MAX_BYTES: number;
|
|
3
|
+
/** Returns the encoded UTF-8 size used by the message API. */
|
|
4
|
+
export declare function messageTextUtf8ByteLength(value: string): number;
|
|
5
|
+
/** Whether human-authored message text fits the API's UTF-8 byte budget. */
|
|
6
|
+
export declare function isHumanMessageTextWithinLimit(value: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Maximum UTF-8 payload size for a human-authored message. */
|
|
2
|
+
export const HUMAN_MESSAGE_TEXT_MAX_BYTES = 32 * 1024;
|
|
3
|
+
const UTF8_ENCODER = new TextEncoder();
|
|
4
|
+
/** Returns the encoded UTF-8 size used by the message API. */
|
|
5
|
+
export function messageTextUtf8ByteLength(value) {
|
|
6
|
+
return UTF8_ENCODER.encode(value).byteLength;
|
|
7
|
+
}
|
|
8
|
+
/** Whether human-authored message text fits the API's UTF-8 byte budget. */
|
|
9
|
+
export function isHumanMessageTextWithinLimit(value) {
|
|
10
|
+
return messageTextUtf8ByteLength(value) <= HUMAN_MESSAGE_TEXT_MAX_BYTES;
|
|
11
|
+
}
|