jazz-tools 0.19.22 → 0.20.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/.svelte-kit/__package__/react.d.ts.map +1 -1
- package/.svelte-kit/__package__/react.tsx +5 -2
- package/.turbo/turbo-build.log +71 -83
- package/CHANGELOG.md +80 -0
- package/dist/better-auth/auth/react.d.ts.map +1 -1
- package/dist/better-auth/auth/react.js +5 -2
- package/dist/better-auth/auth/react.js.map +1 -1
- package/dist/browser/createBrowserContext.d.ts +1 -2
- package/dist/browser/createBrowserContext.d.ts.map +1 -1
- package/dist/browser/index.js +1 -8
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/provideBrowserLockSession/SessionIDStorage.d.ts +1 -1
- package/dist/{chunk-QCTQH5RS.js → chunk-2OPP7KWV.js} +382 -174
- package/dist/chunk-2OPP7KWV.js.map +1 -0
- package/dist/{chunk-M2HGBOXS.js → chunk-K4D7IMFM.js} +3 -3
- package/dist/chunk-K4D7IMFM.js.map +1 -0
- package/dist/chunk-ZQWSQH6L.js +20 -0
- package/dist/expo/auth/clerk/index.d.ts.map +1 -1
- package/dist/expo/index.js +5 -2
- package/dist/expo/index.js.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/inspector/{chunk-YQNK5Y7B.js → chunk-MCTB5ZJC.js} +1 -1
- package/dist/inspector/chunk-MCTB5ZJC.js.map +1 -0
- package/dist/inspector/contexts/node.d.ts.map +1 -1
- package/dist/inspector/{custom-element-KYV64IOC.js → custom-element-5YWVZBWA.js} +1 -1
- package/dist/inspector/{custom-element-KYV64IOC.js.map → custom-element-5YWVZBWA.js.map} +1 -1
- package/dist/inspector/index.js +3 -3
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/standalone.js +1 -1
- package/dist/react/auth/Clerk.d.ts.map +1 -1
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.js +61 -47
- package/dist/react/index.js.map +1 -1
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/ssr.js +2 -2
- package/dist/react/ssr.js.map +1 -1
- package/dist/react-core/chunk-UOYH6JFJ.js +10 -0
- package/dist/react-core/chunk-UOYH6JFJ.js.map +1 -0
- package/dist/react-core/hooks.d.ts +3 -3
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +27 -25
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/provider.d.ts +2 -3
- package/dist/react-core/provider.d.ts.map +1 -1
- package/dist/react-core/testing.d.ts.map +1 -1
- package/dist/react-core/testing.js +4 -10
- package/dist/react-core/testing.js.map +1 -1
- package/dist/react-native/index.js +61 -53
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native-core/ReactNativeContextManager.d.ts +0 -1
- package/dist/react-native-core/ReactNativeContextManager.d.ts.map +1 -1
- package/dist/react-native-core/hooks.d.ts +1 -1
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js +58 -50
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/platform.d.ts +0 -4
- package/dist/react-native-core/platform.d.ts.map +1 -1
- package/dist/react-native-core/provider.d.ts +2 -1
- package/dist/react-native-core/provider.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +2 -8
- package/dist/svelte/tests/AccountCoState.svelte.test.d.ts +2 -0
- package/dist/svelte/tests/AccountCoState.svelte.test.d.ts.map +1 -0
- package/dist/svelte/tests/AccountCoState.svelte.test.js +59 -0
- package/dist/svelte/tests/CoState.svelte.test.js +23 -0
- package/dist/svelte/tests/TestAccountCoStateWrapper.svelte +24 -0
- package/dist/svelte/tests/TestAccountCoStateWrapper.svelte.d.ts +11 -0
- package/dist/svelte/tests/TestAccountCoStateWrapper.svelte.d.ts.map +1 -0
- package/dist/testing.js +7 -7
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/coList.d.ts +2 -2
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +2 -2
- package/dist/tools/coValues/deepLoading.d.ts +2 -2
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +32 -0
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/ContextManager.d.ts.map +1 -1
- package/dist/tools/implementation/createContext.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +5 -4
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +5 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +7 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +3 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +3 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +2 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +6 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/ssr.js +2 -2
- package/dist/tools/subscribe/JazzError.d.ts +3 -3
- package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/types.d.ts +5 -1
- package/dist/tools/subscribe/types.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +3 -3
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/deleteCoValues.test.d.ts +2 -0
- package/dist/tools/tests/deleteCoValues.test.d.ts.map +1 -0
- package/dist/tools/tests/deletedState.test.d.ts +2 -0
- package/dist/tools/tests/deletedState.test.d.ts.map +1 -0
- package/dist/worker/edge-wasm.js +2 -1
- package/dist/worker/edge-wasm.js.map +1 -1
- package/dist/worker/wasm.d.ts +2 -0
- package/dist/worker/wasm.d.ts.map +1 -0
- package/package.json +9 -28
- package/src/better-auth/auth/react.tsx +5 -2
- package/src/browser/createBrowserContext.ts +2 -5
- package/src/expo/auth/clerk/index.tsx +5 -2
- package/src/inspector/contexts/node.tsx +1 -2
- package/src/inspector/index.tsx +2 -2
- package/src/react/auth/Clerk.tsx +5 -2
- package/src/react/auth/PasskeyAuth.tsx +2 -2
- package/src/react/hooks.tsx +3 -2
- package/src/react/provider.tsx +45 -41
- package/src/react-core/auth/DemoAuth.tsx +2 -2
- package/src/react-core/auth/PassphraseAuth.tsx +2 -2
- package/src/react-core/hooks.ts +26 -27
- package/src/react-core/provider.tsx +1 -5
- package/src/react-core/testing.tsx +3 -11
- package/src/react-core/tests/useAccount.selector.test.ts +2 -3
- package/src/react-core/tests/useAccount.test.ts +57 -7
- package/src/react-core/tests/useCoState.test.ts +37 -0
- package/src/react-core/tests/useInboxSender.test.ts +2 -5
- package/src/react-core/tests/useSuspenseAccount.test.tsx +68 -0
- package/src/react-core/tests/useSuspenseCoState.test.tsx +44 -0
- package/src/react-native-core/ReactNativeContextManager.ts +0 -3
- package/src/react-native-core/auth/usePasskeyAuth.tsx +2 -2
- package/src/react-native-core/hooks.tsx +3 -3
- package/src/react-native-core/platform.ts +2 -6
- package/src/react-native-core/provider.tsx +47 -43
- package/src/svelte/jazz.class.svelte.ts +2 -8
- package/src/svelte/tests/AccountCoState.svelte.test.ts +79 -0
- package/src/svelte/tests/CoState.svelte.test.ts +36 -0
- package/src/svelte/tests/TestAccountCoStateWrapper.svelte +24 -0
- package/src/tools/coValues/coList.ts +73 -37
- package/src/tools/coValues/deepLoading.ts +2 -0
- package/src/tools/coValues/interfaces.ts +170 -32
- package/src/tools/exports.ts +1 -0
- package/src/tools/implementation/ContextManager.ts +2 -2
- package/src/tools/implementation/createContext.ts +4 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +30 -8
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +55 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +38 -16
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +40 -8
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +40 -16
- package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +6 -2
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +6 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +5 -2
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +9 -2
- package/src/tools/ssr/ssr.ts +2 -2
- package/src/tools/subscribe/CoValueCoreSubscription.ts +1 -0
- package/src/tools/subscribe/JazzError.ts +4 -1
- package/src/tools/subscribe/SubscriptionScope.ts +23 -0
- package/src/tools/subscribe/types.ts +5 -0
- package/src/tools/testing.ts +5 -5
- package/src/tools/tests/PassphraseAuth.test.ts +5 -5
- package/src/tools/tests/coList.test.ts +262 -0
- package/src/tools/tests/deleteCoValues.test.ts +231 -0
- package/src/tools/tests/deletedState.test.ts +110 -0
- package/src/tools/tests/request.test.ts +15 -2
- package/src/tools/tests/schema.withPermissions.test.ts +27 -4
- package/src/worker/edge-wasm.ts +2 -1
- package/src/worker/wasm.ts +1 -0
- package/tsup.config.ts +0 -4
- package/dist/browser/storageOptions.d.ts +0 -8
- package/dist/browser/storageOptions.d.ts.map +0 -1
- package/dist/browser/tests/storageOptions.test.d.ts +0 -2
- package/dist/browser/tests/storageOptions.test.d.ts.map +0 -1
- package/dist/chunk-M2HGBOXS.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-QCTQH5RS.js.map +0 -1
- package/dist/expo/crypto.d.ts +0 -2
- package/dist/expo/crypto.d.ts.map +0 -1
- package/dist/expo/crypto.js +0 -6
- package/dist/expo/crypto.js.map +0 -1
- package/dist/inspector/chunk-YQNK5Y7B.js.map +0 -1
- package/dist/react-core/chunk-7DYMJ74I.js +0 -12
- package/dist/react-core/chunk-7DYMJ74I.js.map +0 -1
- package/dist/react-native/chunk-DGUM43GV.js +0 -11
- package/dist/react-native/chunk-DGUM43GV.js.map +0 -1
- package/dist/react-native/crypto.d.ts +0 -2
- package/dist/react-native/crypto.d.ts.map +0 -1
- package/dist/react-native/crypto.js +0 -8
- package/dist/react-native/crypto.js.map +0 -1
- package/dist/react-native-core/chunk-DGUM43GV.js +0 -11
- package/dist/react-native-core/chunk-DGUM43GV.js.map +0 -1
- package/dist/react-native-core/crypto/RNCrypto.d.ts +0 -2
- package/dist/react-native-core/crypto/RNCrypto.d.ts.map +0 -1
- package/dist/react-native-core/crypto/RNCrypto.js +0 -3
- package/dist/react-native-core/crypto/RNCrypto.js.map +0 -1
- package/dist/react-native-core/crypto/RNQuickCrypto.d.ts +0 -17
- package/dist/react-native-core/crypto/RNQuickCrypto.d.ts.map +0 -1
- package/dist/react-native-core/crypto/index.d.ts +0 -2
- package/dist/react-native-core/crypto/index.d.ts.map +0 -1
- package/dist/react-native-core/crypto.js +0 -89
- package/dist/react-native-core/crypto.js.map +0 -1
- package/src/browser/storageOptions.ts +0 -17
- package/src/browser/tests/storageOptions.test.ts +0 -33
- package/src/expo/crypto.ts +0 -1
- package/src/react-native/crypto.ts +0 -1
- package/src/react-native-core/crypto/RNCrypto.ts +0 -1
- package/src/react-native-core/crypto/RNQuickCrypto.ts +0 -122
- package/src/react-native-core/crypto/index.ts +0 -1
- /package/dist/{chunk-PZ5AY32C.js.map → chunk-ZQWSQH6L.js.map} +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__export
|
|
3
|
-
|
|
2
|
+
__export,
|
|
3
|
+
__privateAdd,
|
|
4
|
+
__privateGet,
|
|
5
|
+
__privateSet
|
|
6
|
+
} from "./chunk-ZQWSQH6L.js";
|
|
4
7
|
|
|
5
8
|
// src/tools/implementation/zodSchema/zodReExport.ts
|
|
6
9
|
var zodReExport_exports = {};
|
|
@@ -127,6 +130,56 @@ function isAnyCoValueSchema(schema) {
|
|
|
127
130
|
return typeof schema === "object" && schema !== null && "collaborative" in schema && schema.collaborative === true;
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
// src/tools/subscribe/JazzError.ts
|
|
134
|
+
var JazzError = class _JazzError {
|
|
135
|
+
constructor(id, type, issues) {
|
|
136
|
+
this.id = id;
|
|
137
|
+
this.type = type;
|
|
138
|
+
this.issues = issues;
|
|
139
|
+
}
|
|
140
|
+
toString() {
|
|
141
|
+
let result = this.issues.map((issue) => {
|
|
142
|
+
let message = `${issue.message}`;
|
|
143
|
+
if (issue.path.length > 0) {
|
|
144
|
+
if (this.id) {
|
|
145
|
+
message += `. Subscription starts from ${this.id}`;
|
|
146
|
+
}
|
|
147
|
+
message += ` and the value is on path ${issue.path.join(".")}`;
|
|
148
|
+
}
|
|
149
|
+
return message;
|
|
150
|
+
}).join("\n");
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
prependPath(item) {
|
|
154
|
+
if (this.issues.length === 0) {
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
const issues = this.issues.map((issue) => {
|
|
158
|
+
return {
|
|
159
|
+
...issue,
|
|
160
|
+
path: [item].concat(issue.path)
|
|
161
|
+
};
|
|
162
|
+
});
|
|
163
|
+
return new _JazzError(this.id, this.type, issues);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
function fillErrorWithJazzErrorInfo(errorBase, jazzError) {
|
|
167
|
+
if (!jazzError) {
|
|
168
|
+
return errorBase;
|
|
169
|
+
}
|
|
170
|
+
errorBase.message = jazzError.toString();
|
|
171
|
+
Object.defineProperty(errorBase, "@jazzErrorType", {
|
|
172
|
+
value: jazzError.type
|
|
173
|
+
});
|
|
174
|
+
return errorBase;
|
|
175
|
+
}
|
|
176
|
+
function getJazzErrorType(error) {
|
|
177
|
+
if (error instanceof Error && "@jazzErrorType" in error && typeof error["@jazzErrorType"] === "string") {
|
|
178
|
+
return error["@jazzErrorType"];
|
|
179
|
+
}
|
|
180
|
+
return "unknown";
|
|
181
|
+
}
|
|
182
|
+
|
|
130
183
|
// src/tools/coValues/interfaces.ts
|
|
131
184
|
import {
|
|
132
185
|
cojsonInternals as cojsonInternals6
|
|
@@ -1229,7 +1282,7 @@ var CoListJazzApi = class extends CoValueJazzApi {
|
|
|
1229
1282
|
void 0,
|
|
1230
1283
|
"private"
|
|
1231
1284
|
);
|
|
1232
|
-
return this.raw.
|
|
1285
|
+
return this.raw.length();
|
|
1233
1286
|
}
|
|
1234
1287
|
/**
|
|
1235
1288
|
* Inserts new elements at the start of an array, and returns the new length of the array.
|
|
@@ -1245,7 +1298,7 @@ var CoListJazzApi = class extends CoValueJazzApi {
|
|
|
1245
1298
|
)) {
|
|
1246
1299
|
this.raw.prepend(item);
|
|
1247
1300
|
}
|
|
1248
|
-
return this.raw.
|
|
1301
|
+
return this.raw.length();
|
|
1249
1302
|
}
|
|
1250
1303
|
/**
|
|
1251
1304
|
* Removes the last element from an array and returns it.
|
|
@@ -1477,40 +1530,60 @@ function toRawItems(items, itemDescriptor, owner) {
|
|
|
1477
1530
|
}
|
|
1478
1531
|
return rawItems;
|
|
1479
1532
|
}
|
|
1533
|
+
function getCoListItemValue(target, key) {
|
|
1534
|
+
const rawValue = target.$jazz.raw.get(Number(key));
|
|
1535
|
+
if (rawValue === void 0) {
|
|
1536
|
+
return void 0;
|
|
1537
|
+
}
|
|
1538
|
+
const itemDescriptor = target.$jazz.schema[ItemsSym];
|
|
1539
|
+
if (itemDescriptor === "json") {
|
|
1540
|
+
return rawValue;
|
|
1541
|
+
} else if ("encoded" in itemDescriptor) {
|
|
1542
|
+
return itemDescriptor.encoded.decode(rawValue);
|
|
1543
|
+
} else if (isRefEncoded(itemDescriptor)) {
|
|
1544
|
+
if (rawValue === null) {
|
|
1545
|
+
return void 0;
|
|
1546
|
+
}
|
|
1547
|
+
return accessChildByKey(target, rawValue, key);
|
|
1548
|
+
}
|
|
1549
|
+
return void 0;
|
|
1550
|
+
}
|
|
1480
1551
|
var CoListProxyHandler = {
|
|
1481
1552
|
get(target, key, receiver) {
|
|
1482
|
-
if (typeof key === "
|
|
1483
|
-
const itemDescriptor = target.$jazz.schema[ItemsSym];
|
|
1484
|
-
const rawValue = target.$jazz.raw.get(Number(key));
|
|
1485
|
-
if (itemDescriptor === "json") {
|
|
1486
|
-
return rawValue;
|
|
1487
|
-
} else if ("encoded" in itemDescriptor) {
|
|
1488
|
-
return rawValue === void 0 ? void 0 : itemDescriptor.encoded.decode(rawValue);
|
|
1489
|
-
} else if (isRefEncoded(itemDescriptor)) {
|
|
1490
|
-
return rawValue === void 0 || rawValue === null ? void 0 : accessChildByKey(target, rawValue, key);
|
|
1491
|
-
}
|
|
1492
|
-
} else if (key === "length") {
|
|
1493
|
-
return target.$jazz.raw.entries().length;
|
|
1494
|
-
} else {
|
|
1553
|
+
if (typeof key === "symbol") {
|
|
1495
1554
|
return Reflect.get(target, key, receiver);
|
|
1496
1555
|
}
|
|
1556
|
+
if (!isNaN(+key)) {
|
|
1557
|
+
return getCoListItemValue(target, key);
|
|
1558
|
+
} else if (key === "length") {
|
|
1559
|
+
return target.$jazz.raw.length();
|
|
1560
|
+
}
|
|
1561
|
+
return Reflect.get(target, key, receiver);
|
|
1497
1562
|
},
|
|
1498
1563
|
set(target, key, value, receiver) {
|
|
1564
|
+
if (typeof key === "symbol") {
|
|
1565
|
+
return Reflect.set(target, key, value, receiver);
|
|
1566
|
+
}
|
|
1499
1567
|
if (key === ItemsSym && typeof value === "object" && SchemaInit in value) {
|
|
1500
|
-
target.constructor
|
|
1501
|
-
|
|
1568
|
+
const constructor = target.constructor;
|
|
1569
|
+
if (!constructor._schema) {
|
|
1570
|
+
constructor._schema = {};
|
|
1571
|
+
}
|
|
1572
|
+
constructor._schema[ItemsSym] = value[SchemaInit];
|
|
1502
1573
|
return true;
|
|
1503
1574
|
}
|
|
1504
|
-
if (
|
|
1575
|
+
if (!isNaN(+key)) {
|
|
1505
1576
|
throw Error("Cannot update a CoList directly. Use `$jazz.set` instead.");
|
|
1506
|
-
} else {
|
|
1507
|
-
return Reflect.set(target, key, value, receiver);
|
|
1508
1577
|
}
|
|
1578
|
+
return Reflect.set(target, key, value, receiver);
|
|
1509
1579
|
},
|
|
1510
1580
|
defineProperty(target, key, descriptor) {
|
|
1511
1581
|
if (descriptor.value && key === ItemsSym && typeof descriptor.value === "object" && SchemaInit in descriptor.value) {
|
|
1512
|
-
target.constructor
|
|
1513
|
-
|
|
1582
|
+
const constructor = target.constructor;
|
|
1583
|
+
if (!constructor._schema) {
|
|
1584
|
+
constructor._schema = {};
|
|
1585
|
+
}
|
|
1586
|
+
constructor._schema[ItemsSym] = descriptor.value[SchemaInit];
|
|
1514
1587
|
return true;
|
|
1515
1588
|
} else {
|
|
1516
1589
|
return Reflect.defineProperty(target, key, descriptor);
|
|
@@ -1518,18 +1591,23 @@ var CoListProxyHandler = {
|
|
|
1518
1591
|
},
|
|
1519
1592
|
has(target, key) {
|
|
1520
1593
|
if (typeof key === "string" && !isNaN(+key)) {
|
|
1521
|
-
return Number(key) < target.$jazz.raw.
|
|
1594
|
+
return Number(key) < target.$jazz.raw.length();
|
|
1522
1595
|
} else {
|
|
1523
1596
|
return Reflect.has(target, key);
|
|
1524
1597
|
}
|
|
1525
1598
|
},
|
|
1526
1599
|
ownKeys(target) {
|
|
1527
1600
|
const keys = Reflect.ownKeys(target);
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1601
|
+
const length = target.$jazz.raw.length();
|
|
1602
|
+
for (let i = 0; i < length; i++) {
|
|
1603
|
+
keys.push(String(i));
|
|
1604
|
+
}
|
|
1530
1605
|
return keys;
|
|
1531
1606
|
},
|
|
1532
1607
|
getOwnPropertyDescriptor(target, key) {
|
|
1608
|
+
if (typeof key === "symbol") {
|
|
1609
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
1610
|
+
}
|
|
1533
1611
|
if (key === TypeSym) {
|
|
1534
1612
|
return {
|
|
1535
1613
|
enumerable: false,
|
|
@@ -1537,24 +1615,26 @@ var CoListProxyHandler = {
|
|
|
1537
1615
|
writable: false,
|
|
1538
1616
|
value: target[TypeSym]
|
|
1539
1617
|
};
|
|
1540
|
-
} else if (key
|
|
1541
|
-
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
1542
|
-
} else if (typeof key === "string" && !isNaN(+key)) {
|
|
1618
|
+
} else if (!isNaN(+key)) {
|
|
1543
1619
|
const index = Number(key);
|
|
1544
|
-
if (index >= 0 && index < target.$jazz.raw.
|
|
1620
|
+
if (index >= 0 && index < target.$jazz.raw.length()) {
|
|
1545
1621
|
return {
|
|
1546
1622
|
enumerable: true,
|
|
1547
1623
|
configurable: true,
|
|
1548
|
-
writable:
|
|
1624
|
+
writable: false,
|
|
1625
|
+
value: getCoListItemValue(target, key)
|
|
1549
1626
|
};
|
|
1550
1627
|
}
|
|
1551
1628
|
} else if (key === "length") {
|
|
1552
1629
|
return {
|
|
1553
1630
|
enumerable: false,
|
|
1554
1631
|
configurable: false,
|
|
1555
|
-
writable:
|
|
1632
|
+
writable: true,
|
|
1633
|
+
// Must be writable, otherwise JS complains
|
|
1634
|
+
value: target.$jazz.raw.length()
|
|
1556
1635
|
};
|
|
1557
1636
|
}
|
|
1637
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
|
1558
1638
|
}
|
|
1559
1639
|
};
|
|
1560
1640
|
|
|
@@ -3993,6 +4073,10 @@ var CoValueLoadingState = {
|
|
|
3993
4073
|
* The coValue is being loaded.
|
|
3994
4074
|
*/
|
|
3995
4075
|
LOADING: "loading",
|
|
4076
|
+
/**
|
|
4077
|
+
* The coValue existed but has been deleted (tombstoned).
|
|
4078
|
+
*/
|
|
4079
|
+
DELETED: "deleted",
|
|
3996
4080
|
/**
|
|
3997
4081
|
* The coValue was loaded but the account is not authorized to access it.
|
|
3998
4082
|
*/
|
|
@@ -4133,57 +4217,7 @@ var CoValueCoreSubscription = class {
|
|
|
4133
4217
|
}
|
|
4134
4218
|
};
|
|
4135
4219
|
function isCompletelyDownloaded(value) {
|
|
4136
|
-
return value.core.verified?.header.meta?.type === "binary" || value.core.isCompletelyDownloaded();
|
|
4137
|
-
}
|
|
4138
|
-
|
|
4139
|
-
// src/tools/subscribe/JazzError.ts
|
|
4140
|
-
var JazzError = class _JazzError {
|
|
4141
|
-
constructor(id, type, issues) {
|
|
4142
|
-
this.id = id;
|
|
4143
|
-
this.type = type;
|
|
4144
|
-
this.issues = issues;
|
|
4145
|
-
}
|
|
4146
|
-
toString() {
|
|
4147
|
-
let result = this.issues.map((issue) => {
|
|
4148
|
-
let message = `${issue.message}`;
|
|
4149
|
-
if (issue.path.length > 0) {
|
|
4150
|
-
if (this.id) {
|
|
4151
|
-
message += `. Subscription starts from ${this.id}`;
|
|
4152
|
-
}
|
|
4153
|
-
message += ` and the value is on path ${issue.path.join(".")}`;
|
|
4154
|
-
}
|
|
4155
|
-
return message;
|
|
4156
|
-
}).join("\n");
|
|
4157
|
-
return result;
|
|
4158
|
-
}
|
|
4159
|
-
prependPath(item) {
|
|
4160
|
-
if (this.issues.length === 0) {
|
|
4161
|
-
return this;
|
|
4162
|
-
}
|
|
4163
|
-
const issues = this.issues.map((issue) => {
|
|
4164
|
-
return {
|
|
4165
|
-
...issue,
|
|
4166
|
-
path: [item].concat(issue.path)
|
|
4167
|
-
};
|
|
4168
|
-
});
|
|
4169
|
-
return new _JazzError(this.id, this.type, issues);
|
|
4170
|
-
}
|
|
4171
|
-
};
|
|
4172
|
-
function fillErrorWithJazzErrorInfo(errorBase, jazzError) {
|
|
4173
|
-
if (!jazzError) {
|
|
4174
|
-
return errorBase;
|
|
4175
|
-
}
|
|
4176
|
-
errorBase.message = jazzError.toString();
|
|
4177
|
-
Object.defineProperty(errorBase, "@jazzErrorType", {
|
|
4178
|
-
value: jazzError.type
|
|
4179
|
-
});
|
|
4180
|
-
return errorBase;
|
|
4181
|
-
}
|
|
4182
|
-
function getJazzErrorType(error) {
|
|
4183
|
-
if (error instanceof Error && "@jazzErrorType" in error && typeof error["@jazzErrorType"] === "string") {
|
|
4184
|
-
return error["@jazzErrorType"];
|
|
4185
|
-
}
|
|
4186
|
-
return "unknown";
|
|
4220
|
+
return value.core.isDeleted || value.core.verified?.header.meta?.type === "binary" || value.core.isCompletelyDownloaded();
|
|
4187
4221
|
}
|
|
4188
4222
|
|
|
4189
4223
|
// src/tools/subscribe/errorReporting.ts
|
|
@@ -4384,6 +4418,23 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
|
4384
4418
|
this.triggerUpdate();
|
|
4385
4419
|
return;
|
|
4386
4420
|
}
|
|
4421
|
+
if (update.core.isDeleted) {
|
|
4422
|
+
if (this.value.type !== CoValueLoadingState.DELETED) {
|
|
4423
|
+
const error = new JazzError(this.id, CoValueLoadingState.DELETED, [
|
|
4424
|
+
{
|
|
4425
|
+
code: CoValueLoadingState.DELETED,
|
|
4426
|
+
message: `Jazz Deleted Error: ${this.id} has been deleted`,
|
|
4427
|
+
params: {
|
|
4428
|
+
id: this.id
|
|
4429
|
+
},
|
|
4430
|
+
path: []
|
|
4431
|
+
}
|
|
4432
|
+
]);
|
|
4433
|
+
this.updateValue(error);
|
|
4434
|
+
this.triggerUpdate();
|
|
4435
|
+
}
|
|
4436
|
+
return;
|
|
4437
|
+
}
|
|
4387
4438
|
if (!hasAccessToCoValue(update)) {
|
|
4388
4439
|
if (this.value.type !== CoValueLoadingState.UNAUTHORIZED) {
|
|
4389
4440
|
const message = `Jazz Authorization Error: The current user (${this.node.getCurrentAgent().id}) is not authorized to access ${this.id}`;
|
|
@@ -4461,7 +4512,7 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
|
4461
4512
|
this.pendingLoadedChildren.delete(id);
|
|
4462
4513
|
this.pendingAutoloadedChildren.delete(id);
|
|
4463
4514
|
this.childValues.set(id, value);
|
|
4464
|
-
if (value.type === CoValueLoadingState.UNAVAILABLE || value.type === CoValueLoadingState.UNAUTHORIZED) {
|
|
4515
|
+
if (value.type === CoValueLoadingState.UNAVAILABLE || value.type === CoValueLoadingState.DELETED || value.type === CoValueLoadingState.UNAUTHORIZED) {
|
|
4465
4516
|
this.childErrors.set(id, value.prependPath(key ?? id));
|
|
4466
4517
|
this.errorFromChildren = this.computeChildErrors();
|
|
4467
4518
|
} else if (this.errorFromChildren && this.childErrors.has(id)) {
|
|
@@ -4555,14 +4606,14 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
|
4555
4606
|
}
|
|
4556
4607
|
getCurrentValue() {
|
|
4557
4608
|
const rawValue = this.getCurrentRawValue();
|
|
4558
|
-
if (rawValue === CoValueLoadingState.UNAUTHORIZED || rawValue === CoValueLoadingState.UNAVAILABLE || rawValue === CoValueLoadingState.LOADING) {
|
|
4609
|
+
if (rawValue === CoValueLoadingState.UNAUTHORIZED || rawValue === CoValueLoadingState.DELETED || rawValue === CoValueLoadingState.UNAVAILABLE || rawValue === CoValueLoadingState.LOADING) {
|
|
4559
4610
|
this.logError();
|
|
4560
4611
|
return this.getUnloadedValue(rawValue);
|
|
4561
4612
|
}
|
|
4562
4613
|
return rawValue;
|
|
4563
4614
|
}
|
|
4564
4615
|
getCurrentRawValue() {
|
|
4565
|
-
if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
|
|
4616
|
+
if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.DELETED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
|
|
4566
4617
|
return this.value.type;
|
|
4567
4618
|
}
|
|
4568
4619
|
if (!this.shouldSendUpdates()) {
|
|
@@ -4596,7 +4647,7 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
|
4596
4647
|
return result;
|
|
4597
4648
|
}
|
|
4598
4649
|
getError() {
|
|
4599
|
-
if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
|
|
4650
|
+
if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.DELETED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
|
|
4600
4651
|
return this.value;
|
|
4601
4652
|
}
|
|
4602
4653
|
if (this.errorFromChildren) {
|
|
@@ -5127,6 +5178,9 @@ async function createJazzContext(options) {
|
|
|
5127
5178
|
const authSecretStorage = options.authSecretStorage;
|
|
5128
5179
|
await authSecretStorage.migrate();
|
|
5129
5180
|
const credentials = options.credentials ?? await authSecretStorage.get();
|
|
5181
|
+
if (options.storage) {
|
|
5182
|
+
options.storage.enableDeletedCoValuesErasure();
|
|
5183
|
+
}
|
|
5130
5184
|
if (credentials && !options.newAccountProps) {
|
|
5131
5185
|
context = await createJazzContextFromExistingCredentials({
|
|
5132
5186
|
credentials: {
|
|
@@ -5227,11 +5281,18 @@ var CoDiscriminatedUnionSchema = class _CoDiscriminatedUnionSchema {
|
|
|
5227
5281
|
withSchemaResolveQuery(options, this.resolveQuery)
|
|
5228
5282
|
);
|
|
5229
5283
|
}
|
|
5230
|
-
subscribe(id,
|
|
5284
|
+
subscribe(id, optionsOrListener, maybeListener) {
|
|
5285
|
+
if (typeof optionsOrListener === "function") {
|
|
5286
|
+
return this.coValueClass.subscribe(
|
|
5287
|
+
id,
|
|
5288
|
+
withSchemaResolveQuery({}, this.resolveQuery),
|
|
5289
|
+
optionsOrListener
|
|
5290
|
+
);
|
|
5291
|
+
}
|
|
5231
5292
|
return this.coValueClass.subscribe(
|
|
5232
5293
|
id,
|
|
5233
|
-
withSchemaResolveQuery(
|
|
5234
|
-
|
|
5294
|
+
withSchemaResolveQuery(optionsOrListener, this.resolveQuery),
|
|
5295
|
+
maybeListener
|
|
5235
5296
|
);
|
|
5236
5297
|
}
|
|
5237
5298
|
getCoValueClass() {
|
|
@@ -5381,13 +5442,21 @@ function createCoreCoRichTextSchema() {
|
|
|
5381
5442
|
resolveQuery: true
|
|
5382
5443
|
};
|
|
5383
5444
|
}
|
|
5384
|
-
var
|
|
5445
|
+
var _permissions;
|
|
5446
|
+
var _RichTextSchema = class _RichTextSchema {
|
|
5385
5447
|
constructor(coValueClass) {
|
|
5386
5448
|
this.coValueClass = coValueClass;
|
|
5387
5449
|
this.collaborative = true;
|
|
5388
5450
|
this.builtin = "CoRichText";
|
|
5389
5451
|
this.resolveQuery = true;
|
|
5390
|
-
this
|
|
5452
|
+
__privateAdd(this, _permissions, null);
|
|
5453
|
+
}
|
|
5454
|
+
/**
|
|
5455
|
+
* Permissions to be used when creating or composing CoValues
|
|
5456
|
+
* @internal
|
|
5457
|
+
*/
|
|
5458
|
+
get permissions() {
|
|
5459
|
+
return __privateGet(this, _permissions) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
5391
5460
|
}
|
|
5392
5461
|
create(text, options) {
|
|
5393
5462
|
const optionsWithPermissions = withSchemaPermissions(
|
|
@@ -5416,10 +5485,12 @@ var RichTextSchema = class _RichTextSchema {
|
|
|
5416
5485
|
*/
|
|
5417
5486
|
withPermissions(permissions) {
|
|
5418
5487
|
const copy = new _RichTextSchema(this.coValueClass);
|
|
5419
|
-
copy
|
|
5488
|
+
__privateSet(copy, _permissions, permissions);
|
|
5420
5489
|
return copy;
|
|
5421
5490
|
}
|
|
5422
5491
|
};
|
|
5492
|
+
_permissions = new WeakMap();
|
|
5493
|
+
var RichTextSchema = _RichTextSchema;
|
|
5423
5494
|
|
|
5424
5495
|
// src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts
|
|
5425
5496
|
function createCoreGroupSchema() {
|
|
@@ -5593,6 +5664,7 @@ __export(coExport_exports, {
|
|
|
5593
5664
|
});
|
|
5594
5665
|
|
|
5595
5666
|
// src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts
|
|
5667
|
+
var _permissions2;
|
|
5596
5668
|
var CoMapSchema = class {
|
|
5597
5669
|
constructor(coreSchema, coValueClass) {
|
|
5598
5670
|
this.coValueClass = coValueClass;
|
|
@@ -5604,15 +5676,18 @@ var CoMapSchema = class {
|
|
|
5604
5676
|
* @default true
|
|
5605
5677
|
*/
|
|
5606
5678
|
this.resolveQuery = true;
|
|
5607
|
-
|
|
5608
|
-
* Permissions to be used when creating or composing CoValues
|
|
5609
|
-
* @internal
|
|
5610
|
-
*/
|
|
5611
|
-
this.permissions = DEFAULT_SCHEMA_PERMISSIONS;
|
|
5679
|
+
__privateAdd(this, _permissions2, null);
|
|
5612
5680
|
this.shape = coreSchema.shape;
|
|
5613
5681
|
this.catchAll = coreSchema.catchAll;
|
|
5614
5682
|
this.getDefinition = coreSchema.getDefinition;
|
|
5615
5683
|
}
|
|
5684
|
+
/**
|
|
5685
|
+
* Permissions to be used when creating or composing CoValues
|
|
5686
|
+
* @internal
|
|
5687
|
+
*/
|
|
5688
|
+
get permissions() {
|
|
5689
|
+
return __privateGet(this, _permissions2) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
5690
|
+
}
|
|
5616
5691
|
create(init, options) {
|
|
5617
5692
|
const optionsWithPermissions = withSchemaPermissions(
|
|
5618
5693
|
options,
|
|
@@ -5635,11 +5710,18 @@ var CoMapSchema = class {
|
|
|
5635
5710
|
withSchemaResolveQuery(options, this.resolveQuery)
|
|
5636
5711
|
);
|
|
5637
5712
|
}
|
|
5638
|
-
subscribe(id,
|
|
5713
|
+
subscribe(id, optionsOrListener, maybeListener) {
|
|
5714
|
+
if (typeof optionsOrListener === "function") {
|
|
5715
|
+
return this.coValueClass.subscribe(
|
|
5716
|
+
id,
|
|
5717
|
+
withSchemaResolveQuery({}, this.resolveQuery),
|
|
5718
|
+
optionsOrListener
|
|
5719
|
+
);
|
|
5720
|
+
}
|
|
5639
5721
|
return this.coValueClass.subscribe(
|
|
5640
5722
|
id,
|
|
5641
|
-
withSchemaResolveQuery(
|
|
5642
|
-
|
|
5723
|
+
withSchemaResolveQuery(optionsOrListener, this.resolveQuery),
|
|
5724
|
+
maybeListener
|
|
5643
5725
|
);
|
|
5644
5726
|
}
|
|
5645
5727
|
/** @deprecated Use `CoMap.upsertUnique` and `CoMap.loadUnique` instead. */
|
|
@@ -5759,10 +5841,11 @@ var CoMapSchema = class {
|
|
|
5759
5841
|
const copy = hydrateCoreCoValueSchema(coreSchema);
|
|
5760
5842
|
copy.coValueClass.prototype.migrate = this.coValueClass.prototype.migrate;
|
|
5761
5843
|
copy.resolveQuery = resolveQuery ?? this.resolveQuery;
|
|
5762
|
-
copy
|
|
5844
|
+
__privateSet(copy, _permissions2, permissions ?? __privateGet(this, _permissions2));
|
|
5763
5845
|
return copy;
|
|
5764
5846
|
}
|
|
5765
5847
|
};
|
|
5848
|
+
_permissions2 = new WeakMap();
|
|
5766
5849
|
function createCoreCoMapSchema(shape, catchAll) {
|
|
5767
5850
|
return {
|
|
5768
5851
|
collaborative: true,
|
|
@@ -5796,6 +5879,7 @@ function createCoreCoMapSchema(shape, catchAll) {
|
|
|
5796
5879
|
}
|
|
5797
5880
|
|
|
5798
5881
|
// src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts
|
|
5882
|
+
var _permissions3;
|
|
5799
5883
|
var CoListSchema = class {
|
|
5800
5884
|
constructor(element, coValueClass) {
|
|
5801
5885
|
this.element = element;
|
|
@@ -5808,11 +5892,14 @@ var CoListSchema = class {
|
|
|
5808
5892
|
* @default true
|
|
5809
5893
|
*/
|
|
5810
5894
|
this.resolveQuery = true;
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5895
|
+
__privateAdd(this, _permissions3, null);
|
|
5896
|
+
}
|
|
5897
|
+
/**
|
|
5898
|
+
* Permissions to be used when creating or composing CoValues
|
|
5899
|
+
* @internal
|
|
5900
|
+
*/
|
|
5901
|
+
get permissions() {
|
|
5902
|
+
return __privateGet(this, _permissions3) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
5816
5903
|
}
|
|
5817
5904
|
create(items, options) {
|
|
5818
5905
|
const optionsWithPermissions = withSchemaPermissions(
|
|
@@ -5839,11 +5926,19 @@ var CoListSchema = class {
|
|
|
5839
5926
|
withSchemaResolveQuery(options, this.resolveQuery)
|
|
5840
5927
|
);
|
|
5841
5928
|
}
|
|
5842
|
-
subscribe(id,
|
|
5929
|
+
subscribe(id, optionsOrListener, maybeListener) {
|
|
5930
|
+
if (typeof optionsOrListener === "function") {
|
|
5931
|
+
return this.coValueClass.subscribe(
|
|
5932
|
+
id,
|
|
5933
|
+
withSchemaResolveQuery({}, this.resolveQuery),
|
|
5934
|
+
optionsOrListener
|
|
5935
|
+
);
|
|
5936
|
+
}
|
|
5843
5937
|
return this.coValueClass.subscribe(
|
|
5844
5938
|
id,
|
|
5845
|
-
withSchemaResolveQuery(
|
|
5846
|
-
|
|
5939
|
+
withSchemaResolveQuery(optionsOrListener, this.resolveQuery),
|
|
5940
|
+
// @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is
|
|
5941
|
+
maybeListener
|
|
5847
5942
|
);
|
|
5848
5943
|
}
|
|
5849
5944
|
getCoValueClass() {
|
|
@@ -5890,10 +5985,11 @@ var CoListSchema = class {
|
|
|
5890
5985
|
const coreSchema = createCoreCoListSchema(this.element);
|
|
5891
5986
|
const copy = hydrateCoreCoValueSchema(coreSchema);
|
|
5892
5987
|
copy.resolveQuery = resolveQuery ?? this.resolveQuery;
|
|
5893
|
-
copy
|
|
5988
|
+
__privateSet(copy, _permissions3, permissions ?? __privateGet(this, _permissions3));
|
|
5894
5989
|
return copy;
|
|
5895
5990
|
}
|
|
5896
5991
|
};
|
|
5992
|
+
_permissions3 = new WeakMap();
|
|
5897
5993
|
function createCoreCoListSchema(element) {
|
|
5898
5994
|
return {
|
|
5899
5995
|
collaborative: true,
|
|
@@ -5904,6 +6000,7 @@ function createCoreCoListSchema(element) {
|
|
|
5904
6000
|
}
|
|
5905
6001
|
|
|
5906
6002
|
// src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts
|
|
6003
|
+
var _permissions4;
|
|
5907
6004
|
var CoFeedSchema = class {
|
|
5908
6005
|
constructor(element, coValueClass) {
|
|
5909
6006
|
this.element = element;
|
|
@@ -5916,11 +6013,14 @@ var CoFeedSchema = class {
|
|
|
5916
6013
|
* @default true
|
|
5917
6014
|
*/
|
|
5918
6015
|
this.resolveQuery = true;
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
6016
|
+
__privateAdd(this, _permissions4, null);
|
|
6017
|
+
}
|
|
6018
|
+
/**
|
|
6019
|
+
* Permissions to be used when creating or composing CoValues
|
|
6020
|
+
* @internal
|
|
6021
|
+
*/
|
|
6022
|
+
get permissions() {
|
|
6023
|
+
return __privateGet(this, _permissions4) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
5924
6024
|
}
|
|
5925
6025
|
create(init, options) {
|
|
5926
6026
|
const optionsWithPermissions = withSchemaPermissions(
|
|
@@ -5947,13 +6047,19 @@ var CoFeedSchema = class {
|
|
|
5947
6047
|
withSchemaResolveQuery(options, this.resolveQuery)
|
|
5948
6048
|
);
|
|
5949
6049
|
}
|
|
5950
|
-
subscribe(id,
|
|
5951
|
-
|
|
6050
|
+
subscribe(id, optionsOrListener, maybeListener) {
|
|
6051
|
+
if (typeof optionsOrListener === "function") {
|
|
6052
|
+
return this.coValueClass.subscribe(
|
|
6053
|
+
id,
|
|
6054
|
+
withSchemaResolveQuery({}, this.resolveQuery),
|
|
6055
|
+
optionsOrListener
|
|
6056
|
+
);
|
|
6057
|
+
}
|
|
5952
6058
|
return this.coValueClass.subscribe(
|
|
5953
6059
|
id,
|
|
6060
|
+
withSchemaResolveQuery(optionsOrListener, this.resolveQuery),
|
|
5954
6061
|
// @ts-expect-error
|
|
5955
|
-
|
|
5956
|
-
listener
|
|
6062
|
+
maybeListener
|
|
5957
6063
|
);
|
|
5958
6064
|
}
|
|
5959
6065
|
getCoValueClass() {
|
|
@@ -5982,10 +6088,11 @@ var CoFeedSchema = class {
|
|
|
5982
6088
|
const coreSchema = createCoreCoFeedSchema(this.element);
|
|
5983
6089
|
const copy = hydrateCoreCoValueSchema(coreSchema);
|
|
5984
6090
|
copy.resolveQuery = resolveQuery ?? this.resolveQuery;
|
|
5985
|
-
copy
|
|
6091
|
+
__privateSet(copy, _permissions4, permissions ?? __privateGet(this, _permissions4));
|
|
5986
6092
|
return copy;
|
|
5987
6093
|
}
|
|
5988
6094
|
};
|
|
6095
|
+
_permissions4 = new WeakMap();
|
|
5989
6096
|
function createCoreCoFeedSchema(element) {
|
|
5990
6097
|
return {
|
|
5991
6098
|
collaborative: true,
|
|
@@ -6003,17 +6110,21 @@ function createCoreCoPlainTextSchema() {
|
|
|
6003
6110
|
resolveQuery: true
|
|
6004
6111
|
};
|
|
6005
6112
|
}
|
|
6006
|
-
var
|
|
6113
|
+
var _permissions5;
|
|
6114
|
+
var _PlainTextSchema = class _PlainTextSchema {
|
|
6007
6115
|
constructor(coValueClass) {
|
|
6008
6116
|
this.coValueClass = coValueClass;
|
|
6009
6117
|
this.collaborative = true;
|
|
6010
6118
|
this.builtin = "CoPlainText";
|
|
6011
6119
|
this.resolveQuery = true;
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6120
|
+
__privateAdd(this, _permissions5, null);
|
|
6121
|
+
}
|
|
6122
|
+
/**
|
|
6123
|
+
* Permissions to be used when creating or composing CoValues
|
|
6124
|
+
* @internal
|
|
6125
|
+
*/
|
|
6126
|
+
get permissions() {
|
|
6127
|
+
return __privateGet(this, _permissions5) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
6017
6128
|
}
|
|
6018
6129
|
create(text, options) {
|
|
6019
6130
|
const optionsWithPermissions = withSchemaPermissions(
|
|
@@ -6045,10 +6156,12 @@ var PlainTextSchema = class _PlainTextSchema {
|
|
|
6045
6156
|
*/
|
|
6046
6157
|
withPermissions(permissions) {
|
|
6047
6158
|
const copy = new _PlainTextSchema(this.coValueClass);
|
|
6048
|
-
copy
|
|
6159
|
+
__privateSet(copy, _permissions5, permissions);
|
|
6049
6160
|
return copy;
|
|
6050
6161
|
}
|
|
6051
6162
|
};
|
|
6163
|
+
_permissions5 = new WeakMap();
|
|
6164
|
+
var PlainTextSchema = _PlainTextSchema;
|
|
6052
6165
|
|
|
6053
6166
|
// src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts
|
|
6054
6167
|
function createCoreFileStreamSchema() {
|
|
@@ -6058,16 +6171,21 @@ function createCoreFileStreamSchema() {
|
|
|
6058
6171
|
resolveQuery: true
|
|
6059
6172
|
};
|
|
6060
6173
|
}
|
|
6061
|
-
var
|
|
6174
|
+
var _permissions6;
|
|
6175
|
+
var _FileStreamSchema = class _FileStreamSchema {
|
|
6062
6176
|
constructor(coValueClass) {
|
|
6063
6177
|
this.coValueClass = coValueClass;
|
|
6064
6178
|
this.collaborative = true;
|
|
6065
6179
|
this.builtin = "FileStream";
|
|
6066
6180
|
this.resolveQuery = true;
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6181
|
+
__privateAdd(this, _permissions6, null);
|
|
6182
|
+
}
|
|
6183
|
+
/**
|
|
6184
|
+
* Permissions to be used when creating or composing CoValues
|
|
6185
|
+
* @internal
|
|
6186
|
+
*/
|
|
6187
|
+
get permissions() {
|
|
6188
|
+
return __privateGet(this, _permissions6) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
6071
6189
|
}
|
|
6072
6190
|
create(options) {
|
|
6073
6191
|
const optionsWithPermissions = withSchemaPermissions(
|
|
@@ -6118,10 +6236,12 @@ var FileStreamSchema = class _FileStreamSchema {
|
|
|
6118
6236
|
*/
|
|
6119
6237
|
withPermissions(permissions) {
|
|
6120
6238
|
const copy = new _FileStreamSchema(this.coValueClass);
|
|
6121
|
-
copy
|
|
6239
|
+
__privateSet(copy, _permissions6, permissions);
|
|
6122
6240
|
return copy;
|
|
6123
6241
|
}
|
|
6124
6242
|
};
|
|
6243
|
+
_permissions6 = new WeakMap();
|
|
6244
|
+
var FileStreamSchema = _FileStreamSchema;
|
|
6125
6245
|
|
|
6126
6246
|
// src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts
|
|
6127
6247
|
function createCoreCoVectorSchema(dimensions) {
|
|
@@ -6132,17 +6252,22 @@ function createCoreCoVectorSchema(dimensions) {
|
|
|
6132
6252
|
resolveQuery: true
|
|
6133
6253
|
};
|
|
6134
6254
|
}
|
|
6135
|
-
var
|
|
6255
|
+
var _permissions7;
|
|
6256
|
+
var _CoVectorSchema = class _CoVectorSchema {
|
|
6136
6257
|
constructor(dimensions, coValueClass) {
|
|
6137
6258
|
this.dimensions = dimensions;
|
|
6138
6259
|
this.coValueClass = coValueClass;
|
|
6139
6260
|
this.collaborative = true;
|
|
6140
6261
|
this.builtin = "CoVector";
|
|
6141
6262
|
this.resolveQuery = true;
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6263
|
+
__privateAdd(this, _permissions7, null);
|
|
6264
|
+
}
|
|
6265
|
+
/**
|
|
6266
|
+
* Permissions to be used when creating or composing CoValues
|
|
6267
|
+
* @internal
|
|
6268
|
+
*/
|
|
6269
|
+
get permissions() {
|
|
6270
|
+
return __privateGet(this, _permissions7) ?? DEFAULT_SCHEMA_PERMISSIONS;
|
|
6146
6271
|
}
|
|
6147
6272
|
create(vector, options) {
|
|
6148
6273
|
const optionsWithPermissions = withSchemaPermissions(
|
|
@@ -6171,10 +6296,12 @@ var CoVectorSchema = class _CoVectorSchema {
|
|
|
6171
6296
|
*/
|
|
6172
6297
|
withPermissions(permissions) {
|
|
6173
6298
|
const copy = new _CoVectorSchema(this.dimensions, this.coValueClass);
|
|
6174
|
-
copy
|
|
6299
|
+
__privateSet(copy, _permissions7, permissions);
|
|
6175
6300
|
return copy;
|
|
6176
6301
|
}
|
|
6177
6302
|
};
|
|
6303
|
+
_permissions7 = new WeakMap();
|
|
6304
|
+
var CoVectorSchema = _CoVectorSchema;
|
|
6178
6305
|
|
|
6179
6306
|
// src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts
|
|
6180
6307
|
var AccountSchema = class _AccountSchema {
|
|
@@ -6237,12 +6364,20 @@ var AccountSchema = class _AccountSchema {
|
|
|
6237
6364
|
withSchemaResolveQuery(options, this.resolveQuery)
|
|
6238
6365
|
);
|
|
6239
6366
|
}
|
|
6240
|
-
subscribe(id,
|
|
6367
|
+
subscribe(id, optionsOrListener, maybeListener) {
|
|
6368
|
+
if (typeof optionsOrListener === "function") {
|
|
6369
|
+
return this.coValueClass.subscribe(
|
|
6370
|
+
id,
|
|
6371
|
+
withSchemaResolveQuery({}, this.resolveQuery),
|
|
6372
|
+
// @ts-expect-error
|
|
6373
|
+
optionsOrListener
|
|
6374
|
+
);
|
|
6375
|
+
}
|
|
6241
6376
|
return this.coValueClass.subscribe(
|
|
6242
6377
|
id,
|
|
6243
6378
|
// @ts-expect-error
|
|
6244
|
-
withSchemaResolveQuery(
|
|
6245
|
-
|
|
6379
|
+
withSchemaResolveQuery(optionsOrListener, this.resolveQuery),
|
|
6380
|
+
maybeListener
|
|
6246
6381
|
);
|
|
6247
6382
|
}
|
|
6248
6383
|
getMe() {
|
|
@@ -6742,7 +6877,6 @@ var ImageDefinition = ImageDefinitionBase;
|
|
|
6742
6877
|
|
|
6743
6878
|
// src/tools/implementation/ContextManager.ts
|
|
6744
6879
|
import { cojsonInternals as cojsonInternals5 } from "cojson";
|
|
6745
|
-
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
|
6746
6880
|
|
|
6747
6881
|
// src/tools/auth/KvStoreContext.ts
|
|
6748
6882
|
var KvStoreContext = class _KvStoreContext {
|
|
@@ -7083,10 +7217,11 @@ var SubscriptionCache = class {
|
|
|
7083
7217
|
};
|
|
7084
7218
|
|
|
7085
7219
|
// src/tools/implementation/ContextManager.ts
|
|
7220
|
+
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
|
7086
7221
|
function getAnonymousFallback() {
|
|
7087
7222
|
const context = createAnonymousJazzContext({
|
|
7088
7223
|
peers: [],
|
|
7089
|
-
crypto:
|
|
7224
|
+
crypto: WasmCrypto.createSync()
|
|
7090
7225
|
});
|
|
7091
7226
|
return {
|
|
7092
7227
|
guest: context.agent,
|
|
@@ -7470,8 +7605,7 @@ function loadCoValue(cls, id, options) {
|
|
|
7470
7605
|
loadAs: options.loadAs,
|
|
7471
7606
|
syncResolution: true,
|
|
7472
7607
|
skipRetry: options.skipRetry,
|
|
7473
|
-
|
|
7474
|
-
onUnauthorized: resolve,
|
|
7608
|
+
onError: resolve,
|
|
7475
7609
|
unstable_branch: options.unstable_branch
|
|
7476
7610
|
},
|
|
7477
7611
|
(value, unsubscribe) => {
|
|
@@ -7503,6 +7637,7 @@ function parseSubscribeRestArgs(args) {
|
|
|
7503
7637
|
options: {
|
|
7504
7638
|
resolve: args[0].resolve,
|
|
7505
7639
|
loadAs: args[0].loadAs,
|
|
7640
|
+
onError: args[0].onError,
|
|
7506
7641
|
onUnauthorized: args[0].onUnauthorized,
|
|
7507
7642
|
onUnavailable: args[0].onUnavailable,
|
|
7508
7643
|
unstable_branch: args[0].unstable_branch
|
|
@@ -7555,6 +7690,7 @@ function subscribeToCoValue(cls, id, options, listener) {
|
|
|
7555
7690
|
listener(value, unsubscribe);
|
|
7556
7691
|
return;
|
|
7557
7692
|
}
|
|
7693
|
+
options.onError?.(value);
|
|
7558
7694
|
switch (value.$jazz.loadingState) {
|
|
7559
7695
|
case CoValueLoadingState.UNAVAILABLE:
|
|
7560
7696
|
options.onUnavailable?.(value);
|
|
@@ -7588,6 +7724,7 @@ function subscribeToExistingCoValue(existing, options, listener) {
|
|
|
7588
7724
|
{
|
|
7589
7725
|
loadAs: existing.$jazz.loadedAs,
|
|
7590
7726
|
resolve: options?.resolve,
|
|
7727
|
+
onError: options?.onError,
|
|
7591
7728
|
onUnavailable: options?.onUnavailable,
|
|
7592
7729
|
onUnauthorized: options?.onUnauthorized,
|
|
7593
7730
|
unstable_branch: options?.unstable_branch
|
|
@@ -7710,18 +7847,11 @@ async function exportCoValue(cls, id, options) {
|
|
|
7710
7847
|
options.bestEffortResolution,
|
|
7711
7848
|
options.unstable_branch
|
|
7712
7849
|
);
|
|
7713
|
-
|
|
7714
|
-
rootNode.
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
} else if (value2.$jazz.loadingState === CoValueLoadingState.UNAVAILABLE || value2.$jazz.loadingState === CoValueLoadingState.UNAUTHORIZED) {
|
|
7719
|
-
resolve2(null);
|
|
7720
|
-
rootNode.destroy();
|
|
7721
|
-
}
|
|
7722
|
-
});
|
|
7723
|
-
});
|
|
7724
|
-
if (!value) {
|
|
7850
|
+
try {
|
|
7851
|
+
await rootNode.getPromise();
|
|
7852
|
+
rootNode.destroy();
|
|
7853
|
+
} catch (error) {
|
|
7854
|
+
rootNode.destroy();
|
|
7725
7855
|
return null;
|
|
7726
7856
|
}
|
|
7727
7857
|
const valuesExported = /* @__PURE__ */ new Set();
|
|
@@ -7809,23 +7939,101 @@ async function unstable_mergeBranchWithResolve(cls, id, options) {
|
|
|
7809
7939
|
false,
|
|
7810
7940
|
options.branch
|
|
7811
7941
|
);
|
|
7812
|
-
|
|
7813
|
-
rootNode.
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
resolve2();
|
|
7820
|
-
}
|
|
7821
|
-
rootNode.destroy();
|
|
7822
|
-
});
|
|
7823
|
-
});
|
|
7942
|
+
try {
|
|
7943
|
+
await rootNode.getPromise();
|
|
7944
|
+
rootNode.destroy();
|
|
7945
|
+
} catch (error) {
|
|
7946
|
+
rootNode.destroy();
|
|
7947
|
+
throw error;
|
|
7948
|
+
}
|
|
7824
7949
|
unstable_mergeBranch(rootNode);
|
|
7825
7950
|
}
|
|
7951
|
+
async function deleteCoValues(cls, id, options = {}) {
|
|
7952
|
+
const loadAs = options.loadAs ?? activeAccountContext3.get();
|
|
7953
|
+
const node = "node" in loadAs ? loadAs.node : loadAs.$jazz.localNode;
|
|
7954
|
+
const resolve = options.resolve ?? true;
|
|
7955
|
+
const rootNode = new SubscriptionScope(
|
|
7956
|
+
node,
|
|
7957
|
+
resolve,
|
|
7958
|
+
id,
|
|
7959
|
+
{
|
|
7960
|
+
ref: coValueClassFromCoValueClassOrSchema(cls),
|
|
7961
|
+
optional: false
|
|
7962
|
+
},
|
|
7963
|
+
false,
|
|
7964
|
+
false,
|
|
7965
|
+
void 0
|
|
7966
|
+
);
|
|
7967
|
+
try {
|
|
7968
|
+
await rootNode.getPromise();
|
|
7969
|
+
rootNode.destroy();
|
|
7970
|
+
} catch (error) {
|
|
7971
|
+
rootNode.destroy();
|
|
7972
|
+
throw error;
|
|
7973
|
+
}
|
|
7974
|
+
const errors = validateDeletePermissions(rootNode);
|
|
7975
|
+
if (errors.length > 0) {
|
|
7976
|
+
const combined = new JazzError(
|
|
7977
|
+
id,
|
|
7978
|
+
CoValueLoadingState.DELETED,
|
|
7979
|
+
errors.flatMap((e) => e.issues)
|
|
7980
|
+
);
|
|
7981
|
+
throw new Error(combined.toString());
|
|
7982
|
+
}
|
|
7983
|
+
const deletedValues = deleteCoValueFromSubscription(rootNode);
|
|
7984
|
+
await Promise.allSettled(
|
|
7985
|
+
Array.from(deletedValues, (value) => value.waitForSync())
|
|
7986
|
+
);
|
|
7987
|
+
}
|
|
7988
|
+
function validateDeletePermissions(rootNode, path = [], errors = []) {
|
|
7989
|
+
for (const [key, childNode] of rootNode.childNodes.entries()) {
|
|
7990
|
+
validateDeletePermissions(childNode, [...path, key], errors);
|
|
7991
|
+
}
|
|
7992
|
+
if (rootNode.value.type !== CoValueLoadingState.LOADED) {
|
|
7993
|
+
return errors;
|
|
7994
|
+
}
|
|
7995
|
+
const core2 = rootNode.value.value.$jazz.raw.core;
|
|
7996
|
+
if (core2.isGroupOrAccount()) {
|
|
7997
|
+
return errors;
|
|
7998
|
+
}
|
|
7999
|
+
const result = core2.validateDeletePermissions();
|
|
8000
|
+
if (!result.ok) {
|
|
8001
|
+
errors.push(
|
|
8002
|
+
new JazzError(core2.id, CoValueLoadingState.DELETED, [
|
|
8003
|
+
{
|
|
8004
|
+
code: "deleteError",
|
|
8005
|
+
message: `Jazz Delete Error: ${result.message}`,
|
|
8006
|
+
params: {},
|
|
8007
|
+
path
|
|
8008
|
+
}
|
|
8009
|
+
])
|
|
8010
|
+
);
|
|
8011
|
+
}
|
|
8012
|
+
return errors;
|
|
8013
|
+
}
|
|
8014
|
+
function deleteCoValueFromSubscription(rootNode, values = /* @__PURE__ */ new Set()) {
|
|
8015
|
+
for (const childNode of rootNode.childNodes.values()) {
|
|
8016
|
+
deleteCoValueFromSubscription(childNode, values);
|
|
8017
|
+
}
|
|
8018
|
+
if (rootNode.value.type !== CoValueLoadingState.LOADED) {
|
|
8019
|
+
return values;
|
|
8020
|
+
}
|
|
8021
|
+
const core2 = rootNode.value.value.$jazz.raw.core;
|
|
8022
|
+
if (core2.isGroupOrAccount()) {
|
|
8023
|
+
return values;
|
|
8024
|
+
}
|
|
8025
|
+
try {
|
|
8026
|
+
core2.deleteCoValue();
|
|
8027
|
+
values.add(core2);
|
|
8028
|
+
} catch (error) {
|
|
8029
|
+
console.error("Failed to delete coValue", error);
|
|
8030
|
+
}
|
|
8031
|
+
return values;
|
|
8032
|
+
}
|
|
7826
8033
|
|
|
7827
8034
|
export {
|
|
7828
8035
|
zodReExport_exports,
|
|
8036
|
+
getJazzErrorType,
|
|
7829
8037
|
getUnloadedCoValueWithoutId,
|
|
7830
8038
|
createUnloadedCoValue,
|
|
7831
8039
|
loadCoValue,
|
|
@@ -7833,6 +8041,7 @@ export {
|
|
|
7833
8041
|
unstable_loadUnique,
|
|
7834
8042
|
exportCoValue,
|
|
7835
8043
|
importContentPieces,
|
|
8044
|
+
deleteCoValues,
|
|
7836
8045
|
CoValueBase,
|
|
7837
8046
|
CoMap,
|
|
7838
8047
|
CoList,
|
|
@@ -7856,7 +8065,6 @@ export {
|
|
|
7856
8065
|
Encoders,
|
|
7857
8066
|
coField,
|
|
7858
8067
|
CoValueLoadingState,
|
|
7859
|
-
getJazzErrorType,
|
|
7860
8068
|
enableCaptureErrorCause,
|
|
7861
8069
|
setCustomErrorReporter,
|
|
7862
8070
|
captureStack,
|
|
@@ -7877,4 +8085,4 @@ export {
|
|
|
7877
8085
|
JazzContextManager
|
|
7878
8086
|
};
|
|
7879
8087
|
/* istanbul ignore file -- @preserve */
|
|
7880
|
-
//# sourceMappingURL=chunk-
|
|
8088
|
+
//# sourceMappingURL=chunk-2OPP7KWV.js.map
|