Skip to content

Commit 437787d

Browse files
authored
Merge pull request #4 from windingtree/develop
Fix module exports
2 parents 8a22bcf + 9bbf7f0 commit 437787d

File tree

10 files changed

+2548
-825
lines changed

10 files changed

+2548
-825
lines changed

examples/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"react-dom": "^18.2.0",
1919
"typescript": "^4.9.3",
2020
"vite": "^4.1.0",
21-
"zod": "^3.21.4"
21+
"zod": "^3.21.4",
22+
"@windingtree/sdk": "^0.1.0-beta.3"
2223
},
2324
"eslintConfig": {
2425
"extends": [

examples/client/src/App.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState, useEffect, useRef } from 'react';
12
import {
23
RequestQuerySchema,
34
RequestQuery,
@@ -6,11 +7,11 @@ import {
67
contractConfig,
78
serverAddress,
89
} from '../../shared/types.js';
9-
import { useState, useEffect, useRef } from 'react';
10-
import { createClient, Client, ClientOptions } from '../../../src/index.js';
11-
import { localStorage } from '../../../src/storage/index.js';
1210
import { isExpired } from '../../../src/utils/time.js';
13-
import { RequestRecord } from '../../../src/client/requestManager.js';
11+
import { RequestRecord } from '../../../src/client/requestsRegistry.js';
12+
import { createClient, Client } from '../../../src/client/index.js';
13+
import { ClientOptions, storage } from '@windingtree/sdk';
14+
// import { isExpired } from '@windingtree/sdk/utils';
1415

1516
/** Default request expiration time */
1617
const defaultExpire = '30s';
@@ -165,7 +166,7 @@ export const App = () => {
165166
offerOptionsSchema: OfferOptionsSchema,
166167
contractConfig,
167168
serverAddress,
168-
storageInitializer: localStorage.createInitializer({
169+
storageInitializer: storage.localStorage.createInitializer({
169170
session: true,
170171
}),
171172
requestRegistryPrefix: 'requestsRegistry',

examples/client/yarn.lock

Lines changed: 2086 additions & 390 deletions
Large diffs are not rendered by default.

examples/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createServer, ServerOptions } from '../../src/index.js';
22
import { memoryStorage } from '../../src/storage/index.js';
3-
import peerKey from '../../test/peerKey.json';
3+
import peerKey from '../../test/peerKey.json' assert { type: 'json' };
44
import { createLogger } from '../../src/utils/logger.js';
55

66
const logger = createLogger('ServerMain');

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@
1313
"windingtree",
1414
"market",
1515
"protocol",
16-
"p2p",
1716
"libp2p",
1817
"sdk",
19-
"typescript"
18+
"typescript",
19+
"p2p",
20+
"peer",
21+
"peer-to-peer",
22+
"network"
2023
],
2124
"license": "MIT",
2225
"type": "module",
2326
"exports": {
2427
".": {
25-
"import": {
26-
"default": "./lib/esm/index.mjs",
27-
"types": "./lib/esm/types/index.d.ts",
28-
"utils": "./lib/esm/utils"
29-
},
30-
"require": {
31-
"default": "./lib/cjs/index.js",
32-
"types": "./lib/cjs/types/index.d.ts",
33-
"utils": "./lib/cjs/utils"
34-
}
28+
"types": "./lib/cjs/types/index.d.ts",
29+
"import": "./lib/esm/index.mjs",
30+
"require": "./lib/cjs/index.js"
31+
},
32+
"./utils": {
33+
"types": "./lib/cjs/types/utils/index.d.ts",
34+
"import": "./lib/esm/utils/index.js",
35+
"require": "./lib/cjs/utils/index.js"
3536
}
3637
},
3738
"types": "./lib/cjs/types/index.d.ts",

src/client/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
RequestData,
2121
} from '../shared/messages.js';
2222
import { ClientOptions, createClientOptionsSchema } from '../shared/options.js';
23-
import { RequestRecord, RequestsRegistry } from './requestManager.js';
23+
import { RequestRecord, RequestsRegistry } from './requestsRegistry.js';
2424
import { decodeText } from '../utils/text.js';
2525
import { ContractConfig } from '../utils/contract.js';
2626
import { StorageInitializer } from '../storage/index.js';
@@ -617,3 +617,8 @@ export const createClient = <
617617
): Client<CustomRequestQuery, CustomOfferOptions> => {
618618
return new Client(options);
619619
};
620+
621+
/**
622+
* Requests registry exports
623+
*/
624+
export * from './requestsRegistry.js';

src/client/requestManager.ts renamed to src/client/requestsRegistry.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const RequestRegistryPrefixSchema = z.string().default('requestsRegistry'
5454
* @template CustomRequestQuery
5555
* @template CustomOfferOptions
5656
*/
57-
const createRequestManagerOptionsSchema = <
57+
const createRequestsRegistryOptionsSchema = <
5858
CustomRequestQuery extends GenericQuery,
5959
CustomOfferOptions extends GenericOfferOptions,
6060
>() =>
@@ -71,11 +71,11 @@ const createRequestManagerOptionsSchema = <
7171
/**
7272
* Request manager initialization options type
7373
*/
74-
export type RequestManagerOptions<
74+
export type RequestsRegistryOptions<
7575
CustomRequestQuery extends GenericQuery,
7676
CustomOfferOptions extends GenericOfferOptions,
7777
> = z.infer<
78-
ReturnType<typeof createRequestManagerOptionsSchema<CustomRequestQuery, CustomOfferOptions>>
78+
ReturnType<typeof createRequestsRegistryOptionsSchema<CustomRequestQuery, CustomOfferOptions>>
7979
>;
8080

8181
/**
@@ -198,7 +198,7 @@ export interface RequestEvents<
198198
}
199199

200200
/**
201-
* Requests manager
201+
* Requests registry
202202
*
203203
* @class RequestsRegistry
204204
* @extends {EventEmitter<RequestEvents<CustomRequestQuery, CustomOfferOptions>>}
@@ -218,13 +218,13 @@ export class RequestsRegistry<
218218
/**
219219
* Creates an instance of RequestsRegistry.
220220
*
221-
* @param {RequestManagerOptions<CustomRequestQuery, CustomOfferOptions>} options
221+
* @param {RequestsRegistryOptions<CustomRequestQuery, CustomOfferOptions>} options
222222
* @memberof RequestsRegistry
223223
*/
224-
constructor(options: RequestManagerOptions<CustomRequestQuery, CustomOfferOptions>) {
224+
constructor(options: RequestsRegistryOptions<CustomRequestQuery, CustomOfferOptions>) {
225225
super();
226226

227-
const { client, storage, prefix } = createRequestManagerOptionsSchema<
227+
const { client, storage, prefix } = createRequestsRegistryOptionsSchema<
228228
CustomRequestQuery,
229229
CustomOfferOptions
230230
>().parse(options);

src/node/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,8 @@ export const createNode = <
374374
): Node<CustomRequestQuery, CustomOfferOptions> => {
375375
return new Node<CustomRequestQuery, CustomOfferOptions>(options);
376376
};
377+
378+
/**
379+
* Request manager exports
380+
*/
381+
export * from './requestManager.js';

src/shared/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ContractConfigSchema } from '../utils/contract.js';
55
import { parseSeconds } from '../utils/time.js';
66
import { noncePeriod } from '../constants.js';
77
import { StorageInitializerSchema } from '../storage/abstract.js';
8-
import { RequestRegistryPrefixSchema } from '../client/requestManager.js';
8+
import { RequestRegistryPrefixSchema } from '../client/requestsRegistry.js';
99

1010
export const createQuerySchemaOptionSchema = <CustomRequestQuery extends GenericQuery>() =>
1111
z.object({

0 commit comments

Comments
 (0)