rlz-engine 1.0.35 → 1.0.37

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,5 +1,5 @@
1
1
  import ts, { NewLineKind, ScriptKind, ScriptTarget } from 'typescript';
2
- import { createTypeAlias, zodToTs } from 'zod-to-ts';
2
+ import { zodToTs } from 'zod-to-ts';
3
3
  const F = ts.factory;
4
4
  export function generateClient(fileName, ...rpcBuilders) {
5
5
  const sourceFile = ts.createSourceFile(fileName, '', ScriptTarget.Latest, false, ScriptKind.TS);
@@ -44,11 +44,11 @@ function generateTypes(rpcName, e, p) {
44
44
  const resp = [];
45
45
  const bodyTypeName = createBodyTypeName(rpcName, e);
46
46
  const bodyType = zodToTs(e.bodySchema, bodyTypeName);
47
- const bodyTypeAlias = createTypeAlias(bodyType.node, bodyTypeName);
47
+ const bodyTypeAlias = F.createTypeAliasDeclaration([F.createToken(ts.SyntaxKind.ExportKeyword)], F.createIdentifier(bodyTypeName), undefined, bodyType.node);
48
48
  resp.push(p(bodyTypeAlias));
49
49
  const respTypeName = createRespTypeName(rpcName, e);
50
50
  const respType = zodToTs(e.respSchema, respTypeName);
51
- const respTypeAlias = createTypeAlias(respType.node, respTypeName);
51
+ const respTypeAlias = F.createTypeAliasDeclaration([F.createToken(ts.SyntaxKind.ExportKeyword)], F.createIdentifier(respTypeName), undefined, respType.node);
52
52
  resp.push(p(respTypeAlias));
53
53
  return resp;
54
54
  }
@@ -18,7 +18,7 @@ interface RpcEndpointAnon<BodyT extends object = object, RespT extends object =
18
18
  }
19
19
  interface RpcEndpointAuth<BodyT extends object = object, RespT extends object = object, OptsT = never, UserT = never> extends RpcEndpointCommon<BodyT, RespT> {
20
20
  readonly anonimous?: false;
21
- readonly auth: (userId: string, password: string) => UserT | Promise<UserT>;
21
+ readonly auth: (userId: string, password: string, opts: OptsT) => UserT | Promise<UserT>;
22
22
  readonly action: (user: UserT, body: {
23
23
  [k in keyof BodyT]: BodyT[k];
24
24
  }, opts: OptsT) => {
@@ -9,7 +9,7 @@ function makeReg(pluginName, endpoint) {
9
9
  bodySchema: endpoint.bodySchema,
10
10
  respSchema: endpoint.respSchema,
11
11
  reg(app, opts) {
12
- app.post(`/rpc/${pluginName}/${this.name}/v${this.v}`, {
12
+ app.post(`/rpc/${pluginName}_${this.name}_v${this.v}`, {
13
13
  schema: {
14
14
  body: zodToJsonSchema(this.bodySchema),
15
15
  response: {
@@ -28,7 +28,7 @@ function makeReg(pluginName, endpoint) {
28
28
  throw httpErrors.forbidden();
29
29
  }
30
30
  const [userId, password] = authHeader.split(':');
31
- const user = await endpoint.auth(userId, password);
31
+ const user = await endpoint.auth(userId, password, opts);
32
32
  const body = req.body;
33
33
  const respBody = await endpoint.action(user, body, opts);
34
34
  resp.send(respBody);
@@ -29,7 +29,7 @@ export class NotFound extends HttpError {
29
29
  }
30
30
  function url(rpcName, callName, version) {
31
31
  const domain = getFrontConfig().apiDomain;
32
- return `${domain}rpc/${rpcName}/${callName}/v${version}`;
32
+ return `${domain}rpc/${rpcName}_${callName}_v${version}`;
33
33
  }
34
34
  const GZIP_THRESHOLD = 16 * 1024;
35
35
  async function prepareBody(request) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlz-engine",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Deps and tools for my style of development",
5
5
  "scripts": {
6
6
  "build": "tsc",