@lyxa.ai/core 1.0.166-test → 1.0.166-test2
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/dist/libraries/trpc/context.d.ts +11 -12
- package/dist/libraries/trpc/context.js +4 -2
- package/dist/libraries/trpc/context.js.map +1 -1
- package/dist/libraries/trpc/index.d.ts +9 -6
- package/dist/libraries/trpc/index.js.map +1 -1
- package/dist/libraries/trpc/middlewares/auth.d.ts +1 -2
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts +1 -2
- package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +1 -2
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import type { CreateWSSContextFnOptions } from '@trpc/server/adapters/ws';
|
|
|
3
3
|
import { AuthEntityType } from '../auth';
|
|
4
4
|
import jwt from 'jsonwebtoken';
|
|
5
5
|
import { TokenType } from '../auth';
|
|
6
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
6
7
|
export interface EntityContext extends jwt.JwtPayload {
|
|
7
8
|
id: string;
|
|
8
9
|
type: AuthEntityType;
|
|
@@ -15,16 +16,14 @@ export interface LyxaContextParams {
|
|
|
15
16
|
usedRefreshToken?: boolean;
|
|
16
17
|
tokenRenewed?: boolean;
|
|
17
18
|
}
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}>;
|
|
19
|
+
export interface LyxaHTTPContext extends LyxaContextParams {
|
|
20
|
+
req: IncomingMessage;
|
|
21
|
+
res: ServerResponse;
|
|
22
|
+
}
|
|
23
|
+
export interface LyxaWSContext extends LyxaContextParams {
|
|
24
|
+
req: any;
|
|
25
|
+
res: any;
|
|
26
|
+
}
|
|
27
|
+
export declare const createLyxaContext: (opts: CreateHTTPContextOptions) => Promise<LyxaHTTPContext>;
|
|
28
|
+
export declare const createLyxaWsContext: (opts: CreateWSSContextFnOptions) => Promise<LyxaWSContext>;
|
|
29
29
|
export type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;
|
|
30
|
-
export type LyxaWSContext = Awaited<ReturnType<typeof createLyxaWsContext>>;
|
|
@@ -3,23 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createLyxaWsContext = exports.createLyxaContext = void 0;
|
|
4
4
|
const createLyxaContext = async (opts) => {
|
|
5
5
|
return {
|
|
6
|
-
...opts,
|
|
7
6
|
entity: undefined,
|
|
8
7
|
requestId: undefined,
|
|
9
8
|
tokenType: undefined,
|
|
10
9
|
usedRefreshToken: false,
|
|
11
10
|
tokenRenewed: false,
|
|
11
|
+
req: opts.req,
|
|
12
|
+
res: opts.res,
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
exports.createLyxaContext = createLyxaContext;
|
|
15
16
|
const createLyxaWsContext = async (opts) => {
|
|
16
17
|
return {
|
|
17
|
-
...opts,
|
|
18
18
|
entity: undefined,
|
|
19
19
|
requestId: undefined,
|
|
20
20
|
tokenType: undefined,
|
|
21
21
|
usedRefreshToken: false,
|
|
22
22
|
tokenRenewed: false,
|
|
23
|
+
req: opts.req,
|
|
24
|
+
res: opts.res,
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
exports.createLyxaWsContext = createLyxaWsContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"/","sources":["libraries/trpc/context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"/","sources":["libraries/trpc/context.ts"],"names":[],"mappings":";;;AA+BO,MAAM,iBAAiB,GAAG,KAAK,EACrC,IAA8B,EACH,EAAE;IAC7B,OAAO;QACN,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;KACb,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,iBAAiB,qBAY5B;AAEK,MAAM,mBAAmB,GAAG,KAAK,EACvC,IAA+B,EACN,EAAE;IAC3B,OAAO;QACN,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,KAAK;QACnB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;KACb,CAAC;AACH,CAAC,CAAC;AAZW,QAAA,mBAAmB,uBAY9B","sourcesContent":["import { CreateHTTPContextOptions } from '@trpc/server/adapters/standalone';\nimport type { CreateWSSContextFnOptions } from '@trpc/server/adapters/ws';\nimport { AuthEntityType } from '../auth';\nimport jwt from 'jsonwebtoken';\nimport { TokenType } from '../auth';\nimport type { IncomingMessage, ServerResponse } from 'http';\n\nexport interface EntityContext extends jwt.JwtPayload {\n\tid: string;\n\ttype: AuthEntityType;\n\tparameters: Record<string, unknown>;\n}\n\nexport interface LyxaContextParams {\n\tentity?: EntityContext;\n\trequestId?: string;\n\ttokenType?: TokenType;\n\tusedRefreshToken?: boolean;\n\ttokenRenewed?: boolean;\n}\n\nexport interface LyxaHTTPContext extends LyxaContextParams {\n\treq: IncomingMessage;\n\tres: ServerResponse;\n}\n\nexport interface LyxaWSContext extends LyxaContextParams {\n\treq: any;\n\tres: any;\n}\n\nexport const createLyxaContext = async (\n\topts: CreateHTTPContextOptions\n): Promise<LyxaHTTPContext> => {\n\treturn {\n\t\tentity: undefined,\n\t\trequestId: undefined,\n\t\ttokenType: undefined,\n\t\tusedRefreshToken: false,\n\t\ttokenRenewed: false,\n\t\treq: opts.req,\n\t\tres: opts.res,\n\t};\n};\n\nexport const createLyxaWsContext = async (\n\topts: CreateWSSContextFnOptions\n): Promise<LyxaWSContext> => {\n\treturn {\n\t\tentity: undefined,\n\t\trequestId: undefined,\n\t\ttokenType: undefined,\n\t\tusedRefreshToken: false,\n\t\ttokenRenewed: false,\n\t\treq: opts.req,\n\t\tres: opts.res,\n\t};\n};\nexport type LyxaContext = Awaited<ReturnType<typeof createLyxaContext>>;"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const t: import("@trpc/server").TRPCRootObject<import("
|
|
1
|
+
export declare const t: import("@trpc/server").TRPCRootObject<import("./context").LyxaHTTPContext, object, {
|
|
2
2
|
errorFormatter({ shape, error }: {
|
|
3
3
|
error: import("@trpc/server").TRPCError;
|
|
4
4
|
type: import("@trpc/server").ProcedureType | "unknown";
|
|
5
5
|
path: string | undefined;
|
|
6
6
|
input: unknown;
|
|
7
|
-
ctx:
|
|
7
|
+
ctx: import("./context").LyxaHTTPContext | undefined;
|
|
8
8
|
shape: import("@trpc/server").TRPCDefaultErrorShape;
|
|
9
9
|
}): {
|
|
10
10
|
message: string;
|
|
@@ -18,7 +18,7 @@ export declare const t: import("@trpc/server").TRPCRootObject<import("@trpc/serv
|
|
|
18
18
|
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
19
19
|
};
|
|
20
20
|
}, {
|
|
21
|
-
ctx: import("
|
|
21
|
+
ctx: import("./context").LyxaHTTPContext;
|
|
22
22
|
meta: object;
|
|
23
23
|
errorShape: {
|
|
24
24
|
message: string;
|
|
@@ -33,9 +33,9 @@ export declare const t: import("@trpc/server").TRPCRootObject<import("@trpc/serv
|
|
|
33
33
|
};
|
|
34
34
|
transformer: false;
|
|
35
35
|
}>;
|
|
36
|
-
export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<import("
|
|
36
|
+
export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<import("./context").LyxaHTTPContext, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
|
|
37
37
|
export declare const createTRPCRouter: import("@trpc/server").TRPCRouterBuilder<{
|
|
38
|
-
ctx: import("
|
|
38
|
+
ctx: import("./context").LyxaHTTPContext;
|
|
39
39
|
meta: object;
|
|
40
40
|
errorShape: {
|
|
41
41
|
message: string;
|
|
@@ -51,7 +51,7 @@ export declare const createTRPCRouter: import("@trpc/server").TRPCRouterBuilder<
|
|
|
51
51
|
transformer: false;
|
|
52
52
|
}>;
|
|
53
53
|
export declare const createCallerFactory: import("@trpc/server").TRPCRouterCallerFactory<{
|
|
54
|
-
ctx: import("
|
|
54
|
+
ctx: import("./context").LyxaHTTPContext;
|
|
55
55
|
meta: object;
|
|
56
56
|
errorShape: {
|
|
57
57
|
message: string;
|
|
@@ -66,3 +66,6 @@ export declare const createCallerFactory: import("@trpc/server").TRPCRouterCalle
|
|
|
66
66
|
};
|
|
67
67
|
transformer: false;
|
|
68
68
|
}>;
|
|
69
|
+
export type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';
|
|
70
|
+
export type { AnyTRPCRouter } from '@trpc/server';
|
|
71
|
+
export type LyxaRouter = ReturnType<typeof createTRPCRouter>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/trpc/index.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC,6BAA+B;AAGlB,QAAA,CAAC,GAAG,iBAAQ,CAAC,OAAO,EAAe,CAAC,MAAM,CAAC;IACvD,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE;QAC9B,IAAI,SAAS,GAAG,IAAI,CAAC;QAErB,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,KAAK,YAAY,cAAQ,EAAE,CAAC;YACrE,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACxC,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC;QACnC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAE5D,OAAO;YACN,GAAG,KAAK;YACR,OAAO,EACN,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;gBACzC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO;gBACnD,CAAC,CAAC,KAAK,CAAC,OAAO;YACjB,IAAI,EAAE;gBACL,GAAG,KAAK,CAAC,IAAI;gBAEb,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE,SAAS;aACf;YAED,KAAK,EAAE,SAAS;SAChB,CAAC;IACH,CAAC;CACD,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,SAAC,CAAC,SAAS,CAAC;AAC9B,QAAA,gBAAgB,GAAG,SAAC,CAAC,MAAM,CAAC;AAC5B,QAAA,mBAAmB,GAAG,SAAC,CAAC,mBAAmB,CAAC","sourcesContent":["import { initTRPC } from '@trpc/server';\nimport { ZodError } from 'zod';\nimport { LyxaContext } from './context';\n\nexport const t = initTRPC.context<LyxaContext>().create({\n\terrorFormatter({ shape, error }) {\n\t\tlet zodErrors = null;\n\n\t\tif (error.code === 'BAD_REQUEST' && error.cause instanceof ZodError) {\n\t\t\tconst flattened = error.cause.flatten();\n\t\t\tzodErrors = flattened.fieldErrors;\n\t\t}\n\n\t\tconsole.log('Error:', error, shape, 'error log', zodErrors);\n\n\t\treturn {\n\t\t\t...shape,\n\t\t\tmessage:\n\t\t\t\tzodErrors && typeof zodErrors === 'object'\n\t\t\t\t\t? Object.values(zodErrors)[0]?.[0] || shape.message\n\t\t\t\t\t: shape.message,\n\t\t\tdata: {\n\t\t\t\t...shape.data,\n\n\t\t\t\tstack: undefined,\n\t\t\t\tpath: undefined,\n\t\t\t},\n\t\t\t// Prevent stack trace from being returned in the response\n\t\t\tstack: undefined,\n\t\t};\n\t},\n});\n\nexport const publicProcedure = t.procedure;\nexport const createTRPCRouter = t.router;\nexport const createCallerFactory = t.createCallerFactory;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/trpc/index.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC,6BAA+B;AAGlB,QAAA,CAAC,GAAG,iBAAQ,CAAC,OAAO,EAAe,CAAC,MAAM,CAAC;IACvD,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE;QAC9B,IAAI,SAAS,GAAG,IAAI,CAAC;QAErB,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,KAAK,YAAY,cAAQ,EAAE,CAAC;YACrE,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACxC,SAAS,GAAG,SAAS,CAAC,WAAW,CAAC;QACnC,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;QAE5D,OAAO;YACN,GAAG,KAAK;YACR,OAAO,EACN,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ;gBACzC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO;gBACnD,CAAC,CAAC,KAAK,CAAC,OAAO;YACjB,IAAI,EAAE;gBACL,GAAG,KAAK,CAAC,IAAI;gBAEb,KAAK,EAAE,SAAS;gBAChB,IAAI,EAAE,SAAS;aACf;YAED,KAAK,EAAE,SAAS;SAChB,CAAC;IACH,CAAC;CACD,CAAC,CAAC;AAEU,QAAA,eAAe,GAAG,SAAC,CAAC,SAAS,CAAC;AAC9B,QAAA,gBAAgB,GAAG,SAAC,CAAC,MAAM,CAAC;AAC5B,QAAA,mBAAmB,GAAG,SAAC,CAAC,mBAAmB,CAAC","sourcesContent":["import { initTRPC } from '@trpc/server';\nimport { ZodError } from 'zod';\nimport { LyxaContext } from './context';\n\nexport const t = initTRPC.context<LyxaContext>().create({\n\terrorFormatter({ shape, error }) {\n\t\tlet zodErrors = null;\n\n\t\tif (error.code === 'BAD_REQUEST' && error.cause instanceof ZodError) {\n\t\t\tconst flattened = error.cause.flatten();\n\t\t\tzodErrors = flattened.fieldErrors;\n\t\t}\n\n\t\tconsole.log('Error:', error, shape, 'error log', zodErrors);\n\n\t\treturn {\n\t\t\t...shape,\n\t\t\tmessage:\n\t\t\t\tzodErrors && typeof zodErrors === 'object'\n\t\t\t\t\t? Object.values(zodErrors)[0]?.[0] || shape.message\n\t\t\t\t\t: shape.message,\n\t\t\tdata: {\n\t\t\t\t...shape.data,\n\n\t\t\t\tstack: undefined,\n\t\t\t\tpath: undefined,\n\t\t\t},\n\t\t\t// Prevent stack trace from being returned in the response\n\t\t\tstack: undefined,\n\t\t};\n\t},\n});\n\nexport const publicProcedure = t.procedure;\nexport const createTRPCRouter = t.router;\nexport const createCallerFactory = t.createCallerFactory;\n\nexport type { inferRouterInputs, inferRouterOutputs } from '@trpc/server';\nexport type { AnyTRPCRouter } from '@trpc/server';\nexport type LyxaRouter = ReturnType<typeof createTRPCRouter>;"]}
|
|
@@ -4,8 +4,7 @@ interface AuthOptions {
|
|
|
4
4
|
allowRefreshToken?: boolean;
|
|
5
5
|
autoRefresh?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("
|
|
8
|
-
info: import("@trpc/server/dist/unstable-core-do-not-import.d-C6mFWtNG.cjs").TRPCRequestInfo;
|
|
7
|
+
export declare function createAuthenticatedProcedure(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
9
8
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
10
9
|
tokenType: TokenType | undefined;
|
|
11
10
|
entity: import("../context").EntityContext | undefined;
|
|
@@ -2,8 +2,7 @@ import { AuthEntityType } from '../../auth';
|
|
|
2
2
|
interface PhoneVerifiedOptions {
|
|
3
3
|
entityTypes: AuthEntityType[];
|
|
4
4
|
}
|
|
5
|
-
export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("
|
|
6
|
-
info: import("@trpc/server/dist/unstable-core-do-not-import.d-C6mFWtNG.cjs").TRPCRequestInfo;
|
|
5
|
+
export declare function createPhoneVerifiedProcedure(options: PhoneVerifiedOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
7
6
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
8
7
|
tokenType: import("../../auth").TokenType | undefined;
|
|
9
8
|
entity: import("../context").EntityContext | undefined;
|
|
@@ -4,8 +4,7 @@ interface AuthOptions {
|
|
|
4
4
|
allowRefreshToken?: boolean;
|
|
5
5
|
autoRefresh?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("
|
|
8
|
-
info: import("@trpc/server/dist/unstable-core-do-not-import.d-C6mFWtNG.cjs").TRPCRequestInfo;
|
|
7
|
+
export declare function publicUserDecoder(options: AuthOptions): import("@trpc/server").TRPCProcedureBuilder<import("../context").LyxaHTTPContext, object, {
|
|
9
8
|
res: import("http").ServerResponse<import("http").IncomingMessage>;
|
|
10
9
|
tokenType: TokenType | undefined;
|
|
11
10
|
entity: import("../context").EntityContext | undefined;
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyxa.ai/types",
|
|
3
|
-
"version": "1.0.166-
|
|
3
|
+
"version": "1.0.166-test2",
|
|
4
4
|
"description": "Lyxa type definitions and validation schemas for both frontend and backend",
|
|
5
5
|
"author": "elie <42282499+Internalizable@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|