@pluv/io 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
 
2
- > @pluv/io@3.1.0 build /home/runner/work/pluv/pluv/packages/io
2
+ > @pluv/io@3.1.1 build /home/runner/work/pluv/pluv/packages/io
3
3
  > pnpm run version && tsup src/index.ts --format esm,cjs --dts
4
4
 
5
5
 
6
- > @pluv/io@3.1.0 version /home/runner/work/pluv/pluv/packages/io
6
+ > @pluv/io@3.1.1 version /home/runner/work/pluv/pluv/packages/io
7
7
  > genversion ./src/version.generated.ts --esm
8
8
 
9
9
  CLI Building entry: src/index.ts
@@ -12,11 +12,11 @@
12
12
  CLI Target: es6
13
13
  ESM Build start
14
14
  CJS Build start
15
- ESM dist/index.mjs 52.48 KB
16
- ESM ⚡️ Build success in 177ms
17
- CJS dist/index.js 54.65 KB
18
- CJS ⚡️ Build success in 177ms
15
+ ESM dist/index.mjs 52.51 KB
16
+ ESM ⚡️ Build success in 116ms
17
+ CJS dist/index.js 54.68 KB
18
+ CJS ⚡️ Build success in 119ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 4363ms
21
- DTS dist/index.d.mts 33.31 KB
22
- DTS dist/index.d.ts 33.31 KB
20
+ DTS ⚡️ Build success in 4316ms
21
+ DTS dist/index.d.mts 33.94 KB
22
+ DTS dist/index.d.ts 33.94 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @pluv/io
2
2
 
3
+ ## 3.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7b719bf: Fixed `PluvIO.server` not requiring input parameters (i.e. was optional) when `createIO` specified `crdt`.
8
+ - @pluv/crdt@3.1.1
9
+ - @pluv/types@3.1.1
10
+
3
11
  ## 3.1.0
4
12
 
5
13
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbstractCrdtDocFactory, CrdtLibraryType as CrdtLibraryType$1, NoopCrdtDocFactory } from '@pluv/crdt';
2
2
  export { CrdtLibraryType } from '@pluv/crdt';
3
- import { JsonObject, IOAuthorize, InferIOAuthorizeUser, MaybePromise, IOEventMessage, EventRecord, ProcedureLike, InputZodLike, IORouterLike, BaseUser, UndefinedProps, CrdtDocLike, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, CrdtLibraryType, InferIOInput, InferIOAuthorize } from '@pluv/types';
3
+ import { JsonObject, IOAuthorize, InferIOAuthorizeUser, MaybePromise, IOEventMessage, EventRecord, ProcedureLike, InputZodLike, IORouterLike, BaseUser, UndefinedProps, CrdtDocLike, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, CrdtLibraryType, InferIOInput, InferIOAuthorize, HasRequiredProperty } from '@pluv/types';
4
4
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
5
5
 
6
6
  declare abstract class AbstractPersistence {
@@ -494,9 +494,10 @@ type ResolvedServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlat
494
494
  } : {
495
495
  getInitialStorage: GetInitialStorageFn<TContext>;
496
496
  });
497
- type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
497
+ type BaseServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
498
498
  [P in keyof ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents> as ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P] extends undefined ? never : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P];
499
499
  };
500
+ type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = HasRequiredProperty<BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>> extends true ? [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>] : [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>?];
500
501
  declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<any>> {
501
502
  readonly version: string;
502
503
  private readonly _authorize;
@@ -510,7 +511,7 @@ declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
510
511
  createToken(params: JWTEncodeParams<InferIOAuthorizeUser<TAuthorize>, TPlatform>): Promise<string>;
511
512
  mergeRouters<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
512
513
  router<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>>(events: TEvents): PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
513
- server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}>(config?: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>): PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents>;
514
+ server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}>(...config: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>): PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents>;
514
515
  private _getIOAuthorize;
515
516
  }
516
517
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbstractCrdtDocFactory, CrdtLibraryType as CrdtLibraryType$1, NoopCrdtDocFactory } from '@pluv/crdt';
2
2
  export { CrdtLibraryType } from '@pluv/crdt';
3
- import { JsonObject, IOAuthorize, InferIOAuthorizeUser, MaybePromise, IOEventMessage, EventRecord, ProcedureLike, InputZodLike, IORouterLike, BaseUser, UndefinedProps, CrdtDocLike, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, CrdtLibraryType, InferIOInput, InferIOAuthorize } from '@pluv/types';
3
+ import { JsonObject, IOAuthorize, InferIOAuthorizeUser, MaybePromise, IOEventMessage, EventRecord, ProcedureLike, InputZodLike, IORouterLike, BaseUser, UndefinedProps, CrdtDocLike, Id, InferEventMessage, InferEventsOutput, Maybe, IOLike, InferIOOutput, CrdtLibraryType, InferIOInput, InferIOAuthorize, HasRequiredProperty } from '@pluv/types';
4
4
  export { BaseUser, EventMessage, EventRecord, IOEventMessage } from '@pluv/types';
5
5
 
6
6
  declare abstract class AbstractPersistence {
@@ -494,9 +494,10 @@ type ResolvedServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlat
494
494
  } : {
495
495
  getInitialStorage: GetInitialStorageFn<TContext>;
496
496
  });
497
- type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
497
+ type BaseServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = {
498
498
  [P in keyof ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents> as ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P] extends undefined ? never : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P];
499
499
  };
500
+ type ServerConfig<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<NoopCrdtDocFactory>, TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}> = HasRequiredProperty<BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>> extends true ? [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>] : [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>?];
500
501
  declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>, TAuthorize extends PluvIOAuthorize<TPlatform, any, InferInitContextType<TPlatform>> | null = any, TContext extends Record<string, any> = {}, TCrdt extends CrdtLibraryType$1<any> = CrdtLibraryType$1<any>> {
501
502
  readonly version: string;
502
503
  private readonly _authorize;
@@ -510,7 +511,7 @@ declare class PluvIO<TPlatform extends AbstractPlatform<any> = AbstractPlatform<
510
511
  createToken(params: JWTEncodeParams<InferIOAuthorizeUser<TAuthorize>, TPlatform>): Promise<string>;
511
512
  mergeRouters<TRouters extends PluvRouter<TPlatform, TAuthorize, TContext, any>[]>(...routers: TRouters): MergedRouter<TRouters>;
512
513
  router<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext>>(events: TEvents): PluvRouter<TPlatform, TAuthorize, TContext, TEvents>;
513
- server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}>(config?: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>): PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents>;
514
+ server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}>(...config: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>): PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents>;
514
515
  private _getIOAuthorize;
515
516
  }
516
517
 
package/dist/index.js CHANGED
@@ -1170,7 +1170,7 @@ var IORoom = class {
1170
1170
  };
1171
1171
 
1172
1172
  // src/version.generated.ts
1173
- var version = "3.1.0";
1173
+ var version = "3.1.1";
1174
1174
 
1175
1175
  // src/PluvServer.ts
1176
1176
  var PluvServer = class {
@@ -1493,10 +1493,10 @@ var PluvIO = class {
1493
1493
  }
1494
1494
  return new PluvRouter(events);
1495
1495
  }
1496
- server(config = {}) {
1497
- var _a;
1498
- return new PluvServer(__spreadProps(__spreadValues({}, config), {
1499
- authorize: (_a = this._authorize) != null ? _a : void 0,
1496
+ server(...config) {
1497
+ var _a, _b;
1498
+ return new PluvServer(__spreadProps(__spreadValues({}, (_a = config[0]) != null ? _a : {}), {
1499
+ authorize: (_b = this._authorize) != null ? _b : void 0,
1500
1500
  context: this._context,
1501
1501
  crdt: this._crdt,
1502
1502
  debug: this._debug,
package/dist/index.mjs CHANGED
@@ -1128,7 +1128,7 @@ var IORoom = class {
1128
1128
  };
1129
1129
 
1130
1130
  // src/version.generated.ts
1131
- var version = "3.1.0";
1131
+ var version = "3.1.1";
1132
1132
 
1133
1133
  // src/PluvServer.ts
1134
1134
  var PluvServer = class {
@@ -1451,10 +1451,10 @@ var PluvIO = class {
1451
1451
  }
1452
1452
  return new PluvRouter(events);
1453
1453
  }
1454
- server(config = {}) {
1455
- var _a;
1456
- return new PluvServer(__spreadProps(__spreadValues({}, config), {
1457
- authorize: (_a = this._authorize) != null ? _a : void 0,
1454
+ server(...config) {
1455
+ var _a, _b;
1456
+ return new PluvServer(__spreadProps(__spreadValues({}, (_a = config[0]) != null ? _a : {}), {
1457
+ authorize: (_b = this._authorize) != null ? _b : void 0,
1458
1458
  context: this._context,
1459
1459
  crdt: this._crdt,
1460
1460
  debug: this._debug,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/io",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "@pluv/io server-side websocket manager",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -21,16 +21,16 @@
21
21
  "jose": "^5.10.0",
22
22
  "kleur": "^4.1.5",
23
23
  "wonka": "^6.3.5",
24
- "@pluv/crdt": "^3.1.0",
25
- "@pluv/types": "^3.1.0"
24
+ "@pluv/crdt": "^3.1.1",
25
+ "@pluv/types": "^3.1.1"
26
26
  },
27
27
  "devDependencies": {
28
28
  "eslint": "^9.27.0",
29
29
  "genversion": "^3.2.0",
30
30
  "tsup": "^8.5.0",
31
31
  "typescript": "^5.8.3",
32
- "@pluv/tsconfig": "^3.1.0",
33
- "eslint-config-pluv": "^3.1.0"
32
+ "@pluv/tsconfig": "^3.1.1",
33
+ "eslint-config-pluv": "^3.1.1"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "pnpm run version && tsup src/index.ts --format esm,cjs --dts",
package/src/PluvIO.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { AbstractCrdtDocFactory, CrdtLibraryType, NoopCrdtDocFactory } from "@pluv/crdt";
2
2
  import { noop } from "@pluv/crdt";
3
- import type { BaseUser, IOAuthorize, InferIOAuthorizeUser } from "@pluv/types";
3
+ import type { BaseUser, HasRequiredProperty, IOAuthorize, InferIOAuthorizeUser } from "@pluv/types";
4
4
  import type { AbstractPlatform, InferInitContextType } from "./AbstractPlatform";
5
5
  import type { WebSocketRegisterConfig } from "./IORoom";
6
6
  import { PluvProcedure } from "./PluvProcedure";
@@ -56,7 +56,7 @@ type ResolvedServerConfig<
56
56
  ? { getInitialStorage?: "[ERROR]: Must specify crdt to use getInitialStorage" }
57
57
  : { getInitialStorage: GetInitialStorageFn<TContext> });
58
58
 
59
- export type ServerConfig<
59
+ export type BaseServerConfig<
60
60
  TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>,
61
61
  TAuthorize extends PluvIOAuthorize<
62
62
  TPlatform,
@@ -78,6 +78,23 @@ export type ServerConfig<
78
78
  : P]: ResolvedServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>[P];
79
79
  };
80
80
 
81
+ export type ServerConfig<
82
+ TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>,
83
+ TAuthorize extends PluvIOAuthorize<
84
+ TPlatform,
85
+ any,
86
+ InferInitContextType<TPlatform>
87
+ > | null = any,
88
+ TContext extends Record<string, any> = {},
89
+ TCrdt extends CrdtLibraryType<any> = CrdtLibraryType<NoopCrdtDocFactory>,
90
+ TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {},
91
+ > =
92
+ HasRequiredProperty<
93
+ BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>
94
+ > extends true
95
+ ? [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>]
96
+ : [BaseServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>?];
97
+
81
98
  export class PluvIO<
82
99
  TPlatform extends AbstractPlatform<any> = AbstractPlatform<any>,
83
100
  TAuthorize extends PluvIOAuthorize<
@@ -187,24 +204,24 @@ export class PluvIO<
187
204
  }
188
205
 
189
206
  public server<TEvents extends PluvRouterEventConfig<TPlatform, TAuthorize, TContext> = {}>(
190
- config: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents> = {} as ServerConfig<
191
- TPlatform,
192
- TAuthorize,
193
- TContext,
194
- TCrdt,
195
- TEvents
196
- >,
207
+ ...config: ServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>
197
208
  ): PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents> {
198
209
  return new PluvServer<TPlatform, TAuthorize, TContext, TCrdt, TEvents>({
199
- ...config,
210
+ ...((config[0] ?? {}) as PluvServerConfig<
211
+ TPlatform,
212
+ TAuthorize,
213
+ TContext,
214
+ TCrdt,
215
+ TEvents
216
+ >),
200
217
  authorize: this._authorize ?? undefined,
201
218
  context: this._context,
202
219
  crdt: this._crdt,
203
220
  debug: this._debug,
204
- io: this as PluvIO<TPlatform, TAuthorize, TContext>,
221
+ io: this as PluvIO<TPlatform, TAuthorize, TContext, TCrdt>,
205
222
  limits: this._limits,
206
223
  platform: this._platform,
207
- } as PluvServerConfig<TPlatform, TAuthorize, TContext, TCrdt, TEvents>);
224
+ });
208
225
  }
209
226
 
210
227
  private _getIOAuthorize(
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '3.1.0'
2
+ export const version = '3.1.1'