@travetto/web-rpc 6.0.3 → 7.0.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/web-rpc",
3
- "version": "6.0.3",
3
+ "version": "7.0.0-rc.0",
4
4
  "description": "RPC support for a Web Application",
5
5
  "keywords": [
6
6
  "web",
@@ -26,9 +26,9 @@
26
26
  "directory": "module/web-rpc"
27
27
  },
28
28
  "dependencies": {
29
- "@travetto/config": "^6.0.1",
30
- "@travetto/schema": "^6.0.1",
31
- "@travetto/web": "^6.0.3"
29
+ "@travetto/config": "^7.0.0-rc.0",
30
+ "@travetto/schema": "^7.0.0-rc.0",
31
+ "@travetto/web": "^7.0.0-rc.0"
32
32
  },
33
33
  "travetto": {
34
34
  "displayName": "Web RPC Support"
package/src/controller.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Inject } from '@travetto/di';
2
2
  import { Any, AppError, Util } from '@travetto/runtime';
3
+ import { IsPrivate } from '@travetto/schema';
3
4
  import {
4
- HeaderParam, Controller, Undocumented, ExcludeInterceptors, ControllerRegistry,
5
+ HeaderParam, Controller, ExcludeInterceptors, ControllerRegistryIndex,
5
6
  WebAsyncContext, Body, EndpointUtil, BodyInterceptor, Post, WebCommonUtil,
6
7
  RespondInterceptor, DecompressInterceptor, Get
7
8
  } from '@travetto/web';
@@ -13,7 +14,7 @@ import {
13
14
  val instanceof RespondInterceptor ||
14
15
  val.category === 'global'
15
16
  ))
16
- @Undocumented()
17
+ @IsPrivate()
17
18
  export class WebRpcController {
18
19
 
19
20
  @Inject()
@@ -32,7 +33,7 @@ export class WebRpcController {
32
33
  */
33
34
  @Post('/:target')
34
35
  async onRequest(target: string, @HeaderParam('X-TRV-RPC-INPUTS') paramInput?: string, @Body() body?: Any): Promise<unknown> {
35
- const endpoint = ControllerRegistry.getEndpointById(target);
36
+ const endpoint = ControllerRegistryIndex.getEndpointConfigById(target);
36
37
 
37
38
  if (!endpoint || !endpoint.filter) {
38
39
  throw new AppError('Unknown endpoint', { category: 'notfound' });
@@ -48,7 +49,7 @@ export class WebRpcController {
48
49
  } else if (Array.isArray(body)) { // Params passed via body
49
50
  params = body;
50
51
 
51
- const bodyParamIdx = endpoint.params.findIndex((x) => x.location === 'body');
52
+ const bodyParamIdx = endpoint.parameters.findIndex((x) => x.location === 'body');
52
53
  if (bodyParamIdx >= 0) { // Re-assign body
53
54
  request.body = params[bodyParamIdx];
54
55
  }
@@ -58,7 +59,7 @@ export class WebRpcController {
58
59
  params = [];
59
60
  }
60
61
 
61
- const final = endpoint.params.map((x, i) => (x.location === 'body' && paramInput) ? EndpointUtil.MissingParamSymbol : params[i]);
62
+ const final = endpoint.parameters.map((x, i) => (x.location === 'body' && paramInput) ? EndpointUtil.MissingParamSymbol : params[i]);
62
63
  WebCommonUtil.setRequestParams(request, final);
63
64
 
64
65
  // Dispatch
package/src/service.ts CHANGED
@@ -2,14 +2,16 @@ import path from 'node:path';
2
2
  import fs from 'node:fs/promises';
3
3
 
4
4
  import { Inject, Injectable } from '@travetto/di';
5
- import { ControllerRegistry } from '@travetto/web';
5
+ import { ControllerRegistryIndex } from '@travetto/web';
6
6
  import { Runtime, RuntimeIndex } from '@travetto/runtime';
7
7
  import { ManifestModuleUtil } from '@travetto/manifest';
8
+ import { Registry } from '@travetto/registry';
9
+ import { SchemaRegistryIndex } from '@travetto/schema';
8
10
 
9
11
  import { clientFactory } from '../support/client/rpc.ts';
10
12
  import { WebRpcClient, WebRpcConfig } from './config.ts';
11
13
 
12
- @Injectable({ autoCreate: !Runtime.production })
14
+ @Injectable({ autoInject: !Runtime.production })
13
15
  export class WebRpcClientGeneratorService {
14
16
 
15
17
  @Inject()
@@ -21,16 +23,16 @@ export class WebRpcClientGeneratorService {
21
23
  if (!this.config.clients.length || !Runtime.dynamic) {
22
24
  return;
23
25
  }
24
- ControllerRegistry.on(() => this.render());
26
+ Registry.onClassChange(() => this.render(), ControllerRegistryIndex);
25
27
  }
26
28
 
27
29
  async #getClasses(relativeTo: string): Promise<{ name: string, import: string }[]> {
28
- return ControllerRegistry.getClasses()
30
+ return ControllerRegistryIndex.getClasses()
29
31
  .filter(x => {
30
32
  const entry = RuntimeIndex.getEntry(Runtime.getSourceFile(x));
31
33
  return entry && entry.role === 'std';
32
34
  })
33
- .filter(x => ControllerRegistry.get(x).documented !== false)
35
+ .filter(x => SchemaRegistryIndex.getConfig(x).private !== true)
34
36
  .map(x => {
35
37
  const imp = ManifestModuleUtil.withOutputExtension(Runtime.getImport(x));
36
38
  const base = Runtime.workspaceRelative(RuntimeIndex.manifest.build.typesFolder);
@@ -2,8 +2,8 @@ import path from 'node:path';
2
2
 
3
3
  import { Env } from '@travetto/runtime';
4
4
  import { CliCommand, CliCommandShape, CliValidationResultError } from '@travetto/cli';
5
- import { DependencyRegistry } from '@travetto/di';
6
- import { RootRegistry } from '@travetto/registry';
5
+ import { DependencyRegistryIndex } from '@travetto/di';
6
+ import { Registry } from '@travetto/registry';
7
7
  import { Ignore } from '@travetto/schema';
8
8
 
9
9
  import type { WebRpcClient } from '../src/config.ts';
@@ -24,7 +24,7 @@ export class CliWebRpcCommand implements CliCommandShape {
24
24
  }
25
25
 
26
26
  get #service(): Promise<WebRpcClientGeneratorService> {
27
- return RootRegistry.init().then(() => DependencyRegistry.getInstance(WebRpcClientGeneratorService));
27
+ return Registry.init().then(() => DependencyRegistryIndex.getInstance(WebRpcClientGeneratorService));
28
28
  }
29
29
 
30
30
  async main(type: WebRpcClient['type'] | 'config', output?: string): Promise<void> {