@agora-sdk/social-core 0.6.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/LICENSE +202 -0
- package/dist/cjs/context/social-context.d.ts +65 -0
- package/dist/cjs/context/social-context.js +125 -0
- package/dist/cjs/context/social-context.js.map +1 -0
- package/dist/cjs/contract/index.d.ts +19 -0
- package/dist/cjs/contract/index.js +57 -0
- package/dist/cjs/contract/index.js.map +1 -0
- package/dist/cjs/hooks/useSocialConstellation.d.ts +29 -0
- package/dist/cjs/hooks/useSocialConstellation.js +70 -0
- package/dist/cjs/hooks/useSocialConstellation.js.map +1 -0
- package/dist/cjs/hooks/useSocialNeighborhood.d.ts +29 -0
- package/dist/cjs/hooks/useSocialNeighborhood.js +90 -0
- package/dist/cjs/hooks/useSocialNeighborhood.js.map +1 -0
- package/dist/cjs/hooks/useSocialTransparency.d.ts +25 -0
- package/dist/cjs/hooks/useSocialTransparency.js +28 -0
- package/dist/cjs/hooks/useSocialTransparency.js.map +1 -0
- package/dist/cjs/hooks/useSocialWeather.d.ts +28 -0
- package/dist/cjs/hooks/useSocialWeather.js +72 -0
- package/dist/cjs/hooks/useSocialWeather.js.map +1 -0
- package/dist/cjs/index.d.ts +14 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/transport/rest.d.ts +105 -0
- package/dist/cjs/transport/rest.js +177 -0
- package/dist/cjs/transport/rest.js.map +1 -0
- package/dist/esm/context/social-context.d.ts +65 -0
- package/dist/esm/context/social-context.js +120 -0
- package/dist/esm/context/social-context.js.map +1 -0
- package/dist/esm/contract/index.d.ts +19 -0
- package/dist/esm/contract/index.js +54 -0
- package/dist/esm/contract/index.js.map +1 -0
- package/dist/esm/hooks/useSocialConstellation.d.ts +29 -0
- package/dist/esm/hooks/useSocialConstellation.js +67 -0
- package/dist/esm/hooks/useSocialConstellation.js.map +1 -0
- package/dist/esm/hooks/useSocialNeighborhood.d.ts +29 -0
- package/dist/esm/hooks/useSocialNeighborhood.js +87 -0
- package/dist/esm/hooks/useSocialNeighborhood.js.map +1 -0
- package/dist/esm/hooks/useSocialTransparency.d.ts +25 -0
- package/dist/esm/hooks/useSocialTransparency.js +25 -0
- package/dist/esm/hooks/useSocialTransparency.js.map +1 -0
- package/dist/esm/hooks/useSocialWeather.d.ts +28 -0
- package/dist/esm/hooks/useSocialWeather.js +69 -0
- package/dist/esm/hooks/useSocialWeather.js.map +1 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/transport/rest.d.ts +105 -0
- package/dist/esm/transport/rest.js +168 -0
- package/dist/esm/transport/rest.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Replyke
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SocialRestClient } from "../transport/rest.js";
|
|
3
|
+
import { ResolvedSocialConfig } from "../contract/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* The resolved-config sentinel used when the social graph is unavailable (`503
|
|
6
|
+
* social/graph-unavailable`) — every lens and analytics flag disabled, so hooks/components render
|
|
7
|
+
* nothing rather than erroring. Tier is the safe `"community"` default and numeric tuning fields are
|
|
8
|
+
* zeroed; none of these are read while the lenses are disabled.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ALL_DISABLED_SOCIAL_CONFIG: ResolvedSocialConfig;
|
|
11
|
+
/**
|
|
12
|
+
* The value exposed by {@link useSocial}: the shared REST client, the auto-fetched feature config and
|
|
13
|
+
* its load state, and the active project id.
|
|
14
|
+
*/
|
|
15
|
+
export interface SocialContextValue {
|
|
16
|
+
/** REST client for the social endpoints. */
|
|
17
|
+
rest: SocialRestClient;
|
|
18
|
+
/**
|
|
19
|
+
* The project's resolved social config, or `null` until the transparency fetch resolves. When the
|
|
20
|
+
* graph is unavailable this is the {@link ALL_DISABLED_SOCIAL_CONFIG} sentinel (not `null`).
|
|
21
|
+
*/
|
|
22
|
+
config: ResolvedSocialConfig | null;
|
|
23
|
+
/** True while the initial transparency fetch is in flight. */
|
|
24
|
+
configLoading: boolean;
|
|
25
|
+
/** A non-degradation error from the transparency fetch (the `503` graph-off case is not an error). */
|
|
26
|
+
configError: unknown;
|
|
27
|
+
/** The Agora project id these clients are scoped to. */
|
|
28
|
+
projectId: string;
|
|
29
|
+
}
|
|
30
|
+
/** Props for {@link SocialProvider}. */
|
|
31
|
+
export interface SocialProviderProps {
|
|
32
|
+
/** Agora project id (path-scoped on every endpoint — a privacy boundary). */
|
|
33
|
+
projectId: string;
|
|
34
|
+
/** Current access token. Re-pass on refresh; read lazily per request. */
|
|
35
|
+
accessToken?: string;
|
|
36
|
+
/** Override token resolution (takes precedence over `accessToken`). */
|
|
37
|
+
getAccessToken?: () => string | undefined;
|
|
38
|
+
/** Override the API base URL. Defaults to @agora-sdk/core `getApiBaseUrl()`. */
|
|
39
|
+
baseUrl?: string;
|
|
40
|
+
children: React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Provides the social REST client + the project's resolved feature config to the `useSocial*` hooks
|
|
44
|
+
* and components. Render inside a `ReplykeProvider`. Auto-fetches `GET /social/transparency` once on
|
|
45
|
+
* mount; treats `503 social/graph-unavailable` as "all lenses disabled" rather than an error.
|
|
46
|
+
*
|
|
47
|
+
* @param props - {@link SocialProviderProps}.
|
|
48
|
+
* @returns A context provider wrapping `children`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <SocialProvider projectId={projectId} accessToken={token}>
|
|
53
|
+
* <CommunityWeather />
|
|
54
|
+
* <Constellation />
|
|
55
|
+
* </SocialProvider>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function SocialProvider({ projectId, accessToken, getAccessToken, baseUrl, children, }: SocialProviderProps): React.JSX.Element;
|
|
59
|
+
/**
|
|
60
|
+
* Access the nearest {@link SocialContextValue}.
|
|
61
|
+
*
|
|
62
|
+
* @returns The shared rest client, resolved feature config + load state, and project id.
|
|
63
|
+
* @throws {Error} When called outside a `<SocialProvider>`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useSocial(): SocialContextValue;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALL_DISABLED_SOCIAL_CONFIG = void 0;
|
|
4
|
+
exports.SocialProvider = SocialProvider;
|
|
5
|
+
exports.useSocial = useSocial;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
// SocialProvider — wires the social REST transport and auto-resolves the project's feature config.
|
|
8
|
+
//
|
|
9
|
+
// Sits INSIDE a ReplykeProvider: by default it resolves the API base URL from @agora-sdk/core's
|
|
10
|
+
// runtime singleton (getApiBaseUrl). On mount it fetches `GET /social/transparency` once and stores
|
|
11
|
+
// the resolved config so every hook/component can self-gate on the per-project feature flags WITHOUT
|
|
12
|
+
// each issuing its own probe (SOCIAL.md §7 — "check transparency at app init"). There is no crypto and
|
|
13
|
+
// no persistence here: social data is public/server-side and slow-moving, so the provider holds
|
|
14
|
+
// fetched config in React state only.
|
|
15
|
+
//
|
|
16
|
+
// Graceful degradation: a `503 social/graph-unavailable` is treated as "the whole graph is off" — we
|
|
17
|
+
// store an ALL-DISABLED sentinel rather than an error, so surfaces hide silently instead of throwing
|
|
18
|
+
// at members. Any other failure is surfaced via `configError` for the host app to decide on.
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const core_1 = require("@agora-sdk/core");
|
|
21
|
+
const rest_js_1 = require("../transport/rest.js");
|
|
22
|
+
const rest_js_2 = require("../transport/rest.js");
|
|
23
|
+
/**
|
|
24
|
+
* The resolved-config sentinel used when the social graph is unavailable (`503
|
|
25
|
+
* social/graph-unavailable`) — every lens and analytics flag disabled, so hooks/components render
|
|
26
|
+
* nothing rather than erroring. Tier is the safe `"community"` default and numeric tuning fields are
|
|
27
|
+
* zeroed; none of these are read while the lenses are disabled.
|
|
28
|
+
*/
|
|
29
|
+
exports.ALL_DISABLED_SOCIAL_CONFIG = {
|
|
30
|
+
privacyTier: "community",
|
|
31
|
+
graphEnabled: false,
|
|
32
|
+
weatherEnabled: false,
|
|
33
|
+
constellationEnabled: false,
|
|
34
|
+
constellationKFloor: 0,
|
|
35
|
+
neighborhoodEnabled: false,
|
|
36
|
+
neighborhoodIncludeInteractions: false,
|
|
37
|
+
influenceScoresEnabled: false,
|
|
38
|
+
siloDetectionEnabled: false,
|
|
39
|
+
engagementScoresEnabled: false,
|
|
40
|
+
frictionVisibleToStewards: false,
|
|
41
|
+
frictionAnalyticsEnabled: false,
|
|
42
|
+
readAffinityEnabled: false,
|
|
43
|
+
readReceiptsAllowed: false,
|
|
44
|
+
warmthHalfLifeDays: 0,
|
|
45
|
+
frictionHalfLifeDays: 0,
|
|
46
|
+
};
|
|
47
|
+
const SocialContext = (0, react_1.createContext)(null);
|
|
48
|
+
/**
|
|
49
|
+
* Provides the social REST client + the project's resolved feature config to the `useSocial*` hooks
|
|
50
|
+
* and components. Render inside a `ReplykeProvider`. Auto-fetches `GET /social/transparency` once on
|
|
51
|
+
* mount; treats `503 social/graph-unavailable` as "all lenses disabled" rather than an error.
|
|
52
|
+
*
|
|
53
|
+
* @param props - {@link SocialProviderProps}.
|
|
54
|
+
* @returns A context provider wrapping `children`.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* <SocialProvider projectId={projectId} accessToken={token}>
|
|
59
|
+
* <CommunityWeather />
|
|
60
|
+
* <Constellation />
|
|
61
|
+
* </SocialProvider>
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
function SocialProvider({ projectId, accessToken, getAccessToken, baseUrl, children, }) {
|
|
65
|
+
const tokenRef = (0, react_1.useRef)(accessToken);
|
|
66
|
+
tokenRef.current = accessToken;
|
|
67
|
+
const resolveToken = (0, react_1.useMemo)(() => getAccessToken ?? (() => tokenRef.current), [getAccessToken]);
|
|
68
|
+
const rest = (0, react_1.useMemo)(() => new rest_js_1.SocialRestClient({
|
|
69
|
+
projectId,
|
|
70
|
+
getAccessToken: resolveToken,
|
|
71
|
+
getBaseUrl: () => baseUrl ?? (0, core_1.getApiBaseUrl)(),
|
|
72
|
+
}), [projectId, resolveToken, baseUrl]);
|
|
73
|
+
const [config, setConfig] = (0, react_1.useState)(null);
|
|
74
|
+
const [configLoading, setConfigLoading] = (0, react_1.useState)(true);
|
|
75
|
+
const [configError, setConfigError] = (0, react_1.useState)(null);
|
|
76
|
+
// Auto-resolve the per-project feature config once on mount (and whenever the client identity
|
|
77
|
+
// changes). A `503 social/graph-unavailable` is degradation, not an error: store the all-disabled
|
|
78
|
+
// sentinel so every surface hides silently (SOCIAL.md §7). A stale-guard prevents a slow first fetch
|
|
79
|
+
// from clobbering a newer one after a projectId/token swap.
|
|
80
|
+
(0, react_1.useEffect)(() => {
|
|
81
|
+
let active = true;
|
|
82
|
+
setConfigLoading(true);
|
|
83
|
+
setConfigError(null);
|
|
84
|
+
rest
|
|
85
|
+
.getTransparency()
|
|
86
|
+
.then((resolved) => {
|
|
87
|
+
if (!active)
|
|
88
|
+
return;
|
|
89
|
+
setConfig(resolved);
|
|
90
|
+
})
|
|
91
|
+
.catch((err) => {
|
|
92
|
+
if (!active)
|
|
93
|
+
return;
|
|
94
|
+
if (err instanceof rest_js_2.SocialApiError && err.code === "social/graph-unavailable") {
|
|
95
|
+
setConfig(exports.ALL_DISABLED_SOCIAL_CONFIG);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
setConfigError(err);
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
.finally(() => {
|
|
102
|
+
if (active)
|
|
103
|
+
setConfigLoading(false);
|
|
104
|
+
});
|
|
105
|
+
return () => {
|
|
106
|
+
active = false;
|
|
107
|
+
};
|
|
108
|
+
}, [rest]);
|
|
109
|
+
const value = (0, react_1.useMemo)(() => ({ rest, config, configLoading, configError, projectId }), [rest, config, configLoading, configError, projectId]);
|
|
110
|
+
return (0, jsx_runtime_1.jsx)(SocialContext.Provider, { value: value, children: children });
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Access the nearest {@link SocialContextValue}.
|
|
114
|
+
*
|
|
115
|
+
* @returns The shared rest client, resolved feature config + load state, and project id.
|
|
116
|
+
* @throws {Error} When called outside a `<SocialProvider>`.
|
|
117
|
+
*/
|
|
118
|
+
function useSocial() {
|
|
119
|
+
const ctx = (0, react_1.useContext)(SocialContext);
|
|
120
|
+
if (!ctx) {
|
|
121
|
+
throw new Error("useSocial must be used within a <SocialProvider>.");
|
|
122
|
+
}
|
|
123
|
+
return ctx;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=social-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-context.js","sourceRoot":"","sources":["../../../src/context/social-context.tsx"],"names":[],"mappings":";;;AAgGA,wCAiEC;AAQD,8BAMC;;AA/KD,mGAAmG;AACnG,EAAE;AACF,gGAAgG;AAChG,oGAAoG;AACpG,qGAAqG;AACrG,uGAAuG;AACvG,gGAAgG;AAChG,sCAAsC;AACtC,EAAE;AACF,qGAAqG;AACrG,qGAAqG;AACrG,6FAA6F;AAE7F,iCAA+F;AAC/F,0CAAgD;AAEhD,kDAAwD;AACxD,kDAAsD;AAGtD;;;;;GAKG;AACU,QAAA,0BAA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EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,CAAC,CACtD,CAAC;IAEF,OAAO,uBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAA0B,CAAC;AACnF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,SAAS;IACvB,MAAM,GAAG,GAAG,IAAA,kBAAU,EAAC,aAAa,CAAC,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { SocialWeather, WeatherBand, SocialConstellation, ConstellationBlob, BlobSizeBucket, SocialNeighborhood, NeighborhoodTie, NeighborhoodTieKind, ResolvedSocialConfig, SocialPrivacyTier, } from "@agora-server/contract";
|
|
2
|
+
import type { WeatherBand, BlobSizeBucket, NeighborhoodTieKind } from "@agora-server/contract";
|
|
3
|
+
/**
|
|
4
|
+
* Runtime list of {@link WeatherBand} values, low → high (for iteration / validation). Mirrors the
|
|
5
|
+
* contract's `WEATHER_BANDS`; re-declared locally so core's CJS build need not `require()` the
|
|
6
|
+
* ESM-only contract. Typed against the contract union, so any drift is a compile error.
|
|
7
|
+
*/
|
|
8
|
+
export declare const WEATHER_BANDS: readonly WeatherBand[];
|
|
9
|
+
/**
|
|
10
|
+
* Runtime list of {@link BlobSizeBucket} values, small → large (for iteration / validation). Mirrors
|
|
11
|
+
* the contract's `BLOB_SIZE_BUCKETS` (en-dash strings); re-declared locally for the CJS-build reason
|
|
12
|
+
* above.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BLOB_SIZE_BUCKETS: readonly BlobSizeBucket[];
|
|
15
|
+
/**
|
|
16
|
+
* Runtime list of {@link NeighborhoodTieKind} values (for iteration / validation). Mirrors the
|
|
17
|
+
* contract's `NEIGHBORHOOD_TIE_KINDS`; re-declared locally for the CJS-build reason above.
|
|
18
|
+
*/
|
|
19
|
+
export declare const NEIGHBORHOOD_TIE_KINDS: readonly NeighborhoodTieKind[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Social-graph wire types — re-exported from the published `@agora-server/contract` (Apache-2.0).
|
|
3
|
+
//
|
|
4
|
+
// The dependency arrow is **SDK → contract**: agora-server owns the social wire contract, this SDK
|
|
5
|
+
// depends on it. As of `@agora-server/contract@0.12.1` the social surface is published, so this module
|
|
6
|
+
// is a thin **type-only re-export** (one source of truth, zero drift) — it replaces the earlier local
|
|
7
|
+
// byte-faithful stand-in that stood in until the contract shipped these types.
|
|
8
|
+
//
|
|
9
|
+
// Type-only on purpose: `@agora-server/contract` is ESM-only, but `export type` re-exports are erased
|
|
10
|
+
// from the emitted JS, so core's dual ESM/CJS build never `require()`s it at runtime (mirrors
|
|
11
|
+
// `secure-chat-core/src/contract`). For the SAME reason the three runtime const arrays are re-declared
|
|
12
|
+
// **locally** rather than value-re-exported — a value re-export would force the CJS build to
|
|
13
|
+
// `require()` the ESM-only contract. They are typed against the contract's unions, so any drift in the
|
|
14
|
+
// bands/buckets/tie-kinds becomes a compile error here.
|
|
15
|
+
//
|
|
16
|
+
// Scope: only the three member-facing lenses (Weather, Constellation, Neighborhood) + the resolved
|
|
17
|
+
// config the SDK consumes. The contract's corporate-analytics surface (influence / silos / engagement,
|
|
18
|
+
// read-receipts) is intentionally NOT re-exported — it is outside this package's scope.
|
|
19
|
+
//
|
|
20
|
+
// Wire conventions (owned by the contract): timestamps are ISO 8601 strings; `value`/`trend`/
|
|
21
|
+
// `brightness` are JSON numbers; size buckets are en-dash strings ("5–9", U+2013).
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.NEIGHBORHOOD_TIE_KINDS = exports.BLOB_SIZE_BUCKETS = exports.WEATHER_BANDS = void 0;
|
|
24
|
+
/**
|
|
25
|
+
* Runtime list of {@link WeatherBand} values, low → high (for iteration / validation). Mirrors the
|
|
26
|
+
* contract's `WEATHER_BANDS`; re-declared locally so core's CJS build need not `require()` the
|
|
27
|
+
* ESM-only contract. Typed against the contract union, so any drift is a compile error.
|
|
28
|
+
*/
|
|
29
|
+
exports.WEATHER_BANDS = [
|
|
30
|
+
"quiet",
|
|
31
|
+
"stormy",
|
|
32
|
+
"overcast",
|
|
33
|
+
"fine",
|
|
34
|
+
"sunny",
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Runtime list of {@link BlobSizeBucket} values, small → large (for iteration / validation). Mirrors
|
|
38
|
+
* the contract's `BLOB_SIZE_BUCKETS` (en-dash strings); re-declared locally for the CJS-build reason
|
|
39
|
+
* above.
|
|
40
|
+
*/
|
|
41
|
+
exports.BLOB_SIZE_BUCKETS = [
|
|
42
|
+
"5–9",
|
|
43
|
+
"10–19",
|
|
44
|
+
"20–49",
|
|
45
|
+
"50–99",
|
|
46
|
+
"100+",
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Runtime list of {@link NeighborhoodTieKind} values (for iteration / validation). Mirrors the
|
|
50
|
+
* contract's `NEIGHBORHOOD_TIE_KINDS`; re-declared locally for the CJS-build reason above.
|
|
51
|
+
*/
|
|
52
|
+
exports.NEIGHBORHOOD_TIE_KINDS = [
|
|
53
|
+
"follow",
|
|
54
|
+
"connection",
|
|
55
|
+
"interaction",
|
|
56
|
+
];
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/contract/index.ts"],"names":[],"mappings":";AAAA,kGAAkG;AAClG,EAAE;AACF,mGAAmG;AACnG,uGAAuG;AACvG,sGAAsG;AACtG,+EAA+E;AAC/E,EAAE;AACF,sGAAsG;AACtG,8FAA8F;AAC9F,uGAAuG;AACvG,6FAA6F;AAC7F,uGAAuG;AACvG,wDAAwD;AACxD,EAAE;AACF,mGAAmG;AACnG,uGAAuG;AACvG,wFAAwF;AACxF,EAAE;AACF,8FAA8F;AAC9F,mFAAmF;;;AAiBnF;;;;GAIG;AACU,QAAA,aAAa,GAA2B;IACnD,OAAO;IACP,QAAQ;IACR,UAAU;IACV,MAAM;IACN,OAAO;CACR,CAAC;AAEF;;;;GAIG;AACU,QAAA,iBAAiB,GAA8B;IAC1D,KAAK;IACL,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;CACP,CAAC;AAEF;;;GAGG;AACU,QAAA,sBAAsB,GAAmC;IACpE,QAAQ;IACR,YAAY;IACZ,aAAa;CACd,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SocialConstellation } from "../contract/index.js";
|
|
2
|
+
/** The state and actions returned by {@link useSocialConstellation}. */
|
|
3
|
+
export interface UseSocialConstellationValues {
|
|
4
|
+
/** The current snapshot, or `null` while loading, when disabled, or on error. `asOf: null` = still forming. */
|
|
5
|
+
constellation: SocialConstellation | null;
|
|
6
|
+
/** True while a fetch is in flight (always `false` when the lens is disabled). */
|
|
7
|
+
loading: boolean;
|
|
8
|
+
/** The last error thrown by the fetch, or `null`. */
|
|
9
|
+
error: unknown;
|
|
10
|
+
/** Re-fetch the snapshot. No-op when the lens is disabled. */
|
|
11
|
+
refresh: () => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Load the Constellation snapshot (anonymous cluster blobs) for the current project.
|
|
15
|
+
*
|
|
16
|
+
* Waits for the provider's transparency config, then fetches `GET /social/constellation` only when
|
|
17
|
+
* `constellationEnabled` is true. A snapshot with `asOf === null` is the valid "still forming" state,
|
|
18
|
+
* not an error — render a nebula.
|
|
19
|
+
*
|
|
20
|
+
* @returns {@link UseSocialConstellationValues} — the snapshot, load state, and a `refresh` action.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { constellation } = useSocialConstellation();
|
|
25
|
+
* if (!constellation) return null; // disabled or loading
|
|
26
|
+
* if (constellation.asOf === null) return <Nebula />; // still forming
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useSocialConstellation(): UseSocialConstellationValues;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// useSocialConstellation — load the anonymous Constellation snapshot, gated on the feature config.
|
|
3
|
+
//
|
|
4
|
+
// Self-gates on `config.constellationEnabled`. The Constellation is a slow seasonal snapshot
|
|
5
|
+
// (materialized ~every 6 weeks), so one fetch on enable is plenty; `refresh()` is exposed only for
|
|
6
|
+
// completeness. The returned `blobs` carry no stable identity — re-randomizing their LAYOUT on every
|
|
7
|
+
// render is the rendering layer's job (SOCIAL.md §6), not this hook's.
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useSocialConstellation = useSocialConstellation;
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const rest_js_1 = require("../transport/rest.js");
|
|
12
|
+
const social_context_js_1 = require("../context/social-context.js");
|
|
13
|
+
/**
|
|
14
|
+
* Load the Constellation snapshot (anonymous cluster blobs) for the current project.
|
|
15
|
+
*
|
|
16
|
+
* Waits for the provider's transparency config, then fetches `GET /social/constellation` only when
|
|
17
|
+
* `constellationEnabled` is true. A snapshot with `asOf === null` is the valid "still forming" state,
|
|
18
|
+
* not an error — render a nebula.
|
|
19
|
+
*
|
|
20
|
+
* @returns {@link UseSocialConstellationValues} — the snapshot, load state, and a `refresh` action.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { constellation } = useSocialConstellation();
|
|
25
|
+
* if (!constellation) return null; // disabled or loading
|
|
26
|
+
* if (constellation.asOf === null) return <Nebula />; // still forming
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function useSocialConstellation() {
|
|
30
|
+
const { rest, config, configLoading } = (0, social_context_js_1.useSocial)();
|
|
31
|
+
const enabled = config?.constellationEnabled ?? false;
|
|
32
|
+
const [constellation, setConstellation] = (0, react_1.useState)(null);
|
|
33
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
34
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
35
|
+
const refresh = (0, react_1.useCallback)(async () => {
|
|
36
|
+
if (!enabled)
|
|
37
|
+
return;
|
|
38
|
+
setLoading(true);
|
|
39
|
+
setError(null);
|
|
40
|
+
try {
|
|
41
|
+
setConstellation(await rest.getConstellation());
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
// Fail soft on degradation (graph off, or the lens disabled mid-session): hide the surface —
|
|
45
|
+
// clear the snapshot and swallow the error rather than surface it to members (SOCIAL.md §7). Real
|
|
46
|
+
// errors still propagate via `error`.
|
|
47
|
+
if ((0, rest_js_1.isSocialDegradation)(err)) {
|
|
48
|
+
setConstellation(null);
|
|
49
|
+
setError(null);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
setError(err);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
setLoading(false);
|
|
57
|
+
}
|
|
58
|
+
}, [enabled, rest]);
|
|
59
|
+
(0, react_1.useEffect)(() => {
|
|
60
|
+
if (configLoading)
|
|
61
|
+
return;
|
|
62
|
+
if (!enabled) {
|
|
63
|
+
setConstellation(null);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
void refresh();
|
|
67
|
+
}, [configLoading, enabled, refresh]);
|
|
68
|
+
return { constellation, loading, error, refresh };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=useSocialConstellation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSocialConstellation.js","sourceRoot":"","sources":["../../../src/hooks/useSocialConstellation.tsx"],"names":[],"mappings":";AAAA,mGAAmG;AACnG,EAAE;AACF,6FAA6F;AAC7F,mGAAmG;AACnG,qGAAqG;AACrG,uEAAuE;;AAmCvE,wDAuCC;AAxED,iCAAyD;AAEzD,kDAA2D;AAC3D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CAAC,OAAO,EAAE,CAAC;YACb,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACvB,OAAO;QACT,CAAC;QACD,KAAK,OAAO,EAAE,CAAC;IACjB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SocialNeighborhood } from "../contract/index.js";
|
|
2
|
+
/** The state and actions returned by {@link useSocialNeighborhood}. */
|
|
3
|
+
export interface UseSocialNeighborhoodValues {
|
|
4
|
+
/** The caller's ties (brightest-first), or `null` while loading, when disabled, or on error. */
|
|
5
|
+
neighborhood: SocialNeighborhood | null;
|
|
6
|
+
/** True while a fetch is in flight (always `false` when the lens is disabled). */
|
|
7
|
+
loading: boolean;
|
|
8
|
+
/** The last error thrown by the fetch, or `null`. */
|
|
9
|
+
error: unknown;
|
|
10
|
+
/** The effective `includeInteractions` value currently in effect. */
|
|
11
|
+
includeInteractions: boolean;
|
|
12
|
+
/** Flip whether interaction-only ties are included; triggers a re-fetch. */
|
|
13
|
+
setIncludeInteractions: (value: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Load the caller's Neighborhood — their own named ties with dyadic brightness. Self-view only.
|
|
17
|
+
*
|
|
18
|
+
* Waits for the provider's transparency config, seeds the `includeInteractions` toggle from the
|
|
19
|
+
* project default, then fetches `GET /social/neighborhood` only when `neighborhoodEnabled` is true.
|
|
20
|
+
* Flipping the toggle re-fetches; the hook syncs to the server's echoed effective value.
|
|
21
|
+
*
|
|
22
|
+
* @returns {@link UseSocialNeighborhoodValues} — the ties, load state, and the interactions toggle.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* const { neighborhood, includeInteractions, setIncludeInteractions } = useSocialNeighborhood();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useSocialNeighborhood(): UseSocialNeighborhoodValues;
|