cozy-sharing 37.4.0 → 37.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +11 -0
- package/dist/state.js +8 -0
- package/package.json +3 -3
- package/src/state.js +4 -0
- package/tsconfig.json +4 -0
- package/types.d.ts +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [37.5.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.4.0...cozy-sharing@37.5.0) (2026-08-25)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **cozy-sharing:** Export recipient types ([ca5fd55](https://github.com/cozy/cozy-libs/commit/ca5fd554471320993cd89eaca33a65a09d2ecc46))
|
|
11
|
+
|
|
6
12
|
# [37.4.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.3.0...cozy-sharing@37.4.0) (2026-08-25)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/README.md
CHANGED
|
@@ -82,6 +82,17 @@ const MyComp = () => {
|
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
### Recipient types
|
|
86
|
+
|
|
87
|
+
`SharingMember` and `SharingGroup` model the values returned by the stack.
|
|
88
|
+
`cozy-sharing` adds display metadata and returns `SharingMemberRecipient` or
|
|
89
|
+
`SharingGroupRecipient` from its recipient selectors. TypeScript consumers can
|
|
90
|
+
use their union when both are possible:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import type { SharingRecipient } from 'cozy-sharing/types'
|
|
94
|
+
```
|
|
95
|
+
|
|
85
96
|
***
|
|
86
97
|
|
|
87
98
|
## How it works
|
package/dist/state.js
CHANGED
|
@@ -430,10 +430,14 @@ export var getOwner = function getOwner(state, docId) {
|
|
|
430
430
|
return r.status === 'owner';
|
|
431
431
|
});
|
|
432
432
|
};
|
|
433
|
+
/** @returns {import('../types').SharingRecipient[]} */
|
|
434
|
+
|
|
433
435
|
export var getRecipients = function getRecipients(state, docId) {
|
|
434
436
|
var sharings = getDocumentSharings(state, docId);
|
|
435
437
|
return getRecipientsFromSharings(sharings, docId);
|
|
436
438
|
};
|
|
439
|
+
/** @returns {import('../types').SharingRecipient[]} */
|
|
440
|
+
|
|
437
441
|
export var getRecipientsFromSharing = function getRecipientsFromSharing(sharing, docId) {
|
|
438
442
|
if (!sharing) {
|
|
439
443
|
return [];
|
|
@@ -466,6 +470,8 @@ var getRecipientType = function getRecipientType(sharing, member, documentType)
|
|
|
466
470
|
|
|
467
471
|
return documentType;
|
|
468
472
|
};
|
|
473
|
+
/** @returns {import('../types').SharingMemberRecipient[]} */
|
|
474
|
+
|
|
469
475
|
|
|
470
476
|
var getRecipientsWithoutGroups = function getRecipientsWithoutGroups(sharings, docId) {
|
|
471
477
|
var recipients = sharings.map(function (sharing) {
|
|
@@ -493,6 +499,8 @@ var getRecipientsWithoutGroups = function getRecipientsWithoutGroups(sharings, d
|
|
|
493
499
|
|
|
494
500
|
return recipients;
|
|
495
501
|
};
|
|
502
|
+
/** @returns {import('../types').SharingRecipient[]} */
|
|
503
|
+
|
|
496
504
|
|
|
497
505
|
export var getRecipientsWithGroups = function getRecipientsWithGroups(sharings, docId) {
|
|
498
506
|
var recipients = sharings.flatMap(function (sharing) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-sharing",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.5.0",
|
|
4
4
|
"description": "Provides sharing login for React applications.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Cozy",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"cozy-intent": "^2.31.1",
|
|
60
60
|
"cozy-minilog": "^3.10.1",
|
|
61
61
|
"cozy-ui": "^140.5.0",
|
|
62
|
-
"cozy-ui-plus": "^12.3.
|
|
62
|
+
"cozy-ui-plus": "^12.3.9",
|
|
63
63
|
"jest": "30.3.0",
|
|
64
64
|
"jest-environment-jsdom": "30.3.0",
|
|
65
65
|
"react": "16.12.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"sideEffects": [
|
|
86
86
|
"*.css"
|
|
87
87
|
],
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "814149b46bd8ddbc22384fd5dda8a14dc41ee806"
|
|
89
89
|
}
|
package/src/state.js
CHANGED
|
@@ -341,11 +341,13 @@ export const canReshare = (state, docId, instanceUri) => {
|
|
|
341
341
|
export const getOwner = (state, docId) =>
|
|
342
342
|
getRecipients(state, docId).find(r => r.status === 'owner')
|
|
343
343
|
|
|
344
|
+
/** @returns {import('../types').SharingRecipient[]} */
|
|
344
345
|
export const getRecipients = (state, docId) => {
|
|
345
346
|
const sharings = getDocumentSharings(state, docId)
|
|
346
347
|
return getRecipientsFromSharings(sharings, docId)
|
|
347
348
|
}
|
|
348
349
|
|
|
350
|
+
/** @returns {import('../types').SharingRecipient[]} */
|
|
349
351
|
export const getRecipientsFromSharing = (sharing, docId) => {
|
|
350
352
|
if (!sharing) {
|
|
351
353
|
return []
|
|
@@ -379,6 +381,7 @@ const getRecipientType = (sharing, member, documentType) => {
|
|
|
379
381
|
return documentType
|
|
380
382
|
}
|
|
381
383
|
|
|
384
|
+
/** @returns {import('../types').SharingMemberRecipient[]} */
|
|
382
385
|
const getRecipientsWithoutGroups = (sharings, docId) => {
|
|
383
386
|
const recipients = sharings
|
|
384
387
|
.map(sharing => {
|
|
@@ -400,6 +403,7 @@ const getRecipientsWithoutGroups = (sharings, docId) => {
|
|
|
400
403
|
return recipients
|
|
401
404
|
}
|
|
402
405
|
|
|
406
|
+
/** @returns {import('../types').SharingRecipient[]} */
|
|
403
407
|
export const getRecipientsWithGroups = (sharings, docId) => {
|
|
404
408
|
const recipients = sharings.flatMap(sharing => {
|
|
405
409
|
const type = getDocumentSharingType(sharing, docId)
|
package/tsconfig.json
ADDED
package/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Member fields returned by the stack sharing API. */
|
|
2
|
+
export interface SharingMember {
|
|
3
|
+
email?: string
|
|
4
|
+
groups?: number[]
|
|
5
|
+
instance?: string
|
|
6
|
+
name?: string
|
|
7
|
+
only_in_groups?: boolean
|
|
8
|
+
public_name?: string
|
|
9
|
+
read_only?: boolean
|
|
10
|
+
status: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Group fields returned by the stack sharing API. */
|
|
14
|
+
export interface SharingGroup {
|
|
15
|
+
addedBy: number
|
|
16
|
+
color?: string
|
|
17
|
+
id?: string
|
|
18
|
+
name: string
|
|
19
|
+
read_only: boolean
|
|
20
|
+
revoked?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Member enriched by cozy-sharing for display. */
|
|
24
|
+
export type SharingMemberRecipient = SharingMember & {
|
|
25
|
+
avatarPath: string
|
|
26
|
+
/** Stable display identifier generated by cozy-sharing. */
|
|
27
|
+
index: string
|
|
28
|
+
/** Position in the members array returned by the stack. */
|
|
29
|
+
memberIndex: number
|
|
30
|
+
sharingId: string
|
|
31
|
+
type: 'one-way' | 'two-way'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Group enriched by cozy-sharing for display. */
|
|
35
|
+
export type SharingGroupRecipient = SharingGroup & {
|
|
36
|
+
/** Position in the groups array returned by the stack. */
|
|
37
|
+
groupIndex: number
|
|
38
|
+
/** Stable display identifier generated by cozy-sharing. */
|
|
39
|
+
index: string
|
|
40
|
+
members: SharingMemberRecipient[]
|
|
41
|
+
owner: SharingMemberRecipient
|
|
42
|
+
sharingId: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Member or group returned by cozy-sharing recipient selectors. */
|
|
46
|
+
export type SharingRecipient = SharingMemberRecipient | SharingGroupRecipient
|