@ya-accelerators/web-backend-framework 0.0.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.
Files changed (42) hide show
  1. package/@types/error.d.ts +4 -0
  2. package/@types/general.d.ts +9 -0
  3. package/dist/app/index.d.ts +2 -0
  4. package/dist/app/index.js +3 -0
  5. package/dist/app/index.js.map +1 -0
  6. package/dist/app/server/index.d.ts +16 -0
  7. package/dist/app/server/index.js +162 -0
  8. package/dist/app/server/index.js.map +1 -0
  9. package/dist/app/trpc/error/index.d.ts +12 -0
  10. package/dist/app/trpc/error/index.js +108 -0
  11. package/dist/app/trpc/error/index.js.map +1 -0
  12. package/dist/app/trpc/header/index.d.ts +2 -0
  13. package/dist/app/trpc/header/index.js +9 -0
  14. package/dist/app/trpc/header/index.js.map +1 -0
  15. package/dist/app/trpc/index.d.ts +4 -0
  16. package/dist/app/trpc/index.js +5 -0
  17. package/dist/app/trpc/index.js.map +1 -0
  18. package/dist/app/trpc/schema/index.d.ts +10 -0
  19. package/dist/app/trpc/schema/index.js +28 -0
  20. package/dist/app/trpc/schema/index.js.map +1 -0
  21. package/dist/app/trpc/server/index.d.ts +149 -0
  22. package/dist/app/trpc/server/index.js +125 -0
  23. package/dist/app/trpc/server/index.js.map +1 -0
  24. package/dist/env.d.ts +16 -0
  25. package/dist/env.js +43 -0
  26. package/dist/env.js.map +1 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.js +7 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/prisma/index.d.ts +37 -0
  31. package/dist/prisma/index.js +204 -0
  32. package/dist/prisma/index.js.map +1 -0
  33. package/dist/redis/index.d.ts +7 -0
  34. package/dist/redis/index.js +55 -0
  35. package/dist/redis/index.js.map +1 -0
  36. package/dist/s3/index.d.ts +4 -0
  37. package/dist/s3/index.js +19 -0
  38. package/dist/s3/index.js.map +1 -0
  39. package/dist/util/index.d.ts +26 -0
  40. package/dist/util/index.js +174 -0
  41. package/dist/util/index.js.map +1 -0
  42. package/package.json +53 -0
@@ -0,0 +1,4 @@
1
+ interface ValidationError {
2
+ target: string
3
+ message: string
4
+ }
@@ -0,0 +1,9 @@
1
+ type JsonPrimitive = string | number | boolean
2
+ type JsonObject = { [key: string]: JsonValue }
3
+ type JsonArray = JsonValue[]
4
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray
5
+
6
+ type EmptyObject = Record<string, never>
7
+ const Empty: EmptyObject = {} as const satisfies EmptyObject
8
+
9
+ type Simplify<T> = { [K in keyof T]: T[K] } & {}
@@ -0,0 +1,2 @@
1
+ export * from './server/index.ts';
2
+ export * from './trpc/index.ts';
@@ -0,0 +1,3 @@
1
+ export * from "./server/index.js";
2
+ export * from "./trpc/index.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import type { ClientRequest, IncomingMessage } from 'node:http';
2
+ import type { NextFunction, Request, Response } from 'express';
3
+ import express from 'express';
4
+ export declare const createApp: (params?: {
5
+ loggingEnabled?: boolean;
6
+ customRoutes?: (app: express.Express) => void;
7
+ middlewares?: ((req: Request, res: Response, next: NextFunction) => void)[];
8
+ proxyTarget?: {
9
+ targets: string[][];
10
+ proxyReq?: (proxyReq: ClientRequest, req: Request, res: Response) => void;
11
+ onEnd?: (proxyRes: IncomingMessage) => void;
12
+ };
13
+ nonForwardableHeaders?: string[];
14
+ }) => void;
15
+ export declare const createRequestIdMiddleware: () => (req: Request, res: Response, next: NextFunction) => void;
16
+ export declare const runWithRequestHeaders: <T>(headers: Record<string, string>, fn: () => Promise<T>) => Promise<T>;
@@ -0,0 +1,162 @@
1
+ import { AsyncLocalStorage } from 'async_hooks';
2
+ import cors from 'cors';
3
+ import express from 'express';
4
+ import { createProxyMiddleware } from 'http-proxy-middleware';
5
+ import { defaultEnv } from "../../env.js";
6
+ import { Util } from "../../util/index.js";
7
+ import { getHeaderValue } from "../trpc/header/index.js";
8
+ let nonForwardableHeaders = new Set();
9
+ export const createApp = (params) => {
10
+ const { loggingEnabled = false, customRoutes, middlewares = [], proxyTarget, nonForwardableHeaders: nonForwardableHeadersParam = [], } = params ?? {};
11
+ nonForwardableHeaders = new Set(nonForwardableHeadersParam);
12
+ const app = express();
13
+ app.use(cors({
14
+ origin: '*',
15
+ optionsSuccessStatus: 204,
16
+ }));
17
+ if (proxyTarget) {
18
+ app.get('/health', async (_, res) => {
19
+ res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
20
+ res.setHeader('Pragma', 'no-cache');
21
+ res.setHeader('Expires', '0');
22
+ const healthChecks = await Promise.all(proxyTarget.targets.map(async ([path, url]) => {
23
+ const serviceName = path.replace(/^\//, '') || 'unknown';
24
+ try {
25
+ const healthUrl = `${url}/health`;
26
+ const response = await fetch(healthUrl, {
27
+ method: 'GET',
28
+ signal: AbortSignal.timeout(5000),
29
+ });
30
+ if (response.ok) {
31
+ const healthData = await response.json();
32
+ return {
33
+ service: serviceName,
34
+ ...healthData,
35
+ };
36
+ }
37
+ else {
38
+ return {
39
+ service: serviceName,
40
+ status: 'NG',
41
+ };
42
+ }
43
+ }
44
+ catch {
45
+ return {
46
+ service: serviceName,
47
+ status: 'NG',
48
+ };
49
+ }
50
+ }));
51
+ res.json(healthChecks.map((x) => x.result.data.json));
52
+ res.end();
53
+ });
54
+ }
55
+ if (customRoutes) {
56
+ customRoutes(app);
57
+ }
58
+ app.use('', createRequestIdMiddleware());
59
+ middlewares.forEach((middleware) => app.use('', middleware));
60
+ proxyTarget?.targets.forEach((x) => {
61
+ const onHandlers = {
62
+ proxyRes: (proxyRes, req) => {
63
+ const body = [];
64
+ proxyRes.on('data', (chunk) => body.push(chunk));
65
+ proxyRes.on('end', () => {
66
+ if (loggingEnabled && (proxyRes.statusCode ?? 500) >= 400) {
67
+ const message = Buffer.concat(body).toString();
68
+ if (!message.includes('UNAUTHORIZED') &&
69
+ !message.includes('NO_UPDATES_FOUND') &&
70
+ !message.includes('.me') &&
71
+ !message.includes('authentication.current')) {
72
+ console.log(`${req.url} : ${defaultEnv.NODE_ENV === 'development' ? JSON.stringify(Util.sanitize(JSON.parse(message)), null, 2) : JSON.stringify(Util.sanitize(JSON.parse(message)))}`);
73
+ }
74
+ }
75
+ proxyTarget.onEnd?.(proxyRes);
76
+ });
77
+ },
78
+ };
79
+ if (proxyTarget.proxyReq) {
80
+ onHandlers.proxyReq = proxyTarget.proxyReq;
81
+ }
82
+ app.use(x[0], createProxyMiddleware({
83
+ target: x[1],
84
+ pathRewrite: {
85
+ [`^${x[1]}`]: '',
86
+ },
87
+ on: onHandlers,
88
+ }));
89
+ });
90
+ app.listen(defaultEnv.PORT, () => console.log(`✨✨✨✨ [${defaultEnv.SERVICE}] Listening on port ${defaultEnv.PORT} on ${defaultEnv.NODE_ENV} ✨✨✨✨`));
91
+ };
92
+ const requestContextStorage = new AsyncLocalStorage();
93
+ const convertHeadersToRecord = (headers) => {
94
+ const result = {};
95
+ for (const [key, value] of Object.entries(headers)) {
96
+ if (value !== undefined) {
97
+ result[key] = Array.isArray(value) ? value[0] : value;
98
+ }
99
+ }
100
+ return result;
101
+ };
102
+ export const createRequestIdMiddleware = () => (req, res, next) => {
103
+ const requestId = getHeaderValue(req.headers, 'x-request-id') ?? Util.createULID();
104
+ req.headers['x-request-id'] = requestId;
105
+ res.setHeader('X-Request-Id', requestId);
106
+ requestContextStorage.run({
107
+ headers: {
108
+ ...convertHeadersToRecord(req.headers),
109
+ 'x-request-id': requestId,
110
+ },
111
+ }, next);
112
+ };
113
+ export const runWithRequestHeaders = (headers, fn) => requestContextStorage.run({
114
+ headers: { ...requestContextStorage.getStore()?.headers, ...headers },
115
+ }, fn);
116
+ const DEFAULT_NON_FORWARDABLE_HEADERS = new Set([
117
+ 'content-length',
118
+ 'host',
119
+ 'connection',
120
+ 'transfer-encoding',
121
+ 'keep-alive',
122
+ 'upgrade',
123
+ 'expect',
124
+ 'te',
125
+ 'proxy-connection',
126
+ 'proxy-authenticate',
127
+ 'proxy-authorization',
128
+ 'trailer',
129
+ ]);
130
+ const patchFetchWithRequestHeaders = () => {
131
+ const FETCH_PATCHED_FLAG = '__yaLibraryFetchPatched__';
132
+ if (typeof globalThis.fetch !== 'function') {
133
+ return;
134
+ }
135
+ const globalObject = globalThis;
136
+ if (globalObject[FETCH_PATCHED_FLAG] === true) {
137
+ return;
138
+ }
139
+ const originalFetch = globalThis.fetch.bind(globalThis);
140
+ globalObject[FETCH_PATCHED_FLAG] = true;
141
+ const patchedFetch = async (input, init) => {
142
+ const store = requestContextStorage.getStore();
143
+ if (!store) {
144
+ return originalFetch(input, init);
145
+ }
146
+ const headers = new Headers(init?.headers ?? {});
147
+ for (const [key, value] of Object.entries(store.headers)) {
148
+ if (!headers.has(key) &&
149
+ !nonForwardableHeaders.has(key) &&
150
+ !DEFAULT_NON_FORWARDABLE_HEADERS.has(key.toLowerCase())) {
151
+ headers.set(key, value);
152
+ }
153
+ }
154
+ return originalFetch(input, {
155
+ ...init,
156
+ headers,
157
+ });
158
+ };
159
+ globalThis.fetch = patchedFetch;
160
+ };
161
+ patchFetchWithRequestHeaders();
162
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app/server/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB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AI,EAAE,OAAO,IAAI,EAAE,CAAC,CAAA;QAChD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACzD,IACE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;gBACjB,CAAC,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC;gBAC/B,CAAC,+BAA+B,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EACvD,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;QACD,OAAO,aAAa,CAAC,KAAK,EAAE;YAC1B,GAAG,IAAI;YACP,OAAO;SACR,CAAC,CAAA;IACJ,CAAC,CAAA;IACD,UAAU,CAAC,KAAK,GAAG,YAAY,CAAA;AACjC,CAAC,CAAA;AACD,4BAA4B,EAAE,CAAA"}
@@ -0,0 +1,12 @@
1
+ export declare const throwUnauthorizedError: (message?: string, input?: unknown) => never;
2
+ export declare const throwInternalServerError: (source?: Error, input?: unknown) => never;
3
+ export declare const throwBadRequestError: (message: string, input?: unknown) => never;
4
+ export declare const throwValidationError: (errors: ValidationError[]) => never;
5
+ export declare const throwPaymentRequiredError: (message: string, input?: unknown) => never;
6
+ export declare const throwForbiddenError: (message: string, input?: unknown) => never;
7
+ export declare const throwNotFoundError: (message: string, input?: unknown) => never;
8
+ export declare const throwPreconditionFailedError: (message: string, input?: unknown) => never;
9
+ export declare const throwPreconditionRequiredError: (message: string, input?: unknown) => never;
10
+ export declare const throwUnsupportedMediaTypeError: (message: string, input?: unknown) => never;
11
+ export declare const throwUnprocessableContentError: (message: string, input?: unknown) => never;
12
+ export declare const throwTooManyRequestsError: (message: string, input?: unknown) => never;
@@ -0,0 +1,108 @@
1
+ import { TRPCError } from '@trpc/server';
2
+ export const throwUnauthorizedError = (message, input) => {
3
+ throw new TRPCError({
4
+ code: 'UNAUTHORIZED',
5
+ message: message ?? 'Unauthorized',
6
+ cause: {
7
+ input,
8
+ },
9
+ });
10
+ };
11
+ export const throwInternalServerError = (source, input) => {
12
+ throw new TRPCError({
13
+ code: 'INTERNAL_SERVER_ERROR',
14
+ message: source?.message ?? 'Internal server error',
15
+ cause: {
16
+ input,
17
+ source,
18
+ },
19
+ });
20
+ };
21
+ export const throwBadRequestError = (message, input) => {
22
+ throw new TRPCError({
23
+ code: 'BAD_REQUEST',
24
+ message,
25
+ cause: {
26
+ input,
27
+ },
28
+ });
29
+ };
30
+ export const throwValidationError = (errors) => {
31
+ throw new TRPCError({
32
+ code: 'BAD_REQUEST',
33
+ message: JSON.stringify(errors),
34
+ });
35
+ };
36
+ export const throwPaymentRequiredError = (message, input) => {
37
+ throw new TRPCError({
38
+ code: 'PAYMENT_REQUIRED',
39
+ message,
40
+ cause: {
41
+ input,
42
+ },
43
+ });
44
+ };
45
+ export const throwForbiddenError = (message, input) => {
46
+ throw new TRPCError({
47
+ code: 'FORBIDDEN',
48
+ message,
49
+ cause: {
50
+ input,
51
+ },
52
+ });
53
+ };
54
+ export const throwNotFoundError = (message, input) => {
55
+ throw new TRPCError({
56
+ code: 'NOT_FOUND',
57
+ message,
58
+ cause: {
59
+ input,
60
+ },
61
+ });
62
+ };
63
+ export const throwPreconditionFailedError = (message, input) => {
64
+ throw new TRPCError({
65
+ code: 'PRECONDITION_FAILED',
66
+ message,
67
+ cause: {
68
+ input,
69
+ },
70
+ });
71
+ };
72
+ export const throwPreconditionRequiredError = (message, input) => {
73
+ throw new TRPCError({
74
+ code: 'PRECONDITION_REQUIRED',
75
+ message,
76
+ cause: {
77
+ input,
78
+ },
79
+ });
80
+ };
81
+ export const throwUnsupportedMediaTypeError = (message, input) => {
82
+ throw new TRPCError({
83
+ code: 'UNSUPPORTED_MEDIA_TYPE',
84
+ message,
85
+ cause: {
86
+ input,
87
+ },
88
+ });
89
+ };
90
+ export const throwUnprocessableContentError = (message, input) => {
91
+ throw new TRPCError({
92
+ code: 'UNPROCESSABLE_CONTENT',
93
+ message,
94
+ cause: {
95
+ input,
96
+ },
97
+ });
98
+ };
99
+ export const throwTooManyRequestsError = (message, input) => {
100
+ throw new TRPCError({
101
+ code: 'TOO_MANY_REQUESTS',
102
+ message,
103
+ cause: {
104
+ input,
105
+ },
106
+ });
107
+ };
108
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app/trpc/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAAgB,EAAE,KAAe,EAAE,EAAE;IAC1E,MAAM,IAAI,SAAS,CAAC;QAClB,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,OAAO,IAAI,cAAc;QAClC,KAAK,EAAE;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAE,KAAe,EAAE,EAAE;IAC1E,MAAM,IAAI,SAAS,CAAC;QAClB,IAAI,EAAE,uBAAuB;QAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,IAAI,uBAAuB;QACnD,KAAK,EAAE;YACL,KAAK;YACL,MAAM;SACP;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE;IACvE,MAAM,IAAI,SAAS,CAAC;QAClB,IAAI,EAAE,aAAa;QACnB,OAAO;QACP,KAAK,EAAE;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAyB,EAAE,EAAE;IAChE,MAAM,IAAI,SAAS,CAAC;QAClB,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,IA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EAAE,wBAAwB;QAC9B,OAAO;QACP,KAAK,EAAE;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE;IACjF,MAAM,IAAI,SAAS,CAAC;QAClB,IAAI,EAAE,uBAAuB;QAC7B,OAAO;QACP,KAAK,EAAE;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAe,EAAE,KAAe,EAAE,EAAE;IAC5E,MAAM,IAAI,SAAS,CAAC;QAClB,IAAI,EAAE,mBAAmB;QACzB,OAAO;QACP,KAAK,EAAE;YACL,KAAK;SACN;KACF,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { type IncomingHttpHeaders } from 'http';
2
+ export declare const getHeaderValue: (headers: IncomingHttpHeaders | Record<string, string | string[] | undefined>, name: string) => string | undefined;
@@ -0,0 +1,9 @@
1
+ export const getHeaderValue = (headers, name) => {
2
+ const key = name.toLowerCase();
3
+ const value = headers[name] ?? headers[key];
4
+ if (Array.isArray(value)) {
5
+ return value[0].length > 0 ? value[0] : undefined;
6
+ }
7
+ return typeof value === 'string' && value.length > 0 ? value : undefined;
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app/trpc/header/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,OAA4E,EAC5E,IAAY,EACQ,EAAE;IACtB,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAA;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACnD,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC1E,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './error/index.ts';
2
+ export * from './header/index.ts';
3
+ export * from './schema/index.ts';
4
+ export * from './server/index.ts';
@@ -0,0 +1,5 @@
1
+ export * from "./error/index.js";
2
+ export * from "./header/index.js";
3
+ export * from "./schema/index.js";
4
+ export * from "./server/index.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/app/trpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export declare const JsonValueSchema: z.ZodType<JsonValue, JsonValue>;
3
+ export declare const EmailSchema: z.ZodString;
4
+ export declare const PasswordCharactersSchema: z.ZodString;
5
+ export declare const PasswordSchema: z.ZodString;
6
+ export declare const PhoneE164Schema: z.ZodString;
7
+ export declare const JapanesePhoneNumberSchema: z.ZodString;
8
+ export declare const JapaneseCorporateIdSchema: z.ZodString;
9
+ export declare const JapaneseInvoiceNumberSchema: z.ZodString;
10
+ export declare const JapaneseZipCodeSchema: z.ZodString;
@@ -0,0 +1,28 @@
1
+ import { z } from 'zod';
2
+ import { Util } from "../../../util/index.js";
3
+ export const JsonValueSchema = z.lazy(() => z.union([z.string(), z.number(), z.boolean(), z.array(JsonValueSchema), z.record(z.string(), JsonValueSchema)]));
4
+ export const EmailSchema = z
5
+ .string()
6
+ .refine((val) => Util.isValidEmail(val), { message: 'Invalid email address format.' });
7
+ export const PasswordCharactersSchema = z
8
+ .string()
9
+ .refine((val) => Util.isValidPasswordCharacters(val), { message: 'Invalid password characters.' });
10
+ export const PasswordSchema = z
11
+ .string()
12
+ .refine((val) => Util.isValidPassword(val), { message: 'Invalid password format.' });
13
+ export const PhoneE164Schema = z
14
+ .string()
15
+ .refine((val) => Util.isValidPhoneE164(val), { message: 'Invalid phone number format.' });
16
+ export const JapanesePhoneNumberSchema = z
17
+ .string()
18
+ .refine((val) => Util.isValidJapanesePhoneNumber(val), { message: 'Invalid Japanese phone number format.' });
19
+ export const JapaneseCorporateIdSchema = z
20
+ .string()
21
+ .refine((val) => Util.isValidJapaneseCorporateId(val), { message: 'Invalid Japanese corporate ID format.' });
22
+ export const JapaneseInvoiceNumberSchema = z
23
+ .string()
24
+ .refine((val) => Util.isValidInvoiceNumber(val), { message: 'Invalid invoice number format.' });
25
+ export const JapaneseZipCodeSchema = z
26
+ .string()
27
+ .refine((val) => Util.isValidJapaneseZipCode(val), { message: 'Invalid Japanese zip code format.' });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app/trpc/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAoC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC1E,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,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A2B,GAAG,CAAC;KACzC,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC,CAAA;AAEjG,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,mCAAmC,EAAE,CAAC,CAAA"}
@@ -0,0 +1,149 @@
1
+ import { type AnyTRPCRouter } from '@trpc/server';
2
+ import type express from 'express';
3
+ import superjson from 'superjson';
4
+ export declare function httpServerGenerator<TContext extends object = EmptyObject>(options?: {
5
+ loggingEnabled?: boolean;
6
+ customRoutes?: (app: express.Express) => void;
7
+ }): Generator<import("@trpc/server").TRPCRootObject<{
8
+ requestHeaders: import("node:http").IncomingHttpHeaders;
9
+ ip: string | undefined;
10
+ } & TContext extends infer T ? T extends {
11
+ requestHeaders: import("node:http").IncomingHttpHeaders;
12
+ ip: string | undefined;
13
+ } & TContext ? T extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T> : T : never : never, object, {
14
+ transformer: typeof superjson;
15
+ errorFormatter({ error, type, path, input, shape, ctx }: {
16
+ error: import("@trpc/server").TRPCError;
17
+ type: import("@trpc/server").ProcedureType | "unknown";
18
+ path: string | undefined;
19
+ input: unknown;
20
+ ctx: ({
21
+ requestHeaders: import("node:http").IncomingHttpHeaders;
22
+ ip: string | undefined;
23
+ } & TContext extends infer T_1 ? T_1 extends {
24
+ requestHeaders: import("node:http").IncomingHttpHeaders;
25
+ ip: string | undefined;
26
+ } & TContext ? T_1 extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T_1> : T_1 : never : never) | undefined;
27
+ shape: import("@trpc/server").TRPCDefaultErrorShape;
28
+ }): {
29
+ data: {
30
+ source?: {
31
+ name: string;
32
+ message: string;
33
+ stack: string | undefined;
34
+ } | undefined;
35
+ name: string;
36
+ type: "unknown" | "query" | "mutation" | "subscription";
37
+ path: string | undefined;
38
+ headers: import("node:http").IncomingHttpHeaders | undefined;
39
+ input: unknown;
40
+ code: "UNAUTHORIZED" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
41
+ message: string;
42
+ };
43
+ message: string;
44
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
45
+ };
46
+ }, {
47
+ ctx: {
48
+ requestHeaders: import("node:http").IncomingHttpHeaders;
49
+ ip: string | undefined;
50
+ } & TContext extends infer T_1 ? T_1 extends {
51
+ requestHeaders: import("node:http").IncomingHttpHeaders;
52
+ ip: string | undefined;
53
+ } & TContext ? T_1 extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T_1> : T_1 : never : never;
54
+ meta: object;
55
+ errorShape: {
56
+ data: {
57
+ source?: {
58
+ name: string;
59
+ message: string;
60
+ stack: string | undefined;
61
+ } | undefined;
62
+ name: string;
63
+ type: "unknown" | "query" | "mutation" | "subscription";
64
+ path: string | undefined;
65
+ headers: import("node:http").IncomingHttpHeaders | undefined;
66
+ input: unknown;
67
+ code: "UNAUTHORIZED" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
68
+ message: string;
69
+ };
70
+ message: string;
71
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
72
+ };
73
+ transformer: true;
74
+ }> & {
75
+ procedure: import("@trpc/server").TRPCProcedureBuilder<{
76
+ requestHeaders: import("node:http").IncomingHttpHeaders;
77
+ ip: string | undefined;
78
+ } & TContext extends infer T_2 ? T_2 extends {
79
+ requestHeaders: import("node:http").IncomingHttpHeaders;
80
+ ip: string | undefined;
81
+ } & TContext ? T_2 extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T_2> : T_2 : never : never, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
82
+ }, import("@trpc/server").TRPCRootObject<{
83
+ requestHeaders: import("node:http").IncomingHttpHeaders;
84
+ ip: string | undefined;
85
+ } & TContext extends infer T_3 ? T_3 extends {
86
+ requestHeaders: import("node:http").IncomingHttpHeaders;
87
+ ip: string | undefined;
88
+ } & TContext ? T_3 extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T_3> : T_3 : never : never, object, {
89
+ transformer: typeof superjson;
90
+ errorFormatter({ error, type, path, input, shape, ctx }: {
91
+ error: import("@trpc/server").TRPCError;
92
+ type: import("@trpc/server").ProcedureType | "unknown";
93
+ path: string | undefined;
94
+ input: unknown;
95
+ ctx: ({
96
+ requestHeaders: import("node:http").IncomingHttpHeaders;
97
+ ip: string | undefined;
98
+ } & TContext extends infer T_4 ? T_4 extends {
99
+ requestHeaders: import("node:http").IncomingHttpHeaders;
100
+ ip: string | undefined;
101
+ } & TContext ? T_4 extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T_4> : T_4 : never : never) | undefined;
102
+ shape: import("@trpc/server").TRPCDefaultErrorShape;
103
+ }): {
104
+ data: {
105
+ source?: {
106
+ name: string;
107
+ message: string;
108
+ stack: string | undefined;
109
+ } | undefined;
110
+ name: string;
111
+ type: "unknown" | "query" | "mutation" | "subscription";
112
+ path: string | undefined;
113
+ headers: import("node:http").IncomingHttpHeaders | undefined;
114
+ input: unknown;
115
+ code: "UNAUTHORIZED" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
116
+ message: string;
117
+ };
118
+ message: string;
119
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
120
+ };
121
+ }, {
122
+ ctx: {
123
+ requestHeaders: import("node:http").IncomingHttpHeaders;
124
+ ip: string | undefined;
125
+ } & TContext extends infer T_4 ? T_4 extends {
126
+ requestHeaders: import("node:http").IncomingHttpHeaders;
127
+ ip: string | undefined;
128
+ } & TContext ? T_4 extends (...args: any[]) => object | Promise<object> ? import("@trpc/server/unstable-core-do-not-import").Unwrap<T_4> : T_4 : never : never;
129
+ meta: object;
130
+ errorShape: {
131
+ data: {
132
+ source?: {
133
+ name: string;
134
+ message: string;
135
+ stack: string | undefined;
136
+ } | undefined;
137
+ name: string;
138
+ type: "unknown" | "query" | "mutation" | "subscription";
139
+ path: string | undefined;
140
+ headers: import("node:http").IncomingHttpHeaders | undefined;
141
+ input: unknown;
142
+ code: "UNAUTHORIZED" | "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "UNPROCESSABLE_CONTENT" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
143
+ message: string;
144
+ };
145
+ message: string;
146
+ code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
147
+ };
148
+ transformer: true;
149
+ }>, AnyTRPCRouter>;