@sudobility/entity_client 0.0.2

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.
Files changed (41) hide show
  1. package/dist/hooks/index.cjs +30 -0
  2. package/dist/hooks/index.d.ts +8 -0
  3. package/dist/hooks/index.d.ts.map +1 -0
  4. package/dist/hooks/index.js +8 -0
  5. package/dist/hooks/index.js.map +1 -0
  6. package/dist/hooks/useCurrentEntity.cjs +69 -0
  7. package/dist/hooks/useCurrentEntity.d.ts +44 -0
  8. package/dist/hooks/useCurrentEntity.d.ts.map +1 -0
  9. package/dist/hooks/useCurrentEntity.js +65 -0
  10. package/dist/hooks/useCurrentEntity.js.map +1 -0
  11. package/dist/hooks/useEntities.cjs +113 -0
  12. package/dist/hooks/useEntities.d.ts +40 -0
  13. package/dist/hooks/useEntities.d.ts.map +1 -0
  14. package/dist/hooks/useEntities.js +105 -0
  15. package/dist/hooks/useEntities.js.map +1 -0
  16. package/dist/hooks/useEntityMembers.cjs +77 -0
  17. package/dist/hooks/useEntityMembers.d.ts +33 -0
  18. package/dist/hooks/useEntityMembers.d.ts.map +1 -0
  19. package/dist/hooks/useEntityMembers.js +71 -0
  20. package/dist/hooks/useEntityMembers.js.map +1 -0
  21. package/dist/hooks/useInvitations.cjs +132 -0
  22. package/dist/hooks/useInvitations.d.ts +45 -0
  23. package/dist/hooks/useInvitations.d.ts.map +1 -0
  24. package/dist/hooks/useInvitations.js +123 -0
  25. package/dist/hooks/useInvitations.js.map +1 -0
  26. package/dist/index.cjs +58 -0
  27. package/dist/index.d.ts +30 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +39 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/network/EntityClient.cjs +158 -0
  32. package/dist/network/EntityClient.d.ts +90 -0
  33. package/dist/network/EntityClient.d.ts.map +1 -0
  34. package/dist/network/EntityClient.js +154 -0
  35. package/dist/network/EntityClient.js.map +1 -0
  36. package/dist/network/index.cjs +9 -0
  37. package/dist/network/index.d.ts +5 -0
  38. package/dist/network/index.d.ts.map +1 -0
  39. package/dist/network/index.js +5 -0
  40. package/dist/network/index.js.map +1 -0
  41. package/package.json +62 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @fileoverview Entity Member Hooks
3
+ * @description React Query hooks for entity member management
4
+ */
5
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
6
+ import { entityKeys } from './useEntities';
7
+ /**
8
+ * Query keys for member-related queries.
9
+ */
10
+ export const memberKeys = {
11
+ all: (entitySlug) => [...entityKeys.detail(entitySlug), 'members'],
12
+ list: (entitySlug) => [...memberKeys.all(entitySlug), 'list'],
13
+ };
14
+ /**
15
+ * Hook to list members of an entity.
16
+ */
17
+ export function useEntityMembers(client, entitySlug) {
18
+ return useQuery({
19
+ queryKey: entitySlug ? memberKeys.list(entitySlug) : ['disabled'],
20
+ queryFn: async () => {
21
+ if (!entitySlug)
22
+ return [];
23
+ const response = await client.listMembers(entitySlug);
24
+ if (!response.success) {
25
+ throw new Error(response.error || 'Failed to fetch members');
26
+ }
27
+ return response.data;
28
+ },
29
+ enabled: !!entitySlug,
30
+ });
31
+ }
32
+ /**
33
+ * Hook to update a member's role.
34
+ */
35
+ export function useUpdateMemberRole(client) {
36
+ const queryClient = useQueryClient();
37
+ return useMutation({
38
+ mutationFn: async ({ entitySlug, memberId, role, }) => {
39
+ const response = await client.updateMemberRole(entitySlug, memberId, role);
40
+ if (!response.success) {
41
+ throw new Error(response.error || 'Failed to update member role');
42
+ }
43
+ return response.data;
44
+ },
45
+ onSuccess: (_, variables) => {
46
+ queryClient.invalidateQueries({
47
+ queryKey: memberKeys.list(variables.entitySlug),
48
+ });
49
+ },
50
+ });
51
+ }
52
+ /**
53
+ * Hook to remove a member from an entity.
54
+ */
55
+ export function useRemoveMember(client) {
56
+ const queryClient = useQueryClient();
57
+ return useMutation({
58
+ mutationFn: async ({ entitySlug, memberId, }) => {
59
+ const response = await client.removeMember(entitySlug, memberId);
60
+ if (!response.success) {
61
+ throw new Error(response.error || 'Failed to remove member');
62
+ }
63
+ },
64
+ onSuccess: (_, variables) => {
65
+ queryClient.invalidateQueries({
66
+ queryKey: memberKeys.list(variables.entitySlug),
67
+ });
68
+ },
69
+ });
70
+ }
71
+ //# sourceMappingURL=useEntityMembers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityMembers.js","sourceRoot":"","sources":["../../src/hooks/useEntityMembers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,CAAC,UAAkB,EAAE,EAAE,CAC1B,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,SAAS,CAAU;IACxD,IAAI,EAAE,CAAC,UAAkB,EAAE,EAAE,CAC3B,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM,CAAU;CACnD,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAoB,EACpB,UAAyB;IAEzB,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;QACjE,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,UAAU;gBAAE,OAAO,EAAE,CAAC;YAC3B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;YACtD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,yBAAyB,CAAC,CAAC;YAC/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CAAC;QACD,SAAS,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE;YAC1B,WAAW,CAAC,iBAAiB,CAAC;gBAC5B,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;aAChD,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Invitation Hooks
4
+ * @description React Query hooks for entity invitation management
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.invitationKeys = void 0;
8
+ exports.useMyInvitations = useMyInvitations;
9
+ exports.useEntityInvitations = useEntityInvitations;
10
+ exports.useCreateInvitation = useCreateInvitation;
11
+ exports.useCancelInvitation = useCancelInvitation;
12
+ exports.useAcceptInvitation = useAcceptInvitation;
13
+ exports.useDeclineInvitation = useDeclineInvitation;
14
+ const react_query_1 = require("@tanstack/react-query");
15
+ const useEntities_1 = require("./useEntities");
16
+ /**
17
+ * Query keys for invitation-related queries.
18
+ */
19
+ exports.invitationKeys = {
20
+ all: ['invitations'],
21
+ myList: () => [...exports.invitationKeys.all, 'my'],
22
+ entityList: (entitySlug) => [...useEntities_1.entityKeys.detail(entitySlug), 'invitations'],
23
+ };
24
+ /**
25
+ * Hook to list pending invitations for the current user.
26
+ */
27
+ function useMyInvitations(client) {
28
+ return (0, react_query_1.useQuery)({
29
+ queryKey: exports.invitationKeys.myList(),
30
+ queryFn: async () => {
31
+ const response = await client.listMyInvitations();
32
+ if (!response.success) {
33
+ throw new Error(response.error || 'Failed to fetch invitations');
34
+ }
35
+ return response.data;
36
+ },
37
+ });
38
+ }
39
+ /**
40
+ * Hook to list invitations for an entity.
41
+ */
42
+ function useEntityInvitations(client, entitySlug) {
43
+ return (0, react_query_1.useQuery)({
44
+ queryKey: entitySlug ? exports.invitationKeys.entityList(entitySlug) : ['disabled'],
45
+ queryFn: async () => {
46
+ if (!entitySlug)
47
+ return [];
48
+ const response = await client.listEntityInvitations(entitySlug);
49
+ if (!response.success) {
50
+ throw new Error(response.error || 'Failed to fetch invitations');
51
+ }
52
+ return response.data;
53
+ },
54
+ enabled: !!entitySlug,
55
+ });
56
+ }
57
+ /**
58
+ * Hook to create an invitation.
59
+ */
60
+ function useCreateInvitation(client) {
61
+ const queryClient = (0, react_query_1.useQueryClient)();
62
+ return (0, react_query_1.useMutation)({
63
+ mutationFn: async ({ entitySlug, request, }) => {
64
+ const response = await client.createInvitation(entitySlug, request);
65
+ if (!response.success) {
66
+ throw new Error(response.error || 'Failed to create invitation');
67
+ }
68
+ return response.data;
69
+ },
70
+ onSuccess: (_, variables) => {
71
+ queryClient.invalidateQueries({
72
+ queryKey: exports.invitationKeys.entityList(variables.entitySlug),
73
+ });
74
+ },
75
+ });
76
+ }
77
+ /**
78
+ * Hook to cancel an invitation.
79
+ */
80
+ function useCancelInvitation(client) {
81
+ const queryClient = (0, react_query_1.useQueryClient)();
82
+ return (0, react_query_1.useMutation)({
83
+ mutationFn: async ({ entitySlug, invitationId, }) => {
84
+ const response = await client.cancelInvitation(entitySlug, invitationId);
85
+ if (!response.success) {
86
+ throw new Error(response.error || 'Failed to cancel invitation');
87
+ }
88
+ },
89
+ onSuccess: (_, variables) => {
90
+ queryClient.invalidateQueries({
91
+ queryKey: exports.invitationKeys.entityList(variables.entitySlug),
92
+ });
93
+ },
94
+ });
95
+ }
96
+ /**
97
+ * Hook to accept an invitation.
98
+ */
99
+ function useAcceptInvitation(client) {
100
+ const queryClient = (0, react_query_1.useQueryClient)();
101
+ return (0, react_query_1.useMutation)({
102
+ mutationFn: async (token) => {
103
+ const response = await client.acceptInvitation(token);
104
+ if (!response.success) {
105
+ throw new Error(response.error || 'Failed to accept invitation');
106
+ }
107
+ },
108
+ onSuccess: () => {
109
+ // Invalidate both my invitations and entity list
110
+ queryClient.invalidateQueries({ queryKey: exports.invitationKeys.myList() });
111
+ queryClient.invalidateQueries({ queryKey: useEntities_1.entityKeys.lists() });
112
+ },
113
+ });
114
+ }
115
+ /**
116
+ * Hook to decline an invitation.
117
+ */
118
+ function useDeclineInvitation(client) {
119
+ const queryClient = (0, react_query_1.useQueryClient)();
120
+ return (0, react_query_1.useMutation)({
121
+ mutationFn: async (token) => {
122
+ const response = await client.declineInvitation(token);
123
+ if (!response.success) {
124
+ throw new Error(response.error || 'Failed to decline invitation');
125
+ }
126
+ },
127
+ onSuccess: () => {
128
+ queryClient.invalidateQueries({ queryKey: exports.invitationKeys.myList() });
129
+ },
130
+ });
131
+ }
132
+ //# sourceMappingURL=useInvitations.js.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @fileoverview Invitation Hooks
3
+ * @description React Query hooks for entity invitation management
4
+ */
5
+ import type { InviteMemberRequest } from '@sudobility/types';
6
+ import { EntityClient } from '../network/EntityClient';
7
+ /**
8
+ * Query keys for invitation-related queries.
9
+ */
10
+ export declare const invitationKeys: {
11
+ all: readonly ["invitations"];
12
+ myList: () => readonly ["invitations", "my"];
13
+ entityList: (entitySlug: string) => readonly ["entities", "detail", string, "invitations"];
14
+ };
15
+ /**
16
+ * Hook to list pending invitations for the current user.
17
+ */
18
+ export declare function useMyInvitations(client: EntityClient): import("@tanstack/react-query").UseQueryResult<import("@sudobility/types").EntityInvitation[], Error>;
19
+ /**
20
+ * Hook to list invitations for an entity.
21
+ */
22
+ export declare function useEntityInvitations(client: EntityClient, entitySlug: string | null): import("@tanstack/react-query").UseQueryResult<import("@sudobility/types").EntityInvitation[], Error>;
23
+ /**
24
+ * Hook to create an invitation.
25
+ */
26
+ export declare function useCreateInvitation(client: EntityClient): import("@tanstack/react-query").UseMutationResult<import("@sudobility/types").EntityInvitation, Error, {
27
+ entitySlug: string;
28
+ request: InviteMemberRequest;
29
+ }, unknown>;
30
+ /**
31
+ * Hook to cancel an invitation.
32
+ */
33
+ export declare function useCancelInvitation(client: EntityClient): import("@tanstack/react-query").UseMutationResult<void, Error, {
34
+ entitySlug: string;
35
+ invitationId: string;
36
+ }, unknown>;
37
+ /**
38
+ * Hook to accept an invitation.
39
+ */
40
+ export declare function useAcceptInvitation(client: EntityClient): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
41
+ /**
42
+ * Hook to decline an invitation.
43
+ */
44
+ export declare function useDeclineInvitation(client: EntityClient): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
45
+ //# sourceMappingURL=useInvitations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInvitations.d.ts","sourceRoot":"","sources":["../../src/hooks/useInvitations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD;;GAEG;AACH,eAAO,MAAM,cAAc;;;6BAGA,MAAM;CAEhC,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,yGAWpD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,GAAG,IAAI,yGAc1B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY;gBAQtC,MAAM;aACT,mBAAmB;YAcjC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY;gBAQtC,MAAM;kBACJ,MAAM;YAazB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,mFAgBvD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,mFAcxD"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * @fileoverview Invitation Hooks
3
+ * @description React Query hooks for entity invitation management
4
+ */
5
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
6
+ import { entityKeys } from './useEntities';
7
+ /**
8
+ * Query keys for invitation-related queries.
9
+ */
10
+ export const invitationKeys = {
11
+ all: ['invitations'],
12
+ myList: () => [...invitationKeys.all, 'my'],
13
+ entityList: (entitySlug) => [...entityKeys.detail(entitySlug), 'invitations'],
14
+ };
15
+ /**
16
+ * Hook to list pending invitations for the current user.
17
+ */
18
+ export function useMyInvitations(client) {
19
+ return useQuery({
20
+ queryKey: invitationKeys.myList(),
21
+ queryFn: async () => {
22
+ const response = await client.listMyInvitations();
23
+ if (!response.success) {
24
+ throw new Error(response.error || 'Failed to fetch invitations');
25
+ }
26
+ return response.data;
27
+ },
28
+ });
29
+ }
30
+ /**
31
+ * Hook to list invitations for an entity.
32
+ */
33
+ export function useEntityInvitations(client, entitySlug) {
34
+ return useQuery({
35
+ queryKey: entitySlug ? invitationKeys.entityList(entitySlug) : ['disabled'],
36
+ queryFn: async () => {
37
+ if (!entitySlug)
38
+ return [];
39
+ const response = await client.listEntityInvitations(entitySlug);
40
+ if (!response.success) {
41
+ throw new Error(response.error || 'Failed to fetch invitations');
42
+ }
43
+ return response.data;
44
+ },
45
+ enabled: !!entitySlug,
46
+ });
47
+ }
48
+ /**
49
+ * Hook to create an invitation.
50
+ */
51
+ export function useCreateInvitation(client) {
52
+ const queryClient = useQueryClient();
53
+ return useMutation({
54
+ mutationFn: async ({ entitySlug, request, }) => {
55
+ const response = await client.createInvitation(entitySlug, request);
56
+ if (!response.success) {
57
+ throw new Error(response.error || 'Failed to create invitation');
58
+ }
59
+ return response.data;
60
+ },
61
+ onSuccess: (_, variables) => {
62
+ queryClient.invalidateQueries({
63
+ queryKey: invitationKeys.entityList(variables.entitySlug),
64
+ });
65
+ },
66
+ });
67
+ }
68
+ /**
69
+ * Hook to cancel an invitation.
70
+ */
71
+ export function useCancelInvitation(client) {
72
+ const queryClient = useQueryClient();
73
+ return useMutation({
74
+ mutationFn: async ({ entitySlug, invitationId, }) => {
75
+ const response = await client.cancelInvitation(entitySlug, invitationId);
76
+ if (!response.success) {
77
+ throw new Error(response.error || 'Failed to cancel invitation');
78
+ }
79
+ },
80
+ onSuccess: (_, variables) => {
81
+ queryClient.invalidateQueries({
82
+ queryKey: invitationKeys.entityList(variables.entitySlug),
83
+ });
84
+ },
85
+ });
86
+ }
87
+ /**
88
+ * Hook to accept an invitation.
89
+ */
90
+ export function useAcceptInvitation(client) {
91
+ const queryClient = useQueryClient();
92
+ return useMutation({
93
+ mutationFn: async (token) => {
94
+ const response = await client.acceptInvitation(token);
95
+ if (!response.success) {
96
+ throw new Error(response.error || 'Failed to accept invitation');
97
+ }
98
+ },
99
+ onSuccess: () => {
100
+ // Invalidate both my invitations and entity list
101
+ queryClient.invalidateQueries({ queryKey: invitationKeys.myList() });
102
+ queryClient.invalidateQueries({ queryKey: entityKeys.lists() });
103
+ },
104
+ });
105
+ }
106
+ /**
107
+ * Hook to decline an invitation.
108
+ */
109
+ export function useDeclineInvitation(client) {
110
+ const queryClient = useQueryClient();
111
+ return useMutation({
112
+ mutationFn: async (token) => {
113
+ const response = await client.declineInvitation(token);
114
+ if (!response.success) {
115
+ throw new Error(response.error || 'Failed to decline invitation');
116
+ }
117
+ },
118
+ onSuccess: () => {
119
+ queryClient.invalidateQueries({ queryKey: invitationKeys.myList() });
120
+ },
121
+ });
122
+ }
123
+ //# sourceMappingURL=useInvitations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInvitations.js","sourceRoot":"","sources":["../../src/hooks/useInvitations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG9E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,GAAG,EAAE,CAAC,aAAa,CAAU;IAC7B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,CAAU;IACpD,UAAU,EAAE,CAAC,UAAkB,EAAE,EAAE,CACjC,CAAC,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ict";
2
+ /**
3
+ * @fileoverview Entity Client Library
4
+ * @description Frontend client and React hooks for entity/organization management
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import {
9
+ * EntityClient,
10
+ * useEntities,
11
+ * useCurrentEntity,
12
+ * CurrentEntityProvider,
13
+ * } from '@sudobility/entity_client';
14
+ *
15
+ * // Create client
16
+ * const client = new EntityClient({
17
+ * baseUrl: 'https://api.example.com/api/v1',
18
+ * getAuthToken: async () => firebase.currentUser?.getIdToken() ?? null,
19
+ * });
20
+ *
21
+ * // Use in React component
22
+ * function EntityList() {
23
+ * const { data: entities, isLoading } = useEntities(client);
24
+ * // ...
25
+ * }
26
+ * ```
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.CurrentEntityProvider = exports.useCurrentEntity = exports.invitationKeys = exports.useDeclineInvitation = exports.useAcceptInvitation = exports.useCancelInvitation = exports.useCreateInvitation = exports.useEntityInvitations = exports.useMyInvitations = exports.memberKeys = exports.useRemoveMember = exports.useUpdateMemberRole = exports.useEntityMembers = exports.entityKeys = exports.useDeleteEntity = exports.useUpdateEntity = exports.useCreateEntity = exports.useEntity = exports.useEntities = exports.EntityClient = void 0;
30
+ // Network exports
31
+ var network_1 = require("./network");
32
+ Object.defineProperty(exports, "EntityClient", { enumerable: true, get: function () { return network_1.EntityClient; } });
33
+ // Hook exports
34
+ var hooks_1 = require("./hooks");
35
+ // Entity hooks
36
+ Object.defineProperty(exports, "useEntities", { enumerable: true, get: function () { return hooks_1.useEntities; } });
37
+ Object.defineProperty(exports, "useEntity", { enumerable: true, get: function () { return hooks_1.useEntity; } });
38
+ Object.defineProperty(exports, "useCreateEntity", { enumerable: true, get: function () { return hooks_1.useCreateEntity; } });
39
+ Object.defineProperty(exports, "useUpdateEntity", { enumerable: true, get: function () { return hooks_1.useUpdateEntity; } });
40
+ Object.defineProperty(exports, "useDeleteEntity", { enumerable: true, get: function () { return hooks_1.useDeleteEntity; } });
41
+ Object.defineProperty(exports, "entityKeys", { enumerable: true, get: function () { return hooks_1.entityKeys; } });
42
+ // Member hooks
43
+ Object.defineProperty(exports, "useEntityMembers", { enumerable: true, get: function () { return hooks_1.useEntityMembers; } });
44
+ Object.defineProperty(exports, "useUpdateMemberRole", { enumerable: true, get: function () { return hooks_1.useUpdateMemberRole; } });
45
+ Object.defineProperty(exports, "useRemoveMember", { enumerable: true, get: function () { return hooks_1.useRemoveMember; } });
46
+ Object.defineProperty(exports, "memberKeys", { enumerable: true, get: function () { return hooks_1.memberKeys; } });
47
+ // Invitation hooks
48
+ Object.defineProperty(exports, "useMyInvitations", { enumerable: true, get: function () { return hooks_1.useMyInvitations; } });
49
+ Object.defineProperty(exports, "useEntityInvitations", { enumerable: true, get: function () { return hooks_1.useEntityInvitations; } });
50
+ Object.defineProperty(exports, "useCreateInvitation", { enumerable: true, get: function () { return hooks_1.useCreateInvitation; } });
51
+ Object.defineProperty(exports, "useCancelInvitation", { enumerable: true, get: function () { return hooks_1.useCancelInvitation; } });
52
+ Object.defineProperty(exports, "useAcceptInvitation", { enumerable: true, get: function () { return hooks_1.useAcceptInvitation; } });
53
+ Object.defineProperty(exports, "useDeclineInvitation", { enumerable: true, get: function () { return hooks_1.useDeclineInvitation; } });
54
+ Object.defineProperty(exports, "invitationKeys", { enumerable: true, get: function () { return hooks_1.invitationKeys; } });
55
+ // Context
56
+ Object.defineProperty(exports, "useCurrentEntity", { enumerable: true, get: function () { return hooks_1.useCurrentEntity; } });
57
+ Object.defineProperty(exports, "CurrentEntityProvider", { enumerable: true, get: function () { return hooks_1.CurrentEntityProvider; } });
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @fileoverview Entity Client Library
3
+ * @description Frontend client and React hooks for entity/organization management
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import {
8
+ * EntityClient,
9
+ * useEntities,
10
+ * useCurrentEntity,
11
+ * CurrentEntityProvider,
12
+ * } from '@sudobility/entity_client';
13
+ *
14
+ * // Create client
15
+ * const client = new EntityClient({
16
+ * baseUrl: 'https://api.example.com/api/v1',
17
+ * getAuthToken: async () => firebase.currentUser?.getIdToken() ?? null,
18
+ * });
19
+ *
20
+ * // Use in React component
21
+ * function EntityList() {
22
+ * const { data: entities, isLoading } = useEntities(client);
23
+ * // ...
24
+ * }
25
+ * ```
26
+ */
27
+ export { EntityClient, type EntityClientConfig, type ApiResponse, } from './network';
28
+ export { useEntities, useEntity, useCreateEntity, useUpdateEntity, useDeleteEntity, entityKeys, useEntityMembers, useUpdateMemberRole, useRemoveMember, memberKeys, useMyInvitations, useEntityInvitations, useCreateInvitation, useCancelInvitation, useAcceptInvitation, useDeclineInvitation, invitationKeys, useCurrentEntity, CurrentEntityProvider, type CurrentEntityContextValue, type CurrentEntityProviderProps, } from './hooks';
29
+ export type { Entity, EntityWithRole, EntityMember, EntityMemberUser, EntityInvitation, EntityType, EntityRole, InvitationStatus, EntityPermissions, CreateEntityRequest, UpdateEntityRequest, InviteMemberRequest, UpdateMemberRoleRequest, } from '@sudobility/types';
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC;AAGnB,OAAO,EAEL,WAAW,EACX,SAAS,EACT,eAAe,EACf,eAAe,EACf,eAAe,EACf,UAAU,EAEV,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,UAAU,EAEV,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EAEd,gBAAgB,EAChB,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,MAAM,EACN,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @fileoverview Entity Client Library
3
+ * @description Frontend client and React hooks for entity/organization management
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * import {
8
+ * EntityClient,
9
+ * useEntities,
10
+ * useCurrentEntity,
11
+ * CurrentEntityProvider,
12
+ * } from '@sudobility/entity_client';
13
+ *
14
+ * // Create client
15
+ * const client = new EntityClient({
16
+ * baseUrl: 'https://api.example.com/api/v1',
17
+ * getAuthToken: async () => firebase.currentUser?.getIdToken() ?? null,
18
+ * });
19
+ *
20
+ * // Use in React component
21
+ * function EntityList() {
22
+ * const { data: entities, isLoading } = useEntities(client);
23
+ * // ...
24
+ * }
25
+ * ```
26
+ */
27
+ // Network exports
28
+ export { EntityClient, } from './network';
29
+ // Hook exports
30
+ export {
31
+ // Entity hooks
32
+ useEntities, useEntity, useCreateEntity, useUpdateEntity, useDeleteEntity, entityKeys,
33
+ // Member hooks
34
+ useEntityMembers, useUpdateMemberRole, useRemoveMember, memberKeys,
35
+ // Invitation hooks
36
+ useMyInvitations, useEntityInvitations, useCreateInvitation, useCancelInvitation, useAcceptInvitation, useDeclineInvitation, invitationKeys,
37
+ // Context
38
+ useCurrentEntity, CurrentEntityProvider, } from './hooks';
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,kBAAkB;AAClB,OAAO,EACL,YAAY,GAGb,MAAM,WAAW,CAAC;AAEnB,eAAe;AACf,OAAO;AACL,eAAe;AACf,WAAW,EACX,SAAS,EACT,eAAe,EACf,eAAe,EACf,eAAe,EACf,UAAU;AACV,eAAe;AACf,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,UAAU;AACV,mBAAmB;AACnB,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc;AACd,UAAU;AACV,gBAAgB,EAChB,qBAAqB,GAGtB,MAAM,SAAS,CAAC"}