cozy-sharing 37.4.0 → 37.5.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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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.1](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.5.0...cozy-sharing@37.5.1) (2026-08-25)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **sharing:** Restore allLoaded gate for federated modal routing ([fcb492a](https://github.com/cozy/cozy-libs/commit/fcb492a3d09110beb0cd3a9e524d3547bdaafa21))
11
+
12
+ # [37.5.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.4.0...cozy-sharing@37.5.0) (2026-08-25)
13
+
14
+ ### Features
15
+
16
+ - **cozy-sharing:** Export recipient types ([ca5fd55](https://github.com/cozy/cozy-libs/commit/ca5fd554471320993cd89eaca33a65a09d2ecc46))
17
+
6
18
  # [37.4.0](https://github.com/cozy/cozy-libs/compare/cozy-sharing@37.3.0...cozy-sharing@37.4.0) (2026-08-25)
7
19
 
8
20
  ### 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
@@ -30,7 +30,8 @@ export var ShareModal = withLocales(function (props) {
30
30
  canReshare = _useSharingContext.canReshare,
31
31
  documentType = _useSharingContext.documentType,
32
32
  getRecipients = _useSharingContext.getRecipients,
33
- revokeSelf = _useSharingContext.revokeSelf;
33
+ revokeSelf = _useSharingContext.revokeSelf,
34
+ allLoaded = _useSharingContext.allLoaded;
34
35
 
35
36
  var handleRevokeSelf = /*#__PURE__*/function () {
36
37
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(document) {
@@ -60,7 +61,7 @@ export var ShareModal = withLocales(function (props) {
60
61
  if (isEditable) {
61
62
  var isFederatedMode = flag('drive.federated-shared-folder.enabled');
62
63
 
63
- if (isFederatedMode && document.driveId) {
64
+ if (isFederatedMode && allLoaded) {
64
65
  return /*#__PURE__*/React.createElement(FederatedFolderModal, _extends({
65
66
  document: document,
66
67
  onRevokeSuccess: onRevokeSuccess
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.4.0",
3
+ "version": "37.5.1",
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.8",
62
+ "cozy-ui-plus": "^12.3.10",
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": "b20d8f7573c3d64dddc40ec8baa69037423fa368"
88
+ "gitHead": "1f5ca5edaf02675c51870c3d525eef0112781453"
89
89
  }
@@ -23,7 +23,8 @@ export const ShareModal = withLocales(props => {
23
23
  canReshare,
24
24
  documentType,
25
25
  getRecipients,
26
- revokeSelf
26
+ revokeSelf,
27
+ allLoaded
27
28
  } = useSharingContext()
28
29
 
29
30
  const handleRevokeSelf = async document => {
@@ -36,7 +37,7 @@ export const ShareModal = withLocales(props => {
36
37
 
37
38
  if (isEditable) {
38
39
  const isFederatedMode = flag('drive.federated-shared-folder.enabled')
39
- if (isFederatedMode && document.driveId) {
40
+ if (isFederatedMode && allLoaded) {
40
41
  return (
41
42
  <FederatedFolderModal
42
43
  document={document}
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
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "cozy-tsconfig",
3
+ "include": ["types.d.ts"]
4
+ }
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