@hypercerts-org/sdk-core 0.5.0-beta.0 → 0.7.0-beta.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/README.md +130 -8
- package/dist/index.cjs +93 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +64 -1
- package/dist/index.mjs +93 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
- package/.turbo/turbo-build.log +0 -40
- package/.turbo/turbo-test.log +0 -119
- package/CHANGELOG.md +0 -62
- package/eslint.config.mjs +0 -22
- package/rollup.config.js +0 -75
- package/src/auth/OAuthClient.ts +0 -497
- package/src/core/SDK.ts +0 -410
- package/src/core/config.ts +0 -243
- package/src/core/errors.ts +0 -257
- package/src/core/interfaces.ts +0 -324
- package/src/core/types.ts +0 -282
- package/src/errors.ts +0 -57
- package/src/index.ts +0 -107
- package/src/lexicons.ts +0 -64
- package/src/repository/BlobOperationsImpl.ts +0 -199
- package/src/repository/CollaboratorOperationsImpl.ts +0 -442
- package/src/repository/HypercertOperationsImpl.ts +0 -1146
- package/src/repository/LexiconRegistry.ts +0 -332
- package/src/repository/OrganizationOperationsImpl.ts +0 -282
- package/src/repository/ProfileOperationsImpl.ts +0 -281
- package/src/repository/RecordOperationsImpl.ts +0 -340
- package/src/repository/Repository.ts +0 -482
- package/src/repository/interfaces.ts +0 -909
- package/src/repository/types.ts +0 -111
- package/src/services/hypercerts/types.ts +0 -87
- package/src/storage/InMemorySessionStore.ts +0 -127
- package/src/storage/InMemoryStateStore.ts +0 -146
- package/src/storage.ts +0 -63
- package/src/testing/index.ts +0 -67
- package/src/testing/mocks.ts +0 -142
- package/src/testing/stores.ts +0 -285
- package/src/testing.ts +0 -64
- package/src/types.ts +0 -86
- package/tests/auth/OAuthClient.test.ts +0 -164
- package/tests/core/SDK.test.ts +0 -176
- package/tests/core/errors.test.ts +0 -81
- package/tests/repository/BlobOperationsImpl.test.ts +0 -155
- package/tests/repository/CollaboratorOperationsImpl.test.ts +0 -438
- package/tests/repository/HypercertOperationsImpl.test.ts +0 -652
- package/tests/repository/LexiconRegistry.test.ts +0 -192
- package/tests/repository/OrganizationOperationsImpl.test.ts +0 -240
- package/tests/repository/ProfileOperationsImpl.test.ts +0 -254
- package/tests/repository/RecordOperationsImpl.test.ts +0 -375
- package/tests/repository/Repository.test.ts +0 -149
- package/tests/utils/fixtures.ts +0 -117
- package/tests/utils/mocks.ts +0 -109
- package/tests/utils/repository-fixtures.ts +0 -78
- package/tsconfig.json +0 -11
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -30
package/src/testing/mocks.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mock factories for testing.
|
|
3
|
-
*
|
|
4
|
-
* This module provides factory functions to create mock objects
|
|
5
|
-
* for testing SDK functionality without real AT Protocol connections.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { Session } from "../core/types.js";
|
|
11
|
-
import type { ATProtoSDKConfig } from "../core/config.js";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Creates a mock OAuth session for testing.
|
|
15
|
-
*
|
|
16
|
-
* The mock session includes all required properties and a mock
|
|
17
|
-
* `fetchHandler` that returns empty successful responses by default.
|
|
18
|
-
*
|
|
19
|
-
* @param overrides - Partial session object to override default values
|
|
20
|
-
* @returns A mock Session object suitable for testing
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* The mock session is cast to `Session` type for compatibility.
|
|
24
|
-
* In real usage, sessions come from the OAuth flow and contain
|
|
25
|
-
* actual tokens and a real fetch handler.
|
|
26
|
-
*
|
|
27
|
-
* **Default Values**:
|
|
28
|
-
* - `did`: `"did:plc:test123"`
|
|
29
|
-
* - `handle`: `"test.bsky.social"`
|
|
30
|
-
* - `fetchHandler`: Returns `Response` with `{}` body
|
|
31
|
-
*
|
|
32
|
-
* @example Basic mock session
|
|
33
|
-
* ```typescript
|
|
34
|
-
* import { createMockSession } from "@hypercerts-org/sdk/testing";
|
|
35
|
-
*
|
|
36
|
-
* const session = createMockSession();
|
|
37
|
-
* const repo = sdk.repository(session);
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @example With custom DID
|
|
41
|
-
* ```typescript
|
|
42
|
-
* const session = createMockSession({
|
|
43
|
-
* did: "did:plc:custom-test-user",
|
|
44
|
-
* handle: "custom.bsky.social",
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @example With custom fetch handler
|
|
49
|
-
* ```typescript
|
|
50
|
-
* const session = createMockSession({
|
|
51
|
-
* fetchHandler: async (url, init) => {
|
|
52
|
-
* // Custom response logic
|
|
53
|
-
* return new Response(JSON.stringify({ success: true }));
|
|
54
|
-
* },
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export function createMockSession(overrides: Partial<Session> = {}): Session {
|
|
59
|
-
const mockSession = {
|
|
60
|
-
did: "did:plc:test123",
|
|
61
|
-
sub: "did:plc:test123",
|
|
62
|
-
handle: "test.bsky.social",
|
|
63
|
-
accessJwt: "mock-access-jwt",
|
|
64
|
-
refreshJwt: "mock-refresh-jwt",
|
|
65
|
-
active: true,
|
|
66
|
-
fetchHandler: async (_input: RequestInfo | URL, _init?: RequestInit) => {
|
|
67
|
-
return new Response(JSON.stringify({}), {
|
|
68
|
-
status: 200,
|
|
69
|
-
headers: { "Content-Type": "application/json" },
|
|
70
|
-
});
|
|
71
|
-
},
|
|
72
|
-
...overrides,
|
|
73
|
-
} as unknown as Session;
|
|
74
|
-
|
|
75
|
-
return mockSession;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Creates a mock SDK configuration for testing.
|
|
80
|
-
*
|
|
81
|
-
* The configuration includes all required OAuth settings with
|
|
82
|
-
* placeholder values suitable for testing (not real credentials).
|
|
83
|
-
*
|
|
84
|
-
* @param overrides - Partial configuration to override default values
|
|
85
|
-
* @returns A complete ATProtoSDKConfig suitable for testing
|
|
86
|
-
*
|
|
87
|
-
* @remarks
|
|
88
|
-
* The default configuration uses example.com domains and a minimal
|
|
89
|
-
* JWK structure. This is sufficient for unit tests but won't work
|
|
90
|
-
* for integration tests that require real OAuth flows.
|
|
91
|
-
*
|
|
92
|
-
* **Default Values**:
|
|
93
|
-
* - `clientId`: `"https://test.example.com/client-metadata.json"`
|
|
94
|
-
* - `pds`: `"https://bsky.social"`
|
|
95
|
-
* - `sds`: `"https://sds.example.com"`
|
|
96
|
-
*
|
|
97
|
-
* @example Basic test config
|
|
98
|
-
* ```typescript
|
|
99
|
-
* import { createTestConfig } from "@hypercerts-org/sdk/testing";
|
|
100
|
-
*
|
|
101
|
-
* const config = createTestConfig();
|
|
102
|
-
* const sdk = new ATProtoSDK(config);
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @example With custom PDS
|
|
106
|
-
* ```typescript
|
|
107
|
-
* const config = createTestConfig({
|
|
108
|
-
* servers: {
|
|
109
|
-
* pds: "https://custom-pds.example.com",
|
|
110
|
-
* },
|
|
111
|
-
* });
|
|
112
|
-
* ```
|
|
113
|
-
*
|
|
114
|
-
* @example With logger for debugging tests
|
|
115
|
-
* ```typescript
|
|
116
|
-
* const config = createTestConfig({
|
|
117
|
-
* logger: console,
|
|
118
|
-
* });
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
export function createTestConfig(overrides: Partial<ATProtoSDKConfig> = {}): ATProtoSDKConfig {
|
|
122
|
-
return {
|
|
123
|
-
oauth: {
|
|
124
|
-
clientId: "https://test.example.com/client-metadata.json",
|
|
125
|
-
redirectUri: "https://test.example.com/callback",
|
|
126
|
-
scope: "atproto transition:generic",
|
|
127
|
-
jwksUri: "https://test.example.com/jwks.json",
|
|
128
|
-
jwkPrivate: JSON.stringify({
|
|
129
|
-
kty: "EC",
|
|
130
|
-
crv: "P-256",
|
|
131
|
-
x: "test",
|
|
132
|
-
y: "test",
|
|
133
|
-
d: "test",
|
|
134
|
-
}),
|
|
135
|
-
},
|
|
136
|
-
servers: {
|
|
137
|
-
pds: "https://bsky.social",
|
|
138
|
-
sds: "https://sds.example.com",
|
|
139
|
-
},
|
|
140
|
-
...overrides,
|
|
141
|
-
};
|
|
142
|
-
}
|
package/src/testing/stores.ts
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mock storage implementations for testing.
|
|
3
|
-
*
|
|
4
|
-
* This module provides mock implementations of SessionStore and StateStore
|
|
5
|
-
* that track all operations for verification in tests.
|
|
6
|
-
*
|
|
7
|
-
* @packageDocumentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { SessionStore, StateStore } from "../core/interfaces.js";
|
|
11
|
-
import type { NodeSavedSession, NodeSavedState } from "@atproto/oauth-client-node";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Mock session store that tracks all operations.
|
|
15
|
-
*
|
|
16
|
-
* This implementation stores sessions in memory and records all
|
|
17
|
-
* method calls for verification in tests.
|
|
18
|
-
*
|
|
19
|
-
* @remarks
|
|
20
|
-
* Use this in tests to:
|
|
21
|
-
* - Verify that sessions are being stored correctly
|
|
22
|
-
* - Check what DIDs have been accessed
|
|
23
|
-
* - Assert on the number and order of operations
|
|
24
|
-
* - Pre-populate sessions for testing restore flows
|
|
25
|
-
*
|
|
26
|
-
* @example Basic usage
|
|
27
|
-
* ```typescript
|
|
28
|
-
* import { MockSessionStore } from "@hypercerts-org/sdk/testing";
|
|
29
|
-
*
|
|
30
|
-
* const sessionStore = new MockSessionStore();
|
|
31
|
-
* const sdk = new ATProtoSDK({
|
|
32
|
-
* ...config,
|
|
33
|
-
* storage: { sessionStore },
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* // After some operations...
|
|
37
|
-
* expect(sessionStore.setCalls).toHaveLength(1);
|
|
38
|
-
* expect(sessionStore.getCalls).toContain("did:plc:test123");
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @example Pre-populating for tests
|
|
42
|
-
* ```typescript
|
|
43
|
-
* const sessionStore = new MockSessionStore();
|
|
44
|
-
*
|
|
45
|
-
* // Pre-populate a session
|
|
46
|
-
* await sessionStore.set("did:plc:existing", mockSessionData);
|
|
47
|
-
*
|
|
48
|
-
* // Reset tracking (keeps the data)
|
|
49
|
-
* sessionStore.getCalls = [];
|
|
50
|
-
* sessionStore.setCalls = [];
|
|
51
|
-
*
|
|
52
|
-
* // Now test restore behavior
|
|
53
|
-
* const session = await sdk.restoreSession("did:plc:existing");
|
|
54
|
-
* expect(sessionStore.getCalls).toContain("did:plc:existing");
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @example Asserting on operations
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const sessionStore = new MockSessionStore();
|
|
60
|
-
*
|
|
61
|
-
* // ... perform operations ...
|
|
62
|
-
*
|
|
63
|
-
* // Verify session was stored for correct DID
|
|
64
|
-
* expect(sessionStore.setCalls[0].did).toBe("did:plc:expected");
|
|
65
|
-
*
|
|
66
|
-
* // Verify session was deleted on logout
|
|
67
|
-
* expect(sessionStore.delCalls).toContain("did:plc:logged-out");
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export class MockSessionStore implements SessionStore {
|
|
71
|
-
/**
|
|
72
|
-
* Internal storage for sessions.
|
|
73
|
-
* @internal
|
|
74
|
-
*/
|
|
75
|
-
private store = new Map<string, NodeSavedSession>();
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Record of all `get()` calls made to this store.
|
|
79
|
-
*
|
|
80
|
-
* Each entry is the DID that was requested.
|
|
81
|
-
*/
|
|
82
|
-
public getCalls: string[] = [];
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Record of all `set()` calls made to this store.
|
|
86
|
-
*
|
|
87
|
-
* Each entry contains the DID and session that was stored.
|
|
88
|
-
*/
|
|
89
|
-
public setCalls: Array<{ did: string; session: NodeSavedSession }> = [];
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Record of all `del()` calls made to this store.
|
|
93
|
-
*
|
|
94
|
-
* Each entry is the DID that was deleted.
|
|
95
|
-
*/
|
|
96
|
-
public delCalls: string[] = [];
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Retrieves a session by DID.
|
|
100
|
-
*
|
|
101
|
-
* Records the call in `getCalls`.
|
|
102
|
-
*
|
|
103
|
-
* @param did - The DID to look up
|
|
104
|
-
* @returns The stored session or undefined
|
|
105
|
-
*/
|
|
106
|
-
async get(did: string): Promise<NodeSavedSession | undefined> {
|
|
107
|
-
this.getCalls.push(did);
|
|
108
|
-
return this.store.get(did);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Stores a session.
|
|
113
|
-
*
|
|
114
|
-
* Records the call in `setCalls`.
|
|
115
|
-
*
|
|
116
|
-
* @param did - The DID to store under
|
|
117
|
-
* @param session - The session data to store
|
|
118
|
-
*/
|
|
119
|
-
async set(did: string, session: NodeSavedSession): Promise<void> {
|
|
120
|
-
this.setCalls.push({ did, session });
|
|
121
|
-
this.store.set(did, session);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Deletes a session.
|
|
126
|
-
*
|
|
127
|
-
* Records the call in `delCalls`.
|
|
128
|
-
*
|
|
129
|
-
* @param did - The DID to delete
|
|
130
|
-
*/
|
|
131
|
-
async del(did: string): Promise<void> {
|
|
132
|
-
this.delCalls.push(did);
|
|
133
|
-
this.store.delete(did);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Resets the store to initial state.
|
|
138
|
-
*
|
|
139
|
-
* Clears all stored sessions and all recorded calls.
|
|
140
|
-
* Call this in `beforeEach` or `afterEach` to ensure test isolation.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```typescript
|
|
144
|
-
* beforeEach(() => {
|
|
145
|
-
* sessionStore.reset();
|
|
146
|
-
* });
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
reset(): void {
|
|
150
|
-
this.store.clear();
|
|
151
|
-
this.getCalls = [];
|
|
152
|
-
this.setCalls = [];
|
|
153
|
-
this.delCalls = [];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Mock state store that tracks all operations.
|
|
159
|
-
*
|
|
160
|
-
* This implementation stores OAuth state in memory and records all
|
|
161
|
-
* method calls for verification in tests.
|
|
162
|
-
*
|
|
163
|
-
* @remarks
|
|
164
|
-
* Use this in tests to:
|
|
165
|
-
* - Verify OAuth state is being created during authorization
|
|
166
|
-
* - Check that state is retrieved during callback
|
|
167
|
-
* - Assert that state is cleaned up after use
|
|
168
|
-
* - Test error handling for missing/invalid state
|
|
169
|
-
*
|
|
170
|
-
* @example Basic usage
|
|
171
|
-
* ```typescript
|
|
172
|
-
* import { MockStateStore } from "@hypercerts-org/sdk/testing";
|
|
173
|
-
*
|
|
174
|
-
* const stateStore = new MockStateStore();
|
|
175
|
-
* const sdk = new ATProtoSDK({
|
|
176
|
-
* ...config,
|
|
177
|
-
* storage: { stateStore },
|
|
178
|
-
* });
|
|
179
|
-
*
|
|
180
|
-
* // After authorize()
|
|
181
|
-
* expect(stateStore.setCalls).toHaveLength(1);
|
|
182
|
-
*
|
|
183
|
-
* // After callback()
|
|
184
|
-
* expect(stateStore.getCalls).toHaveLength(1);
|
|
185
|
-
* expect(stateStore.delCalls).toHaveLength(1);
|
|
186
|
-
* ```
|
|
187
|
-
*
|
|
188
|
-
* @example Testing invalid state
|
|
189
|
-
* ```typescript
|
|
190
|
-
* const stateStore = new MockStateStore();
|
|
191
|
-
* // Don't pre-populate - state will be missing
|
|
192
|
-
*
|
|
193
|
-
* // This should fail because state doesn't exist
|
|
194
|
-
* await expect(sdk.callback(params)).rejects.toThrow();
|
|
195
|
-
*
|
|
196
|
-
* // Verify the lookup was attempted
|
|
197
|
-
* expect(stateStore.getCalls).toContain(stateKey);
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
export class MockStateStore implements StateStore {
|
|
201
|
-
/**
|
|
202
|
-
* Internal storage for OAuth state.
|
|
203
|
-
* @internal
|
|
204
|
-
*/
|
|
205
|
-
private store = new Map<string, NodeSavedState>();
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Record of all `get()` calls made to this store.
|
|
209
|
-
*
|
|
210
|
-
* Each entry is the state key that was requested.
|
|
211
|
-
*/
|
|
212
|
-
public getCalls: string[] = [];
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Record of all `set()` calls made to this store.
|
|
216
|
-
*
|
|
217
|
-
* Each entry contains the key and state that was stored.
|
|
218
|
-
*/
|
|
219
|
-
public setCalls: Array<{ key: string; state: NodeSavedState }> = [];
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Record of all `del()` calls made to this store.
|
|
223
|
-
*
|
|
224
|
-
* Each entry is the state key that was deleted.
|
|
225
|
-
*/
|
|
226
|
-
public delCalls: string[] = [];
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Retrieves OAuth state by key.
|
|
230
|
-
*
|
|
231
|
-
* Records the call in `getCalls`.
|
|
232
|
-
*
|
|
233
|
-
* @param key - The state key to look up
|
|
234
|
-
* @returns The stored state or undefined
|
|
235
|
-
*/
|
|
236
|
-
async get(key: string): Promise<NodeSavedState | undefined> {
|
|
237
|
-
this.getCalls.push(key);
|
|
238
|
-
return this.store.get(key);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Stores OAuth state.
|
|
243
|
-
*
|
|
244
|
-
* Records the call in `setCalls`.
|
|
245
|
-
*
|
|
246
|
-
* @param key - The state key to store under
|
|
247
|
-
* @param state - The OAuth state data to store
|
|
248
|
-
*/
|
|
249
|
-
async set(key: string, state: NodeSavedState): Promise<void> {
|
|
250
|
-
this.setCalls.push({ key, state });
|
|
251
|
-
this.store.set(key, state);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Deletes OAuth state.
|
|
256
|
-
*
|
|
257
|
-
* Records the call in `delCalls`.
|
|
258
|
-
*
|
|
259
|
-
* @param key - The state key to delete
|
|
260
|
-
*/
|
|
261
|
-
async del(key: string): Promise<void> {
|
|
262
|
-
this.delCalls.push(key);
|
|
263
|
-
this.store.delete(key);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Resets the store to initial state.
|
|
268
|
-
*
|
|
269
|
-
* Clears all stored state and all recorded calls.
|
|
270
|
-
* Call this in `beforeEach` or `afterEach` to ensure test isolation.
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* ```typescript
|
|
274
|
-
* beforeEach(() => {
|
|
275
|
-
* stateStore.reset();
|
|
276
|
-
* });
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
reset(): void {
|
|
280
|
-
this.store.clear();
|
|
281
|
-
this.getCalls = [];
|
|
282
|
-
this.setCalls = [];
|
|
283
|
-
this.delCalls = [];
|
|
284
|
-
}
|
|
285
|
-
}
|
package/src/testing.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Testing entrypoint - Test utilities and mocks
|
|
3
|
-
*
|
|
4
|
-
* This module provides utilities for testing applications built with the Hypercerts SDK.
|
|
5
|
-
* Includes mock factories for creating test data and mock store implementations
|
|
6
|
-
* with call tracking for assertions.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* These utilities are designed for use in unit and integration tests.
|
|
10
|
-
* They should NOT be used in production code.
|
|
11
|
-
*
|
|
12
|
-
* The mock stores track all method calls, making it easy to verify
|
|
13
|
-
* that your code interacts with storage correctly.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* // Basic test setup
|
|
18
|
-
* import {
|
|
19
|
-
* createMockSession,
|
|
20
|
-
* createTestConfig,
|
|
21
|
-
* MockSessionStore,
|
|
22
|
-
* MockStateStore
|
|
23
|
-
* } from "@hypercerts-org/sdk/testing";
|
|
24
|
-
* import { HypercertsSDK } from "@hypercerts-org/sdk";
|
|
25
|
-
*
|
|
26
|
-
* describe("MyComponent", () => {
|
|
27
|
-
* let sdk: HypercertsSDK;
|
|
28
|
-
* let sessionStore: MockSessionStore;
|
|
29
|
-
*
|
|
30
|
-
* beforeEach(() => {
|
|
31
|
-
* sessionStore = new MockSessionStore();
|
|
32
|
-
* sdk = new HypercertsSDK(createTestConfig({
|
|
33
|
-
* sessionStore,
|
|
34
|
-
* stateStore: new MockStateStore(),
|
|
35
|
-
* }));
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* it("should store session after login", async () => {
|
|
39
|
-
* // ... perform login flow
|
|
40
|
-
* expect(sessionStore.setCalls).toHaveLength(1);
|
|
41
|
-
* });
|
|
42
|
-
* });
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // Creating mock data for tests
|
|
48
|
-
* import { createMockSession } from "@hypercerts-org/sdk/testing";
|
|
49
|
-
*
|
|
50
|
-
* const session = createMockSession({
|
|
51
|
-
* did: "did:plc:testuser123",
|
|
52
|
-
* handle: "testuser.bsky.social",
|
|
53
|
-
* });
|
|
54
|
-
*
|
|
55
|
-
* // Session has all required fields populated with test values
|
|
56
|
-
* expect(session.did).toBe("did:plc:testuser123");
|
|
57
|
-
* expect(session.accessToken).toBeDefined();
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* @packageDocumentation
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
export { createMockSession, createTestConfig } from "./testing/mocks.js";
|
|
64
|
-
export { MockSessionStore, MockStateStore } from "./testing/stores.js";
|
package/src/types.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Types entrypoint - All TypeScript types and interfaces.
|
|
3
|
-
*
|
|
4
|
-
* This sub-entrypoint exports only TypeScript types and Zod schemas,
|
|
5
|
-
* with no runtime code. Use this for type-only imports to reduce
|
|
6
|
-
* bundle size when you only need types.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* Import from `@hypercerts-org/sdk/types` when you only need types:
|
|
10
|
-
*
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import type {
|
|
13
|
-
* HypercertClaim,
|
|
14
|
-
* Session,
|
|
15
|
-
* CreateHypercertParams,
|
|
16
|
-
* } from "@hypercerts-org/sdk/types";
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* **Categories of exports**:
|
|
20
|
-
* - Core types (DID, Session, Config)
|
|
21
|
-
* - Entity types (Organization, Collaborator)
|
|
22
|
-
* - Repository types (CreateResult, PaginatedList)
|
|
23
|
-
* - Operation interfaces (RecordOperations, HypercertOperations)
|
|
24
|
-
* - Hypercert record types (HypercertClaim, HypercertRights, etc.)
|
|
25
|
-
* - Zod schemas for runtime validation
|
|
26
|
-
*
|
|
27
|
-
* @packageDocumentation
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
// Core types
|
|
31
|
-
export type { DID, Session } from "./core/types.js";
|
|
32
|
-
export type { ATProtoSDKConfig } from "./core/config.js";
|
|
33
|
-
export type { AuthorizeOptions } from "./core/SDK.js";
|
|
34
|
-
export type { SessionStore, StateStore, CacheInterface, LoggerInterface } from "./core/interfaces.js";
|
|
35
|
-
|
|
36
|
-
// Entity types
|
|
37
|
-
export type { Organization, Collaborator, CollaboratorPermissions } from "./core/types.js";
|
|
38
|
-
|
|
39
|
-
// Zod schemas (for runtime validation)
|
|
40
|
-
export { ATProtoSDKConfigSchema, OAuthConfigSchema, ServerConfigSchema, TimeoutConfigSchema } from "./core/config.js";
|
|
41
|
-
export { OrganizationSchema, CollaboratorSchema, CollaboratorPermissionsSchema } from "./core/types.js";
|
|
42
|
-
|
|
43
|
-
// Repository class
|
|
44
|
-
export type { ValidationResult } from "./repository/LexiconRegistry.js";
|
|
45
|
-
|
|
46
|
-
// Repository types
|
|
47
|
-
export type {
|
|
48
|
-
RepositoryOptions,
|
|
49
|
-
CreateResult,
|
|
50
|
-
UpdateResult,
|
|
51
|
-
PaginatedList,
|
|
52
|
-
ListParams,
|
|
53
|
-
RepositoryRole,
|
|
54
|
-
RepositoryAccessGrant,
|
|
55
|
-
OrganizationInfo,
|
|
56
|
-
ProgressStep,
|
|
57
|
-
} from "./repository/types.js";
|
|
58
|
-
|
|
59
|
-
// Operation interfaces
|
|
60
|
-
export type {
|
|
61
|
-
RecordOperations,
|
|
62
|
-
BlobOperations,
|
|
63
|
-
ProfileOperations,
|
|
64
|
-
HypercertOperations,
|
|
65
|
-
HypercertEvents,
|
|
66
|
-
CollaboratorOperations,
|
|
67
|
-
OrganizationOperations,
|
|
68
|
-
CreateHypercertParams,
|
|
69
|
-
CreateHypercertResult,
|
|
70
|
-
} from "./repository/interfaces.js";
|
|
71
|
-
|
|
72
|
-
// Hypercert types
|
|
73
|
-
export type {
|
|
74
|
-
HypercertClaim,
|
|
75
|
-
HypercertRights,
|
|
76
|
-
HypercertLocation,
|
|
77
|
-
HypercertContribution,
|
|
78
|
-
HypercertMeasurement,
|
|
79
|
-
HypercertEvaluation,
|
|
80
|
-
HypercertCollection,
|
|
81
|
-
HypercertCollectionClaimItem,
|
|
82
|
-
HypercertEvidence,
|
|
83
|
-
HypercertImage,
|
|
84
|
-
BlobRef,
|
|
85
|
-
HypercertWithMetadata,
|
|
86
|
-
} from "./services/hypercerts/types.js";
|