@lark-sh/client 0.1.17 → 0.1.19
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/{chunk-VLAAYUVX.mjs → chunk-UF3SZ62Y.mjs} +35 -3
- package/dist/chunk-UF3SZ62Y.mjs.map +1 -0
- package/dist/fb-v8/index.js +34 -2
- package/dist/fb-v8/index.js.map +1 -1
- package/dist/fb-v8/index.mjs +1 -1
- package/dist/index.js +34 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-VLAAYUVX.mjs.map +0 -1
package/dist/fb-v8/index.mjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -2873,6 +2873,9 @@ function generatePushId() {
|
|
|
2873
2873
|
|
|
2874
2874
|
// src/utils/validation.ts
|
|
2875
2875
|
var MAX_KEY_BYTES = 768;
|
|
2876
|
+
var MAX_STRING_VALUE_BYTES = 10 * 1024 * 1024;
|
|
2877
|
+
var MAX_WRITE_BYTES = 16 * 1024 * 1024;
|
|
2878
|
+
var MAX_VOLATILE_WRITE_BYTES = 2 * 1024;
|
|
2876
2879
|
var INVALID_KEY_CHARS = /[.#$\[\]\/]/;
|
|
2877
2880
|
var CONTROL_CHARS = /[\x00-\x1f\x7f]/;
|
|
2878
2881
|
function hasControlChars(str) {
|
|
@@ -2943,10 +2946,11 @@ function validateValue(value, context, path = "") {
|
|
|
2943
2946
|
return;
|
|
2944
2947
|
}
|
|
2945
2948
|
if (typeof value === "string") {
|
|
2946
|
-
|
|
2949
|
+
const byteLength = getByteLength(value);
|
|
2950
|
+
if (byteLength > MAX_STRING_VALUE_BYTES) {
|
|
2947
2951
|
throw new LarkError(
|
|
2948
2952
|
ErrorCode.INVALID_DATA,
|
|
2949
|
-
`${prefix}string value${location}
|
|
2953
|
+
`${prefix}string value${location} exceeds maximum size of 10 MB (got ${Math.round(byteLength / 1024 / 1024 * 100) / 100} MB)`
|
|
2950
2954
|
);
|
|
2951
2955
|
}
|
|
2952
2956
|
return;
|
|
@@ -2989,6 +2993,30 @@ function validateValue(value, context, path = "") {
|
|
|
2989
2993
|
function validateWriteData(value, context) {
|
|
2990
2994
|
validateValue(value, context);
|
|
2991
2995
|
}
|
|
2996
|
+
function getJsonByteSize(value) {
|
|
2997
|
+
const json = JSON.stringify(value);
|
|
2998
|
+
return getByteLength(json);
|
|
2999
|
+
}
|
|
3000
|
+
function validateWriteSize(value, context) {
|
|
3001
|
+
const byteSize = getJsonByteSize(value);
|
|
3002
|
+
if (byteSize > MAX_WRITE_BYTES) {
|
|
3003
|
+
const sizeMB = Math.round(byteSize / 1024 / 1024 * 100) / 100;
|
|
3004
|
+
throw new LarkError(
|
|
3005
|
+
ErrorCode.INVALID_DATA,
|
|
3006
|
+
`${context ? `${context}: ` : ""}write exceeds 16 MB limit (got ${sizeMB} MB)`
|
|
3007
|
+
);
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
function validateVolatileWriteSize(value, context) {
|
|
3011
|
+
const byteSize = getJsonByteSize(value);
|
|
3012
|
+
if (byteSize > MAX_VOLATILE_WRITE_BYTES) {
|
|
3013
|
+
const sizeKB = Math.round(byteSize / 1024 * 100) / 100;
|
|
3014
|
+
throw new LarkError(
|
|
3015
|
+
ErrorCode.INVALID_DATA,
|
|
3016
|
+
`${context ? `${context}: ` : ""}volatile write exceeds 2 KB limit (got ${sizeKB} KB)`
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
2992
3020
|
|
|
2993
3021
|
// src/DatabaseReference.ts
|
|
2994
3022
|
function isInfoPath(path) {
|
|
@@ -5105,6 +5133,7 @@ var LarkDatabase = class {
|
|
|
5105
5133
|
if (!this.isAuthenticatedOrThrow()) await this.waitForAuthenticated();
|
|
5106
5134
|
const normalizedPath = normalizePath(path) || "/";
|
|
5107
5135
|
validateWriteData(value, normalizedPath);
|
|
5136
|
+
validateWriteSize(value, normalizedPath);
|
|
5108
5137
|
const requestId = this.messageQueue.nextRequestId();
|
|
5109
5138
|
const pendingWriteIds = this.subscriptionManager.getPendingWriteIdsForPath(normalizedPath);
|
|
5110
5139
|
this.pendingWrites.trackWrite(requestId, "set", normalizedPath, value);
|
|
@@ -5133,6 +5162,7 @@ var LarkDatabase = class {
|
|
|
5133
5162
|
const fullPath = key.startsWith("/") ? key : `${normalizedPath}/${key}`;
|
|
5134
5163
|
validateWriteData(value, fullPath);
|
|
5135
5164
|
}
|
|
5165
|
+
validateWriteSize(values, normalizedPath);
|
|
5136
5166
|
const requestId = this.messageQueue.nextRequestId();
|
|
5137
5167
|
const pendingWriteIds = this.subscriptionManager.getPendingWriteIdsForPath(normalizedPath);
|
|
5138
5168
|
this.pendingWrites.trackWrite(requestId, "update", normalizedPath, values);
|
|
@@ -5194,6 +5224,7 @@ var LarkDatabase = class {
|
|
|
5194
5224
|
*/
|
|
5195
5225
|
_sendVolatileSet(path, value) {
|
|
5196
5226
|
const normalizedPath = normalizePath(path) || "/";
|
|
5227
|
+
validateVolatileWriteSize(value, normalizedPath);
|
|
5197
5228
|
this.subscriptionManager.applyOptimisticWrite(normalizedPath, value, "", "set");
|
|
5198
5229
|
if (this._state !== "authenticated" || !this.transport || !this.transport.connected) {
|
|
5199
5230
|
return;
|
|
@@ -5210,6 +5241,7 @@ var LarkDatabase = class {
|
|
|
5210
5241
|
*/
|
|
5211
5242
|
_sendVolatileUpdate(path, values) {
|
|
5212
5243
|
const normalizedPath = normalizePath(path) || "/";
|
|
5244
|
+
validateVolatileWriteSize(values, normalizedPath);
|
|
5213
5245
|
this.subscriptionManager.applyOptimisticWrite(normalizedPath, values, "", "update");
|
|
5214
5246
|
if (this._state !== "authenticated" || !this.transport || !this.transport.connected) {
|
|
5215
5247
|
return;
|