@evolu/common 8.5.0 → 8.6.1
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/src/Array.d.ts +170 -97
- package/dist/src/Array.d.ts.map +1 -1
- package/dist/src/Array.js +67 -42
- package/dist/src/Assert.d.ts +233 -30
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +150 -30
- package/dist/src/BigInt.d.ts +3 -3
- package/dist/src/BigInt.js +3 -3
- package/dist/src/Brand.d.ts +7 -7
- package/dist/src/Buffer.d.ts +12 -4
- package/dist/src/Buffer.d.ts.map +1 -1
- package/dist/src/Cache.d.ts +8 -3
- package/dist/src/Cache.d.ts.map +1 -1
- package/dist/src/Cache.js +8 -3
- package/dist/src/Callbacks.d.ts +8 -4
- package/dist/src/Callbacks.d.ts.map +1 -1
- package/dist/src/Console.d.ts +45 -30
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +32 -21
- package/dist/src/Crypto.d.ts +13 -8
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +6 -3
- package/dist/src/Eq.d.ts +107 -58
- package/dist/src/Eq.d.ts.map +1 -1
- package/dist/src/Eq.js +308 -112
- package/dist/src/Function.d.ts +54 -24
- package/dist/src/Function.d.ts.map +1 -1
- package/dist/src/Function.js +34 -17
- package/dist/src/Http.d.ts +52 -19
- package/dist/src/Http.d.ts.map +1 -1
- package/dist/src/Identicon.d.ts +9 -4
- package/dist/src/Identicon.d.ts.map +1 -1
- package/dist/src/Identicon.js +9 -4
- package/dist/src/LockManager.d.ts +12 -10
- package/dist/src/LockManager.d.ts.map +1 -1
- package/dist/src/Lookup.d.ts +4 -2
- package/dist/src/Lookup.d.ts.map +1 -1
- package/dist/src/Lookup.js +4 -2
- package/dist/src/Number.d.ts +28 -24
- package/dist/src/Number.d.ts.map +1 -1
- package/dist/src/Number.js +16 -17
- package/dist/src/Object.d.ts +89 -47
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +88 -41
- package/dist/src/Option.d.ts +14 -5
- package/dist/src/Option.d.ts.map +1 -1
- package/dist/src/Option.js +14 -5
- package/dist/src/Order.d.ts +12 -12
- package/dist/src/Order.js +12 -12
- package/dist/src/Platform.d.ts +2 -2
- package/dist/src/Random.d.ts +7 -4
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Redacted.d.ts +13 -6
- package/dist/src/Redacted.d.ts.map +1 -1
- package/dist/src/Redacted.js +4 -2
- package/dist/src/Ref.d.ts +4 -4
- package/dist/src/Relation.d.ts +5 -7
- package/dist/src/Relation.d.ts.map +1 -1
- package/dist/src/Resource.d.ts +27 -12
- package/dist/src/Resource.d.ts.map +1 -1
- package/dist/src/Result.d.ts +258 -114
- package/dist/src/Result.d.ts.map +1 -1
- package/dist/src/Result.js +71 -34
- package/dist/src/Schedule.d.ts +233 -116
- package/dist/src/Schedule.d.ts.map +1 -1
- package/dist/src/Schedule.js +204 -110
- package/dist/src/Set.d.ts +43 -24
- package/dist/src/Set.d.ts.map +1 -1
- package/dist/src/Set.js +25 -13
- package/dist/src/Sqlite.d.ts +4 -4
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +9 -8
- package/dist/src/Task.d.ts +441 -212
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +238 -115
- package/dist/src/Test.d.ts +10 -4
- package/dist/src/Test.d.ts.map +1 -1
- package/dist/src/Test.js +10 -4
- package/dist/src/Time.d.ts +27 -17
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +16 -6
- package/dist/src/Type.d.ts +1096 -387
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +1046 -372
- package/dist/src/Types.d.ts +95 -40
- package/dist/src/Types.d.ts.map +1 -1
- package/dist/src/Types.js +13 -4
- package/dist/src/WebSocket.d.ts +14 -6
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/Worker.d.ts +10 -6
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/intl/_en.d.ts +3 -1
- package/dist/src/intl/_en.d.ts.map +1 -1
- package/dist/src/intl/_en.js +17 -3
- package/dist/src/intl/ar.d.ts +3 -1
- package/dist/src/intl/ar.d.ts.map +1 -1
- package/dist/src/intl/ar.js +15 -2
- package/dist/src/intl/bn.d.ts +3 -1
- package/dist/src/intl/bn.d.ts.map +1 -1
- package/dist/src/intl/bn.js +16 -3
- package/dist/src/intl/ca.d.ts +3 -1
- package/dist/src/intl/ca.d.ts.map +1 -1
- package/dist/src/intl/ca.js +16 -3
- package/dist/src/intl/cs.d.ts +3 -1
- package/dist/src/intl/cs.d.ts.map +1 -1
- package/dist/src/intl/cs.js +16 -3
- package/dist/src/intl/da.d.ts +3 -1
- package/dist/src/intl/da.d.ts.map +1 -1
- package/dist/src/intl/da.js +16 -3
- package/dist/src/intl/de.d.ts +3 -1
- package/dist/src/intl/de.d.ts.map +1 -1
- package/dist/src/intl/de.js +16 -3
- package/dist/src/intl/el.d.ts +3 -1
- package/dist/src/intl/el.d.ts.map +1 -1
- package/dist/src/intl/el.js +16 -3
- package/dist/src/intl/es.d.ts +3 -1
- package/dist/src/intl/es.d.ts.map +1 -1
- package/dist/src/intl/es.js +16 -3
- package/dist/src/intl/fa.d.ts +3 -1
- package/dist/src/intl/fa.d.ts.map +1 -1
- package/dist/src/intl/fa.js +16 -3
- package/dist/src/intl/fi.d.ts +3 -1
- package/dist/src/intl/fi.d.ts.map +1 -1
- package/dist/src/intl/fi.js +16 -3
- package/dist/src/intl/fil.d.ts +3 -1
- package/dist/src/intl/fil.d.ts.map +1 -1
- package/dist/src/intl/fil.js +16 -3
- package/dist/src/intl/fr.d.ts +3 -1
- package/dist/src/intl/fr.d.ts.map +1 -1
- package/dist/src/intl/fr.js +16 -3
- package/dist/src/intl/he.d.ts +3 -1
- package/dist/src/intl/he.d.ts.map +1 -1
- package/dist/src/intl/he.js +16 -3
- package/dist/src/intl/hi.d.ts +3 -1
- package/dist/src/intl/hi.d.ts.map +1 -1
- package/dist/src/intl/hi.js +16 -3
- package/dist/src/intl/hr.d.ts +3 -1
- package/dist/src/intl/hr.d.ts.map +1 -1
- package/dist/src/intl/hr.js +16 -3
- package/dist/src/intl/hu.d.ts +2 -1
- package/dist/src/intl/hu.d.ts.map +1 -1
- package/dist/src/intl/hu.js +15 -3
- package/dist/src/intl/id.d.ts +3 -1
- package/dist/src/intl/id.d.ts.map +1 -1
- package/dist/src/intl/id.js +16 -3
- package/dist/src/intl/it.d.ts +3 -1
- package/dist/src/intl/it.d.ts.map +1 -1
- package/dist/src/intl/it.js +16 -3
- package/dist/src/intl/ja.d.ts +3 -1
- package/dist/src/intl/ja.d.ts.map +1 -1
- package/dist/src/intl/ja.js +16 -3
- package/dist/src/intl/ko.d.ts +3 -1
- package/dist/src/intl/ko.d.ts.map +1 -1
- package/dist/src/intl/ko.js +16 -3
- package/dist/src/intl/ml.d.ts +3 -1
- package/dist/src/intl/ml.d.ts.map +1 -1
- package/dist/src/intl/ml.js +16 -3
- package/dist/src/intl/mr.d.ts +3 -1
- package/dist/src/intl/mr.d.ts.map +1 -1
- package/dist/src/intl/mr.js +16 -3
- package/dist/src/intl/ms.d.ts +3 -1
- package/dist/src/intl/ms.d.ts.map +1 -1
- package/dist/src/intl/ms.js +15 -2
- package/dist/src/intl/nb.d.ts +2 -1
- package/dist/src/intl/nb.d.ts.map +1 -1
- package/dist/src/intl/nb.js +14 -2
- package/dist/src/intl/nl.d.ts +3 -1
- package/dist/src/intl/nl.d.ts.map +1 -1
- package/dist/src/intl/nl.js +16 -3
- package/dist/src/intl/pa.d.ts +3 -1
- package/dist/src/intl/pa.d.ts.map +1 -1
- package/dist/src/intl/pa.js +16 -3
- package/dist/src/intl/pl.d.ts +2 -0
- package/dist/src/intl/pl.d.ts.map +1 -1
- package/dist/src/intl/pl.js +15 -2
- package/dist/src/intl/pt-BR.d.ts +3 -1
- package/dist/src/intl/pt-BR.d.ts.map +1 -1
- package/dist/src/intl/pt-BR.js +16 -3
- package/dist/src/intl/pt.d.ts +3 -1
- package/dist/src/intl/pt.d.ts.map +1 -1
- package/dist/src/intl/pt.js +15 -2
- package/dist/src/intl/ro.d.ts +3 -1
- package/dist/src/intl/ro.d.ts.map +1 -1
- package/dist/src/intl/ro.js +16 -3
- package/dist/src/intl/sk.d.ts +3 -1
- package/dist/src/intl/sk.d.ts.map +1 -1
- package/dist/src/intl/sk.js +15 -2
- package/dist/src/intl/sl.d.ts +3 -1
- package/dist/src/intl/sl.d.ts.map +1 -1
- package/dist/src/intl/sl.js +16 -3
- package/dist/src/intl/sv.d.ts +3 -1
- package/dist/src/intl/sv.d.ts.map +1 -1
- package/dist/src/intl/sv.js +16 -3
- package/dist/src/intl/sw.d.ts +1 -0
- package/dist/src/intl/sw.d.ts.map +1 -1
- package/dist/src/intl/sw.js +14 -2
- package/dist/src/intl/ta.d.ts +3 -1
- package/dist/src/intl/ta.d.ts.map +1 -1
- package/dist/src/intl/ta.js +16 -3
- package/dist/src/intl/te.d.ts +3 -1
- package/dist/src/intl/te.d.ts.map +1 -1
- package/dist/src/intl/te.js +16 -3
- package/dist/src/intl/th.d.ts +3 -1
- package/dist/src/intl/th.d.ts.map +1 -1
- package/dist/src/intl/th.js +16 -3
- package/dist/src/intl/tr.d.ts +3 -1
- package/dist/src/intl/tr.d.ts.map +1 -1
- package/dist/src/intl/tr.js +16 -3
- package/dist/src/intl/uk.d.ts +3 -1
- package/dist/src/intl/uk.d.ts.map +1 -1
- package/dist/src/intl/uk.js +16 -3
- package/dist/src/intl/ur.d.ts +3 -1
- package/dist/src/intl/ur.d.ts.map +1 -1
- package/dist/src/intl/ur.js +15 -2
- package/dist/src/intl/vi.d.ts +3 -1
- package/dist/src/intl/vi.d.ts.map +1 -1
- package/dist/src/intl/vi.js +16 -3
- package/dist/src/intl/zh-CN.d.ts +3 -1
- package/dist/src/intl/zh-CN.d.ts.map +1 -1
- package/dist/src/intl/zh-CN.js +16 -3
- package/dist/src/intl/zh-TW.d.ts +3 -1
- package/dist/src/intl/zh-TW.d.ts.map +1 -1
- package/dist/src/intl/zh-TW.js +16 -3
- package/dist/src/local-first/Evolu.d.ts +47 -24
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Owner.d.ts +10 -7
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +10 -7
- package/dist/src/local-first/Protocol.d.ts +5 -5
- package/dist/src/local-first/Protocol.js +7 -7
- package/dist/src/local-first/Query.d.ts +34 -21
- package/dist/src/local-first/Query.d.ts.map +1 -1
- package/dist/src/local-first/Query.js +25 -13
- package/dist/src/local-first/Relay.d.ts +12 -5
- package/dist/src/local-first/Relay.d.ts.map +1 -1
- package/dist/src/local-first/Schema.d.ts +19 -11
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Schema.js +11 -6
- package/dist/src/local-first/Storage.d.ts +4 -2
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/Array.ts +170 -97
- package/src/Assert.ts +336 -31
- package/src/BigInt.ts +3 -3
- package/src/Brand.ts +7 -7
- package/src/Buffer.ts +12 -4
- package/src/Cache.ts +8 -3
- package/src/Callbacks.ts +8 -4
- package/src/Console.ts +45 -30
- package/src/Crypto.ts +13 -8
- package/src/Eq.ts +450 -122
- package/src/Function.ts +54 -24
- package/src/Http.ts +52 -19
- package/src/Identicon.ts +9 -4
- package/src/LockManager.ts +12 -10
- package/src/Lookup.ts +4 -2
- package/src/Number.ts +28 -24
- package/src/Object.ts +115 -49
- package/src/Option.ts +14 -5
- package/src/Order.ts +12 -12
- package/src/Platform.ts +2 -2
- package/src/Random.ts +7 -4
- package/src/Redacted.ts +13 -6
- package/src/Ref.ts +4 -4
- package/src/Relation.ts +5 -7
- package/src/Resource.ts +27 -12
- package/src/Result.ts +258 -114
- package/src/Schedule.ts +233 -116
- package/src/Set.ts +43 -24
- package/src/Sqlite.ts +9 -8
- package/src/Task.ts +441 -212
- package/src/Test.ts +10 -4
- package/src/Time.ts +27 -17
- package/src/Type.ts +2077 -620
- package/src/Types.ts +108 -40
- package/src/WebSocket.ts +14 -6
- package/src/Worker.ts +10 -6
- package/src/intl/_en.ts +20 -4
- package/src/intl/ar.ts +17 -2
- package/src/intl/bn.ts +19 -4
- package/src/intl/ca.ts +19 -4
- package/src/intl/cs.ts +19 -4
- package/src/intl/da.ts +19 -4
- package/src/intl/de.ts +19 -4
- package/src/intl/el.ts +19 -4
- package/src/intl/es.ts +19 -4
- package/src/intl/fa.ts +19 -4
- package/src/intl/fi.ts +19 -4
- package/src/intl/fil.ts +19 -4
- package/src/intl/fr.ts +19 -4
- package/src/intl/he.ts +19 -4
- package/src/intl/hi.ts +19 -4
- package/src/intl/hr.ts +19 -4
- package/src/intl/hu.ts +18 -4
- package/src/intl/id.ts +19 -4
- package/src/intl/it.ts +19 -4
- package/src/intl/ja.ts +19 -4
- package/src/intl/ko.ts +19 -4
- package/src/intl/ml.ts +19 -4
- package/src/intl/mr.ts +19 -4
- package/src/intl/ms.ts +17 -2
- package/src/intl/nb.ts +16 -2
- package/src/intl/nl.ts +19 -4
- package/src/intl/pa.ts +19 -4
- package/src/intl/pl.ts +18 -2
- package/src/intl/pt-BR.ts +19 -4
- package/src/intl/pt.ts +17 -2
- package/src/intl/ro.ts +19 -4
- package/src/intl/sk.ts +17 -2
- package/src/intl/sl.ts +19 -4
- package/src/intl/sv.ts +19 -4
- package/src/intl/sw.ts +15 -2
- package/src/intl/ta.ts +19 -4
- package/src/intl/te.ts +19 -4
- package/src/intl/th.ts +19 -4
- package/src/intl/tr.ts +19 -4
- package/src/intl/uk.ts +19 -4
- package/src/intl/ur.ts +17 -2
- package/src/intl/vi.ts +19 -3
- package/src/intl/zh-CN.ts +19 -4
- package/src/intl/zh-TW.ts +19 -4
- package/src/local-first/Evolu.ts +47 -24
- package/src/local-first/Owner.ts +10 -7
- package/src/local-first/Protocol.ts +7 -7
- package/src/local-first/Query.ts +34 -21
- package/src/local-first/Relay.ts +12 -5
- package/src/local-first/Schema.ts +19 -11
- package/src/local-first/Storage.ts +4 -2
package/src/intl/th.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -332,10 +333,6 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
332
333
|
if (error.reason.kind === "NotSet") {
|
|
333
334
|
return `ค่า ${safelyStringifyUnknownValue(error.reason.value)} ไม่ใช่ Set`;
|
|
334
335
|
}
|
|
335
|
-
if (error.reason.kind === "UnexpectedPrototype") {
|
|
336
|
-
return "ค่านี้เป็นอินสแตนซ์ของคลาสย่อย Set แต่ Set Output ต้องเป็นอินสแตนซ์ของ Set โดยตรง";
|
|
337
|
-
}
|
|
338
|
-
|
|
339
336
|
const issue = error.reason.issues[0];
|
|
340
337
|
|
|
341
338
|
switch (issue.kind) {
|
|
@@ -346,6 +343,24 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
346
343
|
}
|
|
347
344
|
};
|
|
348
345
|
|
|
346
|
+
/** จัดรูปแบบ MapError เป็นภาษาไทย */
|
|
347
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
348
|
+
if (error.reason.kind === "NotMap") {
|
|
349
|
+
return `ค่า ${safelyStringifyUnknownValue(error.reason.value)} ไม่ใช่ Map`;
|
|
350
|
+
}
|
|
351
|
+
const issue = error.reason.issues[0];
|
|
352
|
+
|
|
353
|
+
switch (issue.kind) {
|
|
354
|
+
case "ExcessProperty":
|
|
355
|
+
return `ไม่อนุญาตให้มี Map property ส่วนเกิน ${safelyStringifyUnknownValue(issue.key)}`;
|
|
356
|
+
case "Key":
|
|
357
|
+
case "Value":
|
|
358
|
+
return `องค์ประกอบ Map ที่ดัชนี ${issue.index} ไม่ถูกต้อง`;
|
|
359
|
+
case "Collision":
|
|
360
|
+
return `คีย์ Map ${safelyStringifyUnknownValue(issue.previousKey)} และ ${safelyStringifyUnknownValue(issue.key)} ถอดรหัสเป็นคีย์เดียวกัน ${safelyStringifyUnknownValue(issue.outputKey)}`;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
|
|
349
364
|
/** จัดรูปแบบ TupleError เป็นภาษาไทย */
|
|
350
365
|
export const formatTupleError: TypeErrorFormatter<
|
|
351
366
|
TupleError | TupleElementsError<TypeError>
|
package/src/intl/tr.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -335,10 +336,6 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
335
336
|
if (error.reason.kind === "NotSet") {
|
|
336
337
|
return `Değer ${safelyStringifyUnknownValue(error.reason.value)} bir Set değildir.`;
|
|
337
338
|
}
|
|
338
|
-
if (error.reason.kind === "UnexpectedPrototype") {
|
|
339
|
-
return "Değer bir Set alt sınıfının örneğidir, ancak bir Set Output doğrudan bir Set örneği olmalıdır.";
|
|
340
|
-
}
|
|
341
|
-
|
|
342
339
|
const issue = error.reason.issues[0];
|
|
343
340
|
|
|
344
341
|
switch (issue.kind) {
|
|
@@ -349,6 +346,24 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
349
346
|
}
|
|
350
347
|
};
|
|
351
348
|
|
|
349
|
+
/** Formats a MapError in Turkish. */
|
|
350
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
351
|
+
if (error.reason.kind === "NotMap") {
|
|
352
|
+
return `Değer ${safelyStringifyUnknownValue(error.reason.value)} bir Map değildir.`;
|
|
353
|
+
}
|
|
354
|
+
const issue = error.reason.issues[0];
|
|
355
|
+
|
|
356
|
+
switch (issue.kind) {
|
|
357
|
+
case "ExcessProperty":
|
|
358
|
+
return `Fazladan Map özelliğine ${safelyStringifyUnknownValue(issue.key)} izin verilmez.`;
|
|
359
|
+
case "Key":
|
|
360
|
+
case "Value":
|
|
361
|
+
return `${issue.index} dizinindeki Map öğesi geçersiz.`;
|
|
362
|
+
case "Collision":
|
|
363
|
+
return `Map anahtarları ${safelyStringifyUnknownValue(issue.previousKey)} ve ${safelyStringifyUnknownValue(issue.key)}, aynı ${safelyStringifyUnknownValue(issue.outputKey)} anahtarına çözümleniyor.`;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
352
367
|
/** Formats a TupleError in Turkish. */
|
|
353
368
|
export const formatTupleError: TypeErrorFormatter<
|
|
354
369
|
TupleError | TupleElementsError<TypeError>
|
package/src/intl/uk.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -336,10 +337,6 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
336
337
|
if (error.reason.kind === "NotSet") {
|
|
337
338
|
return `A value ${safelyStringifyUnknownValue(error.reason.value)} is not a Set.`;
|
|
338
339
|
}
|
|
339
|
-
if (error.reason.kind === "UnexpectedPrototype") {
|
|
340
|
-
return "The value is an instance of a Set subclass, but a Set Output must be a direct Set instance.";
|
|
341
|
-
}
|
|
342
|
-
|
|
343
340
|
const issue = error.reason.issues[0];
|
|
344
341
|
|
|
345
342
|
switch (issue.kind) {
|
|
@@ -350,6 +347,24 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
350
347
|
}
|
|
351
348
|
};
|
|
352
349
|
|
|
350
|
+
/** Formats a MapError in English. */
|
|
351
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
352
|
+
if (error.reason.kind === "NotMap") {
|
|
353
|
+
return `A value ${safelyStringifyUnknownValue(error.reason.value)} is not a Map.`;
|
|
354
|
+
}
|
|
355
|
+
const issue = error.reason.issues[0];
|
|
356
|
+
|
|
357
|
+
switch (issue.kind) {
|
|
358
|
+
case "ExcessProperty":
|
|
359
|
+
return `An excess Map property ${safelyStringifyUnknownValue(issue.key)} is not allowed.`;
|
|
360
|
+
case "Key":
|
|
361
|
+
case "Value":
|
|
362
|
+
return `A Map element at index ${issue.index} is invalid.`;
|
|
363
|
+
case "Collision":
|
|
364
|
+
return `Map keys ${safelyStringifyUnknownValue(issue.previousKey)} and ${safelyStringifyUnknownValue(issue.key)} decode to the same key ${safelyStringifyUnknownValue(issue.outputKey)}.`;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
|
|
353
368
|
/** Formats a TupleError in English. */
|
|
354
369
|
export const formatTupleError: TypeErrorFormatter<
|
|
355
370
|
TupleError | TupleElementsError<TypeError>
|
package/src/intl/ur.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -284,8 +285,6 @@ export const formatArrayError: TypeErrorFormatter<ArrayError> = (error) => {
|
|
|
284
285
|
export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
285
286
|
if (error.reason.kind === "NotSet")
|
|
286
287
|
return `قدر ${safelyStringifyUnknownValue(error.reason.value)} Set نہیں ہے۔`;
|
|
287
|
-
if (error.reason.kind === "UnexpectedPrototype")
|
|
288
|
-
return "قدر Set subclass کی instance ہے، لیکن Set Output براہ راست Set instance ہونا چاہیے۔";
|
|
289
288
|
const issue = error.reason.issues[0];
|
|
290
289
|
switch (issue.kind) {
|
|
291
290
|
case "ExcessProperty":
|
|
@@ -294,6 +293,22 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
294
293
|
return `index ${issue.index} پر Set element درست نہیں ہے۔`;
|
|
295
294
|
}
|
|
296
295
|
};
|
|
296
|
+
|
|
297
|
+
/** MapError کو اردو میں فارمیٹ کرتا ہے۔ */
|
|
298
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
299
|
+
if (error.reason.kind === "NotMap")
|
|
300
|
+
return `قدر ${safelyStringifyUnknownValue(error.reason.value)} Map نہیں ہے۔`;
|
|
301
|
+
const issue = error.reason.issues[0];
|
|
302
|
+
switch (issue.kind) {
|
|
303
|
+
case "ExcessProperty":
|
|
304
|
+
return `اضافی Map property ${safelyStringifyUnknownValue(issue.key)} کی اجازت نہیں ہے۔`;
|
|
305
|
+
case "Key":
|
|
306
|
+
case "Value":
|
|
307
|
+
return `index ${issue.index} پر Map element درست نہیں ہے۔`;
|
|
308
|
+
case "Collision":
|
|
309
|
+
return `Map keys ${safelyStringifyUnknownValue(issue.previousKey)} اور ${safelyStringifyUnknownValue(issue.key)} decode ہونے کے بعد ایک ہی key ${safelyStringifyUnknownValue(issue.outputKey)} بن جاتے ہیں۔`;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
297
312
|
/** TupleError کو اردو میں فارمیٹ کرتا ہے۔ */
|
|
298
313
|
export const formatTupleError: TypeErrorFormatter<
|
|
299
314
|
TupleError | TupleElementsError<TypeError>
|
package/src/intl/vi.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -289,9 +290,6 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
289
290
|
if (error.reason.kind === "NotSet") {
|
|
290
291
|
return `Giá trị ${safelyStringifyUnknownValue(error.reason.value)} không phải là Set.`;
|
|
291
292
|
}
|
|
292
|
-
if (error.reason.kind === "UnexpectedPrototype") {
|
|
293
|
-
return "Giá trị là một thể hiện của lớp con Set, nhưng Set Output phải là một thể hiện Set trực tiếp.";
|
|
294
|
-
}
|
|
295
293
|
const issue = error.reason.issues[0];
|
|
296
294
|
|
|
297
295
|
switch (issue.kind) {
|
|
@@ -302,6 +300,24 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
302
300
|
}
|
|
303
301
|
};
|
|
304
302
|
|
|
303
|
+
/** Định dạng MapError bằng tiếng Việt. */
|
|
304
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
305
|
+
if (error.reason.kind === "NotMap") {
|
|
306
|
+
return `Giá trị ${safelyStringifyUnknownValue(error.reason.value)} không phải là Map.`;
|
|
307
|
+
}
|
|
308
|
+
const issue = error.reason.issues[0];
|
|
309
|
+
|
|
310
|
+
switch (issue.kind) {
|
|
311
|
+
case "ExcessProperty":
|
|
312
|
+
return `Không cho phép thuộc tính Map dư thừa ${safelyStringifyUnknownValue(issue.key)}.`;
|
|
313
|
+
case "Key":
|
|
314
|
+
case "Value":
|
|
315
|
+
return `Phần tử Map tại chỉ mục ${issue.index} không hợp lệ.`;
|
|
316
|
+
case "Collision":
|
|
317
|
+
return `Các khóa Map ${safelyStringifyUnknownValue(issue.previousKey)} và ${safelyStringifyUnknownValue(issue.key)} giải mã thành cùng một khóa ${safelyStringifyUnknownValue(issue.outputKey)}.`;
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
305
321
|
/** Định dạng TupleError bằng tiếng Việt. */
|
|
306
322
|
export const formatTupleError: TypeErrorFormatter<
|
|
307
323
|
TupleError | TupleElementsError<TypeError>
|
package/src/intl/zh-CN.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -330,10 +331,6 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
330
331
|
if (error.reason.kind === "NotSet") {
|
|
331
332
|
return `值 ${safelyStringifyUnknownValue(error.reason.value)} 不是 Set。`;
|
|
332
333
|
}
|
|
333
|
-
if (error.reason.kind === "UnexpectedPrototype") {
|
|
334
|
-
return "该值是 Set 子类的实例,但 Set Output 必须是直接的 Set 实例。";
|
|
335
|
-
}
|
|
336
|
-
|
|
337
334
|
const issue = error.reason.issues[0];
|
|
338
335
|
|
|
339
336
|
switch (issue.kind) {
|
|
@@ -344,6 +341,24 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
344
341
|
}
|
|
345
342
|
};
|
|
346
343
|
|
|
344
|
+
/** 以简体中文格式化 MapError。 */
|
|
345
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
346
|
+
if (error.reason.kind === "NotMap") {
|
|
347
|
+
return `值 ${safelyStringifyUnknownValue(error.reason.value)} 不是 Map。`;
|
|
348
|
+
}
|
|
349
|
+
const issue = error.reason.issues[0];
|
|
350
|
+
|
|
351
|
+
switch (issue.kind) {
|
|
352
|
+
case "ExcessProperty":
|
|
353
|
+
return `不允许多余的 Map 属性 ${safelyStringifyUnknownValue(issue.key)}。`;
|
|
354
|
+
case "Key":
|
|
355
|
+
case "Value":
|
|
356
|
+
return `索引 ${issue.index} 处的 Map 元素无效。`;
|
|
357
|
+
case "Collision":
|
|
358
|
+
return `Map 键 ${safelyStringifyUnknownValue(issue.previousKey)} 和 ${safelyStringifyUnknownValue(issue.key)} 解码后得到相同的键 ${safelyStringifyUnknownValue(issue.outputKey)}。`;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
347
362
|
/** 以简体中文格式化 TupleError。 */
|
|
348
363
|
export const formatTupleError: TypeErrorFormatter<
|
|
349
364
|
TupleError | TupleElementsError<TypeError>
|
package/src/intl/zh-TW.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
LessThanError,
|
|
31
31
|
LessThanOrEqualToError,
|
|
32
32
|
LiteralError,
|
|
33
|
+
MapError,
|
|
33
34
|
MaxLengthError,
|
|
34
35
|
MinLengthError,
|
|
35
36
|
MnemonicError,
|
|
@@ -330,10 +331,6 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
330
331
|
if (error.reason.kind === "NotSet") {
|
|
331
332
|
return `值 ${safelyStringifyUnknownValue(error.reason.value)} 不是 Set。`;
|
|
332
333
|
}
|
|
333
|
-
if (error.reason.kind === "UnexpectedPrototype") {
|
|
334
|
-
return "此值是 Set 子類別的執行個體,但 Set Output 必須是直接的 Set 執行個體。";
|
|
335
|
-
}
|
|
336
|
-
|
|
337
334
|
const issue = error.reason.issues[0];
|
|
338
335
|
|
|
339
336
|
switch (issue.kind) {
|
|
@@ -344,6 +341,24 @@ export const formatSetError: TypeErrorFormatter<SetError> = (error) => {
|
|
|
344
341
|
}
|
|
345
342
|
};
|
|
346
343
|
|
|
344
|
+
/** 以繁體中文格式化 MapError。 */
|
|
345
|
+
export const formatMapError: TypeErrorFormatter<MapError> = (error) => {
|
|
346
|
+
if (error.reason.kind === "NotMap") {
|
|
347
|
+
return `值 ${safelyStringifyUnknownValue(error.reason.value)} 不是 Map。`;
|
|
348
|
+
}
|
|
349
|
+
const issue = error.reason.issues[0];
|
|
350
|
+
|
|
351
|
+
switch (issue.kind) {
|
|
352
|
+
case "ExcessProperty":
|
|
353
|
+
return `不允許多餘的 Map 屬性 ${safelyStringifyUnknownValue(issue.key)}。`;
|
|
354
|
+
case "Key":
|
|
355
|
+
case "Value":
|
|
356
|
+
return `索引 ${issue.index} 的 Map 元素無效。`;
|
|
357
|
+
case "Collision":
|
|
358
|
+
return `Map 鍵 ${safelyStringifyUnknownValue(issue.previousKey)} 和 ${safelyStringifyUnknownValue(issue.key)} 解碼為相同的鍵 ${safelyStringifyUnknownValue(issue.outputKey)}。`;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
347
362
|
/** 以繁體中文格式化 TupleError。 */
|
|
348
363
|
export const formatTupleError: TypeErrorFormatter<
|
|
349
364
|
TupleError | TupleElementsError<TypeError>
|
package/src/local-first/Evolu.ts
CHANGED
|
@@ -97,10 +97,10 @@ export interface EvoluConfig {
|
|
|
97
97
|
* ### Example
|
|
98
98
|
*
|
|
99
99
|
* ```ts
|
|
100
|
-
* import { AppName } from "@evolu/common";
|
|
100
|
+
* import { AppName, assertEqual } from "@evolu/common";
|
|
101
101
|
*
|
|
102
102
|
* const appName = AppName.orThrow("MyApp");
|
|
103
|
-
*
|
|
103
|
+
* assertEqual(appName, "MyApp");
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
106
106
|
readonly appName: AppName;
|
|
@@ -164,6 +164,7 @@ export interface EvoluConfig {
|
|
|
164
164
|
*
|
|
165
165
|
* ```ts
|
|
166
166
|
* import {
|
|
167
|
+
* assertEqual,
|
|
167
168
|
* createAppOwner,
|
|
168
169
|
* createOwnerWebSocketTransport,
|
|
169
170
|
* createOwnerSecret,
|
|
@@ -177,19 +178,19 @@ export interface EvoluConfig {
|
|
|
177
178
|
* );
|
|
178
179
|
*
|
|
179
180
|
* // Use one relay.
|
|
180
|
-
* const
|
|
181
|
+
* const _singleRelay = [
|
|
181
182
|
* { type: "WebSocket", url: "wss://relay1.example.com" },
|
|
182
183
|
* ] satisfies ReadonlyArray<OwnerTransport>;
|
|
183
184
|
*
|
|
184
185
|
* // Use independent relays for redundancy.
|
|
185
|
-
* const
|
|
186
|
+
* const _redundantRelays = [
|
|
186
187
|
* { type: "WebSocket", url: "wss://relay1.example.com" },
|
|
187
188
|
* { type: "WebSocket", url: "wss://relay2.example.com" },
|
|
188
189
|
* ] satisfies ReadonlyArray<OwnerTransport>;
|
|
189
190
|
*
|
|
190
191
|
* // Start local-only before authentication. After authentication, pass an
|
|
191
192
|
* // owner-scoped transport to evolu.useOwner.
|
|
192
|
-
* const
|
|
193
|
+
* const _localOnlyBeforeAuthentication =
|
|
193
194
|
* [] satisfies ReadonlyArray<OwnerTransport>;
|
|
194
195
|
*
|
|
195
196
|
* // Include the OwnerId when the relay authenticates owners.
|
|
@@ -200,7 +201,8 @@ export interface EvoluConfig {
|
|
|
200
201
|
* }),
|
|
201
202
|
* ];
|
|
202
203
|
*
|
|
203
|
-
*
|
|
204
|
+
* assertEqual(
|
|
205
|
+
* authenticatedRelay[0]?.url,
|
|
204
206
|
* `wss://relay.example.com?ownerId=${appOwner.id}`,
|
|
205
207
|
* );
|
|
206
208
|
* ```
|
|
@@ -231,6 +233,7 @@ export interface EvoluConfig {
|
|
|
231
233
|
* ```ts
|
|
232
234
|
* import {
|
|
233
235
|
* AppName,
|
|
236
|
+
* assertTrue,
|
|
234
237
|
* createAppOwner,
|
|
235
238
|
* createEvolu,
|
|
236
239
|
* createOwnerSecret,
|
|
@@ -259,7 +262,7 @@ export interface EvoluConfig {
|
|
|
259
262
|
* ],
|
|
260
263
|
* });
|
|
261
264
|
*
|
|
262
|
-
*
|
|
265
|
+
* assertTrue(typeof createTodoEvolu === "function");
|
|
263
266
|
* ```
|
|
264
267
|
*/
|
|
265
268
|
readonly indexes?: IndexesConfig;
|
|
@@ -340,6 +343,7 @@ export interface Evolu<
|
|
|
340
343
|
*
|
|
341
344
|
* ```ts
|
|
342
345
|
* import {
|
|
346
|
+
* assertType,
|
|
343
347
|
* id,
|
|
344
348
|
* NonEmptyTrimmedString100,
|
|
345
349
|
* type Evolu,
|
|
@@ -366,12 +370,13 @@ export interface Evolu<
|
|
|
366
370
|
* { onComplete },
|
|
367
371
|
* ).id;
|
|
368
372
|
*
|
|
369
|
-
*
|
|
373
|
+
* assertType<
|
|
374
|
+
* [TodoId, TodoId],
|
|
370
375
|
* [
|
|
371
376
|
* ReturnType<typeof insertTodo>,
|
|
372
377
|
* ReturnType<typeof insertTodoAndNotify>,
|
|
373
378
|
* ]
|
|
374
|
-
* >()
|
|
379
|
+
* >();
|
|
375
380
|
* ```
|
|
376
381
|
*
|
|
377
382
|
* @see {@link Mutation}
|
|
@@ -387,6 +392,7 @@ export interface Evolu<
|
|
|
387
392
|
*
|
|
388
393
|
* ```ts
|
|
389
394
|
* import {
|
|
395
|
+
* assertType,
|
|
390
396
|
* id,
|
|
391
397
|
* NonEmptyTrimmedString100,
|
|
392
398
|
* sqliteTrue,
|
|
@@ -408,9 +414,10 @@ export interface Evolu<
|
|
|
408
414
|
* const softDeleteTodo = (evolu: Evolu<typeof Schema>, todoId: TodoId) =>
|
|
409
415
|
* evolu.update("todo", { id: todoId, isDeleted: sqliteTrue }).id;
|
|
410
416
|
*
|
|
411
|
-
*
|
|
417
|
+
* assertType<
|
|
418
|
+
* [TodoId, TodoId],
|
|
412
419
|
* [ReturnType<typeof renameTodo>, ReturnType<typeof softDeleteTodo>]
|
|
413
|
-
* >()
|
|
420
|
+
* >();
|
|
414
421
|
* ```
|
|
415
422
|
*
|
|
416
423
|
* @see {@link Mutation}
|
|
@@ -433,6 +440,7 @@ export interface Evolu<
|
|
|
433
440
|
*
|
|
434
441
|
* ```ts
|
|
435
442
|
* import {
|
|
443
|
+
* assertType,
|
|
436
444
|
* createIdFromString,
|
|
437
445
|
* id,
|
|
438
446
|
* NonEmptyTrimmedString100,
|
|
@@ -451,7 +459,7 @@ export interface Evolu<
|
|
|
451
459
|
* title: NonEmptyTrimmedString100.orThrow("Learn Evolu"),
|
|
452
460
|
* }).id;
|
|
453
461
|
*
|
|
454
|
-
*
|
|
462
|
+
* assertType<TodoId, ReturnType<typeof upsertTodo>>();
|
|
455
463
|
* ```
|
|
456
464
|
*
|
|
457
465
|
* @see {@link Mutation}
|
|
@@ -477,6 +485,7 @@ export interface Evolu<
|
|
|
477
485
|
*
|
|
478
486
|
* ```ts
|
|
479
487
|
* import {
|
|
488
|
+
* assertType,
|
|
480
489
|
* createQueryBuilder,
|
|
481
490
|
* id,
|
|
482
491
|
* NonEmptyTrimmedString100,
|
|
@@ -496,8 +505,9 @@ export interface Evolu<
|
|
|
496
505
|
* return rows;
|
|
497
506
|
* };
|
|
498
507
|
*
|
|
499
|
-
*
|
|
500
|
-
* Promise<QueryRows<typeof allTodos.Row
|
|
508
|
+
* assertType<
|
|
509
|
+
* Promise<QueryRows<typeof allTodos.Row>>,
|
|
510
|
+
* ReturnType<typeof loadTodos>
|
|
501
511
|
* >();
|
|
502
512
|
* ```
|
|
503
513
|
*/
|
|
@@ -514,6 +524,7 @@ export interface Evolu<
|
|
|
514
524
|
*
|
|
515
525
|
* ```ts
|
|
516
526
|
* import {
|
|
527
|
+
* assertType,
|
|
517
528
|
* createIdFromString,
|
|
518
529
|
* createQueryBuilder,
|
|
519
530
|
* id,
|
|
@@ -541,11 +552,12 @@ export interface Evolu<
|
|
|
541
552
|
* const loadTodoQueries = (evolu: Evolu<typeof Schema>) =>
|
|
542
553
|
* evolu.loadQueries([allTodos, firstTodo]);
|
|
543
554
|
*
|
|
544
|
-
*
|
|
555
|
+
* assertType<
|
|
545
556
|
* [
|
|
546
557
|
* Promise<QueryRows<typeof allTodos.Row>>,
|
|
547
558
|
* Promise<QueryRows<typeof firstTodo.Row>>,
|
|
548
|
-
* ]
|
|
559
|
+
* ],
|
|
560
|
+
* ReturnType<typeof loadTodoQueries>
|
|
549
561
|
* >();
|
|
550
562
|
* ```
|
|
551
563
|
*/
|
|
@@ -560,6 +572,7 @@ export interface Evolu<
|
|
|
560
572
|
*
|
|
561
573
|
* ```ts
|
|
562
574
|
* import {
|
|
575
|
+
* assertType,
|
|
563
576
|
* createQueryBuilder,
|
|
564
577
|
* id,
|
|
565
578
|
* NonEmptyTrimmedString100,
|
|
@@ -583,7 +596,7 @@ export interface Evolu<
|
|
|
583
596
|
* onRows(evolu.getQueryRows(allTodos));
|
|
584
597
|
* });
|
|
585
598
|
*
|
|
586
|
-
*
|
|
599
|
+
* assertType<Unsubscribe, ReturnType<typeof subscribeToTodos>>();
|
|
587
600
|
* ```
|
|
588
601
|
*/
|
|
589
602
|
readonly subscribeQuery: (
|
|
@@ -597,6 +610,7 @@ export interface Evolu<
|
|
|
597
610
|
*
|
|
598
611
|
* ```ts
|
|
599
612
|
* import {
|
|
613
|
+
* assertType,
|
|
600
614
|
* createQueryBuilder,
|
|
601
615
|
* id,
|
|
602
616
|
* NonEmptyTrimmedString100,
|
|
@@ -614,8 +628,9 @@ export interface Evolu<
|
|
|
614
628
|
* const getTodos = (evolu: Evolu<typeof Schema>) =>
|
|
615
629
|
* evolu.getQueryRows(allTodos);
|
|
616
630
|
*
|
|
617
|
-
*
|
|
618
|
-
* QueryRows<typeof allTodos.Row
|
|
631
|
+
* assertType<
|
|
632
|
+
* QueryRows<typeof allTodos.Row>,
|
|
633
|
+
* ReturnType<typeof getTodos>
|
|
619
634
|
* >();
|
|
620
635
|
* ```
|
|
621
636
|
*/
|
|
@@ -683,6 +698,7 @@ export interface Evolu<
|
|
|
683
698
|
*
|
|
684
699
|
* ```ts
|
|
685
700
|
* import {
|
|
701
|
+
* assertEqual,
|
|
686
702
|
* createAppOwner,
|
|
687
703
|
* createOwnerWebSocketTransport,
|
|
688
704
|
* createOwnerSecret,
|
|
@@ -702,10 +718,10 @@ export interface Evolu<
|
|
|
702
718
|
* url: "wss://relay.example.com",
|
|
703
719
|
* ownerId: shardOwner.id,
|
|
704
720
|
* });
|
|
705
|
-
* const
|
|
721
|
+
* const _useShardOwner = (evolu: Evolu): UnuseOwner =>
|
|
706
722
|
* evolu.useOwner(shardOwner, [shardTransport]);
|
|
707
723
|
*
|
|
708
|
-
* const
|
|
724
|
+
* const _useOwners = (
|
|
709
725
|
* evolu: Evolu,
|
|
710
726
|
* owners: ReadonlyArray<ReadonlyOwner>,
|
|
711
727
|
* ): UnuseOwner => {
|
|
@@ -723,7 +739,7 @@ export interface Evolu<
|
|
|
723
739
|
* };
|
|
724
740
|
*
|
|
725
741
|
* // Call each returned UnuseOwner once to stop syncing.
|
|
726
|
-
*
|
|
742
|
+
* assertEqual(shardTransport, {
|
|
727
743
|
* type: "WebSocket",
|
|
728
744
|
* url: `wss://relay.example.com?ownerId=${shardOwner.id}`,
|
|
729
745
|
* });
|
|
@@ -748,7 +764,12 @@ export interface EvoluErrorDep {
|
|
|
748
764
|
* ### Example
|
|
749
765
|
*
|
|
750
766
|
* ```ts
|
|
751
|
-
* import {
|
|
767
|
+
* import {
|
|
768
|
+
* assertEqual,
|
|
769
|
+
* createStore,
|
|
770
|
+
* Millis,
|
|
771
|
+
* type EvoluError,
|
|
772
|
+
* } from "@evolu/common";
|
|
752
773
|
* import type { EvoluErrorDep } from "@evolu/common/local-first";
|
|
753
774
|
*
|
|
754
775
|
* // Stand-in for run.deps.evoluError from createEvoluDeps.
|
|
@@ -763,6 +784,7 @@ export interface EvoluErrorDep {
|
|
|
763
784
|
* const error = deps.evoluError.get();
|
|
764
785
|
* if (!error) return;
|
|
765
786
|
*
|
|
787
|
+
* // oxlint-disable-next-line typescript/switch-exhaustiveness-check -- The default intentionally handles every other EvoluError.
|
|
766
788
|
* switch (error.type) {
|
|
767
789
|
* case "TimestampDriftError":
|
|
768
790
|
* // Show guidance specific to the detected error.
|
|
@@ -781,7 +803,8 @@ export interface EvoluErrorDep {
|
|
|
781
803
|
* next: Millis.orThrow(360000),
|
|
782
804
|
* now: Millis.orThrow(0),
|
|
783
805
|
* });
|
|
784
|
-
*
|
|
806
|
+
* assertEqual(
|
|
807
|
+
* displayedMessage,
|
|
785
808
|
* "Your system clock appears incorrect. Please fix it.",
|
|
786
809
|
* );
|
|
787
810
|
* ```
|
package/src/local-first/Owner.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ## Intro
|
|
3
|
-
*
|
|
4
2
|
* Cryptographic identities that define ownership, encryption, sync, and
|
|
5
3
|
* deletion boundaries for Evolu data.
|
|
6
4
|
*
|
|
@@ -448,6 +446,8 @@ export interface OwnerWebSocketTransport extends Typed<"WebSocket"> {
|
|
|
448
446
|
* ```ts
|
|
449
447
|
* import {
|
|
450
448
|
* AppName,
|
|
449
|
+
* assertEqual,
|
|
450
|
+
* assertTrue,
|
|
451
451
|
* createAppOwner,
|
|
452
452
|
* createEvolu,
|
|
453
453
|
* createOwnerWebSocketTransport,
|
|
@@ -473,8 +473,8 @@ export interface OwnerWebSocketTransport extends Typed<"WebSocket"> {
|
|
|
473
473
|
* },
|
|
474
474
|
* );
|
|
475
475
|
*
|
|
476
|
-
*
|
|
477
|
-
*
|
|
476
|
+
* assertTrue(typeof createTodoEvolu === "function");
|
|
477
|
+
* assertEqual(transport, {
|
|
478
478
|
* type: "WebSocket",
|
|
479
479
|
* url: `wss://relay.evolu.dev?ownerId=${appOwner.id}`,
|
|
480
480
|
* });
|
|
@@ -501,6 +501,7 @@ export const createOwnerWebSocketTransport = (config: {
|
|
|
501
501
|
*
|
|
502
502
|
* ```ts
|
|
503
503
|
* import {
|
|
504
|
+
* assertEqual,
|
|
504
505
|
* createAppOwner,
|
|
505
506
|
* createOwnerSecret,
|
|
506
507
|
* createRandomBytes,
|
|
@@ -513,12 +514,14 @@ export const createOwnerWebSocketTransport = (config: {
|
|
|
513
514
|
* );
|
|
514
515
|
* const url = `/sync?ownerId=${appOwner.id}`;
|
|
515
516
|
*
|
|
516
|
-
*
|
|
517
|
+
* assertEqual(
|
|
518
|
+
* parseOwnerIdFromOwnerWebSocketTransportUrl(url),
|
|
517
519
|
* appOwner.id,
|
|
518
520
|
* );
|
|
519
|
-
*
|
|
521
|
+
* assertEqual(
|
|
520
522
|
* parseOwnerIdFromOwnerWebSocketTransportUrl("/sync?ownerId=invalid"),
|
|
521
|
-
*
|
|
523
|
+
* null,
|
|
524
|
+
* );
|
|
522
525
|
* ```
|
|
523
526
|
*
|
|
524
527
|
* @group Transport
|
|
@@ -183,7 +183,7 @@ import {
|
|
|
183
183
|
isNonEmptyArray,
|
|
184
184
|
type NonEmptyReadonlyArray,
|
|
185
185
|
} from "../Array.ts";
|
|
186
|
-
import { assert, assertNonNullable } from "../Assert.ts";
|
|
186
|
+
import { assert, assertNonNullable, assertNotUndefined } from "../Assert.ts";
|
|
187
187
|
import type { Brand } from "../Brand.ts";
|
|
188
188
|
import {
|
|
189
189
|
type Buffer,
|
|
@@ -1814,13 +1814,13 @@ export const decodeNumber = (buffer: Buffer): number => {
|
|
|
1814
1814
|
* ### Example
|
|
1815
1815
|
*
|
|
1816
1816
|
* ```ts
|
|
1817
|
-
* import { createBuffer } from "@evolu/common";
|
|
1817
|
+
* import { assertEqual, createBuffer } from "@evolu/common";
|
|
1818
1818
|
* import { encodeFlags } from "@evolu/common/local-first";
|
|
1819
1819
|
*
|
|
1820
1820
|
* const buffer = createBuffer();
|
|
1821
1821
|
* encodeFlags(buffer, [true, false, true]);
|
|
1822
1822
|
*
|
|
1823
|
-
*
|
|
1823
|
+
* assertEqual(buffer.unwrap(), new Uint8Array([0b101]));
|
|
1824
1824
|
* ```
|
|
1825
1825
|
*/
|
|
1826
1826
|
export const encodeFlags = (
|
|
@@ -1842,14 +1842,14 @@ export const encodeFlags = (
|
|
|
1842
1842
|
* ### Example
|
|
1843
1843
|
*
|
|
1844
1844
|
* ```ts
|
|
1845
|
-
* import { createBuffer, PositiveInt } from "@evolu/common";
|
|
1845
|
+
* import { assertEqual, createBuffer, PositiveInt } from "@evolu/common";
|
|
1846
1846
|
* import { decodeFlags } from "@evolu/common/local-first";
|
|
1847
1847
|
*
|
|
1848
1848
|
* const buffer = createBuffer([0b101]);
|
|
1849
1849
|
* const flags = decodeFlags(buffer, PositiveInt.orThrow(3));
|
|
1850
1850
|
*
|
|
1851
|
-
*
|
|
1852
|
-
*
|
|
1851
|
+
* assertEqual(flags, [true, false, true]);
|
|
1852
|
+
* assertEqual(buffer.getLength(), 0);
|
|
1853
1853
|
* ```
|
|
1854
1854
|
*/
|
|
1855
1855
|
export const decodeFlags = (
|
|
@@ -1898,7 +1898,7 @@ export const encodeAndEncryptDbChange =
|
|
|
1898
1898
|
|
|
1899
1899
|
encodeLength(buffer, entries);
|
|
1900
1900
|
for (const [column, value] of entries) {
|
|
1901
|
-
|
|
1901
|
+
assertNotUndefined(value);
|
|
1902
1902
|
encodeString(buffer, column);
|
|
1903
1903
|
encodeSqliteValue(buffer, value);
|
|
1904
1904
|
}
|