jazz-tools 0.9.16 → 0.9.17
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +7 -0
- package/dist/{chunk-7OI3SFBS.js → chunk-LRDIS2Q2.js} +60 -2
- package/dist/chunk-LRDIS2Q2.js.map +1 -0
- package/dist/index.native.js +7 -1
- package/dist/index.native.js.map +1 -1
- package/dist/index.web.js +7 -1
- package/dist/index.web.js.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/src/coValues/group.ts +10 -2
- package/src/exports.ts +6 -0
- package/src/implementation/invites.ts +99 -0
- package/src/tests/groupsAndAccounts.test.ts +65 -1
- package/src/tests/invites.test.ts +85 -0
- package/dist/chunk-7OI3SFBS.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.9.
|
2
|
+
> jazz-tools@0.9.17 build /home/runner/work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index.web":"src/index.web.ts","index.native":"src/index.native.ts","testing":"src/testing.ts"}
|
@@ -9,12 +9,12 @@
|
|
9
9
|
[34mCLI[39m Target: es2021
|
10
10
|
[34mCLI[39m Cleaning output folder
|
11
11
|
[34mESM[39m Build start
|
12
|
-
[32mESM[39m [1mdist/index.web.js [22m[32m1.
|
13
|
-
[32mESM[39m [1mdist/index.native.js [22m[32m1.
|
12
|
+
[32mESM[39m [1mdist/index.web.js [22m[32m1.27 KB[39m
|
13
|
+
[32mESM[39m [1mdist/index.native.js [22m[32m1.26 KB[39m
|
14
14
|
[32mESM[39m [1mdist/testing.js [22m[32m3.43 KB[39m
|
15
|
-
[32mESM[39m [1mdist/chunk-
|
16
|
-
[32mESM[39m [1mdist/index.web.js.map [22m[
|
17
|
-
[32mESM[39m [1mdist/index.native.js.map [22m[
|
15
|
+
[32mESM[39m [1mdist/chunk-LRDIS2Q2.js [22m[32m96.73 KB[39m
|
16
|
+
[32mESM[39m [1mdist/index.web.js.map [22m[32m276.00 B[39m
|
17
|
+
[32mESM[39m [1mdist/index.native.js.map [22m[32m286.00 B[39m
|
18
18
|
[32mESM[39m [1mdist/testing.js.map [22m[32m6.94 KB[39m
|
19
|
-
[32mESM[39m [1mdist/chunk-
|
20
|
-
[32mESM[39m ⚡️ Build success in
|
19
|
+
[32mESM[39m [1mdist/chunk-LRDIS2Q2.js.map [22m[32m239.73 KB[39m
|
20
|
+
[32mESM[39m ⚡️ Build success in 106ms
|
package/CHANGELOG.md
CHANGED
@@ -3349,6 +3349,61 @@ var SchemaUnion = class _SchemaUnion extends CoValueBase {
|
|
3349
3349
|
}
|
3350
3350
|
};
|
3351
3351
|
|
3352
|
+
// src/implementation/invites.ts
|
3353
|
+
import { cojsonInternals as cojsonInternals4 } from "cojson";
|
3354
|
+
function createInviteLink(value, role, baseURL, valueHint) {
|
3355
|
+
const coValueCore = value._raw.core;
|
3356
|
+
let currentCoValue = coValueCore;
|
3357
|
+
while (currentCoValue.header.ruleset.type === "ownedByGroup") {
|
3358
|
+
currentCoValue = currentCoValue.getGroup().core;
|
3359
|
+
}
|
3360
|
+
const { ruleset, meta } = currentCoValue.header;
|
3361
|
+
if (ruleset.type !== "group" || meta?.type === "account") {
|
3362
|
+
throw new Error("Can't create invite link for object without group");
|
3363
|
+
}
|
3364
|
+
const group = cojsonInternals4.expectGroup(currentCoValue.getCurrentContent());
|
3365
|
+
const inviteSecret = group.createInvite(role);
|
3366
|
+
return `${baseURL}#/invite/${valueHint ? valueHint + "/" : ""}${value.id}/${inviteSecret}`;
|
3367
|
+
}
|
3368
|
+
function parseInviteLink(inviteURL) {
|
3369
|
+
const url = new URL(inviteURL);
|
3370
|
+
const parts = url.hash.split("/");
|
3371
|
+
let valueHint;
|
3372
|
+
let valueID;
|
3373
|
+
let inviteSecret;
|
3374
|
+
if (parts[0] === "#" && parts[1] === "invite") {
|
3375
|
+
if (parts.length === 5) {
|
3376
|
+
valueHint = parts[2];
|
3377
|
+
valueID = parts[3];
|
3378
|
+
inviteSecret = parts[4];
|
3379
|
+
} else if (parts.length === 4) {
|
3380
|
+
valueID = parts[2];
|
3381
|
+
inviteSecret = parts[3];
|
3382
|
+
}
|
3383
|
+
if (!valueID || !inviteSecret) {
|
3384
|
+
return void 0;
|
3385
|
+
}
|
3386
|
+
return { valueID, inviteSecret, valueHint };
|
3387
|
+
}
|
3388
|
+
}
|
3389
|
+
function consumeInviteLink({
|
3390
|
+
inviteURL,
|
3391
|
+
as = Account.getMe(),
|
3392
|
+
forValueHint,
|
3393
|
+
invitedObjectSchema
|
3394
|
+
}) {
|
3395
|
+
return new Promise((resolve, reject) => {
|
3396
|
+
const result = parseInviteLink(inviteURL);
|
3397
|
+
if (result && result.valueHint === forValueHint) {
|
3398
|
+
as.acceptInvite(result.valueID, result.inviteSecret, invitedObjectSchema).then(() => {
|
3399
|
+
resolve(result);
|
3400
|
+
}).catch(reject);
|
3401
|
+
} else {
|
3402
|
+
resolve(void 0);
|
3403
|
+
}
|
3404
|
+
});
|
3405
|
+
}
|
3406
|
+
|
3352
3407
|
export {
|
3353
3408
|
activeAccountContext,
|
3354
3409
|
AnonymousJazzAgent,
|
@@ -3377,7 +3432,10 @@ export {
|
|
3377
3432
|
CoRichText,
|
3378
3433
|
Marks,
|
3379
3434
|
ImageDefinition,
|
3380
|
-
SchemaUnion
|
3435
|
+
SchemaUnion,
|
3436
|
+
createInviteLink,
|
3437
|
+
parseInviteLink,
|
3438
|
+
consumeInviteLink
|
3381
3439
|
};
|
3382
3440
|
/* istanbul ignore file -- @preserve */
|
3383
|
-
//# sourceMappingURL=chunk-
|
3441
|
+
//# sourceMappingURL=chunk-LRDIS2Q2.js.map
|